aboutsummaryrefslogtreecommitdiff
path: root/Emby.Server.Implementations/HttpServer
diff options
context:
space:
mode:
Diffstat (limited to 'Emby.Server.Implementations/HttpServer')
-rw-r--r--Emby.Server.Implementations/HttpServer/FileWriter.cs6
-rw-r--r--Emby.Server.Implementations/HttpServer/HttpListenerHost.cs26
-rw-r--r--Emby.Server.Implementations/HttpServer/HttpResultFactory.cs28
-rw-r--r--Emby.Server.Implementations/HttpServer/IHttpListener.cs4
-rw-r--r--Emby.Server.Implementations/HttpServer/LoggerUtils.cs2
-rw-r--r--Emby.Server.Implementations/HttpServer/RangeRequestWriter.cs2
-rw-r--r--Emby.Server.Implementations/HttpServer/ResponseFilter.cs5
-rw-r--r--Emby.Server.Implementations/HttpServer/Security/AuthService.cs11
-rw-r--r--Emby.Server.Implementations/HttpServer/Security/AuthorizationContext.cs11
-rw-r--r--Emby.Server.Implementations/HttpServer/Security/SessionContext.cs8
-rw-r--r--Emby.Server.Implementations/HttpServer/StreamWriter.cs3
-rw-r--r--Emby.Server.Implementations/HttpServer/WebSocketConnection.cs18
12 files changed, 52 insertions, 72 deletions
diff --git a/Emby.Server.Implementations/HttpServer/FileWriter.cs b/Emby.Server.Implementations/HttpServer/FileWriter.cs
index 568432902..c32c91670 100644
--- a/Emby.Server.Implementations/HttpServer/FileWriter.cs
+++ b/Emby.Server.Implementations/HttpServer/FileWriter.cs
@@ -1,13 +1,13 @@
-using System;
+using System;
using System.Collections.Generic;
using System.Globalization;
+using System.Linq;
using System.Net;
using System.Threading;
using System.Threading.Tasks;
using MediaBrowser.Model.IO;
-using Microsoft.Extensions.Logging;
using MediaBrowser.Model.Services;
-using System.Linq;
+using Microsoft.Extensions.Logging;
namespace Emby.Server.Implementations.HttpServer
{
diff --git a/Emby.Server.Implementations/HttpServer/HttpListenerHost.cs b/Emby.Server.Implementations/HttpServer/HttpListenerHost.cs
index d51563d51..6ae56c2ad 100644
--- a/Emby.Server.Implementations/HttpServer/HttpListenerHost.cs
+++ b/Emby.Server.Implementations/HttpServer/HttpListenerHost.cs
@@ -1,27 +1,27 @@
-using MediaBrowser.Common.Extensions;
-using MediaBrowser.Controller.Configuration;
-using MediaBrowser.Controller.Net;
-using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
+using System.Net.Sockets;
using System.Reflection;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
+using Emby.Server.Implementations.Net;
using Emby.Server.Implementations.Services;
+using MediaBrowser.Common.Extensions;
using MediaBrowser.Common.Net;
using MediaBrowser.Common.Security;
using MediaBrowser.Controller;
+using MediaBrowser.Controller.Configuration;
+using MediaBrowser.Controller.Net;
+using MediaBrowser.Model.Events;
using MediaBrowser.Model.Extensions;
using MediaBrowser.Model.Serialization;
using MediaBrowser.Model.Services;
using MediaBrowser.Model.Text;
-using System.Net.Sockets;
-using Emby.Server.Implementations.Net;
-using MediaBrowser.Model.Events;
+using Microsoft.Extensions.Logging;
namespace Emby.Server.Implementations.HttpServer
{
@@ -124,8 +124,7 @@ namespace Emby.Server.Implementations.HttpServer
public Type GetServiceTypeByRequest(Type requestType)
{
- Type serviceType;
- ServiceOperationsMap.TryGetValue(requestType, out serviceType);
+ ServiceOperationsMap.TryGetValue(requestType, out var serviceType);
return serviceType;
}
@@ -215,8 +214,7 @@ namespace Emby.Server.Implementations.HttpServer
var exceptionType = ex.GetType();
- int statusCode;
- if (!_mapExceptionToStatusCode.TryGetValue(exceptionType, out statusCode))
+ if (!_mapExceptionToStatusCode.TryGetValue(exceptionType, out var statusCode))
{
if (ex is DirectoryNotFoundException)
{
@@ -704,8 +702,7 @@ namespace Emby.Server.Implementations.HttpServer
return null;
}
- string contentType;
- var restPath = ServiceHandler.FindMatchingRestPath(httpReq.HttpMethod, pathInfo, out contentType);
+ var restPath = ServiceHandler.FindMatchingRestPath(httpReq.HttpMethod, pathInfo, out var contentType);
if (restPath != null)
{
@@ -731,8 +728,7 @@ namespace Emby.Server.Implementations.HttpServer
private void RedirectToSecureUrl(IHttpRequest httpReq, IResponse httpRes, string url)
{
int currentPort;
- Uri uri;
- if (Uri.TryCreate(url, UriKind.Absolute, out uri))
+ if (Uri.TryCreate(url, UriKind.Absolute, out var uri))
{
currentPort = uri.Port;
var builder = new UriBuilder(uri);
diff --git a/Emby.Server.Implementations/HttpServer/HttpResultFactory.cs b/Emby.Server.Implementations/HttpServer/HttpResultFactory.cs
index e6dbcf65d..3cfa2bc75 100644
--- a/Emby.Server.Implementations/HttpServer/HttpResultFactory.cs
+++ b/Emby.Server.Implementations/HttpServer/HttpResultFactory.cs
@@ -1,7 +1,3 @@
-using MediaBrowser.Common.Extensions;
-using MediaBrowser.Controller.Net;
-using Microsoft.Extensions.Logging;
-using MediaBrowser.Model.Serialization;
using System;
using System.Collections.Generic;
using System.Globalization;
@@ -13,8 +9,12 @@ using System.Text;
using System.Threading.Tasks;
using System.Xml;
using Emby.Server.Implementations.Services;
+using MediaBrowser.Common.Extensions;
+using MediaBrowser.Controller.Net;
using MediaBrowser.Model.IO;
+using MediaBrowser.Model.Serialization;
using MediaBrowser.Model.Services;
+using Microsoft.Extensions.Logging;
using IRequest = MediaBrowser.Model.Services.IRequest;
using MimeTypes = MediaBrowser.Model.Net.MimeTypes;
@@ -96,8 +96,7 @@ namespace Emby.Server.Implementations.HttpServer
responseHeaders = new Dictionary<string, string>();
}
- string expires;
- if (addCachePrevention && !responseHeaders.TryGetValue("Expires", out expires))
+ if (addCachePrevention && !responseHeaders.TryGetValue("Expires", out var expires))
{
responseHeaders["Expires"] = "-1";
}
@@ -115,7 +114,8 @@ namespace Emby.Server.Implementations.HttpServer
string compressionType = null;
bool isHeadRequest = false;
- if (requestContext != null) {
+ if (requestContext != null)
+ {
compressionType = GetCompressionType(requestContext, content, contentType);
isHeadRequest = string.Equals(requestContext.Verb, "head", StringComparison.OrdinalIgnoreCase);
}
@@ -142,8 +142,7 @@ namespace Emby.Server.Implementations.HttpServer
responseHeaders = new Dictionary<string, string>();
}
- string expires;
- if (addCachePrevention && !responseHeaders.TryGetValue("Expires", out expires))
+ if (addCachePrevention && !responseHeaders.TryGetValue("Expires", out var expires))
{
responseHeaders["Expires"] = "-1";
}
@@ -187,8 +186,7 @@ namespace Emby.Server.Implementations.HttpServer
responseHeaders = new Dictionary<string, string>();
}
- string expires;
- if (addCachePrevention && !responseHeaders.TryGetValue("Expires", out expires))
+ if (addCachePrevention && !responseHeaders.TryGetValue("Expires", out var expires))
{
responseHeaders["Expires"] = "-1";
}
@@ -701,9 +699,7 @@ namespace Emby.Server.Implementations.HttpServer
if (!string.IsNullOrEmpty(ifModifiedSinceHeader))
{
- DateTime ifModifiedSince;
-
- if (DateTime.TryParse(ifModifiedSinceHeader, out ifModifiedSince))
+ if (DateTime.TryParse(ifModifiedSinceHeader, out var ifModifiedSince))
{
if (IsNotModified(ifModifiedSince.ToUniversalTime(), cacheDuration, lastDateModified))
{
@@ -719,11 +715,9 @@ namespace Emby.Server.Implementations.HttpServer
// Validate If-None-Match
if ((hasCacheKey || !string.IsNullOrEmpty(ifNoneMatchHeader)))
{
- Guid ifNoneMatch;
-
ifNoneMatchHeader = (ifNoneMatchHeader ?? string.Empty).Trim('\"');
- if (Guid.TryParse(ifNoneMatchHeader, out ifNoneMatch))
+ if (Guid.TryParse(ifNoneMatchHeader, out var ifNoneMatch))
{
if (hasCacheKey && cacheKey.Equals(ifNoneMatch))
{
diff --git a/Emby.Server.Implementations/HttpServer/IHttpListener.cs b/Emby.Server.Implementations/HttpServer/IHttpListener.cs
index d50d7df6b..835091361 100644
--- a/Emby.Server.Implementations/HttpServer/IHttpListener.cs
+++ b/Emby.Server.Implementations/HttpServer/IHttpListener.cs
@@ -1,10 +1,10 @@
-using MediaBrowser.Controller.Net;
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
-using MediaBrowser.Model.Services;
using Emby.Server.Implementations.Net;
+using MediaBrowser.Controller.Net;
+using MediaBrowser.Model.Services;
namespace Emby.Server.Implementations.HttpServer
{
diff --git a/Emby.Server.Implementations/HttpServer/LoggerUtils.cs b/Emby.Server.Implementations/HttpServer/LoggerUtils.cs
index 5b7bbe79c..d22d9db26 100644
--- a/Emby.Server.Implementations/HttpServer/LoggerUtils.cs
+++ b/Emby.Server.Implementations/HttpServer/LoggerUtils.cs
@@ -1,7 +1,7 @@
-using Microsoft.Extensions.Logging;
using System;
using System.Globalization;
using MediaBrowser.Model.Services;
+using Microsoft.Extensions.Logging;
namespace Emby.Server.Implementations.HttpServer
{
diff --git a/Emby.Server.Implementations/HttpServer/RangeRequestWriter.cs b/Emby.Server.Implementations/HttpServer/RangeRequestWriter.cs
index f08112f9c..bb52cd705 100644
--- a/Emby.Server.Implementations/HttpServer/RangeRequestWriter.cs
+++ b/Emby.Server.Implementations/HttpServer/RangeRequestWriter.cs
@@ -1,4 +1,3 @@
-using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Globalization;
@@ -7,6 +6,7 @@ using System.Net;
using System.Threading;
using System.Threading.Tasks;
using MediaBrowser.Model.Services;
+using Microsoft.Extensions.Logging;
namespace Emby.Server.Implementations.HttpServer
{
diff --git a/Emby.Server.Implementations/HttpServer/ResponseFilter.cs b/Emby.Server.Implementations/HttpServer/ResponseFilter.cs
index f38aa5ea0..ed8644e33 100644
--- a/Emby.Server.Implementations/HttpServer/ResponseFilter.cs
+++ b/Emby.Server.Implementations/HttpServer/ResponseFilter.cs
@@ -1,8 +1,8 @@
-using Microsoft.Extensions.Logging;
using System;
using System.Globalization;
using System.Text;
using MediaBrowser.Model.Services;
+using Microsoft.Extensions.Logging;
namespace Emby.Server.Implementations.HttpServer
{
@@ -56,9 +56,8 @@ namespace Emby.Server.Implementations.HttpServer
}
// Content length has to be explicitly set on on HttpListenerResponse or it won't be happy
- string contentLength;
- if (hasHeaders.Headers.TryGetValue("Content-Length", out contentLength) && !string.IsNullOrEmpty(contentLength))
+ if (hasHeaders.Headers.TryGetValue("Content-Length", out var contentLength) && !string.IsNullOrEmpty(contentLength))
{
var length = long.Parse(contentLength, UsCulture);
diff --git a/Emby.Server.Implementations/HttpServer/Security/AuthService.cs b/Emby.Server.Implementations/HttpServer/Security/AuthService.cs
index fb5bfa601..499a334fc 100644
--- a/Emby.Server.Implementations/HttpServer/Security/AuthService.cs
+++ b/Emby.Server.Implementations/HttpServer/Security/AuthService.cs
@@ -1,15 +1,13 @@
+using System;
+using System.Linq;
+using MediaBrowser.Common.Net;
using MediaBrowser.Controller.Configuration;
-using MediaBrowser.Controller.Connect;
-using MediaBrowser.Controller.Devices;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Net;
using MediaBrowser.Controller.Security;
using MediaBrowser.Controller.Session;
-using System;
-using System.Linq;
using MediaBrowser.Model.Services;
-using MediaBrowser.Common.Net;
namespace Emby.Server.Implementations.HttpServer.Security
{
@@ -209,8 +207,7 @@ namespace Emby.Server.Implementations.HttpServer.Security
private static AuthenticationInfo GetTokenInfo(IRequest request)
{
- object info;
- request.Items.TryGetValue("OriginalAuthenticationInfo", out info);
+ request.Items.TryGetValue("OriginalAuthenticationInfo", out var info);
return info as AuthenticationInfo;
}
diff --git a/Emby.Server.Implementations/HttpServer/Security/AuthorizationContext.cs b/Emby.Server.Implementations/HttpServer/Security/AuthorizationContext.cs
index f561c3d60..cab41e65b 100644
--- a/Emby.Server.Implementations/HttpServer/Security/AuthorizationContext.cs
+++ b/Emby.Server.Implementations/HttpServer/Security/AuthorizationContext.cs
@@ -1,12 +1,10 @@
-using MediaBrowser.Controller.Connect;
-using MediaBrowser.Controller.Net;
-using MediaBrowser.Controller.Security;
using System;
using System.Collections.Generic;
-using MediaBrowser.Model.Services;
using System.Linq;
-using System.Threading;
using MediaBrowser.Controller.Library;
+using MediaBrowser.Controller.Net;
+using MediaBrowser.Controller.Security;
+using MediaBrowser.Model.Services;
namespace Emby.Server.Implementations.HttpServer.Security
{
@@ -28,8 +26,7 @@ namespace Emby.Server.Implementations.HttpServer.Security
public AuthorizationInfo GetAuthorizationInfo(IRequest requestContext)
{
- object cached;
- if (requestContext.Items.TryGetValue("AuthorizationInfo", out cached))
+ if (requestContext.Items.TryGetValue("AuthorizationInfo", out var cached))
{
return (AuthorizationInfo)cached;
}
diff --git a/Emby.Server.Implementations/HttpServer/Security/SessionContext.cs b/Emby.Server.Implementations/HttpServer/Security/SessionContext.cs
index a919ce008..81e11d312 100644
--- a/Emby.Server.Implementations/HttpServer/Security/SessionContext.cs
+++ b/Emby.Server.Implementations/HttpServer/Security/SessionContext.cs
@@ -1,11 +1,10 @@
-using MediaBrowser.Controller.Entities;
+using System;
+using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Net;
using MediaBrowser.Controller.Security;
using MediaBrowser.Controller.Session;
-using System.Threading.Tasks;
using MediaBrowser.Model.Services;
-using System;
namespace Emby.Server.Implementations.HttpServer.Security
{
@@ -32,8 +31,7 @@ namespace Emby.Server.Implementations.HttpServer.Security
private AuthenticationInfo GetTokenInfo(IRequest request)
{
- object info;
- request.Items.TryGetValue("OriginalAuthenticationInfo", out info);
+ request.Items.TryGetValue("OriginalAuthenticationInfo", out var info);
return info as AuthenticationInfo;
}
diff --git a/Emby.Server.Implementations/HttpServer/StreamWriter.cs b/Emby.Server.Implementations/HttpServer/StreamWriter.cs
index df0d74685..3269d44cf 100644
--- a/Emby.Server.Implementations/HttpServer/StreamWriter.cs
+++ b/Emby.Server.Implementations/HttpServer/StreamWriter.cs
@@ -1,12 +1,11 @@
-using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
-
using MediaBrowser.Model.Services;
+using Microsoft.Extensions.Logging;
namespace Emby.Server.Implementations.HttpServer
{
diff --git a/Emby.Server.Implementations/HttpServer/WebSocketConnection.cs b/Emby.Server.Implementations/HttpServer/WebSocketConnection.cs
index 5426114f6..b9146d007 100644
--- a/Emby.Server.Implementations/HttpServer/WebSocketConnection.cs
+++ b/Emby.Server.Implementations/HttpServer/WebSocketConnection.cs
@@ -1,15 +1,15 @@
-using System.Text;
-using MediaBrowser.Controller.Net;
-using Microsoft.Extensions.Logging;
-using MediaBrowser.Model.Net;
-using MediaBrowser.Model.Serialization;
using System;
+using System.Net.WebSockets;
+using System.Text;
using System.Threading;
using System.Threading.Tasks;
+using Emby.Server.Implementations.Net;
+using MediaBrowser.Controller.Net;
+using MediaBrowser.Model.Net;
+using MediaBrowser.Model.Serialization;
using MediaBrowser.Model.Services;
using MediaBrowser.Model.Text;
-using System.Net.WebSockets;
-using Emby.Server.Implementations.Net;
+using Microsoft.Extensions.Logging;
namespace Emby.Server.Implementations.HttpServer
{
@@ -77,7 +77,7 @@ namespace Emby.Server.Implementations.HttpServer
/// <param name="remoteEndPoint">The remote end point.</param>
/// <param name="jsonSerializer">The json serializer.</param>
/// <param name="logger">The logger.</param>
- /// <exception cref="System.ArgumentNullException">socket</exception>
+ /// <exception cref="ArgumentNullException">socket</exception>
public WebSocketConnection(IWebSocket socket, string remoteEndPoint, IJsonSerializer jsonSerializer, ILogger logger, ITextEncoding textEncoding)
{
if (socket == null)
@@ -215,7 +215,7 @@ namespace Emby.Server.Implementations.HttpServer
/// <param name="message">The message.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>Task.</returns>
- /// <exception cref="System.ArgumentNullException">message</exception>
+ /// <exception cref="ArgumentNullException">message</exception>
public Task SendAsync<T>(WebSocketMessage<T> message, CancellationToken cancellationToken)
{
if (message == null)