diff options
Diffstat (limited to 'SocketHttpListener/Net/HttpEndPointListener.cs')
| -rw-r--r-- | SocketHttpListener/Net/HttpEndPointListener.cs | 31 |
1 files changed, 9 insertions, 22 deletions
diff --git a/SocketHttpListener/Net/HttpEndPointListener.cs b/SocketHttpListener/Net/HttpEndPointListener.cs index a108e7dd4..ea7d8fd2d 100644 --- a/SocketHttpListener/Net/HttpEndPointListener.cs +++ b/SocketHttpListener/Net/HttpEndPointListener.cs @@ -1,21 +1,15 @@ using System; -using System.Collections; using System.Collections.Generic; -using System.IO; using System.Net; using System.Net.Sockets; using System.Security.Cryptography.X509Certificates; using System.Threading; using MediaBrowser.Model.Cryptography; using MediaBrowser.Model.IO; -using Microsoft.Extensions.Logging; using MediaBrowser.Model.Net; using MediaBrowser.Model.System; using MediaBrowser.Model.Text; -using SocketHttpListener.Primitives; -using ProtocolType = MediaBrowser.Model.Net.ProtocolType; -using SocketType = MediaBrowser.Model.Net.SocketType; -using System.Threading.Tasks; +using Microsoft.Extensions.Logging; namespace SocketHttpListener.Net { @@ -64,13 +58,7 @@ namespace SocketHttpListener.Net CreateSocket(); } - internal HttpListener Listener - { - get - { - return _listener; - } - } + internal HttpListener Listener => _listener; private void CreateSocket() { @@ -172,7 +160,7 @@ namespace SocketHttpListener.Net } catch (Exception ex) { - HttpEndPointListener epl = (HttpEndPointListener)acceptEventArg.UserToken; + var epl = (HttpEndPointListener)acceptEventArg.UserToken; epl._logger.LogError(ex, "Error in socket.AcceptAsync"); } @@ -188,7 +176,7 @@ namespace SocketHttpListener.Net private static async void ProcessAccept(SocketAsyncEventArgs args) { - HttpEndPointListener epl = (HttpEndPointListener)args.UserToken; + var epl = (HttpEndPointListener)args.UserToken; if (epl._closed) { @@ -209,7 +197,7 @@ namespace SocketHttpListener.Net return; } - if(accepted == null) + if (accepted == null) { return; } @@ -226,7 +214,7 @@ namespace SocketHttpListener.Net var localEndPointString = accepted.LocalEndPoint == null ? string.Empty : accepted.LocalEndPoint.ToString(); //_logger.LogInformation("HttpEndPointListener Accepting connection from {0} to {1} secure connection requested: {2}", remoteEndPointString, localEndPointString, _secure); - HttpConnection conn = new HttpConnection(epl._logger, accepted, epl, epl._secure, epl._cert, epl._cryptoProvider, epl._streamHelper, epl._textEncoding, epl._fileSystem, epl._environment); + var conn = new HttpConnection(epl._logger, accepted, epl, epl._secure, epl._cert, epl._cryptoProvider, epl._streamHelper, epl._textEncoding, epl._fileSystem, epl._environment); await conn.Init().ConfigureAwait(false); @@ -288,9 +276,8 @@ namespace SocketHttpListener.Net public bool BindContext(HttpListenerContext context) { - HttpListenerRequest req = context.Request; - ListenerPrefix prefix; - HttpListener listener = SearchListener(req.Url, out prefix); + var req = context.Request; + HttpListener listener = SearchListener(req.Url, out var prefix); if (listener == null) return false; @@ -323,7 +310,7 @@ namespace SocketHttpListener.Net if (host != null && host != "") { Dictionary<ListenerPrefix, HttpListener> localPrefixes = _prefixes; - foreach (ListenerPrefix p in localPrefixes.Keys) + foreach (var p in localPrefixes.Keys) { string ppath = p.Path; if (ppath.Length < bestLength) |
