diff options
Diffstat (limited to 'SocketHttpListener')
| -rw-r--r-- | SocketHttpListener/Ext.cs | 3 | ||||
| -rw-r--r-- | SocketHttpListener/Net/CookieHelper.cs | 3 | ||||
| -rw-r--r-- | SocketHttpListener/Net/HttpEndPointListener.cs | 3 | ||||
| -rw-r--r-- | SocketHttpListener/Net/HttpEndPointManager.cs | 3 | ||||
| -rw-r--r-- | SocketHttpListener/Net/HttpListenerRequestUriBuilder.cs | 6 | ||||
| -rw-r--r-- | SocketHttpListener/Net/WebHeaderCollection.cs | 6 | ||||
| -rw-r--r-- | SocketHttpListener/Net/WebSockets/HttpWebSocket.Managed.cs | 3 |
7 files changed, 9 insertions, 18 deletions
diff --git a/SocketHttpListener/Ext.cs b/SocketHttpListener/Ext.cs index 1251d19c0..b9894ca8f 100644 --- a/SocketHttpListener/Ext.cs +++ b/SocketHttpListener/Ext.cs @@ -932,9 +932,8 @@ namespace SocketHttpListener /// </param> public static Uri ToUri(this string uriString) { - Uri res; return Uri.TryCreate( - uriString, uriString.MaybeUri() ? UriKind.Absolute : UriKind.Relative, out res) + uriString, uriString.MaybeUri() ? UriKind.Absolute : UriKind.Relative, out var res) ? res : null; } diff --git a/SocketHttpListener/Net/CookieHelper.cs b/SocketHttpListener/Net/CookieHelper.cs index c59756c77..3ad76ff23 100644 --- a/SocketHttpListener/Net/CookieHelper.cs +++ b/SocketHttpListener/Net/CookieHelper.cs @@ -43,13 +43,12 @@ namespace SocketHttpListener.Net if (i < pairs.Length - 1) buffer.AppendFormat(", {0}", pairs[++i].Trim()); - DateTime expires; if (!DateTime.TryParseExact( buffer.ToString(), new[] { "ddd, dd'-'MMM'-'yyyy HH':'mm':'ss 'GMT'", "r" }, new CultureInfo("en-US"), DateTimeStyles.AdjustToUniversal | DateTimeStyles.AssumeUniversal, - out expires)) + out var expires)) expires = DateTime.Now; if (cookie != null && cookie.Expires == DateTime.MinValue) diff --git a/SocketHttpListener/Net/HttpEndPointListener.cs b/SocketHttpListener/Net/HttpEndPointListener.cs index d002c13b2..c78d186c5 100644 --- a/SocketHttpListener/Net/HttpEndPointListener.cs +++ b/SocketHttpListener/Net/HttpEndPointListener.cs @@ -277,8 +277,7 @@ namespace SocketHttpListener.Net public bool BindContext(HttpListenerContext context) { var req = context.Request; - ListenerPrefix prefix; - var listener = SearchListener(req.Url, out prefix); + var listener = SearchListener(req.Url, out var prefix); if (listener == null) return false; diff --git a/SocketHttpListener/Net/HttpEndPointManager.cs b/SocketHttpListener/Net/HttpEndPointManager.cs index 98986333b..07b6331f2 100644 --- a/SocketHttpListener/Net/HttpEndPointManager.cs +++ b/SocketHttpListener/Net/HttpEndPointManager.cs @@ -57,8 +57,7 @@ namespace SocketHttpListener.Net int root = p.IndexOf('/', colon, p.Length - colon); string portString = p.Substring(colon + 1, root - colon - 1); - int port; - if (!int.TryParse(portString, out port) || port <= 0 || port >= 65536) + if (!int.TryParse(portString, out var port) || port <= 0 || port >= 65536) { throw new HttpListenerException((int)HttpStatusCode.BadRequest, "net_invalid_port"); } diff --git a/SocketHttpListener/Net/HttpListenerRequestUriBuilder.cs b/SocketHttpListener/Net/HttpListenerRequestUriBuilder.cs index 310c71a0d..52e70b68b 100644 --- a/SocketHttpListener/Net/HttpListenerRequestUriBuilder.cs +++ b/SocketHttpListener/Net/HttpListenerRequestUriBuilder.cs @@ -232,8 +232,7 @@ namespace SocketHttpListener.Net { // http.sys only supports %uXXXX (4 hex-digits), even though unicode code points could have up to // 6 hex digits. Therefore we parse always 4 characters after %u and convert them to an int. - int codePointValue; - if (!int.TryParse(codePoint, NumberStyles.HexNumber, null, out codePointValue)) + if (!int.TryParse(codePoint, NumberStyles.HexNumber, null, out var codePointValue)) { //if (NetEventSource.IsEnabled) // NetEventSource.Error(this, SR.Format(SR.net_log_listener_cant_convert_percent_value, codePoint)); @@ -264,8 +263,7 @@ namespace SocketHttpListener.Net private bool AddPercentEncodedOctetToRawOctetsList(Encoding encoding, string escapedCharacter) { - byte encodedValue; - if (!byte.TryParse(escapedCharacter, NumberStyles.HexNumber, null, out encodedValue)) + if (!byte.TryParse(escapedCharacter, NumberStyles.HexNumber, null, out var encodedValue)) { //if (NetEventSource.IsEnabled) NetEventSource.Error(this, SR.Format(SR.net_log_listener_cant_convert_percent_value, escapedCharacter)); return false; diff --git a/SocketHttpListener/Net/WebHeaderCollection.cs b/SocketHttpListener/Net/WebHeaderCollection.cs index 02d3cf61f..c56d2ef38 100644 --- a/SocketHttpListener/Net/WebHeaderCollection.cs +++ b/SocketHttpListener/Net/WebHeaderCollection.cs @@ -208,8 +208,7 @@ namespace SocketHttpListener.Net if (!IsHeaderName(headerName)) throw new ArgumentException("Invalid character in header"); - HeaderInfo info; - if (!headers.TryGetValue(headerName, out info)) + if (!headers.TryGetValue(headerName, out var info)) return false; var flag = response ? HeaderInfo.Response : HeaderInfo.Request; @@ -313,8 +312,7 @@ namespace SocketHttpListener.Net if (headerName == null) return false; - HeaderInfo info; - return headers.TryGetValue(headerName, out info) && (info & HeaderInfo.MultiValue) != 0; + return headers.TryGetValue(headerName, out var info) && (info & HeaderInfo.MultiValue) != 0; } internal static bool IsHeaderValue(string value) diff --git a/SocketHttpListener/Net/WebSockets/HttpWebSocket.Managed.cs b/SocketHttpListener/Net/WebSockets/HttpWebSocket.Managed.cs index f51f72dba..5f77ff565 100644 --- a/SocketHttpListener/Net/WebSockets/HttpWebSocket.Managed.cs +++ b/SocketHttpListener/Net/WebSockets/HttpWebSocket.Managed.cs @@ -26,12 +26,11 @@ namespace SocketHttpListener.Net.WebSockets string origin = request.Headers[HttpKnownHeaderNames.Origin]; string[] secWebSocketProtocols = null; - string outgoingSecWebSocketProtocolString; bool shouldSendSecWebSocketProtocolHeader = ProcessWebSocketProtocolHeader( request.Headers[HttpKnownHeaderNames.SecWebSocketProtocol], subProtocol, - out outgoingSecWebSocketProtocolString); + out var outgoingSecWebSocketProtocolString); if (shouldSendSecWebSocketProtocolHeader) { |
