aboutsummaryrefslogtreecommitdiff
path: root/SocketHttpListener/Net
diff options
context:
space:
mode:
Diffstat (limited to 'SocketHttpListener/Net')
-rw-r--r--SocketHttpListener/Net/ChunkStream.cs10
-rw-r--r--SocketHttpListener/Net/ChunkedInputStream.cs6
-rw-r--r--SocketHttpListener/Net/CookieHelper.cs6
-rw-r--r--SocketHttpListener/Net/HttpEndPointListener.cs7
-rw-r--r--SocketHttpListener/Net/HttpListener.cs4
-rw-r--r--SocketHttpListener/Net/HttpListenerBasicIdentity.cs6
-rw-r--r--SocketHttpListener/Net/HttpListenerContext.cs4
-rw-r--r--SocketHttpListener/Net/HttpListenerPrefixCollection.cs2
-rw-r--r--SocketHttpListener/Net/HttpListenerRequest.Managed.cs4
-rw-r--r--SocketHttpListener/Net/HttpListenerRequest.cs2
-rw-r--r--SocketHttpListener/Net/HttpListenerRequestUriBuilder.cs12
-rw-r--r--SocketHttpListener/Net/HttpListenerResponse.Managed.cs14
-rw-r--r--SocketHttpListener/Net/HttpListenerResponse.cs6
-rw-r--r--SocketHttpListener/Net/HttpRequestStream.Managed.cs6
-rw-r--r--SocketHttpListener/Net/HttpRequestStream.cs6
-rw-r--r--SocketHttpListener/Net/HttpResponseStream.Managed.cs8
-rw-r--r--SocketHttpListener/Net/WebHeaderCollection.cs140
-rw-r--r--SocketHttpListener/Net/WebSockets/HttpWebSocket.cs22
-rw-r--r--SocketHttpListener/Net/WebSockets/WebSocketCloseStatus.cs6
19 files changed, 136 insertions, 135 deletions
diff --git a/SocketHttpListener/Net/ChunkStream.cs b/SocketHttpListener/Net/ChunkStream.cs
index b41285dbc..5cc01614f 100644
--- a/SocketHttpListener/Net/ChunkStream.cs
+++ b/SocketHttpListener/Net/ChunkStream.cs
@@ -14,7 +14,7 @@ namespace SocketHttpListener.Net
// System.Net.ResponseStream
//
// Author:
- // Gonzalo Paniagua Javier (gonzalo@novell.com)
+ // Gonzalo Paniagua Javier (gonzalo@novell.com)
//
// Copyright (c) 2005 Novell, Inc. (http://www.novell.com)
//
@@ -25,10 +25,10 @@ namespace SocketHttpListener.Net
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
- //
+ //
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
- //
+ //
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
@@ -271,7 +271,7 @@ namespace SocketHttpListener.Net
{
if (_saved.Length > 0)
{
- _chunkSize = Int32.Parse(RemoveChunkExtension(_saved.ToString()), NumberStyles.HexNumber);
+ _chunkSize = int.Parse(RemoveChunkExtension(_saved.ToString()), NumberStyles.HexNumber);
}
}
catch (Exception)
@@ -285,7 +285,7 @@ namespace SocketHttpListener.Net
_chunkRead = 0;
try
{
- _chunkSize = Int32.Parse(RemoveChunkExtension(_saved.ToString()), NumberStyles.HexNumber);
+ _chunkSize = int.Parse(RemoveChunkExtension(_saved.ToString()), NumberStyles.HexNumber);
}
catch (Exception)
{
diff --git a/SocketHttpListener/Net/ChunkedInputStream.cs b/SocketHttpListener/Net/ChunkedInputStream.cs
index 919bd95ea..4d6d96a6c 100644
--- a/SocketHttpListener/Net/ChunkedInputStream.cs
+++ b/SocketHttpListener/Net/ChunkedInputStream.cs
@@ -12,7 +12,7 @@ namespace SocketHttpListener.Net
// System.Net.ResponseStream
//
// Author:
- // Gonzalo Paniagua Javier (gonzalo@novell.com)
+ // Gonzalo Paniagua Javier (gonzalo@novell.com)
//
// Copyright (c) 2005 Novell, Inc. (http://www.novell.com)
//
@@ -23,10 +23,10 @@ namespace SocketHttpListener.Net
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
- //
+ //
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
- //
+ //
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
diff --git a/SocketHttpListener/Net/CookieHelper.cs b/SocketHttpListener/Net/CookieHelper.cs
index a32131956..6c1764e09 100644
--- a/SocketHttpListener/Net/CookieHelper.cs
+++ b/SocketHttpListener/Net/CookieHelper.cs
@@ -36,7 +36,7 @@ namespace SocketHttpListener.Net
if (pair.StartsWith("version", StringComparison.OrdinalIgnoreCase))
{
if (cookie != null)
- cookie.Version = Int32.Parse(pair.GetValueInternal("=").Trim('"'));
+ cookie.Version = int.Parse(pair.GetValueInternal("=").Trim('"'));
}
else if (pair.StartsWith("expires", StringComparison.OrdinalIgnoreCase))
{
@@ -58,7 +58,7 @@ namespace SocketHttpListener.Net
}
else if (pair.StartsWith("max-age", StringComparison.OrdinalIgnoreCase))
{
- var max = Int32.Parse(pair.GetValueInternal("=").Trim('"'));
+ var max = int.Parse(pair.GetValueInternal("=").Trim('"'));
var expires = DateTime.Now.AddSeconds((double)max);
if (cookie != null)
cookie.Expires = expires;
@@ -113,7 +113,7 @@ namespace SocketHttpListener.Net
cookies.Add(cookie);
string name;
- string val = String.Empty;
+ string val = string.Empty;
var pos = pair.IndexOf('=');
if (pos == -1)
diff --git a/SocketHttpListener/Net/HttpEndPointListener.cs b/SocketHttpListener/Net/HttpEndPointListener.cs
index fb093314c..a108e7dd4 100644
--- a/SocketHttpListener/Net/HttpEndPointListener.cs
+++ b/SocketHttpListener/Net/HttpEndPointListener.cs
@@ -168,6 +168,7 @@ namespace SocketHttpListener.Net
}
catch (ObjectDisposedException)
{
+ // TODO Investigate or properly fix.
}
catch (Exception ex)
{
@@ -177,9 +178,9 @@ namespace SocketHttpListener.Net
}
}
- // This method is the callback method associated with Socket.AcceptAsync
- // operations and is invoked when an accept operation is complete
- //
+ // This method is the callback method associated with Socket.AcceptAsync
+ // operations and is invoked when an accept operation is complete
+ //
private static void OnAccept(object sender, SocketAsyncEventArgs e)
{
ProcessAccept(e);
diff --git a/SocketHttpListener/Net/HttpListener.cs b/SocketHttpListener/Net/HttpListener.cs
index 941b99f35..a159cd273 100644
--- a/SocketHttpListener/Net/HttpListener.cs
+++ b/SocketHttpListener/Net/HttpListener.cs
@@ -35,7 +35,7 @@ namespace SocketHttpListener.Net
bool listening;
bool disposed;
- Dictionary<HttpListenerContext, HttpListenerContext> registry; // Dictionary<HttpListenerContext,HttpListenerContext>
+ Dictionary<HttpListenerContext, HttpListenerContext> registry; // Dictionary<HttpListenerContext,HttpListenerContext>
Dictionary<HttpConnection, HttpConnection> connections;
private ILogger _logger;
private X509Certificate _certificate;
@@ -248,7 +248,7 @@ namespace SocketHttpListener.Net
internal void CheckDisposed()
{
if (disposed)
- throw new ObjectDisposedException(GetType().ToString());
+ throw new ObjectDisposedException(GetType().Name);
}
internal void RegisterContext(HttpListenerContext context)
diff --git a/SocketHttpListener/Net/HttpListenerBasicIdentity.cs b/SocketHttpListener/Net/HttpListenerBasicIdentity.cs
index faa26693d..d20e72777 100644
--- a/SocketHttpListener/Net/HttpListenerBasicIdentity.cs
+++ b/SocketHttpListener/Net/HttpListenerBasicIdentity.cs
@@ -26,7 +26,7 @@ namespace SocketHttpListener.Net
public GenericIdentity(string name)
{
if (name == null)
- throw new System.ArgumentNullException("name");
+ throw new System.ArgumentNullException(nameof(name));
m_name = name;
m_type = "";
@@ -35,9 +35,9 @@ namespace SocketHttpListener.Net
public GenericIdentity(string name, string type)
{
if (name == null)
- throw new System.ArgumentNullException("name");
+ throw new System.ArgumentNullException(nameof(name));
if (type == null)
- throw new System.ArgumentNullException("type");
+ throw new System.ArgumentNullException(nameof(type));
m_name = name;
m_type = type;
diff --git a/SocketHttpListener/Net/HttpListenerContext.cs b/SocketHttpListener/Net/HttpListenerContext.cs
index 0aaac1ad5..e3e6eb906 100644
--- a/SocketHttpListener/Net/HttpListenerContext.cs
+++ b/SocketHttpListener/Net/HttpListenerContext.cs
@@ -49,7 +49,7 @@ namespace SocketHttpListener.Net
public GenericPrincipal(IIdentity identity, string[] roles)
{
if (identity == null)
- throw new ArgumentNullException("identity");
+ throw new ArgumentNullException(nameof(identity));
m_identity = identity;
if (roles != null)
@@ -81,7 +81,7 @@ namespace SocketHttpListener.Net
for (int i = 0; i < m_roles.Length; ++i)
{
- if (m_roles[i] != null && String.Compare(m_roles[i], role, StringComparison.OrdinalIgnoreCase) == 0)
+ if (m_roles[i] != null && string.Compare(m_roles[i], role, StringComparison.OrdinalIgnoreCase) == 0)
return true;
}
return false;
diff --git a/SocketHttpListener/Net/HttpListenerPrefixCollection.cs b/SocketHttpListener/Net/HttpListenerPrefixCollection.cs
index ed99af1a6..f0e496a5a 100644
--- a/SocketHttpListener/Net/HttpListenerPrefixCollection.cs
+++ b/SocketHttpListener/Net/HttpListenerPrefixCollection.cs
@@ -85,7 +85,7 @@ namespace SocketHttpListener.Net
{
listener.CheckDisposed();
if (uriPrefix == null)
- throw new ArgumentNullException("uriPrefix");
+ throw new ArgumentNullException(nameof(uriPrefix));
bool result = prefixes.Remove(uriPrefix);
if (result && listener.IsListening)
diff --git a/SocketHttpListener/Net/HttpListenerRequest.Managed.cs b/SocketHttpListener/Net/HttpListenerRequest.Managed.cs
index 47a6dfcfd..8b68afe33 100644
--- a/SocketHttpListener/Net/HttpListenerRequest.Managed.cs
+++ b/SocketHttpListener/Net/HttpListenerRequest.Managed.cs
@@ -183,14 +183,14 @@ namespace SocketHttpListener.Net
}
}
- if (String.Compare(Headers[HttpKnownHeaderNames.Expect], "100-continue", StringComparison.OrdinalIgnoreCase) == 0)
+ if (string.Compare(Headers[HttpKnownHeaderNames.Expect], "100-continue", StringComparison.OrdinalIgnoreCase) == 0)
{
HttpResponseStream output = _context.Connection.GetResponseStream();
output.InternalWrite(s_100continue, 0, s_100continue.Length);
}
}
- internal static string Unquote(String str)
+ internal static string Unquote(string str)
{
int start = str.IndexOf('\"');
int end = str.LastIndexOf('\"');
diff --git a/SocketHttpListener/Net/HttpListenerRequest.cs b/SocketHttpListener/Net/HttpListenerRequest.cs
index 1b369dfa8..16e245611 100644
--- a/SocketHttpListener/Net/HttpListenerRequest.cs
+++ b/SocketHttpListener/Net/HttpListenerRequest.cs
@@ -27,7 +27,7 @@ namespace SocketHttpListener.Net
public string[] UserLanguages => Helpers.ParseMultivalueHeader(Headers[HttpKnownHeaderNames.AcceptLanguage]);
- private CookieCollection ParseCookies(Uri uri, string setCookieHeader)
+ private static CookieCollection ParseCookies(Uri uri, string setCookieHeader)
{
CookieCollection cookies = new CookieCollection();
return cookies;
diff --git a/SocketHttpListener/Net/HttpListenerRequestUriBuilder.cs b/SocketHttpListener/Net/HttpListenerRequestUriBuilder.cs
index 34b5eaf74..63790d796 100644
--- a/SocketHttpListener/Net/HttpListenerRequestUriBuilder.cs
+++ b/SocketHttpListener/Net/HttpListenerRequestUriBuilder.cs
@@ -28,11 +28,11 @@ namespace SocketHttpListener.Net
// The raw path is parsed by looping through all characters from left to right. 'rawOctets'
// is used to store consecutive percent encoded octets as actual byte values: e.g. for path /pa%C3%84th%2F/
// rawOctets will be set to { 0xC3, 0x84 } when we reach character 't' and it will be { 0x2F } when
- // we reach the final '/'. I.e. after a sequence of percent encoded octets ends, we use rawOctets as
+ // we reach the final '/'. I.e. after a sequence of percent encoded octets ends, we use rawOctets as
// input to the encoding and percent encode the resulting string into UTF-8 octets.
//
// When parsing ANSI (Latin 1) encoded path '/pa%C4th/', %C4 will be added to rawOctets and when
- // we reach 't', the content of rawOctets { 0xC4 } will be fed into the ANSI encoding. The resulting
+ // we reach 't', the content of rawOctets { 0xC4 } will be fed into the ANSI encoding. The resulting
// string 'Ä' will be percent encoded into UTF-8 octets and appended to requestUriString. The final
// path will be '/pa%C3%84th/', where '%C3%84' is the UTF-8 percent encoded character 'Ä'.
private List<byte> _rawOctets;
@@ -146,7 +146,7 @@ namespace SocketHttpListener.Net
if (!Uri.TryCreate(_requestUriString.ToString(), UriKind.Absolute, out _requestUri))
{
- // If we can't create a Uri from the string, this is an invalid string and it doesn't make
+ // If we can't create a Uri from the string, this is an invalid string and it doesn't make
// sense to try another encoding.
result = ParsingResult.InvalidString;
}
@@ -196,7 +196,7 @@ namespace SocketHttpListener.Net
}
else
{
- // We found '%', but not followed by 'u', i.e. we have a percent encoded octed: %XX
+ // We found '%', but not followed by 'u', i.e. we have a percent encoded octed: %XX
if (!AddPercentEncodedOctetToRawOctetsList(encoding, _rawPath.Substring(index, 2)))
{
return ParsingResult.InvalidString;
@@ -207,7 +207,7 @@ namespace SocketHttpListener.Net
else
{
// We found a non-'%' character: decode the content of rawOctets into percent encoded
- // UTF-8 characters and append it to the result.
+ // UTF-8 characters and append it to the result.
if (!EmptyDecodeAndAppendRawOctetsList(encoding))
{
return ParsingResult.EncodingError;
@@ -402,7 +402,7 @@ namespace SocketHttpListener.Net
// Find end of path: The path is terminated by
// - the first '?' character
- // - the first '#' character: This is never the case here, since http.sys won't accept
+ // - the first '#' character: This is never the case here, since http.sys won't accept
// Uris containing fragments. Also, RFC2616 doesn't allow fragments in request Uris.
// - end of Uri string
int queryIndex = uriString.IndexOf('?');
diff --git a/SocketHttpListener/Net/HttpListenerResponse.Managed.cs b/SocketHttpListener/Net/HttpListenerResponse.Managed.cs
index 34953b569..8fb4518a1 100644
--- a/SocketHttpListener/Net/HttpListenerResponse.Managed.cs
+++ b/SocketHttpListener/Net/HttpListenerResponse.Managed.cs
@@ -207,13 +207,13 @@ namespace SocketHttpListener.Net
}
/* Apache forces closing the connection for these status codes:
- * HttpStatusCode.BadRequest 400
- * HttpStatusCode.RequestTimeout 408
- * HttpStatusCode.LengthRequired 411
- * HttpStatusCode.RequestEntityTooLarge 413
- * HttpStatusCode.RequestUriTooLong 414
- * HttpStatusCode.InternalServerError 500
- * HttpStatusCode.ServiceUnavailable 503
+ * HttpStatusCode.BadRequest 400
+ * HttpStatusCode.RequestTimeout 408
+ * HttpStatusCode.LengthRequired 411
+ * HttpStatusCode.RequestEntityTooLarge 413
+ * HttpStatusCode.RequestUriTooLong 414
+ * HttpStatusCode.InternalServerError 500
+ * HttpStatusCode.ServiceUnavailable 503
*/
bool conn_close = (_statusCode == (int)HttpStatusCode.BadRequest || _statusCode == (int)HttpStatusCode.RequestTimeout
|| _statusCode == (int)HttpStatusCode.LengthRequired || _statusCode == (int)HttpStatusCode.RequestEntityTooLarge
diff --git a/SocketHttpListener/Net/HttpListenerResponse.cs b/SocketHttpListener/Net/HttpListenerResponse.cs
index 1cbd6165e..351a206ee 100644
--- a/SocketHttpListener/Net/HttpListenerResponse.cs
+++ b/SocketHttpListener/Net/HttpListenerResponse.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Collections.Generic;
using System.IO;
using System.Net;
@@ -71,7 +71,7 @@ namespace SocketHttpListener.Net
public bool SendChunked
{
- get { return EntitySendFormat == EntitySendFormat.Chunked; ; }
+ get { return EntitySendFormat == EntitySendFormat.Chunked; }
set { EntitySendFormat = value ? EntitySendFormat.Chunked : EntitySendFormat.ContentLength; }
}
@@ -104,7 +104,7 @@ namespace SocketHttpListener.Net
}
else
{
- throw new ArgumentOutOfRangeException("net_clsmall");
+ throw new ArgumentOutOfRangeException(nameof(value));
}
}
}
diff --git a/SocketHttpListener/Net/HttpRequestStream.Managed.cs b/SocketHttpListener/Net/HttpRequestStream.Managed.cs
index c9c148b15..493e2673b 100644
--- a/SocketHttpListener/Net/HttpRequestStream.Managed.cs
+++ b/SocketHttpListener/Net/HttpRequestStream.Managed.cs
@@ -13,7 +13,7 @@ namespace SocketHttpListener.Net
// System.Net.ResponseStream
//
// Author:
- // Gonzalo Paniagua Javier (gonzalo@novell.com)
+ // Gonzalo Paniagua Javier (gonzalo@novell.com)
//
// Copyright (c) 2005 Novell, Inc. (http://www.novell.com)
//
@@ -24,10 +24,10 @@ namespace SocketHttpListener.Net
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
- //
+ //
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
- //
+ //
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
diff --git a/SocketHttpListener/Net/HttpRequestStream.cs b/SocketHttpListener/Net/HttpRequestStream.cs
index f10c04a4f..c9a1d5a2d 100644
--- a/SocketHttpListener/Net/HttpRequestStream.cs
+++ b/SocketHttpListener/Net/HttpRequestStream.cs
@@ -13,7 +13,7 @@ namespace SocketHttpListener.Net
// System.Net.ResponseStream
//
// Author:
- // Gonzalo Paniagua Javier (gonzalo@novell.com)
+ // Gonzalo Paniagua Javier (gonzalo@novell.com)
//
// Copyright (c) 2005 Novell, Inc. (http://www.novell.com)
//
@@ -24,10 +24,10 @@ namespace SocketHttpListener.Net
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
- //
+ //
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
- //
+ //
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
diff --git a/SocketHttpListener/Net/HttpResponseStream.Managed.cs b/SocketHttpListener/Net/HttpResponseStream.Managed.cs
index e727f1b4a..719dfcc12 100644
--- a/SocketHttpListener/Net/HttpResponseStream.Managed.cs
+++ b/SocketHttpListener/Net/HttpResponseStream.Managed.cs
@@ -19,7 +19,7 @@ namespace SocketHttpListener.Net
// System.Net.ResponseStream
//
// Author:
- // Gonzalo Paniagua Javier (gonzalo@novell.com)
+ // Gonzalo Paniagua Javier (gonzalo@novell.com)
//
// Copyright (c) 2005 Novell, Inc. (http://www.novell.com)
//
@@ -30,10 +30,10 @@ namespace SocketHttpListener.Net
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
- //
+ //
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
- //
+ //
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
@@ -157,7 +157,7 @@ namespace SocketHttpListener.Net
private static byte[] s_crlf = new byte[] { 13, 10 };
private static byte[] GetChunkSizeBytes(int size, bool final)
{
- string str = String.Format("{0:x}\r\n{1}", size, final ? "\r\n" : "");
+ string str = string.Format("{0:x}\r\n{1}", size, final ? "\r\n" : "");
return Encoding.ASCII.GetBytes(str);
}
diff --git a/SocketHttpListener/Net/WebHeaderCollection.cs b/SocketHttpListener/Net/WebHeaderCollection.cs
index 4bed81404..ed3cb921c 100644
--- a/SocketHttpListener/Net/WebHeaderCollection.cs
+++ b/SocketHttpListener/Net/WebHeaderCollection.cs
@@ -23,69 +23,69 @@ namespace SocketHttpListener.Net
}
static readonly bool[] allowed_chars = {
- false, false, false, false, false, false, false, false, false, false, false, false, false, false,
- false, false, false, false, false, false, false, false, false, false, false, false, false, false,
- false, false, false, false, false, true, false, true, true, true, true, false, false, false, true,
- true, false, true, true, false, true, true, true, true, true, true, true, true, true, true, false,
- false, false, false, false, false, false, true, true, true, true, true, true, true, true, true,
- true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true,
- false, false, false, true, true, true, true, true, true, true, true, true, true, true, true, true,
- true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true,
- false, true, false
- };
+ false, false, false, false, false, false, false, false, false, false, false, false, false, false,
+ false, false, false, false, false, false, false, false, false, false, false, false, false, false,
+ false, false, false, false, false, true, false, true, true, true, true, false, false, false, true,
+ true, false, true, true, false, true, true, true, true, true, true, true, true, true, true, false,
+ false, false, false, false, false, false, true, true, true, true, true, true, true, true, true,
+ true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true,
+ false, false, false, true, true, true, true, true, true, true, true, true, true, true, true, true,
+ true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true,
+ false, true, false
+ };
static readonly Dictionary<string, HeaderInfo> headers;
static WebHeaderCollection()
{
headers = new Dictionary<string, HeaderInfo>(StringComparer.OrdinalIgnoreCase) {
- { "Allow", HeaderInfo.MultiValue },
- { "Accept", HeaderInfo.Request | HeaderInfo.MultiValue },
- { "Accept-Charset", HeaderInfo.MultiValue },
- { "Accept-Encoding", HeaderInfo.MultiValue },
- { "Accept-Language", HeaderInfo.MultiValue },
- { "Accept-Ranges", HeaderInfo.MultiValue },
- { "Age", HeaderInfo.Response },
- { "Authorization", HeaderInfo.MultiValue },
- { "Cache-Control", HeaderInfo.MultiValue },
- { "Cookie", HeaderInfo.MultiValue },
- { "Connection", HeaderInfo.Request | HeaderInfo.MultiValue },
- { "Content-Encoding", HeaderInfo.MultiValue },
- { "Content-Length", HeaderInfo.Request | HeaderInfo.Response },
- { "Content-Type", HeaderInfo.Request },
- { "Content-Language", HeaderInfo.MultiValue },
- { "Date", HeaderInfo.Request },
- { "Expect", HeaderInfo.Request | HeaderInfo.MultiValue},
- { "Host", HeaderInfo.Request },
- { "If-Match", HeaderInfo.MultiValue },
- { "If-Modified-Since", HeaderInfo.Request },
- { "If-None-Match", HeaderInfo.MultiValue },
- { "Keep-Alive", HeaderInfo.Response },
- { "Pragma", HeaderInfo.MultiValue },
- { "Proxy-Authenticate", HeaderInfo.MultiValue },
- { "Proxy-Authorization", HeaderInfo.MultiValue },
- { "Proxy-Connection", HeaderInfo.Request | HeaderInfo.MultiValue },
- { "Range", HeaderInfo.Request | HeaderInfo.MultiValue },
- { "Referer", HeaderInfo.Request },
- { "Set-Cookie", HeaderInfo.MultiValue },
- { "Set-Cookie2", HeaderInfo.MultiValue },
- { "Server", HeaderInfo.Response },
- { "TE", HeaderInfo.MultiValue },
- { "Trailer", HeaderInfo.MultiValue },
- { "Transfer-Encoding", HeaderInfo.Request | HeaderInfo.Response | HeaderInfo.MultiValue },
- { "Translate", HeaderInfo.Request | HeaderInfo.Response },
- { "Upgrade", HeaderInfo.MultiValue },
- { "User-Agent", HeaderInfo.Request },
- { "Vary", HeaderInfo.MultiValue },
- { "Via", HeaderInfo.MultiValue },
- { "Warning", HeaderInfo.MultiValue },
- { "WWW-Authenticate", HeaderInfo.Response | HeaderInfo. MultiValue },
- { "SecWebSocketAccept", HeaderInfo.Response },
- { "SecWebSocketExtensions", HeaderInfo.Request | HeaderInfo.Response | HeaderInfo. MultiValue },
- { "SecWebSocketKey", HeaderInfo.Request },
- { "Sec-WebSocket-Protocol", HeaderInfo.Request | HeaderInfo.Response | HeaderInfo. MultiValue },
- { "SecWebSocketVersion", HeaderInfo.Response | HeaderInfo. MultiValue }
- };
+ { "Allow", HeaderInfo.MultiValue },
+ { "Accept", HeaderInfo.Request | HeaderInfo.MultiValue },
+ { "Accept-Charset", HeaderInfo.MultiValue },
+ { "Accept-Encoding", HeaderInfo.MultiValue },
+ { "Accept-Language", HeaderInfo.MultiValue },
+ { "Accept-Ranges", HeaderInfo.MultiValue },
+ { "Age", HeaderInfo.Response },
+ { "Authorization", HeaderInfo.MultiValue },
+ { "Cache-Control", HeaderInfo.MultiValue },
+ { "Cookie", HeaderInfo.MultiValue },
+ { "Connection", HeaderInfo.Request | HeaderInfo.MultiValue },
+ { "Content-Encoding", HeaderInfo.MultiValue },
+ { "Content-Length", HeaderInfo.Request | HeaderInfo.Response },
+ { "Content-Type", HeaderInfo.Request },
+ { "Content-Language", HeaderInfo.MultiValue },
+ { "Date", HeaderInfo.Request },
+ { "Expect", HeaderInfo.Request | HeaderInfo.MultiValue},
+ { "Host", HeaderInfo.Request },
+ { "If-Match", HeaderInfo.MultiValue },
+ { "If-Modified-Since", HeaderInfo.Request },
+ { "If-None-Match", HeaderInfo.MultiValue },
+ { "Keep-Alive", HeaderInfo.Response },
+ { "Pragma", HeaderInfo.MultiValue },
+ { "Proxy-Authenticate", HeaderInfo.MultiValue },
+ { "Proxy-Authorization", HeaderInfo.MultiValue },
+ { "Proxy-Connection", HeaderInfo.Request | HeaderInfo.MultiValue },
+ { "Range", HeaderInfo.Request | HeaderInfo.MultiValue },
+ { "Referer", HeaderInfo.Request },
+ { "Set-Cookie", HeaderInfo.MultiValue },
+ { "Set-Cookie2", HeaderInfo.MultiValue },
+ { "Server", HeaderInfo.Response },
+ { "TE", HeaderInfo.MultiValue },
+ { "Trailer", HeaderInfo.MultiValue },
+ { "Transfer-Encoding", HeaderInfo.Request | HeaderInfo.Response | HeaderInfo.MultiValue },
+ { "Translate", HeaderInfo.Request | HeaderInfo.Response },
+ { "Upgrade", HeaderInfo.MultiValue },
+ { "User-Agent", HeaderInfo.Request },
+ { "Vary", HeaderInfo.MultiValue },
+ { "Via", HeaderInfo.MultiValue },
+ { "Warning", HeaderInfo.MultiValue },
+ { "WWW-Authenticate", HeaderInfo.Response | HeaderInfo. MultiValue },
+ { "SecWebSocketAccept", HeaderInfo.Response },
+ { "SecWebSocketExtensions", HeaderInfo.Request | HeaderInfo.Response | HeaderInfo. MultiValue },
+ { "SecWebSocketKey", HeaderInfo.Request },
+ { "Sec-WebSocket-Protocol", HeaderInfo.Request | HeaderInfo.Response | HeaderInfo. MultiValue },
+ { "SecWebSocketVersion", HeaderInfo.Response | HeaderInfo. MultiValue }
+ };
}
// Methods
@@ -93,10 +93,10 @@ namespace SocketHttpListener.Net
public void Add(string header)
{
if (header == null)
- throw new ArgumentNullException("header");
+ throw new ArgumentNullException(nameof(header));
int pos = header.IndexOf(':');
if (pos == -1)
- throw new ArgumentException("no colon found", "header");
+ throw new ArgumentException("no colon found", nameof(header));
this.Add(header.Substring(0, pos), header.Substring(pos + 1));
}
@@ -104,7 +104,7 @@ namespace SocketHttpListener.Net
public override void Add(string name, string value)
{
if (name == null)
- throw new ArgumentNullException("name");
+ throw new ArgumentNullException(nameof(name));
this.AddWithoutValidate(name, value);
}
@@ -112,13 +112,13 @@ namespace SocketHttpListener.Net
protected void AddWithoutValidate(string headerName, string headerValue)
{
if (!IsHeaderName(headerName))
- throw new ArgumentException("invalid header name: " + headerName, "headerName");
+ throw new ArgumentException("invalid header name: " + headerName, nameof(headerName));
if (headerValue == null)
- headerValue = String.Empty;
+ headerValue = string.Empty;
else
headerValue = headerValue.Trim();
if (!IsHeaderValue(headerValue))
- throw new ArgumentException("invalid header value: " + headerValue, "headerValue");
+ throw new ArgumentException("invalid header value: " + headerValue, nameof(headerValue));
AddValue(headerName, headerValue);
}
@@ -131,7 +131,7 @@ namespace SocketHttpListener.Net
internal List<string> GetValues_internal(string header, bool split)
{
if (header == null)
- throw new ArgumentNullException("header");
+ throw new ArgumentNullException(nameof(header));
var values = base.GetValues(header);
if (values == null || values.Count == 0)
@@ -205,10 +205,10 @@ namespace SocketHttpListener.Net
public static bool IsRestricted(string headerName, bool response)
{
if (headerName == null)
- throw new ArgumentNullException("headerName");
+ throw new ArgumentNullException(nameof(headerName));
if (headerName.Length == 0)
- throw new ArgumentException("empty string", "headerName");
+ throw new ArgumentException("empty string", nameof(headerName));
if (!IsHeaderName(headerName))
throw new ArgumentException("Invalid character in header");
@@ -224,11 +224,11 @@ namespace SocketHttpListener.Net
public override void Set(string name, string value)
{
if (name == null)
- throw new ArgumentNullException("name");
+ throw new ArgumentNullException(nameof(name));
if (!IsHeaderName(name))
throw new ArgumentException("invalid header name");
if (value == null)
- value = String.Empty;
+ value = string.Empty;
else
value = value.Trim();
if (!IsHeaderValue(value))
@@ -288,7 +288,7 @@ namespace SocketHttpListener.Net
{
int pos = header.IndexOf(':');
if (pos == -1)
- throw new ArgumentException("no colon found", "header");
+ throw new ArgumentException("no colon found", nameof(header));
SetInternal(header.Substring(0, pos), header.Substring(pos + 1));
}
@@ -296,7 +296,7 @@ namespace SocketHttpListener.Net
internal void SetInternal(string name, string value)
{
if (value == null)
- value = String.Empty;
+ value = string.Empty;
else
value = value.Trim();
if (!IsHeaderValue(value))
diff --git a/SocketHttpListener/Net/WebSockets/HttpWebSocket.cs b/SocketHttpListener/Net/WebSockets/HttpWebSocket.cs
index 9dc9143f8..f72a139f3 100644
--- a/SocketHttpListener/Net/WebSockets/HttpWebSocket.cs
+++ b/SocketHttpListener/Net/WebSockets/HttpWebSocket.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Collections.Generic;
using System.Text;
using System.Diagnostics.CodeAnalysis;
@@ -30,7 +30,7 @@ namespace SocketHttpListener.Net.WebSockets
return retVal;
}
- // return value here signifies if a Sec-WebSocket-Protocol header should be returned by the server.
+ // return value here signifies if a Sec-WebSocket-Protocol header should be returned by the server.
internal static bool ProcessWebSocketProtocolHeader(string clientSecWebSocketProtocol,
string subProtocol,
out string acceptProtocol)
@@ -44,7 +44,7 @@ namespace SocketHttpListener.Net.WebSockets
// If the server specified _anything_ this isn't valid.
throw new WebSocketException("UnsupportedProtocol");
}
- // Treat empty and null from the server as the same thing here, server should not send headers.
+ // Treat empty and null from the server as the same thing here, server should not send headers.
return false;
}
@@ -52,7 +52,7 @@ namespace SocketHttpListener.Net.WebSockets
if (subProtocol == null)
{
- // client specified some protocols, server specified 'null'. So server should send headers.
+ // client specified some protocols, server specified 'null'. So server should send headers.
return true;
}
@@ -63,8 +63,8 @@ namespace SocketHttpListener.Net.WebSockets
StringSplitOptions.RemoveEmptyEntries);
acceptProtocol = subProtocol;
- // client specified protocols, serverOptions has exactly 1 non-empty entry. Check that
- // this exists in the list the client specified.
+ // client specified protocols, serverOptions has exactly 1 non-empty entry. Check that
+ // this exists in the list the client specified.
for (int i = 0; i < requestProtocols.Length; i++)
{
string currentRequestProtocol = requestProtocols[i].Trim();
@@ -86,27 +86,27 @@ namespace SocketHttpListener.Net.WebSockets
if (receiveBufferSize < MinReceiveBufferSize)
{
- throw new ArgumentOutOfRangeException("net_WebSockets_ArgumentOutOfRange_TooSmall");
+ throw new ArgumentOutOfRangeException(nameof(receiveBufferSize), "The receiveBufferSize was too small.");
}
if (sendBufferSize < MinSendBufferSize)
{
- throw new ArgumentOutOfRangeException("net_WebSockets_ArgumentOutOfRange_TooSmall");
+ throw new ArgumentOutOfRangeException(nameof(sendBufferSize), "The sendBufferSize was too small.");
}
if (receiveBufferSize > MaxBufferSize)
{
- throw new ArgumentOutOfRangeException("net_WebSockets_ArgumentOutOfRange_TooBig");
+ throw new ArgumentOutOfRangeException(nameof(receiveBufferSize), "The receiveBufferSize was too large.");
}
if (sendBufferSize > MaxBufferSize)
{
- throw new ArgumentOutOfRangeException("net_WebSockets_ArgumentOutOfRange_TooBig");
+ throw new ArgumentOutOfRangeException(nameof(sendBufferSize), "The sendBufferSize was too large.");
}
if (keepAliveInterval < Timeout.InfiniteTimeSpan) // -1 millisecond
{
- throw new ArgumentOutOfRangeException("net_WebSockets_ArgumentOutOfRange_TooSmall");
+ throw new ArgumentOutOfRangeException(nameof(keepAliveInterval), "The keepAliveInterval was too small.");
}
}
diff --git a/SocketHttpListener/Net/WebSockets/WebSocketCloseStatus.cs b/SocketHttpListener/Net/WebSockets/WebSocketCloseStatus.cs
index 0f43b7b80..b83b6cd0f 100644
--- a/SocketHttpListener/Net/WebSockets/WebSocketCloseStatus.cs
+++ b/SocketHttpListener/Net/WebSockets/WebSocketCloseStatus.cs
@@ -22,9 +22,9 @@ namespace SocketHttpListener.Net.WebSockets
// 0 - 999 Status codes in the range 0-999 are not used.
// 1000 - 1999 Status codes in the range 1000-1999 are reserved for definition by this protocol.
// 2000 - 2999 Status codes in the range 2000-2999 are reserved for use by extensions.
- // 3000 - 3999 Status codes in the range 3000-3999 MAY be used by libraries and frameworks. The
- // interpretation of these codes is undefined by this protocol. End applications MUST
- // NOT use status codes in this range.
+ // 3000 - 3999 Status codes in the range 3000-3999 MAY be used by libraries and frameworks. The
+ // interpretation of these codes is undefined by this protocol. End applications MUST
+ // NOT use status codes in this range.
// 4000 - 4999 Status codes in the range 4000-4999 MAY be used by application code. The interpretation
// of these codes is undefined by this protocol.
}