From c6e3e12aaf581ab6e6bc5b73541d961992d8d613 Mon Sep 17 00:00:00 2001 From: David Burhans Date: Wed, 3 Jun 2015 11:15:02 -0600 Subject: [PATCH 0001/6294] Port 443 is also a default port and should be excluded from the Host header on websocket requests for compatibility reasons --- websocket-sharp/HttpRequest.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/HttpRequest.cs b/websocket-sharp/HttpRequest.cs index 41f700e2e..d7c2c8423 100644 --- a/websocket-sharp/HttpRequest.cs +++ b/websocket-sharp/HttpRequest.cs @@ -133,7 +133,8 @@ internal static HttpRequest CreateWebSocketRequest (Uri uri) var headers = req.Headers; headers["Upgrade"] = "websocket"; headers["Connection"] = "Upgrade"; - headers["Host"] = uri.Port == 80 ? uri.DnsSafeHost : uri.Authority; + bool isDefaultPort = (uri.Port == 80 && uri.Scheme == "ws") || (uri.Port == 443 && uri.Scheme == "wss"); + headers["Host"] = isDefaultPort ? uri.DnsSafeHost : uri.Authority; return req; } From ab3d3bd7b50d75cf1bd48a3106a460a63d9b2789 Mon Sep 17 00:00:00 2001 From: David Burhans Date: Tue, 9 Jun 2015 08:06:04 -0600 Subject: [PATCH 0002/6294] fix spacing. add intermediate variables --- websocket-sharp/HttpRequest.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/HttpRequest.cs b/websocket-sharp/HttpRequest.cs index d7c2c8423..d6a11d67a 100644 --- a/websocket-sharp/HttpRequest.cs +++ b/websocket-sharp/HttpRequest.cs @@ -133,8 +133,12 @@ internal static HttpRequest CreateWebSocketRequest (Uri uri) var headers = req.Headers; headers["Upgrade"] = "websocket"; headers["Connection"] = "Upgrade"; - bool isDefaultPort = (uri.Port == 80 && uri.Scheme == "ws") || (uri.Port == 443 && uri.Scheme == "wss"); - headers["Host"] = isDefaultPort ? uri.DnsSafeHost : uri.Authority; + var port = uri.Port; + var scheme = uri.Scheme + bool isDefaultPort = (port == 80 && scheme == "ws") || (port == 443 && scheme == "wss"); + // only include port in host header if it is non-default + // https://tools.ietf.org/html/rfc6455#page-17 + headers["Host"] = isDefaultPort ? uri.DnsSafeHost : uri.Authority; return req; } From 23a8c1f4b17330dd56a42890b0789dd458d30399 Mon Sep 17 00:00:00 2001 From: David Burhans Date: Tue, 9 Jun 2015 09:17:25 -0600 Subject: [PATCH 0003/6294] add missed semicolon --- websocket-sharp/HttpRequest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/HttpRequest.cs b/websocket-sharp/HttpRequest.cs index d6a11d67a..cfced5c8c 100644 --- a/websocket-sharp/HttpRequest.cs +++ b/websocket-sharp/HttpRequest.cs @@ -134,7 +134,7 @@ internal static HttpRequest CreateWebSocketRequest (Uri uri) headers["Upgrade"] = "websocket"; headers["Connection"] = "Upgrade"; var port = uri.Port; - var scheme = uri.Scheme + var scheme = uri.Scheme; bool isDefaultPort = (port == 80 && scheme == "ws") || (port == 443 && scheme == "wss"); // only include port in host header if it is non-default // https://tools.ietf.org/html/rfc6455#page-17 From bf0cb2f8e393e9a394f9723f7b3590f3617283e7 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 12 Jun 2015 17:14:36 +0900 Subject: [PATCH 0004/6294] Check if the headers are valid --- websocket-sharp/Net/ResponseStream.cs | 40 +++++++++++++++++++-------- 1 file changed, 28 insertions(+), 12 deletions(-) diff --git a/websocket-sharp/Net/ResponseStream.cs b/websocket-sharp/Net/ResponseStream.cs index 3fb3976e8..09b7196ee 100644 --- a/websocket-sharp/Net/ResponseStream.cs +++ b/websocket-sharp/Net/ResponseStream.cs @@ -125,16 +125,11 @@ public override long Position { #region Private Methods - private void flush (bool closing) + private bool flush (bool closing) { if (!_response.HeadersSent) { - using (var headers = new MemoryStream ()) { - _response.WriteHeadersTo (headers, closing); - var start = headers.Position; - _write (headers.GetBuffer (), (int) start, (int) (headers.Length - start)); - } - - _response.HeadersSent = true; + if (!flushHeaders (closing)) + return false; _chunked = _response.SendChunked; _writeBody = _chunked ? _writeChunked : _write; @@ -145,6 +140,8 @@ private void flush (bool closing) var last = getChunkSizeBytes (0, true); _write (last, 0, last.Length); } + + return true; } private void flushBody (bool closing) @@ -167,6 +164,25 @@ private void flushBody (bool closing) _body = !closing ? new MemoryStream () : null; } + private bool flushHeaders (bool closing) + { + using (var headers = new MemoryStream ()) { + _response.WriteHeadersTo (headers, closing); + var start = headers.Position; + var len = headers.Length - start; + if (len > 32768) + return false; + + if (!_response.SendChunked && _response.ContentLength64 != _body.Length) + return false; + + _write (headers.GetBuffer (), (int) start, (int) len); + } + + _response.HeadersSent = true; + return true; + } + private static byte[] getChunkSizeBytes (int size, bool final) { return Encoding.ASCII.GetBytes (String.Format ("{0:x}\r\n{1}", size, final ? "\r\n" : "")); @@ -208,18 +224,18 @@ internal void Close (bool force) return; _disposed = true; - if (!force) { - flush (true); + if (!force && flush (true)) { _response.Close (); } else { - _body.Dispose (); - _body = null; if (_chunked) { var last = getChunkSizeBytes (0, true); _write (last, 0, last.Length); } + _body.Dispose (); + _body = null; + _response.Abort (); } From 5641184ee6ebba0daa8e5a726f3b942b230928d1 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 13 Jun 2015 17:20:00 +0900 Subject: [PATCH 0005/6294] Reset the headers after the updated headers are sent successfully --- websocket-sharp/Net/HttpListenerResponse.cs | 54 ++++++++++++--------- websocket-sharp/Net/ResponseStream.cs | 19 +++++--- 2 files changed, 43 insertions(+), 30 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index 94fc63464..7570f20fc 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -233,10 +233,7 @@ public CookieCollection Cookies { /// The value specified for a set operation is . /// /// - /// The response has already been sent. - /// - /// - /// This object is closed. + /// The headers has already been sent. /// public WebHeaderCollection Headers { get { @@ -254,7 +251,7 @@ public WebHeaderCollection Headers { // TODO: Check if this is marked readonly after the headers are sent. - checkDisposedOrHeadersSent (); + checkHeadersSent (); if (value == null) throw new ArgumentNullException ("value"); @@ -482,6 +479,12 @@ private void checkDisposedOrHeadersSent () throw new InvalidOperationException ("Cannot be changed after the headers are sent."); } + private void checkHeadersSent () + { + if (_headersSent) + throw new InvalidOperationException ("Cannot be changed after the headers are sent."); + } + private void close (bool force) { _disposed = true; @@ -505,23 +508,26 @@ private IEnumerable findCookie (Cookie cookie) #region Internal Methods - internal void WriteHeadersTo (MemoryStream destination, bool closing) + internal WebHeaderCollection WriteHeadersTo (MemoryStream destination, bool closing) { + var headers = new WebHeaderCollection (); + headers.Add (_headers); + if (_contentType != null) { var type = _contentType.IndexOf ("charset=", StringComparison.Ordinal) == -1 && _contentEncoding != null ? String.Format ("{0}; charset={1}", _contentType, _contentEncoding.WebName) : _contentType; - _headers.InternalSet ("Content-Type", type, true); + headers.InternalSet ("Content-Type", type, true); } - if (_headers["Server"] == null) - _headers.InternalSet ("Server", "websocket-sharp/1.0", true); + if (headers["Server"] == null) + headers.InternalSet ("Server", "websocket-sharp/1.0", true); var prov = CultureInfo.InvariantCulture; - if (_headers["Date"] == null) - _headers.InternalSet ("Date", DateTime.UtcNow.ToString ("r", prov), true); + if (headers["Date"] == null) + headers.InternalSet ("Date", DateTime.UtcNow.ToString ("r", prov), true); if (!_chunked) { if (!_contentLengthSet && closing) { @@ -530,13 +536,13 @@ internal void WriteHeadersTo (MemoryStream destination, bool closing) } if (_contentLengthSet) - _headers.InternalSet ("Content-Length", _contentLength.ToString (prov), true); + headers.InternalSet ("Content-Length", _contentLength.ToString (prov), true); else if (_context.Request.ProtocolVersion > HttpVersion.Version10) _chunked = true; } if (_chunked) - _headers.InternalSet ("Transfer-Encoding", "chunked", true); + headers.InternalSet ("Transfer-Encoding", "chunked", true); /* * Apache forces closing the connection for these status codes: @@ -548,43 +554,45 @@ internal void WriteHeadersTo (MemoryStream destination, bool closing) * - HttpStatusCode.InternalServerError 500 * - HttpStatusCode.ServiceUnavailable 503 */ - var closeConn = _statusCode == 400 || + var closeConn = !_context.Request.KeepAlive || + !_keepAlive || + _statusCode == 400 || _statusCode == 408 || _statusCode == 411 || _statusCode == 413 || _statusCode == 414 || _statusCode == 500 || - _statusCode == 503 || - !_context.Request.KeepAlive || - !_keepAlive; + _statusCode == 503; var reuses = _context.Connection.Reuses; if (closeConn || reuses >= 100) { - _headers.InternalSet ("Connection", "close", true); + headers.InternalSet ("Connection", "close", true); } else { - _headers.InternalSet ( + headers.InternalSet ( "Keep-Alive", String.Format ("timeout=15,max={0}", 100 - reuses), true); if (_context.Request.ProtocolVersion < HttpVersion.Version11) - _headers.InternalSet ("Connection", "keep-alive", true); + headers.InternalSet ("Connection", "keep-alive", true); } if (_location != null) - _headers.InternalSet ("Location", _location, true); + headers.InternalSet ("Location", _location, true); if (_cookies != null) foreach (Cookie cookie in _cookies) - _headers.InternalSet ("Set-Cookie", cookie.ToResponseString (), true); + headers.InternalSet ("Set-Cookie", cookie.ToResponseString (), true); var enc = _contentEncoding ?? Encoding.Default; var writer = new StreamWriter (destination, enc, 256); writer.Write ("HTTP/{0} {1} {2}\r\n", _version, _statusCode, _statusDescription); - writer.Write (_headers.ToStringMultiValue (true)); + writer.Write (headers.ToStringMultiValue (true)); writer.Flush (); // Assumes that the destination was at position 0. destination.Position = enc.CodePage == 65001 ? 3 : enc.GetPreamble ().Length; + + return headers; } #endregion diff --git a/websocket-sharp/Net/ResponseStream.cs b/websocket-sharp/Net/ResponseStream.cs index 09b7196ee..250d2b9fa 100644 --- a/websocket-sharp/Net/ResponseStream.cs +++ b/websocket-sharp/Net/ResponseStream.cs @@ -128,8 +128,12 @@ public override long Position { private bool flush (bool closing) { if (!_response.HeadersSent) { - if (!flushHeaders (closing)) + if (!flushHeaders (closing)) { + if (closing) + _response.Headers.InternalSet ("Connection", "close", true); + return false; + } _chunked = _response.SendChunked; _writeBody = _chunked ? _writeChunked : _write; @@ -166,20 +170,21 @@ private void flushBody (bool closing) private bool flushHeaders (bool closing) { - using (var headers = new MemoryStream ()) { - _response.WriteHeadersTo (headers, closing); - var start = headers.Position; - var len = headers.Length - start; + using (var buff = new MemoryStream ()) { + var headers = _response.WriteHeadersTo (buff, closing); + var start = buff.Position; + var len = buff.Length - start; if (len > 32768) return false; if (!_response.SendChunked && _response.ContentLength64 != _body.Length) return false; - _write (headers.GetBuffer (), (int) start, (int) len); + _write (buff.GetBuffer (), (int) start, (int) len); + _response.Headers = headers; + _response.HeadersSent = true; } - _response.HeadersSent = true; return true; } From 33684e9fde302cbf1346a2c10a5488d61223f25d Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 14 Jun 2015 17:20:30 +0900 Subject: [PATCH 0006/6294] Refactored a few for WebHeaderCollection.cs --- websocket-sharp/Net/WebHeaderCollection.cs | 157 +++++++++++---------- 1 file changed, 80 insertions(+), 77 deletions(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 69bf4c8b9..650fe57ba 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -61,7 +61,7 @@ public class WebHeaderCollection : NameValueCollection, ISerializable #region Private Fields private static readonly Dictionary _headers; - private bool _internallyCreated; + private bool _internallyUsed; private HttpHeaderType _state; #endregion @@ -451,10 +451,10 @@ static WebHeaderCollection () #region Internal Constructors - internal WebHeaderCollection (bool internallyCreated) + internal WebHeaderCollection (HttpHeaderType state, bool internallyUsed) { - _internallyCreated = internallyCreated; - _state = HttpHeaderType.Unspecified; + _state = state; + _internallyUsed = internallyUsed; } #endregion @@ -484,7 +484,7 @@ protected WebHeaderCollection ( throw new ArgumentNullException ("serializationInfo"); try { - _internallyCreated = serializationInfo.GetBoolean ("InternallyCreated"); + _internallyUsed = serializationInfo.GetBoolean ("InternallyUsed"); _state = (HttpHeaderType) serializationInfo.GetInt32 ("State"); var cnt = serializationInfo.GetInt32 ("Count"); @@ -508,7 +508,16 @@ protected WebHeaderCollection ( /// public WebHeaderCollection () { - _state = HttpHeaderType.Unspecified; + } + + #endregion + + #region Internal Properties + + internal HttpHeaderType State { + get { + return _state; + } } #endregion @@ -546,8 +555,8 @@ public override int Count { /// A that represents the value of the request . /// /// - /// One of the enum values, represents the request header - /// to get or set. + /// One of the enum values, represents + /// the request header to get or set. /// /// /// @@ -564,8 +573,8 @@ public override int Count { /// The length of is greater than 65,535 characters. /// /// - /// The current instance doesn't allow the request - /// . + /// The current instance doesn't allow + /// the request . /// public string this[HttpRequestHeader header] { get { @@ -584,8 +593,8 @@ public string this[HttpRequestHeader header] { /// A that represents the value of the response . /// /// - /// One of the enum values, represents the response header - /// to get or set. + /// One of the enum values, represents + /// the response header to get or set. /// /// /// @@ -602,8 +611,8 @@ public string this[HttpRequestHeader header] { /// The length of is greater than 65,535 characters. /// /// - /// The current instance doesn't allow the response - /// . + /// The current instance doesn't allow + /// the response . /// public string this[HttpResponseHeader header] { get { @@ -619,8 +628,8 @@ public string this[HttpResponseHeader header] { /// Gets a collection of header names in the collection. /// /// - /// A that contains all header names - /// in the collection. + /// A that contains + /// all header names in the collection. /// public override NameObjectCollectionBase.KeysCollection Keys { get { @@ -653,11 +662,11 @@ private void addWithoutCheckingNameAndRestricted (string name, string value) private static int checkColonSeparated (string header) { - var i = header.IndexOf (':'); - if (i == -1) + var idx = header.IndexOf (':'); + if (idx == -1) throw new ArgumentException ("No colon could be found.", "header"); - return i; + return idx; } private static HttpHeaderType checkHeaderType (string name) @@ -686,7 +695,7 @@ private static string checkName (string name) private void checkRestricted (string name) { - if (!_internallyCreated && isRestricted (name, true)) + if (!_internallyUsed && isRestricted (name, true)) throw new ArgumentException ("This header must be modified with the appropiate property."); } @@ -722,9 +731,7 @@ private static string checkValue (string value) private static string convert (string key) { HttpHeaderInfo info; - return _headers.TryGetValue (key, out info) - ? info.Name - : String.Empty; + return _headers.TryGetValue (key, out info) ? info.Name : String.Empty; } private void doWithCheckingState ( @@ -854,8 +861,8 @@ internal string ToStringMultiValue (bool response) #region Protected Methods /// - /// Adds a header to the collection without checking whether the header is on the restricted - /// header list. + /// Adds a header to the collection without checking if the header is on + /// the restricted header list. /// /// /// A that represents the name of the header to add. @@ -922,7 +929,7 @@ protected void AddWithoutValidate (string headerName, string headerValue) /// public void Add (string header) { - if (header.IsNullOrEmpty ()) + if (header == null || header.Length == 0) throw new ArgumentNullException ("header"); var pos = checkColonSeparated (header); @@ -930,12 +937,12 @@ public void Add (string header) } /// - /// Adds the specified request with the specified - /// to the collection. + /// Adds the specified request with + /// the specified to the collection. /// /// - /// One of the enum values, represents the request header - /// to add. + /// One of the enum values, represents + /// the request header to add. /// /// /// A that represents the value of the header to add. @@ -955,8 +962,8 @@ public void Add (string header) /// The length of is greater than 65,535 characters. /// /// - /// The current instance doesn't allow the request - /// . + /// The current instance doesn't allow + /// the request . /// public void Add (HttpRequestHeader header, string value) { @@ -964,12 +971,12 @@ public void Add (HttpRequestHeader header, string value) } /// - /// Adds the specified response with the specified - /// to the collection. + /// Adds the specified response with + /// the specified to the collection. /// /// - /// One of the enum values, represents the response header - /// to add. + /// One of the enum values, represents + /// the response header to add. /// /// /// A that represents the value of the header to add. @@ -989,8 +996,8 @@ public void Add (HttpRequestHeader header, string value) /// The length of is greater than 65,535 characters. /// /// - /// The current instance doesn't allow the response - /// . + /// The current instance doesn't allow + /// the response . /// public void Add (HttpResponseHeader header, string value) { @@ -998,8 +1005,8 @@ public void Add (HttpResponseHeader header, string value) } /// - /// Adds a header with the specified and - /// to the collection. + /// Adds a header with the specified and + /// to the collection. /// /// /// A that represents the name of the header to add. @@ -1025,8 +1032,8 @@ public void Add (HttpResponseHeader header, string value) /// The length of is greater than 65,535 characters. /// /// - /// The current instance doesn't allow the header - /// . + /// The current instance doesn't allow + /// the header . /// public override void Add (string name, string value) { @@ -1063,8 +1070,8 @@ public override string Get (int index) /// Get the value of the header with the specified in the collection. /// /// - /// A that receives the value of the header if found; otherwise, - /// . + /// A that receives the value of the header if found; + /// otherwise, . /// /// /// A that represents the name of the header to find. @@ -1103,12 +1110,12 @@ public override string GetKey (int index) } /// - /// Gets an array of header values stored in the specified position - /// of the collection. + /// Gets an array of header values stored in the specified position of + /// the collection. /// /// - /// An array of that receives the header values if found; otherwise, - /// . + /// An array of that receives the header values if found; + /// otherwise, . /// /// /// An that represents the zero-based index of the header to find. @@ -1119,17 +1126,15 @@ public override string GetKey (int index) public override string[] GetValues (int index) { var vals = base.GetValues (index); - return vals != null && vals.Length > 0 - ? vals - : null; + return vals != null && vals.Length > 0 ? vals : null; } /// /// Gets an array of header values stored in the specified . /// /// - /// An array of that receives the header values if found; otherwise, - /// . + /// An array of that receives the header values if found; + /// otherwise, . /// /// /// A that represents the name of the header to find. @@ -1137,9 +1142,7 @@ public override string[] GetValues (int index) public override string[] GetValues (string header) { var vals = base.GetValues (header); - return vals != null && vals.Length > 0 - ? vals - : null; + return vals != null && vals.Length > 0 ? vals : null; } /// @@ -1163,7 +1166,7 @@ public override void GetObjectData ( if (serializationInfo == null) throw new ArgumentNullException ("serializationInfo"); - serializationInfo.AddValue ("InternallyCreated", _internallyCreated); + serializationInfo.AddValue ("InternallyUsed", _internallyUsed); serializationInfo.AddValue ("State", (int) _state); var cnt = Count; @@ -1233,15 +1236,15 @@ public override void OnDeserialization (object sender) /// Removes the specified request from the collection. /// /// - /// One of the enum values, represents the request header - /// to remove. + /// One of the enum values, represents + /// the request header to remove. /// /// /// is a restricted header. /// /// - /// The current instance doesn't allow the request - /// . + /// The current instance doesn't allow + /// the request . /// public void Remove (HttpRequestHeader header) { @@ -1252,15 +1255,15 @@ public void Remove (HttpRequestHeader header) /// Removes the specified response from the collection. /// /// - /// One of the enum values, represents the response header - /// to remove. + /// One of the enum values, represents + /// the response header to remove. /// /// /// is a restricted header. /// /// - /// The current instance doesn't allow the response - /// . + /// The current instance doesn't allow + /// the response . /// public void Remove (HttpResponseHeader header) { @@ -1288,8 +1291,8 @@ public void Remove (HttpResponseHeader header) /// /// /// - /// The current instance doesn't allow the header - /// . + /// The current instance doesn't allow + /// the header . /// public override void Remove (string name) { @@ -1300,8 +1303,8 @@ public override void Remove (string name) /// Sets the specified request to the specified value. /// /// - /// One of the enum values, represents the request header - /// to set. + /// One of the enum values, represents + /// the request header to set. /// /// /// A that represents the value of the request header to set. @@ -1321,8 +1324,8 @@ public override void Remove (string name) /// The length of is greater than 65,535 characters. /// /// - /// The current instance doesn't allow the request - /// . + /// The current instance doesn't allow + /// the request . /// public void Set (HttpRequestHeader header, string value) { @@ -1333,8 +1336,8 @@ public void Set (HttpRequestHeader header, string value) /// Sets the specified response to the specified value. /// /// - /// One of the enum values, represents the response header - /// to set. + /// One of the enum values, represents + /// the response header to set. /// /// /// A that represents the value of the response header to set. @@ -1354,8 +1357,8 @@ public void Set (HttpRequestHeader header, string value) /// The length of is greater than 65,535 characters. /// /// - /// The current instance doesn't allow the response - /// . + /// The current instance doesn't allow + /// the response . /// public void Set (HttpResponseHeader header, string value) { @@ -1389,8 +1392,8 @@ public void Set (HttpResponseHeader header, string value) /// The length of is greater than 65,535 characters. /// /// - /// The current instance doesn't allow the header - /// . + /// The current instance doesn't allow + /// the header . /// public override void Set (string name, string value) { From d8b5ae4ff1434e0091684abd1712ccc398d53517 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 15 Jun 2015 15:22:36 +0900 Subject: [PATCH 0007/6294] Modified a bit for the description of WebHeaderCollection.cs --- websocket-sharp/Net/WebHeaderCollection.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 650fe57ba..d831dcc39 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -2,7 +2,7 @@ /* * WebHeaderCollection.cs * - * This code is derived from System.Net.WebHeaderCollection.cs of Mono + * This code is derived from WebHeaderCollection.cs (System.Net) of Mono * (http://www.mono-project.com). * * The MIT License From dc9b2ae4888721503242db2ad1a0d5d0ff6c638e Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 15 Jun 2015 15:25:59 +0900 Subject: [PATCH 0008/6294] Modified a bit for WebHeaderCollection.cs, into the year 2015 --- websocket-sharp/Net/WebHeaderCollection.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index d831dcc39..8423d2f17 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -9,7 +9,7 @@ * * Copyright (c) 2003 Ximian, Inc. (http://www.ximian.com) * Copyright (c) 2007 Novell, Inc. (http://www.novell.com) - * Copyright (c) 2012-2014 sta.blockhead + * Copyright (c) 2012-2015 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From 0c610dd41f9c56e4f861bf3a7f5dbf3af49e1f97 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 16 Jun 2015 21:37:55 +0900 Subject: [PATCH 0009/6294] Refactored HttpListenerResponse.cs --- websocket-sharp/Net/HttpListenerResponse.cs | 205 ++++++++------------ websocket-sharp/Net/ResponseStream.cs | 4 +- 2 files changed, 84 insertions(+), 125 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index 7570f20fc..c0b011ff1 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -56,6 +56,7 @@ public sealed class HttpListenerResponse : IDisposable #region Private Fields private bool _chunked; + private bool _closeConnection; private Encoding _contentEncoding; private long _contentLength; private bool _contentLengthSet; @@ -79,7 +80,6 @@ public sealed class HttpListenerResponse : IDisposable internal HttpListenerResponse (HttpListenerContext context) { _context = context; - _headers = new WebHeaderCollection (); _keepAlive = true; _statusCode = 200; _statusDescription = "OK"; @@ -92,7 +92,11 @@ internal HttpListenerResponse (HttpListenerContext context) internal bool CloseConnection { get { - return _headers["Connection"] == "close"; + return _closeConnection; + } + + set { + _closeConnection = value; } } @@ -171,12 +175,12 @@ public long ContentLength64 { /// /// A that represents the value of the Content-Type entity-header. /// - /// - /// The value specified for a set operation is empty. - /// /// /// The value specified for a set operation is . /// + /// + /// The value specified for a set operation is empty. + /// /// /// The response has already been sent. /// @@ -206,19 +210,12 @@ public string ContentType { /// /// A that contains the cookies sent with the response. /// - /// - /// The response has already been sent. - /// - /// - /// This object is closed. - /// public CookieCollection Cookies { get { return _cookies ?? (_cookies = new CookieCollection ()); } set { - checkDisposedOrHeadersSent (); _cookies = value; } } @@ -229,31 +226,18 @@ public CookieCollection Cookies { /// /// A that contains the headers sent to the client. /// - /// - /// The value specified for a set operation is . - /// /// - /// The headers has already been sent. + /// The value specified for a set operation isn't valid for a response. /// public WebHeaderCollection Headers { get { - return _headers; + return _headers ?? (_headers = new WebHeaderCollection (HttpHeaderType.Response, false)); } set { - /* - * "If you attempt to set a Content-Length, Keep-Alive, Transfer-Encoding, - * or WWW-Authenticate header using the Headers property, an exception - * will be thrown. Use the ContentLength64 or KeepAlive properties to set - * these headers. You cannot set the Transfer-Encoding or WWW-Authenticate - * headers manually." - */ - - // TODO: Check if this is marked readonly after the headers are sent. - - checkHeadersSent (); - if (value == null) - throw new ArgumentNullException ("value"); + if (value != null && value.State != HttpHeaderType.Response) + throw new InvalidOperationException ( + "The specified headers aren't valid for a response."); _headers = value; } @@ -305,13 +289,13 @@ public Stream OutputStream { /// /// A that represents the version used in the response. /// + /// + /// The value specified for a set operation is . + /// /// /// The value specified for a set operation doesn't have its Major property set to 1 or /// doesn't have its Minor property set to either 0 or 1. /// - /// - /// The value specified for a set operation is . - /// /// /// The response has already been sent. /// @@ -344,9 +328,6 @@ public Version ProtocolVersion { /// /// The value specified for a set operation is empty. /// - /// - /// The response has already been sent. - /// /// /// This object is closed. /// @@ -356,8 +337,8 @@ public string RedirectLocation { } set { - checkDisposedOrHeadersSent (); - if (value.Length == 0) + checkDisposed (); + if (value != null && value.Length == 0) throw new ArgumentException ("An empty string.", "value"); _location = value; @@ -397,12 +378,12 @@ public bool SendChunked { /// /// The response has already been sent. /// - /// - /// The value specified for a set operation is invalid. Valid values are between 100 and 999. - /// /// /// This object is closed. /// + /// + /// The value specified for a set operation is invalid. Valid values are between 100 and 999. + /// public int StatusCode { get { return _statusCode; @@ -424,6 +405,9 @@ public int StatusCode { /// /// A that represents the description of the status code. /// + /// + /// The value specified for a set operation is . + /// /// /// The response has already been sent. /// @@ -437,7 +421,10 @@ public string StatusDescription { set { checkDisposedOrHeadersSent (); - _statusDescription = value != null && value.Length > 0 + if (value == null) + throw new ArgumentNullException ("value"); + + _statusDescription = value.Length > 0 ? value : _statusCode.GetStatusDescription (); } @@ -479,12 +466,6 @@ private void checkDisposedOrHeadersSent () throw new InvalidOperationException ("Cannot be changed after the headers are sent."); } - private void checkHeadersSent () - { - if (_headersSent) - throw new InvalidOperationException ("Cannot be changed after the headers are sent."); - } - private void close (bool force) { _disposed = true; @@ -510,8 +491,9 @@ private IEnumerable findCookie (Cookie cookie) internal WebHeaderCollection WriteHeadersTo (MemoryStream destination, bool closing) { - var headers = new WebHeaderCollection (); - headers.Add (_headers); + var headers = new WebHeaderCollection (HttpHeaderType.Response, true); + if (_headers != null) + headers.Add (_headers); if (_contentType != null) { var type = _contentType.IndexOf ("charset=", StringComparison.Ordinal) == -1 && @@ -546,13 +528,13 @@ internal WebHeaderCollection WriteHeadersTo (MemoryStream destination, bool clos /* * 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 + * - 400 Bad Request + * - 408 Request Timeout + * - 411 Length Required + * - 413 Request Entity Too Large + * - 414 Request-Uri Too Long + * - 500 Internal Server Error + * - 503 Service Unavailable */ var closeConn = !_context.Request.KeepAlive || !_keepAlive || @@ -620,6 +602,9 @@ public void Abort () /// /// A that represents the value of the header to add. /// + /// + /// is or empty. + /// /// /// /// or contains invalid characters. @@ -631,30 +616,15 @@ public void Abort () /// is a restricted header name. /// /// - /// - /// is or empty. - /// /// /// The length of is greater than 65,535 characters. /// /// - /// - /// The response has already been sent. - /// - /// - /// -or- - /// - /// - /// The header cannot be allowed to add to the current headers. - /// - /// - /// - /// This object is closed. + /// The header cannot be allowed to add to the current headers. /// public void AddHeader (string name, string value) { - checkDisposedOrHeadersSent (); - _headers.Set (name, value); + Headers.Set (name, value); } /// @@ -666,15 +636,8 @@ public void AddHeader (string name, string value) /// /// is . /// - /// - /// The response has already been sent. - /// - /// - /// This object is closed. - /// public void AppendCookie (Cookie cookie) { - checkDisposedOrHeadersSent (); Cookies.Add (cookie); } @@ -688,6 +651,9 @@ public void AppendCookie (Cookie cookie) /// /// A that represents the value to append to the header. /// + /// + /// is or empty. + /// /// /// /// or contains invalid characters. @@ -699,30 +665,15 @@ public void AppendCookie (Cookie cookie) /// is a restricted header name. /// /// - /// - /// is or empty. - /// /// /// The length of is greater than 65,535 characters. /// /// - /// - /// The response has already been sent. - /// - /// - /// -or- - /// - /// - /// The current headers cannot allow the header to append a value. - /// - /// - /// - /// This object is closed. + /// The current headers cannot allow the header to append a value. /// public void AppendHeader (string name, string value) { - checkDisposedOrHeadersSent (); - _headers.Add (name, value); + Headers.Add (name, value); } /// @@ -781,24 +732,32 @@ public void Close (byte[] responseEntity, bool willBlock) } /// - /// Copies properties from the specified to this response. + /// Copies some properties from the specified to + /// this response. /// /// /// A to copy. /// - /// - /// The response has already been sent. - /// - /// - /// This object is closed. + /// + /// is . /// public void CopyFrom (HttpListenerResponse templateResponse) { - checkDisposedOrHeadersSent (); + if (templateResponse == null) + throw new ArgumentNullException ("templateResponse"); + + if (templateResponse._headers != null) { + if (_headers != null) + _headers.Clear (); + + Headers.Add (templateResponse._headers); + } + else if (_headers != null) { + _headers = null; + } - _headers.Clear (); - _headers.Add (templateResponse._headers); _contentLength = templateResponse._contentLength; + _contentLengthSet = templateResponse._contentLengthSet; _statusCode = templateResponse._statusCode; _statusDescription = templateResponse._statusDescription; _keepAlive = templateResponse._keepAlive; @@ -806,22 +765,29 @@ public void CopyFrom (HttpListenerResponse templateResponse) } /// - /// Configures the response to redirect the client's request to the specified - /// . + /// Configures the response to redirect the client's request to + /// the specified . /// /// /// A that represents the URL to redirect the client's request to. /// - /// - /// The response has already been sent. + /// + /// is . /// - /// - /// This object is closed. + /// + /// is empty. /// public void Redirect (string url) { - StatusCode = (int) HttpStatusCode.Redirect; + if (url == null) + throw new ArgumentNullException ("url"); + + if (url.Length == 0) + throw new ArgumentException ("An empty string.", "url"); + _location = url; + _statusCode = 302; + _statusDescription = "Found"; } /// @@ -830,21 +796,14 @@ public void Redirect (string url) /// /// A to set. /// - /// - /// already exists in the cookies and couldn't be replaced. - /// /// /// is . /// - /// - /// The response has already been sent. - /// - /// - /// This object is closed. + /// + /// already exists in the cookies and couldn't be replaced. /// public void SetCookie (Cookie cookie) { - checkDisposedOrHeadersSent (); if (cookie == null) throw new ArgumentNullException ("cookie"); diff --git a/websocket-sharp/Net/ResponseStream.cs b/websocket-sharp/Net/ResponseStream.cs index 250d2b9fa..ad3c760a3 100644 --- a/websocket-sharp/Net/ResponseStream.cs +++ b/websocket-sharp/Net/ResponseStream.cs @@ -130,7 +130,7 @@ private bool flush (bool closing) if (!_response.HeadersSent) { if (!flushHeaders (closing)) { if (closing) - _response.Headers.InternalSet ("Connection", "close", true); + _response.CloseConnection = true; return false; } @@ -181,7 +181,7 @@ private bool flushHeaders (bool closing) return false; _write (buff.GetBuffer (), (int) start, (int) len); - _response.Headers = headers; + _response.CloseConnection = headers["Connection"] == "close"; _response.HeadersSent = true; } From 9c4482e770cbc7d721b01b5ad6aa8cb95827af58 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 17 Jun 2015 21:33:59 +0900 Subject: [PATCH 0010/6294] Refactored a few for HttpListenerResponse.cs --- websocket-sharp/Net/HttpListenerResponse.cs | 32 +++++++++++++-------- 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index c0b011ff1..20d588133 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -372,8 +372,8 @@ public bool SendChunked { /// Gets or sets the HTTP status code returned to the client. /// /// - /// An that represents the status code for the response to the request. - /// The default value is . + /// An that represents the status code for the response to + /// the request. The default value is same as . /// /// /// The response has already been sent. @@ -382,7 +382,8 @@ public bool SendChunked { /// This object is closed. /// /// - /// The value specified for a set operation is invalid. Valid values are between 100 and 999. + /// The value specified for a set operation is invalid. Valid values are + /// between 100 and 999 inclusive. /// public int StatusCode { get { @@ -392,7 +393,8 @@ public int StatusCode { set { checkDisposedOrHeadersSent (); if (value < 100 || value > 999) - throw new System.Net.ProtocolViolationException ("A value isn't between 100 and 999."); + throw new System.Net.ProtocolViolationException ( + "A value isn't between 100 and 999 inclusive."); _statusCode = value; _statusDescription = value.GetStatusDescription (); @@ -403,10 +405,13 @@ public int StatusCode { /// Gets or sets the description of the HTTP status code returned to the client. /// /// - /// A that represents the description of the status code. + /// A that represents the description of the status code. The default + /// value is the RFC 2616 + /// description for the property value, + /// or if an RFC 2616 description doesn't exist. /// - /// - /// The value specified for a set operation is . + /// + /// The value specified for a set operation contains invalid characters. /// /// /// The response has already been sent. @@ -421,12 +426,15 @@ public string StatusDescription { set { checkDisposedOrHeadersSent (); - if (value == null) - throw new ArgumentNullException ("value"); + if (value == null || value.Length == 0) { + _statusDescription = _statusCode.GetStatusDescription (); + return; + } + + if (!value.IsText () || value.IndexOfAny (new[] { '\r', '\n' }) > -1) + throw new ArgumentException ("Contains invalid characters.", "value"); - _statusDescription = value.Length > 0 - ? value - : _statusCode.GetStatusDescription (); + _statusDescription = value; } } From d9d35a6527dec734a0f213fbb29a422092399f17 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 18 Jun 2015 23:08:08 +0900 Subject: [PATCH 0011/6294] Refactored a few for HttpListenerResponse.cs --- websocket-sharp/Net/HttpListenerResponse.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index 20d588133..4084703da 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -785,8 +785,15 @@ public void CopyFrom (HttpListenerResponse templateResponse) /// /// is empty. /// + /// + /// The response has already been sent. + /// + /// + /// This object is closed. + /// public void Redirect (string url) { + checkDisposedOrHeadersSent (); if (url == null) throw new ArgumentNullException ("url"); From 78aa91c115d64d6007ce8f59262d944639589c72 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 19 Jun 2015 17:26:59 +0900 Subject: [PATCH 0012/6294] Refactored a few for HttpListenerResponse.cs --- websocket-sharp/Net/HttpListenerResponse.cs | 41 +++++++++++++++++++-- 1 file changed, 38 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index 4084703da..21ff83bc2 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -326,7 +326,15 @@ public Version ProtocolVersion { /// A that represents the value of the Location response-header. /// /// - /// The value specified for a set operation is empty. + /// + /// The value specified for a set operation is empty. + /// + /// + /// -or- + /// + /// + /// The value specified for a set operation isn't an absolute URL. + /// /// /// /// This object is closed. @@ -338,9 +346,18 @@ public string RedirectLocation { set { checkDisposed (); - if (value != null && value.Length == 0) + if (value == null) { + _location = null; + return; + } + + if (value.Length == 0) throw new ArgumentException ("An empty string.", "value"); + Uri uri = null; + if (!value.MaybeUri () || !Uri.TryCreate (value, UriKind.Absolute, out uri)) + throw new ArgumentException ("Not an absolute URL.", "value"); + _location = value; } } @@ -776,6 +793,12 @@ public void CopyFrom (HttpListenerResponse templateResponse) /// Configures the response to redirect the client's request to /// the specified . /// + /// + /// This method sets the property to + /// , the property to + /// 302, and the property to + /// "Found". + /// /// /// A that represents the URL to redirect the client's request to. /// @@ -783,7 +806,15 @@ public void CopyFrom (HttpListenerResponse templateResponse) /// is . /// /// - /// is empty. + /// + /// is empty. + /// + /// + /// -or- + /// + /// + /// isn't an absolute URL. + /// /// /// /// The response has already been sent. @@ -800,6 +831,10 @@ public void Redirect (string url) if (url.Length == 0) throw new ArgumentException ("An empty string.", "url"); + Uri uri = null; + if (!url.MaybeUri () || !Uri.TryCreate (url, UriKind.Absolute, out uri)) + throw new ArgumentException ("Not an absolute URL.", "url"); + _location = url; _statusCode = 302; _statusDescription = "Found"; From 0ecbca86e9ba9b250952234dc163a4bae38c1949 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 20 Jun 2015 16:59:16 +0900 Subject: [PATCH 0013/6294] Refactored a few for HttpListenerResponse.cs --- websocket-sharp/Net/HttpListenerResponse.cs | 29 +++------------------ 1 file changed, 4 insertions(+), 25 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index 21ff83bc2..89f2d5f12 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -323,18 +323,11 @@ public Version ProtocolVersion { /// Gets or sets the URL to which the client is redirected to locate a requested resource. /// /// - /// A that represents the value of the Location response-header. + /// A that represents the value of the Location response-header, + /// or if no redirect location is specified. /// /// - /// - /// The value specified for a set operation is empty. - /// - /// - /// -or- - /// - /// - /// The value specified for a set operation isn't an absolute URL. - /// + /// The value specified for a set operation isn't an absolute URL. /// /// /// This object is closed. @@ -351,9 +344,6 @@ public string RedirectLocation { return; } - if (value.Length == 0) - throw new ArgumentException ("An empty string.", "value"); - Uri uri = null; if (!value.MaybeUri () || !Uri.TryCreate (value, UriKind.Absolute, out uri)) throw new ArgumentException ("Not an absolute URL.", "value"); @@ -806,15 +796,7 @@ public void CopyFrom (HttpListenerResponse templateResponse) /// is . /// /// - /// - /// is empty. - /// - /// - /// -or- - /// - /// - /// isn't an absolute URL. - /// + /// isn't an absolute URL. /// /// /// The response has already been sent. @@ -828,9 +810,6 @@ public void Redirect (string url) if (url == null) throw new ArgumentNullException ("url"); - if (url.Length == 0) - throw new ArgumentException ("An empty string.", "url"); - Uri uri = null; if (!url.MaybeUri () || !Uri.TryCreate (url, UriKind.Absolute, out uri)) throw new ArgumentException ("Not an absolute URL.", "url"); From 9ad62f6a5f9f1963550b6cf7d6eab73560693ec3 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 21 Jun 2015 16:46:58 +0900 Subject: [PATCH 0014/6294] Refactored a few for HttpListenerResponse.cs --- websocket-sharp/Net/HttpListenerResponse.cs | 25 ++++++--------------- 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index 89f2d5f12..d46291438 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -121,9 +121,6 @@ internal bool HeadersSent { /// A that represents the encoding for the entity body data, /// or if no encoding is specified. /// - /// - /// The response has already been sent. - /// /// /// This object is closed. /// @@ -133,17 +130,16 @@ public Encoding ContentEncoding { } set { - checkDisposedOrHeadersSent (); + checkDisposed (); _contentEncoding = value; } } /// - /// Gets or sets the size of the entity body data included in the response. + /// Gets or sets the number of bytes in the entity body data included in the response. /// /// /// A that represents the value of the Content-Length entity-header. - /// The value is a number of bytes in the entity body data. /// /// /// The value specified for a set operation is less than zero. @@ -173,17 +169,13 @@ public long ContentLength64 { /// Gets or sets the media type of the entity body included in the response. /// /// - /// A that represents the value of the Content-Type entity-header. + /// A that represents the media type of the entity body, + /// or if no media type is specified. This value is + /// used for the value of the Content-Type entity-header. /// - /// - /// The value specified for a set operation is . - /// /// /// The value specified for a set operation is empty. /// - /// - /// The response has already been sent. - /// /// /// This object is closed. /// @@ -193,11 +185,8 @@ public string ContentType { } set { - checkDisposedOrHeadersSent (); - if (value == null) - throw new ArgumentNullException ("value"); - - if (value.Length == 0) + checkDisposed (); + if (value != null && value.Length == 0) throw new ArgumentException ("An empty string.", "value"); _contentType = value; From 86451853213e94ad21293c0fa232082fedec626c Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 22 Jun 2015 14:20:09 +0900 Subject: [PATCH 0015/6294] Refactored a few for HttpListenerResponse.cs --- websocket-sharp/Net/HttpListenerResponse.cs | 30 +++++++-------------- websocket-sharp/Net/ResponseStream.cs | 2 +- 2 files changed, 10 insertions(+), 22 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index d46291438..8ee98cd5e 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -55,11 +55,9 @@ public sealed class HttpListenerResponse : IDisposable { #region Private Fields - private bool _chunked; private bool _closeConnection; private Encoding _contentEncoding; private long _contentLength; - private bool _contentLengthSet; private string _contentType; private HttpListenerContext _context; private CookieCollection _cookies; @@ -69,6 +67,7 @@ public sealed class HttpListenerResponse : IDisposable private bool _keepAlive; private string _location; private ResponseStream _outputStream; + private bool _sendChunked; private int _statusCode; private string _statusDescription; private Version _version; @@ -160,7 +159,6 @@ public long ContentLength64 { if (value < 0) throw new ArgumentOutOfRangeException ("Less than zero.", "value"); - _contentLengthSet = true; _contentLength = value; } } @@ -345,7 +343,8 @@ public string RedirectLocation { /// Gets or sets a value indicating whether the response uses the chunked transfer encoding. /// /// - /// true if the response uses the chunked transfer encoding; otherwise, false. + /// true if the response uses the chunked transfer encoding; + /// otherwise, false. The default value is false. /// /// /// The response has already been sent. @@ -355,12 +354,12 @@ public string RedirectLocation { /// public bool SendChunked { get { - return _chunked; + return _sendChunked; } set { checkDisposedOrHeadersSent (); - _chunked = value; + _sendChunked = value; } } @@ -493,7 +492,7 @@ private IEnumerable findCookie (Cookie cookie) #region Internal Methods - internal WebHeaderCollection WriteHeadersTo (MemoryStream destination, bool closing) + internal WebHeaderCollection WriteHeadersTo (MemoryStream destination) { var headers = new WebHeaderCollection (HttpHeaderType.Response, true); if (_headers != null) @@ -515,19 +514,9 @@ internal WebHeaderCollection WriteHeadersTo (MemoryStream destination, bool clos if (headers["Date"] == null) headers.InternalSet ("Date", DateTime.UtcNow.ToString ("r", prov), true); - if (!_chunked) { - if (!_contentLengthSet && closing) { - _contentLengthSet = true; - _contentLength = 0; - } - - if (_contentLengthSet) - headers.InternalSet ("Content-Length", _contentLength.ToString (prov), true); - else if (_context.Request.ProtocolVersion > HttpVersion.Version10) - _chunked = true; - } - - if (_chunked) + if (!_sendChunked) + headers.InternalSet ("Content-Length", _contentLength.ToString (prov), true); + else headers.InternalSet ("Transfer-Encoding", "chunked", true); /* @@ -761,7 +750,6 @@ public void CopyFrom (HttpListenerResponse templateResponse) } _contentLength = templateResponse._contentLength; - _contentLengthSet = templateResponse._contentLengthSet; _statusCode = templateResponse._statusCode; _statusDescription = templateResponse._statusDescription; _keepAlive = templateResponse._keepAlive; diff --git a/websocket-sharp/Net/ResponseStream.cs b/websocket-sharp/Net/ResponseStream.cs index ad3c760a3..ef69645c2 100644 --- a/websocket-sharp/Net/ResponseStream.cs +++ b/websocket-sharp/Net/ResponseStream.cs @@ -171,7 +171,7 @@ private void flushBody (bool closing) private bool flushHeaders (bool closing) { using (var buff = new MemoryStream ()) { - var headers = _response.WriteHeadersTo (buff, closing); + var headers = _response.WriteHeadersTo (buff); var start = buff.Position; var len = buff.Length - start; if (len > 32768) From 846f3801573d0ad0258658d31ee573bdca44691a Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 22 Jun 2015 14:40:23 +0900 Subject: [PATCH 0016/6294] Refactored a few for ResponseStream.cs --- websocket-sharp/Net/ResponseStream.cs | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/websocket-sharp/Net/ResponseStream.cs b/websocket-sharp/Net/ResponseStream.cs index ef69645c2..85059a407 100644 --- a/websocket-sharp/Net/ResponseStream.cs +++ b/websocket-sharp/Net/ResponseStream.cs @@ -43,19 +43,15 @@ namespace WebSocketSharp.Net { - // FIXME: Does this buffer the response until close? - // Update: We send a single packet for the first non-chunked write. - // What happens when we set Content-Length to X and write X-1 bytes then close? - // What happens if we don't set Content-Length at all? internal class ResponseStream : Stream { #region Private Fields private MemoryStream _body; - private bool _chunked; private static readonly byte[] _crlf = new byte[] { 13, 10 }; private bool _disposed; private HttpListenerResponse _response; + private bool _sendChunked; private Stream _stream; private Action _write; private Action _writeBody; @@ -135,12 +131,12 @@ private bool flush (bool closing) return false; } - _chunked = _response.SendChunked; - _writeBody = _chunked ? _writeChunked : _write; + _sendChunked = _response.SendChunked; + _writeBody = _sendChunked ? _writeChunked : _write; } flushBody (closing); - if (closing && _chunked) { + if (closing && _sendChunked) { var last = getChunkSizeBytes (0, true); _write (last, 0, last.Length); } @@ -233,7 +229,7 @@ internal void Close (bool force) _response.Close (); } else { - if (_chunked) { + if (_sendChunked) { var last = getChunkSizeBytes (0, true); _write (last, 0, last.Length); } @@ -297,7 +293,7 @@ public override void EndWrite (IAsyncResult asyncResult) public override void Flush () { - if (!_disposed && (_chunked || _response.SendChunked)) + if (!_disposed && (_sendChunked || _response.SendChunked)) flush (false); } From 5e3814fa712e2bb8ab84e444fa08f6894a5e02c2 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 23 Jun 2015 11:01:19 +0900 Subject: [PATCH 0017/6294] Refactored a few for HttpConnection.cs --- websocket-sharp/Net/HttpConnection.cs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/websocket-sharp/Net/HttpConnection.cs b/websocket-sharp/Net/HttpConnection.cs index 03d055638..21ea5050f 100644 --- a/websocket-sharp/Net/HttpConnection.cs +++ b/websocket-sharp/Net/HttpConnection.cs @@ -262,8 +262,10 @@ private static void onRead (IAsyncResult asyncResult) len = (int) conn._requestBuffer.Length; } catch (Exception ex) { - if (conn._requestBuffer != null && conn._requestBuffer.Length > 0) + if (conn._requestBuffer != null && conn._requestBuffer.Length > 0) { conn.SendError (ex.Message, 400); + return; + } conn.close (); return; @@ -280,15 +282,11 @@ private static void onRead (IAsyncResult asyncResult) if (conn._context.HasError) { conn.SendError (); - conn.Close (true); - return; } if (!conn._listener.BindContext (conn._context)) { conn.SendError ("Invalid host", 400); - conn.Close (true); - return; } @@ -332,7 +330,7 @@ private bool processInput (byte[] data, int length) continue; if (_position > 32768) - _context.ErrorMessage = "Maximum total headers length exceeded"; + _context.ErrorMessage = "Headers too long"; _currentLine = null; return true; @@ -357,7 +355,7 @@ private bool processInput (byte[] data, int length) _position += nread; if (_position >= 32768) { - _context.ErrorMessage = "Maximum total headers length exceeded"; + _context.ErrorMessage = "Headers too long"; return true; } @@ -548,7 +546,7 @@ public void SendError (string message, int status) res.Close (entity, true); } catch { - // Response was already closed. + Close (true); } } } From 0516da098c915ec1e3128b63004ca1b38c7f3f92 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 24 Jun 2015 18:06:32 +0900 Subject: [PATCH 0018/6294] Fix for pull request #115, added null check for IPAddress parameter in the WebSocketServer (System.Net.IPAddress, int, bool) constructor --- websocket-sharp/Ext.cs | 5 +---- websocket-sharp/Server/WebSocketServer.cs | 19 ++++++++++++------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 77db7fb7a..5f3689de7 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1193,13 +1193,10 @@ public static bool IsHostOrder (this ByteOrder order) /// /// A to test. /// - /// - /// is . - /// public static bool IsLocal (this System.Net.IPAddress address) { if (address == null) - throw new ArgumentNullException ("address"); + return false; if (address.Equals (System.Net.IPAddress.Any) || System.Net.IPAddress.IsLoopback (address)) return true; diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 3c2b18d9a..99ff33c11 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -34,6 +34,7 @@ * - Juan Manuel Lallana * - Jonas Hovgaard * - Liryna + * - Rohan Singh */ #endregion @@ -225,8 +226,8 @@ public WebSocketServer (System.Net.IPAddress address, int port) /// , , and . /// /// - /// An instance initialized by this constructor listens for the incoming connection requests - /// on . + /// An instance initialized by this constructor listens for the incoming connection requests on + /// . /// /// /// A that represents the local IP address of the server. @@ -238,6 +239,9 @@ public WebSocketServer (System.Net.IPAddress address, int port) /// A that indicates providing a secure connection or not. /// (true indicates providing a secure connection.) /// + /// + /// is . + /// /// /// /// isn't a local IP address. @@ -249,19 +253,20 @@ public WebSocketServer (System.Net.IPAddress address, int port) /// Pair of and is invalid. /// /// - /// - /// is . - /// /// - /// isn't between 1 and 65535. + /// isn't between 1 and 65535 inclusive. /// public WebSocketServer (System.Net.IPAddress address, int port, bool secure) { + if (address == null) + throw new ArgumentNullException ("address"); + if (!address.IsLocal ()) throw new ArgumentException ("Not a local IP address: " + address, "address"); if (!port.IsPortNumber ()) - throw new ArgumentOutOfRangeException ("port", "Not between 1 and 65535: " + port); + throw new ArgumentOutOfRangeException ( + "port", "Not between 1 and 65535 inclusive: " + port); if ((port == 80 && secure) || (port == 443 && !secure)) throw new ArgumentException ( From 7559c5c8f27d8006e693ffdf77661ce24973a851 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 25 Jun 2015 17:17:05 +0900 Subject: [PATCH 0019/6294] Fix for pull request #115, refactored a few for HttpConnection.cs --- websocket-sharp/Net/HttpConnection.cs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Net/HttpConnection.cs b/websocket-sharp/Net/HttpConnection.cs index 21ea5050f..3527731ed 100644 --- a/websocket-sharp/Net/HttpConnection.cs +++ b/websocket-sharp/Net/HttpConnection.cs @@ -41,6 +41,7 @@ /* * Contributors: * - Liryna + * - Rohan Singh */ #endregion @@ -535,14 +536,11 @@ public void SendError (string message, int status) else content.Append (""); - var enc = res.ContentEncoding; - if (enc == null) { - enc = Encoding.UTF8; - res.ContentEncoding = enc; - } - + var enc = Encoding.UTF8; var entity = enc.GetBytes (content.ToString ()); + res.ContentEncoding = enc; res.ContentLength64 = entity.LongLength; + res.Close (entity, true); } catch { From 3764de92e7775e31aa507e2e8a7a82b7387f51ec Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 26 Jun 2015 17:20:35 +0900 Subject: [PATCH 0020/6294] Refactored a few for WebSocketServer.cs --- websocket-sharp/Server/WebSocketServer.cs | 114 ++++++++++++---------- 1 file changed, 62 insertions(+), 52 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 99ff33c11..f74163587 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -84,22 +84,22 @@ public class WebSocketServer /// Initializes a new instance of the class. /// /// - /// An instance initialized by this constructor listens for the incoming connection requests - /// on port 80. + /// An instance initialized by this constructor listens for the incoming + /// connection requests on port 80. /// public WebSocketServer () - : this (System.Net.IPAddress.Any, 80, false) { + init (System.Net.IPAddress.Any, 80, false); } /// - /// Initializes a new instance of the class with the specified - /// . + /// Initializes a new instance of the class with + /// the specified . /// /// /// - /// An instance initialized by this constructor listens for the incoming connection requests - /// on . + /// An instance initialized by this constructor listens for the incoming + /// connection requests on . /// /// /// If is 443, that instance provides a secure connection. @@ -109,37 +109,49 @@ public WebSocketServer () /// An that represents the port number on which to listen. /// /// - /// isn't between 1 and 65535. + /// isn't between 1 and 65535 inclusive. /// public WebSocketServer (int port) - : this (System.Net.IPAddress.Any, port, port == 443) { + if (!port.IsPortNumber ()) + throw new ArgumentOutOfRangeException ( + "port", "Not between 1 and 65535 inclusive: " + port); + + init (System.Net.IPAddress.Any, port, port == 443); } /// - /// Initializes a new instance of the class with the specified - /// WebSocket URL. + /// Initializes a new instance of the class with + /// the specified WebSocket URL. /// /// /// - /// An instance initialized by this constructor listens for the incoming connection requests - /// on the port in . + /// An instance initialized by this constructor listens for the incoming + /// connection requests on the port in . /// /// - /// If doesn't include a port, either port 80 or 443 is used on which - /// to listen. It's determined by the scheme (ws or wss) in . + /// If doesn't include a port, either port 80 or 443 is used on + /// which to listen. It's determined by the scheme (ws or wss) in . /// (Port 80 if the scheme is ws.) /// /// /// /// A that represents the WebSocket URL of the server. /// - /// - /// is invalid. - /// /// /// is . /// + /// + /// + /// is empty. + /// + /// + /// -or- + /// + /// + /// is invalid. + /// + /// public WebSocketServer (string url) { if (url == null) @@ -148,27 +160,26 @@ public WebSocketServer (string url) if (url.Length == 0) throw new ArgumentException ("An empty string.", "url"); + Uri uri; string msg; - if (!tryCreateUri (url, out _uri, out msg)) + if (!tryCreateUri (url, out uri, out msg)) throw new ArgumentException (msg, "url"); - _address = _uri.DnsSafeHost.ToIPAddress (); - if (_address == null || !_address.IsLocal ()) + var addr = uri.DnsSafeHost.ToIPAddress (); + if (!addr.IsLocal ()) throw new ArgumentException ("The host part isn't a local host name: " + url, "url"); - _port = _uri.Port; - _secure = _uri.Scheme == "wss"; - - init (); + _uri = uri; + init (addr, uri.Port, uri.Scheme == "wss"); } /// - /// Initializes a new instance of the class with the specified - /// and . + /// Initializes a new instance of the class with + /// the specified and . /// /// - /// An instance initialized by this constructor listens for the incoming connection requests - /// on . + /// An instance initialized by this constructor listens for the incoming + /// connection requests on . /// /// /// An that represents the port number on which to listen. @@ -181,7 +192,7 @@ public WebSocketServer (string url) /// Pair of and is invalid. /// /// - /// isn't between 1 and 65535. + /// isn't between 1 and 65535 inclusive. /// public WebSocketServer (int port, bool secure) : this (System.Net.IPAddress.Any, port, secure) @@ -189,13 +200,13 @@ public WebSocketServer (int port, bool secure) } /// - /// Initializes a new instance of the class with the specified - /// and . + /// Initializes a new instance of the class with + /// the specified and . /// /// /// - /// An instance initialized by this constructor listens for the incoming connection requests - /// on . + /// An instance initialized by this constructor listens for the incoming + /// connection requests on . /// /// /// If is 443, that instance provides a secure connection. @@ -207,14 +218,14 @@ public WebSocketServer (int port, bool secure) /// /// An that represents the port number on which to listen. /// - /// - /// isn't a local IP address. - /// /// /// is . /// + /// + /// isn't a local IP address. + /// /// - /// isn't between 1 and 65535. + /// isn't between 1 and 65535 inclusive. /// public WebSocketServer (System.Net.IPAddress address, int port) : this (address, port, port == 443) @@ -222,12 +233,13 @@ public WebSocketServer (System.Net.IPAddress address, int port) } /// - /// Initializes a new instance of the class with the specified - /// , , and . + /// Initializes a new instance of the class with + /// the specified , , and + /// . /// /// - /// An instance initialized by this constructor listens for the incoming connection requests on - /// . + /// An instance initialized by this constructor listens for the incoming + /// connection requests on . /// /// /// A that represents the local IP address of the server. @@ -272,12 +284,7 @@ public WebSocketServer (System.Net.IPAddress address, int port, bool secure) throw new ArgumentException ( String.Format ("An invalid pair of 'port' and 'secure': {0}, {1}", port, secure)); - _address = address; - _port = port; - _secure = secure; - _uri = "/".ToUri (); - - init (); + init (address, port, secure); } #endregion @@ -599,13 +606,16 @@ private string checkIfCertificateExists () : null; } - private void init () + private void init (System.Net.IPAddress address, int port, bool secure) { + _address = address; + _port = port; + _secure = secure; + _listener = new TcpListener (address, port); + _authSchemes = AuthenticationSchemes.Anonymous; - _listener = new TcpListener (_address, _port); _logger = new Logger (); _services = new WebSocketServiceManager (_logger); - _state = ServerState.Ready; _sync = new object (); } @@ -617,7 +627,7 @@ private void processRequest (TcpListenerWebSocketContext context) return; } - if (_uri.IsAbsoluteUri) { + if (_uri != null && _uri.IsAbsoluteUri) { var actual = uri.DnsSafeHost; var expected = _uri.DnsSafeHost; if (Uri.CheckHostName (actual) == UriHostNameType.Dns && From 72b7cafe4f045cfa7812ceb60f8834dde930e052 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 27 Jun 2015 17:39:19 +0900 Subject: [PATCH 0021/6294] Refactored a few for WebSocketServer.cs --- websocket-sharp/Server/WebSocketServer.cs | 98 +++++++++++------------ 1 file changed, 49 insertions(+), 49 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index f74163587..20358ae28 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -62,7 +62,7 @@ public class WebSocketServer private System.Net.IPAddress _address; private AuthenticationSchemes _authSchemes; - private Func _credentialsFinder; + private Func _credFinder; private TcpListener _listener; private Logger _logger; private int _port; @@ -234,8 +234,8 @@ public WebSocketServer (System.Net.IPAddress address, int port) /// /// Initializes a new instance of the class with - /// the specified , , and - /// . + /// the specified , , + /// and . /// /// /// An instance initialized by this constructor listens for the incoming @@ -352,8 +352,8 @@ public bool IsSecure { } /// - /// Gets or sets a value indicating whether the server cleans up the inactive sessions - /// periodically. + /// Gets or sets a value indicating whether the server cleans up + /// the inactive sessions periodically. /// /// /// true if the server cleans up the inactive sessions every 60 seconds; @@ -408,8 +408,8 @@ public int Port { /// Gets or sets the name of the realm associated with the server. /// /// - /// A that represents the name of the realm. - /// The default value is "SECRET AREA". + /// A that represents the name of the realm. The default value is + /// "SECRET AREA". /// public string Realm { get { @@ -428,12 +428,12 @@ public string Realm { } /// - /// Gets or sets a value indicating whether the server is allowed to be bound to an address - /// that is already in use. + /// Gets or sets a value indicating whether the server is allowed to be bound to + /// an address that is already in use. /// /// - /// If you would like to resolve to wait for socket in TIME_WAIT state, you should set - /// this property to true. + /// If you would like to resolve to wait for socket in TIME_WAIT state, + /// you should set this property to true. /// /// /// true if the server is allowed to be bound to an address that is already in use; @@ -460,8 +460,8 @@ public bool ReuseAddress { /// optionally the client for secure connection. /// /// - /// A that represents the configuration used - /// to authenticate the server and optionally the client for secure connection. + /// A that represents the configuration used to + /// authenticate the server and optionally the client for secure connection. /// public ServerSslConfiguration SslConfiguration { get { @@ -484,13 +484,13 @@ public ServerSslConfiguration SslConfiguration { /// authenticate a client. /// /// - /// A Func<, > delegate that - /// references the method(s) used to find the credentials. The default value is a function - /// that only returns . + /// A Func<, > delegate that + /// references the method(s) used to find the credentials. The default value is a function that + /// only returns . /// public Func UserCredentialsFinder { get { - return _credentialsFinder ?? (_credentialsFinder = identity => null); + return _credFinder ?? (_credFinder = identity => null); } set { @@ -500,7 +500,7 @@ public Func UserCredentialsFinder { return; } - _credentialsFinder = value; + _credFinder = value; } } @@ -669,7 +669,7 @@ private void receiveRequest () }); } catch (SocketException ex) { - _logger.Warn ("Receiving has been stopped.\nreason: " + ex.Message); + _logger.Warn ("Receiving has been stopped.\n reason: " + ex.Message); break; } catch (Exception ex) { @@ -719,27 +719,6 @@ private static bool tryCreateUri (string uriString, out Uri result, out string m #region Public Methods - /// - /// Adds a WebSocket service with the specified behavior and . - /// - /// - /// This method converts to URL-decoded string, - /// and removes '/' from tail end of . - /// - /// - /// A that represents the absolute path to the service to add. - /// - /// - /// The type of the behavior of the service to add. The TBehaviorWithNew must inherit - /// the class, and must have a public parameterless - /// constructor. - /// - public void AddWebSocketService (string path) - where TBehaviorWithNew : WebSocketBehavior, new () - { - AddWebSocketService (path, () => new TBehaviorWithNew ()); - } - /// /// Adds a WebSocket service with the specified behavior, , /// and . @@ -758,9 +737,9 @@ public void AddWebSocketService (string path) /// A that represents the absolute path to the service to add. /// /// - /// A Func<T> delegate that references the method used to initialize a new specified - /// typed instance (a new - /// instance). + /// A Func<T> delegate that references the method used to initialize + /// a new specified typed instance (a new + /// instance). /// /// /// The type of the behavior of the service to add. The TBehavior must inherit @@ -780,6 +759,27 @@ public void AddWebSocketService (string path, Func initial _services.Add (path, initializer); } + /// + /// Adds a WebSocket service with the specified behavior and . + /// + /// + /// This method converts to URL-decoded string, + /// and removes '/' from tail end of . + /// + /// + /// A that represents the absolute path to the service to add. + /// + /// + /// The type of the behavior of the service to add. The TBehaviorWithNew must inherit + /// the class, and must have a public parameterless + /// constructor. + /// + public void AddWebSocketService (string path) + where TBehaviorWithNew : WebSocketBehavior, new () + { + AddWebSocketService (path, () => new TBehaviorWithNew ()); + } + /// /// Removes the WebSocket service with the specified . /// @@ -845,8 +845,8 @@ public void Stop () } /// - /// Stops receiving the WebSocket connection requests with the specified - /// and . + /// Stops receiving the WebSocket connection requests with + /// the specified and . /// /// /// A that represents the status code indicating the reason for the stop. @@ -879,12 +879,12 @@ public void Stop (ushort code, string reason) } /// - /// Stops receiving the WebSocket connection requests with the specified - /// and . + /// Stops receiving the WebSocket connection requests with + /// the specified and . /// /// - /// One of the enum values, represents the status code - /// indicating the reason for the stop. + /// One of the enum values, represents the status code indicating + /// the reason for the stop. /// /// /// A that represents the reason for the stop. From 85dc704cc68be743acb796ac6e5a89812f3f16b8 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 28 Jun 2015 16:59:39 +0900 Subject: [PATCH 0022/6294] Refactored a few for Ext.cs --- websocket-sharp/Ext.cs | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 5f3689de7..e1afb2f1c 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -808,22 +808,24 @@ internal static string TrimEndSlash (this string value) } /// - /// Tries to create a for WebSocket with the specified - /// . + /// Tries to create a for WebSocket with + /// the specified . /// /// /// true if a is successfully created; otherwise, false. /// /// - /// A that represents the WebSocket URL to try. + /// A that represents a WebSocket URL to try. /// /// - /// When this method returns, a that represents the WebSocket URL - /// if is valid; otherwise, . + /// When this method returns, a that represents + /// a WebSocket URL if is valid; + /// otherwise, . /// /// - /// When this method returns, a that represents the error message - /// if is invalid; otherwise, . + /// When this method returns, a that represents + /// an error message if is invalid; + /// otherwise, . /// internal static bool TryCreateWebSocketUri ( this string uriString, out Uri result, out string message) @@ -831,7 +833,7 @@ internal static bool TryCreateWebSocketUri ( result = null; var uri = uriString.ToUri (); - if (!uri.IsAbsoluteUri) { + if (uri == null || !uri.IsAbsoluteUri) { message = "Not an absolute URI: " + uriString; return false; } @@ -1719,11 +1721,11 @@ public static string ToString (this T[] array, string separator) /// public static Uri ToUri (this string uriString) { - Uri res; - return Uri.TryCreate ( - uriString, uriString.MaybeUri () ? UriKind.Absolute : UriKind.Relative, out res) - ? res - : null; + Uri ret; + Uri.TryCreate ( + uriString, uriString.MaybeUri () ? UriKind.Absolute : UriKind.Relative, out ret); + + return ret; } /// From cb8d1e75f654885c5148a85464cfdaa8d2414273 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 29 Jun 2015 16:20:00 +0900 Subject: [PATCH 0023/6294] Refactored a few for HttpServer.cs --- websocket-sharp/Server/HttpServer.cs | 154 ++++++++++++++------------- 1 file changed, 79 insertions(+), 75 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index c078e549c..6ff46a77e 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -80,18 +80,18 @@ public class HttpServer /// An instance initialized by this constructor listens for the incoming requests on port 80. /// public HttpServer () - : this (80, false) { + init ("*", 80, false); } /// - /// Initializes a new instance of the class with the specified - /// . + /// Initializes a new instance of the class with + /// the specified . /// /// /// - /// An instance initialized by this constructor listens for the incoming requests - /// on . + /// An instance initialized by this constructor listens for the incoming + /// requests on . /// /// /// If is 443, that instance provides a secure connection. @@ -101,20 +101,24 @@ public HttpServer () /// An that represents the port number on which to listen. /// /// - /// isn't between 1 and 65535. + /// isn't between 1 and 65535 inclusive. /// public HttpServer (int port) - : this (port, port == 443) { + if (!port.IsPortNumber ()) + throw new ArgumentOutOfRangeException ( + "port", "Not between 1 and 65535 inclusive: " + port); + + init ("*", port, port == 443); } /// - /// Initializes a new instance of the class with the specified - /// and . + /// Initializes a new instance of the class with + /// the specified and . /// /// - /// An instance initialized by this constructor listens for the incoming requests - /// on . + /// An instance initialized by this constructor listens for the incoming + /// requests on . /// /// /// An that represents the port number on which to listen. @@ -127,30 +131,19 @@ public HttpServer (int port) /// Pair of and is invalid. /// /// - /// isn't between 1 and 65535. + /// isn't between 1 and 65535 inclusive. /// public HttpServer (int port, bool secure) { if (!port.IsPortNumber ()) - throw new ArgumentOutOfRangeException ("port", "Not between 1 and 65535: " + port); + throw new ArgumentOutOfRangeException ( + "port", "Not between 1 and 65535 inclusive: " + port); if ((port == 80 && secure) || (port == 443 && !secure)) throw new ArgumentException ( String.Format ("An invalid pair of 'port' and 'secure': {0}, {1}", port, secure)); - _port = port; - _secure = secure; - _listener = new HttpListener (); - _logger = _listener.Log; - _services = new WebSocketServiceManager (_logger); - _state = ServerState.Ready; - _sync = new object (); - - var os = Environment.OSVersion; - _windows = os.Platform != PlatformID.Unix && os.Platform != PlatformID.MacOSX; - - var pref = String.Format ("http{0}://*:{1}/", _secure ? "s" : "", _port); - _listener.Prefixes.Add (pref); + init ("*", port, secure); } #endregion @@ -206,8 +199,8 @@ public bool IsSecure { } /// - /// Gets or sets a value indicating whether the server cleans up the inactive sessions - /// in the WebSocket services periodically. + /// Gets or sets a value indicating whether the server cleans up + /// the inactive sessions in the WebSocket services periodically. /// /// /// true if the server cleans up the inactive sessions every 60 seconds; @@ -262,8 +255,8 @@ public int Port { /// Gets or sets the name of the realm associated with the server. /// /// - /// A that represents the name of the realm. - /// The default value is "SECRET AREA". + /// A that represents the name of the realm. The default value is + /// "SECRET AREA". /// public string Realm { get { @@ -282,12 +275,12 @@ public string Realm { } /// - /// Gets or sets a value indicating whether the server is allowed to be bound to an address - /// that is already in use. + /// Gets or sets a value indicating whether the server is allowed to be bound to + /// an address that is already in use. /// /// - /// If you would like to resolve to wait for socket in TIME_WAIT state, you should set - /// this property to true. + /// If you would like to resolve to wait for socket in TIME_WAIT state, + /// you should set this property to true. /// /// /// true if the server is allowed to be bound to an address that is already in use; @@ -318,9 +311,7 @@ public bool ReuseAddress { /// public string RootPath { get { - return _rootPath != null && _rootPath.Length > 0 - ? _rootPath - : (_rootPath = "./Public"); + return _rootPath != null && _rootPath.Length > 0 ? _rootPath : (_rootPath = "./Public"); } set { @@ -339,8 +330,8 @@ public string RootPath { /// optionally the client for secure connection. /// /// - /// A that represents the configuration used - /// to authenticate the server and optionally the client for secure connection. + /// A that represents the configuration used to + /// authenticate the server and optionally the client for secure connection. /// public ServerSslConfiguration SslConfiguration { get { @@ -363,9 +354,9 @@ public ServerSslConfiguration SslConfiguration { /// authenticate a client. /// /// - /// A Func<, > delegate that - /// references the method(s) used to find the credentials. The default value is a function - /// that only returns . + /// A Func<, > delegate that + /// references the method(s) used to find the credentials. The default value is a function that + /// only returns . /// public Func UserCredentialsFinder { get { @@ -498,9 +489,24 @@ private string checkIfCertificateExists () return null; } - return !(usr || port) - ? "The secure connection requires a server certificate." - : null; + return !(usr || port) ? "The secure connection requires a server certificate." : null; + } + + private void init (string hostname, int port, bool secure) + { + _port = port; + _secure = secure; + + _listener = new HttpListener (); + _listener.Prefixes.Add ( + String.Format ("http{0}://{1}:{2}/", secure ? "s" : "", hostname, port)); + + _logger = _listener.Log; + _services = new WebSocketServiceManager (_logger); + _sync = new object (); + + var os = Environment.OSVersion; + _windows = os.Platform != PlatformID.Unix && os.Platform != PlatformID.MacOSX; } private void processRequest (HttpListenerContext context) @@ -567,7 +573,7 @@ private void receiveRequest () }); } catch (HttpListenerException ex) { - _logger.Warn ("Receiving has been stopped.\nreason: " + ex.Message); + _logger.Warn ("Receiving has been stopped.\n reason: " + ex.Message); break; } catch (Exception ex) { @@ -598,27 +604,6 @@ private void stopReceiving (int millisecondsTimeout) #region Public Methods - /// - /// Adds a WebSocket service with the specified behavior and . - /// - /// - /// This method converts to URL-decoded string, - /// and removes '/' from tail end of . - /// - /// - /// A that represents the absolute path to the service to add. - /// - /// - /// The type of the behavior of the service to add. The TBehaviorWithNew must inherit - /// the class, and must have a public parameterless - /// constructor. - /// - public void AddWebSocketService (string path) - where TBehaviorWithNew : WebSocketBehavior, new () - { - AddWebSocketService (path, () => new TBehaviorWithNew ()); - } - /// /// Adds the WebSocket service with the specified behavior, , /// and . @@ -637,9 +622,9 @@ public void AddWebSocketService (string path) /// A that represents the absolute path to the service to add. /// /// - /// A Func<T> delegate that references the method used to initialize a new specified - /// typed instance (a new - /// instance). + /// A Func<T> delegate that references the method used to initialize + /// a new specified typed instance (a new + /// instance). /// /// /// The type of the behavior of the service to add. The TBehavior must inherit @@ -659,6 +644,27 @@ public void AddWebSocketService (string path, Func initial _services.Add (path, initializer); } + /// + /// Adds a WebSocket service with the specified behavior and . + /// + /// + /// This method converts to URL-decoded string, + /// and removes '/' from tail end of . + /// + /// + /// A that represents the absolute path to the service to add. + /// + /// + /// The type of the behavior of the service to add. The TBehaviorWithNew must inherit + /// the class, and must have a public parameterless + /// constructor. + /// + public void AddWebSocketService (string path) + where TBehaviorWithNew : WebSocketBehavior, new () + { + AddWebSocketService (path, () => new TBehaviorWithNew ()); + } + /// /// Gets the contents of the file with the specified . /// @@ -675,9 +681,7 @@ public byte[] GetFile (string path) if (_windows) path = path.Replace ("/", "\\"); - return File.Exists (path) - ? File.ReadAllBytes (path) - : null; + return File.Exists (path) ? File.ReadAllBytes (path) : null; } /// @@ -784,8 +788,8 @@ public void Stop (ushort code, string reason) /// used to stop the WebSocket services. /// /// - /// One of the enum values, represents the status code - /// indicating the reason for the stop. + /// One of the enum values, represents the status code indicating + /// the reason for the stop. /// /// /// A that represents the reason for the stop. From 2078bfad5ab09852abb8c99633ef67812be1d77d Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 30 Jun 2015 15:43:00 +0900 Subject: [PATCH 0024/6294] Fix for pull request #133, allow port 443 with non secure scheme, and allow port 80 with secure scheme --- websocket-sharp/Ext.cs | 43 ++++++++++------------- websocket-sharp/Server/HttpServer.cs | 13 +------ websocket-sharp/Server/WebSocketServer.cs | 29 ++++----------- 3 files changed, 27 insertions(+), 58 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index e1afb2f1c..10699f7ae 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -40,6 +40,7 @@ /* * Contributors: * - Liryna + * - Nikola Kovacevic */ #endregion @@ -818,14 +819,12 @@ internal static string TrimEndSlash (this string value) /// A that represents a WebSocket URL to try. /// /// - /// When this method returns, a that represents - /// a WebSocket URL if is valid; - /// otherwise, . + /// When this method returns, a that represents a WebSocket URL, + /// or if is invalid. /// /// - /// When this method returns, a that represents - /// an error message if is invalid; - /// otherwise, . + /// When this method returns, a that represents an error message, + /// or if is valid. /// internal static bool TryCreateWebSocketUri ( this string uriString, out Uri result, out string message) @@ -839,7 +838,7 @@ internal static bool TryCreateWebSocketUri ( } var schm = uri.Scheme; - if (schm != "ws" && schm != "wss") { + if (!(schm == "ws" || schm == "wss")) { message = "The scheme part isn't 'ws' or 'wss': " + uriString; return false; } @@ -850,26 +849,22 @@ internal static bool TryCreateWebSocketUri ( } var port = uri.Port; - if (port > 0) { - if (port > 65535) { - message = "The port part is greater than 65535: " + uriString; - return false; - } - - if ((schm == "ws" && port == 443) || (schm == "wss" && port == 80)) { - message = "An invalid pair of scheme and port: " + uriString; - return false; - } - } - else { - uri = new Uri ( - String.Format ( - "{0}://{1}:{2}{3}", schm, uri.Host, schm == "ws" ? 80 : 443, uri.PathAndQuery)); + if (port > 65535) { + message = "The port part is greater than 65535: " + uriString; + return false; } - result = uri; - message = String.Empty; + result = port > 0 + ? uri + : new Uri ( + String.Format ( + "{0}://{1}:{2}{3}", + schm, + uri.Host, + schm == "ws" ? 80 : 443, + uri.PathAndQuery)); + message = String.Empty; return true; } diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 6ff46a77e..d98bc32db 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -104,12 +104,8 @@ public HttpServer () /// isn't between 1 and 65535 inclusive. /// public HttpServer (int port) + : this (port, port == 443) { - if (!port.IsPortNumber ()) - throw new ArgumentOutOfRangeException ( - "port", "Not between 1 and 65535 inclusive: " + port); - - init ("*", port, port == 443); } /// @@ -127,9 +123,6 @@ public HttpServer (int port) /// A that indicates providing a secure connection or not. /// (true indicates providing a secure connection.) /// - /// - /// Pair of and is invalid. - /// /// /// isn't between 1 and 65535 inclusive. /// @@ -139,10 +132,6 @@ public HttpServer (int port, bool secure) throw new ArgumentOutOfRangeException ( "port", "Not between 1 and 65535 inclusive: " + port); - if ((port == 80 && secure) || (port == 443 && !secure)) - throw new ArgumentException ( - String.Format ("An invalid pair of 'port' and 'secure': {0}, {1}", port, secure)); - init ("*", port, secure); } diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 20358ae28..12b1fc8cc 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -112,12 +112,8 @@ public WebSocketServer () /// isn't between 1 and 65535 inclusive. /// public WebSocketServer (int port) + : this (port, port == 443) { - if (!port.IsPortNumber ()) - throw new ArgumentOutOfRangeException ( - "port", "Not between 1 and 65535 inclusive: " + port); - - init (System.Net.IPAddress.Any, port, port == 443); } /// @@ -188,15 +184,16 @@ public WebSocketServer (string url) /// A that indicates providing a secure connection or not. /// (true indicates providing a secure connection.) /// - /// - /// Pair of and is invalid. - /// /// /// isn't between 1 and 65535 inclusive. /// public WebSocketServer (int port, bool secure) - : this (System.Net.IPAddress.Any, port, secure) { + if (!port.IsPortNumber ()) + throw new ArgumentOutOfRangeException ( + "port", "Not between 1 and 65535 inclusive: " + port); + + init (System.Net.IPAddress.Any, port, secure); } /// @@ -255,15 +252,7 @@ public WebSocketServer (System.Net.IPAddress address, int port) /// is . /// /// - /// - /// isn't a local IP address. - /// - /// - /// -or- - /// - /// - /// Pair of and is invalid. - /// + /// isn't a local IP address. /// /// /// isn't between 1 and 65535 inclusive. @@ -280,10 +269,6 @@ public WebSocketServer (System.Net.IPAddress address, int port, bool secure) throw new ArgumentOutOfRangeException ( "port", "Not between 1 and 65535 inclusive: " + port); - if ((port == 80 && secure) || (port == 443 && !secure)) - throw new ArgumentException ( - String.Format ("An invalid pair of 'port' and 'secure': {0}, {1}", port, secure)); - init (address, port, secure); } From dbe7e0b17c3f5274e8b75dcf24c1ccac02d90c71 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 1 Jul 2015 01:35:13 +0900 Subject: [PATCH 0025/6294] Refactored a bit for WebSocket.cs --- websocket-sharp/WebSocket.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index db1e3b178..4dc519dcf 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -162,6 +162,9 @@ internal WebSocket (TcpListenerWebSocketContext context, string protocol) /// Each value of must be a token defined in /// RFC 2616. /// + /// + /// is . + /// /// /// /// is invalid. @@ -173,9 +176,6 @@ internal WebSocket (TcpListenerWebSocketContext context, string protocol) /// is invalid. /// /// - /// - /// is . - /// public WebSocket (string url, params string[] protocols) { if (url == null) From d3410a3ac43e4af51a13e31c6141c24bae44c012 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 2 Jul 2015 17:54:16 +0900 Subject: [PATCH 0026/6294] Refactored a few for WebSocket.cs --- websocket-sharp/WebSocket.cs | 44 ++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 25 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 4dc519dcf..5ca128420 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -509,9 +509,7 @@ public ClientSslConfiguration SslConfiguration { /// public Uri Url { get { - return _client - ? _uri - : _context.RequestUri; + return _client ? _uri : _context.RequestUri; } } @@ -897,9 +895,7 @@ private HttpResponse createHandshakeResponse () private MessageEventArgs dequeueFromMessageEventQueue () { lock (_forMessageEventQueue) - return _messageEventQueue.Count > 0 - ? _messageEventQueue.Dequeue () - : null; + return _messageEventQueue.Count > 0 ? _messageEventQueue.Dequeue () : null; } // As client @@ -1223,8 +1219,7 @@ private bool send (Opcode opcode, Stream stream, bool compressed) else buff = new byte[rem]; - return stream.Read (buff, 0, rem) == rem && - send (Fin.Final, Opcode.Cont, buff, compressed); + return stream.Read (buff, 0, rem) == rem && send (Fin.Final, Opcode.Cont, buff, compressed); } private bool send (Fin fin, Opcode opcode, byte[] data, bool compressed) @@ -1767,8 +1762,7 @@ public void Close () /// the allowable range of the close status code. /// /// - /// A that represents the status code indicating the reason for - /// the close. + /// A that represents the status code indicating the reason for the close. /// public void Close (ushort code) { @@ -1946,8 +1940,8 @@ public void CloseAsync (ushort code) /// This method doesn't wait for the close to be complete. /// /// - /// One of the enum values, represents - /// the status code indicating the reason for the close. + /// One of the enum values, represents the status code indicating + /// the reason for the close. /// public void CloseAsync (CloseStatusCode code) { @@ -2022,8 +2016,8 @@ public void CloseAsync (ushort code, string reason) /// /// /// - /// One of the enum values, represents - /// the status code indicating the reason for the close. + /// One of the enum values, represents the status code indicating + /// the reason for the close. /// /// /// A that represents the reason for the close. @@ -2331,8 +2325,8 @@ public void SendAsync (Stream stream, int length, Action completed) } /// - /// Sets an HTTP to send with the WebSocket connection request to - /// the server. + /// Sets an HTTP to send with + /// the WebSocket connection request to the server. /// /// /// A that represents the cookie to send. @@ -2361,12 +2355,12 @@ public void SetCookie (Cookie cookie) /// A that represents the user name used to authenticate. /// /// - /// A that represents the password for - /// used to authenticate. + /// A that represents the password for used + /// to authenticate. /// /// - /// true if the sends the Basic authentication credentials - /// with the first connection request to the server; otherwise, false. + /// true if the sends the Basic authentication credentials with + /// the first connection request to the server; otherwise, false. /// public void SetCredentials (string username, string password, bool preAuth) { @@ -2401,9 +2395,9 @@ public void SetCredentials (string username, string password, bool preAuth) } /// - /// Sets an HTTP Proxy server URL to connect through, and if necessary, a pair of - /// and for the proxy server - /// authentication (Basic/Digest). + /// Sets an HTTP Proxy server URL to connect through, and if necessary, + /// a pair of and for + /// the proxy server authentication (Basic/Digest). /// /// /// A that represents the proxy server URL to connect through. @@ -2412,8 +2406,8 @@ public void SetCredentials (string username, string password, bool preAuth) /// A that represents the user name used to authenticate. /// /// - /// A that represents the password for - /// used to authenticate. + /// A that represents the password for used + /// to authenticate. /// public void SetProxy (string url, string username, string password) { From 987a02e5948efb259c64804dcc2fab9fa36d4c57 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 3 Jul 2015 18:03:40 +0900 Subject: [PATCH 0027/6294] Refactored a few for HttpListenerRequest.cs --- websocket-sharp/Net/HttpListenerRequest.cs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index 4fb04ecd3..766501ad5 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -62,14 +62,14 @@ public sealed class HttpListenerRequest private bool _chunked; private Encoding _contentEncoding; private long _contentLength; - private bool _contentLengthWasSet; + private bool _contentLengthSet; private HttpListenerContext _context; private CookieCollection _cookies; private WebHeaderCollection _headers; private Guid _identifier; private Stream _inputStream; private bool _keepAlive; - private bool _keepAliveWasSet; + private bool _keepAliveSet; private string _method; private NameValueCollection _queryString; private Uri _referer; @@ -78,7 +78,7 @@ public sealed class HttpListenerRequest private string[] _userLanguages; private Version _version; private bool _websocketRequest; - private bool _websocketRequestWasSet; + private bool _websocketRequestSet; #endregion @@ -276,13 +276,13 @@ public bool IsSecureConnection { /// public bool IsWebSocketRequest { get { - if (!_websocketRequestWasSet) { + if (!_websocketRequestSet) { _websocketRequest = _method == "GET" && _version > HttpVersion.Version10 && _headers.Contains ("Upgrade", "websocket") && _headers.Contains ("Connection", "Upgrade"); - _websocketRequestWasSet = true; + _websocketRequestSet = true; } return _websocketRequest; @@ -297,13 +297,13 @@ public bool IsWebSocketRequest { /// public bool KeepAlive { get { - if (!_keepAliveWasSet) { + if (!_keepAliveSet) { string keepAlive; _keepAlive = _version > HttpVersion.Version10 || _headers.Contains ("Connection", "keep-alive") || ((keepAlive = _headers["Keep-Alive"]) != null && keepAlive != "closed"); - _keepAliveWasSet = true; + _keepAliveSet = true; } return _keepAlive; @@ -505,7 +505,7 @@ internal void AddHeader (string header) long len; if (Int64.TryParse (val, out len) && len >= 0) { _contentLength = len; - _contentLengthWasSet = true; + _contentLengthSet = true; } else { _context.ErrorMessage = "Invalid Content-Length header"; @@ -558,7 +558,7 @@ internal void FinishInitialization () } } - if (!_chunked && !_contentLengthWasSet) { + if (!_chunked && !_contentLengthSet) { var method = _method.ToLower (); if (method == "post" || method == "put") { _context.ErrorMessage = String.Empty; From 5728b471895d57b55760bdaf3939ede92746b25b Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 4 Jul 2015 22:37:23 +0900 Subject: [PATCH 0028/6294] Refactored a few for HttpListenerRequest.cs --- websocket-sharp/Net/HttpListenerRequest.cs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index 766501ad5..04ccd80d1 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -109,8 +109,9 @@ internal HttpListenerRequest (HttpListenerContext context) /// Gets the media types which are acceptable for the response. /// /// - /// An array of that contains the media type names in the Accept - /// request-header, or if the request didn't include an Accept header. + /// An array of that contains the media type names in + /// the Accept request-header, or if the request didn't include + /// the Accept header. /// public string[] AcceptTypes { get { @@ -135,8 +136,8 @@ public int ClientCertificateError { /// /// /// A that represents the encoding for the entity body data, - /// or if the request didn't include the information - /// about the encoding. + /// or if the request didn't include the information about + /// the encoding. /// public Encoding ContentEncoding { get { @@ -145,11 +146,11 @@ public Encoding ContentEncoding { } /// - /// Gets the size of the entity body data included in the request. + /// Gets the number of bytes in the entity body data included in the request. /// /// - /// A that represents the value of the Content-Length entity-header. The - /// value is a number of bytes in the entity body data. -1 if the size isn't known. + /// A that represents the value of the Content-Length entity-header, + /// or -1 if the value isn't known. /// public long ContentLength64 { get { From df9c8b1e74156a5f7afaee43cd7ee43c59fee6cc Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 5 Jul 2015 16:20:22 +0900 Subject: [PATCH 0029/6294] Refactored a few for HttpRequest.cs --- websocket-sharp/HttpRequest.cs | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/websocket-sharp/HttpRequest.cs b/websocket-sharp/HttpRequest.cs index cfced5c8c..d8c9abd76 100644 --- a/websocket-sharp/HttpRequest.cs +++ b/websocket-sharp/HttpRequest.cs @@ -26,6 +26,13 @@ */ #endregion +#region Contributors +/* + * Contributors: + * - David Burhans + */ +#endregion + using System; using System.Collections.Specialized; using System.IO; @@ -41,7 +48,7 @@ internal class HttpRequest : HttpBase private string _method; private string _uri; private bool _websocketRequest; - private bool _websocketRequestWasSet; + private bool _websocketRequestSet; #endregion @@ -91,14 +98,14 @@ public string HttpMethod { public bool IsWebSocketRequest { get { - if (!_websocketRequestWasSet) { + if (!_websocketRequestSet) { var headers = Headers; _websocketRequest = _method == "GET" && ProtocolVersion > HttpVersion.Version10 && headers.Contains ("Upgrade", "websocket") && headers.Contains ("Connection", "Upgrade"); - _websocketRequestWasSet = true; + _websocketRequestSet = true; } return _websocketRequest; @@ -129,16 +136,18 @@ internal static HttpRequest CreateConnectRequest (Uri uri) internal static HttpRequest CreateWebSocketRequest (Uri uri) { var req = new HttpRequest ("GET", uri.PathAndQuery); - var headers = req.Headers; + + // Only includes a port number in the Host header value if it's non-default. + // See: https://tools.ietf.org/html/rfc6455#page-17 + var port = uri.Port; + var schm = uri.Scheme; + headers["Host"] = (port == 80 && schm == "ws") || (port == 443 && schm == "wss") + ? uri.DnsSafeHost + : uri.Authority; + headers["Upgrade"] = "websocket"; headers["Connection"] = "Upgrade"; - var port = uri.Port; - var scheme = uri.Scheme; - bool isDefaultPort = (port == 80 && scheme == "ws") || (port == 443 && scheme == "wss"); - // only include port in host header if it is non-default - // https://tools.ietf.org/html/rfc6455#page-17 - headers["Host"] = isDefaultPort ? uri.DnsSafeHost : uri.Authority; return req; } From 1998a535a490988f58088a2f7386916fc5ff22fb Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 5 Jul 2015 16:26:24 +0900 Subject: [PATCH 0030/6294] Modified a bit for HttpRequest.cs, into the year 2015 --- websocket-sharp/HttpRequest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/HttpRequest.cs b/websocket-sharp/HttpRequest.cs index d8c9abd76..f9aa5cb33 100644 --- a/websocket-sharp/HttpRequest.cs +++ b/websocket-sharp/HttpRequest.cs @@ -4,7 +4,7 @@ * * The MIT License * - * Copyright (c) 2012-2014 sta.blockhead + * Copyright (c) 2012-2015 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From 4bc2c4d4f03c6f4c2ee84eff86b3125e182001c3 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 6 Jul 2015 17:14:11 +0900 Subject: [PATCH 0031/6294] Refactored a few for HttpListenerRequest.cs --- websocket-sharp/Net/HttpListenerRequest.cs | 40 +++++++++++----------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index 04ccd80d1..701128120 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -635,27 +635,27 @@ internal void SetRequestLine (string requestLine) /// Begins getting the client's X.509 v.3 certificate asynchronously. /// /// - /// This asynchronous operation must be completed by calling the - /// method. Typically, that method is invoked by the - /// delegate. + /// This asynchronous operation must be completed by calling + /// the method. Typically, + /// that method is invoked by the delegate. /// /// /// An that contains the status of the asynchronous operation. /// /// - /// An delegate that references the method(s) called when the - /// asynchronous operation completes. + /// An delegate that references the method(s) called when + /// the asynchronous operation completes. /// /// - /// An that contains a user defined object to pass to the - /// delegate. + /// An that contains a user defined object to pass to + /// the delegate. /// /// /// This method isn't implemented. /// public IAsyncResult BeginGetClientCertificate (AsyncCallback requestCallback, object state) { - // TODO: Not Implemented. + // TODO: Not implemented. throw new NotImplementedException (); } @@ -663,22 +663,22 @@ public IAsyncResult BeginGetClientCertificate (AsyncCallback requestCallback, ob /// Ends an asynchronous operation to get the client's X.509 v.3 certificate. /// /// - /// This method completes an asynchronous operation started by calling the - /// method. + /// This method completes an asynchronous operation started by calling + /// the method. /// /// /// A that contains the client's X.509 v.3 certificate. /// /// - /// An obtained by calling the - /// method. + /// An obtained by calling + /// the method. /// /// /// This method isn't implemented. /// public X509Certificate2 EndGetClientCertificate (IAsyncResult asyncResult) { - // TODO: Not Implemented. + // TODO: Not implemented. throw new NotImplementedException (); } @@ -693,24 +693,24 @@ public X509Certificate2 EndGetClientCertificate (IAsyncResult asyncResult) /// public X509Certificate2 GetClientCertificate () { - // TODO: Not Implemented. + // TODO: Not implemented. throw new NotImplementedException (); } /// - /// Returns a that represents the current - /// . + /// Returns a that represents + /// the current . /// /// /// A that represents the current . /// public override string ToString () { - var output = new StringBuilder (64); - output.AppendFormat ("{0} {1} HTTP/{2}\r\n", _method, _uri, _version); - output.Append (_headers.ToString ()); + var buff = new StringBuilder (64); + buff.AppendFormat ("{0} {1} HTTP/{2}\r\n", _method, _uri, _version); + buff.Append (_headers.ToString ()); - return output.ToString (); + return buff.ToString (); } #endregion From c10c9886ef7d95be5922c2b855e6ef16f85351d6 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 7 Jul 2015 17:31:33 +0900 Subject: [PATCH 0032/6294] Fix for pull request #115, added the HttpServer (System.Net.IPAddress, int, bool) constructor --- Example3/Program.cs | 3 +- websocket-sharp/Net/EndPointListener.cs | 6 +++- websocket-sharp/Server/HttpServer.cs | 44 +++++++++++++++++++++++++ 3 files changed, 51 insertions(+), 2 deletions(-) diff --git a/Example3/Program.cs b/Example3/Program.cs index e2b534d7e..7463a44d4 100644 --- a/Example3/Program.cs +++ b/Example3/Program.cs @@ -18,7 +18,8 @@ public static void Main (string[] args) * with the 'secure' parameter set to true. */ var httpsv = new HttpServer (4649); - //httpsv = new HttpServer (4649, true); + //var httpsv = new HttpServer (5963, true); + //var httpsv = new HttpServer (System.Net.IPAddress.Parse ("127.0.0.1"), 4649, false); #if DEBUG // To change the logging level. httpsv.Log.Level = LogLevel.Trace; diff --git a/websocket-sharp/Net/EndPointListener.cs b/websocket-sharp/Net/EndPointListener.cs index b3339661e..7bec84c6e 100644 --- a/websocket-sharp/Net/EndPointListener.cs +++ b/websocket-sharp/Net/EndPointListener.cs @@ -311,6 +311,8 @@ private HttpListener searchListener (Uri uri, out HttpListenerPrefix prefix) return null; var host = uri.Host; + var dns = Uri.CheckHostName (host) == UriHostNameType.Dns; + var port = uri.Port; var path = HttpUtility.UrlDecode (uri.AbsolutePath); var pathSlash = path[path.Length - 1] == '/' ? path : path + "/"; @@ -323,7 +325,9 @@ private HttpListener searchListener (Uri uri, out HttpListenerPrefix prefix) if (ppath.Length < bestLen) continue; - if (pref.Host != host || pref.Port != port) + var phost = pref.Host; + var pdns = Uri.CheckHostName (phost) == UriHostNameType.Dns; + if ((dns && pdns && phost != host) || pref.Port != port) continue; if (path.StartsWith (ppath) || pathSlash.StartsWith (ppath)) { diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index d98bc32db..5fc139fd2 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -40,6 +40,7 @@ using System.Collections.Generic; using System.Diagnostics; using System.IO; +using System.Net.Sockets; using System.Security.Cryptography.X509Certificates; using System.Security.Principal; using System.Threading; @@ -135,6 +136,49 @@ public HttpServer (int port, bool secure) init ("*", port, secure); } + /// + /// Initializes a new instance of the class with + /// the specified , , + /// and . + /// + /// + /// An instance initialized by this constructor listens for the incoming + /// connection requests on . + /// + /// + /// A that represents the local IP address of the server. + /// + /// + /// An that represents the port number on which to listen. + /// + /// + /// A that indicates providing a secure connection or not. + /// (true indicates providing a secure connection.) + /// + /// + /// is . + /// + /// + /// isn't a local IP address. + /// + /// + /// isn't between 1 and 65535 inclusive. + /// + public HttpServer (System.Net.IPAddress address, int port, bool secure) + { + if (address == null) + throw new ArgumentNullException ("address"); + + if (!address.IsLocal ()) + throw new ArgumentException ("Not a local IP address: " + address, "address"); + + if (!port.IsPortNumber ()) + throw new ArgumentOutOfRangeException ( + "port", "Not between 1 and 65535 inclusive: " + port); + + init (address.ToString (), port, secure); + } + #endregion #region Public Properties From d4fc8da7a88fe286322a1cec0cdf9a68e7402224 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 8 Jul 2015 15:00:38 +0900 Subject: [PATCH 0033/6294] Fix for pull request #115, added the HttpServer (System.Net.IPAddress, int) constructor --- Example3/Program.cs | 3 ++- websocket-sharp/Server/HttpServer.cs | 33 ++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/Example3/Program.cs b/Example3/Program.cs index 7463a44d4..d5ebcf9f7 100644 --- a/Example3/Program.cs +++ b/Example3/Program.cs @@ -19,7 +19,8 @@ public static void Main (string[] args) */ var httpsv = new HttpServer (4649); //var httpsv = new HttpServer (5963, true); - //var httpsv = new HttpServer (System.Net.IPAddress.Parse ("127.0.0.1"), 4649, false); + //var httpsv = new HttpServer (System.Net.IPAddress.Parse ("127.0.0.1"), 4649); + //var httpsv = new HttpServer (System.Net.IPAddress.Parse ("127.0.0.1"), 5963, true); #if DEBUG // To change the logging level. httpsv.Log.Level = LogLevel.Trace; diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 5fc139fd2..ffdf54892 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -136,6 +136,39 @@ public HttpServer (int port, bool secure) init ("*", port, secure); } + /// + /// Initializes a new instance of the class with + /// the specified and . + /// + /// + /// + /// An instance initialized by this constructor listens for the incoming + /// connection requests on . + /// + /// + /// If is 443, that instance provides a secure connection. + /// + /// + /// + /// A that represents the local IP address of the server. + /// + /// + /// An that represents the port number on which to listen. + /// + /// + /// is . + /// + /// + /// isn't a local IP address. + /// + /// + /// isn't between 1 and 65535 inclusive. + /// + public HttpServer (System.Net.IPAddress address, int port) + : this (address, port, port == 443) + { + } + /// /// Initializes a new instance of the class with /// the specified , , From 34de5b9ca424b95546f5e2c89fdc17f74d206552 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 9 Jul 2015 15:13:53 +0900 Subject: [PATCH 0034/6294] Refactored a few for HttpServer.cs --- websocket-sharp/Server/HttpServer.cs | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index ffdf54892..1a0aac290 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -33,6 +33,7 @@ * Contributors: * - Juan Manuel Lallana * - Liryna + * - Rohan Singh */ #endregion @@ -91,8 +92,8 @@ public HttpServer () /// /// /// - /// An instance initialized by this constructor listens for the incoming - /// requests on . + /// An instance initialized by this constructor listens for the incoming requests on + /// . /// /// /// If is 443, that instance provides a secure connection. @@ -114,8 +115,8 @@ public HttpServer (int port) /// the specified and . /// /// - /// An instance initialized by this constructor listens for the incoming - /// requests on . + /// An instance initialized by this constructor listens for the incoming requests on + /// . /// /// /// An that represents the port number on which to listen. @@ -142,8 +143,8 @@ public HttpServer (int port, bool secure) /// /// /// - /// An instance initialized by this constructor listens for the incoming - /// connection requests on . + /// An instance initialized by this constructor listens for the incoming requests on + /// and . /// /// /// If is 443, that instance provides a secure connection. @@ -175,8 +176,8 @@ public HttpServer (System.Net.IPAddress address, int port) /// and . /// /// - /// An instance initialized by this constructor listens for the incoming - /// connection requests on . + /// An instance initialized by this constructor listens for the incoming requests on + /// and . /// /// /// A that represents the local IP address of the server. From 96b684036ffc24b03ce6e0d6af9f2e0baf856924 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 10 Jul 2015 21:18:36 +0900 Subject: [PATCH 0035/6294] Refactored a few for WebSocketServer.cs --- websocket-sharp/Server/WebSocketServer.cs | 56 +++++++++++------------ 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 12b1fc8cc..a61551571 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -63,6 +63,8 @@ public class WebSocketServer private System.Net.IPAddress _address; private AuthenticationSchemes _authSchemes; private Func _credFinder; + private bool _dnsStyle; + private string _hostname; private TcpListener _listener; private Logger _logger; private int _port; @@ -74,7 +76,6 @@ public class WebSocketServer private ServerSslConfiguration _sslConfig; private volatile ServerState _state; private object _sync; - private Uri _uri; #endregion @@ -84,12 +85,12 @@ public class WebSocketServer /// Initializes a new instance of the class. /// /// - /// An instance initialized by this constructor listens for the incoming - /// connection requests on port 80. + /// An instance initialized by this constructor listens for the incoming connection requests on + /// port 80. /// public WebSocketServer () { - init (System.Net.IPAddress.Any, 80, false); + init (null, System.Net.IPAddress.Any, 80, false); } /// @@ -98,8 +99,8 @@ public WebSocketServer () /// /// /// - /// An instance initialized by this constructor listens for the incoming - /// connection requests on . + /// An instance initialized by this constructor listens for the incoming connection requests + /// on . /// /// /// If is 443, that instance provides a secure connection. @@ -122,8 +123,8 @@ public WebSocketServer (int port) /// /// /// - /// An instance initialized by this constructor listens for the incoming - /// connection requests on the port in . + /// An instance initialized by this constructor listens for the incoming connection requests + /// on the host name and port in . /// /// /// If doesn't include a port, either port 80 or 443 is used on @@ -161,12 +162,12 @@ public WebSocketServer (string url) if (!tryCreateUri (url, out uri, out msg)) throw new ArgumentException (msg, "url"); - var addr = uri.DnsSafeHost.ToIPAddress (); + var host = uri.DnsSafeHost; + var addr = host.ToIPAddress (); if (!addr.IsLocal ()) throw new ArgumentException ("The host part isn't a local host name: " + url, "url"); - _uri = uri; - init (addr, uri.Port, uri.Scheme == "wss"); + init (host, addr, uri.Port, uri.Scheme == "wss"); } /// @@ -174,8 +175,8 @@ public WebSocketServer (string url) /// the specified and . /// /// - /// An instance initialized by this constructor listens for the incoming - /// connection requests on . + /// An instance initialized by this constructor listens for the incoming connection requests on + /// . /// /// /// An that represents the port number on which to listen. @@ -193,7 +194,7 @@ public WebSocketServer (int port, bool secure) throw new ArgumentOutOfRangeException ( "port", "Not between 1 and 65535 inclusive: " + port); - init (System.Net.IPAddress.Any, port, secure); + init (null, System.Net.IPAddress.Any, port, secure); } /// @@ -202,8 +203,8 @@ public WebSocketServer (int port, bool secure) /// /// /// - /// An instance initialized by this constructor listens for the incoming - /// connection requests on . + /// An instance initialized by this constructor listens for the incoming connection requests + /// on and . /// /// /// If is 443, that instance provides a secure connection. @@ -235,8 +236,8 @@ public WebSocketServer (System.Net.IPAddress address, int port) /// and . /// /// - /// An instance initialized by this constructor listens for the incoming - /// connection requests on . + /// An instance initialized by this constructor listens for the incoming connection requests on + /// and . /// /// /// A that represents the local IP address of the server. @@ -269,7 +270,7 @@ public WebSocketServer (System.Net.IPAddress address, int port, bool secure) throw new ArgumentOutOfRangeException ( "port", "Not between 1 and 65535 inclusive: " + port); - init (address, port, secure); + init (null, address, port, secure); } #endregion @@ -591,14 +592,16 @@ private string checkIfCertificateExists () : null; } - private void init (System.Net.IPAddress address, int port, bool secure) + private void init (string hostname, System.Net.IPAddress address, int port, bool secure) { + _hostname = hostname ?? address.ToString (); _address = address; _port = port; _secure = secure; - _listener = new TcpListener (address, port); _authSchemes = AuthenticationSchemes.Anonymous; + _dnsStyle = Uri.CheckHostName (hostname) == UriHostNameType.Dns; + _listener = new TcpListener (address, port); _logger = new Logger (); _services = new WebSocketServiceManager (_logger); _sync = new object (); @@ -607,17 +610,14 @@ private void init (System.Net.IPAddress address, int port, bool secure) private void processRequest (TcpListenerWebSocketContext context) { var uri = context.RequestUri; - if (uri == null) { + if (uri == null || uri.Port != _port) { context.Close (HttpStatusCode.BadRequest); return; } - if (_uri != null && _uri.IsAbsoluteUri) { - var actual = uri.DnsSafeHost; - var expected = _uri.DnsSafeHost; - if (Uri.CheckHostName (actual) == UriHostNameType.Dns && - Uri.CheckHostName (expected) == UriHostNameType.Dns && - actual != expected) { + if (_dnsStyle) { + var hostname = uri.DnsSafeHost; + if (Uri.CheckHostName (hostname) == UriHostNameType.Dns && hostname != _hostname) { context.Close (HttpStatusCode.NotFound); return; } From 3c0fa929a1179e757423aa8847bf54136df771f0 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 11 Jul 2015 16:29:09 +0900 Subject: [PATCH 0036/6294] Refactored a few for Ext.cs --- websocket-sharp/Ext.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 10699f7ae..38305b68e 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -776,11 +776,10 @@ internal static string ToExtensionString ( return String.Format ("{0}; {1}", m, parameters.ToString ("; ")); } - internal static System.Net.IPAddress ToIPAddress (this string hostNameOrAddress) + internal static System.Net.IPAddress ToIPAddress (this string hostnameOrAddress) { try { - var addrs = System.Net.Dns.GetHostAddresses (hostNameOrAddress); - return addrs[0]; + return System.Net.Dns.GetHostAddresses (hostnameOrAddress)[0]; } catch { return null; From d2dc6ff959a903c915e4eefa140a974a00f0edd1 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 12 Jul 2015 16:56:02 +0900 Subject: [PATCH 0037/6294] Fix for pull request #115, added the Address property to the HttpServer class --- websocket-sharp/Server/HttpServer.cs | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 1a0aac290..aa0a12340 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -60,6 +60,8 @@ public class HttpServer { #region Private Fields + private System.Net.IPAddress _address; + private string _hostname; private HttpListener _listener; private Logger _logger; private int _port; @@ -83,7 +85,7 @@ public class HttpServer /// public HttpServer () { - init ("*", 80, false); + init ("*", System.Net.IPAddress.Any, 80, false); } /// @@ -134,7 +136,7 @@ public HttpServer (int port, bool secure) throw new ArgumentOutOfRangeException ( "port", "Not between 1 and 65535 inclusive: " + port); - init ("*", port, secure); + init ("*", System.Net.IPAddress.Any, port, secure); } /// @@ -210,13 +212,25 @@ public HttpServer (System.Net.IPAddress address, int port, bool secure) throw new ArgumentOutOfRangeException ( "port", "Not between 1 and 65535 inclusive: " + port); - init (address.ToString (), port, secure); + init (null, address, port, secure); } #endregion #region Public Properties + /// + /// Gets the local IP address of the server. + /// + /// + /// A that represents the local IP address of the server. + /// + public System.Net.IPAddress Address { + get { + return _address; + } + } + /// /// Gets or sets the scheme used to authenticate the clients. /// @@ -559,14 +573,16 @@ private string checkIfCertificateExists () return !(usr || port) ? "The secure connection requires a server certificate." : null; } - private void init (string hostname, int port, bool secure) + private void init (string hostname, System.Net.IPAddress address, int port, bool secure) { + _hostname = hostname ?? address.ToString (); + _address = address; _port = port; _secure = secure; _listener = new HttpListener (); _listener.Prefixes.Add ( - String.Format ("http{0}://{1}:{2}/", secure ? "s" : "", hostname, port)); + String.Format ("http{0}://{1}:{2}/", secure ? "s" : "", _hostname, port)); _logger = _listener.Log; _services = new WebSocketServiceManager (_logger); From 68b9fb0106acbd7d8bc582522fd8aeb74ed169a9 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 13 Jul 2015 18:15:09 +0900 Subject: [PATCH 0038/6294] Refactored a few for EndPointListener.cs --- websocket-sharp/Net/EndPointListener.cs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/EndPointListener.cs b/websocket-sharp/Net/EndPointListener.cs index 7bec84c6e..4e1e92ccd 100644 --- a/websocket-sharp/Net/EndPointListener.cs +++ b/websocket-sharp/Net/EndPointListener.cs @@ -312,7 +312,6 @@ private HttpListener searchListener (Uri uri, out HttpListenerPrefix prefix) var host = uri.Host; var dns = Uri.CheckHostName (host) == UriHostNameType.Dns; - var port = uri.Port; var path = HttpUtility.UrlDecode (uri.AbsolutePath); var pathSlash = path[path.Length - 1] == '/' ? path : path + "/"; @@ -325,11 +324,15 @@ private HttpListener searchListener (Uri uri, out HttpListenerPrefix prefix) if (ppath.Length < bestLen) continue; - var phost = pref.Host; - var pdns = Uri.CheckHostName (phost) == UriHostNameType.Dns; - if ((dns && pdns && phost != host) || pref.Port != port) + if (pref.Port != port) continue; + if (dns) { + var phost = pref.Host; + if (Uri.CheckHostName (phost) == UriHostNameType.Dns && phost != host) + continue; + } + if (path.StartsWith (ppath) || pathSlash.StartsWith (ppath)) { bestLen = ppath.Length; bestMatch = _prefixes[pref]; From 77472f073ff7c96463055d6119d7ba2950246298 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 14 Jul 2015 17:20:15 +0900 Subject: [PATCH 0039/6294] Modified a bit for echotest.js --- Example3/Public/Js/echotest.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Example3/Public/Js/echotest.js b/Example3/Public/Js/echotest.js index b6054455e..3f99991d1 100644 --- a/Example3/Public/Js/echotest.js +++ b/Example3/Public/Js/echotest.js @@ -7,7 +7,7 @@ */ var url = "ws://localhost:4649/Echo"; -//var url = "wss://localhost:4649/Echo"; +//var url = "wss://localhost:5963/Echo"; var output; function init () { From ad41099180d551755ccbf9567cf2f4bd74e601a1 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 15 Jul 2015 17:38:06 +0900 Subject: [PATCH 0040/6294] Modified a bit for Program.cs --- Example2/Program.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Example2/Program.cs b/Example2/Program.cs index 12a0106f6..9c608ccde 100644 --- a/Example2/Program.cs +++ b/Example2/Program.cs @@ -13,13 +13,15 @@ public static void Main (string[] args) { /* Create a new instance of the WebSocketServer class. * - * If you would like to provide the secure connection, you should create the instance - * with the 'secure' parameter set to true, or the wss scheme WebSocket URL. + * If you would like to provide the secure connection, you should create the instance with + * the 'secure' parameter set to true, or the wss scheme WebSocket URL. */ var wssv = new WebSocketServer (4649); - //var wssv = new WebSocketServer (4649, true); + //var wssv = new WebSocketServer (5963, true); + //var wssv = new WebSocketServer (System.Net.IPAddress.Parse ("127.0.0.1"), 4649); + //var wssv = new WebSocketServer (System.Net.IPAddress.Parse ("127.0.0.1"), 5963, true); //var wssv = new WebSocketServer ("ws://localhost:4649"); - //var wssv = new WebSocketServer ("wss://localhost:4649"); + //var wssv = new WebSocketServer ("wss://localhost:5963"); #if DEBUG // To change the logging level. wssv.Log.Level = LogLevel.Trace; From 9360a6d99a836191ff8c9697b03f250fce2922de Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 16 Jul 2015 17:37:53 +0900 Subject: [PATCH 0041/6294] Fix for pull request #115, added the HttpServer (string) constructor --- websocket-sharp/Server/HttpServer.cs | 90 ++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index aa0a12340..68ef1788f 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -112,6 +112,59 @@ public HttpServer (int port) { } + /// + /// Initializes a new instance of the class with + /// the specified HTTP URL. + /// + /// + /// + /// An instance initialized by this constructor listens for the incoming requests on + /// the host name and port in . + /// + /// + /// If doesn't include a port, either port 80 or 443 is used on + /// which to listen. It's determined by the scheme (http or https) in . + /// (Port 80 if the scheme is http.) + /// + /// + /// + /// A that represents the HTTP URL of the server. + /// + /// + /// is . + /// + /// + /// + /// is empty. + /// + /// + /// -or- + /// + /// + /// is invalid. + /// + /// + public HttpServer (string url) + { + if (url == null) + throw new ArgumentNullException ("url"); + + if (url.Length == 0) + throw new ArgumentException ("An empty string.", "url"); + + Uri uri; + string msg; + if (!tryCreateUri (url, out uri, out msg)) + throw new ArgumentException (msg, "url"); + + var host = uri.DnsSafeHost; + var addr = host.ToIPAddress (); + if (!addr.IsLocal ()) + throw new ArgumentException ("The host part isn't a local host name: " + url, "url"); + + init (host, addr, uri.Port, uri.Scheme == "https"); + } + /// /// Initializes a new instance of the class with /// the specified and . @@ -683,6 +736,43 @@ private void stopReceiving (int millisecondsTimeout) _receiveThread.Join (millisecondsTimeout); } + private static bool tryCreateUri (string uriString, out Uri result, out string message) + { + result = null; + + var uri = uriString.ToUri (); + if (uri == null || !uri.IsAbsoluteUri) { + message = "Not an absolute URI: " + uriString; + return false; + } + + var schm = uri.Scheme; + if (!(schm == "http" || schm == "https")) { + message = "The scheme part isn't 'http' or 'https': " + uriString; + return false; + } + + if (uri.PathAndQuery != "/") { + message = "Includes the path or query component: " + uriString; + return false; + } + + if (uri.Fragment.Length > 0) { + message = "Includes the fragment component: " + uriString; + return false; + } + + if (uri.Port < 1) { + message = "The port part is less than 1: " + uriString; + return false; + } + + result = uri; + message = String.Empty; + + return true; + } + #endregion #region Public Methods From 38669444b45b4a36806382f0858381d6794216ba Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 17 Jul 2015 16:58:42 +0900 Subject: [PATCH 0042/6294] Modified a bit for Program.cs --- Example3/Program.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Example3/Program.cs b/Example3/Program.cs index d5ebcf9f7..ea2bf2486 100644 --- a/Example3/Program.cs +++ b/Example3/Program.cs @@ -14,13 +14,15 @@ public static void Main (string[] args) { /* Create a new instance of the HttpServer class. * - * If you would like to provide the secure connection, you should create the instance - * with the 'secure' parameter set to true. + * If you would like to provide the secure connection, you should create the instance with + * the 'secure' parameter set to true, or the https scheme HTTP URL. */ var httpsv = new HttpServer (4649); //var httpsv = new HttpServer (5963, true); //var httpsv = new HttpServer (System.Net.IPAddress.Parse ("127.0.0.1"), 4649); //var httpsv = new HttpServer (System.Net.IPAddress.Parse ("127.0.0.1"), 5963, true); + //var httpsv = new HttpServer ("http://localhost:4649/"); + //var httpsv = new HttpServer ("https://localhost:5963/"); #if DEBUG // To change the logging level. httpsv.Log.Level = LogLevel.Trace; From 624b20afa8c55e46a60e6860aac4523a862d7d1f Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 18 Jul 2015 14:55:04 +0900 Subject: [PATCH 0043/6294] Refactored a few for Ext.cs --- websocket-sharp/Ext.cs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 38305b68e..57b43193c 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -831,7 +831,12 @@ internal static bool TryCreateWebSocketUri ( result = null; var uri = uriString.ToUri (); - if (uri == null || !uri.IsAbsoluteUri) { + if (uri == null) { + message = "An invalid URI string: " + uriString; + return false; + } + + if (!uri.IsAbsoluteUri) { message = "Not an absolute URI: " + uriString; return false; } @@ -848,12 +853,12 @@ internal static bool TryCreateWebSocketUri ( } var port = uri.Port; - if (port > 65535) { - message = "The port part is greater than 65535: " + uriString; + if (port == 0) { + message = "The port part is zero: " + uriString; return false; } - result = port > 0 + result = port != -1 ? uri : new Uri ( String.Format ( From 8cd2248b2b83774222d3556a48ea8c601101f6d2 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 19 Jul 2015 15:24:46 +0900 Subject: [PATCH 0044/6294] Refactored a few for HttpServer.cs --- websocket-sharp/Server/HttpServer.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 68ef1788f..7f3bdae67 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -741,7 +741,12 @@ private static bool tryCreateUri (string uriString, out Uri result, out string m result = null; var uri = uriString.ToUri (); - if (uri == null || !uri.IsAbsoluteUri) { + if (uri == null) { + message = "An invalid URI string: " + uriString; + return false; + } + + if (!uri.IsAbsoluteUri) { message = "Not an absolute URI: " + uriString; return false; } @@ -762,8 +767,8 @@ private static bool tryCreateUri (string uriString, out Uri result, out string m return false; } - if (uri.Port < 1) { - message = "The port part is less than 1: " + uriString; + if (uri.Port == 0) { + message = "The port part is zero: " + uriString; return false; } From 87ce74010e22cab50bc4090ded6693378a1c08c9 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 20 Jul 2015 16:23:40 +0900 Subject: [PATCH 0045/6294] Fix for pull request #116 --- websocket-sharp/MessageEventArgs.cs | 35 +++++++++++++++-------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/websocket-sharp/MessageEventArgs.cs b/websocket-sharp/MessageEventArgs.cs index ec257c398..05be0c575 100644 --- a/websocket-sharp/MessageEventArgs.cs +++ b/websocket-sharp/MessageEventArgs.cs @@ -49,6 +49,7 @@ public class MessageEventArgs : EventArgs #region Private Fields private string _data; + private bool _dataSet; private Opcode _opcode; private byte[] _rawData; @@ -60,7 +61,6 @@ internal MessageEventArgs (WebSocketFrame frame) { _opcode = frame.Opcode; _rawData = frame.PayloadData.ApplicationData; - _data = convertToString (_opcode, _rawData); } internal MessageEventArgs (Opcode opcode, byte[] rawData) @@ -70,7 +70,6 @@ internal MessageEventArgs (Opcode opcode, byte[] rawData) _opcode = opcode; _rawData = rawData; - _data = convertToString (opcode, rawData); } #endregion @@ -80,19 +79,17 @@ internal MessageEventArgs (Opcode opcode, byte[] rawData) /// /// Gets the message data as a . /// - /// - /// - /// If the message data is empty, this property returns . - /// - /// - /// Or if the message is a binary message, this property returns "Binary". - /// - /// /// - /// A that represents the message data. + /// A that represents the message data, + /// or if the message data cannot be decoded to a string. /// public string Data { get { + if (!_dataSet) { + _data = convertToString (_rawData, _opcode); + _dataSet = true; + } + return _data; } } @@ -125,13 +122,17 @@ public Opcode Type { #region Private Methods - private static string convertToString (Opcode opcode, byte[] rawData) + private static string convertToString (byte[] rawData, Opcode opcode) { - return rawData.LongLength == 0 - ? String.Empty - : opcode == Opcode.Text - ? Encoding.UTF8.GetString (rawData) - : opcode.ToString (); + if (opcode == Opcode.Binary) + return BitConverter.ToString (rawData); + + try { + return Encoding.UTF8.GetString (rawData); + } + catch { + return null; + } } #endregion From 058d952970fcdaf8672344c8886581b94a6dff13 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 21 Jul 2015 15:13:28 +0900 Subject: [PATCH 0046/6294] Modified a bit for MessageEventArgs.cs, into the year 2015 --- websocket-sharp/MessageEventArgs.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/MessageEventArgs.cs b/websocket-sharp/MessageEventArgs.cs index 05be0c575..665eeed0b 100644 --- a/websocket-sharp/MessageEventArgs.cs +++ b/websocket-sharp/MessageEventArgs.cs @@ -4,7 +4,7 @@ * * The MIT License * - * Copyright (c) 2012-2014 sta.blockhead + * Copyright (c) 2012-2015 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From 82077d321ce40dffb100e95524f858ebabb034f8 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 22 Jul 2015 16:57:45 +0900 Subject: [PATCH 0047/6294] Added processFragmentedFrame2 method, to replace the processFragmentedFrame method with this --- websocket-sharp/WebSocket.cs | 46 ++++++++++++++++++++++++++++++++---- 1 file changed, 42 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 5ca128420..7ee211f0e 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -79,14 +79,17 @@ public class WebSocket : IDisposable private bool _enableRedirection; private string _extensions; private AutoResetEvent _exitReceiving; + private Opcode _fopcode; private object _forConn; private object _forEvent; private object _forMessageEventQueue; private object _forSend; + private MemoryStream _fragmentsBuffer; private const string _guid = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11"; private Func _handshakeRequestChecker; private bool _ignoreExtensions; + private bool _inContinuation; private volatile Logger _logger; private Queue _messageEventQueue; private uint _nonceCount; @@ -656,9 +659,11 @@ private string checkIfValidReceivedFrame (WebSocketFrame frame) ? "A frame from the server is masked." : !_client && !masked ? "A frame from a client isn't masked." - : frame.IsCompressed && _compression == CompressionMethod.None - ? "A compressed frame is without the available decompression method." - : null; + : _inContinuation && frame.IsData + ? "A data frame has been received while receiving the fragmented data." + : frame.IsCompressed && _compression == CompressionMethod.None + ? "A compressed frame is without the available decompression method." + : null; } private void close (CloseEventArgs e, bool send, bool wait) @@ -707,6 +712,11 @@ private bool closeHandshake (byte[] frameAsBytes, TimeSpan timeout, Action relea (sent && _exitReceiving != null && _exitReceiving.WaitOne (timeout)); release (); + if (_fragmentsBuffer != null) { + _fragmentsBuffer.Dispose (); + _fragmentsBuffer = null; + } + if (_receivePong != null) { _receivePong.Close (); _receivePong = null; @@ -1017,6 +1027,34 @@ private bool processFragmentedFrame (WebSocketFrame frame) return frame.IsContinuation || processFragments (frame); } + private bool processFragmentedFrame2 (WebSocketFrame frame) + { + if (!_inContinuation) { + if (frame.IsContinuation) + return true; + + _fopcode = frame.Opcode; + _fragmentsBuffer = new MemoryStream (); + _inContinuation = true; + } + + _fragmentsBuffer.WriteBytes (frame.PayloadData.ApplicationData); + if (frame.IsFinal) { + using (_fragmentsBuffer) { + var data = _compression != CompressionMethod.None + ? _fragmentsBuffer.DecompressToArray (_compression) + : _fragmentsBuffer.ToArray (); + + enqueueToMessageEventQueue (new MessageEventArgs (_fopcode, data)); + } + + _fragmentsBuffer = null; + _inContinuation = false; + } + + return true; + } + private bool processFragments (WebSocketFrame first) { using (var buff = new MemoryStream ()) { @@ -1441,7 +1479,7 @@ private void startReceiving () if (processReceivedFrame (frame) && _readyState != WebSocketState.Closed) { receive (); - if (!frame.IsData) + if (frame.IsControl || !frame.IsFinal) return; lock (_forEvent) { From 0be4389d97915c909570444ca8b9484308685a9e Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 23 Jul 2015 16:39:06 +0900 Subject: [PATCH 0048/6294] Replaced the processFragmentedFrame method with the processFragmentedFrame2 method, and renamed --- websocket-sharp/WebSocket.cs | 82 +----------------------------------- 1 file changed, 1 insertion(+), 81 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 7ee211f0e..8bf865294 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -734,60 +734,6 @@ private bool closeHandshake (byte[] frameAsBytes, TimeSpan timeout, Action relea return ret; } - private bool concatenateFragmentsInto (Stream destination) - { - while (true) { - var frame = WebSocketFrame.Read (_stream, false); - var msg = checkIfValidReceivedFrame (frame); - if (msg != null) - return processUnsupportedFrame (frame, CloseStatusCode.ProtocolError, msg); - - frame.Unmask (); - if (frame.IsFinal) { - /* FINAL */ - - // CONT - if (frame.IsContinuation) { - destination.WriteBytes (frame.PayloadData.ApplicationData); - break; - } - - // PING - if (frame.IsPing) { - processPingFrame (frame); - continue; - } - - // PONG - if (frame.IsPong) { - processPongFrame (frame); - continue; - } - - // CLOSE - if (frame.IsClose) - return processCloseFrame (frame); - } - else { - /* MORE */ - - // CONT - if (frame.IsContinuation) { - destination.WriteBytes (frame.PayloadData.ApplicationData); - continue; - } - } - - // ? - return processUnsupportedFrame ( - frame, - CloseStatusCode.UnsupportedData, - "Unsupported data has been received while receiving the fragmented data."); - } - - return true; - } - private bool connect () { lock (_forConn) { @@ -1022,14 +968,9 @@ private void processException (Exception exception, string message) } private bool processFragmentedFrame (WebSocketFrame frame) - { - // Must process first fragment. - return frame.IsContinuation || processFragments (frame); - } - - private bool processFragmentedFrame2 (WebSocketFrame frame) { if (!_inContinuation) { + // Must process first fragment. if (frame.IsContinuation) return true; @@ -1055,27 +996,6 @@ private bool processFragmentedFrame2 (WebSocketFrame frame) return true; } - private bool processFragments (WebSocketFrame first) - { - using (var buff = new MemoryStream ()) { - buff.WriteBytes (first.PayloadData.ApplicationData); - if (!concatenateFragmentsInto (buff)) - return false; - - byte[] data; - if (_compression != CompressionMethod.None) { - data = buff.DecompressToArray (_compression); - } - else { - buff.Close (); - data = buff.ToArray (); - } - - enqueueToMessageEventQueue (new MessageEventArgs (first.Opcode, data)); - return true; - } - } - private bool processPingFrame (WebSocketFrame frame) { if (send (new WebSocketFrame (Opcode.Pong, frame.PayloadData, _client).ToByteArray ())) From 196f5d92a1fe277044badeeab1dae760c24933c7 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 24 Jul 2015 14:04:21 +0900 Subject: [PATCH 0049/6294] Fix for issue #145 --- websocket-sharp/Net/EndPointListener.cs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Net/EndPointListener.cs b/websocket-sharp/Net/EndPointListener.cs index 4e1e92ccd..3fbf80a53 100644 --- a/websocket-sharp/Net/EndPointListener.cs +++ b/websocket-sharp/Net/EndPointListener.cs @@ -252,9 +252,18 @@ private static void onAccept (object sender, EventArgs e) args.AcceptSocket = null; } - var ret = true; try { - ret = lsnr._socket.AcceptAsync (args); + while (!lsnr._socket.AcceptAsync (args)) { + if (sock != null) { + processAccepted (sock, lsnr); + sock = null; + } + + if (args.SocketError == SocketError.Success) { + sock = args.AcceptSocket; + args.AcceptSocket = null; + } + } } catch { if (sock != null) @@ -265,9 +274,6 @@ private static void onAccept (object sender, EventArgs e) if (sock != null) processAccepted (sock, lsnr); - - if (!ret) - onAccept (sender, e); } private static void processAccepted (Socket socket, EndPointListener listener) From 2461b431452e92bb5eee67fe0c705c6ee7f30497 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 25 Jul 2015 16:32:06 +0900 Subject: [PATCH 0050/6294] Refactored a few for MessageEventArgs.cs --- websocket-sharp/MessageEventArgs.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/MessageEventArgs.cs b/websocket-sharp/MessageEventArgs.cs index 665eeed0b..9e9bb6a15 100644 --- a/websocket-sharp/MessageEventArgs.cs +++ b/websocket-sharp/MessageEventArgs.cs @@ -86,7 +86,10 @@ internal MessageEventArgs (Opcode opcode, byte[] rawData) public string Data { get { if (!_dataSet) { - _data = convertToString (_rawData, _opcode); + _data = _opcode != Opcode.Binary + ? convertToString (_rawData) + : BitConverter.ToString (_rawData); + _dataSet = true; } @@ -122,11 +125,8 @@ public Opcode Type { #region Private Methods - private static string convertToString (byte[] rawData, Opcode opcode) + private static string convertToString (byte[] rawData) { - if (opcode == Opcode.Binary) - return BitConverter.ToString (rawData); - try { return Encoding.UTF8.GetString (rawData); } From 58a4f02bda695e511ea0b7942b8dca5055d65ecc Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 26 Jul 2015 17:25:08 +0900 Subject: [PATCH 0051/6294] Fix for pull request #113 --- Example/Program.cs | 5 ++++- websocket-sharp/MessageEventArgs.cs | 9 +++++---- websocket-sharp/WebSocket.cs | 24 +++++++++++++++++++++++- 3 files changed, 32 insertions(+), 6 deletions(-) diff --git a/Example/Program.cs b/Example/Program.cs index 7d2e19be1..4ea070d16 100644 --- a/Example/Program.cs +++ b/Example/Program.cs @@ -35,7 +35,7 @@ public static void Main (string[] args) nf.Notify ( new NotificationMessage { Summary = "WebSocket Message", - Body = e.Data, + Body = e.Type != Opcode.Ping ? e.Data : "Received a Ping.", Icon = "notification-message-im" }); @@ -61,6 +61,9 @@ public static void Main (string[] args) // To change the wait time for the response to the Ping or Close. ws.WaitTime = TimeSpan.FromSeconds (10); + + // To emit a WebSocket.OnMessage event when receives a Ping. + ws.EmitOnPing = true; #endif // To enable the Per-message Compression extension. //ws.Compression = CompressionMethod.Deflate; diff --git a/websocket-sharp/MessageEventArgs.cs b/websocket-sharp/MessageEventArgs.cs index 9e9bb6a15..0ae9d48b8 100644 --- a/websocket-sharp/MessageEventArgs.cs +++ b/websocket-sharp/MessageEventArgs.cs @@ -37,11 +37,12 @@ namespace WebSocketSharp /// /// /// A event occurs when the receives - /// a text or binary message. + /// a text or binary message, or a Ping if the property is + /// set to true. /// /// - /// If you would like to get the message data, you should access - /// the or property. + /// If you would like to get the message data, you should access the or + /// property. /// /// public class MessageEventArgs : EventArgs @@ -113,7 +114,7 @@ public byte[] RawData { /// Gets the type of the message. /// /// - /// or . + /// , , or . /// public Opcode Type { get { diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 8bf865294..237b06b93 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -76,6 +76,7 @@ public class WebSocket : IDisposable private WebSocketContext _context; private CookieCollection _cookies; private NetworkCredential _credentials; + private bool _emitOnPing; private bool _enableRedirection; private string _extensions; private AutoResetEvent _exitReceiving; @@ -308,6 +309,24 @@ public NetworkCredential Credentials { } } + /// + /// Gets or sets a value indicating whether the emits + /// a event when receives a Ping. + /// + /// + /// true if the emits a event + /// when receives a Ping; otherwise, false. The default value is false. + /// + public bool EmitOnPing { + get { + return _emitOnPing; + } + + set { + _emitOnPing = value; + } + } + /// /// Gets or sets a value indicating whether the redirects to /// the new URL located in the handshake response. @@ -1001,6 +1020,9 @@ private bool processPingFrame (WebSocketFrame frame) if (send (new WebSocketFrame (Opcode.Pong, frame.PayloadData, _client).ToByteArray ())) _logger.Trace ("Returned a Pong."); + if (_emitOnPing) + enqueueToMessageEventQueue (new MessageEventArgs (frame)); + return true; } @@ -1399,7 +1421,7 @@ private void startReceiving () if (processReceivedFrame (frame) && _readyState != WebSocketState.Closed) { receive (); - if (frame.IsControl || !frame.IsFinal) + if ((frame.IsControl && !(frame.IsPing && _emitOnPing)) || !frame.IsFinal) return; lock (_forEvent) { From f99112fc2fc47dc094a9461cf03541dfa0734838 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 27 Jul 2015 16:11:16 +0900 Subject: [PATCH 0052/6294] Fix for pull request #113 --- Example2/Program.cs | 2 ++ Example3/Program.cs | 2 ++ websocket-sharp/Server/WebSocketBehavior.cs | 25 +++++++++++++++++++++ 3 files changed, 29 insertions(+) diff --git a/Example2/Program.cs b/Example2/Program.cs index 9c608ccde..02f003dc8 100644 --- a/Example2/Program.cs +++ b/Example2/Program.cs @@ -63,6 +63,8 @@ public static void Main (string[] args) "/Chat", () => new Chat ("Anon#") { Protocol = "chat", + // To emit a WebSocket.OnMessage event when receives a Ping. + EmitOnPing = true, // To ignore the Sec-WebSocket-Extensions header. IgnoreExtensions = true, // To validate the Origin header. diff --git a/Example3/Program.cs b/Example3/Program.cs index ea2bf2486..68c1657c4 100644 --- a/Example3/Program.cs +++ b/Example3/Program.cs @@ -90,6 +90,8 @@ public static void Main (string[] args) "/Chat", () => new Chat ("Anon#") { Protocol = "chat", + // To emit a WebSocket.OnMessage event when receives a Ping. + EmitOnPing = true, // To ignore the Sec-WebSocket-Extensions header. IgnoreExtensions = true, // To validate the Origin header. diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 2b9b0b648..791203859 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -46,6 +46,7 @@ public abstract class WebSocketBehavior : IWebSocketSession private WebSocketContext _context; private Func _cookiesValidator; + private bool _emitOnPing; private string _id; private bool _ignoreExtensions; private Func _originValidator; @@ -145,6 +146,29 @@ public Func CookiesValidator { } } + /// + /// Gets or sets a value indicating whether the used in a session emits + /// a event when receives a Ping. + /// + /// + /// true if the emits a event + /// when receives a Ping; otherwise, false. The default value is false. + /// + public bool EmitOnPing { + get { + return _websocket != null ? _websocket.EmitOnPing : _emitOnPing; + } + + set { + if (_websocket != null) { + _websocket.EmitOnPing = value; + return; + } + + _emitOnPing = value; + } + } + /// /// Gets the unique ID of a session. /// @@ -329,6 +353,7 @@ internal void Start (WebSocketContext context, WebSocketSessionManager sessions) _websocket = context.WebSocket; _websocket.CustomHandshakeRequestChecker = checkIfValidConnectionRequest; + _websocket.EmitOnPing = _emitOnPing; _websocket.IgnoreExtensions = _ignoreExtensions; _websocket.Protocol = _protocol; From 0eec6595a6cc26abf684a50343e29b3d3a3e18ea Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 28 Jul 2015 15:07:41 +0900 Subject: [PATCH 0053/6294] Refactored a few for WebSocketBehavior.cs --- websocket-sharp/Server/WebSocketBehavior.cs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 791203859..ef7e0f508 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -35,7 +35,7 @@ namespace WebSocketSharp.Server { /// /// Exposes the methods and properties used to define the behavior of a WebSocket service - /// provided by the or . + /// provided by the or . /// /// /// The WebSocketBehavior class is an abstract class. @@ -75,8 +75,8 @@ protected WebSocketBehavior () /// Gets the logging functions. /// /// - /// A that provides the logging functions, or - /// if the WebSocket connection isn't established. + /// A that provides the logging functions, + /// or if the WebSocket connection isn't established. /// protected Logger Log { get { @@ -119,7 +119,7 @@ public WebSocketContext Context { /// a connection request to the WebSocket service. /// /// - /// The delegate is called when the used in the session validates + /// This delegate is called when the used in a session validates /// the connection request. /// /// @@ -187,8 +187,8 @@ public string ID { /// the Sec-WebSocket-Extensions header included in a connection request. /// /// - /// true if the WebSocket service ignores the extensions; otherwise, false. - /// The default value is false. + /// true if the WebSocket service ignores the extensions; + /// otherwise, false. The default value is false. /// public bool IgnoreExtensions { get { @@ -205,7 +205,7 @@ public bool IgnoreExtensions { /// a connection request to the WebSocket service. /// /// - /// The delegate is called when the used in the session validates + /// This delegate is called when the used in a session validates /// the connection request. /// /// @@ -235,8 +235,8 @@ public Func OriginValidator { /// Gets or sets the WebSocket subprotocol used in the WebSocket service. /// /// - /// Set operation of this property is available before the WebSocket connection has been - /// established. + /// Set operation of this property is available before the WebSocket connection has + /// been established. /// /// /// @@ -282,7 +282,7 @@ public DateTime StartTime { /// /// /// One of the enum values, indicates the state of - /// the used in the session. + /// the . /// public WebSocketState State { get { From 0539311d877b74711ed6a0d257657dd29bfe07ac Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 29 Jul 2015 17:16:40 +0900 Subject: [PATCH 0054/6294] Modified a few for 'WebSocket.OnMessage Event' --- README.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/README.md b/README.md index 7072bcb89..21f571c77 100644 --- a/README.md +++ b/README.md @@ -159,6 +159,22 @@ if (e.Type == Opcode.Binary) { } ``` +And if you would like to notify that a **Ping** has been received, via this event, you should set the `WebSocket.EmitOnPing` property to `true`, such as the following. + +```csharp +ws.EmitOnPing = true; +ws.OnMessage += (sender, e) => { + if (e.Type == Opcode.Ping) { + // Do something to notify that a Ping has been received. + ... + + return; + } + + ... +}; +``` + ##### WebSocket.OnError Event ##### A `WebSocket.OnError` event occurs when the `WebSocket` gets an error. From 82da4816c4bf29a2ddbcc564cb488b743735939f Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 30 Jul 2015 17:18:04 +0900 Subject: [PATCH 0055/6294] Added 'Ignoring Sec-WebSocket-Extensions header' --- README.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/README.md b/README.md index 21f571c77..196bdcf28 100644 --- a/README.md +++ b/README.md @@ -434,6 +434,23 @@ And then your client will send the following header with the connection request If the server accepts this extension, it will return the same header which has the corresponding value. And when your client receives it, this extension will be available. +#### Ignoring Sec-WebSocket-Extensions header #### + +As a WebSocket server, if you would like to ignore the extensions requested from a client, you should set the `WebSocketBehavior.IgnoreExtensions` property to `true` in your `WebSocketBehavior` constructor or initializing it, such as the following. + +```csharp +wssv.AddWebSocketService ( + "/Chat", + () => new Chat () { + // To ignore the Sec-WebSocket-Extensions header. + IgnoreExtensions = true + }); +``` + +If it's set to `true`, the server doesn't return the Sec-WebSocket-Extensions header in the connection response. + +I think that it's useful when you get something error in connecting the server and exclude the extensions as a cause of the error. + ### Secure Connection ### websocket-sharp supports the **Secure Connection** with **SSL/TLS**. From 0505294d8eec836251eb225b7f4ad186675351b0 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 31 Jul 2015 16:40:51 +0900 Subject: [PATCH 0056/6294] Modified a few for 'Unity Asset Store' --- README.md | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 196bdcf28..64542ec89 100644 --- a/README.md +++ b/README.md @@ -51,12 +51,13 @@ websocket-sharp is available on the **Unity Asset Store**. It works with **Unity Free**, but there are some limitations: -- **[Security Sandbox of the Webplayer]** (the server doesn't work in the webplayer) -- **[.NET Socket Support for iOS/Android][Unity Licenses Comparison]** (requires iOS/Android Pro) -- **Limited support for the System.IO.Compression** (the compression extension isn't available on Windows) +- **[Security Sandbox of the Webplayer]** (The server isn't available in Web Player) +- **[WebGL Networking]** (Not available in WebGL) +- **.NET Socket Support for iOS/Android** (It requires iOS/Android Pro if your Unity is earlier than Unity 5) - **.NET API 2.0 compatibility level for iOS/Android** +- **Weak Support for the System.IO.Compression** (The compression extension isn't available on Windows) -Using **.NET API 2.0 compatibility level for iOS/Android** requires to fix lack of some features for later than .NET 2.0, such as the `System.Func<...>` delegates (so i've fixed it in the asset package). +**.NET API 2.0 compatibility level for iOS/Android** may require to fix lack of some features for later than .NET 2.0, such as the `System.Func<...>` delegates (so i've fixed it in the asset package). And it's priced at **US$15**. I think your $15 makes this project more better and accelerated, **Thank you!** @@ -686,7 +687,7 @@ websocket-sharp is provided under **[The MIT License]**. [Squid]: http://www.squid-cache.org [The MIT License]: https://raw.github.com/sta/websocket-sharp/master/LICENSE.txt [Unity]: http://unity3d.com -[Unity Licenses Comparison]: http://unity3d.com/unity/licenses +[WebGL Networking]: http://docs.unity3d.com/Manual/webgl-networking.html [WebSocket-Sharp for Unity]: http://u3d.as/content/sta-blockhead/websocket-sharp-for-unity [api]: http://www.w3.org/TR/websockets [api_ja]: http://www.hcn.zaq.ne.jp/___/WEB/WebSocket-ja.html From 228695019f37aac62f8c66da2dddf134019c991b Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 1 Aug 2015 11:52:53 +0900 Subject: [PATCH 0057/6294] Modified a bit for README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 64542ec89..8bfbba7b2 100644 --- a/README.md +++ b/README.md @@ -53,9 +53,9 @@ It works with **Unity Free**, but there are some limitations: - **[Security Sandbox of the Webplayer]** (The server isn't available in Web Player) - **[WebGL Networking]** (Not available in WebGL) +- **Weak Support for the System.IO.Compression** (The compression extension isn't available on Windows) - **.NET Socket Support for iOS/Android** (It requires iOS/Android Pro if your Unity is earlier than Unity 5) - **.NET API 2.0 compatibility level for iOS/Android** -- **Weak Support for the System.IO.Compression** (The compression extension isn't available on Windows) **.NET API 2.0 compatibility level for iOS/Android** may require to fix lack of some features for later than .NET 2.0, such as the `System.Func<...>` delegates (so i've fixed it in the asset package). @@ -450,7 +450,7 @@ wssv.AddWebSocketService ( If it's set to `true`, the server doesn't return the Sec-WebSocket-Extensions header in the connection response. -I think that it's useful when you get something error in connecting the server and exclude the extensions as a cause of the error. +I think that this is useful when you get something error in connecting the server and exclude the extensions as a cause of the error. ### Secure Connection ### From 82f089730e0ef647373ddeca731de93225070578 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 2 Aug 2015 18:18:27 +0900 Subject: [PATCH 0058/6294] Modified a few for 'WebSocket Extensions' --- README.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 8bfbba7b2..ff14ba4ee 100644 --- a/README.md +++ b/README.md @@ -421,21 +421,21 @@ For more information, would you see **[Example3]**? #### Per-message Compression #### -websocket-sharp supports the **[Per-message Compression][compression]** extension. (But this doesn't support it with the [context take over].) +websocket-sharp supports the **[Per-message Compression][compression]** extension (but doesn't support this extension with the [context take over]). -If you would like to enable this extension as a WebSocket client, you should set such as the following. +As a WebSocket client, if you would like to enable this extension, you should set such as the following. ```csharp ws.Compression = CompressionMethod.Deflate; ``` -And then your client will send the following header with the connection request to the server. +And then your client will send the following header in the connection request to the server. Sec-WebSocket-Extensions: permessage-deflate; server_no_context_takeover; client_no_context_takeover If the server accepts this extension, it will return the same header which has the corresponding value. And when your client receives it, this extension will be available. -#### Ignoring Sec-WebSocket-Extensions header #### +#### Ignoring the extensions #### As a WebSocket server, if you would like to ignore the extensions requested from a client, you should set the `WebSocketBehavior.IgnoreExtensions` property to `true` in your `WebSocketBehavior` constructor or initializing it, such as the following. @@ -443,14 +443,14 @@ As a WebSocket server, if you would like to ignore the extensions requested from wssv.AddWebSocketService ( "/Chat", () => new Chat () { - // To ignore the Sec-WebSocket-Extensions header. + // To ignore the extensions requested from a client. IgnoreExtensions = true }); ``` -If it's set to `true`, the server doesn't return the Sec-WebSocket-Extensions header in the connection response. +If it's set to `true`, the server doesn't return the **Sec-WebSocket-Extensions header** in the connection response. -I think that this is useful when you get something error in connecting the server and exclude the extensions as a cause of the error. +I think this is useful when you get something error in connecting the server and exclude the extensions as a cause of the error. ### Secure Connection ### From 586a6202a2eb46ee1b76ca1c3190f2559d858380 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 4 Aug 2015 15:50:36 +0900 Subject: [PATCH 0059/6294] Fix for pull request #146 --- websocket-sharp/WebSocket.cs | 4 ++-- websocket-sharp/WebSocketFrame.cs | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 237b06b93..49ef30af8 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -115,6 +115,7 @@ private Func #region Internal Fields internal const int FragmentLength = 1016; // Max value is Int32.MaxValue - 14. + internal static readonly RandomNumberGenerator RandomNumber = new RNGCryptoServiceProvider (); #endregion @@ -1627,8 +1628,7 @@ internal void ConnectAsServer () internal static string CreateBase64Key () { var src = new byte[16]; - var rand = new Random (); - rand.NextBytes (src); + RandomNumber.GetBytes (src); return Convert.ToBase64String (src); } diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index 4142fab83..427bb597a 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -277,8 +277,7 @@ public Rsv Rsv3 { private static byte[] createMaskingKey () { var key = new byte[4]; - var rand = new Random (); - rand.NextBytes (key); + WebSocket.RandomNumber.GetBytes (key); return key; } From 776fee91704f2f182a91104a0b12c6516d51a236 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 5 Aug 2015 16:37:53 +0900 Subject: [PATCH 0060/6294] Refactored a few for WebSocket.cs --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- websocket-sharp/WebSocket.cs | 38 ++++++++++----------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index ef7e0f508..079d4da71 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -366,7 +366,7 @@ internal void Start (WebSocketContext context, WebSocketSessionManager sessions) _websocket.OnError += onError; _websocket.OnClose += onClose; - _websocket.ConnectAsServer (); + _websocket.Accept (); } #endregion diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 49ef30af8..76b699906 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -601,7 +601,7 @@ private bool acceptHandshake () var msg = checkIfValidHandshakeRequest (_context); if (msg != null) { _logger.Error (msg); - error ("An error has occurred while connecting.", null); + error ("An error has occurred while accepting.", null); Close (HttpStatusCode.BadRequest); return false; @@ -760,7 +760,7 @@ private bool connect () var msg = _readyState.CheckIfConnectable (); if (msg != null) { _logger.Error (msg); - error ("An error has occurred in connecting.", null); + error ("An error has occurred in handshaking.", null); return false; } @@ -773,7 +773,7 @@ private bool connect () } } catch (Exception ex) { - processException (ex, "An exception has occurred while connecting."); + processException (ex, "An exception has occurred while handshaking."); } return false; @@ -1536,6 +1536,20 @@ private bool validateSecWebSocketVersionServerHeader (string value) #region Internal Methods + // As server + internal void Accept () + { + try { + if (acceptHandshake ()) { + _readyState = WebSocketState.Open; + open (); + } + } + catch (Exception ex) { + processException (ex, "An exception has occurred while accepting."); + } + } + internal static string CheckCloseParameters (ushort code, string reason, bool client) { return !code.IsCloseStatusCode () @@ -1610,20 +1624,6 @@ internal void Close (CloseEventArgs e, byte[] frameAsBytes, TimeSpan timeout) } } - // As server - internal void ConnectAsServer () - { - try { - if (acceptHandshake ()) { - _readyState = WebSocketState.Open; - open (); - } - } - catch (Exception ex) { - processException (ex, "An exception has occurred while connecting."); - } - } - // As client internal static string CreateBase64Key () { @@ -2029,7 +2029,7 @@ public void Connect () var msg = checkIfCanConnect (); if (msg != null) { _logger.Error (msg); - error ("An error has occurred in connecting.", null); + error ("An error has occurred in handshaking.", null); return; } @@ -2049,7 +2049,7 @@ public void ConnectAsync () var msg = checkIfCanConnect (); if (msg != null) { _logger.Error (msg); - error ("An error has occurred in connecting.", null); + error ("An error has occurred in handshaking.", null); return; } From 745da216313d8b36d844a4b9b7ffe3dd5822194d Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 6 Aug 2015 17:15:02 +0900 Subject: [PATCH 0061/6294] Added accept method --- websocket-sharp/Ext.cs | 7 +++++++ websocket-sharp/WebSocket.cs | 26 ++++++++++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 57b43193c..198e6af3c 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -201,6 +201,13 @@ internal static byte[] Append (this ushort code, string reason) } } + internal static string CheckIfCanAccept (this WebSocketState state) + { + return state != WebSocketState.Connecting + ? "This operation has already been done." + : null; + } + internal static string CheckIfCanRead (this Stream stream) { return stream == null diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 76b699906..551d47491 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -592,6 +592,32 @@ public TimeSpan WaitTime { #region Private Methods + // As server + private bool accept () + { + lock (_forConn) { + var msg = _readyState.CheckIfCanAccept (); + if (msg != null) { + _logger.Error (msg); + error ("An error has occurred in accepting.", null); + + return false; + } + + try { + if (acceptHandshake ()) { + _readyState = WebSocketState.Open; + return true; + } + } + catch (Exception ex) { + processException (ex, "An exception has occurred while accepting."); + } + + return false; + } + } + // As server private bool acceptHandshake () { From 8efe37eb2fe88986ac819506266d690b990f64a7 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 7 Aug 2015 17:27:04 +0900 Subject: [PATCH 0062/6294] Added the public WebSocket.Accept and AcceptAsync methods --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- websocket-sharp/WebSocket.cs | 85 +++++++++++++++++---- 2 files changed, 72 insertions(+), 15 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 079d4da71..5ae6c8f6e 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -366,7 +366,7 @@ internal void Start (WebSocketContext context, WebSocketSessionManager sessions) _websocket.OnError += onError; _websocket.OnClose += onClose; - _websocket.Accept (); + _websocket.InternalAccept (); } #endregion diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 551d47491..1538e2db4 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -655,6 +655,13 @@ private string checkIfAvailable (bool asServer, bool asConnected) : null; } + private string checkIfCanAccept () + { + return _client + ? "This operation isn't available as a client." + : _readyState.CheckIfCanAccept (); + } + private string checkIfCanConnect () { return !_client && _readyState == WebSocketState.Closed @@ -1562,20 +1569,6 @@ private bool validateSecWebSocketVersionServerHeader (string value) #region Internal Methods - // As server - internal void Accept () - { - try { - if (acceptHandshake ()) { - _readyState = WebSocketState.Open; - open (); - } - } - catch (Exception ex) { - processException (ex, "An exception has occurred while accepting."); - } - } - internal static string CheckCloseParameters (ushort code, string reason, bool client) { return !code.IsCloseStatusCode () @@ -1669,6 +1662,20 @@ internal static string CreateResponseKey (string base64Key) return Convert.ToBase64String (src); } + // As server + internal void InternalAccept () + { + try { + if (acceptHandshake ()) { + _readyState = WebSocketState.Open; + open (); + } + } + catch (Exception ex) { + processException (ex, "An exception has occurred while accepting."); + } + } + internal bool Ping (byte[] frameAsBytes, TimeSpan timeout) { try { @@ -1743,6 +1750,56 @@ internal void Send (Opcode opcode, Stream stream, Dictionary + /// Accepts the WebSocket connection request. + /// + /// + /// This method isn't available as a client. + /// + public void Accept () + { + var msg = checkIfCanAccept (); + if (msg != null) { + _logger.Error (msg); + error ("An error has occurred in accepting.", null); + + return; + } + + if (accept ()) + open (); + } + + /// + /// Accepts the WebSocket connection request asynchronously. + /// + /// + /// + /// This method doesn't wait for the accept to be complete. + /// + /// + /// This method isn't available as a client. + /// + /// + public void AcceptAsync () + { + var msg = checkIfCanAccept (); + if (msg != null) { + _logger.Error (msg); + error ("An error has occurred in accepting.", null); + + return; + } + + Func acceptor = accept; + acceptor.BeginInvoke ( + ar => { + if (acceptor.EndInvoke (ar)) + open (); + }, + null); + } + /// /// Closes the WebSocket connection, and releases all associated resources. /// From 5ceb4c43110e48b2859471326793def7962444b8 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 8 Aug 2015 15:39:31 +0900 Subject: [PATCH 0063/6294] Modified a few for the WebSocket.Connect and ConnectAsync methods --- websocket-sharp/Ext.cs | 7 +++++++ websocket-sharp/WebSocket.cs | 29 +++++++++++++++++++---------- 2 files changed, 26 insertions(+), 10 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 198e6af3c..3dbc28ba3 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -208,6 +208,13 @@ internal static string CheckIfCanAccept (this WebSocketState state) : null; } + internal static string CheckIfCanConnect (this WebSocketState state) + { + return state == WebSocketState.Open || state == WebSocketState.Closing + ? "This operation has already been done." + : null; + } + internal static string CheckIfCanRead (this Stream stream) { return stream == null diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 1538e2db4..2f83aadc0 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -664,9 +664,9 @@ private string checkIfCanAccept () private string checkIfCanConnect () { - return !_client && _readyState == WebSocketState.Closed - ? "Connect isn't available to reconnect as a server." - : _readyState.CheckIfConnectable (); + return !_client + ? "This operation isn't available in the server." + : _readyState.CheckIfCanConnect (); } // As server @@ -787,26 +787,27 @@ private bool closeHandshake (byte[] frameAsBytes, TimeSpan timeout, Action relea return ret; } + // As client private bool connect () { lock (_forConn) { - var msg = _readyState.CheckIfConnectable (); + var msg = _readyState.CheckIfCanConnect (); if (msg != null) { _logger.Error (msg); - error ("An error has occurred in handshaking.", null); + error ("An error has occurred in connecting.", null); return false; } try { _readyState = WebSocketState.Connecting; - if (_client ? doHandshake () : acceptHandshake ()) { + if (doHandshake ()) { _readyState = WebSocketState.Open; return true; } } catch (Exception ex) { - processException (ex, "An exception has occurred while handshaking."); + processException (ex, "An exception has occurred while connecting."); } return false; @@ -2107,12 +2108,15 @@ public void CloseAsync (CloseStatusCode code, string reason) /// /// Establishes a WebSocket connection. /// + /// + /// This method isn't available in the server. + /// public void Connect () { var msg = checkIfCanConnect (); if (msg != null) { _logger.Error (msg); - error ("An error has occurred in handshaking.", null); + error ("An error has occurred in connecting.", null); return; } @@ -2125,14 +2129,19 @@ public void Connect () /// Establishes a WebSocket connection asynchronously. /// /// - /// This method doesn't wait for the connect to be complete. + /// + /// This method doesn't wait for the connect to be complete. + /// + /// + /// This method isn't available in the server. + /// /// public void ConnectAsync () { var msg = checkIfCanConnect (); if (msg != null) { _logger.Error (msg); - error ("An error has occurred in handshaking.", null); + error ("An error has occurred in connecting.", null); return; } From f780f536e2bb8a63fdb175a6059168e2e16d42f7 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 9 Aug 2015 11:27:42 +0900 Subject: [PATCH 0064/6294] Refactored a few for WebSocket.cs --- websocket-sharp/Ext.cs | 7 ------- websocket-sharp/WebSocket.cs | 16 ++++++++-------- 2 files changed, 8 insertions(+), 15 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 3dbc28ba3..47b0d1e09 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -233,13 +233,6 @@ internal static string CheckIfClosable (this WebSocketState state) : null; } - internal static string CheckIfConnectable (this WebSocketState state) - { - return state == WebSocketState.Open || state == WebSocketState.Closing - ? "A WebSocket connection has already been established." - : null; - } - internal static string CheckIfOpen (this WebSocketState state) { return state == WebSocketState.Connecting diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 2f83aadc0..0d7061bed 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -646,19 +646,19 @@ private bool acceptHandshake () return sendHttpResponse (createHandshakeResponse ()); } - private string checkIfAvailable (bool asServer, bool asConnected) + private string checkIfAvailable (bool server, bool connected) { - return !_client && !asServer - ? "This operation isn't available as a server." - : !asConnected - ? _readyState.CheckIfConnectable () + return !server && !_client + ? "This operation isn't available in the server." + : !connected && IsConnected + ? "This operation isn't available after the connection has been established." : null; } private string checkIfCanAccept () { return _client - ? "This operation isn't available as a client." + ? "This operation isn't available in the client." : _readyState.CheckIfCanAccept (); } @@ -1755,7 +1755,7 @@ internal void Send (Opcode opcode, Stream stream, Dictionary /// - /// This method isn't available as a client. + /// This method isn't available in the client. /// public void Accept () { @@ -1779,7 +1779,7 @@ public void Accept () /// This method doesn't wait for the accept to be complete. /// /// - /// This method isn't available as a client. + /// This method isn't available in the client. /// /// public void AcceptAsync () From dce49c037fa5f6e94d1a7d655e68ed237180185a Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 10 Aug 2015 15:53:09 +0900 Subject: [PATCH 0065/6294] Added the internal Ext.CheckIfCanClose (WebSocketState) method --- websocket-sharp/Ext.cs | 16 +++++++--------- websocket-sharp/WebSocket.cs | 20 ++++++++++---------- 2 files changed, 17 insertions(+), 19 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 47b0d1e09..44735945a 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -208,6 +208,13 @@ internal static string CheckIfCanAccept (this WebSocketState state) : null; } + internal static string CheckIfCanClose (this WebSocketState state) + { + return state == WebSocketState.Closing || state == WebSocketState.Closed + ? String.Format ("This operation isn't available ({0}).", state) + : null; + } + internal static string CheckIfCanConnect (this WebSocketState state) { return state == WebSocketState.Open || state == WebSocketState.Closing @@ -224,15 +231,6 @@ internal static string CheckIfCanRead (this Stream stream) : null; } - internal static string CheckIfClosable (this WebSocketState state) - { - return state == WebSocketState.Closing - ? "While closing the WebSocket connection." - : state == WebSocketState.Closed - ? "The WebSocket connection has already been closed." - : null; - } - internal static string CheckIfOpen (this WebSocketState state) { return state == WebSocketState.Connecting diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 0d7061bed..933a99ee2 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1806,7 +1806,7 @@ public void AcceptAsync () /// public void Close () { - var msg = _readyState.CheckIfClosable (); + var msg = _readyState.CheckIfCanClose (); if (msg != null) { _logger.Error (msg); error ("An error has occurred in closing the connection.", null); @@ -1830,7 +1830,7 @@ public void Close () /// public void Close (ushort code) { - var msg = _readyState.CheckIfClosable () ?? CheckCloseParameters (code, null, _client); + var msg = _readyState.CheckIfCanClose () ?? CheckCloseParameters (code, null, _client); if (msg != null) { _logger.Error (msg); error ("An error has occurred in closing the connection.", null); @@ -1857,7 +1857,7 @@ public void Close (ushort code) /// public void Close (CloseStatusCode code) { - var msg = _readyState.CheckIfClosable () ?? CheckCloseParameters (code, null, _client); + var msg = _readyState.CheckIfCanClose () ?? CheckCloseParameters (code, null, _client); if (msg != null) { _logger.Error (msg); error ("An error has occurred in closing the connection.", null); @@ -1891,7 +1891,7 @@ public void Close (CloseStatusCode code) /// public void Close (ushort code, string reason) { - var msg = _readyState.CheckIfClosable () ?? CheckCloseParameters (code, reason, _client); + var msg = _readyState.CheckIfCanClose () ?? CheckCloseParameters (code, reason, _client); if (msg != null) { _logger.Error (msg); error ("An error has occurred in closing the connection.", null); @@ -1925,7 +1925,7 @@ public void Close (ushort code, string reason) /// public void Close (CloseStatusCode code, string reason) { - var msg = _readyState.CheckIfClosable () ?? CheckCloseParameters (code, reason, _client); + var msg = _readyState.CheckIfCanClose () ?? CheckCloseParameters (code, reason, _client); if (msg != null) { _logger.Error (msg); error ("An error has occurred in closing the connection.", null); @@ -1950,7 +1950,7 @@ public void Close (CloseStatusCode code, string reason) /// public void CloseAsync () { - var msg = _readyState.CheckIfClosable (); + var msg = _readyState.CheckIfCanClose (); if (msg != null) { _logger.Error (msg); error ("An error has occurred in closing the connection.", null); @@ -1979,7 +1979,7 @@ public void CloseAsync () /// public void CloseAsync (ushort code) { - var msg = _readyState.CheckIfClosable () ?? CheckCloseParameters (code, null, _client); + var msg = _readyState.CheckIfCanClose () ?? CheckCloseParameters (code, null, _client); if (msg != null) { _logger.Error (msg); error ("An error has occurred in closing the connection.", null); @@ -2009,7 +2009,7 @@ public void CloseAsync (ushort code) /// public void CloseAsync (CloseStatusCode code) { - var msg = _readyState.CheckIfClosable () ?? CheckCloseParameters (code, null, _client); + var msg = _readyState.CheckIfCanClose () ?? CheckCloseParameters (code, null, _client); if (msg != null) { _logger.Error (msg); error ("An error has occurred in closing the connection.", null); @@ -2048,7 +2048,7 @@ public void CloseAsync (CloseStatusCode code) /// public void CloseAsync (ushort code, string reason) { - var msg = _readyState.CheckIfClosable () ?? CheckCloseParameters (code, reason, _client); + var msg = _readyState.CheckIfCanClose () ?? CheckCloseParameters (code, reason, _client); if (msg != null) { _logger.Error (msg); error ("An error has occurred in closing the connection.", null); @@ -2088,7 +2088,7 @@ public void CloseAsync (ushort code, string reason) /// public void CloseAsync (CloseStatusCode code, string reason) { - var msg = _readyState.CheckIfClosable () ?? CheckCloseParameters (code, reason, _client); + var msg = _readyState.CheckIfCanClose () ?? CheckCloseParameters (code, reason, _client); if (msg != null) { _logger.Error (msg); error ("An error has occurred in closing the connection.", null); From 7bd0fb87f265a38a24862877faf389ff150163aa Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 11 Aug 2015 11:12:23 +0900 Subject: [PATCH 0066/6294] Added the internal Ext.CheckIfCanSend (WebSocketState) method --- websocket-sharp/Ext.cs | 14 +++++--------- websocket-sharp/WebSocket.cs | 14 +++++++------- 2 files changed, 12 insertions(+), 16 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 44735945a..317379716 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -231,15 +231,11 @@ internal static string CheckIfCanRead (this Stream stream) : null; } - internal static string CheckIfOpen (this WebSocketState state) - { - return state == WebSocketState.Connecting - ? "A WebSocket connection isn't established." - : state == WebSocketState.Closing - ? "While closing the WebSocket connection." - : state == WebSocketState.Closed - ? "The WebSocket connection has already been closed." - : null; + internal static string CheckIfCanSend (this WebSocketState state) + { + return state != WebSocketState.Open + ? String.Format ("This operation isn't available ({0}).", state) + : null; } internal static string CheckIfStart (this ServerState state) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 933a99ee2..d874713c5 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2206,7 +2206,7 @@ public bool Ping (string message) /// public void Send (byte[] data) { - var msg = _readyState.CheckIfOpen () ?? data.CheckIfValidSendData (); + var msg = _readyState.CheckIfCanSend () ?? data.CheckIfValidSendData (); if (msg != null) { _logger.Error (msg); error ("An error has occurred in sending the data.", null); @@ -2225,7 +2225,7 @@ public void Send (byte[] data) /// public void Send (FileInfo file) { - var msg = _readyState.CheckIfOpen () ?? file.CheckIfValidSendData (); + var msg = _readyState.CheckIfCanSend () ?? file.CheckIfValidSendData (); if (msg != null) { _logger.Error (msg); error ("An error has occurred in sending the data.", null); @@ -2244,7 +2244,7 @@ public void Send (FileInfo file) /// public void Send (string data) { - var msg = _readyState.CheckIfOpen () ?? data.CheckIfValidSendData (); + var msg = _readyState.CheckIfCanSend () ?? data.CheckIfValidSendData (); if (msg != null) { _logger.Error (msg); error ("An error has occurred in sending the data.", null); @@ -2271,7 +2271,7 @@ public void Send (string data) /// public void SendAsync (byte[] data, Action completed) { - var msg = _readyState.CheckIfOpen () ?? data.CheckIfValidSendData (); + var msg = _readyState.CheckIfCanSend () ?? data.CheckIfValidSendData (); if (msg != null) { _logger.Error (msg); error ("An error has occurred in sending the data.", null); @@ -2299,7 +2299,7 @@ public void SendAsync (byte[] data, Action completed) /// public void SendAsync (FileInfo file, Action completed) { - var msg = _readyState.CheckIfOpen () ?? file.CheckIfValidSendData (); + var msg = _readyState.CheckIfCanSend () ?? file.CheckIfValidSendData (); if (msg != null) { _logger.Error (msg); error ("An error has occurred in sending the data.", null); @@ -2326,7 +2326,7 @@ public void SendAsync (FileInfo file, Action completed) /// public void SendAsync (string data, Action completed) { - var msg = _readyState.CheckIfOpen () ?? data.CheckIfValidSendData (); + var msg = _readyState.CheckIfCanSend () ?? data.CheckIfValidSendData (); if (msg != null) { _logger.Error (msg); error ("An error has occurred in sending the data.", null); @@ -2357,7 +2357,7 @@ public void SendAsync (string data, Action completed) /// public void SendAsync (Stream stream, int length, Action completed) { - var msg = _readyState.CheckIfOpen () ?? + var msg = _readyState.CheckIfCanSend () ?? stream.CheckIfCanRead () ?? (length < 1 ? "'length' is less than 1." : null); From 46eae139e27f8b8187eceace3c775a67699b941c Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 12 Aug 2015 17:24:53 +0900 Subject: [PATCH 0067/6294] Added the internal Ext.CheckIfCanStart (ServerState) method --- websocket-sharp/Ext.cs | 7 +++++++ websocket-sharp/Server/HttpServer.cs | 2 +- websocket-sharp/Server/WebSocketServer.cs | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 317379716..b5ec9335e 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -238,6 +238,13 @@ internal static string CheckIfCanSend (this WebSocketState state) : null; } + internal static string CheckIfCanStart (this ServerState state) + { + return state == ServerState.Start || state == ServerState.ShuttingDown + ? "This operation has already been done." + : null; + } + internal static string CheckIfStart (this ServerState state) { return state == ServerState.Ready diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 7f3bdae67..06a01efbd 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -892,7 +892,7 @@ public bool RemoveWebSocketService (string path) public void Start () { lock (_sync) { - var msg = _state.CheckIfStartable () ?? checkIfCertificateExists (); + var msg = _state.CheckIfCanStart () ?? checkIfCertificateExists (); if (msg != null) { _logger.Error (msg); return; diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index a61551571..93610dc63 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -795,7 +795,7 @@ public bool RemoveWebSocketService (string path) public void Start () { lock (_sync) { - var msg = _state.CheckIfStartable () ?? checkIfCertificateExists (); + var msg = _state.CheckIfCanStart () ?? checkIfCertificateExists (); if (msg != null) { _logger.Error (msg); return; From 80a0107bab5df7074af59b36c7a727cd871ab233 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 13 Aug 2015 11:41:38 +0900 Subject: [PATCH 0068/6294] Added the internal Ext.CheckIfCanStop (ServerState) method --- websocket-sharp/Ext.cs | 7 +++++++ websocket-sharp/Server/HttpServer.cs | 6 +++--- websocket-sharp/Server/WebSocketServer.cs | 6 +++--- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index b5ec9335e..f73135ef9 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -245,6 +245,13 @@ internal static string CheckIfCanStart (this ServerState state) : null; } + internal static string CheckIfCanStop (this ServerState state) + { + return state != ServerState.Start + ? String.Format ("This operation isn't available ({0}).", state) + : null; + } + internal static string CheckIfStart (this ServerState state) { return state == ServerState.Ready diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 06a01efbd..01e3c3c76 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -911,7 +911,7 @@ public void Start () public void Stop () { lock (_sync) { - var msg = _state.CheckIfStart (); + var msg = _state.CheckIfCanStop (); if (msg != null) { _logger.Error (msg); return; @@ -939,7 +939,7 @@ public void Stop () public void Stop (ushort code, string reason) { lock (_sync) { - var msg = _state.CheckIfStart () ?? WebSocket.CheckCloseParameters (code, reason, false); + var msg = _state.CheckIfCanStop () ?? WebSocket.CheckCloseParameters (code, reason, false); if (msg != null) { _logger.Error (msg); return; @@ -975,7 +975,7 @@ public void Stop (ushort code, string reason) public void Stop (CloseStatusCode code, string reason) { lock (_sync) { - var msg = _state.CheckIfStart () ?? WebSocket.CheckCloseParameters (code, reason, false); + var msg = _state.CheckIfCanStop () ?? WebSocket.CheckCloseParameters (code, reason, false); if (msg != null) { _logger.Error (msg); return; diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 93610dc63..cd9833ec8 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -814,7 +814,7 @@ public void Start () public void Stop () { lock (_sync) { - var msg = _state.CheckIfStart (); + var msg = _state.CheckIfCanStop (); if (msg != null) { _logger.Error (msg); return; @@ -842,7 +842,7 @@ public void Stop () public void Stop (ushort code, string reason) { lock (_sync) { - var msg = _state.CheckIfStart () ?? WebSocket.CheckCloseParameters (code, reason, false); + var msg = _state.CheckIfCanStop () ?? WebSocket.CheckCloseParameters (code, reason, false); if (msg != null) { _logger.Error (msg); return; @@ -877,7 +877,7 @@ public void Stop (ushort code, string reason) public void Stop (CloseStatusCode code, string reason) { lock (_sync) { - var msg = _state.CheckIfStart () ?? WebSocket.CheckCloseParameters (code, reason, false); + var msg = _state.CheckIfCanStop () ?? WebSocket.CheckCloseParameters (code, reason, false); if (msg != null) { _logger.Error (msg); return; From 999e77751781abd5a2cf018a61900bc41c1e4c32 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 14 Aug 2015 16:05:00 +0900 Subject: [PATCH 0069/6294] Added the internal Ext.CheckIfAvailable (ServerState, bool, bool, bool) method --- websocket-sharp/Ext.cs | 44 +++++-------------- websocket-sharp/Server/HttpServer.cs | 28 +++++++----- websocket-sharp/Server/WebSocketServer.cs | 26 ++++++----- .../Server/WebSocketServiceHost.cs | 6 ++- .../Server/WebSocketServiceManager.cs | 18 ++++---- .../Server/WebSocketSessionManager.cs | 18 ++++---- 6 files changed, 65 insertions(+), 75 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index f73135ef9..95737fe0b 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -201,6 +201,16 @@ internal static byte[] Append (this ushort code, string reason) } } + internal static string CheckIfAvailable ( + this ServerState state, bool ready, bool start, bool shutting) + { + return (!ready && (state == ServerState.Ready || state == ServerState.Stop)) || + (!start && state == ServerState.Start) || + (!shutting && state == ServerState.ShuttingDown) + ? "This operation isn't available in: " + state + : null; + } + internal static string CheckIfCanAccept (this WebSocketState state) { return state != WebSocketState.Connecting @@ -238,40 +248,6 @@ internal static string CheckIfCanSend (this WebSocketState state) : null; } - internal static string CheckIfCanStart (this ServerState state) - { - return state == ServerState.Start || state == ServerState.ShuttingDown - ? "This operation has already been done." - : null; - } - - internal static string CheckIfCanStop (this ServerState state) - { - return state != ServerState.Start - ? String.Format ("This operation isn't available ({0}).", state) - : null; - } - - internal static string CheckIfStart (this ServerState state) - { - return state == ServerState.Ready - ? "The server hasn't yet started." - : state == ServerState.ShuttingDown - ? "The server is shutting down." - : state == ServerState.Stop - ? "The server has already stopped." - : null; - } - - internal static string CheckIfStartable (this ServerState state) - { - return state == ServerState.Start - ? "The server has already started." - : state == ServerState.ShuttingDown - ? "The server is shutting down." - : null; - } - internal static string CheckIfValidProtocols (this string[] protocols) { return protocols.Contains ( diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 01e3c3c76..d4ec6ad98 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -298,7 +298,7 @@ public AuthenticationSchemes AuthenticationSchemes { } set { - var msg = _state.CheckIfStartable (); + var msg = _state.CheckIfAvailable (true, false, false); if (msg != null) { _logger.Error (msg); return; @@ -346,7 +346,7 @@ public bool KeepClean { } set { - var msg = _state.CheckIfStartable (); + var msg = _state.CheckIfAvailable (true, false, false); if (msg != null) { _logger.Error (msg); return; @@ -398,7 +398,7 @@ public string Realm { } set { - var msg = _state.CheckIfStartable (); + var msg = _state.CheckIfAvailable (true, false, false); if (msg != null) { _logger.Error (msg); return; @@ -426,7 +426,7 @@ public bool ReuseAddress { } set { - var msg = _state.CheckIfStartable (); + var msg = _state.CheckIfAvailable (true, false, false); if (msg != null) { _logger.Error (msg); return; @@ -449,7 +449,7 @@ public string RootPath { } set { - var msg = _state.CheckIfStartable (); + var msg = _state.CheckIfAvailable (true, false, false); if (msg != null) { _logger.Error (msg); return; @@ -473,7 +473,7 @@ public ServerSslConfiguration SslConfiguration { } set { - var msg = _state.CheckIfStartable (); + var msg = _state.CheckIfAvailable (true, false, false); if (msg != null) { _logger.Error (msg); return; @@ -498,7 +498,7 @@ public Func UserCredentialsFinder { } set { - var msg = _state.CheckIfStartable (); + var msg = _state.CheckIfAvailable (true, false, false); if (msg != null) { _logger.Error (msg); return; @@ -521,7 +521,7 @@ public TimeSpan WaitTime { } set { - var msg = _state.CheckIfStartable () ?? value.CheckIfValidWaitTime (); + var msg = _state.CheckIfAvailable (true, false, false) ?? value.CheckIfValidWaitTime (); if (msg != null) { _logger.Error (msg); return; @@ -892,7 +892,7 @@ public bool RemoveWebSocketService (string path) public void Start () { lock (_sync) { - var msg = _state.CheckIfCanStart () ?? checkIfCertificateExists (); + var msg = _state.CheckIfAvailable (true, false, false) ?? checkIfCertificateExists (); if (msg != null) { _logger.Error (msg); return; @@ -911,7 +911,7 @@ public void Start () public void Stop () { lock (_sync) { - var msg = _state.CheckIfCanStop (); + var msg = _state.CheckIfAvailable (false, true, false); if (msg != null) { _logger.Error (msg); return; @@ -939,7 +939,9 @@ public void Stop () public void Stop (ushort code, string reason) { lock (_sync) { - var msg = _state.CheckIfCanStop () ?? WebSocket.CheckCloseParameters (code, reason, false); + var msg = _state.CheckIfAvailable (false, true, false) ?? + WebSocket.CheckCloseParameters (code, reason, false); + if (msg != null) { _logger.Error (msg); return; @@ -975,7 +977,9 @@ public void Stop (ushort code, string reason) public void Stop (CloseStatusCode code, string reason) { lock (_sync) { - var msg = _state.CheckIfCanStop () ?? WebSocket.CheckCloseParameters (code, reason, false); + var msg = _state.CheckIfAvailable (false, true, false) ?? + WebSocket.CheckCloseParameters (code, reason, false); + if (msg != null) { _logger.Error (msg); return; diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index cd9833ec8..457df8c6d 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -303,7 +303,7 @@ public AuthenticationSchemes AuthenticationSchemes { } set { - var msg = _state.CheckIfStartable (); + var msg = _state.CheckIfAvailable (true, false, false); if (msg != null) { _logger.Error (msg); return; @@ -351,7 +351,7 @@ public bool KeepClean { } set { - var msg = _state.CheckIfStartable (); + var msg = _state.CheckIfAvailable (true, false, false); if (msg != null) { _logger.Error (msg); return; @@ -403,7 +403,7 @@ public string Realm { } set { - var msg = _state.CheckIfStartable (); + var msg = _state.CheckIfAvailable (true, false, false); if (msg != null) { _logger.Error (msg); return; @@ -431,7 +431,7 @@ public bool ReuseAddress { } set { - var msg = _state.CheckIfStartable (); + var msg = _state.CheckIfAvailable (true, false, false); if (msg != null) { _logger.Error (msg); return; @@ -455,7 +455,7 @@ public ServerSslConfiguration SslConfiguration { } set { - var msg = _state.CheckIfStartable (); + var msg = _state.CheckIfAvailable (true, false, false); if (msg != null) { _logger.Error (msg); return; @@ -480,7 +480,7 @@ public Func UserCredentialsFinder { } set { - var msg = _state.CheckIfStartable (); + var msg = _state.CheckIfAvailable (true, false, false); if (msg != null) { _logger.Error (msg); return; @@ -503,7 +503,7 @@ public TimeSpan WaitTime { } set { - var msg = _state.CheckIfStartable () ?? value.CheckIfValidWaitTime (); + var msg = _state.CheckIfAvailable (true, false, false) ?? value.CheckIfValidWaitTime (); if (msg != null) { _logger.Error (msg); return; @@ -795,7 +795,7 @@ public bool RemoveWebSocketService (string path) public void Start () { lock (_sync) { - var msg = _state.CheckIfCanStart () ?? checkIfCertificateExists (); + var msg = _state.CheckIfAvailable (true, false, false) ?? checkIfCertificateExists (); if (msg != null) { _logger.Error (msg); return; @@ -814,7 +814,7 @@ public void Start () public void Stop () { lock (_sync) { - var msg = _state.CheckIfCanStop (); + var msg = _state.CheckIfAvailable (false, true, false); if (msg != null) { _logger.Error (msg); return; @@ -842,7 +842,9 @@ public void Stop () public void Stop (ushort code, string reason) { lock (_sync) { - var msg = _state.CheckIfCanStop () ?? WebSocket.CheckCloseParameters (code, reason, false); + var msg = _state.CheckIfAvailable (false, true, false) ?? + WebSocket.CheckCloseParameters (code, reason, false); + if (msg != null) { _logger.Error (msg); return; @@ -877,7 +879,9 @@ public void Stop (ushort code, string reason) public void Stop (CloseStatusCode code, string reason) { lock (_sync) { - var msg = _state.CheckIfCanStop () ?? WebSocket.CheckCloseParameters (code, reason, false); + var msg = _state.CheckIfAvailable (false, true, false) ?? + WebSocket.CheckCloseParameters (code, reason, false); + if (msg != null) { _logger.Error (msg); return; diff --git a/websocket-sharp/Server/WebSocketServiceHost.cs b/websocket-sharp/Server/WebSocketServiceHost.cs index 5d1fb3789..1db348ec2 100644 --- a/websocket-sharp/Server/WebSocketServiceHost.cs +++ b/websocket-sharp/Server/WebSocketServiceHost.cs @@ -187,7 +187,7 @@ public override bool KeepClean { } set { - var msg = _sessions.State.CheckIfStartable (); + var msg = _sessions.State.CheckIfAvailable (true, false, false); if (msg != null) { _logger.Error (msg); return; @@ -221,7 +221,9 @@ public override TimeSpan WaitTime { } set { - var msg = _sessions.State.CheckIfStartable () ?? value.CheckIfValidWaitTime (); + var msg = _sessions.State.CheckIfAvailable (true, false, false) ?? + value.CheckIfValidWaitTime (); + if (msg != null) { _logger.Error (msg); return; diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index 1ed1e6fa7..2e3a218b7 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -385,7 +385,7 @@ internal void Stop (CloseEventArgs e, bool send, bool wait) /// public void Broadcast (byte[] data) { - var msg = _state.CheckIfStart () ?? data.CheckIfValidSendData (); + var msg = _state.CheckIfAvailable (false, true, false) ?? data.CheckIfValidSendData (); if (msg != null) { _logger.Error (msg); return; @@ -405,7 +405,7 @@ public void Broadcast (byte[] data) /// public void Broadcast (string data) { - var msg = _state.CheckIfStart () ?? data.CheckIfValidSendData (); + var msg = _state.CheckIfAvailable (false, true, false) ?? data.CheckIfValidSendData (); if (msg != null) { _logger.Error (msg); return; @@ -434,7 +434,7 @@ public void Broadcast (string data) /// public void BroadcastAsync (byte[] data, Action completed) { - var msg = _state.CheckIfStart () ?? data.CheckIfValidSendData (); + var msg = _state.CheckIfAvailable (false, true, false) ?? data.CheckIfValidSendData (); if (msg != null) { _logger.Error (msg); return; @@ -462,7 +462,7 @@ public void BroadcastAsync (byte[] data, Action completed) /// public void BroadcastAsync (string data, Action completed) { - var msg = _state.CheckIfStart () ?? data.CheckIfValidSendData (); + var msg = _state.CheckIfAvailable (false, true, false) ?? data.CheckIfValidSendData (); if (msg != null) { _logger.Error (msg); return; @@ -494,7 +494,7 @@ public void BroadcastAsync (string data, Action completed) /// public void BroadcastAsync (Stream stream, int length, Action completed) { - var msg = _state.CheckIfStart () ?? + var msg = _state.CheckIfAvailable (false, true, false) ?? stream.CheckIfCanRead () ?? (length < 1 ? "'length' is less than 1." : null); @@ -538,7 +538,7 @@ public void BroadcastAsync (Stream stream, int length, Action completed) /// public Dictionary> Broadping () { - var msg = _state.CheckIfStart (); + var msg = _state.CheckIfAvailable (false, true, false); if (msg != null) { _logger.Error (msg); return null; @@ -567,7 +567,9 @@ public Dictionary> Broadping (string message) return Broadping (); byte[] data = null; - var msg = _state.CheckIfStart () ?? WebSocket.CheckPingParameter (message, out data); + var msg = _state.CheckIfAvailable (false, true, false) ?? + WebSocket.CheckPingParameter (message, out data); + if (msg != null) { _logger.Error (msg); return null; @@ -592,7 +594,7 @@ public Dictionary> Broadping (string message) /// public bool TryGetServiceHost (string path, out WebSocketServiceHost host) { - var msg = _state.CheckIfStart () ?? path.CheckIfValidServicePath (); + var msg = _state.CheckIfAvailable (false, true, false) ?? path.CheckIfValidServicePath (); if (msg != null) { _logger.Error (msg); host = null; diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 051aa023d..ddd0ca6fb 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -393,7 +393,7 @@ internal void Stop (CloseEventArgs e, byte[] frameAsBytes, TimeSpan timeout) /// public void Broadcast (byte[] data) { - var msg = _state.CheckIfStart () ?? data.CheckIfValidSendData (); + var msg = _state.CheckIfAvailable (false, true, false) ?? data.CheckIfValidSendData (); if (msg != null) { _logger.Error (msg); return; @@ -413,7 +413,7 @@ public void Broadcast (byte[] data) /// public void Broadcast (string data) { - var msg = _state.CheckIfStart () ?? data.CheckIfValidSendData (); + var msg = _state.CheckIfAvailable (false, true, false) ?? data.CheckIfValidSendData (); if (msg != null) { _logger.Error (msg); return; @@ -442,7 +442,7 @@ public void Broadcast (string data) /// public void BroadcastAsync (byte[] data, Action completed) { - var msg = _state.CheckIfStart () ?? data.CheckIfValidSendData (); + var msg = _state.CheckIfAvailable (false, true, false) ?? data.CheckIfValidSendData (); if (msg != null) { _logger.Error (msg); return; @@ -470,7 +470,7 @@ public void BroadcastAsync (byte[] data, Action completed) /// public void BroadcastAsync (string data, Action completed) { - var msg = _state.CheckIfStart () ?? data.CheckIfValidSendData (); + var msg = _state.CheckIfAvailable (false, true, false) ?? data.CheckIfValidSendData (); if (msg != null) { _logger.Error (msg); return; @@ -502,7 +502,7 @@ public void BroadcastAsync (string data, Action completed) /// public void BroadcastAsync (Stream stream, int length, Action completed) { - var msg = _state.CheckIfStart () ?? + var msg = _state.CheckIfAvailable (false, true, false) ?? stream.CheckIfCanRead () ?? (length < 1 ? "'length' is less than 1." : null); @@ -545,7 +545,7 @@ public void BroadcastAsync (Stream stream, int length, Action completed) /// public Dictionary Broadping () { - var msg = _state.CheckIfStart (); + var msg = _state.CheckIfAvailable (false, true, false); if (msg != null) { _logger.Error (msg); return null; @@ -572,7 +572,9 @@ public Dictionary Broadping (string message) return Broadping (); byte[] data = null; - var msg = _state.CheckIfStart () ?? WebSocket.CheckPingParameter (message, out data); + var msg = _state.CheckIfAvailable (false, true, false) ?? + WebSocket.CheckPingParameter (message, out data); + if (msg != null) { _logger.Error (msg); return null; @@ -831,7 +833,7 @@ public void Sweep () /// public bool TryGetSession (string id, out IWebSocketSession session) { - var msg = _state.CheckIfStart () ?? id.CheckIfValidSessionID (); + var msg = _state.CheckIfAvailable (false, true, false) ?? id.CheckIfValidSessionID (); if (msg != null) { _logger.Error (msg); session = null; From 18776d1a221ccb91c05c667fe5cbec445a856119 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 15 Aug 2015 16:28:46 +0900 Subject: [PATCH 0070/6294] Added the internal Ext.CheckIfAvailable (WebSocketState, bool, bool, bool, bool) method --- websocket-sharp/Ext.cs | 31 ++++------------ websocket-sharp/WebSocket.cs | 70 +++++++++++++++++++++++++----------- 2 files changed, 56 insertions(+), 45 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 95737fe0b..4d781d322 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -211,24 +211,14 @@ internal static string CheckIfAvailable ( : null; } - internal static string CheckIfCanAccept (this WebSocketState state) - { - return state != WebSocketState.Connecting - ? "This operation has already been done." - : null; - } - - internal static string CheckIfCanClose (this WebSocketState state) - { - return state == WebSocketState.Closing || state == WebSocketState.Closed - ? String.Format ("This operation isn't available ({0}).", state) - : null; - } - - internal static string CheckIfCanConnect (this WebSocketState state) + internal static string CheckIfAvailable ( + this WebSocketState state, bool connecting, bool open, bool closing, bool closed) { - return state == WebSocketState.Open || state == WebSocketState.Closing - ? "This operation has already been done." + return (!connecting && state == WebSocketState.Connecting) || + (!open && state == WebSocketState.Open) || + (!closing && state == WebSocketState.Closing) || + (!closed && state == WebSocketState.Closed) + ? "This operation isn't available in: " + state : null; } @@ -241,13 +231,6 @@ internal static string CheckIfCanRead (this Stream stream) : null; } - internal static string CheckIfCanSend (this WebSocketState state) - { - return state != WebSocketState.Open - ? String.Format ("This operation isn't available ({0}).", state) - : null; - } - internal static string CheckIfValidProtocols (this string[] protocols) { return protocols.Contains ( diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index d874713c5..536c9126e 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -596,7 +596,7 @@ public TimeSpan WaitTime { private bool accept () { lock (_forConn) { - var msg = _readyState.CheckIfCanAccept (); + var msg = _readyState.CheckIfAvailable (true, false, false, false); if (msg != null) { _logger.Error (msg); error ("An error has occurred in accepting.", null); @@ -659,14 +659,14 @@ private string checkIfCanAccept () { return _client ? "This operation isn't available in the client." - : _readyState.CheckIfCanAccept (); + : _readyState.CheckIfAvailable (true, false, false, false); } private string checkIfCanConnect () { return !_client ? "This operation isn't available in the server." - : _readyState.CheckIfCanConnect (); + : _readyState.CheckIfAvailable (true, false, false, true); } // As server @@ -791,7 +791,7 @@ private bool closeHandshake (byte[] frameAsBytes, TimeSpan timeout, Action relea private bool connect () { lock (_forConn) { - var msg = _readyState.CheckIfCanConnect (); + var msg = _readyState.CheckIfAvailable (true, false, false, true); if (msg != null) { _logger.Error (msg); error ("An error has occurred in connecting.", null); @@ -1806,7 +1806,7 @@ public void AcceptAsync () /// public void Close () { - var msg = _readyState.CheckIfCanClose (); + var msg = _readyState.CheckIfAvailable (true, true, false, false); if (msg != null) { _logger.Error (msg); error ("An error has occurred in closing the connection.", null); @@ -1830,7 +1830,9 @@ public void Close () /// public void Close (ushort code) { - var msg = _readyState.CheckIfCanClose () ?? CheckCloseParameters (code, null, _client); + var msg = _readyState.CheckIfAvailable (true, true, false, false) ?? + CheckCloseParameters (code, null, _client); + if (msg != null) { _logger.Error (msg); error ("An error has occurred in closing the connection.", null); @@ -1857,7 +1859,9 @@ public void Close (ushort code) /// public void Close (CloseStatusCode code) { - var msg = _readyState.CheckIfCanClose () ?? CheckCloseParameters (code, null, _client); + var msg = _readyState.CheckIfAvailable (true, true, false, false) ?? + CheckCloseParameters (code, null, _client); + if (msg != null) { _logger.Error (msg); error ("An error has occurred in closing the connection.", null); @@ -1891,7 +1895,9 @@ public void Close (CloseStatusCode code) /// public void Close (ushort code, string reason) { - var msg = _readyState.CheckIfCanClose () ?? CheckCloseParameters (code, reason, _client); + var msg = _readyState.CheckIfAvailable (true, true, false, false) ?? + CheckCloseParameters (code, reason, _client); + if (msg != null) { _logger.Error (msg); error ("An error has occurred in closing the connection.", null); @@ -1925,7 +1931,9 @@ public void Close (ushort code, string reason) /// public void Close (CloseStatusCode code, string reason) { - var msg = _readyState.CheckIfCanClose () ?? CheckCloseParameters (code, reason, _client); + var msg = _readyState.CheckIfAvailable (true, true, false, false) ?? + CheckCloseParameters (code, reason, _client); + if (msg != null) { _logger.Error (msg); error ("An error has occurred in closing the connection.", null); @@ -1950,7 +1958,7 @@ public void Close (CloseStatusCode code, string reason) /// public void CloseAsync () { - var msg = _readyState.CheckIfCanClose (); + var msg = _readyState.CheckIfAvailable (true, true, false, false); if (msg != null) { _logger.Error (msg); error ("An error has occurred in closing the connection.", null); @@ -1979,7 +1987,9 @@ public void CloseAsync () /// public void CloseAsync (ushort code) { - var msg = _readyState.CheckIfCanClose () ?? CheckCloseParameters (code, null, _client); + var msg = _readyState.CheckIfAvailable (true, true, false, false) ?? + CheckCloseParameters (code, null, _client); + if (msg != null) { _logger.Error (msg); error ("An error has occurred in closing the connection.", null); @@ -2009,7 +2019,9 @@ public void CloseAsync (ushort code) /// public void CloseAsync (CloseStatusCode code) { - var msg = _readyState.CheckIfCanClose () ?? CheckCloseParameters (code, null, _client); + var msg = _readyState.CheckIfAvailable (true, true, false, false) ?? + CheckCloseParameters (code, null, _client); + if (msg != null) { _logger.Error (msg); error ("An error has occurred in closing the connection.", null); @@ -2048,7 +2060,9 @@ public void CloseAsync (CloseStatusCode code) /// public void CloseAsync (ushort code, string reason) { - var msg = _readyState.CheckIfCanClose () ?? CheckCloseParameters (code, reason, _client); + var msg = _readyState.CheckIfAvailable (true, true, false, false) ?? + CheckCloseParameters (code, reason, _client); + if (msg != null) { _logger.Error (msg); error ("An error has occurred in closing the connection.", null); @@ -2088,7 +2102,9 @@ public void CloseAsync (ushort code, string reason) /// public void CloseAsync (CloseStatusCode code, string reason) { - var msg = _readyState.CheckIfCanClose () ?? CheckCloseParameters (code, reason, _client); + var msg = _readyState.CheckIfAvailable (true, true, false, false) ?? + CheckCloseParameters (code, reason, _client); + if (msg != null) { _logger.Error (msg); error ("An error has occurred in closing the connection.", null); @@ -2206,7 +2222,9 @@ public bool Ping (string message) /// public void Send (byte[] data) { - var msg = _readyState.CheckIfCanSend () ?? data.CheckIfValidSendData (); + var msg = _readyState.CheckIfAvailable (false, true, false, false) ?? + data.CheckIfValidSendData (); + if (msg != null) { _logger.Error (msg); error ("An error has occurred in sending the data.", null); @@ -2225,7 +2243,9 @@ public void Send (byte[] data) /// public void Send (FileInfo file) { - var msg = _readyState.CheckIfCanSend () ?? file.CheckIfValidSendData (); + var msg = _readyState.CheckIfAvailable (false, true, false, false) ?? + file.CheckIfValidSendData (); + if (msg != null) { _logger.Error (msg); error ("An error has occurred in sending the data.", null); @@ -2244,7 +2264,9 @@ public void Send (FileInfo file) /// public void Send (string data) { - var msg = _readyState.CheckIfCanSend () ?? data.CheckIfValidSendData (); + var msg = _readyState.CheckIfAvailable (false, true, false, false) ?? + data.CheckIfValidSendData (); + if (msg != null) { _logger.Error (msg); error ("An error has occurred in sending the data.", null); @@ -2271,7 +2293,9 @@ public void Send (string data) /// public void SendAsync (byte[] data, Action completed) { - var msg = _readyState.CheckIfCanSend () ?? data.CheckIfValidSendData (); + var msg = _readyState.CheckIfAvailable (false, true, false, false) ?? + data.CheckIfValidSendData (); + if (msg != null) { _logger.Error (msg); error ("An error has occurred in sending the data.", null); @@ -2299,7 +2323,9 @@ public void SendAsync (byte[] data, Action completed) /// public void SendAsync (FileInfo file, Action completed) { - var msg = _readyState.CheckIfCanSend () ?? file.CheckIfValidSendData (); + var msg = _readyState.CheckIfAvailable (false, true, false, false) ?? + file.CheckIfValidSendData (); + if (msg != null) { _logger.Error (msg); error ("An error has occurred in sending the data.", null); @@ -2326,7 +2352,9 @@ public void SendAsync (FileInfo file, Action completed) /// public void SendAsync (string data, Action completed) { - var msg = _readyState.CheckIfCanSend () ?? data.CheckIfValidSendData (); + var msg = _readyState.CheckIfAvailable (false, true, false, false) ?? + data.CheckIfValidSendData (); + if (msg != null) { _logger.Error (msg); error ("An error has occurred in sending the data.", null); @@ -2357,7 +2385,7 @@ public void SendAsync (string data, Action completed) /// public void SendAsync (Stream stream, int length, Action completed) { - var msg = _readyState.CheckIfCanSend () ?? + var msg = _readyState.CheckIfAvailable (false, true, false, false) ?? stream.CheckIfCanRead () ?? (length < 1 ? "'length' is less than 1." : null); From b0048a213a0fa8dc8905fa1df2f2cb76be25e29c Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 16 Aug 2015 17:26:22 +0900 Subject: [PATCH 0071/6294] Refactored a few for WebSocket.cs --- websocket-sharp/WebSocket.cs | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 536c9126e..a9d2688e4 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -651,7 +651,7 @@ private string checkIfAvailable (bool server, bool connected) return !server && !_client ? "This operation isn't available in the server." : !connected && IsConnected - ? "This operation isn't available after the connection has been established." + ? "This operation isn't available in: " + _readyState : null; } @@ -722,8 +722,13 @@ private string checkIfValidReceivedFrame (WebSocketFrame frame) private void close (CloseEventArgs e, bool send, bool wait) { lock (_forConn) { - if (_readyState == WebSocketState.Closing || _readyState == WebSocketState.Closed) { - _logger.Info ("Closing the connection has already been done."); + if (_readyState == WebSocketState.Closing) { + _logger.Info ("The closing is already in progress."); + return; + } + + if (_readyState == WebSocketState.Closed) { + _logger.Info ("The connection has been closed."); return; } @@ -1152,7 +1157,7 @@ private bool send (byte[] frameAsBytes) { lock (_forConn) { if (_readyState != WebSocketState.Open) { - _logger.Error ("Closing the connection has been done."); + _logger.Error ("The sending has been interrupted."); return false; } @@ -1174,7 +1179,7 @@ private bool send (Opcode opcode, Stream stream) sent = send (opcode, stream, compressed); if (!sent) - error ("Sending the data has been interrupted.", null); + error ("The sending has been interrupted.", null); } catch (Exception ex) { _logger.Fatal (ex.ToString ()); @@ -1241,7 +1246,7 @@ private bool send (Fin fin, Opcode opcode, byte[] data, bool compressed) { lock (_forConn) { if (_readyState != WebSocketState.Open) { - _logger.Error ("Closing the connection has been done."); + _logger.Error ("The sending has been interrupted."); return false; } @@ -1625,8 +1630,13 @@ internal void Close (HttpStatusCode code) internal void Close (CloseEventArgs e, byte[] frameAsBytes, TimeSpan timeout) { lock (_forConn) { - if (_readyState == WebSocketState.Closing || _readyState == WebSocketState.Closed) { - _logger.Info ("Closing the connection has already been done."); + if (_readyState == WebSocketState.Closing) { + _logger.Info ("The closing is already in progress."); + return; + } + + if (_readyState == WebSocketState.Closed) { + _logger.Info ("The connection has been closed."); return; } @@ -1698,7 +1708,7 @@ internal void Send (Opcode opcode, byte[] data, Dictionary Date: Mon, 17 Aug 2015 17:00:29 +0900 Subject: [PATCH 0072/6294] Refactored a few for WebSocket.cs --- websocket-sharp/WebSocket.cs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index a9d2688e4..3357bd577 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -114,7 +114,23 @@ private Func #region Internal Fields - internal const int FragmentLength = 1016; // Max value is Int32.MaxValue - 14. + /// + /// Represents the length to determine whether the data should be fragmented in sending. + /// + /// + /// + /// The data will be fragmented if that length is greater than this. + /// + /// + /// If you would like to change this value, you must set this to a value between 1 and + /// Int32.MaxValue - 14 inclusive. + /// + /// + internal const int FragmentLength = 1016; + + /// + /// Represents the random number generator to use internally. + /// internal static readonly RandomNumberGenerator RandomNumber = new RNGCryptoServiceProvider (); #endregion From 009ca2d701d0d04b3fdfaa474342abf79f3cb07e Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 18 Aug 2015 12:36:53 +0900 Subject: [PATCH 0073/6294] Refactored a few for WebSocket.cs --- websocket-sharp/WebSocket.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 3357bd577..ae90b230d 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -115,7 +115,7 @@ private Func #region Internal Fields /// - /// Represents the length to determine whether the data should be fragmented in sending. + /// Represents the length used to determine whether the data should be fragmented in sending. /// /// /// @@ -129,7 +129,7 @@ private Func internal const int FragmentLength = 1016; /// - /// Represents the random number generator to use internally. + /// Represents the random number generator used internally. /// internal static readonly RandomNumberGenerator RandomNumber = new RNGCryptoServiceProvider (); From 170977586a7dfab96eaa28855ee6ce664b5436d2 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 18 Aug 2015 13:05:22 +0900 Subject: [PATCH 0074/6294] Refactored a few for WebSocketServiceHost.cs --- websocket-sharp/Server/WebSocketServiceHost.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceHost.cs b/websocket-sharp/Server/WebSocketServiceHost.cs index 1db348ec2..1bf444416 100644 --- a/websocket-sharp/Server/WebSocketServiceHost.cs +++ b/websocket-sharp/Server/WebSocketServiceHost.cs @@ -41,7 +41,7 @@ namespace WebSocketSharp.Server { /// /// Exposes the methods and properties used to access the information in a WebSocket service - /// provided by the or . + /// provided by the or . /// /// /// The WebSocketServiceHost class is an abstract class. @@ -131,7 +131,6 @@ internal void StartSession (WebSocketContext context) internal void Stop (ushort code, string reason) { var e = new CloseEventArgs (code, reason); - var send = !code.IsReserved (); var bytes = send ? WebSocketFrame.CreateCloseFrame (e.PayloadData, false).ToByteArray () : null; From 18b980fc980d0ba97b329ecc3d3d4d69071c8e7a Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 18 Aug 2015 13:15:58 +0900 Subject: [PATCH 0075/6294] Modified a bit for WebSocketServiceHost.cs, into the year 2015 --- websocket-sharp/Server/WebSocketServiceHost.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServiceHost.cs b/websocket-sharp/Server/WebSocketServiceHost.cs index 1bf444416..f7a78ff45 100644 --- a/websocket-sharp/Server/WebSocketServiceHost.cs +++ b/websocket-sharp/Server/WebSocketServiceHost.cs @@ -4,7 +4,7 @@ * * The MIT License * - * Copyright (c) 2012-2014 sta.blockhead + * Copyright (c) 2012-2015 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From f852a197469150fc2df902f561c80727b2ca66b7 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 19 Aug 2015 15:47:57 +0900 Subject: [PATCH 0076/6294] Refactored WebSocketServiceHost.cs, separated the WebSocketServiceHost class into a new file --- .../Server/WebSocketServiceHost.cs | 91 ------------- .../Server/WebSocketServiceHost`1.cs | 122 ++++++++++++++++++ websocket-sharp/websocket-sharp.csproj | 1 + 3 files changed, 123 insertions(+), 91 deletions(-) create mode 100644 websocket-sharp/Server/WebSocketServiceHost`1.cs diff --git a/websocket-sharp/Server/WebSocketServiceHost.cs b/websocket-sharp/Server/WebSocketServiceHost.cs index f7a78ff45..860019a5c 100644 --- a/websocket-sharp/Server/WebSocketServiceHost.cs +++ b/websocket-sharp/Server/WebSocketServiceHost.cs @@ -34,7 +34,6 @@ #endregion using System; -using WebSocketSharp.Net; using WebSocketSharp.Net.WebSockets; namespace WebSocketSharp.Server @@ -153,94 +152,4 @@ internal void Stop (ushort code, string reason) #endregion } - - internal class WebSocketServiceHost : WebSocketServiceHost - where TBehavior : WebSocketBehavior - { - #region Private Fields - - private Func _initializer; - private Logger _logger; - private string _path; - private WebSocketSessionManager _sessions; - - #endregion - - #region Internal Constructors - - internal WebSocketServiceHost (string path, Func initializer, Logger logger) - { - _path = path; - _initializer = initializer; - _logger = logger; - _sessions = new WebSocketSessionManager (logger); - } - - #endregion - - #region Public Properties - - public override bool KeepClean { - get { - return _sessions.KeepClean; - } - - set { - var msg = _sessions.State.CheckIfAvailable (true, false, false); - if (msg != null) { - _logger.Error (msg); - return; - } - - _sessions.KeepClean = value; - } - } - - public override string Path { - get { - return _path; - } - } - - public override WebSocketSessionManager Sessions { - get { - return _sessions; - } - } - - public override Type Type { - get { - return typeof (TBehavior); - } - } - - public override TimeSpan WaitTime { - get { - return _sessions.WaitTime; - } - - set { - var msg = _sessions.State.CheckIfAvailable (true, false, false) ?? - value.CheckIfValidWaitTime (); - - if (msg != null) { - _logger.Error (msg); - return; - } - - _sessions.WaitTime = value; - } - } - - #endregion - - #region Protected Methods - - protected override WebSocketBehavior CreateSession () - { - return _initializer (); - } - - #endregion - } } diff --git a/websocket-sharp/Server/WebSocketServiceHost`1.cs b/websocket-sharp/Server/WebSocketServiceHost`1.cs new file mode 100644 index 000000000..78e3983e8 --- /dev/null +++ b/websocket-sharp/Server/WebSocketServiceHost`1.cs @@ -0,0 +1,122 @@ +#region License +/* + * WebSocketServiceHost`1.cs + * + * The MIT License + * + * Copyright (c) 2015 sta.blockhead + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, 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 NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +#endregion + +using System; + +namespace WebSocketSharp.Server +{ + internal class WebSocketServiceHost : WebSocketServiceHost + where TBehavior : WebSocketBehavior + { + #region Private Fields + + private Func _initializer; + private Logger _logger; + private string _path; + private WebSocketSessionManager _sessions; + + #endregion + + #region Internal Constructors + + internal WebSocketServiceHost (string path, Func initializer, Logger logger) + { + _path = path; + _initializer = initializer; + _logger = logger; + _sessions = new WebSocketSessionManager (logger); + } + + #endregion + + #region Public Properties + + public override bool KeepClean { + get { + return _sessions.KeepClean; + } + + set { + var msg = _sessions.State.CheckIfAvailable (true, false, false); + if (msg != null) { + _logger.Error (msg); + return; + } + + _sessions.KeepClean = value; + } + } + + public override string Path { + get { + return _path; + } + } + + public override WebSocketSessionManager Sessions { + get { + return _sessions; + } + } + + public override Type Type { + get { + return typeof (TBehavior); + } + } + + public override TimeSpan WaitTime { + get { + return _sessions.WaitTime; + } + + set { + var msg = _sessions.State.CheckIfAvailable (true, false, false) ?? + value.CheckIfValidWaitTime (); + + if (msg != null) { + _logger.Error (msg); + return; + } + + _sessions.WaitTime = value; + } + } + + #endregion + + #region Protected Methods + + protected override WebSocketBehavior CreateSession () + { + return _initializer (); + } + + #endregion + } +} diff --git a/websocket-sharp/websocket-sharp.csproj b/websocket-sharp/websocket-sharp.csproj index c1192aaa7..087679547 100644 --- a/websocket-sharp/websocket-sharp.csproj +++ b/websocket-sharp/websocket-sharp.csproj @@ -139,6 +139,7 @@ + From 09a64d67be836adb10641af586737f7c4371de72 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 20 Aug 2015 16:36:14 +0900 Subject: [PATCH 0077/6294] Added the WebSocket.CheckSendParameter methods --- websocket-sharp/Ext.cs | 15 ----------- .../Server/WebSocketServiceManager.cs | 16 ++++++++--- .../Server/WebSocketSessionManager.cs | 16 ++++++++--- websocket-sharp/WebSocket.cs | 27 ++++++++++++++----- 4 files changed, 45 insertions(+), 29 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 4d781d322..634538e5c 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -241,21 +241,6 @@ internal static string CheckIfValidProtocols (this string[] protocols) : null; } - internal static string CheckIfValidSendData (this byte[] data) - { - return data == null ? "'data' is null." : null; - } - - internal static string CheckIfValidSendData (this FileInfo file) - { - return file == null ? "'file' is null." : null; - } - - internal static string CheckIfValidSendData (this string data) - { - return data == null ? "'data' is null." : null; - } - internal static string CheckIfValidServicePath (this string path) { return path == null || path.Length == 0 diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index 2e3a218b7..bd1269d9b 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -385,7 +385,9 @@ internal void Stop (CloseEventArgs e, bool send, bool wait) /// public void Broadcast (byte[] data) { - var msg = _state.CheckIfAvailable (false, true, false) ?? data.CheckIfValidSendData (); + var msg = _state.CheckIfAvailable (false, true, false) ?? + WebSocket.CheckSendParameter (data); + if (msg != null) { _logger.Error (msg); return; @@ -405,7 +407,9 @@ public void Broadcast (byte[] data) /// public void Broadcast (string data) { - var msg = _state.CheckIfAvailable (false, true, false) ?? data.CheckIfValidSendData (); + var msg = _state.CheckIfAvailable (false, true, false) ?? + WebSocket.CheckSendParameter (data); + if (msg != null) { _logger.Error (msg); return; @@ -434,7 +438,9 @@ public void Broadcast (string data) /// public void BroadcastAsync (byte[] data, Action completed) { - var msg = _state.CheckIfAvailable (false, true, false) ?? data.CheckIfValidSendData (); + var msg = _state.CheckIfAvailable (false, true, false) ?? + WebSocket.CheckSendParameter (data); + if (msg != null) { _logger.Error (msg); return; @@ -462,7 +468,9 @@ public void BroadcastAsync (byte[] data, Action completed) /// public void BroadcastAsync (string data, Action completed) { - var msg = _state.CheckIfAvailable (false, true, false) ?? data.CheckIfValidSendData (); + var msg = _state.CheckIfAvailable (false, true, false) ?? + WebSocket.CheckSendParameter (data); + if (msg != null) { _logger.Error (msg); return; diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index ddd0ca6fb..de4729254 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -393,7 +393,9 @@ internal void Stop (CloseEventArgs e, byte[] frameAsBytes, TimeSpan timeout) /// public void Broadcast (byte[] data) { - var msg = _state.CheckIfAvailable (false, true, false) ?? data.CheckIfValidSendData (); + var msg = _state.CheckIfAvailable (false, true, false) ?? + WebSocket.CheckSendParameter (data); + if (msg != null) { _logger.Error (msg); return; @@ -413,7 +415,9 @@ public void Broadcast (byte[] data) /// public void Broadcast (string data) { - var msg = _state.CheckIfAvailable (false, true, false) ?? data.CheckIfValidSendData (); + var msg = _state.CheckIfAvailable (false, true, false) ?? + WebSocket.CheckSendParameter (data); + if (msg != null) { _logger.Error (msg); return; @@ -442,7 +446,9 @@ public void Broadcast (string data) /// public void BroadcastAsync (byte[] data, Action completed) { - var msg = _state.CheckIfAvailable (false, true, false) ?? data.CheckIfValidSendData (); + var msg = _state.CheckIfAvailable (false, true, false) ?? + WebSocket.CheckSendParameter (data); + if (msg != null) { _logger.Error (msg); return; @@ -470,7 +476,9 @@ public void BroadcastAsync (byte[] data, Action completed) /// public void BroadcastAsync (string data, Action completed) { - var msg = _state.CheckIfAvailable (false, true, false) ?? data.CheckIfValidSendData (); + var msg = _state.CheckIfAvailable (false, true, false) ?? + WebSocket.CheckSendParameter (data); + if (msg != null) { _logger.Error (msg); return; diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index ae90b230d..77fcc7fdb 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1625,6 +1625,21 @@ internal static string CheckPingParameter (string message, out byte[] bytes) return bytes.Length > 125 ? "A message has greater than the allowable max size." : null; } + internal static string CheckSendParameter (byte[] data) + { + return data == null ? "'data' is null." : null; + } + + internal static string CheckSendParameter (FileInfo file) + { + return file == null ? "'file' is null." : null; + } + + internal static string CheckSendParameter (string data) + { + return data == null ? "'data' is null." : null; + } + // As server internal void Close (HttpResponse response) { @@ -2249,7 +2264,7 @@ public bool Ping (string message) public void Send (byte[] data) { var msg = _readyState.CheckIfAvailable (false, true, false, false) ?? - data.CheckIfValidSendData (); + CheckSendParameter (data); if (msg != null) { _logger.Error (msg); @@ -2270,7 +2285,7 @@ public void Send (byte[] data) public void Send (FileInfo file) { var msg = _readyState.CheckIfAvailable (false, true, false, false) ?? - file.CheckIfValidSendData (); + CheckSendParameter (file); if (msg != null) { _logger.Error (msg); @@ -2291,7 +2306,7 @@ public void Send (FileInfo file) public void Send (string data) { var msg = _readyState.CheckIfAvailable (false, true, false, false) ?? - data.CheckIfValidSendData (); + CheckSendParameter (data); if (msg != null) { _logger.Error (msg); @@ -2320,7 +2335,7 @@ public void Send (string data) public void SendAsync (byte[] data, Action completed) { var msg = _readyState.CheckIfAvailable (false, true, false, false) ?? - data.CheckIfValidSendData (); + CheckSendParameter (data); if (msg != null) { _logger.Error (msg); @@ -2350,7 +2365,7 @@ public void SendAsync (byte[] data, Action completed) public void SendAsync (FileInfo file, Action completed) { var msg = _readyState.CheckIfAvailable (false, true, false, false) ?? - file.CheckIfValidSendData (); + CheckSendParameter (file); if (msg != null) { _logger.Error (msg); @@ -2379,7 +2394,7 @@ public void SendAsync (FileInfo file, Action completed) public void SendAsync (string data, Action completed) { var msg = _readyState.CheckIfAvailable (false, true, false, false) ?? - data.CheckIfValidSendData (); + CheckSendParameter (data); if (msg != null) { _logger.Error (msg); From ddb5819a0eb3d978cd7bdd7bb7b483e76aef1e9e Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 21 Aug 2015 16:31:50 +0900 Subject: [PATCH 0078/6294] Added the WebSocket.CheckSendParameters method --- websocket-sharp/Ext.cs | 9 --------- websocket-sharp/Server/WebSocketServiceManager.cs | 3 +-- websocket-sharp/Server/WebSocketSessionManager.cs | 3 +-- websocket-sharp/WebSocket.cs | 14 ++++++++++++-- 4 files changed, 14 insertions(+), 15 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 634538e5c..a45fda846 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -222,15 +222,6 @@ internal static string CheckIfAvailable ( : null; } - internal static string CheckIfCanRead (this Stream stream) - { - return stream == null - ? "'stream' is null." - : !stream.CanRead - ? "'stream' cannot be read." - : null; - } - internal static string CheckIfValidProtocols (this string[] protocols) { return protocols.Contains ( diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index bd1269d9b..3f2240030 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -503,8 +503,7 @@ public void BroadcastAsync (string data, Action completed) public void BroadcastAsync (Stream stream, int length, Action completed) { var msg = _state.CheckIfAvailable (false, true, false) ?? - stream.CheckIfCanRead () ?? - (length < 1 ? "'length' is less than 1." : null); + WebSocket.CheckSendParameters (stream, length); if (msg != null) { _logger.Error (msg); diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index de4729254..96fd62358 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -511,8 +511,7 @@ public void BroadcastAsync (string data, Action completed) public void BroadcastAsync (Stream stream, int length, Action completed) { var msg = _state.CheckIfAvailable (false, true, false) ?? - stream.CheckIfCanRead () ?? - (length < 1 ? "'length' is less than 1." : null); + WebSocket.CheckSendParameters (stream, length); if (msg != null) { _logger.Error (msg); diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 77fcc7fdb..e6f1b3a07 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1640,6 +1640,17 @@ internal static string CheckSendParameter (string data) return data == null ? "'data' is null." : null; } + internal static string CheckSendParameters (Stream stream, int length) + { + return stream == null + ? "'stream' is null." + : !stream.CanRead + ? "'stream' cannot be read." + : length < 1 + ? "'length' is less than 1." + : null; + } + // As server internal void Close (HttpResponse response) { @@ -2427,8 +2438,7 @@ public void SendAsync (string data, Action completed) public void SendAsync (Stream stream, int length, Action completed) { var msg = _readyState.CheckIfAvailable (false, true, false, false) ?? - stream.CheckIfCanRead () ?? - (length < 1 ? "'length' is less than 1." : null); + CheckSendParameters (stream, length); if (msg != null) { _logger.Error (msg); From f8f68e49b0e517e24fa19613416a18591f5ba94d Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 22 Aug 2015 11:50:19 +0900 Subject: [PATCH 0079/6294] Added the Ext.UTF8Decode method --- websocket-sharp/CloseEventArgs.cs | 2 +- websocket-sharp/Ext.cs | 10 ++++++++++ websocket-sharp/MessageEventArgs.cs | 16 +--------------- 3 files changed, 12 insertions(+), 16 deletions(-) diff --git a/websocket-sharp/CloseEventArgs.cs b/websocket-sharp/CloseEventArgs.cs index c687bd524..d7929a8bf 100644 --- a/websocket-sharp/CloseEventArgs.cs +++ b/websocket-sharp/CloseEventArgs.cs @@ -87,7 +87,7 @@ internal CloseEventArgs (PayloadData payloadData) : (ushort) CloseStatusCode.NoStatus; _reason = len > 2 - ? Encoding.UTF8.GetString (_rawData.SubArray (2, len - 2)) + ? _rawData.SubArray (2, len - 2).UTF8Decode () : String.Empty; } diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index a45fda846..07b16c796 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -838,6 +838,16 @@ internal static string Unquote (this string value) : value.Substring (start + 1, len).Replace ("\\\"", "\""); } + internal static string UTF8Decode (this byte[] bytes) + { + try { + return Encoding.UTF8.GetString (bytes); + } + catch { + return null; + } + } + internal static void WriteBytes (this Stream stream, byte[] bytes) { using (var input = new MemoryStream (bytes)) diff --git a/websocket-sharp/MessageEventArgs.cs b/websocket-sharp/MessageEventArgs.cs index 0ae9d48b8..947a1adf4 100644 --- a/websocket-sharp/MessageEventArgs.cs +++ b/websocket-sharp/MessageEventArgs.cs @@ -88,7 +88,7 @@ public string Data { get { if (!_dataSet) { _data = _opcode != Opcode.Binary - ? convertToString (_rawData) + ? _rawData.UTF8Decode () : BitConverter.ToString (_rawData); _dataSet = true; @@ -123,19 +123,5 @@ public Opcode Type { } #endregion - - #region Private Methods - - private static string convertToString (byte[] rawData) - { - try { - return Encoding.UTF8.GetString (rawData); - } - catch { - return null; - } - } - - #endregion } } From cd886d32dfd09ab4fe1db9f06b319907673e8018 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 23 Aug 2015 16:31:18 +0900 Subject: [PATCH 0080/6294] Added the Ext.UTF8Encode method --- websocket-sharp/Ext.cs | 5 +++++ websocket-sharp/Server/WebSocketServiceManager.cs | 4 ++-- websocket-sharp/Server/WebSocketSessionManager.cs | 4 ++-- websocket-sharp/WebSocket.cs | 12 ++++++------ 4 files changed, 15 insertions(+), 10 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 07b16c796..cbb954abd 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -848,6 +848,11 @@ internal static string UTF8Decode (this byte[] bytes) } } + internal static byte[] UTF8Encode (this string s) + { + return Encoding.UTF8.GetBytes (s); + } + internal static void WriteBytes (this Stream stream, byte[] bytes) { using (var input = new MemoryStream (bytes)) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index 3f2240030..e28f44908 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -415,7 +415,7 @@ public void Broadcast (string data) return; } - var bytes = Encoding.UTF8.GetBytes (data); + var bytes = data.UTF8Encode (); if (bytes.LongLength <= WebSocket.FragmentLength) broadcast (Opcode.Text, bytes, null); else @@ -476,7 +476,7 @@ public void BroadcastAsync (string data, Action completed) return; } - var bytes = Encoding.UTF8.GetBytes (data); + var bytes = data.UTF8Encode (); if (bytes.LongLength <= WebSocket.FragmentLength) broadcastAsync (Opcode.Text, bytes, completed); else diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 96fd62358..1c27e341a 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -423,7 +423,7 @@ public void Broadcast (string data) return; } - var bytes = Encoding.UTF8.GetBytes (data); + var bytes = data.UTF8Encode (); if (bytes.LongLength <= WebSocket.FragmentLength) broadcast (Opcode.Text, bytes, null); else @@ -484,7 +484,7 @@ public void BroadcastAsync (string data, Action completed) return; } - var bytes = Encoding.UTF8.GetBytes (data); + var bytes = data.UTF8Encode (); if (bytes.LongLength <= WebSocket.FragmentLength) broadcastAsync (Opcode.Text, bytes, completed); else diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index e6f1b3a07..7a591ffcf 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1601,7 +1601,7 @@ internal static string CheckCloseParameters (ushort code, string reason, bool cl ? "MandatoryExtension cannot be used by the server." : code == (ushort) CloseStatusCode.ServerError && client ? "ServerError cannot be used by the client." - : !reason.IsNullOrEmpty () && Encoding.UTF8.GetBytes (reason).Length > 123 + : !reason.IsNullOrEmpty () && reason.UTF8Encode ().Length > 123 ? "A reason has greater than the allowable max size." : null; } @@ -1614,14 +1614,14 @@ internal static string CheckCloseParameters (CloseStatusCode code, string reason ? "MandatoryExtension cannot be used by the server." : code == CloseStatusCode.ServerError && client ? "ServerError cannot be used by the client." - : !reason.IsNullOrEmpty () && Encoding.UTF8.GetBytes (reason).Length > 123 + : !reason.IsNullOrEmpty () && reason.UTF8Encode ().Length > 123 ? "A reason has greater than the allowable max size." : null; } internal static string CheckPingParameter (string message, out byte[] bytes) { - bytes = Encoding.UTF8.GetBytes (message); + bytes = message.UTF8Encode (); return bytes.Length > 125 ? "A message has greater than the allowable max size." : null; } @@ -1710,7 +1710,7 @@ internal static string CreateResponseKey (string base64Key) var buff = new StringBuilder (base64Key, 64); buff.Append (_guid); SHA1 sha1 = new SHA1CryptoServiceProvider (); - var src = sha1.ComputeHash (Encoding.UTF8.GetBytes (buff.ToString ())); + var src = sha1.ComputeHash (buff.ToString ().UTF8Encode ()); return Convert.ToBase64String (src); } @@ -2326,7 +2326,7 @@ public void Send (string data) return; } - send (Opcode.Text, new MemoryStream (Encoding.UTF8.GetBytes (data))); + send (Opcode.Text, new MemoryStream (data.UTF8Encode ())); } /// @@ -2414,7 +2414,7 @@ public void SendAsync (string data, Action completed) return; } - sendAsync (Opcode.Text, new MemoryStream (Encoding.UTF8.GetBytes (data)), completed); + sendAsync (Opcode.Text, new MemoryStream (data.UTF8Encode ()), completed); } /// From 9ff19e6ecd3956e8a392dee45011db67adf248be Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 24 Aug 2015 16:03:50 +0900 Subject: [PATCH 0081/6294] Added the internal WebSocket.EmptyBytes field --- websocket-sharp/Ext.cs | 12 +++--------- websocket-sharp/PayloadData.cs | 4 ++-- websocket-sharp/WebSocket.cs | 7 ++++++- websocket-sharp/WebSocketFrame.cs | 12 ++++++------ 4 files changed, 17 insertions(+), 18 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index cbb954abd..2dccd4d77 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -70,12 +70,6 @@ public static class Ext #endregion - #region Internal Fields - - internal static readonly byte[] EmptyByteArray = new byte[0]; - - #endregion - #region Private Methods private static byte[] compress (this byte[] data) @@ -608,13 +602,13 @@ internal static void ReadBytesAsync ( try { var len = stream.EndRead (ar); bytes = len < 1 - ? EmptyByteArray + ? WebSocket.EmptyBytes : len < length ? stream.readBytes (buff, len, length - len) : buff; } catch { - bytes = EmptyByteArray; + bytes = WebSocket.EmptyBytes; } if (completed != null) @@ -1601,7 +1595,7 @@ public static byte[] ToByteArray (this T value, ByteOrder order) ? BitConverter.GetBytes ((UInt32)(object) value) : type == typeof (UInt64) ? BitConverter.GetBytes ((UInt64)(object) value) - : EmptyByteArray; + : WebSocket.EmptyBytes; if (bytes.Length > 1 && !order.IsHostOrder ()) Array.Reverse (bytes); diff --git a/websocket-sharp/PayloadData.cs b/websocket-sharp/PayloadData.cs index e7d7bcdad..d6991364f 100644 --- a/websocket-sharp/PayloadData.cs +++ b/websocket-sharp/PayloadData.cs @@ -54,7 +54,7 @@ internal class PayloadData : IEnumerable internal PayloadData () { - _data = Ext.EmptyByteArray; + _data = WebSocket.EmptyBytes; } internal PayloadData (byte[] data) @@ -105,7 +105,7 @@ public byte[] ExtensionData { get { return _extDataLength > 0 ? _data.SubArray (0, _extDataLength) - : Ext.EmptyByteArray; + : WebSocket.EmptyBytes; } } diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 7a591ffcf..3e38ff024 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -114,6 +114,11 @@ private Func #region Internal Fields + /// + /// Represents the empty array of used internally. + /// + internal static readonly byte[] EmptyBytes = new byte[0]; + /// /// Represents the length used to determine whether the data should be fragmented in sending. /// @@ -1219,7 +1224,7 @@ private bool send (Opcode opcode, Stream stream, bool compressed) /* Not fragmented */ if (len == 0) - return send (Fin.Final, opcode, new byte[0], compressed); + return send (Fin.Final, opcode, EmptyBytes, compressed); var quo = len / FragmentLength; var rem = (int) (len % FragmentLength); diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index 427bb597a..3a4b45a0a 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -98,7 +98,7 @@ internal WebSocketFrame ( var len = payloadData.Length; if (len < 126) { _payloadLength = (byte) len; - _extPayloadLength = Ext.EmptyByteArray; + _extPayloadLength = WebSocket.EmptyBytes; } else if (len < 0x010000) { _payloadLength = (byte) 126; @@ -116,7 +116,7 @@ internal WebSocketFrame ( } else { _mask = Mask.Unmask; - _maskingKey = Ext.EmptyByteArray; + _maskingKey = WebSocket.EmptyBytes; } _payloadData = payloadData; @@ -461,7 +461,7 @@ private static WebSocketFrame read (byte[] header, Stream stream, bool unmask) /* Extended Payload Length */ var size = payloadLen < 126 ? 0 : (payloadLen == 126 ? 2 : 8); - var extPayloadLen = size > 0 ? stream.ReadBytes (size) : Ext.EmptyByteArray; + var extPayloadLen = size > 0 ? stream.ReadBytes (size) : WebSocket.EmptyBytes; if (size > 0 && extPayloadLen.Length != size) throw new WebSocketException ( "The 'Extended Payload Length' of a frame cannot be read from the data source."); @@ -471,7 +471,7 @@ private static WebSocketFrame read (byte[] header, Stream stream, bool unmask) /* Masking Key */ var masked = mask == Mask.Mask; - var maskingKey = masked ? stream.ReadBytes (4) : Ext.EmptyByteArray; + var maskingKey = masked ? stream.ReadBytes (4) : WebSocket.EmptyBytes; if (masked && maskingKey.Length != 4) throw new WebSocketException ( "The 'Masking Key' of a frame cannot be read from the data source."); @@ -503,7 +503,7 @@ private static WebSocketFrame read (byte[] header, Stream stream, bool unmask) "The 'Payload Data' of a frame cannot be read from the data source."); } else { - data = Ext.EmptyByteArray; + data = WebSocket.EmptyBytes; } frame._payloadData = new PayloadData (data, masked); @@ -577,7 +577,7 @@ internal void Unmask () _mask = Mask.Unmask; _payloadData.Mask (_maskingKey); - _maskingKey = Ext.EmptyByteArray; + _maskingKey = WebSocket.EmptyBytes; } #endregion From 0cddc670010a3b918a45f262c974f936ec5b5462 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 25 Aug 2015 10:04:11 +0900 Subject: [PATCH 0082/6294] Initialize the continuation flag when closing --- websocket-sharp/WebSocket.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 3e38ff024..7b6a54dda 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -794,6 +794,7 @@ private bool closeHandshake (byte[] frameAsBytes, TimeSpan timeout, Action relea if (_fragmentsBuffer != null) { _fragmentsBuffer.Dispose (); _fragmentsBuffer = null; + _inContinuation = false; } if (_receivePong != null) { From 3c060c545a101392a7029d3a44327bcdbde0ea57 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 25 Aug 2015 14:29:03 +0900 Subject: [PATCH 0083/6294] Fix for pull request #155, merged https://github.com/ndevenish/websocket-sharp/commit/710b1e89b0ca52a86ef91b3124ac022594f65a2b --- websocket-sharp/Net/HttpListenerResponse.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index 8ee98cd5e..92c0a7970 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -37,6 +37,13 @@ */ #endregion +#region Contributors +/* + * Contributors: + * - Nicholas Devenish + */ +#endregion + using System; using System.Collections.Generic; using System.Globalization; @@ -565,7 +572,7 @@ internal WebHeaderCollection WriteHeadersTo (MemoryStream destination) writer.Flush (); // Assumes that the destination was at position 0. - destination.Position = enc.CodePage == 65001 ? 3 : enc.GetPreamble ().Length; + destination.Position = enc.GetPreamble ().Length; return headers; } From 2c65fd271472b36d1e27b8580a0c11eb904ae7ea Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 26 Aug 2015 15:57:25 +0900 Subject: [PATCH 0084/6294] Fix for pull request #155, merged https://github.com/ndevenish/websocket-sharp/commit/503ada402b6549e2c57af2d03e9cf12c19553ee2 --- websocket-sharp/Net/HttpListenerAsyncResult.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerAsyncResult.cs b/websocket-sharp/Net/HttpListenerAsyncResult.cs index cee32c5e7..569bac314 100644 --- a/websocket-sharp/Net/HttpListenerAsyncResult.cs +++ b/websocket-sharp/Net/HttpListenerAsyncResult.cs @@ -37,6 +37,13 @@ */ #endregion +#region Contributors +/* + * Contributors: + * - Nicholas Devenish + */ +#endregion + using System; using System.Security.Principal; using System.Threading; @@ -137,7 +144,7 @@ private static void complete (HttpListenerAsyncResult asyncResult) var callback = asyncResult._callback; if (callback != null) - ThreadPool.UnsafeQueueUserWorkItem ( + ThreadPool.QueueUserWorkItem ( state => { try { callback (asyncResult); From bdbdf64d3d780f28960cc2087da0435af32d6b6e Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 27 Aug 2015 15:58:28 +0900 Subject: [PATCH 0085/6294] Fix for pull request #155, merged https://github.com/ndevenish/websocket-sharp/commit/ddab2067da26245b52c7393b6afb1dabd8908533 --- websocket-sharp/Net/EndPointListener.cs | 34 +++++-------------------- 1 file changed, 7 insertions(+), 27 deletions(-) diff --git a/websocket-sharp/Net/EndPointListener.cs b/websocket-sharp/Net/EndPointListener.cs index 3fbf80a53..59bfbde65 100644 --- a/websocket-sharp/Net/EndPointListener.cs +++ b/websocket-sharp/Net/EndPointListener.cs @@ -41,6 +41,7 @@ /* * Contributors: * - Liryna + * - Nicholas Devenish */ #endregion @@ -115,12 +116,7 @@ internal EndPointListener ( _endpoint = new IPEndPoint (address, port); _socket.Bind (_endpoint); _socket.Listen (500); - - var args = new SocketAsyncEventArgs (); - args.UserToken = this; - args.Completed += onAccept; - if (!_socket.AcceptAsync (args)) - onAccept (this, args); + _socket.BeginAccept (onAccept, this); } #endregion @@ -241,29 +237,14 @@ private static HttpListener matchFromList ( return bestMatch; } - private static void onAccept (object sender, EventArgs e) + private static void onAccept (IAsyncResult ar) { - var args = (SocketAsyncEventArgs) e; - var lsnr = (EndPointListener) args.UserToken; + var lsnr = (EndPointListener) ar.AsyncState; Socket sock = null; - if (args.SocketError == SocketError.Success) { - sock = args.AcceptSocket; - args.AcceptSocket = null; - } - try { - while (!lsnr._socket.AcceptAsync (args)) { - if (sock != null) { - processAccepted (sock, lsnr); - sock = null; - } - - if (args.SocketError == SocketError.Success) { - sock = args.AcceptSocket; - args.AcceptSocket = null; - } - } + sock = lsnr._socket.EndAccept (ar); + lsnr._socket.BeginAccept (onAccept, lsnr); } catch { if (sock != null) @@ -272,8 +253,7 @@ private static void onAccept (object sender, EventArgs e) return; } - if (sock != null) - processAccepted (sock, lsnr); + processAccepted (sock, lsnr); } private static void processAccepted (Socket socket, EndPointListener listener) From efb922a67a49de9edd703b27cd3eeff6f38c9b7f Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 28 Aug 2015 16:52:35 +0900 Subject: [PATCH 0086/6294] Refactored a bit for EndPointListener.cs --- websocket-sharp/Net/EndPointListener.cs | 5 ++--- websocket-sharp/Net/EndPointManager.cs | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Net/EndPointListener.cs b/websocket-sharp/Net/EndPointListener.cs index 59bfbde65..40a049d3e 100644 --- a/websocket-sharp/Net/EndPointListener.cs +++ b/websocket-sharp/Net/EndPointListener.cs @@ -89,10 +89,10 @@ static EndPointListener () internal EndPointListener ( IPAddress address, int port, + bool reuseAddress, bool secure, string certificateFolderPath, - ServerSslConfiguration sslConfig, - bool reuseAddress) + ServerSslConfiguration sslConfig) { if (secure) { var cert = getCertificate (port, certificateFolderPath, sslConfig.ServerCertificate); @@ -105,7 +105,6 @@ internal EndPointListener ( } _prefixes = new Dictionary (); - _unregistered = new Dictionary (); _unregisteredSync = ((ICollection) _unregistered).SyncRoot; diff --git a/websocket-sharp/Net/EndPointManager.cs b/websocket-sharp/Net/EndPointManager.cs index c727d6503..9a82e8769 100644 --- a/websocket-sharp/Net/EndPointManager.cs +++ b/websocket-sharp/Net/EndPointManager.cs @@ -132,10 +132,10 @@ private static EndPointListener getEndPointListener ( lsnr = new EndPointListener ( addr, port, + listener.ReuseAddress, secure, listener.CertificateFolderPath, - listener.SslConfiguration, - listener.ReuseAddress); + listener.SslConfiguration); eps[port] = lsnr; } From 653064223b94e7656ce086a064d42024c8f9a23e Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 29 Aug 2015 16:37:52 +0900 Subject: [PATCH 0087/6294] Refactored a few for EndPointManager.cs --- websocket-sharp/Net/EndPointManager.cs | 31 +++++++++++++++----------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/websocket-sharp/Net/EndPointManager.cs b/websocket-sharp/Net/EndPointManager.cs index 9a82e8769..11fada49a 100644 --- a/websocket-sharp/Net/EndPointManager.cs +++ b/websocket-sharp/Net/EndPointManager.cs @@ -55,7 +55,8 @@ internal sealed class EndPointManager { #region Private Fields - private static Dictionary> _addressToEndpoints; + private static readonly Dictionary> + _addressToEndpoints; #endregion @@ -81,18 +82,19 @@ private EndPointManager () private static void addPrefix (string uriPrefix, HttpListener listener) { var pref = new HttpListenerPrefix (uriPrefix); - if (pref.Path.IndexOf ('%') != -1) + + var path = pref.Path; + if (path.IndexOf ('%') != -1) throw new HttpListenerException (400, "Invalid path."); // TODO: Code? - if (pref.Path.IndexOf ("//", StringComparison.Ordinal) != -1) + if (path.IndexOf ("//", StringComparison.Ordinal) != -1) throw new HttpListenerException (400, "Invalid path."); // TODO: Code? // Listens on all the interfaces if host name cannot be parsed by IPAddress. - var lsnr = getEndPointListener (pref.Host, pref.Port, listener, pref.IsSecure); - lsnr.AddPrefix (pref, listener); + getEndPointListener (pref, listener).AddPrefix (pref, listener); } - private static IPAddress convertToAddress (string hostname) + private static IPAddress convertToIPAddress (string hostname) { if (hostname == "*" || hostname == "+") return IPAddress.Any; @@ -111,9 +113,9 @@ private static IPAddress convertToAddress (string hostname) } private static EndPointListener getEndPointListener ( - string host, int port, HttpListener listener, bool secure) + HttpListenerPrefix prefix, HttpListener listener) { - var addr = convertToAddress (host); + var addr = convertToIPAddress (prefix.Host); Dictionary eps = null; if (_addressToEndpoints.ContainsKey (addr)) { @@ -124,6 +126,8 @@ private static EndPointListener getEndPointListener ( _addressToEndpoints[addr] = eps; } + var port = prefix.Port; + EndPointListener lsnr = null; if (eps.ContainsKey (port)) { lsnr = eps[port]; @@ -133,7 +137,7 @@ private static EndPointListener getEndPointListener ( addr, port, listener.ReuseAddress, - secure, + prefix.IsSecure, listener.CertificateFolderPath, listener.SslConfiguration); @@ -146,14 +150,15 @@ private static EndPointListener getEndPointListener ( private static void removePrefix (string uriPrefix, HttpListener listener) { var pref = new HttpListenerPrefix (uriPrefix); - if (pref.Path.IndexOf ('%') != -1) + + var path = pref.Path; + if (path.IndexOf ('%') != -1) return; - if (pref.Path.IndexOf ("//", StringComparison.Ordinal) != -1) + if (path.IndexOf ("//", StringComparison.Ordinal) != -1) return; - var lsnr = getEndPointListener (pref.Host, pref.Port, listener, pref.IsSecure); - lsnr.RemovePrefix (pref, listener); + getEndPointListener (pref, listener).RemovePrefix (pref, listener); } #endregion From 72302fba97c386fd324559d3b92803c98c6912fa Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 30 Aug 2015 17:53:12 +0900 Subject: [PATCH 0088/6294] Refactored a bit for WebSocket.cs --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 7b6a54dda..1ebbc6ebf 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -131,7 +131,7 @@ private Func /// Int32.MaxValue - 14 inclusive. /// /// - internal const int FragmentLength = 1016; + internal static readonly int FragmentLength = 1016; /// /// Represents the random number generator used internally. From 3ba410bc2e568812532afb27854cef53a7e7f611 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 31 Aug 2015 17:10:35 +0900 Subject: [PATCH 0089/6294] Added checkIfAvailable (bool, bool, bool, bool, bool, bool) method --- websocket-sharp/WebSocket.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 1ebbc6ebf..4ce4aeb5c 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -676,6 +676,16 @@ private string checkIfAvailable (bool server, bool connected) : null; } + private string checkIfAvailable ( + bool client, bool server, bool connecting, bool open, bool closing, bool closed) + { + return !client && _client + ? "This operation isn't available in the client." + : !server && !_client + ? "This operation isn't available in the server." + : _readyState.CheckIfAvailable (connecting, open, closing, closed); + } + private string checkIfCanAccept () { return _client From 1d403af6bf6655311a1aa949f6e8f3c41119d9cc Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 1 Sep 2015 17:04:43 +0900 Subject: [PATCH 0090/6294] Removed the checkIfCanConnect method --- websocket-sharp/WebSocket.cs | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 4ce4aeb5c..5c534081b 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -693,13 +693,6 @@ private string checkIfCanAccept () : _readyState.CheckIfAvailable (true, false, false, false); } - private string checkIfCanConnect () - { - return !_client - ? "This operation isn't available in the server." - : _readyState.CheckIfAvailable (true, false, false, true); - } - // As server private string checkIfValidHandshakeRequest (WebSocketContext context) { @@ -2197,7 +2190,7 @@ public void CloseAsync (CloseStatusCode code, string reason) /// public void Connect () { - var msg = checkIfCanConnect (); + var msg = checkIfAvailable (true, false, true, false, false, true); if (msg != null) { _logger.Error (msg); error ("An error has occurred in connecting.", null); @@ -2222,7 +2215,7 @@ public void Connect () /// public void ConnectAsync () { - var msg = checkIfCanConnect (); + var msg = checkIfAvailable (true, false, true, false, false, true); if (msg != null) { _logger.Error (msg); error ("An error has occurred in connecting.", null); From d07e9cb5e9dab4b918c5f069627a7d5fed5f96ff Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 2 Sep 2015 17:30:01 +0900 Subject: [PATCH 0091/6294] Removed the checkIfCanAccept method --- websocket-sharp/WebSocket.cs | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 5c534081b..53337f5b3 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -686,13 +686,6 @@ private string checkIfAvailable ( : _readyState.CheckIfAvailable (connecting, open, closing, closed); } - private string checkIfCanAccept () - { - return _client - ? "This operation isn't available in the client." - : _readyState.CheckIfAvailable (true, false, false, false); - } - // As server private string checkIfValidHandshakeRequest (WebSocketContext context) { @@ -1820,7 +1813,7 @@ internal void Send (Opcode opcode, Stream stream, Dictionary public void Accept () { - var msg = checkIfCanAccept (); + var msg = checkIfAvailable (false, true, true, false, false, false); if (msg != null) { _logger.Error (msg); error ("An error has occurred in accepting.", null); @@ -1845,7 +1838,7 @@ public void Accept () /// public void AcceptAsync () { - var msg = checkIfCanAccept (); + var msg = checkIfAvailable (false, true, true, false, false, false); if (msg != null) { _logger.Error (msg); error ("An error has occurred in accepting.", null); From c87acb5029ba645b71ccad22840bdd9505f5769e Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 3 Sep 2015 11:43:55 +0900 Subject: [PATCH 0092/6294] Refactored a bit for EndPointListener.cs --- websocket-sharp/Net/EndPointListener.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/EndPointListener.cs b/websocket-sharp/Net/EndPointListener.cs index 40a049d3e..936f81d06 100644 --- a/websocket-sharp/Net/EndPointListener.cs +++ b/websocket-sharp/Net/EndPointListener.cs @@ -236,13 +236,13 @@ private static HttpListener matchFromList ( return bestMatch; } - private static void onAccept (IAsyncResult ar) + private static void onAccept (IAsyncResult asyncResult) { - var lsnr = (EndPointListener) ar.AsyncState; + var lsnr = (EndPointListener) asyncResult.AsyncState; Socket sock = null; try { - sock = lsnr._socket.EndAccept (ar); + sock = lsnr._socket.EndAccept (asyncResult); lsnr._socket.BeginAccept (onAccept, lsnr); } catch { From de8f4caffaf0d0eb3dbace71de70b606ae0a887c Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 4 Sep 2015 11:35:50 +0900 Subject: [PATCH 0093/6294] Removed the checkIfAvailable (bool, bool) method --- websocket-sharp/WebSocket.cs | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 53337f5b3..166e685fd 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -289,7 +289,7 @@ public CompressionMethod Compression { set { lock (_forConn) { - var msg = checkIfAvailable (false, false); + var msg = checkIfAvailable (true, false, true, false, false, true); if (msg != null) { _logger.Error (msg); error ("An error has occurred in setting the compression.", null); @@ -364,7 +364,7 @@ public bool EnableRedirection { set { lock (_forConn) { - var msg = checkIfAvailable (false, false); + var msg = checkIfAvailable (true, false, true, false, false, true); if (msg != null) { _logger.Error (msg); error ("An error has occurred in setting the enable redirection.", null); @@ -460,7 +460,7 @@ public string Origin { set { lock (_forConn) { - var msg = checkIfAvailable (false, false); + var msg = checkIfAvailable (true, false, true, false, false, true); if (msg == null) { if (value.IsNullOrEmpty ()) { _origin = value; @@ -532,7 +532,7 @@ public ClientSslConfiguration SslConfiguration { set { lock (_forConn) { - var msg = checkIfAvailable (false, false); + var msg = checkIfAvailable (true, false, true, false, false, true); if (msg != null) { _logger.Error (msg); error ("An error has occurred in setting the ssl configuration.", null); @@ -572,7 +572,9 @@ public TimeSpan WaitTime { set { lock (_forConn) { - var msg = checkIfAvailable (true, false) ?? value.CheckIfValidWaitTime (); + var msg = checkIfAvailable (true, true, true, false, false, true) ?? + value.CheckIfValidWaitTime (); + if (msg != null) { _logger.Error (msg); error ("An error has occurred in setting the wait time.", null); @@ -667,15 +669,6 @@ private bool acceptHandshake () return sendHttpResponse (createHandshakeResponse ()); } - private string checkIfAvailable (bool server, bool connected) - { - return !server && !_client - ? "This operation isn't available in the server." - : !connected && IsConnected - ? "This operation isn't available in: " + _readyState - : null; - } - private string checkIfAvailable ( bool client, bool server, bool connecting, bool open, bool closing, bool closed) { @@ -2487,7 +2480,9 @@ public void SendAsync (Stream stream, int length, Action completed) public void SetCookie (Cookie cookie) { lock (_forConn) { - var msg = checkIfAvailable (false, false) ?? (cookie == null ? "'cookie' is null." : null); + var msg = checkIfAvailable (true, false, true, false, false, true) ?? + (cookie == null ? "'cookie' is null." : null); + if (msg != null) { _logger.Error (msg); error ("An error has occurred in setting the cookie.", null); @@ -2518,7 +2513,7 @@ public void SetCookie (Cookie cookie) public void SetCredentials (string username, string password, bool preAuth) { lock (_forConn) { - var msg = checkIfAvailable (false, false); + var msg = checkIfAvailable (true, false, true, false, false, true); if (msg == null) { if (username.IsNullOrEmpty ()) { _credentials = null; @@ -2565,7 +2560,7 @@ public void SetCredentials (string username, string password, bool preAuth) public void SetProxy (string url, string username, string password) { lock (_forConn) { - var msg = checkIfAvailable (false, false); + var msg = checkIfAvailable (true, false, true, false, false, true); if (msg == null) { if (url.IsNullOrEmpty ()) { _proxyUri = null; From b1e77df0b699cc9939fd94a7264b1136c2daf799 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 5 Sep 2015 14:41:56 +0900 Subject: [PATCH 0094/6294] Refactored a few for WebSocket.cs --- websocket-sharp/WebSocket.cs | 68 +++++++++++++++++------------------- 1 file changed, 33 insertions(+), 35 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 166e685fd..f901a6705 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -278,9 +278,8 @@ internal bool IsConnected { /// the WebSocket connection. /// /// - /// One of the enum values, indicates - /// the compression method used to compress the message. The default value is - /// . + /// One of the enum values, indicates the compression method + /// used to compress the message. The default value is . /// public CompressionMethod Compression { get { @@ -350,12 +349,12 @@ public bool EmitOnPing { } /// - /// Gets or sets a value indicating whether the redirects to - /// the new URL located in the handshake response. + /// Gets or sets a value indicating whether the redirects + /// the connection request to the new URL located in the connection response. /// /// - /// true if the redirects to the new URL; - /// otherwise, false. The default value is false. + /// true if the redirects the connection request to + /// the new URL; otherwise, false. The default value is false. /// public bool EnableRedirection { get { @@ -469,7 +468,7 @@ public string Origin { Uri origin; if (!Uri.TryCreate (value, UriKind.Absolute, out origin) || origin.Segments.Length > 1) - msg = "The syntax of the origin must be '://[:]'."; + msg = "The syntax of an origin must be '://[:]'."; } if (msg != null) { @@ -505,8 +504,8 @@ internal set { /// Gets the state of the WebSocket connection. /// /// - /// One of the enum values, indicates the state of - /// the WebSocket connection. The default value is . + /// One of the enum values, indicates the state of the connection. + /// The default value is . /// public WebSocketState ReadyState { get { @@ -521,7 +520,7 @@ public WebSocketState ReadyState { /// /// A that represents the configuration used /// to authenticate the server and optionally the client for secure connection, - /// or if the is used as server. + /// or if the is used in a server. /// public ClientSslConfiguration SslConfiguration { get { @@ -546,10 +545,10 @@ public ClientSslConfiguration SslConfiguration { } /// - /// Gets the WebSocket URL to connect. + /// Gets the WebSocket URL used to connect, or accepted. /// /// - /// A that represents the WebSocket URL to connect. + /// A that represents the URL used to connect, or accepted. /// public Uri Url { get { @@ -561,9 +560,8 @@ public Uri Url { /// Gets or sets the wait time for the response to the Ping or Close. /// /// - /// A that represents the wait time. The default value is - /// the same as 5 seconds, or 1 second if the is used by - /// a server. + /// A that represents the wait time. The default value is the same as + /// 5 seconds, or 1 second if the is used in a server. /// public TimeSpan WaitTime { get { @@ -673,9 +671,9 @@ private string checkIfAvailable ( bool client, bool server, bool connecting, bool open, bool closing, bool closed) { return !client && _client - ? "This operation isn't available in the client." + ? "This operation isn't available in: client" : !server && !_client - ? "This operation isn't available in the server." + ? "This operation isn't available in: server" : _readyState.CheckIfAvailable (connecting, open, closing, closed); } @@ -725,7 +723,7 @@ private string checkIfValidReceivedFrame (WebSocketFrame frame) : _inContinuation && frame.IsData ? "A data frame has been received while receiving the fragmented data." : frame.IsCompressed && _compression == CompressionMethod.None - ? "A compressed frame is without the available decompression method." + ? "A compressed frame is without an available decompression method." : null; } @@ -1593,9 +1591,9 @@ internal static string CheckCloseParameters (ushort code, string reason, bool cl : code == (ushort) CloseStatusCode.NoStatus ? (!reason.IsNullOrEmpty () ? "NoStatus cannot have a reason." : null) : code == (ushort) CloseStatusCode.MandatoryExtension && !client - ? "MandatoryExtension cannot be used by the server." + ? "MandatoryExtension cannot be used by a server." : code == (ushort) CloseStatusCode.ServerError && client - ? "ServerError cannot be used by the client." + ? "ServerError cannot be used by a client." : !reason.IsNullOrEmpty () && reason.UTF8Encode ().Length > 123 ? "A reason has greater than the allowable max size." : null; @@ -1606,9 +1604,9 @@ internal static string CheckCloseParameters (CloseStatusCode code, string reason return code == CloseStatusCode.NoStatus ? (!reason.IsNullOrEmpty () ? "NoStatus cannot have a reason." : null) : code == CloseStatusCode.MandatoryExtension && !client - ? "MandatoryExtension cannot be used by the server." + ? "MandatoryExtension cannot be used by a server." : code == CloseStatusCode.ServerError && client - ? "ServerError cannot be used by the client." + ? "ServerError cannot be used by a client." : !reason.IsNullOrEmpty () && reason.UTF8Encode ().Length > 123 ? "A reason has greater than the allowable max size." : null; @@ -1802,7 +1800,7 @@ internal void Send (Opcode opcode, Stream stream, Dictionary /// - /// This method isn't available in the client. + /// This method isn't available in a client. /// public void Accept () { @@ -1826,7 +1824,7 @@ public void Accept () /// This method doesn't wait for the accept to be complete. /// /// - /// This method isn't available in the client. + /// This method isn't available in a client. /// /// public void AcceptAsync () @@ -2172,7 +2170,7 @@ public void CloseAsync (CloseStatusCode code, string reason) /// Establishes a WebSocket connection. /// /// - /// This method isn't available in the server. + /// This method isn't available in a server. /// public void Connect () { @@ -2196,7 +2194,7 @@ public void Connect () /// This method doesn't wait for the connect to be complete. /// /// - /// This method isn't available in the server. + /// This method isn't available in a server. /// /// public void ConnectAsync () @@ -2503,12 +2501,12 @@ public void SetCookie (Cookie cookie) /// A that represents the user name used to authenticate. /// /// - /// A that represents the password for used - /// to authenticate. + /// A that represents the password for + /// used to authenticate. /// /// - /// true if the sends the Basic authentication credentials with - /// the first connection request to the server; otherwise, false. + /// true if the sends the Basic authentication credentials + /// with the first connection request to the server; otherwise, false. /// public void SetCredentials (string username, string password, bool preAuth) { @@ -2543,7 +2541,7 @@ public void SetCredentials (string username, string password, bool preAuth) } /// - /// Sets an HTTP Proxy server URL to connect through, and if necessary, + /// Sets an HTTP proxy server URL to connect through, and if necessary, /// a pair of and for /// the proxy server authentication (Basic/Digest). /// @@ -2554,8 +2552,8 @@ public void SetCredentials (string username, string password, bool preAuth) /// A that represents the user name used to authenticate. /// /// - /// A that represents the password for used - /// to authenticate. + /// A that represents the password for + /// used to authenticate. /// public void SetProxy (string url, string username, string password) { @@ -2574,7 +2572,7 @@ public void SetProxy (string url, string username, string password) if (!Uri.TryCreate (url, UriKind.Absolute, out uri) || uri.Scheme != "http" || uri.Segments.Length > 1) { - msg = "The syntax of the proxy url must be 'http://[:]'."; + msg = "The syntax of a proxy url must be 'http://[:]'."; } else { _proxyUri = uri; From 75412101d80fe476365f9141c184826b10083b35 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 6 Sep 2015 15:52:32 +0900 Subject: [PATCH 0095/6294] [Modify] Output a state in lowercase --- websocket-sharp/Ext.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 2dccd4d77..ffffd704b 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -201,7 +201,7 @@ internal static string CheckIfAvailable ( return (!ready && (state == ServerState.Ready || state == ServerState.Stop)) || (!start && state == ServerState.Start) || (!shutting && state == ServerState.ShuttingDown) - ? "This operation isn't available in: " + state + ? "This operation isn't available in: " + state.ToString ().ToLower () : null; } @@ -212,7 +212,7 @@ internal static string CheckIfAvailable ( (!open && state == WebSocketState.Open) || (!closing && state == WebSocketState.Closing) || (!closed && state == WebSocketState.Closed) - ? "This operation isn't available in: " + state + ? "This operation isn't available in: " + state.ToString ().ToLower () : null; } From ceb831b18ffe47c961d9a176ac077988193171d9 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 7 Sep 2015 21:51:49 +0900 Subject: [PATCH 0096/6294] [Modify] Add readBytesAsync method Merge a part of pull request #153 from https://github.com/cswiedler/websocket-sharp/commit/fd5fc9a5fc5fa8d993a150e40c9eeb1a02138c27. --- websocket-sharp/Ext.cs | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index ffffd704b..055a77188 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -41,6 +41,7 @@ * Contributors: * - Liryna * - Nikola Kovacevic + * - Chris Swiedler */ #endregion @@ -161,6 +162,40 @@ private static byte[] readBytes (this Stream stream, byte[] buffer, int offset, return cnt < count ? buffer.SubArray (0, offset + cnt) : buffer; } + private static void readBytesAsync ( + this Stream stream, + byte[] buffer, + int offset, + int count, + Action completed, + Action error) + { + AsyncCallback callback = ar => { + try { + var nread = stream.EndRead (ar); + if (nread < 1) { + // EOF/Disconnect before reading specified number of bytes. + completed (buffer.SubArray (0, offset)); + return; + } + + if (nread < count) { + // Need to read more. + stream.readBytesAsync (buffer, offset + nread, count - nread, completed, error); + return; + } + + completed (buffer); + } + catch (Exception ex) { + if (error != null) + error (ex); + } + }; + + stream.BeginRead (buffer, offset, count, callback, null); + } + private static void times (this ulong n, Action action) { for (ulong i = 0; i < n; i++) From 10af5c7320a6d80149b6d7213d91d0cd5ab18608 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 8 Sep 2015 10:52:57 +0900 Subject: [PATCH 0097/6294] [Modify] Add null check --- websocket-sharp/Ext.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 055a77188..ce9a95a34 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -185,7 +185,8 @@ private static void readBytesAsync ( return; } - completed (buffer); + if (completed != null) + completed (buffer); } catch (Exception ex) { if (error != null) From c6243a14d9c902d3d91138402bf27a02b464bbdb Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 8 Sep 2015 11:03:40 +0900 Subject: [PATCH 0098/6294] [Modify] Add null check --- websocket-sharp/Ext.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index ce9a95a34..ddd531d1c 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -175,7 +175,9 @@ private static void readBytesAsync ( var nread = stream.EndRead (ar); if (nread < 1) { // EOF/Disconnect before reading specified number of bytes. - completed (buffer.SubArray (0, offset)); + if (completed != null) + completed (buffer.SubArray (0, offset)); + return; } From 577ea14ffdaa37ed059a997cbe71b3db3a0d4e3f Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 9 Sep 2015 11:22:29 +0900 Subject: [PATCH 0099/6294] [Modify] Add ReadBytesAsync2 method Merge a part of pull request #153 from https://github.com/cswiedler/websocket-sharp/commit/fd5fc9a5fc5fa8d993a150e40c9eeb1a02138c27. --- websocket-sharp/Ext.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index ddd531d1c..ea1dd8045 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -660,6 +660,12 @@ internal static void ReadBytesAsync ( null); } + internal static void ReadBytesAsync2 ( + this Stream stream, int length, Action completed, Action error) + { + stream.readBytesAsync (new byte[length], 0, length, completed, error); + } + internal static string RemovePrefix (this string value, params string[] prefixes) { var idx = 0; From 4d5add5e8d10bccc9539cba64a084e62b3451bfc Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 10 Sep 2015 14:20:04 +0900 Subject: [PATCH 0100/6294] [Modify] Add ReadBytesAsync2 method Add ReadBytesAsync2 (Stream, long, int, Action, Action) method to support pull request #153 --- websocket-sharp/Ext.cs | 48 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index ea1dd8045..b7d437bc0 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -666,6 +666,54 @@ internal static void ReadBytesAsync2 ( stream.readBytesAsync (new byte[length], 0, length, completed, error); } + internal static void ReadBytesAsync2 ( + this Stream stream, + long length, + int bufferLength, + Action completed, + Action error) + { + var dest = new MemoryStream (); + var buff = new byte[bufferLength]; + + Action read = null; + read = len => { + if (len < bufferLength) { + bufferLength = (int) len; + buff = new byte[bufferLength]; + } + + stream.readBytesAsync ( + buff, + 0, + bufferLength, + bytes => { + var nread = bytes.Length; + if (nread > 0) + dest.Write (bytes, 0, nread); + + if (nread == 0 || (len -= nread) == 0) { + if (completed != null) { + dest.Close (); + completed (dest.ToArray ()); + } + + dest.Dispose (); + return; + } + + read (len); + }, + ex => { + dest.Dispose (); + if (error != null) + error (ex); + }); + }; + + read (length); + } + internal static string RemovePrefix (this string value, params string[] prefixes) { var idx = 0; From f518dd717cb34ef3aae59da0cc54be9deb833266 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 11 Sep 2015 15:38:50 +0900 Subject: [PATCH 0101/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index b7d437bc0..c5a834e17 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -170,25 +170,21 @@ private static void readBytesAsync ( Action completed, Action error) { - AsyncCallback callback = ar => { + AsyncCallback callback = null; + callback = ar => { try { var nread = stream.EndRead (ar); - if (nread < 1) { - // EOF/Disconnect before reading specified number of bytes. + if (nread <= 0 || nread == count) { if (completed != null) - completed (buffer.SubArray (0, offset)); + completed (buffer.SubArray (0, nread > 0 ? offset + nread : offset)); return; } - if (nread < count) { - // Need to read more. - stream.readBytesAsync (buffer, offset + nread, count - nread, completed, error); - return; - } + offset += nread; + count -= nread; - if (completed != null) - completed (buffer); + stream.BeginRead (buffer, offset, count, callback, null); } catch (Exception ex) { if (error != null) @@ -196,7 +192,13 @@ private static void readBytesAsync ( } }; - stream.BeginRead (buffer, offset, count, callback, null); + try { + stream.BeginRead (buffer, offset, count, callback, null); + } + catch (Exception ex) { + if (error != null) + error (ex); + } } private static void times (this ulong n, Action action) From 69c99b87655054bb4b6ff52e56d611b1dd53eda8 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 12 Sep 2015 14:35:45 +0900 Subject: [PATCH 0102/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index c5a834e17..80465d197 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -680,10 +680,8 @@ internal static void ReadBytesAsync2 ( Action read = null; read = len => { - if (len < bufferLength) { + if (len < bufferLength) bufferLength = (int) len; - buff = new byte[bufferLength]; - } stream.readBytesAsync ( buff, @@ -694,7 +692,7 @@ internal static void ReadBytesAsync2 ( if (nread > 0) dest.Write (bytes, 0, nread); - if (nread == 0 || (len -= nread) == 0) { + if (nread == 0 || nread == len) { if (completed != null) { dest.Close (); completed (dest.ToArray ()); @@ -704,7 +702,7 @@ internal static void ReadBytesAsync2 ( return; } - read (len); + read (len - nread); }, ex => { dest.Dispose (); From 2b984221fd682801734fab248e4f942581857524 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 13 Sep 2015 14:27:13 +0900 Subject: [PATCH 0103/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 80465d197..73e33ebbb 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -174,9 +174,9 @@ private static void readBytesAsync ( callback = ar => { try { var nread = stream.EndRead (ar); - if (nread <= 0 || nread == count) { + if (nread == 0 || nread == count) { if (completed != null) - completed (buffer.SubArray (0, nread > 0 ? offset + nread : offset)); + completed (buffer.SubArray (0, offset + nread)); return; } From a749a678382543a7ab39fcca097220ca983168d2 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 14 Sep 2015 12:07:37 +0900 Subject: [PATCH 0104/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 73e33ebbb..a0975b498 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -142,24 +142,22 @@ private static byte[] decompressToArray (this Stream stream) private static byte[] readBytes (this Stream stream, byte[] buffer, int offset, int count) { - var cnt = 0; + var nread = 0; try { - cnt = stream.Read (buffer, offset, count); - if (cnt < 1) - return buffer.SubArray (0, offset); - - while (cnt < count) { - var nread = stream.Read (buffer, offset + cnt, count - cnt); - if (nread < 1) + while (true) { + nread = stream.Read (buffer, offset, count); + if (nread == 0 || nread == count) break; - cnt += nread; + offset += nread; + count -= nread; } } catch { + nread = 0; } - return cnt < count ? buffer.SubArray (0, offset + cnt) : buffer; + return buffer.SubArray (0, offset + nread); } private static void readBytesAsync ( From bee39e08a9274ba12dbb8ec008f00b4f35343e01 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 15 Sep 2015 15:27:03 +0900 Subject: [PATCH 0105/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 36 +++++++++++++++--------------------- 1 file changed, 15 insertions(+), 21 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index a0975b498..eac5a1e68 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -205,15 +205,6 @@ private static void times (this ulong n, Action action) action (); } - private static bool writeTo (this Stream stream, Stream destination, int length, byte[] buffer) - { - var bytes = stream.readBytes (buffer, 0, length); - var len = bytes.Length; - destination.Write (bytes, 0, len); - - return len == length; - } - #endregion #region Internal Methods @@ -606,20 +597,23 @@ internal static byte[] ReadBytes (this Stream stream, int length) internal static byte[] ReadBytes (this Stream stream, long length, int bufferLength) { using (var dest = new MemoryStream ()) { - var cnt = length / bufferLength; - var rem = (int) (length % bufferLength); - - var buff = new byte[bufferLength]; - var end = false; - for (long i = 0; i < cnt; i++) { - if (!stream.writeTo (dest, bufferLength, buff)) { - end = true; - break; + try { + var buff = new byte[bufferLength]; + var nread = 0; + while (length > 0) { + if (length < bufferLength) + bufferLength = (int) length; + + nread = stream.Read (buff, 0, bufferLength); + if (nread == 0) + break; + + dest.Write (buff, 0, nread); + length -= nread; } } - - if (!end && rem > 0) - stream.writeTo (dest, rem, new byte[rem]); + catch { + } dest.Close (); return dest.ToArray (); From 58734d7ba64d0f4148db30cf858b9fa190e4f8c5 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 15 Sep 2015 15:43:53 +0900 Subject: [PATCH 0106/6294] [Modify] Remove older --- websocket-sharp/Ext.cs | 36 +----------------------------------- 1 file changed, 1 insertion(+), 35 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index eac5a1e68..60c82c676 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -622,45 +622,11 @@ internal static byte[] ReadBytes (this Stream stream, long length, int bufferLen internal static void ReadBytesAsync ( this Stream stream, int length, Action completed, Action error) - { - var buff = new byte[length]; - stream.BeginRead ( - buff, - 0, - length, - ar => { - try { - byte[] bytes = null; - try { - var len = stream.EndRead (ar); - bytes = len < 1 - ? WebSocket.EmptyBytes - : len < length - ? stream.readBytes (buff, len, length - len) - : buff; - } - catch { - bytes = WebSocket.EmptyBytes; - } - - if (completed != null) - completed (bytes); - } - catch (Exception ex) { - if (error != null) - error (ex); - } - }, - null); - } - - internal static void ReadBytesAsync2 ( - this Stream stream, int length, Action completed, Action error) { stream.readBytesAsync (new byte[length], 0, length, completed, error); } - internal static void ReadBytesAsync2 ( + internal static void ReadBytesAsync ( this Stream stream, long length, int bufferLength, From 2937598db9dc38201d0b9106fd5a5a6bf3efa608 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 16 Sep 2015 11:10:10 +0900 Subject: [PATCH 0107/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 38 +++++++++++++++++--------------------- 1 file changed, 17 insertions(+), 21 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 60c82c676..8fcd72ce5 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -140,26 +140,6 @@ private static byte[] decompressToArray (this Stream stream) } } - private static byte[] readBytes (this Stream stream, byte[] buffer, int offset, int count) - { - var nread = 0; - try { - while (true) { - nread = stream.Read (buffer, offset, count); - if (nread == 0 || nread == count) - break; - - offset += nread; - count -= nread; - } - } - catch { - nread = 0; - } - - return buffer.SubArray (0, offset + nread); - } - private static void readBytesAsync ( this Stream stream, byte[] buffer, @@ -591,7 +571,23 @@ internal static string Quote (this string value) internal static byte[] ReadBytes (this Stream stream, int length) { - return stream.readBytes (new byte[length], 0, length); + var buff = new byte[length]; + var offset = 0; + try { + var nread = 0; + while (length > 0) { + nread = stream.Read (buff, offset, length); + if (nread == 0) + break; + + offset += nread; + length -= nread; + } + } + catch { + } + + return buff.SubArray (0, offset); } internal static byte[] ReadBytes (this Stream stream, long length, int bufferLength) From 6e6bab85af6bfa861175f39773dedcf564b6414e Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 16 Sep 2015 14:39:58 +0900 Subject: [PATCH 0108/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 8fcd72ce5..cf63bc360 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -619,7 +619,38 @@ internal static byte[] ReadBytes (this Stream stream, long length, int bufferLen internal static void ReadBytesAsync ( this Stream stream, int length, Action completed, Action error) { - stream.readBytesAsync (new byte[length], 0, length, completed, error); + var buff = new byte[length]; + var offset = 0; + + AsyncCallback callback = null; + callback = ar => { + try { + var nread = stream.EndRead (ar); + if (nread == 0 || nread == length) { + if (completed != null) + completed (buff.SubArray (0, offset + nread)); + + return; + } + + offset += nread; + length -= nread; + + stream.BeginRead (buff, offset, length, callback, null); + } + catch (Exception ex) { + if (error != null) + error (ex); + } + }; + + try { + stream.BeginRead (buff, offset, length, callback, null); + } + catch (Exception ex) { + if (error != null) + error (ex); + } } internal static void ReadBytesAsync ( From 6833c2b014ac05bfa0162e36ff926e40fca9cd76 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 17 Sep 2015 14:08:40 +0900 Subject: [PATCH 0109/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 87 ++++++++++++++---------------------------- 1 file changed, 29 insertions(+), 58 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index cf63bc360..1bea822f0 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -140,45 +140,6 @@ private static byte[] decompressToArray (this Stream stream) } } - private static void readBytesAsync ( - this Stream stream, - byte[] buffer, - int offset, - int count, - Action completed, - Action error) - { - AsyncCallback callback = null; - callback = ar => { - try { - var nread = stream.EndRead (ar); - if (nread == 0 || nread == count) { - if (completed != null) - completed (buffer.SubArray (0, offset + nread)); - - return; - } - - offset += nread; - count -= nread; - - stream.BeginRead (buffer, offset, count, callback, null); - } - catch (Exception ex) { - if (error != null) - error (ex); - } - }; - - try { - stream.BeginRead (buffer, offset, count, callback, null); - } - catch (Exception ex) { - if (error != null) - error (ex); - } - } - private static void times (this ulong n, Action action) { for (ulong i = 0; i < n; i++) @@ -668,35 +629,45 @@ internal static void ReadBytesAsync ( if (len < bufferLength) bufferLength = (int) len; - stream.readBytesAsync ( + stream.BeginRead ( buff, 0, bufferLength, - bytes => { - var nread = bytes.Length; - if (nread > 0) - dest.Write (bytes, 0, nread); - - if (nread == 0 || nread == len) { - if (completed != null) { - dest.Close (); - completed (dest.ToArray ()); + ar => { + try { + var nread = stream.EndRead (ar); + if (nread > 0) + dest.Write (buff, 0, nread); + + if (nread == 0 || nread == len) { + if (completed != null) { + dest.Close (); + completed (dest.ToArray ()); + } + + dest.Dispose (); + return; } + read (len - nread); + } + catch (Exception ex) { dest.Dispose (); - return; + if (error != null) + error (ex); } - - read (len - nread); }, - ex => { - dest.Dispose (); - if (error != null) - error (ex); - }); + null); }; - read (length); + try { + read (length); + } + catch (Exception ex) { + dest.Dispose (); + if (error != null) + error (ex); + } } internal static string RemovePrefix (this string value, params string[] prefixes) From 6d3960ed7dfa8fd7255799a7d5dbd59ff3aedf92 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 18 Sep 2015 21:06:17 +0900 Subject: [PATCH 0110/6294] [Modify] Add ReadAsync2 method Merge a part of pull request #153 from https://github.com/cswiedler/websocket-sharp/commit/fd5fc9a5fc5fa8d993a150e40c9eeb1a02138c27. --- websocket-sharp/WebSocketFrame.cs | 213 ++++++++++++++++++++++++++++++ 1 file changed, 213 insertions(+) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index 3a4b45a0a..5657f9350 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -26,6 +26,13 @@ */ #endregion +#region Contributors +/* + * Contributors: + * - Chris Swiedler + */ +#endregion + using System; using System.Collections; using System.Collections.Generic; @@ -513,6 +520,169 @@ private static WebSocketFrame read (byte[] header, Stream stream, bool unmask) return frame; } + private static void readExtendedPayloadLengthAsync ( + Stream stream, + int length, + WebSocketFrame frame, + Action completed, + Action error) + { + if (length == 0) { + frame._extPayloadLength = WebSocket.EmptyBytes; + completed (frame); + + return; + } + + stream.ReadBytesAsync ( + length, + len => { + if (len.Length != length) + throw new WebSocketException ( + "The 'Extended Payload Length' of a frame cannot be read from the data source."); + + frame._extPayloadLength = len; + completed (frame); + }, + error); + } + + private static void readHeaderAsync ( + Stream stream, Action completed, Action error) + { + stream.ReadBytesAsync ( + 2, + header => { + if (header.Length != 2) + throw new WebSocketException ( + "The header part of a frame cannot be read from the data source."); + + // FIN + var fin = (header[0] & 0x80) == 0x80 ? Fin.Final : Fin.More; + + // RSV1 + var rsv1 = (header[0] & 0x40) == 0x40 ? Rsv.On : Rsv.Off; + + // RSV2 + var rsv2 = (header[0] & 0x20) == 0x20 ? Rsv.On : Rsv.Off; + + // RSV3 + var rsv3 = (header[0] & 0x10) == 0x10 ? Rsv.On : Rsv.Off; + + // Opcode + var opcode = (Opcode) (header[0] & 0x0f); + + // MASK + var mask = (header[1] & 0x80) == 0x80 ? Mask.Mask : Mask.Unmask; + + // Payload Length + var payloadLen = (byte) (header[1] & 0x7f); + + // Check if valid header. + var err = isControl (opcode) && payloadLen > 125 + ? "A control frame has payload data which is greater than the allowable max length." + : isControl (opcode) && fin == Fin.More + ? "A control frame is fragmented." + : !isData (opcode) && rsv1 == Rsv.On + ? "A non data frame is compressed." + : null; + + if (err != null) + throw new WebSocketException (CloseStatusCode.ProtocolError, err); + + var frame = new WebSocketFrame (); + frame._fin = fin; + frame._rsv1 = rsv1; + frame._rsv2 = rsv2; + frame._rsv3 = rsv3; + frame._opcode = opcode; + frame._mask = mask; + frame._payloadLength = payloadLen; + + completed (frame); + }, + error); + } + + private static void readMaskingKeyAsync ( + Stream stream, + int length, + WebSocketFrame frame, + Action completed, + Action error) + { + if (length == 0) { + frame._maskingKey = WebSocket.EmptyBytes; + completed (frame); + + return; + } + + stream.ReadBytesAsync ( + length, + key => { + if (key.Length != length) + throw new WebSocketException ( + "The 'Masking Key' of a frame cannot be read from the data source."); + + frame._maskingKey = key; + completed (frame); + }, + error); + } + + private static void readPayloadDataAsync ( + Stream stream, + ulong length, + WebSocketFrame frame, + Action completed, + Action error) + { + if (length > PayloadData.MaxLength) + throw new WebSocketException ( + CloseStatusCode.TooBig, + "The length of 'Payload Data' of a frame is greater than the allowable max length."); + + var masked = frame._mask == Mask.Mask; + if (length == 0) { + frame._payloadData = new PayloadData (WebSocket.EmptyBytes, masked); + completed (frame); + + return; + } + + if (frame._payloadLength < 127) { + var len = (int) length; + stream.ReadBytesAsync ( + len, + data => { + if (data.Length != len) + throw new WebSocketException ( + "The 'Payload Data' of a frame cannot be read from the data source."); + + frame._payloadData = new PayloadData (data, masked); + completed (frame); + }, + error); + + return; + } + + var llen = (long) length; + stream.ReadBytesAsync ( + llen, + 1024, + data => { + if (data.LongLength != llen) + throw new WebSocketException ( + "The 'Payload Data' of a frame cannot be read from the data source."); + + frame._payloadData = new PayloadData (data, masked); + completed (frame); + }, + error); + } + #endregion #region Internal Methods @@ -570,6 +740,49 @@ internal static void ReadAsync ( error); } + internal static void ReadAsync2 ( + Stream stream, bool unmask, Action completed, Action error) + { + readHeaderAsync ( + stream, + frame => { + var payloadLen = frame._payloadLength; + readExtendedPayloadLengthAsync ( + stream, + payloadLen < 126 ? 0 : (payloadLen == 126 ? 2 : 8), + frame, + frame1 => { + var masked = frame1._mask == Mask.Mask; + readMaskingKeyAsync ( + stream, + masked ? 4 : 0, + frame1, + frame2 => { + ulong len = payloadLen < 126 + ? payloadLen + : payloadLen == 126 + ? frame2._extPayloadLength.ToUInt16 (ByteOrder.Big) + : frame2._extPayloadLength.ToUInt64 (ByteOrder.Big); + + readPayloadDataAsync ( + stream, + len, + frame2, + frame3 => { + if (unmask && masked) + frame3.Unmask (); + + completed (frame3); + }, + error); + }, + error); + }, + error); + }, + error); + } + internal void Unmask () { if (_mask == Mask.Unmask) From 48b55173fa72b44acf5e65e1834d5c59c44f05c3 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 19 Sep 2015 15:35:15 +0900 Subject: [PATCH 0111/6294] [Modify] Polish it --- websocket-sharp/WebSocketFrame.cs | 104 +++++++++++++++--------------- 1 file changed, 52 insertions(+), 52 deletions(-) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index 5657f9350..25bcaff2d 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -425,6 +425,57 @@ private static string print (WebSocketFrame frame) payload); } + private static WebSocketFrame processHeader (byte[] header) + { + if (header.Length != 2) + throw new WebSocketException ( + "The header part of a frame cannot be read from the data source."); + + // FIN + var fin = (header[0] & 0x80) == 0x80 ? Fin.Final : Fin.More; + + // RSV1 + var rsv1 = (header[0] & 0x40) == 0x40 ? Rsv.On : Rsv.Off; + + // RSV2 + var rsv2 = (header[0] & 0x20) == 0x20 ? Rsv.On : Rsv.Off; + + // RSV3 + var rsv3 = (header[0] & 0x10) == 0x10 ? Rsv.On : Rsv.Off; + + // Opcode + var opcode = (Opcode) (header[0] & 0x0f); + + // MASK + var mask = (header[1] & 0x80) == 0x80 ? Mask.Mask : Mask.Unmask; + + // Payload Length + var payloadLen = (byte) (header[1] & 0x7f); + + // Check if valid header. + var err = isControl (opcode) && payloadLen > 125 + ? "A control frame has payload data which is greater than the allowable max length." + : isControl (opcode) && fin == Fin.More + ? "A control frame is fragmented." + : !isData (opcode) && rsv1 == Rsv.On + ? "A non data frame is compressed." + : null; + + if (err != null) + throw new WebSocketException (CloseStatusCode.ProtocolError, err); + + var frame = new WebSocketFrame (); + frame._fin = fin; + frame._rsv1 = rsv1; + frame._rsv2 = rsv2; + frame._rsv3 = rsv3; + frame._opcode = opcode; + frame._mask = mask; + frame._payloadLength = payloadLen; + + return frame; + } + private static WebSocketFrame read (byte[] header, Stream stream, bool unmask) { /* Header */ @@ -550,58 +601,7 @@ private static void readExtendedPayloadLengthAsync ( private static void readHeaderAsync ( Stream stream, Action completed, Action error) { - stream.ReadBytesAsync ( - 2, - header => { - if (header.Length != 2) - throw new WebSocketException ( - "The header part of a frame cannot be read from the data source."); - - // FIN - var fin = (header[0] & 0x80) == 0x80 ? Fin.Final : Fin.More; - - // RSV1 - var rsv1 = (header[0] & 0x40) == 0x40 ? Rsv.On : Rsv.Off; - - // RSV2 - var rsv2 = (header[0] & 0x20) == 0x20 ? Rsv.On : Rsv.Off; - - // RSV3 - var rsv3 = (header[0] & 0x10) == 0x10 ? Rsv.On : Rsv.Off; - - // Opcode - var opcode = (Opcode) (header[0] & 0x0f); - - // MASK - var mask = (header[1] & 0x80) == 0x80 ? Mask.Mask : Mask.Unmask; - - // Payload Length - var payloadLen = (byte) (header[1] & 0x7f); - - // Check if valid header. - var err = isControl (opcode) && payloadLen > 125 - ? "A control frame has payload data which is greater than the allowable max length." - : isControl (opcode) && fin == Fin.More - ? "A control frame is fragmented." - : !isData (opcode) && rsv1 == Rsv.On - ? "A non data frame is compressed." - : null; - - if (err != null) - throw new WebSocketException (CloseStatusCode.ProtocolError, err); - - var frame = new WebSocketFrame (); - frame._fin = fin; - frame._rsv1 = rsv1; - frame._rsv2 = rsv2; - frame._rsv3 = rsv3; - frame._opcode = opcode; - frame._mask = mask; - frame._payloadLength = payloadLen; - - completed (frame); - }, - error); + stream.ReadBytesAsync (2, header => completed (processHeader (header)), error); } private static void readMaskingKeyAsync ( From de63dc152927c7c42b965feb941fae1faf1adb27 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 20 Sep 2015 16:39:19 +0900 Subject: [PATCH 0112/6294] [Modify] Polish it --- websocket-sharp/WebSocketFrame.cs | 83 +++++++++++++++++++++++++++++-- 1 file changed, 78 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index 25bcaff2d..b941c1628 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -571,6 +571,23 @@ private static WebSocketFrame read (byte[] header, Stream stream, bool unmask) return frame; } + private static WebSocketFrame readExtendedPayloadLength (Stream stream, WebSocketFrame frame) + { + var len = frame._payloadLength < 126 ? 0 : (frame._payloadLength == 126 ? 2 : 8); + if (len == 0) { + frame._extPayloadLength = WebSocket.EmptyBytes; + return frame; + } + + var bytes = stream.ReadBytes (len); + if (bytes.Length != len) + throw new WebSocketException ( + "The 'Extended Payload Length' of a frame cannot be read from the data source."); + + frame._extPayloadLength = bytes; + return frame; + } + private static void readExtendedPayloadLengthAsync ( Stream stream, int length, @@ -598,12 +615,34 @@ private static void readExtendedPayloadLengthAsync ( error); } + private static WebSocketFrame readHeader (Stream stream) + { + return processHeader (stream.ReadBytes (2)); + } + private static void readHeaderAsync ( Stream stream, Action completed, Action error) { stream.ReadBytesAsync (2, header => completed (processHeader (header)), error); } + private static WebSocketFrame readMaskingKey (Stream stream, WebSocketFrame frame) + { + var len = frame.IsMasked ? 4 : 0; + if (len == 0) { + frame._maskingKey = WebSocket.EmptyBytes; + return frame; + } + + var bytes = stream.ReadBytes (len); + if (bytes.Length != len) + throw new WebSocketException ( + "The 'Masking Key' of a frame cannot be read from the data source."); + + frame._maskingKey = bytes; + return frame; + } + private static void readMaskingKeyAsync ( Stream stream, int length, @@ -631,6 +670,37 @@ private static void readMaskingKeyAsync ( error); } + private static WebSocketFrame readPayloadData (Stream stream, WebSocketFrame frame) + { + ulong len = frame._payloadLength < 126 + ? frame._payloadLength + : frame._payloadLength == 126 + ? frame._extPayloadLength.ToUInt16 (ByteOrder.Big) + : frame._extPayloadLength.ToUInt64 (ByteOrder.Big); + + if (len == 0) { + frame._payloadData = new PayloadData (WebSocket.EmptyBytes, frame.IsMasked); + return frame; + } + + // Check if allowable length. + if (len > PayloadData.MaxLength) + throw new WebSocketException ( + CloseStatusCode.TooBig, + "The length of 'Payload Data' of a frame is greater than the allowable max length."); + + var bytes = frame._payloadLength < 127 + ? stream.ReadBytes ((int) len) + : stream.ReadBytes ((long) len, 1024); + + if (bytes.LongLength != (long) len) + throw new WebSocketException ( + "The 'Payload Data' of a frame cannot be read from the data source."); + + frame._payloadData = new PayloadData (bytes, frame.IsMasked); + return frame; + } + private static void readPayloadDataAsync ( Stream stream, ulong length, @@ -709,12 +779,15 @@ internal static WebSocketFrame Read (Stream stream) internal static WebSocketFrame Read (Stream stream, bool unmask) { - var header = stream.ReadBytes (2); - if (header.Length != 2) - throw new WebSocketException ( - "The header part of a frame cannot be read from the data source."); + var frame = readHeader (stream); + readExtendedPayloadLength (stream, frame); + readMaskingKey (stream, frame); + readPayloadData (stream, frame); - return read (header, stream, unmask); + if (unmask && frame.IsMasked) + frame.Unmask (); + + return frame; } internal static void ReadAsync ( From f902958aad2356a97d89d37ae12e61a92b783791 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 21 Sep 2015 15:11:31 +0900 Subject: [PATCH 0113/6294] [Modify] Polish it --- websocket-sharp/WebSocketFrame.cs | 114 +++--------------------------- 1 file changed, 10 insertions(+), 104 deletions(-) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index b941c1628..81c39eb6c 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -476,101 +476,6 @@ private static WebSocketFrame processHeader (byte[] header) return frame; } - private static WebSocketFrame read (byte[] header, Stream stream, bool unmask) - { - /* Header */ - - // FIN - var fin = (header[0] & 0x80) == 0x80 ? Fin.Final : Fin.More; - // RSV1 - var rsv1 = (header[0] & 0x40) == 0x40 ? Rsv.On : Rsv.Off; - // RSV2 - var rsv2 = (header[0] & 0x20) == 0x20 ? Rsv.On : Rsv.Off; - // RSV3 - var rsv3 = (header[0] & 0x10) == 0x10 ? Rsv.On : Rsv.Off; - // Opcode - var opcode = (Opcode) (header[0] & 0x0f); - // MASK - var mask = (header[1] & 0x80) == 0x80 ? Mask.Mask : Mask.Unmask; - // Payload Length - var payloadLen = (byte) (header[1] & 0x7f); - - // Check if valid header. - var err = isControl (opcode) && payloadLen > 125 - ? "A control frame has payload data which is greater than the allowable max length." - : isControl (opcode) && fin == Fin.More - ? "A control frame is fragmented." - : !isData (opcode) && rsv1 == Rsv.On - ? "A non data frame is compressed." - : null; - - if (err != null) - throw new WebSocketException (CloseStatusCode.ProtocolError, err); - - var frame = new WebSocketFrame (); - frame._fin = fin; - frame._rsv1 = rsv1; - frame._rsv2 = rsv2; - frame._rsv3 = rsv3; - frame._opcode = opcode; - frame._mask = mask; - frame._payloadLength = payloadLen; - - /* Extended Payload Length */ - - var size = payloadLen < 126 ? 0 : (payloadLen == 126 ? 2 : 8); - var extPayloadLen = size > 0 ? stream.ReadBytes (size) : WebSocket.EmptyBytes; - if (size > 0 && extPayloadLen.Length != size) - throw new WebSocketException ( - "The 'Extended Payload Length' of a frame cannot be read from the data source."); - - frame._extPayloadLength = extPayloadLen; - - /* Masking Key */ - - var masked = mask == Mask.Mask; - var maskingKey = masked ? stream.ReadBytes (4) : WebSocket.EmptyBytes; - if (masked && maskingKey.Length != 4) - throw new WebSocketException ( - "The 'Masking Key' of a frame cannot be read from the data source."); - - frame._maskingKey = maskingKey; - - /* Payload Data */ - - ulong len = payloadLen < 126 - ? payloadLen - : payloadLen == 126 - ? extPayloadLen.ToUInt16 (ByteOrder.Big) - : extPayloadLen.ToUInt64 (ByteOrder.Big); - - byte[] data = null; - if (len > 0) { - // Check if allowable max length. - if (payloadLen > 126 && len > PayloadData.MaxLength) - throw new WebSocketException ( - CloseStatusCode.TooBig, - "The length of 'Payload Data' of a frame is greater than the allowable max length."); - - data = payloadLen > 126 - ? stream.ReadBytes ((long) len, 1024) - : stream.ReadBytes ((int) len); - - if (data.LongLength != (long) len) - throw new WebSocketException ( - "The 'Payload Data' of a frame cannot be read from the data source."); - } - else { - data = WebSocket.EmptyBytes; - } - - frame._payloadData = new PayloadData (data, masked); - if (unmask && masked) - frame.Unmask (); - - return frame; - } - private static WebSocketFrame readExtendedPayloadLength (Stream stream, WebSocketFrame frame) { var len = frame._payloadLength < 126 ? 0 : (frame._payloadLength == 126 ? 2 : 8); @@ -799,16 +704,17 @@ internal static void ReadAsync ( internal static void ReadAsync ( Stream stream, bool unmask, Action completed, Action error) { - stream.ReadBytesAsync ( - 2, - header => { - if (header.Length != 2) - throw new WebSocketException ( - "The header part of a frame cannot be read from the data source."); + readHeaderAsync ( + stream, + frame => { + readExtendedPayloadLength (stream, frame); + readMaskingKey (stream, frame); + readPayloadData (stream, frame); - var frame = read (header, stream, unmask); - if (completed != null) - completed (frame); + if (unmask && frame.IsMasked) + frame.Unmask (); + + completed (frame); }, error); } From 3521004c43814f0b9ec5c98f9de0d987b20c8f60 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 22 Sep 2015 12:23:43 +0900 Subject: [PATCH 0114/6294] [Modify] Polish it --- websocket-sharp/WebSocketFrame.cs | 93 ++++++++++++++----------------- 1 file changed, 42 insertions(+), 51 deletions(-) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index 81c39eb6c..861a12ea6 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -495,12 +495,12 @@ private static WebSocketFrame readExtendedPayloadLength (Stream stream, WebSocke private static void readExtendedPayloadLengthAsync ( Stream stream, - int length, WebSocketFrame frame, Action completed, Action error) { - if (length == 0) { + var len = frame._payloadLength < 126 ? 0 : (frame._payloadLength == 126 ? 2 : 8); + if (len == 0) { frame._extPayloadLength = WebSocket.EmptyBytes; completed (frame); @@ -508,13 +508,13 @@ private static void readExtendedPayloadLengthAsync ( } stream.ReadBytesAsync ( - length, - len => { - if (len.Length != length) + len, + bytes => { + if (bytes.Length != len) throw new WebSocketException ( "The 'Extended Payload Length' of a frame cannot be read from the data source."); - frame._extPayloadLength = len; + frame._extPayloadLength = bytes; completed (frame); }, error); @@ -528,7 +528,7 @@ private static WebSocketFrame readHeader (Stream stream) private static void readHeaderAsync ( Stream stream, Action completed, Action error) { - stream.ReadBytesAsync (2, header => completed (processHeader (header)), error); + stream.ReadBytesAsync (2, bytes => completed (processHeader (bytes)), error); } private static WebSocketFrame readMaskingKey (Stream stream, WebSocketFrame frame) @@ -550,12 +550,12 @@ private static WebSocketFrame readMaskingKey (Stream stream, WebSocketFrame fram private static void readMaskingKeyAsync ( Stream stream, - int length, WebSocketFrame frame, Action completed, Action error) { - if (length == 0) { + var len = frame.IsMasked ? 4 : 0; + if (len == 0) { frame._maskingKey = WebSocket.EmptyBytes; completed (frame); @@ -563,13 +563,13 @@ private static void readMaskingKeyAsync ( } stream.ReadBytesAsync ( - length, - key => { - if (key.Length != length) + len, + bytes => { + if (bytes.Length != len) throw new WebSocketException ( "The 'Masking Key' of a frame cannot be read from the data source."); - frame._maskingKey = key; + frame._maskingKey = bytes; completed (frame); }, error); @@ -608,34 +608,39 @@ private static WebSocketFrame readPayloadData (Stream stream, WebSocketFrame fra private static void readPayloadDataAsync ( Stream stream, - ulong length, WebSocketFrame frame, Action completed, Action error) { - if (length > PayloadData.MaxLength) - throw new WebSocketException ( - CloseStatusCode.TooBig, - "The length of 'Payload Data' of a frame is greater than the allowable max length."); + ulong len = frame._payloadLength < 126 + ? frame._payloadLength + : frame._payloadLength == 126 + ? frame._extPayloadLength.ToUInt16 (ByteOrder.Big) + : frame._extPayloadLength.ToUInt64 (ByteOrder.Big); - var masked = frame._mask == Mask.Mask; - if (length == 0) { - frame._payloadData = new PayloadData (WebSocket.EmptyBytes, masked); + if (len == 0) { + frame._payloadData = new PayloadData (WebSocket.EmptyBytes, frame.IsMasked); completed (frame); return; } + // Check if allowable length. + if (len > PayloadData.MaxLength) + throw new WebSocketException ( + CloseStatusCode.TooBig, + "The length of 'Payload Data' of a frame is greater than the allowable max length."); + if (frame._payloadLength < 127) { - var len = (int) length; + var ilen = (int) len; stream.ReadBytesAsync ( - len, - data => { - if (data.Length != len) + ilen, + bytes => { + if (bytes.Length != ilen) throw new WebSocketException ( "The 'Payload Data' of a frame cannot be read from the data source."); - frame._payloadData = new PayloadData (data, masked); + frame._payloadData = new PayloadData (bytes, frame.IsMasked); completed (frame); }, error); @@ -643,16 +648,16 @@ private static void readPayloadDataAsync ( return; } - var llen = (long) length; + var llen = (long) len; stream.ReadBytesAsync ( llen, 1024, - data => { - if (data.LongLength != llen) + bytes => { + if (bytes.LongLength != llen) throw new WebSocketException ( "The 'Payload Data' of a frame cannot be read from the data source."); - frame._payloadData = new PayloadData (data, masked); + frame._payloadData = new PayloadData (bytes, frame.IsMasked); completed (frame); }, error); @@ -724,41 +729,27 @@ internal static void ReadAsync2 ( { readHeaderAsync ( stream, - frame => { - var payloadLen = frame._payloadLength; + frame => readExtendedPayloadLengthAsync ( stream, - payloadLen < 126 ? 0 : (payloadLen == 126 ? 2 : 8), frame, - frame1 => { - var masked = frame1._mask == Mask.Mask; + frame1 => readMaskingKeyAsync ( stream, - masked ? 4 : 0, frame1, - frame2 => { - ulong len = payloadLen < 126 - ? payloadLen - : payloadLen == 126 - ? frame2._extPayloadLength.ToUInt16 (ByteOrder.Big) - : frame2._extPayloadLength.ToUInt64 (ByteOrder.Big); - + frame2 => readPayloadDataAsync ( stream, - len, frame2, frame3 => { - if (unmask && masked) + if (unmask && frame3.IsMasked) frame3.Unmask (); completed (frame3); }, - error); - }, - error); - }, - error); - }, + error), + error), + error), error); } From b0be2a7dbb966b1a87f1b5a2c607e5baa32dfaa3 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 23 Sep 2015 14:51:32 +0900 Subject: [PATCH 0115/6294] [Modify] Polish it --- websocket-sharp/WebSocketFrame.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index 861a12ea6..2433f345f 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -694,7 +694,7 @@ internal static WebSocketFrame Read (Stream stream, bool unmask) readMaskingKey (stream, frame); readPayloadData (stream, frame); - if (unmask && frame.IsMasked) + if (unmask) frame.Unmask (); return frame; @@ -716,7 +716,7 @@ internal static void ReadAsync ( readMaskingKey (stream, frame); readPayloadData (stream, frame); - if (unmask && frame.IsMasked) + if (unmask) frame.Unmask (); completed (frame); @@ -742,7 +742,7 @@ internal static void ReadAsync2 ( stream, frame2, frame3 => { - if (unmask && frame3.IsMasked) + if (unmask) frame3.Unmask (); completed (frame3); From 011fc19269311710b553b0f213ff4f96dfce4f61 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 24 Sep 2015 14:43:09 +0900 Subject: [PATCH 0116/6294] [Modify] Remove older --- websocket-sharp/WebSocketFrame.cs | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index 2433f345f..adc38bc07 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -708,24 +708,6 @@ internal static void ReadAsync ( internal static void ReadAsync ( Stream stream, bool unmask, Action completed, Action error) - { - readHeaderAsync ( - stream, - frame => { - readExtendedPayloadLength (stream, frame); - readMaskingKey (stream, frame); - readPayloadData (stream, frame); - - if (unmask) - frame.Unmask (); - - completed (frame); - }, - error); - } - - internal static void ReadAsync2 ( - Stream stream, bool unmask, Action completed, Action error) { readHeaderAsync ( stream, From d2bb26730632635ba5d4a9c2c2ebddc172f4d7e5 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 25 Sep 2015 15:00:58 +0900 Subject: [PATCH 0117/6294] [Modify] Polish it --- websocket-sharp/WebSocketFrame.cs | 37 +++++++++---------------------- 1 file changed, 11 insertions(+), 26 deletions(-) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index adc38bc07..dafad8f42 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -631,36 +631,21 @@ private static void readPayloadDataAsync ( CloseStatusCode.TooBig, "The length of 'Payload Data' of a frame is greater than the allowable max length."); - if (frame._payloadLength < 127) { - var ilen = (int) len; - stream.ReadBytesAsync ( - ilen, - bytes => { - if (bytes.Length != ilen) - throw new WebSocketException ( - "The 'Payload Data' of a frame cannot be read from the data source."); - - frame._payloadData = new PayloadData (bytes, frame.IsMasked); - completed (frame); - }, - error); + Action compl = bytes => { + if (bytes.LongLength != (long) len) + throw new WebSocketException ( + "The 'Payload Data' of a frame cannot be read from the data source."); + + frame._payloadData = new PayloadData (bytes, frame.IsMasked); + completed (frame); + }; + if (frame._payloadLength < 127) { + stream.ReadBytesAsync ((int) len, compl, error); return; } - var llen = (long) len; - stream.ReadBytesAsync ( - llen, - 1024, - bytes => { - if (bytes.LongLength != llen) - throw new WebSocketException ( - "The 'Payload Data' of a frame cannot be read from the data source."); - - frame._payloadData = new PayloadData (bytes, frame.IsMasked); - completed (frame); - }, - error); + stream.ReadBytesAsync ((long) len, 1024, compl, error); } #endregion From 8542bccc55111bde33cb3f26ba6fa98fed3393e4 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 26 Sep 2015 11:57:34 +0900 Subject: [PATCH 0118/6294] [Modify] Polish it --- websocket-sharp/WebSocketFrame.cs | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index dafad8f42..de343152c 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -145,6 +145,16 @@ public Fin Fin { } } + public ulong FullPayloadLength { + get { + return _payloadLength < 126 + ? _payloadLength + : _payloadLength == 126 + ? _extPayloadLength.ToUInt16 (ByteOrder.Big) + : _extPayloadLength.ToUInt64 (ByteOrder.Big); + } + } + public bool IsBinary { get { return _opcode == Opcode.Binary; @@ -577,12 +587,7 @@ private static void readMaskingKeyAsync ( private static WebSocketFrame readPayloadData (Stream stream, WebSocketFrame frame) { - ulong len = frame._payloadLength < 126 - ? frame._payloadLength - : frame._payloadLength == 126 - ? frame._extPayloadLength.ToUInt16 (ByteOrder.Big) - : frame._extPayloadLength.ToUInt64 (ByteOrder.Big); - + var len = frame.FullPayloadLength; if (len == 0) { frame._payloadData = new PayloadData (WebSocket.EmptyBytes, frame.IsMasked); return frame; @@ -612,12 +617,7 @@ private static void readPayloadDataAsync ( Action completed, Action error) { - ulong len = frame._payloadLength < 126 - ? frame._payloadLength - : frame._payloadLength == 126 - ? frame._extPayloadLength.ToUInt16 (ByteOrder.Big) - : frame._extPayloadLength.ToUInt64 (ByteOrder.Big); - + var len = frame.FullPayloadLength; if (len == 0) { frame._payloadData = new PayloadData (WebSocket.EmptyBytes, frame.IsMasked); completed (frame); From afbd7b2f713f1c0bd19bfdae15d7a015ae040b82 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 27 Sep 2015 15:08:51 +0900 Subject: [PATCH 0119/6294] [Modify] Polish it --- websocket-sharp/WebSocketFrame.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index de343152c..1bc8bdcbd 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -139,6 +139,12 @@ public byte[] ExtendedPayloadLength { } } + public int ExtendedPayloadLengthCount { + get { + return _payloadLength < 126 ? 0 : (_payloadLength == 126 ? 2 : 8); + } + } + public Fin Fin { get { return _fin; @@ -488,7 +494,7 @@ private static WebSocketFrame processHeader (byte[] header) private static WebSocketFrame readExtendedPayloadLength (Stream stream, WebSocketFrame frame) { - var len = frame._payloadLength < 126 ? 0 : (frame._payloadLength == 126 ? 2 : 8); + var len = frame.ExtendedPayloadLengthCount; if (len == 0) { frame._extPayloadLength = WebSocket.EmptyBytes; return frame; @@ -509,7 +515,7 @@ private static void readExtendedPayloadLengthAsync ( Action completed, Action error) { - var len = frame._payloadLength < 126 ? 0 : (frame._payloadLength == 126 ? 2 : 8); + var len = frame.ExtendedPayloadLengthCount; if (len == 0) { frame._extPayloadLength = WebSocket.EmptyBytes; completed (frame); From 78ef7d64f782a592d9c27897fa0640aea67c5624 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 28 Sep 2015 15:27:29 +0900 Subject: [PATCH 0120/6294] [Modify] Replace it with readonly And add some xml doc comments to help to change the field value. --- websocket-sharp/PayloadData.cs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/PayloadData.cs b/websocket-sharp/PayloadData.cs index d6991364f..b51ff1962 100644 --- a/websocket-sharp/PayloadData.cs +++ b/websocket-sharp/PayloadData.cs @@ -46,7 +46,20 @@ internal class PayloadData : IEnumerable #region Public Fields - public const ulong MaxLength = Int64.MaxValue; + /// + /// Represents the allowable max length. + /// + /// + /// + /// A will occur if the payload data length is + /// greater than this. + /// + /// + /// If you would like to change this value, you must set this to a value greater than + /// WebSocket.FragmentLength, and equal to or less than Int64.MaxValue. + /// + /// + public static readonly ulong MaxLength = Int64.MaxValue; #endregion From 4654252a22622f47feb2f6e9b0bb6dd32c8e206e Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 28 Sep 2015 15:38:31 +0900 Subject: [PATCH 0121/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index f901a6705..6b3e9305f 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -127,8 +127,8 @@ private Func /// The data will be fragmented if that length is greater than this. /// /// - /// If you would like to change this value, you must set this to a value between 1 and - /// Int32.MaxValue - 14 inclusive. + /// If you would like to change this value, you must set this to a value between 125 + /// and Int32.MaxValue - 14 inclusive. /// /// internal static readonly int FragmentLength = 1016; From 53d2077ca58f61d79aa519d985d577db36e6f9f7 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 28 Sep 2015 16:00:51 +0900 Subject: [PATCH 0122/6294] [Modify] Polish it --- websocket-sharp/PayloadData.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/PayloadData.cs b/websocket-sharp/PayloadData.cs index b51ff1962..965547c03 100644 --- a/websocket-sharp/PayloadData.cs +++ b/websocket-sharp/PayloadData.cs @@ -55,8 +55,8 @@ internal class PayloadData : IEnumerable /// greater than this. /// /// - /// If you would like to change this value, you must set this to a value greater than - /// WebSocket.FragmentLength, and equal to or less than Int64.MaxValue. + /// If you would like to change this value, you must set this to a value between + /// WebSocket.FragmentLength and Int64.MaxValue inclusive. /// /// public static readonly ulong MaxLength = Int64.MaxValue; From 4bc3c5ed602182402a2e7d2c6427517bd42d2605 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 29 Sep 2015 15:20:19 +0900 Subject: [PATCH 0123/6294] [Modify] Rename it to ToArray --- websocket-sharp/PayloadData.cs | 2 +- websocket-sharp/WebSocketFrame.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/PayloadData.cs b/websocket-sharp/PayloadData.cs index 965547c03..2130ca766 100644 --- a/websocket-sharp/PayloadData.cs +++ b/websocket-sharp/PayloadData.cs @@ -156,7 +156,7 @@ public IEnumerator GetEnumerator () yield return b; } - public byte[] ToByteArray () + public byte[] ToArray () { return _data; } diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index 1bc8bdcbd..79ee71527 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -775,7 +775,7 @@ public byte[] ToByteArray () buff.Write (_maskingKey, 0, 4); if (_payloadLength > 0) { - var bytes = _payloadData.ToByteArray (); + var bytes = _payloadData.ToArray (); if (_payloadLength < 127) buff.Write (bytes, 0, bytes.Length); else From d699a8d49ad92b963b0a138b10e6beb8f98e0070 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 30 Sep 2015 12:28:48 +0900 Subject: [PATCH 0124/6294] [Modify] Remove it It will never ever be used. --- websocket-sharp/PayloadData.cs | 16 +++------------- websocket-sharp/WebSocketFrame.cs | 8 ++++---- 2 files changed, 7 insertions(+), 17 deletions(-) diff --git a/websocket-sharp/PayloadData.cs b/websocket-sharp/PayloadData.cs index 2130ca766..1c6e6f9f4 100644 --- a/websocket-sharp/PayloadData.cs +++ b/websocket-sharp/PayloadData.cs @@ -40,7 +40,6 @@ internal class PayloadData : IEnumerable private byte[] _data; private long _extDataLength; private long _length; - private bool _masked; #endregion @@ -71,15 +70,14 @@ internal PayloadData () } internal PayloadData (byte[] data) - : this (data, false) + : this (data, data.LongLength) { } - internal PayloadData (byte[] data, bool masked) + internal PayloadData (byte[] data, long length) { _data = data; - _masked = masked; - _length = data.LongLength; + _length = length; } #endregion @@ -122,12 +120,6 @@ public byte[] ExtensionData { } } - public bool IsMasked { - get { - return _masked; - } - } - public ulong Length { get { return (ulong) _length; @@ -142,8 +134,6 @@ internal void Mask (byte[] key) { for (long i = 0; i < _length; i++) _data[i] = (byte) (_data[i] ^ key[i % 4]); - - _masked = !_masked; } #endregion diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index 79ee71527..2ef5e758e 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -595,7 +595,7 @@ private static WebSocketFrame readPayloadData (Stream stream, WebSocketFrame fra { var len = frame.FullPayloadLength; if (len == 0) { - frame._payloadData = new PayloadData (WebSocket.EmptyBytes, frame.IsMasked); + frame._payloadData = new PayloadData (); return frame; } @@ -613,7 +613,7 @@ private static WebSocketFrame readPayloadData (Stream stream, WebSocketFrame fra throw new WebSocketException ( "The 'Payload Data' of a frame cannot be read from the data source."); - frame._payloadData = new PayloadData (bytes, frame.IsMasked); + frame._payloadData = new PayloadData (bytes); return frame; } @@ -625,7 +625,7 @@ private static void readPayloadDataAsync ( { var len = frame.FullPayloadLength; if (len == 0) { - frame._payloadData = new PayloadData (WebSocket.EmptyBytes, frame.IsMasked); + frame._payloadData = new PayloadData (); completed (frame); return; @@ -642,7 +642,7 @@ private static void readPayloadDataAsync ( throw new WebSocketException ( "The 'Payload Data' of a frame cannot be read from the data source."); - frame._payloadData = new PayloadData (bytes, frame.IsMasked); + frame._payloadData = new PayloadData (bytes); completed (frame); }; From 7b462520385acb48f751305b1d242e9b593b116d Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 1 Oct 2015 14:50:17 +0900 Subject: [PATCH 0125/6294] [Modify] Add a field It can be used as the empty payload data. --- websocket-sharp/PayloadData.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/websocket-sharp/PayloadData.cs b/websocket-sharp/PayloadData.cs index 1c6e6f9f4..a89cec564 100644 --- a/websocket-sharp/PayloadData.cs +++ b/websocket-sharp/PayloadData.cs @@ -45,6 +45,11 @@ internal class PayloadData : IEnumerable #region Public Fields + /// + /// Represents the empty payload data. + /// + public static readonly PayloadData Empty = new PayloadData (); + /// /// Represents the allowable max length. /// From 72ae755c50dcfc8d17e27294f2521e2c6f1b91a7 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 1 Oct 2015 15:34:00 +0900 Subject: [PATCH 0126/6294] [Modify] Polish it --- websocket-sharp/PayloadData.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/websocket-sharp/PayloadData.cs b/websocket-sharp/PayloadData.cs index a89cec564..39f212c78 100644 --- a/websocket-sharp/PayloadData.cs +++ b/websocket-sharp/PayloadData.cs @@ -29,7 +29,6 @@ using System; using System.Collections; using System.Collections.Generic; -using System.Text; namespace WebSocketSharp { From e02b5537394b8a55a2728997813e1d800aa099ed Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 2 Oct 2015 11:32:36 +0900 Subject: [PATCH 0127/6294] [Modify] Rename it to ToArray --- websocket-sharp/Server/WebSocketServiceHost.cs | 4 +--- websocket-sharp/Server/WebSocketServiceManager.cs | 4 ++-- websocket-sharp/Server/WebSocketSessionManager.cs | 2 +- websocket-sharp/WebSocket.cs | 13 ++++++------- websocket-sharp/WebSocketFrame.cs | 10 +++++----- 5 files changed, 15 insertions(+), 18 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceHost.cs b/websocket-sharp/Server/WebSocketServiceHost.cs index 860019a5c..c938a8ee9 100644 --- a/websocket-sharp/Server/WebSocketServiceHost.cs +++ b/websocket-sharp/Server/WebSocketServiceHost.cs @@ -131,9 +131,7 @@ internal void Stop (ushort code, string reason) { var e = new CloseEventArgs (code, reason); var send = !code.IsReserved (); - var bytes = - send ? WebSocketFrame.CreateCloseFrame (e.PayloadData, false).ToByteArray () : null; - + var bytes = send ? WebSocketFrame.CreateCloseFrame (e.PayloadData, false).ToArray () : null; var timeout = send ? WaitTime : TimeSpan.Zero; Sessions.Stop (e, bytes, timeout); } diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index e28f44908..7c7e89d43 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -361,7 +361,7 @@ internal void Stop (CloseEventArgs e, bool send, bool wait) lock (_sync) { _state = ServerState.ShuttingDown; var bytes = send - ? WebSocketFrame.CreateCloseFrame (e.PayloadData, false).ToByteArray () + ? WebSocketFrame.CreateCloseFrame (e.PayloadData, false).ToArray () : null; var timeout = wait ? _waitTime : TimeSpan.Zero; @@ -582,7 +582,7 @@ public Dictionary> Broadping (string message) return null; } - return broadping (WebSocketFrame.CreatePingFrame (data, false).ToByteArray (), _waitTime); + return broadping (WebSocketFrame.CreatePingFrame (data, false).ToArray (), _waitTime); } /// diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 1c27e341a..357e01357 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -587,7 +587,7 @@ public Dictionary Broadping (string message) return null; } - return Broadping (WebSocketFrame.CreatePingFrame (data, false).ToByteArray (), _waitTime); + return Broadping (WebSocketFrame.CreatePingFrame (data, false).ToArray (), _waitTime); } /// diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 6b3e9305f..241bd4a26 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -749,7 +749,7 @@ private void close (CloseEventArgs e, bool send, bool wait) _logger.Trace ("Begin closing the connection."); e.WasClean = closeHandshake ( - send ? WebSocketFrame.CreateCloseFrame (e.PayloadData, _client).ToByteArray () : null, + send ? WebSocketFrame.CreateCloseFrame (e.PayloadData, _client).ToArray () : null, wait ? _waitTime : TimeSpan.Zero, _client ? (Action) releaseClientResources : releaseServerResources); @@ -1066,7 +1066,7 @@ private bool processFragmentedFrame (WebSocketFrame frame) private bool processPingFrame (WebSocketFrame frame) { - if (send (new WebSocketFrame (Opcode.Pong, frame.PayloadData, _client).ToByteArray ())) + if (send (new WebSocketFrame (Opcode.Pong, frame.PayloadData, _client).ToArray ())) _logger.Trace ("Returned a Pong."); if (_emitOnPing) @@ -1259,8 +1259,7 @@ private bool send (Fin fin, Opcode opcode, byte[] data, bool compressed) return false; } - return sendBytes ( - new WebSocketFrame (fin, opcode, data, compressed, _client).ToByteArray ()); + return sendBytes (new WebSocketFrame (fin, opcode, data, compressed, _client).ToArray ()); } } @@ -1756,7 +1755,7 @@ internal void Send (Opcode opcode, byte[] data, Dictionary diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index 2ef5e758e..2fc587981 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -68,7 +68,7 @@ internal class WebSocketFrame : IEnumerable static WebSocketFrame () { - EmptyUnmaskPingBytes = CreatePingFrame (false).ToByteArray (); + EmptyUnmaskPingBytes = CreatePingFrame (false).ToArray (); } #endregion @@ -347,7 +347,7 @@ private static string dump (WebSocketFrame frame) output.AppendFormat (headerFmt, String.Empty); - var bytes = frame.ToByteArray (); + var bytes = frame.ToArray (); for (long i = 0; i <= cnt; i++) { var j = i * 4; if (i < cnt) { @@ -742,7 +742,7 @@ internal void Unmask () public IEnumerator GetEnumerator () { - foreach (var b in ToByteArray ()) + foreach (var b in ToArray ()) yield return b; } @@ -756,7 +756,7 @@ public string PrintToString (bool dumped) return dumped ? dump (this) : print (this); } - public byte[] ToByteArray () + public byte[] ToArray () { using (var buff = new MemoryStream ()) { var header = (int) _fin; @@ -789,7 +789,7 @@ public byte[] ToByteArray () public override string ToString () { - return BitConverter.ToString (ToByteArray ()); + return BitConverter.ToString (ToArray ()); } #endregion From 242c96efd7f8d1e7e60622b4fb70c8ef45ed994b Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 2 Oct 2015 15:03:10 +0900 Subject: [PATCH 0128/6294] [Modify] Polish it --- websocket-sharp/WebSocketFrame.cs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index 2fc587981..9d31c2d21 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -605,15 +605,16 @@ private static WebSocketFrame readPayloadData (Stream stream, WebSocketFrame fra CloseStatusCode.TooBig, "The length of 'Payload Data' of a frame is greater than the allowable max length."); + var llen = (long) len; var bytes = frame._payloadLength < 127 ? stream.ReadBytes ((int) len) - : stream.ReadBytes ((long) len, 1024); + : stream.ReadBytes (llen, 1024); - if (bytes.LongLength != (long) len) + if (bytes.LongLength != llen) throw new WebSocketException ( "The 'Payload Data' of a frame cannot be read from the data source."); - frame._payloadData = new PayloadData (bytes); + frame._payloadData = new PayloadData (bytes, llen); return frame; } @@ -637,12 +638,13 @@ private static void readPayloadDataAsync ( CloseStatusCode.TooBig, "The length of 'Payload Data' of a frame is greater than the allowable max length."); + var llen = (long) len; Action compl = bytes => { - if (bytes.LongLength != (long) len) + if (bytes.LongLength != llen) throw new WebSocketException ( "The 'Payload Data' of a frame cannot be read from the data source."); - frame._payloadData = new PayloadData (bytes); + frame._payloadData = new PayloadData (bytes, llen); completed (frame); }; @@ -651,7 +653,7 @@ private static void readPayloadDataAsync ( return; } - stream.ReadBytesAsync ((long) len, 1024, compl, error); + stream.ReadBytesAsync (llen, 1024, compl, error); } #endregion From 53421952b5e986ef5962344206c214a229906de6 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 3 Oct 2015 15:12:21 +0900 Subject: [PATCH 0129/6294] [Modify] Replace it --- websocket-sharp/WebSocketFrame.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index 9d31c2d21..cfac12827 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -595,7 +595,7 @@ private static WebSocketFrame readPayloadData (Stream stream, WebSocketFrame fra { var len = frame.FullPayloadLength; if (len == 0) { - frame._payloadData = new PayloadData (); + frame._payloadData = PayloadData.Empty; return frame; } @@ -626,7 +626,7 @@ private static void readPayloadDataAsync ( { var len = frame.FullPayloadLength; if (len == 0) { - frame._payloadData = new PayloadData (); + frame._payloadData = PayloadData.Empty; completed (frame); return; @@ -667,7 +667,7 @@ internal static WebSocketFrame CreateCloseFrame (PayloadData payloadData, bool m internal static WebSocketFrame CreatePingFrame (bool mask) { - return new WebSocketFrame (Fin.Final, Opcode.Ping, new PayloadData (), false, mask); + return new WebSocketFrame (Fin.Final, Opcode.Ping, PayloadData.Empty, false, mask); } internal static WebSocketFrame CreatePingFrame (byte[] data, bool mask) From 4603399f9238574e5faa03b33f43af013256a444 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 3 Oct 2015 15:33:45 +0900 Subject: [PATCH 0130/6294] [Modify] Rename it --- websocket-sharp/WebSocketFrame.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index cfac12827..108fffe1a 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -675,12 +675,12 @@ internal static WebSocketFrame CreatePingFrame (byte[] data, bool mask) return new WebSocketFrame (Fin.Final, Opcode.Ping, new PayloadData (data), false, mask); } - internal static WebSocketFrame Read (Stream stream) + internal static WebSocketFrame ReadFrame (Stream stream) { - return Read (stream, true); + return ReadFrame (stream, true); } - internal static WebSocketFrame Read (Stream stream, bool unmask) + internal static WebSocketFrame ReadFrame (Stream stream, bool unmask) { var frame = readHeader (stream); readExtendedPayloadLength (stream, frame); From d0cb45855050a91f24efae872df5e9485dd2ac25 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 4 Oct 2015 15:36:11 +0900 Subject: [PATCH 0131/6294] [Modify] Rename it --- websocket-sharp/WebSocket.cs | 2 +- websocket-sharp/WebSocketFrame.cs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 241bd4a26..bca183898 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1462,7 +1462,7 @@ private void startReceiving () _receivePong = new AutoResetEvent (false); Action receive = null; - receive = () => WebSocketFrame.ReadAsync ( + receive = () => WebSocketFrame.ReadFrameAsync ( _stream, false, frame => { diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index 108fffe1a..d1487bcdf 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -693,13 +693,13 @@ internal static WebSocketFrame ReadFrame (Stream stream, bool unmask) return frame; } - internal static void ReadAsync ( + internal static void ReadFrameAsync ( Stream stream, Action completed, Action error) { - ReadAsync (stream, true, completed, error); + ReadFrameAsync (stream, true, completed, error); } - internal static void ReadAsync ( + internal static void ReadFrameAsync ( Stream stream, bool unmask, Action completed, Action error) { readHeaderAsync ( From 51e61827f60033900af09a9a523b691dace6e8cb Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 4 Oct 2015 15:40:57 +0900 Subject: [PATCH 0132/6294] [Modify] Remove it --- websocket-sharp/WebSocketFrame.cs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index d1487bcdf..abd9cbef8 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -675,11 +675,6 @@ internal static WebSocketFrame CreatePingFrame (byte[] data, bool mask) return new WebSocketFrame (Fin.Final, Opcode.Ping, new PayloadData (data), false, mask); } - internal static WebSocketFrame ReadFrame (Stream stream) - { - return ReadFrame (stream, true); - } - internal static WebSocketFrame ReadFrame (Stream stream, bool unmask) { var frame = readHeader (stream); From c8c4f1223269c0b008ab9e238690e2e20e3754b1 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 5 Oct 2015 14:23:12 +0900 Subject: [PATCH 0133/6294] [Modify] Remove it --- websocket-sharp/WebSocketFrame.cs | 6 ------ 1 file changed, 6 deletions(-) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index abd9cbef8..827b8ae62 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -688,12 +688,6 @@ internal static WebSocketFrame ReadFrame (Stream stream, bool unmask) return frame; } - internal static void ReadFrameAsync ( - Stream stream, Action completed, Action error) - { - ReadFrameAsync (stream, true, completed, error); - } - internal static void ReadFrameAsync ( Stream stream, bool unmask, Action completed, Action error) { From 41619ca1b1899e8b6bac8106b3077241df05b0b9 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 5 Oct 2015 14:31:00 +0900 Subject: [PATCH 0134/6294] [Modify] Move it --- websocket-sharp/WebSocketFrame.cs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index 827b8ae62..2d8b59535 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -131,17 +131,21 @@ internal WebSocketFrame ( #endregion - #region Public Properties + #region Internal Properties - public byte[] ExtendedPayloadLength { + internal int ExtendedPayloadLengthCount { get { - return _extPayloadLength; + return _payloadLength < 126 ? 0 : (_payloadLength == 126 ? 2 : 8); } } - public int ExtendedPayloadLengthCount { + #endregion + + #region Public Properties + + public byte[] ExtendedPayloadLength { get { - return _payloadLength < 126 ? 0 : (_payloadLength == 126 ? 2 : 8); + return _extPayloadLength; } } From 75faec8860e6bd5f72a17f8d1646d060b854f5ce Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 6 Oct 2015 14:43:36 +0900 Subject: [PATCH 0135/6294] [Modify] Move it --- websocket-sharp/WebSocketFrame.cs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index 2d8b59535..0c02b8d11 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -139,6 +139,16 @@ internal int ExtendedPayloadLengthCount { } } + internal ulong FullPayloadLength { + get { + return _payloadLength < 126 + ? _payloadLength + : _payloadLength == 126 + ? _extPayloadLength.ToUInt16 (ByteOrder.Big) + : _extPayloadLength.ToUInt64 (ByteOrder.Big); + } + } + #endregion #region Public Properties @@ -155,16 +165,6 @@ public Fin Fin { } } - public ulong FullPayloadLength { - get { - return _payloadLength < 126 - ? _payloadLength - : _payloadLength == 126 - ? _extPayloadLength.ToUInt16 (ByteOrder.Big) - : _extPayloadLength.ToUInt64 (ByteOrder.Big); - } - } - public bool IsBinary { get { return _opcode == Opcode.Binary; From 086b1717c0655dd67fc85c4104d29b9c5bbf52f1 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 6 Oct 2015 14:46:36 +0900 Subject: [PATCH 0136/6294] [Modify] Remove it --- websocket-sharp/WebSocketFrame.cs | 6 ------ 1 file changed, 6 deletions(-) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index 0c02b8d11..8445f1479 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -219,12 +219,6 @@ public bool IsMasked { } } - public bool IsPerMessageCompressed { - get { - return (_opcode == Opcode.Binary || _opcode == Opcode.Text) && _rsv1 == Rsv.On; - } - } - public bool IsPing { get { return _opcode == Opcode.Ping; From ee177afb7cd21156e398ed8b79511fa7ab1a9586 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 7 Oct 2015 11:08:34 +0900 Subject: [PATCH 0137/6294] [Modify] Rename it --- websocket-sharp/Server/WebSocketServiceManager.cs | 2 +- websocket-sharp/Server/WebSocketSessionManager.cs | 6 +++--- websocket-sharp/WebSocket.cs | 2 +- websocket-sharp/WebSocketFrame.cs | 11 +++++++++-- 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index 7c7e89d43..5a7420248 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -551,7 +551,7 @@ public Dictionary> Broadping () return null; } - return broadping (WebSocketFrame.EmptyUnmaskPingBytes, _waitTime); + return broadping (WebSocketFrame.EmptyPingBytes, _waitTime); } /// diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 357e01357..6a0071eb5 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -99,7 +99,7 @@ internal ServerState State { /// public IEnumerable ActiveIDs { get { - foreach (var res in Broadping (WebSocketFrame.EmptyUnmaskPingBytes, _waitTime)) + foreach (var res in Broadping (WebSocketFrame.EmptyPingBytes, _waitTime)) if (res.Value) yield return res.Key; } @@ -144,7 +144,7 @@ public IEnumerable IDs { /// public IEnumerable InactiveIDs { get { - foreach (var res in Broadping (WebSocketFrame.EmptyUnmaskPingBytes, _waitTime)) + foreach (var res in Broadping (WebSocketFrame.EmptyPingBytes, _waitTime)) if (!res.Value) yield return res.Key; } @@ -558,7 +558,7 @@ public Dictionary Broadping () return null; } - return Broadping (WebSocketFrame.EmptyUnmaskPingBytes, _waitTime); + return Broadping (WebSocketFrame.EmptyPingBytes, _waitTime); } /// diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index bca183898..b65aec3a3 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2226,7 +2226,7 @@ public bool Ping () { var bytes = _client ? WebSocketFrame.CreatePingFrame (true).ToArray () - : WebSocketFrame.EmptyUnmaskPingBytes; + : WebSocketFrame.EmptyPingBytes; return Ping (bytes, _waitTime); } diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index 8445f1479..2ee8687b0 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -60,7 +60,14 @@ internal class WebSocketFrame : IEnumerable #region Internal Fields - internal static readonly byte[] EmptyUnmaskPingBytes; + /// + /// Represents the Ping frame without the payload data as an array of . + /// + /// + /// The value of this field is created from an unmasked Ping frame, so it can only be used to + /// send a Ping from a server. + /// + internal static readonly byte[] EmptyPingBytes; #endregion @@ -68,7 +75,7 @@ internal class WebSocketFrame : IEnumerable static WebSocketFrame () { - EmptyUnmaskPingBytes = CreatePingFrame (false).ToArray (); + EmptyPingBytes = CreatePingFrame (false).ToArray (); } #endregion From e89b674bc89bafd24308a40b88fc966bc8685abe Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 8 Oct 2015 14:38:33 +0900 Subject: [PATCH 0138/6294] [Modify] Polish it --- websocket-sharp/WebSocketFrame.cs | 34 ++++++++++--------------------- 1 file changed, 11 insertions(+), 23 deletions(-) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index 2ee8687b0..0eeddc081 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -389,35 +389,23 @@ private static bool isData (Opcode opcode) private static string print (WebSocketFrame frame) { - /* Opcode */ - - var opcode = frame._opcode.ToString (); - - /* Payload Length */ - + // Payload Length var payloadLen = frame._payloadLength; - /* Extended Payload Length */ - - var extPayloadLen = payloadLen < 126 - ? String.Empty - : payloadLen == 126 - ? frame._extPayloadLength.ToUInt16 (ByteOrder.Big).ToString () - : frame._extPayloadLength.ToUInt64 (ByteOrder.Big).ToString (); - - /* Masking Key */ - - var masked = frame.IsMasked; - var maskingKey = masked ? BitConverter.ToString (frame._maskingKey) : String.Empty; + // Extended Payload Length + var extPayloadLen = payloadLen > 125 ? frame.FullPayloadLength.ToString () : String.Empty; - /* Payload Data */ + // Masking Key + var maskingKey = BitConverter.ToString (frame._maskingKey); + // Payload Data var payload = payloadLen == 0 ? String.Empty : payloadLen > 125 - ? String.Format ("A {0} frame.", opcode.ToLower ()) - : !masked && !frame.IsFragmented && !frame.IsCompressed && frame.IsText - ? Encoding.UTF8.GetString (frame._payloadData.ApplicationData) + ? "---" + : frame.IsText && + !(frame.IsMasked || frame.IsFragmented || frame.IsCompressed) + ? frame._payloadData.ApplicationData.UTF8Decode () : frame._payloadData.ToString (); var fmt = @" @@ -438,7 +426,7 @@ private static string print (WebSocketFrame frame) frame._rsv1, frame._rsv2, frame._rsv3, - opcode, + frame._opcode, frame._mask, payloadLen, extPayloadLen, From 1ebb9194f2b19423550104f17bb4b5643817ecf8 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 9 Oct 2015 15:33:30 +0900 Subject: [PATCH 0139/6294] [Modify] Add the static constructor --- websocket-sharp/PayloadData.cs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/PayloadData.cs b/websocket-sharp/PayloadData.cs index 39f212c78..511089db1 100644 --- a/websocket-sharp/PayloadData.cs +++ b/websocket-sharp/PayloadData.cs @@ -47,7 +47,7 @@ internal class PayloadData : IEnumerable /// /// Represents the empty payload data. /// - public static readonly PayloadData Empty = new PayloadData (); + public static readonly PayloadData Empty; /// /// Represents the allowable max length. @@ -62,7 +62,17 @@ internal class PayloadData : IEnumerable /// WebSocket.FragmentLength and Int64.MaxValue inclusive. /// /// - public static readonly ulong MaxLength = Int64.MaxValue; + public static readonly ulong MaxLength; + + #endregion + + #region Static Constructor + + static PayloadData () + { + Empty = new PayloadData (); + MaxLength = Int64.MaxValue; + } #endregion From 2dca329d6a7e07415e37f9e1a7fd9de71b4e98db Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 10 Oct 2015 17:10:22 +0900 Subject: [PATCH 0140/6294] [Modify] Polish it --- websocket-sharp/PayloadData.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/PayloadData.cs b/websocket-sharp/PayloadData.cs index 511089db1..6bbf6905d 100644 --- a/websocket-sharp/PayloadData.cs +++ b/websocket-sharp/PayloadData.cs @@ -55,10 +55,10 @@ internal class PayloadData : IEnumerable /// /// /// A will occur if the payload data length is - /// greater than this. + /// greater than the value of this field. /// /// - /// If you would like to change this value, you must set this to a value between + /// If you would like to change the value, you must set it to a value between /// WebSocket.FragmentLength and Int64.MaxValue inclusive. /// /// From 6fdef3c7f2cdb5b976203bc24830e8e85d1b79ea Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 11 Oct 2015 14:44:59 +0900 Subject: [PATCH 0141/6294] [Modify] Add the static constructor --- websocket-sharp/WebSocket.cs | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index b65aec3a3..6c1b24088 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -117,7 +117,7 @@ private Func /// /// Represents the empty array of used internally. /// - internal static readonly byte[] EmptyBytes = new byte[0]; + internal static readonly byte[] EmptyBytes; /// /// Represents the length used to determine whether the data should be fragmented in sending. @@ -131,12 +131,23 @@ private Func /// and Int32.MaxValue - 14 inclusive. /// /// - internal static readonly int FragmentLength = 1016; + internal static readonly int FragmentLength; /// /// Represents the random number generator used internally. /// - internal static readonly RandomNumberGenerator RandomNumber = new RNGCryptoServiceProvider (); + internal static readonly RandomNumberGenerator RandomNumber; + + #endregion + + #region Static Constructor + + static WebSocket () + { + EmptyBytes = new byte[0]; + FragmentLength = 1016; + RandomNumber = new RNGCryptoServiceProvider (); + } #endregion From a22bdb9efbdf2a6fbd89daf58a729f7e2d84d790 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 12 Oct 2015 15:16:44 +0900 Subject: [PATCH 0142/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 6c1b24088..aa2038e69 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -124,11 +124,11 @@ private Func /// /// /// - /// The data will be fragmented if that length is greater than this. + /// The data will be fragmented if that length is greater than the value of this field. /// /// - /// If you would like to change this value, you must set this to a value between 125 - /// and Int32.MaxValue - 14 inclusive. + /// If you would like to change the value, you must set it to a value between 125 and + /// Int32.MaxValue - 14 inclusive. /// /// internal static readonly int FragmentLength; From 16e5111996e922b598a9b8e1f999dfd217dbfbb9 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 13 Oct 2015 14:56:57 +0900 Subject: [PATCH 0143/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index aa2038e69..b4561d7f7 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1473,11 +1473,20 @@ private void startReceiving () _receivePong = new AutoResetEvent (false); Action receive = null; - receive = () => WebSocketFrame.ReadFrameAsync ( - _stream, - false, - frame => { - if (processReceivedFrame (frame) && _readyState != WebSocketState.Closed) { + receive = () => + WebSocketFrame.ReadFrameAsync ( + _stream, + false, + frame => { + if (!processReceivedFrame (frame) || _readyState == WebSocketState.Closed) { + var exit = _exitReceiving; + if (exit != null) + exit.Set (); + + return; + } + + // Receive next asap because a Ping or Close needs a response to it. receive (); if ((frame.IsControl && !(frame.IsPing && _emitOnPing)) || !frame.IsFinal) @@ -1493,12 +1502,8 @@ private void startReceiving () processException (ex, "An exception has occurred during an OnMessage event."); } } - } - else if (_exitReceiving != null) { - _exitReceiving.Set (); - } - }, - ex => processException (ex, "An exception has occurred while receiving a message.")); + }, + ex => processException (ex, "An exception has occurred while receiving a message.")); receive (); } From d5b6bcfe88b96a2c556cdeabdf42a9ee973f0df0 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 14 Oct 2015 17:11:46 +0900 Subject: [PATCH 0144/6294] [Modify] Add an extension method --- websocket-sharp/Ext.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 1bea822f0..071adff56 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -901,6 +901,11 @@ internal static void WriteBytes (this Stream stream, byte[] bytes) input.CopyTo (stream); } + internal static void WriteBytes (this Stream stream, byte[] bytes, int length) + { + stream.Write (bytes, 0, length); + } + #endregion #region Public Methods From f9eb4a8433ded4b4c841d56e59f015e5f7c24b81 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 15 Oct 2015 13:30:06 +0900 Subject: [PATCH 0145/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 071adff56..fc67621c4 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -91,7 +91,7 @@ private static MemoryStream compress (this Stream stream) stream.Position = 0; using (var ds = new DeflateStream (output, CompressionMode.Compress, true)) { - stream.CopyTo (ds); + stream.CopyTo (ds, 1024); ds.Close (); // BFINAL set to 1. output.Write (_last, 0, 1); output.Position = 0; @@ -125,7 +125,7 @@ private static MemoryStream decompress (this Stream stream) stream.Position = 0; using (var ds = new DeflateStream (stream, CompressionMode.Decompress, true)) { - ds.CopyTo (output); + ds.CopyTo (output, 1024); output.Position = 0; return output; @@ -288,12 +288,11 @@ internal static T[] Copy (this T[] source, long length) return dest; } - internal static void CopyTo (this Stream source, Stream destination) + internal static void CopyTo (this Stream source, Stream destination, int bufferLength) { - var buffLen = 1024; - var buff = new byte[buffLen]; + var buff = new byte[bufferLength]; var nread = 0; - while ((nread = source.Read (buff, 0, buffLen)) > 0) + while ((nread = source.Read (buff, 0, bufferLength)) > 0) destination.Write (buff, 0, nread); } @@ -739,7 +738,7 @@ internal static byte[] ToByteArray (this Stream stream) { using (var output = new MemoryStream ()) { stream.Position = 0; - stream.CopyTo (output); + stream.CopyTo (output, 1024); output.Close (); return output.ToArray (); @@ -898,7 +897,7 @@ internal static byte[] UTF8Encode (this string s) internal static void WriteBytes (this Stream stream, byte[] bytes) { using (var input = new MemoryStream (bytes)) - input.CopyTo (stream); + input.CopyTo (stream, 1024); } internal static void WriteBytes (this Stream stream, byte[] bytes, int length) From fef4747e265274d147e9b5e1ba9d1ac484e8abfd Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 15 Oct 2015 15:40:15 +0900 Subject: [PATCH 0146/6294] [Modify] Add an extension method --- websocket-sharp/Ext.cs | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index fc67621c4..f0ec2d8d7 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -905,6 +905,37 @@ internal static void WriteBytes (this Stream stream, byte[] bytes, int length) stream.Write (bytes, 0, length); } + internal static void WriteBytesAsync ( + this Stream stream, byte[] bytes, int bufferLength, Action completed, Action error) + { + var input = new MemoryStream (bytes); + var buff = new byte[bufferLength]; + + AsyncCallback callback = null; + callback = ar => { + try { + var nread = input.EndRead (ar); + if (nread <= 0) { + if (completed != null) + completed (); + + input.Dispose (); + return; + } + + stream.Write (buff, 0, nread); + input.BeginRead (buff, 0, bufferLength, callback, null); + } + catch (Exception ex) { + input.Dispose (); + if (error != null) + error (ex); + } + }; + + input.BeginRead (buff, 0, bufferLength, callback, null); + } + #endregion #region Public Methods From 1d645fe8f0ce0aa4ae45e78db0db34df82627a2c Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 15 Oct 2015 15:49:08 +0900 Subject: [PATCH 0147/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 11 +++-------- websocket-sharp/WebSocket.cs | 2 +- websocket-sharp/WebSocketFrame.cs | 2 +- 3 files changed, 5 insertions(+), 10 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index f0ec2d8d7..4e041a135 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -894,15 +894,10 @@ internal static byte[] UTF8Encode (this string s) return Encoding.UTF8.GetBytes (s); } - internal static void WriteBytes (this Stream stream, byte[] bytes) + internal static void WriteBytes (this Stream stream, byte[] bytes, int bufferLength) { using (var input = new MemoryStream (bytes)) - input.CopyTo (stream, 1024); - } - - internal static void WriteBytes (this Stream stream, byte[] bytes, int length) - { - stream.Write (bytes, 0, length); + input.CopyTo (stream, bufferLength); } internal static void WriteBytesAsync ( @@ -1840,7 +1835,7 @@ public static void WriteContent (this HttpListenerResponse response, byte[] cont if (len <= Int32.MaxValue) output.Write (content, 0, (int) len); else - output.WriteBytes (content); + output.WriteBytes (content, 1024); output.Close (); } diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index b4561d7f7..02d61be1e 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1058,7 +1058,7 @@ private bool processFragmentedFrame (WebSocketFrame frame) _inContinuation = true; } - _fragmentsBuffer.WriteBytes (frame.PayloadData.ApplicationData); + _fragmentsBuffer.WriteBytes (frame.PayloadData.ApplicationData, 1024); if (frame.IsFinal) { using (_fragmentsBuffer) { var data = _compression != CompressionMethod.None diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index 0eeddc081..5ff0b833c 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -763,7 +763,7 @@ public byte[] ToArray () if (_payloadLength < 127) buff.Write (bytes, 0, bytes.Length); else - buff.WriteBytes (bytes); + buff.WriteBytes (bytes, 1024); } buff.Close (); From 9d514440bf75c5f2006782b3a22b2f505c8ff181 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 15 Oct 2015 16:04:43 +0900 Subject: [PATCH 0148/6294] [Modify] Add an extension method --- websocket-sharp/Ext.cs | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 4e041a135..e004217b4 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -296,6 +296,44 @@ internal static void CopyTo (this Stream source, Stream destination, int bufferL destination.Write (buff, 0, nread); } + internal static void CopyToAsync ( + this Stream source, + Stream destination, + int bufferLength, + Action completed, + Action error) + { + var buff = new byte[bufferLength]; + + AsyncCallback callback = null; + callback = ar => { + try { + var nread = source.EndRead (ar); + if (nread <= 0) { + if (completed != null) + completed (); + + return; + } + + destination.Write (buff, 0, nread); + source.BeginRead (buff, 0, bufferLength, callback, null); + } + catch (Exception ex) { + if (error != null) + error (ex); + } + }; + + try { + source.BeginRead (buff, 0, bufferLength, callback, null); + } + catch (Exception ex) { + if (error != null) + error (ex); + } + } + internal static byte[] Decompress (this byte[] data, CompressionMethod method) { return method == CompressionMethod.Deflate From 39add76329f8d032618d51d417edb61d6509c4af Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 16 Oct 2015 11:26:36 +0900 Subject: [PATCH 0149/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 31 ++++++++++--------------------- 1 file changed, 10 insertions(+), 21 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index e004217b4..e9e99b325 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -942,31 +942,20 @@ internal static void WriteBytesAsync ( this Stream stream, byte[] bytes, int bufferLength, Action completed, Action error) { var input = new MemoryStream (bytes); - var buff = new byte[bufferLength]; + input.CopyToAsync ( + stream, + bufferLength, + () => { + if (completed != null) + completed (); - AsyncCallback callback = null; - callback = ar => { - try { - var nread = input.EndRead (ar); - if (nread <= 0) { - if (completed != null) - completed (); - - input.Dispose (); - return; - } - - stream.Write (buff, 0, nread); - input.BeginRead (buff, 0, bufferLength, callback, null); - } - catch (Exception ex) { + input.Dispose (); + }, + ex => { input.Dispose (); if (error != null) error (ex); - } - }; - - input.BeginRead (buff, 0, bufferLength, callback, null); + }); } #endregion From 1f40f8e5669a7475280b777b962f4d49458cd545 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 17 Oct 2015 15:31:00 +0900 Subject: [PATCH 0150/6294] [Modify] Polish it More clearly received or not. --- .../Server/WebSocketServiceHost.cs | 3 +- .../Server/WebSocketServiceManager.cs | 9 +-- .../Server/WebSocketSessionManager.cs | 4 +- websocket-sharp/WebSocket.cs | 77 ++++++++++--------- 4 files changed, 46 insertions(+), 47 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceHost.cs b/websocket-sharp/Server/WebSocketServiceHost.cs index c938a8ee9..8d41d2104 100644 --- a/websocket-sharp/Server/WebSocketServiceHost.cs +++ b/websocket-sharp/Server/WebSocketServiceHost.cs @@ -132,8 +132,7 @@ internal void Stop (ushort code, string reason) var e = new CloseEventArgs (code, reason); var send = !code.IsReserved (); var bytes = send ? WebSocketFrame.CreateCloseFrame (e.PayloadData, false).ToArray () : null; - var timeout = send ? WaitTime : TimeSpan.Zero; - Sessions.Stop (e, bytes, timeout); + Sessions.Stop (e, bytes, send); } #endregion diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index 5a7420248..8ed76b335 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -356,17 +356,14 @@ internal void Start () } } - internal void Stop (CloseEventArgs e, bool send, bool wait) + internal void Stop (CloseEventArgs e, bool send, bool receive) { lock (_sync) { _state = ServerState.ShuttingDown; - var bytes = send - ? WebSocketFrame.CreateCloseFrame (e.PayloadData, false).ToArray () - : null; - var timeout = wait ? _waitTime : TimeSpan.Zero; + var bytes = send ? WebSocketFrame.CreateCloseFrame (e.PayloadData, false).ToArray () : null; foreach (var host in _hosts.Values) - host.Sessions.Stop (e, bytes, timeout); + host.Sessions.Stop (e, bytes, receive); _hosts.Clear (); _state = ServerState.Stop; diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 6a0071eb5..88271994a 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -368,14 +368,14 @@ internal void Start () } } - internal void Stop (CloseEventArgs e, byte[] frameAsBytes, TimeSpan timeout) + internal void Stop (CloseEventArgs e, byte[] frameAsBytes, bool receive) { lock (_sync) { _state = ServerState.ShuttingDown; _sweepTimer.Enabled = false; foreach (var session in _sessions.Values.ToList ()) - session.Context.WebSocket.Close (e, frameAsBytes, timeout); + session.Context.WebSocket.Close (e, frameAsBytes, receive); _state = ServerState.Stop; } diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 02d61be1e..eee09c29f 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -738,7 +738,7 @@ private string checkIfValidReceivedFrame (WebSocketFrame frame) : null; } - private void close (CloseEventArgs e, bool send, bool wait) + private void close (CloseEventArgs e, bool send, bool receive, bool received) { lock (_forConn) { if (_readyState == WebSocketState.Closing) { @@ -752,17 +752,15 @@ private void close (CloseEventArgs e, bool send, bool wait) } send = send && _readyState == WebSocketState.Open; - wait = wait && send; + receive = receive && send; _readyState = WebSocketState.Closing; } _logger.Trace ("Begin closing the connection."); - e.WasClean = closeHandshake ( - send ? WebSocketFrame.CreateCloseFrame (e.PayloadData, _client).ToArray () : null, - wait ? _waitTime : TimeSpan.Zero, - _client ? (Action) releaseClientResources : releaseServerResources); + var bytes = send ? WebSocketFrame.CreateCloseFrame (e.PayloadData, _client).ToArray () : null; + e.WasClean = closeHandshake (bytes, receive, received); _logger.Trace ("End closing the connection."); @@ -776,19 +774,23 @@ private void close (CloseEventArgs e, bool send, bool wait) } } - private void closeAsync (CloseEventArgs e, bool send, bool wait) + private void closeAsync (CloseEventArgs e, bool send, bool receive, bool received) { - Action closer = close; - closer.BeginInvoke (e, send, wait, ar => closer.EndInvoke (ar), null); + Action closer = close; + closer.BeginInvoke (e, send, receive, received, ar => closer.EndInvoke (ar), null); } - private bool closeHandshake (byte[] frameAsBytes, TimeSpan timeout, Action release) + private bool closeHandshake (byte[] frameAsBytes, bool receive, bool received) { var sent = frameAsBytes != null && sendBytes (frameAsBytes); - var received = timeout == TimeSpan.Zero || - (sent && _exitReceiving != null && _exitReceiving.WaitOne (timeout)); + received = received || + (receive && sent && _exitReceiving != null && _exitReceiving.WaitOne (_waitTime)); + + if (_client) + releaseClientResources (); + else + releaseServerResources (); - release (); if (_fragmentsBuffer != null) { _fragmentsBuffer.Dispose (); _fragmentsBuffer = null; @@ -944,7 +946,7 @@ private bool doHandshake () msg = "An error has occurred while connecting."; error (msg, null); - close (new CloseEventArgs (CloseStatusCode.Abnormal, msg), false, false); + close (new CloseEventArgs (CloseStatusCode.Abnormal, msg), false, false, false); return false; } @@ -1006,7 +1008,7 @@ private void open () private bool processCloseFrame (WebSocketFrame frame) { var payload = frame.PayloadData; - close (new CloseEventArgs (payload), !payload.IncludesReservedCloseStatusCode, false); + close (new CloseEventArgs (payload), !payload.IncludesReservedCloseStatusCode, false, true); return false; } @@ -1043,7 +1045,8 @@ private void processException (Exception exception, string message) return; } - close (new CloseEventArgs (code, reason ?? code.GetMessage ()), !code.IsReserved (), false); + close ( + new CloseEventArgs (code, reason ?? code.GetMessage ()), !code.IsReserved (), false, false); } private bool processFragmentedFrame (WebSocketFrame frame) @@ -1677,7 +1680,7 @@ internal void Close (HttpStatusCode code) } // As server - internal void Close (CloseEventArgs e, byte[] frameAsBytes, TimeSpan timeout) + internal void Close (CloseEventArgs e, byte[] frameAsBytes, bool receive) { lock (_forConn) { if (_readyState == WebSocketState.Closing) { @@ -1693,7 +1696,7 @@ internal void Close (CloseEventArgs e, byte[] frameAsBytes, TimeSpan timeout) _readyState = WebSocketState.Closing; } - e.WasClean = closeHandshake (frameAsBytes, timeout, releaseServerResources); + e.WasClean = closeHandshake (frameAsBytes, receive, false); _readyState = WebSocketState.Closed; try { @@ -1874,7 +1877,7 @@ public void Close () return; } - close (new CloseEventArgs (), true, true); + close (new CloseEventArgs (), true, true, false); } /// @@ -1901,12 +1904,12 @@ public void Close (ushort code) } if (code == (ushort) CloseStatusCode.NoStatus) { - close (new CloseEventArgs (), true, true); + close (new CloseEventArgs (), true, true, false); return; } var send = !code.IsReserved (); - close (new CloseEventArgs (code), send, send); + close (new CloseEventArgs (code), send, send, false); } /// @@ -1930,12 +1933,12 @@ public void Close (CloseStatusCode code) } if (code == CloseStatusCode.NoStatus) { - close (new CloseEventArgs (), true, true); + close (new CloseEventArgs (), true, true, false); return; } var send = !code.IsReserved (); - close (new CloseEventArgs (code), send, send); + close (new CloseEventArgs (code), send, send, false); } /// @@ -1966,12 +1969,12 @@ public void Close (ushort code, string reason) } if (code == (ushort) CloseStatusCode.NoStatus) { - close (new CloseEventArgs (), true, true); + close (new CloseEventArgs (), true, true, false); return; } var send = !code.IsReserved (); - close (new CloseEventArgs (code, reason), send, send); + close (new CloseEventArgs (code, reason), send, send, false); } /// @@ -2002,12 +2005,12 @@ public void Close (CloseStatusCode code, string reason) } if (code == CloseStatusCode.NoStatus) { - close (new CloseEventArgs (), true, true); + close (new CloseEventArgs (), true, true, false); return; } var send = !code.IsReserved (); - close (new CloseEventArgs (code, reason), send, send); + close (new CloseEventArgs (code, reason), send, send, false); } /// @@ -2026,7 +2029,7 @@ public void CloseAsync () return; } - closeAsync (new CloseEventArgs (), true, true); + closeAsync (new CloseEventArgs (), true, true, false); } /// @@ -2058,12 +2061,12 @@ public void CloseAsync (ushort code) } if (code == (ushort) CloseStatusCode.NoStatus) { - closeAsync (new CloseEventArgs (), true, true); + closeAsync (new CloseEventArgs (), true, true, false); return; } var send = !code.IsReserved (); - closeAsync (new CloseEventArgs (code), send, send); + closeAsync (new CloseEventArgs (code), send, send, false); } /// @@ -2090,12 +2093,12 @@ public void CloseAsync (CloseStatusCode code) } if (code == CloseStatusCode.NoStatus) { - closeAsync (new CloseEventArgs (), true, true); + closeAsync (new CloseEventArgs (), true, true, false); return; } var send = !code.IsReserved (); - closeAsync (new CloseEventArgs (code), send, send); + closeAsync (new CloseEventArgs (code), send, send, false); } /// @@ -2131,12 +2134,12 @@ public void CloseAsync (ushort code, string reason) } if (code == (ushort) CloseStatusCode.NoStatus) { - closeAsync (new CloseEventArgs (), true, true); + closeAsync (new CloseEventArgs (), true, true, false); return; } var send = !code.IsReserved (); - closeAsync (new CloseEventArgs (code, reason), send, send); + closeAsync (new CloseEventArgs (code, reason), send, send, false); } /// @@ -2173,12 +2176,12 @@ public void CloseAsync (CloseStatusCode code, string reason) } if (code == CloseStatusCode.NoStatus) { - closeAsync (new CloseEventArgs (), true, true); + closeAsync (new CloseEventArgs (), true, true, false); return; } var send = !code.IsReserved (); - closeAsync (new CloseEventArgs (code, reason), send, send); + closeAsync (new CloseEventArgs (code, reason), send, send, false); } /// @@ -2631,7 +2634,7 @@ public void SetProxy (string url, string username, string password) /// void IDisposable.Dispose () { - close (new CloseEventArgs (CloseStatusCode.Away), true, true); + close (new CloseEventArgs (CloseStatusCode.Away), true, true, false); } #endregion From 0b748281e42c55e336fe3b34058a9079592db653 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 18 Oct 2015 17:40:33 +0900 Subject: [PATCH 0151/6294] [Modify] Polish it Add a method to release common resources. --- websocket-sharp/WebSocket.cs | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index eee09c29f..a15553130 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -791,21 +791,7 @@ private bool closeHandshake (byte[] frameAsBytes, bool receive, bool received) else releaseServerResources (); - if (_fragmentsBuffer != null) { - _fragmentsBuffer.Dispose (); - _fragmentsBuffer = null; - _inContinuation = false; - } - - if (_receivePong != null) { - _receivePong.Close (); - _receivePong = null; - } - - if (_exitReceiving != null) { - _exitReceiving.Close (); - _exitReceiving = null; - } + releaseCommonResources (); var ret = sent && received; _logger.Debug ( @@ -1164,6 +1150,25 @@ private void releaseClientResources () } } + private void releaseCommonResources () + { + if (_fragmentsBuffer != null) { + _fragmentsBuffer.Dispose (); + _fragmentsBuffer = null; + _inContinuation = false; + } + + if (_receivePong != null) { + _receivePong.Close (); + _receivePong = null; + } + + if (_exitReceiving != null) { + _exitReceiving.Close (); + _exitReceiving = null; + } + } + // As server private void releaseServerResources () { From 30a62b479dc38d195658f387c8a2e32dfd6f1809 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 19 Oct 2015 15:01:46 +0900 Subject: [PATCH 0152/6294] [Modify] Polish it Remove releasing resources from the closeHandshake method. --- websocket-sharp/WebSocket.cs | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index a15553130..52818f81a 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -761,6 +761,7 @@ private void close (CloseEventArgs e, bool send, bool receive, bool received) var bytes = send ? WebSocketFrame.CreateCloseFrame (e.PayloadData, _client).ToArray () : null; e.WasClean = closeHandshake (bytes, receive, received); + releaseResources (); _logger.Trace ("End closing the connection."); @@ -786,13 +787,6 @@ private bool closeHandshake (byte[] frameAsBytes, bool receive, bool received) received = received || (receive && sent && _exitReceiving != null && _exitReceiving.WaitOne (_waitTime)); - if (_client) - releaseClientResources (); - else - releaseServerResources (); - - releaseCommonResources (); - var ret = sent && received; _logger.Debug ( String.Format ("Was clean?: {0}\n sent: {1}\n received: {2}", ret, sent, received)); @@ -1169,6 +1163,16 @@ private void releaseCommonResources () } } + private void releaseResources () + { + if (_client) + releaseClientResources (); + else + releaseServerResources (); + + releaseCommonResources (); + } + // As server private void releaseServerResources () { @@ -1702,6 +1706,8 @@ internal void Close (CloseEventArgs e, byte[] frameAsBytes, bool receive) } e.WasClean = closeHandshake (frameAsBytes, receive, false); + releaseServerResources (); + releaseCommonResources (); _readyState = WebSocketState.Closed; try { From 41e37f750a3c6d1a922c95b975bf2fe0f9c1d640 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 20 Oct 2015 17:37:49 +0900 Subject: [PATCH 0153/6294] [Modify] Polish it Add some xml doc comments. --- websocket-sharp/Fin.cs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Fin.cs b/websocket-sharp/Fin.cs index 12aa9faac..eddffbe4e 100644 --- a/websocket-sharp/Fin.cs +++ b/websocket-sharp/Fin.cs @@ -4,7 +4,7 @@ * * The MIT License * - * Copyright (c) 2012-2014 sta.blockhead + * Copyright (c) 2012-2015 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,9 +30,22 @@ namespace WebSocketSharp { + /// + /// Contains the values that indicate whether a WebSocket frame is the final frame of a message. + /// + /// + /// The values of this enumeration are defined in + /// Section 5.2 of RFC 6455. + /// internal enum Fin : byte { + /// + /// Equivalent to numeric value 0. Indicates more frames of a message follow. + /// More = 0x0, + /// + /// Equivalent to numeric value 1. Indicates the final frame of a message. + /// Final = 0x1 } } From ce5cbdd67af0b7244de109ee9f0ba778c24c38cb Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 21 Oct 2015 12:29:48 +0900 Subject: [PATCH 0154/6294] [Modify] Polish it Add some xml doc comments. --- websocket-sharp/Mask.cs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Mask.cs b/websocket-sharp/Mask.cs index bd23b2886..018751d2f 100644 --- a/websocket-sharp/Mask.cs +++ b/websocket-sharp/Mask.cs @@ -4,7 +4,7 @@ * * The MIT License * - * Copyright (c) 2012-2014 sta.blockhead + * Copyright (c) 2012-2015 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,9 +30,22 @@ namespace WebSocketSharp { + /// + /// Contains the values that indicate whether the payload data of a WebSocket frame is masked. + /// + /// + /// The values of this enumeration are defined in + /// Section 5.2 of RFC 6455. + /// internal enum Mask : byte { + /// + /// Equivalent to numeric value 0. Indicates not masked. + /// Unmask = 0x0, + /// + /// Equivalent to numeric value 1. Indicates masked. + /// Mask = 0x1 } } From c262195f576cde7756110748c396c22366c6304e Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 22 Oct 2015 15:21:36 +0900 Subject: [PATCH 0155/6294] [Modify] Polish it Rename them. --- websocket-sharp/Mask.cs | 4 ++-- websocket-sharp/WebSocketFrame.cs | 14 +++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/websocket-sharp/Mask.cs b/websocket-sharp/Mask.cs index 018751d2f..5e308398a 100644 --- a/websocket-sharp/Mask.cs +++ b/websocket-sharp/Mask.cs @@ -42,10 +42,10 @@ internal enum Mask : byte /// /// Equivalent to numeric value 0. Indicates not masked. /// - Unmask = 0x0, + None = 0x0, /// /// Equivalent to numeric value 1. Indicates masked. /// - Mask = 0x1 + Masked = 0x1 } } diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index 5ff0b833c..fbd78a8b1 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -124,12 +124,12 @@ internal WebSocketFrame ( } if (mask) { - _mask = Mask.Mask; + _mask = Mask.Masked; _maskingKey = createMaskingKey (); payloadData.Mask (_maskingKey); } else { - _mask = Mask.Unmask; + _mask = Mask.None; _maskingKey = WebSocket.EmptyBytes; } @@ -222,7 +222,7 @@ public bool IsFragmented { public bool IsMasked { get { - return _mask == Mask.Mask; + return _mask == Mask.Masked; } } @@ -456,7 +456,7 @@ private static WebSocketFrame processHeader (byte[] header) var opcode = (Opcode) (header[0] & 0x0f); // MASK - var mask = (header[1] & 0x80) == 0x80 ? Mask.Mask : Mask.Unmask; + var mask = (header[1] & 0x80) == 0x80 ? Mask.Masked : Mask.None; // Payload Length var payloadLen = (byte) (header[1] & 0x7f); @@ -712,10 +712,10 @@ internal static void ReadFrameAsync ( internal void Unmask () { - if (_mask == Mask.Unmask) + if (_mask == Mask.None) return; - _mask = Mask.Unmask; + _mask = Mask.None; _payloadData.Mask (_maskingKey); _maskingKey = WebSocket.EmptyBytes; } @@ -755,7 +755,7 @@ public byte[] ToArray () if (_payloadLength > 125) buff.Write (_extPayloadLength, 0, _payloadLength == 126 ? 2 : 8); - if (_mask == Mask.Mask) + if (_mask == Mask.Masked) buff.Write (_maskingKey, 0, 4); if (_payloadLength > 0) { From da943ed4f3c0c0b050a9b621453a51e4865ed66b Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 23 Oct 2015 12:00:15 +0900 Subject: [PATCH 0156/6294] [Modify] Polish it --- websocket-sharp/WebSocketFrame.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index fbd78a8b1..66dbd05e5 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -64,7 +64,7 @@ internal class WebSocketFrame : IEnumerable /// Represents the Ping frame without the payload data as an array of . /// /// - /// The value of this field is created from an unmasked Ping frame, so it can only be used to + /// The value of this field is created from a non masked frame, so it can only be used to /// send a Ping from a server. /// internal static readonly byte[] EmptyPingBytes; From f2ccf9082cfeff0ef69552eb0bf69a4055cf1dc8 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 24 Oct 2015 14:04:07 +0900 Subject: [PATCH 0157/6294] [Modify] Polish it Add some xml doc comments. --- websocket-sharp/Rsv.cs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Rsv.cs b/websocket-sharp/Rsv.cs index 993ea91bf..577435a24 100644 --- a/websocket-sharp/Rsv.cs +++ b/websocket-sharp/Rsv.cs @@ -4,7 +4,7 @@ * * The MIT License * - * Copyright (c) 2012-2014 sta.blockhead + * Copyright (c) 2012-2015 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,9 +30,22 @@ namespace WebSocketSharp { + /// + /// Contains the values used in the RSVs (RSV1, RSV2, and RSV3) of a WebSocket frame. + /// + /// + /// The values of this enumeration are defined in + /// Section 5.2 of RFC 6455. + /// internal enum Rsv : byte { + /// + /// Equivalent to numeric value 0. Indicates zero. + /// Off = 0x0, + /// + /// Equivalent to numeric value 1. Indicates non-zero. + /// On = 0x1 } } From 65b6b27edca072a6aff01581e3dc4dee5e526a04 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 25 Oct 2015 15:23:38 +0900 Subject: [PATCH 0158/6294] [Modify] Polish it --- websocket-sharp/Rsv.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Rsv.cs b/websocket-sharp/Rsv.cs index 577435a24..1e85e32b2 100644 --- a/websocket-sharp/Rsv.cs +++ b/websocket-sharp/Rsv.cs @@ -31,7 +31,7 @@ namespace WebSocketSharp { /// - /// Contains the values used in the RSVs (RSV1, RSV2, and RSV3) of a WebSocket frame. + /// Contains the values used in each RSV (RSV1, RSV2, and RSV3) of a WebSocket frame. /// /// /// The values of this enumeration are defined in From 95c61ecca6e0739bd279dfe7c9b7c1ac6a7efd23 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 26 Oct 2015 14:33:27 +0900 Subject: [PATCH 0159/6294] [Modify] Polish it --- websocket-sharp/Opcode.cs | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/websocket-sharp/Opcode.cs b/websocket-sharp/Opcode.cs index 90e983830..362fcfeaa 100644 --- a/websocket-sharp/Opcode.cs +++ b/websocket-sharp/Opcode.cs @@ -31,42 +31,36 @@ namespace WebSocketSharp { /// - /// Contains the values of the opcode that indicates the type of a WebSocket frame. + /// Contains the values of the opcode that indicate the type of a WebSocket frame. /// /// - /// The values of the opcode are defined in + /// The values of this enumeration are defined in /// Section 5.2 of RFC 6455. /// public enum Opcode : byte { /// - /// Equivalent to numeric value 0. - /// Indicates a continuation frame. + /// Equivalent to numeric value 0. Indicates a continuation frame. /// Cont = 0x0, /// - /// Equivalent to numeric value 1. - /// Indicates a text frame. + /// Equivalent to numeric value 1. Indicates a text frame. /// Text = 0x1, /// - /// Equivalent to numeric value 2. - /// Indicates a binary frame. + /// Equivalent to numeric value 2. Indicates a binary frame. /// Binary = 0x2, /// - /// Equivalent to numeric value 8. - /// Indicates a connection close frame. + /// Equivalent to numeric value 8. Indicates a connection close frame. /// Close = 0x8, /// - /// Equivalent to numeric value 9. - /// Indicates a ping frame. + /// Equivalent to numeric value 9. Indicates a ping frame. /// Ping = 0x9, /// - /// Equivalent to numeric value 10. - /// Indicates a pong frame. + /// Equivalent to numeric value 10. Indicates a pong frame. /// Pong = 0xa } From 265c2a0221c656a5a5fe9e59df7545e3b4c07568 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 27 Oct 2015 14:47:44 +0900 Subject: [PATCH 0160/6294] [Modify] Polish it Rename them. --- websocket-sharp/Mask.cs | 4 ++-- websocket-sharp/WebSocketFrame.cs | 14 +++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/websocket-sharp/Mask.cs b/websocket-sharp/Mask.cs index 5e308398a..2123e6f87 100644 --- a/websocket-sharp/Mask.cs +++ b/websocket-sharp/Mask.cs @@ -42,10 +42,10 @@ internal enum Mask : byte /// /// Equivalent to numeric value 0. Indicates not masked. /// - None = 0x0, + Off = 0x0, /// /// Equivalent to numeric value 1. Indicates masked. /// - Masked = 0x1 + On = 0x1 } } diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index 66dbd05e5..7ee1353a5 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -124,12 +124,12 @@ internal WebSocketFrame ( } if (mask) { - _mask = Mask.Masked; + _mask = Mask.On; _maskingKey = createMaskingKey (); payloadData.Mask (_maskingKey); } else { - _mask = Mask.None; + _mask = Mask.Off; _maskingKey = WebSocket.EmptyBytes; } @@ -222,7 +222,7 @@ public bool IsFragmented { public bool IsMasked { get { - return _mask == Mask.Masked; + return _mask == Mask.On; } } @@ -456,7 +456,7 @@ private static WebSocketFrame processHeader (byte[] header) var opcode = (Opcode) (header[0] & 0x0f); // MASK - var mask = (header[1] & 0x80) == 0x80 ? Mask.Masked : Mask.None; + var mask = (header[1] & 0x80) == 0x80 ? Mask.On : Mask.Off; // Payload Length var payloadLen = (byte) (header[1] & 0x7f); @@ -712,10 +712,10 @@ internal static void ReadFrameAsync ( internal void Unmask () { - if (_mask == Mask.None) + if (_mask == Mask.Off) return; - _mask = Mask.None; + _mask = Mask.Off; _payloadData.Mask (_maskingKey); _maskingKey = WebSocket.EmptyBytes; } @@ -755,7 +755,7 @@ public byte[] ToArray () if (_payloadLength > 125) buff.Write (_extPayloadLength, 0, _payloadLength == 126 ? 2 : 8); - if (_mask == Mask.Masked) + if (_mask == Mask.On) buff.Write (_maskingKey, 0, 4); if (_payloadLength > 0) { From c9c6fdd7ad8e2179fce8eaa4abfa94cd39d09984 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 28 Oct 2015 16:20:12 +0900 Subject: [PATCH 0161/6294] [Modify] Polish it --- websocket-sharp/WebSocketState.cs | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/websocket-sharp/WebSocketState.cs b/websocket-sharp/WebSocketState.cs index 7136b60b6..635405cd1 100644 --- a/websocket-sharp/WebSocketState.cs +++ b/websocket-sharp/WebSocketState.cs @@ -4,7 +4,7 @@ * * The MIT License * - * Copyright (c) 2010-2014 sta.blockhead + * Copyright (c) 2010-2015 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -31,33 +31,31 @@ namespace WebSocketSharp { /// - /// Contains the values of the state of the WebSocket connection. + /// Contains the values of the state of a WebSocket connection. /// /// - /// The values of the state are defined in + /// The values of this enumeration are defined in /// The WebSocket API. /// public enum WebSocketState : ushort { /// - /// Equivalent to numeric value 0. - /// Indicates that the connection hasn't yet been established. + /// Equivalent to numeric value 0. Indicates that the connection hasn't yet been established. /// Connecting = 0, /// - /// Equivalent to numeric value 1. - /// Indicates that the connection is established and the communication is possible. + /// Equivalent to numeric value 1. Indicates that the connection has been established, + /// and the communication is possible. /// Open = 1, /// - /// Equivalent to numeric value 2. - /// Indicates that the connection is going through the closing handshake or - /// the WebSocket.Close method has been invoked. + /// Equivalent to numeric value 2. Indicates that the connection is going through + /// the closing handshake, or the WebSocket.Close method has been invoked. /// Closing = 2, /// - /// Equivalent to numeric value 3. - /// Indicates that the connection has been closed or couldn't be opened. + /// Equivalent to numeric value 3. Indicates that the connection has been closed or + /// couldn't be opened. /// Closed = 3 } From adefc5fe43f47c2703b51bafe007de437945ef56 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 29 Oct 2015 17:37:52 +0900 Subject: [PATCH 0162/6294] [Modify] Polish it --- websocket-sharp/CloseStatusCode.cs | 64 +++++++++++++----------------- 1 file changed, 28 insertions(+), 36 deletions(-) diff --git a/websocket-sharp/CloseStatusCode.cs b/websocket-sharp/CloseStatusCode.cs index c66a1efac..3c534c403 100644 --- a/websocket-sharp/CloseStatusCode.cs +++ b/websocket-sharp/CloseStatusCode.cs @@ -35,11 +35,11 @@ namespace WebSocketSharp /// /// /// - /// The values of the status code are defined in + /// The values of this enumeration are defined in /// Section 7.4 of RFC 6455. /// /// - /// "Reserved value" must not be set as a status code in a close control frame by + /// "Reserved value" must not be set as a status code in a connection close frame by /// an endpoint. It's designated for use in applications expecting a status code to /// indicate that the connection was closed due to the system grounds. /// @@ -47,76 +47,68 @@ namespace WebSocketSharp public enum CloseStatusCode : ushort { /// - /// Equivalent to close status 1000. - /// Indicates a normal close. + /// Equivalent to close status 1000. Indicates a normal close. /// Normal = 1000, /// - /// Equivalent to close status 1001. - /// Indicates that an endpoint is going away. + /// Equivalent to close status 1001. Indicates that an endpoint is going away. /// Away = 1001, /// - /// Equivalent to close status 1002. - /// Indicates that an endpoint is terminating the connection due to a protocol error. + /// Equivalent to close status 1002. Indicates that an endpoint is terminating + /// the connection due to a protocol error. /// ProtocolError = 1002, /// - /// Equivalent to close status 1003. - /// Indicates that an endpoint is terminating the connection because it has received - /// a type of data that it cannot accept. + /// Equivalent to close status 1003. Indicates that an endpoint is terminating + /// the connection because it has received a type of data that it cannot accept. /// UnsupportedData = 1003, /// - /// Equivalent to close status 1004. - /// Still undefined. A Reserved value. + /// Equivalent to close status 1004. Still undefined. A Reserved value. /// Undefined = 1004, /// - /// Equivalent to close status 1005. - /// Indicates that no status code was actually present. A Reserved value. + /// Equivalent to close status 1005. Indicates that no status code was actually present. + /// A Reserved value. /// NoStatus = 1005, /// - /// Equivalent to close status 1006. - /// Indicates that the connection was closed abnormally. A Reserved value. + /// Equivalent to close status 1006. Indicates that the connection was closed abnormally. + /// A Reserved value. /// Abnormal = 1006, /// - /// Equivalent to close status 1007. - /// Indicates that an endpoint is terminating the connection because it has received - /// a message that contains data that isn't consistent with the type of the message. + /// Equivalent to close status 1007. Indicates that an endpoint is terminating + /// the connection because it has received a message that contains data that + /// isn't consistent with the type of the message. /// InvalidData = 1007, /// - /// Equivalent to close status 1008. - /// Indicates that an endpoint is terminating the connection because it has received - /// a message that violates its policy. + /// Equivalent to close status 1008. Indicates that an endpoint is terminating + /// the connection because it has received a message that violates its policy. /// PolicyViolation = 1008, /// - /// Equivalent to close status 1009. - /// Indicates that an endpoint is terminating the connection because it has received - /// a message that is too big to process. + /// Equivalent to close status 1009. Indicates that an endpoint is terminating + /// the connection because it has received a message that is too big to process. /// TooBig = 1009, /// - /// Equivalent to close status 1010. - /// Indicates that a client is terminating the connection because it has expected - /// the server to negotiate one or more extension, but the server didn't return - /// them in the handshake response. + /// Equivalent to close status 1010. Indicates that a client is terminating + /// the connection because it has expected the server to negotiate one or more extension, + /// but the server didn't return them in the handshake response. /// MandatoryExtension = 1010, /// - /// Equivalent to close status 1011. - /// Indicates that a server is terminating the connection because it has encountered - /// an unexpected condition that prevented it from fulfilling the request. + /// Equivalent to close status 1011. Indicates that a server is terminating + /// the connection because it has encountered an unexpected condition that + /// prevented it from fulfilling the request. /// ServerError = 1011, /// - /// Equivalent to close status 1015. - /// Indicates that the connection was closed due to a failure to perform a TLS handshake. - /// A Reserved value. + /// Equivalent to close status 1015. Indicates that the connection was closed + /// due to a failure to perform a TLS handshake. A Reserved value. /// TlsHandshakeFailure = 1015 } From 4706c80282d05efb1762b319e78ab33c896b8ea4 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 30 Oct 2015 16:49:17 +0900 Subject: [PATCH 0163/6294] [Modify] Polish it --- websocket-sharp/CompressionMethod.cs | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/websocket-sharp/CompressionMethod.cs b/websocket-sharp/CompressionMethod.cs index f70546874..6e5aaaa54 100644 --- a/websocket-sharp/CompressionMethod.cs +++ b/websocket-sharp/CompressionMethod.cs @@ -4,7 +4,7 @@ * * The MIT License * - * Copyright (c) 2013-2014 sta.blockhead + * Copyright (c) 2013-2015 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -31,22 +31,21 @@ namespace WebSocketSharp { /// - /// Contains the values of the compression method used to compress the message on the WebSocket - /// connection. + /// Specifies the compression method used to compress a message on the WebSocket connection. /// /// - /// The values of the compression method are defined in - /// Compression - /// Extensions for WebSocket. + /// The compression methods are defined in + /// + /// Compression Extensions for WebSocket. /// public enum CompressionMethod : byte { /// - /// Indicates non compression. + /// Specifies non compression. /// None, /// - /// Indicates using DEFLATE. + /// Specifies DEFLATE. /// Deflate } From 5db923d6bd40e29a20075aa926da16373ba5f862 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 31 Oct 2015 15:22:38 +0900 Subject: [PATCH 0164/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 52818f81a..416d53b94 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -285,12 +285,11 @@ internal bool IsConnected { #region Public Properties /// - /// Gets or sets the compression method used to compress the message on - /// the WebSocket connection. + /// Gets or sets the compression method used to compress a message on the WebSocket connection. /// /// - /// One of the enum values, indicates the compression method - /// used to compress the message. The default value is . + /// One of the enum values, specifies the compression method + /// used to compress a message. The default value is . /// public CompressionMethod Compression { get { From 4464c50abd9aae21bdb08f434e752c6bfb28bae6 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 1 Nov 2015 17:07:01 +0900 Subject: [PATCH 0165/6294] [Modify] Polish it --- websocket-sharp/ByteOrder.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/ByteOrder.cs b/websocket-sharp/ByteOrder.cs index de8d42ffe..317f462ea 100644 --- a/websocket-sharp/ByteOrder.cs +++ b/websocket-sharp/ByteOrder.cs @@ -4,7 +4,7 @@ * * The MIT License * - * Copyright (c) 2012-2014 sta.blockhead + * Copyright (c) 2012-2015 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -31,16 +31,16 @@ namespace WebSocketSharp { /// - /// Contains the values that indicate whether the byte order is a Little-endian or Big-endian. + /// Specifies the byte order. /// - public enum ByteOrder : byte + public enum ByteOrder { /// - /// Indicates a Little-endian. + /// Specifies Little-endian. /// Little, /// - /// Indicates a Big-endian. + /// Specifies Big-endian. /// Big } From f8362fd367201d7de7845b672627a551b6fa85d5 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 2 Nov 2015 16:22:41 +0900 Subject: [PATCH 0166/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index e9e99b325..23fcae38d 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1615,7 +1615,7 @@ public static void Times (this ulong n, Action action) /// An array of to convert. /// /// - /// One of the enum values, indicates the byte order of + /// One of the enum values, specifies the byte order of /// . /// /// @@ -1669,7 +1669,7 @@ public static T To (this byte[] source, ByteOrder sourceOrder) /// A T to convert. /// /// - /// One of the enum values, indicates the byte order of the return. + /// One of the enum values, specifies the byte order of the return. /// /// /// The type of . The T must be a value type. @@ -1718,7 +1718,7 @@ public static byte[] ToByteArray (this T value, ByteOrder order) /// An array of to convert. /// /// - /// One of the enum values, indicates the byte order of + /// One of the enum values, specifies the byte order of /// . /// /// From f1e2f46bef6638102caa4bd0a8cbcf2b6f0a838a Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 3 Nov 2015 17:24:26 +0900 Subject: [PATCH 0167/6294] [Modify] Polish it --- websocket-sharp/LogLevel.cs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/websocket-sharp/LogLevel.cs b/websocket-sharp/LogLevel.cs index 5c9fdfe28..ef9967728 100644 --- a/websocket-sharp/LogLevel.cs +++ b/websocket-sharp/LogLevel.cs @@ -4,7 +4,7 @@ * * The MIT License * - * Copyright (c) 2013-2014 sta.blockhead + * Copyright (c) 2013-2015 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -31,32 +31,32 @@ namespace WebSocketSharp { /// - /// Contains the values of the logging level. + /// Specifies the logging level. /// public enum LogLevel { /// - /// Indicates the bottom logging level. + /// Specifies the bottom logging level. /// Trace, /// - /// Indicates the 2nd logging level from the bottom. + /// Specifies the 2nd logging level from the bottom. /// Debug, /// - /// Indicates the 3rd logging level from the bottom. + /// Specifies the 3rd logging level from the bottom. /// Info, /// - /// Indicates the 3rd logging level from the top. + /// Specifies the 3rd logging level from the top. /// Warn, /// - /// Indicates the 2nd logging level from the top. + /// Specifies the 2nd logging level from the top. /// Error, /// - /// Indicates the top logging level. + /// Specifies the top logging level. /// Fatal } From 989ab295dc568f45d764eb6fa18203bf17ed8a94 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 4 Nov 2015 15:12:28 +0900 Subject: [PATCH 0168/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 416d53b94..4ebadd3cb 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -428,7 +428,7 @@ public bool IsSecure { /// /// /// The default logging level is . If you would like to change it, - /// you should set the Log.Level property to any of the enum + /// you should set this Log.Level property to any of the enum /// values. /// /// From 829f3f6eead416d1038fbf4a6361dcf11ce2331d Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 4 Nov 2015 15:20:06 +0900 Subject: [PATCH 0169/6294] [Modify] Polish it --- websocket-sharp/Logger.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Logger.cs b/websocket-sharp/Logger.cs index c53257854..bc7117f5e 100644 --- a/websocket-sharp/Logger.cs +++ b/websocket-sharp/Logger.cs @@ -4,7 +4,7 @@ * * The MIT License * - * Copyright (c) 2013-2014 sta.blockhead + * Copyright (c) 2013-2015 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -140,7 +140,7 @@ public string File { /// A log with lower than the value of this property cannot be outputted. /// /// - /// One of the enum values, indicates the current logging level. + /// One of the enum values, specifies the current logging level. /// public LogLevel Level { get { From 7f833eab38e2c966d255bee82633dcaaef876aec Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 5 Nov 2015 16:49:37 +0900 Subject: [PATCH 0170/6294] [Modify] Polish it --- websocket-sharp/Logger.cs | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/websocket-sharp/Logger.cs b/websocket-sharp/Logger.cs index bc7117f5e..17850e67e 100644 --- a/websocket-sharp/Logger.cs +++ b/websocket-sharp/Logger.cs @@ -37,16 +37,17 @@ namespace WebSocketSharp /// /// /// - /// If you output a log with lower than the , + /// If you output a log with lower than the value of the property, /// it cannot be outputted. /// /// - /// The default output action writes a log to the standard output stream and - /// the if it has a valid path. + /// The default output action writes a log to the standard output stream and the log file + /// if the property has a valid path to it. /// /// - /// If you would like to use the custom output action, you should set the - /// to any Action<LogData, string> delegate. + /// If you would like to use the custom output action, you should set + /// the property to any Action<LogData, string> + /// delegate. /// /// public class Logger @@ -74,8 +75,8 @@ public Logger () } /// - /// Initializes a new instance of the class with the specified - /// logging . + /// Initializes a new instance of the class with + /// the specified logging . /// /// /// One of the enum values. @@ -86,9 +87,9 @@ public Logger (LogLevel level) } /// - /// Initializes a new instance of the class with the specified - /// logging , path to the log , and - /// action. + /// Initializes a new instance of the class with + /// the specified logging , path to the log , + /// and action. /// /// /// One of the enum values. @@ -97,9 +98,9 @@ public Logger (LogLevel level) /// A that represents the path to the log file. /// /// - /// An Action<LogData, string> delegate that references the method(s) - /// used to output a log. A parameter passed to this delegate - /// is . + /// An Action<LogData, string> delegate that references the method(s) used to + /// output a log. A parameter passed to this delegate is + /// . /// public Logger (LogLevel level, string file, Action output) { @@ -162,7 +163,7 @@ public LogLevel Level { /// /// An Action<LogData, string> delegate that references the method(s) used to /// output a log. A parameter passed to this delegate is the value of - /// the . + /// the property. /// /// /// If the value to set is , the current output action is changed to From 3f38dad3cd75cb8e2622b109c896ec3cf0b578ca Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 6 Nov 2015 16:52:11 +0900 Subject: [PATCH 0171/6294] [Modify] Polish it --- websocket-sharp/LogData.cs | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/websocket-sharp/LogData.cs b/websocket-sharp/LogData.cs index f52d37cb3..9c0843093 100644 --- a/websocket-sharp/LogData.cs +++ b/websocket-sharp/LogData.cs @@ -4,7 +4,7 @@ * * The MIT License * - * Copyright (c) 2013-2014 sta.blockhead + * Copyright (c) 2013-2015 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -125,24 +125,23 @@ public override string ToString () var type = method.DeclaringType; #if DEBUG var lineNum = _caller.GetFileLineNumber (); - var headerAndCaller = String.Format ( - "{0}{1}.{2}:{3}|", header, type.Name, method.Name, lineNum); + var headerAndCaller = + String.Format ("{0}{1}.{2}:{3}|", header, type.Name, method.Name, lineNum); #else var headerAndCaller = String.Format ("{0}{1}.{2}|", header, type.Name, method.Name); #endif - var msgs = _message.Replace ("\r\n", "\n").TrimEnd ('\n').Split ('\n'); if (msgs.Length <= 1) return String.Format ("{0}{1}", headerAndCaller, _message); - var output = new StringBuilder (String.Format ("{0}{1}\n", headerAndCaller, msgs[0]), 64); + var buff = new StringBuilder (String.Format ("{0}{1}\n", headerAndCaller, msgs[0]), 64); var fmt = String.Format ("{{0,{0}}}{{1}}\n", header.Length); for (var i = 1; i < msgs.Length; i++) - output.AppendFormat (fmt, "", msgs[i]); + buff.AppendFormat (fmt, "", msgs[i]); - output.Length--; - return output.ToString (); + buff.Length--; + return buff.ToString (); } #endregion From 3a6dd700ba6d82f50c2e9e24788a90dcf6aa24f9 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 7 Nov 2015 16:31:31 +0900 Subject: [PATCH 0172/6294] [Modify] Polish it --- websocket-sharp/WebSocketState.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocketState.cs b/websocket-sharp/WebSocketState.cs index 635405cd1..469350cb9 100644 --- a/websocket-sharp/WebSocketState.cs +++ b/websocket-sharp/WebSocketState.cs @@ -31,7 +31,7 @@ namespace WebSocketSharp { /// - /// Contains the values of the state of a WebSocket connection. + /// Indicates the state of a WebSocket connection. /// /// /// The values of this enumeration are defined in @@ -55,7 +55,7 @@ public enum WebSocketState : ushort Closing = 2, /// /// Equivalent to numeric value 3. Indicates that the connection has been closed or - /// couldn't be opened. + /// couldn't be established. /// Closed = 3 } From 7a9379d186e73ed45af993e416b9e71a4c615ea0 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 8 Nov 2015 15:23:37 +0900 Subject: [PATCH 0173/6294] [Modify] Polish it --- websocket-sharp/Fin.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Fin.cs b/websocket-sharp/Fin.cs index eddffbe4e..8965c378e 100644 --- a/websocket-sharp/Fin.cs +++ b/websocket-sharp/Fin.cs @@ -31,7 +31,7 @@ namespace WebSocketSharp { /// - /// Contains the values that indicate whether a WebSocket frame is the final frame of a message. + /// Indicates whether a WebSocket frame is the final frame of a message. /// /// /// The values of this enumeration are defined in From f475eb547b7b9d453431f5925646377bd32eab35 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 8 Nov 2015 15:30:51 +0900 Subject: [PATCH 0174/6294] [Modify] Polish it --- websocket-sharp/Rsv.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Rsv.cs b/websocket-sharp/Rsv.cs index 1e85e32b2..8a10567c5 100644 --- a/websocket-sharp/Rsv.cs +++ b/websocket-sharp/Rsv.cs @@ -31,7 +31,7 @@ namespace WebSocketSharp { /// - /// Contains the values used in each RSV (RSV1, RSV2, and RSV3) of a WebSocket frame. + /// Indicates whether each RSV (RSV1, RSV2, and RSV3) of a WebSocket frame is non-zero. /// /// /// The values of this enumeration are defined in From bfa5a6ac5dc56f42cc8605a5d8a25f8a52e25eaa Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 9 Nov 2015 13:44:52 +0900 Subject: [PATCH 0175/6294] [Modify] Polish it --- websocket-sharp/Mask.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Mask.cs b/websocket-sharp/Mask.cs index 2123e6f87..fcafac80c 100644 --- a/websocket-sharp/Mask.cs +++ b/websocket-sharp/Mask.cs @@ -31,7 +31,7 @@ namespace WebSocketSharp { /// - /// Contains the values that indicate whether the payload data of a WebSocket frame is masked. + /// Indicates whether the payload data of a WebSocket frame is masked. /// /// /// The values of this enumeration are defined in From 5fc3d52d1f2671d56f0a0a9ce6b92bcdc6dae270 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 10 Nov 2015 15:11:48 +0900 Subject: [PATCH 0176/6294] [Modify] Polish it --- websocket-sharp/Opcode.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/websocket-sharp/Opcode.cs b/websocket-sharp/Opcode.cs index 362fcfeaa..faabdb0dd 100644 --- a/websocket-sharp/Opcode.cs +++ b/websocket-sharp/Opcode.cs @@ -31,7 +31,7 @@ namespace WebSocketSharp { /// - /// Contains the values of the opcode that indicate the type of a WebSocket frame. + /// Indicates the WebSocket frame type. /// /// /// The values of this enumeration are defined in @@ -40,27 +40,27 @@ namespace WebSocketSharp public enum Opcode : byte { /// - /// Equivalent to numeric value 0. Indicates a continuation frame. + /// Equivalent to numeric value 0. Indicates continuation frame. /// Cont = 0x0, /// - /// Equivalent to numeric value 1. Indicates a text frame. + /// Equivalent to numeric value 1. Indicates text frame. /// Text = 0x1, /// - /// Equivalent to numeric value 2. Indicates a binary frame. + /// Equivalent to numeric value 2. Indicates binary frame. /// Binary = 0x2, /// - /// Equivalent to numeric value 8. Indicates a connection close frame. + /// Equivalent to numeric value 8. Indicates connection close frame. /// Close = 0x8, /// - /// Equivalent to numeric value 9. Indicates a ping frame. + /// Equivalent to numeric value 9. Indicates ping frame. /// Ping = 0x9, /// - /// Equivalent to numeric value 10. Indicates a pong frame. + /// Equivalent to numeric value 10. Indicates pong frame. /// Pong = 0xa } From d4dbf739fa7b53ea2ca2d2d8ea8d1d9489145df7 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 11 Nov 2015 15:17:33 +0900 Subject: [PATCH 0177/6294] [Modify] Polish it --- websocket-sharp/CloseStatusCode.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/CloseStatusCode.cs b/websocket-sharp/CloseStatusCode.cs index 3c534c403..74bb9da7e 100644 --- a/websocket-sharp/CloseStatusCode.cs +++ b/websocket-sharp/CloseStatusCode.cs @@ -31,7 +31,7 @@ namespace WebSocketSharp { /// - /// Contains the values of the status code for the WebSocket connection close. + /// Indicates the status code for the WebSocket connection close. /// /// /// @@ -47,7 +47,7 @@ namespace WebSocketSharp public enum CloseStatusCode : ushort { /// - /// Equivalent to close status 1000. Indicates a normal close. + /// Equivalent to close status 1000. Indicates normal close. /// Normal = 1000, /// From 03fc76ce06ec226593c872d83f2631124f899a1a Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 12 Nov 2015 15:45:57 +0900 Subject: [PATCH 0178/6294] [Modify] Polish it --- websocket-sharp/MessageEventArgs.cs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/MessageEventArgs.cs b/websocket-sharp/MessageEventArgs.cs index 947a1adf4..1ea9529c3 100644 --- a/websocket-sharp/MessageEventArgs.cs +++ b/websocket-sharp/MessageEventArgs.cs @@ -27,12 +27,11 @@ #endregion using System; -using System.Text; namespace WebSocketSharp { /// - /// Contains the event data associated with a event. + /// Represents the event data for the event. /// /// /// @@ -81,8 +80,8 @@ internal MessageEventArgs (Opcode opcode, byte[] rawData) /// Gets the message data as a . /// /// - /// A that represents the message data, - /// or if the message data cannot be decoded to a string. + /// A that represents the message data or + /// if the message data cannot be decoded to a string. /// public string Data { get { From 0e0fdbdfbd977df50b834d1c4b8f25f460ad9115 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 13 Nov 2015 14:45:16 +0900 Subject: [PATCH 0179/6294] [Modify] Add a property Add IsText property to determine that the message type is text. --- websocket-sharp/MessageEventArgs.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/websocket-sharp/MessageEventArgs.cs b/websocket-sharp/MessageEventArgs.cs index 1ea9529c3..5715f1488 100644 --- a/websocket-sharp/MessageEventArgs.cs +++ b/websocket-sharp/MessageEventArgs.cs @@ -97,6 +97,18 @@ public string Data { } } + /// + /// Gets a value indicating whether the message type is text. + /// + /// + /// true if the message type is text; otherwise, false. + /// + public bool IsText { + get { + return _opcode == Opcode.Text; + } + } + /// /// Gets the message data as an array of . /// From 6da68d455a1016724681da5966d645729bbec73a Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 13 Nov 2015 14:52:35 +0900 Subject: [PATCH 0180/6294] [Modify] Add a property Add IsBinary property to determine that the message type is binary. --- websocket-sharp/MessageEventArgs.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/websocket-sharp/MessageEventArgs.cs b/websocket-sharp/MessageEventArgs.cs index 5715f1488..09bf61490 100644 --- a/websocket-sharp/MessageEventArgs.cs +++ b/websocket-sharp/MessageEventArgs.cs @@ -97,6 +97,18 @@ public string Data { } } + /// + /// Gets a value indicating whether the message type is binary. + /// + /// + /// true if the message type is binary; otherwise, false. + /// + public bool IsBinary { + get { + return _opcode == Opcode.Binary; + } + } + /// /// Gets a value indicating whether the message type is text. /// From 5eff459c44b7bbdd331f92b6c23ad121cded43a1 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 14 Nov 2015 15:04:44 +0900 Subject: [PATCH 0181/6294] [Modify] Add a property Add IsPing property to determine that the message type is ping. --- websocket-sharp/MessageEventArgs.cs | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/MessageEventArgs.cs b/websocket-sharp/MessageEventArgs.cs index 09bf61490..8629ea298 100644 --- a/websocket-sharp/MessageEventArgs.cs +++ b/websocket-sharp/MessageEventArgs.cs @@ -36,7 +36,7 @@ namespace WebSocketSharp /// /// /// A event occurs when the receives - /// a text or binary message, or a Ping if the property is + /// a text or binary message, or a ping if the property is /// set to true. /// /// @@ -109,6 +109,18 @@ public bool IsBinary { } } + /// + /// Gets a value indicating whether the message type is ping. + /// + /// + /// true if the message type is ping; otherwise, false. + /// + public bool IsPing { + get { + return _opcode == Opcode.Ping; + } + } + /// /// Gets a value indicating whether the message type is text. /// @@ -134,11 +146,12 @@ public byte[] RawData { } /// - /// Gets the type of the message. + /// Gets the message type. /// /// /// , , or . /// + [Obsolete ("This property will be removed. Use any of the Is properties instead.")] public Opcode Type { get { return _opcode; From b8bc01d100e93895c3f2e92471f264ab517fcb4c Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 15 Nov 2015 15:36:01 +0900 Subject: [PATCH 0182/6294] [Modify] Polish it --- Example/Notifier.cs | 4 +--- Example/Program.cs | 27 ++++++++++++++------------- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/Example/Notifier.cs b/Example/Notifier.cs index 7f3c524f0..f21eec32c 100644 --- a/Example/Notifier.cs +++ b/Example/Notifier.cs @@ -54,9 +54,7 @@ public int Count { private NotificationMessage dequeue () { lock (_sync) - return _queue.Count > 0 - ? _queue.Dequeue () - : null; + return _queue.Count > 0 ? _queue.Dequeue () : null; } public void Close () diff --git a/Example/Program.cs b/Example/Program.cs index 4ea070d16..f3d91f6de 100644 --- a/Example/Program.cs +++ b/Example/Program.cs @@ -9,15 +9,15 @@ public class Program { public static void Main (string[] args) { - /* Create a new instance of the WebSocket class. - * - * The WebSocket class inherits the System.IDisposable interface, so you can use the using - * statement. And the WebSocket connection will be closed with close status 1001 (going away) - * when the control leaves the using block. - * - * If you would like to connect to the server with the secure connection, you should create - * the instance with the wss scheme WebSocket URL. - */ + // Create a new instance of the WebSocket class. + // + // The WebSocket class inherits the System.IDisposable interface, so you can + // use the using statement. And the WebSocket connection will be closed with + // close status 1001 (going away) when the control leaves the using block. + // + // If you would like to connect to the server with the secure connection, + // you should create the instance with the wss scheme WebSocket URL. + using (var nf = new Notifier ()) using (var ws = new WebSocket ("ws://echo.websocket.org")) //using (var ws = new WebSocket ("wss://echo.websocket.org")) @@ -28,14 +28,15 @@ public static void Main (string[] args) //using (var ws = new WebSocket ("ws://localhost:4649/Chat?name=nobita")) //using (var ws = new WebSocket ("wss://localhost:4649/Chat")) { - // To set the WebSocket events. + // Set the WebSocket events. + ws.OnOpen += (sender, e) => ws.Send ("Hi, there!"); ws.OnMessage += (sender, e) => nf.Notify ( new NotificationMessage { Summary = "WebSocket Message", - Body = e.Type != Opcode.Ping ? e.Data : "Received a Ping.", + Body = !e.IsPing ? e.Data : "Received a ping.", Icon = "notification-message-im" }); @@ -62,7 +63,7 @@ public static void Main (string[] args) // To change the wait time for the response to the Ping or Close. ws.WaitTime = TimeSpan.FromSeconds (10); - // To emit a WebSocket.OnMessage event when receives a Ping. + // To emit a WebSocket.OnMessage event when receives a ping. ws.EmitOnPing = true; #endif // To enable the Per-message Compression extension. @@ -81,7 +82,7 @@ public static void Main (string[] args) }; */ - // To set the credentials for the HTTP Authentication (Basic/Digest). + // To send the credentials for the HTTP Authentication (Basic/Digest). //ws.SetCredentials ("nobita", "password", false); // To send the Origin header. From 5cc462ac25c89480aab56aa7399c7e5602ca103a Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 16 Nov 2015 14:41:11 +0900 Subject: [PATCH 0183/6294] [Modify] Polish it --- Example1/AudioStreamer.cs | 2 +- Example1/Notifier.cs | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/Example1/AudioStreamer.cs b/Example1/AudioStreamer.cs index 5e76028e1..669d5c527 100644 --- a/Example1/AudioStreamer.cs +++ b/Example1/AudioStreamer.cs @@ -39,7 +39,7 @@ private void configure () _websocket.Send (createTextMessage ("connection", String.Empty)); _websocket.OnMessage += (sender, e) => { - if (e.Type == Opcode.Text) { + if (e.IsText) { _notifier.Notify (convertTextMessage (e.Data)); } else { diff --git a/Example1/Notifier.cs b/Example1/Notifier.cs index 77c2a399e..5bcbb16ac 100644 --- a/Example1/Notifier.cs +++ b/Example1/Notifier.cs @@ -54,9 +54,7 @@ public int Count { private NotificationMessage dequeue () { lock (_sync) - return _queue.Count > 0 - ? _queue.Dequeue () - : null; + return _queue.Count > 0 ? _queue.Dequeue () : null; } public void Close () From e38c614906c5c182d8a1f278aeb8ab00a0babcce Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 17 Nov 2015 11:48:31 +0900 Subject: [PATCH 0184/6294] [Modify] Polish it --- websocket-sharp/ErrorEventArgs.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/ErrorEventArgs.cs b/websocket-sharp/ErrorEventArgs.cs index 003d89d11..a4c0b85e9 100644 --- a/websocket-sharp/ErrorEventArgs.cs +++ b/websocket-sharp/ErrorEventArgs.cs @@ -4,7 +4,7 @@ * * The MIT License * - * Copyright (c) 2012-2014 sta.blockhead + * Copyright (c) 2012-2015 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -38,7 +38,7 @@ namespace WebSocketSharp { /// - /// Contains the event data associated with a event. + /// Represents the event data for the event. /// /// /// @@ -50,8 +50,8 @@ namespace WebSocketSharp /// the property. /// /// - /// And if the error is due to an exception, you can get the - /// instance by accessing the property. + /// And if the error is due to an exception, you can get the exception by accessing + /// the property. /// /// public class ErrorEventArgs : EventArgs @@ -81,7 +81,7 @@ internal ErrorEventArgs (string message, Exception exception) #region Public Properties /// - /// Gets the instance that caused the error. + /// Gets the exception that caused the error. /// /// /// An instance that represents the cause of the error, From 974f6dc1d7a8737f57cc4cc2aeb47b646c914fe8 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 18 Nov 2015 15:23:58 +0900 Subject: [PATCH 0185/6294] [Modify] Polish it --- websocket-sharp/CloseEventArgs.cs | 35 +++++++++++-------------------- 1 file changed, 12 insertions(+), 23 deletions(-) diff --git a/websocket-sharp/CloseEventArgs.cs b/websocket-sharp/CloseEventArgs.cs index d7929a8bf..e1cd18420 100644 --- a/websocket-sharp/CloseEventArgs.cs +++ b/websocket-sharp/CloseEventArgs.cs @@ -27,21 +27,20 @@ #endregion using System; -using System.Text; namespace WebSocketSharp { /// - /// Contains the event data associated with a event. + /// Represents the event data for the event. /// /// /// - /// A event occurs when the WebSocket connection has been - /// closed. + /// A event occurs when the WebSocket connection + /// has been closed. /// /// /// If you would like to get the reason for the close, you should access - /// the or property. + /// the or property. /// /// public class CloseEventArgs : EventArgs @@ -51,7 +50,6 @@ public class CloseEventArgs : EventArgs private bool _clean; private ushort _code; private PayloadData _payloadData; - private byte[] _rawData; private string _reason; #endregion @@ -61,14 +59,12 @@ public class CloseEventArgs : EventArgs internal CloseEventArgs () { _code = (ushort) CloseStatusCode.NoStatus; - _payloadData = new PayloadData (); - _rawData = _payloadData.ApplicationData; + _payloadData = PayloadData.Empty; } internal CloseEventArgs (ushort code) { _code = code; - _rawData = code.InternalToByteArray (ByteOrder.Big); } internal CloseEventArgs (CloseStatusCode code) @@ -79,15 +75,15 @@ internal CloseEventArgs (CloseStatusCode code) internal CloseEventArgs (PayloadData payloadData) { _payloadData = payloadData; - _rawData = payloadData.ApplicationData; - var len = _rawData.Length; + var data = payloadData.ApplicationData; + var len = data.Length; _code = len > 1 - ? _rawData.SubArray (0, 2).ToUInt16 (ByteOrder.Big) + ? data.SubArray (0, 2).ToUInt16 (ByteOrder.Big) : (ushort) CloseStatusCode.NoStatus; _reason = len > 2 - ? _rawData.SubArray (2, len - 2).UTF8Decode () + ? data.SubArray (2, len - 2).UTF8Decode () : String.Empty; } @@ -95,7 +91,6 @@ internal CloseEventArgs (ushort code, string reason) { _code = code; _reason = reason; - _rawData = code.Append (reason); } internal CloseEventArgs (CloseStatusCode code, string reason) @@ -109,13 +104,7 @@ internal CloseEventArgs (CloseStatusCode code, string reason) internal PayloadData PayloadData { get { - return _payloadData ?? (_payloadData = new PayloadData (_rawData)); - } - } - - internal byte[] RawData { - get { - return _rawData; + return _payloadData ?? (_payloadData = new PayloadData (_code.Append (_reason))); } } @@ -148,10 +137,10 @@ public string Reason { } /// - /// Gets a value indicating whether the WebSocket connection has been closed cleanly. + /// Gets a value indicating whether the connection has been closed cleanly. /// /// - /// true if the WebSocket connection has been closed cleanly; otherwise, false. + /// true if the connection has been closed cleanly; otherwise, false. /// public bool WasClean { get { From ea831f0dd8397b71e8fa1249698f1b0f3b33e922 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 19 Nov 2015 16:11:49 +0900 Subject: [PATCH 0186/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 23fcae38d..91983f894 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -152,17 +152,14 @@ private static void times (this ulong n, Action action) internal static byte[] Append (this ushort code, string reason) { - using (var buff = new MemoryStream ()) { - var bytes = code.InternalToByteArray (ByteOrder.Big); - buff.Write (bytes, 0, 2); - if (reason != null && reason.Length > 0) { - bytes = Encoding.UTF8.GetBytes (reason); - buff.Write (bytes, 0, bytes.Length); - } - - buff.Close (); - return buff.ToArray (); + var ret = code.InternalToByteArray (ByteOrder.Big); + if (reason != null && reason.Length > 0) { + var buff = new List (ret); + buff.AddRange (Encoding.UTF8.GetBytes (reason)); + ret = buff.ToArray (); } + + return ret; } internal static string CheckIfAvailable ( From 02ec346c30804381978c118123e403f59101374e Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 20 Nov 2015 18:05:13 +0900 Subject: [PATCH 0187/6294] [Modify] Polish it --- .../Server/HttpRequestEventArgs.cs | 22 +++++++++---------- 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/websocket-sharp/Server/HttpRequestEventArgs.cs b/websocket-sharp/Server/HttpRequestEventArgs.cs index f355d0a10..34a83ecf8 100644 --- a/websocket-sharp/Server/HttpRequestEventArgs.cs +++ b/websocket-sharp/Server/HttpRequestEventArgs.cs @@ -4,7 +4,7 @@ * * The MIT License * - * Copyright (c) 2012-2014 sta.blockhead + * Copyright (c) 2012-2015 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -32,20 +32,19 @@ namespace WebSocketSharp.Server { /// - /// Contains the event data associated with an HTTP request event that - /// the emits. + /// Represents the event data for the HTTP request event that the emits. /// /// /// /// An HTTP request event occurs when the receives an HTTP request. /// /// - /// If you would like to get the request data, you should access - /// the property. + /// If you would like to get the request data sent from a client, + /// you should access the property. /// /// - /// And if you would like to get the data used to return a response, you should access - /// the property. + /// And if you would like to get the response data used to return a response, + /// you should access the property. /// /// public class HttpRequestEventArgs : EventArgs @@ -70,11 +69,10 @@ internal HttpRequestEventArgs (HttpListenerContext context) #region Public Properties /// - /// Gets the that represents the HTTP request sent from - /// a client. + /// Gets the HTTP request data sent from a client. /// /// - /// A that represents the request. + /// A that represents the request data. /// public HttpListenerRequest Request { get { @@ -83,10 +81,10 @@ public HttpListenerRequest Request { } /// - /// Gets the used to return an HTTP response to the client. + /// Gets the HTTP response data used to return a response to the client. /// /// - /// A used to return a response. + /// A that represents the response data. /// public HttpListenerResponse Response { get { From f276f96526ae27678c9bc7e4ed7f7cbfe307c136 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 21 Nov 2015 15:58:37 +0900 Subject: [PATCH 0188/6294] [Modify] Polish it --- websocket-sharp/MessageEventArgs.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/MessageEventArgs.cs b/websocket-sharp/MessageEventArgs.cs index 8629ea298..0639baf39 100644 --- a/websocket-sharp/MessageEventArgs.cs +++ b/websocket-sharp/MessageEventArgs.cs @@ -80,8 +80,8 @@ internal MessageEventArgs (Opcode opcode, byte[] rawData) /// Gets the message data as a . /// /// - /// A that represents the message data or - /// if the message data cannot be decoded to a string. + /// A that represents the message data, + /// or if the message data cannot be decoded to a string. /// public string Data { get { From bc794a6b6bcc24291f79f2436c8f1d6d993c51aa Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 22 Nov 2015 16:02:57 +0900 Subject: [PATCH 0189/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 4ebadd3cb..7b3ca0574 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -342,11 +342,11 @@ public NetworkCredential Credentials { /// /// Gets or sets a value indicating whether the emits - /// a event when receives a Ping. + /// a event when receives a ping. /// /// /// true if the emits a event - /// when receives a Ping; otherwise, false. The default value is false. + /// when receives a ping; otherwise, false. The default value is false. /// public bool EmitOnPing { get { @@ -1060,7 +1060,7 @@ private bool processFragmentedFrame (WebSocketFrame frame) private bool processPingFrame (WebSocketFrame frame) { if (send (new WebSocketFrame (Opcode.Pong, frame.PayloadData, _client).ToArray ())) - _logger.Trace ("Returned a Pong."); + _logger.Trace ("Returned a pong."); if (_emitOnPing) enqueueToMessageEventQueue (new MessageEventArgs (frame)); @@ -1071,7 +1071,7 @@ private bool processPingFrame (WebSocketFrame frame) private bool processPongFrame (WebSocketFrame frame) { _receivePong.Set (); - _logger.Trace ("Received a Pong."); + _logger.Trace ("Received a pong."); return true; } @@ -1497,7 +1497,7 @@ private void startReceiving () return; } - // Receive next asap because a Ping or Close needs a response to it. + // Receive next asap because the Ping or Close needs a response to it. receive (); if ((frame.IsControl && !(frame.IsPing && _emitOnPing)) || !frame.IsFinal) @@ -2245,10 +2245,10 @@ public void ConnectAsync () } /// - /// Sends a Ping using the WebSocket connection. + /// Sends a ping using the WebSocket connection. /// /// - /// true if the receives a Pong to this Ping in a time; + /// true if the receives a pong to this ping in a time; /// otherwise, false. /// public bool Ping () @@ -2261,10 +2261,10 @@ public bool Ping () } /// - /// Sends a Ping with the specified using the WebSocket connection. + /// Sends a ping with the specified using the WebSocket connection. /// /// - /// true if the receives a Pong to this Ping in a time; + /// true if the receives a pong to this ping in a time; /// otherwise, false. /// /// @@ -2279,7 +2279,7 @@ public bool Ping (string message) var msg = CheckPingParameter (message, out data); if (msg != null) { _logger.Error (msg); - error ("An error has occurred in sending the ping.", null); + error ("An error has occurred in sending a ping.", null); return false; } From b5ae901e5c3fcfa0845057b096b381651fb40b94 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 23 Nov 2015 17:20:12 +0900 Subject: [PATCH 0190/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 7b3ca0574..29661bec6 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1214,7 +1214,7 @@ private bool send (Opcode opcode, Stream stream) } catch (Exception ex) { _logger.Fatal (ex.ToString ()); - error ("An exception has occurred while sending the data.", ex); + error ("An exception has occurred while sending data.", ex); } finally { if (compressed) @@ -2300,7 +2300,7 @@ public void Send (byte[] data) if (msg != null) { _logger.Error (msg); - error ("An error has occurred in sending the data.", null); + error ("An error has occurred in sending data.", null); return; } @@ -2321,7 +2321,7 @@ public void Send (FileInfo file) if (msg != null) { _logger.Error (msg); - error ("An error has occurred in sending the data.", null); + error ("An error has occurred in sending data.", null); return; } @@ -2342,7 +2342,7 @@ public void Send (string data) if (msg != null) { _logger.Error (msg); - error ("An error has occurred in sending the data.", null); + error ("An error has occurred in sending data.", null); return; } @@ -2371,7 +2371,7 @@ public void SendAsync (byte[] data, Action completed) if (msg != null) { _logger.Error (msg); - error ("An error has occurred in sending the data.", null); + error ("An error has occurred in sending data.", null); return; } @@ -2401,7 +2401,7 @@ public void SendAsync (FileInfo file, Action completed) if (msg != null) { _logger.Error (msg); - error ("An error has occurred in sending the data.", null); + error ("An error has occurred in sending data.", null); return; } @@ -2430,7 +2430,7 @@ public void SendAsync (string data, Action completed) if (msg != null) { _logger.Error (msg); - error ("An error has occurred in sending the data.", null); + error ("An error has occurred in sending data.", null); return; } @@ -2463,7 +2463,7 @@ public void SendAsync (Stream stream, int length, Action completed) if (msg != null) { _logger.Error (msg); - error ("An error has occurred in sending the data.", null); + error ("An error has occurred in sending data.", null); return; } @@ -2474,7 +2474,7 @@ public void SendAsync (Stream stream, int length, Action completed) var len = data.Length; if (len == 0) { _logger.Error ("The data cannot be read from 'stream'."); - error ("An error has occurred in sending the data.", null); + error ("An error has occurred in sending data.", null); return; } @@ -2492,7 +2492,7 @@ public void SendAsync (Stream stream, int length, Action completed) }, ex => { _logger.Fatal (ex.ToString ()); - error ("An exception has occurred while sending the data.", ex); + error ("An exception has occurred while sending data.", ex); }); } @@ -2511,7 +2511,7 @@ public void SetCookie (Cookie cookie) if (msg != null) { _logger.Error (msg); - error ("An error has occurred in setting the cookie.", null); + error ("An error has occurred in setting a cookie.", null); return; } From f7330ffa145c6428b10d0ffb66b2ff9bbb365c41 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 24 Nov 2015 16:19:31 +0900 Subject: [PATCH 0191/6294] [Modify] Polish it --- README.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index ff14ba4ee..985b5863e 100644 --- a/README.md +++ b/README.md @@ -138,11 +138,11 @@ ws.OnMessage += (sender, e) => { `e` has passed as a `WebSocketSharp.MessageEventArgs`. -`e.Type` property returns either `WebSocketSharp.Opcode.Text` or `WebSocketSharp.Opcode.Binary` that represents the type of the message. So by checking it, you can determine which item you should use. +`e.Type` property returns either `WebSocketSharp.Opcode.Text` or `WebSocketSharp.Opcode.Binary` that represents the message type. So by checking it, you can determine which item you should use. -If it returns `Opcode.Text`, you should use `e.Data` property that returns a `string` (represents the **Text** message). +If it returns `Opcode.Text`, you should use `e.Data` property that returns a `string` (represents a **text** message). -Or if it returns `Opcode.Binary`, you should use `e.RawData` property that returns a `byte[]` (represents the **Binary** message). +Or if it returns `Opcode.Binary`, you should use `e.RawData` property that returns a `byte[]` (represents a **binary** message). ```csharp if (e.Type == Opcode.Text) { @@ -160,13 +160,13 @@ if (e.Type == Opcode.Binary) { } ``` -And if you would like to notify that a **Ping** has been received, via this event, you should set the `WebSocket.EmitOnPing` property to `true`, such as the following. +And if you would like to notify that a **ping** has been received, via this event, you should set the `WebSocket.EmitOnPing` property to `true`, such as the following. ```csharp ws.EmitOnPing = true; ws.OnMessage += (sender, e) => { if (e.Type == Opcode.Ping) { - // Do something to notify that a Ping has been received. + // Do something to notify that a ping has been received. ... return; @@ -543,7 +543,7 @@ And also if you would like to send the **Cookies** with the WebSocket connection ws.SetCookie (new Cookie ("name", "nobita")); ``` -As a **WebSocket Server**, if you would like to get the **Query String** included in each WebSocket connection request, you should access the `WebSocketBehavior.Context.QueryString` property, such as the following. +As a **WebSocket Server**, if you would like to get the **Query String** included in a WebSocket connection request, you should access the `WebSocketBehavior.Context.QueryString` property, such as the following. ```csharp public class Chat : WebSocketBehavior @@ -560,7 +560,7 @@ public class Chat : WebSocketBehavior } ``` -And if you would like to validate the **Origin header**, **Cookies**, or both included in each WebSocket connection request, you should set each validation with your `WebSocketBehavior`, for example, by using the `AddWebSocketService (string, Func)` method with initializing, such as the following. +And if you would like to validate the **Origin header**, **Cookies**, or both included in a WebSocket connection request, you should set each validation with your `WebSocketBehavior`, for example, by using the `AddWebSocketService (string, Func)` method with initializing, such as the following. ```csharp wssv.AddWebSocketService ( From 4cfdbeb6f626bef559c0d7d67845ac7c460a8b89 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 25 Nov 2015 17:20:40 +0900 Subject: [PATCH 0192/6294] [Modify] Use the Is properties --- README.md | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 985b5863e..4494dd01d 100644 --- a/README.md +++ b/README.md @@ -138,21 +138,21 @@ ws.OnMessage += (sender, e) => { `e` has passed as a `WebSocketSharp.MessageEventArgs`. -`e.Type` property returns either `WebSocketSharp.Opcode.Text` or `WebSocketSharp.Opcode.Binary` that represents the message type. So by checking it, you can determine which item you should use. +If you would like to get the message data, you should access `e.Data` or `e.RawData` property. And you can determine which property you should access by checking `e.IsText` or `e.IsBinary` property. -If it returns `Opcode.Text`, you should use `e.Data` property that returns a `string` (represents a **text** message). +If `e.IsText` is `true`, you should access `e.Data` that returns a `string` (represents a **text** message). -Or if it returns `Opcode.Binary`, you should use `e.RawData` property that returns a `byte[]` (represents a **binary** message). +Or if `e.IsBinary` is `true`, you should access `e.RawData` that returns a `byte[]` (represents a **binary** message). ```csharp -if (e.Type == Opcode.Text) { +if (e.IsText) { // Do something with e.Data. ... return; } -if (e.Type == Opcode.Binary) { +if (e.IsBinary) { // Do something with e.RawData. ... @@ -165,14 +165,12 @@ And if you would like to notify that a **ping** has been received, via this even ```csharp ws.EmitOnPing = true; ws.OnMessage += (sender, e) => { - if (e.Type == Opcode.Ping) { + if (e.IsPing) { // Do something to notify that a ping has been received. ... return; } - - ... }; ``` From ec0ba0a0db716aec452b766ef210cba481ed73bc Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 26 Nov 2015 15:59:48 +0900 Subject: [PATCH 0193/6294] [Modify] Polish it --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4494dd01d..89b8b55be 100644 --- a/README.md +++ b/README.md @@ -351,7 +351,7 @@ And if you override the `WebSocketBehavior.OnOpen ()`, `WebSocketBehavior.OnErro The `WebSocketBehavior.Send` method sends data to the client on a session in the service. -If you would like to access the sessions in the service, you should use the `WebSocketBehavior.Sessions` property (returns a `WebSocketSharp.Server.WebSocketSessionManager`). +If you would like to get the sessions in the service, you should access the `WebSocketBehavior.Sessions` property (returns a `WebSocketSharp.Server.WebSocketSessionManager`). The `WebSocketBehavior.Sessions.Broadcast` method sends data to every client in the service. From b1b728eefd769c2fe36122780f89760d64887b58 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 27 Nov 2015 17:38:37 +0900 Subject: [PATCH 0194/6294] [Modify] Polish it --- Example2/Chat.cs | 4 +--- Example2/Echo.cs | 3 +-- Example2/Program.cs | 13 +++++++------ 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/Example2/Chat.cs b/Example2/Chat.cs index a330ad38e..68387a7a0 100644 --- a/Example2/Chat.cs +++ b/Example2/Chat.cs @@ -24,9 +24,7 @@ public Chat (string prefix) private string getName () { var name = Context.QueryString["name"]; - return !name.IsNullOrEmpty () - ? name - : (_prefix + getNumber ()); + return !name.IsNullOrEmpty () ? name : _prefix + getNumber (); } private static int getNumber () diff --git a/Example2/Echo.cs b/Example2/Echo.cs index f0a087caa..dd780c8d1 100644 --- a/Example2/Echo.cs +++ b/Example2/Echo.cs @@ -9,8 +9,7 @@ public class Echo : WebSocketBehavior protected override void OnMessage (MessageEventArgs e) { var name = Context.QueryString["name"]; - var msg = !name.IsNullOrEmpty () ? String.Format ("'{0}' to {1}", e.Data, name) : e.Data; - Send (msg); + Send (!name.IsNullOrEmpty () ? String.Format ("\"{0}\" to {1}", e.Data, name) : e.Data); } } } diff --git a/Example2/Program.cs b/Example2/Program.cs index 02f003dc8..950ffde85 100644 --- a/Example2/Program.cs +++ b/Example2/Program.cs @@ -11,11 +11,11 @@ public class Program { public static void Main (string[] args) { - /* Create a new instance of the WebSocketServer class. - * - * If you would like to provide the secure connection, you should create the instance with - * the 'secure' parameter set to true, or the wss scheme WebSocket URL. - */ + // Create a new instance of the WebSocketServer class. + // + // If you would like to provide the secure connection, you should create the instance with + // the 'secure' parameter set to true, or the wss scheme WebSocket URL. + var wssv = new WebSocketServer (4649); //var wssv = new WebSocketServer (5963, true); //var wssv = new WebSocketServer (System.Net.IPAddress.Parse ("127.0.0.1"), 4649); @@ -62,8 +62,9 @@ public static void Main (string[] args) wssv.AddWebSocketService ( "/Chat", () => new Chat ("Anon#") { + // To send the Sec-WebSocket-Protocol header that has a subprotocol name. Protocol = "chat", - // To emit a WebSocket.OnMessage event when receives a Ping. + // To emit a WebSocket.OnMessage event when receives a ping. EmitOnPing = true, // To ignore the Sec-WebSocket-Extensions header. IgnoreExtensions = true, From 83aa8c9460f12e6a583bb4cea47d76ea507b24d0 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 28 Nov 2015 15:52:44 +0900 Subject: [PATCH 0195/6294] [Modify] Polish it --- Example3/Chat.cs | 4 +--- Example3/Echo.cs | 3 +-- Example3/Program.cs | 22 ++++++++++++++-------- Example3/Public/Js/echotest.js | 32 ++++++++++++++++---------------- 4 files changed, 32 insertions(+), 29 deletions(-) diff --git a/Example3/Chat.cs b/Example3/Chat.cs index 7708a1a73..172f0f8db 100644 --- a/Example3/Chat.cs +++ b/Example3/Chat.cs @@ -24,9 +24,7 @@ public Chat (string prefix) private string getName () { var name = Context.QueryString["name"]; - return !name.IsNullOrEmpty () - ? name - : (_prefix + getNumber ()); + return !name.IsNullOrEmpty () ? name : _prefix + getNumber (); } private static int getNumber () diff --git a/Example3/Echo.cs b/Example3/Echo.cs index 1e0701914..eb7c33410 100644 --- a/Example3/Echo.cs +++ b/Example3/Echo.cs @@ -9,8 +9,7 @@ public class Echo : WebSocketBehavior protected override void OnMessage (MessageEventArgs e) { var name = Context.QueryString["name"]; - var msg = !name.IsNullOrEmpty () ? String.Format ("'{0}' to {1}", e.Data, name) : e.Data; - Send (msg); + Send (!name.IsNullOrEmpty () ? String.Format ("\"{0}\" to {1}", e.Data, name) : e.Data); } } } diff --git a/Example3/Program.cs b/Example3/Program.cs index 68c1657c4..8fde6d7af 100644 --- a/Example3/Program.cs +++ b/Example3/Program.cs @@ -12,11 +12,11 @@ public class Program { public static void Main (string[] args) { - /* Create a new instance of the HttpServer class. - * - * If you would like to provide the secure connection, you should create the instance with - * the 'secure' parameter set to true, or the https scheme HTTP URL. - */ + // Create a new instance of the HttpServer class. + // + // If you would like to provide the secure connection, you should create the instance with + // the 'secure' parameter set to true, or the https scheme HTTP URL. + var httpsv = new HttpServer (4649); //var httpsv = new HttpServer (5963, true); //var httpsv = new HttpServer (System.Net.IPAddress.Parse ("127.0.0.1"), 4649); @@ -49,10 +49,10 @@ public static void Main (string[] args) }; */ - // To set the document root path. + // Set the document root path. httpsv.RootPath = ConfigurationManager.AppSettings["RootPath"]; - // To set the HTTP GET method event. + // Set the HTTP GET request event. httpsv.OnGet += (sender, e) => { var req = e.Request; var res = e.Response; @@ -72,6 +72,11 @@ public static void Main (string[] args) res.ContentEncoding = Encoding.UTF8; } + if (path.EndsWith (".js")) { + res.ContentType = "application/javascript"; + res.ContentEncoding = Encoding.UTF8; + } + res.WriteContent (content); }; @@ -89,8 +94,9 @@ public static void Main (string[] args) httpsv.AddWebSocketService ( "/Chat", () => new Chat ("Anon#") { + // To send the Sec-WebSocket-Protocol header that has a subprotocol name. Protocol = "chat", - // To emit a WebSocket.OnMessage event when receives a Ping. + // To emit a WebSocket.OnMessage event when receives a ping. EmitOnPing = true, // To ignore the Sec-WebSocket-Extensions header. IgnoreExtensions = true, diff --git a/Example3/Public/Js/echotest.js b/Example3/Public/Js/echotest.js index 3f99991d1..a356f0d3e 100644 --- a/Example3/Public/Js/echotest.js +++ b/Example3/Public/Js/echotest.js @@ -18,39 +18,39 @@ function init () { function doWebSocket () { websocket = new WebSocket (url); - websocket.onopen = function (evt) { - onOpen (evt) + websocket.onopen = function (e) { + onOpen (e); }; - websocket.onclose = function (evt) { - onClose (evt) + websocket.onmessage = function (e) { + onMessage (e); }; - websocket.onmessage = function (evt) { - onMessage (evt) + websocket.onerror = function (e) { + onError (e); }; - websocket.onerror = function (evt) { - onError (evt) + websocket.onclose = function (e) { + onClose (e); }; } -function onOpen (evt) { +function onOpen (event) { writeToScreen ("CONNECTED"); send ("WebSocket rocks"); } -function onClose (evt) { - writeToScreen ("DISCONNECTED"); +function onMessage (event) { + writeToScreen ('RESPONSE: ' + event.data + ''); + websocket.close (); } -function onMessage (evt) { - writeToScreen ('RESPONSE: ' + evt.data + ''); - websocket.close (); +function onError (event) { + writeToScreen ('ERROR: ' + event.data + ''); } -function onError (evt) { - writeToScreen('ERROR: ' + evt.data + ''); +function onClose (event) { + writeToScreen ("DISCONNECTED"); } function send (message) { From 9c03d1e8e3f90965f360a53032f982a46ab6d8e7 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 29 Nov 2015 16:35:49 +0900 Subject: [PATCH 0196/6294] [Modify] Polish it --- Example3/Program.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Example3/Program.cs b/Example3/Program.cs index 8fde6d7af..dad6e5f6d 100644 --- a/Example3/Program.cs +++ b/Example3/Program.cs @@ -71,8 +71,7 @@ public static void Main (string[] args) res.ContentType = "text/html"; res.ContentEncoding = Encoding.UTF8; } - - if (path.EndsWith (".js")) { + else if (path.EndsWith (".js")) { res.ContentType = "application/javascript"; res.ContentEncoding = Encoding.UTF8; } From b6bf45c019df09d756ec4daa4e4d612e6e2bd9b2 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 30 Nov 2015 12:06:31 +0900 Subject: [PATCH 0197/6294] [Modify] Polish it --- Example2/Chat.cs | 8 ++++---- Example3/Chat.cs | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Example2/Chat.cs b/Example2/Chat.cs index 68387a7a0..a6b367d96 100644 --- a/Example2/Chat.cs +++ b/Example2/Chat.cs @@ -32,9 +32,9 @@ private static int getNumber () return Interlocked.Increment (ref _number); } - protected override void OnOpen () + protected override void OnClose (CloseEventArgs e) { - _name = getName (); + Sessions.Broadcast (String.Format ("{0} got logged off...", _name)); } protected override void OnMessage (MessageEventArgs e) @@ -42,9 +42,9 @@ protected override void OnMessage (MessageEventArgs e) Sessions.Broadcast (String.Format ("{0}: {1}", _name, e.Data)); } - protected override void OnClose (CloseEventArgs e) + protected override void OnOpen () { - Sessions.Broadcast (String.Format ("{0} got logged off...", _name)); + _name = getName (); } } } diff --git a/Example3/Chat.cs b/Example3/Chat.cs index 172f0f8db..b1a3f4d7d 100644 --- a/Example3/Chat.cs +++ b/Example3/Chat.cs @@ -32,9 +32,9 @@ private static int getNumber () return Interlocked.Increment (ref _number); } - protected override void OnOpen () + protected override void OnClose (CloseEventArgs e) { - _name = getName (); + Sessions.Broadcast (String.Format ("{0} got logged off...", _name)); } protected override void OnMessage (MessageEventArgs e) @@ -42,9 +42,9 @@ protected override void OnMessage (MessageEventArgs e) Sessions.Broadcast (String.Format ("{0}: {1}", _name, e.Data)); } - protected override void OnClose (CloseEventArgs e) + protected override void OnOpen () { - Sessions.Broadcast (String.Format ("{0} got logged off...", _name)); + _name = getName (); } } } From a636653d389a74ed07b4fa62d61ff43c8f535bbb Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 1 Dec 2015 16:02:20 +0900 Subject: [PATCH 0198/6294] [Modify] Polish it --- README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 89b8b55be..2307a0712 100644 --- a/README.md +++ b/README.md @@ -138,7 +138,9 @@ ws.OnMessage += (sender, e) => { `e` has passed as a `WebSocketSharp.MessageEventArgs`. -If you would like to get the message data, you should access `e.Data` or `e.RawData` property. And you can determine which property you should access by checking `e.IsText` or `e.IsBinary` property. +If you would like to get the message data, you should access `e.Data` or `e.RawData` property. + +And you can determine which property you should access by checking `e.IsText` or `e.IsBinary` property. If `e.IsText` is `true`, you should access `e.Data` that returns a `string` (represents a **text** message). @@ -648,7 +650,7 @@ And Example1 uses **[Json.NET]**. **[Example3]** starts an HTTP server that allows to accept the WebSocket connection requests. -Would you access to [http://localhost:4649](http://localhost:4649) to do **WebSocket Echo Test** with your web browser after Example3 running? +Would you access to [http://localhost:4649](http://localhost:4649) to do **WebSocket Echo Test** with your web browser while Example3 is running? ## Supported WebSocket Specifications ## From dc533278e9704a5c825b4b06d49a25a55ec9ea62 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 3 Dec 2015 16:56:43 +0900 Subject: [PATCH 0199/6294] [Modify] Replace it with new message process --- websocket-sharp/WebSocket.cs | 83 +++++++++++++++++++++++++++++++----- 1 file changed, 72 insertions(+), 11 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 29661bec6..ea309e10d 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -91,7 +91,10 @@ private Func _handshakeRequestChecker; private bool _ignoreExtensions; private bool _inContinuation; + private volatile bool _inMessage; private volatile Logger _logger; + private Action + _message; private Queue _messageEventQueue; private uint _nonceCount; private string _origin; @@ -161,6 +164,7 @@ internal WebSocket (HttpListenerWebSocketContext context, string protocol) _closeContext = context.Close; _logger = context.Log; + _message = messages; _secure = context.IsSecureConnection; _stream = context.Stream; _waitTime = TimeSpan.FromSeconds (1); @@ -176,6 +180,7 @@ internal WebSocket (TcpListenerWebSocketContext context, string protocol) _closeContext = context.Close; _logger = context.Log; + _message = messages; _secure = context.IsSecureConnection; _stream = context.Stream; _waitTime = TimeSpan.FromSeconds (1); @@ -236,6 +241,7 @@ public WebSocket (string url, params string[] protocols) _base64Key = CreateBase64Key (); _client = true; _logger = new Logger (); + _message = messagec; _secure = _uri.Scheme == "wss"; _waitTime = TimeSpan.FromSeconds (5); @@ -263,6 +269,13 @@ internal Func CustomHandshakeRequestChecker { } } + internal bool HasMessage { + get { + lock (_forMessageEventQueue) + return _messageEventQueue.Count > 0; + } + } + // As server internal bool IgnoreExtensions { get { @@ -965,6 +978,63 @@ private void init () _readyState = WebSocketState.Connecting; } + private void message () + { + MessageEventArgs e = null; + lock (_forMessageEventQueue) { + if (_inMessage || _messageEventQueue.Count == 0 || _readyState != WebSocketState.Open) + return; + + _inMessage = true; + e = _messageEventQueue.Dequeue (); + } + + _message (e); + } + + private void messagec (MessageEventArgs e) + { + do { + try { + OnMessage.Emit (this, e); + } + catch (Exception ex) { + processException (ex, "An exception has occurred during an OnMessage event."); + } + + lock (_forMessageEventQueue) { + if (_messageEventQueue.Count == 0 || _readyState != WebSocketState.Open) { + _inMessage = false; + break; + } + + e = _messageEventQueue.Dequeue (); + } + } + while (true); + } + + private void messages (MessageEventArgs e) + { + try { + OnMessage.Emit (this, e); + } + catch (Exception ex) { + processException (ex, "An exception has occurred during an OnMessage event."); + } + + lock (_forMessageEventQueue) { + if (_messageEventQueue.Count == 0 || _readyState != WebSocketState.Open) { + _inMessage = false; + return; + } + + e = _messageEventQueue.Dequeue (); + } + + ThreadPool.QueueUserWorkItem (state => messages (e)); + } + private void open () { try { @@ -1500,19 +1570,10 @@ private void startReceiving () // Receive next asap because the Ping or Close needs a response to it. receive (); - if ((frame.IsControl && !(frame.IsPing && _emitOnPing)) || !frame.IsFinal) + if (_inMessage || !HasMessage || _readyState != WebSocketState.Open) return; - lock (_forEvent) { - try { - var e = dequeueFromMessageEventQueue (); - if (e != null && _readyState == WebSocketState.Open) - OnMessage.Emit (this, e); - } - catch (Exception ex) { - processException (ex, "An exception has occurred during an OnMessage event."); - } - } + message (); }, ex => processException (ex, "An exception has occurred while receiving a message.")); From 014df48806aae2a6ece2919b84fb439fddf7527a Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 4 Dec 2015 17:41:13 +0900 Subject: [PATCH 0200/6294] [Modify] Open, and then message --- websocket-sharp/WebSocket.cs | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index ea309e10d..375f89f26 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -82,7 +82,6 @@ public class WebSocket : IDisposable private AutoResetEvent _exitReceiving; private Opcode _fopcode; private object _forConn; - private object _forEvent; private object _forMessageEventQueue; private object _forSend; private MemoryStream _fragmentsBuffer; @@ -971,7 +970,6 @@ private void init () _compression = CompressionMethod.None; _cookies = new CookieCollection (); _forConn = new object (); - _forEvent = new object (); _forSend = new object (); _messageEventQueue = new Queue (); _forMessageEventQueue = ((ICollection) _messageEventQueue).SyncRoot; @@ -1037,21 +1035,31 @@ private void messages (MessageEventArgs e) private void open () { + _inMessage = true; try { startReceiving (); - - lock (_forEvent) { - try { - OnOpen.Emit (this, EventArgs.Empty); - } - catch (Exception ex) { - processException (ex, "An exception has occurred during an OnOpen event."); - } + try { + OnOpen.Emit (this, EventArgs.Empty); + } + catch (Exception ex) { + processException (ex, "An exception has occurred during an OnOpen event."); } } catch (Exception ex) { processException (ex, "An exception has occurred while opening."); } + + MessageEventArgs e = null; + lock (_forMessageEventQueue) { + if (_messageEventQueue.Count == 0 || _readyState != WebSocketState.Open) { + _inMessage = false; + return; + } + + e = _messageEventQueue.Dequeue (); + } + + _message.BeginInvoke (e, ar => _message.EndInvoke (ar), null); } private bool processCloseFrame (WebSocketFrame frame) From 643cc4552acd33c293275908e1f2ff9f1404a7c1 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 5 Dec 2015 13:43:46 +0900 Subject: [PATCH 0201/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 84 ++++++++++++++++++------------------ 1 file changed, 41 insertions(+), 43 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 375f89f26..7740a5d29 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -68,49 +68,47 @@ public class WebSocket : IDisposable { #region Private Fields - private AuthenticationChallenge _authChallenge; - private string _base64Key; - private bool _client; - private Action _closeContext; - private CompressionMethod _compression; - private WebSocketContext _context; - private CookieCollection _cookies; - private NetworkCredential _credentials; - private bool _emitOnPing; - private bool _enableRedirection; - private string _extensions; - private AutoResetEvent _exitReceiving; - private Opcode _fopcode; - private object _forConn; - private object _forMessageEventQueue; - private object _forSend; - private MemoryStream _fragmentsBuffer; - private const string _guid = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11"; - private Func - _handshakeRequestChecker; - private bool _ignoreExtensions; - private bool _inContinuation; - private volatile bool _inMessage; - private volatile Logger _logger; - private Action - _message; - private Queue _messageEventQueue; - private uint _nonceCount; - private string _origin; - private bool _preAuth; - private string _protocol; - private string[] _protocols; - private NetworkCredential _proxyCredentials; - private Uri _proxyUri; - private volatile WebSocketState _readyState; - private AutoResetEvent _receivePong; - private bool _secure; - private ClientSslConfiguration _sslConfig; - private Stream _stream; - private TcpClient _tcpClient; - private Uri _uri; - private const string _version = "13"; - private TimeSpan _waitTime; + private AuthenticationChallenge _authChallenge; + private string _base64Key; + private bool _client; + private Action _closeContext; + private CompressionMethod _compression; + private WebSocketContext _context; + private CookieCollection _cookies; + private NetworkCredential _credentials; + private bool _emitOnPing; + private bool _enableRedirection; + private AutoResetEvent _exitReceiving; + private string _extensions; + private Opcode _fopcode; + private object _forConn; + private object _forMessageEventQueue; + private object _forSend; + private MemoryStream _fragmentsBuffer; + private const string _guid = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11"; + private Func _handshakeRequestChecker; + private bool _ignoreExtensions; + private bool _inContinuation; + private volatile bool _inMessage; + private volatile Logger _logger; + private Action _message; + private Queue _messageEventQueue; + private uint _nonceCount; + private string _origin; + private bool _preAuth; + private string _protocol; + private string[] _protocols; + private NetworkCredential _proxyCredentials; + private Uri _proxyUri; + private volatile WebSocketState _readyState; + private AutoResetEvent _receivePong; + private bool _secure; + private ClientSslConfiguration _sslConfig; + private Stream _stream; + private TcpClient _tcpClient; + private Uri _uri; + private const string _version = "13"; + private TimeSpan _waitTime; #endregion From 97ab72660f10fb438b775e8c4bb61bc8ffc58fb2 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 6 Dec 2015 17:37:08 +0900 Subject: [PATCH 0202/6294] [Modify] Polish it --- websocket-sharp/Net/NetworkCredential.cs | 75 +++++++++++++----------- 1 file changed, 40 insertions(+), 35 deletions(-) diff --git a/websocket-sharp/Net/NetworkCredential.cs b/websocket-sharp/Net/NetworkCredential.cs index e66394a91..d2d392ce6 100644 --- a/websocket-sharp/Net/NetworkCredential.cs +++ b/websocket-sharp/Net/NetworkCredential.cs @@ -4,7 +4,7 @@ * * The MIT License * - * Copyright (c) 2014 sta.blockhead + * Copyright (c) 2014-2015 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -31,69 +31,76 @@ namespace WebSocketSharp.Net { /// - /// Provides the credentials for HTTP authentication (Basic/Digest). + /// Provides the credentials for the HTTP authentication (Basic/Digest). /// public class NetworkCredential { #region Private Fields - private string _domain; - private string _password; - private string [] _roles; - private string _username; + private string _domain; + private string _password; + private string[] _roles; + private string _username; #endregion #region Public Constructors /// - /// Initializes a new instance of the class - /// with the specified user name and password. + /// Initializes a new instance of the class with + /// the specified user name and password. /// /// - /// A that represents the user name associated with the - /// credentials. + /// A that represents the user name associated with the credentials. /// /// - /// A that represents the password for the user name - /// associated with the credentials. + /// A that represents the password for the user name associated with + /// the credentials. /// + /// + /// is . + /// /// - /// is or empty. + /// is empty. /// public NetworkCredential (string username, string password) - : this (username, password, null, new string [0]) + : this (username, password, null, new string[0]) { } /// - /// Initializes a new instance of the class - /// with the specified user name, password, domain, and roles. + /// Initializes a new instance of the class with + /// the specified user name, password, domain, and roles. /// /// - /// A that represents the user name associated with the - /// credentials. + /// A that represents the user name associated with the credentials. /// /// - /// A that represents the password for the user name - /// associated with the credentials. + /// A that represents the password for the user name associated with + /// the credentials. /// /// - /// A that represents the name of the user domain - /// associated with the credentials. + /// A that represents the name of the user domain associated with + /// the credentials. /// /// /// An array of that contains the role names to which /// the user associated with the credentials belongs if any. /// + /// + /// is . + /// /// - /// is or empty. + /// is empty. /// public NetworkCredential ( - string username, string password, string domain, params string [] roles) + string username, string password, string domain, params string[] roles) { - if (username == null || username.Length == 0) - throw new ArgumentException ("Must not be null or empty.", "username"); + if (username == null) + throw new ArgumentNullException ("username"); + + if (username.Length == 0) + throw new ArgumentException ("An empty string.", "username"); _username = username; _password = password; @@ -109,8 +116,8 @@ public NetworkCredential ( /// Gets the name of the user domain associated with the credentials. /// /// - /// A that represents the name of the user domain - /// associated with the credentials. + /// A that represents the name of the user domain associated with + /// the credentials. /// public string Domain { get { @@ -126,8 +133,8 @@ internal set { /// Gets the password for the user name associated with the credentials. /// /// - /// A that represents the password for the user name - /// associated with the credentials. + /// A that represents the password for the user name associated with + /// the credentials. /// public string Password { get { @@ -140,14 +147,13 @@ internal set { } /// - /// Gets the role names to which the user associated with the credentials - /// belongs. + /// Gets the role names to which the user associated with the credentials belongs. /// /// /// An array of that contains the role names to which /// the user associated with the credentials belongs. /// - public string [] Roles { + public string[] Roles { get { return _roles; } @@ -161,8 +167,7 @@ internal set { /// Gets the user name associated with the credentials. /// /// - /// A that represents the user name associated with the - /// credentials. + /// A that represents the user name associated with the credentials. /// public string UserName { get { From 93ab4dcae40fa695b6d091fc00c65dff74b31ba3 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 7 Dec 2015 15:20:12 +0900 Subject: [PATCH 0203/6294] [Modify] Polish it --- websocket-sharp/Net/NetworkCredential.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/NetworkCredential.cs b/websocket-sharp/Net/NetworkCredential.cs index d2d392ce6..397ac094a 100644 --- a/websocket-sharp/Net/NetworkCredential.cs +++ b/websocket-sharp/Net/NetworkCredential.cs @@ -64,7 +64,7 @@ public class NetworkCredential /// is empty. /// public NetworkCredential (string username, string password) - : this (username, password, null, new string[0]) + : this (username, password, null, null) { } @@ -151,11 +151,11 @@ internal set { /// /// /// An array of that contains the role names to which - /// the user associated with the credentials belongs. + /// the user associated with the credentials belongs if any. /// public string[] Roles { get { - return _roles; + return _roles ?? (_roles = new string[0]); } internal set { From 53407f5732ac7ee274c3254ce4f2f58ad61c71e0 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 8 Dec 2015 16:52:47 +0900 Subject: [PATCH 0204/6294] [Modify] Polish it --- websocket-sharp/Net/NetworkCredential.cs | 34 ++++++++++++------------ 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/websocket-sharp/Net/NetworkCredential.cs b/websocket-sharp/Net/NetworkCredential.cs index 397ac094a..b90bcad25 100644 --- a/websocket-sharp/Net/NetworkCredential.cs +++ b/websocket-sharp/Net/NetworkCredential.cs @@ -40,7 +40,7 @@ public class NetworkCredential private string _domain; private string _password; private string[] _roles; - private string _username; + private string _userName; #endregion @@ -50,7 +50,7 @@ public class NetworkCredential /// Initializes a new instance of the class with /// the specified user name and password. /// - /// + /// /// A that represents the user name associated with the credentials. /// /// @@ -58,13 +58,13 @@ public class NetworkCredential /// the credentials. /// /// - /// is . + /// is . /// /// - /// is empty. + /// is empty. /// - public NetworkCredential (string username, string password) - : this (username, password, null, null) + public NetworkCredential (string userName, string password) + : this (userName, password, null, null) { } @@ -72,7 +72,7 @@ public NetworkCredential (string username, string password) /// Initializes a new instance of the class with /// the specified user name, password, domain, and roles. /// - /// + /// /// A that represents the user name associated with the credentials. /// /// @@ -88,21 +88,21 @@ public NetworkCredential (string username, string password) /// the user associated with the credentials belongs if any. /// /// - /// is . + /// is . /// /// - /// is empty. + /// is empty. /// public NetworkCredential ( - string username, string password, string domain, params string[] roles) + string userName, string password, string domain, params string[] roles) { - if (username == null) - throw new ArgumentNullException ("username"); + if (userName == null) + throw new ArgumentNullException ("userName"); - if (username.Length == 0) - throw new ArgumentException ("An empty string.", "username"); + if (userName.Length == 0) + throw new ArgumentException ("An empty string.", "userName"); - _username = username; + _userName = userName; _password = password; _domain = domain; _roles = roles; @@ -171,11 +171,11 @@ internal set { /// public string UserName { get { - return _username; + return _userName; } internal set { - _username = value; + _userName = value; } } From ff7e00f661a93f60605becbb5872ef86449d888e Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 9 Dec 2015 15:55:08 +0900 Subject: [PATCH 0205/6294] [Modify] Add RSV check --- websocket-sharp/WebSocket.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 7740a5d29..d227d6e3c 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -744,7 +744,11 @@ private string checkIfValidReceivedFrame (WebSocketFrame frame) ? "A data frame has been received while receiving the fragmented data." : frame.IsCompressed && _compression == CompressionMethod.None ? "A compressed frame is without an available decompression method." - : null; + : frame.Rsv2 == Rsv.On + ? "The RSV2 of a frame is non-zero without any negotiation for it." + : frame.Rsv3 == Rsv.On + ? "The RSV3 of a frame is non-zero without any negotiation for it." + : null; } private void close (CloseEventArgs e, bool send, bool receive, bool received) From 7d52b5492dc0a51ac1398fa2f6c619b797a580d8 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 10 Dec 2015 15:51:04 +0900 Subject: [PATCH 0206/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index d227d6e3c..6f083b7fe 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -741,9 +741,9 @@ private string checkIfValidReceivedFrame (WebSocketFrame frame) : !_client && !masked ? "A frame from a client isn't masked." : _inContinuation && frame.IsData - ? "A data frame has been received while receiving the fragmented data." + ? "A data frame has been received while receiving continuation frames." : frame.IsCompressed && _compression == CompressionMethod.None - ? "A compressed frame is without an available decompression method." + ? "A compressed frame has been received without any agreement for it." : frame.Rsv2 == Rsv.On ? "The RSV2 of a frame is non-zero without any negotiation for it." : frame.Rsv3 == Rsv.On From 07addc4eeed60db5eec94e206c7f8c679a790a8a Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 11 Dec 2015 15:16:01 +0900 Subject: [PATCH 0207/6294] [Modify] Use first fragment to determine if the fragmented data are compressed --- websocket-sharp/WebSocket.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 6f083b7fe..459062e82 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -80,6 +80,7 @@ public class WebSocket : IDisposable private bool _enableRedirection; private AutoResetEvent _exitReceiving; private string _extensions; + private bool _fcompressed; private Opcode _fopcode; private object _forConn; private object _forMessageEventQueue; @@ -1116,6 +1117,7 @@ private bool processFragmentedFrame (WebSocketFrame frame) return true; _fopcode = frame.Opcode; + _fcompressed = frame.IsCompressed; _fragmentsBuffer = new MemoryStream (); _inContinuation = true; } @@ -1123,7 +1125,7 @@ private bool processFragmentedFrame (WebSocketFrame frame) _fragmentsBuffer.WriteBytes (frame.PayloadData.ApplicationData, 1024); if (frame.IsFinal) { using (_fragmentsBuffer) { - var data = _compression != CompressionMethod.None + var data = _fcompressed ? _fragmentsBuffer.DecompressToArray (_compression) : _fragmentsBuffer.ToArray (); From 8b48f224ea71e704c41d8b926f61904f3c5523f0 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 11 Dec 2015 15:24:41 +0900 Subject: [PATCH 0208/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 459062e82..cd35951b6 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -80,12 +80,12 @@ public class WebSocket : IDisposable private bool _enableRedirection; private AutoResetEvent _exitReceiving; private string _extensions; - private bool _fcompressed; - private Opcode _fopcode; private object _forConn; private object _forMessageEventQueue; private object _forSend; private MemoryStream _fragmentsBuffer; + private bool _fragmentsCompressed; + private Opcode _fragmentsOpcode; private const string _guid = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11"; private Func _handshakeRequestChecker; private bool _ignoreExtensions; @@ -1116,8 +1116,8 @@ private bool processFragmentedFrame (WebSocketFrame frame) if (frame.IsContinuation) return true; - _fopcode = frame.Opcode; - _fcompressed = frame.IsCompressed; + _fragmentsOpcode = frame.Opcode; + _fragmentsCompressed = frame.IsCompressed; _fragmentsBuffer = new MemoryStream (); _inContinuation = true; } @@ -1125,11 +1125,11 @@ private bool processFragmentedFrame (WebSocketFrame frame) _fragmentsBuffer.WriteBytes (frame.PayloadData.ApplicationData, 1024); if (frame.IsFinal) { using (_fragmentsBuffer) { - var data = _fcompressed + var data = _fragmentsCompressed ? _fragmentsBuffer.DecompressToArray (_compression) : _fragmentsBuffer.ToArray (); - enqueueToMessageEventQueue (new MessageEventArgs (_fopcode, data)); + enqueueToMessageEventQueue (new MessageEventArgs (_fragmentsOpcode, data)); } _fragmentsBuffer = null; From 842b5b3b3a0644a995eb47ff21a6e566cc6b9e8d Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 12 Dec 2015 15:26:05 +0900 Subject: [PATCH 0209/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 6 +++--- websocket-sharp/WebSocketFrame.cs | 5 ++--- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index cd35951b6..225a577a9 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1109,7 +1109,7 @@ private void processException (Exception exception, string message) new CloseEventArgs (code, reason ?? code.GetMessage ()), !code.IsReserved (), false, false); } - private bool processFragmentedFrame (WebSocketFrame frame) + private bool processFragmentFrame (WebSocketFrame frame) { if (!_inContinuation) { // Must process first fragment. @@ -1165,8 +1165,8 @@ private bool processReceivedFrame (WebSocketFrame frame) return processUnsupportedFrame (frame, CloseStatusCode.ProtocolError, msg); frame.Unmask (); - return frame.IsFragmented - ? processFragmentedFrame (frame) + return frame.IsFragment + ? processFragmentFrame (frame) : frame.IsData ? processDataFrame (frame) : frame.IsPing diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index 7ee1353a5..6168f219c 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -214,7 +214,7 @@ public bool IsFinal { } } - public bool IsFragmented { + public bool IsFragment { get { return _fin == Fin.More || _opcode == Opcode.Cont; } @@ -403,8 +403,7 @@ private static string print (WebSocketFrame frame) ? String.Empty : payloadLen > 125 ? "---" - : frame.IsText && - !(frame.IsMasked || frame.IsFragmented || frame.IsCompressed) + : frame.IsText && !(frame.IsFragment || frame.IsMasked || frame.IsCompressed) ? frame._payloadData.ApplicationData.UTF8Decode () : frame._payloadData.ToString (); From 1a6e1fb1694ebce98a8fde7cd444cb06f131c268 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 13 Dec 2015 17:54:39 +0900 Subject: [PATCH 0210/6294] [Modify] Add an Opcode check --- websocket-sharp/WebSocketFrame.cs | 33 ++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index 6168f219c..efd63ab4e 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -377,16 +377,33 @@ private static string dump (WebSocketFrame frame) return output.ToString (); } + private static bool isControl (byte opcode) + { + return opcode == (byte) Opcode.Close || + opcode == (byte) Opcode.Ping || + opcode == (byte) Opcode.Pong; + } + private static bool isControl (Opcode opcode) { return opcode == Opcode.Close || opcode == Opcode.Ping || opcode == Opcode.Pong; } + private static bool isData (byte opcode) + { + return opcode == (byte) Opcode.Text || opcode == (byte) Opcode.Binary; + } + private static bool isData (Opcode opcode) { return opcode == Opcode.Text || opcode == Opcode.Binary; } + private static bool isSupported (byte opcode) + { + return Enum.IsDefined (typeof (Opcode), opcode); + } + private static string print (WebSocketFrame frame) { // Payload Length @@ -452,7 +469,7 @@ private static WebSocketFrame processHeader (byte[] header) var rsv3 = (header[0] & 0x10) == 0x10 ? Rsv.On : Rsv.Off; // Opcode - var opcode = (Opcode) (header[0] & 0x0f); + var opcode = (byte) (header[0] & 0x0f); // MASK var mask = (header[1] & 0x80) == 0x80 ? Mask.On : Mask.Off; @@ -461,13 +478,15 @@ private static WebSocketFrame processHeader (byte[] header) var payloadLen = (byte) (header[1] & 0x7f); // Check if valid header. - var err = isControl (opcode) && payloadLen > 125 - ? "A control frame has payload data which is greater than the allowable max length." + var err = !isSupported (opcode) + ? "An unsupported opcode." : isControl (opcode) && fin == Fin.More ? "A control frame is fragmented." - : !isData (opcode) && rsv1 == Rsv.On - ? "A non data frame is compressed." - : null; + : isControl (opcode) && payloadLen > 125 + ? "A control frame has a long payload length than the allowable max length." + : !isData (opcode) && rsv1 == Rsv.On + ? "A non data frame is compressed." + : null; if (err != null) throw new WebSocketException (CloseStatusCode.ProtocolError, err); @@ -477,7 +496,7 @@ private static WebSocketFrame processHeader (byte[] header) frame._rsv1 = rsv1; frame._rsv2 = rsv2; frame._rsv3 = rsv3; - frame._opcode = opcode; + frame._opcode = (Opcode) opcode; frame._mask = mask; frame._payloadLength = payloadLen; From a56f0c87dcf0f8eebe18460c9a9da98d140aaa39 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 14 Dec 2015 15:01:55 +0900 Subject: [PATCH 0211/6294] [Modify] Polish it --- websocket-sharp/WebSocketFrame.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index efd63ab4e..bf247a100 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -483,7 +483,7 @@ private static WebSocketFrame processHeader (byte[] header) : isControl (opcode) && fin == Fin.More ? "A control frame is fragmented." : isControl (opcode) && payloadLen > 125 - ? "A control frame has a long payload length than the allowable max length." + ? "A control frame has a long payload length." : !isData (opcode) && rsv1 == Rsv.On ? "A non data frame is compressed." : null; From 514cccac12908dbc4a33cf4ada6caf58d45494f0 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 15 Dec 2015 17:01:43 +0900 Subject: [PATCH 0212/6294] [Modify] Move them to the extension methods --- websocket-sharp/Ext.cs | 15 +++++++++++++++ websocket-sharp/WebSocketFrame.cs | 25 ++++--------------------- 2 files changed, 19 insertions(+), 21 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 91983f894..42f50de63 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -508,6 +508,16 @@ internal static bool IsCompressionExtension (this string value, CompressionMetho return value.StartsWith (method.ToExtensionString ()); } + internal static bool IsControl (this byte opcode) + { + return opcode > 0x7 && opcode < 0x10; + } + + internal static bool IsData (this byte opcode) + { + return opcode == 0x1 || opcode == 0x2; + } + internal static bool IsPortNumber (this int value) { return value > 0 && value < 65536; @@ -529,6 +539,11 @@ internal static bool IsReserved (this CloseStatusCode code) code == CloseStatusCode.TlsHandshakeFailure; } + internal static bool IsSupported (this byte opcode) + { + return Enum.IsDefined (typeof (Opcode), opcode); + } + internal static bool IsText (this string value) { var len = value.Length; diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index bf247a100..c81720fd0 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -377,33 +377,16 @@ private static string dump (WebSocketFrame frame) return output.ToString (); } - private static bool isControl (byte opcode) - { - return opcode == (byte) Opcode.Close || - opcode == (byte) Opcode.Ping || - opcode == (byte) Opcode.Pong; - } - private static bool isControl (Opcode opcode) { return opcode == Opcode.Close || opcode == Opcode.Ping || opcode == Opcode.Pong; } - private static bool isData (byte opcode) - { - return opcode == (byte) Opcode.Text || opcode == (byte) Opcode.Binary; - } - private static bool isData (Opcode opcode) { return opcode == Opcode.Text || opcode == Opcode.Binary; } - private static bool isSupported (byte opcode) - { - return Enum.IsDefined (typeof (Opcode), opcode); - } - private static string print (WebSocketFrame frame) { // Payload Length @@ -478,13 +461,13 @@ private static WebSocketFrame processHeader (byte[] header) var payloadLen = (byte) (header[1] & 0x7f); // Check if valid header. - var err = !isSupported (opcode) + var err = !opcode.IsSupported () ? "An unsupported opcode." - : isControl (opcode) && fin == Fin.More + : opcode.IsControl () && fin == Fin.More ? "A control frame is fragmented." - : isControl (opcode) && payloadLen > 125 + : opcode.IsControl () && payloadLen > 125 ? "A control frame has a long payload length." - : !isData (opcode) && rsv1 == Rsv.On + : !opcode.IsData () && rsv1 == Rsv.On ? "A non data frame is compressed." : null; From 8359eadb8de77985638360356d6c5a04da71d9f1 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 16 Dec 2015 15:57:10 +0900 Subject: [PATCH 0213/6294] [Modify] Polish it --- websocket-sharp/WebSocketFrame.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index c81720fd0..da969787b 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -463,12 +463,12 @@ private static WebSocketFrame processHeader (byte[] header) // Check if valid header. var err = !opcode.IsSupported () ? "An unsupported opcode." - : opcode.IsControl () && fin == Fin.More - ? "A control frame is fragmented." - : opcode.IsControl () && payloadLen > 125 - ? "A control frame has a long payload length." - : !opcode.IsData () && rsv1 == Rsv.On - ? "A non data frame is compressed." + : !opcode.IsData () && rsv1 == Rsv.On + ? "A non data frame is compressed." + : opcode.IsControl () && fin == Fin.More + ? "A control frame is fragmented." + : opcode.IsControl () && payloadLen > 125 + ? "A control frame has a long payload length." : null; if (err != null) From b60111fd5578fe2b5bebd088d6f444f01ec8509c Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 17 Dec 2015 13:39:09 +0900 Subject: [PATCH 0214/6294] [Modify] Move them to the extension methods --- websocket-sharp/Ext.cs | 10 ++++++++++ websocket-sharp/WebSocketFrame.cs | 12 +----------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 42f50de63..ba9606d79 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -513,11 +513,21 @@ internal static bool IsControl (this byte opcode) return opcode > 0x7 && opcode < 0x10; } + internal static bool IsControl (this Opcode opcode) + { + return opcode >= Opcode.Close; + } + internal static bool IsData (this byte opcode) { return opcode == 0x1 || opcode == 0x2; } + internal static bool IsData (this Opcode opcode) + { + return opcode == Opcode.Text || opcode == Opcode.Binary; + } + internal static bool IsPortNumber (this int value) { return value > 0 && value < 65536; diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index da969787b..dc440a2a3 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -104,7 +104,7 @@ internal WebSocketFrame ( Fin fin, Opcode opcode, PayloadData payloadData, bool compressed, bool mask) { _fin = fin; - _rsv1 = isData (opcode) && compressed ? Rsv.On : Rsv.Off; + _rsv1 = opcode.IsData () && compressed ? Rsv.On : Rsv.Off; _rsv2 = Rsv.Off; _rsv3 = Rsv.Off; _opcode = opcode; @@ -377,16 +377,6 @@ private static string dump (WebSocketFrame frame) return output.ToString (); } - private static bool isControl (Opcode opcode) - { - return opcode == Opcode.Close || opcode == Opcode.Ping || opcode == Opcode.Pong; - } - - private static bool isData (Opcode opcode) - { - return opcode == Opcode.Text || opcode == Opcode.Binary; - } - private static string print (WebSocketFrame frame) { // Payload Length From 7d520184c89e8ed47ab276c9f4f9add7f8d59eb1 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 18 Dec 2015 15:36:52 +0900 Subject: [PATCH 0215/6294] [Modify] Polish it --- websocket-sharp/WebSocketFrame.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index dc440a2a3..38865b97c 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -198,13 +198,13 @@ public bool IsContinuation { public bool IsControl { get { - return _opcode == Opcode.Close || _opcode == Opcode.Ping || _opcode == Opcode.Pong; + return _opcode >= Opcode.Close; } } public bool IsData { get { - return _opcode == Opcode.Binary || _opcode == Opcode.Text; + return _opcode == Opcode.Text || _opcode == Opcode.Binary; } } From 29e0d3607a4160a9bb66eb539d617d29d3194d06 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 19 Dec 2015 16:08:04 +0900 Subject: [PATCH 0216/6294] [Modify] Polish it --- websocket-sharp/WebSocketFrame.cs | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index 38865b97c..b2954030b 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -426,8 +426,7 @@ private static string print (WebSocketFrame frame) private static WebSocketFrame processHeader (byte[] header) { if (header.Length != 2) - throw new WebSocketException ( - "The header part of a frame cannot be read from the data source."); + throw new WebSocketException ("The header of a frame cannot be read from the stream."); // FIN var fin = (header[0] & 0x80) == 0x80 ? Fin.Final : Fin.More; @@ -450,7 +449,6 @@ private static WebSocketFrame processHeader (byte[] header) // Payload Length var payloadLen = (byte) (header[1] & 0x7f); - // Check if valid header. var err = !opcode.IsSupported () ? "An unsupported opcode." : !opcode.IsData () && rsv1 == Rsv.On @@ -487,7 +485,7 @@ private static WebSocketFrame readExtendedPayloadLength (Stream stream, WebSocke var bytes = stream.ReadBytes (len); if (bytes.Length != len) throw new WebSocketException ( - "The 'Extended Payload Length' of a frame cannot be read from the data source."); + "The extended payload length of a frame cannot be read from the stream."); frame._extPayloadLength = bytes; return frame; @@ -512,7 +510,7 @@ private static void readExtendedPayloadLengthAsync ( bytes => { if (bytes.Length != len) throw new WebSocketException ( - "The 'Extended Payload Length' of a frame cannot be read from the data source."); + "The extended payload length of a frame cannot be read from the stream."); frame._extPayloadLength = bytes; completed (frame); @@ -541,8 +539,7 @@ private static WebSocketFrame readMaskingKey (Stream stream, WebSocketFrame fram var bytes = stream.ReadBytes (len); if (bytes.Length != len) - throw new WebSocketException ( - "The 'Masking Key' of a frame cannot be read from the data source."); + throw new WebSocketException ("The masking key of a frame cannot be read from the stream."); frame._maskingKey = bytes; return frame; @@ -567,7 +564,7 @@ private static void readMaskingKeyAsync ( bytes => { if (bytes.Length != len) throw new WebSocketException ( - "The 'Masking Key' of a frame cannot be read from the data source."); + "The masking key of a frame cannot be read from the stream."); frame._maskingKey = bytes; completed (frame); @@ -583,11 +580,8 @@ private static WebSocketFrame readPayloadData (Stream stream, WebSocketFrame fra return frame; } - // Check if allowable length. if (len > PayloadData.MaxLength) - throw new WebSocketException ( - CloseStatusCode.TooBig, - "The length of 'Payload Data' of a frame is greater than the allowable max length."); + throw new WebSocketException (CloseStatusCode.TooBig, "A frame has a long payload length."); var llen = (long) len; var bytes = frame._payloadLength < 127 @@ -596,7 +590,7 @@ private static WebSocketFrame readPayloadData (Stream stream, WebSocketFrame fra if (bytes.LongLength != llen) throw new WebSocketException ( - "The 'Payload Data' of a frame cannot be read from the data source."); + "The payload data of a frame cannot be read from the stream."); frame._payloadData = new PayloadData (bytes, llen); return frame; @@ -616,17 +610,14 @@ private static void readPayloadDataAsync ( return; } - // Check if allowable length. if (len > PayloadData.MaxLength) - throw new WebSocketException ( - CloseStatusCode.TooBig, - "The length of 'Payload Data' of a frame is greater than the allowable max length."); + throw new WebSocketException (CloseStatusCode.TooBig, "A frame has a long payload length."); var llen = (long) len; Action compl = bytes => { if (bytes.LongLength != llen) throw new WebSocketException ( - "The 'Payload Data' of a frame cannot be read from the data source."); + "The payload data of a frame cannot be read from the stream."); frame._payloadData = new PayloadData (bytes, llen); completed (frame); From 9728750114634c2e8880c8aeffda5e43f1392523 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 20 Dec 2015 16:02:47 +0900 Subject: [PATCH 0217/6294] [Modify] Polish it --- websocket-sharp/WebSocketFrame.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index b2954030b..219242c1d 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -61,11 +61,11 @@ internal class WebSocketFrame : IEnumerable #region Internal Fields /// - /// Represents the Ping frame without the payload data as an array of . + /// Represents the ping frame without the payload data as an array of . /// /// /// The value of this field is created from a non masked frame, so it can only be used to - /// send a Ping from a server. + /// send a ping from a server. /// internal static readonly byte[] EmptyPingBytes; From 5cc400a5b29a86275cde12519200bd3d8b63cd47 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 21 Dec 2015 17:44:16 +0900 Subject: [PATCH 0218/6294] [Modify] Call error --- websocket-sharp/WebSocket.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 225a577a9..f62364e46 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1045,7 +1045,8 @@ private void open () OnOpen.Emit (this, EventArgs.Empty); } catch (Exception ex) { - processException (ex, "An exception has occurred during an OnOpen event."); + _logger.Error (ex.ToString ()); + error ("An exception has occurred during the OnOpen event.", ex); } } catch (Exception ex) { From 3f8420259f6361e34d8d955547943bef555aeed7 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 22 Dec 2015 14:25:50 +0900 Subject: [PATCH 0219/6294] [Modify] Call error --- websocket-sharp/WebSocket.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index f62364e46..a46d84be2 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1000,7 +1000,8 @@ private void messagec (MessageEventArgs e) OnMessage.Emit (this, e); } catch (Exception ex) { - processException (ex, "An exception has occurred during an OnMessage event."); + _logger.Error (ex.ToString ()); + error ("An exception has occurred during an OnMessage event.", ex); } lock (_forMessageEventQueue) { @@ -1021,7 +1022,8 @@ private void messages (MessageEventArgs e) OnMessage.Emit (this, e); } catch (Exception ex) { - processException (ex, "An exception has occurred during an OnMessage event."); + _logger.Error (ex.ToString ()); + error ("An exception has occurred during an OnMessage event.", ex); } lock (_forMessageEventQueue) { From dd2579fd9954f66a8d318931b0154d3a4d804324 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 23 Dec 2015 15:32:55 +0900 Subject: [PATCH 0220/6294] [Modify] Use Error --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index a46d84be2..a32437c8f 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -964,7 +964,7 @@ private void error (string message, Exception exception) OnError.Emit (this, new ErrorEventArgs (message, exception)); } catch (Exception ex) { - _logger.Fatal (ex.ToString ()); + _logger.Error (ex.ToString ()); } } From f472e91515718b29c49e097e15e435d1d77591c4 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 24 Dec 2015 21:18:40 +0900 Subject: [PATCH 0221/6294] [Modify] Use Error --- websocket-sharp/WebSocket.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index a32437c8f..cdf906a72 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -784,8 +784,8 @@ private void close (CloseEventArgs e, bool send, bool receive, bool received) OnClose.Emit (this, e); } catch (Exception ex) { - _logger.Fatal (ex.ToString ()); - error ("An exception has occurred during an OnClose event.", ex); + _logger.Error (ex.ToString ()); + error ("An exception has occurred during the OnClose event.", ex); } } From d0989cb7c873d688911ad1b91727f4c1317b8ee4 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 25 Dec 2015 15:19:32 +0900 Subject: [PATCH 0222/6294] [Modify] Use Fatal --- websocket-sharp/WebSocket.cs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index cdf906a72..ec94c67b0 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1097,10 +1097,7 @@ private void processException (Exception exception, string message) reason = wsex.Message; } - if (code == CloseStatusCode.Abnormal || code == CloseStatusCode.TlsHandshakeFailure) - _logger.Fatal (exception.ToString ()); - else - _logger.Error (reason); + _logger.Fatal (exception.ToString ()); error (message ?? code.GetMessage (), exception); if (!_client && _readyState == WebSocketState.Connecting) { From 29a858e340843bb9923c457ff557623b5b6b1393 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 26 Dec 2015 15:48:20 +0900 Subject: [PATCH 0223/6294] [Modify] Don't call error --- websocket-sharp/WebSocket.cs | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index ec94c67b0..48b1cb56a 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1089,24 +1089,21 @@ private bool processDataFrame (WebSocketFrame frame) private void processException (Exception exception, string message) { - var code = CloseStatusCode.Abnormal; - var reason = message; - if (exception is WebSocketException) { - var wsex = (WebSocketException) exception; - code = wsex.Code; - reason = wsex.Message; - } - _logger.Fatal (exception.ToString ()); - - error (message ?? code.GetMessage (), exception); if (!_client && _readyState == WebSocketState.Connecting) { Close (HttpStatusCode.BadRequest); return; } + var code = exception is WebSocketException + ? ((WebSocketException) exception).Code + : CloseStatusCode.Abnormal; + close ( - new CloseEventArgs (code, reason ?? code.GetMessage ()), !code.IsReserved (), false, false); + new CloseEventArgs (code, message ?? code.GetMessage ()), + !code.IsReserved (), + false, + false); } private bool processFragmentFrame (WebSocketFrame frame) From 752da8a7f5d572034ad55d53bf89f4f3b83586ed Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 27 Dec 2015 16:26:33 +0900 Subject: [PATCH 0224/6294] [Modify] Use Error --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 48b1cb56a..5705a95b6 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1783,7 +1783,7 @@ internal void Close (CloseEventArgs e, byte[] frameAsBytes, bool receive) OnClose.Emit (this, e); } catch (Exception ex) { - _logger.Fatal (ex.ToString ()); + _logger.Error (ex.ToString ()); } } From d7a6d822af5004479ca1d49aeb1c2c939061546d Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 28 Dec 2015 15:20:34 +0900 Subject: [PATCH 0225/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 5705a95b6..34f71a1da 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1041,18 +1041,13 @@ private void messages (MessageEventArgs e) private void open () { _inMessage = true; + startReceiving (); try { - startReceiving (); - try { - OnOpen.Emit (this, EventArgs.Empty); - } - catch (Exception ex) { - _logger.Error (ex.ToString ()); - error ("An exception has occurred during the OnOpen event.", ex); - } + OnOpen.Emit (this, EventArgs.Empty); } catch (Exception ex) { - processException (ex, "An exception has occurred while opening."); + _logger.Error (ex.ToString ()); + error ("An exception has occurred during the OnOpen event.", ex); } MessageEventArgs e = null; From a569d934c75af2bfe6088432354e42a53001798c Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 29 Dec 2015 15:41:25 +0900 Subject: [PATCH 0226/6294] [Modify] Use Error --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 34f71a1da..dceeb85e6 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1287,7 +1287,7 @@ private bool send (Opcode opcode, Stream stream) error ("The sending has been interrupted.", null); } catch (Exception ex) { - _logger.Fatal (ex.ToString ()); + _logger.Error (ex.ToString ()); error ("An exception has occurred while sending data.", ex); } finally { From bcf65ed7d6bece9a556e65df2a5bfb5b6a72067e Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 30 Dec 2015 15:46:57 +0900 Subject: [PATCH 0227/6294] [Modify] Use Error --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index dceeb85e6..c7aead4d0 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1372,7 +1372,7 @@ private void sendAsync (Opcode opcode, Stream stream, Action completed) completed (sent); } catch (Exception ex) { - _logger.Fatal (ex.ToString ()); + _logger.Error (ex.ToString ()); error ("An exception has occurred during a send callback.", ex); } }, From b56cdd1aae9951db82f4736c5a25d8060516c9dd Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 31 Dec 2015 17:59:53 +0900 Subject: [PATCH 0228/6294] [Modify] Use Error --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index c7aead4d0..52710c964 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1386,7 +1386,7 @@ private bool sendBytes (byte[] bytes) return true; } catch (Exception ex) { - _logger.Fatal (ex.ToString ()); + _logger.Error (ex.ToString ()); return false; } } From 1de22cb3b1c8b84e84deb42c1971aeb1c9838d5b Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 1 Jan 2016 16:36:51 +0900 Subject: [PATCH 0229/6294] [Modify] Use Error --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 52710c964..b1ebf7c2b 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1825,7 +1825,7 @@ internal bool Ping (byte[] frameAsBytes, TimeSpan timeout) pong.WaitOne (timeout); } catch (Exception ex) { - _logger.Fatal (ex.ToString ()); + _logger.Error (ex.ToString ()); return false; } } From 5c66a44ac60bf2d82e2086dca9d464ec0ed0f058 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 1 Jan 2016 16:42:52 +0900 Subject: [PATCH 0230/6294] [Modify] Into the year 2016 --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index b1ebf7c2b..44bc80f6c 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -10,7 +10,7 @@ * The MIT License * * Copyright (c) 2009 Adam MacBeth - * Copyright (c) 2010-2015 sta.blockhead + * Copyright (c) 2010-2016 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From 9bf71f2668b6b668ca39c68c8446a8eb1de1e573 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 1 Jan 2016 16:44:51 +0900 Subject: [PATCH 0231/6294] [Modify] Into the year 2016 --- LICENSE.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LICENSE.txt b/LICENSE.txt index 39c64688b..b9c30e643 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2010-2015 sta.blockhead +Copyright (c) 2010-2016 sta.blockhead Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal From ebdaecfd1923e5b0f2758a5d66506bc4db9a2cab Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 2 Jan 2016 16:32:44 +0900 Subject: [PATCH 0232/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 44bc80f6c..2258025be 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1817,17 +1817,17 @@ internal void InternalAccept () internal bool Ping (byte[] frameAsBytes, TimeSpan timeout) { - try { - AutoResetEvent pong; - return _readyState == WebSocketState.Open && - send (frameAsBytes) && - (pong = _receivePong) != null && - pong.WaitOne (timeout); - } - catch (Exception ex) { - _logger.Error (ex.ToString ()); + if (_readyState != WebSocketState.Open) return false; - } + + if (!send (frameAsBytes)) + return false; + + var receivePong = _receivePong; + if (receivePong == null) + return false; + + return receivePong.WaitOne (timeout); } // As server, used to broadcast From 50dbfe716b7ab901afd66f1de56990620eb9c812 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 3 Jan 2016 10:39:24 +0900 Subject: [PATCH 0233/6294] [Modify] Use Error --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 2258025be..40560f97b 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1857,7 +1857,7 @@ internal void Send (Opcode opcode, byte[] data, Dictionary Date: Mon, 4 Jan 2016 16:04:05 +0900 Subject: [PATCH 0234/6294] [Modify] Use Error --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 40560f97b..d86ee391c 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1880,7 +1880,7 @@ internal void Send (Opcode opcode, Stream stream, Dictionary Date: Tue, 5 Jan 2016 15:58:38 +0900 Subject: [PATCH 0235/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index d86ee391c..5fd0ceb46 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1841,20 +1841,22 @@ internal void Send (Opcode opcode, byte[] data, Dictionary Date: Wed, 6 Jan 2016 15:15:34 +0900 Subject: [PATCH 0236/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 5fd0ceb46..ab785b70e 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1870,16 +1870,16 @@ internal void Send (Opcode opcode, Stream stream, Dictionary Date: Wed, 6 Jan 2016 15:23:09 +0900 Subject: [PATCH 0237/6294] [Modify] Use Error --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index ab785b70e..624b7e9ee 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2558,7 +2558,7 @@ public void SendAsync (Stream stream, int length, Action completed) completed (sent); }, ex => { - _logger.Fatal (ex.ToString ()); + _logger.Error (ex.ToString ()); error ("An exception has occurred while sending data.", ex); }); } From 2018fca931f54545d0bc9304d1d2ac070e92907d Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 7 Jan 2016 15:31:04 +0900 Subject: [PATCH 0238/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 624b7e9ee..20b9e2768 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2549,9 +2549,11 @@ public void SendAsync (Stream stream, int length, Action completed) if (len < length) _logger.Warn ( String.Format ( - "The data with 'length' cannot be read from 'stream':\n expected: {0}\n actual: {1}", + "The length of the data is less than 'length':\n expected: {0}\n actual: {1}", length, - len)); + len + ) + ); var sent = send (Opcode.Binary, new MemoryStream (data)); if (completed != null) @@ -2560,7 +2562,8 @@ public void SendAsync (Stream stream, int length, Action completed) ex => { _logger.Error (ex.ToString ()); error ("An exception has occurred while sending data.", ex); - }); + } + ); } /// From f8f8189b4b03a7fa2c8fc8a2c4293e557d51dbce Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 8 Jan 2016 15:28:39 +0900 Subject: [PATCH 0239/6294] [Modify] Replace it --- websocket-sharp/WebSocket.cs | 61 +++++++++++++++++++++++------------- 1 file changed, 40 insertions(+), 21 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 20b9e2768..30833c28a 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -968,6 +968,20 @@ private void error (string message, Exception exception) } } + private void fatal (string message, Exception exception) + { + var code = exception is WebSocketException + ? ((WebSocketException) exception).Code + : CloseStatusCode.Abnormal; + + close ( + new CloseEventArgs (code, message ?? code.GetMessage ()), + !code.IsReserved (), + false, + false + ); + } + private void init () { _compression = CompressionMethod.None; @@ -1558,28 +1572,33 @@ private void startReceiving () _receivePong = new AutoResetEvent (false); Action receive = null; - receive = () => - WebSocketFrame.ReadFrameAsync ( - _stream, - false, - frame => { - if (!processReceivedFrame (frame) || _readyState == WebSocketState.Closed) { - var exit = _exitReceiving; - if (exit != null) - exit.Set (); - - return; + receive = + () => + WebSocketFrame.ReadFrameAsync ( + _stream, + false, + frame => { + if (!processReceivedFrame (frame) || _readyState == WebSocketState.Closed) { + var exit = _exitReceiving; + if (exit != null) + exit.Set (); + + return; + } + + // Receive next asap because the Ping or Close needs a response to it. + receive (); + + if (_inMessage || !HasMessage || _readyState != WebSocketState.Open) + return; + + message (); + }, + ex => { + _logger.Fatal (ex.ToString ()); + fatal ("An exception has occurred while receiving.", ex); } - - // Receive next asap because the Ping or Close needs a response to it. - receive (); - - if (_inMessage || !HasMessage || _readyState != WebSocketState.Open) - return; - - message (); - }, - ex => processException (ex, "An exception has occurred while receiving a message.")); + ); receive (); } From 5c008aba1477c397cda51e6b8a580a2d842688dc Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 9 Jan 2016 15:47:02 +0900 Subject: [PATCH 0240/6294] [Modify] Replace it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 30833c28a..f98a433a3 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1168,7 +1168,7 @@ private bool processReceivedFrame (WebSocketFrame frame) { var msg = checkIfValidReceivedFrame (frame); if (msg != null) - return processUnsupportedFrame (frame, CloseStatusCode.ProtocolError, msg); + throw new WebSocketException (CloseStatusCode.ProtocolError, msg); frame.Unmask (); return frame.IsFragment From a2016d543a31a2445d2879910269de8d8833aae2 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 10 Jan 2016 15:39:39 +0900 Subject: [PATCH 0241/6294] [Modify] Replace it --- websocket-sharp/WebSocket.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index f98a433a3..e25fac031 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1181,7 +1181,7 @@ private bool processReceivedFrame (WebSocketFrame frame) ? processPongFrame (frame) : frame.IsClose ? processCloseFrame (frame) - : processUnsupportedFrame (frame, CloseStatusCode.UnsupportedData, null); + : processUnsupportedFrame (frame); } // As server @@ -1209,10 +1209,10 @@ private void processSecWebSocketExtensionsHeader (string value) } } - private bool processUnsupportedFrame (WebSocketFrame frame, CloseStatusCode code, string reason) + private bool processUnsupportedFrame (WebSocketFrame frame) { - _logger.Debug ("An unsupported frame:" + frame.PrintToString (false)); - processException (new WebSocketException (code, reason), null); + _logger.Fatal ("An unsupported frame:" + frame.PrintToString (false)); + fatal ("There is no way to handle it.", null); return false; } From 0d5b7d45538ee6b01a70b95209e5a0f25e48624f Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 11 Jan 2016 17:43:48 +0900 Subject: [PATCH 0242/6294] [Modify] Return bool --- websocket-sharp/WebSocket.cs | 52 +++++++++++++++++++++++++----------- 1 file changed, 36 insertions(+), 16 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index e25fac031..ab901c6d4 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -734,22 +734,42 @@ private string checkIfValidHandshakeResponse (HttpResponse response) : null; } - private string checkIfValidReceivedFrame (WebSocketFrame frame) + private bool checkIfValidReceivedFrame (WebSocketFrame frame, out string message) { + message = null; + var masked = frame.IsMasked; - return _client && masked - ? "A frame from the server is masked." - : !_client && !masked - ? "A frame from a client isn't masked." - : _inContinuation && frame.IsData - ? "A data frame has been received while receiving continuation frames." - : frame.IsCompressed && _compression == CompressionMethod.None - ? "A compressed frame has been received without any agreement for it." - : frame.Rsv2 == Rsv.On - ? "The RSV2 of a frame is non-zero without any negotiation for it." - : frame.Rsv3 == Rsv.On - ? "The RSV3 of a frame is non-zero without any negotiation for it." - : null; + if (_client && masked) { + message = "A frame from the server is masked."; + return false; + } + + if (!_client && !masked) { + message = "A frame from a client isn't masked."; + return false; + } + + if (_inContinuation && frame.IsData) { + message = "A data frame has been received while receiving continuation frames."; + return false; + } + + if (frame.IsCompressed && _compression == CompressionMethod.None) { + message = "A compressed frame has been received without any agreement for it."; + return false; + } + + if (frame.Rsv2 == Rsv.On) { + message = "The RSV2 of a frame is non-zero without any negotiation for it."; + return false; + } + + if (frame.Rsv3 == Rsv.On) { + message = "The RSV3 of a frame is non-zero without any negotiation for it."; + return false; + } + + return true; } private void close (CloseEventArgs e, bool send, bool receive, bool received) @@ -1166,8 +1186,8 @@ private bool processPongFrame (WebSocketFrame frame) private bool processReceivedFrame (WebSocketFrame frame) { - var msg = checkIfValidReceivedFrame (frame); - if (msg != null) + string msg; + if (!checkIfValidReceivedFrame (frame, out msg)) throw new WebSocketException (CloseStatusCode.ProtocolError, msg); frame.Unmask (); From 422be7a2567a8fe9728b2c483f2be7f12ab5a4c3 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 12 Jan 2016 15:02:07 +0900 Subject: [PATCH 0243/6294] [Modify] Replace it --- websocket-sharp/WebSocket.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index ab901c6d4..99ff65c2a 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -848,7 +848,8 @@ private bool connect () } } catch (Exception ex) { - processException (ex, "An exception has occurred while connecting."); + _logger.Fatal (ex.ToString ()); + fatal ("An exception has occurred while connecting.", ex); } return false; From 461d32b0cf116dbbaa74ed3deede3db55dd6587b Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 13 Jan 2016 15:32:16 +0900 Subject: [PATCH 0244/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 99ff65c2a..1122c05d3 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -840,8 +840,8 @@ private bool connect () return false; } + _readyState = WebSocketState.Connecting; try { - _readyState = WebSocketState.Connecting; if (doHandshake ()) { _readyState = WebSocketState.Open; return true; From 8cd6416872dd9c14ea123c179c5c4dab8ed2bac9 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 13 Jan 2016 15:39:42 +0900 Subject: [PATCH 0245/6294] [Modify] Replace it --- websocket-sharp/WebSocket.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 1122c05d3..04e34d5b0 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -653,7 +653,8 @@ private bool accept () } } catch (Exception ex) { - processException (ex, "An exception has occurred while accepting."); + _logger.Fatal (ex.ToString ()); + fatal ("An exception has occurred while accepting.", ex); } return false; From 43fb6368bb28ca4631c5d1e2096e900c53bd9dc2 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 14 Jan 2016 16:02:18 +0900 Subject: [PATCH 0246/6294] [Modify] Replace it --- websocket-sharp/WebSocket.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 04e34d5b0..9e2b66ffc 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1852,7 +1852,8 @@ internal void InternalAccept () } } catch (Exception ex) { - processException (ex, "An exception has occurred while accepting."); + _logger.Fatal (ex.ToString ()); + fatal ("An exception has occurred while accepting.", ex); } } From b3541bc78785a432a5571abafb2d0277b69ef5bb Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 15 Jan 2016 15:07:20 +0900 Subject: [PATCH 0247/6294] [Modify] Remove it --- websocket-sharp/WebSocket.cs | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 9e2b66ffc..09bf6158f 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1118,25 +1118,6 @@ private bool processDataFrame (WebSocketFrame frame) return true; } - private void processException (Exception exception, string message) - { - _logger.Fatal (exception.ToString ()); - if (!_client && _readyState == WebSocketState.Connecting) { - Close (HttpStatusCode.BadRequest); - return; - } - - var code = exception is WebSocketException - ? ((WebSocketException) exception).Code - : CloseStatusCode.Abnormal; - - close ( - new CloseEventArgs (code, message ?? code.GetMessage ()), - !code.IsReserved (), - false, - false); - } - private bool processFragmentFrame (WebSocketFrame frame) { if (!_inContinuation) { From a849b1c73eb312a93723a30fbc9a3c911dacfaca Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 16 Jan 2016 15:36:12 +0900 Subject: [PATCH 0248/6294] [Modify] Replace it --- websocket-sharp/WebSocket.cs | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 09bf6158f..375d51698 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -957,15 +957,8 @@ private bool doHandshake () setClientStream (); var res = sendHandshakeRequest (); var msg = checkIfValidHandshakeResponse (res); - if (msg != null) { - _logger.Error (msg); - - msg = "An error has occurred while connecting."; - error (msg, null); - close (new CloseEventArgs (CloseStatusCode.Abnormal, msg), false, false, false); - - return false; - } + if (msg != null) + throw new WebSocketException (CloseStatusCode.ProtocolError, msg); var cookies = res.Cookies; if (cookies.Count > 0) From 8c58beb2ba4eb244f38c2cdfdd7ff142890845d5 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 17 Jan 2016 16:35:54 +0900 Subject: [PATCH 0249/6294] [Modify] Return bool --- websocket-sharp/WebSocket.cs | 60 +++++++++++++++++++++++++----------- 1 file changed, 42 insertions(+), 18 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 375d51698..083d8b8b1 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -715,24 +715,47 @@ private string checkIfValidHandshakeRequest (WebSocketContext context) } // As client - private string checkIfValidHandshakeResponse (HttpResponse response) + private bool checkIfValidHandshakeResponse (HttpResponse response, out string message) { + message = null; + + if (response.IsRedirect) { + message = "Indicates the redirection."; + return false; + } + + if (response.IsUnauthorized) { + message = "Requires the authentication."; + return false; + } + + if (!response.IsWebSocketResponse) { + message = "Not a WebSocket connection response."; + return false; + } + var headers = response.Headers; - return response.IsRedirect - ? "Indicates the redirection." - : response.IsUnauthorized - ? "Requires the authentication." - : !response.IsWebSocketResponse - ? "Not a WebSocket connection response." - : !validateSecWebSocketAcceptHeader (headers["Sec-WebSocket-Accept"]) - ? "Includes an invalid Sec-WebSocket-Accept header." - : !validateSecWebSocketProtocolHeader (headers["Sec-WebSocket-Protocol"]) - ? "Includes an invalid Sec-WebSocket-Protocol header." - : !validateSecWebSocketExtensionsHeader (headers["Sec-WebSocket-Extensions"]) - ? "Includes an invalid Sec-WebSocket-Extensions header." - : !validateSecWebSocketVersionServerHeader (headers["Sec-WebSocket-Version"]) - ? "Includes an invalid Sec-WebSocket-Version header." - : null; + if (!validateSecWebSocketAcceptHeader (headers["Sec-WebSocket-Accept"])) { + message = "Includes an invalid Sec-WebSocket-Accept header."; + return false; + } + + if (!validateSecWebSocketProtocolHeader (headers["Sec-WebSocket-Protocol"])) { + message = "Includes an invalid Sec-WebSocket-Protocol header."; + return false; + } + + if (!validateSecWebSocketExtensionsHeader (headers["Sec-WebSocket-Extensions"])) { + message = "Includes an invalid Sec-WebSocket-Extensions header."; + return false; + } + + if (!validateSecWebSocketVersionServerHeader (headers["Sec-WebSocket-Version"])) { + message = "Includes an invalid Sec-WebSocket-Version header."; + return false; + } + + return true; } private bool checkIfValidReceivedFrame (WebSocketFrame frame, out string message) @@ -956,8 +979,9 @@ private bool doHandshake () { setClientStream (); var res = sendHandshakeRequest (); - var msg = checkIfValidHandshakeResponse (res); - if (msg != null) + + string msg; + if (!checkIfValidHandshakeResponse (res, out msg)) throw new WebSocketException (CloseStatusCode.ProtocolError, msg); var cookies = res.Cookies; From a11582d104b2bb8751463019aae73402b2cceddc Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 18 Jan 2016 16:10:46 +0900 Subject: [PATCH 0250/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 083d8b8b1..8b277c7a3 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -730,7 +730,7 @@ private bool checkIfValidHandshakeResponse (HttpResponse response, out string me } if (!response.IsWebSocketResponse) { - message = "Not a WebSocket connection response."; + message = "Not a WebSocket handshake response."; return false; } From ae2e23687bc91f345d4a40902859f9bda037b2ba Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 19 Jan 2016 14:44:16 +0900 Subject: [PATCH 0251/6294] [Modify] Replace it --- websocket-sharp/WebSocket.cs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 8b277c7a3..87735b246 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -669,11 +669,8 @@ private bool acceptHandshake () var msg = checkIfValidHandshakeRequest (_context); if (msg != null) { - _logger.Error (msg); - error ("An error has occurred while accepting.", null); - Close (HttpStatusCode.BadRequest); - - return false; + sendHttpResponse (createHandshakeCloseResponse (HttpStatusCode.BadRequest)); + throw new WebSocketException (CloseStatusCode.ProtocolError, msg); } if (_protocol != null && From bcab731cd5b71c3adb8a3d70e3c173149ab653c9 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 20 Jan 2016 15:11:43 +0900 Subject: [PATCH 0252/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 87735b246..3f0b3edd3 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -664,8 +664,7 @@ private bool accept () // As server private bool acceptHandshake () { - _logger.Debug ( - String.Format ("A connection request from {0}:\n{1}", _context.UserEndPoint, _context)); + _logger.Debug (String.Format ("A request from {0}:\n{1}", _context.UserEndPoint, _context)); var msg = checkIfValidHandshakeRequest (_context); if (msg != null) { @@ -673,14 +672,16 @@ private bool acceptHandshake () throw new WebSocketException (CloseStatusCode.ProtocolError, msg); } - if (_protocol != null && - !_context.SecWebSocketProtocols.Contains (protocol => protocol == _protocol)) + if (_protocol != null + && !_context.SecWebSocketProtocols.Contains (protocol => protocol == _protocol) + ) { _protocol = null; + } if (!_ignoreExtensions) { - var exts = _context.Headers["Sec-WebSocket-Extensions"]; - if (exts != null && exts.Length > 0) - processSecWebSocketExtensionsHeader (exts); + var val = _context.Headers["Sec-WebSocket-Extensions"]; + if (val != null && val.Length > 0) + processSecWebSocketExtensionsHeader (val); } return sendHttpResponse (createHandshakeResponse ()); From 00ea73f33152fe41657cd0d5f7c4f1eb0603b2aa Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 21 Jan 2016 15:37:32 +0900 Subject: [PATCH 0253/6294] [Modify] Return bool --- websocket-sharp/WebSocket.cs | 42 +++++++++++++++++++++++++----------- 1 file changed, 30 insertions(+), 12 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 3f0b3edd3..ca34b8b4f 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -666,8 +666,8 @@ private bool acceptHandshake () { _logger.Debug (String.Format ("A request from {0}:\n{1}", _context.UserEndPoint, _context)); - var msg = checkIfValidHandshakeRequest (_context); - if (msg != null) { + string msg; + if (!checkIfValidHandshakeRequest (_context, out msg)) { sendHttpResponse (createHandshakeCloseResponse (HttpStatusCode.BadRequest)); throw new WebSocketException (CloseStatusCode.ProtocolError, msg); } @@ -698,18 +698,36 @@ private string checkIfAvailable ( } // As server - private string checkIfValidHandshakeRequest (WebSocketContext context) + private bool checkIfValidHandshakeRequest (WebSocketContext context, out string message) { + message = null; + + if (context.RequestUri == null) { + message = "Specifies an invalid Request-URI."; + return false; + } + + if (!context.IsWebSocketRequest) { + message = "Not a WebSocket handshake request."; + return false; + } + var headers = context.Headers; - return context.RequestUri == null - ? "Specifies an invalid Request-URI." - : !context.IsWebSocketRequest - ? "Not a WebSocket connection request." - : !validateSecWebSocketKeyHeader (headers["Sec-WebSocket-Key"]) - ? "Includes an invalid Sec-WebSocket-Key header." - : !validateSecWebSocketVersionClientHeader (headers["Sec-WebSocket-Version"]) - ? "Includes an invalid Sec-WebSocket-Version header." - : CustomHandshakeRequestChecker (context); + if (!validateSecWebSocketKeyHeader (headers["Sec-WebSocket-Key"])) { + message = "Includes an invalid Sec-WebSocket-Key header."; + return false; + } + + if (!validateSecWebSocketVersionClientHeader (headers["Sec-WebSocket-Version"])) { + message = "Includes an invalid Sec-WebSocket-Version header."; + return false; + } + + message = CustomHandshakeRequestChecker (context); + if (message != null) + return false; + + return true; } // As client From aff6ffe6b2839e994c15d8f8ee8468a40b4a16ba Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 22 Jan 2016 15:18:16 +0900 Subject: [PATCH 0254/6294] [Modify] Separate it --- websocket-sharp/WebSocket.cs | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index ca34b8b4f..4e59ae641 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -672,6 +672,11 @@ private bool acceptHandshake () throw new WebSocketException (CloseStatusCode.ProtocolError, msg); } + if (!customCheckIfValidHandshakeRequest (_context, out msg)) { + sendHttpResponse (createHandshakeCloseResponse (HttpStatusCode.BadRequest)); + throw new WebSocketException (CloseStatusCode.PolicyViolation, msg); + } + if (_protocol != null && !_context.SecWebSocketProtocols.Contains (protocol => protocol == _protocol) ) { @@ -723,10 +728,6 @@ private bool checkIfValidHandshakeRequest (WebSocketContext context, out string return false; } - message = CustomHandshakeRequestChecker (context); - if (message != null) - return false; - return true; } @@ -984,6 +985,14 @@ private HttpResponse createHandshakeResponse () return ret; } + // As server + private bool customCheckIfValidHandshakeRequest (WebSocketContext context, out string message) + { + message = null; + return _handshakeRequestChecker == null + || (message = _handshakeRequestChecker (context)) == null; + } + private MessageEventArgs dequeueFromMessageEventQueue () { lock (_forMessageEventQueue) From 21d03639739be2b63e246beaf2b80cfabab47919 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 22 Jan 2016 15:51:24 +0900 Subject: [PATCH 0255/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 4e59ae641..27470199b 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -259,7 +259,7 @@ internal CookieCollection CookieCollection { // As server internal Func CustomHandshakeRequestChecker { get { - return _handshakeRequestChecker ?? (context => null); + return _handshakeRequestChecker; } set { From 5230aa68b79246c3db950ec8e7e7416ac3f5bbe4 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 23 Jan 2016 18:00:11 +0900 Subject: [PATCH 0256/6294] [Modify] Add it --- websocket-sharp/WebSocket.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 27470199b..8b6bd03cf 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1046,6 +1046,11 @@ private void fatal (string message, Exception exception) ); } + private void fatal (string message, CloseStatusCode code) + { + close (new CloseEventArgs (code, message), !code.IsReserved (), false, false); + } + private void init () { _compression = CompressionMethod.None; From df7b41c71f648d8c8ca3db27a6fae57781a37fe6 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 24 Jan 2016 15:58:35 +0900 Subject: [PATCH 0257/6294] [Modify] Replace it --- websocket-sharp/WebSocket.cs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 8b6bd03cf..1c479808f 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1038,12 +1038,7 @@ private void fatal (string message, Exception exception) ? ((WebSocketException) exception).Code : CloseStatusCode.Abnormal; - close ( - new CloseEventArgs (code, message ?? code.GetMessage ()), - !code.IsReserved (), - false, - false - ); + fatal (message, code); } private void fatal (string message, CloseStatusCode code) From 978b38fcf4a381456d895afa071352171f56d63c Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 25 Jan 2016 15:22:56 +0900 Subject: [PATCH 0258/6294] [Modify] Replace it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 1c479808f..d91310896 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1257,7 +1257,7 @@ private void processSecWebSocketExtensionsHeader (string value) private bool processUnsupportedFrame (WebSocketFrame frame) { _logger.Fatal ("An unsupported frame:" + frame.PrintToString (false)); - fatal ("There is no way to handle it.", null); + fatal ("There is no way to handle it.", CloseStatusCode.PolicyViolation); return false; } From dcdd283f65c9b4bb59a3e98b224b30d8ab49e5b7 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 26 Jan 2016 16:48:07 +0900 Subject: [PATCH 0259/6294] [Modify] Edit it --- README.md | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 2307a0712..36775c61b 100644 --- a/README.md +++ b/README.md @@ -442,13 +442,15 @@ As a WebSocket server, if you would like to ignore the extensions requested from ```csharp wssv.AddWebSocketService ( "/Chat", - () => new Chat () { - // To ignore the extensions requested from a client. - IgnoreExtensions = true - }); + () => + new Chat () { + // To ignore the extensions requested from a client. + IgnoreExtensions = true + } +); ``` -If it's set to `true`, the server doesn't return the **Sec-WebSocket-Extensions header** in the connection response. +If it's set to `true`, the server doesn't return the **Sec-WebSocket-Extensions** header in its response. I think this is useful when you get something error in connecting the server and exclude the extensions as a cause of the error. From 1556f463d4173e530003bf7094798153cccb1a56 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 27 Jan 2016 16:30:48 +0900 Subject: [PATCH 0260/6294] [Modify] Edit it --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 36775c61b..a8e0f3a66 100644 --- a/README.md +++ b/README.md @@ -533,7 +533,7 @@ using (var ws = new WebSocket ("ws://example.com/?name=nobita")) { } ``` -And if you would like to send the **Origin header** with the WebSocket connection request to the server, you should set the `WebSocket.Origin` property to an allowable value as the [Origin header] before connecting, such as the following. +And if you would like to send the **Origin** header with the WebSocket connection request to the server, you should set the `WebSocket.Origin` property to an allowable value as the [Origin] header before connecting, such as the following. ```csharp ws.Origin = "http://example.com/"; @@ -562,7 +562,7 @@ public class Chat : WebSocketBehavior } ``` -And if you would like to validate the **Origin header**, **Cookies**, or both included in a WebSocket connection request, you should set each validation with your `WebSocketBehavior`, for example, by using the `AddWebSocketService (string, Func)` method with initializing, such as the following. +And if you would like to validate the **Origin** header, **Cookies**, or both included in a WebSocket connection request, you should set each validation with your `WebSocketBehavior`, for example, by using the `AddWebSocketService (string, Func)` method with initializing, such as the following. ```csharp wssv.AddWebSocketService ( @@ -683,7 +683,7 @@ websocket-sharp is provided under **[The MIT License]**. [MonoDevelop]: http://monodevelop.com [NuGet Gallery]: http://www.nuget.org [NuGet Gallery: websocket-sharp]: http://www.nuget.org/packages/WebSocketSharp -[Origin header]: http://tools.ietf.org/html/rfc6454#section-7 +[Origin]: http://tools.ietf.org/html/rfc6454#section-7 [Query]: http://tools.ietf.org/html/rfc3986#section-3.4 [Security Sandbox of the Webplayer]: http://docs.unity3d.com/Manual/SecuritySandbox.html [Squid]: http://www.squid-cache.org From c576b2302cfaf22ce54c521574b063dc1ec51457 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 28 Jan 2016 16:09:45 +0900 Subject: [PATCH 0261/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index d91310896..717af333f 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -683,11 +683,8 @@ private bool acceptHandshake () _protocol = null; } - if (!_ignoreExtensions) { - var val = _context.Headers["Sec-WebSocket-Extensions"]; - if (val != null && val.Length > 0) - processSecWebSocketExtensionsHeader (val); - } + if (!_ignoreExtensions) + processSecWebSocketExtensionsHeader (_context.Headers["Sec-WebSocket-Extensions"]); return sendHttpResponse (createHandshakeResponse ()); } @@ -1232,6 +1229,9 @@ private bool processReceivedFrame (WebSocketFrame frame) // As server private void processSecWebSocketExtensionsHeader (string value) { + if (value == null || value.Length == 0) + return; + var buff = new StringBuilder (80); var comp = false; @@ -1239,10 +1239,13 @@ private void processSecWebSocketExtensionsHeader (string value) var ext = e.Trim (); if (!comp && ext.IsCompressionExtension (CompressionMethod.Deflate)) { _compression = CompressionMethod.Deflate; - var str = _compression.ToExtensionString ( - "client_no_context_takeover", "server_no_context_takeover"); + buff.AppendFormat ( + "{0}, ", + _compression.ToExtensionString ( + "client_no_context_takeover", "server_no_context_takeover" + ) + ); - buff.AppendFormat ("{0}, ", str); comp = true; } } From dcc56fa07156b26d5d588686f27cb138022cb909 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 29 Jan 2016 15:36:08 +0900 Subject: [PATCH 0262/6294] [Modify] Rename it --- websocket-sharp/WebSocket.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 717af333f..ba07bf8f2 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -668,12 +668,12 @@ private bool acceptHandshake () string msg; if (!checkIfValidHandshakeRequest (_context, out msg)) { - sendHttpResponse (createHandshakeCloseResponse (HttpStatusCode.BadRequest)); + sendHttpResponse (createHandshakeFailureResponse (HttpStatusCode.BadRequest)); throw new WebSocketException (CloseStatusCode.ProtocolError, msg); } if (!customCheckIfValidHandshakeRequest (_context, out msg)) { - sendHttpResponse (createHandshakeCloseResponse (HttpStatusCode.BadRequest)); + sendHttpResponse (createHandshakeFailureResponse (HttpStatusCode.BadRequest)); throw new WebSocketException (CloseStatusCode.PolicyViolation, msg); } @@ -916,7 +916,7 @@ private string createExtensions () } // As server - private HttpResponse createHandshakeCloseResponse (HttpStatusCode code) + private HttpResponse createHandshakeFailureResponse (HttpStatusCode code) { var ret = HttpResponse.CreateCloseResponse (code); ret.Headers["Sec-WebSocket-Version"] = _version; @@ -1816,7 +1816,7 @@ internal void Close (HttpResponse response) // As server internal void Close (HttpStatusCode code) { - Close (createHandshakeCloseResponse (code)); + Close (createHandshakeFailureResponse (code)); } // As server From eaaba53442b440fc7d8ca7ad2318e89bd2ae464b Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 30 Jan 2016 16:11:34 +0900 Subject: [PATCH 0263/6294] [Modify] Replace it --- websocket-sharp/WebSocket.cs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index ba07bf8f2..73dc31385 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -677,11 +677,8 @@ private bool acceptHandshake () throw new WebSocketException (CloseStatusCode.PolicyViolation, msg); } - if (_protocol != null - && !_context.SecWebSocketProtocols.Contains (protocol => protocol == _protocol) - ) { - _protocol = null; - } + if (_protocol != null) + processSecWebSocketProtocolHeader (_context.SecWebSocketProtocols); if (!_ignoreExtensions) processSecWebSocketExtensionsHeader (_context.Headers["Sec-WebSocket-Extensions"]); @@ -1257,6 +1254,15 @@ private void processSecWebSocketExtensionsHeader (string value) } } + // As server + private void processSecWebSocketProtocolHeader (IEnumerable values) + { + if (values.Contains (p => p == _protocol)) + return; + + _protocol = null; + } + private bool processUnsupportedFrame (WebSocketFrame frame) { _logger.Fatal ("An unsupported frame:" + frame.PrintToString (false)); From 633d80904bad561a5ae229d930a6fc6db565eafc Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 31 Jan 2016 15:41:47 +0900 Subject: [PATCH 0264/6294] [Modify] Move it --- websocket-sharp/WebSocket.cs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 73dc31385..f968d2ba3 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -677,6 +677,8 @@ private bool acceptHandshake () throw new WebSocketException (CloseStatusCode.PolicyViolation, msg); } + _base64Key = _context.Headers["Sec-WebSocket-Key"]; + if (_protocol != null) processSecWebSocketProtocolHeader (_context.SecWebSocketProtocols); @@ -1712,11 +1714,7 @@ private bool validateSecWebSocketExtensionsHeader (string value) // As server private bool validateSecWebSocketKeyHeader (string value) { - if (value == null || value.Length == 0) - return false; - - _base64Key = value; - return true; + return value != null && value.Length > 0; } // As client From 1b1582e0d7bc14d270ef7205e3c9e7c235140c69 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 1 Feb 2016 15:39:16 +0900 Subject: [PATCH 0265/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index f968d2ba3..e45ab5246 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -715,7 +715,7 @@ private bool checkIfValidHandshakeRequest (WebSocketContext context, out string var headers = context.Headers; if (!validateSecWebSocketKeyHeader (headers["Sec-WebSocket-Key"])) { - message = "Includes an invalid Sec-WebSocket-Key header."; + message = "Includes no Sec-WebSocket-Key header, or it has an invalid value."; return false; } From a1abb054f6a77842d543bdf088c60d83a764e2ab Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 1 Feb 2016 15:48:24 +0900 Subject: [PATCH 0266/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index e45ab5246..3b6f2d4e3 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -720,7 +720,7 @@ private bool checkIfValidHandshakeRequest (WebSocketContext context, out string } if (!validateSecWebSocketVersionClientHeader (headers["Sec-WebSocket-Version"])) { - message = "Includes an invalid Sec-WebSocket-Version header."; + message = "Includes no Sec-WebSocket-Version header, or it has an invalid value."; return false; } From 008ccc3fec5743e8469b2fe4e1eb8dd3680d3e76 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 2 Feb 2016 15:24:52 +0900 Subject: [PATCH 0267/6294] [Modify] Rename it --- websocket-sharp/WebSocket.cs | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 3b6f2d4e3..576928125 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -667,7 +667,7 @@ private bool acceptHandshake () _logger.Debug (String.Format ("A request from {0}:\n{1}", _context.UserEndPoint, _context)); string msg; - if (!checkIfValidHandshakeRequest (_context, out msg)) { + if (!checkHandshakeRequest (_context, out msg)) { sendHttpResponse (createHandshakeFailureResponse (HttpStatusCode.BadRequest)); throw new WebSocketException (CloseStatusCode.ProtocolError, msg); } @@ -688,18 +688,8 @@ private bool acceptHandshake () return sendHttpResponse (createHandshakeResponse ()); } - private string checkIfAvailable ( - bool client, bool server, bool connecting, bool open, bool closing, bool closed) - { - return !client && _client - ? "This operation isn't available in: client" - : !server && !_client - ? "This operation isn't available in: server" - : _readyState.CheckIfAvailable (connecting, open, closing, closed); - } - // As server - private bool checkIfValidHandshakeRequest (WebSocketContext context, out string message) + private bool checkHandshakeRequest (WebSocketContext context, out string message) { message = null; @@ -727,6 +717,16 @@ private bool checkIfValidHandshakeRequest (WebSocketContext context, out string return true; } + private string checkIfAvailable ( + bool client, bool server, bool connecting, bool open, bool closing, bool closed) + { + return !client && _client + ? "This operation isn't available in: client" + : !server && !_client + ? "This operation isn't available in: server" + : _readyState.CheckIfAvailable (connecting, open, closing, closed); + } + // As client private bool checkIfValidHandshakeResponse (HttpResponse response, out string message) { From 465dbb091afec2e7089c6abf970ef2b2469dbac2 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 3 Feb 2016 15:31:39 +0900 Subject: [PATCH 0268/6294] [Modify] Rename it --- websocket-sharp/WebSocket.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 576928125..68a6df209 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -672,7 +672,7 @@ private bool acceptHandshake () throw new WebSocketException (CloseStatusCode.ProtocolError, msg); } - if (!customCheckIfValidHandshakeRequest (_context, out msg)) { + if (!customCheckHandshakeRequest (_context, out msg)) { sendHttpResponse (createHandshakeFailureResponse (HttpStatusCode.BadRequest)); throw new WebSocketException (CloseStatusCode.PolicyViolation, msg); } @@ -982,7 +982,7 @@ private HttpResponse createHandshakeResponse () } // As server - private bool customCheckIfValidHandshakeRequest (WebSocketContext context, out string message) + private bool customCheckHandshakeRequest (WebSocketContext context, out string message) { message = null; return _handshakeRequestChecker == null From fccc4d8bec89a232d45003a46b11579625ea17a7 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 4 Feb 2016 15:05:23 +0900 Subject: [PATCH 0269/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketBehavior.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 5ae6c8f6e..57690f360 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -4,7 +4,7 @@ * * The MIT License * - * Copyright (c) 2012-2015 sta.blockhead + * Copyright (c) 2012-2016 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -297,10 +297,10 @@ public WebSocketState State { private string checkIfValidConnectionRequest (WebSocketContext context) { return _originValidator != null && !_originValidator (context.Origin) - ? "Invalid Origin header." - : _cookiesValidator != null && - !_cookiesValidator (context.CookieCollection, context.WebSocket.CookieCollection) - ? "Invalid Cookies." + ? "Includes no Origin header, or it has an invalid value." + : _cookiesValidator != null + && !_cookiesValidator (context.CookieCollection, context.WebSocket.CookieCollection) + ? "Includes no cookie, or an invalid cookie exists." : null; } From efcf714a5f9da528747caa2ebdca0b3c7fb86d57 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 5 Feb 2016 15:11:41 +0900 Subject: [PATCH 0270/6294] [Modify] Rename it --- websocket-sharp/Server/WebSocketBehavior.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 57690f360..653f978a5 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -294,7 +294,7 @@ public WebSocketState State { #region Private Methods - private string checkIfValidConnectionRequest (WebSocketContext context) + private string checkHandshakeRequest (WebSocketContext context) { return _originValidator != null && !_originValidator (context.Origin) ? "Includes no Origin header, or it has an invalid value." @@ -352,7 +352,7 @@ internal void Start (WebSocketContext context, WebSocketSessionManager sessions) _sessions = sessions; _websocket = context.WebSocket; - _websocket.CustomHandshakeRequestChecker = checkIfValidConnectionRequest; + _websocket.CustomHandshakeRequestChecker = checkHandshakeRequest; _websocket.EmitOnPing = _emitOnPing; _websocket.IgnoreExtensions = _ignoreExtensions; _websocket.Protocol = _protocol; From f23a7a39e7da20547fb9bcc5c94d02f2b2186cc5 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 6 Feb 2016 16:04:46 +0900 Subject: [PATCH 0271/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketBehavior.cs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 653f978a5..aab21c8ff 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -116,18 +116,24 @@ public WebSocketContext Context { /// /// Gets or sets the delegate called to validate the HTTP cookies included in - /// a connection request to the WebSocket service. + /// a handshake request to the WebSocket service. /// /// /// This delegate is called when the used in a session validates - /// the connection request. + /// the handshake request. /// /// /// /// A Func<CookieCollection, CookieCollection, bool> delegate that references - /// the method(s) used to validate the cookies. 1st passed to - /// this delegate contains the cookies to validate if any. 2nd - /// passed to this delegate receives the cookies to send to the client. + /// the method(s) used to validate the cookies. + /// + /// + /// 1st parameter passed to this delegate contains + /// the cookies to validate if any. + /// + /// + /// 2nd parameter passed to this delegate receives + /// the cookies to send to the client. /// /// /// This delegate should return true if the cookies are valid. From f7ce165e7b89cfd358dded17289e3fbbf890d70b Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 7 Feb 2016 16:17:22 +0900 Subject: [PATCH 0272/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketBehavior.cs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index aab21c8ff..d99bc4c5a 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -208,16 +208,19 @@ public bool IgnoreExtensions { /// /// Gets or sets the delegate called to validate the Origin header included in - /// a connection request to the WebSocket service. + /// a handshake request to the WebSocket service. /// /// /// This delegate is called when the used in a session validates - /// the connection request. + /// the handshake request. /// /// /// - /// A Func<string, bool> delegate that references the method(s) used to validate - /// the origin header. A passed to this delegate represents the value of + /// A Func<string, bool> delegate that references the method(s) used to + /// validate the origin header. + /// + /// + /// parameter passed to this delegate represents the value of /// the origin header to validate if any. /// /// From b9e0980a5e36b7c7e5c5e24c4725dab9fb7810d4 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 8 Feb 2016 16:23:54 +0900 Subject: [PATCH 0273/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketBehavior.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index d99bc4c5a..71febd7f3 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -102,10 +102,10 @@ protected WebSocketSessionManager Sessions { #region Public Properties /// - /// Gets the information in a connection request to the WebSocket service. + /// Gets the information in a handshake request to the WebSocket service. /// /// - /// A that provides the access to the connection request, + /// A instance that provides the access to the handshake request, /// or if the WebSocket connection isn't established. /// public WebSocketContext Context { @@ -190,11 +190,11 @@ public string ID { /// /// Gets or sets a value indicating whether the WebSocket service ignores - /// the Sec-WebSocket-Extensions header included in a connection request. + /// the Sec-WebSocket-Extensions header included in a handshake request. /// /// - /// true if the WebSocket service ignores the extensions; - /// otherwise, false. The default value is false. + /// true if the WebSocket service ignores the extensions requested from + /// a client; otherwise, false. The default value is false. /// public bool IgnoreExtensions { get { From c015c3bd376bb1888f2fd9caaf80b45743ab7c05 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 9 Feb 2016 14:53:19 +0900 Subject: [PATCH 0274/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 68a6df209..cb42a2238 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -749,7 +749,7 @@ private bool checkIfValidHandshakeResponse (HttpResponse response, out string me var headers = response.Headers; if (!validateSecWebSocketAcceptHeader (headers["Sec-WebSocket-Accept"])) { - message = "Includes an invalid Sec-WebSocket-Accept header."; + message = "Includes no Sec-WebSocket-Accept header, or it has an invalid value."; return false; } From 83f7f4ec8a40dbe12b827532f0c5ec3425c2db56 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 9 Feb 2016 15:49:06 +0900 Subject: [PATCH 0275/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index cb42a2238..2b0705298 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -754,7 +754,7 @@ private bool checkIfValidHandshakeResponse (HttpResponse response, out string me } if (!validateSecWebSocketProtocolHeader (headers["Sec-WebSocket-Protocol"])) { - message = "Includes an invalid Sec-WebSocket-Protocol header."; + message = "Includes no Sec-WebSocket-Protocol header, or it has an invalid value."; return false; } @@ -1723,7 +1723,10 @@ private bool validateSecWebSocketProtocolHeader (string value) if (value == null) return _protocols == null; - if (_protocols == null || !_protocols.Contains (protocol => protocol == value)) + if (value.Length == 0) + return false; + + if (_protocols == null || !_protocols.Contains (p => p == value)) return false; _protocol = value; From 2ca4c4592c7a34a12ad646911c03399a00a09990 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 10 Feb 2016 14:59:43 +0900 Subject: [PATCH 0276/6294] [Modify] Move it --- websocket-sharp/WebSocket.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 2b0705298..ad23dbbf0 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1005,6 +1005,9 @@ private bool doHandshake () if (!checkIfValidHandshakeResponse (res, out msg)) throw new WebSocketException (CloseStatusCode.ProtocolError, msg); + if (_protocols != null) + _protocol = res.Headers["Sec-WebSocket-Protocol"]; + var cookies = res.Cookies; if (cookies.Count > 0) _cookies.SetOrRemove (cookies); @@ -1729,7 +1732,6 @@ private bool validateSecWebSocketProtocolHeader (string value) if (_protocols == null || !_protocols.Contains (p => p == value)) return false; - _protocol = value; return true; } From 2abe20eb0809e8d8403cf91da9126703caa8c4da Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 10 Feb 2016 16:25:02 +0900 Subject: [PATCH 0277/6294] [Modify] Add it --- websocket-sharp/WebSocket.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index ad23dbbf0..546b744a4 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1259,6 +1259,17 @@ private void processSecWebSocketExtensionsHeader (string value) } } + // As client + private void processSecWebSocketExtensionsServerHeader (string value) + { + if (value == null) { + _compression = CompressionMethod.None; + return; + } + + _extensions = value; + } + // As server private void processSecWebSocketProtocolHeader (IEnumerable values) { From 7146f6e1da0cd2990d6ae6d65908c9486969ed05 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 10 Feb 2016 16:33:58 +0900 Subject: [PATCH 0278/6294] [Modify] Add it --- websocket-sharp/WebSocket.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 546b744a4..de8d735f2 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -267,6 +267,13 @@ internal Func CustomHandshakeRequestChecker { } } + // As client + internal bool ExtensionsRequested { + get { + return _compression != CompressionMethod.None; + } + } + internal bool HasMessage { get { lock (_forMessageEventQueue) From 60eae92f3023063ad53a756dc52482ca5087e3cb Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 11 Feb 2016 17:25:15 +0900 Subject: [PATCH 0279/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index de8d735f2..0531c51f5 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1015,6 +1015,9 @@ private bool doHandshake () if (_protocols != null) _protocol = res.Headers["Sec-WebSocket-Protocol"]; + if (ExtensionsRequested) + processSecWebSocketExtensionsServerHeader (res.Headers["Sec-WebSocket-Extensions"]); + var cookies = res.Cookies; if (cookies.Count > 0) _cookies.SetOrRemove (cookies); @@ -1689,20 +1692,19 @@ private bool validateSecWebSocketAcceptHeader (string value) // As client private bool validateSecWebSocketExtensionsHeader (string value) { - var comp = _compression != CompressionMethod.None; - if (value == null || value.Length == 0) { - if (comp) - _compression = CompressionMethod.None; - + if (value == null) return true; - } - if (!comp) + if (value.Length == 0) + return false; + + if (!ExtensionsRequested) return false; + var comp = _compression != CompressionMethod.None; foreach (var e in value.SplitHeaderValue (',')) { var ext = e.Trim (); - if (ext.IsCompressionExtension (_compression)) { + if (comp && ext.IsCompressionExtension (_compression)) { if (!ext.Contains ("server_no_context_takeover")) { _logger.Error ("The server hasn't sent back 'server_no_context_takeover'."); return false; @@ -1712,13 +1714,15 @@ private bool validateSecWebSocketExtensionsHeader (string value) _logger.Warn ("The server hasn't sent back 'client_no_context_takeover'."); var method = _compression.ToExtensionString (); - var invalid = ext.SplitHeaderValue (';').Contains ( - t => { - t = t.Trim (); - return t != method && - t != "server_no_context_takeover" && - t != "client_no_context_takeover"; - }); + var invalid = + ext.SplitHeaderValue (';').Contains ( + t => { + t = t.Trim (); + return t != method + && t != "server_no_context_takeover" + && t != "client_no_context_takeover"; + } + ); if (invalid) return false; @@ -1728,7 +1732,6 @@ private bool validateSecWebSocketExtensionsHeader (string value) } } - _extensions = value; return true; } From 1ee1139da890a1cf825b1dd4b21c0faf506c3cb7 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 12 Feb 2016 14:43:43 +0900 Subject: [PATCH 0280/6294] [Modify] Replace it --- websocket-sharp/WebSocket.cs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 0531c51f5..adab3d14c 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1018,9 +1018,7 @@ private bool doHandshake () if (ExtensionsRequested) processSecWebSocketExtensionsServerHeader (res.Headers["Sec-WebSocket-Extensions"]); - var cookies = res.Cookies; - if (cookies.Count > 0) - _cookies.SetOrRemove (cookies); + processCookies (res.Cookies); return true; } @@ -1158,6 +1156,15 @@ private bool processCloseFrame (WebSocketFrame frame) return false; } + // As client + private void processCookies (CookieCollection cookies) + { + if (cookies.Count == 0) + return; + + _cookies.SetOrRemove (cookies); + } + private bool processDataFrame (WebSocketFrame frame) { enqueueToMessageEventQueue ( From 47eeb50a77da5acfe943c5b8d800053c726e7dc4 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 12 Feb 2016 15:01:18 +0900 Subject: [PATCH 0281/6294] [Modify] Replace it --- websocket-sharp/WebSocket.cs | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index adab3d14c..141ac6976 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -80,6 +80,7 @@ public class WebSocket : IDisposable private bool _enableRedirection; private AutoResetEvent _exitReceiving; private string _extensions; + private bool _extensionsRequested; private object _forConn; private object _forMessageEventQueue; private object _forSend; @@ -267,13 +268,6 @@ internal Func CustomHandshakeRequestChecker { } } - // As client - internal bool ExtensionsRequested { - get { - return _compression != CompressionMethod.None; - } - } - internal bool HasMessage { get { lock (_forMessageEventQueue) @@ -944,9 +938,9 @@ private HttpRequest createHandshakeRequest () if (_protocols != null) headers["Sec-WebSocket-Protocol"] = _protocols.ToString (", "); - var exts = createExtensions (); - if (exts != null) - headers["Sec-WebSocket-Extensions"] = exts; + _extensionsRequested = _compression != CompressionMethod.None; + if (_extensionsRequested) + headers["Sec-WebSocket-Extensions"] = createExtensions (); headers["Sec-WebSocket-Version"] = _version; @@ -1015,7 +1009,7 @@ private bool doHandshake () if (_protocols != null) _protocol = res.Headers["Sec-WebSocket-Protocol"]; - if (ExtensionsRequested) + if (_extensionsRequested) processSecWebSocketExtensionsServerHeader (res.Headers["Sec-WebSocket-Extensions"]); processCookies (res.Cookies); @@ -1705,7 +1699,7 @@ private bool validateSecWebSocketExtensionsHeader (string value) if (value.Length == 0) return false; - if (!ExtensionsRequested) + if (!_extensionsRequested) return false; var comp = _compression != CompressionMethod.None; From a520733ba2e66ffdf10a99eceed5b941e50fcd9f Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 12 Feb 2016 15:17:40 +0900 Subject: [PATCH 0282/6294] [Modify] Replace it --- websocket-sharp/WebSocket.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 141ac6976..90e42ed53 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -100,6 +100,7 @@ public class WebSocket : IDisposable private bool _preAuth; private string _protocol; private string[] _protocols; + private bool _protocolsRequested; private NetworkCredential _proxyCredentials; private Uri _proxyUri; private volatile WebSocketState _readyState; @@ -935,7 +936,8 @@ private HttpRequest createHandshakeRequest () headers["Sec-WebSocket-Key"] = _base64Key; - if (_protocols != null) + _protocolsRequested = _protocols != null; + if (_protocolsRequested) headers["Sec-WebSocket-Protocol"] = _protocols.ToString (", "); _extensionsRequested = _compression != CompressionMethod.None; @@ -1006,7 +1008,7 @@ private bool doHandshake () if (!checkIfValidHandshakeResponse (res, out msg)) throw new WebSocketException (CloseStatusCode.ProtocolError, msg); - if (_protocols != null) + if (_protocolsRequested) _protocol = res.Headers["Sec-WebSocket-Protocol"]; if (_extensionsRequested) @@ -1746,12 +1748,12 @@ private bool validateSecWebSocketKeyHeader (string value) private bool validateSecWebSocketProtocolHeader (string value) { if (value == null) - return _protocols == null; + return !_protocolsRequested; if (value.Length == 0) return false; - if (_protocols == null || !_protocols.Contains (p => p == value)) + if (!_protocolsRequested || !_protocols.Contains (p => p == value)) return false; return true; From b5af31a756008853f55d4317370219a2e3d02cfb Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 13 Feb 2016 16:00:13 +0900 Subject: [PATCH 0283/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 90e42ed53..b7fd69be8 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1753,10 +1753,7 @@ private bool validateSecWebSocketProtocolHeader (string value) if (value.Length == 0) return false; - if (!_protocolsRequested || !_protocols.Contains (p => p == value)) - return false; - - return true; + return _protocolsRequested && _protocols.Contains (p => p == value); } // As server From d56b9bfef8a43a00bde283ce052da1917949d20e Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 14 Feb 2016 16:16:20 +0900 Subject: [PATCH 0284/6294] [Modify] Rename it --- websocket-sharp/WebSocket.cs | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index b7fd69be8..21df704b5 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -719,18 +719,8 @@ private bool checkHandshakeRequest (WebSocketContext context, out string message return true; } - private string checkIfAvailable ( - bool client, bool server, bool connecting, bool open, bool closing, bool closed) - { - return !client && _client - ? "This operation isn't available in: client" - : !server && !_client - ? "This operation isn't available in: server" - : _readyState.CheckIfAvailable (connecting, open, closing, closed); - } - // As client - private bool checkIfValidHandshakeResponse (HttpResponse response, out string message) + private bool checkHandshakeResponse (HttpResponse response, out string message) { message = null; @@ -773,6 +763,16 @@ private bool checkIfValidHandshakeResponse (HttpResponse response, out string me return true; } + private string checkIfAvailable ( + bool client, bool server, bool connecting, bool open, bool closing, bool closed) + { + return !client && _client + ? "This operation isn't available in: client" + : !server && !_client + ? "This operation isn't available in: server" + : _readyState.CheckIfAvailable (connecting, open, closing, closed); + } + private bool checkIfValidReceivedFrame (WebSocketFrame frame, out string message) { message = null; @@ -1005,7 +1005,7 @@ private bool doHandshake () var res = sendHandshakeRequest (); string msg; - if (!checkIfValidHandshakeResponse (res, out msg)) + if (!checkHandshakeResponse (res, out msg)) throw new WebSocketException (CloseStatusCode.ProtocolError, msg); if (_protocolsRequested) From 810befd904f59a811c878ce11fc02354b8403d08 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 15 Feb 2016 15:06:20 +0900 Subject: [PATCH 0285/6294] [Modify] Rename it --- websocket-sharp/WebSocket.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 21df704b5..b1dab66cf 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -773,7 +773,7 @@ private string checkIfAvailable ( : _readyState.CheckIfAvailable (connecting, open, closing, closed); } - private bool checkIfValidReceivedFrame (WebSocketFrame frame, out string message) + private bool checkReceivedFrame (WebSocketFrame frame, out string message) { message = null; @@ -1224,7 +1224,7 @@ private bool processPongFrame (WebSocketFrame frame) private bool processReceivedFrame (WebSocketFrame frame) { string msg; - if (!checkIfValidReceivedFrame (frame, out msg)) + if (!checkReceivedFrame (frame, out msg)) throw new WebSocketException (CloseStatusCode.ProtocolError, msg); frame.Unmask (); From 3c94369a96edc8844fc73f0edde2e885181fb6cb Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 16 Feb 2016 14:46:39 +0900 Subject: [PATCH 0286/6294] [Modify] Add it --- websocket-sharp/WebSocket.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index b1dab66cf..382292d94 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -716,6 +716,11 @@ private bool checkHandshakeRequest (WebSocketContext context, out string message return false; } + if (!validateSecWebSocketProtocolClientHeader (headers["Sec-WebSocket-Protocol"])) { + message = "Includes an invalid Sec-WebSocket-Protocol header."; + return false; + } + return true; } @@ -1744,6 +1749,12 @@ private bool validateSecWebSocketKeyHeader (string value) return value != null && value.Length > 0; } + // As server + private bool validateSecWebSocketProtocolClientHeader (string value) + { + return value == null || value.Length > 0; + } + // As client private bool validateSecWebSocketProtocolHeader (string value) { From 7e0e992b594f97e983ae04a497f4000ae9fbbf9a Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 16 Feb 2016 14:56:24 +0900 Subject: [PATCH 0287/6294] [Modify] Rename it --- websocket-sharp/WebSocket.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 382292d94..d342d475b 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -750,7 +750,7 @@ private bool checkHandshakeResponse (HttpResponse response, out string message) return false; } - if (!validateSecWebSocketProtocolHeader (headers["Sec-WebSocket-Protocol"])) { + if (!validateSecWebSocketProtocolServerHeader (headers["Sec-WebSocket-Protocol"])) { message = "Includes no Sec-WebSocket-Protocol header, or it has an invalid value."; return false; } @@ -1756,7 +1756,7 @@ private bool validateSecWebSocketProtocolClientHeader (string value) } // As client - private bool validateSecWebSocketProtocolHeader (string value) + private bool validateSecWebSocketProtocolServerHeader (string value) { if (value == null) return !_protocolsRequested; From 5596be71bb8fd5e87a56f519de35794a350bf7cc Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 17 Feb 2016 15:12:52 +0900 Subject: [PATCH 0288/6294] [Modify] Add it --- websocket-sharp/WebSocket.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index d342d475b..abc7e3a4a 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -721,6 +721,13 @@ private bool checkHandshakeRequest (WebSocketContext context, out string message return false; } + if (!_ignoreExtensions + && !validateSecWebSocketExtensionsClientHeader (headers["Sec-WebSocket-Extensions"]) + ) { + message = "Includes an invalid Sec-WebSocket-Extensions header."; + return false; + } + return true; } @@ -1697,6 +1704,12 @@ private bool validateSecWebSocketAcceptHeader (string value) return value != null && value == CreateResponseKey (_base64Key); } + // As server + private bool validateSecWebSocketExtensionsClientHeader (string value) + { + return value == null || value.Length > 0; + } + // As client private bool validateSecWebSocketExtensionsHeader (string value) { From 48e5ce79cbf3dff95494dc52c14ffd8fb484e0a7 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 17 Feb 2016 15:21:00 +0900 Subject: [PATCH 0289/6294] [Modify] Rename it --- websocket-sharp/WebSocket.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index abc7e3a4a..ff2c17414 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -762,7 +762,7 @@ private bool checkHandshakeResponse (HttpResponse response, out string message) return false; } - if (!validateSecWebSocketExtensionsHeader (headers["Sec-WebSocket-Extensions"])) { + if (!validateSecWebSocketExtensionsServerHeader (headers["Sec-WebSocket-Extensions"])) { message = "Includes an invalid Sec-WebSocket-Extensions header."; return false; } @@ -1711,7 +1711,7 @@ private bool validateSecWebSocketExtensionsClientHeader (string value) } // As client - private bool validateSecWebSocketExtensionsHeader (string value) + private bool validateSecWebSocketExtensionsServerHeader (string value) { if (value == null) return true; From eb7900bc2b2f5a8e0b279050446e77b498233f63 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 18 Feb 2016 14:48:43 +0900 Subject: [PATCH 0290/6294] [Modify] Remove it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index ff2c17414..9a369c938 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1256,7 +1256,7 @@ private bool processReceivedFrame (WebSocketFrame frame) // As server private void processSecWebSocketExtensionsHeader (string value) { - if (value == null || value.Length == 0) + if (value == null) return; var buff = new StringBuilder (80); From 944972c8bb3e494aae9b69a20501f0a0b6dcd1a4 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 18 Feb 2016 14:52:01 +0900 Subject: [PATCH 0291/6294] [Modify] Rename it --- websocket-sharp/WebSocket.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 9a369c938..0b4cb4db3 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -685,7 +685,7 @@ private bool acceptHandshake () processSecWebSocketProtocolHeader (_context.SecWebSocketProtocols); if (!_ignoreExtensions) - processSecWebSocketExtensionsHeader (_context.Headers["Sec-WebSocket-Extensions"]); + processSecWebSocketExtensionsClientHeader (_context.Headers["Sec-WebSocket-Extensions"]); return sendHttpResponse (createHandshakeResponse ()); } @@ -1254,7 +1254,7 @@ private bool processReceivedFrame (WebSocketFrame frame) } // As server - private void processSecWebSocketExtensionsHeader (string value) + private void processSecWebSocketExtensionsClientHeader (string value) { if (value == null) return; From 07f85d67644e66919e26c2f422415f48ec2e77b5 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 19 Feb 2016 15:19:57 +0900 Subject: [PATCH 0292/6294] [Modify] Don't throw --- websocket-sharp/WebSocket.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 0b4cb4db3..13d04d8df 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1017,8 +1017,12 @@ private bool doHandshake () var res = sendHandshakeRequest (); string msg; - if (!checkHandshakeResponse (res, out msg)) - throw new WebSocketException (CloseStatusCode.ProtocolError, msg); + if (!checkHandshakeResponse (res, out msg)) { + _logger.Fatal (msg); + fatal ("An error has occurred while connecting.", CloseStatusCode.ProtocolError); + + return false; + } if (_protocolsRequested) _protocol = res.Headers["Sec-WebSocket-Protocol"]; From 88b182083c7283a3cc370a5cf7fae3ea7c182155 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 20 Feb 2016 15:41:27 +0900 Subject: [PATCH 0293/6294] [Modify] Don't throw --- websocket-sharp/WebSocket.cs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 13d04d8df..b455fea2d 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -671,12 +671,20 @@ private bool acceptHandshake () string msg; if (!checkHandshakeRequest (_context, out msg)) { sendHttpResponse (createHandshakeFailureResponse (HttpStatusCode.BadRequest)); - throw new WebSocketException (CloseStatusCode.ProtocolError, msg); + + _logger.Fatal (msg); + fatal ("An error has occurred while accepting.", CloseStatusCode.ProtocolError); + + return false; } if (!customCheckHandshakeRequest (_context, out msg)) { sendHttpResponse (createHandshakeFailureResponse (HttpStatusCode.BadRequest)); - throw new WebSocketException (CloseStatusCode.PolicyViolation, msg); + + _logger.Fatal (msg); + fatal ("An error has occurred while accepting.", CloseStatusCode.PolicyViolation); + + return false; } _base64Key = _context.Headers["Sec-WebSocket-Key"]; From 2befe83d7ddb4d731f6240c05263fe0be25cb78e Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 21 Feb 2016 15:40:52 +0900 Subject: [PATCH 0294/6294] [Modify] Polish it --- websocket-sharp/Net/AuthenticationSchemes.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/websocket-sharp/Net/AuthenticationSchemes.cs b/websocket-sharp/Net/AuthenticationSchemes.cs index af0efb170..e8cd49571 100644 --- a/websocket-sharp/Net/AuthenticationSchemes.cs +++ b/websocket-sharp/Net/AuthenticationSchemes.cs @@ -2,13 +2,13 @@ /* * AuthenticationSchemes.cs * - * This code is derived from System.Net.AuthenticationSchemes.cs of Mono + * This code is derived from AuthenticationSchemes.cs (System.Net) of Mono * (http://www.mono-project.com). * * The MIT License * * Copyright (c) 2005 Novell, Inc. (http://www.novell.com) - * Copyright (c) 2012-2014 sta.blockhead + * Copyright (c) 2012-2016 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -42,25 +42,25 @@ namespace WebSocketSharp.Net { /// - /// Contains the values of the schemes for authentication. + /// Specifies the scheme for authentication. /// [Flags] public enum AuthenticationSchemes { /// - /// Indicates that no authentication is allowed. + /// No authentication is allowed. /// None, /// - /// Indicates digest authentication. + /// Specifies digest authentication. /// Digest = 1, /// - /// Indicates basic authentication. + /// Specifies basic authentication. /// Basic = 8, /// - /// Indicates anonymous authentication. + /// Specifies anonymous authentication. /// Anonymous = 0x8000 } From c128ea7b7beaf6f19de30171ac4dc6de2e31224c Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 22 Feb 2016 15:14:25 +0900 Subject: [PATCH 0295/6294] [Fix] Remove it Fix for issue #217. --- websocket-sharp/Net/AuthenticationSchemes.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/websocket-sharp/Net/AuthenticationSchemes.cs b/websocket-sharp/Net/AuthenticationSchemes.cs index e8cd49571..ab7721a15 100644 --- a/websocket-sharp/Net/AuthenticationSchemes.cs +++ b/websocket-sharp/Net/AuthenticationSchemes.cs @@ -44,7 +44,6 @@ namespace WebSocketSharp.Net /// /// Specifies the scheme for authentication. /// - [Flags] public enum AuthenticationSchemes { /// From 437896fc9c63749d47c63befe8e3f64c6c4520ba Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 23 Feb 2016 15:20:13 +0900 Subject: [PATCH 0296/6294] [Modify] Add it --- websocket-sharp/WebSocket.cs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index b455fea2d..7b84acd74 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -793,6 +793,23 @@ private string checkIfAvailable ( : _readyState.CheckIfAvailable (connecting, open, closing, closed); } + private bool checkIfAvailable (bool client, bool server, out string message) + { + message = null; + + if (!client && _client) { + message = "This operation isn't available in: client"; + return false; + } + + if (!server && !_client) { + message = "This operation isn't available in: server"; + return false; + } + + return true; + } + private bool checkReceivedFrame (WebSocketFrame frame, out string message) { message = null; From f8955042f717a5c942deb7e612b7b62129347be1 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 24 Feb 2016 16:19:09 +0900 Subject: [PATCH 0297/6294] [Modify] Add it --- websocket-sharp/WebSocket.cs | 45 ++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 7b84acd74..ea1a19b3d 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -810,6 +810,51 @@ private bool checkIfAvailable (bool client, bool server, out string message) return true; } + private bool checkIfAvailable ( + bool client, + bool server, + bool connecting, + bool open, + bool closing, + bool closed, + out string message + ) + { + message = null; + + if (!client && _client) { + message = "This operation isn't available in: client"; + return false; + } + + if (!server && !_client) { + message = "This operation isn't available in: server"; + return false; + } + + if (!connecting && _readyState == WebSocketState.Connecting) { + message = "This operation isn't available in: connecting"; + return false; + } + + if (!open && _readyState == WebSocketState.Open) { + message = "This operation isn't available in: open"; + return false; + } + + if (!closing && _readyState == WebSocketState.Closing) { + message = "This operation isn't available in: closing"; + return false; + } + + if (!closed && _readyState == WebSocketState.Closed) { + message = "This operation isn't available in: closed"; + return false; + } + + return true; + } + private bool checkReceivedFrame (WebSocketFrame frame, out string message) { message = null; From e8cafc37c2aaddcbe6ce31aa99b73cc02ddb07ee Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 24 Feb 2016 16:24:25 +0900 Subject: [PATCH 0298/6294] [Modify] Add it --- websocket-sharp/WebSocket.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index ea1a19b3d..56264c457 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -810,6 +810,13 @@ private bool checkIfAvailable (bool client, bool server, out string message) return true; } + private bool checkIfAvailable ( + bool connecting, bool open, bool closing, bool closed, out string message + ) + { + return checkIfAvailable (true, true, connecting, open, closing, closed, out message); + } + private bool checkIfAvailable ( bool client, bool server, From fcb4b6604e67fd8a7586b65c1c6d87eccbda1c92 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 24 Feb 2016 16:27:11 +0900 Subject: [PATCH 0299/6294] [Modify] Remove it --- websocket-sharp/WebSocket.cs | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 56264c457..105750b25 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -793,23 +793,6 @@ private string checkIfAvailable ( : _readyState.CheckIfAvailable (connecting, open, closing, closed); } - private bool checkIfAvailable (bool client, bool server, out string message) - { - message = null; - - if (!client && _client) { - message = "This operation isn't available in: client"; - return false; - } - - if (!server && !_client) { - message = "This operation isn't available in: server"; - return false; - } - - return true; - } - private bool checkIfAvailable ( bool connecting, bool open, bool closing, bool closed, out string message ) From c2961bc8e7a226bf24e7ae7b1a2745d94d554f38 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 25 Feb 2016 15:11:18 +0900 Subject: [PATCH 0300/6294] [Modify] Replace it --- websocket-sharp/WebSocket.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 105750b25..2ba61f95c 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2455,8 +2455,8 @@ public void CloseAsync (CloseStatusCode code, string reason) /// public void Connect () { - var msg = checkIfAvailable (true, false, true, false, false, true); - if (msg != null) { + string msg; + if (!checkIfAvailable (true, false, true, false, false, true, out msg)) { _logger.Error (msg); error ("An error has occurred in connecting.", null); From 522450a6e2802c8111fbb4d6c322ef5997f56efc Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 25 Feb 2016 15:15:20 +0900 Subject: [PATCH 0301/6294] [Modify] Replace it --- websocket-sharp/WebSocket.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 2ba61f95c..072896058 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2480,8 +2480,8 @@ public void Connect () /// public void ConnectAsync () { - var msg = checkIfAvailable (true, false, true, false, false, true); - if (msg != null) { + string msg; + if (!checkIfAvailable (true, false, true, false, false, true, out msg)) { _logger.Error (msg); error ("An error has occurred in connecting.", null); From 430962f1803733acb6191a0f9420a6de0941792b Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 26 Feb 2016 15:17:50 +0900 Subject: [PATCH 0302/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 072896058..4928bad64 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2494,7 +2494,8 @@ public void ConnectAsync () if (connector.EndInvoke (ar)) open (); }, - null); + null + ); } /// From 9dee9542457bcebafc0d48b6d0a8f61d46a0ba28 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 27 Feb 2016 18:03:52 +0900 Subject: [PATCH 0303/6294] [Modify] Replace it --- websocket-sharp/WebSocket.cs | 46 +++++++++++++++++++----------------- 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 4928bad64..e3f17284b 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -797,7 +797,29 @@ private bool checkIfAvailable ( bool connecting, bool open, bool closing, bool closed, out string message ) { - return checkIfAvailable (true, true, connecting, open, closing, closed, out message); + message = null; + + if (!connecting && _readyState == WebSocketState.Connecting) { + message = "This operation isn't available in: connecting"; + return false; + } + + if (!open && _readyState == WebSocketState.Open) { + message = "This operation isn't available in: open"; + return false; + } + + if (!closing && _readyState == WebSocketState.Closing) { + message = "This operation isn't available in: closing"; + return false; + } + + if (!closed && _readyState == WebSocketState.Closed) { + message = "This operation isn't available in: closed"; + return false; + } + + return true; } private bool checkIfAvailable ( @@ -822,27 +844,7 @@ out string message return false; } - if (!connecting && _readyState == WebSocketState.Connecting) { - message = "This operation isn't available in: connecting"; - return false; - } - - if (!open && _readyState == WebSocketState.Open) { - message = "This operation isn't available in: open"; - return false; - } - - if (!closing && _readyState == WebSocketState.Closing) { - message = "This operation isn't available in: closing"; - return false; - } - - if (!closed && _readyState == WebSocketState.Closed) { - message = "This operation isn't available in: closed"; - return false; - } - - return true; + return checkIfAvailable (connecting, open, closing, closed, out message); } private bool checkReceivedFrame (WebSocketFrame frame, out string message) From 27fe90bae08077d2e59608cd81a469e4c62fa02c Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 28 Feb 2016 16:03:42 +0900 Subject: [PATCH 0304/6294] [Modify] Replace it --- websocket-sharp/WebSocket.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index e3f17284b..19fb20f1f 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -945,8 +945,8 @@ private bool closeHandshake (byte[] frameAsBytes, bool receive, bool received) private bool connect () { lock (_forConn) { - var msg = _readyState.CheckIfAvailable (true, false, false, true); - if (msg != null) { + string msg; + if (!checkIfAvailable (true, false, false, true, out msg)) { _logger.Error (msg); error ("An error has occurred in connecting.", null); From a844baaa5c55bfc69342033871da0d7701393e56 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 29 Feb 2016 15:26:26 +0900 Subject: [PATCH 0305/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 19fb20f1f..d2a598833 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -953,19 +953,20 @@ private bool connect () return false; } - _readyState = WebSocketState.Connecting; try { - if (doHandshake ()) { - _readyState = WebSocketState.Open; - return true; - } + _readyState = WebSocketState.Connecting; + if (!doHandshake ()) + return false; + + _readyState = WebSocketState.Open; + return true; } catch (Exception ex) { _logger.Fatal (ex.ToString ()); fatal ("An exception has occurred while connecting.", ex); - } - return false; + return false; + } } } From da4fbb686f9b516b6dbb6a51a4116c0dbd56dd62 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 1 Mar 2016 14:58:48 +0900 Subject: [PATCH 0306/6294] [Modify] Replace it --- websocket-sharp/WebSocket.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index d2a598833..24307a305 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2088,8 +2088,8 @@ internal void Send (Opcode opcode, Stream stream, Dictionary public void Accept () { - var msg = checkIfAvailable (false, true, true, false, false, false); - if (msg != null) { + string msg; + if (!checkIfAvailable (false, true, true, false, false, false, out msg)) { _logger.Error (msg); error ("An error has occurred in accepting.", null); From 3a369c22d8a96856fd525165e5b6e412a3214ee3 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 1 Mar 2016 15:04:20 +0900 Subject: [PATCH 0307/6294] [Modify] Replace it --- websocket-sharp/WebSocket.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 24307a305..4b84440e7 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2113,8 +2113,8 @@ public void Accept () /// public void AcceptAsync () { - var msg = checkIfAvailable (false, true, true, false, false, false); - if (msg != null) { + string msg; + if (!checkIfAvailable (false, true, true, false, false, false, out msg)) { _logger.Error (msg); error ("An error has occurred in accepting.", null); From 6ce1556c5eeb3b5837fb193ec1915bf03e629a0a Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 2 Mar 2016 15:20:22 +0900 Subject: [PATCH 0308/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 4b84440e7..eb716bdcc 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2127,7 +2127,8 @@ public void AcceptAsync () if (acceptor.EndInvoke (ar)) open (); }, - null); + null + ); } /// From e73c4770765e0adcf496db643ac4577bf1d220fc Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 2 Mar 2016 15:24:22 +0900 Subject: [PATCH 0309/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index eb716bdcc..4f343bc98 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2081,7 +2081,7 @@ internal void Send (Opcode opcode, Stream stream, Dictionary - /// Accepts the WebSocket connection request. + /// Accepts the WebSocket handshake request. /// /// /// This method isn't available in a client. From 1d833e2965ab5bd7da67b8b0268b8f0c56820d22 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 2 Mar 2016 15:26:18 +0900 Subject: [PATCH 0310/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 4f343bc98..1ea9c739c 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2101,7 +2101,7 @@ public void Accept () } /// - /// Accepts the WebSocket connection request asynchronously. + /// Accepts the WebSocket handshake request asynchronously. /// /// /// From b11d8a006d2af8a6e9b00585be336b324b6d2ae0 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 3 Mar 2016 15:20:40 +0900 Subject: [PATCH 0311/6294] [Modify] Replace it --- websocket-sharp/WebSocket.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 1ea9c739c..8c76b027c 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -640,8 +640,8 @@ public TimeSpan WaitTime { private bool accept () { lock (_forConn) { - var msg = _readyState.CheckIfAvailable (true, false, false, false); - if (msg != null) { + string msg; + if (!checkIfAvailable (true, false, false, false, out msg)) { _logger.Error (msg); error ("An error has occurred in accepting.", null); From c6b7063cb84a6bf8e94abd8fa90806f79599f257 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 4 Mar 2016 15:20:23 +0900 Subject: [PATCH 0312/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 8c76b027c..c4b540877 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -649,17 +649,18 @@ private bool accept () } try { - if (acceptHandshake ()) { - _readyState = WebSocketState.Open; - return true; - } + if (!acceptHandshake ()) + return false; + + _readyState = WebSocketState.Open; + return true; } catch (Exception ex) { _logger.Fatal (ex.ToString ()); fatal ("An exception has occurred while accepting.", ex); - } - return false; + return false; + } } } From e588a4ad856deb89a713389d1439f2cfaad0923a Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 5 Mar 2016 16:00:44 +0900 Subject: [PATCH 0313/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index c4b540877..e5ad7964f 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1994,15 +1994,19 @@ internal static string CreateResponseKey (string base64Key) internal void InternalAccept () { try { - if (acceptHandshake ()) { - _readyState = WebSocketState.Open; - open (); - } + if (!acceptHandshake ()) + return; + + _readyState = WebSocketState.Open; } catch (Exception ex) { _logger.Fatal (ex.ToString ()); fatal ("An exception has occurred while accepting.", ex); + + return; } + + open (); } internal bool Ping (byte[] frameAsBytes, TimeSpan timeout) From 0c04fefabc735c86d23ff62692fa8d5f113fe49d Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 6 Mar 2016 14:44:39 +0900 Subject: [PATCH 0314/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index e5ad7964f..42b51174c 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -960,7 +960,6 @@ private bool connect () return false; _readyState = WebSocketState.Open; - return true; } catch (Exception ex) { _logger.Fatal (ex.ToString ()); @@ -968,6 +967,8 @@ private bool connect () return false; } + + return true; } } From f3c8f291b451327939581f21d45e92d657b6d78d Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 7 Mar 2016 15:18:31 +0900 Subject: [PATCH 0315/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 42b51174c..04a70ac77 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -653,7 +653,6 @@ private bool accept () return false; _readyState = WebSocketState.Open; - return true; } catch (Exception ex) { _logger.Fatal (ex.ToString ()); @@ -661,6 +660,8 @@ private bool accept () return false; } + + return true; } } From 9b482d88103eda1c777998f6a729fa86d3f07009 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 8 Mar 2016 14:28:32 +0900 Subject: [PATCH 0316/6294] [Modify] Replace it --- websocket-sharp/WebSocket.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 04a70ac77..648a5c392 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -311,8 +311,8 @@ public CompressionMethod Compression { set { lock (_forConn) { - var msg = checkIfAvailable (true, false, true, false, false, true); - if (msg != null) { + string msg; + if (!checkIfAvailable (true, false, true, false, false, true, out msg)) { _logger.Error (msg); error ("An error has occurred in setting the compression.", null); From 0763dc6e5398dc58abebe5157e30764af0e8f26c Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 9 Mar 2016 15:04:22 +0900 Subject: [PATCH 0317/6294] [Modify] Replace it --- websocket-sharp/WebSocket.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 648a5c392..4438b7787 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -386,8 +386,8 @@ public bool EnableRedirection { set { lock (_forConn) { - var msg = checkIfAvailable (true, false, true, false, false, true); - if (msg != null) { + string msg; + if (!checkIfAvailable (true, false, true, false, false, true, out msg)) { _logger.Error (msg); error ("An error has occurred in setting the enable redirection.", null); From fcc783497dc2158a171143b44c0d56be2b51571b Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 10 Mar 2016 14:36:33 +0900 Subject: [PATCH 0318/6294] [Modify] Replace it --- websocket-sharp/WebSocket.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 4438b7787..d537be2d9 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -554,8 +554,8 @@ public ClientSslConfiguration SslConfiguration { set { lock (_forConn) { - var msg = checkIfAvailable (true, false, true, false, false, true); - if (msg != null) { + string msg; + if (!checkIfAvailable (true, false, true, false, false, true, out msg)) { _logger.Error (msg); error ("An error has occurred in setting the ssl configuration.", null); From 18597a35c1543bda3aa6f015f0931fd5ed80b618 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 10 Mar 2016 15:33:34 +0900 Subject: [PATCH 0319/6294] [Modify] Add it --- websocket-sharp/Ext.cs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index ba9606d79..a9ce853ea 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -14,7 +14,7 @@ * Copyright (c) 2003 Ben Maurer * Copyright (c) 2003, 2005, 2009 Novell, Inc. (http://www.novell.com) * Copyright (c) 2009 Stephane Delcroix - * Copyright (c) 2010-2015 sta.blockhead + * Copyright (c) 2010-2016 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -214,6 +214,18 @@ internal static string CheckIfValidWaitTime (this TimeSpan time) return time <= TimeSpan.Zero ? "A wait time is zero or less." : null; } + internal static bool CheckWaitTime (this TimeSpan time, out string message) + { + message = null; + + if (time <= TimeSpan.Zero) { + message = "A wait time is zero or less."; + return false; + } + + return true; + } + internal static void Close (this HttpListenerResponse response, HttpStatusCode code) { response.StatusCode = (int) code; From 12e7fb1498f9daa31bc87c82fdca98ef5f370088 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 11 Mar 2016 14:35:16 +0900 Subject: [PATCH 0320/6294] [Modify] Replace it --- websocket-sharp/WebSocket.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index d537be2d9..d628b5b21 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -593,10 +593,10 @@ public TimeSpan WaitTime { set { lock (_forConn) { - var msg = checkIfAvailable (true, true, true, false, false, true) ?? - value.CheckIfValidWaitTime (); - - if (msg != null) { + string msg; + if (!checkIfAvailable (true, true, true, false, false, true, out msg) + || !value.CheckWaitTime (out msg) + ) { _logger.Error (msg); error ("An error has occurred in setting the wait time.", null); From 6817a3aa0061ebe676d1cc5b5274e25f631cead9 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 12 Mar 2016 15:44:31 +0900 Subject: [PATCH 0321/6294] [Modify] Replace it --- websocket-sharp/WebSocket.cs | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index d628b5b21..035e947bc 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -482,20 +482,22 @@ public string Origin { set { lock (_forConn) { - var msg = checkIfAvailable (true, false, true, false, false, true); - if (msg == null) { - if (value.IsNullOrEmpty ()) { - _origin = value; - return; - } + string msg; + if (!checkIfAvailable (true, false, true, false, false, true, out msg)) { + _logger.Error (msg); + error ("An error has occurred in setting the origin.", null); - Uri origin; - if (!Uri.TryCreate (value, UriKind.Absolute, out origin) || origin.Segments.Length > 1) - msg = "The syntax of an origin must be '://[:]'."; + return; } - if (msg != null) { - _logger.Error (msg); + if (value.IsNullOrEmpty ()) { + _origin = value; + return; + } + + Uri origin; + if (!Uri.TryCreate (value, UriKind.Absolute, out origin) || origin.Segments.Length > 1) { + _logger.Error ("The syntax of an origin must be '://[:]'."); error ("An error has occurred in setting the origin.", null); return; From 92b0be81570222592f78a40833582ea100b76072 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 13 Mar 2016 16:15:48 +0900 Subject: [PATCH 0322/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 035e947bc..c31735beb 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -325,7 +325,7 @@ public CompressionMethod Compression { } /// - /// Gets the HTTP cookies included in the WebSocket connection request and response. + /// Gets the HTTP cookies included in the WebSocket handshake request and response. /// /// /// An From 6656b471bad8932a3b7d867306f8cb1a6305b776 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 14 Mar 2016 14:44:26 +0900 Subject: [PATCH 0323/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index c31735beb..0ce996aa0 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -373,10 +373,10 @@ public bool EmitOnPing { /// /// Gets or sets a value indicating whether the redirects - /// the connection request to the new URL located in the connection response. + /// the handshake request to the new URL located in the handshake response. /// /// - /// true if the redirects the connection request to + /// true if the redirects the handshake request to /// the new URL; otherwise, false. The default value is false. /// public bool EnableRedirection { From 6dcc5c257947cc8f7b0232e2bde28fa4a034dbd8 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 15 Mar 2016 14:33:06 +0900 Subject: [PATCH 0324/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 0ce996aa0..50defff9c 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -459,7 +459,7 @@ internal set { /// /// Gets or sets the value of the HTTP Origin header to send with - /// the WebSocket connection request to the server. + /// the WebSocket handshake request to the server. /// /// /// The sends the Origin header if this property has any. From 9f995bb1ae1446eac390fcf86bf3d5fc0a5b473b Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 16 Mar 2016 15:15:28 +0900 Subject: [PATCH 0325/6294] [Fix] Separate it Fix for issue #232 --- websocket-sharp/Net/EndPointListener.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/websocket-sharp/Net/EndPointListener.cs b/websocket-sharp/Net/EndPointListener.cs index 936f81d06..855a334c8 100644 --- a/websocket-sharp/Net/EndPointListener.cs +++ b/websocket-sharp/Net/EndPointListener.cs @@ -243,6 +243,12 @@ private static void onAccept (IAsyncResult asyncResult) Socket sock = null; try { sock = lsnr._socket.EndAccept (asyncResult); + } + catch (ObjectDisposedException) { + return; + } + + try { lsnr._socket.BeginAccept (onAccept, lsnr); } catch { @@ -252,6 +258,9 @@ private static void onAccept (IAsyncResult asyncResult) return; } + if (sock == null) + return; + processAccepted (sock, lsnr); } From b5294ef96cf65517e76456c36cbece2ae5de06f0 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 17 Mar 2016 15:48:12 +0900 Subject: [PATCH 0326/6294] [Modify] Replace it --- websocket-sharp/WebSocket.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 50defff9c..d38fa7848 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2145,8 +2145,8 @@ public void AcceptAsync () /// public void Close () { - var msg = _readyState.CheckIfAvailable (true, true, false, false); - if (msg != null) { + string msg; + if (!checkIfAvailable (true, true, false, false, out msg)) { _logger.Error (msg); error ("An error has occurred in closing the connection.", null); From 6da672a65e01ce2750872289a9ae13b3e3646b1f Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 18 Mar 2016 14:46:06 +0900 Subject: [PATCH 0327/6294] [Modify] Replace it --- websocket-sharp/WebSocket.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index d38fa7848..6b2a92b12 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2297,8 +2297,8 @@ public void Close (CloseStatusCode code, string reason) /// public void CloseAsync () { - var msg = _readyState.CheckIfAvailable (true, true, false, false); - if (msg != null) { + string msg; + if (!checkIfAvailable (true, true, false, false, out msg)) { _logger.Error (msg); error ("An error has occurred in closing the connection.", null); From f096e3b561f38c5d4f1febaadf6a142a371bf324 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 19 Mar 2016 16:25:47 +0900 Subject: [PATCH 0328/6294] [Modify] Replace it --- websocket-sharp/WebSocket.cs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 6b2a92b12..1befcfa06 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2776,16 +2776,21 @@ public void SendAsync (Stream stream, int length, Action completed) public void SetCookie (Cookie cookie) { lock (_forConn) { - var msg = checkIfAvailable (true, false, true, false, false, true) ?? - (cookie == null ? "'cookie' is null." : null); - - if (msg != null) { + string msg; + if (!checkIfAvailable (true, false, true, false, false, true, out msg)) { _logger.Error (msg); error ("An error has occurred in setting a cookie.", null); return; } + if (cookie == null) { + _logger.Error ("'cookie' is null."); + error ("An error has occurred in setting a cookie.", null); + + return; + } + lock (_cookies.SyncRoot) _cookies.SetOrRemove (cookie); } From 7987622cc011d7cb891bf232f4b0a88d1275bf5f Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 20 Mar 2016 19:33:37 +0900 Subject: [PATCH 0329/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 1befcfa06..5ff73803c 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2768,7 +2768,7 @@ public void SendAsync (Stream stream, int length, Action completed) /// /// Sets an HTTP to send with - /// the WebSocket connection request to the server. + /// the WebSocket handshake request to the server. /// /// /// A that represents the cookie to send. From 80efd30b93465f2eb80dc15c6d0aa2838f6beb02 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 21 Mar 2016 15:24:08 +0900 Subject: [PATCH 0330/6294] [Modify] Replace it --- websocket-sharp/WebSocket.cs | 36 +++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 5ff73803c..268716e13 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2814,25 +2814,31 @@ public void SetCookie (Cookie cookie) public void SetCredentials (string username, string password, bool preAuth) { lock (_forConn) { - var msg = checkIfAvailable (true, false, true, false, false, true); - if (msg == null) { - if (username.IsNullOrEmpty ()) { - _credentials = null; - _preAuth = false; - _logger.Warn ("The credentials were set back to the default."); + string msg; + if (!checkIfAvailable (true, false, true, false, false, true, out msg)) { + _logger.Error (msg); + error ("An error has occurred in setting the credentials.", null); - return; - } + return; + } - msg = username.Contains (':') || !username.IsText () - ? "'username' contains an invalid character." - : !password.IsNullOrEmpty () && !password.IsText () - ? "'password' contains an invalid character." - : null; + if (username.IsNullOrEmpty ()) { + _credentials = null; + _preAuth = false; + _logger.Warn ("The credentials were set back to the default."); + + return; } - if (msg != null) { - _logger.Error (msg); + if (username.Contains (':') || !username.IsText ()) { + _logger.Error ("'username' contains an invalid character."); + error ("An error has occurred in setting the credentials.", null); + + return; + } + + if (!password.IsNullOrEmpty () && !password.IsText ()) { + _logger.Error ("'password' contains an invalid character."); error ("An error has occurred in setting the credentials.", null); return; From 302cc816b56f8128a197774971a7aefac15406ab Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 22 Mar 2016 15:31:54 +0900 Subject: [PATCH 0331/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 268716e13..731f9ff85 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2823,9 +2823,9 @@ public void SetCredentials (string username, string password, bool preAuth) } if (username.IsNullOrEmpty ()) { + _logger.Warn ("The credentials are set back to the default."); _credentials = null; _preAuth = false; - _logger.Warn ("The credentials were set back to the default."); return; } From f892fecb9aafc9e8caf1e90b33eb1ac1e1c031ad Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 22 Mar 2016 15:38:54 +0900 Subject: [PATCH 0332/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 731f9ff85..28c42c141 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2808,8 +2808,8 @@ public void SetCookie (Cookie cookie) /// used to authenticate. /// /// - /// true if the sends the Basic authentication credentials - /// with the first connection request to the server; otherwise, false. + /// true if the sends the Basic authentication credentials with + /// the first handshake request to the server; otherwise, false. /// public void SetCredentials (string username, string password, bool preAuth) { From ea97ab3fd6ec213fc18dd07a5173f673768952fb Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 23 Mar 2016 14:57:26 +0900 Subject: [PATCH 0333/6294] [Modify] Replace it --- websocket-sharp/WebSocket.cs | 73 +++++++++++++++++++++--------------- 1 file changed, 42 insertions(+), 31 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 28c42c141..09f8206e2 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2867,49 +2867,60 @@ public void SetCredentials (string username, string password, bool preAuth) public void SetProxy (string url, string username, string password) { lock (_forConn) { - var msg = checkIfAvailable (true, false, true, false, false, true); - if (msg == null) { - if (url.IsNullOrEmpty ()) { - _proxyUri = null; - _proxyCredentials = null; - _logger.Warn ("The proxy url and credentials were set back to the default."); + string msg; + if (!checkIfAvailable (true, false, true, false, false, true, out msg)) { + _logger.Error (msg); + error ("An error has occurred in setting the proxy.", null); - return; - } + return; + } - Uri uri; - if (!Uri.TryCreate (url, UriKind.Absolute, out uri) || - uri.Scheme != "http" || - uri.Segments.Length > 1) { - msg = "The syntax of a proxy url must be 'http://[:]'."; - } - else { - _proxyUri = uri; + if (url.IsNullOrEmpty ()) { + _proxyUri = null; + _proxyCredentials = null; + _logger.Warn ("The proxy url and credentials were set back to the default."); - if (username.IsNullOrEmpty ()) { - _proxyCredentials = null; - _logger.Warn ("The proxy credentials were set back to the default."); + return; + } - return; - } + Uri uri; + if (!Uri.TryCreate (url, UriKind.Absolute, out uri) + || uri.Scheme != "http" + || uri.Segments.Length > 1 + ) { + _logger.Error ("The syntax of a proxy url must be 'http://[:]'."); + error ("An error has occurred in setting the proxy.", null); - msg = username.Contains (':') || !username.IsText () - ? "'username' contains an invalid character." - : !password.IsNullOrEmpty () && !password.IsText () - ? "'password' contains an invalid character." - : null; - } + return; } - if (msg != null) { - _logger.Error (msg); + if (username.IsNullOrEmpty ()) { + _proxyUri = uri; + _proxyCredentials = null; + _logger.Warn ("The proxy credentials were set back to the default."); + + return; + } + + if (username.Contains (':') || !username.IsText ()) { + _logger.Error ("'username' contains an invalid character."); error ("An error has occurred in setting the proxy.", null); return; } - _proxyCredentials = new NetworkCredential ( - username, password, String.Format ("{0}:{1}", _uri.DnsSafeHost, _uri.Port)); + if (!password.IsNullOrEmpty () && !password.IsText ()) { + _logger.Error ("'password' contains an invalid character."); + error ("An error has occurred in setting the proxy.", null); + + return; + } + + _proxyUri = uri; + _proxyCredentials = + new NetworkCredential ( + username, password, String.Format ("{0}:{1}", _uri.DnsSafeHost, _uri.Port) + ); } } From dafea984aca2522dd2cb966976c3c8b1ae152361 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 23 Mar 2016 15:00:56 +0900 Subject: [PATCH 0334/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 09f8206e2..d08451036 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2876,9 +2876,9 @@ public void SetProxy (string url, string username, string password) } if (url.IsNullOrEmpty ()) { + _logger.Warn ("The proxy url and credentials are set back to the default."); _proxyUri = null; _proxyCredentials = null; - _logger.Warn ("The proxy url and credentials were set back to the default."); return; } From c89f18696472a901c045f41bdb562ea76cc79872 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 23 Mar 2016 15:10:05 +0900 Subject: [PATCH 0335/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index d08451036..2ea667b4b 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2895,9 +2895,9 @@ public void SetProxy (string url, string username, string password) } if (username.IsNullOrEmpty ()) { + _logger.Warn ("The proxy credentials are set back to the default."); _proxyUri = uri; _proxyCredentials = null; - _logger.Warn ("The proxy credentials were set back to the default."); return; } From cf6d4dc9ac66395b78cebbbfb30c289919213977 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 24 Mar 2016 14:42:49 +0900 Subject: [PATCH 0336/6294] [Modify] Remove it --- websocket-sharp/WebSocket.cs | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 2ea667b4b..511fb1585 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -787,16 +787,6 @@ private bool checkHandshakeResponse (HttpResponse response, out string message) return true; } - private string checkIfAvailable ( - bool client, bool server, bool connecting, bool open, bool closing, bool closed) - { - return !client && _client - ? "This operation isn't available in: client" - : !server && !_client - ? "This operation isn't available in: server" - : _readyState.CheckIfAvailable (connecting, open, closing, closed); - } - private bool checkIfAvailable ( bool connecting, bool open, bool closing, bool closed, out string message ) From 5bf96cf7ffc7ff13297425e28c4af9504685aaf7 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 25 Mar 2016 17:09:33 +0900 Subject: [PATCH 0337/6294] [Modify] Add a check --- websocket-sharp/WebSocket.cs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 511fb1585..c9159a7fb 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2765,9 +2765,16 @@ public void SendAsync (Stream stream, int length, Action completed) /// public void SetCookie (Cookie cookie) { + string msg; + if (!checkIfAvailable (true, false, true, false, false, true, out msg)) { + _logger.Error (msg); + error ("An error has occurred in setting a cookie.", null); + + return; + } + lock (_forConn) { - string msg; - if (!checkIfAvailable (true, false, true, false, false, true, out msg)) { + if (!checkIfAvailable (true, false, false, true, out msg)) { _logger.Error (msg); error ("An error has occurred in setting a cookie.", null); From 49b09654f6d1630bbbb5589df4de2f739d14160f Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 26 Mar 2016 16:25:48 +0900 Subject: [PATCH 0338/6294] [Modify] Add a check --- websocket-sharp/WebSocket.cs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index c9159a7fb..055f14dc5 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2810,9 +2810,16 @@ public void SetCookie (Cookie cookie) /// public void SetCredentials (string username, string password, bool preAuth) { + string msg; + if (!checkIfAvailable (true, false, true, false, false, true, out msg)) { + _logger.Error (msg); + error ("An error has occurred in setting the credentials.", null); + + return; + } + lock (_forConn) { - string msg; - if (!checkIfAvailable (true, false, true, false, false, true, out msg)) { + if (!checkIfAvailable (true, false, false, true, out msg)) { _logger.Error (msg); error ("An error has occurred in setting the credentials.", null); From 8126aa5111389c29cc367108a69cdb4bca23647f Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 27 Mar 2016 14:56:34 +0900 Subject: [PATCH 0339/6294] [Modify] Add a check --- websocket-sharp/WebSocket.cs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 055f14dc5..b463b4f52 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2870,9 +2870,16 @@ public void SetCredentials (string username, string password, bool preAuth) /// public void SetProxy (string url, string username, string password) { + string msg; + if (!checkIfAvailable (true, false, true, false, false, true, out msg)) { + _logger.Error (msg); + error ("An error has occurred in setting the proxy.", null); + + return; + } + lock (_forConn) { - string msg; - if (!checkIfAvailable (true, false, true, false, false, true, out msg)) { + if (!checkIfAvailable (true, false, false, true, out msg)) { _logger.Error (msg); error ("An error has occurred in setting the proxy.", null); From 0a919b4e0971757f7599b82250e7bce07d0b0fec Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 28 Mar 2016 17:30:34 +0900 Subject: [PATCH 0340/6294] [Modify] 2016 --- websocket-sharp/Net/EndPointListener.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/EndPointListener.cs b/websocket-sharp/Net/EndPointListener.cs index 855a334c8..3a3f7dd2d 100644 --- a/websocket-sharp/Net/EndPointListener.cs +++ b/websocket-sharp/Net/EndPointListener.cs @@ -8,7 +8,7 @@ * The MIT License * * Copyright (c) 2005 Novell, Inc. (http://www.novell.com) - * Copyright (c) 2012-2015 sta.blockhead + * Copyright (c) 2012-2016 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From c10e5a7049652be08515b12b1a4996733c3d7519 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 29 Mar 2016 16:28:45 +0900 Subject: [PATCH 0341/6294] [Fix] Replace it (back to the original) Fix for issue #235 --- websocket-sharp/Net/HttpListener.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 830fcd30c..e045272be 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -782,8 +782,7 @@ public void Stop () return; _listening = false; - EndPointManager.RemoveListener (this); - sendServiceUnavailable (); + close (false); } #endregion From 8fd4b160f8e6930b96377426765181105c567fed Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 29 Mar 2016 17:10:11 +0900 Subject: [PATCH 0342/6294] [Fix] Move it out Fix for issue #235 --- websocket-sharp/Net/HttpListener.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index e045272be..3ab4def4c 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -415,18 +415,20 @@ private void cleanup (bool force) private void cleanupConnections () { + HttpConnection[] conns = null; lock (_connectionsSync) { if (_connections.Count == 0) return; // Need to copy this since closing will call the RemoveConnection method. var keys = _connections.Keys; - var conns = new HttpConnection[keys.Count]; + conns = new HttpConnection[keys.Count]; keys.CopyTo (conns, 0); _connections.Clear (); - for (var i = conns.Length - 1; i >= 0; i--) - conns[i].Close (true); } + + for (var i = conns.Length - 1; i >= 0; i--) + conns[i].Close (true); } private void cleanupContextRegistry () From 46014466ba8ed70ae17d3258e4a3c4af3ff02ff0 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 30 Mar 2016 17:27:39 +0900 Subject: [PATCH 0343/6294] [Fix] Move it out As a preventive move. See: issue #235 --- websocket-sharp/Net/EndPointListener.cs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Net/EndPointListener.cs b/websocket-sharp/Net/EndPointListener.cs index 3a3f7dd2d..61d06ada2 100644 --- a/websocket-sharp/Net/EndPointListener.cs +++ b/websocket-sharp/Net/EndPointListener.cs @@ -449,14 +449,16 @@ public void Close () { _socket.Close (); + List conns = null; lock (_unregisteredSync) { - var conns = new List (_unregistered.Keys); + conns = new List (_unregistered.Keys); _unregistered.Clear (); - foreach (var conn in conns) - conn.Close (true); - - conns.Clear (); } + + foreach (var conn in conns) + conn.Close (true); + + conns.Clear (); } public void RemovePrefix (HttpListenerPrefix prefix, HttpListener listener) From 5427c15d94a7991282e702fd4bd85ff168ad1a4b Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 31 Mar 2016 14:29:30 +0900 Subject: [PATCH 0344/6294] [Modify] Add a check --- websocket-sharp/Net/EndPointListener.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/websocket-sharp/Net/EndPointListener.cs b/websocket-sharp/Net/EndPointListener.cs index 61d06ada2..4052a12b7 100644 --- a/websocket-sharp/Net/EndPointListener.cs +++ b/websocket-sharp/Net/EndPointListener.cs @@ -451,6 +451,9 @@ public void Close () List conns = null; lock (_unregisteredSync) { + if (_unregistered.Count == 0) + return; + conns = new List (_unregistered.Keys); _unregistered.Clear (); } From d879d983cef4c171ae61884e6173689e21a5d74c Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 31 Mar 2016 14:47:04 +0900 Subject: [PATCH 0345/6294] [Modify] Replace it Be the same as the WebSocketSharp.Net.HttpListener.cleanupConnections method. --- websocket-sharp/Net/EndPointListener.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Net/EndPointListener.cs b/websocket-sharp/Net/EndPointListener.cs index 4052a12b7..99040e199 100644 --- a/websocket-sharp/Net/EndPointListener.cs +++ b/websocket-sharp/Net/EndPointListener.cs @@ -449,19 +449,19 @@ public void Close () { _socket.Close (); - List conns = null; + HttpConnection[] conns = null; lock (_unregisteredSync) { if (_unregistered.Count == 0) return; - conns = new List (_unregistered.Keys); + var keys = _unregistered.Keys; + conns = new HttpConnection[keys.Count]; + keys.CopyTo (conns, 0); _unregistered.Clear (); } - foreach (var conn in conns) - conn.Close (true); - - conns.Clear (); + for (var i = conns.Length - 1; i >= 0; i--) + conns[i].Close (true); } public void RemovePrefix (HttpListenerPrefix prefix, HttpListener listener) From 20ad884dbeb8851aa8b84cd2192f925bdd0212c4 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 1 Apr 2016 11:06:48 +0900 Subject: [PATCH 0346/6294] [Fix] Move it out As a preventive move. See: issue #235 --- websocket-sharp/Net/HttpListener.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 3ab4def4c..822b9d01d 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -433,18 +433,20 @@ private void cleanupConnections () private void cleanupContextRegistry () { + HttpListenerContext[] ctxs = null; lock (_ctxRegistrySync) { if (_ctxRegistry.Count == 0) return; // Need to copy this since closing will call the UnregisterContext method. var keys = _ctxRegistry.Keys; - var ctxs = new HttpListenerContext[keys.Count]; + ctxs = new HttpListenerContext[keys.Count]; keys.CopyTo (ctxs, 0); _ctxRegistry.Clear (); - for (var i = ctxs.Length - 1; i >= 0; i--) - ctxs[i].Connection.Close (true); } + + for (var i = ctxs.Length - 1; i >= 0; i--) + ctxs[i].Connection.Close (true); } private void cleanupWaitQueue () From 02248cd95de9056eb0280692d67ba5b8a4940190 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 1 Apr 2016 11:16:45 +0900 Subject: [PATCH 0347/6294] [Fix] Move it out As a preventive move. See: issue #235 --- websocket-sharp/Net/HttpListener.cs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 822b9d01d..5d89368a2 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -483,17 +483,19 @@ private HttpListenerContext getContextFromQueue () private void sendServiceUnavailable () { + HttpListenerContext[] ctxs = null; lock (_ctxQueueSync) { if (_ctxQueue.Count == 0) return; - var ctxs = _ctxQueue.ToArray (); + ctxs = _ctxQueue.ToArray (); _ctxQueue.Clear (); - foreach (var ctx in ctxs) { - var res = ctx.Response; - res.StatusCode = (int) HttpStatusCode.ServiceUnavailable; - res.Close (); - } + } + + foreach (var ctx in ctxs) { + var res = ctx.Response; + res.StatusCode = (int) HttpStatusCode.ServiceUnavailable; + res.Close (); } } From e8fc325e63800e09c1d8f50be8474701b0809e67 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 1 Apr 2016 11:26:54 +0900 Subject: [PATCH 0348/6294] [Modify] Add a check --- websocket-sharp/Net/HttpListener.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 5d89368a2..0b14e9dbe 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -73,7 +73,7 @@ public sealed class HttpListener : IDisposable private Func _credFinder; private bool _disposed; private bool _ignoreWriteExceptions; - private bool _listening; + private volatile bool _listening; private Logger _logger; private HttpListenerPrefixCollection _prefixes; private string _realm; @@ -630,7 +630,11 @@ public void Abort () if (_disposed) return; - close (true); + if (_listening) { + _listening = false; + close (true); + } + _disposed = true; } From b76349936b3c923cabf3a3556adc133ea8d3d002 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 1 Apr 2016 11:30:07 +0900 Subject: [PATCH 0349/6294] [Modify] Add a check --- websocket-sharp/Net/HttpListener.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 0b14e9dbe..8d1064114 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -683,7 +683,11 @@ public void Close () if (_disposed) return; - close (false); + if (_listening) { + _listening = false; + close (false); + } + _disposed = true; } From afd619133173037e22325fdbe38d55cc41f242fe Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 1 Apr 2016 11:39:31 +0900 Subject: [PATCH 0350/6294] [Modify] Add a check --- websocket-sharp/Net/HttpListener.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 8d1064114..09729fb33 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -811,7 +811,11 @@ void IDisposable.Dispose () if (_disposed) return; - close (true); + if (_listening) { + _listening = false; + close (true); + } + _disposed = true; } From c9511823b87d2ea476ce724ce8c5785c30f1bea6 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 1 Apr 2016 12:21:48 +0900 Subject: [PATCH 0351/6294] [Fix] Check if can add a connection --- websocket-sharp/Net/HttpConnection.cs | 6 +++++- websocket-sharp/Net/HttpListener.cs | 13 +++++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/HttpConnection.cs b/websocket-sharp/Net/HttpConnection.cs index 3527731ed..095f454e0 100644 --- a/websocket-sharp/Net/HttpConnection.cs +++ b/websocket-sharp/Net/HttpConnection.cs @@ -294,7 +294,11 @@ private static void onRead (IAsyncResult asyncResult) var lsnr = conn._context.Listener; if (conn._lastListener != lsnr) { conn.removeConnection (); - lsnr.AddConnection (conn); + if (!lsnr.AddConnection (conn)) { + conn.close (); + return; + } + conn._lastListener = lsnr; } diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 09729fb33..924e3cb9e 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -503,10 +503,19 @@ private void sendServiceUnavailable () #region Internal Methods - internal void AddConnection (HttpConnection connection) + internal bool AddConnection (HttpConnection connection) { - lock (_connectionsSync) + if (!_listening) + return false; + + lock (_connectionsSync) { + if (!_listening) + return false; + _connections[connection] = connection; + } + + return true; } internal bool Authenticate (HttpListenerContext context) From fdf1a1880918f3f3aee15c210e0d716e8b5b6028 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 2 Apr 2016 11:14:50 +0900 Subject: [PATCH 0352/6294] [Fix] Check if can register a context --- websocket-sharp/Net/HttpConnection.cs | 7 ++++++- websocket-sharp/Net/HttpListener.cs | 30 +++++++++++++++++---------- 2 files changed, 25 insertions(+), 12 deletions(-) diff --git a/websocket-sharp/Net/HttpConnection.cs b/websocket-sharp/Net/HttpConnection.cs index 095f454e0..d941278a0 100644 --- a/websocket-sharp/Net/HttpConnection.cs +++ b/websocket-sharp/Net/HttpConnection.cs @@ -303,7 +303,12 @@ private static void onRead (IAsyncResult asyncResult) } conn._contextBound = true; - lsnr.RegisterContext (conn._context); + if (!lsnr.RegisterContext (conn._context)) { + conn._contextBound = false; + conn.close (); + + return; + } return; } diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 924e3cb9e..cf1f3499f 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -581,25 +581,33 @@ internal void CheckDisposed () throw new ObjectDisposedException (GetType ().ToString ()); } - internal void RegisterContext (HttpListenerContext context) + internal bool RegisterContext (HttpListenerContext context) { - lock (_ctxRegistrySync) - _ctxRegistry[context] = context; + if (!_listening) + return false; HttpListenerAsyncResult ares = null; - lock (_waitQueueSync) { - if (_waitQueue.Count == 0) { - lock (_ctxQueueSync) - _ctxQueue.Add (context); - } - else { - ares = _waitQueue[0]; - _waitQueue.RemoveAt (0); + lock (_ctxRegistrySync) { + if (!_listening) + return false; + + _ctxRegistry[context] = context; + lock (_waitQueueSync) { + if (_waitQueue.Count == 0) { + lock (_ctxQueueSync) + _ctxQueue.Add (context); + } + else { + ares = _waitQueue[0]; + _waitQueue.RemoveAt (0); + } } } if (ares != null) ares.Complete (context); + + return true; } internal void RemoveConnection (HttpConnection connection) From 40b74422a2383a8b10acd82a4cc26b070eb9b786 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 2 Apr 2016 11:39:34 +0900 Subject: [PATCH 0353/6294] [Fix] Move them out As a preventive move. See: issue #235 --- websocket-sharp/Net/HttpListener.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index cf1f3499f..72b039688 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -406,11 +406,11 @@ private void cleanup (bool force) lock (_ctxRegistrySync) { if (!force) sendServiceUnavailable (); - - cleanupContextRegistry (); - cleanupConnections (); - cleanupWaitQueue (); } + + cleanupContextRegistry (); + cleanupConnections (); + cleanupWaitQueue (); } private void cleanupConnections () From 655acc65288fa3adebf83ee958cafcfd0401ec4d Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 3 Apr 2016 16:33:18 +0900 Subject: [PATCH 0354/6294] [Modify] Lock it within the method --- websocket-sharp/Net/HttpListener.cs | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 72b039688..16087c49d 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -469,16 +469,17 @@ private void close (bool force) cleanup (force); } - // Must be called with a lock on _ctxQueue. private HttpListenerContext getContextFromQueue () { - if (_ctxQueue.Count == 0) - return null; + lock (_ctxQueueSync) { + if (_ctxQueue.Count == 0) + return null; - var ctx = _ctxQueue[0]; - _ctxQueue.RemoveAt (0); + var ctx = _ctxQueue[0]; + _ctxQueue.RemoveAt (0); - return ctx; + return ctx; + } } private void sendServiceUnavailable () @@ -561,12 +562,10 @@ internal HttpListenerAsyncResult BeginGetContext (HttpListenerAsyncResult asyncR // Lock _waitQueue early to avoid race conditions. lock (_waitQueueSync) { - lock (_ctxQueueSync) { - var ctx = getContextFromQueue (); - if (ctx != null) { - asyncResult.Complete (ctx, true); - return asyncResult; - } + var ctx = getContextFromQueue (); + if (ctx != null) { + asyncResult.Complete (ctx, true); + return asyncResult; } _waitQueue.Add (asyncResult); From 83a07a988db29bfe8b3de66c6f15ea360d59ef42 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 4 Apr 2016 04:48:26 +0900 Subject: [PATCH 0355/6294] [Fix] Lock it early --- websocket-sharp/Net/HttpListener.cs | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 16087c49d..fe060483b 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -560,15 +560,20 @@ internal HttpListenerAsyncResult BeginGetContext (HttpListenerAsyncResult asyncR if (!_listening) throw new InvalidOperationException ("The listener hasn't been started."); - // Lock _waitQueue early to avoid race conditions. - lock (_waitQueueSync) { - var ctx = getContextFromQueue (); - if (ctx != null) { - asyncResult.Complete (ctx, true); - return asyncResult; - } + // Lock _ctxRegistrySync early to avoid race conditions. + lock (_ctxRegistrySync) { + if (!_listening) + throw new InvalidOperationException ("The listener is stopped/closed."); - _waitQueue.Add (asyncResult); + lock (_waitQueueSync) { + var ctx = getContextFromQueue (); + if (ctx != null) { + asyncResult.Complete (ctx, true); + return asyncResult; + } + + _waitQueue.Add (asyncResult); + } } return asyncResult; From 7772abd8f39c0099ada2f7301817b86af4acd531 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 5 Apr 2016 14:43:09 +0900 Subject: [PATCH 0356/6294] [Modify] Move it out --- websocket-sharp/Net/HttpListener.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index fe060483b..37c836284 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -451,16 +451,18 @@ private void cleanupContextRegistry () private void cleanupWaitQueue () { + HttpListenerAsyncResult[] aress = null; lock (_waitQueueSync) { if (_waitQueue.Count == 0) return; - var ex = new ObjectDisposedException (GetType ().ToString ()); - foreach (var ares in _waitQueue) - ares.Complete (ex); - + aress = _waitQueue.ToArray (); _waitQueue.Clear (); } + + var ex = new ObjectDisposedException (GetType ().ToString ()); + foreach (var ares in aress) + ares.Complete (ex); } private void close (bool force) From fe86f95d5eb074e0465118fc18380b0f56b4f575 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 6 Apr 2016 14:33:21 +0900 Subject: [PATCH 0357/6294] [Modify] Add it --- websocket-sharp/Net/HttpListener.cs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 37c836284..6e9ff4708 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -465,6 +465,21 @@ private void cleanupWaitQueue () ares.Complete (ex); } + private void cleanupWaitQueue (Exception exception) + { + HttpListenerAsyncResult[] aress = null; + lock (_waitQueueSync) { + if (_waitQueue.Count == 0) + return; + + aress = _waitQueue.ToArray (); + _waitQueue.Clear (); + } + + foreach (var ares in aress) + ares.Complete (exception); + } + private void close (bool force) { EndPointManager.RemoveListener (this); From e14fc1b531aa6af647ff8c96b979564553015ac2 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 7 Apr 2016 17:47:11 +0900 Subject: [PATCH 0358/6294] [Modify] Replace it --- websocket-sharp/Net/HttpListener.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 6e9ff4708..8814a8179 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -834,7 +834,14 @@ public void Stop () return; _listening = false; - close (false); + + EndPointManager.RemoveListener (this); + lock (_ctxRegistrySync) + sendServiceUnavailable (); + + cleanupContextRegistry (); + cleanupConnections (); + cleanupWaitQueue (new HttpListenerException (995, "The listener is stopped.")); } #endregion From b25343f7253a1fb9b28a6768df01bf7652b65172 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 8 Apr 2016 15:48:30 +0900 Subject: [PATCH 0359/6294] [Fix] Set system error code 995 --- websocket-sharp/Net/HttpListenerAsyncResult.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerAsyncResult.cs b/websocket-sharp/Net/HttpListenerAsyncResult.cs index 569bac314..7212379f8 100644 --- a/websocket-sharp/Net/HttpListenerAsyncResult.cs +++ b/websocket-sharp/Net/HttpListenerAsyncResult.cs @@ -162,7 +162,7 @@ private static void complete (HttpListenerAsyncResult asyncResult) internal void Complete (Exception exception) { _exception = _inGet && (exception is ObjectDisposedException) - ? new HttpListenerException (500, "Listener closed.") + ? new HttpListenerException (995, "Listener closed.") : exception; lock (_sync) From f745e503a76a0375981ce8877bc1da29e4a3d72d Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 8 Apr 2016 15:57:31 +0900 Subject: [PATCH 0360/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerAsyncResult.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerAsyncResult.cs b/websocket-sharp/Net/HttpListenerAsyncResult.cs index 7212379f8..bb8d476c3 100644 --- a/websocket-sharp/Net/HttpListenerAsyncResult.cs +++ b/websocket-sharp/Net/HttpListenerAsyncResult.cs @@ -162,7 +162,7 @@ private static void complete (HttpListenerAsyncResult asyncResult) internal void Complete (Exception exception) { _exception = _inGet && (exception is ObjectDisposedException) - ? new HttpListenerException (995, "Listener closed.") + ? new HttpListenerException (995, "The listener is closed.") : exception; lock (_sync) From 3a0a661300a484ce249dfd85ebe4fba4736d09a6 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 9 Apr 2016 15:32:09 +0900 Subject: [PATCH 0361/6294] [Modify] Polish it --- .../Net/HttpListenerAsyncResult.cs | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerAsyncResult.cs b/websocket-sharp/Net/HttpListenerAsyncResult.cs index bb8d476c3..0f1303d4f 100644 --- a/websocket-sharp/Net/HttpListenerAsyncResult.cs +++ b/websocket-sharp/Net/HttpListenerAsyncResult.cs @@ -143,16 +143,19 @@ private static void complete (HttpListenerAsyncResult asyncResult) waitHandle.Set (); var callback = asyncResult._callback; - if (callback != null) - ThreadPool.QueueUserWorkItem ( - state => { - try { - callback (asyncResult); - } - catch { - } - }, - null); + if (callback == null) + return; + + ThreadPool.QueueUserWorkItem ( + state => { + try { + callback (asyncResult); + } + catch { + } + }, + null + ); } #endregion From 0a31183ca794cbcc462369cd7790a601641f6a4d Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 10 Apr 2016 15:20:21 +0900 Subject: [PATCH 0362/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerAsyncResult.cs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerAsyncResult.cs b/websocket-sharp/Net/HttpListenerAsyncResult.cs index 0f1303d4f..e72cef684 100644 --- a/websocket-sharp/Net/HttpListenerAsyncResult.cs +++ b/websocket-sharp/Net/HttpListenerAsyncResult.cs @@ -136,11 +136,13 @@ public bool IsCompleted { private static void complete (HttpListenerAsyncResult asyncResult) { - asyncResult._completed = true; + lock (asyncResult._sync) { + asyncResult._completed = true; - var waitHandle = asyncResult._waitHandle; - if (waitHandle != null) - waitHandle.Set (); + var waitHandle = asyncResult._waitHandle; + if (waitHandle != null) + waitHandle.Set (); + } var callback = asyncResult._callback; if (callback == null) @@ -168,8 +170,7 @@ internal void Complete (Exception exception) ? new HttpListenerException (995, "The listener is closed.") : exception; - lock (_sync) - complete (this); + complete (this); } internal void Complete (HttpListenerContext context) @@ -188,8 +189,7 @@ internal void Complete (HttpListenerContext context, bool syncCompleted) _context = context; _syncCompleted = syncCompleted; - lock (_sync) - complete (this); + complete (this); } internal HttpListenerContext GetContext () From 1423834527833313b8f6ddd204f95cf2e03c5a36 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 10 Apr 2016 15:26:55 +0900 Subject: [PATCH 0363/6294] [Modify] Remove it --- websocket-sharp/Net/HttpListenerAsyncResult.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerAsyncResult.cs b/websocket-sharp/Net/HttpListenerAsyncResult.cs index e72cef684..cf1f520f6 100644 --- a/websocket-sharp/Net/HttpListenerAsyncResult.cs +++ b/websocket-sharp/Net/HttpListenerAsyncResult.cs @@ -45,7 +45,6 @@ #endregion using System; -using System.Security.Principal; using System.Threading; namespace WebSocketSharp.Net From cc627534f8e982e8970e8c1ca55cdd2f6d24fed8 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 10 Apr 2016 15:29:16 +0900 Subject: [PATCH 0364/6294] [Modify] 2016 --- websocket-sharp/Net/HttpListenerAsyncResult.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerAsyncResult.cs b/websocket-sharp/Net/HttpListenerAsyncResult.cs index cf1f520f6..81d602b32 100644 --- a/websocket-sharp/Net/HttpListenerAsyncResult.cs +++ b/websocket-sharp/Net/HttpListenerAsyncResult.cs @@ -8,7 +8,7 @@ * The MIT License * * Copyright (c) 2005 Ximian, Inc. (http://www.ximian.com) - * Copyright (c) 2012-2015 sta.blockhead + * Copyright (c) 2012-2016 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From ea664163c472b993f262dbd9495020a41cb2cb70 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 11 Apr 2016 14:31:47 +0900 Subject: [PATCH 0365/6294] [Modify] Replace it --- websocket-sharp/Net/HttpListener.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 8814a8179..70f683b98 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -483,7 +483,15 @@ private void cleanupWaitQueue (Exception exception) private void close (bool force) { EndPointManager.RemoveListener (this); - cleanup (force); + + lock (_ctxRegistrySync) { + if (!force) + sendServiceUnavailable (); + } + + cleanupContextRegistry (); + cleanupConnections (); + cleanupWaitQueue (new ObjectDisposedException (GetType ().ToString ())); } private HttpListenerContext getContextFromQueue () From 0d92f1205d22554a0cd12c04b1d339ae8c69b63f Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 11 Apr 2016 14:42:31 +0900 Subject: [PATCH 0366/6294] [Modify] Remove them --- websocket-sharp/Net/HttpListener.cs | 28 ---------------------------- 1 file changed, 28 deletions(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 70f683b98..92c1c4d19 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -401,18 +401,6 @@ public Func UserCredentialsFinder { #region Private Methods - private void cleanup (bool force) - { - lock (_ctxRegistrySync) { - if (!force) - sendServiceUnavailable (); - } - - cleanupContextRegistry (); - cleanupConnections (); - cleanupWaitQueue (); - } - private void cleanupConnections () { HttpConnection[] conns = null; @@ -449,22 +437,6 @@ private void cleanupContextRegistry () ctxs[i].Connection.Close (true); } - private void cleanupWaitQueue () - { - HttpListenerAsyncResult[] aress = null; - lock (_waitQueueSync) { - if (_waitQueue.Count == 0) - return; - - aress = _waitQueue.ToArray (); - _waitQueue.Clear (); - } - - var ex = new ObjectDisposedException (GetType ().ToString ()); - foreach (var ares in aress) - ares.Complete (ex); - } - private void cleanupWaitQueue (Exception exception) { HttpListenerAsyncResult[] aress = null; From 82ea0896838dbf930f5d9c3631627f6285fd6141 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 12 Apr 2016 13:44:52 +0900 Subject: [PATCH 0367/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListener.cs | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 92c1c4d19..abb3e3445 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -454,7 +454,10 @@ private void cleanupWaitQueue (Exception exception) private void close (bool force) { - EndPointManager.RemoveListener (this); + if (_listening) { + _listening = false; + EndPointManager.RemoveListener (this); + } lock (_ctxRegistrySync) { if (!force) @@ -464,6 +467,8 @@ private void close (bool force) cleanupContextRegistry (); cleanupConnections (); cleanupWaitQueue (new ObjectDisposedException (GetType ().ToString ())); + + _disposed = true; } private HttpListenerContext getContextFromQueue () @@ -648,12 +653,7 @@ public void Abort () if (_disposed) return; - if (_listening) { - _listening = false; - close (true); - } - - _disposed = true; + close (true); } /// @@ -701,12 +701,7 @@ public void Close () if (_disposed) return; - if (_listening) { - _listening = false; - close (false); - } - - _disposed = true; + close (false); } /// @@ -836,12 +831,7 @@ void IDisposable.Dispose () if (_disposed) return; - if (_listening) { - _listening = false; - close (true); - } - - _disposed = true; + close (true); } #endregion From 6d1ea18c0db479c57391299c0da2c1a4be9559e4 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 12 Apr 2016 13:48:10 +0900 Subject: [PATCH 0368/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListener.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index abb3e3445..2c5857b59 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -809,8 +809,8 @@ public void Stop () return; _listening = false; - EndPointManager.RemoveListener (this); + lock (_ctxRegistrySync) sendServiceUnavailable (); From 9317a7e6b820b5f458b5253adfe3afac78009acc Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 13 Apr 2016 14:07:18 +0900 Subject: [PATCH 0369/6294] [Fix] Handle it --- websocket-sharp/Net/HttpListenerAsyncResult.cs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerAsyncResult.cs b/websocket-sharp/Net/HttpListenerAsyncResult.cs index 81d602b32..37cdf0b48 100644 --- a/websocket-sharp/Net/HttpListenerAsyncResult.cs +++ b/websocket-sharp/Net/HttpListenerAsyncResult.cs @@ -179,9 +179,15 @@ internal void Complete (HttpListenerContext context) internal void Complete (HttpListenerContext context, bool syncCompleted) { - var lsnr = context.Listener; - if (!lsnr.Authenticate (context)) { - lsnr.BeginGetContext (this); + try { + var lsnr = context.Listener; + if (!lsnr.Authenticate (context)) { + lsnr.BeginGetContext (this); + return; + } + } + catch (Exception ex) { + Complete (ex); return; } From 228ea172629c4420e64c7489b470c095553fc530 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 13 Apr 2016 14:22:13 +0900 Subject: [PATCH 0370/6294] [Fix] Move them --- websocket-sharp/Net/HttpListener.cs | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 2c5857b59..010fda62c 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -555,13 +555,6 @@ internal bool Authenticate (HttpListenerContext context) internal HttpListenerAsyncResult BeginGetContext (HttpListenerAsyncResult asyncResult) { - CheckDisposed (); - if (_prefixes.Count == 0) - throw new InvalidOperationException ("The listener has no URI prefix on which listens."); - - if (!_listening) - throw new InvalidOperationException ("The listener hasn't been started."); - // Lock _ctxRegistrySync early to avoid race conditions. lock (_ctxRegistrySync) { if (!_listening) @@ -690,6 +683,13 @@ public void Abort () /// public IAsyncResult BeginGetContext (AsyncCallback callback, Object state) { + CheckDisposed (); + if (_prefixes.Count == 0) + throw new InvalidOperationException ("The listener has no URI prefix on which listens."); + + if (!_listening) + throw new InvalidOperationException ("The listener hasn't been started."); + return BeginGetContext (new HttpListenerAsyncResult (callback, state)); } @@ -774,6 +774,13 @@ public HttpListenerContext EndGetContext (IAsyncResult asyncResult) /// public HttpListenerContext GetContext () { + CheckDisposed (); + if (_prefixes.Count == 0) + throw new InvalidOperationException ("The listener has no URI prefix on which listens."); + + if (!_listening) + throw new InvalidOperationException ("The listener hasn't been started."); + var ares = BeginGetContext (new HttpListenerAsyncResult (null, null)); ares.InGet = true; From c70c58e8f3e5695b21057c05601f03ec5cadf3ab Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 14 Apr 2016 11:44:13 +0900 Subject: [PATCH 0371/6294] [Fix] Replace it --- websocket-sharp/Net/HttpListener.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 010fda62c..13c9df898 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -558,7 +558,7 @@ internal HttpListenerAsyncResult BeginGetContext (HttpListenerAsyncResult asyncR // Lock _ctxRegistrySync early to avoid race conditions. lock (_ctxRegistrySync) { if (!_listening) - throw new InvalidOperationException ("The listener is stopped/closed."); + throw new HttpListenerException (995); lock (_waitQueueSync) { var ctx = getContextFromQueue (); From 9c86b79c9176e10507c72f88d86141e61c8653fc Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 15 Apr 2016 14:33:17 +0900 Subject: [PATCH 0372/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListener.cs | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 13c9df898..b54b41f8a 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -534,23 +534,21 @@ internal bool Authenticate (HttpListenerContext context) var realm = Realm; var req = context.Request; - var user = HttpUtility.CreateUser ( - req.Headers["Authorization"], schm, realm, req.HttpMethod, UserCredentialsFinder); + var user = + HttpUtility.CreateUser ( + req.Headers["Authorization"], schm, realm, req.HttpMethod, UserCredentialsFinder + ); - if (user != null && user.Identity.IsAuthenticated) { - context.User = user; - return true; - } - - if (schm == AuthenticationSchemes.Basic) + if (user == null || !user.Identity.IsAuthenticated) { context.Response.CloseWithAuthChallenge ( - AuthenticationChallenge.CreateBasicChallenge (realm).ToBasicString ()); + new AuthenticationChallenge (schm, realm).ToString () + ); - if (schm == AuthenticationSchemes.Digest) - context.Response.CloseWithAuthChallenge ( - AuthenticationChallenge.CreateDigestChallenge (realm).ToDigestString ()); + return false; + } - return false; + context.User = user; + return true; } internal HttpListenerAsyncResult BeginGetContext (HttpListenerAsyncResult asyncResult) From 25f5cfb2049ffc1556791e8293af6f3c1bdafafa Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 15 Apr 2016 14:43:58 +0900 Subject: [PATCH 0373/6294] [Modify] Add it --- websocket-sharp/Net/HttpListener.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index b54b41f8a..3ef5c4d4d 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -471,6 +471,19 @@ private void close (bool force) _disposed = true; } + private HttpListenerAsyncResult getAsyncResultFromQueue () + { + lock (_waitQueueSync) { + if (_waitQueue.Count == 0) + return null; + + var ares = _waitQueue[0]; + _waitQueue.RemoveAt (0); + + return ares; + } + } + private HttpListenerContext getContextFromQueue () { lock (_ctxQueueSync) { From 7e8035569459b0bab88231d5b80636d6293231b0 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 15 Apr 2016 15:49:47 +0900 Subject: [PATCH 0374/6294] [Fix] Replace it --- websocket-sharp/Net/HttpListener.cs | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 3ef5c4d4d..7c25b2877 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -596,28 +596,23 @@ internal bool RegisterContext (HttpListenerContext context) if (!_listening) return false; - HttpListenerAsyncResult ares = null; lock (_ctxRegistrySync) { if (!_listening) return false; _ctxRegistry[context] = context; - lock (_waitQueueSync) { - if (_waitQueue.Count == 0) { - lock (_ctxQueueSync) - _ctxQueue.Add (context); - } - else { - ares = _waitQueue[0]; - _waitQueue.RemoveAt (0); - } - } - } - if (ares != null) - ares.Complete (context); + var ares = getAsyncResultFromQueue (); + if (ares == null) { + lock (_ctxQueueSync) + _ctxQueue.Add (context); + } + else { + ares.Complete (context); + } - return true; + return true; + } } internal void RemoveConnection (HttpConnection connection) From e90c1533913c291e048b250ce3a65d6c21337aab Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 16 Apr 2016 15:21:46 +0900 Subject: [PATCH 0375/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListener.cs | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 7c25b2877..22558b580 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -566,23 +566,21 @@ internal bool Authenticate (HttpListenerContext context) internal HttpListenerAsyncResult BeginGetContext (HttpListenerAsyncResult asyncResult) { - // Lock _ctxRegistrySync early to avoid race conditions. lock (_ctxRegistrySync) { if (!_listening) throw new HttpListenerException (995); - lock (_waitQueueSync) { - var ctx = getContextFromQueue (); - if (ctx != null) { - asyncResult.Complete (ctx, true); - return asyncResult; - } - - _waitQueue.Add (asyncResult); + var ctx = getContextFromQueue (); + if (ctx == null) { + lock (_waitQueueSync) + _waitQueue.Add (asyncResult); + } + else { + asyncResult.Complete (ctx, true); } - } - return asyncResult; + return asyncResult; + } } internal void CheckDisposed () From c081736add187801e40b3fff6732b83414166e7e Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 16 Apr 2016 15:34:43 +0900 Subject: [PATCH 0376/6294] [Modify] Add it --- websocket-sharp/Net/HttpListener.cs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 22558b580..ecb016fc6 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -419,6 +419,27 @@ private void cleanupConnections () conns[i].Close (true); } + private void cleanupContextQueue (bool sendServiceUnavailable) + { + HttpListenerContext[] ctxs = null; + lock (_ctxQueueSync) { + if (_ctxQueue.Count == 0) + return; + + ctxs = _ctxQueue.ToArray (); + _ctxQueue.Clear (); + } + + if (!sendServiceUnavailable) + return; + + foreach (var ctx in ctxs) { + var res = ctx.Response; + res.StatusCode = (int) HttpStatusCode.ServiceUnavailable; + res.Close (); + } + } + private void cleanupContextRegistry () { HttpListenerContext[] ctxs = null; From 1b0fe2fd19debc63bbc7684859c50df87744b07b Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 16 Apr 2016 15:39:52 +0900 Subject: [PATCH 0377/6294] [Modify] Replace it --- websocket-sharp/Net/HttpListener.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index ecb016fc6..566a463f3 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -844,7 +844,7 @@ public void Stop () EndPointManager.RemoveListener (this); lock (_ctxRegistrySync) - sendServiceUnavailable (); + cleanupContextQueue (true); cleanupContextRegistry (); cleanupConnections (); From db34117862d629886fc0d2077b4478677b9402d6 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 16 Apr 2016 15:44:57 +0900 Subject: [PATCH 0378/6294] [Modify] Replace it --- websocket-sharp/Net/HttpListener.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 566a463f3..a0aa0bdc7 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -480,10 +480,8 @@ private void close (bool force) EndPointManager.RemoveListener (this); } - lock (_ctxRegistrySync) { - if (!force) - sendServiceUnavailable (); - } + lock (_ctxRegistrySync) + cleanupContextQueue (!force); cleanupContextRegistry (); cleanupConnections (); From e9b92baec2d0e9ea094ae4099253caec12f22725 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 16 Apr 2016 15:48:08 +0900 Subject: [PATCH 0379/6294] [Modify] Remove it --- websocket-sharp/Net/HttpListener.cs | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index a0aa0bdc7..5ced2f7fc 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -516,24 +516,6 @@ private HttpListenerContext getContextFromQueue () } } - private void sendServiceUnavailable () - { - HttpListenerContext[] ctxs = null; - lock (_ctxQueueSync) { - if (_ctxQueue.Count == 0) - return; - - ctxs = _ctxQueue.ToArray (); - _ctxQueue.Clear (); - } - - foreach (var ctx in ctxs) { - var res = ctx.Response; - res.StatusCode = (int) HttpStatusCode.ServiceUnavailable; - res.Close (); - } - } - #endregion #region Internal Methods From f41fbd6dcb9ab61256cf5ad44c36913b59b32b0b Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 16 Apr 2016 15:55:19 +0900 Subject: [PATCH 0380/6294] [Modify] Remove it --- websocket-sharp/Net/HttpListener.cs | 6 ------ 1 file changed, 6 deletions(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 5ced2f7fc..f307ce4c8 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -631,12 +631,6 @@ internal void UnregisterContext (HttpListenerContext context) { lock (_ctxRegistrySync) _ctxRegistry.Remove (context); - - lock (_ctxQueueSync) { - var idx = _ctxQueue.IndexOf (context); - if (idx >= 0) - _ctxQueue.RemoveAt (idx); - } } #endregion From 080a436ef0035e98109386834b08ddb770072b8a Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 17 Apr 2016 15:36:26 +0900 Subject: [PATCH 0381/6294] [Modify] Remove some locks --- websocket-sharp/Net/HttpListener.cs | 42 +++++++++++------------------ 1 file changed, 16 insertions(+), 26 deletions(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index f307ce4c8..23cc0320d 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -492,28 +492,24 @@ private void close (bool force) private HttpListenerAsyncResult getAsyncResultFromQueue () { - lock (_waitQueueSync) { - if (_waitQueue.Count == 0) - return null; + if (_waitQueue.Count == 0) + return null; - var ares = _waitQueue[0]; - _waitQueue.RemoveAt (0); + var ares = _waitQueue[0]; + _waitQueue.RemoveAt (0); - return ares; - } + return ares; } private HttpListenerContext getContextFromQueue () { - lock (_ctxQueueSync) { - if (_ctxQueue.Count == 0) - return null; + if (_ctxQueue.Count == 0) + return null; - var ctx = _ctxQueue[0]; - _ctxQueue.RemoveAt (0); + var ctx = _ctxQueue[0]; + _ctxQueue.RemoveAt (0); - return ctx; - } + return ctx; } #endregion @@ -572,13 +568,10 @@ internal HttpListenerAsyncResult BeginGetContext (HttpListenerAsyncResult asyncR throw new HttpListenerException (995); var ctx = getContextFromQueue (); - if (ctx == null) { - lock (_waitQueueSync) - _waitQueue.Add (asyncResult); - } - else { + if (ctx == null) + _waitQueue.Add (asyncResult); + else asyncResult.Complete (ctx, true); - } return asyncResult; } @@ -602,13 +595,10 @@ internal bool RegisterContext (HttpListenerContext context) _ctxRegistry[context] = context; var ares = getAsyncResultFromQueue (); - if (ares == null) { - lock (_ctxQueueSync) - _ctxQueue.Add (context); - } - else { + if (ares == null) + _ctxQueue.Add (context); + else ares.Complete (context); - } return true; } From 3e6646f365cb82ebcdf7a191ae581fad3d38ee84 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 18 Apr 2016 14:44:10 +0900 Subject: [PATCH 0382/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListener.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 23cc0320d..1973ad97e 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -526,9 +526,8 @@ internal bool AddConnection (HttpConnection connection) return false; _connections[connection] = connection; + return true; } - - return true; } internal bool Authenticate (HttpListenerContext context) From f36083f8ff51d9523e5c8112737e1d8416bc54b1 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 18 Apr 2016 14:52:07 +0900 Subject: [PATCH 0383/6294] [Modify] Remove it --- websocket-sharp/Net/HttpConnection.cs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/websocket-sharp/Net/HttpConnection.cs b/websocket-sharp/Net/HttpConnection.cs index d941278a0..08ea56b7f 100644 --- a/websocket-sharp/Net/HttpConnection.cs +++ b/websocket-sharp/Net/HttpConnection.cs @@ -303,12 +303,8 @@ private static void onRead (IAsyncResult asyncResult) } conn._contextBound = true; - if (!lsnr.RegisterContext (conn._context)) { + if (!lsnr.RegisterContext (conn._context)) conn._contextBound = false; - conn.close (); - - return; - } return; } From ff5c62eedb1d0b772322e46be3dce9a4f549c7a3 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 19 Apr 2016 14:48:00 +0900 Subject: [PATCH 0384/6294] [Fix] Move it --- websocket-sharp/Net/HttpConnection.cs | 5 ++--- websocket-sharp/Net/HttpListener.cs | 3 +++ websocket-sharp/Net/HttpListenerAsyncResult.cs | 12 ------------ 3 files changed, 5 insertions(+), 15 deletions(-) diff --git a/websocket-sharp/Net/HttpConnection.cs b/websocket-sharp/Net/HttpConnection.cs index 08ea56b7f..5be058ddb 100644 --- a/websocket-sharp/Net/HttpConnection.cs +++ b/websocket-sharp/Net/HttpConnection.cs @@ -302,9 +302,8 @@ private static void onRead (IAsyncResult asyncResult) conn._lastListener = lsnr; } - conn._contextBound = true; - if (!lsnr.RegisterContext (conn._context)) - conn._contextBound = false; + if (lsnr.RegisterContext (conn._context)) + conn._contextBound = true; return; } diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 1973ad97e..cdcb476c4 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -587,6 +587,9 @@ internal bool RegisterContext (HttpListenerContext context) if (!_listening) return false; + if (!Authenticate (context)) + return false; + lock (_ctxRegistrySync) { if (!_listening) return false; diff --git a/websocket-sharp/Net/HttpListenerAsyncResult.cs b/websocket-sharp/Net/HttpListenerAsyncResult.cs index 37cdf0b48..a1c737421 100644 --- a/websocket-sharp/Net/HttpListenerAsyncResult.cs +++ b/websocket-sharp/Net/HttpListenerAsyncResult.cs @@ -179,18 +179,6 @@ internal void Complete (HttpListenerContext context) internal void Complete (HttpListenerContext context, bool syncCompleted) { - try { - var lsnr = context.Listener; - if (!lsnr.Authenticate (context)) { - lsnr.BeginGetContext (this); - return; - } - } - catch (Exception ex) { - Complete (ex); - return; - } - _context = context; _syncCompleted = syncCompleted; From bc48dbf68b8c342eaa05c7b28062c3e030d735a5 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 20 Apr 2016 14:16:26 +0900 Subject: [PATCH 0385/6294] [Modify] Move it --- websocket-sharp/Net/HttpListener.cs | 32 +------------------- websocket-sharp/Net/HttpListenerContext.cs | 34 ++++++++++++++++++++++ 2 files changed, 35 insertions(+), 31 deletions(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index cdcb476c4..1966c57f6 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -530,36 +530,6 @@ internal bool AddConnection (HttpConnection connection) } } - internal bool Authenticate (HttpListenerContext context) - { - var schm = SelectAuthenticationScheme (context); - if (schm == AuthenticationSchemes.Anonymous) - return true; - - if (schm != AuthenticationSchemes.Basic && schm != AuthenticationSchemes.Digest) { - context.Response.Close (HttpStatusCode.Forbidden); - return false; - } - - var realm = Realm; - var req = context.Request; - var user = - HttpUtility.CreateUser ( - req.Headers["Authorization"], schm, realm, req.HttpMethod, UserCredentialsFinder - ); - - if (user == null || !user.Identity.IsAuthenticated) { - context.Response.CloseWithAuthChallenge ( - new AuthenticationChallenge (schm, realm).ToString () - ); - - return false; - } - - context.User = user; - return true; - } - internal HttpListenerAsyncResult BeginGetContext (HttpListenerAsyncResult asyncResult) { lock (_ctxRegistrySync) { @@ -587,7 +557,7 @@ internal bool RegisterContext (HttpListenerContext context) if (!_listening) return false; - if (!Authenticate (context)) + if (!context.Authenticate ()) return false; lock (_ctxRegistrySync) { diff --git a/websocket-sharp/Net/HttpListenerContext.cs b/websocket-sharp/Net/HttpListenerContext.cs index b5b86b614..397c2db0e 100644 --- a/websocket-sharp/Net/HttpListenerContext.cs +++ b/websocket-sharp/Net/HttpListenerContext.cs @@ -166,6 +166,40 @@ internal set { #endregion + #region Internal Methods + + internal bool Authenticate () + { + var schm = _listener.SelectAuthenticationScheme (this); + if (schm == AuthenticationSchemes.Anonymous) + return true; + + if (schm != AuthenticationSchemes.Basic && schm != AuthenticationSchemes.Digest) { + _response.Close (HttpStatusCode.Forbidden); + return false; + } + + var realm = _listener.Realm; + var user = + HttpUtility.CreateUser ( + _request.Headers["Authorization"], + schm, + realm, + _request.HttpMethod, + _listener.UserCredentialsFinder + ); + + if (user == null || !user.Identity.IsAuthenticated) { + _response.CloseWithAuthChallenge (new AuthenticationChallenge (schm, realm).ToString ()); + return false; + } + + _user = user; + return true; + } + + #endregion + #region Public Methods /// From 4246526a1c9e3d16ac55bb6ebea38538837528af Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 21 Apr 2016 15:20:39 +0900 Subject: [PATCH 0386/6294] [Modify] Replace it --- websocket-sharp/Net/HttpListener.cs | 7 +++---- websocket-sharp/Net/HttpListenerContext.cs | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 1966c57f6..a5a7448f2 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -582,11 +582,10 @@ internal void RemoveConnection (HttpConnection connection) _connections.Remove (connection); } - internal AuthenticationSchemes SelectAuthenticationScheme (HttpListenerContext context) + internal AuthenticationSchemes SelectAuthenticationScheme (HttpListenerRequest request) { - return AuthenticationSchemeSelector != null - ? AuthenticationSchemeSelector (context.Request) - : _authSchemes; + var selector = _authSchemeSelector; + return selector != null ? selector (request) : _authSchemes; } internal void UnregisterContext (HttpListenerContext context) diff --git a/websocket-sharp/Net/HttpListenerContext.cs b/websocket-sharp/Net/HttpListenerContext.cs index 397c2db0e..b0a40a9e6 100644 --- a/websocket-sharp/Net/HttpListenerContext.cs +++ b/websocket-sharp/Net/HttpListenerContext.cs @@ -170,7 +170,7 @@ internal set { internal bool Authenticate () { - var schm = _listener.SelectAuthenticationScheme (this); + var schm = _listener.SelectAuthenticationScheme (_request); if (schm == AuthenticationSchemes.Anonymous) return true; From 9df6d9986cd0b0936ae00b43274698edb2fb9f0e Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 22 Apr 2016 15:25:01 +0900 Subject: [PATCH 0387/6294] [Modify] Add another way to get the realm --- websocket-sharp/Net/HttpListener.cs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index a5a7448f2..e6edc6733 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -71,6 +71,7 @@ public sealed class HttpListener : IDisposable private Dictionary _ctxRegistry; private object _ctxRegistrySync; private Func _credFinder; + private static readonly string _defaultRealm; private bool _disposed; private bool _ignoreWriteExceptions; private volatile bool _listening; @@ -84,6 +85,15 @@ public sealed class HttpListener : IDisposable #endregion + #region Static Constructor + + static HttpListener () + { + _defaultRealm = "SECRET AREA"; + } + + #endregion + #region Public Constructors /// @@ -552,6 +562,12 @@ internal void CheckDisposed () throw new ObjectDisposedException (GetType ().ToString ()); } + internal string GetRealm () + { + var realm = _realm; + return realm != null && realm.Length > 0 ? realm : _defaultRealm; + } + internal bool RegisterContext (HttpListenerContext context) { if (!_listening) From a4b3800a219b075231362a54ce055f991d3736a5 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 22 Apr 2016 15:33:34 +0900 Subject: [PATCH 0388/6294] [Modify] Replace it --- websocket-sharp/Net/HttpListenerContext.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerContext.cs b/websocket-sharp/Net/HttpListenerContext.cs index b0a40a9e6..ca3510ab5 100644 --- a/websocket-sharp/Net/HttpListenerContext.cs +++ b/websocket-sharp/Net/HttpListenerContext.cs @@ -179,7 +179,7 @@ internal bool Authenticate () return false; } - var realm = _listener.Realm; + var realm = _listener.GetRealm (); var user = HttpUtility.CreateUser ( _request.Headers["Authorization"], From f0b53b9e7f0dd4fd401d8f60fe959b6551c4b552 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 23 Apr 2016 16:08:05 +0900 Subject: [PATCH 0389/6294] [Modify] Polish it Return directly the value. --- websocket-sharp/Net/HttpListener.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index e6edc6733..07d02a5c6 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -315,9 +315,13 @@ public HttpListenerPrefixCollection Prefixes { /// /// Gets or sets the name of the realm associated with the listener. /// + /// + /// If this property is or empty, "SECRET AREA" will be used as + /// the name of the realm. + /// /// /// A that represents the name of the realm. The default value is - /// "SECRET AREA". + /// . /// /// /// This listener has been closed. @@ -325,7 +329,7 @@ public HttpListenerPrefixCollection Prefixes { public string Realm { get { CheckDisposed (); - return _realm != null && _realm.Length > 0 ? _realm : (_realm = "SECRET AREA"); + return _realm; } set { From 4186bf72d62b64dccacf116b73247206530fe820 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 24 Apr 2016 16:13:55 +0900 Subject: [PATCH 0390/6294] [Modify] Polish it --- websocket-sharp/Server/HttpServer.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index d4ec6ad98..46e99bdd1 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -388,9 +388,13 @@ public int Port { /// /// Gets or sets the name of the realm associated with the server. /// + /// + /// If this property is or empty, "SECRET AREA" will be used as + /// the name of the realm. + /// /// /// A that represents the name of the realm. The default value is - /// "SECRET AREA". + /// . /// public string Realm { get { From bb9dcb9bbc214898d61e826c604f5c7c0a6881be Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 24 Apr 2016 16:15:37 +0900 Subject: [PATCH 0391/6294] [Modify] 2016 --- websocket-sharp/Server/HttpServer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 46e99bdd1..c5a75abdd 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -6,7 +6,7 @@ * * The MIT License * - * Copyright (c) 2012-2015 sta.blockhead + * Copyright (c) 2012-2016 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From b6e0a74f252229b57f7663f25f67ad6a13153735 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 25 Apr 2016 15:44:55 +0900 Subject: [PATCH 0392/6294] [Modify] Polish it It's same as the HttpListener class. --- websocket-sharp/Server/WebSocketServer.cs | 26 ++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 457df8c6d..cb5c4c01b 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -63,6 +63,7 @@ public class WebSocketServer private System.Net.IPAddress _address; private AuthenticationSchemes _authSchemes; private Func _credFinder; + private static readonly string _defaultRealm; private bool _dnsStyle; private string _hostname; private TcpListener _listener; @@ -79,6 +80,15 @@ public class WebSocketServer #endregion + #region Static Constructor + + static WebSocketServer () + { + _defaultRealm = "SECRET AREA"; + } + + #endregion + #region Public Constructors /// @@ -393,13 +403,17 @@ public int Port { /// /// Gets or sets the name of the realm associated with the server. /// + /// + /// If this property is or empty, "SECRET AREA" will be used as + /// the name of the realm. + /// /// /// A that represents the name of the realm. The default value is - /// "SECRET AREA". + /// . /// public string Realm { get { - return _realm ?? (_realm = "SECRET AREA"); + return _realm; } set { @@ -592,6 +606,12 @@ private string checkIfCertificateExists () : null; } + private string getRealm () + { + var realm = _realm; + return realm != null && realm.Length > 0 ? realm : _defaultRealm; + } + private void init (string hostname, System.Net.IPAddress address, int port, bool secure) { _hostname = hostname ?? address.ToString (); @@ -642,7 +662,7 @@ private void receiveRequest () try { var ctx = cl.GetWebSocketContext (null, _secure, _sslConfig, _logger); if (_authSchemes != AuthenticationSchemes.Anonymous && - !authenticate (ctx, _authSchemes, Realm, UserCredentialsFinder)) + !authenticate (ctx, _authSchemes, getRealm (), UserCredentialsFinder)) return; processRequest (ctx); From baadd7255840d300b653662bd5b90ae4ad1200ff Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 26 Apr 2016 15:07:34 +0900 Subject: [PATCH 0393/6294] [Modify] Add it --- websocket-sharp/Server/WebSocketServer.cs | 45 +++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index cb5c4c01b..d72c51a0c 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -558,6 +558,51 @@ private void abort () _state = ServerState.Stop; } + private bool authenticate (TcpListenerWebSocketContext context) + { + var schm = _authSchemes; + if (schm == AuthenticationSchemes.Anonymous) + return true; + + if (schm != AuthenticationSchemes.Basic && schm != AuthenticationSchemes.Digest) { + context.Close (HttpStatusCode.Forbidden); + return false; + } + + var realm = getRealm (); + var chal = new AuthenticationChallenge (schm, realm).ToString (); + + var retry = -1; + Func auth = null; + auth = + () => { + retry++; + if (retry > 99) { + context.Close (HttpStatusCode.Forbidden); + return false; + } + + var user = + HttpUtility.CreateUser ( + context.Headers["Authorization"], + schm, + realm, + context.HttpMethod, + UserCredentialsFinder + ); + + if (user != null && user.Identity.IsAuthenticated) { + context.SetUser (user); + return true; + } + + context.SendAuthenticationChallenge (chal); + return auth (); + }; + + return auth (); + } + private static bool authenticate ( TcpListenerWebSocketContext context, AuthenticationSchemes scheme, From f0dabbc95790f18d0d6d9a3e0f11af06f1fef33e Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 27 Apr 2016 15:29:37 +0900 Subject: [PATCH 0394/6294] [Modify] Replace it --- websocket-sharp/Server/WebSocketServer.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index d72c51a0c..f4e103e1b 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -706,8 +706,7 @@ private void receiveRequest () state => { try { var ctx = cl.GetWebSocketContext (null, _secure, _sslConfig, _logger); - if (_authSchemes != AuthenticationSchemes.Anonymous && - !authenticate (ctx, _authSchemes, getRealm (), UserCredentialsFinder)) + if (!authenticate (ctx)) return; processRequest (ctx); From 012952b6e482f81f41822f0e5487eed9a0f1ab41 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 27 Apr 2016 15:32:24 +0900 Subject: [PATCH 0395/6294] [Modify] Remove it --- websocket-sharp/Server/WebSocketServer.cs | 41 ----------------------- 1 file changed, 41 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index f4e103e1b..1932d545d 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -603,47 +603,6 @@ private bool authenticate (TcpListenerWebSocketContext context) return auth (); } - private static bool authenticate ( - TcpListenerWebSocketContext context, - AuthenticationSchemes scheme, - string realm, - Func credentialsFinder) - { - var chal = scheme == AuthenticationSchemes.Basic - ? AuthenticationChallenge.CreateBasicChallenge (realm).ToBasicString () - : scheme == AuthenticationSchemes.Digest - ? AuthenticationChallenge.CreateDigestChallenge (realm).ToDigestString () - : null; - - if (chal == null) { - context.Close (HttpStatusCode.Forbidden); - return false; - } - - var retry = -1; - Func auth = null; - auth = () => { - retry++; - if (retry > 99) { - context.Close (HttpStatusCode.Forbidden); - return false; - } - - var user = HttpUtility.CreateUser ( - context.Headers["Authorization"], scheme, realm, context.HttpMethod, credentialsFinder); - - if (user != null && user.Identity.IsAuthenticated) { - context.SetUser (user); - return true; - } - - context.SendAuthenticationChallenge (chal); - return auth (); - }; - - return auth (); - } - private string checkIfCertificateExists () { return _secure && (_sslConfig == null || _sslConfig.ServerCertificate == null) From ad6c08dc72438bca91f887e09ec64813e63d79f9 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 27 Apr 2016 15:35:50 +0900 Subject: [PATCH 0396/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketServer.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 1932d545d..101681d7a 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -674,7 +674,8 @@ private void receiveRequest () _logger.Fatal (ex.ToString ()); cl.Close (); } - }); + } + ); } catch (SocketException ex) { _logger.Warn ("Receiving has been stopped.\n reason: " + ex.Message); From dffa4e800686c7320896002c9de1b85748f3f58c Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 28 Apr 2016 16:00:12 +0900 Subject: [PATCH 0397/6294] [Modify] Add it --- .../WebSockets/TcpListenerWebSocketContext.cs | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs index 9def9f3d2..7c3938e3e 100644 --- a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs @@ -355,6 +355,53 @@ public override WebSocket WebSocket { #region Internal Methods + internal bool Authenticate ( + AuthenticationSchemes scheme, + string realm, + Func credentialsFinder + ) + { + if (scheme == AuthenticationSchemes.Anonymous) + return true; + + if (scheme != AuthenticationSchemes.Basic && scheme != AuthenticationSchemes.Digest) { + Close (HttpStatusCode.Forbidden); + return false; + } + + var chal = new AuthenticationChallenge (scheme, realm).ToString (); + + var retry = -1; + Func auth = null; + auth = + () => { + retry++; + if (retry > 99) { + Close (HttpStatusCode.Forbidden); + return false; + } + + var user = + HttpUtility.CreateUser ( + _request.Headers["Authorization"], + scheme, + realm, + _request.HttpMethod, + credentialsFinder + ); + + if (user == null || !user.Identity.IsAuthenticated) { + SendAuthenticationChallenge (chal); + return auth (); + } + + _user = user; + return true; + }; + + return auth (); + } + internal void Close () { _stream.Close (); From 7e70add981647f0efc7c09f2a27253d7f033544b Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 28 Apr 2016 16:08:26 +0900 Subject: [PATCH 0398/6294] [Modify] Replace it --- websocket-sharp/Server/WebSocketServer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 101681d7a..f69eaf86e 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -665,7 +665,7 @@ private void receiveRequest () state => { try { var ctx = cl.GetWebSocketContext (null, _secure, _sslConfig, _logger); - if (!authenticate (ctx)) + if (!ctx.Authenticate (_authSchemes, getRealm (), UserCredentialsFinder)) return; processRequest (ctx); From 911bdc159189777aa232e9693f3d3fd724b01a22 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 28 Apr 2016 16:11:11 +0900 Subject: [PATCH 0399/6294] [Modify] Remove it --- websocket-sharp/Server/WebSocketServer.cs | 45 ----------------------- 1 file changed, 45 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index f69eaf86e..632ac34d3 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -558,51 +558,6 @@ private void abort () _state = ServerState.Stop; } - private bool authenticate (TcpListenerWebSocketContext context) - { - var schm = _authSchemes; - if (schm == AuthenticationSchemes.Anonymous) - return true; - - if (schm != AuthenticationSchemes.Basic && schm != AuthenticationSchemes.Digest) { - context.Close (HttpStatusCode.Forbidden); - return false; - } - - var realm = getRealm (); - var chal = new AuthenticationChallenge (schm, realm).ToString (); - - var retry = -1; - Func auth = null; - auth = - () => { - retry++; - if (retry > 99) { - context.Close (HttpStatusCode.Forbidden); - return false; - } - - var user = - HttpUtility.CreateUser ( - context.Headers["Authorization"], - schm, - realm, - context.HttpMethod, - UserCredentialsFinder - ); - - if (user != null && user.Identity.IsAuthenticated) { - context.SetUser (user); - return true; - } - - context.SendAuthenticationChallenge (chal); - return auth (); - }; - - return auth (); - } - private string checkIfCertificateExists () { return _secure && (_sslConfig == null || _sslConfig.ServerCertificate == null) From b95b61627cfa6d5c7591ceba0a53f59edf791356 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 28 Apr 2016 16:16:19 +0900 Subject: [PATCH 0400/6294] [Modify] Remove it --- .../Net/WebSockets/TcpListenerWebSocketContext.cs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs index 7c3938e3e..31ae9ed6f 100644 --- a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs @@ -420,11 +420,6 @@ internal void SendAuthenticationChallenge (string challenge) _request = HttpRequest.Read (_stream, 15000); } - internal void SetUser (IPrincipal value) - { - _user = value; - } - #endregion #region Public Methods From b9ffe1c81536e6dd5e26c6607a37e352481f224d Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 28 Apr 2016 16:20:59 +0900 Subject: [PATCH 0401/6294] [Modify] Remove it --- .../Net/WebSockets/TcpListenerWebSocketContext.cs | 6 ------ 1 file changed, 6 deletions(-) diff --git a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs index 31ae9ed6f..78e39de2c 100644 --- a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs @@ -107,12 +107,6 @@ internal TcpListenerWebSocketContext ( #region Internal Properties - internal string HttpMethod { - get { - return _request.HttpMethod; - } - } - internal Logger Log { get { return _logger; From 1773ea2e56de2f91ce9907d9a0d4734277875159 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 29 Apr 2016 15:13:39 +0900 Subject: [PATCH 0402/6294] [Modify] Polish it --- .../WebSockets/TcpListenerWebSocketContext.cs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs index 78e39de2c..429341724 100644 --- a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs @@ -73,7 +73,8 @@ internal TcpListenerWebSocketContext ( string protocol, bool secure, ServerSslConfiguration sslConfig, - Logger logger) + Logger logger + ) { _tcpClient = tcpClient; _secure = secure; @@ -81,14 +82,15 @@ internal TcpListenerWebSocketContext ( var netStream = tcpClient.GetStream (); if (secure) { - var sslStream = new SslStream ( - netStream, false, sslConfig.ClientCertificateValidationCallback); + var sslStream = + new SslStream (netStream, false, sslConfig.ClientCertificateValidationCallback); sslStream.AuthenticateAsServer ( sslConfig.ServerCertificate, sslConfig.ClientCertificateRequired, sslConfig.EnabledSslProtocols, - sslConfig.CheckCertificateRevocation); + sslConfig.CheckCertificateRevocation + ); _stream = sslStream; } @@ -97,8 +99,10 @@ internal TcpListenerWebSocketContext ( } _request = HttpRequest.Read (_stream, 90000); - _uri = HttpUtility.CreateRequestUrl ( - _request.RequestUri, _request.Headers["Host"], _request.IsWebSocketRequest, secure); + _uri = + HttpUtility.CreateRequestUrl ( + _request.RequestUri, _request.Headers["Host"], _request.IsWebSocketRequest, secure + ); _websocket = new WebSocket (this, protocol); } From 18a04f1849a2b73b6745fc54818a10acffc04b4a Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 30 Apr 2016 17:41:33 +0900 Subject: [PATCH 0403/6294] [Modify] Polish it --- .../Net/WebSockets/TcpListenerWebSocketContext.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs index 429341724..bf225a584 100644 --- a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs @@ -231,9 +231,13 @@ public override string Origin { /// public override NameValueCollection QueryString { get { - return _queryString ?? - (_queryString = HttpUtility.InternalParseQueryString ( - _uri != null ? _uri.Query : null, Encoding.UTF8)); + return _queryString + ?? ( + _queryString = + HttpUtility.InternalParseQueryString ( + _uri != null ? _uri.Query : null, Encoding.UTF8 + ) + ); } } From 6b6841f03b83fa75c9478188e46343e383ad8a6e Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 1 May 2016 15:53:01 +0900 Subject: [PATCH 0404/6294] [Modify] Polish it --- websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs index bf225a584..657e0cf47 100644 --- a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs @@ -283,9 +283,10 @@ public override string SecWebSocketKey { public override IEnumerable SecWebSocketProtocols { get { var protocols = _request.Headers["Sec-WebSocket-Protocol"]; - if (protocols != null) + if (protocols != null) { foreach (var protocol in protocols.Split (',')) yield return protocol.Trim (); + } } } From e1acf47ecf4bbcc0c6fe6c97f54b24124392e786 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 2 May 2016 15:23:54 +0900 Subject: [PATCH 0405/6294] [Modify] Polish it --- websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs index 657e0cf47..b02275747 100644 --- a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs @@ -46,8 +46,8 @@ namespace WebSocketSharp.Net.WebSockets { /// - /// Provides the properties used to access the information in a WebSocket connection request - /// received by the . + /// Provides the properties used to access the information in + /// a WebSocket handshake request received by the . /// internal class TcpListenerWebSocketContext : WebSocketContext { From 67c2e7c023d5cef4a33aedc1f684b7414b9dfd1f Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 2 May 2016 15:27:48 +0900 Subject: [PATCH 0406/6294] [Modify] Polish it --- websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs index b02275747..9f6022fe3 100644 --- a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs @@ -200,10 +200,10 @@ public override bool IsSecureConnection { } /// - /// Gets a value indicating whether the request is a WebSocket connection request. + /// Gets a value indicating whether the request is a WebSocket handshake request. /// /// - /// true if the request is a WebSocket connection request; otherwise, false. + /// true if the request is a WebSocket handshake request; otherwise, false. /// public override bool IsWebSocketRequest { get { From 28a60ec94fa9ecb191ef1f10e7eef78e9c0b9baf Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 2 May 2016 15:32:43 +0900 Subject: [PATCH 0407/6294] [Modify] Polish it --- websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs index 9f6022fe3..80a7fbf68 100644 --- a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs @@ -257,8 +257,8 @@ public override Uri RequestUri { /// Gets the value of the Sec-WebSocket-Key header included in the request. /// /// - /// This property provides a part of the information used by the server to prove that it - /// received a valid WebSocket connection request. + /// This property provides a part of the information used by the server to prove that + /// it received a valid WebSocket handshake request. /// /// /// A that represents the value of the Sec-WebSocket-Key header. From c205ecce67539be311db81ede0459e746b469737 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 2 May 2016 15:40:34 +0900 Subject: [PATCH 0408/6294] [Modify] Polish it --- websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs index 80a7fbf68..00fdf36ff 100644 --- a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs @@ -342,8 +342,8 @@ public override System.Net.IPEndPoint UserEndPoint { } /// - /// Gets the instance used for two-way communication - /// between client and server. + /// Gets the instance used for + /// two-way communication between client and server. /// /// /// A . From 9c055b12677cfdf95b519b92ef7330f5622dda79 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 2 May 2016 15:44:01 +0900 Subject: [PATCH 0409/6294] [Modify] Polish it --- .../Net/WebSockets/TcpListenerWebSocketContext.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs index 00fdf36ff..762c762f6 100644 --- a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs @@ -428,12 +428,12 @@ internal void SendAuthenticationChallenge (string challenge) #region Public Methods /// - /// Returns a that represents the current - /// . + /// Returns a that represents + /// the current . /// /// - /// A that represents the current - /// . + /// A that represents + /// the current . /// public override string ToString () { From 0f77b341569a3579e343fb135ace9baf97cd7da5 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 2 May 2016 15:49:19 +0900 Subject: [PATCH 0410/6294] [Modify] Remove it --- websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs index 762c762f6..81b6a29a9 100644 --- a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs @@ -39,7 +39,6 @@ using System.IO; using System.Net.Security; using System.Net.Sockets; -using System.Security.Cryptography.X509Certificates; using System.Security.Principal; using System.Text; From a07860f3c176d120930325c244ee12755afdcc47 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 3 May 2016 15:20:52 +0900 Subject: [PATCH 0411/6294] [Modify] 2016 --- websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs index 81b6a29a9..adb6fc7bf 100644 --- a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs @@ -4,7 +4,7 @@ * * The MIT License * - * Copyright (c) 2012-2015 sta.blockhead + * Copyright (c) 2012-2016 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From 86947f66a17c8b0796efa79b6a19aa77f7b96623 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 4 May 2016 15:33:04 +0900 Subject: [PATCH 0412/6294] [Fix] Set system error code 87 --- websocket-sharp/Net/EndPointManager.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/EndPointManager.cs b/websocket-sharp/Net/EndPointManager.cs index 11fada49a..bc6a2787b 100644 --- a/websocket-sharp/Net/EndPointManager.cs +++ b/websocket-sharp/Net/EndPointManager.cs @@ -85,10 +85,10 @@ private static void addPrefix (string uriPrefix, HttpListener listener) var path = pref.Path; if (path.IndexOf ('%') != -1) - throw new HttpListenerException (400, "Invalid path."); // TODO: Code? + throw new HttpListenerException (87, "Invalid path."); if (path.IndexOf ("//", StringComparison.Ordinal) != -1) - throw new HttpListenerException (400, "Invalid path."); // TODO: Code? + throw new HttpListenerException (87, "Invalid path."); // Listens on all the interfaces if host name cannot be parsed by IPAddress. getEndPointListener (pref, listener).AddPrefix (pref, listener); From be1adc82f18163dcf0b8d44788abb083e9fade2c Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 5 May 2016 16:15:24 +0900 Subject: [PATCH 0413/6294] [Modify] Polish it --- websocket-sharp/Net/EndPointManager.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/EndPointManager.cs b/websocket-sharp/Net/EndPointManager.cs index bc6a2787b..d1c1f63ed 100644 --- a/websocket-sharp/Net/EndPointManager.cs +++ b/websocket-sharp/Net/EndPointManager.cs @@ -85,10 +85,10 @@ private static void addPrefix (string uriPrefix, HttpListener listener) var path = pref.Path; if (path.IndexOf ('%') != -1) - throw new HttpListenerException (87, "Invalid path."); + throw new HttpListenerException (87, "Includes an invalid path."); if (path.IndexOf ("//", StringComparison.Ordinal) != -1) - throw new HttpListenerException (87, "Invalid path."); + throw new HttpListenerException (87, "Includes an invalid path."); // Listens on all the interfaces if host name cannot be parsed by IPAddress. getEndPointListener (pref, listener).AddPrefix (pref, listener); From aad7490e5d5e553af6a297f025561ec52090dad4 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 5 May 2016 16:26:10 +0900 Subject: [PATCH 0414/6294] [Modify] Polish it --- websocket-sharp/Net/EndPointManager.cs | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/websocket-sharp/Net/EndPointManager.cs b/websocket-sharp/Net/EndPointManager.cs index d1c1f63ed..7f8c9ca83 100644 --- a/websocket-sharp/Net/EndPointManager.cs +++ b/websocket-sharp/Net/EndPointManager.cs @@ -113,7 +113,8 @@ private static IPAddress convertToIPAddress (string hostname) } private static EndPointListener getEndPointListener ( - HttpListenerPrefix prefix, HttpListener listener) + HttpListenerPrefix prefix, HttpListener listener + ) { var addr = convertToIPAddress (prefix.Host); @@ -133,13 +134,15 @@ private static EndPointListener getEndPointListener ( lsnr = eps[port]; } else { - lsnr = new EndPointListener ( - addr, - port, - listener.ReuseAddress, - prefix.IsSecure, - listener.CertificateFolderPath, - listener.SslConfiguration); + lsnr = + new EndPointListener ( + addr, + port, + listener.ReuseAddress, + prefix.IsSecure, + listener.CertificateFolderPath, + listener.SslConfiguration + ); eps[port] = lsnr; } From 7e6896fc0c33b5ec550397d8f4cec0b1d27f5f6d Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 5 May 2016 16:39:11 +0900 Subject: [PATCH 0415/6294] [Modify] Polish it --- websocket-sharp/Net/EndPointManager.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/EndPointManager.cs b/websocket-sharp/Net/EndPointManager.cs index 7f8c9ca83..5d1075920 100644 --- a/websocket-sharp/Net/EndPointManager.cs +++ b/websocket-sharp/Net/EndPointManager.cs @@ -212,9 +212,10 @@ public static void AddPrefix (string uriPrefix, HttpListener listener) public static void RemoveListener (HttpListener listener) { - lock (((ICollection) _addressToEndpoints).SyncRoot) + lock (((ICollection) _addressToEndpoints).SyncRoot) { foreach (var pref in listener.Prefixes) removePrefix (pref, listener); + } } public static void RemovePrefix (string uriPrefix, HttpListener listener) From a231a935a9990422b1104112e043df141253acc5 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 6 May 2016 17:06:39 +0900 Subject: [PATCH 0416/6294] [Modify] 2016 --- websocket-sharp/Net/EndPointManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/EndPointManager.cs b/websocket-sharp/Net/EndPointManager.cs index 5d1075920..6b1feb189 100644 --- a/websocket-sharp/Net/EndPointManager.cs +++ b/websocket-sharp/Net/EndPointManager.cs @@ -8,7 +8,7 @@ * The MIT License * * Copyright (c) 2005 Novell, Inc. (http://www.novell.com) - * Copyright (c) 2012-2015 sta.blockhead + * Copyright (c) 2012-2016 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From 9f8a95980f1d16a21e1bc6a7f88c40d6ff1dba09 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 7 May 2016 17:30:01 +0900 Subject: [PATCH 0417/6294] [Fix] Determine that IPAddress.IPv6Any is a local IP address if available Fix for pull request #243. --- websocket-sharp/Ext.cs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index a9ce853ea..4c0c3e886 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1297,9 +1297,20 @@ public static bool IsLocal (this System.Net.IPAddress address) if (address == null) return false; - if (address.Equals (System.Net.IPAddress.Any) || System.Net.IPAddress.IsLoopback (address)) + if (address.Equals (System.Net.IPAddress.Any)) return true; + if (address.Equals (System.Net.IPAddress.Loopback)) + return true; + + if (Socket.OSSupportsIPv6) { + if (address.Equals (System.Net.IPAddress.IPv6Any)) + return true; + + if (address.Equals (System.Net.IPAddress.IPv6Loopback)) + return true; + } + var host = System.Net.Dns.GetHostName (); var addrs = System.Net.Dns.GetHostAddresses (host); foreach (var addr in addrs) From 322f3932da9a91228477e5f25a9aae6853dd3d80 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 8 May 2016 16:41:36 +0900 Subject: [PATCH 0418/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 4c0c3e886..a62009822 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1283,10 +1283,13 @@ public static bool IsHostOrder (this ByteOrder order) /// /// Determines whether the specified represents - /// the local IP address. + /// a local IP address. /// + /// + /// This local means NOT REMOTE for the current host. + /// /// - /// true if represents the local IP address; + /// true if represents a local IP address; /// otherwise, false. /// /// @@ -1313,9 +1316,10 @@ public static bool IsLocal (this System.Net.IPAddress address) var host = System.Net.Dns.GetHostName (); var addrs = System.Net.Dns.GetHostAddresses (host); - foreach (var addr in addrs) + foreach (var addr in addrs) { if (address.Equals (addr)) return true; + } return false; } From dcce88749a67c579b1d22ec28cbe45628b9ce7e6 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 9 May 2016 16:51:57 +0900 Subject: [PATCH 0419/6294] [Modify] Handle it --- websocket-sharp/Net/HttpListener.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 07d02a5c6..0c9269a59 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -605,7 +605,15 @@ internal void RemoveConnection (HttpConnection connection) internal AuthenticationSchemes SelectAuthenticationScheme (HttpListenerRequest request) { var selector = _authSchemeSelector; - return selector != null ? selector (request) : _authSchemes; + if (selector == null) + return _authSchemes; + + try { + return selector (request); + } + catch { + return AuthenticationSchemes.None; + } } internal void UnregisterContext (HttpListenerContext context) From a3586e941cc5b16c33db2dfe1eefc475248e3cfd Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 10 May 2016 16:26:04 +0900 Subject: [PATCH 0420/6294] [Modify] Rename it --- websocket-sharp/Net/HttpListener.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 0c9269a59..0464c2205 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -70,7 +70,6 @@ public sealed class HttpListener : IDisposable private object _ctxQueueSync; private Dictionary _ctxRegistry; private object _ctxRegistrySync; - private Func _credFinder; private static readonly string _defaultRealm; private bool _disposed; private bool _ignoreWriteExceptions; @@ -80,6 +79,7 @@ public sealed class HttpListener : IDisposable private string _realm; private bool _reuseAddress; private ServerSslConfiguration _sslConfig; + private Func _userCredFinder; private List _waitQueue; private object _waitQueueSync; @@ -402,12 +402,12 @@ public bool UnsafeConnectionNtlmAuthentication { public Func UserCredentialsFinder { get { CheckDisposed (); - return _credFinder ?? (_credFinder = id => null); + return _userCredFinder ?? (_userCredFinder = id => null); } set { CheckDisposed (); - _credFinder = value; + _userCredFinder = value; } } From 67b262dac2774385f7dd5ca420117e6ca155f27c Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 11 May 2016 14:24:17 +0900 Subject: [PATCH 0421/6294] [Modify] Add it --- websocket-sharp/Net/HttpListener.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 0464c2205..1a62307a2 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -572,6 +572,12 @@ internal string GetRealm () return realm != null && realm.Length > 0 ? realm : _defaultRealm; } + internal Func GetUserCredentialsFinder () + { + var finder = _userCredFinder; + return finder ?? (id => null); + } + internal bool RegisterContext (HttpListenerContext context) { if (!_listening) From b2c5f954ba2120318c7e52fd2ab329a6e6edd0a0 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 12 May 2016 17:13:55 +0900 Subject: [PATCH 0422/6294] [Modify] Polish it --- websocket-sharp/Net/HttpUtility.cs | 35 ++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index c5cd117ed..ad197b9dc 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -554,10 +554,19 @@ internal static IPrincipal CreateUser ( AuthenticationSchemes scheme, string realm, string method, - Func credentialsFinder) + Func credentialsFinder + ) { - if (response == null || - !response.StartsWith (scheme.ToString (), StringComparison.OrdinalIgnoreCase)) + if (response == null) + return null; + + if (!(scheme == AuthenticationSchemes.Basic || scheme == AuthenticationSchemes.Digest)) + return null; + + if (!response.StartsWith (scheme.ToString (), StringComparison.OrdinalIgnoreCase)) + return null; + + if (credentialsFinder == null) return null; var res = AuthenticationResponse.Parse (response); @@ -578,15 +587,19 @@ internal static IPrincipal CreateUser ( if (cred == null) return null; - var valid = scheme == AuthenticationSchemes.Basic - ? ((HttpBasicIdentity) id).Password == cred.Password - : scheme == AuthenticationSchemes.Digest - ? ((HttpDigestIdentity) id).IsValid (cred.Password, realm, method, null) - : false; + if (scheme == AuthenticationSchemes.Basic + && ((HttpBasicIdentity) id).Password != cred.Password + ) { + return null; + } + + if (scheme == AuthenticationSchemes.Digest + && !((HttpDigestIdentity) id).IsValid (cred.Password, realm, method, null) + ) { + return null; + } - return valid - ? new GenericPrincipal (id, cred.Roles) - : null; + return new GenericPrincipal (id, cred.Roles); } internal static Encoding GetEncoding (string contentType) From e018206536d430598b988470505d410c744529db Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 13 May 2016 17:20:37 +0900 Subject: [PATCH 0423/6294] [Modify] Polish it --- websocket-sharp/Net/HttpUtility.cs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index ad197b9dc..71dfdcffe 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -557,16 +557,24 @@ internal static IPrincipal CreateUser ( Func credentialsFinder ) { - if (response == null) + if (response == null || response.Length == 0) return null; - if (!(scheme == AuthenticationSchemes.Basic || scheme == AuthenticationSchemes.Digest)) + if (credentialsFinder == null) return null; - if (!response.StartsWith (scheme.ToString (), StringComparison.OrdinalIgnoreCase)) + if (!(scheme == AuthenticationSchemes.Basic || scheme == AuthenticationSchemes.Digest)) return null; - if (credentialsFinder == null) + if (scheme == AuthenticationSchemes.Digest) { + if (realm == null || realm.Length == 0) + return null; + + if (method == null || method.Length == 0) + return null; + } + + if (!response.StartsWith (scheme.ToString (), StringComparison.OrdinalIgnoreCase)) return null; var res = AuthenticationResponse.Parse (response); From f1fcec5cdecf321f646324bb848a86079d51af31 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 14 May 2016 15:14:26 +0900 Subject: [PATCH 0424/6294] [Modify] 2016 --- websocket-sharp/Net/HttpUtility.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 71dfdcffe..3e3c78cf6 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -8,7 +8,7 @@ * The MIT License * * Copyright (c) 2005-2009 Novell, Inc. (http://www.novell.com) - * Copyright (c) 2012-2014 sta.blockhead + * Copyright (c) 2012-2016 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From 6ec3fdeb123f276c4cde13da0108e11a59c87d64 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 14 May 2016 15:17:46 +0900 Subject: [PATCH 0425/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListener.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 1a62307a2..9a5ad839e 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -574,8 +574,7 @@ internal string GetRealm () internal Func GetUserCredentialsFinder () { - var finder = _userCredFinder; - return finder ?? (id => null); + return _userCredFinder; } internal bool RegisterContext (HttpListenerContext context) From 7e33636276e262221f00992ef01fc729116ce1da Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 14 May 2016 15:24:28 +0900 Subject: [PATCH 0426/6294] [Modify] Replace it --- websocket-sharp/Net/HttpListenerContext.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerContext.cs b/websocket-sharp/Net/HttpListenerContext.cs index ca3510ab5..96ce5cc50 100644 --- a/websocket-sharp/Net/HttpListenerContext.cs +++ b/websocket-sharp/Net/HttpListenerContext.cs @@ -186,7 +186,7 @@ internal bool Authenticate () schm, realm, _request.HttpMethod, - _listener.UserCredentialsFinder + _listener.GetUserCredentialsFinder () ); if (user == null || !user.Identity.IsAuthenticated) { From 11323ed8948010fee1b633bc36b8ed1c565246af Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 15 May 2016 15:02:04 +0900 Subject: [PATCH 0427/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerContext.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerContext.cs b/websocket-sharp/Net/HttpListenerContext.cs index 96ce5cc50..e789b1b20 100644 --- a/websocket-sharp/Net/HttpListenerContext.cs +++ b/websocket-sharp/Net/HttpListenerContext.cs @@ -174,7 +174,7 @@ internal bool Authenticate () if (schm == AuthenticationSchemes.Anonymous) return true; - if (schm != AuthenticationSchemes.Basic && schm != AuthenticationSchemes.Digest) { + if (schm == AuthenticationSchemes.None) { _response.Close (HttpStatusCode.Forbidden); return false; } From c091b2736e691be15ccbee5e6582411aeb6c9eec Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 15 May 2016 15:05:14 +0900 Subject: [PATCH 0428/6294] [Modify] Remove it --- websocket-sharp/Net/HttpListenerContext.cs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerContext.cs b/websocket-sharp/Net/HttpListenerContext.cs index e789b1b20..6dca7353e 100644 --- a/websocket-sharp/Net/HttpListenerContext.cs +++ b/websocket-sharp/Net/HttpListenerContext.cs @@ -158,10 +158,6 @@ public IPrincipal User { get { return _user; } - - internal set { - _user = value; - } } #endregion From 2da4a9b3a9f45f7e4dc20c95879ef8f8adbef176 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 15 May 2016 15:24:07 +0900 Subject: [PATCH 0429/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerContext.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerContext.cs b/websocket-sharp/Net/HttpListenerContext.cs index 6dca7353e..e3d691025 100644 --- a/websocket-sharp/Net/HttpListenerContext.cs +++ b/websocket-sharp/Net/HttpListenerContext.cs @@ -44,8 +44,8 @@ namespace WebSocketSharp.Net { /// - /// Provides the access to the HTTP request and response information - /// used by the . + /// Provides the access to the HTTP request and response objects used by + /// the . /// /// /// The HttpListenerContext class cannot be inherited. From 57f14af53c666399750c63cf0428636632dec573 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 15 May 2016 15:27:38 +0900 Subject: [PATCH 0430/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerContext.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerContext.cs b/websocket-sharp/Net/HttpListenerContext.cs index e3d691025..a6364bec6 100644 --- a/websocket-sharp/Net/HttpListenerContext.cs +++ b/websocket-sharp/Net/HttpListenerContext.cs @@ -48,7 +48,7 @@ namespace WebSocketSharp.Net /// the . /// /// - /// The HttpListenerContext class cannot be inherited. + /// This class cannot be inherited. /// public sealed class HttpListenerContext { From 28006eba7401ebaf85505047bcf7119efef11d8b Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 15 May 2016 15:36:39 +0900 Subject: [PATCH 0431/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerContext.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerContext.cs b/websocket-sharp/Net/HttpListenerContext.cs index a6364bec6..1cb1b5830 100644 --- a/websocket-sharp/Net/HttpListenerContext.cs +++ b/websocket-sharp/Net/HttpListenerContext.cs @@ -125,10 +125,10 @@ internal HttpListener Listener { #region Public Properties /// - /// Gets the HTTP request information from a client. + /// Gets the HTTP request object that represents a client request. /// /// - /// A that represents the HTTP request. + /// A that represents the client request. /// public HttpListenerRequest Request { get { From 9c57d888599dd5b2139ee60a7ebf23c60188e8e7 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 15 May 2016 15:51:32 +0900 Subject: [PATCH 0432/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerContext.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerContext.cs b/websocket-sharp/Net/HttpListenerContext.cs index 1cb1b5830..13a685164 100644 --- a/websocket-sharp/Net/HttpListenerContext.cs +++ b/websocket-sharp/Net/HttpListenerContext.cs @@ -137,10 +137,10 @@ public HttpListenerRequest Request { } /// - /// Gets the HTTP response information used to send to the client. + /// Gets the HTTP response object used to send a response to the client. /// /// - /// A that represents the HTTP response to send. + /// A that represents a response to the client request. /// public HttpListenerResponse Response { get { From 0f6138f533e1c182a1ec969e5df36a61d364bb1b Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 16 May 2016 16:13:38 +0900 Subject: [PATCH 0433/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerContext.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerContext.cs b/websocket-sharp/Net/HttpListenerContext.cs index 13a685164..99247beab 100644 --- a/websocket-sharp/Net/HttpListenerContext.cs +++ b/websocket-sharp/Net/HttpListenerContext.cs @@ -199,14 +199,15 @@ internal bool Authenticate () #region Public Methods /// - /// Accepts a WebSocket connection request. + /// Accepts a WebSocket handshake request. /// /// - /// A that represents the WebSocket connection - /// request. + /// A that represents + /// the WebSocket handshake request. /// /// - /// A that represents the subprotocol used in the WebSocket connection. + /// A that represents the subprotocol supported on + /// this WebSocket connection. /// /// /// From 4f13fcb423800795fab5edda8373e838dd90c9d9 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 16 May 2016 16:15:45 +0900 Subject: [PATCH 0434/6294] [Modify] 2016 --- websocket-sharp/Net/HttpListenerContext.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerContext.cs b/websocket-sharp/Net/HttpListenerContext.cs index 99247beab..3546406b4 100644 --- a/websocket-sharp/Net/HttpListenerContext.cs +++ b/websocket-sharp/Net/HttpListenerContext.cs @@ -8,7 +8,7 @@ * The MIT License * * Copyright (c) 2005 Novell, Inc. (http://www.novell.com) - * Copyright (c) 2012-2015 sta.blockhead + * Copyright (c) 2012-2016 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From 1b6e894d6d3fb83eb94a6abbb4abf3f9c665862b Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 17 May 2016 17:28:52 +0900 Subject: [PATCH 0435/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListener.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 9a5ad839e..7341d3aea 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -392,9 +392,9 @@ public bool UnsafeConnectionNtlmAuthentication { /// authenticate a client. /// /// - /// A Func<, > delegate that - /// references the method used to find the credentials. The default value is a function that - /// only returns . + /// A Func<, > delegate + /// that references the method used to find the credentials. The default value is + /// . /// /// /// This listener has been closed. @@ -402,7 +402,7 @@ public bool UnsafeConnectionNtlmAuthentication { public Func UserCredentialsFinder { get { CheckDisposed (); - return _userCredFinder ?? (_userCredFinder = id => null); + return _userCredFinder; } set { From cd964a5987c33722a0a3ce1c9beb1d60bbc17f5d Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 18 May 2016 14:40:38 +0900 Subject: [PATCH 0436/6294] [Modify] 2016 --- websocket-sharp/Net/HttpListener.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 7341d3aea..ed6358c2f 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -8,7 +8,7 @@ * The MIT License * * Copyright (c) 2005 Novell, Inc. (http://www.novell.com) - * Copyright (c) 2012-2015 sta.blockhead + * Copyright (c) 2012-2016 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From ab29d4db4fc75073f24e338a4cdee15bf47089a6 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 19 May 2016 16:30:54 +0900 Subject: [PATCH 0437/6294] [Fix] Throw invalid operation exception --- websocket-sharp/Net/HttpListenerContext.cs | 24 ++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerContext.cs b/websocket-sharp/Net/HttpListenerContext.cs index 3546406b4..911718b7c 100644 --- a/websocket-sharp/Net/HttpListenerContext.cs +++ b/websocket-sharp/Net/HttpListenerContext.cs @@ -54,13 +54,14 @@ public sealed class HttpListenerContext { #region Private Fields - private HttpConnection _connection; - private string _error; - private int _errorStatus; - private HttpListener _listener; - private HttpListenerRequest _request; - private HttpListenerResponse _response; - private IPrincipal _user; + private HttpConnection _connection; + private string _error; + private int _errorStatus; + private HttpListener _listener; + private HttpListenerRequest _request; + private HttpListenerResponse _response; + private IPrincipal _user; + private HttpListenerWebSocketContext _websocketContext; #endregion @@ -220,8 +221,14 @@ internal bool Authenticate () /// contains an invalid character. /// /// + /// + /// This method has already been called. + /// public HttpListenerWebSocketContext AcceptWebSocket (string protocol) { + if (_websocketContext != null) + throw new InvalidOperationException ("The accepting is already in progress."); + if (protocol != null) { if (protocol.Length == 0) throw new ArgumentException ("An empty string.", "protocol"); @@ -230,7 +237,8 @@ public HttpListenerWebSocketContext AcceptWebSocket (string protocol) throw new ArgumentException ("Contains an invalid character.", "protocol"); } - return new HttpListenerWebSocketContext (this, protocol); + _websocketContext = new HttpListenerWebSocketContext (this, protocol); + return _websocketContext; } #endregion From f4d76318f610d03d28cedaf15326dcef0768c2f4 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 20 May 2016 15:21:20 +0900 Subject: [PATCH 0438/6294] [Modify] Polish it --- websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs index adb6fc7bf..b177c1c51 100644 --- a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs @@ -366,7 +366,7 @@ Func credentialsFinder if (scheme == AuthenticationSchemes.Anonymous) return true; - if (scheme != AuthenticationSchemes.Basic && scheme != AuthenticationSchemes.Digest) { + if (scheme == AuthenticationSchemes.None) { Close (HttpStatusCode.Forbidden); return false; } From 2a72bef65d1df6668cae50b67e5e9b21b485cd1d Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 20 May 2016 15:32:17 +0900 Subject: [PATCH 0439/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketServer.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 632ac34d3..53dbdf16c 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -484,13 +484,13 @@ public ServerSslConfiguration SslConfiguration { /// authenticate a client. /// /// - /// A Func<, > delegate that - /// references the method(s) used to find the credentials. The default value is a function that - /// only returns . + /// A Func<, > delegate + /// that references the method(s) used to find the credentials. The default value is + /// . /// public Func UserCredentialsFinder { get { - return _credFinder ?? (_credFinder = identity => null); + return _credFinder; } set { @@ -620,7 +620,7 @@ private void receiveRequest () state => { try { var ctx = cl.GetWebSocketContext (null, _secure, _sslConfig, _logger); - if (!ctx.Authenticate (_authSchemes, getRealm (), UserCredentialsFinder)) + if (!ctx.Authenticate (_authSchemes, getRealm (), _credFinder)) return; processRequest (ctx); From 0ffdfd7e39c462679a09ff2100b8ef207812ce0c Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 20 May 2016 15:38:52 +0900 Subject: [PATCH 0440/6294] [Modify] Rename it --- websocket-sharp/Server/WebSocketServer.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 53dbdf16c..85fdba268 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -62,7 +62,6 @@ public class WebSocketServer private System.Net.IPAddress _address; private AuthenticationSchemes _authSchemes; - private Func _credFinder; private static readonly string _defaultRealm; private bool _dnsStyle; private string _hostname; @@ -77,6 +76,7 @@ public class WebSocketServer private ServerSslConfiguration _sslConfig; private volatile ServerState _state; private object _sync; + private Func _userCredFinder; #endregion @@ -490,7 +490,7 @@ public ServerSslConfiguration SslConfiguration { /// public Func UserCredentialsFinder { get { - return _credFinder; + return _userCredFinder; } set { @@ -500,7 +500,7 @@ public Func UserCredentialsFinder { return; } - _credFinder = value; + _userCredFinder = value; } } @@ -620,7 +620,7 @@ private void receiveRequest () state => { try { var ctx = cl.GetWebSocketContext (null, _secure, _sslConfig, _logger); - if (!ctx.Authenticate (_authSchemes, getRealm (), _credFinder)) + if (!ctx.Authenticate (_authSchemes, getRealm (), _userCredFinder)) return; processRequest (ctx); From acd56acae3098451313041988334a01f89abaeeb Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 20 May 2016 15:47:15 +0900 Subject: [PATCH 0441/6294] [Modify] Polish it --- websocket-sharp/Server/HttpServer.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index c5a75abdd..3b1a2e7a7 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -492,9 +492,9 @@ public ServerSslConfiguration SslConfiguration { /// authenticate a client. /// /// - /// A Func<, > delegate that - /// references the method(s) used to find the credentials. The default value is a function that - /// only returns . + /// A Func<, > delegate + /// that references the method(s) used to find the credentials. The default value is + /// . /// public Func UserCredentialsFinder { get { From a8a342097e3cef18bfeeb2e0a33c51d63dde5634 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 21 May 2016 16:38:07 +0900 Subject: [PATCH 0442/6294] [Fix] Catch it Fix for issue #232 and #261. --- websocket-sharp/Net/EndPointListener.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/websocket-sharp/Net/EndPointListener.cs b/websocket-sharp/Net/EndPointListener.cs index 99040e199..7d6b5193c 100644 --- a/websocket-sharp/Net/EndPointListener.cs +++ b/websocket-sharp/Net/EndPointListener.cs @@ -244,6 +244,9 @@ private static void onAccept (IAsyncResult asyncResult) try { sock = lsnr._socket.EndAccept (asyncResult); } + catch (SocketException) { + // TODO: Should log the error code when this class has a logging. + } catch (ObjectDisposedException) { return; } From 8a2798739b6c6d5675a21abd072f573e7904eee0 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 22 May 2016 16:03:06 +0900 Subject: [PATCH 0443/6294] [Modify] Rename it --- websocket-sharp/Net/HttpConnection.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/HttpConnection.cs b/websocket-sharp/Net/HttpConnection.cs index 5be058ddb..793bf1abb 100644 --- a/websocket-sharp/Net/HttpConnection.cs +++ b/websocket-sharp/Net/HttpConnection.cs @@ -62,7 +62,7 @@ internal sealed class HttpConnection private byte[] _buffer; private const int _bufferLength = 8192; private HttpListenerContext _context; - private bool _contextBound; + private bool _contextRegistered; private StringBuilder _currentLine; private InputState _inputState; private RequestStream _inputStream; @@ -303,7 +303,7 @@ private static void onRead (IAsyncResult asyncResult) } if (lsnr.RegisterContext (conn._context)) - conn._contextBound = true; + conn._contextRegistered = true; return; } @@ -402,11 +402,11 @@ private void removeConnection () private void unbind () { - if (!_contextBound) + if (!_contextRegistered) return; _listener.UnbindContext (_context); - _contextBound = false; + _contextRegistered = false; } #endregion From 97f195eb1fa22b7ea37ffdb265222138106c1634 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 23 May 2016 15:06:33 +0900 Subject: [PATCH 0444/6294] [Modify] Add it --- websocket-sharp/Net/HttpConnection.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/websocket-sharp/Net/HttpConnection.cs b/websocket-sharp/Net/HttpConnection.cs index 793bf1abb..599882c94 100644 --- a/websocket-sharp/Net/HttpConnection.cs +++ b/websocket-sharp/Net/HttpConnection.cs @@ -409,6 +409,15 @@ private void unbind () _contextRegistered = false; } + private void unregisterContext () + { + if (!_contextRegistered) + return; + + _context.Listener.UnregisterContext (_context); + _contextRegistered = false; + } + #endregion #region Internal Methods From 43c4df1321ecbef0a9bdefcebf44ef516725689e Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 23 May 2016 15:11:25 +0900 Subject: [PATCH 0445/6294] [Modify] Replace it --- websocket-sharp/Net/HttpConnection.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpConnection.cs b/websocket-sharp/Net/HttpConnection.cs index 599882c94..fdf9e4deb 100644 --- a/websocket-sharp/Net/HttpConnection.cs +++ b/websocket-sharp/Net/HttpConnection.cs @@ -180,7 +180,7 @@ private void close () closeSocket (); } - unbind (); + unregisterContext (); removeConnection (); } @@ -437,7 +437,7 @@ internal void Close (bool force) // Don't close. Keep working. _reuses++; disposeRequestBuffer (); - unbind (); + unregisterContext (); init (); BeginReadRequest (); From 189fe2615b3af8445e688c07523b02640b85150f Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 23 May 2016 15:13:30 +0900 Subject: [PATCH 0446/6294] [Modify] Remove it --- websocket-sharp/Net/HttpConnection.cs | 9 --------- 1 file changed, 9 deletions(-) diff --git a/websocket-sharp/Net/HttpConnection.cs b/websocket-sharp/Net/HttpConnection.cs index fdf9e4deb..e805144a3 100644 --- a/websocket-sharp/Net/HttpConnection.cs +++ b/websocket-sharp/Net/HttpConnection.cs @@ -400,15 +400,6 @@ private void removeConnection () _listener.RemoveConnection (this); } - private void unbind () - { - if (!_contextRegistered) - return; - - _listener.UnbindContext (_context); - _contextRegistered = false; - } - private void unregisterContext () { if (!_contextRegistered) From f90a3470550b61ae2164ec5c2c690cf9a828cabd Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 23 May 2016 15:16:04 +0900 Subject: [PATCH 0447/6294] [Modify] Remove it --- websocket-sharp/Net/EndPointListener.cs | 8 -------- 1 file changed, 8 deletions(-) diff --git a/websocket-sharp/Net/EndPointListener.cs b/websocket-sharp/Net/EndPointListener.cs index 7d6b5193c..8850db482 100644 --- a/websocket-sharp/Net/EndPointListener.cs +++ b/websocket-sharp/Net/EndPointListener.cs @@ -516,14 +516,6 @@ public void RemovePrefix (HttpListenerPrefix prefix, HttpListener listener) checkIfRemove (); } - public void UnbindContext (HttpListenerContext context) - { - if (context == null || context.Listener == null) - return; - - context.Listener.UnregisterContext (context); - } - #endregion } } From 562938e61b266b1577a5331c76a32280ac97e332 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 24 May 2016 14:47:45 +0900 Subject: [PATCH 0448/6294] [Modify] Add it --- websocket-sharp/Net/HttpListenerContext.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/websocket-sharp/Net/HttpListenerContext.cs b/websocket-sharp/Net/HttpListenerContext.cs index 911718b7c..15f557028 100644 --- a/websocket-sharp/Net/HttpListenerContext.cs +++ b/websocket-sharp/Net/HttpListenerContext.cs @@ -195,6 +195,11 @@ internal bool Authenticate () return true; } + internal void Unregister () + { + _listener.UnregisterContext (this); + } + #endregion #region Public Methods From 508a2b3bb1fda27f5ff28ded8cd4e0bfbea7ae3f Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 24 May 2016 14:51:22 +0900 Subject: [PATCH 0449/6294] [Modify] Replace it --- websocket-sharp/Net/HttpConnection.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpConnection.cs b/websocket-sharp/Net/HttpConnection.cs index e805144a3..a60d4f70e 100644 --- a/websocket-sharp/Net/HttpConnection.cs +++ b/websocket-sharp/Net/HttpConnection.cs @@ -405,7 +405,7 @@ private void unregisterContext () if (!_contextRegistered) return; - _context.Listener.UnregisterContext (_context); + _context.Unregister (); _contextRegistered = false; } From aff6bc4128df93cd1e29e1a13c4c2844eb6176ca Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 24 May 2016 15:35:00 +0900 Subject: [PATCH 0450/6294] [Fix] Add a try parse Fix for a part of pull request #264. --- websocket-sharp/Ext.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index a62009822..5d6710d39 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -841,6 +841,10 @@ internal static string ToExtensionString ( internal static System.Net.IPAddress ToIPAddress (this string hostnameOrAddress) { + System.Net.IPAddress addr; + if (System.Net.IPAddress.TryParse (hostnameOrAddress, out addr)) + return addr; + try { return System.Net.Dns.GetHostAddresses (hostnameOrAddress)[0]; } From dcde4e3cd8442068fce55e6b9380071e6906592a Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 25 May 2016 14:31:21 +0900 Subject: [PATCH 0451/6294] [Modify] Add it --- websocket-sharp/Net/HttpListenerContext.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/websocket-sharp/Net/HttpListenerContext.cs b/websocket-sharp/Net/HttpListenerContext.cs index 15f557028..638078d4f 100644 --- a/websocket-sharp/Net/HttpListenerContext.cs +++ b/websocket-sharp/Net/HttpListenerContext.cs @@ -195,6 +195,11 @@ internal bool Authenticate () return true; } + internal bool Register () + { + return _listener.RegisterContext (this); + } + internal void Unregister () { _listener.UnregisterContext (this); From 8e6b88ab71eb96625a82b52a031a95f16ae8259f Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 25 May 2016 14:39:07 +0900 Subject: [PATCH 0452/6294] [Modify] Replace it --- websocket-sharp/Net/HttpConnection.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpConnection.cs b/websocket-sharp/Net/HttpConnection.cs index a60d4f70e..6011ef68d 100644 --- a/websocket-sharp/Net/HttpConnection.cs +++ b/websocket-sharp/Net/HttpConnection.cs @@ -302,7 +302,7 @@ private static void onRead (IAsyncResult asyncResult) conn._lastListener = lsnr; } - if (lsnr.RegisterContext (conn._context)) + if (conn._context.Register ()) conn._contextRegistered = true; return; From e36ee5e7ac9a99951c06d93d78ccfa106969eacc Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 26 May 2016 14:22:00 +0900 Subject: [PATCH 0453/6294] [Modify] Move it --- websocket-sharp/Net/HttpConnection.cs | 3 +++ websocket-sharp/Net/HttpListener.cs | 3 --- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/HttpConnection.cs b/websocket-sharp/Net/HttpConnection.cs index 6011ef68d..89b5fff0e 100644 --- a/websocket-sharp/Net/HttpConnection.cs +++ b/websocket-sharp/Net/HttpConnection.cs @@ -302,6 +302,9 @@ private static void onRead (IAsyncResult asyncResult) conn._lastListener = lsnr; } + if (!conn._context.Authenticate ()) + return; + if (conn._context.Register ()) conn._contextRegistered = true; diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index ed6358c2f..c83349871 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -582,9 +582,6 @@ internal bool RegisterContext (HttpListenerContext context) if (!_listening) return false; - if (!context.Authenticate ()) - return false; - lock (_ctxRegistrySync) { if (!_listening) return false; From 6878e608e7839882be0daa99e195c2e136846997 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 27 May 2016 15:11:02 +0900 Subject: [PATCH 0454/6294] [Fix] Add a closing square bracket check Fix for a part of pull request #264. --- websocket-sharp/Net/HttpListenerPrefix.cs | 39 +++++++++++------------ 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerPrefix.cs b/websocket-sharp/Net/HttpListenerPrefix.cs index dd9699b2f..a9cf859c8 100644 --- a/websocket-sharp/Net/HttpListenerPrefix.cs +++ b/websocket-sharp/Net/HttpListenerPrefix.cs @@ -157,37 +157,34 @@ public static void CheckPrefix (string uriPrefix) var len = uriPrefix.Length; if (len == 0) - throw new ArgumentException ("An empty string."); + throw new ArgumentException ("An empty string.", "uriPrefix"); if (!(uriPrefix.StartsWith ("http://") || uriPrefix.StartsWith ("https://"))) - throw new ArgumentException ("The scheme isn't 'http' or 'https'."); + throw new ArgumentException ("The scheme isn't 'http' or 'https'.", "uriPrefix"); var startHost = uriPrefix.IndexOf (':') + 3; if (startHost >= len) - throw new ArgumentException ("No host is specified."); + throw new ArgumentException ("No host is specified.", "uriPrefix"); - var colon = uriPrefix.IndexOf (':', startHost, len - startHost); - if (startHost == colon) - throw new ArgumentException ("No host is specified."); + if (uriPrefix[startHost] == ':') + throw new ArgumentException ("No host is specified.", "uriPrefix"); - if (colon > 0) { - var root = uriPrefix.IndexOf ('/', colon, len - colon); - if (root == -1) - throw new ArgumentException ("No path is specified."); + var root = uriPrefix.IndexOf ('/', startHost, len - startHost); + if (root == startHost) + throw new ArgumentException ("No host is specified.", "uriPrefix"); + + if (uriPrefix[len - 1] != '/') + throw new ArgumentException ("Ends without '/'.", "uriPrefix"); + var colon = uriPrefix.LastIndexOf (':', root - 1, root - startHost - 1); + if (uriPrefix[root - 1] != ']' && colon > startHost) { int port; - if (!Int32.TryParse (uriPrefix.Substring (colon + 1, root - colon - 1), out port) || - !port.IsPortNumber ()) - throw new ArgumentException ("An invalid port is specified."); + if (!Int32.TryParse (uriPrefix.Substring (colon + 1, root - colon - 1), out port) + || !port.IsPortNumber () + ) { + throw new ArgumentException ("An invalid port is specified.", "uriPrefix"); + } } - else { - var root = uriPrefix.IndexOf ('/', startHost, len - startHost); - if (root == -1) - throw new ArgumentException ("No path is specified."); - } - - if (uriPrefix[len - 1] != '/') - throw new ArgumentException ("Ends without '/'."); } // The Equals and GetHashCode methods are required to detect duplicates in any collection. From e8661442a89299673d9033fe426a447026705731 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 27 May 2016 15:33:25 +0900 Subject: [PATCH 0455/6294] [Fix] Add a closing square bracket check Fix for a part of pull request #264. --- websocket-sharp/Net/HttpListenerPrefix.cs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerPrefix.cs b/websocket-sharp/Net/HttpListenerPrefix.cs index a9cf859c8..d7053a9d5 100644 --- a/websocket-sharp/Net/HttpListenerPrefix.cs +++ b/websocket-sharp/Net/HttpListenerPrefix.cs @@ -126,15 +126,14 @@ private void parse (string uriPrefix) var len = uriPrefix.Length; var startHost = uriPrefix.IndexOf (':') + 3; - var colon = uriPrefix.IndexOf (':', startHost, len - startHost); - var root = 0; - if (colon > 0) { - root = uriPrefix.IndexOf ('/', colon, len - colon); + var root = uriPrefix.IndexOf ('/', startHost, len - startHost); + + var colon = uriPrefix.LastIndexOf (':', root - 1, root - startHost - 1); + if (uriPrefix[root - 1] != ']' && colon > startHost) { _host = uriPrefix.Substring (startHost, colon - startHost); _port = (ushort) Int32.Parse (uriPrefix.Substring (colon + 1, root - colon - 1)); } else { - root = uriPrefix.IndexOf ('/', startHost, len - startHost); _host = uriPrefix.Substring (startHost, root - startHost); _port = (ushort) defaultPort; } From 5885971f906422d9036d9483e90d75e879907b4b Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 27 May 2016 16:11:34 +0900 Subject: [PATCH 0456/6294] [Fix] Bracket it if IPv6 address Fix for a part of pull request #264. --- websocket-sharp/Server/HttpServer.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 3b1a2e7a7..29d174dec 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -630,9 +630,17 @@ private string checkIfCertificateExists () return !(usr || port) ? "The secure connection requires a server certificate." : null; } + private static string convertToString (System.Net.IPAddress address) + { + var str = address.ToString (); + return address.AddressFamily == AddressFamily.InterNetworkV6 + ? String.Format ("[{0}]", str) + : str; + } + private void init (string hostname, System.Net.IPAddress address, int port, bool secure) { - _hostname = hostname ?? address.ToString (); + _hostname = hostname ?? convertToString (address); _address = address; _port = port; _secure = secure; From 174ff5eb070c9b6d5c9d738e74433b791d9311ed Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 28 May 2016 15:37:41 +0900 Subject: [PATCH 0457/6294] [Modify] Add some examples to create a new server instance --- Example3/Program.cs | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/Example3/Program.cs b/Example3/Program.cs index dad6e5f6d..66fec34e1 100644 --- a/Example3/Program.cs +++ b/Example3/Program.cs @@ -19,10 +19,33 @@ public static void Main (string[] args) var httpsv = new HttpServer (4649); //var httpsv = new HttpServer (5963, true); - //var httpsv = new HttpServer (System.Net.IPAddress.Parse ("127.0.0.1"), 4649); - //var httpsv = new HttpServer (System.Net.IPAddress.Parse ("127.0.0.1"), 5963, true); + + //var httpsv = new HttpServer (System.Net.IPAddress.Any, 4649); + //var httpsv = new HttpServer (System.Net.IPAddress.Any, 5963, true); + + //var httpsv = new HttpServer (System.Net.IPAddress.IPv6Any, 4649); + //var httpsv = new HttpServer (System.Net.IPAddress.IPv6Any, 5963, true); + + //var httpsv = new HttpServer ("http://0.0.0.0:4649/"); + //var httpsv = new HttpServer ("https://0.0.0.0:5963/"); + + //var httpsv = new HttpServer ("http://[::]:4649/"); + //var httpsv = new HttpServer ("https://[::]:5963/"); + + //var httpsv = new HttpServer (System.Net.IPAddress.Loopback, 4649); + //var httpsv = new HttpServer (System.Net.IPAddress.Loopback, 5963, true); + + //var httpsv = new HttpServer (System.Net.IPAddress.IPv6Loopback, 4649); + //var httpsv = new HttpServer (System.Net.IPAddress.IPv6Loopback, 5963, true); + //var httpsv = new HttpServer ("http://localhost:4649/"); //var httpsv = new HttpServer ("https://localhost:5963/"); + + //var httpsv = new HttpServer ("http://127.0.0.1:4649/"); + //var httpsv = new HttpServer ("https://127.0.0.1:5963/"); + + //var httpsv = new HttpServer ("http://[::1]:4649/"); + //var httpsv = new HttpServer ("https://[::1]:5963/"); #if DEBUG // To change the logging level. httpsv.Log.Level = LogLevel.Trace; From 3b62c0f2ecb5f36de46e62104154bc0230904062 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 29 May 2016 14:53:50 +0900 Subject: [PATCH 0458/6294] [Modify] Add some examples to create a new server instance --- Example2/Program.cs | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/Example2/Program.cs b/Example2/Program.cs index 950ffde85..d552ce81b 100644 --- a/Example2/Program.cs +++ b/Example2/Program.cs @@ -18,10 +18,33 @@ public static void Main (string[] args) var wssv = new WebSocketServer (4649); //var wssv = new WebSocketServer (5963, true); - //var wssv = new WebSocketServer (System.Net.IPAddress.Parse ("127.0.0.1"), 4649); - //var wssv = new WebSocketServer (System.Net.IPAddress.Parse ("127.0.0.1"), 5963, true); + + //var wssv = new WebSocketServer (System.Net.IPAddress.Any, 4649); + //var wssv = new WebSocketServer (System.Net.IPAddress.Any, 5963, true); + + //var wssv = new WebSocketServer (System.Net.IPAddress.IPv6Any, 4649); + //var wssv = new WebSocketServer (System.Net.IPAddress.IPv6Any, 5963, true); + + //var wssv = new WebSocketServer ("ws://0.0.0.0:4649"); + //var wssv = new WebSocketServer ("wss://0.0.0.0:5963"); + + //var wssv = new WebSocketServer ("ws://[::0]:4649"); + //var wssv = new WebSocketServer ("wss://[::0]:5963"); + + //var wssv = new WebSocketServer (System.Net.IPAddress.Loopback, 4649); + //var wssv = new WebSocketServer (System.Net.IPAddress.Loopback, 5963, true); + + //var wssv = new WebSocketServer (System.Net.IPAddress.IPv6Loopback, 4649); + //var wssv = new WebSocketServer (System.Net.IPAddress.IPv6Loopback, 5963, true); + //var wssv = new WebSocketServer ("ws://localhost:4649"); //var wssv = new WebSocketServer ("wss://localhost:5963"); + + //var wssv = new WebSocketServer ("ws://127.0.0.1:4649"); + //var wssv = new WebSocketServer ("wss://127.0.0.1:5963"); + + //var wssv = new WebSocketServer ("ws://[::1]:4649"); + //var wssv = new WebSocketServer ("wss://[::1]:5963"); #if DEBUG // To change the logging level. wssv.Log.Level = LogLevel.Trace; From 91d12041a8bd8c89dbc20d1c964e50aa8798ee56 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 30 May 2016 15:02:46 +0900 Subject: [PATCH 0459/6294] [Fix] Use Host if IPv6 address hostname Fix for a part of pull request #264. --- websocket-sharp/Server/HttpServer.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 29d174dec..5498fb495 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -157,7 +157,7 @@ public HttpServer (string url) if (!tryCreateUri (url, out uri, out msg)) throw new ArgumentException (msg, "url"); - var host = uri.DnsSafeHost; + var host = getHost (uri); var addr = host.ToIPAddress (); if (!addr.IsLocal ()) throw new ArgumentException ("The host part isn't a local host name: " + url, "url"); @@ -638,6 +638,11 @@ private static string convertToString (System.Net.IPAddress address) : str; } + private static string getHost (Uri uri) + { + return uri.HostNameType == UriHostNameType.IPv6 ? uri.Host : uri.DnsSafeHost; + } + private void init (string hostname, System.Net.IPAddress address, int port, bool secure) { _hostname = hostname ?? convertToString (address); From a44139c59abdbbe7972092864e1a8fdd98a3ffcc Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 30 May 2016 15:09:53 +0900 Subject: [PATCH 0460/6294] [Modify] Polish it --- websocket-sharp/Server/HttpServer.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 5498fb495..ad5d615c5 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -632,10 +632,9 @@ private string checkIfCertificateExists () private static string convertToString (System.Net.IPAddress address) { - var str = address.ToString (); return address.AddressFamily == AddressFamily.InterNetworkV6 - ? String.Format ("[{0}]", str) - : str; + ? String.Format ("[{0}]", address.ToString ()) + : address.ToString (); } private static string getHost (Uri uri) From 2915c18811d9532b6d757cb0536067903b5b0649 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 31 May 2016 14:53:34 +0900 Subject: [PATCH 0461/6294] [Modify] Add it --- websocket-sharp/Net/EndPointManager.cs | 34 ++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/websocket-sharp/Net/EndPointManager.cs b/websocket-sharp/Net/EndPointManager.cs index 6b1feb189..aaaa54ccd 100644 --- a/websocket-sharp/Net/EndPointManager.cs +++ b/websocket-sharp/Net/EndPointManager.cs @@ -150,6 +150,40 @@ private static EndPointListener getEndPointListener ( return lsnr; } + private static EndPointListener getEndPointListener ( + IPAddress address, int port, bool secure, HttpListener listener + ) + { + Dictionary endpoints = null; + if (_addressToEndpoints.ContainsKey (address)) { + endpoints = _addressToEndpoints[address]; + } + else { + endpoints = new Dictionary (); + _addressToEndpoints[address] = endpoints; + } + + EndPointListener lsnr = null; + if (endpoints.ContainsKey (port)) { + lsnr = endpoints[port]; + } + else { + lsnr = + new EndPointListener ( + address, + port, + listener.ReuseAddress, + secure, + listener.CertificateFolderPath, + listener.SslConfiguration + ); + + endpoints[port] = lsnr; + } + + return lsnr; + } + private static void removePrefix (string uriPrefix, HttpListener listener) { var pref = new HttpListenerPrefix (uriPrefix); From 6d24085b7a88920f7cec270947bc863ac478c570 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 31 May 2016 15:31:57 +0900 Subject: [PATCH 0462/6294] [Modify] Replace it --- websocket-sharp/Net/EndPointManager.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/EndPointManager.cs b/websocket-sharp/Net/EndPointManager.cs index aaaa54ccd..85c1de883 100644 --- a/websocket-sharp/Net/EndPointManager.cs +++ b/websocket-sharp/Net/EndPointManager.cs @@ -83,6 +83,10 @@ private static void addPrefix (string uriPrefix, HttpListener listener) { var pref = new HttpListenerPrefix (uriPrefix); + var addr = convertToIPAddress (pref.Host); + + var port = pref.Port; + var path = pref.Path; if (path.IndexOf ('%') != -1) throw new HttpListenerException (87, "Includes an invalid path."); @@ -91,7 +95,7 @@ private static void addPrefix (string uriPrefix, HttpListener listener) throw new HttpListenerException (87, "Includes an invalid path."); // Listens on all the interfaces if host name cannot be parsed by IPAddress. - getEndPointListener (pref, listener).AddPrefix (pref, listener); + getEndPointListener (addr, port, pref.IsSecure, listener).AddPrefix (pref, listener); } private static IPAddress convertToIPAddress (string hostname) From b1883ec5f518e95253d8cf7b6cdb9bf79e64d7e0 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 1 Jun 2016 14:45:49 +0900 Subject: [PATCH 0463/6294] [Modify] Add a host check --- websocket-sharp/Net/EndPointManager.cs | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/websocket-sharp/Net/EndPointManager.cs b/websocket-sharp/Net/EndPointManager.cs index 85c1de883..15952b36f 100644 --- a/websocket-sharp/Net/EndPointManager.cs +++ b/websocket-sharp/Net/EndPointManager.cs @@ -84,6 +84,8 @@ private static void addPrefix (string uriPrefix, HttpListener listener) var pref = new HttpListenerPrefix (uriPrefix); var addr = convertToIPAddress (pref.Host); + if (!addr.IsLocal ()) + throw new HttpListenerException (87, "Includes an invalid host."); var port = pref.Port; @@ -94,26 +96,12 @@ private static void addPrefix (string uriPrefix, HttpListener listener) if (path.IndexOf ("//", StringComparison.Ordinal) != -1) throw new HttpListenerException (87, "Includes an invalid path."); - // Listens on all the interfaces if host name cannot be parsed by IPAddress. getEndPointListener (addr, port, pref.IsSecure, listener).AddPrefix (pref, listener); } private static IPAddress convertToIPAddress (string hostname) { - if (hostname == "*" || hostname == "+") - return IPAddress.Any; - - IPAddress addr; - if (IPAddress.TryParse (hostname, out addr)) - return addr; - - try { - var host = Dns.GetHostEntry (hostname); - return host != null ? host.AddressList[0] : IPAddress.Any; - } - catch { - return IPAddress.Any; - } + return hostname == "*" || hostname == "+" ? IPAddress.Any : hostname.ToIPAddress (); } private static EndPointListener getEndPointListener ( From e61253baea74bcfd55ba40319be69898b9e0ba52 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 1 Jun 2016 15:10:06 +0900 Subject: [PATCH 0464/6294] [Modify] Replace it --- websocket-sharp/Net/EndPointManager.cs | 46 ++++---------------------- 1 file changed, 7 insertions(+), 39 deletions(-) diff --git a/websocket-sharp/Net/EndPointManager.cs b/websocket-sharp/Net/EndPointManager.cs index 15952b36f..65dd5a88d 100644 --- a/websocket-sharp/Net/EndPointManager.cs +++ b/websocket-sharp/Net/EndPointManager.cs @@ -104,44 +104,6 @@ private static IPAddress convertToIPAddress (string hostname) return hostname == "*" || hostname == "+" ? IPAddress.Any : hostname.ToIPAddress (); } - private static EndPointListener getEndPointListener ( - HttpListenerPrefix prefix, HttpListener listener - ) - { - var addr = convertToIPAddress (prefix.Host); - - Dictionary eps = null; - if (_addressToEndpoints.ContainsKey (addr)) { - eps = _addressToEndpoints[addr]; - } - else { - eps = new Dictionary (); - _addressToEndpoints[addr] = eps; - } - - var port = prefix.Port; - - EndPointListener lsnr = null; - if (eps.ContainsKey (port)) { - lsnr = eps[port]; - } - else { - lsnr = - new EndPointListener ( - addr, - port, - listener.ReuseAddress, - prefix.IsSecure, - listener.CertificateFolderPath, - listener.SslConfiguration - ); - - eps[port] = lsnr; - } - - return lsnr; - } - private static EndPointListener getEndPointListener ( IPAddress address, int port, bool secure, HttpListener listener ) @@ -180,6 +142,12 @@ private static void removePrefix (string uriPrefix, HttpListener listener) { var pref = new HttpListenerPrefix (uriPrefix); + var addr = convertToIPAddress (pref.Host); + if (!addr.IsLocal ()) + return; + + var port = pref.Port; + var path = pref.Path; if (path.IndexOf ('%') != -1) return; @@ -187,7 +155,7 @@ private static void removePrefix (string uriPrefix, HttpListener listener) if (path.IndexOf ("//", StringComparison.Ordinal) != -1) return; - getEndPointListener (pref, listener).RemovePrefix (pref, listener); + getEndPointListener (addr, port, pref.IsSecure, listener).RemovePrefix (pref, listener); } #endregion From ca31d86c1ab40b440b708349c08c37a16a72f99b Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 2 Jun 2016 16:43:14 +0900 Subject: [PATCH 0465/6294] [Modify] Move port checks --- websocket-sharp/Net/EndPointListener.cs | 2 +- websocket-sharp/Net/EndPointManager.cs | 14 ++++++-- websocket-sharp/Net/HttpListenerPrefix.cs | 39 ++++++++++------------- 3 files changed, 29 insertions(+), 26 deletions(-) diff --git a/websocket-sharp/Net/EndPointListener.cs b/websocket-sharp/Net/EndPointListener.cs index 8850db482..6198dff36 100644 --- a/websocket-sharp/Net/EndPointListener.cs +++ b/websocket-sharp/Net/EndPointListener.cs @@ -309,7 +309,7 @@ private HttpListener searchListener (Uri uri, out HttpListenerPrefix prefix) var host = uri.Host; var dns = Uri.CheckHostName (host) == UriHostNameType.Dns; - var port = uri.Port; + var port = uri.Port.ToString (); var path = HttpUtility.UrlDecode (uri.AbsolutePath); var pathSlash = path[path.Length - 1] == '/' ? path : path + "/"; diff --git a/websocket-sharp/Net/EndPointManager.cs b/websocket-sharp/Net/EndPointManager.cs index 65dd5a88d..a4d4a324b 100644 --- a/websocket-sharp/Net/EndPointManager.cs +++ b/websocket-sharp/Net/EndPointManager.cs @@ -87,7 +87,12 @@ private static void addPrefix (string uriPrefix, HttpListener listener) if (!addr.IsLocal ()) throw new HttpListenerException (87, "Includes an invalid host."); - var port = pref.Port; + int port; + if (!Int32.TryParse (pref.Port, out port)) + throw new HttpListenerException (87, "Includes an invalid port."); + + if (!port.IsPortNumber ()) + throw new HttpListenerException (87, "Includes an invalid port."); var path = pref.Path; if (path.IndexOf ('%') != -1) @@ -146,7 +151,12 @@ private static void removePrefix (string uriPrefix, HttpListener listener) if (!addr.IsLocal ()) return; - var port = pref.Port; + int port; + if (!Int32.TryParse (pref.Port, out port)) + return; + + if (!port.IsPortNumber ()) + return; var path = pref.Path; if (path.IndexOf ('%') != -1) diff --git a/websocket-sharp/Net/HttpListenerPrefix.cs b/websocket-sharp/Net/HttpListenerPrefix.cs index d7053a9d5..c88470331 100644 --- a/websocket-sharp/Net/HttpListenerPrefix.cs +++ b/websocket-sharp/Net/HttpListenerPrefix.cs @@ -52,7 +52,7 @@ internal sealed class HttpListenerPrefix private HttpListener _listener; private string _original; private string _path; - private ushort _port; + private string _port; private bool _secure; #endregion @@ -108,9 +108,9 @@ public string Path { } } - public int Port { + public string Port { get { - return (int) _port; + return _port; } } @@ -120,29 +120,26 @@ public int Port { private void parse (string uriPrefix) { - var defaultPort = uriPrefix.StartsWith ("https://") ? 443 : 80; - if (defaultPort == 443) + if (uriPrefix.StartsWith ("https")) _secure = true; var len = uriPrefix.Length; var startHost = uriPrefix.IndexOf (':') + 3; - var root = uriPrefix.IndexOf ('/', startHost, len - startHost); + var root = uriPrefix.IndexOf ('/', startHost + 1, len - startHost - 1); var colon = uriPrefix.LastIndexOf (':', root - 1, root - startHost - 1); if (uriPrefix[root - 1] != ']' && colon > startHost) { _host = uriPrefix.Substring (startHost, colon - startHost); - _port = (ushort) Int32.Parse (uriPrefix.Substring (colon + 1, root - colon - 1)); + _port = uriPrefix.Substring (colon + 1, root - colon - 1); } else { _host = uriPrefix.Substring (startHost, root - startHost); - _port = (ushort) defaultPort; + _port = _secure ? "443" : "80"; } - _path = uriPrefix.Substring (root); - - var pathLen = _path.Length; - if (pathLen > 1) - _path = _path.Substring (0, pathLen - 1); + var path = uriPrefix.Substring (root); + var pathLen = path.Length; + _path = pathLen > 1 ? path.Substring (0, pathLen - 1) : path; } #endregion @@ -172,18 +169,14 @@ public static void CheckPrefix (string uriPrefix) if (root == startHost) throw new ArgumentException ("No host is specified.", "uriPrefix"); - if (uriPrefix[len - 1] != '/') + if (root == -1 || uriPrefix[len - 1] != '/') throw new ArgumentException ("Ends without '/'.", "uriPrefix"); - var colon = uriPrefix.LastIndexOf (':', root - 1, root - startHost - 1); - if (uriPrefix[root - 1] != ']' && colon > startHost) { - int port; - if (!Int32.TryParse (uriPrefix.Substring (colon + 1, root - colon - 1), out port) - || !port.IsPortNumber () - ) { - throw new ArgumentException ("An invalid port is specified.", "uriPrefix"); - } - } + if (uriPrefix[root - 1] == ':') + throw new ArgumentException ("No port is specified.", "uriPrefix"); + + if (root == len - 2) + throw new ArgumentException ("No path is specified.", "uriPrefix"); } // The Equals and GetHashCode methods are required to detect duplicates in any collection. From aec6123c198c4627a14bf14574bdf7d5572bb46e Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 3 Jun 2016 16:08:03 +0900 Subject: [PATCH 0466/6294] [Modify] Polish it --- websocket-sharp/Net/EndPointListener.cs | 5 +++-- websocket-sharp/Net/EndPointManager.cs | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/EndPointListener.cs b/websocket-sharp/Net/EndPointListener.cs index 6198dff36..8b49852ba 100644 --- a/websocket-sharp/Net/EndPointListener.cs +++ b/websocket-sharp/Net/EndPointListener.cs @@ -89,10 +89,11 @@ static EndPointListener () internal EndPointListener ( IPAddress address, int port, - bool reuseAddress, bool secure, string certificateFolderPath, - ServerSslConfiguration sslConfig) + ServerSslConfiguration sslConfig, + bool reuseAddress + ) { if (secure) { var cert = getCertificate (port, certificateFolderPath, sslConfig.ServerCertificate); diff --git a/websocket-sharp/Net/EndPointManager.cs b/websocket-sharp/Net/EndPointManager.cs index a4d4a324b..6558ce35a 100644 --- a/websocket-sharp/Net/EndPointManager.cs +++ b/websocket-sharp/Net/EndPointManager.cs @@ -131,10 +131,10 @@ private static EndPointListener getEndPointListener ( new EndPointListener ( address, port, - listener.ReuseAddress, secure, listener.CertificateFolderPath, - listener.SslConfiguration + listener.SslConfiguration, + listener.ReuseAddress ); endpoints[port] = lsnr; From 6c36b785c3f708ac30b8079252f6715e3ad87e02 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 3 Jun 2016 16:17:42 +0900 Subject: [PATCH 0467/6294] [Fix] Set system error code 87 --- websocket-sharp/Net/EndPointListener.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/EndPointListener.cs b/websocket-sharp/Net/EndPointListener.cs index 8b49852ba..60168341b 100644 --- a/websocket-sharp/Net/EndPointListener.cs +++ b/websocket-sharp/Net/EndPointListener.cs @@ -156,7 +156,7 @@ private static void addSpecial (List prefixes, HttpListenerP var path = prefix.Path; foreach (var pref in prefixes) if (pref.Path == path) - throw new HttpListenerException (400, "The prefix is already in use."); // TODO: Code? + throw new HttpListenerException (87, "The prefix is already in use."); prefixes.Add (prefix); } From 26163779ea59f948389d70e13c3748fb407fa78e Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 3 Jun 2016 16:19:43 +0900 Subject: [PATCH 0468/6294] [Modify] Polish it --- websocket-sharp/Net/EndPointListener.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/EndPointListener.cs b/websocket-sharp/Net/EndPointListener.cs index 60168341b..8cf7fee03 100644 --- a/websocket-sharp/Net/EndPointListener.cs +++ b/websocket-sharp/Net/EndPointListener.cs @@ -154,9 +154,10 @@ public ServerSslConfiguration SslConfiguration { private static void addSpecial (List prefixes, HttpListenerPrefix prefix) { var path = prefix.Path; - foreach (var pref in prefixes) + foreach (var pref in prefixes) { if (pref.Path == path) throw new HttpListenerException (87, "The prefix is already in use."); + } prefixes.Add (prefix); } From f4d88963f8619f3131c0e5e2ee1ca73974271bbb Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 3 Jun 2016 16:27:00 +0900 Subject: [PATCH 0469/6294] [Modify] Polish it --- websocket-sharp/Net/EndPointListener.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/EndPointListener.cs b/websocket-sharp/Net/EndPointListener.cs index 8cf7fee03..4ba1bc709 100644 --- a/websocket-sharp/Net/EndPointListener.cs +++ b/websocket-sharp/Net/EndPointListener.cs @@ -193,7 +193,8 @@ private static RSACryptoServiceProvider createRSAFromFile (string filename) } private static X509Certificate2 getCertificate ( - int port, string certificateFolderPath, X509Certificate2 defaultCertificate) + int port, string certificateFolderPath, X509Certificate2 defaultCertificate + ) { if (certificateFolderPath == null || certificateFolderPath.Length == 0) certificateFolderPath = _defaultCertFolderPath; From 01ad753c3ac209694258548d8bf59ee827304703 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 3 Jun 2016 16:52:36 +0900 Subject: [PATCH 0470/6294] [Modify] Polish it --- websocket-sharp/Net/EndPointListener.cs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Net/EndPointListener.cs b/websocket-sharp/Net/EndPointListener.cs index 4ba1bc709..bb0ea667d 100644 --- a/websocket-sharp/Net/EndPointListener.cs +++ b/websocket-sharp/Net/EndPointListener.cs @@ -216,21 +216,26 @@ private static X509Certificate2 getCertificate ( } private static HttpListener matchFromList ( - string host, string path, List list, out HttpListenerPrefix prefix) + string host, string path, List list, out HttpListenerPrefix prefix + ) { prefix = null; + if (list == null) return null; HttpListener bestMatch = null; + var bestLen = -1; foreach (var pref in list) { - var ppath = pref.Path; - if (ppath.Length < bestLen) + var prefPath = pref.Path; + + var len = prefPath.Length; + if (len < bestLen) continue; - if (path.StartsWith (ppath)) { - bestLen = ppath.Length; + if (path.StartsWith (prefPath)) { + bestLen = len; bestMatch = pref.Listener; prefix = pref; } From 40f1335412cf2987f6cc65a12cad6369276134c4 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 4 Jun 2016 16:26:53 +0900 Subject: [PATCH 0471/6294] [Modify] Polish it --- websocket-sharp/Net/EndPointListener.cs | 33 +++++++++++++------------ 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/websocket-sharp/Net/EndPointListener.cs b/websocket-sharp/Net/EndPointListener.cs index bb0ea667d..488b139fd 100644 --- a/websocket-sharp/Net/EndPointListener.cs +++ b/websocket-sharp/Net/EndPointListener.cs @@ -312,6 +312,7 @@ private static bool removeSpecial (List prefixes, HttpListen private HttpListener searchListener (Uri uri, out HttpListenerPrefix prefix) { prefix = null; + if (uri == null) return null; @@ -319,27 +320,30 @@ private HttpListener searchListener (Uri uri, out HttpListenerPrefix prefix) var dns = Uri.CheckHostName (host) == UriHostNameType.Dns; var port = uri.Port.ToString (); var path = HttpUtility.UrlDecode (uri.AbsolutePath); - var pathSlash = path[path.Length - 1] == '/' ? path : path + "/"; + var pathSlash = path[path.Length - 1] != '/' ? path + "/" : path; HttpListener bestMatch = null; - var bestLen = -1; + if (host != null && host.Length > 0) { + var bestLen = -1; foreach (var pref in _prefixes.Keys) { - var ppath = pref.Path; - if (ppath.Length < bestLen) - continue; + if (dns) { + var prefHost = pref.Host; + if (Uri.CheckHostName (prefHost) == UriHostNameType.Dns && prefHost != host) + continue; + } if (pref.Port != port) continue; - if (dns) { - var phost = pref.Host; - if (Uri.CheckHostName (phost) == UriHostNameType.Dns && phost != host) - continue; - } + var prefPath = pref.Path; + + var len = prefPath.Length; + if (len < bestLen) + continue; - if (path.StartsWith (ppath) || pathSlash.StartsWith (ppath)) { - bestLen = ppath.Length; + if (path.StartsWith (prefPath) || pathSlash.StartsWith (prefPath)) { + bestLen = len; bestMatch = _prefixes[pref]; prefix = pref; } @@ -362,10 +366,7 @@ private HttpListener searchListener (Uri uri, out HttpListenerPrefix prefix) if (path != pathSlash && bestMatch == null) bestMatch = matchFromList (host, pathSlash, list, out prefix); - if (bestMatch != null) - return bestMatch; - - return null; + return bestMatch; } #endregion From 7609c9289fdac7f3383020f8ae56b8e1cc48107d Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 4 Jun 2016 16:32:29 +0900 Subject: [PATCH 0472/6294] [Fix] Set system error code 87 --- websocket-sharp/Net/EndPointListener.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/EndPointListener.cs b/websocket-sharp/Net/EndPointListener.cs index 488b139fd..26bc7b997 100644 --- a/websocket-sharp/Net/EndPointListener.cs +++ b/websocket-sharp/Net/EndPointListener.cs @@ -433,7 +433,7 @@ public void AddPrefix (HttpListenerPrefix prefix, HttpListener listener) if (prefs.ContainsKey (prefix)) { if (prefs[prefix] != listener) throw new HttpListenerException ( - 400, String.Format ("There's another listener for {0}.", prefix)); // TODO: Code? + 87, String.Format ("There's another listener for {0}.", prefix)); return; } From 7f1115e4271c3b03947ab23a84f07f538900349d Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 4 Jun 2016 16:49:11 +0900 Subject: [PATCH 0473/6294] [Modify] Polish it --- websocket-sharp/Net/EndPointListener.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/EndPointListener.cs b/websocket-sharp/Net/EndPointListener.cs index 26bc7b997..6c929febf 100644 --- a/websocket-sharp/Net/EndPointListener.cs +++ b/websocket-sharp/Net/EndPointListener.cs @@ -431,9 +431,11 @@ public void AddPrefix (HttpListenerPrefix prefix, HttpListener listener) do { prefs = _prefixes; if (prefs.ContainsKey (prefix)) { - if (prefs[prefix] != listener) + if (prefs[prefix] != listener) { throw new HttpListenerException ( - 87, String.Format ("There's another listener for {0}.", prefix)); + 87, String.Format ("There's another listener for {0}.", prefix) + ); + } return; } From be55a3112d6262aec89ee9863dfc211545237efa Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 5 Jun 2016 16:51:09 +0900 Subject: [PATCH 0474/6294] [Fix] Don't remove the end slash --- websocket-sharp/Net/HttpListenerPrefix.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerPrefix.cs b/websocket-sharp/Net/HttpListenerPrefix.cs index c88470331..eefa95660 100644 --- a/websocket-sharp/Net/HttpListenerPrefix.cs +++ b/websocket-sharp/Net/HttpListenerPrefix.cs @@ -137,9 +137,7 @@ private void parse (string uriPrefix) _port = _secure ? "443" : "80"; } - var path = uriPrefix.Substring (root); - var pathLen = path.Length; - _path = pathLen > 1 ? path.Substring (0, pathLen - 1) : path; + _path = uriPrefix.Substring (root); } #endregion From e14c32190af1d416a694ee9cafa5704b8f08cbfc Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 6 Jun 2016 14:19:41 +0900 Subject: [PATCH 0475/6294] [Modify] Add it --- websocket-sharp/Net/EndPointListener.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/websocket-sharp/Net/EndPointListener.cs b/websocket-sharp/Net/EndPointListener.cs index 6c929febf..f636d180d 100644 --- a/websocket-sharp/Net/EndPointListener.cs +++ b/websocket-sharp/Net/EndPointListener.cs @@ -373,6 +373,19 @@ private HttpListener searchListener (Uri uri, out HttpListenerPrefix prefix) #region Internal Methods + internal bool BindHttpListenerTo (HttpListenerContext context) + { + HttpListenerPrefix pref; + var lsnr = searchListener (context.Request.Url, out pref); + if (lsnr == null) + return false; + + context.Listener = lsnr; + context.Connection.Prefix = pref; + + return true; + } + internal static bool CertificateExists (int port, string certificateFolderPath) { if (certificateFolderPath == null || certificateFolderPath.Length == 0) From cea98bd34705d9dbe8b339b9996972fb2dcf46e9 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 6 Jun 2016 14:37:23 +0900 Subject: [PATCH 0476/6294] [Modify] Replace it --- websocket-sharp/Net/EndPointListener.cs | 13 ------------- websocket-sharp/Net/HttpConnection.cs | 2 +- 2 files changed, 1 insertion(+), 14 deletions(-) diff --git a/websocket-sharp/Net/EndPointListener.cs b/websocket-sharp/Net/EndPointListener.cs index f636d180d..6e2500467 100644 --- a/websocket-sharp/Net/EndPointListener.cs +++ b/websocket-sharp/Net/EndPointListener.cs @@ -459,19 +459,6 @@ public void AddPrefix (HttpListenerPrefix prefix, HttpListener listener) while (Interlocked.CompareExchange (ref _prefixes, prefs2, prefs) != prefs); } - public bool BindContext (HttpListenerContext context) - { - HttpListenerPrefix pref; - var lsnr = searchListener (context.Request.Url, out pref); - if (lsnr == null) - return false; - - context.Listener = lsnr; - context.Connection.Prefix = pref; - - return true; - } - public void Close () { _socket.Close (); diff --git a/websocket-sharp/Net/HttpConnection.cs b/websocket-sharp/Net/HttpConnection.cs index 89b5fff0e..c21f48f4a 100644 --- a/websocket-sharp/Net/HttpConnection.cs +++ b/websocket-sharp/Net/HttpConnection.cs @@ -286,7 +286,7 @@ private static void onRead (IAsyncResult asyncResult) return; } - if (!conn._listener.BindContext (conn._context)) { + if (!conn._listener.BindHttpListenerTo (conn._context)) { conn.SendError ("Invalid host", 400); return; } From aa7ffde7ac9a2d7dd8102a2a588f82fe85a54e4e Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 6 Jun 2016 16:14:49 +0900 Subject: [PATCH 0477/6294] [Modify] Rename it --- websocket-sharp/Net/EndPointListener.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/EndPointListener.cs b/websocket-sharp/Net/EndPointListener.cs index 6e2500467..ebc8d73db 100644 --- a/websocket-sharp/Net/EndPointListener.cs +++ b/websocket-sharp/Net/EndPointListener.cs @@ -309,7 +309,7 @@ private static bool removeSpecial (List prefixes, HttpListen return false; } - private HttpListener searchListener (Uri uri, out HttpListenerPrefix prefix) + private HttpListener searchHttpListener (Uri uri, out HttpListenerPrefix prefix) { prefix = null; @@ -376,7 +376,7 @@ private HttpListener searchListener (Uri uri, out HttpListenerPrefix prefix) internal bool BindHttpListenerTo (HttpListenerContext context) { HttpListenerPrefix pref; - var lsnr = searchListener (context.Request.Url, out pref); + var lsnr = searchHttpListener (context.Request.Url, out pref); if (lsnr == null) return false; From b02b6f25e041f614999f7c18ae462c225432cfb1 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 7 Jun 2016 14:55:58 +0900 Subject: [PATCH 0478/6294] [Modify] Add it --- websocket-sharp/Net/EndPointListener.cs | 29 +++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/websocket-sharp/Net/EndPointListener.cs b/websocket-sharp/Net/EndPointListener.cs index ebc8d73db..da7fa62ef 100644 --- a/websocket-sharp/Net/EndPointListener.cs +++ b/websocket-sharp/Net/EndPointListener.cs @@ -369,6 +369,35 @@ private HttpListener searchHttpListener (Uri uri, out HttpListenerPrefix prefix) return bestMatch; } + private static HttpListener searchHttpListenerFromSpecial ( + string path, List prefixes, out HttpListenerPrefix prefix + ) + { + prefix = null; + + if (prefixes == null) + return null; + + HttpListener bestMatch = null; + + var bestLen = -1; + foreach (var pref in prefixes) { + var prefPath = pref.Path; + + var len = prefPath.Length; + if (len < bestLen) + continue; + + if (path.StartsWith (prefPath)) { + bestLen = len; + bestMatch = pref.Listener; + prefix = pref; + } + } + + return bestMatch; + } + #endregion #region Internal Methods From 387b9570b9a14804aff7aaf70d4ed93d534a6a47 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 7 Jun 2016 15:11:10 +0900 Subject: [PATCH 0479/6294] [Modify] Replace it --- websocket-sharp/Net/EndPointListener.cs | 37 +++---------------------- 1 file changed, 4 insertions(+), 33 deletions(-) diff --git a/websocket-sharp/Net/EndPointListener.cs b/websocket-sharp/Net/EndPointListener.cs index da7fa62ef..48badaa22 100644 --- a/websocket-sharp/Net/EndPointListener.cs +++ b/websocket-sharp/Net/EndPointListener.cs @@ -215,35 +215,6 @@ private static X509Certificate2 getCertificate ( return defaultCertificate; } - private static HttpListener matchFromList ( - string host, string path, List list, out HttpListenerPrefix prefix - ) - { - prefix = null; - - if (list == null) - return null; - - HttpListener bestMatch = null; - - var bestLen = -1; - foreach (var pref in list) { - var prefPath = pref.Path; - - var len = prefPath.Length; - if (len < bestLen) - continue; - - if (path.StartsWith (prefPath)) { - bestLen = len; - bestMatch = pref.Listener; - prefix = pref; - } - } - - return bestMatch; - } - private static void onAccept (IAsyncResult asyncResult) { var lsnr = (EndPointListener) asyncResult.AsyncState; @@ -354,17 +325,17 @@ private HttpListener searchHttpListener (Uri uri, out HttpListenerPrefix prefix) } var list = _unhandled; - bestMatch = matchFromList (host, path, list, out prefix); + bestMatch = searchHttpListenerFromSpecial (path, list, out prefix); if (path != pathSlash && bestMatch == null) - bestMatch = matchFromList (host, pathSlash, list, out prefix); + bestMatch = searchHttpListenerFromSpecial (pathSlash, list, out prefix); if (bestMatch != null) return bestMatch; list = _all; - bestMatch = matchFromList (host, path, list, out prefix); + bestMatch = searchHttpListenerFromSpecial (path, list, out prefix); if (path != pathSlash && bestMatch == null) - bestMatch = matchFromList (host, pathSlash, list, out prefix); + bestMatch = searchHttpListenerFromSpecial (pathSlash, list, out prefix); return bestMatch; } From 5852d8dd25328e157ef071772d9a346a87b562ca Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 8 Jun 2016 14:51:29 +0900 Subject: [PATCH 0480/6294] [Modify] Polish it --- websocket-sharp/Net/EndPointListener.cs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/websocket-sharp/Net/EndPointListener.cs b/websocket-sharp/Net/EndPointListener.cs index 48badaa22..e2b1b0bdb 100644 --- a/websocket-sharp/Net/EndPointListener.cs +++ b/websocket-sharp/Net/EndPointListener.cs @@ -324,18 +324,18 @@ private HttpListener searchHttpListener (Uri uri, out HttpListenerPrefix prefix) return bestMatch; } - var list = _unhandled; - bestMatch = searchHttpListenerFromSpecial (path, list, out prefix); - if (path != pathSlash && bestMatch == null) - bestMatch = searchHttpListenerFromSpecial (pathSlash, list, out prefix); + var prefs = _unhandled; + bestMatch = searchHttpListenerFromSpecial (path, prefs, out prefix); + if (bestMatch == null && pathSlash != path) + bestMatch = searchHttpListenerFromSpecial (pathSlash, prefs, out prefix); if (bestMatch != null) return bestMatch; - list = _all; - bestMatch = searchHttpListenerFromSpecial (path, list, out prefix); - if (path != pathSlash && bestMatch == null) - bestMatch = searchHttpListenerFromSpecial (pathSlash, list, out prefix); + prefs = _all; + bestMatch = searchHttpListenerFromSpecial (path, prefs, out prefix); + if (bestMatch == null && pathSlash != path) + bestMatch = searchHttpListenerFromSpecial (pathSlash, prefs, out prefix); return bestMatch; } From 6774f5ae37a83ced71fb0e319f88f85382bd3404 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 8 Jun 2016 14:58:30 +0900 Subject: [PATCH 0481/6294] [Modify] Polish it --- websocket-sharp/Net/EndPointListener.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Net/EndPointListener.cs b/websocket-sharp/Net/EndPointListener.cs index e2b1b0bdb..c8451a56b 100644 --- a/websocket-sharp/Net/EndPointListener.cs +++ b/websocket-sharp/Net/EndPointListener.cs @@ -193,15 +193,15 @@ private static RSACryptoServiceProvider createRSAFromFile (string filename) } private static X509Certificate2 getCertificate ( - int port, string certificateFolderPath, X509Certificate2 defaultCertificate + int port, string folderPath, X509Certificate2 defaultCertificate ) { - if (certificateFolderPath == null || certificateFolderPath.Length == 0) - certificateFolderPath = _defaultCertFolderPath; + if (folderPath == null || folderPath.Length == 0) + folderPath = _defaultCertFolderPath; try { - var cer = Path.Combine (certificateFolderPath, String.Format ("{0}.cer", port)); - var key = Path.Combine (certificateFolderPath, String.Format ("{0}.key", port)); + var cer = Path.Combine (folderPath, String.Format ("{0}.cer", port)); + var key = Path.Combine (folderPath, String.Format ("{0}.key", port)); if (File.Exists (cer) && File.Exists (key)) { var cert = new X509Certificate2 (cer); cert.PrivateKey = createRSAFromFile (key); From 8bbb5dde093b5f04641a6a636944da40d61a6f6c Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 8 Jun 2016 15:01:44 +0900 Subject: [PATCH 0482/6294] [Modify] Polish it --- websocket-sharp/Net/EndPointListener.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Net/EndPointListener.cs b/websocket-sharp/Net/EndPointListener.cs index c8451a56b..a4c7c755b 100644 --- a/websocket-sharp/Net/EndPointListener.cs +++ b/websocket-sharp/Net/EndPointListener.cs @@ -386,13 +386,13 @@ internal bool BindHttpListenerTo (HttpListenerContext context) return true; } - internal static bool CertificateExists (int port, string certificateFolderPath) + internal static bool CertificateExists (int port, string folderPath) { - if (certificateFolderPath == null || certificateFolderPath.Length == 0) - certificateFolderPath = _defaultCertFolderPath; + if (folderPath == null || folderPath.Length == 0) + folderPath = _defaultCertFolderPath; - var cer = Path.Combine (certificateFolderPath, String.Format ("{0}.cer", port)); - var key = Path.Combine (certificateFolderPath, String.Format ("{0}.key", port)); + var cer = Path.Combine (folderPath, String.Format ("{0}.cer", port)); + var key = Path.Combine (folderPath, String.Format ("{0}.key", port)); return File.Exists (cer) && File.Exists (key); } From d7c876d7f15fbe0b3cd189ef2747e17d252b55e2 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 9 Jun 2016 14:58:32 +0900 Subject: [PATCH 0483/6294] [Modify] Polish it --- websocket-sharp/Net/EndPointListener.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/EndPointListener.cs b/websocket-sharp/Net/EndPointListener.cs index a4c7c755b..b3b53a869 100644 --- a/websocket-sharp/Net/EndPointListener.cs +++ b/websocket-sharp/Net/EndPointListener.cs @@ -167,12 +167,12 @@ private void checkIfRemove () if (_prefixes.Count > 0) return; - var list = _unhandled; - if (list != null && list.Count > 0) + var prefs = _unhandled; + if (prefs != null && prefs.Count > 0) return; - list = _all; - if (list != null && list.Count > 0) + prefs = _all; + if (prefs != null && prefs.Count > 0) return; EndPointManager.RemoveEndPoint (this); From b75c2be498fd9881264a30b7b5fe2ef9929516ba Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 9 Jun 2016 16:24:52 +0900 Subject: [PATCH 0484/6294] [Fix] Don't use original --- websocket-sharp/Net/HttpListenerPrefix.cs | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerPrefix.cs b/websocket-sharp/Net/HttpListenerPrefix.cs index eefa95660..6deb5369e 100644 --- a/websocket-sharp/Net/HttpListenerPrefix.cs +++ b/websocket-sharp/Net/HttpListenerPrefix.cs @@ -53,6 +53,7 @@ internal sealed class HttpListenerPrefix private string _original; private string _path; private string _port; + private string _prefix; private bool _secure; #endregion @@ -102,6 +103,12 @@ public HttpListener Listener { } } + public string Original { + get { + return _original; + } + } + public string Path { get { return _path; @@ -138,6 +145,9 @@ private void parse (string uriPrefix) } _path = uriPrefix.Substring (root); + + _prefix = + String.Format ("http{0}://{1}:{2}{3}", _secure ? "s" : "", _host, _port, _path); } #endregion @@ -181,17 +191,17 @@ public static void CheckPrefix (string uriPrefix) public override bool Equals (Object obj) { var pref = obj as HttpListenerPrefix; - return pref != null && pref._original == _original; + return pref != null && pref._prefix == _prefix; } public override int GetHashCode () { - return _original.GetHashCode (); + return _prefix.GetHashCode (); } public override string ToString () { - return _original; + return _prefix; } #endregion From 81340a1f3138f0ee164de25b7446736e4d1e5ba0 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 10 Jun 2016 14:59:14 +0900 Subject: [PATCH 0485/6294] [Modify] Remove it --- websocket-sharp/Net/HttpListenerPrefix.cs | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerPrefix.cs b/websocket-sharp/Net/HttpListenerPrefix.cs index 6deb5369e..e470f082d 100644 --- a/websocket-sharp/Net/HttpListenerPrefix.cs +++ b/websocket-sharp/Net/HttpListenerPrefix.cs @@ -47,7 +47,6 @@ internal sealed class HttpListenerPrefix { #region Private Fields - private IPAddress[] _addresses; private string _host; private HttpListener _listener; private string _original; @@ -71,16 +70,6 @@ internal HttpListenerPrefix (string uriPrefix) #region Public Properties - public IPAddress[] Addresses { - get { - return _addresses; - } - - set { - _addresses = value; - } - } - public string Host { get { return _host; From 0ef00bf0a7d526fa705e938f1114d115691a377a Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 11 Jun 2016 15:45:14 +0900 Subject: [PATCH 0486/6294] [Modify] Add some xml doc comments --- websocket-sharp/Net/HttpListenerPrefix.cs | 34 +++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerPrefix.cs b/websocket-sharp/Net/HttpListenerPrefix.cs index e470f082d..cbbfbf020 100644 --- a/websocket-sharp/Net/HttpListenerPrefix.cs +++ b/websocket-sharp/Net/HttpListenerPrefix.cs @@ -59,7 +59,16 @@ internal sealed class HttpListenerPrefix #region Internal Constructors - // Must be called after calling the CheckPrefix method. + /// + /// Initializes a new instance of the class with + /// the specified . + /// + /// + /// This constructor must be called after calling the CheckPrefix method. + /// + /// + /// A that represents the URI prefix. + /// internal HttpListenerPrefix (string uriPrefix) { _original = uriPrefix; @@ -176,13 +185,34 @@ public static void CheckPrefix (string uriPrefix) throw new ArgumentException ("No path is specified.", "uriPrefix"); } - // The Equals and GetHashCode methods are required to detect duplicates in any collection. + /// + /// Determines whether this instance and the specified have the same value. + /// + /// + /// This method will be required to detect duplicates in any collection. + /// + /// + /// An to compare to this instance. + /// + /// + /// true if is a and + /// its value is the same as this instance; otherwise, false. + /// public override bool Equals (Object obj) { var pref = obj as HttpListenerPrefix; return pref != null && pref._prefix == _prefix; } + /// + /// Gets the hash code for this instance. + /// + /// + /// This method will be required to detect duplicates in any collection. + /// + /// + /// An that represents the hash code. + /// public override int GetHashCode () { return _prefix.GetHashCode (); From 2d68047e43f85c51940e85c3773b43915182b5af Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 12 Jun 2016 17:08:26 +0900 Subject: [PATCH 0487/6294] [Modify] 2016 --- websocket-sharp/Net/HttpListenerPrefix.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerPrefix.cs b/websocket-sharp/Net/HttpListenerPrefix.cs index cbbfbf020..960d02edf 100644 --- a/websocket-sharp/Net/HttpListenerPrefix.cs +++ b/websocket-sharp/Net/HttpListenerPrefix.cs @@ -8,7 +8,7 @@ * The MIT License * * Copyright (c) 2005 Novell, Inc. (http://www.novell.com) - * Copyright (c) 2012-2015 sta.blockhead + * Copyright (c) 2012-2016 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From 4fbc2d4f54b070026dd9e9ad3cd59dfa7fbb4317 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 13 Jun 2016 15:11:39 +0900 Subject: [PATCH 0488/6294] [Modify] Polish it --- websocket-sharp/Net/HttpConnection.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpConnection.cs b/websocket-sharp/Net/HttpConnection.cs index c21f48f4a..de6449673 100644 --- a/websocket-sharp/Net/HttpConnection.cs +++ b/websocket-sharp/Net/HttpConnection.cs @@ -99,7 +99,8 @@ internal HttpConnection (Socket socket, EndPointListener listener) conf.ServerCertificate, conf.ClientCertificateRequired, conf.EnabledSslProtocols, - conf.CheckCertificateRevocation); + conf.CheckCertificateRevocation + ); _stream = sslStream; } From cab803cca72b423ba93b7eeb3e6ae2c3349396ed Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 13 Jun 2016 15:43:32 +0900 Subject: [PATCH 0489/6294] [Modify] Polish it --- websocket-sharp/Net/HttpConnection.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/HttpConnection.cs b/websocket-sharp/Net/HttpConnection.cs index de6449673..1b3899428 100644 --- a/websocket-sharp/Net/HttpConnection.cs +++ b/websocket-sharp/Net/HttpConnection.cs @@ -487,12 +487,12 @@ public RequestStream GetRequestStream (long contentLength, bool chunked) disposeRequestBuffer (); if (chunked) { _context.Response.SendChunked = true; - _inputStream = new ChunkedRequestStream ( - _stream, buff, _position, len - _position, _context); + _inputStream = + new ChunkedRequestStream (_stream, buff, _position, len - _position, _context); } else { - _inputStream = new RequestStream ( - _stream, buff, _position, len - _position, contentLength); + _inputStream = + new RequestStream (_stream, buff, _position, len - _position, contentLength); } return _inputStream; From f398f7f05b7950aac66179cba8bb0ba35daa4d61 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 13 Jun 2016 16:13:15 +0900 Subject: [PATCH 0490/6294] [Fix] Set HTTP status code 404 --- websocket-sharp/Net/HttpConnection.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpConnection.cs b/websocket-sharp/Net/HttpConnection.cs index 1b3899428..23c684e91 100644 --- a/websocket-sharp/Net/HttpConnection.cs +++ b/websocket-sharp/Net/HttpConnection.cs @@ -288,7 +288,7 @@ private static void onRead (IAsyncResult asyncResult) } if (!conn._listener.BindHttpListenerTo (conn._context)) { - conn.SendError ("Invalid host", 400); + conn.SendError (null, 404); return; } From 847d78a6e8ea964b905368a136d8274644f7d718 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 14 Jun 2016 15:06:21 +0900 Subject: [PATCH 0491/6294] [Modify] Polish it --- websocket-sharp/Net/HttpConnection.cs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/websocket-sharp/Net/HttpConnection.cs b/websocket-sharp/Net/HttpConnection.cs index 23c684e91..72c3a55a4 100644 --- a/websocket-sharp/Net/HttpConnection.cs +++ b/websocket-sharp/Net/HttpConnection.cs @@ -374,8 +374,10 @@ private bool processInput (byte[] data, int length) private string readLineFrom (byte[] buffer, int offset, int length, out int read) { read = 0; + for (var i = offset; i < length && _lineState != LineState.Lf; i++) { read++; + var b = buffer[i]; if (b == 13) _lineState = LineState.Cr; @@ -385,15 +387,15 @@ private string readLineFrom (byte[] buffer, int offset, int length, out int read _currentLine.Append ((char) b); } - if (_lineState == LineState.Lf) { - _lineState = LineState.None; - var line = _currentLine.ToString (); - _currentLine.Length = 0; + if (_lineState != LineState.Lf) + return null; - return line; - } + var line = _currentLine.ToString (); + + _currentLine.Length = 0; + _lineState = LineState.None; - return null; + return line; } private void removeConnection () From 3351912e99ee5fcae9a5f18bf7c92276b432f627 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 14 Jun 2016 15:23:18 +0900 Subject: [PATCH 0492/6294] [Modify] Remove it --- websocket-sharp/Net/EndPointListener.cs | 1 - websocket-sharp/Net/HttpConnection.cs | 12 ------------ 2 files changed, 13 deletions(-) diff --git a/websocket-sharp/Net/EndPointListener.cs b/websocket-sharp/Net/EndPointListener.cs index b3b53a869..4c015bb17 100644 --- a/websocket-sharp/Net/EndPointListener.cs +++ b/websocket-sharp/Net/EndPointListener.cs @@ -381,7 +381,6 @@ internal bool BindHttpListenerTo (HttpListenerContext context) return false; context.Listener = lsnr; - context.Connection.Prefix = pref; return true; } diff --git a/websocket-sharp/Net/HttpConnection.cs b/websocket-sharp/Net/HttpConnection.cs index 72c3a55a4..e0285a08c 100644 --- a/websocket-sharp/Net/HttpConnection.cs +++ b/websocket-sharp/Net/HttpConnection.cs @@ -71,7 +71,6 @@ internal sealed class HttpConnection private EndPointListener _listener; private ResponseStream _outputStream; private int _position; - private HttpListenerPrefix _prefix; private MemoryStream _requestBuffer; private int _reuses; private bool _secure; @@ -137,16 +136,6 @@ public IPEndPoint LocalEndPoint { } } - public HttpListenerPrefix Prefix { - get { - return _prefix; - } - - set { - _prefix = value; - } - } - public IPEndPoint RemoteEndPoint { get { return (IPEndPoint) _socket.RemoteEndPoint; @@ -241,7 +230,6 @@ private void init () _lineState = LineState.None; _outputStream = null; _position = 0; - _prefix = null; _requestBuffer = new MemoryStream (); } From a595ac364207f906f93d0233df8b9b65edbad077 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 14 Jun 2016 15:30:19 +0900 Subject: [PATCH 0493/6294] [Modify] Add it --- websocket-sharp/Net/EndPointListener.cs | 26 +++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/websocket-sharp/Net/EndPointListener.cs b/websocket-sharp/Net/EndPointListener.cs index 4c015bb17..186e2996e 100644 --- a/websocket-sharp/Net/EndPointListener.cs +++ b/websocket-sharp/Net/EndPointListener.cs @@ -340,6 +340,32 @@ private HttpListener searchHttpListener (Uri uri, out HttpListenerPrefix prefix) return bestMatch; } + private static HttpListener searchHttpListenerFromSpecial ( + string path, List prefixes + ) + { + if (prefixes == null) + return null; + + HttpListener bestMatch = null; + + var bestLen = -1; + foreach (var pref in prefixes) { + var prefPath = pref.Path; + + var len = prefPath.Length; + if (len < bestLen) + continue; + + if (path.StartsWith (prefPath)) { + bestLen = len; + bestMatch = pref.Listener; + } + } + + return bestMatch; + } + private static HttpListener searchHttpListenerFromSpecial ( string path, List prefixes, out HttpListenerPrefix prefix ) From 400ba6ecd996b9fe604d01f10e52076809196a57 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 14 Jun 2016 15:54:34 +0900 Subject: [PATCH 0494/6294] [Modify] Add it --- websocket-sharp/Net/EndPointListener.cs | 57 +++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/websocket-sharp/Net/EndPointListener.cs b/websocket-sharp/Net/EndPointListener.cs index 186e2996e..cc15f8326 100644 --- a/websocket-sharp/Net/EndPointListener.cs +++ b/websocket-sharp/Net/EndPointListener.cs @@ -428,6 +428,63 @@ internal void RemoveConnection (HttpConnection connection) _unregistered.Remove (connection); } + internal bool TrySearchHttpListener (Uri uri, out HttpListener listener) + { + listener = null; + + if (uri == null) + return false; + + var host = uri.Host; + var dns = Uri.CheckHostName (host) == UriHostNameType.Dns; + var port = uri.Port.ToString (); + var path = HttpUtility.UrlDecode (uri.AbsolutePath); + var pathSlash = path[path.Length - 1] != '/' ? path + "/" : path; + + if (host != null && host.Length > 0) { + var bestLen = -1; + foreach (var pref in _prefixes.Keys) { + if (dns) { + var prefHost = pref.Host; + if (Uri.CheckHostName (prefHost) == UriHostNameType.Dns && prefHost != host) + continue; + } + + if (pref.Port != port) + continue; + + var prefPath = pref.Path; + + var len = prefPath.Length; + if (len < bestLen) + continue; + + if (path.StartsWith (prefPath) || pathSlash.StartsWith (prefPath)) { + bestLen = len; + listener = _prefixes[pref]; + } + } + + if (bestLen != -1) + return true; + } + + var prefs = _unhandled; + listener = searchHttpListenerFromSpecial (path, prefs); + if (listener == null && pathSlash != path) + listener = searchHttpListenerFromSpecial (pathSlash, prefs); + + if (listener != null) + return true; + + prefs = _all; + listener = searchHttpListenerFromSpecial (path, prefs); + if (listener == null && pathSlash != path) + listener = searchHttpListenerFromSpecial (pathSlash, prefs); + + return listener != null; + } + #endregion #region Public Methods From a007be11adf31ddcaafc4966a89fbe47ad357ce6 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 15 Jun 2016 15:29:05 +0900 Subject: [PATCH 0495/6294] [Modify] Replace it --- websocket-sharp/Net/EndPointListener.cs | 101 ------------------------ websocket-sharp/Net/HttpConnection.cs | 5 +- 2 files changed, 3 insertions(+), 103 deletions(-) diff --git a/websocket-sharp/Net/EndPointListener.cs b/websocket-sharp/Net/EndPointListener.cs index cc15f8326..9d7fd2011 100644 --- a/websocket-sharp/Net/EndPointListener.cs +++ b/websocket-sharp/Net/EndPointListener.cs @@ -280,66 +280,6 @@ private static bool removeSpecial (List prefixes, HttpListen return false; } - private HttpListener searchHttpListener (Uri uri, out HttpListenerPrefix prefix) - { - prefix = null; - - if (uri == null) - return null; - - var host = uri.Host; - var dns = Uri.CheckHostName (host) == UriHostNameType.Dns; - var port = uri.Port.ToString (); - var path = HttpUtility.UrlDecode (uri.AbsolutePath); - var pathSlash = path[path.Length - 1] != '/' ? path + "/" : path; - - HttpListener bestMatch = null; - - if (host != null && host.Length > 0) { - var bestLen = -1; - foreach (var pref in _prefixes.Keys) { - if (dns) { - var prefHost = pref.Host; - if (Uri.CheckHostName (prefHost) == UriHostNameType.Dns && prefHost != host) - continue; - } - - if (pref.Port != port) - continue; - - var prefPath = pref.Path; - - var len = prefPath.Length; - if (len < bestLen) - continue; - - if (path.StartsWith (prefPath) || pathSlash.StartsWith (prefPath)) { - bestLen = len; - bestMatch = _prefixes[pref]; - prefix = pref; - } - } - - if (bestLen != -1) - return bestMatch; - } - - var prefs = _unhandled; - bestMatch = searchHttpListenerFromSpecial (path, prefs, out prefix); - if (bestMatch == null && pathSlash != path) - bestMatch = searchHttpListenerFromSpecial (pathSlash, prefs, out prefix); - - if (bestMatch != null) - return bestMatch; - - prefs = _all; - bestMatch = searchHttpListenerFromSpecial (path, prefs, out prefix); - if (bestMatch == null && pathSlash != path) - bestMatch = searchHttpListenerFromSpecial (pathSlash, prefs, out prefix); - - return bestMatch; - } - private static HttpListener searchHttpListenerFromSpecial ( string path, List prefixes ) @@ -366,51 +306,10 @@ private static HttpListener searchHttpListenerFromSpecial ( return bestMatch; } - private static HttpListener searchHttpListenerFromSpecial ( - string path, List prefixes, out HttpListenerPrefix prefix - ) - { - prefix = null; - - if (prefixes == null) - return null; - - HttpListener bestMatch = null; - - var bestLen = -1; - foreach (var pref in prefixes) { - var prefPath = pref.Path; - - var len = prefPath.Length; - if (len < bestLen) - continue; - - if (path.StartsWith (prefPath)) { - bestLen = len; - bestMatch = pref.Listener; - prefix = pref; - } - } - - return bestMatch; - } - #endregion #region Internal Methods - internal bool BindHttpListenerTo (HttpListenerContext context) - { - HttpListenerPrefix pref; - var lsnr = searchHttpListener (context.Request.Url, out pref); - if (lsnr == null) - return false; - - context.Listener = lsnr; - - return true; - } - internal static bool CertificateExists (int port, string folderPath) { if (folderPath == null || folderPath.Length == 0) diff --git a/websocket-sharp/Net/HttpConnection.cs b/websocket-sharp/Net/HttpConnection.cs index e0285a08c..c189d320a 100644 --- a/websocket-sharp/Net/HttpConnection.cs +++ b/websocket-sharp/Net/HttpConnection.cs @@ -275,12 +275,12 @@ private static void onRead (IAsyncResult asyncResult) return; } - if (!conn._listener.BindHttpListenerTo (conn._context)) { + HttpListener lsnr; + if (!conn._listener.TrySearchHttpListener (conn._context.Request.Url, out lsnr)) { conn.SendError (null, 404); return; } - var lsnr = conn._context.Listener; if (conn._lastListener != lsnr) { conn.removeConnection (); if (!lsnr.AddConnection (conn)) { @@ -291,6 +291,7 @@ private static void onRead (IAsyncResult asyncResult) conn._lastListener = lsnr; } + conn._context.Listener = lsnr; if (!conn._context.Authenticate ()) return; From f1e6fb22dfe99d20eb8dfbe59182571380b8f026 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 15 Jun 2016 15:32:47 +0900 Subject: [PATCH 0496/6294] [Modify] 2016 --- websocket-sharp/Net/HttpConnection.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpConnection.cs b/websocket-sharp/Net/HttpConnection.cs index c189d320a..feb41139f 100644 --- a/websocket-sharp/Net/HttpConnection.cs +++ b/websocket-sharp/Net/HttpConnection.cs @@ -8,7 +8,7 @@ * The MIT License * * Copyright (c) 2005 Novell, Inc. (http://www.novell.com) - * Copyright (c) 2012-2015 sta.blockhead + * Copyright (c) 2012-2016 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From 33b1c522479025aa8c4241f8c6c616abde51acf9 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 15 Jun 2016 15:51:02 +0900 Subject: [PATCH 0497/6294] [Modify] Add it --- websocket-sharp/Net/EndPointManager.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/websocket-sharp/Net/EndPointManager.cs b/websocket-sharp/Net/EndPointManager.cs index 6558ce35a..111f8721f 100644 --- a/websocket-sharp/Net/EndPointManager.cs +++ b/websocket-sharp/Net/EndPointManager.cs @@ -168,6 +168,17 @@ private static void removePrefix (string uriPrefix, HttpListener listener) getEndPointListener (addr, port, pref.IsSecure, listener).RemovePrefix (pref, listener); } + private static bool tryGetEndPointListener ( + IPAddress address, int port, out EndPointListener listener + ) + { + listener = null; + + Dictionary endpoints; + return _addressToEndpoints.TryGetValue (address, out endpoints) + && endpoints.TryGetValue (port, out listener); + } + #endregion #region Internal Methods From d2c67c0fd6c2e326ea062ad6908cb75dd1d8cc52 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 15 Jun 2016 16:18:33 +0900 Subject: [PATCH 0498/6294] [Modify] Add it --- websocket-sharp/Net/EndPointManager.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/websocket-sharp/Net/EndPointManager.cs b/websocket-sharp/Net/EndPointManager.cs index 111f8721f..3b48b56f0 100644 --- a/websocket-sharp/Net/EndPointManager.cs +++ b/websocket-sharp/Net/EndPointManager.cs @@ -168,6 +168,19 @@ private static void removePrefix (string uriPrefix, HttpListener listener) getEndPointListener (addr, port, pref.IsSecure, listener).RemovePrefix (pref, listener); } + private static void setEndPointListener (EndPointListener listener) + { + var addr = listener.Address; + + Dictionary endpoints; + if (!_addressToEndpoints.TryGetValue (addr, out endpoints)) { + endpoints = new Dictionary (); + _addressToEndpoints[addr] = endpoints; + } + + endpoints[listener.Port] = listener; + } + private static bool tryGetEndPointListener ( IPAddress address, int port, out EndPointListener listener ) From 91842c96b29a91ec99d8e9a51f6b0a86a6fe8a4c Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 16 Jun 2016 14:56:39 +0900 Subject: [PATCH 0499/6294] [Modify] Replace it --- websocket-sharp/Net/EndPointManager.cs | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/EndPointManager.cs b/websocket-sharp/Net/EndPointManager.cs index 3b48b56f0..de1af7af6 100644 --- a/websocket-sharp/Net/EndPointManager.cs +++ b/websocket-sharp/Net/EndPointManager.cs @@ -101,7 +101,24 @@ private static void addPrefix (string uriPrefix, HttpListener listener) if (path.IndexOf ("//", StringComparison.Ordinal) != -1) throw new HttpListenerException (87, "Includes an invalid path."); - getEndPointListener (addr, port, pref.IsSecure, listener).AddPrefix (pref, listener); + EndPointListener lsnr; + if (tryGetEndPointListener (addr, port, out lsnr)) { + } + else { + lsnr = + new EndPointListener ( + addr, + port, + pref.IsSecure, + listener.CertificateFolderPath, + listener.SslConfiguration, + listener.ReuseAddress + ); + + setEndPointListener (lsnr); + } + + lsnr.AddPrefix (pref, listener); } private static IPAddress convertToIPAddress (string hostname) @@ -165,7 +182,11 @@ private static void removePrefix (string uriPrefix, HttpListener listener) if (path.IndexOf ("//", StringComparison.Ordinal) != -1) return; - getEndPointListener (addr, port, pref.IsSecure, listener).RemovePrefix (pref, listener); + EndPointListener lsnr; + if (!tryGetEndPointListener (addr, port, out lsnr)) + return; + + lsnr.RemovePrefix (pref, listener); } private static void setEndPointListener (EndPointListener listener) From c8f674c2f7129b290124a063d30dbfc796d495f2 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 17 Jun 2016 16:36:40 +0900 Subject: [PATCH 0500/6294] [Modify] Add a scheme check --- websocket-sharp/Net/EndPointManager.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/websocket-sharp/Net/EndPointManager.cs b/websocket-sharp/Net/EndPointManager.cs index de1af7af6..f0b692bac 100644 --- a/websocket-sharp/Net/EndPointManager.cs +++ b/websocket-sharp/Net/EndPointManager.cs @@ -103,6 +103,8 @@ private static void addPrefix (string uriPrefix, HttpListener listener) EndPointListener lsnr; if (tryGetEndPointListener (addr, port, out lsnr)) { + if (lsnr.IsSecure ^ pref.IsSecure) + throw new HttpListenerException (87, "Includes an invalid scheme."); } else { lsnr = @@ -186,6 +188,9 @@ private static void removePrefix (string uriPrefix, HttpListener listener) if (!tryGetEndPointListener (addr, port, out lsnr)) return; + if (lsnr.IsSecure ^ pref.IsSecure) + return; + lsnr.RemovePrefix (pref, listener); } From 02201e5772554a1303f5107905d7013e42e94bb1 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 17 Jun 2016 16:40:23 +0900 Subject: [PATCH 0501/6294] [Modify] Remove it --- websocket-sharp/Net/EndPointManager.cs | 34 -------------------------- 1 file changed, 34 deletions(-) diff --git a/websocket-sharp/Net/EndPointManager.cs b/websocket-sharp/Net/EndPointManager.cs index f0b692bac..903ce0715 100644 --- a/websocket-sharp/Net/EndPointManager.cs +++ b/websocket-sharp/Net/EndPointManager.cs @@ -128,40 +128,6 @@ private static IPAddress convertToIPAddress (string hostname) return hostname == "*" || hostname == "+" ? IPAddress.Any : hostname.ToIPAddress (); } - private static EndPointListener getEndPointListener ( - IPAddress address, int port, bool secure, HttpListener listener - ) - { - Dictionary endpoints = null; - if (_addressToEndpoints.ContainsKey (address)) { - endpoints = _addressToEndpoints[address]; - } - else { - endpoints = new Dictionary (); - _addressToEndpoints[address] = endpoints; - } - - EndPointListener lsnr = null; - if (endpoints.ContainsKey (port)) { - lsnr = endpoints[port]; - } - else { - lsnr = - new EndPointListener ( - address, - port, - secure, - listener.CertificateFolderPath, - listener.SslConfiguration, - listener.ReuseAddress - ); - - endpoints[port] = lsnr; - } - - return lsnr; - } - private static void removePrefix (string uriPrefix, HttpListener listener) { var pref = new HttpListenerPrefix (uriPrefix); From bca605bf91731e0380ddc1ca27fdc2124941c4f2 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 18 Jun 2016 15:35:52 +0900 Subject: [PATCH 0502/6294] [Modify] Polish it --- websocket-sharp/Net/EndPointManager.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/EndPointManager.cs b/websocket-sharp/Net/EndPointManager.cs index 903ce0715..2f1fe66dc 100644 --- a/websocket-sharp/Net/EndPointManager.cs +++ b/websocket-sharp/Net/EndPointManager.cs @@ -192,9 +192,9 @@ internal static void RemoveEndPoint (EndPointListener listener) { lock (((ICollection) _addressToEndpoints).SyncRoot) { var addr = listener.Address; - var eps = _addressToEndpoints[addr]; - eps.Remove (listener.Port); - if (eps.Count == 0) + var endpoints = _addressToEndpoints[addr]; + endpoints.Remove (listener.Port); + if (endpoints.Count == 0) _addressToEndpoints.Remove (addr); listener.Close (); From 63ce200cb33c0ebecda002d8d167759d1a91ad96 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 19 Jun 2016 16:00:53 +0900 Subject: [PATCH 0503/6294] [Modify] Add it --- websocket-sharp/Net/EndPointManager.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/websocket-sharp/Net/EndPointManager.cs b/websocket-sharp/Net/EndPointManager.cs index 2f1fe66dc..51bf5e0d5 100644 --- a/websocket-sharp/Net/EndPointManager.cs +++ b/websocket-sharp/Net/EndPointManager.cs @@ -173,6 +173,17 @@ private static void setEndPointListener (EndPointListener listener) endpoints[listener.Port] = listener; } + private static void setEndPointListener (IPAddress address, int port, EndPointListener listener) + { + Dictionary endpoints; + if (!_addressToEndpoints.TryGetValue (address, out endpoints)) { + endpoints = new Dictionary (); + _addressToEndpoints[address] = endpoints; + } + + endpoints[port] = listener; + } + private static bool tryGetEndPointListener ( IPAddress address, int port, out EndPointListener listener ) From 579f327597dcdb384ad031bc5a6c854ac4c2180d Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 20 Jun 2016 15:15:01 +0900 Subject: [PATCH 0504/6294] [Modify] Replace it --- websocket-sharp/Net/EndPointManager.cs | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/websocket-sharp/Net/EndPointManager.cs b/websocket-sharp/Net/EndPointManager.cs index 51bf5e0d5..5c9054e15 100644 --- a/websocket-sharp/Net/EndPointManager.cs +++ b/websocket-sharp/Net/EndPointManager.cs @@ -117,7 +117,7 @@ private static void addPrefix (string uriPrefix, HttpListener listener) listener.ReuseAddress ); - setEndPointListener (lsnr); + setEndPointListener (addr, port, lsnr); } lsnr.AddPrefix (pref, listener); @@ -160,19 +160,6 @@ private static void removePrefix (string uriPrefix, HttpListener listener) lsnr.RemovePrefix (pref, listener); } - private static void setEndPointListener (EndPointListener listener) - { - var addr = listener.Address; - - Dictionary endpoints; - if (!_addressToEndpoints.TryGetValue (addr, out endpoints)) { - endpoints = new Dictionary (); - _addressToEndpoints[addr] = endpoints; - } - - endpoints[listener.Port] = listener; - } - private static void setEndPointListener (IPAddress address, int port, EndPointListener listener) { Dictionary endpoints; From 02be830741d5a09db1d5155102b3e3dbd1987560 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 21 Jun 2016 15:36:29 +0900 Subject: [PATCH 0505/6294] [Modify] Retry the read if it returns zero Experimental modification to avoid 'cannot be read from the stream'. --- websocket-sharp/Ext.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 5d6710d39..36f521b7d 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -67,6 +67,7 @@ public static class Ext #region Private Fields private static readonly byte[] _last = new byte[] { 0x00 }; + private static readonly int _retry = 5; private const string _tspecials = "()<>@,;:\\\"/[]?={} \t"; #endregion @@ -653,17 +654,24 @@ internal static void ReadBytesAsync ( { var buff = new byte[length]; var offset = 0; + var retry = 0; AsyncCallback callback = null; callback = ar => { try { var nread = stream.EndRead (ar); - if (nread == 0 || nread == length) { + if (nread == 0 && retry < _retry) { + retry++; + } + else if (nread == 0 || nread == length) { if (completed != null) completed (buff.SubArray (0, offset + nread)); return; } + else { + retry = 0; + } offset += nread; length -= nread; From e2ab760ca680f08cb762ee9c3468c52125e65233 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 22 Jun 2016 14:41:33 +0900 Subject: [PATCH 0506/6294] [Modify] Retry the read if it returns zero Experimental modification to avoid 'cannot be read from the stream'. --- websocket-sharp/Ext.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 36f521b7d..39e346137 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -702,6 +702,7 @@ internal static void ReadBytesAsync ( { var dest = new MemoryStream (); var buff = new byte[bufferLength]; + var retry = 0; Action read = null; read = len => { @@ -718,7 +719,10 @@ internal static void ReadBytesAsync ( if (nread > 0) dest.Write (buff, 0, nread); - if (nread == 0 || nread == len) { + if (nread == 0 && retry < _retry) { + retry++; + } + else if (nread == 0 || nread == len) { if (completed != null) { dest.Close (); completed (dest.ToArray ()); @@ -727,6 +731,9 @@ internal static void ReadBytesAsync ( dest.Dispose (); return; } + else { + retry = 0; + } read (len - nread); } From 40c993a2de130201f60a7925cadfe5510cb7d7d2 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 22 Jun 2016 15:11:33 +0900 Subject: [PATCH 0507/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 51 +++++++++++++++++++++++------------------- 1 file changed, 28 insertions(+), 23 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 39e346137..df23a5a4f 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -650,39 +650,44 @@ internal static byte[] ReadBytes (this Stream stream, long length, int bufferLen } internal static void ReadBytesAsync ( - this Stream stream, int length, Action completed, Action error) + this Stream stream, int length, Action completed, Action error + ) { var buff = new byte[length]; var offset = 0; var retry = 0; AsyncCallback callback = null; - callback = ar => { - try { - var nread = stream.EndRead (ar); - if (nread == 0 && retry < _retry) { - retry++; - } - else if (nread == 0 || nread == length) { - if (completed != null) - completed (buff.SubArray (0, offset + nread)); + callback = + ar => { + try { + var nread = stream.EndRead (ar); + if (nread == 0 && retry < _retry) { + retry++; + stream.BeginRead (buff, offset, length, callback, null); + + return; + } + + if (nread == 0 || nread == length) { + if (completed != null) + completed (buff.SubArray (0, offset + nread)); + + return; + } - return; - } - else { retry = 0; - } - offset += nread; - length -= nread; + offset += nread; + length -= nread; - stream.BeginRead (buff, offset, length, callback, null); - } - catch (Exception ex) { - if (error != null) - error (ex); - } - }; + stream.BeginRead (buff, offset, length, callback, null); + } + catch (Exception ex) { + if (error != null) + error (ex); + } + }; try { stream.BeginRead (buff, offset, length, callback, null); From 33bbfddda691a4b9ca66d1c955c35f1277f9b73f Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 23 Jun 2016 15:09:52 +0900 Subject: [PATCH 0508/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 79 ++++++++++++++++++++++-------------------- 1 file changed, 42 insertions(+), 37 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index df23a5a4f..b5c5f302a 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -703,53 +703,58 @@ internal static void ReadBytesAsync ( long length, int bufferLength, Action completed, - Action error) + Action error + ) { var dest = new MemoryStream (); var buff = new byte[bufferLength]; var retry = 0; Action read = null; - read = len => { - if (len < bufferLength) - bufferLength = (int) len; - - stream.BeginRead ( - buff, - 0, - bufferLength, - ar => { - try { - var nread = stream.EndRead (ar); - if (nread > 0) - dest.Write (buff, 0, nread); - - if (nread == 0 && retry < _retry) { - retry++; - } - else if (nread == 0 || nread == len) { - if (completed != null) { - dest.Close (); - completed (dest.ToArray ()); + read = + len => { + if (len < bufferLength) + bufferLength = (int) len; + + stream.BeginRead ( + buff, + 0, + bufferLength, + ar => { + try { + var nread = stream.EndRead (ar); + if (nread > 0) + dest.Write (buff, 0, nread); + + if (nread == 0 && retry < _retry) { + retry++; + read (len); + + return; + } + + if (nread == 0 || nread == len) { + if (completed != null) { + dest.Close (); + completed (dest.ToArray ()); + } + + dest.Dispose (); + return; } - dest.Dispose (); - return; - } - else { retry = 0; + read (len - nread); } - - read (len - nread); - } - catch (Exception ex) { - dest.Dispose (); - if (error != null) - error (ex); - } - }, - null); - }; + catch (Exception ex) { + dest.Dispose (); + if (error != null) + error (ex); + } + }, + null + ); + }; try { read (length); From 2b1c986c7364884afef2e33709824d68a211db4f Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 24 Jun 2016 15:07:40 +0900 Subject: [PATCH 0509/6294] [Modify] Polish it --- websocket-sharp/Net/EndPointManager.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/EndPointManager.cs b/websocket-sharp/Net/EndPointManager.cs index 5c9054e15..cdc597d58 100644 --- a/websocket-sharp/Net/EndPointManager.cs +++ b/websocket-sharp/Net/EndPointManager.cs @@ -165,10 +165,10 @@ private static void setEndPointListener (IPAddress address, int port, EndPointLi Dictionary endpoints; if (!_addressToEndpoints.TryGetValue (address, out endpoints)) { endpoints = new Dictionary (); - _addressToEndpoints[address] = endpoints; + _addressToEndpoints.Add (address, endpoints); } - endpoints[port] = listener; + endpoints.Add (port, listener); } private static bool tryGetEndPointListener ( From bcca8707e60e7d40ff5b30b47d4da281e64a2c55 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 24 Jun 2016 15:14:50 +0900 Subject: [PATCH 0510/6294] [Modify] Rename it --- websocket-sharp/Net/EndPointManager.cs | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/websocket-sharp/Net/EndPointManager.cs b/websocket-sharp/Net/EndPointManager.cs index cdc597d58..6923e9faf 100644 --- a/websocket-sharp/Net/EndPointManager.cs +++ b/websocket-sharp/Net/EndPointManager.cs @@ -79,6 +79,17 @@ private EndPointManager () #region Private Methods + private static void addEndPointListener (IPAddress address, int port, EndPointListener listener) + { + Dictionary endpoints; + if (!_addressToEndpoints.TryGetValue (address, out endpoints)) { + endpoints = new Dictionary (); + _addressToEndpoints.Add (address, endpoints); + } + + endpoints.Add (port, listener); + } + private static void addPrefix (string uriPrefix, HttpListener listener) { var pref = new HttpListenerPrefix (uriPrefix); @@ -117,7 +128,7 @@ private static void addPrefix (string uriPrefix, HttpListener listener) listener.ReuseAddress ); - setEndPointListener (addr, port, lsnr); + addEndPointListener (addr, port, lsnr); } lsnr.AddPrefix (pref, listener); @@ -160,17 +171,6 @@ private static void removePrefix (string uriPrefix, HttpListener listener) lsnr.RemovePrefix (pref, listener); } - private static void setEndPointListener (IPAddress address, int port, EndPointListener listener) - { - Dictionary endpoints; - if (!_addressToEndpoints.TryGetValue (address, out endpoints)) { - endpoints = new Dictionary (); - _addressToEndpoints.Add (address, endpoints); - } - - endpoints.Add (port, listener); - } - private static bool tryGetEndPointListener ( IPAddress address, int port, out EndPointListener listener ) From 76e961629e8963dec7a333d54f8d1d0ba513fbe2 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 25 Jun 2016 15:17:44 +0900 Subject: [PATCH 0511/6294] [Modify] Polish it --- websocket-sharp/Net/EndPointManager.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/EndPointManager.cs b/websocket-sharp/Net/EndPointManager.cs index 6923e9faf..4db251ec7 100644 --- a/websocket-sharp/Net/EndPointManager.cs +++ b/websocket-sharp/Net/EndPointManager.cs @@ -190,7 +190,11 @@ internal static void RemoveEndPoint (EndPointListener listener) { lock (((ICollection) _addressToEndpoints).SyncRoot) { var addr = listener.Address; - var endpoints = _addressToEndpoints[addr]; + + Dictionary endpoints; + if (!_addressToEndpoints.TryGetValue (addr, out endpoints)) + return; + endpoints.Remove (listener.Port); if (endpoints.Count == 0) _addressToEndpoints.Remove (addr); From b9c2eefaff8e40f62318be909cab71489236667f Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 25 Jun 2016 15:33:47 +0900 Subject: [PATCH 0512/6294] [Modify] Add it --- websocket-sharp/Net/EndPointManager.cs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/websocket-sharp/Net/EndPointManager.cs b/websocket-sharp/Net/EndPointManager.cs index 4db251ec7..fe6979a58 100644 --- a/websocket-sharp/Net/EndPointManager.cs +++ b/websocket-sharp/Net/EndPointManager.cs @@ -203,6 +203,26 @@ internal static void RemoveEndPoint (EndPointListener listener) } } + internal static bool RemoveEndPoint (IPAddress address, int port) + { + lock (((ICollection) _addressToEndpoints).SyncRoot) { + Dictionary endpoints; + if (!_addressToEndpoints.TryGetValue (address, out endpoints)) + return false; + + EndPointListener lsnr; + if (!endpoints.TryGetValue (port, out lsnr)) + return false; + + endpoints.Remove (port); + if (endpoints.Count == 0) + _addressToEndpoints.Remove (address); + + lsnr.Close (); + return true; + } + } + #endregion #region Public Methods From e9843b9f25f4a8a81aea6e4b3aca409ff05af39c Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 26 Jun 2016 15:21:57 +0900 Subject: [PATCH 0513/6294] [Modify] Replace it --- websocket-sharp/Net/EndPointListener.cs | 2 +- websocket-sharp/Net/EndPointManager.cs | 17 ----------------- 2 files changed, 1 insertion(+), 18 deletions(-) diff --git a/websocket-sharp/Net/EndPointListener.cs b/websocket-sharp/Net/EndPointListener.cs index 9d7fd2011..a271340a3 100644 --- a/websocket-sharp/Net/EndPointListener.cs +++ b/websocket-sharp/Net/EndPointListener.cs @@ -175,7 +175,7 @@ private void checkIfRemove () if (prefs != null && prefs.Count > 0) return; - EndPointManager.RemoveEndPoint (this); + EndPointManager.RemoveEndPoint (_endpoint.Address, _endpoint.Port); } private static RSACryptoServiceProvider createRSAFromFile (string filename) diff --git a/websocket-sharp/Net/EndPointManager.cs b/websocket-sharp/Net/EndPointManager.cs index fe6979a58..c61e476fa 100644 --- a/websocket-sharp/Net/EndPointManager.cs +++ b/websocket-sharp/Net/EndPointManager.cs @@ -186,23 +186,6 @@ private static bool tryGetEndPointListener ( #region Internal Methods - internal static void RemoveEndPoint (EndPointListener listener) - { - lock (((ICollection) _addressToEndpoints).SyncRoot) { - var addr = listener.Address; - - Dictionary endpoints; - if (!_addressToEndpoints.TryGetValue (addr, out endpoints)) - return; - - endpoints.Remove (listener.Port); - if (endpoints.Count == 0) - _addressToEndpoints.Remove (addr); - - listener.Close (); - } - } - internal static bool RemoveEndPoint (IPAddress address, int port) { lock (((ICollection) _addressToEndpoints).SyncRoot) { From afcfb3334f49a8acc465a46b9abb75fa3087e0cd Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 26 Jun 2016 15:58:58 +0900 Subject: [PATCH 0514/6294] [Modify] Add it --- websocket-sharp/Net/EndPointListener.cs | 35 +++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/websocket-sharp/Net/EndPointListener.cs b/websocket-sharp/Net/EndPointListener.cs index a271340a3..98643a0a2 100644 --- a/websocket-sharp/Net/EndPointListener.cs +++ b/websocket-sharp/Net/EndPointListener.cs @@ -86,6 +86,41 @@ static EndPointListener () #region Internal Constructors + internal EndPointListener ( + IPEndPoint endpoint, + bool secure, + string certificateFolderPath, + ServerSslConfiguration sslConfig, + bool reuseAddress + ) + { + if (secure) { + var cert = + getCertificate (endpoint.Port, certificateFolderPath, sslConfig.ServerCertificate); + + if (cert == null) + throw new ArgumentException ("No server certificate could be found."); + + _secure = secure; + _sslConfig = sslConfig; + _sslConfig.ServerCertificate = cert; + } + + _endpoint = endpoint; + _prefixes = new Dictionary (); + _unregistered = new Dictionary (); + _unregisteredSync = ((ICollection) _unregistered).SyncRoot; + _socket = + new Socket (endpoint.Address.AddressFamily, SocketType.Stream, ProtocolType.Tcp); + + if (reuseAddress) + _socket.SetSocketOption (SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true); + + _socket.Bind (endpoint); + _socket.Listen (500); + _socket.BeginAccept (onAccept, this); + } + internal EndPointListener ( IPAddress address, int port, From 8a9125ba3b393e1b7bbf05ecc587e4eec2b7c8ff Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 26 Jun 2016 16:16:32 +0900 Subject: [PATCH 0515/6294] [Modify] Add it --- websocket-sharp/Net/EndPointManager.cs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/websocket-sharp/Net/EndPointManager.cs b/websocket-sharp/Net/EndPointManager.cs index c61e476fa..f2fe9ec8a 100644 --- a/websocket-sharp/Net/EndPointManager.cs +++ b/websocket-sharp/Net/EndPointManager.cs @@ -58,6 +58,8 @@ internal sealed class EndPointManager private static readonly Dictionary> _addressToEndpoints; + private static readonly Dictionary _endpoints; + #endregion #region Static Constructor @@ -65,6 +67,7 @@ private static readonly Dictionary> static EndPointManager () { _addressToEndpoints = new Dictionary> (); + _endpoints = new Dictionary (); } #endregion @@ -186,6 +189,20 @@ private static bool tryGetEndPointListener ( #region Internal Methods + internal static bool RemoveEndPoint (IPEndPoint endpoint) + { + lock (((ICollection) _endpoints).SyncRoot) { + EndPointListener lsnr; + if (!_endpoints.TryGetValue (endpoint, out lsnr)) + return false; + + _endpoints.Remove (endpoint); + lsnr.Close (); + + return true; + } + } + internal static bool RemoveEndPoint (IPAddress address, int port) { lock (((ICollection) _addressToEndpoints).SyncRoot) { From bdafcf2d3934f6e9c8b38dc014a5927af7414b2d Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 27 Jun 2016 14:58:59 +0900 Subject: [PATCH 0516/6294] [Modify] Replace it --- websocket-sharp/Net/EndPointListener.cs | 2 +- websocket-sharp/Net/EndPointManager.cs | 67 +++++-------------------- 2 files changed, 13 insertions(+), 56 deletions(-) diff --git a/websocket-sharp/Net/EndPointListener.cs b/websocket-sharp/Net/EndPointListener.cs index 98643a0a2..85eea886f 100644 --- a/websocket-sharp/Net/EndPointListener.cs +++ b/websocket-sharp/Net/EndPointListener.cs @@ -210,7 +210,7 @@ private void checkIfRemove () if (prefs != null && prefs.Count > 0) return; - EndPointManager.RemoveEndPoint (_endpoint.Address, _endpoint.Port); + EndPointManager.RemoveEndPoint (_endpoint); } private static RSACryptoServiceProvider createRSAFromFile (string filename) diff --git a/websocket-sharp/Net/EndPointManager.cs b/websocket-sharp/Net/EndPointManager.cs index f2fe9ec8a..ebecf459e 100644 --- a/websocket-sharp/Net/EndPointManager.cs +++ b/websocket-sharp/Net/EndPointManager.cs @@ -55,9 +55,6 @@ internal sealed class EndPointManager { #region Private Fields - private static readonly Dictionary> - _addressToEndpoints; - private static readonly Dictionary _endpoints; #endregion @@ -66,7 +63,6 @@ private static readonly Dictionary> static EndPointManager () { - _addressToEndpoints = new Dictionary> (); _endpoints = new Dictionary (); } @@ -82,17 +78,6 @@ private EndPointManager () #region Private Methods - private static void addEndPointListener (IPAddress address, int port, EndPointListener listener) - { - Dictionary endpoints; - if (!_addressToEndpoints.TryGetValue (address, out endpoints)) { - endpoints = new Dictionary (); - _addressToEndpoints.Add (address, endpoints); - } - - endpoints.Add (port, listener); - } - private static void addPrefix (string uriPrefix, HttpListener listener) { var pref = new HttpListenerPrefix (uriPrefix); @@ -115,23 +100,24 @@ private static void addPrefix (string uriPrefix, HttpListener listener) if (path.IndexOf ("//", StringComparison.Ordinal) != -1) throw new HttpListenerException (87, "Includes an invalid path."); + var endpoint = new IPEndPoint (addr, port); + EndPointListener lsnr; - if (tryGetEndPointListener (addr, port, out lsnr)) { + if (_endpoints.TryGetValue (endpoint, out lsnr)) { if (lsnr.IsSecure ^ pref.IsSecure) throw new HttpListenerException (87, "Includes an invalid scheme."); } else { lsnr = new EndPointListener ( - addr, - port, + endpoint, pref.IsSecure, listener.CertificateFolderPath, listener.SslConfiguration, listener.ReuseAddress ); - addEndPointListener (addr, port, lsnr); + _endpoints.Add (endpoint, lsnr); } lsnr.AddPrefix (pref, listener); @@ -164,8 +150,10 @@ private static void removePrefix (string uriPrefix, HttpListener listener) if (path.IndexOf ("//", StringComparison.Ordinal) != -1) return; + var endpoint = new IPEndPoint (addr, port); + EndPointListener lsnr; - if (!tryGetEndPointListener (addr, port, out lsnr)) + if (!_endpoints.TryGetValue (endpoint, out lsnr)) return; if (lsnr.IsSecure ^ pref.IsSecure) @@ -174,17 +162,6 @@ private static void removePrefix (string uriPrefix, HttpListener listener) lsnr.RemovePrefix (pref, listener); } - private static bool tryGetEndPointListener ( - IPAddress address, int port, out EndPointListener listener - ) - { - listener = null; - - Dictionary endpoints; - return _addressToEndpoints.TryGetValue (address, out endpoints) - && endpoints.TryGetValue (port, out listener); - } - #endregion #region Internal Methods @@ -203,26 +180,6 @@ internal static bool RemoveEndPoint (IPEndPoint endpoint) } } - internal static bool RemoveEndPoint (IPAddress address, int port) - { - lock (((ICollection) _addressToEndpoints).SyncRoot) { - Dictionary endpoints; - if (!_addressToEndpoints.TryGetValue (address, out endpoints)) - return false; - - EndPointListener lsnr; - if (!endpoints.TryGetValue (port, out lsnr)) - return false; - - endpoints.Remove (port); - if (endpoints.Count == 0) - _addressToEndpoints.Remove (address); - - lsnr.Close (); - return true; - } - } - #endregion #region Public Methods @@ -230,7 +187,7 @@ internal static bool RemoveEndPoint (IPAddress address, int port) public static void AddListener (HttpListener listener) { var added = new List (); - lock (((ICollection) _addressToEndpoints).SyncRoot) { + lock (((ICollection) _endpoints).SyncRoot) { try { foreach (var pref in listener.Prefixes) { addPrefix (pref, listener); @@ -248,13 +205,13 @@ public static void AddListener (HttpListener listener) public static void AddPrefix (string uriPrefix, HttpListener listener) { - lock (((ICollection) _addressToEndpoints).SyncRoot) + lock (((ICollection) _endpoints).SyncRoot) addPrefix (uriPrefix, listener); } public static void RemoveListener (HttpListener listener) { - lock (((ICollection) _addressToEndpoints).SyncRoot) { + lock (((ICollection) _endpoints).SyncRoot) { foreach (var pref in listener.Prefixes) removePrefix (pref, listener); } @@ -262,7 +219,7 @@ public static void RemoveListener (HttpListener listener) public static void RemovePrefix (string uriPrefix, HttpListener listener) { - lock (((ICollection) _addressToEndpoints).SyncRoot) + lock (((ICollection) _endpoints).SyncRoot) removePrefix (uriPrefix, listener); } From 2a6e25a76fa086ee2d84fb0198d3b56cc8abba07 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 27 Jun 2016 15:03:02 +0900 Subject: [PATCH 0517/6294] [Modify] Remove it --- websocket-sharp/Net/EndPointListener.cs | 33 ------------------------- 1 file changed, 33 deletions(-) diff --git a/websocket-sharp/Net/EndPointListener.cs b/websocket-sharp/Net/EndPointListener.cs index 85eea886f..f68b8c248 100644 --- a/websocket-sharp/Net/EndPointListener.cs +++ b/websocket-sharp/Net/EndPointListener.cs @@ -121,39 +121,6 @@ bool reuseAddress _socket.BeginAccept (onAccept, this); } - internal EndPointListener ( - IPAddress address, - int port, - bool secure, - string certificateFolderPath, - ServerSslConfiguration sslConfig, - bool reuseAddress - ) - { - if (secure) { - var cert = getCertificate (port, certificateFolderPath, sslConfig.ServerCertificate); - if (cert == null) - throw new ArgumentException ("No server certificate could be found."); - - _secure = secure; - _sslConfig = sslConfig; - _sslConfig.ServerCertificate = cert; - } - - _prefixes = new Dictionary (); - _unregistered = new Dictionary (); - _unregisteredSync = ((ICollection) _unregistered).SyncRoot; - - _socket = new Socket (address.AddressFamily, SocketType.Stream, ProtocolType.Tcp); - if (reuseAddress) - _socket.SetSocketOption (SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true); - - _endpoint = new IPEndPoint (address, port); - _socket.Bind (_endpoint); - _socket.Listen (500); - _socket.BeginAccept (onAccept, this); - } - #endregion #region Public Properties From 5af4a39539fa8b076b34988dedcbed7fa0816760 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 28 Jun 2016 16:52:17 +0900 Subject: [PATCH 0518/6294] [Modify] Rename it --- websocket-sharp/Net/EndPointListener.cs | 38 ++++++++++++------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/websocket-sharp/Net/EndPointListener.cs b/websocket-sharp/Net/EndPointListener.cs index f68b8c248..aa3d04232 100644 --- a/websocket-sharp/Net/EndPointListener.cs +++ b/websocket-sharp/Net/EndPointListener.cs @@ -164,22 +164,6 @@ private static void addSpecial (List prefixes, HttpListenerP prefixes.Add (prefix); } - private void checkIfRemove () - { - if (_prefixes.Count > 0) - return; - - var prefs = _unhandled; - if (prefs != null && prefs.Count > 0) - return; - - prefs = _all; - if (prefs != null && prefs.Count > 0) - return; - - EndPointManager.RemoveEndPoint (_endpoint); - } - private static RSACryptoServiceProvider createRSAFromFile (string filename) { byte[] pvk = null; @@ -217,6 +201,22 @@ private static X509Certificate2 getCertificate ( return defaultCertificate; } + private void leaveIfNoPrefix () + { + if (_prefixes.Count > 0) + return; + + var prefs = _unhandled; + if (prefs != null && prefs.Count > 0) + return; + + prefs = _all; + if (prefs != null && prefs.Count > 0) + return; + + EndPointManager.RemoveEndPoint (_endpoint); + } + private static void onAccept (IAsyncResult asyncResult) { var lsnr = (EndPointListener) asyncResult.AsyncState; @@ -476,7 +476,7 @@ public void RemovePrefix (HttpListenerPrefix prefix, HttpListener listener) } while (Interlocked.CompareExchange (ref _unhandled, future, current) != current); - checkIfRemove (); + leaveIfNoPrefix (); return; } @@ -492,7 +492,7 @@ public void RemovePrefix (HttpListenerPrefix prefix, HttpListener listener) } while (Interlocked.CompareExchange (ref _all, future, current) != current); - checkIfRemove (); + leaveIfNoPrefix (); return; } @@ -507,7 +507,7 @@ public void RemovePrefix (HttpListenerPrefix prefix, HttpListener listener) } while (Interlocked.CompareExchange (ref _prefixes, prefs2, prefs) != prefs); - checkIfRemove (); + leaveIfNoPrefix (); } #endregion From 281c99f70490751a698d4e338d58f18e8e480932 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 29 Jun 2016 14:14:04 +0900 Subject: [PATCH 0519/6294] [Modify] Edit it --- websocket-sharp/Net/WebSockets/WebSocketContext.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/WebSockets/WebSocketContext.cs b/websocket-sharp/Net/WebSockets/WebSocketContext.cs index 5f88e7094..481787fbf 100644 --- a/websocket-sharp/Net/WebSockets/WebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/WebSocketContext.cs @@ -34,10 +34,10 @@ namespace WebSocketSharp.Net.WebSockets { /// - /// Exposes the properties used to access the information in a WebSocket connection request. + /// Exposes the properties used to access the information in a WebSocket handshake request. /// /// - /// The WebSocketContext class is an abstract class. + /// This class is an abstract class. /// public abstract class WebSocketContext { From 4c188630844981ac2b1c120fb0ff2b7d0310beeb Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 29 Jun 2016 14:27:00 +0900 Subject: [PATCH 0520/6294] [Modify] Edit it --- websocket-sharp/Net/WebSockets/WebSocketContext.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/WebSockets/WebSocketContext.cs b/websocket-sharp/Net/WebSockets/WebSocketContext.cs index 481787fbf..531a6bd23 100644 --- a/websocket-sharp/Net/WebSockets/WebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/WebSocketContext.cs @@ -103,10 +103,10 @@ protected WebSocketContext () public abstract bool IsSecureConnection { get; } /// - /// Gets a value indicating whether the request is a WebSocket connection request. + /// Gets a value indicating whether the request is a WebSocket handshake request. /// /// - /// true if the request is a WebSocket connection request; otherwise, false. + /// true if the request is a WebSocket handshake request; otherwise, false. /// public abstract bool IsWebSocketRequest { get; } From 899d41489dacccf580588bd940f17e4af1208d25 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 29 Jun 2016 14:34:52 +0900 Subject: [PATCH 0521/6294] [Modify] Edit it --- websocket-sharp/Net/WebSockets/WebSocketContext.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/WebSockets/WebSocketContext.cs b/websocket-sharp/Net/WebSockets/WebSocketContext.cs index 531a6bd23..de3e73f4a 100644 --- a/websocket-sharp/Net/WebSockets/WebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/WebSocketContext.cs @@ -138,8 +138,8 @@ protected WebSocketContext () /// Gets the value of the Sec-WebSocket-Key header included in the request. /// /// - /// This property provides a part of the information used by the server to prove that it - /// received a valid WebSocket connection request. + /// This property provides a part of the information used by the server to prove that + /// it received a valid WebSocket handshake request. /// /// /// A that represents the value of the Sec-WebSocket-Key header. From bb561ee5c07a068ae617c82aed2caf984d99cbda Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 29 Jun 2016 14:47:53 +0900 Subject: [PATCH 0522/6294] [Modify] Edit it --- websocket-sharp/Net/WebSockets/WebSocketContext.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/WebSockets/WebSocketContext.cs b/websocket-sharp/Net/WebSockets/WebSocketContext.cs index de3e73f4a..257263c85 100644 --- a/websocket-sharp/Net/WebSockets/WebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/WebSocketContext.cs @@ -195,8 +195,8 @@ protected WebSocketContext () public abstract System.Net.IPEndPoint UserEndPoint { get; } /// - /// Gets the instance used for two-way communication - /// between client and server. + /// Gets the instance used for + /// two-way communication between client and server. /// /// /// A . From 705905a5838bd75d1071e03fd33b3f36687ad050 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 29 Jun 2016 15:06:12 +0900 Subject: [PATCH 0523/6294] [Modify] 2016 --- websocket-sharp/Net/WebSockets/WebSocketContext.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebSockets/WebSocketContext.cs b/websocket-sharp/Net/WebSockets/WebSocketContext.cs index 257263c85..9ede501bf 100644 --- a/websocket-sharp/Net/WebSockets/WebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/WebSocketContext.cs @@ -4,7 +4,7 @@ * * The MIT License * - * Copyright (c) 2012-2014 sta.blockhead + * Copyright (c) 2012-2016 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From 8a048e040876f8d1217fd6910b41c3a9795c0a87 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 30 Jun 2016 14:34:42 +0900 Subject: [PATCH 0524/6294] [Modify] Edit it --- .../Net/WebSockets/HttpListenerWebSocketContext.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs b/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs index f89e8962a..e998fb5b4 100644 --- a/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs @@ -35,8 +35,8 @@ namespace WebSocketSharp.Net.WebSockets { /// - /// Provides the properties used to access the information in a WebSocket connection request - /// received by the . + /// Provides the properties used to access the information in + /// a WebSocket handshake request received by the . /// public class HttpListenerWebSocketContext : WebSocketContext { From 61e33f5c74039e242de13acc76a55df426287395 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 30 Jun 2016 14:44:13 +0900 Subject: [PATCH 0525/6294] [Modify] Edit it --- .../Net/WebSockets/HttpListenerWebSocketContext.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs b/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs index e998fb5b4..ed46ef270 100644 --- a/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs @@ -148,10 +148,10 @@ public override bool IsSecureConnection { } /// - /// Gets a value indicating whether the request is a WebSocket connection request. + /// Gets a value indicating whether the request is a WebSocket handshake request. /// /// - /// true if the request is a WebSocket connection request; otherwise, false. + /// true if the request is a WebSocket handshake request; otherwise, false. /// public override bool IsWebSocketRequest { get { From f6dc66527ef9458208b5102d5a041e1934710921 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 30 Jun 2016 14:49:29 +0900 Subject: [PATCH 0526/6294] [Modify] Edit it --- .../Net/WebSockets/HttpListenerWebSocketContext.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs b/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs index ed46ef270..23a7f2ed4 100644 --- a/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs @@ -199,8 +199,8 @@ public override Uri RequestUri { /// Gets the value of the Sec-WebSocket-Key header included in the request. /// /// - /// This property provides a part of the information used by the server to prove that it - /// received a valid WebSocket connection request. + /// This property provides a part of the information used by the server to prove that + /// it received a valid WebSocket handshake request. /// /// /// A that represents the value of the Sec-WebSocket-Key header. From 977b9de1b86a39f0fd0ed2c86d883e84de547f36 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 30 Jun 2016 15:01:00 +0900 Subject: [PATCH 0527/6294] [Modify] Edit it --- .../Net/WebSockets/HttpListenerWebSocketContext.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs b/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs index 23a7f2ed4..cd96cb215 100644 --- a/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs @@ -283,8 +283,8 @@ public override System.Net.IPEndPoint UserEndPoint { } /// - /// Gets the instance used for two-way communication - /// between client and server. + /// Gets the instance used for + /// two-way communication between client and server. /// /// /// A . From f374018356c30473e7668ebdeb953d64939bd78a Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 30 Jun 2016 15:05:38 +0900 Subject: [PATCH 0528/6294] [Modify] Edit it --- .../Net/WebSockets/HttpListenerWebSocketContext.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs b/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs index cd96cb215..39b2d07fe 100644 --- a/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs @@ -314,12 +314,12 @@ internal void Close (HttpStatusCode code) #region Public Methods /// - /// Returns a that represents the current - /// . + /// Returns a that represents + /// the current . /// /// - /// A that represents the current - /// . + /// A that represents + /// the current . /// public override string ToString () { From 26fb29ef005c53b9de79032097a94e9476aac0a4 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 30 Jun 2016 15:19:07 +0900 Subject: [PATCH 0529/6294] [Modify] Polish it --- websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs b/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs index 39b2d07fe..1acb5b6ee 100644 --- a/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs @@ -225,9 +225,10 @@ public override string SecWebSocketKey { public override IEnumerable SecWebSocketProtocols { get { var protocols = _context.Request.Headers["Sec-WebSocket-Protocol"]; - if (protocols != null) + if (protocols != null) { foreach (var protocol in protocols.Split (',')) yield return protocol.Trim (); + } } } From e0be365a9cb6f07833ac2bf24c5af2724d6d6700 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 1 Jul 2016 15:44:52 +0900 Subject: [PATCH 0530/6294] [Modify] 2016 --- websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs b/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs index 1acb5b6ee..86e4ff053 100644 --- a/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs @@ -4,7 +4,7 @@ * * The MIT License * - * Copyright (c) 2012-2015 sta.blockhead + * Copyright (c) 2012-2016 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From 217912bb713af74e6fed8bc23f4deb8c15f3079a Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 2 Jul 2016 16:29:43 +0900 Subject: [PATCH 0531/6294] [Fix] Set new one --- websocket-sharp/Net/EndPointListener.cs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/EndPointListener.cs b/websocket-sharp/Net/EndPointListener.cs index aa3d04232..12a7bc0c6 100644 --- a/websocket-sharp/Net/EndPointListener.cs +++ b/websocket-sharp/Net/EndPointListener.cs @@ -102,8 +102,16 @@ bool reuseAddress throw new ArgumentException ("No server certificate could be found."); _secure = secure; - _sslConfig = sslConfig; - _sslConfig.ServerCertificate = cert; + _sslConfig = + new ServerSslConfiguration ( + cert, + sslConfig.ClientCertificateRequired, + sslConfig.EnabledSslProtocols, + sslConfig.CheckCertificateRevocation + ); + + _sslConfig.ClientCertificateValidationCallback = + sslConfig.ClientCertificateValidationCallback; } _endpoint = endpoint; From c044fdc4d057fab99c92e8d5809c088476b1225a Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 3 Jul 2016 15:27:21 +0900 Subject: [PATCH 0532/6294] [Modify] Polish it --- websocket-sharp/Net/EndPointListener.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/EndPointListener.cs b/websocket-sharp/Net/EndPointListener.cs index 12a7bc0c6..63a6c11b5 100644 --- a/websocket-sharp/Net/EndPointListener.cs +++ b/websocket-sharp/Net/EndPointListener.cs @@ -101,7 +101,7 @@ bool reuseAddress if (cert == null) throw new ArgumentException ("No server certificate could be found."); - _secure = secure; + _secure = true; _sslConfig = new ServerSslConfiguration ( cert, From 4c7f6b6c77ab23a051d8f359b9b67b1971c570a2 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 4 Jul 2016 16:29:39 +0900 Subject: [PATCH 0533/6294] [Modify] Edit it --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a8e0f3a66..8db1cfbac 100644 --- a/README.md +++ b/README.md @@ -77,7 +77,7 @@ namespace Example { using (var ws = new WebSocket ("ws://dragonsnest.far/Laputa")) { ws.OnMessage += (sender, e) => - Console.WriteLine ("Laputa says: " + e.Data); + Console.WriteLine ("Laputa says: " + e.Data); ws.Connect (); ws.Send ("BALUS"); From 8839930cdb3e439742f74b7ceae9c931a3d0e668 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 4 Jul 2016 16:34:26 +0900 Subject: [PATCH 0534/6294] [Modify] Edit it --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 8db1cfbac..9a809784c 100644 --- a/README.md +++ b/README.md @@ -120,8 +120,8 @@ A `WebSocket.OnOpen` event occurs when the WebSocket connection has been establi ```csharp ws.OnOpen += (sender, e) => { - ... -}; + ... + }; ``` `e` has passed as the `System.EventArgs.Empty`, so you don't need to use it. From fc4e4e129710ce478d526ddc662304becb37eeba Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 5 Jul 2016 14:00:37 +0900 Subject: [PATCH 0535/6294] [Modify] Edit it --- README.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 9a809784c..cc82290b6 100644 --- a/README.md +++ b/README.md @@ -132,8 +132,8 @@ A `WebSocket.OnMessage` event occurs when the `WebSocket` receives a message. ```csharp ws.OnMessage += (sender, e) => { - ... -}; + ... + }; ``` `e` has passed as a `WebSocketSharp.MessageEventArgs`. @@ -167,13 +167,13 @@ And if you would like to notify that a **ping** has been received, via this even ```csharp ws.EmitOnPing = true; ws.OnMessage += (sender, e) => { - if (e.IsPing) { - // Do something to notify that a ping has been received. - ... + if (e.IsPing) { + // Do something to notify that a ping has been received. + ... - return; - } -}; + return; + } + }; ``` ##### WebSocket.OnError Event ##### From de5ae27986abe86eaf93b8cf0e0f50ed914b7b72 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 5 Jul 2016 14:03:34 +0900 Subject: [PATCH 0536/6294] [Modify] Edit it --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index cc82290b6..605a9a752 100644 --- a/README.md +++ b/README.md @@ -182,8 +182,8 @@ A `WebSocket.OnError` event occurs when the `WebSocket` gets an error. ```csharp ws.OnError += (sender, e) => { - ... -}; + ... + }; ``` `e` has passed as a `WebSocketSharp.ErrorEventArgs`. From 6d5122b9fafee491f8cac21e09beae23dc0b328a Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 5 Jul 2016 14:25:41 +0900 Subject: [PATCH 0537/6294] [Modify] Edit it --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 605a9a752..08b0ecfef 100644 --- a/README.md +++ b/README.md @@ -198,8 +198,8 @@ A `WebSocket.OnClose` event occurs when the WebSocket connection has been closed ```csharp ws.OnClose += (sender, e) => { - ... -}; + ... + }; ``` `e` has passed as a `WebSocketSharp.CloseEventArgs`. From d006215860c58b466e0499ee7f95b36273e6f3be Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 6 Jul 2016 15:14:25 +0900 Subject: [PATCH 0538/6294] [Modify] Edit it --- README.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 08b0ecfef..2936189ee 100644 --- a/README.md +++ b/README.md @@ -508,13 +508,13 @@ As a **WebSocket Server**, you should set an HTTP authentication scheme, a realm wssv.AuthenticationSchemes = AuthenticationSchemes.Basic; wssv.Realm = "WebSocket Test"; wssv.UserCredentialsFinder = id => { - var name = id.Name; + var name = id.Name; - // Return user name, password, and roles. - return name == "nobita" - ? new NetworkCredential (name, "password", "gunfighter") - : null; // If the user credentials aren't found. -}; + // Return user name, password, and roles. + return name == "nobita" + ? new NetworkCredential (name, "password", "gunfighter") + : null; // If the user credentials aren't found. + }; ``` If you would like to provide the Digest authentication, you should set such as the following. From e35babea1b934395e70475b9ff271f6b72c9ce9c Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 7 Jul 2016 15:12:43 +0900 Subject: [PATCH 0539/6294] [Modify] Edit it --- README.md | 38 ++++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 2936189ee..e6314f0db 100644 --- a/README.md +++ b/README.md @@ -567,25 +567,27 @@ And if you would like to validate the **Origin** header, **Cookies**, or both in ```csharp wssv.AddWebSocketService ( "/Chat", - () => new Chat () { - OriginValidator = val => { - // Check the value of the Origin header, and return true if valid. - Uri origin; - return !val.IsNullOrEmpty () && - Uri.TryCreate (val, UriKind.Absolute, out origin) && - origin.Host == "example.com"; - }, - CookiesValidator = (req, res) => { - // Check the Cookies in 'req', and set the Cookies to send to the client with 'res' - // if necessary. - foreach (Cookie cookie in req) { - cookie.Expired = true; - res.Add (cookie); - } - - return true; // If valid. + () => + new Chat () { + OriginValidator = val => { + // Check the value of the Origin header, and return true if valid. + Uri origin; + return !val.IsNullOrEmpty () + && Uri.TryCreate (val, UriKind.Absolute, out origin) + && origin.Host == "example.com"; + }, + CookiesValidator = (req, res) => { + // Check the cookies in 'req', and set the cookies to send to + // the client with 'res' if necessary. + foreach (Cookie cookie in req) { + cookie.Expired = true; + res.Add (cookie); + } + + return true; // If valid. + } } - }); +); ``` And also if you would like to get each value of the Origin header and cookies, you should access each of the `WebSocketBehavior.Context.Origin` and `WebSocketBehavior.Context.CookieCollection` properties. From 0ebba94a26b4dfa9bdad347938c26e850e6492e6 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 8 Jul 2016 14:49:19 +0900 Subject: [PATCH 0540/6294] [Modify] Edit it --- README.md | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index e6314f0db..2d3167053 100644 --- a/README.md +++ b/README.md @@ -402,7 +402,7 @@ You can use the `WebSocketServer.Stop ()`, `WebSocketServer.Stop (ushort, string ### HTTP Server with the WebSocket ### -I modified the `System.Net.HttpListener`, `System.Net.HttpListenerContext`, and some other classes of **[Mono]** to create the HTTP server that allows to accept the WebSocket connection requests. +I modified the `System.Net.HttpListener`, `System.Net.HttpListenerContext`, and some other classes of **[Mono]** to create the HTTP server that allows to accept the WebSocket handshake requests. So websocket-sharp provides the `WebSocketSharp.Server.HttpServer` class. @@ -429,7 +429,7 @@ As a WebSocket client, if you would like to enable this extension, you should se ws.Compression = CompressionMethod.Deflate; ``` -And then your client will send the following header in the connection request to the server. +And then your client will send the following header in the handshake request to the server. Sec-WebSocket-Extensions: permessage-deflate; server_no_context_takeover; client_no_context_takeover @@ -498,9 +498,9 @@ As a **WebSocket Client**, you should set a pair of user name and password for t ws.SetCredentials ("nobita", "password", preAuth); ``` -If `preAuth` is `true`, the `WebSocket` sends the Basic authentication credentials with the first connection request to the server. +If `preAuth` is `true`, the `WebSocket` sends the Basic authentication credentials with the first handshake request to the server. -Or if `preAuth` is `false`, the `WebSocket` sends either the Basic or Digest (determined by the unauthorized response to the first connection request) authentication credentials with the second connection request to the server. +Or if `preAuth` is `false`, the `WebSocket` sends either the Basic or Digest (determined by the unauthorized response to the first handshake request) authentication credentials with the second handshake request to the server. As a **WebSocket Server**, you should set an HTTP authentication scheme, a realm, and any function to find the user credentials before starting, such as the following. @@ -525,7 +525,7 @@ wssv.AuthenticationSchemes = AuthenticationSchemes.Digest; ### Query String, Origin header and Cookies ### -As a **WebSocket Client**, if you would like to send the **Query String** with the WebSocket connection request to the server, you should create a new instance of the `WebSocket` class with the WebSocket URL that includes the [Query] string parameters. +As a **WebSocket Client**, if you would like to send the **Query String** with the WebSocket handshake request to the server, you should create a new instance of the `WebSocket` class with the WebSocket URL that includes the [Query] string parameters. ```csharp using (var ws = new WebSocket ("ws://example.com/?name=nobita")) { @@ -533,19 +533,19 @@ using (var ws = new WebSocket ("ws://example.com/?name=nobita")) { } ``` -And if you would like to send the **Origin** header with the WebSocket connection request to the server, you should set the `WebSocket.Origin` property to an allowable value as the [Origin] header before connecting, such as the following. +And if you would like to send the **Origin** header with the WebSocket handshake request to the server, you should set the `WebSocket.Origin` property to an allowable value as the [Origin] header before connecting, such as the following. ```csharp ws.Origin = "http://example.com/"; ``` -And also if you would like to send the **Cookies** with the WebSocket connection request to the server, you should set any cookie by using the `WebSocket.SetCookie (WebSocketSharp.Net.Cookie)` method before connecting, such as the following. +And also if you would like to send the **Cookies** with the WebSocket handshake request to the server, you should set any cookie by using the `WebSocket.SetCookie (WebSocketSharp.Net.Cookie)` method before connecting, such as the following. ```csharp ws.SetCookie (new Cookie ("name", "nobita")); ``` -As a **WebSocket Server**, if you would like to get the **Query String** included in a WebSocket connection request, you should access the `WebSocketBehavior.Context.QueryString` property, such as the following. +As a **WebSocket Server**, if you would like to get the **Query String** included in a WebSocket handshake request, you should access the `WebSocketBehavior.Context.QueryString` property, such as the following. ```csharp public class Chat : WebSocketBehavior @@ -562,7 +562,7 @@ public class Chat : WebSocketBehavior } ``` -And if you would like to validate the **Origin** header, **Cookies**, or both included in a WebSocket connection request, you should set each validation with your `WebSocketBehavior`, for example, by using the `AddWebSocketService (string, Func)` method with initializing, such as the following. +And if you would like to validate the **Origin** header, **Cookies**, or both included in a WebSocket handshake request, you should set each validation with your `WebSocketBehavior`, for example, by using the `AddWebSocketService (string, Func)` method with initializing, such as the following. ```csharp wssv.AddWebSocketService ( @@ -652,7 +652,7 @@ And Example1 uses **[Json.NET]**. ### Example3 ### -**[Example3]** starts an HTTP server that allows to accept the WebSocket connection requests. +**[Example3]** starts an HTTP server that allows to accept the WebSocket handshake requests. Would you access to [http://localhost:4649](http://localhost:4649) to do **WebSocket Echo Test** with your web browser while Example3 is running? From 2199d9f1f6b875fd0c7e6d280576a5dfc06e5d85 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 8 Jul 2016 14:55:23 +0900 Subject: [PATCH 0541/6294] [Modify] Edit it --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 2d3167053..9237db44a 100644 --- a/README.md +++ b/README.md @@ -525,7 +525,7 @@ wssv.AuthenticationSchemes = AuthenticationSchemes.Digest; ### Query String, Origin header and Cookies ### -As a **WebSocket Client**, if you would like to send the **Query String** with the WebSocket handshake request to the server, you should create a new instance of the `WebSocket` class with the WebSocket URL that includes the [Query] string parameters. +As a **WebSocket Client**, if you would like to send the **Query String** with the handshake request to the server, you should create a new instance of the `WebSocket` class with the WebSocket URL that includes the [Query] string parameters. ```csharp using (var ws = new WebSocket ("ws://example.com/?name=nobita")) { @@ -533,19 +533,19 @@ using (var ws = new WebSocket ("ws://example.com/?name=nobita")) { } ``` -And if you would like to send the **Origin** header with the WebSocket handshake request to the server, you should set the `WebSocket.Origin` property to an allowable value as the [Origin] header before connecting, such as the following. +And if you would like to send the **Origin** header with the handshake request to the server, you should set the `WebSocket.Origin` property to an allowable value as the [Origin] header before connecting, such as the following. ```csharp ws.Origin = "http://example.com/"; ``` -And also if you would like to send the **Cookies** with the WebSocket handshake request to the server, you should set any cookie by using the `WebSocket.SetCookie (WebSocketSharp.Net.Cookie)` method before connecting, such as the following. +And also if you would like to send the **Cookies** with the handshake request to the server, you should set any cookie by using the `WebSocket.SetCookie (WebSocketSharp.Net.Cookie)` method before connecting, such as the following. ```csharp ws.SetCookie (new Cookie ("name", "nobita")); ``` -As a **WebSocket Server**, if you would like to get the **Query String** included in a WebSocket handshake request, you should access the `WebSocketBehavior.Context.QueryString` property, such as the following. +As a **WebSocket Server**, if you would like to get the **Query String** included in a handshake request, you should access the `WebSocketBehavior.Context.QueryString` property, such as the following. ```csharp public class Chat : WebSocketBehavior @@ -562,7 +562,7 @@ public class Chat : WebSocketBehavior } ``` -And if you would like to validate the **Origin** header, **Cookies**, or both included in a WebSocket handshake request, you should set each validation with your `WebSocketBehavior`, for example, by using the `AddWebSocketService (string, Func)` method with initializing, such as the following. +And if you would like to validate the **Origin** header, **Cookies**, or both included in a handshake request, you should set each validation with your `WebSocketBehavior`, for example, by using the `AddWebSocketService (string, Func)` method with initializing, such as the following. ```csharp wssv.AddWebSocketService ( From 6bb23096e653a944f295b693ea70b49ae79d9daf Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 8 Jul 2016 15:25:43 +0900 Subject: [PATCH 0542/6294] [Modify] Edit it --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9237db44a..58f5c7c6b 100644 --- a/README.md +++ b/README.md @@ -204,7 +204,7 @@ ws.OnClose += (sender, e) => { `e` has passed as a `WebSocketSharp.CloseEventArgs`. -`e.Code` property returns a `ushort` that represents the status code indicating the reason for the close, and `e.Reason` property returns a `string` that represents the reason for the close. +`e.Code` property returns a `ushort` that represents the status code for the close, and `e.Reason` property returns a `string` that represents the reason for the close. #### Step 4 #### From 2ab50c123412cc50cf8421ba7fba878ee8c22bd5 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 9 Jul 2016 15:26:49 +0900 Subject: [PATCH 0543/6294] [Modify] Edit it --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 58f5c7c6b..39a93ee26 100644 --- a/README.md +++ b/README.md @@ -347,15 +347,15 @@ public class Chat : WebSocketBehavior You can define the behavior of any WebSocket service by creating the class that inherits the `WebSocketBehavior` class. -If you override the `WebSocketBehavior.OnMessage (MessageEventArgs)` method, it's called when the `WebSocket` used in a session in the service receives a message. +If you override the `WebSocketBehavior.OnMessage (MessageEventArgs)` method, it will be called when the `WebSocket` used in a session in the service receives a message. -And if you override the `WebSocketBehavior.OnOpen ()`, `WebSocketBehavior.OnError (ErrorEventArgs)`, and `WebSocketBehavior.OnClose (CloseEventArgs)` methods, each of them is called when each event of the `WebSocket` (the `OnOpen`, `OnError`, and `OnClose` events) occurs. +And if you override the `WebSocketBehavior.OnOpen ()`, `WebSocketBehavior.OnError (ErrorEventArgs)`, and `WebSocketBehavior.OnClose (CloseEventArgs)` methods, each of them will be called when each of the `WebSocket` events (`OnOpen`, `OnError`, and `OnClose`) occurs. -The `WebSocketBehavior.Send` method sends data to the client on a session in the service. +The `WebSocketBehavior.Send` method can send data to the client on a session in the service. If you would like to get the sessions in the service, you should access the `WebSocketBehavior.Sessions` property (returns a `WebSocketSharp.Server.WebSocketSessionManager`). -The `WebSocketBehavior.Sessions.Broadcast` method sends data to every client in the service. +The `WebSocketBehavior.Sessions.Broadcast` method can send data to every client in the service. #### Step 3 #### From a40667ef7cb0a84b13fdd929c6b922df60f8885e Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 9 Jul 2016 15:50:49 +0900 Subject: [PATCH 0544/6294] [Modify] Edit it --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 39a93ee26..178186b83 100644 --- a/README.md +++ b/README.md @@ -402,7 +402,7 @@ You can use the `WebSocketServer.Stop ()`, `WebSocketServer.Stop (ushort, string ### HTTP Server with the WebSocket ### -I modified the `System.Net.HttpListener`, `System.Net.HttpListenerContext`, and some other classes of **[Mono]** to create the HTTP server that allows to accept the WebSocket handshake requests. +I have modified the `System.Net.HttpListener`, `System.Net.HttpListenerContext`, and some other classes from **[Mono]** to create an HTTP server that allows to accept the WebSocket handshake requests. So websocket-sharp provides the `WebSocketSharp.Server.HttpServer` class. From 86ae9df9a61fadf88cd2ef7e6fd39bf7a8963245 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 9 Jul 2016 16:21:55 +0900 Subject: [PATCH 0545/6294] [Modify] Edit it --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 178186b83..c5aba4732 100644 --- a/README.md +++ b/README.md @@ -603,7 +603,7 @@ var ws = new WebSocket ("ws://example.com"); ws.SetProxy ("http://localhost:3128/", "nobita", "password"); ``` -I tested this with the [Squid]. And it's necessary to disable the following configuration option in **squid.conf** (e.g. `/etc/squid/squid.conf`). +I have tested this with the [Squid]. And it's necessary to disable the following configuration option in **squid.conf** (e.g. `/etc/squid/squid.conf`). ``` # Deny CONNECT to other than SSL ports From 16bb5ebf1e0aa41f7b70ed5982eba3001bb0fff6 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 10 Jul 2016 14:54:41 +0900 Subject: [PATCH 0546/6294] [Modify] Edit it --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index c5aba4732..52c5185e4 100644 --- a/README.md +++ b/README.md @@ -612,7 +612,7 @@ I have tested this with the [Squid]. And it's necessary to disable the following ### Logging ### -The `WebSocket` class includes the own logging function. +The `WebSocket` class has the own logging function. You can use it with the `WebSocket.Log` property (returns a `WebSocketSharp.Logger`). @@ -630,7 +630,7 @@ And if you would like to output a log, you should use any of the output methods. ws.Log.Debug ("This is a debug message."); ``` -The `WebSocketServer` and `HttpServer` classes include the same logging function. +The `WebSocketServer` and `HttpServer` classes have the same logging function. ## Examples ## From 7699a4f348c2921568f321c2abf8b2deb506bd99 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 11 Jul 2016 16:33:02 +0900 Subject: [PATCH 0547/6294] [Modify] Edit it --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 52c5185e4..e6c664747 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ - **[HTTP Authentication](#http-authentication)** - **[Query String, Origin header and Cookies](#query-string-origin-header-and-cookies)** - **[Connecting through the HTTP Proxy server](#connecting-through-the-http-proxy-server)** -- .NET **3.5** or later (includes compatible) +- .NET Framework **3.5** or later (includes compatible) ## Branches ## From 3c9a9d85cc8a5ea208e3caca7f46216f5624bb55 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 12 Jul 2016 14:46:06 +0900 Subject: [PATCH 0548/6294] [Modify] Edit it --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e6c664747..3eccc5560 100644 --- a/README.md +++ b/README.md @@ -450,7 +450,7 @@ wssv.AddWebSocketService ( ); ``` -If it's set to `true`, the server doesn't return the **Sec-WebSocket-Extensions** header in its response. +If it's set to `true`, the service will not return the **Sec-WebSocket-Extensions** header in its handshake response. I think this is useful when you get something error in connecting the server and exclude the extensions as a cause of the error. From e76210b0fbdf2c1db576b7dda8093949e5b3b748 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 13 Jul 2016 14:21:42 +0900 Subject: [PATCH 0549/6294] [Modify] Edit it --- README.md | 9 --------- 1 file changed, 9 deletions(-) diff --git a/README.md b/README.md index 3eccc5560..b34239986 100644 --- a/README.md +++ b/README.md @@ -640,12 +640,6 @@ Examples using websocket-sharp. **[Example]** connects to the **[Echo server]** with the WebSocket. -### Example1 ### - -**[Example1]** connects to the **[Audio Data delivery server]** with the WebSocket. (But it's only implemented the chat feature, still unfinished.) - -And Example1 uses **[Json.NET]**. - ### Example2 ### **[Example2]** starts a WebSocket server. @@ -674,13 +668,10 @@ Thanks for translating to japanese. websocket-sharp is provided under **[The MIT License]**. -[Audio Data delivery server]: http://agektmr.node-ninja.com:3000 [Echo server]: http://www.websocket.org/echo.html [Example]: https://github.com/sta/websocket-sharp/tree/master/Example -[Example1]: https://github.com/sta/websocket-sharp/tree/master/Example1 [Example2]: https://github.com/sta/websocket-sharp/tree/master/Example2 [Example3]: https://github.com/sta/websocket-sharp/tree/master/Example3 -[Json.NET]: http://james.newtonking.com/projects/json-net.aspx [Mono]: http://www.mono-project.com [MonoDevelop]: http://monodevelop.com [NuGet Gallery]: http://www.nuget.org From af28c20eb9d95deca58a3a0a21baba21636f6abb Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 14 Jul 2016 16:48:18 +0900 Subject: [PATCH 0550/6294] [Modify] Edit it --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index b34239986..fa89324ee 100644 --- a/README.md +++ b/README.md @@ -53,11 +53,12 @@ It works with **Unity Free**, but there are some limitations: - **[Security Sandbox of the Webplayer]** (The server isn't available in Web Player) - **[WebGL Networking]** (Not available in WebGL) -- **Weak Support for the System.IO.Compression** (The compression extension isn't available on Windows) +- **Incompatible platform** (Not available for such UWP) +- **Limited support for the System.IO.Compression** (The compression extension isn't available on Windows) - **.NET Socket Support for iOS/Android** (It requires iOS/Android Pro if your Unity is earlier than Unity 5) - **.NET API 2.0 compatibility level for iOS/Android** -**.NET API 2.0 compatibility level for iOS/Android** may require to fix lack of some features for later than .NET 2.0, such as the `System.Func<...>` delegates (so i've fixed it in the asset package). +**.NET API 2.0 compatibility level for iOS/Android** may require to fix lack of some features for later than .NET 2.0, such as the `System.Func<...>` delegates (so i have added them in that asset package). And it's priced at **US$15**. I think your $15 makes this project more better and accelerated, **Thank you!** From ff60d11808bf3da44d562c6dba67fc263e7286f9 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 15 Jul 2016 15:19:08 +0900 Subject: [PATCH 0551/6294] [Modify] Edit it --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index fa89324ee..3026fba38 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ - **[HTTP Authentication](#http-authentication)** - **[Query String, Origin header and Cookies](#query-string-origin-header-and-cookies)** - **[Connecting through the HTTP Proxy server](#connecting-through-the-http-proxy-server)** -- .NET Framework **3.5** or later (includes compatible) +- .NET Framework **3.5** or later (includes compatible environment such as **[Mono]**) ## Branches ## From 950c7fde25616f9f4cfd5e717ec12bab269e8983 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 17 Jul 2016 15:40:21 +0900 Subject: [PATCH 0552/6294] [Modify] Edit it --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 3026fba38..9ab2d000e 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ websocket-sharp is built as a single assembly, **websocket-sharp.dll**. -websocket-sharp is developed with **[MonoDevelop]**. So the simple way to build is to open **websocket-sharp.sln** and run build for **websocket-sharp project** with any of the build configurations (e.g. `Debug`) in MonoDevelop. +websocket-sharp is developed with **[MonoDevelop]**. So a simple way to build is to open **websocket-sharp.sln** and run build for **websocket-sharp project** with any of the build configurations (e.g. `Debug`) in MonoDevelop. ## Install ## From 7c2d98bbb7f77f411f2398a43119fa9b8e9dba22 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 18 Jul 2016 17:13:10 +0900 Subject: [PATCH 0553/6294] [Modify] Edit it --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 9ab2d000e..95cdded42 100644 --- a/README.md +++ b/README.md @@ -597,14 +597,14 @@ And also if you would like to get each value of the Origin header and cookies, y websocket-sharp supports to connect through the **HTTP Proxy** server. -If you would like to connect to a WebSocket server through the HTTP Proxy server, you should set the proxy server URL, and if necessary, a pair of user name and password for the proxy server authentication (Basic/Digest), by using the `WebSocket.SetProxy (string, string, string)` method before connecting. +If you would like to connect to a WebSocket server through the HTTP proxy server, you should set the proxy server URL, and if necessary, a pair of user name and password for the proxy server authentication (Basic/Digest), by using the `WebSocket.SetProxy (string, string, string)` method before connecting. ```csharp var ws = new WebSocket ("ws://example.com"); ws.SetProxy ("http://localhost:3128/", "nobita", "password"); ``` -I have tested this with the [Squid]. And it's necessary to disable the following configuration option in **squid.conf** (e.g. `/etc/squid/squid.conf`). +I have tested this with **[Squid]**. It's necessary to disable the following configuration option in **squid.conf** (e.g. `/etc/squid/squid.conf`). ``` # Deny CONNECT to other than SSL ports From 2bc95c251f64cd4f3e6f375e848566796e038049 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 20 Jul 2016 17:24:23 +0900 Subject: [PATCH 0554/6294] [Fix] Cancel timeout process --- websocket-sharp/Net/HttpConnection.cs | 32 ++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpConnection.cs b/websocket-sharp/Net/HttpConnection.cs index feb41139f..0e30c1c7a 100644 --- a/websocket-sharp/Net/HttpConnection.cs +++ b/websocket-sharp/Net/HttpConnection.cs @@ -61,11 +61,13 @@ internal sealed class HttpConnection private byte[] _buffer; private const int _bufferLength = 8192; + private volatile bool _cancelTimeout; private HttpListenerContext _context; private bool _contextRegistered; private StringBuilder _currentLine; private InputState _inputState; private RequestStream _inputStream; + private volatile bool _inTimeout; private HttpListener _lastListener; private LineState _lineState; private EndPointListener _listener; @@ -291,6 +293,9 @@ private static void onRead (IAsyncResult asyncResult) conn._lastListener = lsnr; } + if (conn._inTimeout) + conn._cancelTimeout = true; + conn._context.Listener = lsnr; if (!conn._context.Authenticate ()) return; @@ -301,6 +306,9 @@ private static void onRead (IAsyncResult asyncResult) return; } + if (conn._inTimeout) + conn._cancelTimeout = true; + conn._stream.BeginRead (conn._buffer, 0, _bufferLength, onRead, conn); } } @@ -308,7 +316,29 @@ private static void onRead (IAsyncResult asyncResult) private static void onTimeout (object state) { var conn = (HttpConnection) state; - conn.close (); + + conn._inTimeout = true; + if (conn._socket == null) { + conn._inTimeout = false; + return; + } + + lock (conn._sync) { + if (conn._socket == null) { + conn._inTimeout = false; + return; + } + + if (conn._cancelTimeout) { + conn._cancelTimeout = false; + conn._inTimeout = false; + + return; + } + + conn.SendError (null, 408); + conn._inTimeout = false; + } } // true -> Done processing. From 02af0789e18f12fb312fa08262cdb30f5f6618ab Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 21 Jul 2016 17:23:19 +0900 Subject: [PATCH 0555/6294] [Modify] Polish it --- Example3/Program.cs | 128 ++++++++++++++++++++++---------------------- 1 file changed, 65 insertions(+), 63 deletions(-) diff --git a/Example3/Program.cs b/Example3/Program.cs index 66fec34e1..ffb119c83 100644 --- a/Example3/Program.cs +++ b/Example3/Program.cs @@ -14,8 +14,8 @@ public static void Main (string[] args) { // Create a new instance of the HttpServer class. // - // If you would like to provide the secure connection, you should create the instance with - // the 'secure' parameter set to true, or the https scheme HTTP URL. + // If you would like to provide the secure connection, you should create a new instance with + // the 'secure' parameter set to true, or an https scheme HTTP URL. var httpsv = new HttpServer (4649); //var httpsv = new HttpServer (5963, true); @@ -51,7 +51,13 @@ public static void Main (string[] args) httpsv.Log.Level = LogLevel.Trace; // To change the wait time for the response to the WebSocket Ping or Close. - httpsv.WaitTime = TimeSpan.FromSeconds (2); + //httpsv.WaitTime = TimeSpan.FromSeconds (2); + + // Not to remove the inactive WebSocket sessions periodically. + //httpsv.KeepClean = false; + + // To resolve to wait for socket in TIME_WAIT state. + //httpsv.ReuseAddress = true; #endif /* To provide the secure connection. var cert = ConfigurationManager.AppSettings["ServerCertFile"]; @@ -63,13 +69,13 @@ public static void Main (string[] args) httpsv.AuthenticationSchemes = AuthenticationSchemes.Basic; httpsv.Realm = "WebSocket Test"; httpsv.UserCredentialsFinder = id => { - var name = id.Name; + var name = id.Name; - // Return user name, password, and roles. - return name == "nobita" - ? new NetworkCredential (name, "password", "gunfighter") - : null; // If the user credentials aren't found. - }; + // Return user name, password, and roles. + return name == "nobita" + ? new NetworkCredential (name, "password", "gunfighter") + : null; // If the user credentials aren't found. + }; */ // Set the document root path. @@ -77,36 +83,30 @@ public static void Main (string[] args) // Set the HTTP GET request event. httpsv.OnGet += (sender, e) => { - var req = e.Request; - var res = e.Response; - - var path = req.RawUrl; - if (path == "/") - path += "index.html"; - - var content = httpsv.GetFile (path); - if (content == null) { - res.StatusCode = (int) HttpStatusCode.NotFound; - return; - } - - if (path.EndsWith (".html")) { - res.ContentType = "text/html"; - res.ContentEncoding = Encoding.UTF8; - } - else if (path.EndsWith (".js")) { - res.ContentType = "application/javascript"; - res.ContentEncoding = Encoding.UTF8; - } - - res.WriteContent (content); - }; + var req = e.Request; + var res = e.Response; - // Not to remove the inactive WebSocket sessions periodically. - //httpsv.KeepClean = false; + var path = req.RawUrl; + if (path == "/") + path += "index.html"; - // To resolve to wait for socket in TIME_WAIT state. - //httpsv.ReuseAddress = true; + var content = httpsv.GetFile (path); + if (content == null) { + res.StatusCode = (int) HttpStatusCode.NotFound; + return; + } + + if (path.EndsWith (".html")) { + res.ContentType = "text/html"; + res.ContentEncoding = Encoding.UTF8; + } + else if (path.EndsWith (".js")) { + res.ContentType = "application/javascript"; + res.ContentEncoding = Encoding.UTF8; + } + + res.WriteContent (content); + }; // Add the WebSocket services. httpsv.AddWebSocketService ("/Echo"); @@ -115,33 +115,35 @@ public static void Main (string[] args) /* Add the WebSocket service with initializing. httpsv.AddWebSocketService ( "/Chat", - () => new Chat ("Anon#") { - // To send the Sec-WebSocket-Protocol header that has a subprotocol name. - Protocol = "chat", - // To emit a WebSocket.OnMessage event when receives a ping. - EmitOnPing = true, - // To ignore the Sec-WebSocket-Extensions header. - IgnoreExtensions = true, - // To validate the Origin header. - OriginValidator = val => { - // Check the value of the Origin header, and return true if valid. - Uri origin; - return !val.IsNullOrEmpty () && - Uri.TryCreate (val, UriKind.Absolute, out origin) && - origin.Host == "localhost"; - }, - // To validate the Cookies. - CookiesValidator = (req, res) => { - // Check the Cookies in 'req', and set the Cookies to send to the client with 'res' - // if necessary. - foreach (Cookie cookie in req) { - cookie.Expired = true; - res.Add (cookie); - } - - return true; // If valid. + () => + new Chat ("Anon#") { + // To send the Sec-WebSocket-Protocol header that has a subprotocol name. + Protocol = "chat", + // To emit a WebSocket.OnMessage event when receives a ping. + EmitOnPing = true, + // To ignore the Sec-WebSocket-Extensions header. + IgnoreExtensions = true, + // To validate the Origin header. + OriginValidator = val => { + // Check the value of the Origin header, and return true if valid. + Uri origin; + return !val.IsNullOrEmpty () + && Uri.TryCreate (val, UriKind.Absolute, out origin) + && origin.Host == "localhost"; + }, + // To validate the cookies. + CookiesValidator = (req, res) => { + // Check the cookies in 'req', and set the cookies to send to + // the client with 'res' if necessary. + foreach (Cookie cookie in req) { + cookie.Expired = true; + res.Add (cookie); + } + + return true; // If valid. + } } - }); + ); */ httpsv.Start (); From ae4d764355d16b0582804459fedbf75aa0c3d5ac Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 22 Jul 2016 17:32:11 +0900 Subject: [PATCH 0556/6294] [Fix] Cancel timeout process --- websocket-sharp/Net/HttpConnection.cs | 77 ++++++++++++--------------- 1 file changed, 34 insertions(+), 43 deletions(-) diff --git a/websocket-sharp/Net/HttpConnection.cs b/websocket-sharp/Net/HttpConnection.cs index 0e30c1c7a..36d9a461e 100644 --- a/websocket-sharp/Net/HttpConnection.cs +++ b/websocket-sharp/Net/HttpConnection.cs @@ -46,6 +46,7 @@ #endregion using System; +using System.Collections.Generic; using System.IO; using System.Net; using System.Net.Security; @@ -59,28 +60,27 @@ internal sealed class HttpConnection { #region Private Fields - private byte[] _buffer; - private const int _bufferLength = 8192; - private volatile bool _cancelTimeout; - private HttpListenerContext _context; - private bool _contextRegistered; - private StringBuilder _currentLine; - private InputState _inputState; - private RequestStream _inputStream; - private volatile bool _inTimeout; - private HttpListener _lastListener; - private LineState _lineState; - private EndPointListener _listener; - private ResponseStream _outputStream; - private int _position; - private MemoryStream _requestBuffer; - private int _reuses; - private bool _secure; - private Socket _socket; - private Stream _stream; - private object _sync; - private int _timeout; - private Timer _timer; + private byte[] _buffer; + private const int _bufferLength = 8192; + private HttpListenerContext _context; + private bool _contextRegistered; + private StringBuilder _currentLine; + private InputState _inputState; + private RequestStream _inputStream; + private HttpListener _lastListener; + private LineState _lineState; + private EndPointListener _listener; + private ResponseStream _outputStream; + private int _position; + private MemoryStream _requestBuffer; + private int _reuses; + private bool _secure; + private Socket _socket; + private Stream _stream; + private object _sync; + private int _timeout; + private Dictionary _timeoutCanceled; + private Timer _timer; #endregion @@ -111,6 +111,7 @@ internal HttpConnection (Socket socket, EndPointListener listener) _sync = new object (); _timeout = 90000; // 90k ms for first request, 15k ms from then on. + _timeoutCanceled = new Dictionary (); _timer = new Timer (onTimeout, this, Timeout.Infinite, Timeout.Infinite); init (); @@ -248,7 +249,12 @@ private static void onRead (IAsyncResult asyncResult) var nread = -1; var len = 0; try { - conn._timer.Change (Timeout.Infinite, Timeout.Infinite); + var current = conn._reuses; + if (!conn._timeoutCanceled[current]) { + conn._timer.Change (Timeout.Infinite, Timeout.Infinite); + conn._timeoutCanceled[current] = true; + } + nread = conn._stream.EndRead (asyncResult); conn._requestBuffer.Write (conn._buffer, 0, nread); len = (int) conn._requestBuffer.Length; @@ -293,9 +299,6 @@ private static void onRead (IAsyncResult asyncResult) conn._lastListener = lsnr; } - if (conn._inTimeout) - conn._cancelTimeout = true; - conn._context.Listener = lsnr; if (!conn._context.Authenticate ()) return; @@ -306,9 +309,6 @@ private static void onRead (IAsyncResult asyncResult) return; } - if (conn._inTimeout) - conn._cancelTimeout = true; - conn._stream.BeginRead (conn._buffer, 0, _bufferLength, onRead, conn); } } @@ -316,28 +316,18 @@ private static void onRead (IAsyncResult asyncResult) private static void onTimeout (object state) { var conn = (HttpConnection) state; - - conn._inTimeout = true; - if (conn._socket == null) { - conn._inTimeout = false; + var current = conn._reuses; + if (conn._socket == null) return; - } lock (conn._sync) { - if (conn._socket == null) { - conn._inTimeout = false; + if (conn._socket == null) return; - } - - if (conn._cancelTimeout) { - conn._cancelTimeout = false; - conn._inTimeout = false; + if (conn._timeoutCanceled[current]) return; - } conn.SendError (null, 408); - conn._inTimeout = false; } } @@ -481,6 +471,7 @@ public void BeginReadRequest () _timeout = 15000; try { + _timeoutCanceled.Add (_reuses, false); _timer.Change (_timeout, Timeout.Infinite); _stream.BeginRead (_buffer, 0, _bufferLength, onRead, this); } From 40b23a6aea64e76b200b0a661d67d4ce90efd260 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 23 Jul 2016 16:36:12 +0900 Subject: [PATCH 0557/6294] [Modify] Polish it --- Example2/Program.cs | 84 +++++++++++++++++++++++---------------------- 1 file changed, 43 insertions(+), 41 deletions(-) diff --git a/Example2/Program.cs b/Example2/Program.cs index d552ce81b..81ef2642a 100644 --- a/Example2/Program.cs +++ b/Example2/Program.cs @@ -13,8 +13,8 @@ public static void Main (string[] args) { // Create a new instance of the WebSocketServer class. // - // If you would like to provide the secure connection, you should create the instance with - // the 'secure' parameter set to true, or the wss scheme WebSocket URL. + // If you would like to provide the secure connection, you should create a new instance with + // the 'secure' parameter set to true, or a wss scheme WebSocket URL. var wssv = new WebSocketServer (4649); //var wssv = new WebSocketServer (5963, true); @@ -50,7 +50,13 @@ public static void Main (string[] args) wssv.Log.Level = LogLevel.Trace; // To change the wait time for the response to the WebSocket Ping or Close. - wssv.WaitTime = TimeSpan.FromSeconds (2); + //wssv.WaitTime = TimeSpan.FromSeconds (2); + + // Not to remove the inactive sessions periodically. + //wssv.KeepClean = false; + + // To resolve to wait for socket in TIME_WAIT state. + //wssv.ReuseAddress = true; #endif /* To provide the secure connection. var cert = ConfigurationManager.AppSettings["ServerCertFile"]; @@ -62,21 +68,15 @@ public static void Main (string[] args) wssv.AuthenticationSchemes = AuthenticationSchemes.Basic; wssv.Realm = "WebSocket Test"; wssv.UserCredentialsFinder = id => { - var name = id.Name; + var name = id.Name; - // Return user name, password, and roles. - return name == "nobita" - ? new NetworkCredential (name, "password", "gunfighter") - : null; // If the user credentials aren't found. - }; + // Return user name, password, and roles. + return name == "nobita" + ? new NetworkCredential (name, "password", "gunfighter") + : null; // If the user credentials aren't found. + }; */ - // Not to remove the inactive sessions periodically. - //wssv.KeepClean = false; - - // To resolve to wait for socket in TIME_WAIT state. - //wssv.ReuseAddress = true; - // Add the WebSocket services. wssv.AddWebSocketService ("/Echo"); wssv.AddWebSocketService ("/Chat"); @@ -84,33 +84,35 @@ public static void Main (string[] args) /* Add the WebSocket service with initializing. wssv.AddWebSocketService ( "/Chat", - () => new Chat ("Anon#") { - // To send the Sec-WebSocket-Protocol header that has a subprotocol name. - Protocol = "chat", - // To emit a WebSocket.OnMessage event when receives a ping. - EmitOnPing = true, - // To ignore the Sec-WebSocket-Extensions header. - IgnoreExtensions = true, - // To validate the Origin header. - OriginValidator = val => { - // Check the value of the Origin header, and return true if valid. - Uri origin; - return !val.IsNullOrEmpty () && - Uri.TryCreate (val, UriKind.Absolute, out origin) && - origin.Host == "localhost"; - }, - // To validate the Cookies. - CookiesValidator = (req, res) => { - // Check the Cookies in 'req', and set the Cookies to send to the client with 'res' - // if necessary. - foreach (Cookie cookie in req) { - cookie.Expired = true; - res.Add (cookie); - } - - return true; // If valid. + () => + new Chat ("Anon#") { + // To send the Sec-WebSocket-Protocol header that has a subprotocol name. + Protocol = "chat", + // To emit a WebSocket.OnMessage event when receives a ping. + EmitOnPing = true, + // To ignore the Sec-WebSocket-Extensions header. + IgnoreExtensions = true, + // To validate the Origin header. + OriginValidator = val => { + // Check the value of the Origin header, and return true if valid. + Uri origin; + return !val.IsNullOrEmpty () + && Uri.TryCreate (val, UriKind.Absolute, out origin) + && origin.Host == "localhost"; + }, + // To validate the cookies. + CookiesValidator = (req, res) => { + // Check the cookies in 'req', and set the cookies to send to + // the client with 'res' if necessary. + foreach (Cookie cookie in req) { + cookie.Expired = true; + res.Add (cookie); + } + + return true; // If valid. + } } - }); + ); */ wssv.Start (); From 6786cb017b077f1fd948c2969b64e29265ade569 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 24 Jul 2016 17:04:25 +0900 Subject: [PATCH 0558/6294] [Modify] Polish it --- Example/Program.cs | 66 +++++++++++++++++++++++++--------------------- 1 file changed, 36 insertions(+), 30 deletions(-) diff --git a/Example/Program.cs b/Example/Program.cs index f3d91f6de..78c8fef0b 100644 --- a/Example/Program.cs +++ b/Example/Program.cs @@ -15,56 +15,63 @@ public static void Main (string[] args) // use the using statement. And the WebSocket connection will be closed with // close status 1001 (going away) when the control leaves the using block. // - // If you would like to connect to the server with the secure connection, - // you should create the instance with the wss scheme WebSocket URL. + // If you would like to connect to a server with the secure connection, + // you should create a new instance with a wss scheme WebSocket URL. using (var nf = new Notifier ()) using (var ws = new WebSocket ("ws://echo.websocket.org")) //using (var ws = new WebSocket ("wss://echo.websocket.org")) //using (var ws = new WebSocket ("ws://localhost:4649/Echo")) + //using (var ws = new WebSocket ("wss://localhost:5963/Echo")) //using (var ws = new WebSocket ("ws://localhost:4649/Echo?name=nobita")) - //using (var ws = new WebSocket ("wss://localhost:4649/Echo")) + //using (var ws = new WebSocket ("wss://localhost:5963/Echo?name=nobita")) //using (var ws = new WebSocket ("ws://localhost:4649/Chat")) + //using (var ws = new WebSocket ("wss://localhost:5963/Chat")) //using (var ws = new WebSocket ("ws://localhost:4649/Chat?name=nobita")) - //using (var ws = new WebSocket ("wss://localhost:4649/Chat")) + //using (var ws = new WebSocket ("wss://localhost:5963/Chat?name=nobita")) { // Set the WebSocket events. ws.OnOpen += (sender, e) => ws.Send ("Hi, there!"); ws.OnMessage += (sender, e) => - nf.Notify ( - new NotificationMessage { - Summary = "WebSocket Message", - Body = !e.IsPing ? e.Data : "Received a ping.", - Icon = "notification-message-im" - }); + nf.Notify ( + new NotificationMessage { + Summary = "WebSocket Message", + Body = !e.IsPing ? e.Data : "Received a ping.", + Icon = "notification-message-im" + } + ); ws.OnError += (sender, e) => - nf.Notify ( - new NotificationMessage { - Summary = "WebSocket Error", - Body = e.Message, - Icon = "notification-message-im" - }); + nf.Notify ( + new NotificationMessage { + Summary = "WebSocket Error", + Body = e.Message, + Icon = "notification-message-im" + } + ); ws.OnClose += (sender, e) => - nf.Notify ( - new NotificationMessage { - Summary = String.Format ("WebSocket Close ({0})", e.Code), - Body = e.Reason, - Icon = "notification-message-im" - }); - + nf.Notify ( + new NotificationMessage { + Summary = String.Format ("WebSocket Close ({0})", e.Code), + Body = e.Reason, + Icon = "notification-message-im" + } + ); #if DEBUG // To change the logging level. ws.Log.Level = LogLevel.Trace; // To change the wait time for the response to the Ping or Close. - ws.WaitTime = TimeSpan.FromSeconds (10); + //ws.WaitTime = TimeSpan.FromSeconds (10); // To emit a WebSocket.OnMessage event when receives a ping. - ws.EmitOnPing = true; + //ws.EmitOnPing = true; + + // To enable the redirection. + //ws.EnableRedirection = true; #endif // To enable the Per-message Compression extension. //ws.Compression = CompressionMethod.Deflate; @@ -76,7 +83,9 @@ public static void Main (string[] args) String.Format ( "Certificate:\n- Issuer: {0}\n- Subject: {1}", certificate.Issuer, - certificate.Subject)); + certificate.Subject + ) + ); return true; // If the server certificate is valid. }; @@ -88,16 +97,13 @@ public static void Main (string[] args) // To send the Origin header. //ws.Origin = "http://localhost:4649/"; - // To send the Cookies. + // To send the cookies. //ws.SetCookie (new Cookie ("name", "nobita")); //ws.SetCookie (new Cookie ("roles", "\"idiot, gunfighter\"")); // To connect through the HTTP Proxy server. //ws.SetProxy ("http://localhost:3128/", "nobita", "password"); - // To enable the redirection. - //ws.EnableRedirection = true; - // Connect to the server. ws.Connect (); From a870f7389fcd7ade29a996101205f988db7f1551 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 25 Jul 2016 16:23:30 +0900 Subject: [PATCH 0559/6294] [Modify] Polish it --- Example/Notifier.cs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/Example/Notifier.cs b/Example/Notifier.cs index f21eec32c..5371c37a4 100644 --- a/Example/Notifier.cs +++ b/Example/Notifier.cs @@ -11,16 +11,16 @@ namespace Example internal class Notifier : IDisposable { private volatile bool _enabled; + private ManualResetEvent _exited; private Queue _queue; private object _sync; - private ManualResetEvent _waitHandle; public Notifier () { _enabled = true; + _exited = new ManualResetEvent (false); _queue = new Queue (); _sync = ((ICollection) _queue).SyncRoot; - _waitHandle = new ManualResetEvent (false); ThreadPool.QueueUserWorkItem ( state => { @@ -40,8 +40,9 @@ public Notifier () } } - _waitHandle.Set (); - }); + _exited.Set (); + } + ); } public int Count { @@ -60,15 +61,16 @@ private NotificationMessage dequeue () public void Close () { _enabled = false; - _waitHandle.WaitOne (); - _waitHandle.Close (); + _exited.WaitOne (); + _exited.Close (); } public void Notify (NotificationMessage message) { - lock (_sync) + lock (_sync) { if (_enabled) _queue.Enqueue (message); + } } void IDisposable.Dispose () From 2da22cacf2d2f0d334dfa2d921c6ee5cb986e1ac Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 26 Jul 2016 16:52:42 +0900 Subject: [PATCH 0560/6294] [Modify] Polish it --- Example1/AudioStreamer.cs | 140 +++++++++++++++++++++----------------- 1 file changed, 77 insertions(+), 63 deletions(-) diff --git a/Example1/AudioStreamer.cs b/Example1/AudioStreamer.cs index 669d5c527..f1e7e0cc9 100644 --- a/Example1/AudioStreamer.cs +++ b/Example1/AudioStreamer.cs @@ -12,10 +12,10 @@ namespace Example1 internal class AudioStreamer : IDisposable { private Dictionary _audioBox; - private Timer _heartbeatTimer; private uint? _id; private string _name; private Notifier _notifier; + private Timer _timer; private WebSocket _websocket; public AudioStreamer (string url) @@ -23,9 +23,9 @@ public AudioStreamer (string url) _websocket = new WebSocket (url); _audioBox = new Dictionary (); - _heartbeatTimer = new Timer (sendHeartbeat, null, -1, -1); _id = null; _notifier = new Notifier (); + _timer = new Timer (sendHeartbeat, null, -1, -1); configure (); } @@ -36,71 +36,80 @@ private void configure () _websocket.Log.Level = LogLevel.Trace; #endif _websocket.OnOpen += (sender, e) => - _websocket.Send (createTextMessage ("connection", String.Empty)); + _websocket.Send (createTextMessage ("connection", String.Empty)); _websocket.OnMessage += (sender, e) => { - if (e.IsText) { - _notifier.Notify (convertTextMessage (e.Data)); - } - else { - var msg = convertBinaryMessage (e.RawData); - if (msg.user_id == _id) + if (e.IsText) { + _notifier.Notify (convertToNotificationMessage (e.Data)); return; + } + + if (e.IsBinary) { + var msg = convertToAudioMessage (e.RawData); + if (msg.user_id == _id) + return; + + if (_audioBox.ContainsKey (msg.user_id)) { + _audioBox[msg.user_id].Enqueue (msg.buffer_array); + return; + } + + var queue = Queue.Synchronized (new Queue ()); + queue.Enqueue (msg.buffer_array); + _audioBox.Add (msg.user_id, queue); - if (_audioBox.ContainsKey (msg.user_id)) { - _audioBox[msg.user_id].Enqueue (msg.buffer_array); return; } - - var queue = Queue.Synchronized (new Queue ()); - queue.Enqueue (msg.buffer_array); - _audioBox.Add (msg.user_id, queue); - } - }; + }; _websocket.OnError += (sender, e) => - _notifier.Notify ( - new NotificationMessage { - Summary = "AudioStreamer (error)", - Body = e.Message, - Icon = "notification-message-im" - }); + _notifier.Notify ( + new NotificationMessage { + Summary = "AudioStreamer (error)", + Body = e.Message, + Icon = "notification-message-im" + } + ); _websocket.OnClose += (sender, e) => - _notifier.Notify ( - new NotificationMessage { - Summary = "AudioStreamer (disconnect)", - Body = String.Format ("code: {0} reason: {1}", e.Code, e.Reason), - Icon = "notification-message-im" - }); + _notifier.Notify ( + new NotificationMessage { + Summary = "AudioStreamer (disconnect)", + Body = String.Format ("code: {0} reason: {1}", e.Code, e.Reason), + Icon = "notification-message-im" + } + ); } - private AudioMessage convertBinaryMessage (byte[] data) + private AudioMessage convertToAudioMessage (byte[] binaryMessage) { - var id = data.SubArray (0, 4).To (ByteOrder.Big); - var chNum = data.SubArray (4, 1)[0]; - var buffLen = data.SubArray (5, 4).To (ByteOrder.Big); + var id = binaryMessage.SubArray (0, 4).To (ByteOrder.Big); + var chNum = binaryMessage.SubArray (4, 1)[0]; + var buffLen = binaryMessage.SubArray (5, 4).To (ByteOrder.Big); var buffArr = new float[chNum, buffLen]; var offset = 9; ((int) chNum).Times ( - i => buffLen.Times ( - j => { - buffArr[i, j] = data.SubArray (offset, 4).To (ByteOrder.Big); - offset += 4; - })); + i => + buffLen.Times ( + j => { + buffArr[i, j] = binaryMessage.SubArray (offset, 4).To (ByteOrder.Big); + offset += 4; + } + ) + ); return new AudioMessage { - user_id = id, - ch_num = chNum, - buffer_length = buffLen, - buffer_array = buffArr - }; + user_id = id, + ch_num = chNum, + buffer_length = buffLen, + buffer_array = buffArr + }; } - private NotificationMessage convertTextMessage (string data) + private NotificationMessage convertToNotificationMessage (string textMessage) { - var json = JObject.Parse (data); + var json = JObject.Parse (textMessage); var id = (uint) json["user_id"]; var name = (string) json["name"]; var type = (string) json["type"]; @@ -115,15 +124,17 @@ private NotificationMessage convertTextMessage (string data) else if (type == "connection") { var users = (JArray) json["message"]; var buff = new StringBuilder ("Now keeping connections:"); - foreach (JToken user in users) + foreach (JToken user in users) { buff.AppendFormat ( - "\n- user_id: {0} name: {1}", (uint) user["user_id"], (string) user["name"]); + "\n- user_id: {0} name: {1}", (uint) user["user_id"], (string) user["name"] + ); + } body = buff.ToString (); } else if (type == "connected") { _id = id; - _heartbeatTimer.Change (30000, 30000); + _timer.Change (30000, 30000); body = String.Format ("user_id: {0} name: {1}", id, name); } else { @@ -131,10 +142,10 @@ private NotificationMessage convertTextMessage (string data) } return new NotificationMessage { - Summary = String.Format ("AudioStreamer ({0})", type), - Body = body, - Icon = "notification-message-im" - }; + Summary = String.Format ("AudioStreamer ({0})", type), + Body = body, + Icon = "notification-message-im" + }; } private byte[] createBinaryMessage (float[,] bufferArray) @@ -150,8 +161,11 @@ private byte[] createBinaryMessage (float[,] bufferArray) msg.AddRange (((uint) buffLen).ToByteArray (ByteOrder.Big)); chNum.Times ( - i => buffLen.Times ( - j => msg.AddRange (bufferArray[i, j].ToByteArray (ByteOrder.Big)))); + i => + buffLen.Times ( + j => msg.AddRange (bufferArray[i, j].ToByteArray (ByteOrder.Big)) + ) + ); return msg.ToArray (); } @@ -159,12 +173,13 @@ private byte[] createBinaryMessage (float[,] bufferArray) private string createTextMessage (string type, string message) { return JsonConvert.SerializeObject ( - new TextMessage { - user_id = _id, - name = _name, - type = type, - message = message - }); + new TextMessage { + user_id = _id, + name = _name, + type = type, + message = message + } + ); } private void sendHeartbeat (object state) @@ -180,7 +195,7 @@ public void Connect (string username) public void Disconnect () { - _heartbeatTimer.Change (-1, -1); + _timer.Change (-1, -1); _websocket.Close (CloseStatusCode.Away); _audioBox.Clear (); _id = null; @@ -195,8 +210,7 @@ public void Write (string message) void IDisposable.Dispose () { Disconnect (); - - _heartbeatTimer.Dispose (); + _timer.Dispose (); _notifier.Close (); } } From ef330a0219d80e7ee233c0a5fb0c4853efc4464f Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 27 Jul 2016 17:19:42 +0900 Subject: [PATCH 0561/6294] [Modify] Polish it --- Example1/AudioStreamer.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Example1/AudioStreamer.cs b/Example1/AudioStreamer.cs index f1e7e0cc9..f7fc0b3ce 100644 --- a/Example1/AudioStreamer.cs +++ b/Example1/AudioStreamer.cs @@ -49,12 +49,13 @@ private void configure () if (msg.user_id == _id) return; - if (_audioBox.ContainsKey (msg.user_id)) { - _audioBox[msg.user_id].Enqueue (msg.buffer_array); + Queue queue; + if (_audioBox.TryGetValue (msg.user_id, out queue)) { + queue.Enqueue (msg.buffer_array); return; } - var queue = Queue.Synchronized (new Queue ()); + queue = Queue.Synchronized (new Queue ()); queue.Enqueue (msg.buffer_array); _audioBox.Add (msg.user_id, queue); From 132ec37d94e7e1e72e18f7a0051dc5e88f6bacae Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 28 Jul 2016 15:31:04 +0900 Subject: [PATCH 0562/6294] [Modify] Polish it --- Example1/AudioStreamer.cs | 75 ++++++++++++++++++++------------------- 1 file changed, 38 insertions(+), 37 deletions(-) diff --git a/Example1/AudioStreamer.cs b/Example1/AudioStreamer.cs index f7fc0b3ce..ea10aac02 100644 --- a/Example1/AudioStreamer.cs +++ b/Example1/AudioStreamer.cs @@ -40,7 +40,7 @@ private void configure () _websocket.OnMessage += (sender, e) => { if (e.IsText) { - _notifier.Notify (convertToNotificationMessage (e.Data)); + _notifier.Notify (processTextMessage (e.Data)); return; } @@ -108,9 +108,43 @@ private AudioMessage convertToAudioMessage (byte[] binaryMessage) }; } - private NotificationMessage convertToNotificationMessage (string textMessage) + private byte[] createBinaryMessage (float[,] bufferArray) { - var json = JObject.Parse (textMessage); + var msg = new List (); + + var id = (uint) _id; + var chNum = bufferArray.GetLength (0); + var buffLen = bufferArray.GetLength (1); + + msg.AddRange (id.ToByteArray (ByteOrder.Big)); + msg.Add ((byte) chNum); + msg.AddRange (((uint) buffLen).ToByteArray (ByteOrder.Big)); + + chNum.Times ( + i => + buffLen.Times ( + j => msg.AddRange (bufferArray[i, j].ToByteArray (ByteOrder.Big)) + ) + ); + + return msg.ToArray (); + } + + private string createTextMessage (string type, string message) + { + return JsonConvert.SerializeObject ( + new TextMessage { + user_id = _id, + name = _name, + type = type, + message = message + } + ); + } + + private NotificationMessage processTextMessage (string data) + { + var json = JObject.Parse (data); var id = (uint) json["user_id"]; var name = (string) json["name"]; var type = (string) json["type"]; @@ -136,6 +170,7 @@ private NotificationMessage convertToNotificationMessage (string textMessage) else if (type == "connected") { _id = id; _timer.Change (30000, 30000); + body = String.Format ("user_id: {0} name: {1}", id, name); } else { @@ -149,40 +184,6 @@ private NotificationMessage convertToNotificationMessage (string textMessage) }; } - private byte[] createBinaryMessage (float[,] bufferArray) - { - var msg = new List (); - - var id = (uint) _id; - var chNum = bufferArray.GetLength (0); - var buffLen = bufferArray.GetLength (1); - - msg.AddRange (id.ToByteArray (ByteOrder.Big)); - msg.Add ((byte) chNum); - msg.AddRange (((uint) buffLen).ToByteArray (ByteOrder.Big)); - - chNum.Times ( - i => - buffLen.Times ( - j => msg.AddRange (bufferArray[i, j].ToByteArray (ByteOrder.Big)) - ) - ); - - return msg.ToArray (); - } - - private string createTextMessage (string type, string message) - { - return JsonConvert.SerializeObject ( - new TextMessage { - user_id = _id, - name = _name, - type = type, - message = message - } - ); - } - private void sendHeartbeat (object state) { _websocket.Send (createTextMessage ("heartbeat", String.Empty)); From 3a3802ae8451aef5f54f842e4667e46a411ee328 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 28 Jul 2016 15:45:28 +0900 Subject: [PATCH 0563/6294] [Modify] Polish it --- Example1/AudioStreamer.cs | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/Example1/AudioStreamer.cs b/Example1/AudioStreamer.cs index ea10aac02..2cf46a813 100644 --- a/Example1/AudioStreamer.cs +++ b/Example1/AudioStreamer.cs @@ -45,20 +45,7 @@ private void configure () } if (e.IsBinary) { - var msg = convertToAudioMessage (e.RawData); - if (msg.user_id == _id) - return; - - Queue queue; - if (_audioBox.TryGetValue (msg.user_id, out queue)) { - queue.Enqueue (msg.buffer_array); - return; - } - - queue = Queue.Synchronized (new Queue ()); - queue.Enqueue (msg.buffer_array); - _audioBox.Add (msg.user_id, queue); - + processBinaryMessage (e.RawData); return; } }; @@ -142,6 +129,23 @@ private string createTextMessage (string type, string message) ); } + private void processBinaryMessage (byte[] data) + { + var msg = convertToAudioMessage (data); + if (msg.user_id == _id) + return; + + Queue queue; + if (_audioBox.TryGetValue (msg.user_id, out queue)) { + queue.Enqueue (msg.buffer_array); + return; + } + + queue = Queue.Synchronized (new Queue ()); + queue.Enqueue (msg.buffer_array); + _audioBox.Add (msg.user_id, queue); + } + private NotificationMessage processTextMessage (string data) { var json = JObject.Parse (data); From 8c62e9acb2a88b6bac0dd10ac0e1c6309a777c94 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 29 Jul 2016 16:01:49 +0900 Subject: [PATCH 0564/6294] [Modify] Polish it --- Example1/AudioStreamer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Example1/AudioStreamer.cs b/Example1/AudioStreamer.cs index 2cf46a813..11cbc2aed 100644 --- a/Example1/AudioStreamer.cs +++ b/Example1/AudioStreamer.cs @@ -69,7 +69,7 @@ private void configure () ); } - private AudioMessage convertToAudioMessage (byte[] binaryMessage) + private static AudioMessage convertToAudioMessage (byte[] binaryMessage) { var id = binaryMessage.SubArray (0, 4).To (ByteOrder.Big); var chNum = binaryMessage.SubArray (4, 1)[0]; From 9775d9381766bc0258840c09cc64ef6c5f680037 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 30 Jul 2016 16:19:24 +0900 Subject: [PATCH 0565/6294] [Modify] Polish it --- Example1/AudioStreamer.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Example1/AudioStreamer.cs b/Example1/AudioStreamer.cs index 11cbc2aed..8ad5b51c7 100644 --- a/Example1/AudioStreamer.cs +++ b/Example1/AudioStreamer.cs @@ -193,6 +193,13 @@ private void sendHeartbeat (object state) _websocket.Send (createTextMessage ("heartbeat", String.Empty)); } + public void Close () + { + Disconnect (); + _timer.Dispose (); + _notifier.Close (); + } + public void Connect (string username) { _name = username; @@ -215,9 +222,7 @@ public void Write (string message) void IDisposable.Dispose () { - Disconnect (); - _timer.Dispose (); - _notifier.Close (); + Close (); } } } From df74f3d02140d3373659918e736391671de09001 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 31 Jul 2016 17:02:25 +0900 Subject: [PATCH 0566/6294] [Modify] Polish it --- Example1/AudioStreamer.cs | 15 +++++++-------- Example1/Program.cs | 4 ++-- Example1/TextMessage.cs | 29 +++++++++++++++++++++++++---- 3 files changed, 34 insertions(+), 14 deletions(-) diff --git a/Example1/AudioStreamer.cs b/Example1/AudioStreamer.cs index 8ad5b51c7..c397dc418 100644 --- a/Example1/AudioStreamer.cs +++ b/Example1/AudioStreamer.cs @@ -119,14 +119,13 @@ private byte[] createBinaryMessage (float[,] bufferArray) private string createTextMessage (string type, string message) { - return JsonConvert.SerializeObject ( - new TextMessage { - user_id = _id, - name = _name, - type = type, - message = message - } - ); + return new TextMessage { + UserID = _id, + Name = _name, + Type = type, + Message = message + } + .ToString (); } private void processBinaryMessage (byte[] data) diff --git a/Example1/Program.cs b/Example1/Program.cs index 7b936da93..14613efd3 100644 --- a/Example1/Program.cs +++ b/Example1/Program.cs @@ -7,8 +7,8 @@ public class Program { public static void Main (string[] args) { - using (var streamer = new AudioStreamer ("ws://agektmr.node-ninja.com:3000/socket")) - //using (var streamer = new AudioStreamer ("ws://localhost:3000/socket")) + //using (var streamer = new AudioStreamer ("ws://agektmr.node-ninja.com:3000/socket")) + using (var streamer = new AudioStreamer ("ws://localhost:3000/socket")) { string name; do { diff --git a/Example1/TextMessage.cs b/Example1/TextMessage.cs index 5eab648f9..2b177d845 100644 --- a/Example1/TextMessage.cs +++ b/Example1/TextMessage.cs @@ -1,12 +1,33 @@ +using Newtonsoft.Json; using System; namespace Example1 { internal class TextMessage { - public uint? user_id; - public string name; - public string type; - public string message; + [JsonProperty ("user_id")] + public uint? UserID { + get; set; + } + + [JsonProperty ("name")] + public string Name { + get; set; + } + + [JsonProperty ("type")] + public string Type { + get; set; + } + + [JsonProperty ("message")] + public string Message { + get; set; + } + + public override string ToString () + { + return JsonConvert.SerializeObject (this); + } } } From 48e5a7cc5a50ab798ebdafe6122137927f16840e Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 1 Aug 2016 16:24:39 +0900 Subject: [PATCH 0567/6294] [Add] Add BinaryMessage class --- Example1/BinaryMessage.cs | 74 +++++++++++++++++++++++++++++++++++++++ Example1/Example1.csproj | 1 + 2 files changed, 75 insertions(+) create mode 100644 Example1/BinaryMessage.cs diff --git a/Example1/BinaryMessage.cs b/Example1/BinaryMessage.cs new file mode 100644 index 000000000..eafa7aa98 --- /dev/null +++ b/Example1/BinaryMessage.cs @@ -0,0 +1,74 @@ +using System; +using System.Collections.Generic; +using WebSocketSharp; + +namespace Example1 +{ + internal class BinaryMessage + { + public uint UserID { + get; set; + } + + public byte ChannelNumber { + get; set; + } + + public uint BufferLength { + get; set; + } + + public float[,] BufferArray { + get; set; + } + + public static BinaryMessage Parse (byte[] data) + { + var id = data.SubArray (0, 4).To (ByteOrder.Big); + var num = data.SubArray (4, 1)[0]; + var len = data.SubArray (5, 4).To (ByteOrder.Big); + var arr = new float[num, len]; + + var offset = 9; + ((uint) num).Times ( + i => + len.Times ( + j => { + arr[i, j] = data.SubArray (offset, 4).To (ByteOrder.Big); + offset += 4; + } + ) + ); + + return new BinaryMessage { + UserID = id, + ChannelNumber = num, + BufferLength = len, + BufferArray = arr + }; + } + + public byte[] ToArray () + { + var buff = new List (); + + var id = UserID; + var num = ChannelNumber; + var len = BufferLength; + var arr = BufferArray; + + buff.AddRange (id.ToByteArray (ByteOrder.Big)); + buff.Add (num); + buff.AddRange (len.ToByteArray (ByteOrder.Big)); + + ((uint) num).Times ( + i => + len.Times ( + j => buff.AddRange (arr[i, j].ToByteArray (ByteOrder.Big)) + ) + ); + + return buff.ToArray (); + } + } +} diff --git a/Example1/Example1.csproj b/Example1/Example1.csproj index 903f5b045..1e3425ae6 100644 --- a/Example1/Example1.csproj +++ b/Example1/Example1.csproj @@ -66,6 +66,7 @@ + From ef26fd2c7db37bcc907479bdff0e61f0dacaa60a Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 2 Aug 2016 15:46:56 +0900 Subject: [PATCH 0568/6294] [Modify] Use it --- Example1/AudioStreamer.cs | 39 +++++++++++++++------------------------ 1 file changed, 15 insertions(+), 24 deletions(-) diff --git a/Example1/AudioStreamer.cs b/Example1/AudioStreamer.cs index c397dc418..70dc658a9 100644 --- a/Example1/AudioStreamer.cs +++ b/Example1/AudioStreamer.cs @@ -97,24 +97,13 @@ private static AudioMessage convertToAudioMessage (byte[] binaryMessage) private byte[] createBinaryMessage (float[,] bufferArray) { - var msg = new List (); - - var id = (uint) _id; - var chNum = bufferArray.GetLength (0); - var buffLen = bufferArray.GetLength (1); - - msg.AddRange (id.ToByteArray (ByteOrder.Big)); - msg.Add ((byte) chNum); - msg.AddRange (((uint) buffLen).ToByteArray (ByteOrder.Big)); - - chNum.Times ( - i => - buffLen.Times ( - j => msg.AddRange (bufferArray[i, j].ToByteArray (ByteOrder.Big)) - ) - ); - - return msg.ToArray (); + return new BinaryMessage { + UserID = (uint) _id, + ChannelNumber = (byte) bufferArray.GetLength (0), + BufferLength = (uint) bufferArray.GetLength (1), + BufferArray = bufferArray + } + .ToArray (); } private string createTextMessage (string type, string message) @@ -130,19 +119,21 @@ private string createTextMessage (string type, string message) private void processBinaryMessage (byte[] data) { - var msg = convertToAudioMessage (data); - if (msg.user_id == _id) + var msg = BinaryMessage.Parse (data); + + var id = msg.UserID; + if (id == _id) return; Queue queue; - if (_audioBox.TryGetValue (msg.user_id, out queue)) { - queue.Enqueue (msg.buffer_array); + if (_audioBox.TryGetValue (id, out queue)) { + queue.Enqueue (msg.BufferArray); return; } queue = Queue.Synchronized (new Queue ()); - queue.Enqueue (msg.buffer_array); - _audioBox.Add (msg.user_id, queue); + queue.Enqueue (msg.BufferArray); + _audioBox.Add (id, queue); } private NotificationMessage processTextMessage (string data) From 85a55644fde93daf0904346bcbd75dcc68b46296 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 2 Aug 2016 15:52:28 +0900 Subject: [PATCH 0569/6294] [Modify] Remove it --- Example1/AudioStreamer.cs | 26 -------------------------- 1 file changed, 26 deletions(-) diff --git a/Example1/AudioStreamer.cs b/Example1/AudioStreamer.cs index 70dc658a9..711694e9a 100644 --- a/Example1/AudioStreamer.cs +++ b/Example1/AudioStreamer.cs @@ -69,32 +69,6 @@ private void configure () ); } - private static AudioMessage convertToAudioMessage (byte[] binaryMessage) - { - var id = binaryMessage.SubArray (0, 4).To (ByteOrder.Big); - var chNum = binaryMessage.SubArray (4, 1)[0]; - var buffLen = binaryMessage.SubArray (5, 4).To (ByteOrder.Big); - var buffArr = new float[chNum, buffLen]; - - var offset = 9; - ((int) chNum).Times ( - i => - buffLen.Times ( - j => { - buffArr[i, j] = binaryMessage.SubArray (offset, 4).To (ByteOrder.Big); - offset += 4; - } - ) - ); - - return new AudioMessage { - user_id = id, - ch_num = chNum, - buffer_length = buffLen, - buffer_array = buffArr - }; - } - private byte[] createBinaryMessage (float[,] bufferArray) { return new BinaryMessage { From 6ff198c4825224af95386c4e7d80a81174a26ba3 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 2 Aug 2016 16:24:59 +0900 Subject: [PATCH 0570/6294] [Delete] Delete AudioMessage.cs --- Example1/AudioMessage.cs | 12 ------------ Example1/Example1.csproj | 1 - 2 files changed, 13 deletions(-) delete mode 100644 Example1/AudioMessage.cs diff --git a/Example1/AudioMessage.cs b/Example1/AudioMessage.cs deleted file mode 100644 index 20793d7ba..000000000 --- a/Example1/AudioMessage.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System; - -namespace Example1 -{ - internal class AudioMessage - { - public uint user_id; - public byte ch_num; - public uint buffer_length; - public float[,] buffer_array; - } -} diff --git a/Example1/Example1.csproj b/Example1/Example1.csproj index 1e3425ae6..81c52eff2 100644 --- a/Example1/Example1.csproj +++ b/Example1/Example1.csproj @@ -62,7 +62,6 @@ - From e9bea026aa3fe297be035d28d6cd334fa274b8ac Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 3 Aug 2016 15:32:17 +0900 Subject: [PATCH 0571/6294] [Modify] Polish it --- Example1/Notifier.cs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/Example1/Notifier.cs b/Example1/Notifier.cs index 5bcbb16ac..adf53ec9a 100644 --- a/Example1/Notifier.cs +++ b/Example1/Notifier.cs @@ -11,16 +11,16 @@ namespace Example1 internal class Notifier : IDisposable { private volatile bool _enabled; + private ManualResetEvent _exited; private Queue _queue; private object _sync; - private ManualResetEvent _waitHandle; public Notifier () { _enabled = true; + _exited = new ManualResetEvent (false); _queue = new Queue (); _sync = ((ICollection) _queue).SyncRoot; - _waitHandle = new ManualResetEvent (false); ThreadPool.QueueUserWorkItem ( state => { @@ -40,8 +40,9 @@ public Notifier () } } - _waitHandle.Set (); - }); + _exited.Set (); + } + ); } public int Count { @@ -60,15 +61,16 @@ private NotificationMessage dequeue () public void Close () { _enabled = false; - _waitHandle.WaitOne (); - _waitHandle.Close (); + _exited.WaitOne (); + _exited.Close (); } public void Notify (NotificationMessage message) { - lock (_sync) + lock (_sync) { if (_enabled) _queue.Enqueue (message); + } } void IDisposable.Dispose () From 1d864f0c41563f1c86368da7e594cf89b4830cbb Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 4 Aug 2016 17:46:04 +0900 Subject: [PATCH 0572/6294] [Modify] Edit it --- Example/Program.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Example/Program.cs b/Example/Program.cs index 78c8fef0b..aa840c41c 100644 --- a/Example/Program.cs +++ b/Example/Program.cs @@ -15,7 +15,7 @@ public static void Main (string[] args) // use the using statement. And the WebSocket connection will be closed with // close status 1001 (going away) when the control leaves the using block. // - // If you would like to connect to a server with the secure connection, + // If you would like to connect to the server with the secure connection, // you should create a new instance with a wss scheme WebSocket URL. using (var nf = new Notifier ()) From b3cbea3485593048b0b0ea0004e393394584ed44 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 4 Aug 2016 17:53:09 +0900 Subject: [PATCH 0573/6294] [Modify] Move it --- Example/Program.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Example/Program.cs b/Example/Program.cs index aa840c41c..349aa3c92 100644 --- a/Example/Program.cs +++ b/Example/Program.cs @@ -69,9 +69,6 @@ public static void Main (string[] args) // To emit a WebSocket.OnMessage event when receives a ping. //ws.EmitOnPing = true; - - // To enable the redirection. - //ws.EnableRedirection = true; #endif // To enable the Per-message Compression extension. //ws.Compression = CompressionMethod.Deflate; @@ -104,6 +101,9 @@ public static void Main (string[] args) // To connect through the HTTP Proxy server. //ws.SetProxy ("http://localhost:3128/", "nobita", "password"); + // To enable the redirection. + //ws.EnableRedirection = true; + // Connect to the server. ws.Connect (); From f504d5f926a93a3814befac07c962d17b37b5496 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 5 Aug 2016 15:15:35 +0900 Subject: [PATCH 0574/6294] [Modify] Edit it --- Example/Program.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Example/Program.cs b/Example/Program.cs index 349aa3c92..d414bb1e5 100644 --- a/Example/Program.cs +++ b/Example/Program.cs @@ -73,7 +73,8 @@ public static void Main (string[] args) // To enable the Per-message Compression extension. //ws.Compression = CompressionMethod.Deflate; - /* To validate the server certificate. + // To validate the server certificate. + /* ws.SslConfiguration.ServerCertificateValidationCallback = (sender, certificate, chain, sslPolicyErrors) => { ws.Log.Debug ( From 6999481ef07dba536122e5d4872b5c9204ed2df3 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 5 Aug 2016 15:23:30 +0900 Subject: [PATCH 0575/6294] [Modify] Edit it --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 95cdded42..9da2862fa 100644 --- a/README.md +++ b/README.md @@ -459,7 +459,7 @@ I think this is useful when you get something error in connecting the server and websocket-sharp supports the **Secure Connection** with **SSL/TLS**. -As a **WebSocket Client**, you should create a new instance of the `WebSocket` class with the **wss** scheme WebSocket URL. +As a **WebSocket Client**, you should create a new instance of the `WebSocket` class with a **wss** scheme WebSocket URL. ```csharp using (var ws = new WebSocket ("wss://example.com")) { From 2c1e2dfc6259b831acd5d7fd4160b13e9f794b49 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 6 Aug 2016 17:18:57 +0900 Subject: [PATCH 0576/6294] [Modify] Polish it --- Example1/Program.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Example1/Program.cs b/Example1/Program.cs index 14613efd3..88c0bedfe 100644 --- a/Example1/Program.cs +++ b/Example1/Program.cs @@ -7,7 +7,9 @@ public class Program { public static void Main (string[] args) { - //using (var streamer = new AudioStreamer ("ws://agektmr.node-ninja.com:3000/socket")) + // The AudioStreamer class provides a client (chat) for AudioStreamer + // (https://github.com/agektmr/AudioStreamer). + using (var streamer = new AudioStreamer ("ws://localhost:3000/socket")) { string name; From e707edabd1d8bb83dc1c4dd12d5940634e43b9b6 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 7 Aug 2016 17:06:46 +0900 Subject: [PATCH 0577/6294] [Modify] Polish it --- Example2/Program.cs | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/Example2/Program.cs b/Example2/Program.cs index 81ef2642a..c9bd7ef3d 100644 --- a/Example2/Program.cs +++ b/Example2/Program.cs @@ -13,8 +13,9 @@ public static void Main (string[] args) { // Create a new instance of the WebSocketServer class. // - // If you would like to provide the secure connection, you should create a new instance with - // the 'secure' parameter set to true, or a wss scheme WebSocket URL. + // If you would like to provide the secure connection, you should + // create a new instance with the 'secure' parameter set to true, + // or a wss scheme WebSocket URL. var wssv = new WebSocketServer (4649); //var wssv = new WebSocketServer (5963, true); @@ -54,17 +55,16 @@ public static void Main (string[] args) // Not to remove the inactive sessions periodically. //wssv.KeepClean = false; - - // To resolve to wait for socket in TIME_WAIT state. - //wssv.ReuseAddress = true; #endif - /* To provide the secure connection. + // To provide the secure connection. + /* var cert = ConfigurationManager.AppSettings["ServerCertFile"]; var passwd = ConfigurationManager.AppSettings["CertFilePassword"]; wssv.SslConfiguration.ServerCertificate = new X509Certificate2 (cert, passwd); */ - /* To provide the HTTP Authentication (Basic/Digest). + // To provide the HTTP Authentication (Basic/Digest). + /* wssv.AuthenticationSchemes = AuthenticationSchemes.Basic; wssv.Realm = "WebSocket Test"; wssv.UserCredentialsFinder = id => { @@ -77,21 +77,25 @@ public static void Main (string[] args) }; */ + // To resolve to wait for socket in TIME_WAIT state. + //wssv.ReuseAddress = true; + // Add the WebSocket services. wssv.AddWebSocketService ("/Echo"); wssv.AddWebSocketService ("/Chat"); - /* Add the WebSocket service with initializing. + // Add the WebSocket service with initializing. + /* wssv.AddWebSocketService ( "/Chat", () => new Chat ("Anon#") { // To send the Sec-WebSocket-Protocol header that has a subprotocol name. Protocol = "chat", - // To emit a WebSocket.OnMessage event when receives a ping. - EmitOnPing = true, // To ignore the Sec-WebSocket-Extensions header. IgnoreExtensions = true, + // To emit a WebSocket.OnMessage event when receives a ping. + EmitOnPing = true, // To validate the Origin header. OriginValidator = val => { // Check the value of the Origin header, and return true if valid. From c2032eab718d4c54bc44e7ce25d621acdfff30b9 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 8 Aug 2016 17:50:02 +0900 Subject: [PATCH 0578/6294] [Modify] Polish it --- Example3/Program.cs | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/Example3/Program.cs b/Example3/Program.cs index ffb119c83..29333f2e7 100644 --- a/Example3/Program.cs +++ b/Example3/Program.cs @@ -14,8 +14,9 @@ public static void Main (string[] args) { // Create a new instance of the HttpServer class. // - // If you would like to provide the secure connection, you should create a new instance with - // the 'secure' parameter set to true, or an https scheme HTTP URL. + // If you would like to provide the secure connection, you should + // create a new instance with the 'secure' parameter set to true, + // or an https scheme HTTP URL. var httpsv = new HttpServer (4649); //var httpsv = new HttpServer (5963, true); @@ -55,17 +56,16 @@ public static void Main (string[] args) // Not to remove the inactive WebSocket sessions periodically. //httpsv.KeepClean = false; - - // To resolve to wait for socket in TIME_WAIT state. - //httpsv.ReuseAddress = true; #endif - /* To provide the secure connection. + // To provide the secure connection. + /* var cert = ConfigurationManager.AppSettings["ServerCertFile"]; var passwd = ConfigurationManager.AppSettings["CertFilePassword"]; httpsv.SslConfiguration.ServerCertificate = new X509Certificate2 (cert, passwd); */ - /* To provide the HTTP Authentication (Basic/Digest). + // To provide the HTTP Authentication (Basic/Digest). + /* httpsv.AuthenticationSchemes = AuthenticationSchemes.Basic; httpsv.Realm = "WebSocket Test"; httpsv.UserCredentialsFinder = id => { @@ -78,6 +78,9 @@ public static void Main (string[] args) }; */ + // To resolve to wait for socket in TIME_WAIT state. + //httpsv.ReuseAddress = true; + // Set the document root path. httpsv.RootPath = ConfigurationManager.AppSettings["RootPath"]; @@ -112,17 +115,18 @@ public static void Main (string[] args) httpsv.AddWebSocketService ("/Echo"); httpsv.AddWebSocketService ("/Chat"); - /* Add the WebSocket service with initializing. + // Add the WebSocket service with initializing. + /* httpsv.AddWebSocketService ( "/Chat", () => new Chat ("Anon#") { // To send the Sec-WebSocket-Protocol header that has a subprotocol name. Protocol = "chat", - // To emit a WebSocket.OnMessage event when receives a ping. - EmitOnPing = true, // To ignore the Sec-WebSocket-Extensions header. IgnoreExtensions = true, + // To emit a WebSocket.OnMessage event when receives a ping. + EmitOnPing = true, // To validate the Origin header. OriginValidator = val => { // Check the value of the Origin header, and return true if valid. From cbe6d690dc31621c13f571dc6dea32822d0e1ef8 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 9 Aug 2016 16:43:44 +0900 Subject: [PATCH 0579/6294] [Modify] Move it out --- websocket-sharp/WebSocket.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index b463b4f52..05b77086d 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2773,6 +2773,13 @@ public void SetCookie (Cookie cookie) return; } + if (cookie == null) { + _logger.Error ("'cookie' is null."); + error ("An error has occurred in setting a cookie.", null); + + return; + } + lock (_forConn) { if (!checkIfAvailable (true, false, false, true, out msg)) { _logger.Error (msg); @@ -2781,13 +2788,6 @@ public void SetCookie (Cookie cookie) return; } - if (cookie == null) { - _logger.Error ("'cookie' is null."); - error ("An error has occurred in setting a cookie.", null); - - return; - } - lock (_cookies.SyncRoot) _cookies.SetOrRemove (cookie); } From fb6ef25c5df4228bf06176b8d7b8c05692ced071 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 9 Aug 2016 16:49:27 +0900 Subject: [PATCH 0580/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 05b77086d..810964e59 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2761,7 +2761,7 @@ public void SendAsync (Stream stream, int length, Action completed) /// the WebSocket handshake request to the server. /// /// - /// A that represents the cookie to send. + /// A that represents a cookie to send. /// public void SetCookie (Cookie cookie) { From 32b3043a584480a9a733b671953d08a6ca690d71 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 10 Aug 2016 16:14:27 +0900 Subject: [PATCH 0581/6294] [Modify] Rename it --- websocket-sharp/WebSocket.cs | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 810964e59..19f68b462 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -81,9 +81,9 @@ public class WebSocket : IDisposable private AutoResetEvent _exitReceiving; private string _extensions; private bool _extensionsRequested; - private object _forConn; private object _forMessageEventQueue; private object _forSend; + private object _forState; private MemoryStream _fragmentsBuffer; private bool _fragmentsCompressed; private Opcode _fragmentsOpcode; @@ -310,7 +310,7 @@ public CompressionMethod Compression { } set { - lock (_forConn) { + lock (_forState) { string msg; if (!checkIfAvailable (true, false, true, false, false, true, out msg)) { _logger.Error (msg); @@ -385,7 +385,7 @@ public bool EnableRedirection { } set { - lock (_forConn) { + lock (_forState) { string msg; if (!checkIfAvailable (true, false, true, false, false, true, out msg)) { _logger.Error (msg); @@ -481,7 +481,7 @@ public string Origin { } set { - lock (_forConn) { + lock (_forState) { string msg; if (!checkIfAvailable (true, false, true, false, false, true, out msg)) { _logger.Error (msg); @@ -555,7 +555,7 @@ public ClientSslConfiguration SslConfiguration { } set { - lock (_forConn) { + lock (_forState) { string msg; if (!checkIfAvailable (true, false, true, false, false, true, out msg)) { _logger.Error (msg); @@ -594,7 +594,7 @@ public TimeSpan WaitTime { } set { - lock (_forConn) { + lock (_forState) { string msg; if (!checkIfAvailable (true, true, true, false, false, true, out msg) || !value.CheckWaitTime (out msg) @@ -641,7 +641,7 @@ public TimeSpan WaitTime { // As server private bool accept () { - lock (_forConn) { + lock (_forState) { string msg; if (!checkIfAvailable (true, false, false, false, out msg)) { _logger.Error (msg); @@ -881,7 +881,7 @@ private bool checkReceivedFrame (WebSocketFrame frame, out string message) private void close (CloseEventArgs e, bool send, bool receive, bool received) { - lock (_forConn) { + lock (_forState) { if (_readyState == WebSocketState.Closing) { _logger.Info ("The closing is already in progress."); return; @@ -938,7 +938,7 @@ private bool closeHandshake (byte[] frameAsBytes, bool receive, bool received) // As client private bool connect () { - lock (_forConn) { + lock (_forState) { string msg; if (!checkIfAvailable (true, false, false, true, out msg)) { _logger.Error (msg); @@ -1127,8 +1127,8 @@ private void init () { _compression = CompressionMethod.None; _cookies = new CookieCollection (); - _forConn = new object (); _forSend = new object (); + _forState = new object (); _messageEventQueue = new Queue (); _forMessageEventQueue = ((ICollection) _messageEventQueue).SyncRoot; _readyState = WebSocketState.Connecting; @@ -1431,7 +1431,7 @@ private void releaseServerResources () private bool send (byte[] frameAsBytes) { - lock (_forConn) { + lock (_forState) { if (_readyState != WebSocketState.Open) { _logger.Error ("The sending has been interrupted."); return false; @@ -1520,7 +1520,7 @@ private bool send (Opcode opcode, Stream stream, bool compressed) private bool send (Fin fin, Opcode opcode, byte[] data, bool compressed) { - lock (_forConn) { + lock (_forState) { if (_readyState != WebSocketState.Open) { _logger.Error ("The sending has been interrupted."); return false; @@ -1938,7 +1938,7 @@ internal void Close (HttpStatusCode code) // As server internal void Close (CloseEventArgs e, byte[] frameAsBytes, bool receive) { - lock (_forConn) { + lock (_forState) { if (_readyState == WebSocketState.Closing) { _logger.Info ("The closing is already in progress."); return; @@ -2022,7 +2022,7 @@ internal bool Ping (byte[] frameAsBytes, TimeSpan timeout) internal void Send (Opcode opcode, byte[] data, Dictionary cache) { lock (_forSend) { - lock (_forConn) { + lock (_forState) { if (_readyState != WebSocketState.Open) { _logger.Error ("The sending has been interrupted."); return; @@ -2780,7 +2780,7 @@ public void SetCookie (Cookie cookie) return; } - lock (_forConn) { + lock (_forState) { if (!checkIfAvailable (true, false, false, true, out msg)) { _logger.Error (msg); error ("An error has occurred in setting a cookie.", null); @@ -2818,7 +2818,7 @@ public void SetCredentials (string username, string password, bool preAuth) return; } - lock (_forConn) { + lock (_forState) { if (!checkIfAvailable (true, false, false, true, out msg)) { _logger.Error (msg); error ("An error has occurred in setting the credentials.", null); @@ -2878,7 +2878,7 @@ public void SetProxy (string url, string username, string password) return; } - lock (_forConn) { + lock (_forState) { if (!checkIfAvailable (true, false, false, true, out msg)) { _logger.Error (msg); error ("An error has occurred in setting the proxy.", null); From 296ede4c33e4412b3a476f4985db7665982e79ae Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 11 Aug 2016 16:59:55 +0900 Subject: [PATCH 0582/6294] [Modify] Move it out --- websocket-sharp/WebSocket.cs | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 19f68b462..4aebd11f4 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2818,32 +2818,34 @@ public void SetCredentials (string username, string password, bool preAuth) return; } - lock (_forState) { - if (!checkIfAvailable (true, false, false, true, out msg)) { - _logger.Error (msg); + if (!username.IsNullOrEmpty ()) { + if (username.Contains (':') || !username.IsText ()) { + _logger.Error ("'username' contains an invalid character."); error ("An error has occurred in setting the credentials.", null); return; } - if (username.IsNullOrEmpty ()) { - _logger.Warn ("The credentials are set back to the default."); - _credentials = null; - _preAuth = false; + if (!password.IsNullOrEmpty () && !password.IsText ()) { + _logger.Error ("'password' contains an invalid character."); + error ("An error has occurred in setting the credentials.", null); return; } + } - if (username.Contains (':') || !username.IsText ()) { - _logger.Error ("'username' contains an invalid character."); + lock (_forState) { + if (!checkIfAvailable (true, false, false, true, out msg)) { + _logger.Error (msg); error ("An error has occurred in setting the credentials.", null); return; } - if (!password.IsNullOrEmpty () && !password.IsText ()) { - _logger.Error ("'password' contains an invalid character."); - error ("An error has occurred in setting the credentials.", null); + if (username.IsNullOrEmpty ()) { + _logger.Warn ("The credentials are set back to the default."); + _credentials = null; + _preAuth = false; return; } From 8478bfd9ba6f2fcf7aa0b869b13ad90113281f94 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 12 Aug 2016 16:10:58 +0900 Subject: [PATCH 0583/6294] [Modify] Add it --- websocket-sharp/WebSocket.cs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 4aebd11f4..49c1194e7 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -841,6 +841,31 @@ out string message return checkIfAvailable (connecting, open, closing, closed, out message); } + private static bool checkParametersForSetCredentials ( + string username, string password, out string message + ) + { + message = null; + + if (username.IsNullOrEmpty ()) + return true; + + if (username.Contains (':') || !username.IsText ()) { + message = "'username' contains an invalid character."; + return false; + } + + if (password.IsNullOrEmpty ()) + return true; + + if (!password.IsText ()) { + message = "'password' contains an invalid character."; + return false; + } + + return true; + } + private bool checkReceivedFrame (WebSocketFrame frame, out string message) { message = null; From 03aad074e65245b2d51a5dc1ae746e08c4c93495 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 12 Aug 2016 16:59:39 +0900 Subject: [PATCH 0584/6294] [Modify] Use it --- websocket-sharp/WebSocket.cs | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 49c1194e7..f12dd874d 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2843,20 +2843,11 @@ public void SetCredentials (string username, string password, bool preAuth) return; } - if (!username.IsNullOrEmpty ()) { - if (username.Contains (':') || !username.IsText ()) { - _logger.Error ("'username' contains an invalid character."); - error ("An error has occurred in setting the credentials.", null); - - return; - } - - if (!password.IsNullOrEmpty () && !password.IsText ()) { - _logger.Error ("'password' contains an invalid character."); - error ("An error has occurred in setting the credentials.", null); + if (!checkParametersForSetCredentials (username, password, out msg)) { + _logger.Error (msg); + error ("An error has occurred in setting the credentials.", null); - return; - } + return; } lock (_forState) { From b1deb38c26a44986e5e09c2cef26f41d0457053a Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 13 Aug 2016 17:21:54 +0900 Subject: [PATCH 0585/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index f12dd874d..c1e254093 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2823,15 +2823,22 @@ public void SetCookie (Cookie cookie) /// the HTTP authentication (Basic/Digest). /// /// - /// A that represents the user name used to authenticate. + /// + /// A that represents the user name used to authenticate. + /// + /// + /// If is or empty, + /// the credentials will be initialized and not be sent. + /// /// /// - /// A that represents the password for - /// used to authenticate. + /// A that represents the password for + /// used to authenticate. /// /// - /// true if the sends the Basic authentication credentials with - /// the first handshake request to the server; otherwise, false. + /// true if the sends the credentials for + /// the Basic authentication with the first handshake request to the server; + /// otherwise, false. /// public void SetCredentials (string username, string password, bool preAuth) { From 684726678117cfb6fd98fb06911c9f9f0ca16942 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 14 Aug 2016 14:08:53 +0900 Subject: [PATCH 0586/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index c1e254093..6ffa53079 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2866,7 +2866,7 @@ public void SetCredentials (string username, string password, bool preAuth) } if (username.IsNullOrEmpty ()) { - _logger.Warn ("The credentials are set back to the default."); + _logger.Warn ("The credentials are initialized."); _credentials = null; _preAuth = false; From c07d859670a4c6e49e711cc29a90b61859a4b445 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 15 Aug 2016 17:15:17 +0900 Subject: [PATCH 0587/6294] [Modify] Edit it --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 9da2862fa..4906affda 100644 --- a/README.md +++ b/README.md @@ -499,9 +499,9 @@ As a **WebSocket Client**, you should set a pair of user name and password for t ws.SetCredentials ("nobita", "password", preAuth); ``` -If `preAuth` is `true`, the `WebSocket` sends the Basic authentication credentials with the first handshake request to the server. +If `preAuth` is `true`, the `WebSocket` will send the credentials for the Basic authentication with the first handshake request to the server. -Or if `preAuth` is `false`, the `WebSocket` sends either the Basic or Digest (determined by the unauthorized response to the first handshake request) authentication credentials with the second handshake request to the server. +Otherwise, the `WebSocket` will send the credentials for either the Basic or Digest (determined by the unauthorized response to the first handshake request) authentication with the second handshake request to the server. As a **WebSocket Server**, you should set an HTTP authentication scheme, a realm, and any function to find the user credentials before starting, such as the following. From f6bd88326417c2d53dccc9d9f20bdf04b543e17a Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 16 Aug 2016 17:25:25 +0900 Subject: [PATCH 0588/6294] [Modify] Add it --- websocket-sharp/WebSocket.cs | 37 ++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 6ffa53079..ae37d480c 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -866,6 +866,43 @@ private static bool checkParametersForSetCredentials ( return true; } + private static bool checkParametersForSetProxy ( + string url, string username, string password, out string message + ) + { + message = null; + + if (url.IsNullOrEmpty ()) + return true; + + Uri uri; + if (!Uri.TryCreate (url, UriKind.Absolute, out uri) + || uri.Scheme != "http" + || uri.Segments.Length > 1 + ) { + message = "The syntax of a proxy url must be 'http://[:]'."; + return false; + } + + if (username.IsNullOrEmpty ()) + return true; + + if (username.Contains (':') || !username.IsText ()) { + message = "'username' contains an invalid character."; + return false; + } + + if (password.IsNullOrEmpty ()) + return true; + + if (!password.IsText ()) { + message = "'password' contains an invalid character."; + return false; + } + + return true; + } + private bool checkReceivedFrame (WebSocketFrame frame, out string message) { message = null; From ffa0b10fe6f9b10f7fbb71cbd6bae3c8fc70c1c1 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 17 Aug 2016 15:24:40 +0900 Subject: [PATCH 0589/6294] [Modify] Use it --- websocket-sharp/WebSocket.cs | 38 ++++++++++-------------------------- 1 file changed, 10 insertions(+), 28 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index ae37d480c..96cefb574 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2940,6 +2940,13 @@ public void SetProxy (string url, string username, string password) return; } + if (!checkParametersForSetProxy (url, username, password, out msg)) { + _logger.Error (msg); + error ("An error has occurred in setting the proxy.", null); + + return; + } + lock (_forState) { if (!checkIfAvailable (true, false, false, true, out msg)) { _logger.Error (msg); @@ -2949,47 +2956,22 @@ public void SetProxy (string url, string username, string password) } if (url.IsNullOrEmpty ()) { - _logger.Warn ("The proxy url and credentials are set back to the default."); + _logger.Warn ("The url and credentials for the proxy are initialized."); _proxyUri = null; _proxyCredentials = null; return; } - Uri uri; - if (!Uri.TryCreate (url, UriKind.Absolute, out uri) - || uri.Scheme != "http" - || uri.Segments.Length > 1 - ) { - _logger.Error ("The syntax of a proxy url must be 'http://[:]'."); - error ("An error has occurred in setting the proxy.", null); - - return; - } + _proxyUri = new Uri (url); if (username.IsNullOrEmpty ()) { - _logger.Warn ("The proxy credentials are set back to the default."); - _proxyUri = uri; + _logger.Warn ("The credentials for the proxy are initialized."); _proxyCredentials = null; return; } - if (username.Contains (':') || !username.IsText ()) { - _logger.Error ("'username' contains an invalid character."); - error ("An error has occurred in setting the proxy.", null); - - return; - } - - if (!password.IsNullOrEmpty () && !password.IsText ()) { - _logger.Error ("'password' contains an invalid character."); - error ("An error has occurred in setting the proxy.", null); - - return; - } - - _proxyUri = uri; _proxyCredentials = new NetworkCredential ( username, password, String.Format ("{0}:{1}", _uri.DnsSafeHost, _uri.Port) From b7ede52a9d6abd0a9d69da0958746eeeec63aa82 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 18 Aug 2016 17:13:34 +0900 Subject: [PATCH 0590/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 96cefb574..c5991f536 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2921,14 +2921,28 @@ public void SetCredentials (string username, string password, bool preAuth) /// the proxy server authentication (Basic/Digest). /// /// - /// A that represents the proxy server URL to connect through. + /// + /// A that represents the proxy server URL to connect through. + /// + /// + /// If is or empty, + /// the url and credentials for the proxy will be initialized, + /// and the will not use the proxy to + /// connect through. + /// /// /// - /// A that represents the user name used to authenticate. + /// + /// A that represents the user name used to authenticate. + /// + /// + /// If is or empty, + /// the credentials for the proxy will be initialized and not be sent. + /// /// /// - /// A that represents the password for - /// used to authenticate. + /// A that represents the password for + /// used to authenticate. /// public void SetProxy (string url, string username, string password) { From 94fdbc479af81398a9460596a98d1efeb127594e Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 19 Aug 2016 18:11:13 +0900 Subject: [PATCH 0591/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index c5991f536..6c4cb5137 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2916,13 +2916,14 @@ public void SetCredentials (string username, string password, bool preAuth) } /// - /// Sets an HTTP proxy server URL to connect through, and if necessary, + /// Sets the HTTP proxy server URL to connect through, and if necessary, /// a pair of and for /// the proxy server authentication (Basic/Digest). /// /// /// - /// A that represents the proxy server URL to connect through. + /// A that represents the HTTP proxy server URL to + /// connect through. /// /// /// If is or empty, From d355fa7f8df4e9d8c337254d51473aa8cd9b94e6 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 20 Aug 2016 18:08:58 +0900 Subject: [PATCH 0592/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 6c4cb5137..00013349b 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -880,7 +880,7 @@ private static bool checkParametersForSetProxy ( || uri.Scheme != "http" || uri.Segments.Length > 1 ) { - message = "The syntax of a proxy url must be 'http://[:]'."; + message = "The syntax of 'url' must be 'http://[:]'."; return false; } From ee7485fbc5d13565dc2e619b28ebbb13538ab82c Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 21 Aug 2016 18:11:03 +0900 Subject: [PATCH 0593/6294] [Modify] Add it --- websocket-sharp/WebSocket.cs | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 00013349b..179fcc20c 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1948,6 +1948,40 @@ internal static string CheckCloseParameters (CloseStatusCode code, string reason : null; } + internal static bool CheckParametersForClose ( + ushort code, string reason, bool client, out string message + ) + { + message = null; + + if (!code.IsCloseStatusCode ()) { + message = "'code' is an invalid close status code."; + return false; + } + + if (code == (ushort) CloseStatusCode.NoStatus && !reason.IsNullOrEmpty ()) { + message = "'code' cannot have a reason."; + return false; + } + + if (code == (ushort) CloseStatusCode.MandatoryExtension && !client) { + message = "'code' cannot be used by a server."; + return false; + } + + if (code == (ushort) CloseStatusCode.ServerError && client) { + message = "'code' cannot be used by a client."; + return false; + } + + if (!reason.IsNullOrEmpty () && reason.UTF8Encode ().Length > 123) { + message = "'reason' has greater than the allowable max size."; + return false; + } + + return true; + } + internal static string CheckPingParameter (string message, out byte[] bytes) { bytes = message.UTF8Encode (); From 65f51fa1ed39b3ad52dbd57019a12f505a446f77 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 22 Aug 2016 16:18:45 +0900 Subject: [PATCH 0594/6294] [Modify] Replace it --- websocket-sharp/WebSocket.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 179fcc20c..0e0f6ded9 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2255,10 +2255,15 @@ public void Close () /// public void Close (ushort code) { - var msg = _readyState.CheckIfAvailable (true, true, false, false) ?? - CheckCloseParameters (code, null, _client); + string msg; + if (!checkIfAvailable (true, true, false, false, out msg)) { + _logger.Error (msg); + error ("An error has occurred in closing the connection.", null); - if (msg != null) { + return; + } + + if (!CheckParametersForClose (code, null, _client, out msg)) { _logger.Error (msg); error ("An error has occurred in closing the connection.", null); From eab8746d39e4474465dc5237fd8cf5429f55a754 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 22 Aug 2016 16:32:11 +0900 Subject: [PATCH 0595/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 0e0f6ded9..ebb4ffe45 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2243,15 +2243,12 @@ public void Close () } /// - /// Closes the WebSocket connection with the specified , + /// Closes the WebSocket connection with the specified , /// and releases all associated resources. /// - /// - /// This method emits a event if isn't in - /// the allowable range of the close status code. - /// /// - /// A that represents the status code indicating the reason for the close. + /// A that represents the status code indicating + /// the reason for the close. /// public void Close (ushort code) { From 97742b066704d5f3a8bb7931154e71e1f5bb3f52 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 23 Aug 2016 15:35:37 +0900 Subject: [PATCH 0596/6294] [Modify] Replace it --- websocket-sharp/WebSocket.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index ebb4ffe45..d9d60858c 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2322,10 +2322,15 @@ public void Close (CloseStatusCode code) /// public void Close (ushort code, string reason) { - var msg = _readyState.CheckIfAvailable (true, true, false, false) ?? - CheckCloseParameters (code, reason, _client); + string msg; + if (!checkIfAvailable (true, true, false, false, out msg)) { + _logger.Error (msg); + error ("An error has occurred in closing the connection.", null); - if (msg != null) { + return; + } + + if (!CheckParametersForClose (code, reason, _client, out msg)) { _logger.Error (msg); error ("An error has occurred in closing the connection.", null); From 80db30d1c55f9b021921c0a6cbc159ff11e9811e Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 23 Aug 2016 16:26:31 +0900 Subject: [PATCH 0597/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index d9d60858c..4f404dc02 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2306,19 +2306,16 @@ public void Close (CloseStatusCode code) } /// - /// Closes the WebSocket connection with the specified and - /// , and releases all associated resources. + /// Closes the WebSocket connection with the specified and + /// , and releases all associated resources. /// - /// - /// This method emits a event if isn't in - /// the allowable range of the close status code or the size of is - /// greater than 123 bytes. - /// /// - /// A that represents the status code indicating the reason for the close. + /// A that represents the status code indicating + /// the reason for the close. /// /// /// A that represents the reason for the close. + /// The size must be 123 bytes or less. /// public void Close (ushort code, string reason) { From 869dfb09778de51081b0ae64bd2c3217cffe0699 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 24 Aug 2016 15:33:59 +0900 Subject: [PATCH 0598/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 4f404dc02..4f4036b5e 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1955,7 +1955,7 @@ internal static bool CheckParametersForClose ( message = null; if (!code.IsCloseStatusCode ()) { - message = "'code' is an invalid close status code."; + message = "'code' is an invalid status code."; return false; } @@ -1975,7 +1975,7 @@ internal static bool CheckParametersForClose ( } if (!reason.IsNullOrEmpty () && reason.UTF8Encode ().Length > 123) { - message = "'reason' has greater than the allowable max size."; + message = "The size of 'reason' is greater than the allowable max size."; return false; } From 95d9b745c64c5c751d0c6fd19ba8f4def656c1f8 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 25 Aug 2016 17:01:46 +0900 Subject: [PATCH 0599/6294] [Modify] Add it --- websocket-sharp/WebSocket.cs | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 4f4036b5e..914561dc9 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1982,6 +1982,35 @@ internal static bool CheckParametersForClose ( return true; } + internal static bool CheckParametersForClose ( + CloseStatusCode code, string reason, bool client, out string message + ) + { + message = null; + + if (code == CloseStatusCode.NoStatus && !reason.IsNullOrEmpty ()) { + message = "'code' cannot have a reason."; + return false; + } + + if (code == CloseStatusCode.MandatoryExtension && !client) { + message = "'code' cannot be used by a server."; + return false; + } + + if (code == CloseStatusCode.ServerError && client) { + message = "'code' cannot be used by a client."; + return false; + } + + if (!reason.IsNullOrEmpty () && reason.UTF8Encode ().Length > 123) { + message = "The size of 'reason' is greater than the allowable max size."; + return false; + } + + return true; + } + internal static string CheckPingParameter (string message, out byte[] bytes) { bytes = message.UTF8Encode (); From 4e4d0c5be9ae65c1a6919a60c913d739dac1e7f7 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 25 Aug 2016 17:07:36 +0900 Subject: [PATCH 0600/6294] [Modify] Replace it --- websocket-sharp/WebSocket.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 914561dc9..18ad6efc0 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2315,10 +2315,15 @@ public void Close (ushort code) /// public void Close (CloseStatusCode code) { - var msg = _readyState.CheckIfAvailable (true, true, false, false) ?? - CheckCloseParameters (code, null, _client); + string msg; + if (!checkIfAvailable (true, true, false, false, out msg)) { + _logger.Error (msg); + error ("An error has occurred in closing the connection.", null); - if (msg != null) { + return; + } + + if (!CheckParametersForClose (code, null, _client, out msg)) { _logger.Error (msg); error ("An error has occurred in closing the connection.", null); From 30b7e6937fcb0fc462054dea812d2108506b9081 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 25 Aug 2016 17:22:36 +0900 Subject: [PATCH 0601/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 18ad6efc0..7df01a7b9 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2306,12 +2306,12 @@ public void Close (ushort code) } /// - /// Closes the WebSocket connection with the specified , + /// Closes the WebSocket connection with the specified , /// and releases all associated resources. /// /// - /// One of the enum values, represents the status code indicating - /// the reason for the close. + /// One of the enum values that represents + /// the status code indicating the reason for the close. /// public void Close (CloseStatusCode code) { From 63e0b2ca8c5223f168cbcdc6ebb5540a20f7816f Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 26 Aug 2016 16:38:51 +0900 Subject: [PATCH 0602/6294] [Modify] Replace it --- websocket-sharp/WebSocket.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 7df01a7b9..55b6ce0e0 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2394,10 +2394,15 @@ public void Close (ushort code, string reason) /// public void Close (CloseStatusCode code, string reason) { - var msg = _readyState.CheckIfAvailable (true, true, false, false) ?? - CheckCloseParameters (code, reason, _client); + string msg; + if (!checkIfAvailable (true, true, false, false, out msg)) { + _logger.Error (msg); + error ("An error has occurred in closing the connection.", null); - if (msg != null) { + return; + } + + if (!CheckParametersForClose (code, reason, _client, out msg)) { _logger.Error (msg); error ("An error has occurred in closing the connection.", null); From 1bcffbb1bdb873febaed220a2772379c8cfa2d4e Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 26 Aug 2016 16:46:42 +0900 Subject: [PATCH 0603/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 55b6ce0e0..15dd9e8e7 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2378,19 +2378,16 @@ public void Close (ushort code, string reason) } /// - /// Closes the WebSocket connection with the specified and - /// , and releases all associated resources. + /// Closes the WebSocket connection with the specified and + /// , and releases all associated resources. /// - /// - /// This method emits a event if the size of is - /// greater than 123 bytes. - /// /// - /// One of the enum values, represents the status code indicating - /// the reason for the close. + /// One of the enum values that represents + /// the status code indicating the reason for the close. /// /// /// A that represents the reason for the close. + /// The size must be 123 bytes or less. /// public void Close (CloseStatusCode code, string reason) { From dea817b95035f2489ff5b82489a13e3446da68b9 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 27 Aug 2016 16:19:53 +0900 Subject: [PATCH 0604/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 15dd9e8e7..8c4ea218c 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2997,7 +2997,7 @@ public void SetCredentials (string username, string password, bool preAuth) /// /// /// A that represents the HTTP proxy server URL to - /// connect through. + /// connect through. The syntax must be http://<host>[:<port>]. /// /// /// If is or empty, From 9a5a28403f9b4f89337a3229725b3d99ec6626b7 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 27 Aug 2016 16:24:52 +0900 Subject: [PATCH 0605/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 8c4ea218c..0ae6dafaa 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -880,7 +880,7 @@ private static bool checkParametersForSetProxy ( || uri.Scheme != "http" || uri.Segments.Length > 1 ) { - message = "The syntax of 'url' must be 'http://[:]'."; + message = "'url' is an invalid URL."; return false; } From 4dc757dc5cec7861f080b055d6e2c92d15071535 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 28 Aug 2016 16:10:52 +0900 Subject: [PATCH 0606/6294] [Modify] Replace it --- websocket-sharp/WebSocket.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 0ae6dafaa..200ab5fce 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2452,10 +2452,15 @@ public void CloseAsync () /// public void CloseAsync (ushort code) { - var msg = _readyState.CheckIfAvailable (true, true, false, false) ?? - CheckCloseParameters (code, null, _client); + string msg; + if (!checkIfAvailable (true, true, false, false, out msg)) { + _logger.Error (msg); + error ("An error has occurred in closing the connection.", null); - if (msg != null) { + return; + } + + if (!CheckParametersForClose (code, null, _client, out msg)) { _logger.Error (msg); error ("An error has occurred in closing the connection.", null); From 69a1843d894c28a9ed20f3e7175e57efcc248fa5 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 28 Aug 2016 16:22:03 +0900 Subject: [PATCH 0607/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 200ab5fce..ec7887e96 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2435,20 +2435,15 @@ public void CloseAsync () } /// - /// Closes the WebSocket connection asynchronously with the specified , - /// and releases all associated resources. + /// Closes the WebSocket connection asynchronously with the specified + /// , and releases all associated resources. /// /// - /// - /// This method doesn't wait for the close to be complete. - /// - /// - /// This method emits a event if isn't in - /// the allowable range of the close status code. - /// + /// This method does not wait for the close to be complete. /// /// - /// A that represents the status code indicating the reason for the close. + /// A that represents the status code indicating + /// the reason for the close. /// public void CloseAsync (ushort code) { From 7d9501f0cc5599f27e56ff189b8e523fec7294a0 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 28 Aug 2016 16:27:12 +0900 Subject: [PATCH 0608/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index ec7887e96..4d0a0b0c4 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2416,10 +2416,11 @@ public void Close (CloseStatusCode code, string reason) } /// - /// Closes the WebSocket connection asynchronously, and releases all associated resources. + /// Closes the WebSocket connection asynchronously, and releases + /// all associated resources. /// /// - /// This method doesn't wait for the close to be complete. + /// This method does not wait for the close to be complete. /// public void CloseAsync () { From 2786d6501b6ae1b708634011a8328597850aa9f0 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 29 Aug 2016 15:51:35 +0900 Subject: [PATCH 0609/6294] [Modify] Replace it --- websocket-sharp/WebSocket.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 4d0a0b0c4..11cb0af0b 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2485,10 +2485,15 @@ public void CloseAsync (ushort code) /// public void CloseAsync (CloseStatusCode code) { - var msg = _readyState.CheckIfAvailable (true, true, false, false) ?? - CheckCloseParameters (code, null, _client); + string msg; + if (!checkIfAvailable (true, true, false, false, out msg)) { + _logger.Error (msg); + error ("An error has occurred in closing the connection.", null); - if (msg != null) { + return; + } + + if (!CheckParametersForClose (code, null, _client, out msg)) { _logger.Error (msg); error ("An error has occurred in closing the connection.", null); From 13e19145232bbcbdb467b5d2c81e080f97704970 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 29 Aug 2016 15:58:06 +0900 Subject: [PATCH 0610/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 11cb0af0b..8dd19c240 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2474,14 +2474,14 @@ public void CloseAsync (ushort code) /// /// Closes the WebSocket connection asynchronously with the specified - /// , and releases all associated resources. + /// , and releases all associated resources. /// /// - /// This method doesn't wait for the close to be complete. + /// This method does not wait for the close to be complete. /// /// - /// One of the enum values, represents the status code indicating - /// the reason for the close. + /// One of the enum values that represents + /// the status code indicating the reason for the close. /// public void CloseAsync (CloseStatusCode code) { From e09a8c2f45c49c5835b4f6b13e1268f2a2402b0b Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 30 Aug 2016 14:35:18 +0900 Subject: [PATCH 0611/6294] [Modify] Replace it --- websocket-sharp/WebSocket.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 8dd19c240..409c98da5 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2531,10 +2531,15 @@ public void CloseAsync (CloseStatusCode code) /// public void CloseAsync (ushort code, string reason) { - var msg = _readyState.CheckIfAvailable (true, true, false, false) ?? - CheckCloseParameters (code, reason, _client); + string msg; + if (!checkIfAvailable (true, true, false, false, out msg)) { + _logger.Error (msg); + error ("An error has occurred in closing the connection.", null); - if (msg != null) { + return; + } + + if (!CheckParametersForClose (code, reason, _client, out msg)) { _logger.Error (msg); error ("An error has occurred in closing the connection.", null); From 66221e5d55e639251f41bf6cef3f4ef490560c9c Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 30 Aug 2016 14:50:13 +0900 Subject: [PATCH 0612/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 409c98da5..3cb60c058 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2510,24 +2510,20 @@ public void CloseAsync (CloseStatusCode code) } /// - /// Closes the WebSocket connection asynchronously with the specified and - /// , and releases all associated resources. + /// Closes the WebSocket connection asynchronously with the specified + /// and , and releases + /// all associated resources. /// /// - /// - /// This method doesn't wait for the close to be complete. - /// - /// - /// This method emits a event if isn't in - /// the allowable range of the close status code or the size of is - /// greater than 123 bytes. - /// + /// This method does not wait for the close to be complete. /// /// - /// A that represents the status code indicating the reason for the close. + /// A that represents the status code indicating + /// the reason for the close. /// /// /// A that represents the reason for the close. + /// The size must be 123 bytes or less. /// public void CloseAsync (ushort code, string reason) { From 8c25d2533a8504f7586481fd9978874d10b55b42 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 30 Aug 2016 15:56:07 +0900 Subject: [PATCH 0613/6294] [Modify] Replace it --- websocket-sharp/WebSocket.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 3cb60c058..098111615 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2574,10 +2574,15 @@ public void CloseAsync (ushort code, string reason) /// public void CloseAsync (CloseStatusCode code, string reason) { - var msg = _readyState.CheckIfAvailable (true, true, false, false) ?? - CheckCloseParameters (code, reason, _client); + string msg; + if (!checkIfAvailable (true, true, false, false, out msg)) { + _logger.Error (msg); + error ("An error has occurred in closing the connection.", null); - if (msg != null) { + return; + } + + if (!CheckParametersForClose (code, reason, _client, out msg)) { _logger.Error (msg); error ("An error has occurred in closing the connection.", null); From 675d42346d9428daae71ff6cc9a326684e5aa903 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 31 Aug 2016 16:09:22 +0900 Subject: [PATCH 0614/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 098111615..d972b7790 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2553,24 +2553,19 @@ public void CloseAsync (ushort code, string reason) /// /// Closes the WebSocket connection asynchronously with the specified - /// and , and releases + /// and , and releases /// all associated resources. /// /// - /// - /// This method doesn't wait for the close to be complete. - /// - /// - /// This method emits a event if the size of - /// is greater than 123 bytes. - /// + /// This method does not wait for the close to be complete. /// /// - /// One of the enum values, represents the status code indicating - /// the reason for the close. + /// One of the enum values that represents + /// the status code indicating the reason for the close. /// /// /// A that represents the reason for the close. + /// The size must be 123 bytes or less. /// public void CloseAsync (CloseStatusCode code, string reason) { From eb13c2ff1c77b8905988f8765780afc8a4c256b5 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 31 Aug 2016 16:44:44 +0900 Subject: [PATCH 0615/6294] [Modify] Add it --- websocket-sharp/Server/WebSocketServer.cs | 29 +++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 85fdba268..4e95f9a27 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -558,6 +558,35 @@ private void abort () _state = ServerState.Stop; } + private bool checkIfAvailable ( + bool ready, bool start, bool shutting, bool stop, out string message + ) + { + message = null; + + if (!ready && _state == ServerState.Ready) { + message = "This operation is not available in: ready"; + return false; + } + + if (!start && _state == ServerState.Start) { + message = "This operation is not available in: start"; + return false; + } + + if (!shutting && _state == ServerState.ShuttingDown) { + message = "This operation is not available in: shutting down"; + return false; + } + + if (!stop && _state == ServerState.Stop) { + message = "This operation is not available in: stop"; + return false; + } + + return true; + } + private string checkIfCertificateExists () { return _secure && (_sslConfig == null || _sslConfig.ServerCertificate == null) From 8753ceb72ef459f7fc3410c994736dddb9290254 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 1 Sep 2016 16:09:40 +0900 Subject: [PATCH 0616/6294] [Modify] Replace it --- websocket-sharp/Server/WebSocketServer.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 4e95f9a27..8f516aac5 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -821,9 +821,14 @@ public void Start () /// public void Stop () { + string msg; + if (!checkIfAvailable (false, true, false, false, out msg)) { + _logger.Error (msg); + return; + } + lock (_sync) { - var msg = _state.CheckIfAvailable (false, true, false); - if (msg != null) { + if (!checkIfAvailable (false, true, false, false, out msg)) { _logger.Error (msg); return; } From 030063ccc61ba6d1a380f1dfafb9045ab4d4f0da Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 1 Sep 2016 16:13:11 +0900 Subject: [PATCH 0617/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 8f516aac5..5ac47ada4 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -817,7 +817,7 @@ public void Start () } /// - /// Stops receiving the WebSocket connection requests. + /// Stops receiving the WebSocket handshake requests. /// public void Stop () { From 97c688969631b63e027c994e18e7f326c712114e Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 1 Sep 2016 16:26:50 +0900 Subject: [PATCH 0618/6294] [Modify] Replace it --- websocket-sharp/Server/WebSocketServer.cs | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 5ac47ada4..1b7b59d88 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -854,11 +854,19 @@ public void Stop () /// public void Stop (ushort code, string reason) { - lock (_sync) { - var msg = _state.CheckIfAvailable (false, true, false) ?? - WebSocket.CheckCloseParameters (code, reason, false); + string msg; + if (!checkIfAvailable (false, true, false, false, out msg)) { + _logger.Error (msg); + return; + } - if (msg != null) { + if (!WebSocket.CheckParametersForClose (code, reason, false, out msg)) { + _logger.Error (msg); + return; + } + + lock (_sync) { + if (!checkIfAvailable (false, true, false, false, out msg)) { _logger.Error (msg); return; } @@ -867,6 +875,7 @@ public void Stop (ushort code, string reason) } stopReceiving (5000); + if (code == (ushort) CloseStatusCode.NoStatus) { _services.Stop (new CloseEventArgs (), true, true); } From b348433c9a7c9a1cc0d3ffda101b52702d7c37a5 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 2 Sep 2016 15:43:43 +0900 Subject: [PATCH 0619/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 1b7b59d88..f7443b629 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -843,14 +843,19 @@ public void Stop () } /// - /// Stops receiving the WebSocket connection requests with - /// the specified and . + /// Stops receiving the WebSocket handshake requests, and closes + /// the WebSocket connections with the specified and + /// . /// /// - /// A that represents the status code indicating the reason for the stop. + /// A that represents the status code indicating + /// the reason for the close. The status codes are defined in + /// + /// Section 7.4 of RFC 6455. /// /// - /// A that represents the reason for the stop. + /// A that represents the reason for the close. + /// The size must be 123 bytes or less. /// public void Stop (ushort code, string reason) { From 91f090645aa9bf1f681fe9d71937253a5818cfff Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 2 Sep 2016 15:47:26 +0900 Subject: [PATCH 0620/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index f7443b629..45798a143 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -817,7 +817,8 @@ public void Start () } /// - /// Stops receiving the WebSocket handshake requests. + /// Stops receiving the WebSocket handshake requests, and closes + /// the WebSocket connections. /// public void Stop () { From 3b213b4abbfde3df001895234efc041c3805fe98 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 2 Sep 2016 15:53:46 +0900 Subject: [PATCH 0621/6294] [Modify] Replace it --- websocket-sharp/Server/WebSocketServer.cs | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 45798a143..2aa031779 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -906,11 +906,19 @@ public void Stop (ushort code, string reason) /// public void Stop (CloseStatusCode code, string reason) { - lock (_sync) { - var msg = _state.CheckIfAvailable (false, true, false) ?? - WebSocket.CheckCloseParameters (code, reason, false); + string msg; + if (!checkIfAvailable (false, true, false, false, out msg)) { + _logger.Error (msg); + return; + } - if (msg != null) { + if (!WebSocket.CheckParametersForClose (code, reason, false, out msg)) { + _logger.Error (msg); + return; + } + + lock (_sync) { + if (!checkIfAvailable (false, true, false, false, out msg)) { _logger.Error (msg); return; } @@ -919,6 +927,7 @@ public void Stop (CloseStatusCode code, string reason) } stopReceiving (5000); + if (code == CloseStatusCode.NoStatus) { _services.Stop (new CloseEventArgs (), true, true); } From be5df862e61171c2e364748ee9d42479a3aa3cda Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 2 Sep 2016 16:03:03 +0900 Subject: [PATCH 0622/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 2aa031779..fba17307b 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -894,15 +894,17 @@ public void Stop (ushort code, string reason) } /// - /// Stops receiving the WebSocket connection requests with - /// the specified and . + /// Stops receiving the WebSocket handshake requests, and closes + /// the WebSocket connections with the specified and + /// . /// /// - /// One of the enum values, represents the status code indicating - /// the reason for the stop. + /// One of the enum values that represents + /// the status code indicating the reason for the close. /// /// - /// A that represents the reason for the stop. + /// A that represents the reason for the close. + /// The size must be 123 bytes or less. /// public void Stop (CloseStatusCode code, string reason) { From 5f5053a655ac0e7a0cab58e589d5f72fc787cf48 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 3 Sep 2016 16:29:40 +0900 Subject: [PATCH 0623/6294] [Modify] Add it --- websocket-sharp/Server/HttpServer.cs | 29 ++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index ad5d615c5..e6257f77a 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -615,6 +615,35 @@ private void abort () _state = ServerState.Stop; } + private bool checkIfAvailable ( + bool ready, bool start, bool shutting, bool stop, out string message + ) + { + message = null; + + if (!ready && _state == ServerState.Ready) { + message = "This operation is not available in: ready"; + return false; + } + + if (!start && _state == ServerState.Start) { + message = "This operation is not available in: start"; + return false; + } + + if (!shutting && _state == ServerState.ShuttingDown) { + message = "This operation is not available in: shutting down"; + return false; + } + + if (!stop && _state == ServerState.Stop) { + message = "This operation is not available in: stop"; + return false; + } + + return true; + } + private string checkIfCertificateExists () { if (!_secure) From abee6131cb4d65936604ac80441e0852e74b0254 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 3 Sep 2016 16:37:21 +0900 Subject: [PATCH 0624/6294] [Modify] Replace it --- websocket-sharp/Server/HttpServer.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index e6257f77a..5407e966b 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -955,9 +955,14 @@ public void Start () /// public void Stop () { + string msg; + if (!checkIfAvailable (false, true, false, false, out msg)) { + _logger.Error (msg); + return; + } + lock (_sync) { - var msg = _state.CheckIfAvailable (false, true, false); - if (msg != null) { + if (!checkIfAvailable (false, true, false, false, out msg)) { _logger.Error (msg); return; } From dba7a26540a27e0ce0e2d2b3d2a565782614080d Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 4 Sep 2016 17:42:13 +0900 Subject: [PATCH 0625/6294] [Modify] Edit it --- websocket-sharp/Server/HttpServer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 5407e966b..5c1e56125 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -951,7 +951,7 @@ public void Start () } /// - /// Stops receiving the HTTP requests. + /// Stops receiving the incoming requests, and closes the connections. /// public void Stop () { From 0249f5518e236b476743ea56453cd8f2a8e656b0 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 5 Sep 2016 16:26:29 +0900 Subject: [PATCH 0626/6294] [Modify] Replace it --- websocket-sharp/Server/HttpServer.cs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 5c1e56125..b1c42c2e3 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -988,11 +988,19 @@ public void Stop () /// public void Stop (ushort code, string reason) { - lock (_sync) { - var msg = _state.CheckIfAvailable (false, true, false) ?? - WebSocket.CheckCloseParameters (code, reason, false); + string msg; + if (!checkIfAvailable (false, true, false, false, out msg)) { + _logger.Error (msg); + return; + } - if (msg != null) { + if (!WebSocket.CheckParametersForClose (code, reason, false, out msg)) { + _logger.Error (msg); + return; + } + + lock (_sync) { + if (!checkIfAvailable (false, true, false, false, out msg)) { _logger.Error (msg); return; } From 46ef552ced1b3f546a150cb298312c5f94c896fb Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 6 Sep 2016 15:57:10 +0900 Subject: [PATCH 0627/6294] [Modify] Edit it --- websocket-sharp/Server/HttpServer.cs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index b1c42c2e3..3c614230a 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -977,14 +977,19 @@ public void Stop () } /// - /// Stops receiving the HTTP requests with the specified and - /// used to stop the WebSocket services. + /// Stops receiving the incoming requests, and closes the connections with + /// the specified and for + /// the WebSocket connection close. /// /// - /// A that represents the status code indicating the reason for the stop. + /// A that represents the status code indicating + /// the reason for the WebSocket connection close. The status codes are + /// defined in + /// Section 7.4 of RFC 6455. /// /// - /// A that represents the reason for the stop. + /// A that represents the reason for the WebSocket + /// connection close. The size must be 123 bytes or less. /// public void Stop (ushort code, string reason) { From 4a0ac8ed280eda64d442d8e1c8cdf3b5b20149ff Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 6 Sep 2016 16:01:31 +0900 Subject: [PATCH 0628/6294] [Modify] Remove it --- websocket-sharp/WebSocket.cs | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index d972b7790..c4e803ed6 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1920,21 +1920,6 @@ private bool validateSecWebSocketVersionServerHeader (string value) #region Internal Methods - internal static string CheckCloseParameters (ushort code, string reason, bool client) - { - return !code.IsCloseStatusCode () - ? "An invalid close status code." - : code == (ushort) CloseStatusCode.NoStatus - ? (!reason.IsNullOrEmpty () ? "NoStatus cannot have a reason." : null) - : code == (ushort) CloseStatusCode.MandatoryExtension && !client - ? "MandatoryExtension cannot be used by a server." - : code == (ushort) CloseStatusCode.ServerError && client - ? "ServerError cannot be used by a client." - : !reason.IsNullOrEmpty () && reason.UTF8Encode ().Length > 123 - ? "A reason has greater than the allowable max size." - : null; - } - internal static string CheckCloseParameters (CloseStatusCode code, string reason, bool client) { return code == CloseStatusCode.NoStatus From 443469f641d82cdd2f55af31b67e605ef8af499c Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 7 Sep 2016 15:19:20 +0900 Subject: [PATCH 0629/6294] [Modify] Replace it --- websocket-sharp/Server/HttpServer.cs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 3c614230a..e7f81c7d2 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -1039,11 +1039,19 @@ public void Stop (ushort code, string reason) /// public void Stop (CloseStatusCode code, string reason) { - lock (_sync) { - var msg = _state.CheckIfAvailable (false, true, false) ?? - WebSocket.CheckCloseParameters (code, reason, false); + string msg; + if (!checkIfAvailable (false, true, false, false, out msg)) { + _logger.Error (msg); + return; + } - if (msg != null) { + if (!WebSocket.CheckParametersForClose (code, reason, false, out msg)) { + _logger.Error (msg); + return; + } + + lock (_sync) { + if (!checkIfAvailable (false, true, false, false, out msg)) { _logger.Error (msg); return; } From df4b06472874647a1cb009cecac00d19dbe1c253 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 7 Sep 2016 15:28:27 +0900 Subject: [PATCH 0630/6294] [Modify] Edit it --- websocket-sharp/Server/HttpServer.cs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index e7f81c7d2..d52172cdd 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -1027,15 +1027,17 @@ public void Stop (ushort code, string reason) } /// - /// Stops receiving the HTTP requests with the specified and - /// used to stop the WebSocket services. + /// Stops receiving the incoming requests, and closes the connections with + /// the specified and for + /// the WebSocket connection close. /// /// - /// One of the enum values, represents the status code indicating - /// the reason for the stop. + /// One of the enum values that represents + /// the status code indicating the reason for the WebSocket connection close. /// /// - /// A that represents the reason for the stop. + /// A that represents the reason for the WebSocket + /// connection close. The size must be 123 bytes or less. /// public void Stop (CloseStatusCode code, string reason) { From 901f67430baf5f185c1dcd14fa60eb68af12eb5b Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 7 Sep 2016 15:33:50 +0900 Subject: [PATCH 0631/6294] [Modify] Remove it --- websocket-sharp/WebSocket.cs | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index c4e803ed6..a54f87925 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1920,19 +1920,6 @@ private bool validateSecWebSocketVersionServerHeader (string value) #region Internal Methods - internal static string CheckCloseParameters (CloseStatusCode code, string reason, bool client) - { - return code == CloseStatusCode.NoStatus - ? (!reason.IsNullOrEmpty () ? "NoStatus cannot have a reason." : null) - : code == CloseStatusCode.MandatoryExtension && !client - ? "MandatoryExtension cannot be used by a server." - : code == CloseStatusCode.ServerError && client - ? "ServerError cannot be used by a client." - : !reason.IsNullOrEmpty () && reason.UTF8Encode ().Length > 123 - ? "A reason has greater than the allowable max size." - : null; - } - internal static bool CheckParametersForClose ( ushort code, string reason, bool client, out string message ) From e2f3731516b284427cdffb96ed799e27ef4b7d56 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 8 Sep 2016 16:25:42 +0900 Subject: [PATCH 0632/6294] [Modify] Edit it --- README.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 4906affda..f7e68609e 100644 --- a/README.md +++ b/README.md @@ -103,13 +103,19 @@ The `WebSocket` class exists in the `WebSocketSharp` namespace. Creating a new instance of the `WebSocket` class with the WebSocket URL to connect. +```csharp +var ws = new WebSocket ("ws://example.com"); +``` + +The `WebSocket` class inherits the `System.IDisposable` interface, so you can create it with the `using` statement. + ```csharp using (var ws = new WebSocket ("ws://example.com")) { ... } ``` -The `WebSocket` class inherits the `System.IDisposable` interface, so you can use the `using` statement. And the WebSocket connection will be closed with close status `1001` (going away) when the control leaves the `using` block. +This will **close** the WebSocket connection with status code `1001` (going away) when the control leaves the `using` block. #### Step 3 #### From 8870cf56a1050a4017bde96ad0f77131db935d81 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 9 Sep 2016 16:34:35 +0900 Subject: [PATCH 0633/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index a54f87925..93b39149b 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2249,7 +2249,9 @@ public void Close () /// /// /// A that represents the status code indicating - /// the reason for the close. + /// the reason for the close. The status codes are defined in + /// + /// Section 7.4 of RFC 6455. /// public void Close (ushort code) { From 9b0493cdfac2a3427d0bac75d269e1bcde42bf9a Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 10 Sep 2016 15:56:53 +0900 Subject: [PATCH 0634/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 93b39149b..c4998348f 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2319,7 +2319,9 @@ public void Close (CloseStatusCode code) /// /// /// A that represents the status code indicating - /// the reason for the close. + /// the reason for the close. The status codes are defined in + /// + /// Section 7.4 of RFC 6455. /// /// /// A that represents the reason for the close. From ceadec3c1cf783a573be6595581fd319ede676bf Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 11 Sep 2016 17:14:05 +0900 Subject: [PATCH 0635/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index c4998348f..862e557ee 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2420,7 +2420,9 @@ public void CloseAsync () /// /// /// A that represents the status code indicating - /// the reason for the close. + /// the reason for the close. The status codes are defined in + /// + /// Section 7.4 of RFC 6455. /// public void CloseAsync (ushort code) { From defed84883db664d6a56da50a844e0d374a8ac26 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 12 Sep 2016 16:24:28 +0900 Subject: [PATCH 0636/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 862e557ee..614a7a6d5 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2497,7 +2497,9 @@ public void CloseAsync (CloseStatusCode code) /// /// /// A that represents the status code indicating - /// the reason for the close. + /// the reason for the close. The status codes are defined in + /// + /// Section 7.4 of RFC 6455. /// /// /// A that represents the reason for the close. From c3306c70cb0195b5eeafd32d6bac95aa06b3e596 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 12 Sep 2016 16:34:17 +0900 Subject: [PATCH 0637/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 614a7a6d5..567683de6 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3063,7 +3063,7 @@ public void SetProxy (string url, string username, string password) /// Closes the WebSocket connection, and releases all associated resources. /// /// - /// This method closes the connection with . + /// This method closes the connection with status code 1001 (going away). /// void IDisposable.Dispose () { From f90397e4a8753389f505a01815ec6154caac364e Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 13 Sep 2016 15:11:23 +0900 Subject: [PATCH 0638/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 567683de6..cc95bf7ee 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3067,7 +3067,7 @@ public void SetProxy (string url, string username, string password) /// void IDisposable.Dispose () { - close (new CloseEventArgs (CloseStatusCode.Away), true, true, false); + close (new CloseEventArgs (1001), true, true, false); } #endregion From 454761351ae15c99dcd8e8dc2da002b8dc0ceb09 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 13 Sep 2016 15:15:10 +0900 Subject: [PATCH 0639/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index cc95bf7ee..b6761f9af 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2180,7 +2180,7 @@ internal void Send (Opcode opcode, Stream stream, Dictionary /// - /// This method isn't available in a client. + /// This method is not available in a client. /// public void Accept () { From 4bc28747f5d80046a10eafb9aea4af2d1897d5d5 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 13 Sep 2016 15:21:47 +0900 Subject: [PATCH 0640/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index b6761f9af..6de3831bb 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2201,10 +2201,10 @@ public void Accept () /// /// /// - /// This method doesn't wait for the accept to be complete. + /// This method does not wait for the accept to be complete. /// /// - /// This method isn't available in a client. + /// This method is not available in a client. /// /// public void AcceptAsync () From 021d23ed0fa59e4b23aa058a6164b6fbb9daa26a Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 13 Sep 2016 15:23:56 +0900 Subject: [PATCH 0641/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 6de3831bb..01bef55f6 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2577,7 +2577,7 @@ public void CloseAsync (CloseStatusCode code, string reason) /// Establishes a WebSocket connection. /// /// - /// This method isn't available in a server. + /// This method is not available in a server. /// public void Connect () { From 7f87e8dfb548a526ee5e9d04c602b03b43b23ce7 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 13 Sep 2016 15:32:49 +0900 Subject: [PATCH 0642/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 01bef55f6..7c316be90 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2598,10 +2598,10 @@ public void Connect () /// /// /// - /// This method doesn't wait for the connect to be complete. + /// This method does not wait for the connect to be complete. /// /// - /// This method isn't available in a server. + /// This method is not available in a server. /// /// public void ConnectAsync () From 68a46b073bf2a304d9ad2eaf1b768bd40990b9c5 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 14 Sep 2016 15:24:21 +0900 Subject: [PATCH 0643/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 7c316be90..7ff94000c 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -794,22 +794,22 @@ private bool checkIfAvailable ( message = null; if (!connecting && _readyState == WebSocketState.Connecting) { - message = "This operation isn't available in: connecting"; + message = "This operation is not available in: connecting"; return false; } if (!open && _readyState == WebSocketState.Open) { - message = "This operation isn't available in: open"; + message = "This operation is not available in: open"; return false; } if (!closing && _readyState == WebSocketState.Closing) { - message = "This operation isn't available in: closing"; + message = "This operation is not available in: closing"; return false; } if (!closed && _readyState == WebSocketState.Closed) { - message = "This operation isn't available in: closed"; + message = "This operation is not available in: closed"; return false; } From 536fb2faaa7ab528dace5c06ffb77fe5e98a9f04 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 14 Sep 2016 15:27:12 +0900 Subject: [PATCH 0644/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 7ff94000c..e97cd1989 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -829,12 +829,12 @@ out string message message = null; if (!client && _client) { - message = "This operation isn't available in: client"; + message = "This operation is not available in: client"; return false; } if (!server && !_client) { - message = "This operation isn't available in: server"; + message = "This operation is not available in: server"; return false; } From e41048bcdce46c997dbb272662a304b298334fe0 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 14 Sep 2016 15:29:16 +0900 Subject: [PATCH 0645/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index e97cd1989..7393c1654 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -914,7 +914,7 @@ private bool checkReceivedFrame (WebSocketFrame frame, out string message) } if (!_client && !masked) { - message = "A frame from a client isn't masked."; + message = "A frame from a client is not masked."; return false; } From 425a7a8b09b2d031acd7f94264e6552ec44543d5 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 15 Sep 2016 14:36:25 +0900 Subject: [PATCH 0646/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 7393c1654..b40e93ffb 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2883,6 +2883,9 @@ public void SendAsync (Stream stream, int length, Action completed) /// Sets an HTTP to send with /// the WebSocket handshake request to the server. /// + /// + /// This method is not available in a server. + /// /// /// A that represents a cookie to send. /// From abb678953fa80f6f5f3cc1eea92f59b58eaf3da4 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 15 Sep 2016 14:39:26 +0900 Subject: [PATCH 0647/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index b40e93ffb..37689fdad 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2923,6 +2923,9 @@ public void SetCookie (Cookie cookie) /// Sets a pair of and for /// the HTTP authentication (Basic/Digest). /// + /// + /// This method is not available in a server. + /// /// /// /// A that represents the user name used to authenticate. From cc8fc3e4a9933e70117fe673d18d2b13c9ae4da0 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 15 Sep 2016 14:41:58 +0900 Subject: [PATCH 0648/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 37689fdad..a348ab0ce 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2987,6 +2987,9 @@ public void SetCredentials (string username, string password, bool preAuth) /// a pair of and for /// the proxy server authentication (Basic/Digest). /// + /// + /// This method is not available in a server. + /// /// /// /// A that represents the HTTP proxy server URL to From 18e29b9f939c13aaaa6008268056dc5f6d9db4ab Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 16 Sep 2016 15:03:11 +0900 Subject: [PATCH 0649/6294] [Modify] Add it --- websocket-sharp/WebSocket.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index a348ab0ce..d56b3843d 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -941,6 +941,17 @@ private bool checkReceivedFrame (WebSocketFrame frame, out string message) return true; } + private void close (ushort code, string reason) + { + if (code == 1005) { // == no status + close (new CloseEventArgs (), true, true, false); + return; + } + + var send = !code.IsReserved (); + close (new CloseEventArgs (code, reason), send, send, false); + } + private void close (CloseEventArgs e, bool send, bool receive, bool received) { lock (_forState) { From ce12c9ba5c5c3f3e991cbfbc5a27398fe2d82905 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 16 Sep 2016 15:08:23 +0900 Subject: [PATCH 0650/6294] [Modify] Replace it --- websocket-sharp/WebSocket.cs | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index d56b3843d..8908006dc 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2355,13 +2355,7 @@ public void Close (ushort code, string reason) return; } - if (code == (ushort) CloseStatusCode.NoStatus) { - close (new CloseEventArgs (), true, true, false); - return; - } - - var send = !code.IsReserved (); - close (new CloseEventArgs (code, reason), send, send, false); + close (code, reason); } /// From 8e1638231f97aeee1ef161666e84499fb615a206 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 16 Sep 2016 15:16:16 +0900 Subject: [PATCH 0651/6294] [Modify] Replace it --- websocket-sharp/WebSocket.cs | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 8908006dc..d935dbff3 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2281,13 +2281,7 @@ public void Close (ushort code) return; } - if (code == (ushort) CloseStatusCode.NoStatus) { - close (new CloseEventArgs (), true, true, false); - return; - } - - var send = !code.IsReserved (); - close (new CloseEventArgs (code), send, send, false); + close (code, null); } /// From a69e766ad382f2e9eee8b5c6d1a6ffa14e544769 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 17 Sep 2016 15:59:40 +0900 Subject: [PATCH 0652/6294] [Modify] Replace it --- websocket-sharp/WebSocket.cs | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index d935dbff3..de4655280 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2381,13 +2381,7 @@ public void Close (CloseStatusCode code, string reason) return; } - if (code == CloseStatusCode.NoStatus) { - close (new CloseEventArgs (), true, true, false); - return; - } - - var send = !code.IsReserved (); - close (new CloseEventArgs (code, reason), send, send, false); + close ((ushort) code, reason); } /// From dbfc84453f27d425e57155db9f6afd9cd496c0d9 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 17 Sep 2016 16:02:56 +0900 Subject: [PATCH 0653/6294] [Modify] Replace it --- websocket-sharp/WebSocket.cs | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index de4655280..c29d72a65 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2309,13 +2309,7 @@ public void Close (CloseStatusCode code) return; } - if (code == CloseStatusCode.NoStatus) { - close (new CloseEventArgs (), true, true, false); - return; - } - - var send = !code.IsReserved (); - close (new CloseEventArgs (code), send, send, false); + close ((ushort) code, null); } /// From 1512e15c0a3c34e645c80bd2403a83284992a14d Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 18 Sep 2016 15:23:05 +0900 Subject: [PATCH 0654/6294] [Modify] Add it --- websocket-sharp/WebSocket.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index c29d72a65..27960185f 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -989,6 +989,17 @@ private void close (CloseEventArgs e, bool send, bool receive, bool received) } } + private void closeAsync (ushort code, string reason) + { + if (code == 1005) { // == no status + closeAsync (new CloseEventArgs (), true, true, false); + return; + } + + var send = !code.IsReserved (); + closeAsync (new CloseEventArgs (code, reason), send, send, false); + } + private void closeAsync (CloseEventArgs e, bool send, bool receive, bool received) { Action closer = close; From 38d88e0ff85dea61c64e1d577156855feeb32117 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 18 Sep 2016 15:27:33 +0900 Subject: [PATCH 0655/6294] [Modify] Replace it --- websocket-sharp/WebSocket.cs | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 27960185f..9172c9891 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2520,13 +2520,7 @@ public void CloseAsync (ushort code, string reason) return; } - if (code == (ushort) CloseStatusCode.NoStatus) { - closeAsync (new CloseEventArgs (), true, true, false); - return; - } - - var send = !code.IsReserved (); - closeAsync (new CloseEventArgs (code, reason), send, send, false); + closeAsync (code, reason); } /// From 0ac294aff105978727204a4ffca65de904a2161a Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 18 Sep 2016 15:33:50 +0900 Subject: [PATCH 0656/6294] [Modify] Replace it --- websocket-sharp/WebSocket.cs | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 9172c9891..555d69f54 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2439,13 +2439,7 @@ public void CloseAsync (ushort code) return; } - if (code == (ushort) CloseStatusCode.NoStatus) { - closeAsync (new CloseEventArgs (), true, true, false); - return; - } - - var send = !code.IsReserved (); - closeAsync (new CloseEventArgs (code), send, send, false); + closeAsync (code, null); } /// From f895d249a23c7ab5b3ded55c1e74da0dda8b076c Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 19 Sep 2016 15:03:46 +0900 Subject: [PATCH 0657/6294] [Modify] Replace it --- websocket-sharp/WebSocket.cs | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 555d69f54..66571e985 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2550,13 +2550,7 @@ public void CloseAsync (CloseStatusCode code, string reason) return; } - if (code == CloseStatusCode.NoStatus) { - closeAsync (new CloseEventArgs (), true, true, false); - return; - } - - var send = !code.IsReserved (); - closeAsync (new CloseEventArgs (code, reason), send, send, false); + closeAsync ((ushort) code, reason); } /// From 80b969cc5486901cbf22ad1783ada9752b45ad18 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 19 Sep 2016 15:08:22 +0900 Subject: [PATCH 0658/6294] [Modify] Replace it --- websocket-sharp/WebSocket.cs | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 66571e985..6347478ef 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2470,13 +2470,7 @@ public void CloseAsync (CloseStatusCode code) return; } - if (code == CloseStatusCode.NoStatus) { - closeAsync (new CloseEventArgs (), true, true, false); - return; - } - - var send = !code.IsReserved (); - closeAsync (new CloseEventArgs (code), send, send, false); + closeAsync ((ushort) code, null); } /// From a7c2bad146f1ab57c9b454ad2fc05576efc4a202 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 20 Sep 2016 15:07:58 +0900 Subject: [PATCH 0659/6294] [Modify] Add getters for code and reason --- websocket-sharp/PayloadData.cs | 48 ++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/websocket-sharp/PayloadData.cs b/websocket-sharp/PayloadData.cs index 6bbf6905d..734dbd709 100644 --- a/websocket-sharp/PayloadData.cs +++ b/websocket-sharp/PayloadData.cs @@ -36,9 +36,13 @@ internal class PayloadData : IEnumerable { #region Private Fields + private ushort _code; + private bool _codeSet; private byte[] _data; private long _extDataLength; private long _length; + private string _reason; + private bool _reasonSet; #endregion @@ -80,7 +84,11 @@ static PayloadData () internal PayloadData () { + _code = 1005; _data = WebSocket.EmptyBytes; + + _codeSet = true; + _reasonSet = true; } internal PayloadData (byte[] data) @@ -94,10 +102,36 @@ internal PayloadData (byte[] data, long length) _length = length; } + internal PayloadData (ushort code, string reason) + { + _code = code; + _reason = reason; + + _data = code.Append (reason); + _length = _data.LongLength; + + _codeSet = true; + _reasonSet = true; + } + #endregion #region Internal Properties + internal ushort Code { + get { + if (!_codeSet) { + _code = _length > 1 + ? _data.SubArray (0, 2).ToUInt16 (ByteOrder.Big) + : (ushort) 1005; + + _codeSet = true; + } + + return _code; + } + } + internal long ExtensionDataLength { get { return _extDataLength; @@ -114,6 +148,20 @@ internal bool IncludesReservedCloseStatusCode { } } + internal string Reason { + get { + if (!_reasonSet) { + _reason = _length > 2 + ? _data.SubArray (2, _length - 2).UTF8Decode () + : null; + + _reasonSet = true; + } + + return _reason; + } + } + #endregion #region Public Properties From a49a98bd2e9a10f98ba4f212cb409f416dec57f4 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 20 Sep 2016 15:11:51 +0900 Subject: [PATCH 0660/6294] [Modify] Polish it --- websocket-sharp/PayloadData.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/PayloadData.cs b/websocket-sharp/PayloadData.cs index 734dbd709..388be8097 100644 --- a/websocket-sharp/PayloadData.cs +++ b/websocket-sharp/PayloadData.cs @@ -144,7 +144,7 @@ internal long ExtensionDataLength { internal bool IncludesReservedCloseStatusCode { get { - return _length > 1 && _data.SubArray (0, 2).ToUInt16 (ByteOrder.Big).IsReserved (); + return _length > 1 && Code.IsReserved (); } } From adc38a3125a88c6fd5a65d2a90cd029bf2f5b799 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 20 Sep 2016 15:24:18 +0900 Subject: [PATCH 0661/6294] [Modify] Rename it --- websocket-sharp/PayloadData.cs | 2 +- websocket-sharp/WebSocket.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/PayloadData.cs b/websocket-sharp/PayloadData.cs index 388be8097..801600e5d 100644 --- a/websocket-sharp/PayloadData.cs +++ b/websocket-sharp/PayloadData.cs @@ -142,7 +142,7 @@ internal long ExtensionDataLength { } } - internal bool IncludesReservedCloseStatusCode { + internal bool HasReservedCode { get { return _length > 1 && Code.IsReserved (); } diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 6347478ef..602ddb9de 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1305,7 +1305,7 @@ private void open () private bool processCloseFrame (WebSocketFrame frame) { var payload = frame.PayloadData; - close (new CloseEventArgs (payload), !payload.IncludesReservedCloseStatusCode, false, true); + close (new CloseEventArgs (payload), !payload.HasReservedCode, false, true); return false; } From f001f75ec58000004782da39051231952423bc50 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 21 Sep 2016 17:08:00 +0900 Subject: [PATCH 0662/6294] [Modify] Set String.Empty --- websocket-sharp/PayloadData.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/PayloadData.cs b/websocket-sharp/PayloadData.cs index 801600e5d..12b8a8f4e 100644 --- a/websocket-sharp/PayloadData.cs +++ b/websocket-sharp/PayloadData.cs @@ -85,6 +85,8 @@ static PayloadData () internal PayloadData () { _code = 1005; + _reason = String.Empty; + _data = WebSocket.EmptyBytes; _codeSet = true; @@ -105,7 +107,7 @@ internal PayloadData (byte[] data, long length) internal PayloadData (ushort code, string reason) { _code = code; - _reason = reason; + _reason = reason ?? String.Empty; _data = code.Append (reason); _length = _data.LongLength; @@ -153,7 +155,7 @@ internal string Reason { if (!_reasonSet) { _reason = _length > 2 ? _data.SubArray (2, _length - 2).UTF8Decode () - : null; + : String.Empty; _reasonSet = true; } From 36fd0bbd5574c63e71dc49d2237913bab1285c1c Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 22 Sep 2016 15:14:45 +0900 Subject: [PATCH 0663/6294] [Modify] 2016 --- websocket-sharp/PayloadData.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/PayloadData.cs b/websocket-sharp/PayloadData.cs index 12b8a8f4e..4e629d88c 100644 --- a/websocket-sharp/PayloadData.cs +++ b/websocket-sharp/PayloadData.cs @@ -4,7 +4,7 @@ * * The MIT License * - * Copyright (c) 2012-2015 sta.blockhead + * Copyright (c) 2012-2016 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From 2509ea5b26e3b7194a50070cd938b3d74f2cf44e Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 22 Sep 2016 15:38:49 +0900 Subject: [PATCH 0664/6294] [Modify] Polish it --- websocket-sharp/CloseEventArgs.cs | 26 ++++++-------------------- 1 file changed, 6 insertions(+), 20 deletions(-) diff --git a/websocket-sharp/CloseEventArgs.cs b/websocket-sharp/CloseEventArgs.cs index e1cd18420..1ef67b79a 100644 --- a/websocket-sharp/CloseEventArgs.cs +++ b/websocket-sharp/CloseEventArgs.cs @@ -48,9 +48,7 @@ public class CloseEventArgs : EventArgs #region Private Fields private bool _clean; - private ushort _code; private PayloadData _payloadData; - private string _reason; #endregion @@ -58,39 +56,27 @@ public class CloseEventArgs : EventArgs internal CloseEventArgs () { - _code = (ushort) CloseStatusCode.NoStatus; _payloadData = PayloadData.Empty; } internal CloseEventArgs (ushort code) + : this (code, null) { - _code = code; } internal CloseEventArgs (CloseStatusCode code) - : this ((ushort) code) + : this ((ushort) code, null) { } internal CloseEventArgs (PayloadData payloadData) { _payloadData = payloadData; - - var data = payloadData.ApplicationData; - var len = data.Length; - _code = len > 1 - ? data.SubArray (0, 2).ToUInt16 (ByteOrder.Big) - : (ushort) CloseStatusCode.NoStatus; - - _reason = len > 2 - ? data.SubArray (2, len - 2).UTF8Decode () - : String.Empty; } internal CloseEventArgs (ushort code, string reason) { - _code = code; - _reason = reason; + _payloadData = new PayloadData (code, reason); } internal CloseEventArgs (CloseStatusCode code, string reason) @@ -104,7 +90,7 @@ internal CloseEventArgs (CloseStatusCode code, string reason) internal PayloadData PayloadData { get { - return _payloadData ?? (_payloadData = new PayloadData (_code.Append (_reason))); + return _payloadData; } } @@ -120,7 +106,7 @@ internal PayloadData PayloadData { /// public ushort Code { get { - return _code; + return _payloadData.Code; } } @@ -132,7 +118,7 @@ public ushort Code { /// public string Reason { get { - return _reason ?? String.Empty; + return _payloadData.Reason ?? String.Empty; } } From a3f7ea0148827d6899ca5a06bc3bce10be67ab5f Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 23 Sep 2016 15:23:34 +0900 Subject: [PATCH 0665/6294] [Modify] Edit it --- websocket-sharp/CloseEventArgs.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/websocket-sharp/CloseEventArgs.cs b/websocket-sharp/CloseEventArgs.cs index 1ef67b79a..f402f7f94 100644 --- a/websocket-sharp/CloseEventArgs.cs +++ b/websocket-sharp/CloseEventArgs.cs @@ -35,8 +35,7 @@ namespace WebSocketSharp /// /// /// - /// A event occurs when the WebSocket connection - /// has been closed. + /// That event occurs when the WebSocket connection has been closed. /// /// /// If you would like to get the reason for the close, you should access From ee7750ec8b615cf30021c0c1fe57af3c6e203bbf Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 23 Sep 2016 15:24:47 +0900 Subject: [PATCH 0666/6294] [Modify] 2016 --- websocket-sharp/CloseEventArgs.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/CloseEventArgs.cs b/websocket-sharp/CloseEventArgs.cs index f402f7f94..c665ccde9 100644 --- a/websocket-sharp/CloseEventArgs.cs +++ b/websocket-sharp/CloseEventArgs.cs @@ -4,7 +4,7 @@ * * The MIT License * - * Copyright (c) 2012-2015 sta.blockhead + * Copyright (c) 2012-2016 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From 6009876182fb1c3fc96573829ac8a3d80ae45671 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 23 Sep 2016 16:04:57 +0900 Subject: [PATCH 0667/6294] [Modify] Edit it --- websocket-sharp/ErrorEventArgs.cs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/ErrorEventArgs.cs b/websocket-sharp/ErrorEventArgs.cs index a4c0b85e9..f64d6926f 100644 --- a/websocket-sharp/ErrorEventArgs.cs +++ b/websocket-sharp/ErrorEventArgs.cs @@ -42,15 +42,14 @@ namespace WebSocketSharp /// /// /// - /// A event occurs when the gets - /// an error. + /// That event occurs when the gets an error. /// /// /// If you would like to get the error message, you should access /// the property. /// /// - /// And if the error is due to an exception, you can get the exception by accessing + /// And if the error is due to an exception, you can get it by accessing /// the property. /// /// @@ -84,8 +83,8 @@ internal ErrorEventArgs (string message, Exception exception) /// Gets the exception that caused the error. /// /// - /// An instance that represents the cause of the error, - /// or if the error isn't due to an exception. + /// An instance that represents the cause of + /// the error, or if it is not due to an exception. /// public Exception Exception { get { From 5366e8be765929af864825f70d42e3fd2fc45e77 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 23 Sep 2016 16:05:46 +0900 Subject: [PATCH 0668/6294] [Modify] 2016 --- websocket-sharp/ErrorEventArgs.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/ErrorEventArgs.cs b/websocket-sharp/ErrorEventArgs.cs index f64d6926f..c8b6bd89e 100644 --- a/websocket-sharp/ErrorEventArgs.cs +++ b/websocket-sharp/ErrorEventArgs.cs @@ -4,7 +4,7 @@ * * The MIT License * - * Copyright (c) 2012-2015 sta.blockhead + * Copyright (c) 2012-2016 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From 55a65e313fa364fa141537d2df0a8bbd7f65b87b Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 24 Sep 2016 18:54:05 +0900 Subject: [PATCH 0669/6294] [Modify] Edit it --- websocket-sharp/MessageEventArgs.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/MessageEventArgs.cs b/websocket-sharp/MessageEventArgs.cs index 0639baf39..b30b4d91b 100644 --- a/websocket-sharp/MessageEventArgs.cs +++ b/websocket-sharp/MessageEventArgs.cs @@ -35,13 +35,13 @@ namespace WebSocketSharp /// /// /// - /// A event occurs when the receives - /// a text or binary message, or a ping if the property is - /// set to true. + /// That event occurs when the receives a text or + /// binary message, or a ping if the + /// property is set to true. /// /// - /// If you would like to get the message data, you should access the or - /// property. + /// If you would like to get the message data, you should access + /// the or property. /// /// public class MessageEventArgs : EventArgs @@ -81,7 +81,7 @@ internal MessageEventArgs (Opcode opcode, byte[] rawData) /// /// /// A that represents the message data, - /// or if the message data cannot be decoded to a string. + /// or if it cannot be decoded to a string. /// public string Data { get { From b10153583e2b37fa823ae0c55844a54164c58e61 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 25 Sep 2016 15:41:47 +0900 Subject: [PATCH 0670/6294] [Modify] 2016 --- websocket-sharp/MessageEventArgs.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/MessageEventArgs.cs b/websocket-sharp/MessageEventArgs.cs index b30b4d91b..2271cc3e1 100644 --- a/websocket-sharp/MessageEventArgs.cs +++ b/websocket-sharp/MessageEventArgs.cs @@ -4,7 +4,7 @@ * * The MIT License * - * Copyright (c) 2012-2015 sta.blockhead + * Copyright (c) 2012-2016 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From 6b0c1f6cb64b0adc742c6230f49199247dd490c3 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 26 Sep 2016 16:13:47 +0900 Subject: [PATCH 0671/6294] [Modify] Edit it --- websocket-sharp/MessageEventArgs.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/MessageEventArgs.cs b/websocket-sharp/MessageEventArgs.cs index 2271cc3e1..72749fa52 100644 --- a/websocket-sharp/MessageEventArgs.cs +++ b/websocket-sharp/MessageEventArgs.cs @@ -35,9 +35,8 @@ namespace WebSocketSharp /// /// /// - /// That event occurs when the receives a text or - /// binary message, or a ping if the - /// property is set to true. + /// That event occurs when the receives a message or + /// a ping if the property is set to true. /// /// /// If you would like to get the message data, you should access From a4325ebf5c02369002dd6d637f87bcdd53c76b77 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 26 Sep 2016 17:25:43 +0900 Subject: [PATCH 0672/6294] [Modify] Edit it --- README.md | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index f7e68609e..24ea1dee8 100644 --- a/README.md +++ b/README.md @@ -201,7 +201,7 @@ If the error is due to an exception, `e.Exception` property returns a `System.Ex ##### WebSocket.OnClose Event ##### -A `WebSocket.OnClose` event occurs when the WebSocket connection has been closed. +This event occurs when the WebSocket connection has been closed. ```csharp ws.OnClose += (sender, e) => { @@ -209,9 +209,13 @@ ws.OnClose += (sender, e) => { }; ``` -`e` has passed as a `WebSocketSharp.CloseEventArgs`. +`e` is passed as a `WebSocketSharp.CloseEventArgs` instance. -`e.Code` property returns a `ushort` that represents the status code for the close, and `e.Reason` property returns a `string` that represents the reason for the close. +If you would like to get the reason for the close, you should access `e.Code` or `e.Reason` property. + +`e.Code` property returns a `ushort` that represents the status code for the close. + +`e.Reason` property returns a `string` that represents the reason for the close. #### Step 4 #### From f1d774f5ae5d413ff4cc35203ac4e5a3ced6dd7a Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 27 Sep 2016 15:26:01 +0900 Subject: [PATCH 0673/6294] [Modify] Edit it --- README.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 24ea1dee8..7b17f28c4 100644 --- a/README.md +++ b/README.md @@ -185,7 +185,7 @@ ws.OnMessage += (sender, e) => { ##### WebSocket.OnError Event ##### -A `WebSocket.OnError` event occurs when the `WebSocket` gets an error. +This event occurs when the `WebSocket` gets an error. ```csharp ws.OnError += (sender, e) => { @@ -193,11 +193,13 @@ ws.OnError += (sender, e) => { }; ``` -`e` has passed as a `WebSocketSharp.ErrorEventArgs`. +`e` is passed as a `WebSocketSharp.ErrorEventArgs` instance. + +If you would like to get the error message, you should access `e.Message` property. `e.Message` property returns a `string` that represents the error message. -If the error is due to an exception, `e.Exception` property returns a `System.Exception` instance that caused the error. +And `e.Exception` property returns a `System.Exception` instance that represents the cause of the error if it is due to an exception. ##### WebSocket.OnClose Event ##### From 016f4ba1cbc75b22ba08a97bf9c66052ea34e2ec Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 27 Sep 2016 15:53:54 +0900 Subject: [PATCH 0674/6294] [Modify] Edit it --- websocket-sharp/ErrorEventArgs.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/ErrorEventArgs.cs b/websocket-sharp/ErrorEventArgs.cs index c8b6bd89e..41502ab08 100644 --- a/websocket-sharp/ErrorEventArgs.cs +++ b/websocket-sharp/ErrorEventArgs.cs @@ -84,7 +84,7 @@ internal ErrorEventArgs (string message, Exception exception) /// /// /// An instance that represents the cause of - /// the error, or if it is not due to an exception. + /// the error if it is due to an exception; otherwise, . /// public Exception Exception { get { From dc1bfc2ce745c85ab4c61d4866e5b87a25d3253a Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 28 Sep 2016 14:33:08 +0900 Subject: [PATCH 0675/6294] [Modify] Edit it --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 7b17f28c4..eb28df2b0 100644 --- a/README.md +++ b/README.md @@ -123,7 +123,7 @@ Setting the `WebSocket` events. ##### WebSocket.OnOpen Event ##### -A `WebSocket.OnOpen` event occurs when the WebSocket connection has been established. +This event occurs when the WebSocket connection has been established. ```csharp ws.OnOpen += (sender, e) => { @@ -131,7 +131,7 @@ ws.OnOpen += (sender, e) => { }; ``` -`e` has passed as the `System.EventArgs.Empty`, so you don't need to use it. +`System.EventArgs.Empty` is passed as `e`, so you do not need to use it. ##### WebSocket.OnMessage Event ##### From 0fb482eee2bb80f4bcef50c81e1b76834f22e0eb Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 28 Sep 2016 14:37:08 +0900 Subject: [PATCH 0676/6294] [Modify] Edit it --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index eb28df2b0..da1b34112 100644 --- a/README.md +++ b/README.md @@ -211,7 +211,7 @@ ws.OnClose += (sender, e) => { }; ``` -`e` is passed as a `WebSocketSharp.CloseEventArgs` instance. +A `WebSocketSharp.CloseEventArgs` instance is passed as `e`. If you would like to get the reason for the close, you should access `e.Code` or `e.Reason` property. From 49422f4fbaa310454f2b44f4549c6914a36ebb00 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 28 Sep 2016 14:41:10 +0900 Subject: [PATCH 0677/6294] [Modify] Edit it --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index da1b34112..ecb34fa4e 100644 --- a/README.md +++ b/README.md @@ -193,7 +193,7 @@ ws.OnError += (sender, e) => { }; ``` -`e` is passed as a `WebSocketSharp.ErrorEventArgs` instance. +A `WebSocketSharp.ErrorEventArgs` instance is passed as `e`. If you would like to get the error message, you should access `e.Message` property. From 3ba8d1434e019b65c6004c648cc810a7b7b75074 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 29 Sep 2016 14:41:54 +0900 Subject: [PATCH 0678/6294] [Modify] Edit it --- README.md | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index ecb34fa4e..469539e75 100644 --- a/README.md +++ b/README.md @@ -135,7 +135,7 @@ ws.OnOpen += (sender, e) => { ##### WebSocket.OnMessage Event ##### -A `WebSocket.OnMessage` event occurs when the `WebSocket` receives a message. +This event occurs when the `WebSocket` receives a message. ```csharp ws.OnMessage += (sender, e) => { @@ -143,15 +143,13 @@ ws.OnMessage += (sender, e) => { }; ``` -`e` has passed as a `WebSocketSharp.MessageEventArgs`. +A `WebSocketSharp.MessageEventArgs` instance is passed as `e`. If you would like to get the message data, you should access `e.Data` or `e.RawData` property. -And you can determine which property you should access by checking `e.IsText` or `e.IsBinary` property. +`e.Data` property returns a `string`, so it is mainly used to get the **text** message data. -If `e.IsText` is `true`, you should access `e.Data` that returns a `string` (represents a **text** message). - -Or if `e.IsBinary` is `true`, you should access `e.RawData` that returns a `byte[]` (represents a **binary** message). +`e.RawData` property returns a `byte[]`, so it is mainly used to get the **binary** message data. ```csharp if (e.IsText) { @@ -169,7 +167,7 @@ if (e.IsBinary) { } ``` -And if you would like to notify that a **ping** has been received, via this event, you should set the `WebSocket.EmitOnPing` property to `true`, such as the following. +And if you would like to notify that a **ping** has been received, via this event, you should set the `WebSocket.EmitOnPing` property to `true`. ```csharp ws.EmitOnPing = true; From 3cab7b7722d77ddb88b20ebe2cd534b5351b569e Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 29 Sep 2016 14:56:28 +0900 Subject: [PATCH 0679/6294] [Modify] Edit it --- websocket-sharp/MessageEventArgs.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/MessageEventArgs.cs b/websocket-sharp/MessageEventArgs.cs index 72749fa52..d81c0d931 100644 --- a/websocket-sharp/MessageEventArgs.cs +++ b/websocket-sharp/MessageEventArgs.cs @@ -79,8 +79,8 @@ internal MessageEventArgs (Opcode opcode, byte[] rawData) /// Gets the message data as a . /// /// - /// A that represents the message data, - /// or if it cannot be decoded to a string. + /// A that represents the message data + /// if it can be decoded to a string; otherwise, . /// public string Data { get { From 7c1476522fadf1bdc672cf3ae2f496c23bd09f15 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 30 Sep 2016 15:05:56 +0900 Subject: [PATCH 0680/6294] [Modify] Move and rename it --- websocket-sharp/MessageEventArgs.cs | 30 ++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/websocket-sharp/MessageEventArgs.cs b/websocket-sharp/MessageEventArgs.cs index d81c0d931..3c399a536 100644 --- a/websocket-sharp/MessageEventArgs.cs +++ b/websocket-sharp/MessageEventArgs.cs @@ -73,6 +73,23 @@ internal MessageEventArgs (Opcode opcode, byte[] rawData) #endregion + #region Internal Properties + + /// + /// Gets the opcode for the message. + /// + /// + /// , , + /// or . + /// + internal Opcode Opcode { + get { + return _opcode; + } + } + + #endregion + #region Public Properties /// @@ -144,19 +161,6 @@ public byte[] RawData { } } - /// - /// Gets the message type. - /// - /// - /// , , or . - /// - [Obsolete ("This property will be removed. Use any of the Is properties instead.")] - public Opcode Type { - get { - return _opcode; - } - } - #endregion } } From 57c28c9f4179569a64b48d141027f8c01dfe7abd Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 1 Oct 2016 18:12:47 +0900 Subject: [PATCH 0681/6294] [Modify] Change access level to internal --- websocket-sharp/Opcode.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Opcode.cs b/websocket-sharp/Opcode.cs index faabdb0dd..f35ddfe24 100644 --- a/websocket-sharp/Opcode.cs +++ b/websocket-sharp/Opcode.cs @@ -37,7 +37,7 @@ namespace WebSocketSharp /// The values of this enumeration are defined in /// Section 5.2 of RFC 6455. /// - public enum Opcode : byte + internal enum Opcode : byte { /// /// Equivalent to numeric value 0. Indicates continuation frame. From 21201675a17266ca432cdb25455723f0c393b38f Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 2 Oct 2016 17:09:13 +0900 Subject: [PATCH 0682/6294] [Modify] Edit it --- websocket-sharp/Opcode.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Opcode.cs b/websocket-sharp/Opcode.cs index f35ddfe24..07bf98870 100644 --- a/websocket-sharp/Opcode.cs +++ b/websocket-sharp/Opcode.cs @@ -35,7 +35,8 @@ namespace WebSocketSharp /// /// /// The values of this enumeration are defined in - /// Section 5.2 of RFC 6455. + /// + /// Section 5.2 of RFC 6455. /// internal enum Opcode : byte { From 3ae03bf4039d63b86cae3b06273e8523307154c9 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 2 Oct 2016 17:11:37 +0900 Subject: [PATCH 0683/6294] [Modify] 2016 --- websocket-sharp/Opcode.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Opcode.cs b/websocket-sharp/Opcode.cs index 07bf98870..5a8c632e0 100644 --- a/websocket-sharp/Opcode.cs +++ b/websocket-sharp/Opcode.cs @@ -4,7 +4,7 @@ * * The MIT License * - * Copyright (c) 2012-2015 sta.blockhead + * Copyright (c) 2012-2016 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From 6c8f033a28d6ae5a6b04807ae68b6783e06aa32f Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 3 Oct 2016 15:49:35 +0900 Subject: [PATCH 0684/6294] [Modify] Add it --- websocket-sharp/MessageEventArgs.cs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/websocket-sharp/MessageEventArgs.cs b/websocket-sharp/MessageEventArgs.cs index 3c399a536..6ac326787 100644 --- a/websocket-sharp/MessageEventArgs.cs +++ b/websocket-sharp/MessageEventArgs.cs @@ -162,5 +162,23 @@ public byte[] RawData { } #endregion + + #region Private Methods + + private void setData () + { + if (_dataSet) + return; + + if (_opcode == Opcode.Binary) { + _dataSet = true; + return; + } + + _data = _rawData.UTF8Decode (); + _dataSet = true; + } + + #endregion } } From 0b07b08ad0822e1b8063737989336b36b2d19cc1 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 3 Oct 2016 16:00:21 +0900 Subject: [PATCH 0685/6294] [Modify] Use it --- websocket-sharp/MessageEventArgs.cs | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/websocket-sharp/MessageEventArgs.cs b/websocket-sharp/MessageEventArgs.cs index 6ac326787..da151a229 100644 --- a/websocket-sharp/MessageEventArgs.cs +++ b/websocket-sharp/MessageEventArgs.cs @@ -101,14 +101,7 @@ internal Opcode Opcode { /// public string Data { get { - if (!_dataSet) { - _data = _opcode != Opcode.Binary - ? _rawData.UTF8Decode () - : BitConverter.ToString (_rawData); - - _dataSet = true; - } - + setData (); return _data; } } @@ -157,6 +150,7 @@ public bool IsText { /// public byte[] RawData { get { + setData (); return _rawData; } } From 5de94d407005e468991fb30ce5260cab2246cceb Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 4 Oct 2016 15:25:45 +0900 Subject: [PATCH 0686/6294] [Modify] Edit it --- websocket-sharp/MessageEventArgs.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/MessageEventArgs.cs b/websocket-sharp/MessageEventArgs.cs index da151a229..ec2ef7c5e 100644 --- a/websocket-sharp/MessageEventArgs.cs +++ b/websocket-sharp/MessageEventArgs.cs @@ -96,8 +96,9 @@ internal Opcode Opcode { /// Gets the message data as a . /// /// - /// A that represents the message data - /// if it can be decoded to a string; otherwise, . + /// A that represents the message data if its type is + /// text or ping and if decoding it to a string has successfully done; + /// otherwise, . /// public string Data { get { From 04dd346581ae4d3d4a98f50dfcd3a263fee34f28 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 4 Oct 2016 15:33:19 +0900 Subject: [PATCH 0687/6294] [Modify] Edit it --- websocket-sharp/MessageEventArgs.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/MessageEventArgs.cs b/websocket-sharp/MessageEventArgs.cs index ec2ef7c5e..adf7391aa 100644 --- a/websocket-sharp/MessageEventArgs.cs +++ b/websocket-sharp/MessageEventArgs.cs @@ -35,8 +35,9 @@ namespace WebSocketSharp /// /// /// - /// That event occurs when the receives a message or - /// a ping if the property is set to true. + /// That event occurs when the receives + /// a message or a ping if the + /// property is set to true. /// /// /// If you would like to get the message data, you should access From 077b5d306342bb51cc3cd36e35aeaa0661fab44c Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 5 Oct 2016 15:17:21 +0900 Subject: [PATCH 0688/6294] [Modify] Add it --- websocket-sharp/Server/WebSocketServer.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index fba17307b..842941a95 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -558,6 +558,13 @@ private void abort () _state = ServerState.Stop; } + private bool checkHostName (string name) + { + return !_dnsStyle + || Uri.CheckHostName (name) != UriHostNameType.Dns + || name == _hostname; + } + private bool checkIfAvailable ( bool ready, bool start, bool shutting, bool stop, out string message ) From 215574b9abdda00a0b50cdab54d10d2435a9e5e9 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 5 Oct 2016 15:26:21 +0900 Subject: [PATCH 0689/6294] [Modify] Use it --- websocket-sharp/Server/WebSocketServer.cs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 842941a95..c21ba18a3 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -630,12 +630,9 @@ private void processRequest (TcpListenerWebSocketContext context) return; } - if (_dnsStyle) { - var hostname = uri.DnsSafeHost; - if (Uri.CheckHostName (hostname) == UriHostNameType.Dns && hostname != _hostname) { - context.Close (HttpStatusCode.NotFound); - return; - } + if (!checkHostName (uri.DnsSafeHost)) { + context.Close (HttpStatusCode.NotFound); + return; } WebSocketServiceHost host; From b4c62cf36086f588150144814d7b395e3e289516 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 6 Oct 2016 14:54:31 +0900 Subject: [PATCH 0690/6294] [Modify] Separate it --- websocket-sharp/Server/WebSocketServer.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index c21ba18a3..02e30486d 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -625,7 +625,12 @@ private void init (string hostname, System.Net.IPAddress address, int port, bool private void processRequest (TcpListenerWebSocketContext context) { var uri = context.RequestUri; - if (uri == null || uri.Port != _port) { + if (uri == null) { + context.Close (HttpStatusCode.BadRequest); + return; + } + + if (uri.Port != _port) { context.Close (HttpStatusCode.BadRequest); return; } From 7bd87ee4da4fee6c36cf077bb533d1521afafcf3 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 7 Oct 2016 14:54:24 +0900 Subject: [PATCH 0691/6294] [Modify] Allow it or not --- websocket-sharp/Server/WebSocketServer.cs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 02e30486d..1d8cc254a 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -61,6 +61,7 @@ public class WebSocketServer #region Private Fields private System.Net.IPAddress _address; + private bool _allowForwardedRequest; private AuthenticationSchemes _authSchemes; private static readonly string _defaultRealm; private bool _dnsStyle; @@ -630,14 +631,16 @@ private void processRequest (TcpListenerWebSocketContext context) return; } - if (uri.Port != _port) { - context.Close (HttpStatusCode.BadRequest); - return; - } + if (!_allowForwardedRequest) { + if (uri.Port != _port) { + context.Close (HttpStatusCode.BadRequest); + return; + } - if (!checkHostName (uri.DnsSafeHost)) { - context.Close (HttpStatusCode.NotFound); - return; + if (!checkHostName (uri.DnsSafeHost)) { + context.Close (HttpStatusCode.NotFound); + return; + } } WebSocketServiceHost host; From 0b3a346b86351840cb2171630a37d8b8c94855ce Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 8 Oct 2016 20:50:31 +0900 Subject: [PATCH 0692/6294] [Modify] Add a property Experimental implementation to support #274, #296, and #301. --- websocket-sharp/Server/WebSocketServer.cs | 31 +++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 1d8cc254a..76aea6e37 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -300,6 +300,37 @@ public System.Net.IPAddress Address { } } + /// + /// Gets or sets a value indicating whether the server accepts + /// a forwarded request. + /// + /// + /// true if the server accepts a forwarded request; + /// otherwise, false. The default value is false. + /// + public bool AllowForwardedRequest { + get { + return _allowForwardedRequest; + } + + set { + string msg; + if (!checkIfAvailable (true, false, false, true, out msg)) { + _logger.Error (msg); + return; + } + + lock (_sync) { + if (!checkIfAvailable (true, false, false, true, out msg)) { + _logger.Error (msg); + return; + } + + _allowForwardedRequest = value; + } + } + } + /// /// Gets or sets the scheme used to authenticate the clients. /// From 25c8d9d1ec0557cdb5b933cf7c43b6e10574c53d Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 9 Oct 2016 16:25:50 +0900 Subject: [PATCH 0693/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 76aea6e37..8376e76db 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -289,10 +289,11 @@ public WebSocketServer (System.Net.IPAddress address, int port, bool secure) #region Public Properties /// - /// Gets the local IP address of the server. + /// Gets the IP address of the server. /// /// - /// A that represents the local IP address of the server. + /// A that represents + /// the IP address of the server. /// public System.Net.IPAddress Address { get { From 4df24ba18bf5d5cf801756fa3648fc4c761be6ce Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 9 Oct 2016 16:34:25 +0900 Subject: [PATCH 0694/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketServer.cs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 8376e76db..bc4e73268 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -346,13 +346,20 @@ public AuthenticationSchemes AuthenticationSchemes { } set { - var msg = _state.CheckIfAvailable (true, false, false); - if (msg != null) { + string msg; + if (!checkIfAvailable (true, false, false, true, out msg)) { _logger.Error (msg); return; } - _authSchemes = value; + lock (_sync) { + if (!checkIfAvailable (true, false, false, true, out msg)) { + _logger.Error (msg); + return; + } + + _authSchemes = value; + } } } From a46a16cd56e75f3673944d6f933f9cb88e939e09 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 10 Oct 2016 17:39:22 +0900 Subject: [PATCH 0695/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index bc4e73268..49cc8491a 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -336,8 +336,9 @@ public bool AllowForwardedRequest { /// Gets or sets the scheme used to authenticate the clients. /// /// - /// One of the enum values, - /// indicates the scheme used to authenticate the clients. The default value is + /// One of the enum + /// values that represents the scheme used to authenticate the clients. + /// The default value is /// . /// public AuthenticationSchemes AuthenticationSchemes { From 34a6b91bf69b706b41f43e529a8b1803118ed73f Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 11 Oct 2016 15:38:28 +0900 Subject: [PATCH 0696/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketServer.cs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 49cc8491a..177834537 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -402,13 +402,20 @@ public bool KeepClean { } set { - var msg = _state.CheckIfAvailable (true, false, false); - if (msg != null) { + string msg; + if (!checkIfAvailable (true, false, false, true, out msg)) { _logger.Error (msg); return; } - _services.KeepClean = value; + lock (_sync) { + if (!checkIfAvailable (true, false, false, true, out msg)) { + _logger.Error (msg); + return; + } + + _services.KeepClean = value; + } } } From 4dbfc8bb1c92286aca504d0a2dcfecea048a13ef Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 11 Oct 2016 15:56:51 +0900 Subject: [PATCH 0697/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 177834537..717a6dcb7 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -393,8 +393,8 @@ public bool IsSecure { /// the inactive sessions periodically. /// /// - /// true if the server cleans up the inactive sessions every 60 seconds; - /// otherwise, false. The default value is true. + /// true if the server cleans up the inactive sessions every 60 + /// seconds; otherwise, false. The default value is true. /// public bool KeepClean { get { From bed2ef08247eb50178dab99f1077fe1c35d47747 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 11 Oct 2016 16:04:01 +0900 Subject: [PATCH 0698/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 717a6dcb7..3e520922e 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -380,7 +380,8 @@ public bool IsListening { /// Gets a value indicating whether the server provides a secure connection. /// /// - /// true if the server provides a secure connection; otherwise, false. + /// true if the server provides a secure connection; + /// otherwise, false. /// public bool IsSecure { get { From 81d2834ee7c4c214ad0e2360b5a34caa413da098 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 12 Oct 2016 17:33:07 +0900 Subject: [PATCH 0699/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 3e520922e..f5282eef9 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -421,15 +421,15 @@ public bool KeepClean { } /// - /// Gets the logging functions. + /// Gets the logging function for the server. /// /// - /// The default logging level is . If you would like to change it, - /// you should set the Log.Level property to any of the enum - /// values. + /// The default logging level is . If you would + /// like to change the logging level, you should set this Log.Level + /// property to any of the enum values. /// /// - /// A that provides the logging functions. + /// A that provides the logging function. /// public Logger Log { get { From 2b927a64c24cdf4b89b4e4746332b0284d444d05 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 13 Oct 2016 14:25:48 +0900 Subject: [PATCH 0700/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index f5282eef9..1ebc03615 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -438,7 +438,7 @@ public Logger Log { } /// - /// Gets the port on which to listen for incoming connection requests. + /// Gets the port on which to listen for incoming handshake requests. /// /// /// An that represents the port number on which to listen. From 359de8a4be1f95e8bc0246b7e89a0c3e8bb8f1c3 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 13 Oct 2016 14:30:00 +0900 Subject: [PATCH 0701/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketServer.cs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 1ebc03615..4f131360f 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -466,13 +466,20 @@ public string Realm { } set { - var msg = _state.CheckIfAvailable (true, false, false); - if (msg != null) { + string msg; + if (!checkIfAvailable (true, false, false, true, out msg)) { _logger.Error (msg); return; } - _realm = value; + lock (_sync) { + if (!checkIfAvailable (true, false, false, true, out msg)) { + _logger.Error (msg); + return; + } + + _realm = value; + } } } From f63d4a41a193fe2afbec5dce5097d91adddb6708 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 13 Oct 2016 14:48:06 +0900 Subject: [PATCH 0702/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 4f131360f..a179b73f2 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -450,15 +450,15 @@ public int Port { } /// - /// Gets or sets the name of the realm associated with the server. + /// Gets or sets the name of the realm for the server. /// /// - /// If this property is or empty, "SECRET AREA" will be used as - /// the name of the realm. + /// If this property is or empty, + /// "SECRET AREA" will be used as the name. /// /// - /// A that represents the name of the realm. The default value is - /// . + /// A that represents the name of the realm. + /// The default value is . /// public string Realm { get { From 44bf2f69498d2fcd3529e3c4c4bae7551eebfc08 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 13 Oct 2016 14:54:28 +0900 Subject: [PATCH 0703/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketServer.cs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index a179b73f2..e169af956 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -501,13 +501,20 @@ public bool ReuseAddress { } set { - var msg = _state.CheckIfAvailable (true, false, false); - if (msg != null) { + string msg; + if (!checkIfAvailable (true, false, false, true, out msg)) { _logger.Error (msg); return; } - _reuseAddress = value; + lock (_sync) { + if (!checkIfAvailable (true, false, false, true, out msg)) { + _logger.Error (msg); + return; + } + + _reuseAddress = value; + } } } From 3c1c3c5aa8423a82e23ded3760f5c9f43dd53038 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 14 Oct 2016 15:48:03 +0900 Subject: [PATCH 0704/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index e169af956..9f29ea566 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -484,16 +484,17 @@ public string Realm { } /// - /// Gets or sets a value indicating whether the server is allowed to be bound to - /// an address that is already in use. + /// Gets or sets a value indicating whether the server is allowed to + /// be bound to an address that is already in use. /// /// - /// If you would like to resolve to wait for socket in TIME_WAIT state, + /// If you would like to resolve to wait for socket in TIME_WAIT state, /// you should set this property to true. /// /// - /// true if the server is allowed to be bound to an address that is already in use; - /// otherwise, false. The default value is false. + /// true if the server is allowed to be bound to an address that + /// is already in use; otherwise, false. The default value is + /// false. /// public bool ReuseAddress { get { From 34d61cd8f5591ad4f1bfc59e4535ceff0f66c824 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 14 Oct 2016 15:52:15 +0900 Subject: [PATCH 0705/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketServer.cs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 9f29ea566..7b3ca995d 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -558,13 +558,20 @@ public Func UserCredentialsFinder { } set { - var msg = _state.CheckIfAvailable (true, false, false); - if (msg != null) { + string msg; + if (!checkIfAvailable (true, false, false, true, out msg)) { _logger.Error (msg); return; } - _userCredFinder = value; + lock (_sync) { + if (!checkIfAvailable (true, false, false, true, out msg)) { + _logger.Error (msg); + return; + } + + _userCredFinder = value; + } } } From 10674ae9e8ca0531ad197670c6fb1ebe7c830534 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 15 Oct 2016 16:05:28 +0900 Subject: [PATCH 0706/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 7b3ca995d..f9a8eb885 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -544,13 +544,13 @@ public ServerSslConfiguration SslConfiguration { } /// - /// Gets or sets the delegate called to find the credentials for an identity used to - /// authenticate a client. + /// Gets or sets the delegate called to find the credentials for + /// an identity used to authenticate a client. /// /// - /// A Func<, > delegate - /// that references the method(s) used to find the credentials. The default value is - /// . + /// A Func<IIdentity, NetworkCredential> delegate that + /// invokes the method used to find the credentials. The default value + /// is . /// public Func UserCredentialsFinder { get { From 6ecbffbbf5ee8a010a5304cfda26bb34297cae62 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 16 Oct 2016 17:44:56 +0900 Subject: [PATCH 0707/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketServer.cs | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index f9a8eb885..23423eb77 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -588,13 +588,25 @@ public TimeSpan WaitTime { } set { - var msg = _state.CheckIfAvailable (true, false, false) ?? value.CheckIfValidWaitTime (); - if (msg != null) { + string msg; + if (!checkIfAvailable (true, false, false, true, out msg)) { + _logger.Error (msg); + return; + } + + if (!value.CheckWaitTime (out msg)) { _logger.Error (msg); return; } - _services.WaitTime = value; + lock (_sync) { + if (!checkIfAvailable (true, false, false, true, out msg)) { + _logger.Error (msg); + return; + } + + _services.WaitTime = value; + } } } From ccea8a161608705e31907564e7f8f53779ee811e Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 17 Oct 2016 15:34:23 +0900 Subject: [PATCH 0708/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 23423eb77..77f56174a 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -576,11 +576,12 @@ public Func UserCredentialsFinder { } /// - /// Gets or sets the wait time for the response to the WebSocket Ping or Close. + /// Gets or sets the wait time for the response to + /// the WebSocket Ping or Close. /// /// - /// A that represents the wait time. The default value is - /// the same as 1 second. + /// A that represents the wait time for + /// the response. The default value is the same as 1 second. /// public TimeSpan WaitTime { get { From 1e2dfaa57c2e83e09264c8d00cf9891e3edc16fc Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 18 Oct 2016 14:56:31 +0900 Subject: [PATCH 0709/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 77f56174a..e046e3d8b 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -615,7 +615,8 @@ public TimeSpan WaitTime { /// Gets the access to the WebSocket services provided by the server. /// /// - /// A that manages the WebSocket services. + /// A that manages + /// the WebSocket services provided by the server. /// public WebSocketServiceManager WebSocketServices { get { From 6bf83e095a3d3080c64cd3c7d898684b2a8a0c79 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 19 Oct 2016 15:18:40 +0900 Subject: [PATCH 0710/6294] [Modify] Rename it --- websocket-sharp/Server/WebSocketServer.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index e046e3d8b..c55eed43f 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -643,7 +643,7 @@ private void abort () _state = ServerState.Stop; } - private bool checkHostName (string name) + private bool checkHostNameForRequest (string name) { return !_dnsStyle || Uri.CheckHostName (name) != UriHostNameType.Dns @@ -721,7 +721,7 @@ private void processRequest (TcpListenerWebSocketContext context) return; } - if (!checkHostName (uri.DnsSafeHost)) { + if (!checkHostNameForRequest (uri.DnsSafeHost)) { context.Close (HttpStatusCode.NotFound); return; } From 3f8335c27fb4a718f60692575c57d28624e402f3 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 20 Oct 2016 16:10:41 +0900 Subject: [PATCH 0711/6294] [Modify] Edit it --- README.md | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 469539e75..b5f5187ca 100644 --- a/README.md +++ b/README.md @@ -467,17 +467,15 @@ I think this is useful when you get something error in connecting the server and ### Secure Connection ### -websocket-sharp supports the **Secure Connection** with **SSL/TLS**. +websocket-sharp supports the secure connection with **SSL/TLS**. -As a **WebSocket Client**, you should create a new instance of the `WebSocket` class with a **wss** scheme WebSocket URL. +As a WebSocket client, you should create a new instance of the `WebSocket` class with a **wss** scheme WebSocket URL. ```csharp -using (var ws = new WebSocket ("wss://example.com")) { - ... -} +var ws = new WebSocket ("wss://example.com"); ``` -And if you would like to use the custom validation for the server certificate, you should set the `WebSocket.SslConfiguration.ServerCertificateValidationCallback` property. +If you would like to set a custom validation for the server certificate, you should set the `WebSocket.SslConfiguration.ServerCertificateValidationCallback` property to a callback for it. ```csharp ws.SslConfiguration.ServerCertificateValidationCallback = @@ -489,9 +487,9 @@ ws.SslConfiguration.ServerCertificateValidationCallback = }; ``` -If you set this property to nothing, the validation does nothing with the server certificate, and returns `true`. +The default callback always returns `true`. -As a **WebSocket Server**, you should create a new instance of the `WebSocketServer` or `HttpServer` class with some settings for secure connection, such as the following. +As a WebSocket server, you should create a new instance of the `WebSocketServer` or `HttpServer` class with some settings for the secure connection, such as the following. ```csharp var wssv = new WebSocketServer (5963, true); From 28cb4477bc06be0f563b8e1d16dae7c8d787bb1a Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 21 Oct 2016 16:57:48 +0900 Subject: [PATCH 0712/6294] [Modify] Edit it --- README.md | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index b5f5187ca..ce82ed056 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ - **[Per-message Compression](#per-message-compression)** extension - **[Secure Connection](#secure-connection)** - **[HTTP Authentication](#http-authentication)** -- **[Query String, Origin header and Cookies](#query-string-origin-header-and-cookies)** +- **[Query String, Origin header, and Cookies](#query-string-origin-header-and-cookies)** - **[Connecting through the HTTP Proxy server](#connecting-through-the-http-proxy-server)** - .NET Framework **3.5** or later (includes compatible environment such as **[Mono]**) @@ -532,29 +532,27 @@ If you would like to provide the Digest authentication, you should set such as t wssv.AuthenticationSchemes = AuthenticationSchemes.Digest; ``` -### Query String, Origin header and Cookies ### +### Query String, Origin header, and Cookies ### -As a **WebSocket Client**, if you would like to send the **Query String** with the handshake request to the server, you should create a new instance of the `WebSocket` class with the WebSocket URL that includes the [Query] string parameters. +As a WebSocket client, if you would like to send the query string in the handshake request, you should create a new instance of the `WebSocket` class with a WebSocket URL that includes the [Query] string parameters. ```csharp -using (var ws = new WebSocket ("ws://example.com/?name=nobita")) { - ... -} +var ws = new WebSocket ("ws://example.com/?name=nobita"); ``` -And if you would like to send the **Origin** header with the handshake request to the server, you should set the `WebSocket.Origin` property to an allowable value as the [Origin] header before connecting, such as the following. +And if you would like to send the Origin header in the handshake request, you should set the `WebSocket.Origin` property to an allowable value as the [Origin] header before calling the connect method. ```csharp ws.Origin = "http://example.com/"; ``` -And also if you would like to send the **Cookies** with the handshake request to the server, you should set any cookie by using the `WebSocket.SetCookie (WebSocketSharp.Net.Cookie)` method before connecting, such as the following. +And also if you would like to send the cookies in the handshake request, you should set any cookie by using the `WebSocket.SetCookie (WebSocketSharp.Net.Cookie)` method before calling the connect method. ```csharp ws.SetCookie (new Cookie ("name", "nobita")); ``` -As a **WebSocket Server**, if you would like to get the **Query String** included in a handshake request, you should access the `WebSocketBehavior.Context.QueryString` property, such as the following. +As a WebSocket server, if you would like to get the query string included in a handshake request, you should access the `WebSocketBehavior.Context.QueryString` property, such as the following. ```csharp public class Chat : WebSocketBehavior @@ -571,7 +569,9 @@ public class Chat : WebSocketBehavior } ``` -And if you would like to validate the **Origin** header, **Cookies**, or both included in a handshake request, you should set each validation with your `WebSocketBehavior`, for example, by using the `AddWebSocketService (string, Func)` method with initializing, such as the following. +And if you would like to get each value of the Origin header and cookies, you should access each of the `WebSocketBehavior.Context.Origin` and `WebSocketBehavior.Context.CookieCollection` properties. + +And also if you would like to validate the Origin header, cookies, or both included in a handshake request, you should set each validation with your `WebSocketBehavior`, for example, by using the `WebSocketServer.AddWebSocketService (string, Func)` method with initializing, such as the following. ```csharp wssv.AddWebSocketService ( @@ -599,8 +599,6 @@ wssv.AddWebSocketService ( ); ``` -And also if you would like to get each value of the Origin header and cookies, you should access each of the `WebSocketBehavior.Context.Origin` and `WebSocketBehavior.Context.CookieCollection` properties. - ### Connecting through the HTTP Proxy server ### websocket-sharp supports to connect through the **HTTP Proxy** server. From 1b5d84456cd11c92a580304fa2cf979a4985617e Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 22 Oct 2016 17:26:11 +0900 Subject: [PATCH 0713/6294] [Modify] Edit it --- README.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index ce82ed056..d0a0dad04 100644 --- a/README.md +++ b/README.md @@ -540,13 +540,13 @@ As a WebSocket client, if you would like to send the query string in the handsha var ws = new WebSocket ("ws://example.com/?name=nobita"); ``` -And if you would like to send the Origin header in the handshake request, you should set the `WebSocket.Origin` property to an allowable value as the [Origin] header before calling the connect method. +If you would like to send the Origin header in the handshake request, you should set the `WebSocket.Origin` property to an allowable value as the [Origin] header before calling the connect method. ```csharp ws.Origin = "http://example.com/"; ``` -And also if you would like to send the cookies in the handshake request, you should set any cookie by using the `WebSocket.SetCookie (WebSocketSharp.Net.Cookie)` method before calling the connect method. +And if you would like to send the cookies in the handshake request, you should set any cookie by using the `WebSocket.SetCookie (WebSocketSharp.Net.Cookie)` method before calling the connect method. ```csharp ws.SetCookie (new Cookie ("name", "nobita")); @@ -569,9 +569,11 @@ public class Chat : WebSocketBehavior } ``` -And if you would like to get each value of the Origin header and cookies, you should access each of the `WebSocketBehavior.Context.Origin` and `WebSocketBehavior.Context.CookieCollection` properties. +If you would like to get the value of the Origin header included in a handshake request, you should access the `WebSocketBehavior.Context.Origin` property. -And also if you would like to validate the Origin header, cookies, or both included in a handshake request, you should set each validation with your `WebSocketBehavior`, for example, by using the `WebSocketServer.AddWebSocketService (string, Func)` method with initializing, such as the following. +If you would like to get the cookies included in a handshake request, you should access the `WebSocketBehavior.Context.CookieCollection` property. + +And if you would like to validate the Origin header, cookies, or both, you should set each validation for it with your `WebSocketBehavior`, for example, by using the `WebSocketServer.AddWebSocketService (string, Func)` method with initializing, such as the following. ```csharp wssv.AddWebSocketService ( From e7f32dfc3915cd8bd72c02298b0ef8279ffa0144 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 23 Oct 2016 16:32:13 +0900 Subject: [PATCH 0714/6294] [Modify] Edit it --- README.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index d0a0dad04..dd249c637 100644 --- a/README.md +++ b/README.md @@ -45,22 +45,22 @@ You can add websocket-sharp to your project with the **NuGet Package Manager**, ### Unity Asset Store ### -websocket-sharp is available on the **Unity Asset Store**. +websocket-sharp is available on the Unity Asset Store. - **[WebSocket-Sharp for Unity]** It works with **Unity Free**, but there are some limitations: -- **[Security Sandbox of the Webplayer]** (The server isn't available in Web Player) +- **[Security Sandbox of the Webplayer]** (The server is not available in Web Player) - **[WebGL Networking]** (Not available in WebGL) - **Incompatible platform** (Not available for such UWP) -- **Limited support for the System.IO.Compression** (The compression extension isn't available on Windows) -- **.NET Socket Support for iOS/Android** (It requires iOS/Android Pro if your Unity is earlier than Unity 5) +- **Limited support for the System.IO.Compression** (The compression extension is not available on Windows) +- **.NET Socket Support for iOS/Android** (That requires iOS/Android Pro if your Unity is earlier than Unity 5) - **.NET API 2.0 compatibility level for iOS/Android** -**.NET API 2.0 compatibility level for iOS/Android** may require to fix lack of some features for later than .NET 2.0, such as the `System.Func<...>` delegates (so i have added them in that asset package). +.NET API 2.0 compatibility level for iOS/Android may require to fix lack of some features for later than .NET Framework 2.0, such as the `System.Func<...>` delegates (so i have added them in the asset package). -And it's priced at **US$15**. I think your $15 makes this project more better and accelerated, **Thank you!** +And it is priced at **US$15**. I believe your $15 makes this project more better and accelerated, **Thank you!** ## Usage ## From 88dedeb56688fae68e54fd8914c1accaa6a0cf48 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 24 Oct 2016 15:33:26 +0900 Subject: [PATCH 0715/6294] [Modify] Edit it --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index dd249c637..21683e685 100644 --- a/README.md +++ b/README.md @@ -60,7 +60,7 @@ It works with **Unity Free**, but there are some limitations: .NET API 2.0 compatibility level for iOS/Android may require to fix lack of some features for later than .NET Framework 2.0, such as the `System.Func<...>` delegates (so i have added them in the asset package). -And it is priced at **US$15**. I believe your $15 makes this project more better and accelerated, **Thank you!** +And it is priced at **US$15**. I believe your $15 makes this project more better, **Thank you!** ## Usage ## From 0eee658e76142acb98ffee5abb580c8b3ee61996 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 24 Oct 2016 16:09:41 +0900 Subject: [PATCH 0716/6294] [Modify] Add it --- websocket-sharp/Server/WebSocketServer.cs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index c55eed43f..22f8c828e 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -686,6 +686,28 @@ private string checkIfCertificateExists () : null; } + private bool checkSslConfiguration ( + ServerSslConfiguration configuration, out string message + ) + { + message = null; + + if (!_secure) + return true; + + if (configuration == null) { + message = "There is no configuration for the secure connection."; + return false; + } + + if (configuration.ServerCertificate == null) { + message = "There is no server certificate for the secure connection."; + return false; + } + + return true; + } + private string getRealm () { var realm = _realm; From 6c8636ac72850b5ad9df0636bd586e476905eb74 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 25 Oct 2016 16:06:51 +0900 Subject: [PATCH 0717/6294] [Modify] Add it --- websocket-sharp/Server/WebSocketServer.cs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 22f8c828e..ed25b192a 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -714,6 +714,26 @@ private string getRealm () return realm != null && realm.Length > 0 ? realm : _defaultRealm; } + private ServerSslConfiguration getSslConfiguration () + { + var sslConfig = _sslConfig; + if (sslConfig == null) + return null; + + var ret = + new ServerSslConfiguration ( + sslConfig.ServerCertificate, + sslConfig.ClientCertificateRequired, + sslConfig.EnabledSslProtocols, + sslConfig.CheckCertificateRevocation + ); + + ret.ClientCertificateValidationCallback = + sslConfig.ClientCertificateValidationCallback; + + return ret; + } + private void init (string hostname, System.Net.IPAddress address, int port, bool secure) { _hostname = hostname ?? address.ToString (); From 644ff04bc27bb74ed2ef84f7c18acbe54f70ddda Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 26 Oct 2016 15:43:11 +0900 Subject: [PATCH 0718/6294] [Modify] Edit it --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 21683e685..dcd326b0d 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ If you would like to use that dll in your **[Unity]** project, you should add it ### NuGet Gallery ### -websocket-sharp is available on the **[NuGet Gallery]**, as still a **prerelease** version. +websocket-sharp is available on the [NuGet Gallery], as still a **prerelease** version. - **[NuGet Gallery: websocket-sharp]** From 25e429259bc1c5420d8890ca7058fc2cff5bb332 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 26 Oct 2016 15:51:25 +0900 Subject: [PATCH 0719/6294] [Modify] Edit it --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index dcd326b0d..bf50ac9e2 100644 --- a/README.md +++ b/README.md @@ -29,9 +29,9 @@ websocket-sharp is developed with **[MonoDevelop]**. So a simple way to build is ### Self Build ### -You should add your **websocket-sharp.dll** (e.g. `/path/to/websocket-sharp/bin/Debug/websocket-sharp.dll`) to the library references of your project. +You should add your websocket-sharp.dll (e.g. `/path/to/websocket-sharp/bin/Debug/websocket-sharp.dll`) to the library references of your project. -If you would like to use that dll in your **[Unity]** project, you should add it to any folder of your project (e.g. `Assets/Plugins`) in **Unity Editor**. +If you would like to use that dll in your **[Unity]** project, you should add it to any folder of your project (e.g. `Assets/Plugins`) in the **Unity Editor**. ### NuGet Gallery ### From 8212ca03dea14ec79e2772b4f82ed75fd0dea4a8 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 27 Oct 2016 15:36:55 +0900 Subject: [PATCH 0720/6294] [Modify] Replace them --- websocket-sharp/Server/WebSocketServer.cs | 24 +++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index ed25b192a..7186ef94a 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -70,11 +70,13 @@ public class WebSocketServer private Logger _logger; private int _port; private string _realm; + private string _realmInUse; private Thread _receiveThread; private bool _reuseAddress; private bool _secure; private WebSocketServiceManager _services; private ServerSslConfiguration _sslConfig; + private ServerSslConfiguration _sslConfigInUse; private volatile ServerState _state; private object _sync; private Func _userCredFinder; @@ -786,8 +788,8 @@ private void receiveRequest () ThreadPool.QueueUserWorkItem ( state => { try { - var ctx = cl.GetWebSocketContext (null, _secure, _sslConfig, _logger); - if (!ctx.Authenticate (_authSchemes, getRealm (), _userCredFinder)) + var ctx = cl.GetWebSocketContext (null, _secure, _sslConfigInUse, _logger); + if (!ctx.Authenticate (_authSchemes, _realmInUse, _userCredFinder)) return; processRequest (ctx); @@ -940,13 +942,27 @@ public bool RemoveWebSocketService (string path) /// public void Start () { + string msg; + if (!checkIfAvailable (true, false, false, true, out msg)) { + _logger.Error (msg); + return; + } + + var sslConfig = getSslConfiguration (); + if (!checkSslConfiguration (sslConfig, out msg)) { + _logger.Error (msg); + return; + } + lock (_sync) { - var msg = _state.CheckIfAvailable (true, false, false) ?? checkIfCertificateExists (); - if (msg != null) { + if (!checkIfAvailable (true, false, false, true, out msg)) { _logger.Error (msg); return; } + _realmInUse = getRealm (); + _sslConfigInUse = sslConfig; + _services.Start (); startReceiving (); From 053558b5736a92718145ce8440b73a37067e5273 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 27 Oct 2016 15:41:04 +0900 Subject: [PATCH 0721/6294] [Modify] Remove it --- websocket-sharp/Server/WebSocketServer.cs | 7 ------- 1 file changed, 7 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 7186ef94a..8ff78003e 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -681,13 +681,6 @@ private bool checkIfAvailable ( return true; } - private string checkIfCertificateExists () - { - return _secure && (_sslConfig == null || _sslConfig.ServerCertificate == null) - ? "The secure connection requires a server certificate." - : null; - } - private bool checkSslConfiguration ( ServerSslConfiguration configuration, out string message ) From 0cd0f51a570ce2e3f2ec6aa0d6dcdef970948ba3 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 27 Oct 2016 15:44:23 +0900 Subject: [PATCH 0722/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 8ff78003e..6048e4a1d 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -931,7 +931,7 @@ public bool RemoveWebSocketService (string path) } /// - /// Starts receiving the WebSocket connection requests. + /// Starts receiving the WebSocket handshake requests. /// public void Start () { From 7f491cfc593c3f2b6e6cabcb5117615ab2bf0ce2 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 28 Oct 2016 15:56:28 +0900 Subject: [PATCH 0723/6294] [Modify] Remove setter --- websocket-sharp/Server/WebSocketServer.cs | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 6048e4a1d..6884635ad 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -533,16 +533,6 @@ public ServerSslConfiguration SslConfiguration { get { return _sslConfig ?? (_sslConfig = new ServerSslConfiguration (null)); } - - set { - var msg = _state.CheckIfAvailable (true, false, false); - if (msg != null) { - _logger.Error (msg); - return; - } - - _sslConfig = value; - } } /// From 7b240345e3e233c49c5245b17fbeef67b336861b Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 29 Oct 2016 17:26:43 +0900 Subject: [PATCH 0724/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 6884635ad..c6be71d17 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -522,12 +522,16 @@ public bool ReuseAddress { } /// - /// Gets or sets the SSL configuration used to authenticate the server and - /// optionally the client for secure connection. + /// Gets the configuration used to authenticate the server and + /// optionally the client for the secure connection. /// + /// + /// The configuration will be referenced when the server starts. + /// So you must configure it before calling the start method. + /// /// - /// A that represents the configuration used to - /// authenticate the server and optionally the client for secure connection. + /// A that represents + /// the configuration for the secure connection. /// public ServerSslConfiguration SslConfiguration { get { From db01e9e7f7f27d9865a4c3e6ddad00c0f3ad4d15 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 30 Oct 2016 18:15:05 +0900 Subject: [PATCH 0725/6294] [Modify] Edit it --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index bf50ac9e2..6227060a8 100644 --- a/README.md +++ b/README.md @@ -432,19 +432,19 @@ For more information, would you see **[Example3]**? #### Per-message Compression #### -websocket-sharp supports the **[Per-message Compression][compression]** extension (but doesn't support this extension with the [context take over]). +websocket-sharp supports the [Per-message Compression][compression] extension (but does not support it with the [context take over]). -As a WebSocket client, if you would like to enable this extension, you should set such as the following. +As a WebSocket client, if you would like to enable this extension, you should set the `WebSocket.Compression` property to a compression method before calling the connect method. ```csharp ws.Compression = CompressionMethod.Deflate; ``` -And then your client will send the following header in the handshake request to the server. +And then the client will send the following header in the handshake request to the server. Sec-WebSocket-Extensions: permessage-deflate; server_no_context_takeover; client_no_context_takeover -If the server accepts this extension, it will return the same header which has the corresponding value. And when your client receives it, this extension will be available. +If the server accepts this header, it returns the same header which has the corresponding value. And this extension will be available when the client receives it. #### Ignoring the extensions #### From 8ffee004e5d3c9f3b74704858ad9fa3583183bdb Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 31 Oct 2016 16:58:57 +0900 Subject: [PATCH 0726/6294] [Modify] Edit it --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 6227060a8..9f01e2d28 100644 --- a/README.md +++ b/README.md @@ -444,7 +444,9 @@ And then the client will send the following header in the handshake request to t Sec-WebSocket-Extensions: permessage-deflate; server_no_context_takeover; client_no_context_takeover -If the server accepts this header, it returns the same header which has the corresponding value. And this extension will be available when the client receives it. +If the server supports this extension, it will return the same header which has the corresponding value. + +So eventually this extension will be available when the client receives the header in the handshake response. #### Ignoring the extensions #### From a0fa4b519b40f57cea2db9cf82bb2379a2b8913a Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 1 Nov 2016 15:40:39 +0900 Subject: [PATCH 0727/6294] [Modify] Edit it --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9f01e2d28..39591c23d 100644 --- a/README.md +++ b/README.md @@ -463,7 +463,7 @@ wssv.AddWebSocketService ( ); ``` -If it's set to `true`, the service will not return the **Sec-WebSocket-Extensions** header in its handshake response. +If it is set to `true`, the service will not return the Sec-WebSocket-Extensions header in its handshake response. I think this is useful when you get something error in connecting the server and exclude the extensions as a cause of the error. From f1d0586270af450c8a05da245dc3802545850520 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 1 Nov 2016 15:52:05 +0900 Subject: [PATCH 0728/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 602ddb9de..364ad1ca0 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -310,9 +310,16 @@ public CompressionMethod Compression { } set { + string msg; + if (!checkIfAvailable (true, false, true, false, false, true, out msg)) { + _logger.Error (msg); + error ("An error has occurred in setting the compression.", null); + + return; + } + lock (_forState) { - string msg; - if (!checkIfAvailable (true, false, true, false, false, true, out msg)) { + if (!checkIfAvailable (true, false, false, true, out msg)) { _logger.Error (msg); error ("An error has occurred in setting the compression.", null); From 7f7be0d757b0d10bddb4e640e40662e339fe9f00 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 1 Nov 2016 16:03:50 +0900 Subject: [PATCH 0729/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 364ad1ca0..db1118645 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -298,11 +298,13 @@ internal bool IsConnected { #region Public Properties /// - /// Gets or sets the compression method used to compress a message on the WebSocket connection. + /// Gets or sets the compression method used to compress a message on + /// the WebSocket connection. /// /// - /// One of the enum values, specifies the compression method - /// used to compress a message. The default value is . + /// One of the enum values that specifies + /// the compression method used to compress a message. The default value is + /// . /// public CompressionMethod Compression { get { From 4131e2c3e64495387a1952b4b2e37c04d25ce62d Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 2 Nov 2016 16:14:40 +0900 Subject: [PATCH 0730/6294] [Modify] Edit it --- websocket-sharp/CompressionMethod.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/CompressionMethod.cs b/websocket-sharp/CompressionMethod.cs index 6e5aaaa54..326e06dbd 100644 --- a/websocket-sharp/CompressionMethod.cs +++ b/websocket-sharp/CompressionMethod.cs @@ -31,11 +31,12 @@ namespace WebSocketSharp { /// - /// Specifies the compression method used to compress a message on the WebSocket connection. + /// Specifies the compression method used to compress a message on + /// the WebSocket connection. /// /// - /// The compression methods are defined in - /// + /// The compression methods that can be used are defined in + /// /// Compression Extensions for WebSocket. /// public enum CompressionMethod : byte From a5c19b14d67fc9157c9fc5a98aa4bf945b9bda0d Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 2 Nov 2016 16:16:10 +0900 Subject: [PATCH 0731/6294] [Modify] 2016 --- websocket-sharp/CompressionMethod.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/CompressionMethod.cs b/websocket-sharp/CompressionMethod.cs index 326e06dbd..e7f4bcc00 100644 --- a/websocket-sharp/CompressionMethod.cs +++ b/websocket-sharp/CompressionMethod.cs @@ -4,7 +4,7 @@ * * The MIT License * - * Copyright (c) 2013-2015 sta.blockhead + * Copyright (c) 2013-2016 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From 07211d3ad6621ee28fc1ee8b91b329a45be60ea7 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 3 Nov 2016 15:59:35 +0900 Subject: [PATCH 0732/6294] [Modify] Add it --- websocket-sharp/Server/WebSocketServer.cs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index c6be71d17..227e593f4 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -675,6 +675,28 @@ private bool checkIfAvailable ( return true; } + private bool checkServicePath (string path, out string message) + { + message = null; + + if (path.IsNullOrEmpty ()) { + message = "'path' is null or empty."; + return false; + } + + if (path[0] != '/') { + message = "'path' is not an absolute path."; + return false; + } + + if (path.IndexOfAny (new[] { '?', '#' }) > -1) { + message = "'path' includes either or both query and fragment components."; + return false; + } + + return true; + } + private bool checkSslConfiguration ( ServerSslConfiguration configuration, out string message ) From 483372aa772c05c424e32fcd92f8a8081685ec48 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 3 Nov 2016 16:07:56 +0900 Subject: [PATCH 0733/6294] [Modify] Replace it --- websocket-sharp/Server/WebSocketServer.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 227e593f4..a26da84a7 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -937,8 +937,8 @@ public void AddWebSocketService (string path) /// public bool RemoveWebSocketService (string path) { - var msg = path.CheckIfValidServicePath (); - if (msg != null) { + string msg; + if (!checkServicePath (path, out msg)) { _logger.Error (msg); return false; } From fe17a3bc0496f60ba95c8fc21b44be094f70a9cf Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 3 Nov 2016 17:37:02 +0900 Subject: [PATCH 0734/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index a26da84a7..b53bfba48 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -923,17 +923,18 @@ public void AddWebSocketService (string path) } /// - /// Removes the WebSocket service with the specified . + /// Removes a WebSocket service with the specified . /// /// - /// This method converts to URL-decoded string, + /// This method converts to a URL-decoded string, /// and removes '/' from tail end of . /// /// - /// true if the service is successfully found and removed; otherwise, false. + /// true if the service is successfully found and removed; + /// otherwise, false. /// /// - /// A that represents the absolute path to the service to find. + /// A that represents an absolute path to the service. /// public bool RemoveWebSocketService (string path) { From 0c29a4466428a2cd521d2ea6b741cdba86fb845c Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 3 Nov 2016 17:47:25 +0900 Subject: [PATCH 0735/6294] [Modify] Replace it --- websocket-sharp/Server/WebSocketServer.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index b53bfba48..7bfda9d89 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -919,7 +919,13 @@ public void AddWebSocketService (string path, Func initial public void AddWebSocketService (string path) where TBehaviorWithNew : WebSocketBehavior, new () { - AddWebSocketService (path, () => new TBehaviorWithNew ()); + string msg; + if (!checkServicePath (path, out msg)) { + _logger.Error (msg); + return; + } + + _services.Add (path, () => new TBehaviorWithNew ()); } /// From 5209c490e35bce29fdf8db094a5243dd4bbf8b80 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 4 Nov 2016 16:14:57 +0900 Subject: [PATCH 0736/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 7bfda9d89..5a2230d7b 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -902,19 +902,18 @@ public void AddWebSocketService (string path, Func initial } /// - /// Adds a WebSocket service with the specified behavior and . + /// Adds a WebSocket service with the specified behavior and + /// . /// - /// - /// This method converts to URL-decoded string, - /// and removes '/' from tail end of . - /// /// - /// A that represents the absolute path to the service to add. + /// A that represents an absolute path to + /// the service. It will be converted to a URL-decoded string, + /// and will be removed '/' from tail end if any. /// /// - /// The type of the behavior of the service to add. The TBehaviorWithNew must inherit - /// the class, and must have a public parameterless - /// constructor. + /// The type of the behavior for the service. It must inherit + /// the class, and must have + /// a public parameterless constructor. /// public void AddWebSocketService (string path) where TBehaviorWithNew : WebSocketBehavior, new () From bfab12625527a572cf3a2316c7d0ee5bf3f1839a Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 4 Nov 2016 16:19:56 +0900 Subject: [PATCH 0737/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 5a2230d7b..73e121197 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -930,16 +930,14 @@ public void AddWebSocketService (string path) /// /// Removes a WebSocket service with the specified . /// - /// - /// This method converts to a URL-decoded string, - /// and removes '/' from tail end of . - /// /// /// true if the service is successfully found and removed; /// otherwise, false. /// /// - /// A that represents an absolute path to the service. + /// A that represents an absolute path to + /// the service. It will be converted to a URL-decoded string, + /// and will be removed '/' from tail end if any. /// public bool RemoveWebSocketService (string path) { From c8a2bab27ad749eccb1624afb4eaf09308273a26 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 4 Nov 2016 16:30:16 +0900 Subject: [PATCH 0738/6294] [Modify] Replace it --- websocket-sharp/Server/WebSocketServer.cs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 73e121197..535439ec1 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -887,17 +887,22 @@ private static bool tryCreateUri (string uriString, out Uri result, out string m /// The type of the behavior of the service to add. The TBehavior must inherit /// the class. /// - public void AddWebSocketService (string path, Func initializer) + public void AddWebSocketService ( + string path, Func initializer + ) where TBehavior : WebSocketBehavior { - var msg = path.CheckIfValidServicePath () ?? - (initializer == null ? "'initializer' is null." : null); - - if (msg != null) { + string msg; + if (!checkServicePath (path, out msg)) { _logger.Error (msg); return; } + if (initializer == null) { + _logger.Error ("'initializer' is null."); + return; + } + _services.Add (path, initializer); } From 784ff0d225d6fbbcd5ad7b0bbfd936264a2dcbf0 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 5 Nov 2016 17:33:58 +0900 Subject: [PATCH 0739/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 27 +++++++++-------------- 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 535439ec1..b73741410 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -862,29 +862,22 @@ private static bool tryCreateUri (string uriString, out Uri result, out string m #region Public Methods /// - /// Adds a WebSocket service with the specified behavior, , - /// and . + /// Adds a WebSocket service with the specified behavior, + /// , and . /// - /// - /// - /// This method converts to URL-decoded string, - /// and removes '/' from tail end of . - /// - /// - /// returns an initialized specified typed - /// instance. - /// - /// /// - /// A that represents the absolute path to the service to add. + /// A that represents an absolute path to + /// the service. It will be converted to a URL-decoded string, + /// and will be removed '/' from tail end if any. /// /// - /// A Func<T> delegate that references the method used to initialize - /// a new specified typed instance (a new - /// instance). + /// A Func<TBehavior> delegate that invokes + /// the method used to create a new session instance for + /// the service. The method must create a new instance of + /// the specified behavior class and return it. /// /// - /// The type of the behavior of the service to add. The TBehavior must inherit + /// The type of the behavior for the service. It must inherit /// the class. /// public void AddWebSocketService ( From 0448d39383b12bf01ca158750afefb40d19f3b43 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 6 Nov 2016 15:49:25 +0900 Subject: [PATCH 0740/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 71febd7f3..3bdb4e3c3 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -351,7 +351,7 @@ private void onOpen (object sender, EventArgs e) internal void Start (WebSocketContext context, WebSocketSessionManager sessions) { if (_websocket != null) { - _websocket.Log.Error ("This session has already been started."); + _websocket.Log.Error ("A session instance cannot be reused."); context.WebSocket.Close (HttpStatusCode.ServiceUnavailable); return; From 4e234236c661e4757159aa66efd16b3a016a1060 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 7 Nov 2016 17:24:29 +0900 Subject: [PATCH 0741/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index b73741410..dbbdbe31d 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -305,11 +305,12 @@ public System.Net.IPAddress Address { /// /// Gets or sets a value indicating whether the server accepts - /// a forwarded request. + /// a handshake request without checking the request URI. /// /// - /// true if the server accepts a forwarded request; - /// otherwise, false. The default value is false. + /// true if the server accepts a handshake request without + /// checking the request URI; otherwise, false. The default + /// value is false. /// public bool AllowForwardedRequest { get { From af014718fc78638cc3a989616e768807b42a2345 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 8 Nov 2016 17:00:47 +0900 Subject: [PATCH 0742/6294] [Modify] Edit it --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 39591c23d..88bbd1832 100644 --- a/README.md +++ b/README.md @@ -379,15 +379,15 @@ wssv.AddWebSocketService ("/Chat"); wssv.AddWebSocketService ("/ChatWithNyan", () => new Chat (" Nyan!")); ``` -You can add any WebSocket service to your `WebSocketServer` with the specified behavior and path to the service, by using the `WebSocketServer.AddWebSocketService (string)` or `WebSocketServer.AddWebSocketService (string, Func)` method. +You can add any WebSocket service to your `WebSocketServer` with the specified behavior and absolute path to the service, by using the `WebSocketServer.AddWebSocketService (string)` or `WebSocketServer.AddWebSocketService (string, Func)` method. The type of `TBehaviorWithNew` must inherit the `WebSocketBehavior` class, and must have a public parameterless constructor. -And also the type of `TBehavior` must inherit the `WebSocketBehavior` class. +The type of `TBehavior` must inherit the `WebSocketBehavior` class. -So you can use the classes created in **Step 2** to add the service. +So you can use a class in the above Step 2 to add the service. -If you create a instance of the `WebSocketServer` class without a port number, the `WebSocketServer` class set the port number to **80** automatically. So it's necessary to run with root permission. +If you create a new instance of the `WebSocketServer` class without a port number, it sets the port number to **80**. So it is necessary to run with root permission. $ sudo mono example2.exe From a28a903debd2f8b8a35e3eb3cea675bbcd13775b Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 9 Nov 2016 16:54:05 +0900 Subject: [PATCH 0743/6294] [Modify] Edit it --- README.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 88bbd1832..1db3dfb81 100644 --- a/README.md +++ b/README.md @@ -501,19 +501,19 @@ wssv.SslConfiguration.ServerCertificate = ### HTTP Authentication ### -websocket-sharp supports the **[HTTP Authentication (Basic/Digest)][rfc2617]**. +websocket-sharp supports the [HTTP Authentication (Basic/Digest)][rfc2617]. -As a **WebSocket Client**, you should set a pair of user name and password for the HTTP authentication, by using the `WebSocket.SetCredentials (string, string, bool)` method before connecting. +As a WebSocket client, you should set a pair of user name and password for the HTTP authentication, by using the `WebSocket.SetCredentials (string, string, bool)` method before calling the connect method. ```csharp ws.SetCredentials ("nobita", "password", preAuth); ``` -If `preAuth` is `true`, the `WebSocket` will send the credentials for the Basic authentication with the first handshake request to the server. +If `preAuth` is `true`, the client will send the credentials for the Basic authentication in the first handshake request to the server. -Otherwise, the `WebSocket` will send the credentials for either the Basic or Digest (determined by the unauthorized response to the first handshake request) authentication with the second handshake request to the server. +Otherwise, it will send the credentials for either the Basic or Digest (determined by the unauthorized response to the first handshake request) authentication in the second handshake request to the server. -As a **WebSocket Server**, you should set an HTTP authentication scheme, a realm, and any function to find the user credentials before starting, such as the following. +As a WebSocket server, you should set an HTTP authentication scheme, a realm, and any function to find the user credentials before calling the start method, such as the following. ```csharp wssv.AuthenticationSchemes = AuthenticationSchemes.Basic; @@ -524,7 +524,7 @@ wssv.UserCredentialsFinder = id => { // Return user name, password, and roles. return name == "nobita" ? new NetworkCredential (name, "password", "gunfighter") - : null; // If the user credentials aren't found. + : null; // If the user credentials are not found. }; ``` From b0ece46068472deb9e97f41851585e8b5f29ac89 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 10 Nov 2016 16:48:28 +0900 Subject: [PATCH 0744/6294] [Modify] Edit it --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 1db3dfb81..2d4a0d2a6 100644 --- a/README.md +++ b/README.md @@ -603,18 +603,18 @@ wssv.AddWebSocketService ( ); ``` -### Connecting through the HTTP Proxy server ### +### Connecting through the HTTP proxy server ### -websocket-sharp supports to connect through the **HTTP Proxy** server. +websocket-sharp supports to connect through the HTTP proxy server. -If you would like to connect to a WebSocket server through the HTTP proxy server, you should set the proxy server URL, and if necessary, a pair of user name and password for the proxy server authentication (Basic/Digest), by using the `WebSocket.SetProxy (string, string, string)` method before connecting. +If you would like to connect to a WebSocket server through the HTTP proxy server, you should set the proxy server URL, and if necessary, a pair of user name and password for the proxy server authentication (Basic/Digest), by using the `WebSocket.SetProxy (string, string, string)` method before calling the connect method. ```csharp var ws = new WebSocket ("ws://example.com"); ws.SetProxy ("http://localhost:3128/", "nobita", "password"); ``` -I have tested this with **[Squid]**. It's necessary to disable the following configuration option in **squid.conf** (e.g. `/etc/squid/squid.conf`). +I have tested this with **[Squid]**. It is necessary to disable the following option in **squid.conf** (e.g. `/etc/squid/squid.conf`). ``` # Deny CONNECT to other than SSL ports From d05395e1553b927292a9c1548b329c5371fe6fce Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 11 Nov 2016 16:57:29 +0900 Subject: [PATCH 0745/6294] [Modify] Edit it --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2d4a0d2a6..7da6442e8 100644 --- a/README.md +++ b/README.md @@ -663,7 +663,7 @@ Would you access to [http://localhost:4649](http://localhost:4649) to do **WebSo ## Supported WebSocket Specifications ## -websocket-sharp supports **[RFC 6455][rfc6455]**, and it's based on the following WebSocket references: +websocket-sharp supports **RFC 6455**, and it is based on the following WebSocket references: - **[The WebSocket Protocol][rfc6455]** - **[The WebSocket API][api]** From 1938011fea79b5d2448bc8a364575ff3a91c2be4 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 12 Nov 2016 17:21:45 +0900 Subject: [PATCH 0746/6294] [Modify] Add a limitation for the reconnect --- websocket-sharp/WebSocket.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index db1118645..b66d884ca 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -93,6 +93,7 @@ public class WebSocket : IDisposable private bool _inContinuation; private volatile bool _inMessage; private volatile Logger _logger; + private static readonly int _maxRetryCountForConnect; private Action _message; private Queue _messageEventQueue; private uint _nonceCount; @@ -105,6 +106,7 @@ public class WebSocket : IDisposable private Uri _proxyUri; private volatile WebSocketState _readyState; private AutoResetEvent _receivePong; + private int _retryCountForConnect; private bool _secure; private ClientSslConfiguration _sslConfig; private Stream _stream; @@ -147,6 +149,7 @@ public class WebSocket : IDisposable static WebSocket () { + _maxRetryCountForConnect = 10; EmptyBytes = new byte[0]; FragmentLength = 1016; RandomNumber = new RNGCryptoServiceProvider (); @@ -1040,14 +1043,23 @@ private bool connect () return false; } + if (_retryCountForConnect > _maxRetryCountForConnect) { + _retryCountForConnect = 0; + _logger.Fatal ("A series of reconnecting has failed."); + + return false; + } + try { _readyState = WebSocketState.Connecting; if (!doHandshake ()) return false; + _retryCountForConnect = 1; _readyState = WebSocketState.Open; } catch (Exception ex) { + _retryCountForConnect++; _logger.Fatal (ex.ToString ()); fatal ("An exception has occurred while connecting.", ex); @@ -1169,6 +1181,7 @@ private bool doHandshake () string msg; if (!checkHandshakeResponse (res, out msg)) { + _retryCountForConnect++; _logger.Fatal (msg); fatal ("An error has occurred while connecting.", CloseStatusCode.ProtocolError); From 0d9240c58a26b741e7809440473613e2afa2fa46 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 13 Nov 2016 17:35:42 +0900 Subject: [PATCH 0747/6294] [Modify] Not return a bool --- websocket-sharp/WebSocket.cs | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index b66d884ca..dd7590495 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1050,13 +1050,10 @@ private bool connect () return false; } - try { - _readyState = WebSocketState.Connecting; - if (!doHandshake ()) - return false; + _readyState = WebSocketState.Connecting; - _retryCountForConnect = 1; - _readyState = WebSocketState.Open; + try { + doHandshake (); } catch (Exception ex) { _retryCountForConnect++; @@ -1066,6 +1063,9 @@ private bool connect () return false; } + _retryCountForConnect = 1; + _readyState = WebSocketState.Open; + return true; } } @@ -1174,19 +1174,14 @@ private MessageEventArgs dequeueFromMessageEventQueue () } // As client - private bool doHandshake () + private void doHandshake () { setClientStream (); var res = sendHandshakeRequest (); string msg; - if (!checkHandshakeResponse (res, out msg)) { - _retryCountForConnect++; - _logger.Fatal (msg); - fatal ("An error has occurred while connecting.", CloseStatusCode.ProtocolError); - - return false; - } + if (!checkHandshakeResponse (res, out msg)) + throw new WebSocketException (CloseStatusCode.ProtocolError, msg); if (_protocolsRequested) _protocol = res.Headers["Sec-WebSocket-Protocol"]; @@ -1195,8 +1190,6 @@ private bool doHandshake () processSecWebSocketExtensionsServerHeader (res.Headers["Sec-WebSocket-Extensions"]); processCookies (res.Cookies); - - return true; } private void enqueueToMessageEventQueue (MessageEventArgs e) From 3e82b0930899714b12f88ce4acd4b242b311dcc4 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 14 Nov 2016 16:21:08 +0900 Subject: [PATCH 0748/6294] [Modify] Polish it --- websocket-sharp/WebSocketException.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocketException.cs b/websocket-sharp/WebSocketException.cs index 3380eaabe..f5d483f7e 100644 --- a/websocket-sharp/WebSocketException.cs +++ b/websocket-sharp/WebSocketException.cs @@ -78,7 +78,9 @@ internal WebSocketException (CloseStatusCode code, string message) { } - internal WebSocketException (CloseStatusCode code, string message, Exception innerException) + internal WebSocketException ( + CloseStatusCode code, string message, Exception innerException + ) : base (message ?? code.GetMessage (), innerException) { _code = code; From 947ccd8cb5d99ab98f8b8c68dc02bab004025074 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 14 Nov 2016 16:30:34 +0900 Subject: [PATCH 0749/6294] [Modify] Edit it --- websocket-sharp/WebSocketException.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocketException.cs b/websocket-sharp/WebSocketException.cs index f5d483f7e..3ca59776a 100644 --- a/websocket-sharp/WebSocketException.cs +++ b/websocket-sharp/WebSocketException.cs @@ -94,8 +94,8 @@ internal WebSocketException ( /// Gets the status code indicating the cause of the exception. /// /// - /// One of the enum values, represents the status code - /// indicating the cause of the exception. + /// One of the enum values that represents + /// the status code indicating the cause of the exception. /// public CloseStatusCode Code { get { From 4894d068148b2b65dd32efcf3caf0af0a797198c Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 15 Nov 2016 16:28:33 +0900 Subject: [PATCH 0750/6294] [Modify] Edit it --- websocket-sharp/WebSocketException.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocketException.cs b/websocket-sharp/WebSocketException.cs index 3ca59776a..28d3f31fc 100644 --- a/websocket-sharp/WebSocketException.cs +++ b/websocket-sharp/WebSocketException.cs @@ -31,7 +31,8 @@ namespace WebSocketSharp { /// - /// The exception that is thrown when a gets a fatal error. + /// The exception that is thrown when a fatal error occurs in + /// the WebSocket communication. /// public class WebSocketException : Exception { From 09e803ffd7cf53d44e32bee4d39ca1eeecbcb90c Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 15 Nov 2016 16:30:18 +0900 Subject: [PATCH 0751/6294] [Modify] 2016 --- websocket-sharp/WebSocketException.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocketException.cs b/websocket-sharp/WebSocketException.cs index 28d3f31fc..81d7c8081 100644 --- a/websocket-sharp/WebSocketException.cs +++ b/websocket-sharp/WebSocketException.cs @@ -4,7 +4,7 @@ * * The MIT License * - * Copyright (c) 2012-2014 sta.blockhead + * Copyright (c) 2012-2016 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From 00348958cfbd509abb454f068b2e7ed9e20f3ff1 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 16 Nov 2016 16:01:22 +0900 Subject: [PATCH 0752/6294] [Modify] Throw exceptions --- websocket-sharp/WebSocket.cs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index dd7590495..d67166c7d 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2664,14 +2664,12 @@ public bool Ping (string message) /// public void Send (byte[] data) { - var msg = _readyState.CheckIfAvailable (false, true, false, false) ?? - CheckSendParameter (data); + if (data == null) + throw new ArgumentNullException ("data"); - if (msg != null) { - _logger.Error (msg); - error ("An error has occurred in sending data.", null); - - return; + if (_readyState != WebSocketState.Open) { + var msg = "The current state of the connection is not Open."; + throw new InvalidOperationException (msg); } send (Opcode.Binary, new MemoryStream (data)); From e68d2ab62f4ae6b041f31e904bee654014198b7a Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 16 Nov 2016 16:19:03 +0900 Subject: [PATCH 0753/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index d67166c7d..4f1e2e7ae 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2657,11 +2657,17 @@ public bool Ping (string message) } /// - /// Sends binary using the WebSocket connection. + /// Sends the specified using the WebSocket connection. /// /// /// An array of that represents the binary data to send. /// + /// + /// is . + /// + /// + /// The current state of the connection is not Open. + /// public void Send (byte[] data) { if (data == null) From a391ce84c984a4251c81cd926336cf8c79cc93d2 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 16 Nov 2016 16:38:48 +0900 Subject: [PATCH 0754/6294] [Modify] Edit it --- websocket-sharp/WebSocketState.cs | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/websocket-sharp/WebSocketState.cs b/websocket-sharp/WebSocketState.cs index 469350cb9..68db661bb 100644 --- a/websocket-sharp/WebSocketState.cs +++ b/websocket-sharp/WebSocketState.cs @@ -35,27 +35,30 @@ namespace WebSocketSharp /// /// /// The values of this enumeration are defined in - /// The WebSocket API. + /// + /// The WebSocket API. /// public enum WebSocketState : ushort { /// - /// Equivalent to numeric value 0. Indicates that the connection hasn't yet been established. + /// Equivalent to numeric value 0. Indicates that the connection has not + /// yet been established. /// Connecting = 0, /// - /// Equivalent to numeric value 1. Indicates that the connection has been established, - /// and the communication is possible. + /// Equivalent to numeric value 1. Indicates that the connection has + /// been established, and the communication is possible. /// Open = 1, /// - /// Equivalent to numeric value 2. Indicates that the connection is going through - /// the closing handshake, or the WebSocket.Close method has been invoked. + /// Equivalent to numeric value 2. Indicates that the connection is + /// going through the closing handshake, or the close method has + /// been invoked. /// Closing = 2, /// - /// Equivalent to numeric value 3. Indicates that the connection has been closed or - /// couldn't be established. + /// Equivalent to numeric value 3. Indicates that the connection has + /// been closed or could not be established. /// Closed = 3 } From 946e64c79d262aa5c9f65758072d01d5437d02ab Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 16 Nov 2016 16:40:20 +0900 Subject: [PATCH 0755/6294] [Modify] 2016 --- websocket-sharp/WebSocketState.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocketState.cs b/websocket-sharp/WebSocketState.cs index 68db661bb..2cbcd688d 100644 --- a/websocket-sharp/WebSocketState.cs +++ b/websocket-sharp/WebSocketState.cs @@ -4,7 +4,7 @@ * * The MIT License * - * Copyright (c) 2010-2015 sta.blockhead + * Copyright (c) 2010-2016 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From 5a94a05bc7d1216db0515551ab5cb4cd996536e5 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 17 Nov 2016 04:17:26 +0900 Subject: [PATCH 0756/6294] [Modify] Throw exceptions --- websocket-sharp/WebSocket.cs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 4f1e2e7ae..b3d24b4d4 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2689,14 +2689,12 @@ public void Send (byte[] data) /// public void Send (FileInfo file) { - var msg = _readyState.CheckIfAvailable (false, true, false, false) ?? - CheckSendParameter (file); - - if (msg != null) { - _logger.Error (msg); - error ("An error has occurred in sending data.", null); + if (file == null) + throw new ArgumentNullException ("file"); - return; + if (_readyState != WebSocketState.Open) { + var msg = "The current state of the connection is not Open."; + throw new InvalidOperationException (msg); } send (Opcode.Binary, file.OpenRead ()); From b05a3098cf5f207ad24788a0307c68aebf017bbe Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 17 Nov 2016 04:24:23 +0900 Subject: [PATCH 0757/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index b3d24b4d4..05101552e 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2682,11 +2682,18 @@ public void Send (byte[] data) } /// - /// Sends the specified as binary data using the WebSocket connection. + /// Sends the specified as the binary data using + /// the WebSocket connection. /// /// /// A that represents the file to send. /// + /// + /// is . + /// + /// + /// The current state of the connection is not Open. + /// public void Send (FileInfo file) { if (file == null) From bc4b4a9d8e27cc045501c44c9d7d8e055004a432 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 17 Nov 2016 16:23:19 +0900 Subject: [PATCH 0758/6294] [Modify] Add it --- websocket-sharp/Ext.cs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index b5c5f302a..86cadae10 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -964,6 +964,22 @@ internal static bool TryCreateWebSocketUri ( return true; } + internal static bool TryOpenRead ( + this FileInfo fileInfo, out FileStream fileStream + ) + { + fileStream = null; + + try { + fileStream = fileInfo.OpenRead (); + } + catch { + return false; + } + + return true; + } + internal static string Unquote (this string value) { var start = value.IndexOf ('"'); From f5ab00bf4e1f9e68741603e5a5c90435c6526a29 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 17 Nov 2016 16:41:07 +0900 Subject: [PATCH 0759/6294] [Modify] Use it --- websocket-sharp/WebSocket.cs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 05101552e..28c092804 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2696,15 +2696,19 @@ public void Send (byte[] data) /// public void Send (FileInfo file) { - if (file == null) - throw new ArgumentNullException ("file"); - if (_readyState != WebSocketState.Open) { var msg = "The current state of the connection is not Open."; throw new InvalidOperationException (msg); } - send (Opcode.Binary, file.OpenRead ()); + if (file == null) + throw new ArgumentNullException ("file"); + + FileStream stream; + if (!file.TryOpenRead (out stream)) + throw new ArgumentException ("Cannot be opened to read.", "file"); + + send (Opcode.Binary, stream); } /// From a03257ca4a5c33fc0ed33bfa9c6a071604bbb316 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 17 Nov 2016 16:54:30 +0900 Subject: [PATCH 0760/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 28c092804..cf0caa4c6 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2688,11 +2688,14 @@ public void Send (byte[] data) /// /// A that represents the file to send. /// + /// + /// The current state of the connection is not Open. + /// /// /// is . /// - /// - /// The current state of the connection is not Open. + /// + /// cannot be opened to read. /// public void Send (FileInfo file) { From 63c3d134c9a6b3cbc956e9839e162f907f43f002 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 17 Nov 2016 16:57:16 +0900 Subject: [PATCH 0761/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index cf0caa4c6..a8363493e 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2670,14 +2670,14 @@ public bool Ping (string message) /// public void Send (byte[] data) { - if (data == null) - throw new ArgumentNullException ("data"); - if (_readyState != WebSocketState.Open) { var msg = "The current state of the connection is not Open."; throw new InvalidOperationException (msg); } + if (data == null) + throw new ArgumentNullException ("data"); + send (Opcode.Binary, new MemoryStream (data)); } From 3922d4c8efa39c7121ea4aceae6fae6ce2b8b111 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 17 Nov 2016 17:26:10 +0900 Subject: [PATCH 0762/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index a8363493e..ac699ed83 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2662,12 +2662,12 @@ public bool Ping (string message) /// /// An array of that represents the binary data to send. /// - /// - /// is . - /// /// /// The current state of the connection is not Open. /// + /// + /// is . + /// public void Send (byte[] data) { if (_readyState != WebSocketState.Open) { From 7e98434f6cb85a40384087eadc2ab4c962c3ade5 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 17 Nov 2016 17:29:47 +0900 Subject: [PATCH 0763/6294] [Modify] Add it --- websocket-sharp/Ext.cs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 86cadae10..9c9fdf8c9 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -964,6 +964,20 @@ internal static bool TryCreateWebSocketUri ( return true; } + internal static bool TryGetUTF8EncodedBytes (this string s, out byte[] bytes) + { + bytes = null; + + try { + bytes = Encoding.UTF8.GetBytes (s); + } + catch { + return false; + } + + return true; + } + internal static bool TryOpenRead ( this FileInfo fileInfo, out FileStream fileStream ) From c13dbeb05173fd4b98395c627b328ded22c1aaf3 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 18 Nov 2016 15:57:52 +0900 Subject: [PATCH 0764/6294] [Modify] Throw exceptions --- websocket-sharp/WebSocket.cs | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index ac699ed83..346f8e97e 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2722,17 +2722,19 @@ public void Send (FileInfo file) /// public void Send (string data) { - var msg = _readyState.CheckIfAvailable (false, true, false, false) ?? - CheckSendParameter (data); + if (_readyState != WebSocketState.Open) { + var msg = "The current state of the connection is not Open."; + throw new InvalidOperationException (msg); + } - if (msg != null) { - _logger.Error (msg); - error ("An error has occurred in sending data.", null); + if (data == null) + throw new ArgumentNullException ("data"); - return; - } + byte[] bytes; + if (!data.TryGetUTF8EncodedBytes (out bytes)) + throw new ArgumentException ("Cannot be UTF8 encoded.", "data"); - send (Opcode.Text, new MemoryStream (data.UTF8Encode ())); + send (Opcode.Text, new MemoryStream (bytes)); } /// From 1b52a2129da979de98898bd3495ccae568a0fa6b Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 18 Nov 2016 16:50:39 +0900 Subject: [PATCH 0765/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 346f8e97e..ed86c0f8f 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2715,11 +2715,20 @@ public void Send (FileInfo file) } /// - /// Sends text using the WebSocket connection. + /// Sends the specified using the WebSocket connection. /// /// /// A that represents the text data to send. /// + /// + /// The current state of the connection is not Open. + /// + /// + /// is . + /// + /// + /// cannot be UTF8 encoded. + /// public void Send (string data) { if (_readyState != WebSocketState.Open) { From 1ae31c647971f223153b98e3572be8e8a02a8118 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 19 Nov 2016 16:26:19 +0900 Subject: [PATCH 0766/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index ed86c0f8f..94b4eebdb 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -541,8 +541,9 @@ internal set { /// Gets the state of the WebSocket connection. /// /// - /// One of the enum values, indicates the state of the connection. - /// The default value is . + /// One of the enum values that indicates + /// the current state of the connection. The default value is + /// . /// public WebSocketState ReadyState { get { From 5b8239d9bdd010fb23a3aa4b23490b8c35c6f5bd Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 20 Nov 2016 16:36:22 +0900 Subject: [PATCH 0767/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 37 ++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 94b4eebdb..5de71341c 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1575,9 +1575,6 @@ private bool send (Opcode opcode, Stream stream) private bool send (Opcode opcode, Stream stream, bool compressed) { var len = stream.Length; - - /* Not fragmented */ - if (len == 0) return send (Fin.Final, opcode, EmptyBytes, compressed); @@ -1587,27 +1584,34 @@ private bool send (Opcode opcode, Stream stream, bool compressed) byte[] buff = null; if (quo == 0) { buff = new byte[rem]; - return stream.Read (buff, 0, rem) == rem && - send (Fin.Final, opcode, buff, compressed); + return stream.Read (buff, 0, rem) == rem + && send (Fin.Final, opcode, buff, compressed); } - buff = new byte[FragmentLength]; - if (quo == 1 && rem == 0) - return stream.Read (buff, 0, FragmentLength) == FragmentLength && - send (Fin.Final, opcode, buff, compressed); + if (quo == 1 && rem == 0) { + buff = new byte[FragmentLength]; + return stream.Read (buff, 0, FragmentLength) == FragmentLength + && send (Fin.Final, opcode, buff, compressed); + } - /* Send fragmented */ + /* Send fragments */ // Begin - if (stream.Read (buff, 0, FragmentLength) != FragmentLength || - !send (Fin.More, opcode, buff, compressed)) + buff = new byte[FragmentLength]; + var sent = stream.Read (buff, 0, FragmentLength) == FragmentLength + && send (Fin.More, opcode, buff, compressed); + + if (!sent) return false; var n = rem == 0 ? quo - 2 : quo - 1; - for (long i = 0; i < n; i++) - if (stream.Read (buff, 0, FragmentLength) != FragmentLength || - !send (Fin.More, Opcode.Cont, buff, compressed)) + for (long i = 0; i < n; i++) { + sent = stream.Read (buff, 0, FragmentLength) == FragmentLength + && send (Fin.More, Opcode.Cont, buff, compressed); + + if (!sent) return false; + } // End if (rem == 0) @@ -1615,7 +1619,8 @@ private bool send (Opcode opcode, Stream stream, bool compressed) else buff = new byte[rem]; - return stream.Read (buff, 0, rem) == rem && send (Fin.Final, Opcode.Cont, buff, compressed); + return stream.Read (buff, 0, rem) == rem + && send (Fin.Final, Opcode.Cont, buff, compressed); } private bool send (Fin fin, Opcode opcode, byte[] data, bool compressed) From 9b4b3def00ebc3adface8ea0d5e0e531dd6a789d Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 20 Nov 2016 16:44:07 +0900 Subject: [PATCH 0768/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 5de71341c..3b708637e 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1631,7 +1631,8 @@ private bool send (Fin fin, Opcode opcode, byte[] data, bool compressed) return false; } - return sendBytes (new WebSocketFrame (fin, opcode, data, compressed, _client).ToArray ()); + var frame = new WebSocketFrame (fin, opcode, data, compressed, _client); + return sendBytes (frame.ToArray ()); } } From 85ff491c5447f6d4c79806924ff2928e759efb95 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 21 Nov 2016 15:38:56 +0900 Subject: [PATCH 0769/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 3b708637e..f59f7387c 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1650,10 +1650,14 @@ private void sendAsync (Opcode opcode, Stream stream, Action completed) } catch (Exception ex) { _logger.Error (ex.ToString ()); - error ("An exception has occurred during a send callback.", ex); + error ( + "An exception has occurred during the callback for an async send.", + ex + ); } }, - null); + null + ); } private bool sendBytes (byte[] bytes) From ad563fa46c688094048fe3ed7a1df292e7bbe5d3 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 21 Nov 2016 15:44:44 +0900 Subject: [PATCH 0770/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index f59f7387c..d10c4c3cf 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1559,7 +1559,7 @@ private bool send (Opcode opcode, Stream stream) } catch (Exception ex) { _logger.Error (ex.ToString ()); - error ("An exception has occurred while sending data.", ex); + error ("An exception has occurred while sending.", ex); } finally { if (compressed) From c1ea361e2eb832fa1716865ab0b2f66f5d7b3560 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 21 Nov 2016 16:57:29 +0900 Subject: [PATCH 0771/6294] [Modify] Edit it --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 7da6442e8..c7d44d660 100644 --- a/README.md +++ b/README.md @@ -45,7 +45,7 @@ You can add websocket-sharp to your project with the **NuGet Package Manager**, ### Unity Asset Store ### -websocket-sharp is available on the Unity Asset Store. +websocket-sharp is available on the Unity Asset Store (Sorry, Not available now). - **[WebSocket-Sharp for Unity]** From 922cd7e3b4c32d4f2aca03845067684a993b2554 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 21 Nov 2016 18:01:22 +0900 Subject: [PATCH 0772/6294] [Modify] Throw exceptions --- websocket-sharp/WebSocket.cs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index d10c4c3cf..e1d975f7f 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2773,16 +2773,14 @@ public void Send (string data) /// public void SendAsync (byte[] data, Action completed) { - var msg = _readyState.CheckIfAvailable (false, true, false, false) ?? - CheckSendParameter (data); - - if (msg != null) { - _logger.Error (msg); - error ("An error has occurred in sending data.", null); - - return; + if (_readyState != WebSocketState.Open) { + var msg = "The current state of the connection is not Open."; + throw new InvalidOperationException (msg); } + if (data == null) + throw new ArgumentNullException ("data"); + sendAsync (Opcode.Binary, new MemoryStream (data), completed); } From abf84b401a5b1bbf3ad5a9b8b5f0c95dad0531a0 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 22 Nov 2016 16:30:55 +0900 Subject: [PATCH 0773/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index e1d975f7f..d450b227d 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2758,18 +2758,19 @@ public void Send (string data) } /// - /// Sends binary asynchronously using the WebSocket connection. + /// Sends the specified asynchronously using + /// the WebSocket connection. /// /// - /// This method doesn't wait for the send to be complete. + /// This method does not wait for the send to be complete. /// /// /// An array of that represents the binary data to send. /// /// - /// An Action<bool> delegate that references the method(s) called when - /// the send is complete. A passed to this delegate is true - /// if the send is complete successfully. + /// An Action<bool> delegate that invokes the method called when + /// the send is complete. A passed to this delegate will be + /// true if the send has done with no error. /// public void SendAsync (byte[] data, Action completed) { From 2fd8928eb993ab1c893f3c41bc6c8ba2c226e40f Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 22 Nov 2016 16:37:33 +0900 Subject: [PATCH 0774/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index d450b227d..dd89ed04c 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2772,6 +2772,12 @@ public void Send (string data) /// the send is complete. A passed to this delegate will be /// true if the send has done with no error. /// + /// + /// The current state of the connection is not Open. + /// + /// + /// is . + /// public void SendAsync (byte[] data, Action completed) { if (_readyState != WebSocketState.Open) { From e4542bee97d26a0d2bf94c620f542876843f617c Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 22 Nov 2016 16:42:14 +0900 Subject: [PATCH 0775/6294] [Modify] Throw exceptions --- websocket-sharp/WebSocket.cs | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index dd89ed04c..127738c03 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2808,17 +2808,19 @@ public void SendAsync (byte[] data, Action completed) /// public void SendAsync (FileInfo file, Action completed) { - var msg = _readyState.CheckIfAvailable (false, true, false, false) ?? - CheckSendParameter (file); + if (_readyState != WebSocketState.Open) { + var msg = "The current state of the connection is not Open."; + throw new InvalidOperationException (msg); + } - if (msg != null) { - _logger.Error (msg); - error ("An error has occurred in sending data.", null); + if (file == null) + throw new ArgumentNullException ("file"); - return; - } + FileStream stream; + if (!file.TryOpenRead (out stream)) + throw new ArgumentException ("Cannot be opened to read.", "file"); - sendAsync (Opcode.Binary, file.OpenRead (), completed); + sendAsync (Opcode.Binary, stream, completed); } /// From d13d4c8c797b5b35a754fa938c250b55368d5c1a Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 22 Nov 2016 16:54:13 +0900 Subject: [PATCH 0776/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 127738c03..fbb4cec61 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2792,20 +2792,29 @@ public void SendAsync (byte[] data, Action completed) } /// - /// Sends the specified as binary data asynchronously using - /// the WebSocket connection. + /// Sends the specified as the binary data + /// asynchronously using the WebSocket connection. /// /// - /// This method doesn't wait for the send to be complete. + /// This method does not wait for the send to be complete. /// /// /// A that represents the file to send. /// /// - /// An Action<bool> delegate that references the method(s) called when - /// the send is complete. A passed to this delegate is true - /// if the send is complete successfully. + /// An Action<bool> delegate that invokes the method called when + /// the send is complete. A passed to this delegate will be + /// true if the send has done with no error. /// + /// + /// The current state of the connection is not Open. + /// + /// + /// is . + /// + /// + /// cannot be opened to read. + /// public void SendAsync (FileInfo file, Action completed) { if (_readyState != WebSocketState.Open) { From 4cc4837fbe2e557747da6e6f2d2a4a8b90e99c6e Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 22 Nov 2016 17:04:22 +0900 Subject: [PATCH 0777/6294] [Modify] Throw exceptions --- websocket-sharp/WebSocket.cs | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index fbb4cec61..defdb859e 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2848,17 +2848,19 @@ public void SendAsync (FileInfo file, Action completed) /// public void SendAsync (string data, Action completed) { - var msg = _readyState.CheckIfAvailable (false, true, false, false) ?? - CheckSendParameter (data); + if (_readyState != WebSocketState.Open) { + var msg = "The current state of the connection is not Open."; + throw new InvalidOperationException (msg); + } - if (msg != null) { - _logger.Error (msg); - error ("An error has occurred in sending data.", null); + if (data == null) + throw new ArgumentNullException ("data"); - return; - } + byte[] bytes; + if (!data.TryGetUTF8EncodedBytes (out bytes)) + throw new ArgumentException ("Cannot be UTF8 encoded.", "data"); - sendAsync (Opcode.Text, new MemoryStream (data.UTF8Encode ()), completed); + sendAsync (Opcode.Text, new MemoryStream (bytes), completed); } /// From a985eea23017b3870a588b7c5b4603de1d701516 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 22 Nov 2016 17:36:10 +0900 Subject: [PATCH 0778/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index defdb859e..32e53a458 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2833,19 +2833,29 @@ public void SendAsync (FileInfo file, Action completed) } /// - /// Sends text asynchronously using the WebSocket connection. + /// Sends the specified asynchronously using + /// the WebSocket connection. /// /// - /// This method doesn't wait for the send to be complete. + /// This method does not wait for the send to be complete. /// /// /// A that represents the text data to send. /// /// - /// An Action<bool> delegate that references the method(s) called when - /// the send is complete. A passed to this delegate is true - /// if the send is complete successfully. + /// An Action<bool> delegate that invokes the method called when + /// the send is complete. A passed to this delegate will be + /// true if the send has done with no error. /// + /// + /// The current state of the connection is not Open. + /// + /// + /// is . + /// + /// + /// cannot be UTF8 encoded. + /// public void SendAsync (string data, Action completed) { if (_readyState != WebSocketState.Open) { From a002a77d1dbc887d31a910b7e30448e84f5a8761 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 22 Nov 2016 17:49:42 +0900 Subject: [PATCH 0779/6294] [Modify] Throw exceptions --- websocket-sharp/WebSocket.cs | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 32e53a458..ae9837eb7 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2893,15 +2893,19 @@ public void SendAsync (string data, Action completed) /// public void SendAsync (Stream stream, int length, Action completed) { - var msg = _readyState.CheckIfAvailable (false, true, false, false) ?? - CheckSendParameters (stream, length); + if (_readyState != WebSocketState.Open) { + var msg = "The current state of the connection is not Open."; + throw new InvalidOperationException (msg); + } - if (msg != null) { - _logger.Error (msg); - error ("An error has occurred in sending data.", null); + if (stream == null) + throw new ArgumentNullException ("stream"); - return; - } + if (!stream.CanRead) + throw new ArgumentException ("Cannot be read.", "stream"); + + if (length < 1) + throw new ArgumentException ("Less than 1.", "length"); stream.ReadBytesAsync ( length, From e65bd0aaee718bb0095e391b9c27e747350c0a38 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 23 Nov 2016 17:21:40 +0900 Subject: [PATCH 0780/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 39 ++++++++++++------------------------ 1 file changed, 13 insertions(+), 26 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index ae9837eb7..a923d5a30 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2907,35 +2907,22 @@ public void SendAsync (Stream stream, int length, Action completed) if (length < 1) throw new ArgumentException ("Less than 1.", "length"); - stream.ReadBytesAsync ( - length, - data => { - var len = data.Length; - if (len == 0) { - _logger.Error ("The data cannot be read from 'stream'."); - error ("An error has occurred in sending data.", null); + var bytes = stream.ReadBytes (length); - return; - } + var len = bytes.Length; + if (len == 0) + throw new ArgumentException ("No data could be read.", "stream"); - if (len < length) - _logger.Warn ( - String.Format ( - "The length of the data is less than 'length':\n expected: {0}\n actual: {1}", - length, - len - ) - ); + if (len < length) { + _logger.Warn ( + String.Format ( + "Only {0} byte(s) of data could be read from the specified stream.", + len + ) + ); + } - var sent = send (Opcode.Binary, new MemoryStream (data)); - if (completed != null) - completed (sent); - }, - ex => { - _logger.Error (ex.ToString ()); - error ("An exception has occurred while sending data.", ex); - } - ); + sendAsync (Opcode.Binary, new MemoryStream (bytes), completed); } /// From ecabc73eb007b5f1e3e3da29544772733706658d Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 24 Nov 2016 16:10:04 +0900 Subject: [PATCH 0781/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index a923d5a30..7ec75de33 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2874,22 +2874,23 @@ public void SendAsync (string data, Action completed) } /// - /// Sends binary data from the specified asynchronously using + /// Sends the specified of data from + /// the specified asynchronously using /// the WebSocket connection. /// /// - /// This method doesn't wait for the send to be complete. + /// This method does not wait for the send to be complete. /// /// - /// A from which contains the binary data to send. + /// A from which reads the binary data to send. /// /// /// An that represents the number of bytes to send. /// /// - /// An Action<bool> delegate that references the method(s) called when - /// the send is complete. A passed to this delegate is true - /// if the send is complete successfully. + /// An Action<bool> delegate that invokes the method called when + /// the send is complete. A passed to this delegate will be + /// true if the send has done with no error. /// public void SendAsync (Stream stream, int length, Action completed) { From cf2eb179c1204d93c6394bfcdf26ec3604d9e263 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 24 Nov 2016 16:34:54 +0900 Subject: [PATCH 0782/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 7ec75de33..e1f3e58bb 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2892,6 +2892,29 @@ public void SendAsync (string data, Action completed) /// the send is complete. A passed to this delegate will be /// true if the send has done with no error. /// + /// + /// The current state of the connection is not Open. + /// + /// + /// is . + /// + /// + /// + /// cannot be read. + /// + /// + /// -or- + /// + /// + /// is less than 1. + /// + /// + /// -or- + /// + /// + /// No data could be read from . + /// + /// public void SendAsync (Stream stream, int length, Action completed) { if (_readyState != WebSocketState.Open) { From e8d2eab0cf49bb89196988b7f41ca0fbf910d3a1 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 24 Nov 2016 16:53:12 +0900 Subject: [PATCH 0783/6294] [Modify] Add a check To determine if the file exists. --- websocket-sharp/WebSocket.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index e1f3e58bb..e63a5198d 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2718,6 +2718,9 @@ public void Send (FileInfo file) if (file == null) throw new ArgumentNullException ("file"); + if (!file.Exists) + throw new ArgumentException ("The file does not exist.", "file"); + FileStream stream; if (!file.TryOpenRead (out stream)) throw new ArgumentException ("Cannot be opened to read.", "file"); From 6043ce73251441226d6e4d6c815bd577d054013b Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 24 Nov 2016 17:08:41 +0900 Subject: [PATCH 0784/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index e63a5198d..43f71a890 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2693,37 +2693,37 @@ public void Send (byte[] data) } /// - /// Sends the specified as the binary data using + /// Sends the specified as the binary data using /// the WebSocket connection. /// - /// + /// /// A that represents the file to send. /// /// /// The current state of the connection is not Open. /// /// - /// is . + /// is . /// /// - /// cannot be opened to read. + /// cannot be opened to read. /// - public void Send (FileInfo file) + public void Send (FileInfo fileInfo) { if (_readyState != WebSocketState.Open) { var msg = "The current state of the connection is not Open."; throw new InvalidOperationException (msg); } - if (file == null) - throw new ArgumentNullException ("file"); + if (fileInfo == null) + throw new ArgumentNullException ("fileInfo"); - if (!file.Exists) - throw new ArgumentException ("The file does not exist.", "file"); + if (!fileInfo.Exists) + throw new ArgumentException ("The file does not exist.", "fileInfo"); FileStream stream; - if (!file.TryOpenRead (out stream)) - throw new ArgumentException ("Cannot be opened to read.", "file"); + if (!fileInfo.TryOpenRead (out stream)) + throw new ArgumentException ("The file could not be opened.", "fileInfo"); send (Opcode.Binary, stream); } From 0cdbc70bf5fa73ee91fefdfa40d9926326bec3a7 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 24 Nov 2016 17:27:19 +0900 Subject: [PATCH 0785/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 43f71a890..e9c655fc7 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2693,11 +2693,10 @@ public void Send (byte[] data) } /// - /// Sends the specified as the binary data using - /// the WebSocket connection. + /// Sends the specified file as the binary data using the WebSocket connection. /// /// - /// A that represents the file to send. + /// A that specifies the file to send. /// /// /// The current state of the connection is not Open. @@ -2706,7 +2705,15 @@ public void Send (byte[] data) /// is . /// /// - /// cannot be opened to read. + /// + /// The file does not exist. + /// + /// + /// -or- + /// + /// + /// The file could not be opened. + /// /// public void Send (FileInfo fileInfo) { From bd9724b25746d464ee3544dc312aad7da672d020 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 24 Nov 2016 17:31:13 +0900 Subject: [PATCH 0786/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index e9c655fc7..2b8493777 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2762,7 +2762,7 @@ public void Send (string data) byte[] bytes; if (!data.TryGetUTF8EncodedBytes (out bytes)) - throw new ArgumentException ("Cannot be UTF8 encoded.", "data"); + throw new ArgumentException ("Could not be UTF8 encoded.", "data"); send (Opcode.Text, new MemoryStream (bytes)); } From ee79cac635b7c5246c5a67238ecf843e4fc4dc72 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 24 Nov 2016 17:34:03 +0900 Subject: [PATCH 0787/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 2b8493777..920f02022 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2748,7 +2748,7 @@ public void Send (FileInfo fileInfo) /// is . /// /// - /// cannot be UTF8 encoded. + /// could not be UTF8 encoded. /// public void Send (string data) { From 2d54e45a464f24b56c86f53bfb97b775f7c7c390 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 25 Nov 2016 16:34:15 +0900 Subject: [PATCH 0788/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 920f02022..3bdfd53e9 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2762,7 +2762,7 @@ public void Send (string data) byte[] bytes; if (!data.TryGetUTF8EncodedBytes (out bytes)) - throw new ArgumentException ("Could not be UTF8 encoded.", "data"); + throw new ArgumentException ("It could not be UTF8 encoded.", "data"); send (Opcode.Text, new MemoryStream (bytes)); } From 747fc0557e1e274bc196b799185666b0125fb7ef Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 25 Nov 2016 16:38:51 +0900 Subject: [PATCH 0789/6294] [Modify] Add a check To determine if the file exists. --- websocket-sharp/WebSocket.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 3bdfd53e9..67fd3df0b 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2835,6 +2835,9 @@ public void SendAsync (FileInfo file, Action completed) if (file == null) throw new ArgumentNullException ("file"); + if (!file.Exists) + throw new ArgumentException ("The file does not exist.", "file"); + FileStream stream; if (!file.TryOpenRead (out stream)) throw new ArgumentException ("Cannot be opened to read.", "file"); From 1e288d344d5c7c834eea11db4898e96f8c3a68ce Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 25 Nov 2016 16:45:45 +0900 Subject: [PATCH 0790/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 67fd3df0b..249c3d540 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2802,13 +2802,13 @@ public void SendAsync (byte[] data, Action completed) } /// - /// Sends the specified as the binary data + /// Sends the specified as the binary data /// asynchronously using the WebSocket connection. /// /// /// This method does not wait for the send to be complete. /// - /// + /// /// A that represents the file to send. /// /// @@ -2820,27 +2820,27 @@ public void SendAsync (byte[] data, Action completed) /// The current state of the connection is not Open. /// /// - /// is . + /// is . /// /// - /// cannot be opened to read. + /// cannot be opened to read. /// - public void SendAsync (FileInfo file, Action completed) + public void SendAsync (FileInfo fileInfo, Action completed) { if (_readyState != WebSocketState.Open) { var msg = "The current state of the connection is not Open."; throw new InvalidOperationException (msg); } - if (file == null) - throw new ArgumentNullException ("file"); + if (fileInfo == null) + throw new ArgumentNullException ("fileInfo"); - if (!file.Exists) - throw new ArgumentException ("The file does not exist.", "file"); + if (!fileInfo.Exists) + throw new ArgumentException ("The file does not exist.", "fileInfo"); FileStream stream; - if (!file.TryOpenRead (out stream)) - throw new ArgumentException ("Cannot be opened to read.", "file"); + if (!fileInfo.TryOpenRead (out stream)) + throw new ArgumentException ("The file could not be opened.", "fileInfo"); sendAsync (Opcode.Binary, stream, completed); } From 0789794b2af4595da51440a76c8b1c2ad2d2e887 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 25 Nov 2016 17:00:12 +0900 Subject: [PATCH 0791/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 249c3d540..52be77cd2 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2802,14 +2802,14 @@ public void SendAsync (byte[] data, Action completed) } /// - /// Sends the specified as the binary data - /// asynchronously using the WebSocket connection. + /// Sends the specified file as the binary data asynchronously using + /// the WebSocket connection. /// /// /// This method does not wait for the send to be complete. /// /// - /// A that represents the file to send. + /// A that specifies a file to send. /// /// /// An Action<bool> delegate that invokes the method called when @@ -2823,7 +2823,15 @@ public void SendAsync (byte[] data, Action completed) /// is . /// /// - /// cannot be opened to read. + /// + /// The file does not exist. + /// + /// + /// -or- + /// + /// + /// The file could not be opened. + /// /// public void SendAsync (FileInfo fileInfo, Action completed) { From 218537d0a053cc01882e242026d716f26009c84a Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 25 Nov 2016 17:02:19 +0900 Subject: [PATCH 0792/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 52be77cd2..dfc730b40 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2696,7 +2696,7 @@ public void Send (byte[] data) /// Sends the specified file as the binary data using the WebSocket connection. /// /// - /// A that specifies the file to send. + /// A that specifies a file to send. /// /// /// The current state of the connection is not Open. From 86935bb131b4ee1b62845412af0045276c5ac0cc Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 25 Nov 2016 17:05:52 +0900 Subject: [PATCH 0793/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index dfc730b40..f7dd972b2 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2889,7 +2889,7 @@ public void SendAsync (string data, Action completed) byte[] bytes; if (!data.TryGetUTF8EncodedBytes (out bytes)) - throw new ArgumentException ("Cannot be UTF8 encoded.", "data"); + throw new ArgumentException ("It could not be UTF8 encoded.", "data"); sendAsync (Opcode.Text, new MemoryStream (bytes), completed); } From 5999b61afd3c9df090dc69e6954a9ab3222e3978 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 25 Nov 2016 17:10:10 +0900 Subject: [PATCH 0794/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index f7dd972b2..2e06c5fdc 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2875,7 +2875,7 @@ public void SendAsync (FileInfo fileInfo, Action completed) /// is . /// /// - /// cannot be UTF8 encoded. + /// could not be UTF8 encoded. /// public void SendAsync (string data, Action completed) { From 2f5af3e80eb303eed32e150d1040e104bc7c4429 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 26 Nov 2016 16:23:53 +0900 Subject: [PATCH 0795/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 2e06c5fdc..d34077bcc 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2947,16 +2947,16 @@ public void SendAsync (Stream stream, int length, Action completed) throw new ArgumentNullException ("stream"); if (!stream.CanRead) - throw new ArgumentException ("Cannot be read.", "stream"); + throw new ArgumentException ("It cannot be read.", "stream"); if (length < 1) - throw new ArgumentException ("Less than 1.", "length"); + throw new ArgumentException ("It is less than 1.", "length"); var bytes = stream.ReadBytes (length); var len = bytes.Length; if (len == 0) - throw new ArgumentException ("No data could be read.", "stream"); + throw new ArgumentException ("No data could be read from it.", "stream"); if (len < length) { _logger.Warn ( From edb7b0806bdbc0a4ed37e2141f3a7bb720479fe5 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 26 Nov 2016 16:35:07 +0900 Subject: [PATCH 0796/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index d34077bcc..866d3a762 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2906,7 +2906,7 @@ public void SendAsync (string data, Action completed) /// A from which reads the binary data to send. /// /// - /// An that represents the number of bytes to send. + /// An that specifies the number of bytes to read and send. /// /// /// An Action<bool> delegate that invokes the method called when From 6a349f461c672780c7bdd9d7954c5e1f35711f59 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 27 Nov 2016 18:09:23 +0900 Subject: [PATCH 0797/6294] [Modify] Add it --- websocket-sharp/WebSocket.cs | 68 ++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 866d3a762..38cea8027 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2767,6 +2767,74 @@ public void Send (string data) send (Opcode.Text, new MemoryStream (bytes)); } + /// + /// Sends the specified of data from + /// the specified using the WebSocket + /// connection. + /// + /// + /// A from which reads the binary data to send. + /// + /// + /// An that specifies the number of bytes to read and send. + /// + /// + /// The current state of the connection is not Open. + /// + /// + /// is . + /// + /// + /// + /// cannot be read. + /// + /// + /// -or- + /// + /// + /// is less than 1. + /// + /// + /// -or- + /// + /// + /// No data could be read from . + /// + /// + public void Send (Stream stream, int length) + { + if (_readyState != WebSocketState.Open) { + var msg = "The current state of the connection is not Open."; + throw new InvalidOperationException (msg); + } + + if (stream == null) + throw new ArgumentNullException ("stream"); + + if (!stream.CanRead) + throw new ArgumentException ("It cannot be read.", "stream"); + + if (length < 1) + throw new ArgumentException ("It is less than 1.", "length"); + + var bytes = stream.ReadBytes (length); + + var len = bytes.Length; + if (len == 0) + throw new ArgumentException ("No data could be read from it.", "stream"); + + if (len < length) { + _logger.Warn ( + String.Format ( + "Only {0} byte(s) of data could be read from the specified stream.", + len + ) + ); + } + + send (Opcode.Binary, new MemoryStream (bytes)); + } + /// /// Sends the specified asynchronously using /// the WebSocket connection. From ed1369a61b8244596934f19d461a9aa12f33773c Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 28 Nov 2016 16:46:09 +0900 Subject: [PATCH 0798/6294] [Fix] Remove unnecessary compressed --- websocket-sharp/WebSocket.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 38cea8027..4ffaffd23 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1576,7 +1576,7 @@ private bool send (Opcode opcode, Stream stream, bool compressed) { var len = stream.Length; if (len == 0) - return send (Fin.Final, opcode, EmptyBytes, compressed); + return send (Fin.Final, opcode, EmptyBytes, false); var quo = len / FragmentLength; var rem = (int) (len % FragmentLength); @@ -1607,7 +1607,7 @@ private bool send (Opcode opcode, Stream stream, bool compressed) var n = rem == 0 ? quo - 2 : quo - 1; for (long i = 0; i < n; i++) { sent = stream.Read (buff, 0, FragmentLength) == FragmentLength - && send (Fin.More, Opcode.Cont, buff, compressed); + && send (Fin.More, Opcode.Cont, buff, false); if (!sent) return false; @@ -1620,7 +1620,7 @@ private bool send (Opcode opcode, Stream stream, bool compressed) buff = new byte[rem]; return stream.Read (buff, 0, rem) == rem - && send (Fin.Final, Opcode.Cont, buff, compressed); + && send (Fin.Final, Opcode.Cont, buff, false); } private bool send (Fin fin, Opcode opcode, byte[] data, bool compressed) From 8e10174cab159b80f0eafb47dd7e605520852ef9 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 29 Nov 2016 16:25:26 +0900 Subject: [PATCH 0799/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 4ffaffd23..74b60d689 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1627,7 +1627,7 @@ private bool send (Fin fin, Opcode opcode, byte[] data, bool compressed) { lock (_forState) { if (_readyState != WebSocketState.Open) { - _logger.Error ("The sending has been interrupted."); + _logger.Error ("The state of the connection has been changed."); return false; } From 7eb110212df8082cb661e62bb2bf19dc2ff18214 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 29 Nov 2016 16:35:44 +0900 Subject: [PATCH 0800/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 74b60d689..4ff456cca 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1555,11 +1555,11 @@ private bool send (Opcode opcode, Stream stream) sent = send (opcode, stream, compressed); if (!sent) - error ("The sending has been interrupted.", null); + error ("A send has been interrupted.", null); } catch (Exception ex) { _logger.Error (ex.ToString ()); - error ("An exception has occurred while sending.", ex); + error ("An exception has occurred during a send.", ex); } finally { if (compressed) From a5a4b4365e3cd6af8c19f111b345eac8b506be32 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 29 Nov 2016 17:22:53 +0900 Subject: [PATCH 0801/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 4ff456cca..c628d9967 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1533,7 +1533,7 @@ private bool send (byte[] frameAsBytes) { lock (_forState) { if (_readyState != WebSocketState.Open) { - _logger.Error ("The sending has been interrupted."); + _logger.Error ("The state of the connection has been changed."); return false; } From 4780d94091af651f8d058faec2b6ce6faeac352e Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 30 Nov 2016 16:29:58 +0900 Subject: [PATCH 0802/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index c628d9967..73ca2d058 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2164,12 +2164,14 @@ internal bool Ping (byte[] frameAsBytes, TimeSpan timeout) } // As server, used to broadcast - internal void Send (Opcode opcode, byte[] data, Dictionary cache) + internal void Send ( + Opcode opcode, byte[] data, Dictionary cache + ) { lock (_forSend) { lock (_forState) { if (_readyState != WebSocketState.Open) { - _logger.Error ("The sending has been interrupted."); + _logger.Error ("The state of the connection has been changed."); return; } From e4289c7d0215cdc1ca64fe4bb189953e4c43b86d Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 30 Nov 2016 16:34:15 +0900 Subject: [PATCH 0803/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 73ca2d058..c69067024 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2201,7 +2201,9 @@ internal void Send ( } // As server, used to broadcast - internal void Send (Opcode opcode, Stream stream, Dictionary cache) + internal void Send ( + Opcode opcode, Stream stream, Dictionary cache + ) { lock (_forSend) { try { From da617e042c9770eb5315adaec92e6207bedd09e4 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 30 Nov 2016 16:37:31 +0900 Subject: [PATCH 0804/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index c69067024..6eeb5b19f 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1651,7 +1651,7 @@ private void sendAsync (Opcode opcode, Stream stream, Action completed) catch (Exception ex) { _logger.Error (ex.ToString ()); error ( - "An exception has occurred during the callback for an async send.", + "An error has occurred during the callback for an async send.", ex ); } From e79055912ec3a10c5c10c058737d32f2b45f7c1a Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 30 Nov 2016 16:41:15 +0900 Subject: [PATCH 0805/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 6eeb5b19f..273eddc2a 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1559,7 +1559,7 @@ private bool send (Opcode opcode, Stream stream) } catch (Exception ex) { _logger.Error (ex.ToString ()); - error ("An exception has occurred during a send.", ex); + error ("An error has occurred during a send.", ex); } finally { if (compressed) From 8d9bf2d5f48f00fda9bab44cf3b511414a7d9927 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 30 Nov 2016 16:46:47 +0900 Subject: [PATCH 0806/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 273eddc2a..ab42e1e71 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -998,7 +998,7 @@ private void close (CloseEventArgs e, bool send, bool receive, bool received) } catch (Exception ex) { _logger.Error (ex.ToString ()); - error ("An exception has occurred during the OnClose event.", ex); + error ("An error has occurred during the OnClose event.", ex); } } From 24ba4f9d28e7b0c110235d8fb0e762ac55f3d270 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 30 Nov 2016 16:49:11 +0900 Subject: [PATCH 0807/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index ab42e1e71..cb84290cf 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1256,7 +1256,7 @@ private void messagec (MessageEventArgs e) } catch (Exception ex) { _logger.Error (ex.ToString ()); - error ("An exception has occurred during an OnMessage event.", ex); + error ("An error has occurred during an OnMessage event.", ex); } lock (_forMessageEventQueue) { From f7c4f0ee1f7c1cd72ed725e20ec90135a25d47cb Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 30 Nov 2016 16:51:31 +0900 Subject: [PATCH 0808/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index cb84290cf..327406e00 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1278,7 +1278,7 @@ private void messages (MessageEventArgs e) } catch (Exception ex) { _logger.Error (ex.ToString ()); - error ("An exception has occurred during an OnMessage event.", ex); + error ("An error has occurred during an OnMessage event.", ex); } lock (_forMessageEventQueue) { From 0a55e6859c4d7707f52af5ba429d25472ab8f98f Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 30 Nov 2016 16:58:10 +0900 Subject: [PATCH 0809/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 327406e00..4aff41b00 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1302,7 +1302,7 @@ private void open () } catch (Exception ex) { _logger.Error (ex.ToString ()); - error ("An exception has occurred during the OnOpen event.", ex); + error ("An error has occurred during the OnOpen event.", ex); } MessageEventArgs e = null; From cd6b510cbd97c350f0a23ad990885f0eb3645507 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 1 Dec 2016 16:05:57 +0900 Subject: [PATCH 0810/6294] [Modify] Add it --- websocket-sharp/Ext.cs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 9c9fdf8c9..620458148 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -964,6 +964,20 @@ internal static bool TryCreateWebSocketUri ( return true; } + internal static bool TryGetUTF8DecodedString (this byte[] bytes, out string s) + { + s = null; + + try { + s = Encoding.UTF8.GetString (bytes); + } + catch { + return false; + } + + return true; + } + internal static bool TryGetUTF8EncodedBytes (this string s, out byte[] bytes) { bytes = null; From 66858b524c4ff1516480af619e4c686e3975dafa Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 2 Dec 2016 17:55:05 +0900 Subject: [PATCH 0811/6294] [Modify] Add it --- websocket-sharp/WebSocket.cs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 4aff41b00..043e4529a 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1318,6 +1318,23 @@ private void open () _message.BeginInvoke (e, ar => _message.EndInvoke (ar), null); } + private bool ping (byte[] data) + { + if (_readyState != WebSocketState.Open) + return false; + + var receivePong = _receivePong; + if (receivePong == null) + return false; + + receivePong.Reset (); + + if (!send (Fin.Final, Opcode.Ping, data, false)) + return false; + + return receivePong.WaitOne (_waitTime); + } + private bool processCloseFrame (WebSocketFrame frame) { var payload = frame.PayloadData; From 583933993b17b292852e1f3547785c008d64be5e Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 3 Dec 2016 16:44:57 +0900 Subject: [PATCH 0812/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 043e4529a..c8eb10ca0 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1327,12 +1327,16 @@ private bool ping (byte[] data) if (receivePong == null) return false; - receivePong.Reset (); + try { + receivePong.Reset (); + if (!send (Fin.Final, Opcode.Ping, data, false)) + return false; - if (!send (Fin.Final, Opcode.Ping, data, false)) + return receivePong.WaitOne (_waitTime); + } + catch (ObjectDisposedException) { return false; - - return receivePong.WaitOne (_waitTime); + } } private bool processCloseFrame (WebSocketFrame frame) From 059624f23c600c77d588a260bc76397ce98803cb Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 4 Dec 2016 17:05:55 +0900 Subject: [PATCH 0813/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index c8eb10ca0..b99e0cb30 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -82,6 +82,7 @@ public class WebSocket : IDisposable private string _extensions; private bool _extensionsRequested; private object _forMessageEventQueue; + private object _forPing; private object _forSend; private object _forState; private MemoryStream _fragmentsBuffer; @@ -1227,6 +1228,7 @@ private void init () { _compression = CompressionMethod.None; _cookies = new CookieCollection (); + _forPing = new object (); _forSend = new object (); _forState = new object (); _messageEventQueue = new Queue (); @@ -1327,15 +1329,17 @@ private bool ping (byte[] data) if (receivePong == null) return false; - try { - receivePong.Reset (); - if (!send (Fin.Final, Opcode.Ping, data, false)) - return false; + lock (_forPing) { + try { + receivePong.Reset (); + if (!send (Fin.Final, Opcode.Ping, data, false)) + return false; - return receivePong.WaitOne (_waitTime); - } - catch (ObjectDisposedException) { - return false; + return receivePong.WaitOne (_waitTime); + } + catch (ObjectDisposedException) { + return false; + } } } From c9a11bdad88adea8fd3e5fcf4419795e8fa4db02 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 4 Dec 2016 17:30:10 +0900 Subject: [PATCH 0814/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index b99e0cb30..57e9a9be9 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1415,7 +1415,7 @@ private bool processPingFrame (WebSocketFrame frame) private bool processPongFrame (WebSocketFrame frame) { _receivePong.Set (); - _logger.Trace ("Received a pong."); + _logger.Trace ("A pong frame was received."); return true; } From d4b7e6dd2ccd38d6e85ee5de9b046772d420fc9e Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 5 Dec 2016 16:34:59 +0900 Subject: [PATCH 0815/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 57e9a9be9..95625a056 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1403,8 +1403,11 @@ private bool processFragmentFrame (WebSocketFrame frame) private bool processPingFrame (WebSocketFrame frame) { - if (send (new WebSocketFrame (Opcode.Pong, frame.PayloadData, _client).ToArray ())) - _logger.Trace ("Returned a pong."); + var data = frame.PayloadData.ApplicationData; + if (!send (Fin.Final, Opcode.Pong, data, false)) + return false; + + _logger.Debug ("A pong has been sent to respond to this ping."); if (_emitOnPing) enqueueToMessageEventQueue (new MessageEventArgs (frame)); From f9b0c99b697aa75af09f97e65dac16755119cd38 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 6 Dec 2016 16:33:22 +0900 Subject: [PATCH 0816/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 95625a056..d40fcd824 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1417,8 +1417,17 @@ private bool processPingFrame (WebSocketFrame frame) private bool processPongFrame (WebSocketFrame frame) { - _receivePong.Set (); - _logger.Trace ("A pong frame was received."); + try { + _receivePong.Set (); + } + catch (NullReferenceException) { + return false; + } + catch (ObjectDisposedException) { + return false; + } + + _logger.Trace ("It has been signaled that a pong was received."); return true; } From aea4f8318645fb19287135afd734c6ead74daa99 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 6 Dec 2016 16:39:10 +0900 Subject: [PATCH 0817/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index d40fcd824..14a159ff9 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1407,7 +1407,7 @@ private bool processPingFrame (WebSocketFrame frame) if (!send (Fin.Final, Opcode.Pong, data, false)) return false; - _logger.Debug ("A pong has been sent to respond to this ping."); + _logger.Trace ("A pong has been sent to respond to this ping."); if (_emitOnPing) enqueueToMessageEventQueue (new MessageEventArgs (frame)); From 8961af92749f219c295c5f4b333211ab50701ecf Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 7 Dec 2016 16:35:44 +0900 Subject: [PATCH 0818/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 14a159ff9..8166a6dd6 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2190,14 +2190,30 @@ internal bool Ping (byte[] frameAsBytes, TimeSpan timeout) if (_readyState != WebSocketState.Open) return false; - if (!send (frameAsBytes)) - return false; - var receivePong = _receivePong; if (receivePong == null) return false; - return receivePong.WaitOne (timeout); + lock (_forPing) { + try { + receivePong.Reset (); + + lock (_forState) { + if (_readyState != WebSocketState.Open) { + _logger.Error ("The state of the connection has been changed."); + return false; + } + + if (!sendBytes (frameAsBytes)) + return false; + } + + return receivePong.WaitOne (timeout); + } + catch (ObjectDisposedException) { + return false; + } + } } // As server, used to broadcast From 6f2708dca5f992a885e9b18ae7d08b6b1e047bc3 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 7 Dec 2016 16:50:50 +0900 Subject: [PATCH 0819/6294] [Modify] Use ManualResetEvent instead --- websocket-sharp/WebSocket.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 8166a6dd6..eb0e1cfee 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -78,7 +78,7 @@ public class WebSocket : IDisposable private NetworkCredential _credentials; private bool _emitOnPing; private bool _enableRedirection; - private AutoResetEvent _exitReceiving; + private ManualResetEvent _exitReceiving; private string _extensions; private bool _extensionsRequested; private object _forMessageEventQueue; @@ -106,7 +106,7 @@ public class WebSocket : IDisposable private NetworkCredential _proxyCredentials; private Uri _proxyUri; private volatile WebSocketState _readyState; - private AutoResetEvent _receivePong; + private ManualResetEvent _receivePong; private int _retryCountForConnect; private bool _secure; private ClientSslConfiguration _sslConfig; @@ -1872,8 +1872,8 @@ private void startReceiving () if (_messageEventQueue.Count > 0) _messageEventQueue.Clear (); - _exitReceiving = new AutoResetEvent (false); - _receivePong = new AutoResetEvent (false); + _exitReceiving = new ManualResetEvent (false); + _receivePong = new ManualResetEvent (false); Action receive = null; receive = From 2b06dedec9b05417cb26e24d16fff309c9ad4ac4 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 7 Dec 2016 17:03:15 +0900 Subject: [PATCH 0820/6294] [Modify] Rename it --- websocket-sharp/WebSocket.cs | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index eb0e1cfee..1b78d2ec8 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -99,6 +99,7 @@ public class WebSocket : IDisposable private Queue _messageEventQueue; private uint _nonceCount; private string _origin; + private ManualResetEvent _pongReceived; private bool _preAuth; private string _protocol; private string[] _protocols; @@ -106,7 +107,6 @@ public class WebSocket : IDisposable private NetworkCredential _proxyCredentials; private Uri _proxyUri; private volatile WebSocketState _readyState; - private ManualResetEvent _receivePong; private int _retryCountForConnect; private bool _secure; private ClientSslConfiguration _sslConfig; @@ -1325,17 +1325,17 @@ private bool ping (byte[] data) if (_readyState != WebSocketState.Open) return false; - var receivePong = _receivePong; - if (receivePong == null) + var pongReceived = _pongReceived; + if (pongReceived == null) return false; lock (_forPing) { try { - receivePong.Reset (); + pongReceived.Reset (); if (!send (Fin.Final, Opcode.Ping, data, false)) return false; - return receivePong.WaitOne (_waitTime); + return pongReceived.WaitOne (_waitTime); } catch (ObjectDisposedException) { return false; @@ -1418,7 +1418,7 @@ private bool processPingFrame (WebSocketFrame frame) private bool processPongFrame (WebSocketFrame frame) { try { - _receivePong.Set (); + _pongReceived.Set (); } catch (NullReferenceException) { return false; @@ -1533,9 +1533,9 @@ private void releaseCommonResources () _inContinuation = false; } - if (_receivePong != null) { - _receivePong.Close (); - _receivePong = null; + if (_pongReceived != null) { + _pongReceived.Close (); + _pongReceived = null; } if (_exitReceiving != null) { @@ -1873,7 +1873,7 @@ private void startReceiving () _messageEventQueue.Clear (); _exitReceiving = new ManualResetEvent (false); - _receivePong = new ManualResetEvent (false); + _pongReceived = new ManualResetEvent (false); Action receive = null; receive = @@ -2190,13 +2190,13 @@ internal bool Ping (byte[] frameAsBytes, TimeSpan timeout) if (_readyState != WebSocketState.Open) return false; - var receivePong = _receivePong; - if (receivePong == null) + var pongReceived = _pongReceived; + if (pongReceived == null) return false; lock (_forPing) { try { - receivePong.Reset (); + pongReceived.Reset (); lock (_forState) { if (_readyState != WebSocketState.Open) { @@ -2208,7 +2208,7 @@ internal bool Ping (byte[] frameAsBytes, TimeSpan timeout) return false; } - return receivePong.WaitOne (timeout); + return pongReceived.WaitOne (timeout); } catch (ObjectDisposedException) { return false; From 10fe8a962988b761c99e1cad76a873d6d0ba78f7 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 8 Dec 2016 13:14:16 +0900 Subject: [PATCH 0821/6294] [Modify] Rename it --- websocket-sharp/WebSocket.cs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 1b78d2ec8..5c1f1cc1b 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -78,7 +78,6 @@ public class WebSocket : IDisposable private NetworkCredential _credentials; private bool _emitOnPing; private bool _enableRedirection; - private ManualResetEvent _exitReceiving; private string _extensions; private bool _extensionsRequested; private object _forMessageEventQueue; @@ -107,6 +106,7 @@ public class WebSocket : IDisposable private NetworkCredential _proxyCredentials; private Uri _proxyUri; private volatile WebSocketState _readyState; + private ManualResetEvent _receivingExited; private int _retryCountForConnect; private bool _secure; private ClientSslConfiguration _sslConfig; @@ -1024,7 +1024,7 @@ private bool closeHandshake (byte[] frameAsBytes, bool receive, bool received) { var sent = frameAsBytes != null && sendBytes (frameAsBytes); received = received || - (receive && sent && _exitReceiving != null && _exitReceiving.WaitOne (_waitTime)); + (receive && sent && _receivingExited != null && _receivingExited.WaitOne (_waitTime)); var ret = sent && received; _logger.Debug ( @@ -1538,9 +1538,9 @@ private void releaseCommonResources () _pongReceived = null; } - if (_exitReceiving != null) { - _exitReceiving.Close (); - _exitReceiving = null; + if (_receivingExited != null) { + _receivingExited.Close (); + _receivingExited = null; } } @@ -1872,8 +1872,8 @@ private void startReceiving () if (_messageEventQueue.Count > 0) _messageEventQueue.Clear (); - _exitReceiving = new ManualResetEvent (false); _pongReceived = new ManualResetEvent (false); + _receivingExited = new ManualResetEvent (false); Action receive = null; receive = @@ -1883,9 +1883,9 @@ private void startReceiving () false, frame => { if (!processReceivedFrame (frame) || _readyState == WebSocketState.Closed) { - var exit = _exitReceiving; - if (exit != null) - exit.Set (); + var exited = _receivingExited; + if (exited != null) + exited.Set (); return; } From d99c6f56ee61d0b70dc8a4c5558e464256cd6929 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 8 Dec 2016 13:53:08 +0900 Subject: [PATCH 0822/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 5c1f1cc1b..b1805e40b 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1023,12 +1023,18 @@ private void closeAsync (CloseEventArgs e, bool send, bool receive, bool receive private bool closeHandshake (byte[] frameAsBytes, bool receive, bool received) { var sent = frameAsBytes != null && sendBytes (frameAsBytes); - received = received || - (receive && sent && _receivingExited != null && _receivingExited.WaitOne (_waitTime)); + + var wait = !received && sent && receive && _receivingExited != null; + if (wait) + received = _receivingExited.WaitOne (_waitTime); var ret = sent && received; + _logger.Debug ( - String.Format ("Was clean?: {0}\n sent: {1}\n received: {2}", ret, sent, received)); + String.Format ( + "Was clean?: {0}\n sent: {1}\n received: {2}", ret, sent, received + ) + ); return ret; } From 4f844977331dd0655274870aef15fd193eb69cee Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 8 Dec 2016 13:58:54 +0900 Subject: [PATCH 0823/6294] [Modify] Remove it --- websocket-sharp/WebSocket.cs | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index b1805e40b..04dcbb0ce 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1572,18 +1572,6 @@ private void releaseServerResources () _context = null; } - private bool send (byte[] frameAsBytes) - { - lock (_forState) { - if (_readyState != WebSocketState.Open) { - _logger.Error ("The state of the connection has been changed."); - return false; - } - - return sendBytes (frameAsBytes); - } - } - private bool send (Opcode opcode, Stream stream) { lock (_forSend) { From 0d8f41998094fdedf02c93bb33fb7a7166bc4bc3 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 8 Dec 2016 14:10:39 +0900 Subject: [PATCH 0824/6294] [Modify] Replace it --- websocket-sharp/WebSocket.cs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 04dcbb0ce..bdb644b5c 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2684,11 +2684,7 @@ public void ConnectAsync () /// public bool Ping () { - var bytes = _client - ? WebSocketFrame.CreatePingFrame (true).ToArray () - : WebSocketFrame.EmptyPingBytes; - - return Ping (bytes, _waitTime); + return ping (EmptyBytes); } /// From abd411ee9fc40cb22b06c6465762a8746ea6af44 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 8 Dec 2016 14:28:15 +0900 Subject: [PATCH 0825/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index bdb644b5c..224f5a365 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2679,7 +2679,7 @@ public void ConnectAsync () /// Sends a ping using the WebSocket connection. /// /// - /// true if the receives a pong to this ping in a time; + /// true if a pong has been received within a time; /// otherwise, false. /// public bool Ping () From 8b6e2ecd6162b4fdb2a2d3b11d62aed3d896d213 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 8 Dec 2016 14:56:52 +0900 Subject: [PATCH 0826/6294] [Modify] Throw exceptions --- websocket-sharp/WebSocket.cs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 224f5a365..640f1d91d 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2699,19 +2699,19 @@ public bool Ping () /// public bool Ping (string message) { - if (message == null || message.Length == 0) - return Ping (); + if (message == null) + throw new ArgumentNullException ("message"); - byte[] data; - var msg = CheckPingParameter (message, out data); - if (msg != null) { - _logger.Error (msg); - error ("An error has occurred in sending a ping.", null); + byte[] bytes; + if (!message.TryGetUTF8EncodedBytes (out bytes)) + throw new ArgumentException ("It could not be UTF8 encoded.", "message"); - return false; + if (bytes.Length > 125) { + var msg = "Its size is greater than 125 bytes."; + throw new ArgumentOutOfRangeException ("message", msg); } - return Ping (WebSocketFrame.CreatePingFrame (data, _client).ToArray (), _waitTime); + return ping (bytes); } /// From 9908e5261b85b7d305160be15188329d83be8dbe Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 9 Dec 2016 16:31:56 +0900 Subject: [PATCH 0827/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 640f1d91d..05f250bed 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2688,15 +2688,25 @@ public bool Ping () } /// - /// Sends a ping with the specified using the WebSocket connection. + /// Sends a ping with the specified using + /// the WebSocket connection. /// /// - /// true if the receives a pong to this ping in a time; - /// otherwise, false. + /// true if the ping has been sent and then a pong has been + /// received within a time; otherwise, false. /// /// /// A that represents the message to send. /// + /// + /// is . + /// + /// + /// could not be UTF8 encoded. + /// + /// + /// The size of is greater than 125 bytes. + /// public bool Ping (string message) { if (message == null) From 06ae1e459e9882e61ea0b9f20affa6b61238df3b Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 9 Dec 2016 16:37:49 +0900 Subject: [PATCH 0828/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 05f250bed..0edf27f4b 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2679,8 +2679,8 @@ public void ConnectAsync () /// Sends a ping using the WebSocket connection. /// /// - /// true if a pong has been received within a time; - /// otherwise, false. + /// true if the ping has been sent and then a pong has been + /// received within a time; otherwise, false. /// public bool Ping () { From 57e0bee4c0c66cdfae1257febd840ef204132f6e Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 10 Dec 2016 16:42:12 +0900 Subject: [PATCH 0829/6294] [Modify] Replace it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 0edf27f4b..b0f556358 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -433,7 +433,7 @@ public string Extensions { /// public bool IsAlive { get { - return Ping (); + return ping (EmptyBytes); } } From b1e31a5541f94a5b2e4a7688c330f674d05ccd1c Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 11 Dec 2016 19:32:51 +0900 Subject: [PATCH 0830/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index b0f556358..b721cb0e6 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2679,8 +2679,8 @@ public void ConnectAsync () /// Sends a ping using the WebSocket connection. /// /// - /// true if the ping has been sent and then a pong has been - /// received within a time; otherwise, false. + /// true if the sending a ping has done with no error and + /// a pong has been received within a time; otherwise, false. /// public bool Ping () { From b255601dc3fd09d2f279bfce14141d28462e036b Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 12 Dec 2016 17:03:32 +0900 Subject: [PATCH 0831/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index b721cb0e6..b027c3da2 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2692,17 +2692,18 @@ public bool Ping () /// the WebSocket connection. /// /// - /// true if the ping has been sent and then a pong has been - /// received within a time; otherwise, false. + /// true if the sending a ping has done with no error and + /// a pong has been received within a time; otherwise, false. /// /// /// A that represents the message to send. + /// Its size must be 125 bytes or less in UTF-8. /// /// /// is . /// /// - /// could not be UTF8 encoded. + /// could not be UTF-8-encoded. /// /// /// The size of is greater than 125 bytes. From a49dad8733f647178e7e1f246841390a4532ac7f Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 12 Dec 2016 17:07:47 +0900 Subject: [PATCH 0832/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index b027c3da2..bc2b1351a 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2715,7 +2715,7 @@ public bool Ping (string message) byte[] bytes; if (!message.TryGetUTF8EncodedBytes (out bytes)) - throw new ArgumentException ("It could not be UTF8 encoded.", "message"); + throw new ArgumentException ("It could not be UTF-8-encoded.", "message"); if (bytes.Length > 125) { var msg = "Its size is greater than 125 bytes."; From cc196cf6cab75472a8ceb8c92a4ee310fc3b1200 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 12 Dec 2016 17:09:53 +0900 Subject: [PATCH 0833/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index bc2b1351a..eb11fe72e 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2820,7 +2820,7 @@ public void Send (string data) byte[] bytes; if (!data.TryGetUTF8EncodedBytes (out bytes)) - throw new ArgumentException ("It could not be UTF8 encoded.", "data"); + throw new ArgumentException ("It could not be UTF-8-encoded.", "data"); send (Opcode.Text, new MemoryStream (bytes)); } From ef2f1d81372b2ac86742cdad1a7ed3714e044e36 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 12 Dec 2016 17:11:17 +0900 Subject: [PATCH 0834/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index eb11fe72e..9bc4ad981 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2806,7 +2806,7 @@ public void Send (FileInfo fileInfo) /// is . /// /// - /// could not be UTF8 encoded. + /// could not be UTF-8-encoded. /// public void Send (string data) { From 056f2c8ffc9df13b8da692d602e0258717195b06 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 12 Dec 2016 17:12:18 +0900 Subject: [PATCH 0835/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 9bc4ad981..e8256b375 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3015,7 +3015,7 @@ public void SendAsync (string data, Action completed) byte[] bytes; if (!data.TryGetUTF8EncodedBytes (out bytes)) - throw new ArgumentException ("It could not be UTF8 encoded.", "data"); + throw new ArgumentException ("It could not be UTF-8-encoded.", "data"); sendAsync (Opcode.Text, new MemoryStream (bytes), completed); } From 5056e8467994ef9b2a1a348bfc51dbe9cb780569 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 12 Dec 2016 17:13:31 +0900 Subject: [PATCH 0836/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index e8256b375..39fe22836 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3001,7 +3001,7 @@ public void SendAsync (FileInfo fileInfo, Action completed) /// is . /// /// - /// could not be UTF8 encoded. + /// could not be UTF-8-encoded. /// public void SendAsync (string data, Action completed) { From b21cb164def844cfbfce76b5f15bdf87ff998209 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 13 Dec 2016 16:59:44 +0900 Subject: [PATCH 0837/6294] [Fix] Not error --- websocket-sharp/WebSocket.cs | 178 ++++++++++++++++++----------------- 1 file changed, 91 insertions(+), 87 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 39fe22836..770b16436 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -957,6 +957,16 @@ private bool checkReceivedFrame (WebSocketFrame frame, out string message) private void close (ushort code, string reason) { + if (_readyState == WebSocketState.Closing) { + _logger.Info ("The closing is already in progress."); + return; + } + + if (_readyState == WebSocketState.Closed) { + _logger.Info ("The connection has already been closed."); + return; + } + if (code == 1005) { // == no status close (new CloseEventArgs (), true, true, false); return; @@ -975,7 +985,7 @@ private void close (CloseEventArgs e, bool send, bool receive, bool received) } if (_readyState == WebSocketState.Closed) { - _logger.Info ("The connection has been closed."); + _logger.Info ("The connection has already been closed."); return; } @@ -1005,6 +1015,16 @@ private void close (CloseEventArgs e, bool send, bool receive, bool received) private void closeAsync (ushort code, string reason) { + if (_readyState == WebSocketState.Closing) { + _logger.Info ("The closing is already in progress."); + return; + } + + if (_readyState == WebSocketState.Closed) { + _logger.Info ("The connection has already been closed."); + return; + } + if (code == 1005) { // == no status closeAsync (new CloseEventArgs (), true, true, false); return; @@ -2121,7 +2141,7 @@ internal void Close (CloseEventArgs e, byte[] frameAsBytes, bool receive) } if (_readyState == WebSocketState.Closed) { - _logger.Info ("The connection has been closed."); + _logger.Info ("The connection has already been closed."); return; } @@ -2329,23 +2349,23 @@ public void AcceptAsync () /// /// Closes the WebSocket connection, and releases all associated resources. /// + /// + /// This method does nothing if the current state of the connection is + /// Closing or Closed. + /// public void Close () { - string msg; - if (!checkIfAvailable (true, true, false, false, out msg)) { - _logger.Error (msg); - error ("An error has occurred in closing the connection.", null); - - return; - } - - close (new CloseEventArgs (), true, true, false); + close (1005, String.Empty); } /// /// Closes the WebSocket connection with the specified , /// and releases all associated resources. /// + /// + /// This method does nothing if the current state of the connection is + /// Closing or Closed. + /// /// /// A that represents the status code indicating /// the reason for the close. The status codes are defined in @@ -2355,13 +2375,6 @@ public void Close () public void Close (ushort code) { string msg; - if (!checkIfAvailable (true, true, false, false, out msg)) { - _logger.Error (msg); - error ("An error has occurred in closing the connection.", null); - - return; - } - if (!CheckParametersForClose (code, null, _client, out msg)) { _logger.Error (msg); error ("An error has occurred in closing the connection.", null); @@ -2369,13 +2382,17 @@ public void Close (ushort code) return; } - close (code, null); + close (code, String.Empty); } /// /// Closes the WebSocket connection with the specified , /// and releases all associated resources. /// + /// + /// This method does nothing if the current state of the connection is + /// Closing or Closed. + /// /// /// One of the enum values that represents /// the status code indicating the reason for the close. @@ -2383,13 +2400,6 @@ public void Close (ushort code) public void Close (CloseStatusCode code) { string msg; - if (!checkIfAvailable (true, true, false, false, out msg)) { - _logger.Error (msg); - error ("An error has occurred in closing the connection.", null); - - return; - } - if (!CheckParametersForClose (code, null, _client, out msg)) { _logger.Error (msg); error ("An error has occurred in closing the connection.", null); @@ -2397,13 +2407,17 @@ public void Close (CloseStatusCode code) return; } - close ((ushort) code, null); + close ((ushort) code, String.Empty); } /// /// Closes the WebSocket connection with the specified and /// , and releases all associated resources. /// + /// + /// This method does nothing if the current state of the connection is + /// Closing or Closed. + /// /// /// A that represents the status code indicating /// the reason for the close. The status codes are defined in @@ -2417,13 +2431,6 @@ public void Close (CloseStatusCode code) public void Close (ushort code, string reason) { string msg; - if (!checkIfAvailable (true, true, false, false, out msg)) { - _logger.Error (msg); - error ("An error has occurred in closing the connection.", null); - - return; - } - if (!CheckParametersForClose (code, reason, _client, out msg)) { _logger.Error (msg); error ("An error has occurred in closing the connection.", null); @@ -2438,6 +2445,10 @@ public void Close (ushort code, string reason) /// Closes the WebSocket connection with the specified and /// , and releases all associated resources. /// + /// + /// This method does nothing if the current state of the connection is + /// Closing or Closed. + /// /// /// One of the enum values that represents /// the status code indicating the reason for the close. @@ -2449,13 +2460,6 @@ public void Close (ushort code, string reason) public void Close (CloseStatusCode code, string reason) { string msg; - if (!checkIfAvailable (true, true, false, false, out msg)) { - _logger.Error (msg); - error ("An error has occurred in closing the connection.", null); - - return; - } - if (!CheckParametersForClose (code, reason, _client, out msg)) { _logger.Error (msg); error ("An error has occurred in closing the connection.", null); @@ -2471,19 +2475,17 @@ public void Close (CloseStatusCode code, string reason) /// all associated resources. /// /// - /// This method does not wait for the close to be complete. + /// + /// This method does nothing if the current state of the connection is + /// Closing or Closed. + /// + /// + /// This method does not wait for the close to be complete. + /// /// public void CloseAsync () { - string msg; - if (!checkIfAvailable (true, true, false, false, out msg)) { - _logger.Error (msg); - error ("An error has occurred in closing the connection.", null); - - return; - } - - closeAsync (new CloseEventArgs (), true, true, false); + closeAsync (1005, String.Empty); } /// @@ -2491,7 +2493,13 @@ public void CloseAsync () /// , and releases all associated resources. /// /// - /// This method does not wait for the close to be complete. + /// + /// This method does nothing if the current state of the connection is + /// Closing or Closed. + /// + /// + /// This method does not wait for the close to be complete. + /// /// /// /// A that represents the status code indicating @@ -2502,13 +2510,6 @@ public void CloseAsync () public void CloseAsync (ushort code) { string msg; - if (!checkIfAvailable (true, true, false, false, out msg)) { - _logger.Error (msg); - error ("An error has occurred in closing the connection.", null); - - return; - } - if (!CheckParametersForClose (code, null, _client, out msg)) { _logger.Error (msg); error ("An error has occurred in closing the connection.", null); @@ -2516,7 +2517,7 @@ public void CloseAsync (ushort code) return; } - closeAsync (code, null); + closeAsync (code, String.Empty); } /// @@ -2524,7 +2525,13 @@ public void CloseAsync (ushort code) /// , and releases all associated resources. /// /// - /// This method does not wait for the close to be complete. + /// + /// This method does nothing if the current state of the connection is + /// Closing or Closed. + /// + /// + /// This method does not wait for the close to be complete. + /// /// /// /// One of the enum values that represents @@ -2533,13 +2540,6 @@ public void CloseAsync (ushort code) public void CloseAsync (CloseStatusCode code) { string msg; - if (!checkIfAvailable (true, true, false, false, out msg)) { - _logger.Error (msg); - error ("An error has occurred in closing the connection.", null); - - return; - } - if (!CheckParametersForClose (code, null, _client, out msg)) { _logger.Error (msg); error ("An error has occurred in closing the connection.", null); @@ -2547,7 +2547,7 @@ public void CloseAsync (CloseStatusCode code) return; } - closeAsync ((ushort) code, null); + closeAsync ((ushort) code, String.Empty); } /// @@ -2556,7 +2556,13 @@ public void CloseAsync (CloseStatusCode code) /// all associated resources. /// /// - /// This method does not wait for the close to be complete. + /// + /// This method does nothing if the current state of the connection is + /// Closing or Closed. + /// + /// + /// This method does not wait for the close to be complete. + /// /// /// /// A that represents the status code indicating @@ -2571,13 +2577,6 @@ public void CloseAsync (CloseStatusCode code) public void CloseAsync (ushort code, string reason) { string msg; - if (!checkIfAvailable (true, true, false, false, out msg)) { - _logger.Error (msg); - error ("An error has occurred in closing the connection.", null); - - return; - } - if (!CheckParametersForClose (code, reason, _client, out msg)) { _logger.Error (msg); error ("An error has occurred in closing the connection.", null); @@ -2594,7 +2593,13 @@ public void CloseAsync (ushort code, string reason) /// all associated resources. /// /// - /// This method does not wait for the close to be complete. + /// + /// This method does nothing if the current state of the connection is + /// Closing or Closed. + /// + /// + /// This method does not wait for the close to be complete. + /// /// /// /// One of the enum values that represents @@ -2607,13 +2612,6 @@ public void CloseAsync (ushort code, string reason) public void CloseAsync (CloseStatusCode code, string reason) { string msg; - if (!checkIfAvailable (true, true, false, false, out msg)) { - _logger.Error (msg); - error ("An error has occurred in closing the connection.", null); - - return; - } - if (!CheckParametersForClose (code, reason, _client, out msg)) { _logger.Error (msg); error ("An error has occurred in closing the connection.", null); @@ -3289,11 +3287,17 @@ public void SetProxy (string url, string username, string password) /// Closes the WebSocket connection, and releases all associated resources. /// /// - /// This method closes the connection with status code 1001 (going away). + /// + /// This method does nothing if the current state of the connection is + /// Closing or Closed. + /// + /// + /// This method closes the connection with status code 1001 (going away). + /// /// void IDisposable.Dispose () { - close (new CloseEventArgs (1001), true, true, false); + close (1001, String.Empty); } #endregion From 5341fc5ff715aeae15717873217eb0226c19764f Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 14 Dec 2016 16:44:06 +0900 Subject: [PATCH 0838/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 770b16436..a764eaa2a 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2695,7 +2695,7 @@ public bool Ping () /// /// /// A that represents the message to send. - /// Its size must be 125 bytes or less in UTF-8. + /// The size must be 125 bytes or less in UTF-8. /// /// /// is . From 788bb5afa4492a4d28e2440b8d79765d239533d2 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 14 Dec 2016 16:59:13 +0900 Subject: [PATCH 0839/6294] [Modify] Add it --- websocket-sharp/WebSocket.cs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index a764eaa2a..aa278c5f9 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1059,6 +1059,31 @@ private bool closeHandshake (byte[] frameAsBytes, bool receive, bool received) return ret; } + private bool closeHandshake ( + PayloadData payloadData, bool send, bool receive, bool received + ) + { + var sent = false; + if (send) { + var frame = WebSocketFrame.CreateCloseFrame (payloadData, _client); + sent = sendBytes (frame.ToArray ()); + } + + var wait = !received && sent && receive && _receivingExited != null; + if (wait) + received = _receivingExited.WaitOne (_waitTime); + + var ret = sent && received; + + _logger.Debug ( + String.Format ( + "Was clean?: {0}\n sent: {1}\n received: {2}", ret, sent, received + ) + ); + + return ret; + } + // As client private bool connect () { From a07928db9614cd7e38e54046d0f6eff897339afb Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 15 Dec 2016 16:46:00 +0900 Subject: [PATCH 0840/6294] [Modify] Add it --- websocket-sharp/WebSocket.cs | 42 ++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index aa278c5f9..c98eff3f3 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1013,6 +1013,48 @@ private void close (CloseEventArgs e, bool send, bool receive, bool received) } } + private void close ( + PayloadData payloadData, bool send, bool receive, bool received + ) + { + lock (_forState) { + if (_readyState == WebSocketState.Closing) { + _logger.Info ("The closing is already in progress."); + return; + } + + if (_readyState == WebSocketState.Closed) { + _logger.Info ("The connection has already been closed."); + return; + } + + send = send && _readyState == WebSocketState.Open; + receive = send && receive; + + _readyState = WebSocketState.Closing; + } + + _logger.Trace ("Begin closing the connection."); + + var res = closeHandshake (payloadData, send, receive, received); + releaseResources (); + + _logger.Trace ("End closing the connection."); + + _readyState = WebSocketState.Closed; + + var e = new CloseEventArgs (payloadData); + e.WasClean = res; + + try { + OnClose.Emit (this, e); + } + catch (Exception ex) { + _logger.Error (ex.ToString ()); + error ("An error has occurred during the OnClose event.", ex); + } + } + private void closeAsync (ushort code, string reason) { if (_readyState == WebSocketState.Closing) { From 808f4160f76c4b6ec8c0250d08fe6ef07f7ce4bc Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 15 Dec 2016 17:04:04 +0900 Subject: [PATCH 0841/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index c98eff3f3..a75d4fb22 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1109,6 +1109,9 @@ private bool closeHandshake ( if (send) { var frame = WebSocketFrame.CreateCloseFrame (payloadData, _client); sent = sendBytes (frame.ToArray ()); + + if (_client) + frame.Unmask (); } var wait = !received && sent && receive && _receivingExited != null; From 240310fbe7d2d9e77c51ff2373ef29e738ac9e09 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 16 Dec 2016 16:38:28 +0900 Subject: [PATCH 0842/6294] [Modify] Replace it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index a75d4fb22..bc6e93e67 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1442,7 +1442,7 @@ private bool ping (byte[] data) private bool processCloseFrame (WebSocketFrame frame) { var payload = frame.PayloadData; - close (new CloseEventArgs (payload), !payload.HasReservedCode, false, true); + close (payload, !payload.HasReservedCode, false, true); return false; } From b70016c5af9e021e2600196c81037c846999dc6d Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 16 Dec 2016 16:49:40 +0900 Subject: [PATCH 0843/6294] [Modify] Replace them --- websocket-sharp/WebSocket.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index bc6e93e67..37a5bf6df 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -968,12 +968,12 @@ private void close (ushort code, string reason) } if (code == 1005) { // == no status - close (new CloseEventArgs (), true, true, false); + close (PayloadData.Empty, true, true, false); return; } var send = !code.IsReserved (); - close (new CloseEventArgs (code, reason), send, send, false); + close (new PayloadData (code, reason), send, send, false); } private void close (CloseEventArgs e, bool send, bool receive, bool received) From ee1c59a5f667f83652ad666f4bcae5bdfa29b107 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 16 Dec 2016 16:58:34 +0900 Subject: [PATCH 0844/6294] [Modify] Add it --- websocket-sharp/WebSocket.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 37a5bf6df..433dcd58b 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1082,6 +1082,16 @@ private void closeAsync (CloseEventArgs e, bool send, bool receive, bool receive closer.BeginInvoke (e, send, receive, received, ar => closer.EndInvoke (ar), null); } + private void closeAsync ( + PayloadData payloadData, bool send, bool receive, bool received + ) + { + Action closer = close; + closer.BeginInvoke ( + payloadData, send, receive, received, ar => closer.EndInvoke (ar), null + ); + } + private bool closeHandshake (byte[] frameAsBytes, bool receive, bool received) { var sent = frameAsBytes != null && sendBytes (frameAsBytes); From 52397e4c7acc2b258c32006722863b3f29afa09d Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 16 Dec 2016 17:03:42 +0900 Subject: [PATCH 0845/6294] [Modify] Replace them --- websocket-sharp/WebSocket.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 433dcd58b..31170c8c5 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1068,12 +1068,12 @@ private void closeAsync (ushort code, string reason) } if (code == 1005) { // == no status - closeAsync (new CloseEventArgs (), true, true, false); + closeAsync (PayloadData.Empty, true, true, false); return; } var send = !code.IsReserved (); - closeAsync (new CloseEventArgs (code, reason), send, send, false); + closeAsync (new PayloadData (code, reason), send, send, false); } private void closeAsync (CloseEventArgs e, bool send, bool receive, bool received) From 4f469d6e1428aafbb536b963df8fb6754c29a171 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 17 Dec 2016 16:30:09 +0900 Subject: [PATCH 0846/6294] [Modify] Remove it --- websocket-sharp/WebSocket.cs | 6 ------ 1 file changed, 6 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 31170c8c5..6621a5ba7 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1076,12 +1076,6 @@ private void closeAsync (ushort code, string reason) closeAsync (new PayloadData (code, reason), send, send, false); } - private void closeAsync (CloseEventArgs e, bool send, bool receive, bool received) - { - Action closer = close; - closer.BeginInvoke (e, send, receive, received, ar => closer.EndInvoke (ar), null); - } - private void closeAsync ( PayloadData payloadData, bool send, bool receive, bool received ) From 970ddf7bb9007c388bcb4c627a84afcccaa17598 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 17 Dec 2016 16:45:06 +0900 Subject: [PATCH 0847/6294] [Modify] Replace it --- websocket-sharp/WebSocket.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 6621a5ba7..fd8ff0638 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1321,7 +1321,8 @@ private void fatal (string message, Exception exception) private void fatal (string message, CloseStatusCode code) { - close (new CloseEventArgs (code, message), !code.IsReserved (), false, false); + var payload = new PayloadData ((ushort) code, message); + close (payload, !code.IsReserved (), false, false); } private void init () From e9740e989e5492debe3e9a509dc66e7c3dfe8bc4 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 17 Dec 2016 16:50:09 +0900 Subject: [PATCH 0848/6294] [Modify] Remove it --- websocket-sharp/WebSocket.cs | 37 ------------------------------------ 1 file changed, 37 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index fd8ff0638..72559b4f1 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -976,43 +976,6 @@ private void close (ushort code, string reason) close (new PayloadData (code, reason), send, send, false); } - private void close (CloseEventArgs e, bool send, bool receive, bool received) - { - lock (_forState) { - if (_readyState == WebSocketState.Closing) { - _logger.Info ("The closing is already in progress."); - return; - } - - if (_readyState == WebSocketState.Closed) { - _logger.Info ("The connection has already been closed."); - return; - } - - send = send && _readyState == WebSocketState.Open; - receive = receive && send; - - _readyState = WebSocketState.Closing; - } - - _logger.Trace ("Begin closing the connection."); - - var bytes = send ? WebSocketFrame.CreateCloseFrame (e.PayloadData, _client).ToArray () : null; - e.WasClean = closeHandshake (bytes, receive, received); - releaseResources (); - - _logger.Trace ("End closing the connection."); - - _readyState = WebSocketState.Closed; - try { - OnClose.Emit (this, e); - } - catch (Exception ex) { - _logger.Error (ex.ToString ()); - error ("An error has occurred during the OnClose event.", ex); - } - } - private void close ( PayloadData payloadData, bool send, bool receive, bool received ) From 9a4a1d748b51aad43815aaa487e93cefbfd3d9bc Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 18 Dec 2016 17:53:50 +0900 Subject: [PATCH 0849/6294] [Modify] Edit it --- README.md | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index c7d44d660..b869aba9a 100644 --- a/README.md +++ b/README.md @@ -2,16 +2,16 @@ ## Welcome to websocket-sharp! ## -**websocket-sharp** supports: - -- **[RFC 6455](#supported-websocket-specifications)** -- **[WebSocket Client](#websocket-client)** and **[Server](#websocket-server)** -- **[Per-message Compression](#per-message-compression)** extension -- **[Secure Connection](#secure-connection)** -- **[HTTP Authentication](#http-authentication)** -- **[Query String, Origin header, and Cookies](#query-string-origin-header-and-cookies)** -- **[Connecting through the HTTP Proxy server](#connecting-through-the-http-proxy-server)** -- .NET Framework **3.5** or later (includes compatible environment such as **[Mono]**) +websocket-sharp supports: + +- [RFC 6455](#supported-websocket-specifications) +- [WebSocket Client](#websocket-client) and [Server](#websocket-server) +- [Per-message Compression](#per-message-compression) extension +- [Secure Connection](#secure-connection) +- [HTTP Authentication](#http-authentication) +- [Query string, Origin header, and Cookies](#query-string-origin-header-and-cookies) +- [Connecting through the HTTP proxy server](#connecting-through-the-http-proxy-server) +- .NET Framework **3.5** or later (includes compatible environment such as [Mono]) ## Branches ## From d5e9eb159f98785a31ac9f52098d4433ce49b6c2 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 19 Dec 2016 17:43:46 +0900 Subject: [PATCH 0850/6294] [Modify] Edit it --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index b869aba9a..341327f1d 100644 --- a/README.md +++ b/README.md @@ -15,9 +15,9 @@ websocket-sharp supports: ## Branches ## -- **[master]** for production releases. -- **[hybi-00]** for older [draft-ietf-hybi-thewebsocketprotocol-00]. No longer maintained. -- **[draft75]** for even more old [draft-hixie-thewebsocketprotocol-75]. No longer maintained. +- [master] for production releases. +- [hybi-00] for older [draft-ietf-hybi-thewebsocketprotocol-00]. No longer maintained. +- [draft75] for even more old [draft-hixie-thewebsocketprotocol-75]. No longer maintained. ## Build ## From e5dad92e332ea5f9681e6beb5823f5f9c1c889e4 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 20 Dec 2016 17:27:20 +0900 Subject: [PATCH 0851/6294] [Modify] Edit it --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 341327f1d..4b7e88e97 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ websocket-sharp supports: websocket-sharp is built as a single assembly, **websocket-sharp.dll**. -websocket-sharp is developed with **[MonoDevelop]**. So a simple way to build is to open **websocket-sharp.sln** and run build for **websocket-sharp project** with any of the build configurations (e.g. `Debug`) in MonoDevelop. +websocket-sharp is developed with [MonoDevelop]. So a simple way to build is to open **websocket-sharp.sln** and run build for **websocket-sharp project** with any of the build configurations (e.g. `Debug`) in MonoDevelop. ## Install ## From 74405d030e0b2866f77a61e9afed67f2cff948d7 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 21 Dec 2016 17:30:12 +0900 Subject: [PATCH 0852/6294] [Modify] Edit it --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4b7e88e97..73b2d9bcd 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ websocket-sharp is developed with [MonoDevelop]. So a simple way to build is to You should add your websocket-sharp.dll (e.g. `/path/to/websocket-sharp/bin/Debug/websocket-sharp.dll`) to the library references of your project. -If you would like to use that dll in your **[Unity]** project, you should add it to any folder of your project (e.g. `Assets/Plugins`) in the **Unity Editor**. +If you would like to use that dll in your [Unity] project, you should add it to any folder of your project (e.g. `Assets/Plugins`) in the **Unity Editor**. ### NuGet Gallery ### From eddd271cf40aeeac331125524379cbcf7310fc36 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 22 Dec 2016 17:46:51 +0900 Subject: [PATCH 0853/6294] [Modify] Edit it --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 73b2d9bcd..15d773402 100644 --- a/README.md +++ b/README.md @@ -37,9 +37,9 @@ If you would like to use that dll in your [Unity] project, you should add it to websocket-sharp is available on the [NuGet Gallery], as still a **prerelease** version. -- **[NuGet Gallery: websocket-sharp]** +- [NuGet Gallery: websocket-sharp] -You can add websocket-sharp to your project with the **NuGet Package Manager**, by using the following command in the **Package Manager Console**. +You can add websocket-sharp to your project with the NuGet Package Manager, by using the following command in the Package Manager Console. PM> Install-Package WebSocketSharp -Pre From 527723eea411559c0750acc2dee6010bee398488 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 23 Dec 2016 17:52:07 +0900 Subject: [PATCH 0854/6294] [Modify] Edit it --- README.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 15d773402..15b7c0c40 100644 --- a/README.md +++ b/README.md @@ -47,16 +47,16 @@ You can add websocket-sharp to your project with the NuGet Package Manager, by u websocket-sharp is available on the Unity Asset Store (Sorry, Not available now). -- **[WebSocket-Sharp for Unity]** +- [WebSocket-Sharp for Unity] It works with **Unity Free**, but there are some limitations: -- **[Security Sandbox of the Webplayer]** (The server is not available in Web Player) -- **[WebGL Networking]** (Not available in WebGL) -- **Incompatible platform** (Not available for such UWP) -- **Limited support for the System.IO.Compression** (The compression extension is not available on Windows) -- **.NET Socket Support for iOS/Android** (That requires iOS/Android Pro if your Unity is earlier than Unity 5) -- **.NET API 2.0 compatibility level for iOS/Android** +- [Security Sandbox of the Webplayer] (The server is not available in Web Player) +- [WebGL Networking] (Not available in WebGL) +- Incompatible platform (Not available for such UWP) +- Lack of dll for the System.IO.Compression (The compression extension is not available on Windows) +- .NET Socket Support for iOS/Android (iOS/Android Pro is required if your Unity is earlier than Unity 5) +- .NET API 2.0 compatibility level for iOS/Android .NET API 2.0 compatibility level for iOS/Android may require to fix lack of some features for later than .NET Framework 2.0, such as the `System.Func<...>` delegates (so i have added them in the asset package). From b45a6572cd131b2da15f6f4c7f9386e13f9793de Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 24 Dec 2016 17:35:03 +0900 Subject: [PATCH 0855/6294] [Modify] Edit it --- websocket-sharp/Ext.cs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 620458148..7d9fc1e62 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1285,11 +1285,11 @@ public static string GetStatusDescription (this int code) } /// - /// Determines whether the specified is in the allowable range of - /// the WebSocket close status code. + /// Determines whether the specified is in + /// the allowable range of the WebSocket close status code. /// /// - /// Not allowable ranges are the following: + /// Unallowable ranges are the following: /// /// /// @@ -1298,14 +1298,15 @@ public static string GetStatusDescription (this int code) /// /// /// - /// Numbers greater than 4999 are out of the reserved close status code ranges. + /// Numbers greater than 4999 are out of the reserved + /// close status code ranges. /// /// /// /// /// - /// true if is in the allowable range of the WebSocket - /// close status code; otherwise, false. + /// true if is in the allowable + /// range of the close status code; otherwise, false. /// /// /// A to test. From 9ca05f707eb38e0d903c0854296d9077df4c1a48 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 25 Dec 2016 17:16:08 +0900 Subject: [PATCH 0856/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 7d9fc1e62..b3c3dede7 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1332,10 +1332,10 @@ public static bool IsCloseStatusCode (this ushort value) /// public static bool IsEnclosedIn (this string value, char c) { - return value != null && - value.Length > 1 && - value[0] == c && - value[value.Length - 1] == c; + return value != null + && value.Length > 1 + && value[0] == c + && value[value.Length - 1] == c; } /// From a3c0d4bdfccff26b9c6e23904aa20827759c3259 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 26 Dec 2016 17:02:55 +0900 Subject: [PATCH 0857/6294] [Modify] Edit it --- websocket-sharp/Ext.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index b3c3dede7..f8fab9914 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1317,18 +1317,18 @@ public static bool IsCloseStatusCode (this ushort value) } /// - /// Determines whether the specified is enclosed in the specified - /// . + /// Determines whether the specified is + /// enclosed in the specified . /// /// - /// true if is enclosed in ; - /// otherwise, false. + /// true if is enclosed in + /// ; otherwise, false. /// /// /// A to test. /// /// - /// A that represents the character to find. + /// A to find. /// public static bool IsEnclosedIn (this string value, char c) { From a2280fb3a76a8dfb6f477c1a6126d656c8a68bf4 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 27 Dec 2016 17:53:34 +0900 Subject: [PATCH 0858/6294] [Modify] Edit it --- websocket-sharp/CloseStatusCode.cs | 61 ++++++++++++++++-------------- 1 file changed, 33 insertions(+), 28 deletions(-) diff --git a/websocket-sharp/CloseStatusCode.cs b/websocket-sharp/CloseStatusCode.cs index 74bb9da7e..e88e6c7a2 100644 --- a/websocket-sharp/CloseStatusCode.cs +++ b/websocket-sharp/CloseStatusCode.cs @@ -36,12 +36,12 @@ namespace WebSocketSharp /// /// /// The values of this enumeration are defined in - /// Section 7.4 of RFC 6455. + /// + /// Section 7.4 of RFC 6455. /// /// - /// "Reserved value" must not be set as a status code in a connection close frame by - /// an endpoint. It's designated for use in applications expecting a status code to - /// indicate that the connection was closed due to the system grounds. + /// "Reserved value" cannot be sent as a status code in + /// closing handshake by an endpoint. /// /// public enum CloseStatusCode : ushort @@ -51,17 +51,19 @@ public enum CloseStatusCode : ushort /// Normal = 1000, /// - /// Equivalent to close status 1001. Indicates that an endpoint is going away. + /// Equivalent to close status 1001. Indicates that an endpoint is + /// going away. /// Away = 1001, /// - /// Equivalent to close status 1002. Indicates that an endpoint is terminating - /// the connection due to a protocol error. + /// Equivalent to close status 1002. Indicates that an endpoint is + /// terminating the connection due to a protocol error. /// ProtocolError = 1002, /// - /// Equivalent to close status 1003. Indicates that an endpoint is terminating - /// the connection because it has received a type of data that it cannot accept. + /// Equivalent to close status 1003. Indicates that an endpoint is + /// terminating the connection because it has received a type of + /// data that it cannot accept. /// UnsupportedData = 1003, /// @@ -69,46 +71,49 @@ public enum CloseStatusCode : ushort /// Undefined = 1004, /// - /// Equivalent to close status 1005. Indicates that no status code was actually present. - /// A Reserved value. + /// Equivalent to close status 1005. Indicates that no status code was + /// actually present. A Reserved value. /// NoStatus = 1005, /// - /// Equivalent to close status 1006. Indicates that the connection was closed abnormally. - /// A Reserved value. + /// Equivalent to close status 1006. Indicates that the connection was + /// closed abnormally. A Reserved value. /// Abnormal = 1006, /// - /// Equivalent to close status 1007. Indicates that an endpoint is terminating - /// the connection because it has received a message that contains data that - /// isn't consistent with the type of the message. + /// Equivalent to close status 1007. Indicates that an endpoint is + /// terminating the connection because it has received a message that + /// contains data that is not consistent with the type of the message. /// InvalidData = 1007, /// - /// Equivalent to close status 1008. Indicates that an endpoint is terminating - /// the connection because it has received a message that violates its policy. + /// Equivalent to close status 1008. Indicates that an endpoint is + /// terminating the connection because it has received a message that + /// violates its policy. /// PolicyViolation = 1008, /// - /// Equivalent to close status 1009. Indicates that an endpoint is terminating - /// the connection because it has received a message that is too big to process. + /// Equivalent to close status 1009. Indicates that an endpoint is + /// terminating the connection because it has received a message that + /// is too big to process. /// TooBig = 1009, /// - /// Equivalent to close status 1010. Indicates that a client is terminating - /// the connection because it has expected the server to negotiate one or more extension, - /// but the server didn't return them in the handshake response. + /// Equivalent to close status 1010. Indicates that a client is + /// terminating the connection because it has expected the server to + /// negotiate one or more extension, but the server did not return + /// them in the handshake response. /// MandatoryExtension = 1010, /// - /// Equivalent to close status 1011. Indicates that a server is terminating - /// the connection because it has encountered an unexpected condition that - /// prevented it from fulfilling the request. + /// Equivalent to close status 1011. Indicates that a server is + /// terminating the connection because it has encountered an unexpected + /// condition that prevented it from fulfilling the request. /// ServerError = 1011, /// - /// Equivalent to close status 1015. Indicates that the connection was closed - /// due to a failure to perform a TLS handshake. A Reserved value. + /// Equivalent to close status 1015. Indicates that the connection was + /// closed due to a failure to perform a TLS handshake. A Reserved value. /// TlsHandshakeFailure = 1015 } From 291bc02b614ce28a94fcdc01a0de6d8f0861e7dd Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 28 Dec 2016 16:44:40 +0900 Subject: [PATCH 0859/6294] [Modify] 2016 --- websocket-sharp/CloseStatusCode.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/CloseStatusCode.cs b/websocket-sharp/CloseStatusCode.cs index e88e6c7a2..81f3317a4 100644 --- a/websocket-sharp/CloseStatusCode.cs +++ b/websocket-sharp/CloseStatusCode.cs @@ -4,7 +4,7 @@ * * The MIT License * - * Copyright (c) 2012-2015 sta.blockhead + * Copyright (c) 2012-2016 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From 20a797ade2a0cd2fda06e52b36d3a346c23ad20d Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 28 Dec 2016 16:50:04 +0900 Subject: [PATCH 0860/6294] [Modify] Add it --- websocket-sharp/WebSocket.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 72559b4f1..795d111f2 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1282,6 +1282,12 @@ private void fatal (string message, Exception exception) fatal (message, code); } + private void fatal (string message, ushort code) + { + var payload = new PayloadData (code, message); + close (payload, !code.IsReserved (), false, false); + } + private void fatal (string message, CloseStatusCode code) { var payload = new PayloadData ((ushort) code, message); From c2c51c211d22b3a4f7be60b8faf61d8cb1e891cf Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 28 Dec 2016 16:55:09 +0900 Subject: [PATCH 0861/6294] [Modify] Replace it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 795d111f2..c48f930c3 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1279,7 +1279,7 @@ private void fatal (string message, Exception exception) ? ((WebSocketException) exception).Code : CloseStatusCode.Abnormal; - fatal (message, code); + fatal (message, (ushort) code); } private void fatal (string message, ushort code) From 4fbb1b244d48ac6cc8265d817e72def982f50762 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 28 Dec 2016 16:58:03 +0900 Subject: [PATCH 0862/6294] [Modify] Replace it --- websocket-sharp/WebSocket.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index c48f930c3..57953e471 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1290,8 +1290,7 @@ private void fatal (string message, ushort code) private void fatal (string message, CloseStatusCode code) { - var payload = new PayloadData ((ushort) code, message); - close (payload, !code.IsReserved (), false, false); + fatal (message, (ushort) code); } private void init () From 93196a0230e7b9463d6eebfdd7c47f201877fed9 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 29 Dec 2016 17:35:24 +0900 Subject: [PATCH 0863/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index f8fab9914..ac7c4fc63 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -548,10 +548,10 @@ internal static bool IsPortNumber (this int value) internal static bool IsReserved (this ushort code) { - return code == (ushort) CloseStatusCode.Undefined || - code == (ushort) CloseStatusCode.NoStatus || - code == (ushort) CloseStatusCode.Abnormal || - code == (ushort) CloseStatusCode.TlsHandshakeFailure; + return code == 1004 + || code == 1005 + || code == 1006 + || code == 1015; } internal static bool IsReserved (this CloseStatusCode code) From 8d370374e2899b769d294c22234e5dd887b9396b Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 30 Dec 2016 16:00:26 +0900 Subject: [PATCH 0864/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index ac7c4fc63..1a13a934f 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -556,10 +556,10 @@ internal static bool IsReserved (this ushort code) internal static bool IsReserved (this CloseStatusCode code) { - return code == CloseStatusCode.Undefined || - code == CloseStatusCode.NoStatus || - code == CloseStatusCode.Abnormal || - code == CloseStatusCode.TlsHandshakeFailure; + return code == CloseStatusCode.Undefined + || code == CloseStatusCode.NoStatus + || code == CloseStatusCode.Abnormal + || code == CloseStatusCode.TlsHandshakeFailure; } internal static bool IsSupported (this byte opcode) From 7790037b4ab113c171dc63c48b4fa88c25ac29c7 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 31 Dec 2016 16:19:48 +0900 Subject: [PATCH 0865/6294] [Modify] Edit it --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 15b7c0c40..7b36958df 100644 --- a/README.md +++ b/README.md @@ -534,7 +534,7 @@ If you would like to provide the Digest authentication, you should set such as t wssv.AuthenticationSchemes = AuthenticationSchemes.Digest; ``` -### Query String, Origin header, and Cookies ### +### Query string, Origin header, and Cookies ### As a WebSocket client, if you would like to send the query string in the handshake request, you should create a new instance of the `WebSocket` class with a WebSocket URL that includes the [Query] string parameters. From f4de2e769bdadb7def8b6e0c70f248b0278dda0a Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 1 Jan 2017 16:42:27 +0900 Subject: [PATCH 0866/6294] [Modify] 2017 --- LICENSE.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LICENSE.txt b/LICENSE.txt index b9c30e643..bf3375396 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2010-2016 sta.blockhead +Copyright (c) 2010-2017 sta.blockhead Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal From a8a393bcc4588ed3bbad7cd5237cfe75d19383a0 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 2 Jan 2017 16:39:28 +0900 Subject: [PATCH 0867/6294] [Modify] Edit it --- README.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 7b36958df..6db079b46 100644 --- a/README.md +++ b/README.md @@ -663,16 +663,16 @@ Would you access to [http://localhost:4649](http://localhost:4649) to do **WebSo ## Supported WebSocket Specifications ## -websocket-sharp supports **RFC 6455**, and it is based on the following WebSocket references: +websocket-sharp supports **RFC 6455**, and it is based on the following references: -- **[The WebSocket Protocol][rfc6455]** -- **[The WebSocket API][api]** -- **[Compression Extensions for WebSocket][compression]** +- [The WebSocket Protocol][rfc6455] +- [The WebSocket API][api] +- [Compression Extensions for WebSocket][compression] Thanks for translating to japanese. -- **[The WebSocket Protocol 日本語訳][rfc6455_ja]** -- **[The WebSocket API 日本語訳][api_ja]** +- [The WebSocket Protocol 日本語訳][rfc6455_ja] +- [The WebSocket API 日本語訳][api_ja] ## License ## From 0d8963f7714dbcb36e13c4bb531127696bd3495c Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 2 Jan 2017 16:48:49 +0900 Subject: [PATCH 0868/6294] [Modify] Edit it --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 6db079b46..1198594c1 100644 --- a/README.md +++ b/README.md @@ -676,7 +676,7 @@ Thanks for translating to japanese. ## License ## -websocket-sharp is provided under **[The MIT License]**. +websocket-sharp is provided under [The MIT License]. [Echo server]: http://www.websocket.org/echo.html From b1ee6d44755a201c48912b659ad7063c66b1015e Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 3 Jan 2017 17:08:01 +0900 Subject: [PATCH 0869/6294] [Modify] Edit it --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 1198594c1..e7049b224 100644 --- a/README.md +++ b/README.md @@ -649,15 +649,15 @@ Examples using websocket-sharp. ### Example ### -**[Example]** connects to the **[Echo server]** with the WebSocket. +[Example] connects to the [Echo server]. ### Example2 ### -**[Example2]** starts a WebSocket server. +[Example2] starts a WebSocket server. ### Example3 ### -**[Example3]** starts an HTTP server that allows to accept the WebSocket handshake requests. +[Example3] starts an HTTP server that allows to accept the WebSocket handshake requests. Would you access to [http://localhost:4649](http://localhost:4649) to do **WebSocket Echo Test** with your web browser while Example3 is running? From 5e1270961039b6ea587e2fac4b65f60ac065529c Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 4 Jan 2017 17:23:52 +0900 Subject: [PATCH 0870/6294] [Modify] Add it --- websocket-sharp/Ext.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 1a13a934f..7c43986bb 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -290,6 +290,14 @@ internal static bool ContainsTwice (this string[] values) return contains (0); } + internal static T[] Copy (this T[] source, int length) + { + var dest = new T[length]; + Array.Copy (source, 0, dest, 0, length); + + return dest; + } + internal static T[] Copy (this T[] source, long length) { var dest = new T[length]; From 6effadef75be6f175d579a1d25613ca83c7383de Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 5 Jan 2017 16:35:54 +0900 Subject: [PATCH 0871/6294] [Modify] Add it --- websocket-sharp/WebSocketFrame.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index 219242c1d..75ba85244 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -650,6 +650,13 @@ internal static WebSocketFrame CreatePingFrame (byte[] data, bool mask) return new WebSocketFrame (Fin.Final, Opcode.Ping, new PayloadData (data), false, mask); } + internal static WebSocketFrame CreatePongFrame (byte[] data, bool mask) + { + return new WebSocketFrame ( + Fin.Final, Opcode.Pong, new PayloadData (data), false, mask + ); + } + internal static WebSocketFrame ReadFrame (Stream stream, bool unmask) { var frame = readHeader (stream); From a0bfa1f52d15c041e6ddbe2cc6998c722d261831 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 6 Jan 2017 17:57:11 +0900 Subject: [PATCH 0872/6294] [Fix] Unmask it --- websocket-sharp/WebSocket.cs | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 57953e471..e0283c80b 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1473,13 +1473,26 @@ private bool processFragmentFrame (WebSocketFrame frame) private bool processPingFrame (WebSocketFrame frame) { var data = frame.PayloadData.ApplicationData; - if (!send (Fin.Final, Opcode.Pong, data, false)) - return false; + var pong = WebSocketFrame.CreatePongFrame (data, _client); + + lock (_forState) { + if (_readyState != WebSocketState.Open) { + _logger.Error ("The state of the connection has been changed."); + return false; + } + + if (!sendBytes (pong.ToArray ())) + return false; + } _logger.Trace ("A pong has been sent to respond to this ping."); - if (_emitOnPing) + if (_emitOnPing) { + if (_client) + pong.Unmask (); + enqueueToMessageEventQueue (new MessageEventArgs (frame)); + } return true; } From 1d2461a05befca97e00c4aa68efc3948e700203f Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 7 Jan 2017 17:05:48 +0900 Subject: [PATCH 0873/6294] [Modify] Polish it --- websocket-sharp/WebSocketFrame.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index 75ba85244..9f8c968ce 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -635,9 +635,13 @@ private static void readPayloadDataAsync ( #region Internal Methods - internal static WebSocketFrame CreateCloseFrame (PayloadData payloadData, bool mask) + internal static WebSocketFrame CreateCloseFrame ( + PayloadData payloadData, bool mask + ) { - return new WebSocketFrame (Fin.Final, Opcode.Close, payloadData, false, mask); + return new WebSocketFrame ( + Fin.Final, Opcode.Close, payloadData, false, mask + ); } internal static WebSocketFrame CreatePingFrame (bool mask) From fd4ac4fbc66aea1eb647d8243288cb7db499e498 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 7 Jan 2017 17:08:08 +0900 Subject: [PATCH 0874/6294] [Modify] Polish it --- websocket-sharp/WebSocketFrame.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index 9f8c968ce..e0a2e4fc3 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -646,7 +646,9 @@ internal static WebSocketFrame CreateCloseFrame ( internal static WebSocketFrame CreatePingFrame (bool mask) { - return new WebSocketFrame (Fin.Final, Opcode.Ping, PayloadData.Empty, false, mask); + return new WebSocketFrame ( + Fin.Final, Opcode.Ping, PayloadData.Empty, false, mask + ); } internal static WebSocketFrame CreatePingFrame (byte[] data, bool mask) From c068db5269178b4ebfe6d2811648a4fee7d569f7 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 7 Jan 2017 17:10:40 +0900 Subject: [PATCH 0875/6294] [Modify] Polish it --- websocket-sharp/WebSocketFrame.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index e0a2e4fc3..359880a50 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -653,7 +653,9 @@ internal static WebSocketFrame CreatePingFrame (bool mask) internal static WebSocketFrame CreatePingFrame (byte[] data, bool mask) { - return new WebSocketFrame (Fin.Final, Opcode.Ping, new PayloadData (data), false, mask); + return new WebSocketFrame ( + Fin.Final, Opcode.Ping, new PayloadData (data), false, mask + ); } internal static WebSocketFrame CreatePongFrame (byte[] data, bool mask) From 6d1e7a8fa631fcd77cbce7f10a465c5a8aaf630c Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 7 Jan 2017 17:15:00 +0900 Subject: [PATCH 0876/6294] [Modify] Add it --- websocket-sharp/WebSocketFrame.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index 359880a50..8ddabe65c 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -665,6 +665,15 @@ internal static WebSocketFrame CreatePongFrame (byte[] data, bool mask) ); } + internal static WebSocketFrame CreatePongFrame ( + PayloadData payloadData, bool mask + ) + { + return new WebSocketFrame ( + Fin.Final, Opcode.Pong, payloadData, false, mask + ); + } + internal static WebSocketFrame ReadFrame (Stream stream, bool unmask) { var frame = readHeader (stream); From 15bc590c68325c77a6a6faa931ea420a0a9240d0 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 8 Jan 2017 17:07:49 +0900 Subject: [PATCH 0877/6294] [Modify] Replace it --- websocket-sharp/WebSocket.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index e0283c80b..d6a225283 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1472,8 +1472,7 @@ private bool processFragmentFrame (WebSocketFrame frame) private bool processPingFrame (WebSocketFrame frame) { - var data = frame.PayloadData.ApplicationData; - var pong = WebSocketFrame.CreatePongFrame (data, _client); + var pong = WebSocketFrame.CreatePongFrame (frame.PayloadData, _client); lock (_forState) { if (_readyState != WebSocketState.Open) { From 50a3379392f6f442e40564b259d7c27acf68c5ab Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 8 Jan 2017 17:18:07 +0900 Subject: [PATCH 0878/6294] [Fix] Return true For Closing --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index d6a225283..94247f855 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1477,7 +1477,7 @@ private bool processPingFrame (WebSocketFrame frame) lock (_forState) { if (_readyState != WebSocketState.Open) { _logger.Error ("The state of the connection has been changed."); - return false; + return true; } if (!sendBytes (pong.ToArray ())) From 46bc283d577e4e6fd3c321a32370121a096ae46a Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 9 Jan 2017 16:48:03 +0900 Subject: [PATCH 0879/6294] [Modify] Remove it --- websocket-sharp/WebSocketFrame.cs | 7 ------- 1 file changed, 7 deletions(-) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index 8ddabe65c..2abf2ec98 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -658,13 +658,6 @@ internal static WebSocketFrame CreatePingFrame (byte[] data, bool mask) ); } - internal static WebSocketFrame CreatePongFrame (byte[] data, bool mask) - { - return new WebSocketFrame ( - Fin.Final, Opcode.Pong, new PayloadData (data), false, mask - ); - } - internal static WebSocketFrame CreatePongFrame ( PayloadData payloadData, bool mask ) From 5e0f3532ce6cc20d7e956ea16dcfa9e116461d59 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 10 Jan 2017 17:28:29 +0900 Subject: [PATCH 0880/6294] [Modify] Polish it --- websocket-sharp/WebSocketFrame.cs | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index 2abf2ec98..3be6300fe 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -681,7 +681,11 @@ internal static WebSocketFrame ReadFrame (Stream stream, bool unmask) } internal static void ReadFrameAsync ( - Stream stream, bool unmask, Action completed, Action error) + Stream stream, + bool unmask, + Action completed, + Action error + ) { readHeaderAsync ( stream, @@ -703,10 +707,14 @@ internal static void ReadFrameAsync ( completed (frame3); }, - error), - error), - error), - error); + error + ), + error + ), + error + ), + error + ); } internal void Unmask () From 761ff6856590c4f2a291d64ea417173a0beb62a8 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 11 Jan 2017 17:28:29 +0900 Subject: [PATCH 0881/6294] [Modify] Add it --- websocket-sharp/WebSocket.cs | 50 ++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 94247f855..7b54231b6 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2186,6 +2186,56 @@ internal void Close (HttpStatusCode code) Close (createHandshakeFailureResponse (code)); } + // As server + internal void Close (PayloadData payloadData, byte[] frameAsBytes) + { + lock (_forState) { + if (_readyState == WebSocketState.Closing) { + _logger.Info ("The closing is already in progress."); + return; + } + + if (_readyState == WebSocketState.Closed) { + _logger.Info ("The connection has already been closed."); + return; + } + + _readyState = WebSocketState.Closing; + } + + _logger.Trace ("Begin closing the connection."); + + var sent = frameAsBytes != null && sendBytes (frameAsBytes); + var received = sent && _receivingExited != null + ? _receivingExited.WaitOne (_waitTime) + : false; + + var res = sent && received; + + _logger.Debug ( + String.Format ( + "Was clean?: {0}\n sent: {1}\n received: {2}", res, sent, received + ) + ); + + releaseServerResources (); + releaseCommonResources (); + + _logger.Trace ("End closing the connection."); + + _readyState = WebSocketState.Closed; + + var e = new CloseEventArgs (payloadData); + e.WasClean = res; + + try { + OnClose.Emit (this, e); + } + catch (Exception ex) { + _logger.Error (ex.ToString ()); + } + } + // As server internal void Close (CloseEventArgs e, byte[] frameAsBytes, bool receive) { From 0e2a5ae7db26f53e0206560a388b24dd5d225ae3 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 12 Jan 2017 16:59:38 +0900 Subject: [PATCH 0882/6294] [Modify] Add them --- .../Server/WebSocketSessionManager.cs | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 88271994a..b910c18f5 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -290,6 +290,23 @@ private void setSweepTimer (double interval) _sweepTimer.Elapsed += (sender, e) => Sweep (); } + private void stop (PayloadData payloadData, bool send) + { + var bytes = send + ? WebSocketFrame.CreateCloseFrame (payloadData, false).ToArray () + : null; + + lock (_sync) { + _state = ServerState.ShuttingDown; + + _sweepTimer.Enabled = false; + foreach (var session in _sessions.Values.ToList ()) + session.Context.WebSocket.Close (payloadData, bytes); + + _state = ServerState.Stop; + } + } + private bool tryGetSession (string id, out IWebSocketSession session) { bool ret; @@ -368,6 +385,16 @@ internal void Start () } } + internal void Stop (ushort code, string reason) + { + if (code == 1005) { // == no status + stop (PayloadData.Empty, true); + return; + } + + stop (new PayloadData (code, reason), !code.IsReserved ()); + } + internal void Stop (CloseEventArgs e, byte[] frameAsBytes, bool receive) { lock (_sync) { From f047e07591a837021c957913f4e277d663d5627b Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 12 Jan 2017 17:15:00 +0900 Subject: [PATCH 0883/6294] [Modify] Replace it --- websocket-sharp/Server/WebSocketServiceHost.cs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceHost.cs b/websocket-sharp/Server/WebSocketServiceHost.cs index 8d41d2104..f4d9b3df2 100644 --- a/websocket-sharp/Server/WebSocketServiceHost.cs +++ b/websocket-sharp/Server/WebSocketServiceHost.cs @@ -129,10 +129,7 @@ internal void StartSession (WebSocketContext context) internal void Stop (ushort code, string reason) { - var e = new CloseEventArgs (code, reason); - var send = !code.IsReserved (); - var bytes = send ? WebSocketFrame.CreateCloseFrame (e.PayloadData, false).ToArray () : null; - Sessions.Stop (e, bytes, send); + Sessions.Stop (code, reason); } #endregion From fb62b1e60fcdac840a5d27c755e7b6c3f0ebbf84 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 13 Jan 2017 16:20:48 +0900 Subject: [PATCH 0884/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServiceHost.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceHost.cs b/websocket-sharp/Server/WebSocketServiceHost.cs index f4d9b3df2..de15aacd4 100644 --- a/websocket-sharp/Server/WebSocketServiceHost.cs +++ b/websocket-sharp/Server/WebSocketServiceHost.cs @@ -39,11 +39,12 @@ namespace WebSocketSharp.Server { /// - /// Exposes the methods and properties used to access the information in a WebSocket service - /// provided by the or . + /// Exposes the methods and properties used to access the information in + /// a WebSocket service provided by the or + /// . /// /// - /// The WebSocketServiceHost class is an abstract class. + /// This class is an abstract class. /// public abstract class WebSocketServiceHost { From 053299020ef075b5879c1947718ffaf48c35e35f Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 13 Jan 2017 16:26:07 +0900 Subject: [PATCH 0885/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServiceHost.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServiceHost.cs b/websocket-sharp/Server/WebSocketServiceHost.cs index de15aacd4..f6fd8e6ec 100644 --- a/websocket-sharp/Server/WebSocketServiceHost.cs +++ b/websocket-sharp/Server/WebSocketServiceHost.cs @@ -72,7 +72,7 @@ internal ServerState State { #region Public Properties /// - /// Gets or sets a value indicating whether the WebSocket service cleans up + /// Gets or sets a value indicating whether the service cleans up /// the inactive sessions periodically. /// /// From 23e3c8f8cc8c70dcae7beb28e91186b4b8317e05 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 13 Jan 2017 16:28:45 +0900 Subject: [PATCH 0886/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServiceHost.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServiceHost.cs b/websocket-sharp/Server/WebSocketServiceHost.cs index f6fd8e6ec..1e87a3da4 100644 --- a/websocket-sharp/Server/WebSocketServiceHost.cs +++ b/websocket-sharp/Server/WebSocketServiceHost.cs @@ -82,7 +82,7 @@ internal ServerState State { public abstract bool KeepClean { get; set; } /// - /// Gets the path to the WebSocket service. + /// Gets the path to the service. /// /// /// A that represents the absolute path to the service. From 0613781093f8822ac25ab513e59b347a12177fd2 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 13 Jan 2017 16:33:41 +0900 Subject: [PATCH 0887/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServiceHost.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceHost.cs b/websocket-sharp/Server/WebSocketServiceHost.cs index 1e87a3da4..8a81046ca 100644 --- a/websocket-sharp/Server/WebSocketServiceHost.cs +++ b/websocket-sharp/Server/WebSocketServiceHost.cs @@ -90,10 +90,11 @@ internal ServerState State { public abstract string Path { get; } /// - /// Gets the access to the sessions in the WebSocket service. + /// Gets the access to the sessions in the service. /// /// - /// A that manages the sessions in the service. + /// A that manages the sessions in + /// the service. /// public abstract WebSocketSessionManager Sessions { get; } From 0d4dd70d4c98ab529c8a116eaa0c9de06d99cf11 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 13 Jan 2017 16:46:20 +0900 Subject: [PATCH 0888/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServiceHost.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceHost.cs b/websocket-sharp/Server/WebSocketServiceHost.cs index 8a81046ca..f11f719d0 100644 --- a/websocket-sharp/Server/WebSocketServiceHost.cs +++ b/websocket-sharp/Server/WebSocketServiceHost.cs @@ -99,10 +99,11 @@ internal ServerState State { public abstract WebSocketSessionManager Sessions { get; } /// - /// Gets the of the behavior of the WebSocket service. + /// Gets the of the behavior of the service. /// /// - /// A that represents the type of the behavior of the service. + /// A that represents the type of the behavior of + /// the service. /// public abstract Type Type { get; } From 440a92ef883813259663faf043d17fcbb800d816 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 13 Jan 2017 16:53:37 +0900 Subject: [PATCH 0889/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServiceHost.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceHost.cs b/websocket-sharp/Server/WebSocketServiceHost.cs index f11f719d0..9d4602718 100644 --- a/websocket-sharp/Server/WebSocketServiceHost.cs +++ b/websocket-sharp/Server/WebSocketServiceHost.cs @@ -111,8 +111,7 @@ internal ServerState State { /// Gets or sets the wait time for the response to the WebSocket Ping or Close. /// /// - /// A that represents the wait time. The default value is - /// the same as 1 second. + /// A that represents the wait time for the response. /// public abstract TimeSpan WaitTime { get; set; } From 8e709950c75605764db7efc066cfc34eea9f6461 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 13 Jan 2017 16:58:35 +0900 Subject: [PATCH 0890/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServiceHost.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServiceHost.cs b/websocket-sharp/Server/WebSocketServiceHost.cs index 9d4602718..69c47a69e 100644 --- a/websocket-sharp/Server/WebSocketServiceHost.cs +++ b/websocket-sharp/Server/WebSocketServiceHost.cs @@ -139,7 +139,7 @@ internal void Stop (ushort code, string reason) #region Protected Methods /// - /// Creates a new session in the WebSocket service. + /// Creates a new session in the service. /// /// /// A instance that represents a new session. From 71e937a1510c4879a826c15228a46b761d939e59 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 13 Jan 2017 17:04:58 +0900 Subject: [PATCH 0891/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServiceHost.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServiceHost.cs b/websocket-sharp/Server/WebSocketServiceHost.cs index 69c47a69e..3e46c225b 100644 --- a/websocket-sharp/Server/WebSocketServiceHost.cs +++ b/websocket-sharp/Server/WebSocketServiceHost.cs @@ -139,7 +139,7 @@ internal void Stop (ushort code, string reason) #region Protected Methods /// - /// Creates a new session in the service. + /// Creates a new session for the service. /// /// /// A instance that represents a new session. From f3ed3e27d795d68c9b4f7f687679297dea49dcf7 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 14 Jan 2017 16:45:59 +0900 Subject: [PATCH 0892/6294] [Modify] 2017 --- websocket-sharp/Server/WebSocketServiceHost.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServiceHost.cs b/websocket-sharp/Server/WebSocketServiceHost.cs index 3e46c225b..cfc702147 100644 --- a/websocket-sharp/Server/WebSocketServiceHost.cs +++ b/websocket-sharp/Server/WebSocketServiceHost.cs @@ -4,7 +4,7 @@ * * The MIT License * - * Copyright (c) 2012-2015 sta.blockhead + * Copyright (c) 2012-2017 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From 81530bbf56048dd316692a3cc9ff4c4594e24591 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 15 Jan 2017 15:55:40 +0900 Subject: [PATCH 0893/6294] [Modify] Add it --- websocket-sharp/Server/WebSocketServiceManager.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index 8ed76b335..96d165e41 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -356,6 +356,19 @@ internal void Start () } } + internal void Stop (ushort code, string reason) + { + lock (_sync) { + _state = ServerState.ShuttingDown; + + foreach (var host in _hosts.Values) + host.Stop (code, reason); + + _hosts.Clear (); + _state = ServerState.Stop; + } + } + internal void Stop (CloseEventArgs e, bool send, bool receive) { lock (_sync) { From fa30a602e123063e7732ccef715ebb18558371de Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 16 Jan 2017 16:48:16 +0900 Subject: [PATCH 0894/6294] [Modify] Add it --- websocket-sharp/Server/WebSocketServer.cs | 37 +++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index dbbdbe31d..da0309e10 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -837,6 +837,43 @@ private void startReceiving () _receiveThread.Start (); } + private void stop (ushort code, string reason) + { + if (_state == ServerState.Ready) { + _logger.Info ("The server is not started."); + return; + } + + if (_state == ServerState.ShuttingDown) { + _logger.Info ("The server is shutting down."); + return; + } + + if (_state == ServerState.Stop) { + _logger.Info ("The server has already stopped."); + return; + } + + lock (_sync) { + if (_state == ServerState.ShuttingDown) { + _logger.Info ("The server is shutting down."); + return; + } + + if (_state == ServerState.Stop) { + _logger.Info ("The server has already stopped."); + return; + } + + _state = ServerState.ShuttingDown; + } + + stopReceiving (5000); + _services.Stop (code, reason); + + _state = ServerState.Stop; + } + private void stopReceiving (int millisecondsTimeout) { _listener.Stop (); From cd017fab2744ad72658fbe71be350f630990e4c8 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 17 Jan 2017 15:30:23 +0900 Subject: [PATCH 0895/6294] [Modify] Replace it --- websocket-sharp/Server/WebSocketServer.cs | 20 +------------------- 1 file changed, 1 insertion(+), 19 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index da0309e10..fb41fd73c 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -1025,25 +1025,7 @@ public void Start () /// public void Stop () { - string msg; - if (!checkIfAvailable (false, true, false, false, out msg)) { - _logger.Error (msg); - return; - } - - lock (_sync) { - if (!checkIfAvailable (false, true, false, false, out msg)) { - _logger.Error (msg); - return; - } - - _state = ServerState.ShuttingDown; - } - - stopReceiving (5000); - _services.Stop (new CloseEventArgs (), true, true); - - _state = ServerState.Stop; + stop (1005, String.Empty); } /// From b24ae75f0b3b7ee494b8fc2776244a031a4d8633 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 17 Jan 2017 15:45:24 +0900 Subject: [PATCH 0896/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index fb41fd73c..6ff6f0357 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -1020,9 +1020,13 @@ public void Start () } /// - /// Stops receiving the WebSocket handshake requests, and closes - /// the WebSocket connections. + /// Stops receiving the WebSocket handshake requests, + /// and closes the WebSocket connections. /// + /// + /// This method does nothing if the server is not started, + /// it is shutting down, or it has already stopped. + /// public void Stop () { stop (1005, String.Empty); From abcce988a313eb057773cbf4bc9d3bd9716354ea Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 17 Jan 2017 15:52:51 +0900 Subject: [PATCH 0897/6294] [Modify] Replace it --- websocket-sharp/Server/WebSocketServer.cs | 26 +---------------------- 1 file changed, 1 insertion(+), 25 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 6ff6f0357..0f3ca0174 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -1050,36 +1050,12 @@ public void Stop () public void Stop (ushort code, string reason) { string msg; - if (!checkIfAvailable (false, true, false, false, out msg)) { - _logger.Error (msg); - return; - } - if (!WebSocket.CheckParametersForClose (code, reason, false, out msg)) { _logger.Error (msg); return; } - lock (_sync) { - if (!checkIfAvailable (false, true, false, false, out msg)) { - _logger.Error (msg); - return; - } - - _state = ServerState.ShuttingDown; - } - - stopReceiving (5000); - - if (code == (ushort) CloseStatusCode.NoStatus) { - _services.Stop (new CloseEventArgs (), true, true); - } - else { - var send = !code.IsReserved (); - _services.Stop (new CloseEventArgs (code, reason), send, send); - } - - _state = ServerState.Stop; + stop (code, reason); } /// From 7a9c92a9a8649a4938306463502958dd790dfd9f Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 18 Jan 2017 16:43:39 +0900 Subject: [PATCH 0898/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 0f3ca0174..8815ffe1c 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -1033,10 +1033,14 @@ public void Stop () } /// - /// Stops receiving the WebSocket handshake requests, and closes - /// the WebSocket connections with the specified and - /// . + /// Stops receiving the WebSocket handshake requests, + /// and closes the WebSocket connections with the specified + /// and . /// + /// + /// This method does nothing if the server is not started, + /// it is shutting down, or it has already stopped. + /// /// /// A that represents the status code indicating /// the reason for the close. The status codes are defined in @@ -1045,7 +1049,7 @@ public void Stop () /// /// /// A that represents the reason for the close. - /// The size must be 123 bytes or less. + /// The size must be 123 bytes or less in UTF-8. /// public void Stop (ushort code, string reason) { From 1e311feb9893f06ee943f4ecf741b2b8f6658d5d Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 18 Jan 2017 16:48:28 +0900 Subject: [PATCH 0899/6294] [Modify] Replace it --- websocket-sharp/Server/WebSocketServer.cs | 26 +---------------------- 1 file changed, 1 insertion(+), 25 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 8815ffe1c..e80130943 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -1078,36 +1078,12 @@ public void Stop (ushort code, string reason) public void Stop (CloseStatusCode code, string reason) { string msg; - if (!checkIfAvailable (false, true, false, false, out msg)) { - _logger.Error (msg); - return; - } - if (!WebSocket.CheckParametersForClose (code, reason, false, out msg)) { _logger.Error (msg); return; } - lock (_sync) { - if (!checkIfAvailable (false, true, false, false, out msg)) { - _logger.Error (msg); - return; - } - - _state = ServerState.ShuttingDown; - } - - stopReceiving (5000); - - if (code == CloseStatusCode.NoStatus) { - _services.Stop (new CloseEventArgs (), true, true); - } - else { - var send = !code.IsReserved (); - _services.Stop (new CloseEventArgs (code, reason), send, send); - } - - _state = ServerState.Stop; + stop ((ushort) code, reason); } #endregion From cba0dd223837d70c0bf49cd8748834e16d87c9cc Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 19 Jan 2017 16:15:37 +0900 Subject: [PATCH 0900/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index e80130943..74a6e455b 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -1063,17 +1063,22 @@ public void Stop (ushort code, string reason) } /// - /// Stops receiving the WebSocket handshake requests, and closes - /// the WebSocket connections with the specified and - /// . + /// Stops receiving the WebSocket handshake requests, + /// and closes the WebSocket connections with the specified + /// and . /// + /// + /// This method does nothing if the server is not started, + /// it is shutting down, or it has already stopped. + /// /// - /// One of the enum values that represents - /// the status code indicating the reason for the close. + /// One of the enum values. + /// It represents the status code indicating the reason for + /// the close. /// /// - /// A that represents the reason for the close. - /// The size must be 123 bytes or less. + /// A that represents the reason for + /// the close. The size must be 123 bytes or less in UTF-8. /// public void Stop (CloseStatusCode code, string reason) { From c64674384101c04627b1dcea48151801a51c5148 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 20 Jan 2017 16:33:32 +0900 Subject: [PATCH 0901/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 74a6e455b..e631f5a9c 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -1042,14 +1042,19 @@ public void Stop () /// it is shutting down, or it has already stopped. /// /// - /// A that represents the status code indicating - /// the reason for the close. The status codes are defined in - /// - /// Section 7.4 of RFC 6455. + /// + /// A that represents the status code + /// indicating the reason for the close. + /// + /// + /// The status codes are defined in + /// + /// Section 7.4 of RFC 6455. + /// /// /// - /// A that represents the reason for the close. - /// The size must be 123 bytes or less in UTF-8. + /// A that represents the reason for + /// the close. The size must be 123 bytes or less in UTF-8. /// public void Stop (ushort code, string reason) { From 260803eb18df21c3809c4a6bb4708c27263a32a9 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 21 Jan 2017 17:03:17 +0900 Subject: [PATCH 0902/6294] [Modify] Abort as an abnormal --- websocket-sharp/Server/WebSocketServer.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index e631f5a9c..6a17875d0 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -628,15 +628,19 @@ public WebSocketServiceManager WebSocketServices { private void abort () { lock (_sync) { - if (!IsListening) + if (_state != ServerState.Start) return; _state = ServerState.ShuttingDown; } - _listener.Stop (); - _services.Stop (new CloseEventArgs (CloseStatusCode.ServerError), true, false); + try { + _listener.Stop (); + } + catch { + } + _services.Stop (1006, String.Empty); _state = ServerState.Stop; } From 59346f550f209331c3a1750cd397480d1a63b004 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 22 Jan 2017 17:27:37 +0900 Subject: [PATCH 0903/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketServer.cs | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 6a17875d0..0d9dc305c 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -797,12 +797,15 @@ private void processRequest (TcpListenerWebSocketContext context) private void receiveRequest () { while (true) { + TcpClient cl = null; try { - var cl = _listener.AcceptTcpClient (); + cl = _listener.AcceptTcpClient (); ThreadPool.QueueUserWorkItem ( state => { try { - var ctx = cl.GetWebSocketContext (null, _secure, _sslConfigInUse, _logger); + var ctx = + cl.GetWebSocketContext (null, _secure, _sslConfigInUse, _logger); + if (!ctx.Authenticate (_authSchemes, _realmInUse, _userCredFinder)) return; @@ -816,16 +819,24 @@ private void receiveRequest () ); } catch (SocketException ex) { - _logger.Warn ("Receiving has been stopped.\n reason: " + ex.Message); + if (_state == ServerState.ShuttingDown) { + _logger.Info ("The receiving is stopped."); + break; + } + + _logger.Fatal (ex.ToString ()); break; } catch (Exception ex) { _logger.Fatal (ex.ToString ()); + if (cl != null) + cl.Close (); + break; } } - if (IsListening) + if (_state == ServerState.Start) abort (); } From 079cd4db39abf65b6d810388a5cd0d61db460142 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 23 Jan 2017 16:27:04 +0900 Subject: [PATCH 0904/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketServer.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 0d9dc305c..456c8d964 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -842,9 +842,11 @@ private void receiveRequest () private void startReceiving () { - if (_reuseAddress) + if (_reuseAddress) { _listener.Server.SetSocketOption ( - SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true); + SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true + ); + } _listener.Start (); _receiveThread = new Thread (new ThreadStart (receiveRequest)); From 57441de58550617b3a5cee3e7f7958c4e65a2d77 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 24 Jan 2017 16:18:40 +0900 Subject: [PATCH 0905/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketServer.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 456c8d964..bcf433469 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -897,14 +897,16 @@ private void stopReceiving (int millisecondsTimeout) _receiveThread.Join (millisecondsTimeout); } - private static bool tryCreateUri (string uriString, out Uri result, out string message) + private static bool tryCreateUri ( + string uriString, out Uri result, out string message + ) { if (!uriString.TryCreateWebSocketUri (out result, out message)) return false; if (result.PathAndQuery != "/") { result = null; - message = "Includes the path or query component: " + uriString; + message = "It includes the path or query component."; return false; } From c70ec7f96d679fdf1daee8e71812d14b127dfa42 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 24 Jan 2017 16:54:39 +0900 Subject: [PATCH 0906/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 7c43986bb..e12fc6f48 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -926,35 +926,37 @@ internal static string TrimEndSlash (this string value) /// or if is valid. /// internal static bool TryCreateWebSocketUri ( - this string uriString, out Uri result, out string message) + this string uriString, out Uri result, out string message + ) { result = null; + message = null; var uri = uriString.ToUri (); if (uri == null) { - message = "An invalid URI string: " + uriString; + message = "An invalid URI string."; return false; } if (!uri.IsAbsoluteUri) { - message = "Not an absolute URI: " + uriString; + message = "Not an absolute URI."; return false; } var schm = uri.Scheme; if (!(schm == "ws" || schm == "wss")) { - message = "The scheme part isn't 'ws' or 'wss': " + uriString; + message = "The scheme part is not 'ws' or 'wss'."; return false; } if (uri.Fragment.Length > 0) { - message = "Includes the fragment component: " + uriString; + message = "It includes the fragment component."; return false; } var port = uri.Port; if (port == 0) { - message = "The port part is zero: " + uriString; + message = "The port part is zero."; return false; } @@ -966,9 +968,10 @@ internal static bool TryCreateWebSocketUri ( schm, uri.Host, schm == "ws" ? 80 : 443, - uri.PathAndQuery)); + uri.PathAndQuery + ) + ); - message = String.Empty; return true; } From f5ebe3730d5ef5548cba2ba1da2e9dc50ada9c14 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 25 Jan 2017 15:59:38 +0900 Subject: [PATCH 0907/6294] [Modify] Edit it --- websocket-sharp/Ext.cs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index e12fc6f48..4cb137959 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -908,22 +908,25 @@ internal static string TrimEndSlash (this string value) } /// - /// Tries to create a for WebSocket with + /// Tries to create a new for WebSocket with /// the specified . /// /// - /// true if a is successfully created; otherwise, false. + /// true if the was successfully created; + /// otherwise, false. /// /// /// A that represents a WebSocket URL to try. /// /// - /// When this method returns, a that represents a WebSocket URL, - /// or if is invalid. + /// When this method returns, a that + /// represents the WebSocket URL or + /// if is invalid. /// /// - /// When this method returns, a that represents an error message, - /// or if is valid. + /// When this method returns, a that + /// represents an error message or + /// if is valid. /// internal static bool TryCreateWebSocketUri ( this string uriString, out Uri result, out string message From 6f42f4ff475e75521913077b7081063629f0c7c2 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 25 Jan 2017 16:29:31 +0900 Subject: [PATCH 0908/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 4cb137959..37df2483f 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -942,7 +942,7 @@ internal static bool TryCreateWebSocketUri ( } if (!uri.IsAbsoluteUri) { - message = "Not an absolute URI."; + message = "A relative URI."; return false; } @@ -952,17 +952,17 @@ internal static bool TryCreateWebSocketUri ( return false; } - if (uri.Fragment.Length > 0) { - message = "It includes the fragment component."; - return false; - } - var port = uri.Port; if (port == 0) { message = "The port part is zero."; return false; } + if (uri.Fragment.Length > 0) { + message = "It includes the fragment component."; + return false; + } + result = port != -1 ? uri : new Uri ( From 09e3514453fedb17479a0b36d03333201ad9cb64 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 25 Jan 2017 16:35:52 +0900 Subject: [PATCH 0909/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 37df2483f..3dab29f65 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1923,7 +1923,10 @@ public static Uri ToUri (this string uriString) { Uri ret; Uri.TryCreate ( - uriString, uriString.MaybeUri () ? UriKind.Absolute : UriKind.Relative, out ret); + uriString, + uriString.MaybeUri () ? UriKind.Absolute : UriKind.Relative, + out ret + ); return ret; } From 4380eef0ddd0e00ae096e494ca2363ea21825e77 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 25 Jan 2017 17:02:08 +0900 Subject: [PATCH 0910/6294] [Modify] Edit it --- websocket-sharp/Ext.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 3dab29f65..26c458ed9 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1913,8 +1913,8 @@ public static string ToString (this T[] array, string separator) /// Converts the specified to a . /// /// - /// A converted from , - /// or if isn't successfully converted. + /// A converted from or + /// if the convert has failed. /// /// /// A to convert. From 1617f7b5a6683cc859e283e4942188b8b1ef5ccc Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 26 Jan 2017 15:53:47 +0900 Subject: [PATCH 0911/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 26c458ed9..fd320122b 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1913,19 +1913,17 @@ public static string ToString (this T[] array, string separator) /// Converts the specified to a . /// /// - /// A converted from or + /// A converted from or /// if the convert has failed. /// - /// + /// /// A to convert. /// - public static Uri ToUri (this string uriString) + public static Uri ToUri (this string value) { Uri ret; Uri.TryCreate ( - uriString, - uriString.MaybeUri () ? UriKind.Absolute : UriKind.Relative, - out ret + value, value.MaybeUri () ? UriKind.Absolute : UriKind.Relative, out ret ); return ret; From 94bcc841f8e9915ae2b2fdb0c0c84cf531c2bbad Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 26 Jan 2017 16:03:35 +0900 Subject: [PATCH 0912/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index fd320122b..e0d5779b3 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1525,7 +1525,8 @@ public static bool MaybeUri (this string value) if (idx >= 10) return false; - return value.Substring (0, idx).IsPredefinedScheme (); + var schm = value.Substring (0, idx); + return schm.IsPredefinedScheme (); } /// From db95ecd184183d2612c4b9eaaa0c5ffcb0b5630f Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 26 Jan 2017 16:10:09 +0900 Subject: [PATCH 0913/6294] [Modify] Edit it --- websocket-sharp/Ext.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index e0d5779b3..55eea7c71 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1508,7 +1508,8 @@ public static bool IsUpgradeTo (this HttpListenerRequest request, string protoco /// Determines whether the specified is a URI string. /// /// - /// true if may be a URI string; otherwise, false. + /// true if may be a URI string; + /// otherwise, false. /// /// /// A to test. From 3889002de6d2635de8949680f1e97846a8fe0ef2 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 26 Jan 2017 16:30:34 +0900 Subject: [PATCH 0914/6294] [Modify] Edit it --- websocket-sharp/Ext.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 55eea7c71..10a3a8107 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1428,10 +1428,12 @@ public static bool IsNullOrEmpty (this string value) } /// - /// Determines whether the specified is a predefined scheme. + /// Determines whether the specified is + /// a predefined scheme. /// /// - /// true if is a predefined scheme; otherwise, false. + /// true if is a predefined scheme; + /// otherwise, false. /// /// /// A to test. From ab2be96a48592f657722da0e9621bd883cdcc26f Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 26 Jan 2017 17:16:34 +0900 Subject: [PATCH 0915/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 10a3a8107..82b12b3b7 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1453,6 +1453,12 @@ public static bool IsPredefinedScheme (this string value) if (c == 'f') return value == "file" || value == "ftp"; + if (c == 'g') + return value == "gopher"; + + if (c == 'm') + return value == "mailto"; + if (c == 'n') { c = value[1]; return c == 'e' @@ -1460,7 +1466,7 @@ public static bool IsPredefinedScheme (this string value) : value == "nntp"; } - return (c == 'g' && value == "gopher") || (c == 'm' && value == "mailto"); + return false; } /// From bef14dc1ad23dc978f65bb6c2dc86c05c69c15d0 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 27 Jan 2017 16:20:20 +0900 Subject: [PATCH 0916/6294] [Fix] Add a null check --- websocket-sharp/Server/WebSocketServer.cs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index bcf433469..1ebffe3b5 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -176,9 +176,17 @@ public WebSocketServer (string url) throw new ArgumentException (msg, "url"); var host = uri.DnsSafeHost; + var addr = host.ToIPAddress (); - if (!addr.IsLocal ()) - throw new ArgumentException ("The host part isn't a local host name: " + url, "url"); + if (addr == null) { + msg = "It could not be converted to an IP address."; + throw new ArgumentException (msg, "url"); + } + + if (!addr.IsLocal ()) { + msg = "The IP address is not a local IP address."; + throw new ArgumentException (msg, "url"); + } init (host, addr, uri.Port, uri.Scheme == "wss"); } From 750bdff91f4ba78917eb403cf8b1d34d6ef2747b Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 28 Jan 2017 17:26:33 +0900 Subject: [PATCH 0917/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 82b12b3b7..7a7bc8f50 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -872,14 +872,18 @@ internal static string ToExtensionString ( return String.Format ("{0}; {1}", m, parameters.ToString ("; ")); } - internal static System.Net.IPAddress ToIPAddress (this string hostnameOrAddress) + internal static System.Net.IPAddress ToIPAddress (this string value) { + if (value == null || value.Length == 0) + return null; + System.Net.IPAddress addr; - if (System.Net.IPAddress.TryParse (hostnameOrAddress, out addr)) + if (System.Net.IPAddress.TryParse (value, out addr)) return addr; try { - return System.Net.Dns.GetHostAddresses (hostnameOrAddress)[0]; + var addrs = System.Net.Dns.GetHostAddresses (value); + return addrs[0]; } catch { return null; From 09cb095ed57223dec5a70c07db558328defe7905 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 28 Jan 2017 17:35:42 +0900 Subject: [PATCH 0918/6294] [Modify] Edit it --- websocket-sharp/Ext.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 7a7bc8f50..b8c3d6ea8 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1374,8 +1374,8 @@ public static bool IsHostOrder (this ByteOrder order) } /// - /// Determines whether the specified represents - /// a local IP address. + /// Determines whether the specified + /// represents a local IP address. /// /// /// This local means NOT REMOTE for the current host. From f300d7333d505aa5065536cf5c496cb2d2053728 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 29 Jan 2017 17:18:31 +0900 Subject: [PATCH 0919/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 1ebffe3b5..529553d57 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -131,22 +131,22 @@ public WebSocketServer (int port) } /// - /// Initializes a new instance of the class with - /// the specified WebSocket URL. + /// Initializes a new instance of the class + /// with the specified WebSocket URL. /// /// /// - /// An instance initialized by this constructor listens for the incoming connection requests - /// on the host name and port in . + /// The new instance listens for the incoming handshake requests on + /// the host name and port of . /// /// - /// If doesn't include a port, either port 80 or 443 is used on - /// which to listen. It's determined by the scheme (ws or wss) in . - /// (Port 80 if the scheme is ws.) + /// If includes no port, either port 80 or 443 is + /// used on which to listen. It is determined by the scheme (ws or wss) of + /// . /// /// /// - /// A that represents the WebSocket URL of the server. + /// A that represents the WebSocket URL for the server. /// /// /// is . From cc4788f590f61712a7353fc173cdb2c1d6e058e9 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 29 Jan 2017 17:20:56 +0900 Subject: [PATCH 0920/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 529553d57..388100955 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -54,7 +54,7 @@ namespace WebSocketSharp.Server /// Provides a WebSocket protocol server. /// /// - /// The WebSocketServer class can provide multiple WebSocket services. + /// This class can provide multiple WebSocket services. /// public class WebSocketServer { From f764f1fb3ca927cd2a68b3f24086acf081ed35a4 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 29 Jan 2017 17:27:52 +0900 Subject: [PATCH 0921/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 388100955..93bbac9d1 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -98,8 +98,7 @@ static WebSocketServer () /// Initializes a new instance of the class. /// /// - /// An instance initialized by this constructor listens for the incoming connection requests on - /// port 80. + /// The new instance listens for the incoming handshake requests on port 80. /// public WebSocketServer () { From 5bbaf7559943a3833942eb68fc2cb70078e0e502 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 30 Jan 2017 15:49:39 +0900 Subject: [PATCH 0922/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 93bbac9d1..bd24fb337 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -106,23 +106,23 @@ public WebSocketServer () } /// - /// Initializes a new instance of the class with - /// the specified . + /// Initializes a new instance of the class + /// with the specified . /// /// /// - /// An instance initialized by this constructor listens for the incoming connection requests - /// on . + /// The new instance listens for the incoming handshake requests on + /// . /// /// - /// If is 443, that instance provides a secure connection. + /// It provides secure connections if is 443. /// /// /// /// An that represents the port number on which to listen. /// /// - /// isn't between 1 and 65535 inclusive. + /// is less than 1 or greater than 65535. /// public WebSocketServer (int port) : this (port, port == 443) From b6909ac867bff4c31b4bd4a427046d5736807cf6 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 30 Jan 2017 15:57:42 +0900 Subject: [PATCH 0923/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketServer.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index bd24fb337..45d766a85 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -210,9 +210,10 @@ public WebSocketServer (string url) /// public WebSocketServer (int port, bool secure) { - if (!port.IsPortNumber ()) - throw new ArgumentOutOfRangeException ( - "port", "Not between 1 and 65535 inclusive: " + port); + if (!port.IsPortNumber ()) { + var msg = "It is less than 1 or greater than 65535."; + throw new ArgumentOutOfRangeException ("port", msg); + } init (null, System.Net.IPAddress.Any, port, secure); } From 0f97aea55811d18508ff1a462f454b31f25e1d67 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 30 Jan 2017 16:12:59 +0900 Subject: [PATCH 0924/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 45d766a85..71c7e43cb 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -195,18 +195,18 @@ public WebSocketServer (string url) /// the specified and . /// /// - /// An instance initialized by this constructor listens for the incoming connection requests on + /// The new instance listens for the incoming handshake requests on /// . /// /// /// An that represents the port number on which to listen. /// /// - /// A that indicates providing a secure connection or not. - /// (true indicates providing a secure connection.) + /// A that specifies providing secure connections or not. + /// true specifies providing secure connections. /// /// - /// isn't between 1 and 65535 inclusive. + /// is less than 1 or greater than 65535. /// public WebSocketServer (int port, bool secure) { From 93fb098bb15d91ac6c2fb0dd5a612592d0cebfd8 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 30 Jan 2017 16:21:00 +0900 Subject: [PATCH 0925/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketServer.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 71c7e43cb..ca3eb3c03 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -285,11 +285,12 @@ public WebSocketServer (System.Net.IPAddress address, int port, bool secure) throw new ArgumentNullException ("address"); if (!address.IsLocal ()) - throw new ArgumentException ("Not a local IP address: " + address, "address"); + throw new ArgumentException ("Not a local IP address.", "address"); - if (!port.IsPortNumber ()) - throw new ArgumentOutOfRangeException ( - "port", "Not between 1 and 65535 inclusive: " + port); + if (!port.IsPortNumber ()) { + var msg = "It is less than 1 or greater than 65535."; + throw new ArgumentOutOfRangeException ("port", msg); + } init (null, address, port, secure); } From be392541a05f00abd5c58e27a2a6d194a07ff0e8 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 30 Jan 2017 16:33:54 +0900 Subject: [PATCH 0926/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index ca3eb3c03..c4ed5f9a1 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -252,32 +252,33 @@ public WebSocketServer (System.Net.IPAddress address, int port) } /// - /// Initializes a new instance of the class with - /// the specified , , + /// Initializes a new instance of the class + /// with the specified , , /// and . /// /// - /// An instance initialized by this constructor listens for the incoming connection requests on + /// The new instance listens for the incoming handshake requests on /// and . /// /// - /// A that represents the local IP address of the server. + /// A that represents the local IP address + /// for the server. /// /// /// An that represents the port number on which to listen. /// /// - /// A that indicates providing a secure connection or not. - /// (true indicates providing a secure connection.) + /// A that specifies providing secure connections or not. + /// true specifies providing secure connections. /// /// /// is . /// /// - /// isn't a local IP address. + /// is not a local IP address. /// /// - /// isn't between 1 and 65535 inclusive. + /// is less than 1 or greater than 65535. /// public WebSocketServer (System.Net.IPAddress address, int port, bool secure) { From 47d3b96f00ffe01840fa77d61b966e4753a05ac8 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 30 Jan 2017 16:42:27 +0900 Subject: [PATCH 0927/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index c4ed5f9a1..33f42ebff 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -224,15 +224,16 @@ public WebSocketServer (int port, bool secure) /// /// /// - /// An instance initialized by this constructor listens for the incoming connection requests - /// on and . + /// The new instance listens for the incoming handshake requests on + /// and . /// /// - /// If is 443, that instance provides a secure connection. + /// It provides secure connections if is 443. /// /// /// - /// A that represents the local IP address of the server. + /// A that represents the local IP address + /// for the server. /// /// /// An that represents the port number on which to listen. @@ -241,10 +242,10 @@ public WebSocketServer (int port, bool secure) /// is . /// /// - /// isn't a local IP address. + /// is not a local IP address. /// /// - /// isn't between 1 and 65535 inclusive. + /// is less than 1 or greater than 65535. /// public WebSocketServer (System.Net.IPAddress address, int port) : this (address, port, port == 443) From 75196169e49c032bee59493387f364392493cd59 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 31 Jan 2017 15:48:55 +0900 Subject: [PATCH 0928/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 33f42ebff..d23faf88a 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -139,9 +139,13 @@ public WebSocketServer (int port) /// the host name and port of . /// /// + /// It provides secure connections if the scheme of + /// is wss. + /// + /// /// If includes no port, either port 80 or 443 is - /// used on which to listen. It is determined by the scheme (ws or wss) of - /// . + /// used on which to listen. It is determined by the scheme (ws or wss) + /// of . /// /// /// From 8336dd4be03442e178dea0fc49c597eaf31ef7b7 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 31 Jan 2017 15:54:07 +0900 Subject: [PATCH 0929/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketServer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index d23faf88a..18e3d4463 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -182,7 +182,7 @@ public WebSocketServer (string url) var addr = host.ToIPAddress (); if (addr == null) { - msg = "It could not be converted to an IP address."; + msg = "The host part could not be converted to an IP address."; throw new ArgumentException (msg, "url"); } From 4f3f165fc066420b0511b68ea2c2f3f724d3b2da Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 1 Feb 2017 17:05:33 +0900 Subject: [PATCH 0930/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketServer.cs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 18e3d4463..21159aead 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -102,7 +102,8 @@ static WebSocketServer () /// public WebSocketServer () { - init (null, System.Net.IPAddress.Any, 80, false); + var addr = System.Net.IPAddress.Any; + init (addr.ToString (), addr, 80, false); } /// @@ -219,7 +220,8 @@ public WebSocketServer (int port, bool secure) throw new ArgumentOutOfRangeException ("port", msg); } - init (null, System.Net.IPAddress.Any, port, secure); + var addr = System.Net.IPAddress.Any; + init (addr.ToString (), addr, port, secure); } /// @@ -298,7 +300,7 @@ public WebSocketServer (System.Net.IPAddress address, int port, bool secure) throw new ArgumentOutOfRangeException ("port", msg); } - init (null, address, port, secure); + init (address.ToString (), address, port, secure); } #endregion @@ -765,9 +767,11 @@ private ServerSslConfiguration getSslConfiguration () return ret; } - private void init (string hostname, System.Net.IPAddress address, int port, bool secure) + private void init ( + string hostname, System.Net.IPAddress address, int port, bool secure + ) { - _hostname = hostname ?? address.ToString (); + _hostname = hostname; _address = address; _port = port; _secure = secure; From 262922f0493407e5f037ba64fe93a41955922f9f Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 2 Feb 2017 17:37:20 +0900 Subject: [PATCH 0931/6294] [Fix] Use try-finally --- websocket-sharp/Server/WebSocketServer.cs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 21159aead..c7f454149 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -904,10 +904,17 @@ private void stop (ushort code, string reason) _state = ServerState.ShuttingDown; } - stopReceiving (5000); - _services.Stop (code, reason); - - _state = ServerState.Stop; + try { + try { + stopReceiving (5000); + } + finally { + _services.Stop (code, reason); + } + } + finally { + _state = ServerState.Stop; + } } private void stopReceiving (int millisecondsTimeout) From a376f305c22a276e60fd8e6834f15eb872235ed5 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 3 Feb 2017 15:51:35 +0900 Subject: [PATCH 0932/6294] [Fix] Use try-finally --- websocket-sharp/Server/WebSocketServer.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index c7f454149..0aa68968c 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -652,12 +652,16 @@ private void abort () } try { - _listener.Stop (); + try { + _listener.Stop (); + } + finally { + _services.Stop (1006, String.Empty); + } } catch { } - _services.Stop (1006, String.Empty); _state = ServerState.Stop; } From 731db0f4e9db97141d9a67f61ad30c2fd11ae317 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 4 Feb 2017 18:01:54 +0900 Subject: [PATCH 0933/6294] [Modify] Do not overwrite it --- websocket-sharp/Server/WebSocketServer.cs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 0aa68968c..ff69fb863 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -909,11 +909,22 @@ private void stop (ushort code, string reason) } try { + var threw = false; try { stopReceiving (5000); } + catch { + threw = true; + throw; + } finally { - _services.Stop (code, reason); + try { + _services.Stop (code, reason); + } + catch { + if (!threw) + throw; + } } } finally { From fb56d7bbb1506191dfb4f56e22caa0c8fdb7edb2 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 5 Feb 2017 18:09:46 +0900 Subject: [PATCH 0934/6294] [Modify] Add it --- websocket-sharp/Server/WebSocketServer.cs | 39 +++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index ff69fb863..1ea37f25e 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -863,6 +863,45 @@ private void receiveRequest () abort (); } + private void start (ServerSslConfiguration sslConfig) + { + if (_state == ServerState.Start) { + _logger.Info ("The server has already started."); + return; + } + + if (_state == ServerState.ShuttingDown) { + _logger.Warn ("The server is shutting down."); + return; + } + + lock (_sync) { + if (_state == ServerState.Start) { + _logger.Info ("The server has already started."); + return; + } + + if (_state == ServerState.ShuttingDown) { + _logger.Warn ("The server is shutting down."); + return; + } + + _sslConfigInUse = sslConfig; + _realmInUse = getRealm (); + + _services.Start (); + try { + startReceiving (); + } + catch { + _services.Stop (1011, String.Empty); + throw; + } + + _state = ServerState.Start; + } + } + private void startReceiving () { if (_reuseAddress) { From c7b1657ec76e4534efed17a009cddedfff38ae98 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 6 Feb 2017 15:58:05 +0900 Subject: [PATCH 0935/6294] [Fix] Add a condition --- websocket-sharp/Server/WebSocketServer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 1ea37f25e..0bd2f595c 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -859,7 +859,7 @@ private void receiveRequest () } } - if (_state == ServerState.Start) + if (_state == ServerState.Ready || _state == ServerState.Start) abort (); } From d41f87406d9ce8a3ac9d169c32c2c5342d78247d Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 6 Feb 2017 16:20:08 +0900 Subject: [PATCH 0936/6294] [Modify] Do not clear it --- websocket-sharp/Server/WebSocketServiceManager.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index 96d165e41..94ce7672d 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -364,7 +364,6 @@ internal void Stop (ushort code, string reason) foreach (var host in _hosts.Values) host.Stop (code, reason); - _hosts.Clear (); _state = ServerState.Stop; } } From 25d6f98fed1b5405c179bd53bb27c6cde14ef759 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 6 Feb 2017 16:33:00 +0900 Subject: [PATCH 0937/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketServiceManager.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index 94ce7672d..8d6d0088e 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -291,7 +291,8 @@ internal void Add (string path, Func initializer) WebSocketServiceHost host; if (_hosts.TryGetValue (path, out host)) { _logger.Error ( - "A WebSocket service with the specified path already exists:\n path: " + path); + "A WebSocket service with the specified path has already existed." + ); return; } From 6f89be63193a186ec8cb3f3e7224c9fc211014e3 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 6 Feb 2017 16:53:35 +0900 Subject: [PATCH 0938/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketServiceManager.cs | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index 8d6d0088e..087b65b94 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -311,19 +311,14 @@ internal void Add (string path, Func initializer) } } - internal bool InternalTryGetServiceHost (string path, out WebSocketServiceHost host) + internal bool InternalTryGetServiceHost ( + string path, out WebSocketServiceHost host + ) { - bool ret; lock (_sync) { path = HttpUtility.UrlDecode (path).TrimEndSlash (); - ret = _hosts.TryGetValue (path, out host); + return _hosts.TryGetValue (path, out host); } - - if (!ret) - _logger.Error ( - "A WebSocket service with the specified path isn't found:\n path: " + path); - - return ret; } internal bool Remove (string path) From da25c804ee657b2568b55705889730e7627959c0 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 7 Feb 2017 16:57:51 +0900 Subject: [PATCH 0939/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketServiceManager.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index 087b65b94..08d21eb0c 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -323,12 +323,14 @@ internal bool InternalTryGetServiceHost ( internal bool Remove (string path) { + path = HttpUtility.UrlDecode (path).TrimEndSlash (); + WebSocketServiceHost host; lock (_sync) { - path = HttpUtility.UrlDecode (path).TrimEndSlash (); if (!_hosts.TryGetValue (path, out host)) { _logger.Error ( - "A WebSocket service with the specified path isn't found:\n path: " + path); + "A WebSocket service with the specified path could not be found." + ); return false; } @@ -337,7 +339,7 @@ internal bool Remove (string path) } if (host.State == ServerState.Start) - host.Stop ((ushort) CloseStatusCode.Away, null); + host.Stop (1001, String.Empty); return true; } From 65ec86973362e009e13d34718729b0235039cc71 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 7 Feb 2017 17:02:26 +0900 Subject: [PATCH 0940/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketServiceManager.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index 08d21eb0c..9da1752c0 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -285,9 +285,9 @@ private Dictionary> broadping ( internal void Add (string path, Func initializer) where TBehavior : WebSocketBehavior { - lock (_sync) { - path = HttpUtility.UrlDecode (path).TrimEndSlash (); + path = HttpUtility.UrlDecode (path).TrimEndSlash (); + lock (_sync) { WebSocketServiceHost host; if (_hosts.TryGetValue (path, out host)) { _logger.Error ( From 8614a891f09f99b5540bd8856e4b3f0373291694 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 7 Feb 2017 17:05:32 +0900 Subject: [PATCH 0941/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketServiceManager.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index 9da1752c0..595bf6af8 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -315,10 +315,10 @@ internal bool InternalTryGetServiceHost ( string path, out WebSocketServiceHost host ) { - lock (_sync) { - path = HttpUtility.UrlDecode (path).TrimEndSlash (); + path = HttpUtility.UrlDecode (path).TrimEndSlash (); + + lock (_sync) return _hosts.TryGetValue (path, out host); - } } internal bool Remove (string path) From 47dfbe62dfcc19f8fe402861a16bfd591d11f3c7 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 8 Feb 2017 16:00:54 +0900 Subject: [PATCH 0942/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketServiceManager.cs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index 595bf6af8..f53f4d6aa 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -608,13 +608,16 @@ public Dictionary> Broadping (string message) /// public bool TryGetServiceHost (string path, out WebSocketServiceHost host) { - var msg = _state.CheckIfAvailable (false, true, false) ?? path.CheckIfValidServicePath (); - if (msg != null) { - _logger.Error (msg); - host = null; + host = null; + if (path == null || path.Length == 0) + return false; + + if (path[0] != '/') + return false; + + if (path.IndexOfAny (new[] { '?', '#' }) > -1) return false; - } return InternalTryGetServiceHost (path, out host); } From b20f6d8c9ccacc310eecd355d564e67fdb7aa974 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 9 Feb 2017 16:04:27 +0900 Subject: [PATCH 0943/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServiceManager.cs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index f53f4d6aa..05c3e8664 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -593,18 +593,21 @@ public Dictionary> Broadping (string message) } /// - /// Tries to get the WebSocket service host with the specified . + /// Tries to get the WebSocket service host with + /// the specified . /// /// - /// true if the service is successfully found; otherwise, false. + /// true if the service is successfully found; + /// otherwise, false. /// /// - /// A that represents the absolute path to the service to find. + /// A that represents the absolute path to + /// the service to find. /// /// - /// When this method returns, a instance that - /// provides the access to the information in the service, or - /// if it's not found. This parameter is passed uninitialized. + /// When this method returns, a + /// instance that provides the access to the information in + /// the service or if it is not found. /// public bool TryGetServiceHost (string path, out WebSocketServiceHost host) { From 0bf65062978a5202c07f6794f3e83c13ca9ef8c8 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 9 Feb 2017 16:32:05 +0900 Subject: [PATCH 0944/6294] [Modify] Replace it --- websocket-sharp/Server/WebSocketServer.cs | 23 +++-------------------- 1 file changed, 3 insertions(+), 20 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 0bd2f595c..9125a8a0c 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -1090,32 +1090,15 @@ public bool RemoveWebSocketService (string path) /// public void Start () { - string msg; - if (!checkIfAvailable (true, false, false, true, out msg)) { - _logger.Error (msg); - return; - } - var sslConfig = getSslConfiguration (); + + string msg; if (!checkSslConfiguration (sslConfig, out msg)) { _logger.Error (msg); return; } - lock (_sync) { - if (!checkIfAvailable (true, false, false, true, out msg)) { - _logger.Error (msg); - return; - } - - _realmInUse = getRealm (); - _sslConfigInUse = sslConfig; - - _services.Start (); - startReceiving (); - - _state = ServerState.Start; - } + start (sslConfig); } /// From e1ffa6f3259b434aa6b362ae712d891234b94c44 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 10 Feb 2017 16:18:15 +0900 Subject: [PATCH 0945/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 9125a8a0c..483a293a3 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -1088,6 +1088,10 @@ public bool RemoveWebSocketService (string path) /// /// Starts receiving the WebSocket handshake requests. /// + /// + /// This method does nothing if the server has already started or + /// it is shutting down. + /// public void Start () { var sslConfig = getSslConfiguration (); From 6aa5bfe034ec5ef3c96755a4036f71c721850a78 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 10 Feb 2017 16:28:31 +0900 Subject: [PATCH 0946/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 483a293a3..643c1b384 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -397,10 +397,10 @@ public bool IsListening { } /// - /// Gets a value indicating whether the server provides a secure connection. + /// Gets a value indicating whether the server provides secure connections. /// /// - /// true if the server provides a secure connection; + /// true if the server provides secure connections; /// otherwise, false. /// public bool IsSecure { From 886b5ac12de716e4add4f6305d7367ac05dd6d10 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 11 Feb 2017 16:35:52 +0900 Subject: [PATCH 0947/6294] [Modify] Throw exception --- websocket-sharp/Server/WebSocketServer.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 643c1b384..8af778dac 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -1097,10 +1097,8 @@ public void Start () var sslConfig = getSslConfiguration (); string msg; - if (!checkSslConfiguration (sslConfig, out msg)) { - _logger.Error (msg); - return; - } + if (!checkSslConfiguration (sslConfig, out msg)) + throw new InvalidOperationException (msg); start (sslConfig); } From 407bdce870009b6f3dcaa31b4bfeab3e3eac81a1 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 12 Feb 2017 18:15:52 +0900 Subject: [PATCH 0948/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 8af778dac..394fc92ea 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -1092,6 +1092,13 @@ public bool RemoveWebSocketService (string path) /// This method does nothing if the server has already started or /// it is shutting down. /// + /// + /// There is no configuration or server certificate used to provide + /// secure connections. + /// + /// + /// The underlying has failed to start. + /// public void Start () { var sslConfig = getSslConfiguration (); From 5a5b36e8b4cce1be78962577afbfa85f6b1f1c2c Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 13 Feb 2017 15:39:09 +0900 Subject: [PATCH 0949/6294] [Fix] Do it if not in shutting down --- websocket-sharp/Server/WebSocketServer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 394fc92ea..23f7cf07f 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -859,7 +859,7 @@ private void receiveRequest () } } - if (_state == ServerState.Ready || _state == ServerState.Start) + if (_state != ServerState.ShuttingDown) abort (); } From 61a1e55c187a5c1def69a6af374364758380f7bd Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 13 Feb 2017 15:51:19 +0900 Subject: [PATCH 0950/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketServer.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 23f7cf07f..896acbb6b 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -733,12 +733,12 @@ private bool checkSslConfiguration ( return true; if (configuration == null) { - message = "There is no configuration for the secure connection."; + message = "There is no configuration."; return false; } if (configuration.ServerCertificate == null) { - message = "There is no server certificate for the secure connection."; + message = "There is no server certificate."; return false; } From 3442218d532fba50fd541ad6986b1acff2e68b59 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 14 Feb 2017 15:42:36 +0900 Subject: [PATCH 0951/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 896acbb6b..b4d2a2e46 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -540,8 +540,7 @@ public bool ReuseAddress { } /// - /// Gets the configuration used to authenticate the server and - /// optionally the client for the secure connection. + /// Gets the configuration used to provide secure connections. /// /// /// The configuration will be referenced when the server starts. @@ -549,7 +548,7 @@ public bool ReuseAddress { /// /// /// A that represents - /// the configuration for the secure connection. + /// the configuration used to provide secure connections. /// public ServerSslConfiguration SslConfiguration { get { From bd84fda5b50fee175a2f045cddc145529f33bb7c Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 14 Feb 2017 15:50:38 +0900 Subject: [PATCH 0952/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketServer.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index b4d2a2e46..2ddc80a7d 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -552,7 +552,10 @@ public bool ReuseAddress { /// public ServerSslConfiguration SslConfiguration { get { - return _sslConfig ?? (_sslConfig = new ServerSslConfiguration (null)); + if (_sslConfig == null) + _sslConfig = new ServerSslConfiguration (null); + + return _sslConfig; } } From 7e6d943a6edc410225cf902774878761ca418871 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 14 Feb 2017 15:59:54 +0900 Subject: [PATCH 0953/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketServer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 2ddc80a7d..051d29824 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -740,7 +740,7 @@ private bool checkSslConfiguration ( } if (configuration.ServerCertificate == null) { - message = "There is no server certificate."; + message = "The configuration has no server certificate."; return false; } From a8103c8c001c18267f80d20ec5eb9616416959fa Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 15 Feb 2017 16:34:35 +0900 Subject: [PATCH 0954/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 051d29824..be2db0f9d 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -1095,8 +1095,8 @@ public bool RemoveWebSocketService (string path) /// it is shutting down. /// /// - /// There is no configuration or server certificate used to provide - /// secure connections. + /// There is no configuration used to provide secure connections or + /// the configuration has no server certificate. /// /// /// The underlying has failed to start. From cf40fd54b9df56cdf66e9d7f7f4185c4e8c498ae Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 15 Feb 2017 16:41:19 +0900 Subject: [PATCH 0955/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index be2db0f9d..d8aeb861e 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -1120,6 +1120,9 @@ public void Start () /// This method does nothing if the server is not started, /// it is shutting down, or it has already stopped. /// + /// + /// The underlying has failed to stop. + /// public void Stop () { stop (1005, String.Empty); From 37f28794e144aa18831d071d34af84d17c97e59a Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 15 Feb 2017 16:46:28 +0900 Subject: [PATCH 0956/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index d8aeb861e..c9fe5b29d 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -1152,6 +1152,9 @@ public void Stop () /// A that represents the reason for /// the close. The size must be 123 bytes or less in UTF-8. /// + /// + /// The underlying has failed to stop. + /// public void Stop (ushort code, string reason) { string msg; From 04feb7b61ca3b2bbc709eee01707d784996014c9 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 15 Feb 2017 17:02:10 +0900 Subject: [PATCH 0957/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index c9fe5b29d..598ccbbec 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -1184,6 +1184,9 @@ public void Stop (ushort code, string reason) /// A that represents the reason for /// the close. The size must be 123 bytes or less in UTF-8. /// + /// + /// The underlying has failed to stop. + /// public void Stop (CloseStatusCode code, string reason) { string msg; From 40781f7d04f154072e5b6964cb07b7b03a8424b0 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 15 Feb 2017 17:11:38 +0900 Subject: [PATCH 0958/6294] [Modify] Add it --- websocket-sharp/Server/WebSocketServer.cs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 598ccbbec..412be1d04 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -667,6 +667,23 @@ private void abort () _state = ServerState.Stop; } + private bool canSet (out string message) + { + message = null; + + if (_state == ServerState.Start) { + message = "The server has already started."; + return false; + } + + if (_state == ServerState.ShuttingDown) { + message = "The server is shutting down."; + return false; + } + + return true; + } + private bool checkHostNameForRequest (string name) { return !_dnsStyle From f059b447c82ac7ae015a79bf053944f7ee7e6cfc Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 16 Feb 2017 15:23:57 +0900 Subject: [PATCH 0959/6294] [Modify] Replace them --- websocket-sharp/Server/WebSocketServer.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 412be1d04..ee334d527 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -336,14 +336,14 @@ public bool AllowForwardedRequest { set { string msg; - if (!checkIfAvailable (true, false, false, true, out msg)) { - _logger.Error (msg); + if (!canSet (out msg)) { + _logger.Warn (msg); return; } lock (_sync) { - if (!checkIfAvailable (true, false, false, true, out msg)) { - _logger.Error (msg); + if (!canSet (out msg)) { + _logger.Warn (msg); return; } From 63a0c03e67256270c90f12767da850fdaffa0a23 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 16 Feb 2017 15:32:16 +0900 Subject: [PATCH 0960/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index ee334d527..5b20c7e6f 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -324,6 +324,10 @@ public System.Net.IPAddress Address { /// Gets or sets a value indicating whether the server accepts /// a handshake request without checking the request URI. /// + /// + /// The set operation does nothing if the server has already started or + /// it is shutting down. + /// /// /// true if the server accepts a handshake request without /// checking the request URI; otherwise, false. The default From 0df24ba14cf88dbaf7d0b78354536b6aa6d24d25 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 16 Feb 2017 15:36:32 +0900 Subject: [PATCH 0961/6294] [Modify] Replace them --- websocket-sharp/Server/WebSocketServer.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 5b20c7e6f..a986101b4 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -372,14 +372,14 @@ public AuthenticationSchemes AuthenticationSchemes { set { string msg; - if (!checkIfAvailable (true, false, false, true, out msg)) { - _logger.Error (msg); + if (!canSet (out msg)) { + _logger.Warn (msg); return; } lock (_sync) { - if (!checkIfAvailable (true, false, false, true, out msg)) { - _logger.Error (msg); + if (!canSet (out msg)) { + _logger.Warn (msg); return; } From 0008f89b3111b7d4aec98e30bccfb9be62b572e2 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 16 Feb 2017 15:54:40 +0900 Subject: [PATCH 0962/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index a986101b4..bc341e3e2 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -359,9 +359,13 @@ public bool AllowForwardedRequest { /// /// Gets or sets the scheme used to authenticate the clients. /// + /// + /// The set operation does nothing if the server has already started or + /// it is shutting down. + /// /// /// One of the enum - /// values that represents the scheme used to authenticate the clients. + /// values. It specifies the scheme used to authenticate the clients. /// The default value is /// . /// From a6374836e07e85f007ebd98c724656c3b634caf1 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 16 Feb 2017 16:01:23 +0900 Subject: [PATCH 0963/6294] [Modify] Replace them --- websocket-sharp/Server/WebSocketServer.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index bc341e3e2..4aafb8df2 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -432,14 +432,14 @@ public bool KeepClean { set { string msg; - if (!checkIfAvailable (true, false, false, true, out msg)) { - _logger.Error (msg); + if (!canSet (out msg)) { + _logger.Warn (msg); return; } lock (_sync) { - if (!checkIfAvailable (true, false, false, true, out msg)) { - _logger.Error (msg); + if (!canSet (out msg)) { + _logger.Warn (msg); return; } From 412fe637764ba559877566e10527ee7de65a9ad0 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 16 Feb 2017 16:06:57 +0900 Subject: [PATCH 0964/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 4aafb8df2..5b9bee3b2 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -421,6 +421,10 @@ public bool IsSecure { /// Gets or sets a value indicating whether the server cleans up /// the inactive sessions periodically. /// + /// + /// The set operation does nothing if the server has already started or + /// it is shutting down. + /// /// /// true if the server cleans up the inactive sessions every 60 /// seconds; otherwise, false. The default value is true. From 95c2d5ea2fc54b0bb737089d9829356eb8ab3610 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 17 Feb 2017 14:31:25 +0900 Subject: [PATCH 0965/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 5b9bee3b2..2ad3ff0f3 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -456,9 +456,14 @@ public bool KeepClean { /// Gets the logging function for the server. /// /// - /// The default logging level is . If you would - /// like to change the logging level, you should set this Log.Level - /// property to any of the enum values. + /// + /// The default logging level is . + /// + /// + /// If you would like to change the logging level, + /// you should set the Log.Level property to + /// any of the enum values. + /// /// /// /// A that provides the logging function. From 8ecbb11aec770ebd8aaa77fba13a963e77ec3427 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 17 Feb 2017 14:40:14 +0900 Subject: [PATCH 0966/6294] [Modify] Replace them --- websocket-sharp/Server/WebSocketServer.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 2ad3ff0f3..ddaba6859 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -504,14 +504,14 @@ public string Realm { set { string msg; - if (!checkIfAvailable (true, false, false, true, out msg)) { - _logger.Error (msg); + if (!canSet (out msg)) { + _logger.Warn (msg); return; } lock (_sync) { - if (!checkIfAvailable (true, false, false, true, out msg)) { - _logger.Error (msg); + if (!canSet (out msg)) { + _logger.Warn (msg); return; } From 90e1a2e7ff6a4c439b6e4b0d3dbf030ec8fa2a1b Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 17 Feb 2017 15:10:04 +0900 Subject: [PATCH 0967/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index ddaba6859..5ce1c8e9c 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -490,8 +490,14 @@ public int Port { /// Gets or sets the name of the realm for the server. /// /// - /// If this property is or empty, - /// "SECRET AREA" will be used as the name. + /// + /// The set operation does nothing if the server has + /// already started or it is shutting down. + /// + /// + /// If this property is or empty, + /// SECRET AREA will be used as the name. + /// /// /// /// A that represents the name of the realm. From 5b178d242a172e648091dc71199ce9e6eef04578 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 17 Feb 2017 15:24:39 +0900 Subject: [PATCH 0968/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 5ce1c8e9c..400ffcc67 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -475,10 +475,11 @@ public Logger Log { } /// - /// Gets the port on which to listen for incoming handshake requests. + /// Gets the port number of the server. /// /// - /// An that represents the port number on which to listen. + /// An that represents the port number on which to + /// listen for the incoming handshake requests. /// public int Port { get { From c0a2d19d3f64f340fac0aa92c8ffe9d1cabee23c Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 17 Feb 2017 15:29:19 +0900 Subject: [PATCH 0969/6294] [Modify] Replace them --- websocket-sharp/Server/WebSocketServer.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 400ffcc67..df4e03c30 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -547,14 +547,14 @@ public bool ReuseAddress { set { string msg; - if (!checkIfAvailable (true, false, false, true, out msg)) { - _logger.Error (msg); + if (!canSet (out msg)) { + _logger.Warn (msg); return; } lock (_sync) { - if (!checkIfAvailable (true, false, false, true, out msg)) { - _logger.Error (msg); + if (!canSet (out msg)) { + _logger.Warn (msg); return; } From c3b8238ba8ace4f3b2915219d37b60811d7218db Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 18 Feb 2017 17:23:13 +0900 Subject: [PATCH 0970/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index df4e03c30..b02dc343a 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -532,8 +532,14 @@ public string Realm { /// be bound to an address that is already in use. /// /// - /// If you would like to resolve to wait for socket in TIME_WAIT state, - /// you should set this property to true. + /// + /// The set operation does nothing if the server has already started or + /// it is shutting down. + /// + /// + /// If you would like to resolve to wait for socket in TIME_WAIT state, + /// you should set this property to true. + /// /// /// /// true if the server is allowed to be bound to an address that From 87ea54b0a5988ca2aac02385b8bf656bfe52ea29 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 18 Feb 2017 17:27:00 +0900 Subject: [PATCH 0971/6294] [Modify] Replace them --- websocket-sharp/Server/WebSocketServer.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index b02dc343a..87bbb8ebd 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -605,14 +605,14 @@ public Func UserCredentialsFinder { set { string msg; - if (!checkIfAvailable (true, false, false, true, out msg)) { - _logger.Error (msg); + if (!canSet (out msg)) { + _logger.Warn (msg); return; } lock (_sync) { - if (!checkIfAvailable (true, false, false, true, out msg)) { - _logger.Error (msg); + if (!canSet (out msg)) { + _logger.Warn (msg); return; } From f05efe51c02aecffd63dfaf511e73469876af1f8 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 19 Feb 2017 16:24:15 +0900 Subject: [PATCH 0972/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 87bbb8ebd..87f28407f 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -593,10 +593,14 @@ public ServerSslConfiguration SslConfiguration { /// Gets or sets the delegate called to find the credentials for /// an identity used to authenticate a client. /// + /// + /// The set operation does nothing if the server has already started or + /// it is shutting down. + /// /// - /// A Func<IIdentity, NetworkCredential> delegate that - /// invokes the method used to find the credentials. The default value - /// is . + /// A Func<IIdentity, NetworkCredential> delegate + /// that invokes the method used to find the credentials or + /// by default. /// public Func UserCredentialsFinder { get { From 13e4918305adf30d9f9edc844f3480a327eb57f2 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 19 Feb 2017 16:32:28 +0900 Subject: [PATCH 0973/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 87f28407f..726b279bc 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -501,8 +501,8 @@ public int Port { /// /// /// - /// A that represents the name of the realm. - /// The default value is . + /// A that represents the name of + /// the realm or by default. /// public string Realm { get { From a0e56bcb38dabd4ccec421386683759feb70d157 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 19 Feb 2017 16:37:22 +0900 Subject: [PATCH 0974/6294] [Modify] Replace them --- websocket-sharp/Server/WebSocketServer.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 726b279bc..493c3e041 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -640,19 +640,19 @@ public TimeSpan WaitTime { set { string msg; - if (!checkIfAvailable (true, false, false, true, out msg)) { + if (!value.CheckWaitTime (out msg)) { _logger.Error (msg); return; } - if (!value.CheckWaitTime (out msg)) { - _logger.Error (msg); + if (!canSet (out msg)) { + _logger.Warn (msg); return; } lock (_sync) { - if (!checkIfAvailable (true, false, false, true, out msg)) { - _logger.Error (msg); + if (!canSet (out msg)) { + _logger.Warn (msg); return; } From 8a4e7d33e0416932ba410395a8f6f54fb73ed310 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 19 Feb 2017 16:47:20 +0900 Subject: [PATCH 0975/6294] [Modify] Throw exception --- websocket-sharp/Server/WebSocketServer.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 493c3e041..f9ab97a80 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -640,10 +640,8 @@ public TimeSpan WaitTime { set { string msg; - if (!value.CheckWaitTime (out msg)) { - _logger.Error (msg); - return; - } + if (!value.CheckWaitTime (out msg)) + throw new ArgumentException (msg, "value"); if (!canSet (out msg)) { _logger.Warn (msg); From a8241034cee3fb8b4f30ef53e5c584697d9ae0d1 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 20 Feb 2017 17:28:40 +0900 Subject: [PATCH 0976/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index f9ab97a80..2cede096c 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -629,10 +629,17 @@ public Func UserCredentialsFinder { /// Gets or sets the wait time for the response to /// the WebSocket Ping or Close. /// + /// + /// The set operation does nothing if the server has already + /// started or it is shutting down. + /// /// /// A that represents the wait time for /// the response. The default value is the same as 1 second. /// + /// + /// The value specified for a set operation is zero or less. + /// public TimeSpan WaitTime { get { return _services.WaitTime; From 2ac514e1402603f90d9e39e26ecb7094778fe397 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 21 Feb 2017 16:24:16 +0900 Subject: [PATCH 0977/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 2cede096c..63e646b0c 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -667,7 +667,8 @@ public TimeSpan WaitTime { } /// - /// Gets the access to the WebSocket services provided by the server. + /// Gets the management function for the WebSocket services + /// provided by the server. /// /// /// A that manages From c066adaf54d7d342d39dcf255d0f6842bab2f47e Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 21 Feb 2017 16:27:22 +0900 Subject: [PATCH 0978/6294] [Modify] Remove it --- websocket-sharp/Server/WebSocketServer.cs | 29 ----------------------- 1 file changed, 29 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 63e646b0c..a315b751e 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -731,35 +731,6 @@ private bool checkHostNameForRequest (string name) || name == _hostname; } - private bool checkIfAvailable ( - bool ready, bool start, bool shutting, bool stop, out string message - ) - { - message = null; - - if (!ready && _state == ServerState.Ready) { - message = "This operation is not available in: ready"; - return false; - } - - if (!start && _state == ServerState.Start) { - message = "This operation is not available in: start"; - return false; - } - - if (!shutting && _state == ServerState.ShuttingDown) { - message = "This operation is not available in: shutting down"; - return false; - } - - if (!stop && _state == ServerState.Stop) { - message = "This operation is not available in: stop"; - return false; - } - - return true; - } - private bool checkServicePath (string path, out string message) { message = null; From 385af7c5144e2725b84fe10ed3ce70eb8300ef7f Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 21 Feb 2017 16:35:48 +0900 Subject: [PATCH 0979/6294] [Modify] Rename it --- websocket-sharp/Server/WebSocketServer.cs | 76 +++++++++++------------ 1 file changed, 38 insertions(+), 38 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index a315b751e..4ffaef264 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -67,7 +67,7 @@ public class WebSocketServer private bool _dnsStyle; private string _hostname; private TcpListener _listener; - private Logger _logger; + private Logger _log; private int _port; private string _realm; private string _realmInUse; @@ -341,13 +341,13 @@ public bool AllowForwardedRequest { set { string msg; if (!canSet (out msg)) { - _logger.Warn (msg); + _log.Warn (msg); return; } lock (_sync) { if (!canSet (out msg)) { - _logger.Warn (msg); + _log.Warn (msg); return; } @@ -377,13 +377,13 @@ public AuthenticationSchemes AuthenticationSchemes { set { string msg; if (!canSet (out msg)) { - _logger.Warn (msg); + _log.Warn (msg); return; } lock (_sync) { if (!canSet (out msg)) { - _logger.Warn (msg); + _log.Warn (msg); return; } @@ -437,13 +437,13 @@ public bool KeepClean { set { string msg; if (!canSet (out msg)) { - _logger.Warn (msg); + _log.Warn (msg); return; } lock (_sync) { if (!canSet (out msg)) { - _logger.Warn (msg); + _log.Warn (msg); return; } @@ -470,7 +470,7 @@ public bool KeepClean { /// public Logger Log { get { - return _logger; + return _log; } } @@ -512,13 +512,13 @@ public string Realm { set { string msg; if (!canSet (out msg)) { - _logger.Warn (msg); + _log.Warn (msg); return; } lock (_sync) { if (!canSet (out msg)) { - _logger.Warn (msg); + _log.Warn (msg); return; } @@ -554,13 +554,13 @@ public bool ReuseAddress { set { string msg; if (!canSet (out msg)) { - _logger.Warn (msg); + _log.Warn (msg); return; } lock (_sync) { if (!canSet (out msg)) { - _logger.Warn (msg); + _log.Warn (msg); return; } @@ -610,13 +610,13 @@ public Func UserCredentialsFinder { set { string msg; if (!canSet (out msg)) { - _logger.Warn (msg); + _log.Warn (msg); return; } lock (_sync) { if (!canSet (out msg)) { - _logger.Warn (msg); + _log.Warn (msg); return; } @@ -651,13 +651,13 @@ public TimeSpan WaitTime { throw new ArgumentException (msg, "value"); if (!canSet (out msg)) { - _logger.Warn (msg); + _log.Warn (msg); return; } lock (_sync) { if (!canSet (out msg)) { - _logger.Warn (msg); + _log.Warn (msg); return; } @@ -813,8 +813,8 @@ private void init ( _authSchemes = AuthenticationSchemes.Anonymous; _dnsStyle = Uri.CheckHostName (hostname) == UriHostNameType.Dns; _listener = new TcpListener (address, port); - _logger = new Logger (); - _services = new WebSocketServiceManager (_logger); + _log = new Logger (); + _services = new WebSocketServiceManager (_log); _sync = new object (); } @@ -857,7 +857,7 @@ private void receiveRequest () state => { try { var ctx = - cl.GetWebSocketContext (null, _secure, _sslConfigInUse, _logger); + cl.GetWebSocketContext (null, _secure, _sslConfigInUse, _log); if (!ctx.Authenticate (_authSchemes, _realmInUse, _userCredFinder)) return; @@ -865,7 +865,7 @@ private void receiveRequest () processRequest (ctx); } catch (Exception ex) { - _logger.Fatal (ex.ToString ()); + _log.Fatal (ex.ToString ()); cl.Close (); } } @@ -873,15 +873,15 @@ private void receiveRequest () } catch (SocketException ex) { if (_state == ServerState.ShuttingDown) { - _logger.Info ("The receiving is stopped."); + _log.Info ("The receiving is stopped."); break; } - _logger.Fatal (ex.ToString ()); + _log.Fatal (ex.ToString ()); break; } catch (Exception ex) { - _logger.Fatal (ex.ToString ()); + _log.Fatal (ex.ToString ()); if (cl != null) cl.Close (); @@ -896,23 +896,23 @@ private void receiveRequest () private void start (ServerSslConfiguration sslConfig) { if (_state == ServerState.Start) { - _logger.Info ("The server has already started."); + _log.Info ("The server has already started."); return; } if (_state == ServerState.ShuttingDown) { - _logger.Warn ("The server is shutting down."); + _log.Warn ("The server is shutting down."); return; } lock (_sync) { if (_state == ServerState.Start) { - _logger.Info ("The server has already started."); + _log.Info ("The server has already started."); return; } if (_state == ServerState.ShuttingDown) { - _logger.Warn ("The server is shutting down."); + _log.Warn ("The server is shutting down."); return; } @@ -949,28 +949,28 @@ private void startReceiving () private void stop (ushort code, string reason) { if (_state == ServerState.Ready) { - _logger.Info ("The server is not started."); + _log.Info ("The server is not started."); return; } if (_state == ServerState.ShuttingDown) { - _logger.Info ("The server is shutting down."); + _log.Info ("The server is shutting down."); return; } if (_state == ServerState.Stop) { - _logger.Info ("The server has already stopped."); + _log.Info ("The server has already stopped."); return; } lock (_sync) { if (_state == ServerState.ShuttingDown) { - _logger.Info ("The server is shutting down."); + _log.Info ("The server is shutting down."); return; } if (_state == ServerState.Stop) { - _logger.Info ("The server has already stopped."); + _log.Info ("The server has already stopped."); return; } @@ -1054,12 +1054,12 @@ public void AddWebSocketService ( { string msg; if (!checkServicePath (path, out msg)) { - _logger.Error (msg); + _log.Error (msg); return; } if (initializer == null) { - _logger.Error ("'initializer' is null."); + _log.Error ("'initializer' is null."); return; } @@ -1085,7 +1085,7 @@ public void AddWebSocketService (string path) { string msg; if (!checkServicePath (path, out msg)) { - _logger.Error (msg); + _log.Error (msg); return; } @@ -1108,7 +1108,7 @@ public bool RemoveWebSocketService (string path) { string msg; if (!checkServicePath (path, out msg)) { - _logger.Error (msg); + _log.Error (msg); return false; } @@ -1187,7 +1187,7 @@ public void Stop (ushort code, string reason) { string msg; if (!WebSocket.CheckParametersForClose (code, reason, false, out msg)) { - _logger.Error (msg); + _log.Error (msg); return; } @@ -1219,7 +1219,7 @@ public void Stop (CloseStatusCode code, string reason) { string msg; if (!WebSocket.CheckParametersForClose (code, reason, false, out msg)) { - _logger.Error (msg); + _log.Error (msg); return; } From 1f35449fbe2c594aa24852b0ce2c7995f67908f0 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 21 Feb 2017 16:47:13 +0900 Subject: [PATCH 0980/6294] [Modify] Rename it --- websocket-sharp/Server/WebSocketServiceHost`1.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceHost`1.cs b/websocket-sharp/Server/WebSocketServiceHost`1.cs index 78e3983e8..93cb19924 100644 --- a/websocket-sharp/Server/WebSocketServiceHost`1.cs +++ b/websocket-sharp/Server/WebSocketServiceHost`1.cs @@ -35,7 +35,7 @@ internal class WebSocketServiceHost : WebSocketServiceHost { #region Private Fields - private Func _initializer; + private Func _creator; private Logger _logger; private string _path; private WebSocketSessionManager _sessions; @@ -44,10 +44,10 @@ internal class WebSocketServiceHost : WebSocketServiceHost #region Internal Constructors - internal WebSocketServiceHost (string path, Func initializer, Logger logger) + internal WebSocketServiceHost (string path, Func creator, Logger logger) { _path = path; - _initializer = initializer; + _creator = creator; _logger = logger; _sessions = new WebSocketSessionManager (logger); } @@ -114,7 +114,7 @@ public override TimeSpan WaitTime { protected override WebSocketBehavior CreateSession () { - return _initializer (); + return _creator (); } #endregion From 4f55bf63daf525e091deeb5b3e637a3368529371 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 21 Feb 2017 16:52:53 +0900 Subject: [PATCH 0981/6294] [Modify] Rename it --- websocket-sharp/Server/WebSocketServiceHost`1.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceHost`1.cs b/websocket-sharp/Server/WebSocketServiceHost`1.cs index 93cb19924..ab5400797 100644 --- a/websocket-sharp/Server/WebSocketServiceHost`1.cs +++ b/websocket-sharp/Server/WebSocketServiceHost`1.cs @@ -36,7 +36,7 @@ internal class WebSocketServiceHost : WebSocketServiceHost #region Private Fields private Func _creator; - private Logger _logger; + private Logger _log; private string _path; private WebSocketSessionManager _sessions; @@ -44,12 +44,12 @@ internal class WebSocketServiceHost : WebSocketServiceHost #region Internal Constructors - internal WebSocketServiceHost (string path, Func creator, Logger logger) + internal WebSocketServiceHost (string path, Func creator, Logger log) { _path = path; _creator = creator; - _logger = logger; - _sessions = new WebSocketSessionManager (logger); + _log = log; + _sessions = new WebSocketSessionManager (log); } #endregion @@ -64,7 +64,7 @@ public override bool KeepClean { set { var msg = _sessions.State.CheckIfAvailable (true, false, false); if (msg != null) { - _logger.Error (msg); + _log.Error (msg); return; } @@ -100,7 +100,7 @@ public override TimeSpan WaitTime { value.CheckIfValidWaitTime (); if (msg != null) { - _logger.Error (msg); + _log.Error (msg); return; } From a50386e45d64f8f6183616a180547d954cccf3fd Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 21 Feb 2017 17:06:49 +0900 Subject: [PATCH 0982/6294] [Modify] Add it --- websocket-sharp/Server/WebSocketServiceHost`1.cs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/websocket-sharp/Server/WebSocketServiceHost`1.cs b/websocket-sharp/Server/WebSocketServiceHost`1.cs index ab5400797..a31e8a670 100644 --- a/websocket-sharp/Server/WebSocketServiceHost`1.cs +++ b/websocket-sharp/Server/WebSocketServiceHost`1.cs @@ -36,6 +36,7 @@ internal class WebSocketServiceHost : WebSocketServiceHost #region Private Fields private Func _creator; + private Action _initializer; private Logger _log; private string _path; private WebSocketSessionManager _sessions; @@ -52,6 +53,21 @@ internal WebSocketServiceHost (string path, Func creator, Logger log) _sessions = new WebSocketSessionManager (log); } + internal WebSocketServiceHost ( + string path, + Func creator, + Action initializer, + Logger log + ) + { + _path = path; + _creator = creator; + _initializer = initializer; + _log = log; + + _sessions = new WebSocketSessionManager (log); + } + #endregion #region Public Properties From 15518902d20883a722242de27fbdf8d9d4fd00f1 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 21 Feb 2017 17:11:18 +0900 Subject: [PATCH 0983/6294] [Modify] Use it --- websocket-sharp/Server/WebSocketServiceHost`1.cs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceHost`1.cs b/websocket-sharp/Server/WebSocketServiceHost`1.cs index a31e8a670..d39132173 100644 --- a/websocket-sharp/Server/WebSocketServiceHost`1.cs +++ b/websocket-sharp/Server/WebSocketServiceHost`1.cs @@ -45,12 +45,11 @@ internal class WebSocketServiceHost : WebSocketServiceHost #region Internal Constructors - internal WebSocketServiceHost (string path, Func creator, Logger log) + internal WebSocketServiceHost ( + string path, Func creator, Logger log + ) + : this (path, creator, null, log) { - _path = path; - _creator = creator; - _log = log; - _sessions = new WebSocketSessionManager (log); } internal WebSocketServiceHost ( From f29ecec13800045257bf1af2a93986b39eb6e7e9 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 22 Feb 2017 16:19:24 +0900 Subject: [PATCH 0984/6294] [Modify] Create and initialize --- websocket-sharp/Server/WebSocketServiceHost`1.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServiceHost`1.cs b/websocket-sharp/Server/WebSocketServiceHost`1.cs index d39132173..4032edc48 100644 --- a/websocket-sharp/Server/WebSocketServiceHost`1.cs +++ b/websocket-sharp/Server/WebSocketServiceHost`1.cs @@ -129,7 +129,12 @@ public override TimeSpan WaitTime { protected override WebSocketBehavior CreateSession () { - return _creator (); + var ret = _creator (); + + if (_initializer != null) + _initializer (ret); + + return ret; } #endregion From 86df2dd476716216ecf69ad7dc5cb3f0b52d6e7c Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 22 Feb 2017 16:40:12 +0900 Subject: [PATCH 0985/6294] [Modify] Add it --- .../Server/WebSocketServiceHost`1.cs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/websocket-sharp/Server/WebSocketServiceHost`1.cs b/websocket-sharp/Server/WebSocketServiceHost`1.cs index 4032edc48..0ff83e19a 100644 --- a/websocket-sharp/Server/WebSocketServiceHost`1.cs +++ b/websocket-sharp/Server/WebSocketServiceHost`1.cs @@ -125,6 +125,25 @@ public override TimeSpan WaitTime { #endregion + #region Private Methods + + private Func createCreator ( + Func creator, Action initializer + ) + { + if (initializer == null) + return creator; + + return () => { + var ret = creator (); + initializer (ret); + + return ret; + }; + } + + #endregion + #region Protected Methods protected override WebSocketBehavior CreateSession () From aa7ff1115e60af0968137337f6c72eb31d768958 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 23 Feb 2017 15:10:02 +0900 Subject: [PATCH 0986/6294] [Modify] Use it --- websocket-sharp/Server/WebSocketServiceHost`1.cs | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceHost`1.cs b/websocket-sharp/Server/WebSocketServiceHost`1.cs index 0ff83e19a..fb05efb18 100644 --- a/websocket-sharp/Server/WebSocketServiceHost`1.cs +++ b/websocket-sharp/Server/WebSocketServiceHost`1.cs @@ -36,7 +36,6 @@ internal class WebSocketServiceHost : WebSocketServiceHost #region Private Fields private Func _creator; - private Action _initializer; private Logger _log; private string _path; private WebSocketSessionManager _sessions; @@ -60,8 +59,7 @@ Logger log ) { _path = path; - _creator = creator; - _initializer = initializer; + _creator = createCreator (creator, initializer); _log = log; _sessions = new WebSocketSessionManager (log); @@ -148,12 +146,7 @@ Func creator, Action initializer protected override WebSocketBehavior CreateSession () { - var ret = _creator (); - - if (_initializer != null) - _initializer (ret); - - return ret; + return _creator (); } #endregion From d37e6f672269e1b696c2778684c30af9b5b84bf1 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 23 Feb 2017 15:18:26 +0900 Subject: [PATCH 0987/6294] [Modify] Add it --- .../Server/WebSocketServiceHost`1.cs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/websocket-sharp/Server/WebSocketServiceHost`1.cs b/websocket-sharp/Server/WebSocketServiceHost`1.cs index fb05efb18..24f634c19 100644 --- a/websocket-sharp/Server/WebSocketServiceHost`1.cs +++ b/websocket-sharp/Server/WebSocketServiceHost`1.cs @@ -125,6 +125,24 @@ public override TimeSpan WaitTime { #region Private Methods + private bool canSet (out string message) + { + message = null; + + var state = _sessions.State; + if (state == ServerState.Start) { + message = "The service has already started."; + return false; + } + + if (state == ServerState.ShuttingDown) { + message = "The service is shutting down."; + return false; + } + + return true; + } + private Func createCreator ( Func creator, Action initializer ) From b2934dc373534cc557cac4ad3e5394e88be163d3 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 23 Feb 2017 15:24:29 +0900 Subject: [PATCH 0988/6294] [Modify] Replace it --- websocket-sharp/Server/WebSocketServiceHost`1.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceHost`1.cs b/websocket-sharp/Server/WebSocketServiceHost`1.cs index 24f634c19..b7422745f 100644 --- a/websocket-sharp/Server/WebSocketServiceHost`1.cs +++ b/websocket-sharp/Server/WebSocketServiceHost`1.cs @@ -75,9 +75,9 @@ public override bool KeepClean { } set { - var msg = _sessions.State.CheckIfAvailable (true, false, false); - if (msg != null) { - _log.Error (msg); + string msg; + if (!canSet (out msg)) { + _log.Warn (msg); return; } From 370fd678943b8be19a4ac1616441563520ed4195 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 23 Feb 2017 15:30:43 +0900 Subject: [PATCH 0989/6294] [Modify] Replace it --- websocket-sharp/Server/WebSocketServiceHost`1.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceHost`1.cs b/websocket-sharp/Server/WebSocketServiceHost`1.cs index b7422745f..c4bd633db 100644 --- a/websocket-sharp/Server/WebSocketServiceHost`1.cs +++ b/websocket-sharp/Server/WebSocketServiceHost`1.cs @@ -109,11 +109,12 @@ public override TimeSpan WaitTime { } set { - var msg = _sessions.State.CheckIfAvailable (true, false, false) ?? - value.CheckIfValidWaitTime (); + string msg; + if (!value.CheckWaitTime (out msg)) + throw new ArgumentException (msg, "value"); - if (msg != null) { - _log.Error (msg); + if (!canSet (out msg)) { + _log.Warn (msg); return; } From dc7a4f962755260820c06afc25dbaa4c2db2d245 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 23 Feb 2017 16:08:08 +0900 Subject: [PATCH 0990/6294] [Modify] Move them --- .../Server/WebSocketServiceHost.cs | 100 ++++++++++++++++-- .../Server/WebSocketServiceHost`1.cs | 75 +------------ 2 files changed, 92 insertions(+), 83 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceHost.cs b/websocket-sharp/Server/WebSocketServiceHost.cs index cfc702147..f8e668019 100644 --- a/websocket-sharp/Server/WebSocketServiceHost.cs +++ b/websocket-sharp/Server/WebSocketServiceHost.cs @@ -48,13 +48,32 @@ namespace WebSocketSharp.Server /// public abstract class WebSocketServiceHost { + #region Private Fields + + private Logger _log; + private string _path; + private WebSocketSessionManager _sessions; + + #endregion + #region Protected Constructors /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class + /// with the specified and . /// - protected WebSocketServiceHost () + /// + /// A that represents the absolute path to the service. + /// + /// + /// A that represents the logging function for the service. + /// + protected WebSocketServiceHost (string path, Logger log) { + _path = path; + _log = log; + + _sessions = new WebSocketSessionManager (log); } #endregion @@ -63,7 +82,7 @@ protected WebSocketServiceHost () internal ServerState State { get { - return Sessions.State; + return _sessions.State; } } @@ -79,7 +98,21 @@ internal ServerState State { /// true if the service cleans up the inactive sessions periodically; /// otherwise, false. /// - public abstract bool KeepClean { get; set; } + public bool KeepClean { + get { + return _sessions.KeepClean; + } + + set { + string msg; + if (!canSet (out msg)) { + _log.Warn (msg); + return; + } + + _sessions.KeepClean = value; + } + } /// /// Gets the path to the service. @@ -87,7 +120,11 @@ internal ServerState State { /// /// A that represents the absolute path to the service. /// - public abstract string Path { get; } + public string Path { + get { + return _path; + } + } /// /// Gets the access to the sessions in the service. @@ -96,7 +133,11 @@ internal ServerState State { /// A that manages the sessions in /// the service. /// - public abstract WebSocketSessionManager Sessions { get; } + public WebSocketSessionManager Sessions { + get { + return _sessions; + } + } /// /// Gets the of the behavior of the service. @@ -113,7 +154,46 @@ internal ServerState State { /// /// A that represents the wait time for the response. /// - public abstract TimeSpan WaitTime { get; set; } + public TimeSpan WaitTime { + get { + return _sessions.WaitTime; + } + + set { + string msg; + if (!value.CheckWaitTime (out msg)) + throw new ArgumentException (msg, "value"); + + if (!canSet (out msg)) { + _log.Warn (msg); + return; + } + + _sessions.WaitTime = value; + } + } + + #endregion + + #region Private Methods + + private bool canSet (out string message) + { + message = null; + + var state = _sessions.State; + if (state == ServerState.Start) { + message = "The service has already started."; + return false; + } + + if (state == ServerState.ShuttingDown) { + message = "The service is shutting down."; + return false; + } + + return true; + } #endregion @@ -121,17 +201,17 @@ internal ServerState State { internal void Start () { - Sessions.Start (); + _sessions.Start (); } internal void StartSession (WebSocketContext context) { - CreateSession ().Start (context, Sessions); + CreateSession ().Start (context, _sessions); } internal void Stop (ushort code, string reason) { - Sessions.Stop (code, reason); + _sessions.Stop (code, reason); } #endregion diff --git a/websocket-sharp/Server/WebSocketServiceHost`1.cs b/websocket-sharp/Server/WebSocketServiceHost`1.cs index c4bd633db..9405caf0a 100644 --- a/websocket-sharp/Server/WebSocketServiceHost`1.cs +++ b/websocket-sharp/Server/WebSocketServiceHost`1.cs @@ -35,10 +35,7 @@ internal class WebSocketServiceHost : WebSocketServiceHost { #region Private Fields - private Func _creator; - private Logger _log; - private string _path; - private WebSocketSessionManager _sessions; + private Func _creator; #endregion @@ -57,93 +54,25 @@ internal WebSocketServiceHost ( Action initializer, Logger log ) + : base (path, log) { - _path = path; _creator = createCreator (creator, initializer); - _log = log; - - _sessions = new WebSocketSessionManager (log); } #endregion #region Public Properties - public override bool KeepClean { - get { - return _sessions.KeepClean; - } - - set { - string msg; - if (!canSet (out msg)) { - _log.Warn (msg); - return; - } - - _sessions.KeepClean = value; - } - } - - public override string Path { - get { - return _path; - } - } - - public override WebSocketSessionManager Sessions { - get { - return _sessions; - } - } - public override Type Type { get { return typeof (TBehavior); } } - public override TimeSpan WaitTime { - get { - return _sessions.WaitTime; - } - - set { - string msg; - if (!value.CheckWaitTime (out msg)) - throw new ArgumentException (msg, "value"); - - if (!canSet (out msg)) { - _log.Warn (msg); - return; - } - - _sessions.WaitTime = value; - } - } - #endregion #region Private Methods - private bool canSet (out string message) - { - message = null; - - var state = _sessions.State; - if (state == ServerState.Start) { - message = "The service has already started."; - return false; - } - - if (state == ServerState.ShuttingDown) { - message = "The service is shutting down."; - return false; - } - - return true; - } - private Func createCreator ( Func creator, Action initializer ) From 7d31b8d3a19faec92bda2a3d0e759c5f25b33835 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 23 Feb 2017 16:17:37 +0900 Subject: [PATCH 0991/6294] [Modify] 2017 --- websocket-sharp/Server/WebSocketServiceHost`1.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServiceHost`1.cs b/websocket-sharp/Server/WebSocketServiceHost`1.cs index 9405caf0a..d5efb80d6 100644 --- a/websocket-sharp/Server/WebSocketServiceHost`1.cs +++ b/websocket-sharp/Server/WebSocketServiceHost`1.cs @@ -4,7 +4,7 @@ * * The MIT License * - * Copyright (c) 2015 sta.blockhead + * Copyright (c) 2015-2017 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From 0ba956127fe002681fa7ed1a2a7d9f0dc67bef37 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 24 Feb 2017 15:32:36 +0900 Subject: [PATCH 0992/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServiceHost.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceHost.cs b/websocket-sharp/Server/WebSocketServiceHost.cs index f8e668019..ab14df0a7 100644 --- a/websocket-sharp/Server/WebSocketServiceHost.cs +++ b/websocket-sharp/Server/WebSocketServiceHost.cs @@ -94,9 +94,13 @@ internal ServerState State { /// Gets or sets a value indicating whether the service cleans up /// the inactive sessions periodically. /// + /// + /// The set operation does nothing if the service has already started or + /// it is shutting down. + /// /// - /// true if the service cleans up the inactive sessions periodically; - /// otherwise, false. + /// true if the service cleans up the inactive sessions every 60 + /// seconds; otherwise, false. /// public bool KeepClean { get { From d8f20980f2854ebfc82ea3aca77ef3e43644dae3 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 24 Feb 2017 15:36:55 +0900 Subject: [PATCH 0993/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServiceHost.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServiceHost.cs b/websocket-sharp/Server/WebSocketServiceHost.cs index ab14df0a7..276284e04 100644 --- a/websocket-sharp/Server/WebSocketServiceHost.cs +++ b/websocket-sharp/Server/WebSocketServiceHost.cs @@ -131,7 +131,7 @@ public string Path { } /// - /// Gets the access to the sessions in the service. + /// Gets the management function for the sessions in the service. /// /// /// A that manages the sessions in From 4fec8d0c156c176d5e3cca76abb9e9c2a980a26b Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 24 Feb 2017 15:43:45 +0900 Subject: [PATCH 0994/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServiceHost.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/websocket-sharp/Server/WebSocketServiceHost.cs b/websocket-sharp/Server/WebSocketServiceHost.cs index 276284e04..8ee62e425 100644 --- a/websocket-sharp/Server/WebSocketServiceHost.cs +++ b/websocket-sharp/Server/WebSocketServiceHost.cs @@ -155,9 +155,16 @@ public WebSocketSessionManager Sessions { /// /// Gets or sets the wait time for the response to the WebSocket Ping or Close. /// + /// + /// The set operation does nothing if the server has already started or + /// it is shutting down. + /// /// /// A that represents the wait time for the response. /// + /// + /// The value specified for a set operation is zero or less. + /// public TimeSpan WaitTime { get { return _sessions.WaitTime; From 7db40445d8646d37c1cb783356a3c66f791bacb6 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 24 Feb 2017 16:40:29 +0900 Subject: [PATCH 0995/6294] [Modify] Rename it --- websocket-sharp/Server/WebSocketServiceHost.cs | 2 +- websocket-sharp/Server/WebSocketServiceHost`1.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceHost.cs b/websocket-sharp/Server/WebSocketServiceHost.cs index 8ee62e425..5dadf2310 100644 --- a/websocket-sharp/Server/WebSocketServiceHost.cs +++ b/websocket-sharp/Server/WebSocketServiceHost.cs @@ -150,7 +150,7 @@ public WebSocketSessionManager Sessions { /// A that represents the type of the behavior of /// the service. /// - public abstract Type Type { get; } + public abstract Type BehaviorType { get; } /// /// Gets or sets the wait time for the response to the WebSocket Ping or Close. diff --git a/websocket-sharp/Server/WebSocketServiceHost`1.cs b/websocket-sharp/Server/WebSocketServiceHost`1.cs index d5efb80d6..d4ca6a2d1 100644 --- a/websocket-sharp/Server/WebSocketServiceHost`1.cs +++ b/websocket-sharp/Server/WebSocketServiceHost`1.cs @@ -63,7 +63,7 @@ Logger log #region Public Properties - public override Type Type { + public override Type BehaviorType { get { return typeof (TBehavior); } From 5929b057bf56c4f0b6a74d11822b8f9f35fd16c9 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 24 Feb 2017 16:51:19 +0900 Subject: [PATCH 0996/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServiceHost.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceHost.cs b/websocket-sharp/Server/WebSocketServiceHost.cs index 5dadf2310..bedc3c0db 100644 --- a/websocket-sharp/Server/WebSocketServiceHost.cs +++ b/websocket-sharp/Server/WebSocketServiceHost.cs @@ -144,10 +144,10 @@ public WebSocketSessionManager Sessions { } /// - /// Gets the of the behavior of the service. + /// Gets the of the behavior of the service. /// /// - /// A that represents the type of the behavior of + /// A that represents the type of the behavior of /// the service. /// public abstract Type BehaviorType { get; } From 31d4b31cee29e3470023787bd14a8ff40e5fe6c5 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 25 Feb 2017 17:35:07 +0900 Subject: [PATCH 0997/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServiceHost.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServiceHost.cs b/websocket-sharp/Server/WebSocketServiceHost.cs index bedc3c0db..e89ac9a27 100644 --- a/websocket-sharp/Server/WebSocketServiceHost.cs +++ b/websocket-sharp/Server/WebSocketServiceHost.cs @@ -233,7 +233,8 @@ internal void Stop (ushort code, string reason) /// Creates a new session for the service. /// /// - /// A instance that represents a new session. + /// A instance that represents + /// the new session. /// protected abstract WebSocketBehavior CreateSession (); From c5ce495a30c1ce58eac70a0ca42b5da688f3e5fc Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 25 Feb 2017 17:37:29 +0900 Subject: [PATCH 0998/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServiceHost.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServiceHost.cs b/websocket-sharp/Server/WebSocketServiceHost.cs index e89ac9a27..2ed4f81b6 100644 --- a/websocket-sharp/Server/WebSocketServiceHost.cs +++ b/websocket-sharp/Server/WebSocketServiceHost.cs @@ -122,7 +122,8 @@ public bool KeepClean { /// Gets the path to the service. /// /// - /// A that represents the absolute path to the service. + /// A that represents the absolute path to + /// the service. /// public string Path { get { From 2dd5c2e4ba522d9ed52f942ba5e5617e3260c3e8 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 26 Feb 2017 18:16:00 +0900 Subject: [PATCH 0999/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServiceHost.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceHost.cs b/websocket-sharp/Server/WebSocketServiceHost.cs index 2ed4f81b6..e9f116ad2 100644 --- a/websocket-sharp/Server/WebSocketServiceHost.cs +++ b/websocket-sharp/Server/WebSocketServiceHost.cs @@ -154,14 +154,16 @@ public WebSocketSessionManager Sessions { public abstract Type BehaviorType { get; } /// - /// Gets or sets the wait time for the response to the WebSocket Ping or Close. + /// Gets or sets the wait time for the response to the WebSocket Ping or + /// Close. /// /// - /// The set operation does nothing if the server has already started or + /// The set operation does nothing if the service has already started or /// it is shutting down. /// /// - /// A that represents the wait time for the response. + /// A that represents the wait time for + /// the response. /// /// /// The value specified for a set operation is zero or less. From 5f99e99a453c27b2f362ab74e5264632f8dd6c13 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 27 Feb 2017 16:31:57 +0900 Subject: [PATCH 1000/6294] [Modify] Add it --- websocket-sharp/Server/WebSocketServiceHost.cs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/websocket-sharp/Server/WebSocketServiceHost.cs b/websocket-sharp/Server/WebSocketServiceHost.cs index e9f116ad2..416d7d82a 100644 --- a/websocket-sharp/Server/WebSocketServiceHost.cs +++ b/websocket-sharp/Server/WebSocketServiceHost.cs @@ -88,6 +88,22 @@ internal ServerState State { #endregion + #region Protected Properties + + /// + /// Gets the logging function for the service. + /// + /// + /// A that provides the logging function. + /// + protected Logger Log { + get { + return _log; + } + } + + #endregion + #region Public Properties /// From a553653231005734ee772505521206ac571c8508 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 28 Feb 2017 16:41:23 +0900 Subject: [PATCH 1001/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index b8c3d6ea8..1e60f5820 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1955,7 +1955,9 @@ public static Uri ToUri (this string value) /// public static string UrlDecode (this string value) { - return value != null && value.Length > 0 ? HttpUtility.UrlDecode (value) : value; + return value != null && value.Length > 0 + ? HttpUtility.UrlDecode (value) + : value; } /// From 97581e57a43ef8e4cf9d76aedfc423fe3d494aae Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 28 Feb 2017 16:47:26 +0900 Subject: [PATCH 1002/6294] [Modify] Edit it --- websocket-sharp/Ext.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 1e60f5820..eae27153e 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1947,8 +1947,8 @@ public static Uri ToUri (this string value) /// URL-decodes the specified . /// /// - /// A that receives the decoded string, - /// or the if it's or empty. + /// A that receives the decoded string or + /// if it is or empty. /// /// /// A to decode. From 0a06117e04b3251623c5219309a0c12506669b79 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 1 Mar 2017 16:24:25 +0900 Subject: [PATCH 1003/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index eae27153e..97649eb9e 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1972,7 +1972,9 @@ public static string UrlDecode (this string value) /// public static string UrlEncode (this string value) { - return value != null && value.Length > 0 ? HttpUtility.UrlEncode (value) : value; + return value != null && value.Length > 0 + ? HttpUtility.UrlEncode (value) + : value; } /// From c48861c79e1b9229ca6ea0fecd09cbb4a30a63e2 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 1 Mar 2017 16:29:09 +0900 Subject: [PATCH 1004/6294] [Modify] Edit it --- websocket-sharp/Ext.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 97649eb9e..0b7991257 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1964,8 +1964,8 @@ public static string UrlDecode (this string value) /// URL-encodes the specified . /// /// - /// A that receives the encoded string, - /// or if it's or empty. + /// A that receives the encoded string or + /// if it is or empty. /// /// /// A to encode. From 64925eaa9e7a8f76c06dd23e8e9b34654ffba89b Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 2 Mar 2017 16:07:24 +0900 Subject: [PATCH 1005/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 0b7991257..4f948db5c 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -907,8 +907,8 @@ internal static ulong ToUInt64 (this byte[] source, ByteOrder sourceOrder) internal static string TrimEndSlash (this string value) { - value = value.TrimEnd ('/'); - return value.Length > 0 ? value : "/"; + var ret = value.TrimEnd ('/'); + return ret.Length > 0 ? ret : "/"; } /// From 2fe5697c0ddef1aba3defef8105dd3dfd63f427d Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 3 Mar 2017 15:58:44 +0900 Subject: [PATCH 1006/6294] [Modify] Rename it --- websocket-sharp/Ext.cs | 2 +- websocket-sharp/Server/WebSocketServiceManager.cs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 4f948db5c..ba6766950 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -905,7 +905,7 @@ internal static ulong ToUInt64 (this byte[] source, ByteOrder sourceOrder) return BitConverter.ToUInt64 (source.ToHostOrder (sourceOrder), 0); } - internal static string TrimEndSlash (this string value) + internal static string TrimSlashFromEnd (this string value) { var ret = value.TrimEnd ('/'); return ret.Length > 0 ? ret : "/"; diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index 05c3e8664..8dcd9ad98 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -285,7 +285,7 @@ private Dictionary> broadping ( internal void Add (string path, Func initializer) where TBehavior : WebSocketBehavior { - path = HttpUtility.UrlDecode (path).TrimEndSlash (); + path = HttpUtility.UrlDecode (path).TrimSlashFromEnd (); lock (_sync) { WebSocketServiceHost host; @@ -315,7 +315,7 @@ internal bool InternalTryGetServiceHost ( string path, out WebSocketServiceHost host ) { - path = HttpUtility.UrlDecode (path).TrimEndSlash (); + path = HttpUtility.UrlDecode (path).TrimSlashFromEnd (); lock (_sync) return _hosts.TryGetValue (path, out host); @@ -323,7 +323,7 @@ internal bool InternalTryGetServiceHost ( internal bool Remove (string path) { - path = HttpUtility.UrlDecode (path).TrimEndSlash (); + path = HttpUtility.UrlDecode (path).TrimSlashFromEnd (); WebSocketServiceHost host; lock (_sync) { From 662c2632c4c49cbc9462e2bf82090db2c8ae6f3d Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 4 Mar 2017 17:53:03 +0900 Subject: [PATCH 1007/6294] [Modify] Add it --- .../Server/WebSocketServiceManager.cs | 61 +++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index 8dcd9ad98..ed5115899 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -592,6 +592,67 @@ public Dictionary> Broadping (string message) return broadping (WebSocketFrame.CreatePingFrame (data, false).ToArray (), _waitTime); } + /// + /// Removes a WebSocket service with the specified . + /// + /// + /// is converted to a URL-decoded string and + /// / is trimmed from the end of the converted string if any. + /// + /// + /// true if the service is successfully found and removed; + /// otherwise, false. + /// + /// + /// A that represents an absolute path to + /// the service to remove. + /// + /// + /// is . + /// + /// + /// + /// is empty. + /// + /// + /// -or- + /// + /// + /// is invalid. + /// + /// + public bool RemoveService (string path) + { + if (path == null) + throw new ArgumentNullException ("path"); + + if (path.Length == 0) + throw new ArgumentException ("An empty string.", "path"); + + if (path[0] != '/') + throw new ArgumentException ("Not an absolute path.", "path"); + + if (path.IndexOfAny (new[] { '?', '#' }) > -1) { + var msg = "It includes either or both query and fragment components."; + throw new ArgumentException (msg, "path"); + } + + path = HttpUtility.UrlDecode (path).TrimSlashFromEnd (); + + WebSocketServiceHost host; + lock (_sync) { + if (!_hosts.TryGetValue (path, out host)) + return false; + + _hosts.Remove (path); + } + + if (host.State == ServerState.Start) + host.Stop (1001, String.Empty); + + return true; + } + /// /// Tries to get the WebSocket service host with /// the specified . From 19d1c72dbe311b46fbfe46ba2aad2463ce1d0603 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 5 Mar 2017 17:22:16 +0900 Subject: [PATCH 1008/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServiceManager.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index ed5115899..3fa8eb37e 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -618,7 +618,14 @@ public Dictionary> Broadping (string message) /// -or- /// /// - /// is invalid. + /// is not an absolute path. + /// + /// + /// -or- + /// + /// + /// includes either or both + /// query and fragment components. /// /// public bool RemoveService (string path) From 5326cf720e3174fceed8da565d83aa9ec20b961a Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 6 Mar 2017 16:31:35 +0900 Subject: [PATCH 1009/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServiceManager.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index 3fa8eb37e..580db9e03 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -596,8 +596,14 @@ public Dictionary> Broadping (string message) /// Removes a WebSocket service with the specified . /// /// - /// is converted to a URL-decoded string and - /// / is trimmed from the end of the converted string if any. + /// + /// is converted to a URL-decoded string and + /// / is trimmed from the end of the converted string if any. + /// + /// + /// The service is stopped with close status 1001 (going away) + /// if it has already started. + /// /// /// /// true if the service is successfully found and removed; From c11fc49d518933b388db014b32e1aa45a2f859af Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 7 Mar 2017 16:00:47 +0900 Subject: [PATCH 1010/6294] [Modify] Add it --- .../Server/WebSocketServiceManager.cs | 92 +++++++++++++++++++ 1 file changed, 92 insertions(+) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index 580db9e03..c0a81fd13 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -384,6 +384,98 @@ internal void Stop (CloseEventArgs e, bool send, bool receive) #region Public Methods + /// + /// Adds a WebSocket service with the specified behavior, + /// , and . + /// + /// + /// is converted to a URL-decoded string and + /// / is trimmed from the end of the converted string if any. + /// + /// + /// A that represents an absolute path to + /// the service to add. + /// + /// + /// An Action<TBehavior> delegate that invokes + /// the method used to initialize a new session instance for + /// the service or if not needed. + /// + /// + /// The type of the behavior for the service. It must inherit + /// the class and it must have + /// a public parameterless constructor. + /// + /// + /// is . + /// + /// + /// + /// is empty. + /// + /// + /// -or- + /// + /// + /// is not an absolute path. + /// + /// + /// -or- + /// + /// + /// includes either or both + /// query and fragment components. + /// + /// + /// -or- + /// + /// + /// is already in use. + /// + /// + public void AddService ( + string path, Action initializer + ) + where TBehavior : WebSocketBehavior, new () + { + if (path == null) + throw new ArgumentNullException ("path"); + + if (path.Length == 0) + throw new ArgumentException ("An empty string.", "path"); + + if (path[0] != '/') + throw new ArgumentException ("Not an absolute path.", "path"); + + if (path.IndexOfAny (new[] { '?', '#' }) > -1) { + var msg = "It includes either or both query and fragment components."; + throw new ArgumentException (msg, "path"); + } + + path = HttpUtility.UrlDecode (path).TrimSlashFromEnd (); + + lock (_sync) { + WebSocketServiceHost host; + if (_hosts.TryGetValue (path, out host)) + throw new ArgumentException ("Already in use.", "path"); + + host = new WebSocketServiceHost ( + path, () => new TBehavior (), initializer, _logger + ); + + if (!_clean) + host.KeepClean = false; + + if (_waitTime != host.WaitTime) + host.WaitTime = _waitTime; + + if (_state == ServerState.Start) + host.Start (); + + _hosts.Add (path, host); + } + } + /// /// Sends binary to every client in the WebSocket services. /// From 03622c306698a316f6a8f43ab50643a22d440ff7 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 7 Mar 2017 16:06:54 +0900 Subject: [PATCH 1011/6294] [Modify] Replace it --- websocket-sharp/Server/WebSocketServer.cs | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 4ffaef264..2a13958ac 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -1106,13 +1106,7 @@ public void AddWebSocketService (string path) /// public bool RemoveWebSocketService (string path) { - string msg; - if (!checkServicePath (path, out msg)) { - _log.Error (msg); - return false; - } - - return _services.Remove (path); + return _services.RemoveService (path); } /// From 767d2acb0f1e5cc3e9b7666e81619c0a127c8d25 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 7 Mar 2017 16:12:17 +0900 Subject: [PATCH 1012/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 34 +++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 2a13958ac..dc6a10fcc 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -1095,15 +1095,45 @@ public void AddWebSocketService (string path) /// /// Removes a WebSocket service with the specified . /// + /// + /// + /// is converted to a URL-decoded string and + /// / is trimmed from the end of the converted string if any. + /// + /// + /// The service is stopped with close status 1001 (going away) + /// if it has already started. + /// + /// /// /// true if the service is successfully found and removed; /// otherwise, false. /// /// /// A that represents an absolute path to - /// the service. It will be converted to a URL-decoded string, - /// and will be removed '/' from tail end if any. + /// the service to remove. /// + /// + /// is . + /// + /// + /// + /// is empty. + /// + /// + /// -or- + /// + /// + /// is not an absolute path. + /// + /// + /// -or- + /// + /// + /// includes either or both + /// query and fragment components. + /// + /// public bool RemoveWebSocketService (string path) { return _services.RemoveService (path); From 894d8cae3ec7e6602ea0f8497878f7e3b3f250ac Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 8 Mar 2017 15:57:11 +0900 Subject: [PATCH 1013/6294] [Modify] Replace it --- websocket-sharp/Server/WebSocketServer.cs | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index dc6a10fcc..b800c9f6e 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -1083,13 +1083,7 @@ public void AddWebSocketService ( public void AddWebSocketService (string path) where TBehaviorWithNew : WebSocketBehavior, new () { - string msg; - if (!checkServicePath (path, out msg)) { - _log.Error (msg); - return; - } - - _services.Add (path, () => new TBehaviorWithNew ()); + _services.AddService (path, null); } /// From af04ac1240ead3c56e868e24fb852f42deee6918 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 8 Mar 2017 16:09:58 +0900 Subject: [PATCH 1014/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 36 +++++++++++++++++++++-- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index b800c9f6e..85f6e758c 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -1070,16 +1070,46 @@ public void AddWebSocketService ( /// Adds a WebSocket service with the specified behavior and /// . /// + /// + /// is converted to a URL-decoded string and + /// / is trimmed from the end of the converted string if any. + /// /// /// A that represents an absolute path to - /// the service. It will be converted to a URL-decoded string, - /// and will be removed '/' from tail end if any. + /// the service to add. /// /// /// The type of the behavior for the service. It must inherit - /// the class, and must have + /// the class and it must have /// a public parameterless constructor. /// + /// + /// is . + /// + /// + /// + /// is empty. + /// + /// + /// -or- + /// + /// + /// is not an absolute path. + /// + /// + /// -or- + /// + /// + /// includes either or both + /// query and fragment components. + /// + /// + /// -or- + /// + /// + /// is already in use. + /// + /// public void AddWebSocketService (string path) where TBehaviorWithNew : WebSocketBehavior, new () { From 669f923c96a5baf30534c0acd11d693794a59bcc Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 8 Mar 2017 16:29:49 +0900 Subject: [PATCH 1015/6294] [Modify] Add it --- websocket-sharp/Server/WebSocketServer.cs | 57 +++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 85f6e758c..6621718d6 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -1116,6 +1116,63 @@ public void AddWebSocketService (string path) _services.AddService (path, null); } + /// + /// Adds a WebSocket service with the specified behavior, + /// , and . + /// + /// + /// is converted to a URL-decoded string and + /// / is trimmed from the end of the converted string if any. + /// + /// + /// A that represents an absolute path to + /// the service to add. + /// + /// + /// An Action<TBehaviorWithNew> delegate that invokes + /// the method used to initialize a new session instance for + /// the service or if not needed. + /// + /// + /// The type of the behavior for the service. It must inherit + /// the class and it must have + /// a public parameterless constructor. + /// + /// + /// is . + /// + /// + /// + /// is empty. + /// + /// + /// -or- + /// + /// + /// is not an absolute path. + /// + /// + /// -or- + /// + /// + /// includes either or both + /// query and fragment components. + /// + /// + /// -or- + /// + /// + /// is already in use. + /// + /// + public void AddWebSocketService ( + string path, Action initializer + ) + where TBehaviorWithNew : WebSocketBehavior, new () + { + _services.AddService (path, initializer); + } + /// /// Removes a WebSocket service with the specified . /// From 0e9da7ac58f4ff896473a9df45b1c3a0732b6a49 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 8 Mar 2017 16:37:54 +0900 Subject: [PATCH 1016/6294] [Modify] Throw exception --- websocket-sharp/Server/WebSocketServiceManager.cs | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index c0a81fd13..01b97fa27 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -289,15 +289,11 @@ internal void Add (string path, Func initializer) lock (_sync) { WebSocketServiceHost host; - if (_hosts.TryGetValue (path, out host)) { - _logger.Error ( - "A WebSocket service with the specified path has already existed." - ); - - return; - } + if (_hosts.TryGetValue (path, out host)) + throw new ArgumentException ("Already in use.", "path"); host = new WebSocketServiceHost (path, initializer, _logger); + if (!_clean) host.KeepClean = false; From 681fa65c0d879260ac268c77983922516c1b325b Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 8 Mar 2017 16:46:23 +0900 Subject: [PATCH 1017/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketServiceManager.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index 01b97fa27..2c4f5b6c6 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -282,7 +282,7 @@ private Dictionary> broadping ( #region Internal Methods - internal void Add (string path, Func initializer) + internal void Add (string path, Func creator) where TBehavior : WebSocketBehavior { path = HttpUtility.UrlDecode (path).TrimSlashFromEnd (); @@ -292,7 +292,9 @@ internal void Add (string path, Func initializer) if (_hosts.TryGetValue (path, out host)) throw new ArgumentException ("Already in use.", "path"); - host = new WebSocketServiceHost (path, initializer, _logger); + host = new WebSocketServiceHost ( + path, creator, null, _logger + ); if (!_clean) host.KeepClean = false; From a26e0f96338914815a001ec7a9b3d3e2fd670166 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 9 Mar 2017 15:26:11 +0900 Subject: [PATCH 1018/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketServiceManager.cs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index 2c4f5b6c6..102ba6f90 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -325,13 +325,8 @@ internal bool Remove (string path) WebSocketServiceHost host; lock (_sync) { - if (!_hosts.TryGetValue (path, out host)) { - _logger.Error ( - "A WebSocket service with the specified path could not be found." - ); - + if (!_hosts.TryGetValue (path, out host)) return false; - } _hosts.Remove (path); } From 9dcfc85c1cfd0b070e2becc03ae8659a557fe909 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 9 Mar 2017 15:35:30 +0900 Subject: [PATCH 1019/6294] [Modify] Throw exceptions --- websocket-sharp/Server/WebSocketServer.cs | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 6621718d6..1aa14b9c1 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -1052,15 +1052,21 @@ public void AddWebSocketService ( ) where TBehavior : WebSocketBehavior { - string msg; - if (!checkServicePath (path, out msg)) { - _log.Error (msg); - return; - } + if (path == null) + throw new ArgumentNullException ("path"); - if (initializer == null) { - _log.Error ("'initializer' is null."); - return; + if (initializer == null) + throw new ArgumentNullException ("initializer"); + + if (path.Length == 0) + throw new ArgumentException ("An empty string.", "path"); + + if (path[0] != '/') + throw new ArgumentException ("Not an absolute path.", "path"); + + if (path.IndexOfAny (new[] { '?', '#' }) > -1) { + var msg = "It includes either or both query and fragment components."; + throw new ArgumentException (msg, "path"); } _services.Add (path, initializer); From 0140ddb3b57bcf8e3d241786b9004a2f741713ce Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 9 Mar 2017 15:40:09 +0900 Subject: [PATCH 1020/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketServer.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 1aa14b9c1..290d48b03 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -1030,14 +1030,14 @@ private static bool tryCreateUri ( /// /// Adds a WebSocket service with the specified behavior, - /// , and . + /// , and . /// /// /// A that represents an absolute path to /// the service. It will be converted to a URL-decoded string, /// and will be removed '/' from tail end if any. /// - /// + /// /// A Func<TBehavior> delegate that invokes /// the method used to create a new session instance for /// the service. The method must create a new instance of @@ -1048,15 +1048,15 @@ private static bool tryCreateUri ( /// the class. /// public void AddWebSocketService ( - string path, Func initializer + string path, Func creator ) where TBehavior : WebSocketBehavior { if (path == null) throw new ArgumentNullException ("path"); - if (initializer == null) - throw new ArgumentNullException ("initializer"); + if (creator == null) + throw new ArgumentNullException ("creator"); if (path.Length == 0) throw new ArgumentException ("An empty string.", "path"); @@ -1069,7 +1069,7 @@ public void AddWebSocketService ( throw new ArgumentException (msg, "path"); } - _services.Add (path, initializer); + _services.Add (path, creator); } /// From 95fffb98985a3e8741fce2490342c69fa9166df7 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 10 Mar 2017 17:36:41 +0900 Subject: [PATCH 1021/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 42 +++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 290d48b03..9e8ab16c8 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -1032,10 +1032,13 @@ private static bool tryCreateUri ( /// Adds a WebSocket service with the specified behavior, /// , and . /// + /// + /// is converted to a URL-decoded string and + /// / is trimmed from the end of the converted string if any. + /// /// /// A that represents an absolute path to - /// the service. It will be converted to a URL-decoded string, - /// and will be removed '/' from tail end if any. + /// the service to add. /// /// /// A Func<TBehavior> delegate that invokes @@ -1047,6 +1050,41 @@ private static bool tryCreateUri ( /// The type of the behavior for the service. It must inherit /// the class. /// + /// + /// + /// is . + /// + /// + /// -or- + /// + /// + /// is . + /// + /// + /// + /// + /// is empty. + /// + /// + /// -or- + /// + /// + /// is not an absolute path. + /// + /// + /// -or- + /// + /// + /// includes either or both + /// query and fragment components. + /// + /// + /// -or- + /// + /// + /// is already in use. + /// + /// public void AddWebSocketService ( string path, Func creator ) From 1f9a496220b7c48bba242f3f2cd87fc6e1d2a6de Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 11 Mar 2017 19:25:51 +0900 Subject: [PATCH 1022/6294] [Modify] It will be removed --- websocket-sharp/Server/WebSocketServer.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 9e8ab16c8..4d92b7b1e 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -1085,6 +1085,7 @@ private static bool tryCreateUri ( /// is already in use. /// /// + [Obsolete ("This method will be removed. Use added one instead.")] public void AddWebSocketService ( string path, Func creator ) From 0beba615cc519c12056ae057d22d454209031e08 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 12 Mar 2017 17:15:49 +0900 Subject: [PATCH 1023/6294] [Modify] Remove it --- websocket-sharp/Server/WebSocketServer.cs | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 4d92b7b1e..571bd293b 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -731,28 +731,6 @@ private bool checkHostNameForRequest (string name) || name == _hostname; } - private bool checkServicePath (string path, out string message) - { - message = null; - - if (path.IsNullOrEmpty ()) { - message = "'path' is null or empty."; - return false; - } - - if (path[0] != '/') { - message = "'path' is not an absolute path."; - return false; - } - - if (path.IndexOfAny (new[] { '?', '#' }) > -1) { - message = "'path' includes either or both query and fragment components."; - return false; - } - - return true; - } - private bool checkSslConfiguration ( ServerSslConfiguration configuration, out string message ) From 7bec6fe8ca59f02a501540ffb3e1cf3cc1693203 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 13 Mar 2017 17:19:56 +0900 Subject: [PATCH 1024/6294] [Modify] Polish it Output Message as a fatal log and ToString as a debug log. --- websocket-sharp/Server/WebSocketServer.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 571bd293b..d99573482 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -843,7 +843,9 @@ private void receiveRequest () processRequest (ctx); } catch (Exception ex) { - _log.Fatal (ex.ToString ()); + _log.Fatal (ex.Message); + _log.Debug (ex.ToString ()); + cl.Close (); } } From 555a8d43a63468d8c522269c0f6ad48e244525d3 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 14 Mar 2017 17:42:34 +0900 Subject: [PATCH 1025/6294] [Modify] Polish it Output Message as a fatal log and ToString as a debug log. --- websocket-sharp/Server/WebSocketServer.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index d99573482..90829ae70 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -857,7 +857,9 @@ private void receiveRequest () break; } - _log.Fatal (ex.ToString ()); + _log.Fatal (ex.Message); + _log.Debug (ex.ToString ()); + break; } catch (Exception ex) { From da2287229eade013d7555c404c8a284a7ade2a63 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 15 Mar 2017 18:09:50 +0900 Subject: [PATCH 1026/6294] [Modify] Polish it Output Message as a fatal log and ToString as a debug log. --- websocket-sharp/Server/WebSocketServer.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 90829ae70..77d3f25c0 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -863,7 +863,9 @@ private void receiveRequest () break; } catch (Exception ex) { - _log.Fatal (ex.ToString ()); + _log.Fatal (ex.Message); + _log.Debug (ex.ToString ()); + if (cl != null) cl.Close (); From d3a8582d92a1002ab9a9315142c5df4e3af78031 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 16 Mar 2017 17:39:41 +0900 Subject: [PATCH 1027/6294] [Modify] Throw exceptions --- websocket-sharp/Server/WebSocketServiceManager.cs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index 102ba6f90..e9337f0c2 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -770,16 +770,19 @@ public bool RemoveService (string path) /// public bool TryGetServiceHost (string path, out WebSocketServiceHost host) { - host = null; + if (path == null) + throw new ArgumentNullException ("path"); - if (path == null || path.Length == 0) - return false; + if (path.Length == 0) + throw new ArgumentException ("An empty string.", "path"); if (path[0] != '/') - return false; + throw new ArgumentException ("Not an absolute path.", "path"); - if (path.IndexOfAny (new[] { '?', '#' }) > -1) - return false; + if (path.IndexOfAny (new[] { '?', '#' }) > -1) { + var msg = "It includes either or both query and fragment components."; + throw new ArgumentException (msg, "path"); + } return InternalTryGetServiceHost (path, out host); } From 3bb74b8a6911fcb6d8d2b0ac54ab7e7817eebcac Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 17 Mar 2017 18:24:28 +0900 Subject: [PATCH 1028/6294] [Modify] Edit it --- .../Server/WebSocketServiceManager.cs | 33 ++++++++++++++++--- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index e9337f0c2..644c6cc77 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -752,22 +752,47 @@ public bool RemoveService (string path) } /// - /// Tries to get the WebSocket service host with - /// the specified . + /// Tries to get the WebSocket service host with the specified + /// . /// + /// + /// is converted to a URL-decoded string and + /// / is trimmed from the end of the converted string if any. + /// /// /// true if the service is successfully found; /// otherwise, false. /// /// - /// A that represents the absolute path to + /// A that represents an absolute path to /// the service to find. /// /// /// When this method returns, a /// instance that provides the access to the information in - /// the service or if it is not found. + /// the service or if not found. /// + /// + /// is . + /// + /// + /// + /// is empty. + /// + /// + /// -or- + /// + /// + /// is not an absolute path. + /// + /// + /// -or- + /// + /// + /// includes either or both + /// query and fragment components. + /// + /// public bool TryGetServiceHost (string path, out WebSocketServiceHost host) { if (path == null) From 85b09f3e7b8776dafb8ab10fe3b2f0b924acc1c3 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 18 Mar 2017 17:53:54 +0900 Subject: [PATCH 1029/6294] [Modify] Throw exceptions --- .../Server/WebSocketServiceManager.cs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index 644c6cc77..4f1469f35 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -114,8 +114,22 @@ public IEnumerable Hosts { /// public WebSocketServiceHost this[string path] { get { + if (path == null) + throw new ArgumentNullException ("path"); + + if (path.Length == 0) + throw new ArgumentException ("An empty string.", "path"); + + if (path[0] != '/') + throw new ArgumentException ("Not an absolute path.", "path"); + + if (path.IndexOfAny (new[] { '?', '#' }) > -1) { + var msg = "It includes either or both query and fragment components."; + throw new ArgumentException (msg, "path"); + } + WebSocketServiceHost host; - TryGetServiceHost (path, out host); + InternalTryGetServiceHost (path, out host); return host; } From de60f206c6d0f1457c6534bb1858d7d00f6b9dc5 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 19 Mar 2017 17:46:06 +0900 Subject: [PATCH 1030/6294] [Modify] Edit it --- .../Server/WebSocketServiceManager.cs | 30 +++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index 4f1469f35..d3f636911 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -105,13 +105,39 @@ public IEnumerable Hosts { /// /// Gets the WebSocket service host with the specified . /// + /// + /// is converted to a URL-decoded string and + /// / is trimmed from the end of the converted string if any. + /// /// /// A instance that provides the access to - /// the information in the service, or if it's not found. + /// the information in the service or if not found. /// /// - /// A that represents the absolute path to the service to find. + /// A that represents an absolute path to + /// the service to find. /// + /// + /// is . + /// + /// + /// + /// is empty. + /// + /// + /// -or- + /// + /// + /// is not an absolute path. + /// + /// + /// -or- + /// + /// + /// includes either or both + /// query and fragment components. + /// + /// public WebSocketServiceHost this[string path] { get { if (path == null) From 0bb8cb97e0b3237e876ae5374e56f8598dfb4fcc Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 20 Mar 2017 17:41:20 +0900 Subject: [PATCH 1031/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServiceManager.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index d3f636911..3c9a90c9b 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -37,9 +37,12 @@ namespace WebSocketSharp.Server { /// - /// Manages the WebSocket services provided by the or - /// . + /// Provides the management function for the WebSocket services. /// + /// + /// This class manages the WebSocket services provided by + /// the or . + /// public class WebSocketServiceManager { #region Private Fields From 90750b69ce3bcea5246178b61ce880617e9a1bbb Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 21 Mar 2017 18:21:55 +0900 Subject: [PATCH 1032/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServiceManager.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index 3c9a90c9b..1fa51bb9d 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -92,11 +92,12 @@ public int Count { } /// - /// Gets the host instances for the Websocket services. + /// Gets the WebSocket service hosts. /// /// - /// An IEnumerable<WebSocketServiceHost> instance that provides an enumerator - /// which supports the iteration over the collection of the host instances for the services. + /// An + /// instance that provides an enumerator which supports the iteration over + /// the collection of the instances. /// public IEnumerable Hosts { get { From 76addde28ff8b0f3260c95eaed0be4c41acb73eb Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 22 Mar 2017 18:04:37 +0900 Subject: [PATCH 1033/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServiceManager.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index 1fa51bb9d..0085e8f13 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -95,8 +95,8 @@ public int Count { /// Gets the WebSocket service hosts. /// /// - /// An - /// instance that provides an enumerator which supports the iteration over + /// An IEnumerable<WebSocketServiceHost> instance that + /// provides an enumerator which supports the iteration over /// the collection of the instances. /// public IEnumerable Hosts { From 38ba7c599f607827f1a41994c7f5e691b618385d Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 23 Mar 2017 17:08:16 +0900 Subject: [PATCH 1034/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServiceManager.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index 0085e8f13..fc5ad7bf5 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -194,8 +194,8 @@ internal set { /// Gets the paths for the WebSocket services. /// /// - /// An IEnumerable<string> instance that provides an enumerator which supports - /// the iteration over the collection of the paths for the services. + /// An IEnumerable<string> instance that provides an enumerator + /// which supports the iteration over the collection of the paths. /// public IEnumerable Paths { get { From 26fa3b64d7831f9f43d4bd07ce8281383f4b1b74 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 23 Mar 2017 17:14:55 +0900 Subject: [PATCH 1035/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServiceManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index fc5ad7bf5..482532905 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -92,7 +92,7 @@ public int Count { } /// - /// Gets the WebSocket service hosts. + /// Gets the host instances for the WebSocket services. /// /// /// An IEnumerable<WebSocketServiceHost> instance that From 15a3229f4e3076b05d2cf597e49a63156a993ba0 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 24 Mar 2017 17:01:53 +0900 Subject: [PATCH 1036/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServiceManager.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index 482532905..40e693027 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -107,7 +107,8 @@ public IEnumerable Hosts { } /// - /// Gets the WebSocket service host with the specified . + /// Gets the host instance for the WebSocket service with the specified + /// . /// /// /// is converted to a URL-decoded string and From 983c0acacc5f337074b5a3a87ebcfdc0cf720df2 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 25 Mar 2017 17:04:50 +0900 Subject: [PATCH 1037/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServiceManager.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index 40e693027..bbc8ca723 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -797,8 +797,8 @@ public bool RemoveService (string path) } /// - /// Tries to get the WebSocket service host with the specified - /// . + /// Tries to get the host instance for a WebSocket service with + /// the specified . /// /// /// is converted to a URL-decoded string and From 2f24a3757ebbc47967b5951827ad32bad7f9167b Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 25 Mar 2017 17:24:32 +0900 Subject: [PATCH 1038/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServiceManager.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index bbc8ca723..071d46460 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -107,16 +107,17 @@ public IEnumerable Hosts { } /// - /// Gets the host instance for the WebSocket service with the specified - /// . + /// Gets the host instance for a WebSocket service with + /// the specified . /// /// /// is converted to a URL-decoded string and /// / is trimmed from the end of the converted string if any. /// /// - /// A instance that provides the access to - /// the information in the service or if not found. + /// A instance that provides + /// the access to the information in the service or + /// if not found. /// /// /// A that represents an absolute path to From fb53fa674e460fac6bc157ea8de3c93128f9c98f Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 26 Mar 2017 15:35:42 +0900 Subject: [PATCH 1039/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServiceManager.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index 071d46460..ed7f65a27 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -95,9 +95,13 @@ public int Count { /// Gets the host instances for the WebSocket services. /// /// - /// An IEnumerable<WebSocketServiceHost> instance that - /// provides an enumerator which supports the iteration over - /// the collection of the instances. + /// + /// An IEnumerable<WebSocketServiceHost> instance. + /// + /// + /// It provides an enumerator which supports the iteration over + /// the collection of the host instances. + /// /// public IEnumerable Hosts { get { From 16dfa9fcdb1759343bd3710a7a4aee1980fd4cbd Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 26 Mar 2017 15:44:03 +0900 Subject: [PATCH 1040/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServiceManager.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index ed7f65a27..e916e00bb 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -119,9 +119,13 @@ public IEnumerable Hosts { /// / is trimmed from the end of the converted string if any. /// /// - /// A instance that provides - /// the access to the information in the service or - /// if not found. + /// + /// A instance. + /// + /// + /// It provides the access to the information in the service or + /// if not found. + /// /// /// /// A that represents an absolute path to From f97011e44df0c43c08f21a13a314f85f1a848386 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 26 Mar 2017 16:16:50 +0900 Subject: [PATCH 1041/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServiceManager.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index e916e00bb..828f71ba6 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -204,8 +204,13 @@ internal set { /// Gets the paths for the WebSocket services. /// /// - /// An IEnumerable<string> instance that provides an enumerator - /// which supports the iteration over the collection of the paths. + /// + /// An IEnumerable<string> instance. + /// + /// + /// It provides an enumerator which supports the iteration over + /// the collection of the paths. + /// /// public IEnumerable Paths { get { From 173c21e09efc206a149953220a0e4e7c00373a86 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 27 Mar 2017 17:52:38 +0900 Subject: [PATCH 1042/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServiceManager.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index 828f71ba6..e8099645d 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -120,11 +120,12 @@ public IEnumerable Hosts { /// /// /// - /// A instance. + /// A instance or + /// if not found. /// /// - /// It provides the access to the information in the service or - /// if not found. + /// That host instance provides the function to access + /// the information in the service. /// /// /// From 648346766430a99393268afbe31184b2f6333651 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 28 Mar 2017 16:44:05 +0900 Subject: [PATCH 1043/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServiceManager.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index e8099645d..2fa8caf6a 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -828,9 +828,14 @@ public bool RemoveService (string path) /// the service to find. /// /// - /// When this method returns, a - /// instance that provides the access to the information in - /// the service or if not found. + /// + /// When this method returns, a + /// instance or if not found. + /// + /// + /// That host instance provides the function to access + /// the information in the service. + /// /// /// /// is . From baabf4622cc2bc2b5e14d99b99c1248665a4a5d7 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 29 Mar 2017 15:59:47 +0900 Subject: [PATCH 1044/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServiceManager.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index 2fa8caf6a..2625ae60d 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -224,7 +224,8 @@ public IEnumerable Paths { /// Gets the total number of the sessions in the WebSocket services. /// /// - /// An that represents the total number of the sessions in the services. + /// An that represents the total number of + /// the sessions in the services. /// public int SessionCount { get { From 91112a0bf3ece6ebe2871ea45db375b77534a3e8 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 30 Mar 2017 16:14:13 +0900 Subject: [PATCH 1045/6294] [Modify] It will be removed. --- websocket-sharp/Server/WebSocketServiceManager.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index 2625ae60d..1f6e03fc3 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -227,6 +227,7 @@ public IEnumerable Paths { /// An that represents the total number of /// the sessions in the services. /// + [Obsolete ("This property will be removed.")] public int SessionCount { get { var cnt = 0; From dd392d283b704b8ffd83b33fb36586ee324153b6 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 30 Mar 2017 16:29:38 +0900 Subject: [PATCH 1046/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketServiceManager.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index 1f6e03fc3..3ae268422 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -191,10 +191,8 @@ public bool KeepClean { internal set { lock (_sync) { - if (!(value ^ _clean)) - return; - _clean = value; + foreach (var host in _hosts.Values) host.KeepClean = value; } From 682abf9335c3c77d04f8999b78a2358e887bdef7 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 30 Mar 2017 17:24:22 +0900 Subject: [PATCH 1047/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServiceManager.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index 3ae268422..edc0c81a1 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -177,12 +177,12 @@ public WebSocketServiceHost this[string path] { } /// - /// Gets a value indicating whether the manager cleans up the inactive sessions - /// in the WebSocket services periodically. + /// Gets a value indicating whether the inactive sessions in + /// the WebSocket services are cleaned up periodically. /// /// - /// true if the manager cleans up the inactive sessions every 60 seconds; - /// otherwise, false. + /// true if the inactive sessions in the services are + /// cleaned up every 60 seconds; otherwise, false. /// public bool KeepClean { get { From bd065e5201d016845d0343961b59159b060d8522 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 31 Mar 2017 15:19:52 +0900 Subject: [PATCH 1048/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketServiceManager.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index edc0c81a1..efcb4df43 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -253,10 +253,8 @@ public TimeSpan WaitTime { internal set { lock (_sync) { - if (value == _waitTime) - return; - _waitTime = value; + foreach (var host in _hosts.Values) host.WaitTime = value; } From 09673eb64e4275fca0ddba0d63ae5a77ad7aaa32 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 31 Mar 2017 16:28:16 +0900 Subject: [PATCH 1049/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServiceManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index efcb4df43..f5f2d8de4 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -244,7 +244,7 @@ public int SessionCount { /// Gets the wait time for the response to the WebSocket Ping or Close. /// /// - /// A that represents the wait time. + /// A that represents the wait time for the response. /// public TimeSpan WaitTime { get { From f37c76197140c40d46f548f43c8b0c37be488b26 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 1 Apr 2017 15:27:41 +0900 Subject: [PATCH 1050/6294] [Modify] Throw exceptions --- websocket-sharp/Server/WebSocketServiceManager.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index f5f2d8de4..8685b1466 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -535,14 +535,14 @@ public void AddService ( /// public void Broadcast (byte[] data) { - var msg = _state.CheckIfAvailable (false, true, false) ?? - WebSocket.CheckSendParameter (data); - - if (msg != null) { - _logger.Error (msg); - return; + if (_state != ServerState.Start) { + var msg = "The current state of the manager is not Start."; + throw new InvalidOperationException (msg); } + if (data == null) + throw new ArgumentNullException ("data"); + if (data.LongLength <= WebSocket.FragmentLength) broadcast (Opcode.Binary, data, null); else From bd1d1fd922e0882e5dc4ffc5575962174deccef7 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 1 Apr 2017 16:01:50 +0900 Subject: [PATCH 1051/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServiceManager.cs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index 8685b1466..22961ce8d 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -528,11 +528,19 @@ public void AddService ( } /// - /// Sends binary to every client in the WebSocket services. + /// Sends the specified to + /// every client in the WebSocket services. /// /// - /// An array of that represents the binary data to send. + /// An array of that represents + /// the binary data to send. /// + /// + /// The current state of the manager is not Start. + /// + /// + /// is . + /// public void Broadcast (byte[] data) { if (_state != ServerState.Start) { From a5eccd5442f76360282a1b1725568d2c50ee6f9b Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 2 Apr 2017 17:36:18 +0900 Subject: [PATCH 1052/6294] [Modify] Throw exceptions --- .../Server/WebSocketServiceManager.cs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index 22961ce8d..f99ad7845 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -565,15 +565,18 @@ public void Broadcast (byte[] data) /// public void Broadcast (string data) { - var msg = _state.CheckIfAvailable (false, true, false) ?? - WebSocket.CheckSendParameter (data); - - if (msg != null) { - _logger.Error (msg); - return; + if (_state != ServerState.Start) { + var msg = "The current state of the manager is not Start."; + throw new InvalidOperationException (msg); } - var bytes = data.UTF8Encode (); + if (data == null) + throw new ArgumentNullException ("data"); + + byte[] bytes; + if (!data.TryGetUTF8EncodedBytes (out bytes)) + throw new ArgumentException ("It could not be UTF-8-encoded.", "data"); + if (bytes.LongLength <= WebSocket.FragmentLength) broadcast (Opcode.Text, bytes, null); else From b22a230367c6daf6cee92cce99a5f5336000bb92 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 2 Apr 2017 17:43:12 +0900 Subject: [PATCH 1053/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServiceManager.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index f99ad7845..adada13d3 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -558,11 +558,21 @@ public void Broadcast (byte[] data) } /// - /// Sends text to every client in the WebSocket services. + /// Sends the specified to + /// every client in the WebSocket services. /// /// /// A that represents the text data to send. /// + /// + /// The current state of the manager is not Start. + /// + /// + /// is . + /// + /// + /// could not be UTF-8-encoded. + /// public void Broadcast (string data) { if (_state != ServerState.Start) { From d5fa6ad6110cbec10fc07bb81bcec25dc6c0c9cb Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 2 Apr 2017 17:47:43 +0900 Subject: [PATCH 1054/6294] [Modify] Throw exceptions --- websocket-sharp/Server/WebSocketServiceManager.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index adada13d3..b8b1ba5cd 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -609,14 +609,14 @@ public void Broadcast (string data) /// public void BroadcastAsync (byte[] data, Action completed) { - var msg = _state.CheckIfAvailable (false, true, false) ?? - WebSocket.CheckSendParameter (data); - - if (msg != null) { - _logger.Error (msg); - return; + if (_state != ServerState.Start) { + var msg = "The current state of the manager is not Start."; + throw new InvalidOperationException (msg); } + if (data == null) + throw new ArgumentNullException ("data"); + if (data.LongLength <= WebSocket.FragmentLength) broadcastAsync (Opcode.Binary, data, completed); else From 66ce1f401b588c5c09b026ed2d669d05dafa8394 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 3 Apr 2017 17:03:38 +0900 Subject: [PATCH 1055/6294] [Modify] Edit it --- .../Server/WebSocketServiceManager.cs | 25 ++++++++++++++----- 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index b8b1ba5cd..7ccd55bbb 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -594,19 +594,32 @@ public void Broadcast (string data) } /// - /// Sends binary asynchronously to every client in - /// the WebSocket services. + /// Sends the specified asynchronously to + /// every client in the WebSocket services. /// /// - /// This method doesn't wait for the send to be complete. + /// This method does not wait for the send to be complete. /// /// - /// An array of that represents the binary data to send. + /// An array of that represents + /// the binary data to send. /// /// - /// An delegate that references the method(s) called when - /// the send is complete. + /// + /// An delegate or + /// if not needed. + /// + /// + /// That delegate invokes the method called when + /// the send is complete. + /// /// + /// + /// The current state of the manager is not Start. + /// + /// + /// is . + /// public void BroadcastAsync (byte[] data, Action completed) { if (_state != ServerState.Start) { From 689e0600a6ff188572cf9823e739e2f0ed453ebf Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 3 Apr 2017 17:09:53 +0900 Subject: [PATCH 1056/6294] [Modify] Throw exceptions --- .../Server/WebSocketServiceManager.cs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index 7ccd55bbb..ba9eab5ae 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -652,15 +652,18 @@ public void BroadcastAsync (byte[] data, Action completed) /// public void BroadcastAsync (string data, Action completed) { - var msg = _state.CheckIfAvailable (false, true, false) ?? - WebSocket.CheckSendParameter (data); - - if (msg != null) { - _logger.Error (msg); - return; + if (_state != ServerState.Start) { + var msg = "The current state of the manager is not Start."; + throw new InvalidOperationException (msg); } - var bytes = data.UTF8Encode (); + if (data == null) + throw new ArgumentNullException ("data"); + + byte[] bytes; + if (!data.TryGetUTF8EncodedBytes (out bytes)) + throw new ArgumentException ("It could not be UTF-8-encoded.", "data"); + if (bytes.LongLength <= WebSocket.FragmentLength) broadcastAsync (Opcode.Text, bytes, completed); else From 18a165d6e4c4a7c8a00ae40fd57aedf129b630fe Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 3 Apr 2017 17:23:30 +0900 Subject: [PATCH 1057/6294] [Modify] Edit it --- .../Server/WebSocketServiceManager.cs | 25 +++++++++++++++---- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index ba9eab5ae..039d0977e 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -637,19 +637,34 @@ public void BroadcastAsync (byte[] data, Action completed) } /// - /// Sends text asynchronously to every client in - /// the WebSocket services. + /// Sends the specified asynchronously to + /// every client in the WebSocket services. /// /// - /// This method doesn't wait for the send to be complete. + /// This method does not wait for the send to be complete. /// /// /// A that represents the text data to send. /// /// - /// An delegate that references the method(s) called when - /// the send is complete. + /// + /// An delegate or + /// if not needed. + /// + /// + /// That delegate invokes the method called when + /// the send is complete. + /// /// + /// + /// The current state of the manager is not Start. + /// + /// + /// is . + /// + /// + /// could not be UTF-8-encoded. + /// public void BroadcastAsync (string data, Action completed) { if (_state != ServerState.Start) { From 0e9ec9bf89d79c6ac18cc3a56a0c39d66e2bae7d Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 4 Apr 2017 16:25:04 +0900 Subject: [PATCH 1058/6294] [Modify] Throw exceptions --- .../Server/WebSocketServiceManager.cs | 61 ++++++++++--------- 1 file changed, 32 insertions(+), 29 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index 039d0977e..78cedb1c9 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -704,36 +704,39 @@ public void BroadcastAsync (string data, Action completed) /// public void BroadcastAsync (Stream stream, int length, Action completed) { - var msg = _state.CheckIfAvailable (false, true, false) ?? - WebSocket.CheckSendParameters (stream, length); + if (_state != ServerState.Start) { + var msg = "The current state of the manager is not Start."; + throw new InvalidOperationException (msg); + } - if (msg != null) { - _logger.Error (msg); - return; - } - - stream.ReadBytesAsync ( - length, - data => { - var len = data.Length; - if (len == 0) { - _logger.Error ("The data cannot be read from 'stream'."); - return; - } - - if (len < length) - _logger.Warn ( - String.Format ( - "The data with 'length' cannot be read from 'stream':\n expected: {0}\n actual: {1}", - length, - len)); - - if (len <= WebSocket.FragmentLength) - broadcast (Opcode.Binary, data, completed); - else - broadcast (Opcode.Binary, new MemoryStream (data), completed); - }, - ex => _logger.Fatal (ex.ToString ())); + if (stream == null) + throw new ArgumentNullException ("stream"); + + if (!stream.CanRead) + throw new ArgumentException ("It cannot be read.", "stream"); + + if (length < 1) + throw new ArgumentException ("It is less than 1.", "length"); + + var bytes = stream.ReadBytes (length); + + var len = bytes.Length; + if (len == 0) + throw new ArgumentException ("No data could be read from it.", "stream"); + + if (len < length) { + _logger.Warn ( + String.Format ( + "Only {0} byte(s) of data could be read from the specified stream.", + len + ) + ); + } + + if (len <= WebSocket.FragmentLength) + broadcastAsync (Opcode.Binary, bytes, completed); + else + broadcastAsync (Opcode.Binary, new MemoryStream (bytes), completed); } /// From 8a04234df4b59113398e7c41959b326df2383d70 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 5 Apr 2017 16:04:31 +0900 Subject: [PATCH 1059/6294] [Modify] Edit it --- .../Server/WebSocketServiceManager.cs | 43 ++++++++++++++++--- 1 file changed, 37 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index 78cedb1c9..41a45d4bd 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -686,22 +686,53 @@ public void BroadcastAsync (string data, Action completed) } /// - /// Sends binary data from the specified asynchronously to + /// Sends the specified of data from + /// the specified asynchronously to /// every client in the WebSocket services. /// /// - /// This method doesn't wait for the send to be complete. + /// This method does not wait for the send to be complete. /// /// - /// A from which contains the binary data to send. + /// A from which reads the binary data to send. /// /// - /// An that represents the number of bytes to send. + /// An that specifies the number of bytes to + /// read and send. /// /// - /// An delegate that references the method(s) called when - /// the send is complete. + /// + /// An delegate or + /// if not needed. + /// + /// + /// That delegate invokes the method called when + /// the send is complete. + /// /// + /// + /// The current state of the manager is not Start. + /// + /// + /// is . + /// + /// + /// + /// cannot be read. + /// + /// + /// -or- + /// + /// + /// is less than 1. + /// + /// + /// -or- + /// + /// + /// No data could be read from . + /// + /// public void BroadcastAsync (Stream stream, int length, Action completed) { if (_state != ServerState.Start) { From b226de845551c7661318366d39eb6031dc2707c3 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 5 Apr 2017 16:31:30 +0900 Subject: [PATCH 1060/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketServiceManager.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index 41a45d4bd..011bfd46a 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -323,9 +323,11 @@ private void broadcastAsync (Opcode opcode, Stream stream, Action completed) } private Dictionary> broadping ( - byte[] frameAsBytes, TimeSpan timeout) + byte[] frameAsBytes, TimeSpan timeout + ) { var ret = new Dictionary> (); + foreach (var host in Hosts) { if (_state != ServerState.Start) break; From 1383bd62926628be73f75b59de7df5a4b2eb32ac Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 5 Apr 2017 16:46:13 +0900 Subject: [PATCH 1061/6294] [Modify] Throw exception --- websocket-sharp/Server/WebSocketServiceManager.cs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index 011bfd46a..afb8d8811 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -783,10 +783,9 @@ public void BroadcastAsync (Stream stream, int length, Action completed) /// public Dictionary> Broadping () { - var msg = _state.CheckIfAvailable (false, true, false); - if (msg != null) { - _logger.Error (msg); - return null; + if (_state != ServerState.Start) { + var msg = "The current state of the manager is not Start."; + throw new InvalidOperationException (msg); } return broadping (WebSocketFrame.EmptyPingBytes, _waitTime); From 6cc77601dde32932401fa03dd2cf44faab778651 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 6 Apr 2017 17:04:11 +0900 Subject: [PATCH 1062/6294] [Modify] Edit it --- .../Server/WebSocketServiceManager.cs | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index afb8d8811..b42aed685 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -773,14 +773,22 @@ public void BroadcastAsync (Stream stream, int length, Action completed) } /// - /// Sends a Ping to every client in the WebSocket services. + /// Sends a ping to every client in the WebSocket services. /// /// - /// A Dictionary<string, Dictionary<string, bool>> that contains - /// a collection of pairs of a service path and a collection of pairs of a session ID - /// and a value indicating whether the manager received a Pong from each client in a time, - /// or if this method isn't available. + /// + /// A Dictionary<string, Dictionary<string, bool>>. + /// + /// + /// It contains a collection of pairs of a service path and + /// another collection of pairs of a session ID and a value + /// indicating whether a pong has been received within a time + /// from a client. + /// /// + /// + /// The current state of the manager is not Start. + /// public Dictionary> Broadping () { if (_state != ServerState.Start) { From 4d510902b885244db53f9cce79b37dfa85b39b36 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 6 Apr 2017 17:21:14 +0900 Subject: [PATCH 1063/6294] [Modify] Throw exceptions --- .../Server/WebSocketServiceManager.cs | 26 ++++++++++++------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index b42aed685..152cd0841 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -815,19 +815,27 @@ public Dictionary> Broadping () /// public Dictionary> Broadping (string message) { - if (message == null || message.Length == 0) - return Broadping (); + if (_state != ServerState.Start) { + var msg = "The current state of the manager is not Start."; + throw new InvalidOperationException (msg); + } - byte[] data = null; - var msg = _state.CheckIfAvailable (false, true, false) ?? - WebSocket.CheckPingParameter (message, out data); + if (message == null) + throw new ArgumentNullException ("message"); + + byte[] bytes; + if (!message.TryGetUTF8EncodedBytes (out bytes)) { + var msg = "It could not be UTF-8-encoded."; + throw new ArgumentException (msg, "message"); + } - if (msg != null) { - _logger.Error (msg); - return null; + if (bytes.Length > 125) { + var msg = "Its size is greater than 125 bytes."; + throw new ArgumentOutOfRangeException ("message", msg); } - return broadping (WebSocketFrame.CreatePingFrame (data, false).ToArray (), _waitTime); + var frame = WebSocketFrame.CreatePingFrame (bytes, false); + return broadping (frame.ToArray (), _waitTime); } /// From 15cb9cd1589f3ef28b962896de5dc3e5a5cf9fdb Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 7 Apr 2017 16:37:18 +0900 Subject: [PATCH 1064/6294] [Modify] Edit it --- .../Server/WebSocketServiceManager.cs | 31 ++++++++++++++----- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index 152cd0841..4b22248c1 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -800,19 +800,36 @@ public Dictionary> Broadping () } /// - /// Sends a Ping with the specified to every client in - /// the WebSocket services. + /// Sends a ping with the specified to + /// every client in the WebSocket services. /// /// - /// A Dictionary<string, Dictionary<string, bool>> that contains - /// a collection of pairs of a service path and a collection of pairs of a session ID - /// and a value indicating whether the manager received a Pong from each client in a time, - /// or if this method isn't available or - /// is invalid. + /// + /// A Dictionary<string, Dictionary<string, bool>>. + /// + /// + /// It contains a collection of pairs of a service path and + /// another collection of pairs of a session ID and a value + /// indicating whether a pong has been received within a time + /// from a client. + /// /// /// /// A that represents the message to send. + /// The size must be 125 bytes or less in UTF-8. /// + /// + /// The current state of the manager is not Start. + /// + /// + /// is . + /// + /// + /// could not be UTF-8-encoded. + /// + /// + /// The size of is greater than 125 bytes. + /// public Dictionary> Broadping (string message) { if (_state != ServerState.Start) { From 00b6319589e56f502bd9007fab2f4f9a3e442179 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 8 Apr 2017 16:47:13 +0900 Subject: [PATCH 1065/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketServiceManager.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index 4b22248c1..a1ed50fa0 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -280,7 +280,8 @@ private void broadcast (Opcode opcode, byte[] data, Action completed) completed (); } catch (Exception ex) { - _logger.Fatal (ex.ToString ()); + _logger.Error (ex.Message); + _logger.Debug (ex.ToString ()); } finally { cache.Clear (); From afa1fd716de964be70210a762d7f00eb772606e9 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 8 Apr 2017 16:51:05 +0900 Subject: [PATCH 1066/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketServiceManager.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index a1ed50fa0..5e4b49388 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -303,7 +303,8 @@ private void broadcast (Opcode opcode, Stream stream, Action completed) completed (); } catch (Exception ex) { - _logger.Fatal (ex.ToString ()); + _logger.Error (ex.Message); + _logger.Debug (ex.ToString ()); } finally { foreach (var cached in cache.Values) From 196daac39cf2ae435c9166f95e367b82222bf9e0 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 9 Apr 2017 15:34:28 +0900 Subject: [PATCH 1067/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketServiceManager.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index 5e4b49388..2046c6d40 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -316,7 +316,9 @@ private void broadcast (Opcode opcode, Stream stream, Action completed) private void broadcastAsync (Opcode opcode, byte[] data, Action completed) { - ThreadPool.QueueUserWorkItem (state => broadcast (opcode, data, completed)); + ThreadPool.QueueUserWorkItem ( + state => broadcast (opcode, data, completed) + ); } private void broadcastAsync (Opcode opcode, Stream stream, Action completed) From db978ec5da56ea6df75fdcc08ff5d4826bb3ff4c Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 9 Apr 2017 15:36:26 +0900 Subject: [PATCH 1068/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketServiceManager.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index 2046c6d40..be99eaa71 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -323,7 +323,9 @@ private void broadcastAsync (Opcode opcode, byte[] data, Action completed) private void broadcastAsync (Opcode opcode, Stream stream, Action completed) { - ThreadPool.QueueUserWorkItem (state => broadcast (opcode, stream, completed)); + ThreadPool.QueueUserWorkItem ( + state => broadcast (opcode, stream, completed) + ); } private Dictionary> broadping ( From e17e9adf2f1a43bfda1dd2023b7c9367add8c33e Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 10 Apr 2017 14:04:30 +0900 Subject: [PATCH 1069/6294] [Modify] It will be removed --- websocket-sharp/Server/WebSocketServiceManager.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index be99eaa71..86d722957 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -549,6 +549,7 @@ public void AddService ( /// /// is . /// + [Obsolete ("This method will be removed.")] public void Broadcast (byte[] data) { if (_state != ServerState.Start) { From 2ef6af69fed86eee32c0fc5e7557119395a823c7 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 10 Apr 2017 14:10:19 +0900 Subject: [PATCH 1070/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketServiceManager.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index 86d722957..a60359ea0 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -593,8 +593,10 @@ public void Broadcast (string data) throw new ArgumentNullException ("data"); byte[] bytes; - if (!data.TryGetUTF8EncodedBytes (out bytes)) - throw new ArgumentException ("It could not be UTF-8-encoded.", "data"); + if (!data.TryGetUTF8EncodedBytes (out bytes)) { + var msg = "It could not be UTF-8-encoded."; + throw new ArgumentException (msg, "data"); + } if (bytes.LongLength <= WebSocket.FragmentLength) broadcast (Opcode.Text, bytes, null); From e3b86b56275b14a3091b90195bc16efc74ec192d Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 10 Apr 2017 14:12:58 +0900 Subject: [PATCH 1071/6294] [Modify] It will be removed --- websocket-sharp/Server/WebSocketServiceManager.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index a60359ea0..7ee520380 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -582,6 +582,7 @@ public void Broadcast (byte[] data) /// /// could not be UTF-8-encoded. /// + [Obsolete ("This method will be removed.")] public void Broadcast (string data) { if (_state != ServerState.Start) { From d005fd9789677d1a413f116490d04f070dd36b9f Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 10 Apr 2017 14:15:40 +0900 Subject: [PATCH 1072/6294] [Modify] It will be removed --- websocket-sharp/Server/WebSocketServiceManager.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index 7ee520380..b04e55427 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -632,6 +632,7 @@ public void Broadcast (string data) /// /// is . /// + [Obsolete ("This method will be removed.")] public void BroadcastAsync (byte[] data, Action completed) { if (_state != ServerState.Start) { From 1a3e67fc9dd9327759128a2d76cc2ee8fe06813e Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 10 Apr 2017 14:19:20 +0900 Subject: [PATCH 1073/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketServiceManager.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index b04e55427..02b4bf212 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -689,8 +689,10 @@ public void BroadcastAsync (string data, Action completed) throw new ArgumentNullException ("data"); byte[] bytes; - if (!data.TryGetUTF8EncodedBytes (out bytes)) - throw new ArgumentException ("It could not be UTF-8-encoded.", "data"); + if (!data.TryGetUTF8EncodedBytes (out bytes)) { + var msg = "It could not be UTF-8-encoded."; + throw new ArgumentException (msg, "data"); + } if (bytes.LongLength <= WebSocket.FragmentLength) broadcastAsync (Opcode.Text, bytes, completed); From 7ac427d7a683df5f56883ac51523842a960aa2ed Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 10 Apr 2017 14:22:00 +0900 Subject: [PATCH 1074/6294] [Modify] It will be removed --- websocket-sharp/Server/WebSocketServiceManager.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index 02b4bf212..675b7ac2b 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -678,6 +678,7 @@ public void BroadcastAsync (byte[] data, Action completed) /// /// could not be UTF-8-encoded. /// + [Obsolete ("This method will be removed.")] public void BroadcastAsync (string data, Action completed) { if (_state != ServerState.Start) { From 822b9eb6f4429532698d01d590c82883a6f38b73 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 11 Apr 2017 17:23:28 +0900 Subject: [PATCH 1075/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketServiceManager.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index 675b7ac2b..aee8aeb9d 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -768,8 +768,10 @@ public void BroadcastAsync (Stream stream, int length, Action completed) var bytes = stream.ReadBytes (length); var len = bytes.Length; - if (len == 0) - throw new ArgumentException ("No data could be read from it.", "stream"); + if (len == 0) { + var msg = "No data could be read from it."; + throw new ArgumentException (msg, "stream"); + } if (len < length) { _logger.Warn ( From 5f47418444c301186f2296c38b4e7a2326bc7187 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 11 Apr 2017 17:46:19 +0900 Subject: [PATCH 1076/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServiceManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index aee8aeb9d..a3ecd7b3f 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -710,7 +710,7 @@ public void BroadcastAsync (string data, Action completed) /// This method does not wait for the send to be complete. /// /// - /// A from which reads the binary data to send. + /// A from which to read the binary data to send. /// /// /// An that specifies the number of bytes to From 90bbd6ba95109dd281d0e588710ead352602012c Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 11 Apr 2017 17:53:57 +0900 Subject: [PATCH 1077/6294] [Modify] It will be removed --- websocket-sharp/Server/WebSocketServiceManager.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index a3ecd7b3f..c837a1779 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -749,6 +749,7 @@ public void BroadcastAsync (string data, Action completed) /// No data could be read from . /// /// + [Obsolete ("This method will be removed.")] public void BroadcastAsync (Stream stream, int length, Action completed) { if (_state != ServerState.Start) { From 1c63b4ba72c33ef3c75bdc8756f4fb883868a9b6 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 12 Apr 2017 15:30:26 +0900 Subject: [PATCH 1078/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServiceManager.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index c837a1779..a4dff536c 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -797,10 +797,10 @@ public void BroadcastAsync (Stream stream, int length, Action completed) /// A Dictionary<string, Dictionary<string, bool>>. /// /// - /// It contains a collection of pairs of a service path and + /// It represents a collection of pairs of a service path and /// another collection of pairs of a session ID and a value /// indicating whether a pong has been received within a time - /// from a client. + /// from its client. /// /// /// From 0223b606e8feaf7a173897f5abaebb41ed9008c6 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 12 Apr 2017 15:32:26 +0900 Subject: [PATCH 1079/6294] [Modify] It will be removed --- websocket-sharp/Server/WebSocketServiceManager.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index a4dff536c..707de74fe 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -806,6 +806,7 @@ public void BroadcastAsync (Stream stream, int length, Action completed) /// /// The current state of the manager is not Start. /// + [Obsolete ("This method will be removed.")] public Dictionary> Broadping () { if (_state != ServerState.Start) { From fac4af744bf0367f5d6e9f87031e6cf2289ec808 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 13 Apr 2017 16:20:42 +0900 Subject: [PATCH 1080/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServiceManager.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index 707de74fe..e8a105daf 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -826,14 +826,14 @@ public Dictionary> Broadping () /// A Dictionary<string, Dictionary<string, bool>>. /// /// - /// It contains a collection of pairs of a service path and + /// It represents a collection of pairs of a service path and /// another collection of pairs of a session ID and a value /// indicating whether a pong has been received within a time - /// from a client. + /// from its client. /// /// /// - /// A that represents the message to send. + /// A that represents a message to send. /// The size must be 125 bytes or less in UTF-8. /// /// From 07758992a530b9d40d3d8c6af5e3d3abd3cfda72 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 13 Apr 2017 16:23:46 +0900 Subject: [PATCH 1081/6294] [Modify] It will be removed --- websocket-sharp/Server/WebSocketServiceManager.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index e8a105daf..8028e4191 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -848,6 +848,7 @@ public Dictionary> Broadping () /// /// The size of is greater than 125 bytes. /// + [Obsolete ("This method will be removed.")] public Dictionary> Broadping (string message) { if (_state != ServerState.Start) { From 9d8ed6987b81eea71a3d3ef919935675c1e71e4e Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 13 Apr 2017 17:15:26 +0900 Subject: [PATCH 1082/6294] [Modify] Remove it --- websocket-sharp/Server/WebSocketServiceManager.cs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index 8028e4191..6c30383e6 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -58,11 +58,6 @@ public class WebSocketServiceManager #region Internal Constructors - internal WebSocketServiceManager () - : this (new Logger ()) - { - } - internal WebSocketServiceManager (Logger logger) { _logger = logger; From 94dcb5c5a8ca487d9901ad862d35aec51ecaa1ae Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 14 Apr 2017 17:24:52 +0900 Subject: [PATCH 1083/6294] [Modify] Rename them --- .../Server/WebSocketServiceManager.cs | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index 6c30383e6..118525513 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -49,7 +49,7 @@ public class WebSocketServiceManager private volatile bool _clean; private Dictionary _hosts; - private Logger _logger; + private Logger _log; private volatile ServerState _state; private object _sync; private TimeSpan _waitTime; @@ -58,9 +58,9 @@ public class WebSocketServiceManager #region Internal Constructors - internal WebSocketServiceManager (Logger logger) + internal WebSocketServiceManager (Logger log) { - _logger = logger; + _log = log; _clean = true; _hosts = new Dictionary (); @@ -275,8 +275,8 @@ private void broadcast (Opcode opcode, byte[] data, Action completed) completed (); } catch (Exception ex) { - _logger.Error (ex.Message); - _logger.Debug (ex.ToString ()); + _log.Error (ex.Message); + _log.Debug (ex.ToString ()); } finally { cache.Clear (); @@ -298,8 +298,8 @@ private void broadcast (Opcode opcode, Stream stream, Action completed) completed (); } catch (Exception ex) { - _logger.Error (ex.Message); - _logger.Debug (ex.ToString ()); + _log.Error (ex.Message); + _log.Debug (ex.ToString ()); } finally { foreach (var cached in cache.Values) @@ -354,7 +354,7 @@ internal void Add (string path, Func creator) throw new ArgumentException ("Already in use.", "path"); host = new WebSocketServiceHost ( - path, creator, null, _logger + path, creator, null, _log ); if (!_clean) @@ -514,7 +514,7 @@ public void AddService ( throw new ArgumentException ("Already in use.", "path"); host = new WebSocketServiceHost ( - path, () => new TBehavior (), initializer, _logger + path, () => new TBehavior (), initializer, _log ); if (!_clean) @@ -770,7 +770,7 @@ public void BroadcastAsync (Stream stream, int length, Action completed) } if (len < length) { - _logger.Warn ( + _log.Warn ( String.Format ( "Only {0} byte(s) of data could be read from the specified stream.", len From 30f51b0d0f7debf39288a4eaee0a3c9a8df41001 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 15 Apr 2017 17:52:58 +0900 Subject: [PATCH 1084/6294] [Modify] Add it --- .../Server/WebSocketServiceManager.cs | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index 118525513..1915fb544 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -869,6 +869,28 @@ public Dictionary> Broadping (string message) return broadping (frame.ToArray (), _waitTime); } + /// + /// Removes all WebSocket services managed by the manager. + /// + /// + /// A service is stopped with close status 1001 (going away) + /// if it has already started. + /// + public void Clear () + { + List hosts = null; + + lock (_sync) { + hosts = _hosts.Values.ToList (); + _hosts.Clear (); + } + + foreach (var host in hosts) { + if (host.State == ServerState.Start) + host.Stop (1001, String.Empty); + } + } + /// /// Removes a WebSocket service with the specified . /// From 9fed7a951d3b8cf82f4ff13b5df3990de9d4a999 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 16 Apr 2017 17:36:25 +0900 Subject: [PATCH 1085/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServiceManager.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index 1915fb544..db261d45e 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -451,9 +451,14 @@ internal void Stop (CloseEventArgs e, bool send, bool receive) /// the service to add. /// /// - /// An Action<TBehavior> delegate that invokes - /// the method used to initialize a new session instance for - /// the service or if not needed. + /// + /// An Action<TBehavior> delegate or + /// if not needed. + /// + /// + /// That delegate invokes the method called when initializing + /// a new session instance for the service. + /// /// /// /// The type of the behavior for the service. It must inherit From e92870614070a2cbb27ebbcf62e399a4e309b39a Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 17 Apr 2017 15:16:09 +0900 Subject: [PATCH 1086/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 77d3f25c0..221b29602 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -1025,10 +1025,17 @@ private static bool tryCreateUri ( /// the service to add. /// /// - /// A Func<TBehavior> delegate that invokes - /// the method used to create a new session instance for - /// the service. The method must create a new instance of - /// the specified behavior class and return it. + /// + /// A Func<TBehavior> delegate. + /// + /// + /// It invokes the method called for creating + /// a new session instance for the service. + /// + /// + /// The method must create a new instance of + /// the specified behavior class and return it. + /// /// /// /// The type of the behavior for the service. It must inherit From d38849a3af8aac6cc0ad2f9082c4700794fde44f Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 17 Apr 2017 15:20:03 +0900 Subject: [PATCH 1087/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServiceManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index db261d45e..33da9842e 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -456,7 +456,7 @@ internal void Stop (CloseEventArgs e, bool send, bool receive) /// if not needed. /// /// - /// That delegate invokes the method called when initializing + /// That delegate invokes the method called for initializing /// a new session instance for the service. /// /// From eb14db462899e9e7b2f34c33910fd37518ed6300 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 18 Apr 2017 16:19:03 +0900 Subject: [PATCH 1088/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 221b29602..f83b3f2f5 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -1165,9 +1165,14 @@ public void AddWebSocketService (string path) /// the service to add. /// /// - /// An Action<TBehaviorWithNew> delegate that invokes - /// the method used to initialize a new session instance for - /// the service or if not needed. + /// + /// An Action<TBehaviorWithNew> delegate or + /// if not needed. + /// + /// + /// That delegate invokes the method called for initializing + /// a new session instance for the service. + /// /// /// /// The type of the behavior for the service. It must inherit From 8dadc6bc09476abf1838fe91068ae57e7236a396 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 19 Apr 2017 18:24:43 +0900 Subject: [PATCH 1089/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index f83b3f2f5..92b074955 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -590,17 +590,22 @@ public ServerSslConfiguration SslConfiguration { } /// - /// Gets or sets the delegate called to find the credentials for - /// an identity used to authenticate a client. + /// Gets or sets the delegate used to find the credentials for an identity. /// /// /// The set operation does nothing if the server has already started or /// it is shutting down. /// /// - /// A Func<IIdentity, NetworkCredential> delegate - /// that invokes the method used to find the credentials or - /// by default. + /// + /// A Func<IIdentity, NetworkCredential> delegate or + /// if not needed. The default value is + /// . + /// + /// + /// That delegate invokes the method called for finding + /// the credentials used to authenticate a client. + /// /// public Func UserCredentialsFinder { get { From a8f8e84dfdc41f60860f05cdee4226bf3b4b6b4e Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 20 Apr 2017 14:41:50 +0900 Subject: [PATCH 1090/6294] [Modify] Edit it --- websocket-sharp/Net/HttpBasicIdentity.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpBasicIdentity.cs b/websocket-sharp/Net/HttpBasicIdentity.cs index d55cd9f2b..d32519d4b 100644 --- a/websocket-sharp/Net/HttpBasicIdentity.cs +++ b/websocket-sharp/Net/HttpBasicIdentity.cs @@ -43,7 +43,7 @@ namespace WebSocketSharp.Net { /// - /// Holds the user name and password from the HTTP Basic authentication credentials. + /// Holds the username and password from an HTTP Basic authentication attempt. /// public class HttpBasicIdentity : GenericIdentity { From c9679e42edf1f4984d344e14800efab6f2381854 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 20 Apr 2017 14:50:00 +0900 Subject: [PATCH 1091/6294] [Modify] Edit it --- websocket-sharp/Net/HttpBasicIdentity.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpBasicIdentity.cs b/websocket-sharp/Net/HttpBasicIdentity.cs index d32519d4b..671d020c7 100644 --- a/websocket-sharp/Net/HttpBasicIdentity.cs +++ b/websocket-sharp/Net/HttpBasicIdentity.cs @@ -66,7 +66,7 @@ internal HttpBasicIdentity (string username, string password) #region Public Properties /// - /// Gets the password from the HTTP Basic authentication credentials. + /// Gets the password from an HTTP Basic authentication attempt. /// /// /// A that represents the password. From b278c0b6d2a9f84a7a26b868475f7fe8bd008b35 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 20 Apr 2017 14:54:53 +0900 Subject: [PATCH 1092/6294] [Modify] Polish it --- websocket-sharp/Net/HttpBasicIdentity.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpBasicIdentity.cs b/websocket-sharp/Net/HttpBasicIdentity.cs index 671d020c7..af0fb015d 100644 --- a/websocket-sharp/Net/HttpBasicIdentity.cs +++ b/websocket-sharp/Net/HttpBasicIdentity.cs @@ -53,7 +53,7 @@ public class HttpBasicIdentity : GenericIdentity #endregion - #region internal Constructors + #region Internal Constructors internal HttpBasicIdentity (string username, string password) : base (username, "Basic") From 960a4a07bb4c6d3899a18200d85f8a08df3dd076 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 20 Apr 2017 15:02:36 +0900 Subject: [PATCH 1093/6294] [Modify] Edit it --- websocket-sharp/Net/HttpBasicIdentity.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpBasicIdentity.cs b/websocket-sharp/Net/HttpBasicIdentity.cs index af0fb015d..22d18f1b6 100644 --- a/websocket-sharp/Net/HttpBasicIdentity.cs +++ b/websocket-sharp/Net/HttpBasicIdentity.cs @@ -2,8 +2,8 @@ /* * HttpBasicIdentity.cs * - * This code is derived from System.Net.HttpListenerBasicIdentity.cs of Mono - * (http://www.mono-project.com). + * This code is derived from HttpListenerBasicIdentity.cs (System.Net) of + * Mono (http://www.mono-project.com). * * The MIT License * From 8628ea2e8226a4a46e984eb62c67f00a3a0a2f37 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 20 Apr 2017 15:04:38 +0900 Subject: [PATCH 1094/6294] [Modify] 2017 --- websocket-sharp/Net/HttpBasicIdentity.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpBasicIdentity.cs b/websocket-sharp/Net/HttpBasicIdentity.cs index 22d18f1b6..5ece5dccc 100644 --- a/websocket-sharp/Net/HttpBasicIdentity.cs +++ b/websocket-sharp/Net/HttpBasicIdentity.cs @@ -8,7 +8,7 @@ * The MIT License * * Copyright (c) 2005 Novell, Inc. (http://www.novell.com) - * Copyright (c) 2014 sta.blockhead + * Copyright (c) 2014-2017 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From d23693d8781654c0d0059f49d39bb3d6827a9736 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 20 Apr 2017 15:17:59 +0900 Subject: [PATCH 1095/6294] [Modify] Edit it --- websocket-sharp/Net/HttpDigestIdentity.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpDigestIdentity.cs b/websocket-sharp/Net/HttpDigestIdentity.cs index caa471aa0..8bffe466d 100644 --- a/websocket-sharp/Net/HttpDigestIdentity.cs +++ b/websocket-sharp/Net/HttpDigestIdentity.cs @@ -33,7 +33,8 @@ namespace WebSocketSharp.Net { /// - /// Holds the user name and other parameters from the HTTP Digest authentication credentials. + /// Holds the username and other parameters from + /// an HTTP Digest authentication attempt. /// public class HttpDigestIdentity : GenericIdentity { From 131ba06bc6681e3ffe4fdf27ea58b14a5e08edfd Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 20 Apr 2017 15:24:48 +0900 Subject: [PATCH 1096/6294] [Modify] Edit it --- websocket-sharp/Net/HttpDigestIdentity.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpDigestIdentity.cs b/websocket-sharp/Net/HttpDigestIdentity.cs index 8bffe466d..8ae28f5b9 100644 --- a/websocket-sharp/Net/HttpDigestIdentity.cs +++ b/websocket-sharp/Net/HttpDigestIdentity.cs @@ -57,7 +57,7 @@ internal HttpDigestIdentity (NameValueCollection parameters) #region Public Properties /// - /// Gets the algorithm parameter from the HTTP Digest authentication credentials. + /// Gets the algorithm parameter from a digest authentication attempt. /// /// /// A that represents the algorithm parameter. From f63d005b6377c73c75a43363578e9ceed528d45f Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 20 Apr 2017 15:27:03 +0900 Subject: [PATCH 1097/6294] [Modify] Edit it --- websocket-sharp/Net/HttpDigestIdentity.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpDigestIdentity.cs b/websocket-sharp/Net/HttpDigestIdentity.cs index 8ae28f5b9..db03b807c 100644 --- a/websocket-sharp/Net/HttpDigestIdentity.cs +++ b/websocket-sharp/Net/HttpDigestIdentity.cs @@ -69,7 +69,7 @@ public string Algorithm { } /// - /// Gets the cnonce parameter from the HTTP Digest authentication credentials. + /// Gets the cnonce parameter from a digest authentication attempt. /// /// /// A that represents the cnonce parameter. From 6e40c7d976a6f4b79d09adf27dc7f3387a7f5ea9 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 20 Apr 2017 15:31:05 +0900 Subject: [PATCH 1098/6294] [Modify] Edit it --- websocket-sharp/Net/HttpDigestIdentity.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpDigestIdentity.cs b/websocket-sharp/Net/HttpDigestIdentity.cs index db03b807c..f7267194f 100644 --- a/websocket-sharp/Net/HttpDigestIdentity.cs +++ b/websocket-sharp/Net/HttpDigestIdentity.cs @@ -81,7 +81,7 @@ public string Cnonce { } /// - /// Gets the nc parameter from the HTTP Digest authentication credentials. + /// Gets the nc parameter from a digest authentication attempt. /// /// /// A that represents the nc parameter. From a3a87f896e6a4ad209f23e84c3d97fb0a9f189b3 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 20 Apr 2017 15:32:53 +0900 Subject: [PATCH 1099/6294] [Modify] Edit it --- websocket-sharp/Net/HttpDigestIdentity.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpDigestIdentity.cs b/websocket-sharp/Net/HttpDigestIdentity.cs index f7267194f..a286cefc7 100644 --- a/websocket-sharp/Net/HttpDigestIdentity.cs +++ b/websocket-sharp/Net/HttpDigestIdentity.cs @@ -93,7 +93,7 @@ public string Nc { } /// - /// Gets the nonce parameter from the HTTP Digest authentication credentials. + /// Gets the nonce parameter from a digest authentication attempt. /// /// /// A that represents the nonce parameter. From fa43ecc1841c6b40c3ff7633cfbdf2c66bcfd7b3 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 20 Apr 2017 15:34:37 +0900 Subject: [PATCH 1100/6294] [Modify] Edit it --- websocket-sharp/Net/HttpDigestIdentity.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpDigestIdentity.cs b/websocket-sharp/Net/HttpDigestIdentity.cs index a286cefc7..9d8d6653d 100644 --- a/websocket-sharp/Net/HttpDigestIdentity.cs +++ b/websocket-sharp/Net/HttpDigestIdentity.cs @@ -105,7 +105,7 @@ public string Nonce { } /// - /// Gets the opaque parameter from the HTTP Digest authentication credentials. + /// Gets the opaque parameter from a digest authentication attempt. /// /// /// A that represents the opaque parameter. From 035ac9148f68ab8dffad30e441190e6f1d5deb3f Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 20 Apr 2017 15:36:32 +0900 Subject: [PATCH 1101/6294] [Modify] Edit it --- websocket-sharp/Net/HttpDigestIdentity.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpDigestIdentity.cs b/websocket-sharp/Net/HttpDigestIdentity.cs index 9d8d6653d..6f76582f7 100644 --- a/websocket-sharp/Net/HttpDigestIdentity.cs +++ b/websocket-sharp/Net/HttpDigestIdentity.cs @@ -117,7 +117,7 @@ public string Opaque { } /// - /// Gets the qop parameter from the HTTP Digest authentication credentials. + /// Gets the qop parameter from a digest authentication attempt. /// /// /// A that represents the qop parameter. From 210a79c082f19cc2285227b6ec2a4918d3a952d8 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 20 Apr 2017 15:38:11 +0900 Subject: [PATCH 1102/6294] [Modify] Edit it --- websocket-sharp/Net/HttpDigestIdentity.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpDigestIdentity.cs b/websocket-sharp/Net/HttpDigestIdentity.cs index 6f76582f7..2307c6d40 100644 --- a/websocket-sharp/Net/HttpDigestIdentity.cs +++ b/websocket-sharp/Net/HttpDigestIdentity.cs @@ -129,7 +129,7 @@ public string Qop { } /// - /// Gets the realm parameter from the HTTP Digest authentication credentials. + /// Gets the realm parameter from a digest authentication attempt. /// /// /// A that represents the realm parameter. From 49bb56ff2c5234410a4c0864412a0e442453b9e1 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 20 Apr 2017 15:40:56 +0900 Subject: [PATCH 1103/6294] [Modify] Edit it --- websocket-sharp/Net/HttpDigestIdentity.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpDigestIdentity.cs b/websocket-sharp/Net/HttpDigestIdentity.cs index 2307c6d40..004aaa099 100644 --- a/websocket-sharp/Net/HttpDigestIdentity.cs +++ b/websocket-sharp/Net/HttpDigestIdentity.cs @@ -141,7 +141,7 @@ public string Realm { } /// - /// Gets the response parameter from the HTTP Digest authentication credentials. + /// Gets the response parameter from a digest authentication attempt. /// /// /// A that represents the response parameter. From 0c1d10d60e3423ed898a3fccd5c89455d88e38ec Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 20 Apr 2017 15:42:45 +0900 Subject: [PATCH 1104/6294] [Modify] Edit it --- websocket-sharp/Net/HttpDigestIdentity.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpDigestIdentity.cs b/websocket-sharp/Net/HttpDigestIdentity.cs index 004aaa099..17a1df005 100644 --- a/websocket-sharp/Net/HttpDigestIdentity.cs +++ b/websocket-sharp/Net/HttpDigestIdentity.cs @@ -153,7 +153,7 @@ public string Response { } /// - /// Gets the uri parameter from the HTTP Digest authentication credentials. + /// Gets the uri parameter from a digest authentication attempt. /// /// /// A that represents the uri parameter. From ac311e775942d604a9fc9d9c0aa68cf3cafb3a23 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 21 Apr 2017 17:39:22 +0900 Subject: [PATCH 1105/6294] [Modify] Polish it --- websocket-sharp/Net/HttpDigestIdentity.cs | 30 +++++++++++------------ 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/websocket-sharp/Net/HttpDigestIdentity.cs b/websocket-sharp/Net/HttpDigestIdentity.cs index 17a1df005..7159dcacf 100644 --- a/websocket-sharp/Net/HttpDigestIdentity.cs +++ b/websocket-sharp/Net/HttpDigestIdentity.cs @@ -47,7 +47,7 @@ public class HttpDigestIdentity : GenericIdentity #region Internal Constructors internal HttpDigestIdentity (NameValueCollection parameters) - : base (parameters ["username"], "Digest") + : base (parameters["username"], "Digest") { _parameters = parameters; } @@ -64,7 +64,7 @@ internal HttpDigestIdentity (NameValueCollection parameters) /// public string Algorithm { get { - return _parameters ["algorithm"]; + return _parameters["algorithm"]; } } @@ -76,7 +76,7 @@ public string Algorithm { /// public string Cnonce { get { - return _parameters ["cnonce"]; + return _parameters["cnonce"]; } } @@ -88,7 +88,7 @@ public string Cnonce { /// public string Nc { get { - return _parameters ["nc"]; + return _parameters["nc"]; } } @@ -100,7 +100,7 @@ public string Nc { /// public string Nonce { get { - return _parameters ["nonce"]; + return _parameters["nonce"]; } } @@ -112,7 +112,7 @@ public string Nonce { /// public string Opaque { get { - return _parameters ["opaque"]; + return _parameters["opaque"]; } } @@ -124,7 +124,7 @@ public string Opaque { /// public string Qop { get { - return _parameters ["qop"]; + return _parameters["qop"]; } } @@ -136,7 +136,7 @@ public string Qop { /// public string Realm { get { - return _parameters ["realm"]; + return _parameters["realm"]; } } @@ -148,7 +148,7 @@ public string Realm { /// public string Response { get { - return _parameters ["response"]; + return _parameters["response"]; } } @@ -160,7 +160,7 @@ public string Response { /// public string Uri { get { - return _parameters ["uri"]; + return _parameters["uri"]; } } @@ -171,12 +171,12 @@ public string Uri { internal bool IsValid (string password, string realm, string method, string entity) { var parameters = new NameValueCollection (_parameters); - parameters ["password"] = password; - parameters ["realm"] = realm; - parameters ["method"] = method; - parameters ["entity"] = entity; + parameters["password"] = password; + parameters["realm"] = realm; + parameters["method"] = method; + parameters["entity"] = entity; - return _parameters ["response"] == AuthenticationResponse.CreateRequestDigest (parameters); + return _parameters["response"] == AuthenticationResponse.CreateRequestDigest (parameters); } #endregion From a3115d116125fa411586eb5d35b5b4902de764c1 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 22 Apr 2017 18:24:23 +0900 Subject: [PATCH 1106/6294] [Modify] Polish it --- websocket-sharp/Net/HttpDigestIdentity.cs | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/websocket-sharp/Net/HttpDigestIdentity.cs b/websocket-sharp/Net/HttpDigestIdentity.cs index 7159dcacf..99426eb87 100644 --- a/websocket-sharp/Net/HttpDigestIdentity.cs +++ b/websocket-sharp/Net/HttpDigestIdentity.cs @@ -168,15 +168,18 @@ public string Uri { #region Internal Methods - internal bool IsValid (string password, string realm, string method, string entity) + internal bool IsValid ( + string password, string realm, string method, string entity + ) { - var parameters = new NameValueCollection (_parameters); - parameters["password"] = password; - parameters["realm"] = realm; - parameters["method"] = method; - parameters["entity"] = entity; - - return _parameters["response"] == AuthenticationResponse.CreateRequestDigest (parameters); + var copied = new NameValueCollection (_parameters); + copied["password"] = password; + copied["realm"] = realm; + copied["method"] = method; + copied["entity"] = entity; + + var expected = AuthenticationResponse.CreateRequestDigest (copied); + return _parameters["response"] == expected; } #endregion From 7a6b73f63ee992a22a935f37919ab5cea6c19b2f Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 23 Apr 2017 18:29:17 +0900 Subject: [PATCH 1107/6294] [Modify] 2017 --- websocket-sharp/Net/HttpDigestIdentity.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpDigestIdentity.cs b/websocket-sharp/Net/HttpDigestIdentity.cs index 99426eb87..68ec86d9f 100644 --- a/websocket-sharp/Net/HttpDigestIdentity.cs +++ b/websocket-sharp/Net/HttpDigestIdentity.cs @@ -4,7 +4,7 @@ * * The MIT License * - * Copyright (c) 2014 sta.blockhead + * Copyright (c) 2014-2017 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From 3e684eb1cde2a14db1d8a9c186cb39ef7e0a9926 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 24 Apr 2017 16:59:49 +0900 Subject: [PATCH 1108/6294] [Modify] Edit it --- websocket-sharp/Net/HttpBasicIdentity.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpBasicIdentity.cs b/websocket-sharp/Net/HttpBasicIdentity.cs index 5ece5dccc..d26b29f69 100644 --- a/websocket-sharp/Net/HttpBasicIdentity.cs +++ b/websocket-sharp/Net/HttpBasicIdentity.cs @@ -66,7 +66,7 @@ internal HttpBasicIdentity (string username, string password) #region Public Properties /// - /// Gets the password from an HTTP Basic authentication attempt. + /// Gets the password from a basic authentication attempt. /// /// /// A that represents the password. From f8826ee59baf8f35bd1af46bc2d2ac833fd2f297 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 25 Apr 2017 17:15:11 +0900 Subject: [PATCH 1109/6294] [Modify] Rename them --- websocket-sharp/Net/NetworkCredential.cs | 34 ++++++++++++------------ 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/websocket-sharp/Net/NetworkCredential.cs b/websocket-sharp/Net/NetworkCredential.cs index b90bcad25..397ac094a 100644 --- a/websocket-sharp/Net/NetworkCredential.cs +++ b/websocket-sharp/Net/NetworkCredential.cs @@ -40,7 +40,7 @@ public class NetworkCredential private string _domain; private string _password; private string[] _roles; - private string _userName; + private string _username; #endregion @@ -50,7 +50,7 @@ public class NetworkCredential /// Initializes a new instance of the class with /// the specified user name and password. /// - /// + /// /// A that represents the user name associated with the credentials. /// /// @@ -58,13 +58,13 @@ public class NetworkCredential /// the credentials. /// /// - /// is . + /// is . /// /// - /// is empty. + /// is empty. /// - public NetworkCredential (string userName, string password) - : this (userName, password, null, null) + public NetworkCredential (string username, string password) + : this (username, password, null, null) { } @@ -72,7 +72,7 @@ public NetworkCredential (string userName, string password) /// Initializes a new instance of the class with /// the specified user name, password, domain, and roles. /// - /// + /// /// A that represents the user name associated with the credentials. /// /// @@ -88,21 +88,21 @@ public NetworkCredential (string userName, string password) /// the user associated with the credentials belongs if any. /// /// - /// is . + /// is . /// /// - /// is empty. + /// is empty. /// public NetworkCredential ( - string userName, string password, string domain, params string[] roles) + string username, string password, string domain, params string[] roles) { - if (userName == null) - throw new ArgumentNullException ("userName"); + if (username == null) + throw new ArgumentNullException ("username"); - if (userName.Length == 0) - throw new ArgumentException ("An empty string.", "userName"); + if (username.Length == 0) + throw new ArgumentException ("An empty string.", "username"); - _userName = userName; + _username = username; _password = password; _domain = domain; _roles = roles; @@ -171,11 +171,11 @@ internal set { /// public string UserName { get { - return _userName; + return _username; } internal set { - _userName = value; + _username = value; } } From c4e1609da3ba6169871d5ea7414fe43c310fdcd3 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 25 Apr 2017 17:19:01 +0900 Subject: [PATCH 1110/6294] [Modify] Polish it --- websocket-sharp/Net/NetworkCredential.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/NetworkCredential.cs b/websocket-sharp/Net/NetworkCredential.cs index 397ac094a..9d4a806ba 100644 --- a/websocket-sharp/Net/NetworkCredential.cs +++ b/websocket-sharp/Net/NetworkCredential.cs @@ -94,7 +94,8 @@ public NetworkCredential (string username, string password) /// is empty. /// public NetworkCredential ( - string username, string password, string domain, params string[] roles) + string username, string password, string domain, params string[] roles + ) { if (username == null) throw new ArgumentNullException ("username"); From 3771eeb4570e047f99ab4471c3647f711f731f48 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 26 Apr 2017 14:06:59 +0900 Subject: [PATCH 1111/6294] [Modify] Edit it --- websocket-sharp/Net/NetworkCredential.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/NetworkCredential.cs b/websocket-sharp/Net/NetworkCredential.cs index 9d4a806ba..f6df8f72e 100644 --- a/websocket-sharp/Net/NetworkCredential.cs +++ b/websocket-sharp/Net/NetworkCredential.cs @@ -31,7 +31,7 @@ namespace WebSocketSharp.Net { /// - /// Provides the credentials for the HTTP authentication (Basic/Digest). + /// Provides the credentials for the password-based authentication. /// public class NetworkCredential { From 5d47cdc2c5d62183529e2c37f63f227165314d54 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 26 Apr 2017 14:40:55 +0900 Subject: [PATCH 1112/6294] [Modify] Edit it --- websocket-sharp/Net/NetworkCredential.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/NetworkCredential.cs b/websocket-sharp/Net/NetworkCredential.cs index f6df8f72e..7c34be7a6 100644 --- a/websocket-sharp/Net/NetworkCredential.cs +++ b/websocket-sharp/Net/NetworkCredential.cs @@ -48,14 +48,15 @@ public class NetworkCredential /// /// Initializes a new instance of the class with - /// the specified user name and password. + /// the specified and . /// /// - /// A that represents the user name associated with the credentials. + /// A that represents the username associated with + /// the credentials. /// /// - /// A that represents the password for the user name associated with - /// the credentials. + /// A that represents the password for the username + /// associated with the credentials. /// /// /// is . From b24170c1440e735ef27f11e2c63a2971c63cc44f Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 27 Apr 2017 15:39:34 +0900 Subject: [PATCH 1113/6294] [Modify] Edit it --- websocket-sharp/Net/NetworkCredential.cs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/websocket-sharp/Net/NetworkCredential.cs b/websocket-sharp/Net/NetworkCredential.cs index 7c34be7a6..a62e5f764 100644 --- a/websocket-sharp/Net/NetworkCredential.cs +++ b/websocket-sharp/Net/NetworkCredential.cs @@ -71,22 +71,24 @@ public NetworkCredential (string username, string password) /// /// Initializes a new instance of the class with - /// the specified user name, password, domain, and roles. + /// the specified , , + /// and . /// /// - /// A that represents the user name associated with the credentials. + /// A that represents the username associated with + /// the credentials. /// /// - /// A that represents the password for the user name associated with - /// the credentials. + /// A that represents the password for the username + /// associated with the credentials. /// /// - /// A that represents the name of the user domain associated with + /// A that represents the domain associated with /// the credentials. /// /// - /// An array of that contains the role names to which - /// the user associated with the credentials belongs if any. + /// An array of that represents the roles + /// associated with the credentials if any. /// /// /// is . From 7c7de5150bc72840dd6864561b69f97c21070ab2 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 27 Apr 2017 16:41:46 +0900 Subject: [PATCH 1114/6294] [Modify] Edit it --- websocket-sharp/Net/NetworkCredential.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/NetworkCredential.cs b/websocket-sharp/Net/NetworkCredential.cs index a62e5f764..aa8e38a54 100644 --- a/websocket-sharp/Net/NetworkCredential.cs +++ b/websocket-sharp/Net/NetworkCredential.cs @@ -117,11 +117,10 @@ public NetworkCredential ( #region Public Properties /// - /// Gets the name of the user domain associated with the credentials. + /// Gets the domain associated with the credentials. /// /// - /// A that represents the name of the user domain associated with - /// the credentials. + /// A that represents the domain name. /// public string Domain { get { From b9094fc27d1e0e830579b66ca5f58494d29b0be4 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 27 Apr 2017 17:32:00 +0900 Subject: [PATCH 1115/6294] [Modify] Edit it --- websocket-sharp/Net/NetworkCredential.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/NetworkCredential.cs b/websocket-sharp/Net/NetworkCredential.cs index aa8e38a54..2e9151c4e 100644 --- a/websocket-sharp/Net/NetworkCredential.cs +++ b/websocket-sharp/Net/NetworkCredential.cs @@ -133,11 +133,10 @@ internal set { } /// - /// Gets the password for the user name associated with the credentials. + /// Gets the password for the username associated with the credentials. /// /// - /// A that represents the password for the user name associated with - /// the credentials. + /// A that represents the password for the username. /// public string Password { get { From 17e12b99f4e932f5a8fcaa496a40e640e321f884 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 28 Apr 2017 04:31:05 +0900 Subject: [PATCH 1116/6294] [Modify] Edit it --- websocket-sharp/Net/NetworkCredential.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/NetworkCredential.cs b/websocket-sharp/Net/NetworkCredential.cs index 2e9151c4e..dda6da2fa 100644 --- a/websocket-sharp/Net/NetworkCredential.cs +++ b/websocket-sharp/Net/NetworkCredential.cs @@ -149,11 +149,10 @@ internal set { } /// - /// Gets the role names to which the user associated with the credentials belongs. + /// Gets the roles associated with the credentials. /// /// - /// An array of that contains the role names to which - /// the user associated with the credentials belongs if any. + /// An array of that represents the role names. /// public string[] Roles { get { From 262f135efc553a0b68d5207279eda86e315ad570 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 28 Apr 2017 14:58:45 +0900 Subject: [PATCH 1117/6294] [Modify] Edit it --- websocket-sharp/Net/NetworkCredential.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/NetworkCredential.cs b/websocket-sharp/Net/NetworkCredential.cs index dda6da2fa..1260ee333 100644 --- a/websocket-sharp/Net/NetworkCredential.cs +++ b/websocket-sharp/Net/NetworkCredential.cs @@ -165,10 +165,10 @@ internal set { } /// - /// Gets the user name associated with the credentials. + /// Gets the username associated with the credentials. /// /// - /// A that represents the user name associated with the credentials. + /// A that represents the username. /// public string UserName { get { From 4c08b41f5ac0974c9f97de35b9c33fbe2d8fdc32 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 28 Apr 2017 15:35:27 +0900 Subject: [PATCH 1118/6294] [Modify] Edit it --- websocket-sharp/Net/NetworkCredential.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/NetworkCredential.cs b/websocket-sharp/Net/NetworkCredential.cs index 1260ee333..26d79bbd4 100644 --- a/websocket-sharp/Net/NetworkCredential.cs +++ b/websocket-sharp/Net/NetworkCredential.cs @@ -120,7 +120,8 @@ public NetworkCredential ( /// Gets the domain associated with the credentials. /// /// - /// A that represents the domain name. + /// A that represents the domain name + /// to which the username belongs. /// public string Domain { get { From 856b34a9c4708910e36e76bac427878c2bd5365d Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 28 Apr 2017 15:59:07 +0900 Subject: [PATCH 1119/6294] [Modify] Edit it --- websocket-sharp/Net/NetworkCredential.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/NetworkCredential.cs b/websocket-sharp/Net/NetworkCredential.cs index 26d79bbd4..7e539da6c 100644 --- a/websocket-sharp/Net/NetworkCredential.cs +++ b/websocket-sharp/Net/NetworkCredential.cs @@ -153,7 +153,8 @@ internal set { /// Gets the roles associated with the credentials. /// /// - /// An array of that represents the role names. + /// An array of that represents the role names + /// to which the username belongs. /// public string[] Roles { get { From 724853abb0b80031c55469d2f44cb1fe61656e61 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 29 Apr 2017 14:34:32 +0900 Subject: [PATCH 1120/6294] [Modify] Add them For no roles. --- websocket-sharp/Net/NetworkCredential.cs | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Net/NetworkCredential.cs b/websocket-sharp/Net/NetworkCredential.cs index 7e539da6c..174692955 100644 --- a/websocket-sharp/Net/NetworkCredential.cs +++ b/websocket-sharp/Net/NetworkCredential.cs @@ -37,10 +37,20 @@ public class NetworkCredential { #region Private Fields - private string _domain; - private string _password; - private string[] _roles; - private string _username; + private string _domain; + private static readonly string[] _noRoles; + private string _password; + private string[] _roles; + private string _username; + + #endregion + + #region Static Constructor + + static NetworkCredential () + { + _noRoles = new string[0]; + } #endregion @@ -158,7 +168,7 @@ internal set { /// public string[] Roles { get { - return _roles ?? (_roles = new string[0]); + return _roles ?? _noRoles; } internal set { From 3a759e12ea833d77710dead4abbc583a30901de3 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 30 Apr 2017 15:12:09 +0900 Subject: [PATCH 1121/6294] [Modify] Edit it --- websocket-sharp/Net/NetworkCredential.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/websocket-sharp/Net/NetworkCredential.cs b/websocket-sharp/Net/NetworkCredential.cs index 174692955..7386ab048 100644 --- a/websocket-sharp/Net/NetworkCredential.cs +++ b/websocket-sharp/Net/NetworkCredential.cs @@ -129,6 +129,10 @@ public NetworkCredential ( /// /// Gets the domain associated with the credentials. /// + /// + /// This property returns an empty string if the domain was + /// initialized with . + /// /// /// A that represents the domain name /// to which the username belongs. From 457c0635e2c09363ab43dfc1488fd6dcfd343bc0 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 30 Apr 2017 15:27:37 +0900 Subject: [PATCH 1122/6294] [Modify] Edit it --- websocket-sharp/Net/NetworkCredential.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/NetworkCredential.cs b/websocket-sharp/Net/NetworkCredential.cs index 7386ab048..4881f59d9 100644 --- a/websocket-sharp/Net/NetworkCredential.cs +++ b/websocket-sharp/Net/NetworkCredential.cs @@ -150,8 +150,12 @@ internal set { /// /// Gets the password for the username associated with the credentials. /// + /// + /// This property returns an empty string if the password was + /// initialized with . + /// /// - /// A that represents the password for the username. + /// A that represents the password. /// public string Password { get { From 0f25f3cef2ebbbaec4913cf20adcb70a55f581f7 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 30 Apr 2017 15:38:27 +0900 Subject: [PATCH 1123/6294] [Modify] Edit it --- websocket-sharp/Net/NetworkCredential.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/websocket-sharp/Net/NetworkCredential.cs b/websocket-sharp/Net/NetworkCredential.cs index 4881f59d9..73bd0b302 100644 --- a/websocket-sharp/Net/NetworkCredential.cs +++ b/websocket-sharp/Net/NetworkCredential.cs @@ -170,6 +170,10 @@ internal set { /// /// Gets the roles associated with the credentials. /// + /// + /// This property returns an empty array if the roles were + /// initialized with . + /// /// /// An array of that represents the role names /// to which the username belongs. From 007ec8879c898874a2c34a0f18da385de8878827 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 1 May 2017 16:17:23 +0900 Subject: [PATCH 1124/6294] [Modify] Rename it --- websocket-sharp/Net/AuthenticationResponse.cs | 2 +- websocket-sharp/Net/NetworkCredential.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/AuthenticationResponse.cs b/websocket-sharp/Net/AuthenticationResponse.cs index cc49b372e..0257d85b2 100644 --- a/websocket-sharp/Net/AuthenticationResponse.cs +++ b/websocket-sharp/Net/AuthenticationResponse.cs @@ -75,7 +75,7 @@ internal AuthenticationResponse ( uint nonceCount) : base (scheme, parameters) { - Parameters["username"] = credentials.UserName; + Parameters["username"] = credentials.Username; Parameters["password"] = credentials.Password; Parameters["uri"] = credentials.Domain; _nonceCount = nonceCount; diff --git a/websocket-sharp/Net/NetworkCredential.cs b/websocket-sharp/Net/NetworkCredential.cs index 73bd0b302..357ade499 100644 --- a/websocket-sharp/Net/NetworkCredential.cs +++ b/websocket-sharp/Net/NetworkCredential.cs @@ -194,7 +194,7 @@ internal set { /// /// A that represents the username. /// - public string UserName { + public string Username { get { return _username; } From 70a6946e9e42e488473979e2278961bc2cad9863 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 2 May 2017 15:33:59 +0900 Subject: [PATCH 1125/6294] [Modify] 2017 --- websocket-sharp/Net/NetworkCredential.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/NetworkCredential.cs b/websocket-sharp/Net/NetworkCredential.cs index 357ade499..3ee52f402 100644 --- a/websocket-sharp/Net/NetworkCredential.cs +++ b/websocket-sharp/Net/NetworkCredential.cs @@ -4,7 +4,7 @@ * * The MIT License * - * Copyright (c) 2014-2015 sta.blockhead + * Copyright (c) 2014-2017 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From 9c38b22669eba9d06653ee3ea56be9fe41d187c9 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 2 May 2017 17:32:23 +0900 Subject: [PATCH 1126/6294] [Modify] Edit it --- websocket-sharp/Net/ServerSslConfiguration.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/ServerSslConfiguration.cs b/websocket-sharp/Net/ServerSslConfiguration.cs index 3f0883afe..bcbbe41bf 100644 --- a/websocket-sharp/Net/ServerSslConfiguration.cs +++ b/websocket-sharp/Net/ServerSslConfiguration.cs @@ -41,7 +41,8 @@ namespace WebSocketSharp.Net { /// - /// Stores the parameters used to configure a instance as a server. + /// Stores the parameters used to configure the underlying + /// for servers. /// public class ServerSslConfiguration : SslConfiguration { From c4f02ecfa60d413c31752aa6411e4a26935d454c Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 2 May 2017 17:51:33 +0900 Subject: [PATCH 1127/6294] [Modify] Edit it --- websocket-sharp/Net/ServerSslConfiguration.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/ServerSslConfiguration.cs b/websocket-sharp/Net/ServerSslConfiguration.cs index bcbbe41bf..8d4868799 100644 --- a/websocket-sharp/Net/ServerSslConfiguration.cs +++ b/websocket-sharp/Net/ServerSslConfiguration.cs @@ -56,12 +56,12 @@ public class ServerSslConfiguration : SslConfiguration #region Public Constructors /// - /// Initializes a new instance of the class with - /// the specified . + /// Initializes a new instance of the class + /// with the specified . /// /// - /// A that represents the certificate used to authenticate - /// the server. + /// A that represents an X.509 certificate + /// used to authenticate the server. /// public ServerSslConfiguration (X509Certificate2 serverCertificate) : this (serverCertificate, false, SslProtocols.Default, false) From 3494f6ae403d02e7f879c62f957a4221fe7cbb44 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 2 May 2017 17:55:58 +0900 Subject: [PATCH 1128/6294] [Modify] Polish it --- websocket-sharp/Net/ServerSslConfiguration.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/ServerSslConfiguration.cs b/websocket-sharp/Net/ServerSslConfiguration.cs index 8d4868799..407a73f81 100644 --- a/websocket-sharp/Net/ServerSslConfiguration.cs +++ b/websocket-sharp/Net/ServerSslConfiguration.cs @@ -94,7 +94,8 @@ public ServerSslConfiguration ( X509Certificate2 serverCertificate, bool clientCertificateRequired, SslProtocols enabledSslProtocols, - bool checkCertificateRevocation) + bool checkCertificateRevocation + ) : base (enabledSslProtocols, checkCertificateRevocation) { _cert = serverCertificate; From d62dfa5cd36f50527b96405ed790d81b01542b8e Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 3 May 2017 15:18:54 +0900 Subject: [PATCH 1129/6294] [Modify] Edit it --- websocket-sharp/Net/ServerSslConfiguration.cs | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/websocket-sharp/Net/ServerSslConfiguration.cs b/websocket-sharp/Net/ServerSslConfiguration.cs index 407a73f81..5e745de1e 100644 --- a/websocket-sharp/Net/ServerSslConfiguration.cs +++ b/websocket-sharp/Net/ServerSslConfiguration.cs @@ -69,26 +69,27 @@ public ServerSslConfiguration (X509Certificate2 serverCertificate) } /// - /// Initializes a new instance of the class with - /// the specified , - /// , , + /// Initializes a new instance of the class + /// with the specified , + /// , + /// , /// and . /// /// - /// A that represents the certificate used to authenticate - /// the server. + /// A that represents an X.509 certificate + /// used to authenticate the server. /// /// - /// true if the client must supply a certificate for authentication; + /// true if the client is asked for a certificate for authentication; /// otherwise, false. /// /// - /// The enum value that represents the protocols used for - /// authentication. + /// The enum values that represent the protocols + /// used for authentication. /// /// - /// true if the certificate revocation list is checked during authentication; - /// otherwise, false. + /// true if the certificate revocation list is checked during + /// authentication; otherwise, false. /// public ServerSslConfiguration ( X509Certificate2 serverCertificate, From 79ca5fc2974424909de1ca553553aa6241f6b403 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 3 May 2017 15:32:56 +0900 Subject: [PATCH 1130/6294] [Modify] Edit it --- websocket-sharp/Net/ServerSslConfiguration.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/ServerSslConfiguration.cs b/websocket-sharp/Net/ServerSslConfiguration.cs index 5e745de1e..f6c24dd7d 100644 --- a/websocket-sharp/Net/ServerSslConfiguration.cs +++ b/websocket-sharp/Net/ServerSslConfiguration.cs @@ -108,11 +108,12 @@ bool checkCertificateRevocation #region Public Properties /// - /// Gets or sets a value indicating whether the client must supply a certificate for - /// authentication. + /// Gets or sets a value indicating whether the client is asked for + /// a certificate for authentication. /// /// - /// true if the client must supply a certificate; otherwise, false. + /// true if the client is asked for a certificate for authentication; + /// otherwise, false. /// public bool ClientCertificateRequired { get { From 63cd5a298e2983731f019b8e84e6a1af4e860a53 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 4 May 2017 15:24:08 +0900 Subject: [PATCH 1131/6294] [Modify] Edit it --- websocket-sharp/Net/ServerSslConfiguration.cs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Net/ServerSslConfiguration.cs b/websocket-sharp/Net/ServerSslConfiguration.cs index f6c24dd7d..01fa78c80 100644 --- a/websocket-sharp/Net/ServerSslConfiguration.cs +++ b/websocket-sharp/Net/ServerSslConfiguration.cs @@ -126,15 +126,21 @@ public bool ClientCertificateRequired { } /// - /// Gets or sets the callback used to validate the certificate supplied by the client. + /// Gets or sets the callback used to validate the certificate + /// supplied by the client. /// /// - /// If this callback returns true, the client certificate will be valid. + /// The certificate is valid if the callback returns true. /// /// - /// A delegate that references the method - /// used to validate the client certificate. The default value is a function that only returns - /// true. + /// + /// A delegate. + /// + /// + /// It invokes the method called for validating the certificate. + /// The default value is a delegate that invokes a method that + /// only returns true. + /// /// public RemoteCertificateValidationCallback ClientCertificateValidationCallback { get { From 1b92761737e958c85956c25985504376b60b058d Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 4 May 2017 15:37:51 +0900 Subject: [PATCH 1132/6294] [Modify] Edit it --- websocket-sharp/Net/ServerSslConfiguration.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/ServerSslConfiguration.cs b/websocket-sharp/Net/ServerSslConfiguration.cs index 01fa78c80..0b1b39067 100644 --- a/websocket-sharp/Net/ServerSslConfiguration.cs +++ b/websocket-sharp/Net/ServerSslConfiguration.cs @@ -153,11 +153,11 @@ public RemoteCertificateValidationCallback ClientCertificateValidationCallback { } /// - /// Gets or sets the certificate used to authenticate the server for secure connection. + /// Gets or sets the certificate used to authenticate the server. /// /// - /// A that represents the certificate used to authenticate - /// the server. + /// A that represents an X.509 certificate + /// used to authenticate the server. /// public X509Certificate2 ServerCertificate { get { From 5bd0914bb64c31f1a4fc56951aee9667019383f7 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 5 May 2017 14:57:35 +0900 Subject: [PATCH 1133/6294] [Modify] Rename it --- websocket-sharp/Net/ServerSslConfiguration.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/ServerSslConfiguration.cs b/websocket-sharp/Net/ServerSslConfiguration.cs index 0b1b39067..b10869887 100644 --- a/websocket-sharp/Net/ServerSslConfiguration.cs +++ b/websocket-sharp/Net/ServerSslConfiguration.cs @@ -48,7 +48,7 @@ public class ServerSslConfiguration : SslConfiguration { #region Private Fields - private X509Certificate2 _cert; + private X509Certificate2 _serverCert; private bool _clientCertRequired; #endregion @@ -99,7 +99,7 @@ bool checkCertificateRevocation ) : base (enabledSslProtocols, checkCertificateRevocation) { - _cert = serverCertificate; + _serverCert = serverCertificate; _clientCertRequired = clientCertificateRequired; } @@ -161,11 +161,11 @@ public RemoteCertificateValidationCallback ClientCertificateValidationCallback { /// public X509Certificate2 ServerCertificate { get { - return _cert; + return _serverCert; } set { - _cert = value; + _serverCert = value; } } From 132d31cd12faea7e7c291866f9aec0f1634c2304 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 6 May 2017 14:47:10 +0900 Subject: [PATCH 1134/6294] [Modify] Not inherit it --- websocket-sharp/Net/ServerSslConfiguration.cs | 68 +++++++++++++++++-- 1 file changed, 62 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Net/ServerSslConfiguration.cs b/websocket-sharp/Net/ServerSslConfiguration.cs index b10869887..9920b8c0e 100644 --- a/websocket-sharp/Net/ServerSslConfiguration.cs +++ b/websocket-sharp/Net/ServerSslConfiguration.cs @@ -44,12 +44,15 @@ namespace WebSocketSharp.Net /// Stores the parameters used to configure the underlying /// for servers. /// - public class ServerSslConfiguration : SslConfiguration + public class ServerSslConfiguration { #region Private Fields - private X509Certificate2 _serverCert; - private bool _clientCertRequired; + private bool _checkCertRevocation; + private bool _clientCertRequired; + private RemoteCertificateValidationCallback _clientCertValidationCallback; + private SslProtocols _enabledSslProtocols; + private X509Certificate2 _serverCert; #endregion @@ -97,16 +100,35 @@ public ServerSslConfiguration ( SslProtocols enabledSslProtocols, bool checkCertificateRevocation ) - : base (enabledSslProtocols, checkCertificateRevocation) { _serverCert = serverCertificate; _clientCertRequired = clientCertificateRequired; + _enabledSslProtocols = enabledSslProtocols; + _checkCertRevocation = checkCertificateRevocation; } #endregion #region Public Properties + /// + /// Gets or sets a value indicating whether the certificate revocation + /// list is checked during authentication. + /// + /// + /// true if the certificate revocation list is checked during + /// authentication; otherwise, false. + /// + public bool CheckCertificateRevocation { + get { + return _checkCertRevocation; + } + + set { + _checkCertRevocation = value; + } + } + /// /// Gets or sets a value indicating whether the client is asked for /// a certificate for authentication. @@ -144,11 +166,31 @@ public bool ClientCertificateRequired { /// public RemoteCertificateValidationCallback ClientCertificateValidationCallback { get { - return CertificateValidationCallback; + if (_clientCertValidationCallback == null) + _clientCertValidationCallback = defaultValidateClientCertificate; + + return _clientCertValidationCallback; + } + + set { + _clientCertValidationCallback = value; + } + } + + /// + /// Gets or sets the protocols used for authentication. + /// + /// + /// The enum values that represent the protocols + /// used for authentication. + /// + public SslProtocols EnabledSslProtocols { + get { + return _enabledSslProtocols; } set { - CertificateValidationCallback = value; + _enabledSslProtocols = value; } } @@ -170,5 +212,19 @@ public X509Certificate2 ServerCertificate { } #endregion + + #region Private Methods + + private static bool defaultValidateClientCertificate ( + object sender, + X509Certificate certificate, + X509Chain chain, + SslPolicyErrors sslPolicyErrors + ) + { + return true; + } + + #endregion } } From 3ef3572f5e058803785b92599ad9b63e9c472408 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 6 May 2017 14:57:15 +0900 Subject: [PATCH 1135/6294] [Modify] Add it --- websocket-sharp/Net/ServerSslConfiguration.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/websocket-sharp/Net/ServerSslConfiguration.cs b/websocket-sharp/Net/ServerSslConfiguration.cs index 9920b8c0e..c10b4dc15 100644 --- a/websocket-sharp/Net/ServerSslConfiguration.cs +++ b/websocket-sharp/Net/ServerSslConfiguration.cs @@ -58,6 +58,14 @@ public class ServerSslConfiguration #region Public Constructors + /// + /// Initializes a new instance of the class. + /// + public ServerSslConfiguration () + { + _enabledSslProtocols = SslProtocols.Default; + } + /// /// Initializes a new instance of the class /// with the specified . From 73e8d31d6144aea40671ae7b72097c6501def212 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 6 May 2017 15:24:51 +0900 Subject: [PATCH 1136/6294] [Modify] Add it --- websocket-sharp/Net/HttpListener.cs | 2 +- websocket-sharp/Net/ServerSslConfiguration.cs | 16 ++++++++++++++++ websocket-sharp/Server/WebSocketServer.cs | 2 +- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index c83349871..07970e14d 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -352,7 +352,7 @@ public string Realm { public ServerSslConfiguration SslConfiguration { get { CheckDisposed (); - return _sslConfig ?? (_sslConfig = new ServerSslConfiguration (null)); + return _sslConfig ?? (_sslConfig = new ServerSslConfiguration ()); } set { diff --git a/websocket-sharp/Net/ServerSslConfiguration.cs b/websocket-sharp/Net/ServerSslConfiguration.cs index c10b4dc15..e52d33df1 100644 --- a/websocket-sharp/Net/ServerSslConfiguration.cs +++ b/websocket-sharp/Net/ServerSslConfiguration.cs @@ -79,6 +79,22 @@ public ServerSslConfiguration (X509Certificate2 serverCertificate) { } + /// + /// Copies the parameters from the specified to + /// a new instance of the class. + /// + /// + /// A from which to copy. + /// + public ServerSslConfiguration (ServerSslConfiguration configuration) + { + _checkCertRevocation = configuration._checkCertRevocation; + _clientCertRequired = configuration._clientCertRequired; + _clientCertValidationCallback = configuration._clientCertValidationCallback; + _enabledSslProtocols = configuration._enabledSslProtocols; + _serverCert = configuration._serverCert; + } + /// /// Initializes a new instance of the class /// with the specified , diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 92b074955..e2829f358 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -583,7 +583,7 @@ public bool ReuseAddress { public ServerSslConfiguration SslConfiguration { get { if (_sslConfig == null) - _sslConfig = new ServerSslConfiguration (null); + _sslConfig = new ServerSslConfiguration (); return _sslConfig; } From 55a160c4613db8bebd6c0435ad4a4b998b31f586 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 6 May 2017 15:42:26 +0900 Subject: [PATCH 1137/6294] [Modify] Replace it --- websocket-sharp/Server/WebSocketServer.cs | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index e2829f358..0cb848be8 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -767,21 +767,7 @@ private string getRealm () private ServerSslConfiguration getSslConfiguration () { var sslConfig = _sslConfig; - if (sslConfig == null) - return null; - - var ret = - new ServerSslConfiguration ( - sslConfig.ServerCertificate, - sslConfig.ClientCertificateRequired, - sslConfig.EnabledSslProtocols, - sslConfig.CheckCertificateRevocation - ); - - ret.ClientCertificateValidationCallback = - sslConfig.ClientCertificateValidationCallback; - - return ret; + return sslConfig != null ? new ServerSslConfiguration (sslConfig) : null; } private void init ( From 8614e44afdb3fb0be2ec495c6a6be364762e2a32 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 7 May 2017 14:03:24 +0900 Subject: [PATCH 1138/6294] [Modify] Throw exception --- websocket-sharp/Net/ServerSslConfiguration.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/websocket-sharp/Net/ServerSslConfiguration.cs b/websocket-sharp/Net/ServerSslConfiguration.cs index e52d33df1..f27387910 100644 --- a/websocket-sharp/Net/ServerSslConfiguration.cs +++ b/websocket-sharp/Net/ServerSslConfiguration.cs @@ -34,6 +34,7 @@ */ #endregion +using System; using System.Net.Security; using System.Security.Authentication; using System.Security.Cryptography.X509Certificates; @@ -86,8 +87,14 @@ public ServerSslConfiguration (X509Certificate2 serverCertificate) /// /// A from which to copy. /// + /// + /// is . + /// public ServerSslConfiguration (ServerSslConfiguration configuration) { + if (configuration == null) + throw new ArgumentNullException ("configuration"); + _checkCertRevocation = configuration._checkCertRevocation; _clientCertRequired = configuration._clientCertRequired; _clientCertValidationCallback = configuration._clientCertValidationCallback; From e856a2f194ff5579192136bc4140aa9b63af1638 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 7 May 2017 14:28:57 +0900 Subject: [PATCH 1139/6294] [Modify] Replace it --- websocket-sharp/Net/EndPointListener.cs | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/websocket-sharp/Net/EndPointListener.cs b/websocket-sharp/Net/EndPointListener.cs index 63a6c11b5..67fa26393 100644 --- a/websocket-sharp/Net/EndPointListener.cs +++ b/websocket-sharp/Net/EndPointListener.cs @@ -102,16 +102,8 @@ bool reuseAddress throw new ArgumentException ("No server certificate could be found."); _secure = true; - _sslConfig = - new ServerSslConfiguration ( - cert, - sslConfig.ClientCertificateRequired, - sslConfig.EnabledSslProtocols, - sslConfig.CheckCertificateRevocation - ); - - _sslConfig.ClientCertificateValidationCallback = - sslConfig.ClientCertificateValidationCallback; + _sslConfig = new ServerSslConfiguration (sslConfig); + _sslConfig.ServerCertificate = cert; } _endpoint = endpoint; From abf836dfcd38ab35835d8ef15ff1a2151eb3623a Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 8 May 2017 15:10:28 +0900 Subject: [PATCH 1140/6294] [Modify] Remove it --- websocket-sharp/Net/ServerSslConfiguration.cs | 39 +------------------ 1 file changed, 2 insertions(+), 37 deletions(-) diff --git a/websocket-sharp/Net/ServerSslConfiguration.cs b/websocket-sharp/Net/ServerSslConfiguration.cs index f27387910..43be9a77a 100644 --- a/websocket-sharp/Net/ServerSslConfiguration.cs +++ b/websocket-sharp/Net/ServerSslConfiguration.cs @@ -76,8 +76,9 @@ public ServerSslConfiguration () /// used to authenticate the server. /// public ServerSslConfiguration (X509Certificate2 serverCertificate) - : this (serverCertificate, false, SslProtocols.Default, false) { + _serverCert = serverCertificate; + _enabledSslProtocols = SslProtocols.Default; } /// @@ -102,42 +103,6 @@ public ServerSslConfiguration (ServerSslConfiguration configuration) _serverCert = configuration._serverCert; } - /// - /// Initializes a new instance of the class - /// with the specified , - /// , - /// , - /// and . - /// - /// - /// A that represents an X.509 certificate - /// used to authenticate the server. - /// - /// - /// true if the client is asked for a certificate for authentication; - /// otherwise, false. - /// - /// - /// The enum values that represent the protocols - /// used for authentication. - /// - /// - /// true if the certificate revocation list is checked during - /// authentication; otherwise, false. - /// - public ServerSslConfiguration ( - X509Certificate2 serverCertificate, - bool clientCertificateRequired, - SslProtocols enabledSslProtocols, - bool checkCertificateRevocation - ) - { - _serverCert = serverCertificate; - _clientCertRequired = clientCertificateRequired; - _enabledSslProtocols = enabledSslProtocols; - _checkCertRevocation = checkCertificateRevocation; - } - #endregion #region Public Properties From 38e5a7cb16855e6864d8cc89bbe991a14cf12404 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 8 May 2017 15:17:03 +0900 Subject: [PATCH 1141/6294] [Modify] Edit it --- websocket-sharp/Net/ServerSslConfiguration.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/websocket-sharp/Net/ServerSslConfiguration.cs b/websocket-sharp/Net/ServerSslConfiguration.cs index 43be9a77a..4ad382957 100644 --- a/websocket-sharp/Net/ServerSslConfiguration.cs +++ b/websocket-sharp/Net/ServerSslConfiguration.cs @@ -42,8 +42,7 @@ namespace WebSocketSharp.Net { /// - /// Stores the parameters used to configure the underlying - /// for servers. + /// Stores the parameters for the used by servers. /// public class ServerSslConfiguration { From bb7362ca48c9350eb8755fd0e34cfbea62fb53cc Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 8 May 2017 15:23:32 +0900 Subject: [PATCH 1142/6294] [Modify] Edit it --- websocket-sharp/Net/ServerSslConfiguration.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/ServerSslConfiguration.cs b/websocket-sharp/Net/ServerSslConfiguration.cs index 4ad382957..9c33a99fe 100644 --- a/websocket-sharp/Net/ServerSslConfiguration.cs +++ b/websocket-sharp/Net/ServerSslConfiguration.cs @@ -112,7 +112,8 @@ public ServerSslConfiguration (ServerSslConfiguration configuration) /// /// /// true if the certificate revocation list is checked during - /// authentication; otherwise, false. + /// authentication; otherwise, false. The default value is + /// false. /// public bool CheckCertificateRevocation { get { From 060737fa40740b7732ffac8177e9b6391e35348e Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 8 May 2017 15:31:01 +0900 Subject: [PATCH 1143/6294] [Modify] Edit it --- websocket-sharp/Net/ServerSslConfiguration.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/ServerSslConfiguration.cs b/websocket-sharp/Net/ServerSslConfiguration.cs index 9c33a99fe..84809a48c 100644 --- a/websocket-sharp/Net/ServerSslConfiguration.cs +++ b/websocket-sharp/Net/ServerSslConfiguration.cs @@ -131,7 +131,7 @@ public bool CheckCertificateRevocation { /// /// /// true if the client is asked for a certificate for authentication; - /// otherwise, false. + /// otherwise, false. The default value is false. /// public bool ClientCertificateRequired { get { From 0f47c6574beff55f045b2419bba9714f52c8e668 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 8 May 2017 15:46:54 +0900 Subject: [PATCH 1144/6294] [Modify] Edit it --- websocket-sharp/Net/ServerSslConfiguration.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/ServerSslConfiguration.cs b/websocket-sharp/Net/ServerSslConfiguration.cs index 84809a48c..e1d02e605 100644 --- a/websocket-sharp/Net/ServerSslConfiguration.cs +++ b/websocket-sharp/Net/ServerSslConfiguration.cs @@ -177,8 +177,13 @@ public RemoteCertificateValidationCallback ClientCertificateValidationCallback { /// Gets or sets the protocols used for authentication. /// /// - /// The enum values that represent the protocols - /// used for authentication. + /// + /// The enum values that represent + /// the protocols used for authentication. + /// + /// + /// The default value is . + /// /// public SslProtocols EnabledSslProtocols { get { From a017863b7d70d7c43c5bc859c60814994ef7831b Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 9 May 2017 14:43:27 +0900 Subject: [PATCH 1145/6294] [Modify] Edit it --- websocket-sharp/Net/ServerSslConfiguration.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/ServerSslConfiguration.cs b/websocket-sharp/Net/ServerSslConfiguration.cs index e1d02e605..a0da1dafd 100644 --- a/websocket-sharp/Net/ServerSslConfiguration.cs +++ b/websocket-sharp/Net/ServerSslConfiguration.cs @@ -199,8 +199,13 @@ public SslProtocols EnabledSslProtocols { /// Gets or sets the certificate used to authenticate the server. /// /// - /// A that represents an X.509 certificate - /// used to authenticate the server. + /// + /// A or + /// if not specified. + /// + /// + /// That instance represents an X.509 certificate. + /// /// public X509Certificate2 ServerCertificate { get { From a3ab5dec8040c9099daf7b0cb684497977ebcbdc Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 9 May 2017 14:51:13 +0900 Subject: [PATCH 1146/6294] [Modify] Edit it --- websocket-sharp/Net/ServerSslConfiguration.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/ServerSslConfiguration.cs b/websocket-sharp/Net/ServerSslConfiguration.cs index a0da1dafd..6b4b8b097 100644 --- a/websocket-sharp/Net/ServerSslConfiguration.cs +++ b/websocket-sharp/Net/ServerSslConfiguration.cs @@ -111,9 +111,13 @@ public ServerSslConfiguration (ServerSslConfiguration configuration) /// list is checked during authentication. /// /// - /// true if the certificate revocation list is checked during - /// authentication; otherwise, false. The default value is - /// false. + /// + /// true if the certificate revocation list is checked during + /// authentication; otherwise, false. + /// + /// + /// The default value is false. + /// /// public bool CheckCertificateRevocation { get { From 165f3d4241290ebd7d59fe2f9755d465e74be8ad Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 9 May 2017 14:56:16 +0900 Subject: [PATCH 1147/6294] [Modify] Edit it --- websocket-sharp/Net/ServerSslConfiguration.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/ServerSslConfiguration.cs b/websocket-sharp/Net/ServerSslConfiguration.cs index 6b4b8b097..ef7c6896f 100644 --- a/websocket-sharp/Net/ServerSslConfiguration.cs +++ b/websocket-sharp/Net/ServerSslConfiguration.cs @@ -134,8 +134,13 @@ public bool CheckCertificateRevocation { /// a certificate for authentication. /// /// - /// true if the client is asked for a certificate for authentication; - /// otherwise, false. The default value is false. + /// + /// true if the client is asked for a certificate for + /// authentication; otherwise, false. + /// + /// + /// The default value is false. + /// /// public bool ClientCertificateRequired { get { From 440c6e42d30c7af0e982da93797019f7651e7e50 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 9 May 2017 15:13:35 +0900 Subject: [PATCH 1148/6294] [Modify] Edit it --- websocket-sharp/Net/ServerSslConfiguration.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/ServerSslConfiguration.cs b/websocket-sharp/Net/ServerSslConfiguration.cs index ef7c6896f..2b64ab8cc 100644 --- a/websocket-sharp/Net/ServerSslConfiguration.cs +++ b/websocket-sharp/Net/ServerSslConfiguration.cs @@ -161,10 +161,10 @@ public bool ClientCertificateRequired { /// /// /// - /// A delegate. + /// A delegate that + /// invokes the method called for validating the certificate. /// /// - /// It invokes the method called for validating the certificate. /// The default value is a delegate that invokes a method that /// only returns true. /// From 238e8f71161ab3b4059117b744295a93ab90492c Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 10 May 2017 14:14:18 +0900 Subject: [PATCH 1149/6294] [Modify] Edit it --- websocket-sharp/Net/ServerSslConfiguration.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/ServerSslConfiguration.cs b/websocket-sharp/Net/ServerSslConfiguration.cs index 2b64ab8cc..0141f3181 100644 --- a/websocket-sharp/Net/ServerSslConfiguration.cs +++ b/websocket-sharp/Net/ServerSslConfiguration.cs @@ -71,8 +71,8 @@ public ServerSslConfiguration () /// with the specified . /// /// - /// A that represents an X.509 certificate - /// used to authenticate the server. + /// A that represents the certificate used to + /// authenticate the server. /// public ServerSslConfiguration (X509Certificate2 serverCertificate) { From 8489430b789f486d83f6eb56ecddff7aac7dabd3 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 10 May 2017 14:17:36 +0900 Subject: [PATCH 1150/6294] [Modify] 2017 --- websocket-sharp/Net/ServerSslConfiguration.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/ServerSslConfiguration.cs b/websocket-sharp/Net/ServerSslConfiguration.cs index 0141f3181..ad9b9e7c2 100644 --- a/websocket-sharp/Net/ServerSslConfiguration.cs +++ b/websocket-sharp/Net/ServerSslConfiguration.cs @@ -5,7 +5,7 @@ * The MIT License * * Copyright (c) 2014 liryna - * Copyright (c) 2014 sta.blockhead + * Copyright (c) 2014-2017 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From 190bf4dedf7ea722ea71676d76a65b17ffa7a1ef Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 10 May 2017 14:22:40 +0900 Subject: [PATCH 1151/6294] [Modify] Edit it --- websocket-sharp/Net/ClientSslConfiguration.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/ClientSslConfiguration.cs b/websocket-sharp/Net/ClientSslConfiguration.cs index 5344164f6..8b52219df 100644 --- a/websocket-sharp/Net/ClientSslConfiguration.cs +++ b/websocket-sharp/Net/ClientSslConfiguration.cs @@ -41,7 +41,7 @@ namespace WebSocketSharp.Net { /// - /// Stores the parameters used to configure a instance as a client. + /// Stores the parameters for the used by clients. /// public class ClientSslConfiguration : SslConfiguration { From fca56b7cecd09d09effd528bc35932f82154af4e Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 10 May 2017 14:38:05 +0900 Subject: [PATCH 1152/6294] [Modify] Edit it --- websocket-sharp/Net/ClientSslConfiguration.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/ClientSslConfiguration.cs b/websocket-sharp/Net/ClientSslConfiguration.cs index 8b52219df..20310e74f 100644 --- a/websocket-sharp/Net/ClientSslConfiguration.cs +++ b/websocket-sharp/Net/ClientSslConfiguration.cs @@ -55,12 +55,12 @@ public class ClientSslConfiguration : SslConfiguration #region Public Constructors /// - /// Initializes a new instance of the class with - /// the specified . + /// Initializes a new instance of the class + /// with the specified . /// /// - /// A that represents the name of the server that shares - /// a secure connection. + /// A that represents the name of the server that + /// will share a secure connection. /// public ClientSslConfiguration (string targetHost) : this (targetHost, null, SslProtocols.Default, false) From a43aae2a49c8206f4d69ce45bb219f400973672a Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 10 May 2017 14:41:15 +0900 Subject: [PATCH 1153/6294] [Modify] Polish it --- websocket-sharp/Net/ClientSslConfiguration.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/ClientSslConfiguration.cs b/websocket-sharp/Net/ClientSslConfiguration.cs index 20310e74f..051bc87e0 100644 --- a/websocket-sharp/Net/ClientSslConfiguration.cs +++ b/websocket-sharp/Net/ClientSslConfiguration.cs @@ -91,7 +91,8 @@ public ClientSslConfiguration ( string targetHost, X509CertificateCollection clientCertificates, SslProtocols enabledSslProtocols, - bool checkCertificateRevocation) + bool checkCertificateRevocation + ) : base (enabledSslProtocols, checkCertificateRevocation) { _host = targetHost; From dc3e702e77ea8a2767859b76bf5a70fb5bffacc9 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 10 May 2017 14:49:44 +0900 Subject: [PATCH 1154/6294] [Modify] Edit it --- websocket-sharp/Net/ClientSslConfiguration.cs | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/websocket-sharp/Net/ClientSslConfiguration.cs b/websocket-sharp/Net/ClientSslConfiguration.cs index 051bc87e0..b8fd4edff 100644 --- a/websocket-sharp/Net/ClientSslConfiguration.cs +++ b/websocket-sharp/Net/ClientSslConfiguration.cs @@ -68,24 +68,26 @@ public ClientSslConfiguration (string targetHost) } /// - /// Initializes a new instance of the class with - /// the specified , , - /// , and . + /// Initializes a new instance of the class + /// with the specified , + /// , + /// , + /// and . /// /// - /// A that represents the name of the server that shares - /// a secure connection. + /// A that represents the name of the server that + /// will share a secure connection. /// /// /// A that contains client certificates. /// /// - /// The enum value that represents the protocols used for - /// authentication. + /// The enum values that represent the protocols + /// used for authentication. /// /// - /// true if the certificate revocation list is checked during authentication; - /// otherwise, false. + /// true if the certificate revocation list is checked during + /// authentication; otherwise, false. /// public ClientSslConfiguration ( string targetHost, From b6d8fb98f94a6cdd582cef4753f36199e9ef33d6 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 10 May 2017 15:27:57 +0900 Subject: [PATCH 1155/6294] [Modify] Edit it --- websocket-sharp/Net/ClientSslConfiguration.cs | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Net/ClientSslConfiguration.cs b/websocket-sharp/Net/ClientSslConfiguration.cs index b8fd4edff..342bfb16e 100644 --- a/websocket-sharp/Net/ClientSslConfiguration.cs +++ b/websocket-sharp/Net/ClientSslConfiguration.cs @@ -122,15 +122,22 @@ public X509CertificateCollection ClientCertificates { } /// - /// Gets or sets the callback used to select a client certificate to supply to the server. + /// Gets or sets the callback used to select the certificate to + /// supply to the server. /// /// - /// If this callback returns , no client certificate will be supplied. + /// No certificate is supplied if the callback returns + /// . /// /// - /// A delegate that references the method - /// used to select the client certificate. The default value is a function that only returns - /// . + /// + /// A delegate that + /// invokes the method called for selecting the certificate. + /// + /// + /// The default value is a delegate that invokes a method that + /// only returns . + /// /// public LocalCertificateSelectionCallback ClientCertificateSelectionCallback { get { From 2beccaf96c5060fe7c292d4e3be6cac97e953c31 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 10 May 2017 15:33:59 +0900 Subject: [PATCH 1156/6294] [Modify] Edit it --- websocket-sharp/Net/ClientSslConfiguration.cs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Net/ClientSslConfiguration.cs b/websocket-sharp/Net/ClientSslConfiguration.cs index 342bfb16e..627a18a6f 100644 --- a/websocket-sharp/Net/ClientSslConfiguration.cs +++ b/websocket-sharp/Net/ClientSslConfiguration.cs @@ -150,15 +150,21 @@ public LocalCertificateSelectionCallback ClientCertificateSelectionCallback { } /// - /// Gets or sets the callback used to validate the certificate supplied by the server. + /// Gets or sets the callback used to validate the certificate + /// supplied by the server. /// /// - /// If this callback returns true, the server certificate will be valid. + /// The certificate is valid if the callback returns true. /// /// - /// A delegate that references the method - /// used to validate the server certificate. The default value is a function that only returns - /// true. + /// + /// A delegate that + /// invokes the method called for validating the certificate. + /// + /// + /// The default value is a delegate that invokes a method that + /// only returns true. + /// /// public RemoteCertificateValidationCallback ServerCertificateValidationCallback { get { From f1c4083835a3d73a4a30fc2d32c4e49cff8fac54 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 10 May 2017 16:31:01 +0900 Subject: [PATCH 1157/6294] [Modify] Edit it --- websocket-sharp/Net/ClientSslConfiguration.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/ClientSslConfiguration.cs b/websocket-sharp/Net/ClientSslConfiguration.cs index 627a18a6f..3900bc66e 100644 --- a/websocket-sharp/Net/ClientSslConfiguration.cs +++ b/websocket-sharp/Net/ClientSslConfiguration.cs @@ -177,11 +177,11 @@ public RemoteCertificateValidationCallback ServerCertificateValidationCallback { } /// - /// Gets or sets the name of the server that shares a secure connection. + /// Gets or sets the target host server name. /// /// - /// A that represents the name of the server that shares - /// a secure connection. + /// A that represents the name of the server that + /// will share a secure connection. /// public string TargetHost { get { From de4f97013f47783b3ac2440f31e7da57039ed5c3 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 10 May 2017 16:34:32 +0900 Subject: [PATCH 1158/6294] [Modify] Rename it --- websocket-sharp/Net/ClientSslConfiguration.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/ClientSslConfiguration.cs b/websocket-sharp/Net/ClientSslConfiguration.cs index 3900bc66e..3d2c443de 100644 --- a/websocket-sharp/Net/ClientSslConfiguration.cs +++ b/websocket-sharp/Net/ClientSslConfiguration.cs @@ -47,7 +47,7 @@ public class ClientSslConfiguration : SslConfiguration { #region Private Fields - private X509CertificateCollection _certs; + private X509CertificateCollection _clientCerts; private string _host; #endregion @@ -98,7 +98,7 @@ bool checkCertificateRevocation : base (enabledSslProtocols, checkCertificateRevocation) { _host = targetHost; - _certs = clientCertificates; + _clientCerts = clientCertificates; } #endregion @@ -113,11 +113,11 @@ bool checkCertificateRevocation /// public X509CertificateCollection ClientCertificates { get { - return _certs; + return _clientCerts; } set { - _certs = value; + _clientCerts = value; } } From f7b2ee650182299ecb32d379f93be0cfb9b5ee80 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 10 May 2017 16:38:01 +0900 Subject: [PATCH 1159/6294] [Modify] Rename it --- websocket-sharp/Net/ClientSslConfiguration.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/ClientSslConfiguration.cs b/websocket-sharp/Net/ClientSslConfiguration.cs index 3d2c443de..02645e8c6 100644 --- a/websocket-sharp/Net/ClientSslConfiguration.cs +++ b/websocket-sharp/Net/ClientSslConfiguration.cs @@ -48,7 +48,7 @@ public class ClientSslConfiguration : SslConfiguration #region Private Fields private X509CertificateCollection _clientCerts; - private string _host; + private string _targetHost; #endregion @@ -97,7 +97,7 @@ bool checkCertificateRevocation ) : base (enabledSslProtocols, checkCertificateRevocation) { - _host = targetHost; + _targetHost = targetHost; _clientCerts = clientCertificates; } @@ -185,11 +185,11 @@ public RemoteCertificateValidationCallback ServerCertificateValidationCallback { /// public string TargetHost { get { - return _host; + return _targetHost; } set { - _host = value; + _targetHost = value; } } From e22acbd2401905f749c34e72ea9198ee7b68a626 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 11 May 2017 15:20:31 +0900 Subject: [PATCH 1160/6294] [Modify] Not inherit it --- websocket-sharp/Net/ClientSslConfiguration.cs | 97 +++++++++++++++++-- 1 file changed, 89 insertions(+), 8 deletions(-) diff --git a/websocket-sharp/Net/ClientSslConfiguration.cs b/websocket-sharp/Net/ClientSslConfiguration.cs index 02645e8c6..750564138 100644 --- a/websocket-sharp/Net/ClientSslConfiguration.cs +++ b/websocket-sharp/Net/ClientSslConfiguration.cs @@ -43,12 +43,16 @@ namespace WebSocketSharp.Net /// /// Stores the parameters for the used by clients. /// - public class ClientSslConfiguration : SslConfiguration + public class ClientSslConfiguration { #region Private Fields - private X509CertificateCollection _clientCerts; - private string _targetHost; + private bool _checkCertRevocation; + private LocalCertificateSelectionCallback _clientCertSelectionCallback; + private X509CertificateCollection _clientCerts; + private SslProtocols _enabledSslProtocols; + private RemoteCertificateValidationCallback _serverCertValidationCallback; + private string _targetHost; #endregion @@ -95,16 +99,40 @@ public ClientSslConfiguration ( SslProtocols enabledSslProtocols, bool checkCertificateRevocation ) - : base (enabledSslProtocols, checkCertificateRevocation) { _targetHost = targetHost; _clientCerts = clientCertificates; + _enabledSslProtocols = enabledSslProtocols; + _checkCertRevocation = checkCertificateRevocation; } #endregion #region Public Properties + /// + /// Gets or sets a value indicating whether the certificate revocation + /// list is checked during authentication. + /// + /// + /// + /// true if the certificate revocation list is checked during + /// authentication; otherwise, false. + /// + /// + /// The default value is false. + /// + /// + public bool CheckCertificateRevocation { + get { + return _checkCertRevocation; + } + + set { + _checkCertRevocation = value; + } + } + /// /// Gets or sets the collection that contains client certificates. /// @@ -141,11 +169,36 @@ public X509CertificateCollection ClientCertificates { /// public LocalCertificateSelectionCallback ClientCertificateSelectionCallback { get { - return CertificateSelectionCallback; + if (_clientCertSelectionCallback == null) + _clientCertSelectionCallback = defaultSelectClientCertificate; + + return _clientCertSelectionCallback; } set { - CertificateSelectionCallback = value; + _clientCertSelectionCallback = value; + } + } + + /// + /// Gets or sets the protocols used for authentication. + /// + /// + /// + /// The enum values that represent + /// the protocols used for authentication. + /// + /// + /// The default value is . + /// + /// + public SslProtocols EnabledSslProtocols { + get { + return _enabledSslProtocols; + } + + set { + _enabledSslProtocols = value; } } @@ -168,11 +221,14 @@ public LocalCertificateSelectionCallback ClientCertificateSelectionCallback { /// public RemoteCertificateValidationCallback ServerCertificateValidationCallback { get { - return CertificateValidationCallback; + if (_serverCertValidationCallback == null) + _serverCertValidationCallback = defaultValidateServerCertificate; + + return _serverCertValidationCallback; } set { - CertificateValidationCallback = value; + _serverCertValidationCallback = value; } } @@ -194,5 +250,30 @@ public string TargetHost { } #endregion + + #region Private Methods + + private static X509Certificate defaultSelectClientCertificate ( + object sender, + string targetHost, + X509CertificateCollection clientCertificates, + X509Certificate serverCertificate, + string[] acceptableIssuers + ) + { + return null; + } + + private static bool defaultValidateServerCertificate ( + object sender, + X509Certificate certificate, + X509Chain chain, + SslPolicyErrors sslPolicyErrors + ) + { + return true; + } + + #endregion } } From 3793b4112e4753aeb9e69ac823be32432798c510 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 11 May 2017 15:26:56 +0900 Subject: [PATCH 1161/6294] [Modify] Add it --- websocket-sharp/Net/ClientSslConfiguration.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/websocket-sharp/Net/ClientSslConfiguration.cs b/websocket-sharp/Net/ClientSslConfiguration.cs index 750564138..523b8e547 100644 --- a/websocket-sharp/Net/ClientSslConfiguration.cs +++ b/websocket-sharp/Net/ClientSslConfiguration.cs @@ -58,6 +58,14 @@ public class ClientSslConfiguration #region Public Constructors + /// + /// Initializes a new instance of the class. + /// + public ClientSslConfiguration () + { + _enabledSslProtocols = SslProtocols.Default; + } + /// /// Initializes a new instance of the class /// with the specified . From a748e1bd1606ff2f55bc01c6696855fd2a5e045a Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 11 May 2017 15:38:27 +0900 Subject: [PATCH 1162/6294] [Modify] Add it --- websocket-sharp/Net/ClientSslConfiguration.cs | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/websocket-sharp/Net/ClientSslConfiguration.cs b/websocket-sharp/Net/ClientSslConfiguration.cs index 523b8e547..714aab629 100644 --- a/websocket-sharp/Net/ClientSslConfiguration.cs +++ b/websocket-sharp/Net/ClientSslConfiguration.cs @@ -34,6 +34,7 @@ */ #endregion +using System; using System.Net.Security; using System.Security.Authentication; using System.Security.Cryptography.X509Certificates; @@ -79,6 +80,29 @@ public ClientSslConfiguration (string targetHost) { } + /// + /// Copies the parameters from the specified to + /// a new instance of the class. + /// + /// + /// A from which to copy. + /// + /// + /// is . + /// + public ClientSslConfiguration (ClientSslConfiguration configuration) + { + if (configuration == null) + throw new ArgumentNullException ("configuration"); + + _checkCertRevocation = configuration._checkCertRevocation; + _clientCertSelectionCallback = configuration._clientCertSelectionCallback; + _clientCerts = configuration._clientCerts; + _enabledSslProtocols = configuration._enabledSslProtocols; + _serverCertValidationCallback = configuration._serverCertValidationCallback; + _targetHost = configuration._targetHost; + } + /// /// Initializes a new instance of the class /// with the specified , From e4d60a2c43671c7cd4c9334eab5f031bac83a33e Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 11 May 2017 15:45:44 +0900 Subject: [PATCH 1163/6294] [Modify] Remove it --- websocket-sharp/Net/ClientSslConfiguration.cs | 38 +------------------ 1 file changed, 2 insertions(+), 36 deletions(-) diff --git a/websocket-sharp/Net/ClientSslConfiguration.cs b/websocket-sharp/Net/ClientSslConfiguration.cs index 714aab629..b6abbd5fa 100644 --- a/websocket-sharp/Net/ClientSslConfiguration.cs +++ b/websocket-sharp/Net/ClientSslConfiguration.cs @@ -76,8 +76,9 @@ public ClientSslConfiguration () /// will share a secure connection. /// public ClientSslConfiguration (string targetHost) - : this (targetHost, null, SslProtocols.Default, false) { + _targetHost = targetHost; + _enabledSslProtocols = SslProtocols.Default; } /// @@ -103,41 +104,6 @@ public ClientSslConfiguration (ClientSslConfiguration configuration) _targetHost = configuration._targetHost; } - /// - /// Initializes a new instance of the class - /// with the specified , - /// , - /// , - /// and . - /// - /// - /// A that represents the name of the server that - /// will share a secure connection. - /// - /// - /// A that contains client certificates. - /// - /// - /// The enum values that represent the protocols - /// used for authentication. - /// - /// - /// true if the certificate revocation list is checked during - /// authentication; otherwise, false. - /// - public ClientSslConfiguration ( - string targetHost, - X509CertificateCollection clientCertificates, - SslProtocols enabledSslProtocols, - bool checkCertificateRevocation - ) - { - _targetHost = targetHost; - _clientCerts = clientCertificates; - _enabledSslProtocols = enabledSslProtocols; - _checkCertRevocation = checkCertificateRevocation; - } - #endregion #region Public Properties From e00bd50f153d7c961d93204c8d196efd18bf84ce Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 12 May 2017 15:53:24 +0900 Subject: [PATCH 1164/6294] [Modify] Edit it --- websocket-sharp/Net/ClientSslConfiguration.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/ClientSslConfiguration.cs b/websocket-sharp/Net/ClientSslConfiguration.cs index b6abbd5fa..8854eff0b 100644 --- a/websocket-sharp/Net/ClientSslConfiguration.cs +++ b/websocket-sharp/Net/ClientSslConfiguration.cs @@ -234,8 +234,14 @@ public RemoteCertificateValidationCallback ServerCertificateValidationCallback { /// Gets or sets the target host server name. /// /// - /// A that represents the name of the server that - /// will share a secure connection. + /// + /// A or + /// if not specified. + /// + /// + /// That string represents the name of the server that + /// will share a secure connection with a client. + /// /// public string TargetHost { get { From 4887ebe353f50c0ecc007b54634befe9a50e353d Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 12 May 2017 18:05:33 +0900 Subject: [PATCH 1165/6294] [Modify] Edit it --- websocket-sharp/Net/ClientSslConfiguration.cs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/ClientSslConfiguration.cs b/websocket-sharp/Net/ClientSslConfiguration.cs index 8854eff0b..236f7deab 100644 --- a/websocket-sharp/Net/ClientSslConfiguration.cs +++ b/websocket-sharp/Net/ClientSslConfiguration.cs @@ -132,10 +132,19 @@ public bool CheckCertificateRevocation { } /// - /// Gets or sets the collection that contains client certificates. + /// Gets or sets the certificates from which to select one to + /// supply to the server. /// /// - /// A that contains client certificates. + /// + /// A or . + /// + /// + /// That collection contains client certificates from which to select. + /// + /// + /// The default value is . + /// /// public X509CertificateCollection ClientCertificates { get { From 74ee44a4b9875326267288dd4aec3ca4a4c84cee Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 13 May 2017 14:30:08 +0900 Subject: [PATCH 1166/6294] [Modify] Edit it --- websocket-sharp/Net/ClientSslConfiguration.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/websocket-sharp/Net/ClientSslConfiguration.cs b/websocket-sharp/Net/ClientSslConfiguration.cs index 236f7deab..fbff84c65 100644 --- a/websocket-sharp/Net/ClientSslConfiguration.cs +++ b/websocket-sharp/Net/ClientSslConfiguration.cs @@ -72,8 +72,7 @@ public ClientSslConfiguration () /// with the specified . /// /// - /// A that represents the name of the server that - /// will share a secure connection. + /// A that represents the target host server name. /// public ClientSslConfiguration (string targetHost) { From ee958b0d40580cb165be71863a4a8ebd896a7845 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 13 May 2017 14:57:55 +0900 Subject: [PATCH 1167/6294] [Modify] 2017 --- websocket-sharp/Net/ClientSslConfiguration.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/ClientSslConfiguration.cs b/websocket-sharp/Net/ClientSslConfiguration.cs index fbff84c65..800bcb30d 100644 --- a/websocket-sharp/Net/ClientSslConfiguration.cs +++ b/websocket-sharp/Net/ClientSslConfiguration.cs @@ -5,7 +5,7 @@ * The MIT License * * Copyright (c) 2014 liryna - * Copyright (c) 2014 sta.blockhead + * Copyright (c) 2014-2017 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From 65696a126c2438e44fd9960f7ba2fb389b2e7122 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 14 May 2017 15:26:42 +0900 Subject: [PATCH 1168/6294] [Delete] SslConfiguration.cs --- websocket-sharp/Net/SslConfiguration.cs | 172 ------------------------ websocket-sharp/websocket-sharp.csproj | 1 - 2 files changed, 173 deletions(-) delete mode 100644 websocket-sharp/Net/SslConfiguration.cs diff --git a/websocket-sharp/Net/SslConfiguration.cs b/websocket-sharp/Net/SslConfiguration.cs deleted file mode 100644 index bfd3e5ac0..000000000 --- a/websocket-sharp/Net/SslConfiguration.cs +++ /dev/null @@ -1,172 +0,0 @@ -#region License -/* - * SslConfiguration.cs - * - * This code is derived from ClientSslConfiguration.cs. - * - * The MIT License - * - * Copyright (c) 2014 liryna - * Copyright (c) 2014 sta.blockhead - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, 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 NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -#endregion - -#region Authors -/* - * Authors: - * - Liryna - */ -#endregion - -using System.Net.Security; -using System.Security.Authentication; - -namespace WebSocketSharp.Net -{ - /// - /// Stores the parameters used to configure a instance. - /// - /// - /// The SslConfiguration class is an abstract class. - /// - public abstract class SslConfiguration - { - #region Private Fields - - private LocalCertificateSelectionCallback _certSelectionCallback; - private RemoteCertificateValidationCallback _certValidationCallback; - private bool _checkCertRevocation; - private SslProtocols _enabledProtocols; - - #endregion - - #region Protected Constructors - - /// - /// Initializes a new instance of the class with - /// the specified and - /// . - /// - /// - /// The enum value that represents the protocols used for - /// authentication. - /// - /// - /// true if the certificate revocation list is checked during authentication; - /// otherwise, false. - /// - protected SslConfiguration (SslProtocols enabledSslProtocols, bool checkCertificateRevocation) - { - _enabledProtocols = enabledSslProtocols; - _checkCertRevocation = checkCertificateRevocation; - } - - #endregion - - #region Protected Properties - - /// - /// Gets or sets the callback used to select a certificate to supply to the remote party. - /// - /// - /// If this callback returns , no certificate will be supplied. - /// - /// - /// A delegate that references the method - /// used to select a certificate. The default value is a function that only returns - /// . - /// - protected LocalCertificateSelectionCallback CertificateSelectionCallback { - get { - return _certSelectionCallback ?? - (_certSelectionCallback = - (sender, targetHost, localCertificates, remoteCertificate, acceptableIssuers) => - null); - } - - set { - _certSelectionCallback = value; - } - } - - /// - /// Gets or sets the callback used to validate the certificate supplied by the remote party. - /// - /// - /// If this callback returns true, the certificate will be valid. - /// - /// - /// A delegate that references the method - /// used to validate the certificate. The default value is a function that only returns - /// true. - /// - protected RemoteCertificateValidationCallback CertificateValidationCallback { - get { - return _certValidationCallback ?? - (_certValidationCallback = (sender, certificate, chain, sslPolicyErrors) => true); - } - - set { - _certValidationCallback = value; - } - } - - #endregion - - #region Public Properties - - /// - /// Gets or sets a value indicating whether the certificate revocation list is checked - /// during authentication. - /// - /// - /// true if the certificate revocation list is checked; otherwise, false. - /// - public bool CheckCertificateRevocation { - get { - return _checkCertRevocation; - } - - set { - _checkCertRevocation = value; - } - } - - /// - /// Gets or sets the SSL protocols used for authentication. - /// - /// - /// The enum value that represents the protocols used for - /// authentication. - /// - public SslProtocols EnabledSslProtocols { - get { - return _enabledProtocols; - } - - set { - _enabledProtocols = value; - } - } - - #endregion - } -} diff --git a/websocket-sharp/websocket-sharp.csproj b/websocket-sharp/websocket-sharp.csproj index 087679547..0860c0313 100644 --- a/websocket-sharp/websocket-sharp.csproj +++ b/websocket-sharp/websocket-sharp.csproj @@ -135,7 +135,6 @@ - From bfeac38f0cb8eb6497dbc66cfad333fa5f69575e Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 15 May 2017 16:24:02 +0900 Subject: [PATCH 1169/6294] [Modify] Create it if secure --- websocket-sharp/Server/WebSocketServer.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 0cb848be8..cd9f56ab8 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -766,8 +766,9 @@ private string getRealm () private ServerSslConfiguration getSslConfiguration () { - var sslConfig = _sslConfig; - return sslConfig != null ? new ServerSslConfiguration (sslConfig) : null; + return _secure && _sslConfig != null + ? new ServerSslConfiguration (_sslConfig) + : null; } private void init ( From 8c8f32d2081badc767a01fa2c6f6dd420f06241e Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 16 May 2017 17:37:30 +0900 Subject: [PATCH 1170/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketServer.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index cd9f56ab8..ee0123602 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -746,12 +746,12 @@ private bool checkSslConfiguration ( return true; if (configuration == null) { - message = "There is no configuration."; + message = "There is no configuration for secure connections."; return false; } if (configuration.ServerCertificate == null) { - message = "The configuration has no server certificate."; + message = "There is no server certificate."; return false; } From 20631d494d2228eb277f5757fd58ebefce24fe7f Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 17 May 2017 13:59:51 +0900 Subject: [PATCH 1171/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index ee0123602..1867d78f8 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -570,7 +570,7 @@ public bool ReuseAddress { } /// - /// Gets the configuration used to provide secure connections. + /// Gets the configuration for secure connections. /// /// /// The configuration will be referenced when the server starts. From 0075defe21bbeda60696b77265bea657e2e9befe Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 17 May 2017 14:09:38 +0900 Subject: [PATCH 1172/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 1867d78f8..bb7c5c1d2 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -1261,8 +1261,15 @@ public bool RemoveWebSocketService (string path) /// it is shutting down. /// /// - /// There is no configuration used to provide secure connections or - /// the configuration has no server certificate. + /// + /// There is no configuration for secure connections. + /// + /// + /// -or- + /// + /// + /// There is no server certificate. + /// /// /// /// The underlying has failed to start. From c4ba64e8a0e5d59270f17ca1a4a876449d26ed5b Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 17 May 2017 14:15:07 +0900 Subject: [PATCH 1173/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index bb7c5c1d2..5c3c59d5e 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -405,7 +405,8 @@ public bool IsListening { } /// - /// Gets a value indicating whether the server provides secure connections. + /// Gets a value indicating whether the server provides + /// secure connections. /// /// /// true if the server provides secure connections; From d14883bba76c71c949ebfb534f70e22ea7a1be90 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 17 May 2017 15:35:30 +0900 Subject: [PATCH 1174/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 5c3c59d5e..ec0842440 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -489,7 +489,7 @@ public int Port { } /// - /// Gets or sets the name of the realm for the server. + /// Gets or sets the realm used for authentication. /// /// /// @@ -497,13 +497,18 @@ public int Port { /// already started or it is shutting down. /// /// - /// If this property is or empty, - /// SECRET AREA will be used as the name. + /// SECRET AREA will be used as the name if the value is + /// or an empty string. /// /// /// - /// A that represents the name of - /// the realm or by default. + /// + /// A or + /// by default. + /// + /// + /// That string represents the name of the realm. + /// /// public string Realm { get { From a9e5630954b8aeaa6d97115cde3800b380fd3ebe Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 17 May 2017 16:05:41 +0900 Subject: [PATCH 1175/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index ec0842440..671eb114c 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -360,14 +360,21 @@ public bool AllowForwardedRequest { /// Gets or sets the scheme used to authenticate the clients. /// /// - /// The set operation does nothing if the server has already started or - /// it is shutting down. + /// The set operation does nothing if the server has already + /// started or it is shutting down. /// /// - /// One of the enum - /// values. It specifies the scheme used to authenticate the clients. - /// The default value is - /// . + /// + /// One of the + /// enum values. + /// + /// + /// It represents the scheme used to authenticate the clients. + /// + /// + /// The default value is + /// . + /// /// public AuthenticationSchemes AuthenticationSchemes { get { From ae9283f7bdac98c23b54a494a5f032a9ae1922b1 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 17 May 2017 17:17:38 +0900 Subject: [PATCH 1176/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 671eb114c..4b540ef56 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -325,13 +325,17 @@ public System.Net.IPAddress Address { /// a handshake request without checking the request URI. /// /// - /// The set operation does nothing if the server has already started or - /// it is shutting down. + /// The set operation does nothing if the server has already + /// started or it is shutting down. /// /// - /// true if the server accepts a handshake request without - /// checking the request URI; otherwise, false. The default - /// value is false. + /// + /// true if the server accepts a handshake request without + /// checking the request URI; otherwise, false. + /// + /// + /// The default value is false. + /// /// public bool AllowForwardedRequest { get { From 8708f01702f772495d1ee3fed057dc8c70e2c073 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 18 May 2017 14:46:36 +0900 Subject: [PATCH 1177/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 4b540ef56..9e4273dd8 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -434,12 +434,17 @@ public bool IsSecure { /// the inactive sessions periodically. /// /// - /// The set operation does nothing if the server has already started or - /// it is shutting down. + /// The set operation does nothing if the server has already + /// started or it is shutting down. /// /// - /// true if the server cleans up the inactive sessions every 60 - /// seconds; otherwise, false. The default value is true. + /// + /// true if the server cleans up the inactive sessions + /// every 60 seconds; otherwise, false. + /// + /// + /// The default value is true. + /// /// public bool KeepClean { get { From aa159dc342cbe8652d1eed0d154d9f703220744a Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 18 May 2017 15:15:29 +0900 Subject: [PATCH 1178/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 9e4273dd8..8e674a5f9 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -473,14 +473,7 @@ public bool KeepClean { /// Gets the logging function for the server. /// /// - /// - /// The default logging level is . - /// - /// - /// If you would like to change the logging level, - /// you should set the Log.Level property to - /// any of the enum values. - /// + /// The default logging level is . /// /// /// A that provides the logging function. From aa7d1265fe4216a8f200ecf2a2d704b5c9f4cd2a Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 18 May 2017 15:25:49 +0900 Subject: [PATCH 1179/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 8e674a5f9..4141ca682 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -485,11 +485,11 @@ public Logger Log { } /// - /// Gets the port number of the server. + /// Gets the port of the server. /// /// - /// An that represents the port number on which to - /// listen for the incoming handshake requests. + /// An that represents the number of the port + /// on which to listen for the incoming handshake requests. /// public int Port { get { From 4448e8bd150563555faea80f2748a4db4d82c783 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 18 May 2017 15:30:34 +0900 Subject: [PATCH 1180/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 4141ca682..f7e7412eb 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -502,8 +502,8 @@ public int Port { /// /// /// - /// The set operation does nothing if the server has - /// already started or it is shutting down. + /// The set operation does nothing if the server has already + /// started or it is shutting down. /// /// /// SECRET AREA will be used as the name if the value is From 5211d3c8a5d3bbc068a2e5ee84dda802a9208cb0 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 18 May 2017 15:45:30 +0900 Subject: [PATCH 1181/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index f7e7412eb..136f59f1b 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -548,18 +548,22 @@ public string Realm { /// /// /// - /// The set operation does nothing if the server has already started or - /// it is shutting down. + /// The set operation does nothing if the server has already + /// started or it is shutting down. /// /// - /// If you would like to resolve to wait for socket in TIME_WAIT state, - /// you should set this property to true. + /// You should set this property to true if you would + /// like to resolve to wait for socket in TIME_WAIT state. /// /// /// - /// true if the server is allowed to be bound to an address that - /// is already in use; otherwise, false. The default value is - /// false. + /// + /// true if the server is allowed to be bound to an address + /// that is already in use; otherwise, false. + /// + /// + /// The default value is false. + /// /// public bool ReuseAddress { get { From ea63a299f9106c0b54ad6b9ee32c6dc0cbedd5fe Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 19 May 2017 15:21:57 +0900 Subject: [PATCH 1182/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 136f59f1b..bd2c37884 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -609,22 +609,32 @@ public ServerSslConfiguration SslConfiguration { } /// - /// Gets or sets the delegate used to find the credentials for an identity. + /// Gets or sets the delegate used to find the credentials for + /// an identity. /// /// - /// The set operation does nothing if the server has already started or - /// it is shutting down. + /// + /// The set operation does nothing if the server has already + /// started or it is shutting down. + /// + /// + /// No credentials are found if the method invoked by + /// the delegate returns or + /// the value is . + /// /// /// /// /// A Func<IIdentity, NetworkCredential> delegate or - /// if not needed. The default value is - /// . + /// if not needed. /// /// /// That delegate invokes the method called for finding /// the credentials used to authenticate a client. /// + /// + /// The default value is . + /// /// public Func UserCredentialsFinder { get { From 42272d08813df6e60b23b19b30d7fea6b6c398da Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 20 May 2017 13:06:36 +0900 Subject: [PATCH 1183/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index bd2c37884..f1fe2923a 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -660,7 +660,7 @@ public Func UserCredentialsFinder { } /// - /// Gets or sets the wait time for the response to + /// Gets or sets the time to wait for the response to /// the WebSocket Ping or Close. /// /// @@ -668,8 +668,12 @@ public Func UserCredentialsFinder { /// started or it is shutting down. /// /// - /// A that represents the wait time for - /// the response. The default value is the same as 1 second. + /// + /// A to wait for the response. + /// + /// + /// The default value is the same as 1 second. + /// /// /// /// The value specified for a set operation is zero or less. From 76c6cf61b409c98501f4c7036487d3157355927c Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 20 May 2017 13:13:16 +0900 Subject: [PATCH 1184/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index f1fe2923a..fd4264f37 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -1290,8 +1290,8 @@ public bool RemoveWebSocketService (string path) /// Starts receiving the WebSocket handshake requests. /// /// - /// This method does nothing if the server has already started or - /// it is shutting down. + /// This method does nothing if the server has already + /// started or it is shutting down. /// /// /// From 67ed9154617b99f2f0e9933db0781a38601f739e Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 20 May 2017 13:25:14 +0900 Subject: [PATCH 1185/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index fd4264f37..a140a652c 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -120,7 +120,8 @@ public WebSocketServer () /// /// /// - /// An that represents the port number on which to listen. + /// An that represents the number of the port + /// on which to listen. /// /// /// is less than 1 or greater than 65535. From b4f0330648b2b442d65354b0903eb954c254ac66 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 21 May 2017 15:33:36 +0900 Subject: [PATCH 1186/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index a140a652c..6bd8aa57b 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -133,25 +133,25 @@ public WebSocketServer (int port) /// /// Initializes a new instance of the class - /// with the specified WebSocket URL. + /// with the specified . /// /// /// /// The new instance listens for the incoming handshake requests on - /// the host name and port of . + /// the host and port of . /// /// /// It provides secure connections if the scheme of /// is wss. /// /// - /// If includes no port, either port 80 or 443 is - /// used on which to listen. It is determined by the scheme (ws or wss) - /// of . + /// Either port 80 or 443 is used if includes + /// no port. Port 443 is used if the scheme of + /// is wss; otherwise, port 80 is used. /// /// /// - /// A that represents the WebSocket URL for the server. + /// A that represents the WebSocket URL of the server. /// /// /// is . From ff6d36eba76ccc19b3c325b4ccbf498982b0dd6a Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 21 May 2017 16:09:54 +0900 Subject: [PATCH 1187/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 6bd8aa57b..c528db16f 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -197,19 +197,20 @@ public WebSocketServer (string url) } /// - /// Initializes a new instance of the class with - /// the specified and . + /// Initializes a new instance of the class + /// with the specified and . /// /// /// The new instance listens for the incoming handshake requests on /// . /// /// - /// An that represents the port number on which to listen. + /// An that represents the number of the port + /// on which to listen. /// /// - /// A that specifies providing secure connections or not. - /// true specifies providing secure connections. + /// A : true if the server provides + /// secure connections; otherwise, false. /// /// /// is less than 1 or greater than 65535. From 10fd7ef16da4f08751bba831f09bd1ac10c6817b Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 21 May 2017 16:20:43 +0900 Subject: [PATCH 1188/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index c528db16f..3deb56b0c 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -227,8 +227,8 @@ public WebSocketServer (int port, bool secure) } /// - /// Initializes a new instance of the class with - /// the specified and . + /// Initializes a new instance of the class + /// with the specified and . /// /// /// @@ -240,11 +240,12 @@ public WebSocketServer (int port, bool secure) /// /// /// - /// A that represents the local IP address - /// for the server. + /// A that represents + /// a local IP address of the server. /// /// - /// An that represents the port number on which to listen. + /// An that represents the number of the port + /// on which to listen. /// /// /// is . From fa2f01e3f7ad60ea8c5648fd5d63497e1c1fd432 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 22 May 2017 14:50:08 +0900 Subject: [PATCH 1189/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 3deb56b0c..003482602 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -267,19 +267,20 @@ public WebSocketServer (System.Net.IPAddress address, int port) /// and . /// /// - /// The new instance listens for the incoming handshake requests on + /// The new instance listens for incoming handshake requests on /// and . /// /// - /// A that represents the local IP address - /// for the server. + /// A that represents + /// the local IP address on which to listen. /// /// - /// An that represents the port number on which to listen. + /// An that represents the number of + /// the port on which to listen. /// /// - /// A that specifies providing secure connections or not. - /// true specifies providing secure connections. + /// A : true if the new instance provides + /// secure connections; otherwise, false. /// /// /// is . From a16927f980c35c0881f86b2b45ae98aed6a71758 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 22 May 2017 14:55:42 +0900 Subject: [PATCH 1190/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 003482602..ef2f90a4f 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -98,7 +98,8 @@ static WebSocketServer () /// Initializes a new instance of the class. /// /// - /// The new instance listens for the incoming handshake requests on port 80. + /// The new instance listens for incoming handshake requests on + /// and port 80. /// public WebSocketServer () { From 5fa5f505de1c7c8a514ce891915602ffa8908a69 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 22 May 2017 15:02:12 +0900 Subject: [PATCH 1191/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index ef2f90a4f..20ebfd7d3 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -113,16 +113,16 @@ public WebSocketServer () /// /// /// - /// The new instance listens for the incoming handshake requests on - /// . + /// The new instance listens for incoming handshake requests on + /// and . /// /// /// It provides secure connections if is 443. /// /// /// - /// An that represents the number of the port - /// on which to listen. + /// An that represents the number of + /// the port on which to listen. /// /// /// is less than 1 or greater than 65535. From 20378401bde7ab85f674351401975ea724917cb5 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 23 May 2017 14:45:55 +0900 Subject: [PATCH 1192/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 20ebfd7d3..f15740556 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -138,8 +138,9 @@ public WebSocketServer (int port) /// /// /// - /// The new instance listens for the incoming handshake requests on - /// the host and port of . + /// The new instance listens for incoming handshake requests on + /// the local IP address of the host and the port included in + /// . /// /// /// It provides secure connections if the scheme of @@ -152,7 +153,8 @@ public WebSocketServer (int port) /// /// /// - /// A that represents the WebSocket URL of the server. + /// A that represents the WebSocket URL + /// on which to listen. /// /// /// is . From ada598a2e3acb775855d89c996641138eaf32e6d Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 23 May 2017 14:52:52 +0900 Subject: [PATCH 1193/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index f15740556..a7c579462 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -204,15 +204,15 @@ public WebSocketServer (string url) /// with the specified and . /// /// - /// The new instance listens for the incoming handshake requests on - /// . + /// The new instance listens for incoming handshake requests on + /// and . /// /// - /// An that represents the number of the port - /// on which to listen. + /// An that represents the number of + /// the port on which to listen. /// /// - /// A : true if the server provides + /// A : true if the new instance provides /// secure connections; otherwise, false. /// /// From 9f22274c8842dc022364eb632e6dddb8a8d7bc06 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 23 May 2017 14:56:34 +0900 Subject: [PATCH 1194/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index a7c579462..9dce347fc 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -235,7 +235,7 @@ public WebSocketServer (int port, bool secure) /// /// /// - /// The new instance listens for the incoming handshake requests on + /// The new instance listens for incoming handshake requests on /// and . /// /// @@ -244,11 +244,11 @@ public WebSocketServer (int port, bool secure) /// /// /// A that represents - /// a local IP address of the server. + /// the local IP address on which to listen. /// /// - /// An that represents the number of the port - /// on which to listen. + /// An that represents the number of + /// the port on which to listen. /// /// /// is . From 393e54b9b80fffa451c72c132f8ad0385432d92a Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 23 May 2017 15:00:58 +0900 Subject: [PATCH 1195/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 9dce347fc..85a7757cd 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -121,8 +121,8 @@ public WebSocketServer () /// /// /// - /// An that represents the number of - /// the port on which to listen. + /// An that represents the number of the port + /// on which to listen. /// /// /// is less than 1 or greater than 65535. From a427f26aa343b2d618f4bada99b7a10a52da4433 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 23 May 2017 15:13:24 +0900 Subject: [PATCH 1196/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketServer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 85a7757cd..f39c50ae8 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -192,7 +192,7 @@ public WebSocketServer (string url) } if (!addr.IsLocal ()) { - msg = "The IP address is not a local IP address."; + msg = "The IP address of the host is not a local IP address."; throw new ArgumentException (msg, "url"); } From c1a275c132ce5aaa85ec1d52ecb8ece2c3e5f00b Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 23 May 2017 15:16:49 +0900 Subject: [PATCH 1197/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketServer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index f39c50ae8..4438db015 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -221,7 +221,7 @@ public WebSocketServer (string url) public WebSocketServer (int port, bool secure) { if (!port.IsPortNumber ()) { - var msg = "It is less than 1 or greater than 65535."; + var msg = "Less than 1 or greater than 65535."; throw new ArgumentOutOfRangeException ("port", msg); } From 4b4dea90a796abd08da08ef973c06e6e829eb9f5 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 23 May 2017 15:18:01 +0900 Subject: [PATCH 1198/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 4438db015..519aa8d9f 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -208,8 +208,8 @@ public WebSocketServer (string url) /// and . /// /// - /// An that represents the number of - /// the port on which to listen. + /// An that represents the number of the port + /// on which to listen. /// /// /// A : true if the new instance provides From dcfd226f2953132ec702578e5bf177b54dcf307d Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 23 May 2017 15:22:15 +0900 Subject: [PATCH 1199/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 519aa8d9f..73053651a 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -247,8 +247,8 @@ public WebSocketServer (int port, bool secure) /// the local IP address on which to listen. /// /// - /// An that represents the number of - /// the port on which to listen. + /// An that represents the number of the port + /// on which to listen. /// /// /// is . From 9ebd5b820e2d1cac8020b6218e18866391f0685f Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 23 May 2017 15:24:22 +0900 Subject: [PATCH 1200/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketServer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 73053651a..573f199ad 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -303,7 +303,7 @@ public WebSocketServer (System.Net.IPAddress address, int port, bool secure) throw new ArgumentException ("Not a local IP address.", "address"); if (!port.IsPortNumber ()) { - var msg = "It is less than 1 or greater than 65535."; + var msg = "Less than 1 or greater than 65535."; throw new ArgumentOutOfRangeException ("port", msg); } From a96a0d9264b752c3c333873e79f5f63069ede40a Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 23 May 2017 15:36:07 +0900 Subject: [PATCH 1201/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 573f199ad..1081c3dc4 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -278,8 +278,8 @@ public WebSocketServer (System.Net.IPAddress address, int port) /// the local IP address on which to listen. /// /// - /// An that represents the number of - /// the port on which to listen. + /// An that represents the number of the port + /// on which to listen. /// /// /// A : true if the new instance provides From 99ae754ea322ca4cab5f463870fe65df74b997c3 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 24 May 2017 13:50:51 +0900 Subject: [PATCH 1202/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 1081c3dc4..7c60284b9 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -139,18 +139,18 @@ public WebSocketServer (int port) /// /// /// The new instance listens for incoming handshake requests on - /// the local IP address of the host and the port included in - /// . - /// - /// - /// It provides secure connections if the scheme of - /// is wss. + /// the local IP address of the host of and + /// the port of . /// /// /// Either port 80 or 443 is used if includes /// no port. Port 443 is used if the scheme of /// is wss; otherwise, port 80 is used. /// + /// + /// That instance provides secure connections if the scheme of + /// is wss. + /// /// /// /// A that represents the WebSocket URL From 18f2dc672f67f31674602353427a8091f60b570d Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 24 May 2017 13:54:15 +0900 Subject: [PATCH 1203/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 7c60284b9..81c2c6562 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -496,7 +496,7 @@ public Logger Log { /// /// /// An that represents the number of the port - /// on which to listen for the incoming handshake requests. + /// on which to listen for incoming handshake requests. /// public int Port { get { From 7099e5a43b3269c84058db205769e753ee0f2ea4 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 24 May 2017 14:59:57 +0900 Subject: [PATCH 1204/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 81c2c6562..c58649132 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -318,8 +318,8 @@ public WebSocketServer (System.Net.IPAddress address, int port, bool secure) /// Gets the IP address of the server. /// /// - /// A that represents - /// the IP address of the server. + /// A that represents the local + /// IP address on which to listen for incoming handshake requests. /// public System.Net.IPAddress Address { get { From 4d196e57982ba3e31b9c8e72fee908a2506807de Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 25 May 2017 14:15:57 +0900 Subject: [PATCH 1205/6294] [Modify] It throws exceptions --- websocket-sharp/Server/WebSocketServer.cs | 59 +++++++++++++++++++++-- 1 file changed, 55 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index c58649132..e7ef8a340 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -1365,15 +1365,66 @@ public void Stop () /// A that represents the reason for /// the close. The size must be 123 bytes or less in UTF-8. /// + /// + /// + /// is less than 1000 or greater than 4999. + /// + /// + /// -or- + /// + /// + /// The size of is greater than 123 bytes. + /// + /// + /// + /// + /// is 1010 (mandatory extension). + /// + /// + /// -or- + /// + /// + /// is 1005 (no status) and + /// there is . + /// + /// + /// -or- + /// + /// + /// could not be UTF-8-encoded. + /// + /// /// /// The underlying has failed to stop. /// public void Stop (ushort code, string reason) { - string msg; - if (!WebSocket.CheckParametersForClose (code, reason, false, out msg)) { - _log.Error (msg); - return; + if (!code.IsCloseStatusCode ()) { + var msg = "Less than 1000 or greater than 4999."; + throw new ArgumentOutOfRangeException ("code", msg); + } + + if (code == 1010) { + var msg = "1010 cannot be used."; + throw new ArgumentException (msg, "code"); + } + + if (!reason.IsNullOrEmpty ()) { + if (code == 1005) { + var msg = "1005 cannot be used."; + throw new ArgumentException (msg, "code"); + } + + byte[] bytes; + if (!reason.TryGetUTF8EncodedBytes (out bytes)) { + var msg = "It could not be UTF-8-encoded."; + throw new ArgumentException (msg, "reason"); + } + + if (bytes.Length > 123) { + var msg = "Its size is greater than 123 bytes."; + throw new ArgumentOutOfRangeException ("reason", msg); + } } stop (code, reason); From b4dd374df203394253caab20b035682d7da5884d Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 25 May 2017 15:05:15 +0900 Subject: [PATCH 1206/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index e7ef8a340..80e8e7f9a 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -1342,9 +1342,9 @@ public void Stop () } /// - /// Stops receiving the WebSocket handshake requests, - /// and closes the WebSocket connections with the specified - /// and . + /// Stops receiving incoming handshake requests and closes each + /// connection with the specified and + /// . /// /// /// This method does nothing if the server is not started, @@ -1362,8 +1362,8 @@ public void Stop () /// /// /// - /// A that represents the reason for - /// the close. The size must be 123 bytes or less in UTF-8. + /// A that represents the reason for the close. + /// The size must be 123 bytes or less in UTF-8. /// /// /// From 020742c70e0b7b2343e84fa7fc7efbb9c43e8952 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 25 May 2017 15:22:26 +0900 Subject: [PATCH 1207/6294] [Modify] It throws exceptions --- websocket-sharp/Server/WebSocketServer.cs | 47 +++++++++++++++++++++-- 1 file changed, 43 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 80e8e7f9a..5d678dbcb 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -1448,15 +1448,54 @@ public void Stop (ushort code, string reason) /// A that represents the reason for /// the close. The size must be 123 bytes or less in UTF-8. /// + /// + /// The size of is greater than 123 bytes. + /// + /// + /// + /// is + /// . + /// + /// + /// -or- + /// + /// + /// is and + /// there is . + /// + /// + /// -or- + /// + /// + /// could not be UTF-8-encoded. + /// + /// /// /// The underlying has failed to stop. /// public void Stop (CloseStatusCode code, string reason) { - string msg; - if (!WebSocket.CheckParametersForClose (code, reason, false, out msg)) { - _log.Error (msg); - return; + if (code == CloseStatusCode.MandatoryExtension) { + var msg = "MandatoryExtension cannot be used."; + throw new ArgumentException (msg, "code"); + } + + if (!reason.IsNullOrEmpty ()) { + if (code == CloseStatusCode.NoStatus) { + var msg = "NoStatus cannot be used."; + throw new ArgumentException (msg, "code"); + } + + byte[] bytes; + if (!reason.TryGetUTF8EncodedBytes (out bytes)) { + var msg = "It could not be UTF-8-encoded."; + throw new ArgumentException (msg, "reason"); + } + + if (bytes.Length > 123) { + var msg = "Its size is greater than 123 bytes."; + throw new ArgumentOutOfRangeException ("reason", msg); + } } stop ((ushort) code, reason); From 3ac64830aca848bb664d8fd5bed312e9f4798285 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 25 May 2017 15:37:39 +0900 Subject: [PATCH 1208/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 5d678dbcb..39ff03c59 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -1431,22 +1431,25 @@ public void Stop (ushort code, string reason) } /// - /// Stops receiving the WebSocket handshake requests, - /// and closes the WebSocket connections with the specified - /// and . + /// Stops receiving incoming handshake requests and closes each + /// connection with the specified and + /// . /// /// /// This method does nothing if the server is not started, /// it is shutting down, or it has already stopped. /// /// - /// One of the enum values. - /// It represents the status code indicating the reason for - /// the close. + /// + /// One of the enum values. + /// + /// + /// It represents the status code indicating the reason for the close. + /// /// /// - /// A that represents the reason for - /// the close. The size must be 123 bytes or less in UTF-8. + /// A that represents the reason for the close. + /// The size must be 123 bytes or less in UTF-8. /// /// /// The size of is greater than 123 bytes. @@ -1460,7 +1463,8 @@ public void Stop (ushort code, string reason) /// -or- /// /// - /// is and + /// is + /// and /// there is . /// /// From 623ea75f4c9ce597b345a328b08de04b45fc7203 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 26 May 2017 14:16:54 +0900 Subject: [PATCH 1209/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 39ff03c59..3ef92cfc4 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -1326,8 +1326,8 @@ public void Start () } /// - /// Stops receiving the WebSocket handshake requests, - /// and closes the WebSocket connections. + /// Stops receiving incoming handshake requests and + /// closes each connection. /// /// /// This method does nothing if the server is not started, From 1a463448e425dec11717c5e9b5064e356b765398 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 26 May 2017 14:33:02 +0900 Subject: [PATCH 1210/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 3ef92cfc4..a2efef025 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -1294,7 +1294,7 @@ public bool RemoveWebSocketService (string path) } /// - /// Starts receiving the WebSocket handshake requests. + /// Starts receiving incoming handshake requests. /// /// /// This method does nothing if the server has already @@ -1308,7 +1308,7 @@ public bool RemoveWebSocketService (string path) /// -or- /// /// - /// There is no server certificate. + /// There is no certificate in the configuration. /// /// /// From ff679bd6e570669b41bbf3b7e913b812e765f277 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 27 May 2017 15:35:26 +0900 Subject: [PATCH 1211/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketServer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index a2efef025..a8b3cbd7c 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -791,7 +791,7 @@ private bool checkSslConfiguration ( } if (configuration.ServerCertificate == null) { - message = "There is no server certificate."; + message = "There is no certificate in the configuration."; return false; } From 647218d03fa5d3dafe00c171b5659c85d807db60 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 28 May 2017 13:49:50 +0900 Subject: [PATCH 1212/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketServer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index a8b3cbd7c..b858f4a64 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -1032,7 +1032,7 @@ private static bool tryCreateUri ( if (result.PathAndQuery != "/") { result = null; - message = "It includes the path or query component."; + message = "It includes either or both path and query components."; return false; } From a95448c3bb1e257e7ab270a3b0fc6fbb930d65ee Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 29 May 2017 14:36:07 +0900 Subject: [PATCH 1213/6294] [Modify] Edit it --- websocket-sharp/Ext.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index ba6766950..8f081f70d 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1417,11 +1417,12 @@ public static bool IsLocal (this System.Net.IPAddress address) } /// - /// Determines whether the specified is or empty. + /// Determines whether the specified is + /// or an empty string. /// /// - /// true if is or empty; - /// otherwise, false. + /// true if is or + /// an empty string; otherwise, false. /// /// /// A to test. From bbae618d7e918aae35251f7be60cfb408db127d0 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 30 May 2017 15:49:42 +0900 Subject: [PATCH 1214/6294] [Modify] Edit it --- websocket-sharp/Ext.cs | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 8f081f70d..495237ebc 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1303,28 +1303,36 @@ public static string GetStatusDescription (this int code) } /// - /// Determines whether the specified is in - /// the allowable range of the WebSocket close status code. + /// Determines whether the specified is in the + /// range of the status code for the WebSocket connection close. /// /// - /// Unallowable ranges are the following: + /// + /// The ranges for the status code for the close are the following: + /// /// /// /// - /// Numbers in the range 0-999 are not used. + /// 1000-2999: These numbers are reserved for definition by + /// the WebSocket protocol. + /// + /// + /// + /// + /// 3000-3999: These numbers are reserved for use by libraries, + /// frameworks, and applications. /// /// /// /// - /// Numbers greater than 4999 are out of the reserved - /// close status code ranges. + /// 4000-4999: These numbers are reserved for private use. /// /// /// /// /// - /// true if is in the allowable - /// range of the close status code; otherwise, false. + /// true if is in the range of + /// the status code for the close; otherwise, false. /// /// /// A to test. From 9d91b2cef18e3ef3f87d49606a7b83524f6a2e35 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 31 May 2017 15:01:06 +0900 Subject: [PATCH 1215/6294] [Modify] Edit it --- websocket-sharp/Ext.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 495237ebc..9bbbca191 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1308,7 +1308,7 @@ public static string GetStatusDescription (this int code) /// /// /// - /// The ranges for the status code for the close are the following: + /// The ranges are the following: /// /// /// From 42c66ab65cf4ea908b0b638f3fe3856d3ad9b83c Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 31 May 2017 15:07:42 +0900 Subject: [PATCH 1216/6294] [Modify] Rename it --- websocket-sharp/Server/HttpServer.cs | 54 ++++++++++++++-------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index d52172cdd..fb8ebdd40 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -63,7 +63,7 @@ public class HttpServer private System.Net.IPAddress _address; private string _hostname; private HttpListener _listener; - private Logger _logger; + private Logger _log; private int _port; private Thread _receiveThread; private string _rootPath; @@ -300,7 +300,7 @@ public AuthenticationSchemes AuthenticationSchemes { set { var msg = _state.CheckIfAvailable (true, false, false); if (msg != null) { - _logger.Error (msg); + _log.Error (msg); return; } @@ -348,7 +348,7 @@ public bool KeepClean { set { var msg = _state.CheckIfAvailable (true, false, false); if (msg != null) { - _logger.Error (msg); + _log.Error (msg); return; } @@ -369,7 +369,7 @@ public bool KeepClean { /// public Logger Log { get { - return _logger; + return _log; } } @@ -404,7 +404,7 @@ public string Realm { set { var msg = _state.CheckIfAvailable (true, false, false); if (msg != null) { - _logger.Error (msg); + _log.Error (msg); return; } @@ -432,7 +432,7 @@ public bool ReuseAddress { set { var msg = _state.CheckIfAvailable (true, false, false); if (msg != null) { - _logger.Error (msg); + _log.Error (msg); return; } @@ -455,7 +455,7 @@ public string RootPath { set { var msg = _state.CheckIfAvailable (true, false, false); if (msg != null) { - _logger.Error (msg); + _log.Error (msg); return; } @@ -479,7 +479,7 @@ public ServerSslConfiguration SslConfiguration { set { var msg = _state.CheckIfAvailable (true, false, false); if (msg != null) { - _logger.Error (msg); + _log.Error (msg); return; } @@ -504,7 +504,7 @@ public Func UserCredentialsFinder { set { var msg = _state.CheckIfAvailable (true, false, false); if (msg != null) { - _logger.Error (msg); + _log.Error (msg); return; } @@ -527,7 +527,7 @@ public TimeSpan WaitTime { set { var msg = _state.CheckIfAvailable (true, false, false) ?? value.CheckIfValidWaitTime (); if (msg != null) { - _logger.Error (msg); + _log.Error (msg); return; } @@ -652,7 +652,7 @@ private string checkIfCertificateExists () var usr = _listener.SslConfiguration.ServerCertificate != null; var port = EndPointListener.CertificateExists (_port, _listener.CertificateFolderPath); if (usr && port) { - _logger.Warn ("The server certificate associated with the port number already exists."); + _log.Warn ("The server certificate associated with the port number already exists."); return null; } @@ -682,8 +682,8 @@ private void init (string hostname, System.Net.IPAddress address, int port, bool _listener.Prefixes.Add ( String.Format ("http{0}://{1}:{2}/", secure ? "s" : "", _hostname, port)); - _logger = _listener.Log; - _services = new WebSocketServiceManager (_logger); + _log = _listener.Log; + _services = new WebSocketServiceManager (_log); _sync = new object (); var os = Environment.OSVersion; @@ -748,17 +748,17 @@ private void receiveRequest () processRequest (ctx); } catch (Exception ex) { - _logger.Fatal (ex.ToString ()); + _log.Fatal (ex.ToString ()); ctx.Connection.Close (true); } }); } catch (HttpListenerException ex) { - _logger.Warn ("Receiving has been stopped.\n reason: " + ex.Message); + _log.Warn ("Receiving has been stopped.\n reason: " + ex.Message); break; } catch (Exception ex) { - _logger.Fatal (ex.ToString ()); + _log.Fatal (ex.ToString ()); break; } } @@ -860,7 +860,7 @@ public void AddWebSocketService (string path, Func initial (initializer == null ? "'initializer' is null." : null); if (msg != null) { - _logger.Error (msg); + _log.Error (msg); return; } @@ -924,7 +924,7 @@ public bool RemoveWebSocketService (string path) { var msg = path.CheckIfValidServicePath (); if (msg != null) { - _logger.Error (msg); + _log.Error (msg); return false; } @@ -939,7 +939,7 @@ public void Start () lock (_sync) { var msg = _state.CheckIfAvailable (true, false, false) ?? checkIfCertificateExists (); if (msg != null) { - _logger.Error (msg); + _log.Error (msg); return; } @@ -957,13 +957,13 @@ public void Stop () { string msg; if (!checkIfAvailable (false, true, false, false, out msg)) { - _logger.Error (msg); + _log.Error (msg); return; } lock (_sync) { if (!checkIfAvailable (false, true, false, false, out msg)) { - _logger.Error (msg); + _log.Error (msg); return; } @@ -995,18 +995,18 @@ public void Stop (ushort code, string reason) { string msg; if (!checkIfAvailable (false, true, false, false, out msg)) { - _logger.Error (msg); + _log.Error (msg); return; } if (!WebSocket.CheckParametersForClose (code, reason, false, out msg)) { - _logger.Error (msg); + _log.Error (msg); return; } lock (_sync) { if (!checkIfAvailable (false, true, false, false, out msg)) { - _logger.Error (msg); + _log.Error (msg); return; } @@ -1043,18 +1043,18 @@ public void Stop (CloseStatusCode code, string reason) { string msg; if (!checkIfAvailable (false, true, false, false, out msg)) { - _logger.Error (msg); + _log.Error (msg); return; } if (!WebSocket.CheckParametersForClose (code, reason, false, out msg)) { - _logger.Error (msg); + _log.Error (msg); return; } lock (_sync) { if (!checkIfAvailable (false, true, false, false, out msg)) { - _logger.Error (msg); + _log.Error (msg); return; } From 963db4bdf0204ca0d6871896176c95162b028f33 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 31 May 2017 15:24:48 +0900 Subject: [PATCH 1217/6294] [Modify] Add it --- websocket-sharp/Server/HttpServer.cs | 55 ++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index fb8ebdd40..9309e1735 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -775,6 +775,61 @@ private void startReceiving () _receiveThread.Start (); } + private void stop (ushort code, string reason) + { + if (_state == ServerState.Ready) { + _log.Info ("The server is not started."); + return; + } + + if (_state == ServerState.ShuttingDown) { + _log.Info ("The server is shutting down."); + return; + } + + if (_state == ServerState.Stop) { + _log.Info ("The server has already stopped."); + return; + } + + lock (_sync) { + if (_state == ServerState.ShuttingDown) { + _log.Info ("The server is shutting down."); + return; + } + + if (_state == ServerState.Stop) { + _log.Info ("The server has already stopped."); + return; + } + + _state = ServerState.ShuttingDown; + } + + try { + var threw = false; + try { + _services.Stop (code, reason); + } + catch { + threw = true; + throw; + } + finally { + try { + stopReceiving (5000); + } + catch { + if (!threw) + throw; + } + } + } + finally { + _state = ServerState.Stop; + } + } + private void stopReceiving (int millisecondsTimeout) { _listener.Close (); From e8a0edfeb76ac3ff9bdaa13238abd10119337e88 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 31 May 2017 15:34:52 +0900 Subject: [PATCH 1218/6294] [Modify] Polish it --- websocket-sharp/Server/HttpServer.cs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 9309e1735..c5837797b 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -603,14 +603,22 @@ public WebSocketServiceManager WebSocketServices { private void abort () { lock (_sync) { - if (!IsListening) + if (_state != ServerState.Start) return; _state = ServerState.ShuttingDown; } - _services.Stop (new CloseEventArgs (CloseStatusCode.ServerError), true, false); - _listener.Abort (); + try { + try { + _services.Stop (1006, String.Empty); + } + finally { + _listener.Abort (); + } + } + catch { + } _state = ServerState.Stop; } From 6cfff97441a904a4ab90d8da6a789f9647a8182f Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 31 May 2017 15:42:13 +0900 Subject: [PATCH 1219/6294] [Modify] Replace it --- websocket-sharp/Server/HttpServer.cs | 20 +------------------- 1 file changed, 1 insertion(+), 19 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index c5837797b..7baa30a3a 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -1018,25 +1018,7 @@ public void Start () /// public void Stop () { - string msg; - if (!checkIfAvailable (false, true, false, false, out msg)) { - _log.Error (msg); - return; - } - - lock (_sync) { - if (!checkIfAvailable (false, true, false, false, out msg)) { - _log.Error (msg); - return; - } - - _state = ServerState.ShuttingDown; - } - - _services.Stop (new CloseEventArgs (), true, true); - stopReceiving (5000); - - _state = ServerState.Stop; + stop (1005, String.Empty); } /// From 90ddd792b9e2a8c421a5d30e21eff7a3f6a3faaa Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 1 Jun 2017 04:38:54 +0900 Subject: [PATCH 1220/6294] [Modify] Edit it --- websocket-sharp/Server/HttpServer.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 7baa30a3a..4f5cda1e5 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -1014,8 +1014,12 @@ public void Start () } /// - /// Stops receiving the incoming requests, and closes the connections. + /// Stops receiving incoming requests and closes each connection. /// + /// + /// This method does nothing if the server is not started, + /// it is shutting down, or it has already stopped. + /// public void Stop () { stop (1005, String.Empty); From 372aca103b0297f75734df4bf809ab2fb8a10f96 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 1 Jun 2017 04:43:34 +0900 Subject: [PATCH 1221/6294] [Modify] Replace it --- websocket-sharp/Server/HttpServer.cs | 26 +------------------------- 1 file changed, 1 insertion(+), 25 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 4f5cda1e5..df824ca1c 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -1043,36 +1043,12 @@ public void Stop () public void Stop (ushort code, string reason) { string msg; - if (!checkIfAvailable (false, true, false, false, out msg)) { - _log.Error (msg); - return; - } - if (!WebSocket.CheckParametersForClose (code, reason, false, out msg)) { _log.Error (msg); return; } - lock (_sync) { - if (!checkIfAvailable (false, true, false, false, out msg)) { - _log.Error (msg); - return; - } - - _state = ServerState.ShuttingDown; - } - - if (code == (ushort) CloseStatusCode.NoStatus) { - _services.Stop (new CloseEventArgs (), true, true); - } - else { - var send = !code.IsReserved (); - _services.Stop (new CloseEventArgs (code, reason), send, send); - } - - stopReceiving (5000); - - _state = ServerState.Stop; + stop (code, reason); } /// From b14fc7483f56357043ef6c86a4608ad277de2eca Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 1 Jun 2017 04:50:40 +0900 Subject: [PATCH 1222/6294] [Modify] It throws exceptions --- websocket-sharp/Server/HttpServer.cs | 59 ++++++++++++++++++++++++++-- 1 file changed, 55 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index df824ca1c..507722ef4 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -1040,12 +1040,63 @@ public void Stop () /// A that represents the reason for the WebSocket /// connection close. The size must be 123 bytes or less. /// + /// + /// + /// is less than 1000 or greater than 4999. + /// + /// + /// -or- + /// + /// + /// The size of is greater than 123 bytes. + /// + /// + /// + /// + /// is 1010 (mandatory extension). + /// + /// + /// -or- + /// + /// + /// is 1005 (no status) and + /// there is . + /// + /// + /// -or- + /// + /// + /// could not be UTF-8-encoded. + /// + /// public void Stop (ushort code, string reason) { - string msg; - if (!WebSocket.CheckParametersForClose (code, reason, false, out msg)) { - _log.Error (msg); - return; + if (!code.IsCloseStatusCode ()) { + var msg = "Less than 1000 or greater than 4999."; + throw new ArgumentOutOfRangeException ("code", msg); + } + + if (code == 1010) { + var msg = "1010 cannot be used."; + throw new ArgumentException (msg, "code"); + } + + if (!reason.IsNullOrEmpty ()) { + if (code == 1005) { + var msg = "1005 cannot be used."; + throw new ArgumentException (msg, "code"); + } + + byte[] bytes; + if (!reason.TryGetUTF8EncodedBytes (out bytes)) { + var msg = "It could not be UTF-8-encoded."; + throw new ArgumentException (msg, "reason"); + } + + if (bytes.Length > 123) { + var msg = "Its size is greater than 123 bytes."; + throw new ArgumentOutOfRangeException ("reason", msg); + } } stop (code, reason); From 29c3156a973f302d0537b0b5a0c0df45224c0f6b Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 1 Jun 2017 16:17:24 +0900 Subject: [PATCH 1223/6294] [Modify] Edit it --- websocket-sharp/Server/HttpServer.cs | 30 +++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 507722ef4..68c4980d3 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -1026,19 +1026,31 @@ public void Stop () } /// - /// Stops receiving the incoming requests, and closes the connections with - /// the specified and for - /// the WebSocket connection close. + /// Stops receiving incoming requests and closes each connection. /// + /// + /// This method does nothing if the server is not started, + /// it is shutting down, or it has already stopped. + /// /// - /// A that represents the status code indicating - /// the reason for the WebSocket connection close. The status codes are - /// defined in - /// Section 7.4 of RFC 6455. + /// + /// A that represents the status code + /// indicating the reason for the WebSocket connection close. + /// + /// + /// The status codes are defined in + /// + /// Section 7.4 of RFC 6455. + /// /// /// - /// A that represents the reason for the WebSocket - /// connection close. The size must be 123 bytes or less. + /// + /// A that represents the reason for + /// the WebSocket connection close. + /// + /// + /// The size must be 123 bytes or less in UTF-8. + /// /// /// /// From 6c2f00d5e5a6bfcc743e7f7010187e1739a0a74a Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 1 Jun 2017 16:21:11 +0900 Subject: [PATCH 1224/6294] [Modify] Replace it --- websocket-sharp/Server/HttpServer.cs | 26 +------------------------- 1 file changed, 1 insertion(+), 25 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 68c4980d3..a7f84f691 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -1130,36 +1130,12 @@ public void Stop (ushort code, string reason) public void Stop (CloseStatusCode code, string reason) { string msg; - if (!checkIfAvailable (false, true, false, false, out msg)) { - _log.Error (msg); - return; - } - if (!WebSocket.CheckParametersForClose (code, reason, false, out msg)) { _log.Error (msg); return; } - lock (_sync) { - if (!checkIfAvailable (false, true, false, false, out msg)) { - _log.Error (msg); - return; - } - - _state = ServerState.ShuttingDown; - } - - if (code == CloseStatusCode.NoStatus) { - _services.Stop (new CloseEventArgs (), true, true); - } - else { - var send = !code.IsReserved (); - _services.Stop (new CloseEventArgs (code, reason), send, send); - } - - stopReceiving (5000); - - _state = ServerState.Stop; + stop ((ushort) code, reason); } #endregion From 4ce77fb5c56441a417141564761d875953660894 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 1 Jun 2017 16:25:07 +0900 Subject: [PATCH 1225/6294] [Modify] It throws exceptions --- websocket-sharp/Server/HttpServer.cs | 48 +++++++++++++++++++++++++--- 1 file changed, 44 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index a7f84f691..f15cdc8c0 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -1127,12 +1127,52 @@ public void Stop (ushort code, string reason) /// A that represents the reason for the WebSocket /// connection close. The size must be 123 bytes or less. /// + /// + /// The size of is greater than 123 bytes. + /// + /// + /// + /// is + /// . + /// + /// + /// -or- + /// + /// + /// is + /// and + /// there is . + /// + /// + /// -or- + /// + /// + /// could not be UTF-8-encoded. + /// + /// public void Stop (CloseStatusCode code, string reason) { - string msg; - if (!WebSocket.CheckParametersForClose (code, reason, false, out msg)) { - _log.Error (msg); - return; + if (code == CloseStatusCode.MandatoryExtension) { + var msg = "MandatoryExtension cannot be used."; + throw new ArgumentException (msg, "code"); + } + + if (!reason.IsNullOrEmpty ()) { + if (code == CloseStatusCode.NoStatus) { + var msg = "NoStatus cannot be used."; + throw new ArgumentException (msg, "code"); + } + + byte[] bytes; + if (!reason.TryGetUTF8EncodedBytes (out bytes)) { + var msg = "It could not be UTF-8-encoded."; + throw new ArgumentException (msg, "reason"); + } + + if (bytes.Length > 123) { + var msg = "Its size is greater than 123 bytes."; + throw new ArgumentOutOfRangeException ("reason", msg); + } } stop ((ushort) code, reason); From ee84df541e61b77405c74b44354154a72b3bf3ad Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 2 Jun 2017 14:33:24 +0900 Subject: [PATCH 1226/6294] [Modify] Edit it --- websocket-sharp/Server/HttpServer.cs | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index f15cdc8c0..d8d2c250f 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -1115,17 +1115,29 @@ public void Stop (ushort code, string reason) } /// - /// Stops receiving the incoming requests, and closes the connections with - /// the specified and for - /// the WebSocket connection close. + /// Stops receiving incoming requests and closes each connection. /// + /// + /// This method does nothing if the server is not started, + /// it is shutting down, or it has already stopped. + /// /// - /// One of the enum values that represents - /// the status code indicating the reason for the WebSocket connection close. + /// + /// One of the enum values. + /// + /// + /// It represents the status code indicating the reason for + /// the WebSocket connection close. + /// /// /// - /// A that represents the reason for the WebSocket - /// connection close. The size must be 123 bytes or less. + /// + /// A that represents the reason for + /// the WebSocket connection close. + /// + /// + /// The size must be 123 bytes or less in UTF-8. + /// /// /// /// The size of is greater than 123 bytes. From 4aa9f58b161d3f50ffdf93b5a0adeab7a83e43f0 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 2 Jun 2017 14:38:00 +0900 Subject: [PATCH 1227/6294] [Modify] Remove it --- websocket-sharp/Server/WebSocketServiceManager.cs | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index 33da9842e..374e4c715 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -420,20 +420,6 @@ internal void Stop (ushort code, string reason) } } - internal void Stop (CloseEventArgs e, bool send, bool receive) - { - lock (_sync) { - _state = ServerState.ShuttingDown; - - var bytes = send ? WebSocketFrame.CreateCloseFrame (e.PayloadData, false).ToArray () : null; - foreach (var host in _hosts.Values) - host.Sessions.Stop (e, bytes, receive); - - _hosts.Clear (); - _state = ServerState.Stop; - } - } - #endregion #region Public Methods From 1e2139aafa9f974c8e8dee6c2f8db89540dd909e Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 2 Jun 2017 14:42:36 +0900 Subject: [PATCH 1228/6294] [Modify] Remove it --- websocket-sharp/Server/WebSocketSessionManager.cs | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index b910c18f5..872b9b2a3 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -395,19 +395,6 @@ internal void Stop (ushort code, string reason) stop (new PayloadData (code, reason), !code.IsReserved ()); } - internal void Stop (CloseEventArgs e, byte[] frameAsBytes, bool receive) - { - lock (_sync) { - _state = ServerState.ShuttingDown; - - _sweepTimer.Enabled = false; - foreach (var session in _sessions.Values.ToList ()) - session.Context.WebSocket.Close (e, frameAsBytes, receive); - - _state = ServerState.Stop; - } - } - #endregion #region Public Methods From 4ad2864cdc592e29cbbaf226134e6735f983b17c Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 2 Jun 2017 14:49:07 +0900 Subject: [PATCH 1229/6294] [Modify] Remove it --- websocket-sharp/WebSocket.cs | 30 ------------------------------ 1 file changed, 30 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 7b54231b6..cddd220c8 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2236,36 +2236,6 @@ internal void Close (PayloadData payloadData, byte[] frameAsBytes) } } - // As server - internal void Close (CloseEventArgs e, byte[] frameAsBytes, bool receive) - { - lock (_forState) { - if (_readyState == WebSocketState.Closing) { - _logger.Info ("The closing is already in progress."); - return; - } - - if (_readyState == WebSocketState.Closed) { - _logger.Info ("The connection has already been closed."); - return; - } - - _readyState = WebSocketState.Closing; - } - - e.WasClean = closeHandshake (frameAsBytes, receive, false); - releaseServerResources (); - releaseCommonResources (); - - _readyState = WebSocketState.Closed; - try { - OnClose.Emit (this, e); - } - catch (Exception ex) { - _logger.Error (ex.ToString ()); - } - } - // As client internal static string CreateBase64Key () { From 4e208b70337164a065f24b74baba2f9e77529e51 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 3 Jun 2017 15:55:16 +0900 Subject: [PATCH 1230/6294] [Modify] Add it --- websocket-sharp/Server/HttpServer.cs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index d8d2c250f..242a962b5 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -623,6 +623,31 @@ private void abort () _state = ServerState.Stop; } + private bool checkCertificate (out string message) + { + message = null; + + if (!_secure) + return true; + + var user = _listener.SslConfiguration.ServerCertificate != null; + + var path = _listener.CertificateFolderPath; + var port = EndPointListener.CertificateExists (_port, path); + + if (user && port) { + _log.Warn ("The certificate associated with the port will be used."); + return true; + } + + if (!(user || port)) { + message = "There is no certificate."; + return false; + } + + return true; + } + private bool checkIfAvailable ( bool ready, bool start, bool shutting, bool stop, out string message ) From e420a1b733cef2f1fa6ddbb3f4eaa644f356bd0c Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 3 Jun 2017 16:09:05 +0900 Subject: [PATCH 1231/6294] [Modify] Add it --- websocket-sharp/Server/HttpServer.cs | 37 ++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 242a962b5..2f725dca6 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -800,6 +800,43 @@ private void receiveRequest () abort (); } + private void start () + { + if (_state == ServerState.Start) { + _log.Info ("The server has already started."); + return; + } + + if (_state == ServerState.ShuttingDown) { + _log.Warn ("The server is shutting down."); + return; + } + + lock (_sync) { + if (_state == ServerState.Start) { + _log.Info ("The server has already started."); + return; + } + + if (_state == ServerState.ShuttingDown) { + _log.Warn ("The server is shutting down."); + return; + } + + _services.Start (); + + try { + startReceiving (); + } + catch { + _services.Stop (1011, String.Empty); + throw; + } + + _state = ServerState.Start; + } + } + private void startReceiving () { _listener.Start (); From c1551b8b6f3860c1a2a08ef20d85f759128f4d5c Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 3 Jun 2017 16:12:44 +0900 Subject: [PATCH 1232/6294] [Modify] Replace it --- websocket-sharp/Server/HttpServer.cs | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 2f725dca6..f28506217 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -1061,18 +1061,13 @@ public bool RemoveWebSocketService (string path) /// public void Start () { - lock (_sync) { - var msg = _state.CheckIfAvailable (true, false, false) ?? checkIfCertificateExists (); - if (msg != null) { - _log.Error (msg); - return; - } - - _services.Start (); - startReceiving (); - - _state = ServerState.Start; + var msg = checkIfCertificateExists (); + if (msg != null) { + _log.Error (msg); + return; } + + start (); } /// From aac634848ef2df9582679ebb995f692011e7de32 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 3 Jun 2017 16:22:20 +0900 Subject: [PATCH 1233/6294] [Modify] It throws exception --- websocket-sharp/Server/HttpServer.cs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index f28506217..d329b5d87 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -1059,13 +1059,14 @@ public bool RemoveWebSocketService (string path) /// /// Starts receiving the HTTP requests. /// + /// + /// There is no certificate. + /// public void Start () { - var msg = checkIfCertificateExists (); - if (msg != null) { - _log.Error (msg); - return; - } + string msg; + if (!checkCertificate (out msg)) + throw new InvalidOperationException (msg); start (); } From 9248e524cd5da142e1d58506da0b8915e90baad8 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 4 Jun 2017 14:22:19 +0900 Subject: [PATCH 1234/6294] [Modify] Edit it --- websocket-sharp/Server/HttpServer.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index d329b5d87..0e6e1329b 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -1057,10 +1057,14 @@ public bool RemoveWebSocketService (string path) } /// - /// Starts receiving the HTTP requests. + /// Starts receiving incoming requests. /// + /// + /// This method does nothing if the server has already + /// started or it is shutting down. + /// /// - /// There is no certificate. + /// There is no certificate used to authenticate the server. /// public void Start () { From 5346bd9d1faaa57851d43ef7ac03e50dfdb86854 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 4 Jun 2017 14:28:24 +0900 Subject: [PATCH 1235/6294] [Modify] Polish it --- websocket-sharp/Server/HttpServer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 0e6e1329b..d4fa81547 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -641,7 +641,7 @@ private bool checkCertificate (out string message) } if (!(user || port)) { - message = "There is no certificate."; + message = "There is no certificate used to authenticate the server."; return false; } From 1039994ee874b31af0462132b01ef2ee28980c43 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 4 Jun 2017 14:30:29 +0900 Subject: [PATCH 1236/6294] [Modify] Remove it --- websocket-sharp/Server/HttpServer.cs | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index d4fa81547..9311e0cc3 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -677,21 +677,6 @@ private bool checkIfAvailable ( return true; } - private string checkIfCertificateExists () - { - if (!_secure) - return null; - - var usr = _listener.SslConfiguration.ServerCertificate != null; - var port = EndPointListener.CertificateExists (_port, _listener.CertificateFolderPath); - if (usr && port) { - _log.Warn ("The server certificate associated with the port number already exists."); - return null; - } - - return !(usr || port) ? "The secure connection requires a server certificate." : null; - } - private static string convertToString (System.Net.IPAddress address) { return address.AddressFamily == AddressFamily.InterNetworkV6 From 443fd508b963e38c03197fbe8ab9a0cdddba29a5 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 5 Jun 2017 14:55:23 +0900 Subject: [PATCH 1237/6294] [Modify] Polish it --- websocket-sharp/Server/HttpServer.cs | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 9311e0cc3..019d7ee2c 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -753,8 +753,9 @@ private void processRequest (HttpListenerWebSocketContext context) private void receiveRequest () { while (true) { + HttpListenerContext ctx = null; try { - var ctx = _listener.GetContext (); + ctx = _listener.GetContext (); ThreadPool.QueueUserWorkItem ( state => { try { @@ -766,22 +767,37 @@ private void receiveRequest () processRequest (ctx); } catch (Exception ex) { - _log.Fatal (ex.ToString ()); + _log.Fatal (ex.Message); + _log.Debug (ex.ToString ()); + ctx.Connection.Close (true); } - }); + } + ); } catch (HttpListenerException ex) { - _log.Warn ("Receiving has been stopped.\n reason: " + ex.Message); + if (_state == ServerState.ShuttingDown) { + _log.Info ("The receiving is stopped."); + break; + } + + _log.Fatal (ex.Message); + _log.Debug (ex.ToString ()); + break; } catch (Exception ex) { - _log.Fatal (ex.ToString ()); + _log.Fatal (ex.Message); + _log.Debug (ex.ToString ()); + + if (ctx != null) + ctx.Connection.Close (true); + break; } } - if (IsListening) + if (_state != ServerState.ShuttingDown) abort (); } From 8b490d43647030510f7c477375d1cdc9529b6241 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 5 Jun 2017 15:00:08 +0900 Subject: [PATCH 1238/6294] [Modify] Add it --- websocket-sharp/Server/HttpServer.cs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 019d7ee2c..8d5fefe26 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -623,6 +623,23 @@ private void abort () _state = ServerState.Stop; } + private bool canSet (out string message) + { + message = null; + + if (_state == ServerState.Start) { + message = "The server has already started."; + return false; + } + + if (_state == ServerState.ShuttingDown) { + message = "The server is shutting down."; + return false; + } + + return true; + } + private bool checkCertificate (out string message) { message = null; From 86e14309c30cc6dade2853b3f4cf6bd183d39b9a Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 5 Jun 2017 15:04:51 +0900 Subject: [PATCH 1239/6294] [Modify] Replace it --- websocket-sharp/Server/HttpServer.cs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 8d5fefe26..ffbb12bbd 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -298,13 +298,20 @@ public AuthenticationSchemes AuthenticationSchemes { } set { - var msg = _state.CheckIfAvailable (true, false, false); - if (msg != null) { - _log.Error (msg); + string msg; + if (!canSet (out msg)) { + _log.Warn (msg); return; } - _listener.AuthenticationSchemes = value; + lock (_sync) { + if (!canSet (out msg)) { + _log.Warn (msg); + return; + } + + _listener.AuthenticationSchemes = value; + } } } From 706eaddaf0723c0f8e3e19c1a01a53d56925c32d Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 5 Jun 2017 15:09:16 +0900 Subject: [PATCH 1240/6294] [Modify] Edit it --- websocket-sharp/Server/HttpServer.cs | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index ffbb12bbd..195c879c3 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -287,10 +287,22 @@ public System.Net.IPAddress Address { /// /// Gets or sets the scheme used to authenticate the clients. /// + /// + /// The set operation does nothing if the server has already + /// started or it is shutting down. + /// /// - /// One of the enum values, - /// indicates the scheme used to authenticate the clients. The default value is - /// . + /// + /// One of the + /// enum values. + /// + /// + /// It represents the scheme used to authenticate the clients. + /// + /// + /// The default value is + /// . + /// /// public AuthenticationSchemes AuthenticationSchemes { get { From 36f101567e7a4efd118671146ce23ab46609bcb3 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 5 Jun 2017 15:14:06 +0900 Subject: [PATCH 1241/6294] [Modify] Replace it --- websocket-sharp/Server/HttpServer.cs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 195c879c3..b42f2541c 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -365,13 +365,20 @@ public bool KeepClean { } set { - var msg = _state.CheckIfAvailable (true, false, false); - if (msg != null) { - _log.Error (msg); + string msg; + if (!canSet (out msg)) { + _log.Warn (msg); return; } - _services.KeepClean = value; + lock (_sync) { + if (!canSet (out msg)) { + _log.Warn (msg); + return; + } + + _services.KeepClean = value; + } } } From 30be47d7de92c6335da3a57c43df593470f36160 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 5 Jun 2017 15:16:38 +0900 Subject: [PATCH 1242/6294] [Modify] Edit it --- websocket-sharp/Server/HttpServer.cs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index b42f2541c..d5bbf6f5c 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -353,11 +353,20 @@ public bool IsSecure { /// /// Gets or sets a value indicating whether the server cleans up - /// the inactive sessions in the WebSocket services periodically. + /// the inactive sessions periodically. /// + /// + /// The set operation does nothing if the server has already + /// started or it is shutting down. + /// /// - /// true if the server cleans up the inactive sessions every 60 seconds; - /// otherwise, false. The default value is true. + /// + /// true if the server cleans up the inactive sessions + /// every 60 seconds; otherwise, false. + /// + /// + /// The default value is true. + /// /// public bool KeepClean { get { From 6185f6753526189db7c056cc2a61174c6bc58085 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 5 Jun 2017 15:20:19 +0900 Subject: [PATCH 1243/6294] [Modify] Replace it --- websocket-sharp/Server/HttpServer.cs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index d5bbf6f5c..78cc7c084 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -437,13 +437,20 @@ public string Realm { } set { - var msg = _state.CheckIfAvailable (true, false, false); - if (msg != null) { - _log.Error (msg); + string msg; + if (!canSet (out msg)) { + _log.Warn (msg); return; } - _listener.Realm = value; + lock (_sync) { + if (!canSet (out msg)) { + _log.Warn (msg); + return; + } + + _listener.Realm = value; + } } } From f720d839d548357401e26b36b8dad25f352fd6a2 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 5 Jun 2017 15:33:40 +0900 Subject: [PATCH 1244/6294] [Modify] Edit it --- websocket-sharp/Server/HttpServer.cs | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 78cc7c084..9e682c3ae 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -421,15 +421,26 @@ public int Port { } /// - /// Gets or sets the name of the realm associated with the server. + /// Gets or sets the realm used for authentication. /// /// - /// If this property is or empty, "SECRET AREA" will be used as - /// the name of the realm. + /// + /// SECRET AREA will be used as the name if the value is + /// or an empty string. + /// + /// + /// The set operation does nothing if the server has already + /// started or it is shutting down. + /// /// /// - /// A that represents the name of the realm. The default value is - /// . + /// + /// A or + /// by default. + /// + /// + /// That string represents the name of the realm. + /// /// public string Realm { get { From 53ac2f5f4551c26a6719766072614afad709896a Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 5 Jun 2017 15:37:59 +0900 Subject: [PATCH 1245/6294] [Modify] Replace it --- websocket-sharp/Server/HttpServer.cs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 9e682c3ae..f1f9ead6b 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -483,13 +483,20 @@ public bool ReuseAddress { } set { - var msg = _state.CheckIfAvailable (true, false, false); - if (msg != null) { - _log.Error (msg); + string msg; + if (!canSet (out msg)) { + _log.Warn (msg); return; } - _listener.ReuseAddress = value; + lock (_sync) { + if (!canSet (out msg)) { + _log.Warn (msg); + return; + } + + _listener.ReuseAddress = value; + } } } From 2077be2c47ee909418752ed94c80c5bc267aaa9a Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 5 Jun 2017 17:27:33 +0900 Subject: [PATCH 1246/6294] [Modify] Edit it --- websocket-sharp/Server/HttpServer.cs | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index f1f9ead6b..e9ab74fd7 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -466,16 +466,27 @@ public string Realm { } /// - /// Gets or sets a value indicating whether the server is allowed to be bound to - /// an address that is already in use. + /// Gets or sets a value indicating whether the server is allowed to + /// be bound to an address that is already in use. /// /// - /// If you would like to resolve to wait for socket in TIME_WAIT state, - /// you should set this property to true. + /// + /// You should set this property to true if you would + /// like to resolve to wait for socket in TIME_WAIT state. + /// + /// + /// The set operation does nothing if the server has already + /// started or it is shutting down. + /// /// /// - /// true if the server is allowed to be bound to an address that is already in use; - /// otherwise, false. The default value is false. + /// + /// true if the server is allowed to be bound to an address + /// that is already in use; otherwise, false. + /// + /// + /// The default value is false. + /// /// public bool ReuseAddress { get { From 9098020bfafa342654f38c2e48d8731e27538034 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 5 Jun 2017 17:30:33 +0900 Subject: [PATCH 1247/6294] [Modify] Replace it --- websocket-sharp/Server/HttpServer.cs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index e9ab74fd7..11f7f39d0 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -524,13 +524,20 @@ public string RootPath { } set { - var msg = _state.CheckIfAvailable (true, false, false); - if (msg != null) { - _log.Error (msg); + string msg; + if (!canSet (out msg)) { + _log.Warn (msg); return; } - _rootPath = value; + lock (_sync) { + if (!canSet (out msg)) { + _log.Warn (msg); + return; + } + + _rootPath = value; + } } } From d6703e37032f3d9954f45ca42e7c40f1348bac81 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 5 Jun 2017 17:46:37 +0900 Subject: [PATCH 1248/6294] [Modify] It throws exceptions --- websocket-sharp/Server/HttpServer.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 11f7f39d0..e04d202cc 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -518,12 +518,24 @@ public bool ReuseAddress { /// A that represents the document root path of the server. /// The default value is "./Public". /// + /// + /// The value specified for a set operation is . + /// + /// + /// The value specified for a set operation is an empty string. + /// public string RootPath { get { return _rootPath != null && _rootPath.Length > 0 ? _rootPath : (_rootPath = "./Public"); } set { + if (value == null) + throw new ArgumentNullException ("value"); + + if (value.Length == 0) + throw new ArgumentException ("An empty string.", "value"); + string msg; if (!canSet (out msg)) { _log.Warn (msg); From 5fb4676a436b3172355e1aee4ddcdaf24737bda6 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 5 Jun 2017 17:53:56 +0900 Subject: [PATCH 1249/6294] [Modify] Polish it --- websocket-sharp/Server/HttpServer.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index e04d202cc..6e07a473d 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -526,7 +526,7 @@ public bool ReuseAddress { /// public string RootPath { get { - return _rootPath != null && _rootPath.Length > 0 ? _rootPath : (_rootPath = "./Public"); + return _rootPath; } set { @@ -808,6 +808,7 @@ private void init (string hostname, System.Net.IPAddress address, int port, bool String.Format ("http{0}://{1}:{2}/", secure ? "s" : "", _hostname, port)); _log = _listener.Log; + _rootPath = "./Public"; _services = new WebSocketServiceManager (_log); _sync = new object (); From 59366583335363fc1ef096ac4d0ffb78ebf1dcdf Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 6 Jun 2017 15:14:05 +0900 Subject: [PATCH 1250/6294] [Modify] Edit it --- websocket-sharp/Server/HttpServer.cs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 6e07a473d..9dc0e2af2 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -514,9 +514,18 @@ public bool ReuseAddress { /// /// Gets or sets the document root path of the server. /// + /// + /// The set operation does nothing if the server has already + /// started or it is shutting down. + /// /// - /// A that represents the document root path of the server. - /// The default value is "./Public". + /// + /// A that represents a path to + /// the folder from which to find the requested file. + /// + /// + /// The default value is "./Public". + /// /// /// /// The value specified for a set operation is . From 0dbf9a0de1e0627326a00819df9d39fbb4c53b7c Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 6 Jun 2017 15:18:36 +0900 Subject: [PATCH 1251/6294] [Modify] Remove it --- websocket-sharp/Server/HttpServer.cs | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 9dc0e2af2..69f8a61e8 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -563,7 +563,7 @@ public string RootPath { } /// - /// Gets or sets the SSL configuration used to authenticate the server and + /// Gets the SSL configuration used to authenticate the server and /// optionally the client for secure connection. /// /// @@ -574,16 +574,6 @@ public ServerSslConfiguration SslConfiguration { get { return _listener.SslConfiguration; } - - set { - var msg = _state.CheckIfAvailable (true, false, false); - if (msg != null) { - _log.Error (msg); - return; - } - - _listener.SslConfiguration = value; - } } /// From de8e9a738235b5bf9c516d83765aa61d59e24083 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 6 Jun 2017 15:23:14 +0900 Subject: [PATCH 1252/6294] [Modify] Edit it --- websocket-sharp/Server/HttpServer.cs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 69f8a61e8..6b4243670 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -563,12 +563,15 @@ public string RootPath { } /// - /// Gets the SSL configuration used to authenticate the server and - /// optionally the client for secure connection. + /// Gets the configuration for secure connections. /// + /// + /// The configuration will be referenced when the server starts. + /// So you must configure it before calling the start method. + /// /// - /// A that represents the configuration used to - /// authenticate the server and optionally the client for secure connection. + /// A that represents + /// the configuration used to provide secure connections. /// public ServerSslConfiguration SslConfiguration { get { From a32815cfdff3432c8f890ed5e2099885379e88a6 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 6 Jun 2017 15:27:14 +0900 Subject: [PATCH 1253/6294] [Modify] Replace it --- websocket-sharp/Server/HttpServer.cs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 6b4243670..31bf64f1a 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -594,13 +594,20 @@ public Func UserCredentialsFinder { } set { - var msg = _state.CheckIfAvailable (true, false, false); - if (msg != null) { - _log.Error (msg); + string msg; + if (!canSet (out msg)) { + _log.Warn (msg); return; } - _listener.UserCredentialsFinder = value; + lock (_sync) { + if (!canSet (out msg)) { + _log.Warn (msg); + return; + } + + _listener.UserCredentialsFinder = value; + } } } From 8e5baaea545307f76223e147cca26cae0eec4180 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 6 Jun 2017 15:46:55 +0900 Subject: [PATCH 1254/6294] [Modify] Edit it --- websocket-sharp/Server/HttpServer.cs | 30 +++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 31bf64f1a..a2491579b 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -580,13 +580,33 @@ public ServerSslConfiguration SslConfiguration { } /// - /// Gets or sets the delegate called to find the credentials for an identity used to - /// authenticate a client. + /// Gets or sets the delegate used to find the credentials + /// for an identity. /// + /// + /// + /// No credentials are found if the method invoked by + /// the delegate returns or + /// the value is . + /// + /// + /// The set operation does nothing if the server has + /// already started or it is shutting down. + /// + /// /// - /// A Func<, > delegate - /// that references the method(s) used to find the credentials. The default value is - /// . + /// + /// A Func<, + /// > delegate or + /// if not needed. + /// + /// + /// That delegate invokes the method called for finding + /// the credentials used to authenticate a client. + /// + /// + /// The default value is . + /// /// public Func UserCredentialsFinder { get { From 2b354125803a5cc2a1a2ba625994e5a4258ca5de Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 6 Jun 2017 15:53:35 +0900 Subject: [PATCH 1255/6294] [Modify] Replace it --- websocket-sharp/Server/HttpServer.cs | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index a2491579b..7651a3db1 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -638,19 +638,32 @@ public Func UserCredentialsFinder { /// A that represents the wait time. The default value is /// the same as 1 second. /// + /// + /// The value specified for a set operation is zero or less. + /// public TimeSpan WaitTime { get { return _services.WaitTime; } set { - var msg = _state.CheckIfAvailable (true, false, false) ?? value.CheckIfValidWaitTime (); - if (msg != null) { - _log.Error (msg); + string msg; + if (!value.CheckWaitTime (out msg)) + throw new ArgumentException (msg, "value"); + + if (!canSet (out msg)) { + _log.Warn (msg); return; } - _services.WaitTime = value; + lock (_sync) { + if (!canSet (out msg)) { + _log.Warn (msg); + return; + } + + _services.WaitTime = value; + } } } From 3ea6fc3d142fbef2936fc957f57bd16811b1e627 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 6 Jun 2017 15:57:40 +0900 Subject: [PATCH 1256/6294] [Modify] Edit it --- websocket-sharp/Server/HttpServer.cs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 7651a3db1..6286f27fb 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -632,11 +632,20 @@ public Func UserCredentialsFinder { } /// - /// Gets or sets the wait time for the response to the WebSocket Ping or Close. + /// Gets or sets the time to wait for the response to + /// the WebSocket Ping or Close. /// + /// + /// The set operation does nothing if the server has already + /// started or it is shutting down. + /// /// - /// A that represents the wait time. The default value is - /// the same as 1 second. + /// + /// A to wait for the response. + /// + /// + /// The default value is the same as 1 second. + /// /// /// /// The value specified for a set operation is zero or less. From 45d3bb4bdbd140a48542faf9b1540215bdbff861 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 6 Jun 2017 16:00:18 +0900 Subject: [PATCH 1257/6294] [Modify] Remove it --- websocket-sharp/Server/HttpServer.cs | 29 ---------------------------- 1 file changed, 29 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 6286f27fb..7996b1777 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -806,35 +806,6 @@ private bool checkCertificate (out string message) return true; } - private bool checkIfAvailable ( - bool ready, bool start, bool shutting, bool stop, out string message - ) - { - message = null; - - if (!ready && _state == ServerState.Ready) { - message = "This operation is not available in: ready"; - return false; - } - - if (!start && _state == ServerState.Start) { - message = "This operation is not available in: start"; - return false; - } - - if (!shutting && _state == ServerState.ShuttingDown) { - message = "This operation is not available in: shutting down"; - return false; - } - - if (!stop && _state == ServerState.Stop) { - message = "This operation is not available in: stop"; - return false; - } - - return true; - } - private static string convertToString (System.Net.IPAddress address) { return address.AddressFamily == AddressFamily.InterNetworkV6 From 74e2b0f85b3ea7a3badb6458ab5646c36f8fe7ef Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 6 Jun 2017 16:06:35 +0900 Subject: [PATCH 1258/6294] [Modify] Remove it --- websocket-sharp/Ext.cs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 9bbbca191..1a5c8f458 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -210,11 +210,6 @@ internal static string CheckIfValidSessionID (this string id) return id == null || id.Length == 0 ? "'id' is null or empty." : null; } - internal static string CheckIfValidWaitTime (this TimeSpan time) - { - return time <= TimeSpan.Zero ? "A wait time is zero or less." : null; - } - internal static bool CheckWaitTime (this TimeSpan time, out string message) { message = null; From 1d84914e4698d09d14d223e6360a708fafa79ca4 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 6 Jun 2017 17:16:49 +0900 Subject: [PATCH 1259/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 1a5c8f458..6ac9a64a6 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -215,7 +215,7 @@ internal static bool CheckWaitTime (this TimeSpan time, out string message) message = null; if (time <= TimeSpan.Zero) { - message = "A wait time is zero or less."; + message = "Zero or less."; return false; } From 097987e3a0e8baf15012b75bf390096e85d04402 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 6 Jun 2017 17:19:46 +0900 Subject: [PATCH 1260/6294] [Modify] Replace it --- websocket-sharp/Server/HttpServer.cs | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 7996b1777..31bde274e 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -1178,13 +1178,7 @@ public byte[] GetFile (string path) /// public bool RemoveWebSocketService (string path) { - var msg = path.CheckIfValidServicePath (); - if (msg != null) { - _log.Error (msg); - return false; - } - - return _services.Remove (path); + return _services.RemoveService (path); } /// From 25ad8c6ec0c84fefdc419af0640a5cbe5565a837 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 6 Jun 2017 17:29:12 +0900 Subject: [PATCH 1261/6294] [Modify] Edit it --- websocket-sharp/Server/HttpServer.cs | 39 ++++++++++++++++++++++++---- 1 file changed, 34 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 31bde274e..d419ab1cf 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -1164,18 +1164,47 @@ public byte[] GetFile (string path) } /// - /// Removes the WebSocket service with the specified . + /// Removes a WebSocket service with the specified . /// /// - /// This method converts to URL-decoded string, - /// and removes '/' from tail end of . + /// + /// is converted to a URL-decoded string and + /// '/' is trimmed from the end of the converted string if any. + /// + /// + /// The service is stopped with close status 1001 (going away) + /// if it has already started. + /// /// /// - /// true if the service is successfully found and removed; otherwise, false. + /// true if the service is successfully found and removed; + /// otherwise, false. /// /// - /// A that represents the absolute path to the service to find. + /// A that represents an absolute path to + /// the service to remove. /// + /// + /// is . + /// + /// + /// + /// is an empty string. + /// + /// + /// -or- + /// + /// + /// is not an absolute path. + /// + /// + /// -or- + /// + /// + /// includes either or both + /// query and fragment components. + /// + /// public bool RemoveWebSocketService (string path) { return _services.RemoveService (path); From 86e68f7471878feefe4738f0199e6cc94ddf2e9f Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 6 Jun 2017 17:52:10 +0900 Subject: [PATCH 1262/6294] [Modify] Add it --- websocket-sharp/Server/HttpServer.cs | 66 ++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index d419ab1cf..1994bff0a 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -1144,6 +1144,72 @@ public void AddWebSocketService (string path) AddWebSocketService (path, () => new TBehaviorWithNew ()); } + /// + /// Adds a WebSocket service with the specified behavior, + /// , and . + /// + /// + /// is converted to a URL-decoded string and + /// '/' is trimmed from the end of the converted string if any. + /// + /// + /// A that represents an absolute path to + /// the service to add. + /// + /// + /// + /// An Action<TBehaviorWithNew> delegate or + /// if not needed. + /// + /// + /// That delegate invokes the method called for initializing + /// a new session instance for the service. + /// + /// + /// + /// + /// The type of the behavior for the service. + /// + /// + /// It must inherit the class and + /// must have a public parameterless constructor. + /// + /// + /// + /// is . + /// + /// + /// + /// is an empty string. + /// + /// + /// -or- + /// + /// + /// is not an absolute path. + /// + /// + /// -or- + /// + /// + /// includes either or both + /// query and fragment components. + /// + /// + /// -or- + /// + /// + /// is already in use. + /// + /// + public void AddWebSocketService ( + string path, Action initializer + ) + where TBehaviorWithNew : WebSocketBehavior, new () + { + _services.AddService (path, initializer); + } + /// /// Gets the contents of the file with the specified . /// From 286c509f2932d8d366fd01e95459cf0df8236160 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 6 Jun 2017 17:56:29 +0900 Subject: [PATCH 1263/6294] [Modify] Replace it --- websocket-sharp/Server/HttpServer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 1994bff0a..c5dc45d37 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -1141,7 +1141,7 @@ public void AddWebSocketService (string path, Func initial public void AddWebSocketService (string path) where TBehaviorWithNew : WebSocketBehavior, new () { - AddWebSocketService (path, () => new TBehaviorWithNew ()); + _services.AddService (path, null); } /// From c4f13a5c503b541829918bbbeaadf36406616099 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 6 Jun 2017 19:48:11 +0900 Subject: [PATCH 1264/6294] [Modify] Edit it --- websocket-sharp/Server/HttpServer.cs | 47 +++++++++++++++++++++++----- 1 file changed, 40 insertions(+), 7 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index c5dc45d37..4d7d083f8 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -1124,20 +1124,53 @@ public void AddWebSocketService (string path, Func initial } /// - /// Adds a WebSocket service with the specified behavior and . + /// Adds a WebSocket service with the specified behavior and + /// . /// /// - /// This method converts to URL-decoded string, - /// and removes '/' from tail end of . + /// is converted to a URL-decoded string and + /// '/' is trimmed from the end of the converted string if any. /// /// - /// A that represents the absolute path to the service to add. + /// A that represents an absolute path to + /// the service to add. /// /// - /// The type of the behavior of the service to add. The TBehaviorWithNew must inherit - /// the class, and must have a public parameterless - /// constructor. + /// + /// The type of the behavior for the service. + /// + /// + /// It must inherit the class and + /// must have a public parameterless constructor. + /// /// + /// + /// is . + /// + /// + /// + /// is an empty string. + /// + /// + /// -or- + /// + /// + /// is not an absolute path. + /// + /// + /// -or- + /// + /// + /// includes either or both + /// query and fragment components. + /// + /// + /// -or- + /// + /// + /// is already in use. + /// + /// public void AddWebSocketService (string path) where TBehaviorWithNew : WebSocketBehavior, new () { From 8b5f19e2fc90622b378eb861b60d38a14d9035f5 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 7 Jun 2017 15:02:21 +0900 Subject: [PATCH 1265/6294] [Modify] Replace it --- websocket-sharp/Server/HttpServer.cs | 99 +++++++++++++++++++++------- 1 file changed, 76 insertions(+), 23 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 4d7d083f8..88e309561 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -1084,43 +1084,96 @@ private static bool tryCreateUri (string uriString, out Uri result, out string m #region Public Methods /// - /// Adds the WebSocket service with the specified behavior, , - /// and . + /// Adds a WebSocket service with the specified behavior, + /// , and . /// /// + /// is converted to a URL-decoded string and + /// '/' is trimmed from the end of the converted string if any. + /// + /// + /// A that represents an absolute path to + /// the service to add. + /// + /// /// - /// This method converts to URL-decoded string, - /// and removes '/' from tail end of . + /// A Func<TBehavior> delegate. /// /// - /// returns an initialized specified typed - /// instance. + /// It invokes the method called for creating + /// a new session instance for the service. + /// + /// + /// The method must create a new instance of + /// the specified behavior class and return it. /// - /// - /// - /// A that represents the absolute path to the service to add. - /// - /// - /// A Func<T> delegate that references the method used to initialize - /// a new specified typed instance (a new - /// instance). /// /// - /// The type of the behavior of the service to add. The TBehavior must inherit - /// the class. + /// + /// The type of the behavior for the service. + /// + /// + /// It must inherit the class. + /// /// - public void AddWebSocketService (string path, Func initializer) + /// + /// + /// is . + /// + /// + /// -or- + /// + /// + /// is . + /// + /// + /// + /// + /// is an empty string. + /// + /// + /// -or- + /// + /// + /// is not an absolute path. + /// + /// + /// -or- + /// + /// + /// includes either or both + /// query and fragment components. + /// + /// + /// -or- + /// + /// + /// is already in use. + /// + /// + public void AddWebSocketService ( + string path, Func creator + ) where TBehavior : WebSocketBehavior { - var msg = path.CheckIfValidServicePath () ?? - (initializer == null ? "'initializer' is null." : null); + if (path == null) + throw new ArgumentNullException ("path"); - if (msg != null) { - _log.Error (msg); - return; + if (creator == null) + throw new ArgumentNullException ("creator"); + + if (path.Length == 0) + throw new ArgumentException ("An empty string.", "path"); + + if (path[0] != '/') + throw new ArgumentException ("Not an absolute path.", "path"); + + if (path.IndexOfAny (new[] { '?', '#' }) > -1) { + var msg = "It includes either or both query and fragment components."; + throw new ArgumentException (msg, "path"); } - _services.Add (path, initializer); + _services.Add (path, creator); } /// From 8c50ea9bbd2c2078a99789dfbc94c6d11cc5fc7f Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 7 Jun 2017 15:05:11 +0900 Subject: [PATCH 1266/6294] [Modify] It will be removed --- websocket-sharp/Server/HttpServer.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 88e309561..bc733c1b5 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -1151,6 +1151,7 @@ private static bool tryCreateUri (string uriString, out Uri result, out string m /// is already in use. /// /// + [Obsolete ("This method will be removed. Use added one instead.")] public void AddWebSocketService ( string path, Func creator ) From fb2f4e1d79540ed73a6ff9edcaf46b720178a382 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 7 Jun 2017 15:08:48 +0900 Subject: [PATCH 1267/6294] [Modify] Remove it --- .../Server/WebSocketServiceManager.cs | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index 374e4c715..c52998737 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -380,24 +380,6 @@ internal bool InternalTryGetServiceHost ( return _hosts.TryGetValue (path, out host); } - internal bool Remove (string path) - { - path = HttpUtility.UrlDecode (path).TrimSlashFromEnd (); - - WebSocketServiceHost host; - lock (_sync) { - if (!_hosts.TryGetValue (path, out host)) - return false; - - _hosts.Remove (path); - } - - if (host.State == ServerState.Start) - host.Stop (1001, String.Empty); - - return true; - } - internal void Start () { lock (_sync) { From f0d03cefcbb181b7f4a678e3c91f778eb6c3472a Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 7 Jun 2017 15:10:43 +0900 Subject: [PATCH 1268/6294] [Modify] Remove it --- websocket-sharp/Ext.cs | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 6ac9a64a6..bf72b703b 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -194,17 +194,6 @@ internal static string CheckIfValidProtocols (this string[] protocols) : null; } - internal static string CheckIfValidServicePath (this string path) - { - return path == null || path.Length == 0 - ? "'path' is null or empty." - : path[0] != '/' - ? "'path' isn't an absolute path." - : path.IndexOfAny (new[] { '?', '#' }) > -1 - ? "'path' includes either or both query and fragment components." - : null; - } - internal static string CheckIfValidSessionID (this string id) { return id == null || id.Length == 0 ? "'id' is null or empty." : null; From 2a0479c6346b7963310d626be4c687594b72fd31 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 7 Jun 2017 15:36:22 +0900 Subject: [PATCH 1269/6294] [Modify] Polish it --- websocket-sharp/Server/HttpServer.cs | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index bc733c1b5..840eb04d6 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -1037,45 +1037,46 @@ private void stopReceiving (int millisecondsTimeout) _receiveThread.Join (millisecondsTimeout); } - private static bool tryCreateUri (string uriString, out Uri result, out string message) + private static bool tryCreateUri ( + string uriString, out Uri result, out string message + ) { result = null; + message = null; var uri = uriString.ToUri (); if (uri == null) { - message = "An invalid URI string: " + uriString; + message = "An invalid URI string."; return false; } if (!uri.IsAbsoluteUri) { - message = "Not an absolute URI: " + uriString; + message = "A relative URI."; return false; } var schm = uri.Scheme; if (!(schm == "http" || schm == "https")) { - message = "The scheme part isn't 'http' or 'https': " + uriString; + message = "The scheme part is not 'http' or 'https'."; return false; } if (uri.PathAndQuery != "/") { - message = "Includes the path or query component: " + uriString; + message = "It includes either or both path and query components."; return false; } if (uri.Fragment.Length > 0) { - message = "Includes the fragment component: " + uriString; + message = "It includes the fragment component."; return false; } if (uri.Port == 0) { - message = "The port part is zero: " + uriString; + message = "The port part is zero."; return false; } result = uri; - message = String.Empty; - return true; } From 9e00ef222f716308876ae1f1fac8023bd72239b7 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 7 Jun 2017 15:44:19 +0900 Subject: [PATCH 1270/6294] [Modify] Edit it --- websocket-sharp/Server/HttpServer.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 840eb04d6..d8d488640 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -273,10 +273,11 @@ public HttpServer (System.Net.IPAddress address, int port, bool secure) #region Public Properties /// - /// Gets the local IP address of the server. + /// Gets the IP address of the server. /// /// - /// A that represents the local IP address of the server. + /// A that represents the local + /// IP address on which to listen for incoming requests. /// public System.Net.IPAddress Address { get { From 2ded18565e4da8b1de3a9dfcc95397e6af74f6d1 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 7 Jun 2017 15:50:48 +0900 Subject: [PATCH 1271/6294] [Modify] Edit it --- websocket-sharp/Server/HttpServer.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index d8d488640..29b04f1d3 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -341,10 +341,12 @@ public bool IsListening { } /// - /// Gets a value indicating whether the server provides a secure connection. + /// Gets a value indicating whether the server provides + /// secure connections. /// /// - /// true if the server provides a secure connection; otherwise, false. + /// true if the server provides secure connections; + /// otherwise, false. /// public bool IsSecure { get { From 7703397124e9a54ab1ea22bb04a25514c7dfe6e0 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 7 Jun 2017 15:55:09 +0900 Subject: [PATCH 1272/6294] [Modify] Edit it --- websocket-sharp/Server/HttpServer.cs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 29b04f1d3..9f70fe552 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -395,15 +395,13 @@ public bool KeepClean { } /// - /// Gets the logging functions. + /// Gets the logging function for the server. /// /// - /// The default logging level is . If you would like to change it, - /// you should set the Log.Level property to any of the enum - /// values. + /// The default logging level is . /// /// - /// A that provides the logging functions. + /// A that provides the logging function. /// public Logger Log { get { From 7ad112d7cd668d40a8e8d6a8d93fdd560c99dc9b Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 7 Jun 2017 15:57:53 +0900 Subject: [PATCH 1273/6294] [Modify] Edit it --- websocket-sharp/Server/HttpServer.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 9f70fe552..eb5c1b046 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -410,10 +410,11 @@ public Logger Log { } /// - /// Gets the port on which to listen for incoming requests. + /// Gets the port of the server. /// /// - /// An that represents the port number on which to listen. + /// An that represents the number of the port + /// on which to listen for incoming requests. /// public int Port { get { From 5cb47c6dca68678ffec28214a09ad6ca61be673a Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 7 Jun 2017 16:13:20 +0900 Subject: [PATCH 1274/6294] [Modify] Edit it --- websocket-sharp/Server/HttpServer.cs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index eb5c1b046..c3a064e12 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -427,18 +427,17 @@ public int Port { /// /// /// - /// SECRET AREA will be used as the name if the value is + /// "SECRET AREA" will be used as the name if the value is /// or an empty string. /// /// - /// The set operation does nothing if the server has already - /// started or it is shutting down. + /// The set operation does nothing if the server has + /// already started or it is shutting down. /// /// /// /// - /// A or - /// by default. + /// A or by default. /// /// /// That string represents the name of the realm. From 00a39a059e2114bab7e4743d82d4dc1e5d8be226 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 7 Jun 2017 17:23:01 +0900 Subject: [PATCH 1275/6294] [Modify] Edit it --- websocket-sharp/Server/HttpServer.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index c3a064e12..f28f7e601 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -678,10 +678,12 @@ public TimeSpan WaitTime { } /// - /// Gets the access to the WebSocket services provided by the server. + /// Gets the management function for the WebSocket services + /// provided by the server. /// /// - /// A that manages the WebSocket services. + /// A that manages + /// the WebSocket services provided by the server. /// public WebSocketServiceManager WebSocketServices { get { From f9abc4a89f95a50ff24c6d3588f3da1986cd69bd Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 8 Jun 2017 15:01:11 +0900 Subject: [PATCH 1276/6294] [Modify] Edit it --- websocket-sharp/Server/HttpServer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index f28f7e601..121f88126 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -427,7 +427,7 @@ public int Port { /// /// /// - /// "SECRET AREA" will be used as the name if the value is + /// "SECRET AREA" is used as the realm if the value is /// or an empty string. /// /// From 9ce32f5af2d4785a96efc6f27aee14dead8c15ab Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 8 Jun 2017 15:18:24 +0900 Subject: [PATCH 1277/6294] [Modify] Replace it --- websocket-sharp/Server/HttpServer.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 121f88126..6faffe3ae 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -657,10 +657,10 @@ public TimeSpan WaitTime { } set { - string msg; - if (!value.CheckWaitTime (out msg)) - throw new ArgumentException (msg, "value"); + if (value <= TimeSpan.Zero) + throw new ArgumentException ("Zero or less.", "value"); + string msg; if (!canSet (out msg)) { _log.Warn (msg); return; From 654c648ec8c711cbb6ef20108365e8e6e84d2f0d Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 9 Jun 2017 16:06:35 +0900 Subject: [PATCH 1278/6294] [Modify] It throws exceptions --- websocket-sharp/Server/HttpServer.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 6faffe3ae..24991f3be 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -1311,8 +1311,20 @@ public void AddWebSocketService ( /// /// A that represents the virtual path to the file to find. /// + /// + /// is . + /// + /// + /// is an empty string. + /// public byte[] GetFile (string path) { + if (path == null) + throw new ArgumentNullException ("path"); + + if (path.Length == 0) + throw new ArgumentException ("An empty string.", "path"); + path = RootPath + path; if (_windows) path = path.Replace ("/", "\\"); From d0d845716c530110962f198e50efbf7e06d7d4ea Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 10 Jun 2017 17:23:45 +0900 Subject: [PATCH 1279/6294] [Modify] Edit it --- websocket-sharp/Server/HttpServer.cs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 24991f3be..be6a14aa8 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -1302,14 +1302,21 @@ public void AddWebSocketService ( } /// - /// Gets the contents of the file with the specified . + /// Gets the file with the specified from + /// the document folder of the server. /// /// - /// An array of that receives the contents of the file, - /// or if it doesn't exist. + /// + /// An array of or + /// if not found. + /// + /// + /// That array represents the contents of the file. + /// /// /// - /// A that represents the virtual path to the file to find. + /// A that represents a virtual path to + /// the file to find from the document folder. /// /// /// is . From a4235be0635e222abcf180708a9893fcda9ef910 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 11 Jun 2017 14:40:07 +0900 Subject: [PATCH 1280/6294] [Modify] Edit it --- websocket-sharp/Server/HttpServer.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index be6a14aa8..15a6972a8 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -513,7 +513,7 @@ public bool ReuseAddress { } /// - /// Gets or sets the document root path of the server. + /// Gets or sets the path to the document folder of the server. /// /// /// The set operation does nothing if the server has already @@ -521,8 +521,8 @@ public bool ReuseAddress { /// /// /// - /// A that represents a path to - /// the folder from which to find the requested file. + /// A that represents a path to the folder + /// from which to find the requested file. /// /// /// The default value is "./Public". From 2c531b6288989cdeb02fdafc62c2cad229d935a5 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 12 Jun 2017 15:46:39 +0900 Subject: [PATCH 1281/6294] [Modify] Add it --- websocket-sharp/Ext.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index bf72b703b..2adbe7de7 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -895,6 +895,12 @@ internal static string TrimSlashFromEnd (this string value) return ret.Length > 0 ? ret : "/"; } + internal static string TrimSlashOrBackslashFromEnd (this string value) + { + var ret = value.TrimEnd ('/', '\\'); + return ret.Length > 0 ? ret : value[0].ToString (); + } + /// /// Tries to create a new for WebSocket with /// the specified . From 2a4ea318218e34a1888ff0d7033f28121cb34f16 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 13 Jun 2017 15:14:03 +0900 Subject: [PATCH 1282/6294] [Modify] Trim it --- websocket-sharp/Server/HttpServer.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 15a6972a8..469cb8909 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -516,8 +516,13 @@ public bool ReuseAddress { /// Gets or sets the path to the document folder of the server. /// /// - /// The set operation does nothing if the server has already - /// started or it is shutting down. + /// + /// '/' or '\' is trimmed from the end of the value if any. + /// + /// + /// The set operation does nothing if the server has already + /// started or it is shutting down. + /// /// /// /// @@ -558,7 +563,7 @@ public string RootPath { return; } - _rootPath = value; + _rootPath = value.TrimSlashOrBackslashFromEnd (); } } } From 1c709dde7d56c6cad00db900012d2c06316e8500 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 14 Jun 2017 16:16:22 +0900 Subject: [PATCH 1283/6294] [Modify] Add it --- websocket-sharp/Server/HttpServer.cs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 469cb8909..d64ce2e53 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -44,6 +44,7 @@ using System.Net.Sockets; using System.Security.Cryptography.X509Certificates; using System.Security.Principal; +using System.Text; using System.Threading; using WebSocketSharp.Net; using WebSocketSharp.Net.WebSockets; @@ -821,6 +822,20 @@ private static string convertToString (System.Net.IPAddress address) : address.ToString (); } + private string createFilePath (string path) + { + var parent = _rootPath; + var child = path.TrimStart ('/', '\\'); + + var buff = new StringBuilder (parent, 32); + if (parent == "/" || parent == "\\") + buff.Append (child); + else + buff.AppendFormat ("/{0}", child); + + return buff.ToString ().Replace ('\\', '/'); + } + private static string getHost (Uri uri) { return uri.HostNameType == UriHostNameType.IPv6 ? uri.Host : uri.DnsSafeHost; From f760eabf32157dda7b18f46d079bcc68dc44d314 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 15 Jun 2017 14:43:47 +0900 Subject: [PATCH 1284/6294] [Modify] Replace it --- websocket-sharp/Server/HttpServer.cs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index d64ce2e53..e49b0d7a8 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -1352,10 +1352,7 @@ public byte[] GetFile (string path) if (path.Length == 0) throw new ArgumentException ("An empty string.", "path"); - path = RootPath + path; - if (_windows) - path = path.Replace ("/", "\\"); - + path = createFilePath (path); return File.Exists (path) ? File.ReadAllBytes (path) : null; } From 5e28b6db297543fe57a3bc0d02c8ab1f669ab907 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 15 Jun 2017 14:52:43 +0900 Subject: [PATCH 1285/6294] [Modify] Remove it --- websocket-sharp/Server/HttpServer.cs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index e49b0d7a8..66c5561be 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -72,7 +72,6 @@ public class HttpServer private WebSocketServiceManager _services; private volatile ServerState _state; private object _sync; - private bool _windows; #endregion @@ -856,9 +855,6 @@ private void init (string hostname, System.Net.IPAddress address, int port, bool _rootPath = "./Public"; _services = new WebSocketServiceManager (_log); _sync = new object (); - - var os = Environment.OSVersion; - _windows = os.Platform != PlatformID.Unix && os.Platform != PlatformID.MacOSX; } private void processRequest (HttpListenerContext context) From be58cb2ff3566226e2dbd102a826bda8abeeeb8e Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 16 Jun 2017 16:34:47 +0900 Subject: [PATCH 1286/6294] [Modify] Add some checks for the path --- websocket-sharp/Server/HttpServer.cs | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 66c5561be..37dff42c3 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -1338,7 +1338,15 @@ public void AddWebSocketService ( /// is . /// /// - /// is an empty string. + /// + /// is an empty string. + /// + /// + /// -or- + /// + /// + /// is an invalid path. + /// /// public byte[] GetFile (string path) { @@ -1348,6 +1356,18 @@ public byte[] GetFile (string path) if (path.Length == 0) throw new ArgumentException ("An empty string.", "path"); + if (path.IndexOf (':') > -1) + throw new ArgumentException ("It contains ':'.", "path"); + + if (path.IndexOf ("..") > -1) + throw new ArgumentException ("It contains '..'.", "path"); + + if (path.IndexOf ("//") > -1) + throw new ArgumentException ("It contains '//'.", "path"); + + if (path.IndexOf ("\\\\") > -1) + throw new ArgumentException ("It contains '\\\\'.", "path"); + path = createFilePath (path); return File.Exists (path) ? File.ReadAllBytes (path) : null; } From 50f76522cce9965f3f0ef537397d97db2b32aa45 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 17 Jun 2017 15:33:04 +0900 Subject: [PATCH 1287/6294] [Modify] Polish it --- websocket-sharp/Server/HttpServer.cs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 37dff42c3..9fbfaddc8 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -840,16 +840,22 @@ private static string getHost (Uri uri) return uri.HostNameType == UriHostNameType.IPv6 ? uri.Host : uri.DnsSafeHost; } - private void init (string hostname, System.Net.IPAddress address, int port, bool secure) + private void init ( + string hostname, System.Net.IPAddress address, int port, bool secure + ) { _hostname = hostname ?? convertToString (address); _address = address; _port = port; _secure = secure; - _listener = new HttpListener (); - _listener.Prefixes.Add ( - String.Format ("http{0}://{1}:{2}/", secure ? "s" : "", _hostname, port)); + var lsnr = new HttpListener (); + var pref = String.Format ( + "http{0}://{1}:{2}/", secure ? "s" : "", _hostname, port + ); + + lsnr.Prefixes.Add (pref); + _listener = lsnr; _log = _listener.Log; _rootPath = "./Public"; From f4a9d922779de1ebf9d1bfc8f819a8c65abddfb3 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 17 Jun 2017 15:47:57 +0900 Subject: [PATCH 1288/6294] [Modify] Polish it --- websocket-sharp/Server/HttpRequestEventArgs.cs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Server/HttpRequestEventArgs.cs b/websocket-sharp/Server/HttpRequestEventArgs.cs index 34a83ecf8..680089099 100644 --- a/websocket-sharp/Server/HttpRequestEventArgs.cs +++ b/websocket-sharp/Server/HttpRequestEventArgs.cs @@ -51,8 +51,7 @@ public class HttpRequestEventArgs : EventArgs { #region Private Fields - private HttpListenerRequest _request; - private HttpListenerResponse _response; + private HttpListenerContext _context; #endregion @@ -60,8 +59,7 @@ public class HttpRequestEventArgs : EventArgs internal HttpRequestEventArgs (HttpListenerContext context) { - _request = context.Request; - _response = context.Response; + _context = context; } #endregion @@ -76,7 +74,7 @@ internal HttpRequestEventArgs (HttpListenerContext context) /// public HttpListenerRequest Request { get { - return _request; + return _context.Request; } } @@ -88,7 +86,7 @@ public HttpListenerRequest Request { /// public HttpListenerResponse Response { get { - return _response; + return _context.Response; } } From 98d8d02fd71db6ce36dcb98de8f9935a25ae34a8 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 18 Jun 2017 15:30:58 +0900 Subject: [PATCH 1289/6294] [Modify] Edit it --- websocket-sharp/Server/HttpRequestEventArgs.cs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Server/HttpRequestEventArgs.cs b/websocket-sharp/Server/HttpRequestEventArgs.cs index 680089099..c5daf2e9d 100644 --- a/websocket-sharp/Server/HttpRequestEventArgs.cs +++ b/websocket-sharp/Server/HttpRequestEventArgs.cs @@ -32,19 +32,21 @@ namespace WebSocketSharp.Server { /// - /// Represents the event data for the HTTP request event that the emits. + /// Represents the event data for the HTTP request events of + /// the . /// /// /// - /// An HTTP request event occurs when the receives an HTTP request. + /// An HTTP request event occurs when the + /// receives an HTTP request. /// /// - /// If you would like to get the request data sent from a client, - /// you should access the property. + /// You should access the property if you would + /// like to get the request data sent from a client. /// /// - /// And if you would like to get the response data used to return a response, - /// you should access the property. + /// And you should access the property if you would + /// like to get the response data to return to the client. /// /// public class HttpRequestEventArgs : EventArgs From 4b5da9b3ffcc4d5a94691dab767f8961d7c52a51 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 18 Jun 2017 15:41:45 +0900 Subject: [PATCH 1290/6294] [Modify] Edit it --- websocket-sharp/Server/HttpRequestEventArgs.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/HttpRequestEventArgs.cs b/websocket-sharp/Server/HttpRequestEventArgs.cs index c5daf2e9d..5e5c11cdd 100644 --- a/websocket-sharp/Server/HttpRequestEventArgs.cs +++ b/websocket-sharp/Server/HttpRequestEventArgs.cs @@ -81,7 +81,7 @@ public HttpListenerRequest Request { } /// - /// Gets the HTTP response data used to return a response to the client. + /// Gets the HTTP response data to return to the client. /// /// /// A that represents the response data. From 3984739b5dbf4b023299ef9d6d613be947d3f3fb Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 19 Jun 2017 15:29:37 +0900 Subject: [PATCH 1291/6294] [Modify] It will be removed --- .../Server/HttpRequestEventArgs.cs | 82 ++++++++++++++++++- websocket-sharp/Server/HttpServer.cs | 3 +- 2 files changed, 83 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/HttpRequestEventArgs.cs b/websocket-sharp/Server/HttpRequestEventArgs.cs index 5e5c11cdd..894850428 100644 --- a/websocket-sharp/Server/HttpRequestEventArgs.cs +++ b/websocket-sharp/Server/HttpRequestEventArgs.cs @@ -27,6 +27,8 @@ #endregion using System; +using System.IO; +using System.Text; using WebSocketSharp.Net; namespace WebSocketSharp.Server @@ -54,14 +56,16 @@ public class HttpRequestEventArgs : EventArgs #region Private Fields private HttpListenerContext _context; + private string _rootPath; #endregion #region Internal Constructors - internal HttpRequestEventArgs (HttpListenerContext context) + internal HttpRequestEventArgs (HttpListenerContext context, string rootPath) { _context = context; + _rootPath = rootPath; } #endregion @@ -93,5 +97,81 @@ public HttpListenerResponse Response { } #endregion + + #region Private Methods + + private string createFilePath (string childPath) + { + childPath = childPath.TrimStart ('/', '\\'); + + var buff = new StringBuilder (_rootPath, 32); + if (_rootPath == "/" || _rootPath == "\\") + buff.Append (childPath); + else + buff.AppendFormat ("/{0}", childPath); + + return buff.ToString ().Replace ('\\', '/'); + } + + #endregion + + #region Public Methods + + /// + /// Reads the file with the specified from + /// the document folder of the . + /// + /// + /// + /// An array of or + /// if not found. + /// + /// + /// That array receives the contents of the file. + /// + /// + /// + /// A that represents a virtual path to + /// the file to find from the document folder. + /// + /// + /// is . + /// + /// + /// + /// is an empty string. + /// + /// + /// -or- + /// + /// + /// is an invalid path. + /// + /// + public byte[] ReadFile (string path) + { + if (path == null) + throw new ArgumentNullException ("path"); + + if (path.Length == 0) + throw new ArgumentException ("An empty string.", "path"); + + if (path.IndexOf (':') > -1) + throw new ArgumentException ("It contains ':'.", "path"); + + if (path.IndexOf ("..") > -1) + throw new ArgumentException ("It contains '..'.", "path"); + + if (path.IndexOf ("//") > -1) + throw new ArgumentException ("It contains '//'.", "path"); + + if (path.IndexOf ("\\\\") > -1) + throw new ArgumentException ("It contains '\\\\'.", "path"); + + path = createFilePath (path); + return File.Exists (path) ? File.ReadAllBytes (path) : null; + } + + #endregion } } diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 9fbfaddc8..65122956f 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -887,7 +887,7 @@ private void processRequest (HttpListenerContext context) : null; if (evt != null) - evt (this, new HttpRequestEventArgs (context)); + evt (this, new HttpRequestEventArgs (context, _rootPath)); else context.Response.StatusCode = (int) HttpStatusCode.NotImplemented; @@ -1354,6 +1354,7 @@ public void AddWebSocketService ( /// is an invalid path. /// /// + [Obsolete ("This method will be removed.")] public byte[] GetFile (string path) { if (path == null) From 7a6b2e3e5ad284993b315828663c5702fff0d7ec Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 20 Jun 2017 15:57:43 +0900 Subject: [PATCH 1292/6294] [Modify] Add it --- websocket-sharp/Server/HttpRequestEventArgs.cs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/websocket-sharp/Server/HttpRequestEventArgs.cs b/websocket-sharp/Server/HttpRequestEventArgs.cs index 894850428..bcf48dcc8 100644 --- a/websocket-sharp/Server/HttpRequestEventArgs.cs +++ b/websocket-sharp/Server/HttpRequestEventArgs.cs @@ -113,6 +113,23 @@ private string createFilePath (string childPath) return buff.ToString ().Replace ('\\', '/'); } + private static bool tryReadFile (string path, out byte[] contents) + { + contents = null; + + if (!File.Exists (path)) + return false; + + try { + contents = File.ReadAllBytes (path); + } + catch { + return false; + } + + return true; + } + #endregion #region Public Methods From a586f07359d1f8c52be3e6bb8c0f1d9ee8df5b33 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 21 Jun 2017 15:33:06 +0900 Subject: [PATCH 1293/6294] [Modify] Add it --- .../Server/HttpRequestEventArgs.cs | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/websocket-sharp/Server/HttpRequestEventArgs.cs b/websocket-sharp/Server/HttpRequestEventArgs.cs index bcf48dcc8..439432fb7 100644 --- a/websocket-sharp/Server/HttpRequestEventArgs.cs +++ b/websocket-sharp/Server/HttpRequestEventArgs.cs @@ -189,6 +189,64 @@ public byte[] ReadFile (string path) return File.Exists (path) ? File.ReadAllBytes (path) : null; } + /// + /// Tries to read a file with the specified + /// from the document folder of the . + /// + /// + /// true if the file could successfully be read; + /// otherwise, false. + /// + /// + /// A that represents a virtual path to + /// the file to read. + /// + /// + /// + /// When this method returns, an array of or + /// if the file could not be read. + /// + /// + /// That array receives the contents of the file. + /// + /// + /// + /// is . + /// + /// + /// + /// is an empty string. + /// + /// + /// -or- + /// + /// + /// is an invalid path. + /// + /// + public bool TryReadFile (string path, out byte[] contents) + { + if (path == null) + throw new ArgumentNullException ("path"); + + if (path.Length == 0) + throw new ArgumentException ("An empty string.", "path"); + + if (path.IndexOf (':') > -1) + throw new ArgumentException ("It contains ':'.", "path"); + + if (path.IndexOf ("..") > -1) + throw new ArgumentException ("It contains '..'.", "path"); + + if (path.IndexOf ("//") > -1) + throw new ArgumentException ("It contains '//'.", "path"); + + if (path.IndexOf ("\\\\") > -1) + throw new ArgumentException ("It contains '\\\\'.", "path"); + + return tryReadFile (createFilePath (path), out contents); + } + #endregion } } From a79a90f22cab231da8919c25a21ff1df69737f5a Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 21 Jun 2017 15:39:03 +0900 Subject: [PATCH 1294/6294] [Modify] Replace it --- websocket-sharp/Server/HttpRequestEventArgs.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/HttpRequestEventArgs.cs b/websocket-sharp/Server/HttpRequestEventArgs.cs index 439432fb7..4212f0697 100644 --- a/websocket-sharp/Server/HttpRequestEventArgs.cs +++ b/websocket-sharp/Server/HttpRequestEventArgs.cs @@ -185,8 +185,10 @@ public byte[] ReadFile (string path) if (path.IndexOf ("\\\\") > -1) throw new ArgumentException ("It contains '\\\\'.", "path"); - path = createFilePath (path); - return File.Exists (path) ? File.ReadAllBytes (path) : null; + byte[] contents; + tryReadFile (createFilePath (path), out contents); + + return contents; } /// From 31a6975a2bf22f02b0276c2d2ba0c1a5350daf0d Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 22 Jun 2017 15:17:57 +0900 Subject: [PATCH 1295/6294] [Modify] Edit it --- websocket-sharp/Server/HttpRequestEventArgs.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Server/HttpRequestEventArgs.cs b/websocket-sharp/Server/HttpRequestEventArgs.cs index 4212f0697..20b958079 100644 --- a/websocket-sharp/Server/HttpRequestEventArgs.cs +++ b/websocket-sharp/Server/HttpRequestEventArgs.cs @@ -135,13 +135,13 @@ private static bool tryReadFile (string path, out byte[] contents) #region Public Methods /// - /// Reads the file with the specified from + /// Reads a file with the specified from /// the document folder of the . /// /// /// /// An array of or - /// if not found. + /// if the file could not be read. /// /// /// That array receives the contents of the file. @@ -149,7 +149,7 @@ private static bool tryReadFile (string path, out byte[] contents) /// /// /// A that represents a virtual path to - /// the file to find from the document folder. + /// find the file from the document folder. /// /// /// is . From adb7082cd5d51d3fa6cf3ae390a12aa55d883e4d Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 22 Jun 2017 15:21:40 +0900 Subject: [PATCH 1296/6294] [Modify] Edit it --- websocket-sharp/Server/HttpRequestEventArgs.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/HttpRequestEventArgs.cs b/websocket-sharp/Server/HttpRequestEventArgs.cs index 20b958079..87a205981 100644 --- a/websocket-sharp/Server/HttpRequestEventArgs.cs +++ b/websocket-sharp/Server/HttpRequestEventArgs.cs @@ -201,7 +201,7 @@ public byte[] ReadFile (string path) /// /// /// A that represents a virtual path to - /// the file to read. + /// find the file from the document folder. /// /// /// From d5cd068d16bb9c6f05f62bee50236fb366fa33d7 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 22 Jun 2017 17:01:52 +0900 Subject: [PATCH 1297/6294] [Modify] Rename it --- websocket-sharp/Server/HttpRequestEventArgs.cs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Server/HttpRequestEventArgs.cs b/websocket-sharp/Server/HttpRequestEventArgs.cs index 87a205981..e283a5ff5 100644 --- a/websocket-sharp/Server/HttpRequestEventArgs.cs +++ b/websocket-sharp/Server/HttpRequestEventArgs.cs @@ -56,16 +56,18 @@ public class HttpRequestEventArgs : EventArgs #region Private Fields private HttpListenerContext _context; - private string _rootPath; + private string _docRootPath; #endregion #region Internal Constructors - internal HttpRequestEventArgs (HttpListenerContext context, string rootPath) + internal HttpRequestEventArgs ( + HttpListenerContext context, string documentRootPath + ) { _context = context; - _rootPath = rootPath; + _docRootPath = documentRootPath; } #endregion @@ -104,8 +106,8 @@ private string createFilePath (string childPath) { childPath = childPath.TrimStart ('/', '\\'); - var buff = new StringBuilder (_rootPath, 32); - if (_rootPath == "/" || _rootPath == "\\") + var buff = new StringBuilder (_docRootPath, 32); + if (_docRootPath == "/" || _docRootPath == "\\") buff.Append (childPath); else buff.AppendFormat ("/{0}", childPath); From c41f1374ef24c092008861fc75069ae907fd045a Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 23 Jun 2017 15:39:35 +0900 Subject: [PATCH 1298/6294] [Modify] Replace it --- Example3/Program.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Example3/Program.cs b/Example3/Program.cs index 29333f2e7..f314b5e90 100644 --- a/Example3/Program.cs +++ b/Example3/Program.cs @@ -93,8 +93,8 @@ public static void Main (string[] args) if (path == "/") path += "index.html"; - var content = httpsv.GetFile (path); - if (content == null) { + byte[] contents; + if (!e.TryReadFile (path, out contents)) { res.StatusCode = (int) HttpStatusCode.NotFound; return; } @@ -108,7 +108,7 @@ public static void Main (string[] args) res.ContentEncoding = Encoding.UTF8; } - res.WriteContent (content); + res.WriteContent (contents); }; // Add the WebSocket services. From 992237eeab0c68a3f350274f155fa53a086a79c6 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 24 Jun 2017 15:55:25 +0900 Subject: [PATCH 1299/6294] [Modify] Add it To support issue #367. --- .../Server/HttpRequestEventArgs.cs | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/websocket-sharp/Server/HttpRequestEventArgs.cs b/websocket-sharp/Server/HttpRequestEventArgs.cs index e283a5ff5..ca20ff05b 100644 --- a/websocket-sharp/Server/HttpRequestEventArgs.cs +++ b/websocket-sharp/Server/HttpRequestEventArgs.cs @@ -28,6 +28,7 @@ using System; using System.IO; +using System.Security.Principal; using System.Text; using WebSocketSharp.Net; @@ -98,6 +99,25 @@ public HttpListenerResponse Response { } } + /// + /// Gets the information for the client. + /// + /// + /// + /// A instance or + /// if not authenticated. + /// + /// + /// That instance describes the identity, authentication scheme, + /// and security roles for the client. + /// + /// + public IPrincipal User { + get { + return _context.User; + } + } + #endregion #region Private Methods From 046234d36accead5295906a5518c22a41afb716d Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 25 Jun 2017 18:07:26 +0900 Subject: [PATCH 1300/6294] [Modify] Edit it --- websocket-sharp/Server/HttpRequestEventArgs.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/HttpRequestEventArgs.cs b/websocket-sharp/Server/HttpRequestEventArgs.cs index ca20ff05b..cd32db1cd 100644 --- a/websocket-sharp/Server/HttpRequestEventArgs.cs +++ b/websocket-sharp/Server/HttpRequestEventArgs.cs @@ -76,10 +76,11 @@ internal HttpRequestEventArgs ( #region Public Properties /// - /// Gets the HTTP request data sent from a client. + /// Gets the request data sent from a client. /// /// - /// A that represents the request data. + /// A that provides the methods and + /// properties for the request data. /// public HttpListenerRequest Request { get { From 9ddeb714bced836fe55c25aec21bd5fa4c5c61c9 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 26 Jun 2017 15:04:35 +0900 Subject: [PATCH 1301/6294] [Modify] Edit it --- websocket-sharp/Server/HttpRequestEventArgs.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/HttpRequestEventArgs.cs b/websocket-sharp/Server/HttpRequestEventArgs.cs index cd32db1cd..35ea955a5 100644 --- a/websocket-sharp/Server/HttpRequestEventArgs.cs +++ b/websocket-sharp/Server/HttpRequestEventArgs.cs @@ -89,10 +89,11 @@ public HttpListenerRequest Request { } /// - /// Gets the HTTP response data to return to the client. + /// Gets the response data to return to the client. /// /// - /// A that represents the response data. + /// A that provides the methods and + /// properties for the response data. /// public HttpListenerResponse Response { get { From 989819844f561ac3a8254356cae471ee024ce826 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 27 Jun 2017 16:14:39 +0900 Subject: [PATCH 1302/6294] [Modify] Add some checks for the document root path --- websocket-sharp/Server/HttpServer.cs | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 65122956f..f2f667422 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -537,7 +537,15 @@ public bool ReuseAddress { /// The value specified for a set operation is . /// /// - /// The value specified for a set operation is an empty string. + /// + /// The value specified for a set operation is an empty string. + /// + /// + /// -or- + /// + /// + /// The value specified for a set operation is an absolute root. + /// /// public string RootPath { get { @@ -551,6 +559,16 @@ public string RootPath { if (value.Length == 0) throw new ArgumentException ("An empty string.", "value"); + value = value.TrimSlashOrBackslashFromEnd (); + if (value == "/") + throw new ArgumentException ("An absolute root.", "value"); + + if (value == "\\") + throw new ArgumentException ("An absolute root.", "value"); + + if (value.Length == 2 && value[1] == ':') + throw new ArgumentException ("An absolute root.", "value"); + string msg; if (!canSet (out msg)) { _log.Warn (msg); @@ -563,7 +581,7 @@ public string RootPath { return; } - _rootPath = value.TrimSlashOrBackslashFromEnd (); + _rootPath = value; } } } From d64ea66209ba29c701f2560252e692aa54bf67c1 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 28 Jun 2017 14:28:10 +0900 Subject: [PATCH 1303/6294] [Modify] Polish it --- websocket-sharp/Server/HttpServer.cs | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index f2f667422..2a71605a9 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -839,18 +839,13 @@ private static string convertToString (System.Net.IPAddress address) : address.ToString (); } - private string createFilePath (string path) + private string createFilePath (string childPath) { - var parent = _rootPath; - var child = path.TrimStart ('/', '\\'); - - var buff = new StringBuilder (parent, 32); - if (parent == "/" || parent == "\\") - buff.Append (child); - else - buff.AppendFormat ("/{0}", child); - - return buff.ToString ().Replace ('\\', '/'); + childPath = childPath.TrimStart ('/', '\\'); + return new StringBuilder (_rootPath, 32) + .AppendFormat ("/{0}", childPath) + .ToString () + .Replace ('\\', '/'); } private static string getHost (Uri uri) From cf98f324e4e3783cb22e2e54c4854d16feeedccd Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 28 Jun 2017 14:32:28 +0900 Subject: [PATCH 1304/6294] [Modify] Polish it --- websocket-sharp/Server/HttpServer.cs | 9 --------- 1 file changed, 9 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 2a71605a9..9bf679e50 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -1376,18 +1376,9 @@ public byte[] GetFile (string path) if (path.Length == 0) throw new ArgumentException ("An empty string.", "path"); - if (path.IndexOf (':') > -1) - throw new ArgumentException ("It contains ':'.", "path"); - if (path.IndexOf ("..") > -1) throw new ArgumentException ("It contains '..'.", "path"); - if (path.IndexOf ("//") > -1) - throw new ArgumentException ("It contains '//'.", "path"); - - if (path.IndexOf ("\\\\") > -1) - throw new ArgumentException ("It contains '\\\\'.", "path"); - path = createFilePath (path); return File.Exists (path) ? File.ReadAllBytes (path) : null; } From e1c1775c2573a9cc353a2ed80f7d31cd0d3de611 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 28 Jun 2017 15:40:35 +0900 Subject: [PATCH 1305/6294] [Modify] Edit it --- websocket-sharp/Server/HttpServer.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 9bf679e50..3b617f780 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -1337,13 +1337,13 @@ public void AddWebSocketService ( } /// - /// Gets the file with the specified from - /// the document folder of the server. + /// Gets the contents of the specified file from the document + /// folder of the server. /// /// /// /// An array of or - /// if not found. + /// if it fails. /// /// /// That array represents the contents of the file. @@ -1351,7 +1351,7 @@ public void AddWebSocketService ( /// /// /// A that represents a virtual path to - /// the file to find from the document folder. + /// find the file from the document folder. /// /// /// is . @@ -1364,7 +1364,7 @@ public void AddWebSocketService ( /// -or- /// /// - /// is an invalid path. + /// contains "..". /// /// [Obsolete ("This method will be removed.")] From 48f0087fb3b4309954d19a23b74d1706097d0585 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 29 Jun 2017 15:40:24 +0900 Subject: [PATCH 1306/6294] [Modify] Polish it --- websocket-sharp/Server/HttpRequestEventArgs.cs | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/websocket-sharp/Server/HttpRequestEventArgs.cs b/websocket-sharp/Server/HttpRequestEventArgs.cs index 35ea955a5..181dd494d 100644 --- a/websocket-sharp/Server/HttpRequestEventArgs.cs +++ b/websocket-sharp/Server/HttpRequestEventArgs.cs @@ -127,14 +127,10 @@ public IPrincipal User { private string createFilePath (string childPath) { childPath = childPath.TrimStart ('/', '\\'); - - var buff = new StringBuilder (_docRootPath, 32); - if (_docRootPath == "/" || _docRootPath == "\\") - buff.Append (childPath); - else - buff.AppendFormat ("/{0}", childPath); - - return buff.ToString ().Replace ('\\', '/'); + return new StringBuilder (_docRootPath, 32) + .AppendFormat ("/{0}", childPath) + .ToString () + .Replace ('\\', '/'); } private static bool tryReadFile (string path, out byte[] contents) From daa6b95227195e2597fb33d561cf07863191d6b3 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 29 Jun 2017 15:43:40 +0900 Subject: [PATCH 1307/6294] [Modify] Polish it --- websocket-sharp/Server/HttpRequestEventArgs.cs | 9 --------- 1 file changed, 9 deletions(-) diff --git a/websocket-sharp/Server/HttpRequestEventArgs.cs b/websocket-sharp/Server/HttpRequestEventArgs.cs index 181dd494d..bf274a06f 100644 --- a/websocket-sharp/Server/HttpRequestEventArgs.cs +++ b/websocket-sharp/Server/HttpRequestEventArgs.cs @@ -193,18 +193,9 @@ public byte[] ReadFile (string path) if (path.Length == 0) throw new ArgumentException ("An empty string.", "path"); - if (path.IndexOf (':') > -1) - throw new ArgumentException ("It contains ':'.", "path"); - if (path.IndexOf ("..") > -1) throw new ArgumentException ("It contains '..'.", "path"); - if (path.IndexOf ("//") > -1) - throw new ArgumentException ("It contains '//'.", "path"); - - if (path.IndexOf ("\\\\") > -1) - throw new ArgumentException ("It contains '\\\\'.", "path"); - byte[] contents; tryReadFile (createFilePath (path), out contents); From 5cf5b35dbc5049eb2b68b64849893dbf4c99f632 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 29 Jun 2017 15:52:47 +0900 Subject: [PATCH 1308/6294] [Modify] Edit it --- websocket-sharp/Server/HttpRequestEventArgs.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Server/HttpRequestEventArgs.cs b/websocket-sharp/Server/HttpRequestEventArgs.cs index bf274a06f..270e30416 100644 --- a/websocket-sharp/Server/HttpRequestEventArgs.cs +++ b/websocket-sharp/Server/HttpRequestEventArgs.cs @@ -155,13 +155,13 @@ private static bool tryReadFile (string path, out byte[] contents) #region Public Methods /// - /// Reads a file with the specified from - /// the document folder of the . + /// Reads the specified file from the document folder of + /// the . /// /// /// /// An array of or - /// if the file could not be read. + /// if it fails. /// /// /// That array receives the contents of the file. @@ -182,7 +182,7 @@ private static bool tryReadFile (string path, out byte[] contents) /// -or- /// /// - /// is an invalid path. + /// contains "..". /// /// public byte[] ReadFile (string path) From 8095728c06e6576d67ecb95232199d7c06c5c1f5 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 29 Jun 2017 15:55:03 +0900 Subject: [PATCH 1309/6294] [Modify] Polish it --- websocket-sharp/Server/HttpRequestEventArgs.cs | 9 --------- 1 file changed, 9 deletions(-) diff --git a/websocket-sharp/Server/HttpRequestEventArgs.cs b/websocket-sharp/Server/HttpRequestEventArgs.cs index 270e30416..1773783f6 100644 --- a/websocket-sharp/Server/HttpRequestEventArgs.cs +++ b/websocket-sharp/Server/HttpRequestEventArgs.cs @@ -245,18 +245,9 @@ public bool TryReadFile (string path, out byte[] contents) if (path.Length == 0) throw new ArgumentException ("An empty string.", "path"); - if (path.IndexOf (':') > -1) - throw new ArgumentException ("It contains ':'.", "path"); - if (path.IndexOf ("..") > -1) throw new ArgumentException ("It contains '..'.", "path"); - if (path.IndexOf ("//") > -1) - throw new ArgumentException ("It contains '//'.", "path"); - - if (path.IndexOf ("\\\\") > -1) - throw new ArgumentException ("It contains '\\\\'.", "path"); - return tryReadFile (createFilePath (path), out contents); } From d2a6c90d48d5bad5300203a67f918e260dff7675 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 30 Jun 2017 17:40:16 +0900 Subject: [PATCH 1310/6294] [Modify] Edit it --- websocket-sharp/Server/HttpRequestEventArgs.cs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Server/HttpRequestEventArgs.cs b/websocket-sharp/Server/HttpRequestEventArgs.cs index 1773783f6..610214e81 100644 --- a/websocket-sharp/Server/HttpRequestEventArgs.cs +++ b/websocket-sharp/Server/HttpRequestEventArgs.cs @@ -203,12 +203,11 @@ public byte[] ReadFile (string path) } /// - /// Tries to read a file with the specified - /// from the document folder of the . + /// Tries to read the specified file from the document folder of + /// the . /// /// - /// true if the file could successfully be read; - /// otherwise, false. + /// true if it succeeds to read; otherwise, false. /// /// /// A that represents a virtual path to @@ -217,7 +216,7 @@ public byte[] ReadFile (string path) /// /// /// When this method returns, an array of or - /// if the file could not be read. + /// if it fails. /// /// /// That array receives the contents of the file. @@ -234,7 +233,7 @@ public byte[] ReadFile (string path) /// -or- /// /// - /// is an invalid path. + /// contains "..". /// /// public bool TryReadFile (string path, out byte[] contents) From a854efa0c44eb6adcd2b36ba3bd5a463198a7954 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 30 Jun 2017 17:46:15 +0900 Subject: [PATCH 1311/6294] [Modify] 2017 --- websocket-sharp/Server/HttpRequestEventArgs.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/HttpRequestEventArgs.cs b/websocket-sharp/Server/HttpRequestEventArgs.cs index 610214e81..ee76cbab3 100644 --- a/websocket-sharp/Server/HttpRequestEventArgs.cs +++ b/websocket-sharp/Server/HttpRequestEventArgs.cs @@ -4,7 +4,7 @@ * * The MIT License * - * Copyright (c) 2012-2015 sta.blockhead + * Copyright (c) 2012-2017 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From ebe1fa15d9ca655930863ad7549db8501221fce5 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 1 Jul 2017 15:32:24 +0900 Subject: [PATCH 1312/6294] [Modify] Rename it --- Example3/App.config | 2 +- Example3/Program.cs | 2 +- websocket-sharp/Server/HttpServer.cs | 157 ++++++++++++++------------- 3 files changed, 81 insertions(+), 80 deletions(-) diff --git a/Example3/App.config b/Example3/App.config index b65960f8c..fa624b42b 100644 --- a/Example3/App.config +++ b/Example3/App.config @@ -2,7 +2,7 @@ - + diff --git a/Example3/Program.cs b/Example3/Program.cs index f314b5e90..939bfed89 100644 --- a/Example3/Program.cs +++ b/Example3/Program.cs @@ -82,7 +82,7 @@ public static void Main (string[] args) //httpsv.ReuseAddress = true; // Set the document root path. - httpsv.RootPath = ConfigurationManager.AppSettings["RootPath"]; + httpsv.DocumentRootPath = ConfigurationManager.AppSettings["DocumentRootPath"]; // Set the HTTP GET request event. httpsv.OnGet += (sender, e) => { diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 3b617f780..37d544fc8 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -62,12 +62,12 @@ public class HttpServer #region Private Fields private System.Net.IPAddress _address; + private string _docRootPath; private string _hostname; private HttpListener _listener; private Logger _log; private int _port; private Thread _receiveThread; - private string _rootPath; private bool _secure; private WebSocketServiceManager _services; private volatile ServerState _state; @@ -328,6 +328,80 @@ public AuthenticationSchemes AuthenticationSchemes { } } + /// + /// Gets or sets the path to the document folder of the server. + /// + /// + /// + /// '/' or '\' is trimmed from the end of the value if any. + /// + /// + /// The set operation does nothing if the server has already + /// started or it is shutting down. + /// + /// + /// + /// + /// A that represents a path to the folder + /// from which to find the requested file. + /// + /// + /// The default value is "./Public". + /// + /// + /// + /// The value specified for a set operation is . + /// + /// + /// + /// The value specified for a set operation is an empty string. + /// + /// + /// -or- + /// + /// + /// The value specified for a set operation is an absolute root. + /// + /// + public string DocumentRootPath { + get { + return _docRootPath; + } + + set { + if (value == null) + throw new ArgumentNullException ("value"); + + if (value.Length == 0) + throw new ArgumentException ("An empty string.", "value"); + + value = value.TrimSlashOrBackslashFromEnd (); + if (value == "/") + throw new ArgumentException ("An absolute root.", "value"); + + if (value == "\\") + throw new ArgumentException ("An absolute root.", "value"); + + if (value.Length == 2 && value[1] == ':') + throw new ArgumentException ("An absolute root.", "value"); + + string msg; + if (!canSet (out msg)) { + _log.Warn (msg); + return; + } + + lock (_sync) { + if (!canSet (out msg)) { + _log.Warn (msg); + return; + } + + _docRootPath = value; + } + } + } + /// /// Gets a value indicating whether the server has started. /// @@ -512,80 +586,6 @@ public bool ReuseAddress { } } - /// - /// Gets or sets the path to the document folder of the server. - /// - /// - /// - /// '/' or '\' is trimmed from the end of the value if any. - /// - /// - /// The set operation does nothing if the server has already - /// started or it is shutting down. - /// - /// - /// - /// - /// A that represents a path to the folder - /// from which to find the requested file. - /// - /// - /// The default value is "./Public". - /// - /// - /// - /// The value specified for a set operation is . - /// - /// - /// - /// The value specified for a set operation is an empty string. - /// - /// - /// -or- - /// - /// - /// The value specified for a set operation is an absolute root. - /// - /// - public string RootPath { - get { - return _rootPath; - } - - set { - if (value == null) - throw new ArgumentNullException ("value"); - - if (value.Length == 0) - throw new ArgumentException ("An empty string.", "value"); - - value = value.TrimSlashOrBackslashFromEnd (); - if (value == "/") - throw new ArgumentException ("An absolute root.", "value"); - - if (value == "\\") - throw new ArgumentException ("An absolute root.", "value"); - - if (value.Length == 2 && value[1] == ':') - throw new ArgumentException ("An absolute root.", "value"); - - string msg; - if (!canSet (out msg)) { - _log.Warn (msg); - return; - } - - lock (_sync) { - if (!canSet (out msg)) { - _log.Warn (msg); - return; - } - - _rootPath = value; - } - } - } - /// /// Gets the configuration for secure connections. /// @@ -842,7 +842,7 @@ private static string convertToString (System.Net.IPAddress address) private string createFilePath (string childPath) { childPath = childPath.TrimStart ('/', '\\'); - return new StringBuilder (_rootPath, 32) + return new StringBuilder (_docRootPath, 32) .AppendFormat ("/{0}", childPath) .ToString () .Replace ('\\', '/'); @@ -862,6 +862,8 @@ private void init ( _port = port; _secure = secure; + _docRootPath = "./Public"; + var lsnr = new HttpListener (); var pref = String.Format ( "http{0}://{1}:{2}/", secure ? "s" : "", _hostname, port @@ -871,7 +873,6 @@ private void init ( _listener = lsnr; _log = _listener.Log; - _rootPath = "./Public"; _services = new WebSocketServiceManager (_log); _sync = new object (); } @@ -900,7 +901,7 @@ private void processRequest (HttpListenerContext context) : null; if (evt != null) - evt (this, new HttpRequestEventArgs (context, _rootPath)); + evt (this, new HttpRequestEventArgs (context, _docRootPath)); else context.Response.StatusCode = (int) HttpStatusCode.NotImplemented; From 960103d98a6db4e760640afe718f065eeac9bc66 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 2 Jul 2017 15:56:11 +0900 Subject: [PATCH 1313/6294] [Modify] Rethrow it --- websocket-sharp/Server/HttpServer.cs | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 37d544fc8..ba7ae37dc 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -1009,7 +1009,14 @@ private void start () private void startReceiving () { - _listener.Start (); + try { + _listener.Start (); + } + catch (Exception ex) { + var msg = "The underlying HttpListener has failed to start."; + throw new InvalidOperationException (msg, ex); + } + _receiveThread = new Thread (new ThreadStart (receiveRequest)); _receiveThread.IsBackground = true; _receiveThread.Start (); @@ -1439,7 +1446,15 @@ public bool RemoveWebSocketService (string path) /// started or it is shutting down. /// /// - /// There is no certificate used to authenticate the server. + /// + /// There is no certificate used to authenticate the server. + /// + /// + /// -or- + /// + /// + /// The underlying has failed to start. + /// /// public void Start () { From 6b7af9ad57eee0c6ba224baa41285987ae59119a Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 3 Jul 2017 15:00:37 +0900 Subject: [PATCH 1314/6294] [Modify] Call the Stop method --- websocket-sharp/Server/HttpServer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index ba7ae37dc..f8ef3e9b0 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -1079,7 +1079,7 @@ private void stop (ushort code, string reason) private void stopReceiving (int millisecondsTimeout) { - _listener.Close (); + _listener.Stop (); _receiveThread.Join (millisecondsTimeout); } From 473cf76f1bdf0704234412ab4fb8ade869efa730 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 4 Jul 2017 14:40:03 +0900 Subject: [PATCH 1315/6294] [Modify] Polish it --- websocket-sharp/Server/HttpServer.cs | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index f8ef3e9b0..98280480e 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -944,15 +944,12 @@ private void receiveRequest () } ); } - catch (HttpListenerException ex) { - if (_state == ServerState.ShuttingDown) { - _log.Info ("The receiving is stopped."); - break; - } - - _log.Fatal (ex.Message); - _log.Debug (ex.ToString ()); - + catch (HttpListenerException) { + _log.Info ("The underlying listener is stopped."); + break; + } + catch (InvalidOperationException) { + _log.Info ("The underlying listener is stopped."); break; } catch (Exception ex) { From 512758e8d1ae360af71ec9ab386a5f3a922ca3b9 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 4 Jul 2017 15:49:09 +0900 Subject: [PATCH 1316/6294] [Modify] Edit it --- websocket-sharp/Server/HttpServer.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 98280480e..fe03177fa 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -2,7 +2,7 @@ /* * HttpServer.cs * - * A simple HTTP server that allows to accept the WebSocket connection requests. + * A simple HTTP server that allows to accept WebSocket handshake requests. * * The MIT License * @@ -52,10 +52,11 @@ namespace WebSocketSharp.Server { /// - /// Provides a simple HTTP server that allows to accept the WebSocket connection requests. + /// Provides a simple HTTP server that allows to accept + /// WebSocket handshake requests. /// /// - /// The HttpServer class can provide multiple WebSocket services. + /// This class can provide multiple WebSocket services. /// public class HttpServer { From 5216ee8c8da76da6a48bee52e9c1e3918a622bdf Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 4 Jul 2017 16:08:18 +0900 Subject: [PATCH 1317/6294] [Modify] Edit it --- websocket-sharp/Server/HttpServer.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index fe03177fa..3290f99b7 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -82,7 +82,8 @@ public class HttpServer /// Initializes a new instance of the class. /// /// - /// An instance initialized by this constructor listens for the incoming requests on port 80. + /// The new instance listens for incoming requests on + /// and port 80. /// public HttpServer () { From e4375bd18ae697c279835439a29ecd02818271b5 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 4 Jul 2017 16:12:13 +0900 Subject: [PATCH 1318/6294] [Modify] Polish it --- websocket-sharp/Server/HttpServer.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 3290f99b7..8c7466963 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -187,9 +187,10 @@ public HttpServer (string url) /// public HttpServer (int port, bool secure) { - if (!port.IsPortNumber ()) - throw new ArgumentOutOfRangeException ( - "port", "Not between 1 and 65535 inclusive: " + port); + if (!port.IsPortNumber ()) { + var msg = "Less than 1 or greater than 65535."; + throw new ArgumentOutOfRangeException ("port", msg); + } init ("*", System.Net.IPAddress.Any, port, secure); } From ae2df0619a003bb05d8099ce7ffa81d06f59c1c1 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 4 Jul 2017 16:23:43 +0900 Subject: [PATCH 1319/6294] [Modify] Edit it --- websocket-sharp/Server/HttpServer.cs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 8c7466963..6f891a2ed 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -172,18 +172,19 @@ public HttpServer (string url) /// the specified and . /// /// - /// An instance initialized by this constructor listens for the incoming requests on - /// . + /// The new instance listens for incoming requests on + /// and . /// /// - /// An that represents the port number on which to listen. + /// An that represents the number of the port + /// on which to listen. /// /// - /// A that indicates providing a secure connection or not. - /// (true indicates providing a secure connection.) + /// A : true if the new instance provides + /// secure connections; otherwise, false. /// /// - /// isn't between 1 and 65535 inclusive. + /// is less than 1 or greater than 65535. /// public HttpServer (int port, bool secure) { From ceac08866e55ee97967aa3b7aafbcd06a84c1c6c Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 4 Jul 2017 16:30:34 +0900 Subject: [PATCH 1320/6294] [Modify] Edit it --- websocket-sharp/Server/HttpServer.cs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 6f891a2ed..0928d2c80 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -96,18 +96,19 @@ public HttpServer () /// /// /// - /// An instance initialized by this constructor listens for the incoming requests on - /// . + /// The new instance listens for incoming requests on + /// and . /// /// - /// If is 443, that instance provides a secure connection. + /// It provides secure connections if is 443. /// /// /// - /// An that represents the port number on which to listen. + /// An that represents the number of the port + /// on which to listen. /// /// - /// isn't between 1 and 65535 inclusive. + /// is less than 1 or greater than 65535. /// public HttpServer (int port) : this (port, port == 443) From fb4a07ec6eb8be0a76548e2a4aee2c9e9141f842 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 5 Jul 2017 14:48:31 +0900 Subject: [PATCH 1321/6294] [Modify] Polish it --- websocket-sharp/Server/HttpServer.cs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 0928d2c80..672c09cd4 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -161,9 +161,17 @@ public HttpServer (string url) throw new ArgumentException (msg, "url"); var host = getHost (uri); + var addr = host.ToIPAddress (); - if (!addr.IsLocal ()) - throw new ArgumentException ("The host part isn't a local host name: " + url, "url"); + if (addr == null) { + msg = "The host part could not be converted to an IP address."; + throw new ArgumentException (msg, "url"); + } + + if (!addr.IsLocal ()) { + msg = "The IP address of the host is not a local IP address."; + throw new ArgumentException (msg, "url"); + } init (host, addr, uri.Port, uri.Scheme == "https"); } From 3ec76decb65b4d3fbb462893e3795ac16444e9cf Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 5 Jul 2017 15:49:23 +0900 Subject: [PATCH 1322/6294] [Modify] Edit it --- websocket-sharp/Server/HttpServer.cs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 672c09cd4..39ef7b3ff 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -117,17 +117,21 @@ public HttpServer (int port) /// /// Initializes a new instance of the class with - /// the specified HTTP URL. + /// the specified . /// /// /// - /// An instance initialized by this constructor listens for the incoming requests on - /// the host name and port in . + /// The new instance listens for incoming requests on the IP address of the + /// host of and the port of . + /// + /// + /// Either port 80 or 443 is used if includes + /// no port. Port 443 is used if the scheme of + /// is https; otherwise, port 80 is used. /// /// - /// If doesn't include a port, either port 80 or 443 is used on - /// which to listen. It's determined by the scheme (http or https) in . - /// (Port 80 if the scheme is http.) + /// The new instance provides secure connections if the scheme of + /// is https. /// /// /// From 589c88ff01c803fd0476f8d0d8c87c2885f81e30 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 5 Jul 2017 15:59:35 +0900 Subject: [PATCH 1323/6294] [Modify] Polish it --- websocket-sharp/Server/HttpServer.cs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 39ef7b3ff..939c6f0cd 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -276,13 +276,15 @@ public HttpServer (System.Net.IPAddress address, int port, bool secure) throw new ArgumentNullException ("address"); if (!address.IsLocal ()) - throw new ArgumentException ("Not a local IP address: " + address, "address"); + throw new ArgumentException ("Not a local IP address.", "address"); - if (!port.IsPortNumber ()) - throw new ArgumentOutOfRangeException ( - "port", "Not between 1 and 65535 inclusive: " + port); + if (!port.IsPortNumber ()) { + var msg = "Less than 1 or greater than 65535."; + throw new ArgumentOutOfRangeException ("port", msg); + } - init (null, address, port, secure); + var host = convertToString (address); + init (host, address, port, secure); } #endregion From 821139a569b2a7fc9cc783314e44927eab6ff1c5 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 5 Jul 2017 16:13:27 +0900 Subject: [PATCH 1324/6294] [Modify] Edit it --- websocket-sharp/Server/HttpServer.cs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 939c6f0cd..98a191e24 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -248,27 +248,29 @@ public HttpServer (System.Net.IPAddress address, int port) /// and . /// /// - /// An instance initialized by this constructor listens for the incoming requests on + /// The new instance listens for incoming requests on /// and . /// /// - /// A that represents the local IP address of the server. + /// A that represents + /// the local IP address on which to listen. /// /// - /// An that represents the port number on which to listen. + /// An that represents the number of the port + /// on which to listen. /// /// - /// A that indicates providing a secure connection or not. - /// (true indicates providing a secure connection.) + /// A : true if the new instance provides + /// secure connections; otherwise, false. /// /// /// is . /// /// - /// isn't a local IP address. + /// is not a local IP address. /// /// - /// isn't between 1 and 65535 inclusive. + /// is less than 1 or greater than 65535. /// public HttpServer (System.Net.IPAddress address, int port, bool secure) { From 1c517700d422f1129e409ca6ed2d2583ef282cf4 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 5 Jul 2017 17:22:08 +0900 Subject: [PATCH 1325/6294] [Modify] Edit it --- websocket-sharp/Server/HttpServer.cs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 98a191e24..6fd3b7af5 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -215,27 +215,29 @@ public HttpServer (int port, bool secure) /// /// /// - /// An instance initialized by this constructor listens for the incoming requests on + /// The new instance listens for incoming requests on /// and . /// /// - /// If is 443, that instance provides a secure connection. + /// It provides secure connections if is 443. /// /// /// - /// A that represents the local IP address of the server. + /// A that represents + /// the local IP address on which to listen. /// /// - /// An that represents the port number on which to listen. + /// An that represents the number of the port + /// on which to listen. /// /// /// is . /// /// - /// isn't a local IP address. + /// is not a local IP address. /// /// - /// isn't between 1 and 65535 inclusive. + /// is less than 1 or greater than 65535. /// public HttpServer (System.Net.IPAddress address, int port) : this (address, port, port == 443) From a59192a26429d985b0a7d652e261f89159f47351 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 5 Jul 2017 17:33:16 +0900 Subject: [PATCH 1326/6294] [Modify] Polish it --- websocket-sharp/Server/HttpServer.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 6fd3b7af5..633123019 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -880,7 +880,7 @@ private void init ( string hostname, System.Net.IPAddress address, int port, bool secure ) { - _hostname = hostname ?? convertToString (address); + _hostname = hostname; _address = address; _port = port; _secure = secure; @@ -889,7 +889,7 @@ private void init ( var lsnr = new HttpListener (); var pref = String.Format ( - "http{0}://{1}:{2}/", secure ? "s" : "", _hostname, port + "http{0}://{1}:{2}/", secure ? "s" : "", hostname, port ); lsnr.Prefixes.Add (pref); From 18e0dd4c6d62f940cffe3d56dfa529cc9f985154 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 6 Jul 2017 15:00:13 +0900 Subject: [PATCH 1327/6294] [Modify] Add it --- websocket-sharp/Server/HttpServer.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 633123019..ce82d2cc6 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -871,6 +871,19 @@ private string createFilePath (string childPath) .Replace ('\\', '/'); } + private static HttpListener createListener ( + string hostname, int port, bool secure + ) + { + var lsnr = new HttpListener (); + + var schm = secure ? "https" : "http"; + var pref = String.Format ("{0}://{1}:{2}/", schm, hostname, port); + lsnr.Prefixes.Add (pref); + + return lsnr; + } + private static string getHost (Uri uri) { return uri.HostNameType == UriHostNameType.IPv6 ? uri.Host : uri.DnsSafeHost; From 31e612cac37cdae192e3973325e8e1d9b3d9b11a Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 6 Jul 2017 15:09:31 +0900 Subject: [PATCH 1328/6294] [Modify] Replace it --- websocket-sharp/Server/HttpServer.cs | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index ce82d2cc6..43ed6f8b4 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -899,15 +899,7 @@ private void init ( _secure = secure; _docRootPath = "./Public"; - - var lsnr = new HttpListener (); - var pref = String.Format ( - "http{0}://{1}:{2}/", secure ? "s" : "", hostname, port - ); - - lsnr.Prefixes.Add (pref); - _listener = lsnr; - + _listener = createListener (_hostname, _port, _secure); _log = _listener.Log; _services = new WebSocketServiceManager (_log); _sync = new object (); From 058b5d94a029af0fc96266a166116f105fef6ff8 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 6 Jul 2017 15:31:32 +0900 Subject: [PATCH 1329/6294] [Modify] Add it --- websocket-sharp/Ext.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 2adbe7de7..b604776e4 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -879,6 +879,15 @@ internal static List ToList (this IEnumerable source) return new List (source); } + internal static string ToString ( + this System.Net.IPAddress address, bool bracketIPv6 + ) + { + return bracketIPv6 && address.AddressFamily == AddressFamily.InterNetworkV6 + ? String.Format ("[{0}]", address.ToString ()) + : address.ToString (); + } + internal static ushort ToUInt16 (this byte[] source, ByteOrder sourceOrder) { return BitConverter.ToUInt16 (source.ToHostOrder (sourceOrder), 0); From a98ad15e00400d95801b754b1aa4ef426c1b1a3f Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 6 Jul 2017 15:37:14 +0900 Subject: [PATCH 1330/6294] [Modify] Replace it --- websocket-sharp/Server/HttpServer.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 43ed6f8b4..c8a9c58e1 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -287,8 +287,7 @@ public HttpServer (System.Net.IPAddress address, int port, bool secure) throw new ArgumentOutOfRangeException ("port", msg); } - var host = convertToString (address); - init (host, address, port, secure); + init (address.ToString (true), address, port, secure); } #endregion From ecd9e682e6d5f7e8be6735e5e5a09dc785a9401f Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 6 Jul 2017 15:39:30 +0900 Subject: [PATCH 1331/6294] [Modify] Remove it --- websocket-sharp/Server/HttpServer.cs | 7 ------- 1 file changed, 7 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index c8a9c58e1..5e8db47c9 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -854,13 +854,6 @@ private bool checkCertificate (out string message) return true; } - private static string convertToString (System.Net.IPAddress address) - { - return address.AddressFamily == AddressFamily.InterNetworkV6 - ? String.Format ("[{0}]", address.ToString ()) - : address.ToString (); - } - private string createFilePath (string childPath) { childPath = childPath.TrimStart ('/', '\\'); From 1b609838f4cb6bc62918211634cbe5ca70d1a7ab Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 7 Jul 2017 15:09:19 +0900 Subject: [PATCH 1332/6294] [Modify] Add it --- websocket-sharp/Ext.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index b604776e4..8026fbf9d 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -405,6 +405,13 @@ internal static string GetAbsolutePath (this Uri uri) return idx > 0 ? original.Substring (0, idx) : original; } + internal static string GetDnsSafeHost (this Uri uri, bool bracketIPv6) + { + return bracketIPv6 && uri.HostNameType == UriHostNameType.IPv6 + ? uri.Host + : uri.DnsSafeHost; + } + internal static string GetMessage (this CloseStatusCode code) { return code == CloseStatusCode.ProtocolError From 782cbee7296a3ac94ef30a1494f8ceacdeaba2e3 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 7 Jul 2017 15:12:28 +0900 Subject: [PATCH 1333/6294] [Modify] Replace it --- websocket-sharp/Server/HttpServer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 5e8db47c9..d7b886d97 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -164,7 +164,7 @@ public HttpServer (string url) if (!tryCreateUri (url, out uri, out msg)) throw new ArgumentException (msg, "url"); - var host = getHost (uri); + var host = uri.GetDnsSafeHost (true); var addr = host.ToIPAddress (); if (addr == null) { From 37a38b3d262a4a79d00f3a48fe958a942d34cd16 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 7 Jul 2017 15:13:40 +0900 Subject: [PATCH 1334/6294] [Modify] Remove it --- websocket-sharp/Server/HttpServer.cs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index d7b886d97..53c18cd25 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -876,11 +876,6 @@ private static HttpListener createListener ( return lsnr; } - private static string getHost (Uri uri) - { - return uri.HostNameType == UriHostNameType.IPv6 ? uri.Host : uri.DnsSafeHost; - } - private void init ( string hostname, System.Net.IPAddress address, int port, bool secure ) From b23054594de6c8c3793c3996baff750e1593db66 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 8 Jul 2017 14:46:46 +0900 Subject: [PATCH 1335/6294] [Modify] Polish it --- websocket-sharp/Server/HttpServer.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 53c18cd25..d96198d9e 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -836,17 +836,19 @@ private bool checkCertificate (out string message) if (!_secure) return true; - var user = _listener.SslConfiguration.ServerCertificate != null; + var byUser = _listener.SslConfiguration.ServerCertificate != null; var path = _listener.CertificateFolderPath; - var port = EndPointListener.CertificateExists (_port, path); + var withPort = EndPointListener.CertificateExists (_port, path); - if (user && port) { + var both = byUser && withPort; + if (both) { _log.Warn ("The certificate associated with the port will be used."); return true; } - if (!(user || port)) { + var either = byUser || withPort; + if (!either) { message = "There is no certificate used to authenticate the server."; return false; } From 8876b63a1eab650bf39ba7714b317aa1da1dd762 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 8 Jul 2017 14:53:49 +0900 Subject: [PATCH 1336/6294] [Modify] Polish it --- websocket-sharp/Server/HttpServer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index d96198d9e..4e3e5ee17 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -920,7 +920,7 @@ private void processRequest (HttpListenerContext context) if (evt != null) evt (this, new HttpRequestEventArgs (context, _docRootPath)); else - context.Response.StatusCode = (int) HttpStatusCode.NotImplemented; + context.Response.StatusCode = 501; // Not Implemented context.Response.Close (); } From 0133cd605cd95cc25020debb071591adbfbe48ed Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 8 Jul 2017 15:07:15 +0900 Subject: [PATCH 1337/6294] [Modify] Polish it --- websocket-sharp/Server/HttpServer.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 4e3e5ee17..7f58af25a 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -927,8 +927,10 @@ private void processRequest (HttpListenerContext context) private void processRequest (HttpListenerWebSocketContext context) { + var path = context.RequestUri.AbsolutePath; + WebSocketServiceHost host; - if (!_services.InternalTryGetServiceHost (context.RequestUri.AbsolutePath, out host)) { + if (!_services.InternalTryGetServiceHost (path, out host)) { context.Close (HttpStatusCode.NotImplemented); return; } From 1bbad14186219765265e446bb41d6593ea1b9a30 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 9 Jul 2017 19:12:21 +0900 Subject: [PATCH 1338/6294] [Modify] Polish it --- websocket-sharp/Server/HttpServer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 7f58af25a..1ec5c3bee 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -1029,7 +1029,7 @@ private void startReceiving () _listener.Start (); } catch (Exception ex) { - var msg = "The underlying HttpListener has failed to start."; + var msg = "The underlying listener has failed to start."; throw new InvalidOperationException (msg, ex); } From e117dd9d72363805a25bc7b268d80d85adddf388 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 10 Jul 2017 18:10:39 +0900 Subject: [PATCH 1339/6294] [Modify] Add checks for full path --- websocket-sharp/Server/HttpServer.cs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 1ec5c3bee..a82d1763d 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -398,6 +398,15 @@ public string DocumentRootPath { throw new ArgumentException ("An empty string.", "value"); value = value.TrimSlashOrBackslashFromEnd (); + + string full = null; + try { + full = Path.GetFullPath (value); + } + catch (Exception ex) { + throw new ArgumentException ("An invalid path string.", "value", ex); + } + if (value == "/") throw new ArgumentException ("An absolute root.", "value"); @@ -407,6 +416,12 @@ public string DocumentRootPath { if (value.Length == 2 && value[1] == ':') throw new ArgumentException ("An absolute root.", "value"); + if (full == "/") + throw new ArgumentException ("An absolute root.", "value"); + + if (full.Length == 2 && full[1] == ':') + throw new ArgumentException ("An absolute root.", "value"); + string msg; if (!canSet (out msg)) { _log.Warn (msg); From 04d73de2cc98e637b9ad2e32851dc4ce020826bf Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 11 Jul 2017 17:15:31 +0900 Subject: [PATCH 1340/6294] [Modify] Trim it --- websocket-sharp/Server/HttpServer.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index a82d1763d..281c33364 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -419,6 +419,7 @@ public string DocumentRootPath { if (full == "/") throw new ArgumentException ("An absolute root.", "value"); + full = full.TrimSlashOrBackslashFromEnd (); if (full.Length == 2 && full[1] == ':') throw new ArgumentException ("An absolute root.", "value"); From 98a2b02dc380a17dcc3504cdd5d60b9667c44d22 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 12 Jul 2017 14:52:45 +0900 Subject: [PATCH 1341/6294] [Modify] Edit it --- websocket-sharp/Server/HttpServer.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 281c33364..46da5414e 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -382,6 +382,12 @@ public AuthenticationSchemes AuthenticationSchemes { /// -or- /// /// + /// The value specified for a set operation is an invalid path string. + /// + /// + /// -or- + /// + /// /// The value specified for a set operation is an absolute root. /// /// From 5dab7521e53fd3b1c096016b35c5f639677f3da4 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 12 Jul 2017 15:15:02 +0900 Subject: [PATCH 1342/6294] [Modify] Rethrow it --- websocket-sharp/Server/WebSocketServer.cs | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index b858f4a64..35498220e 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -956,7 +956,14 @@ private void startReceiving () ); } - _listener.Start (); + try { + _listener.Start (); + } + catch (Exception ex) { + var msg = "The underlying listener has failed to start."; + throw new InvalidOperationException (msg, ex); + } + _receiveThread = new Thread (new ThreadStart (receiveRequest)); _receiveThread.IsBackground = true; _receiveThread.Start (); @@ -1310,9 +1317,12 @@ public bool RemoveWebSocketService (string path) /// /// There is no certificate in the configuration. /// - /// - /// - /// The underlying has failed to start. + /// + /// -or- + /// + /// + /// The underlying has failed to start. + /// /// public void Start () { From ed12ccaf21192d22cb9afd65f7aac938d3f6f81c Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 13 Jul 2017 17:12:50 +0900 Subject: [PATCH 1343/6294] [Modify] Rethrow it --- websocket-sharp/Server/WebSocketServer.cs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 35498220e..6c2a2496a 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -1026,7 +1026,14 @@ private void stop (ushort code, string reason) private void stopReceiving (int millisecondsTimeout) { - _listener.Stop (); + try { + _listener.Stop (); + } + catch (Exception ex) { + var msg = "The underlying listener has failed to stop."; + throw new InvalidOperationException (msg, ex); + } + _receiveThread.Join (millisecondsTimeout); } @@ -1343,7 +1350,7 @@ public void Start () /// This method does nothing if the server is not started, /// it is shutting down, or it has already stopped. /// - /// + /// /// The underlying has failed to stop. /// public void Stop () @@ -1404,7 +1411,7 @@ public void Stop () /// could not be UTF-8-encoded. /// /// - /// + /// /// The underlying has failed to stop. /// public void Stop (ushort code, string reason) @@ -1484,7 +1491,7 @@ public void Stop (ushort code, string reason) /// could not be UTF-8-encoded. /// /// - /// + /// /// The underlying has failed to stop. /// public void Stop (CloseStatusCode code, string reason) From 6a4b027e0a7379d774a36a555858d8ceadad328f Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 14 Jul 2017 16:26:42 +0900 Subject: [PATCH 1344/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketServer.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 6c2a2496a..66e01ac15 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -866,8 +866,9 @@ private void receiveRequest () ThreadPool.QueueUserWorkItem ( state => { try { - var ctx = - cl.GetWebSocketContext (null, _secure, _sslConfigInUse, _log); + var ctx = new TcpListenerWebSocketContext ( + cl, null, _secure, _sslConfigInUse, _log + ); if (!ctx.Authenticate (_authSchemes, _realmInUse, _userCredFinder)) return; @@ -875,7 +876,7 @@ private void receiveRequest () processRequest (ctx); } catch (Exception ex) { - _log.Fatal (ex.Message); + _log.Error (ex.Message); _log.Debug (ex.ToString ()); cl.Close (); @@ -885,7 +886,7 @@ private void receiveRequest () } catch (SocketException ex) { if (_state == ServerState.ShuttingDown) { - _log.Info ("The receiving is stopped."); + _log.Info ("The underlying listener is stopped."); break; } From 9b65b64692ab6b43f375b07e1076a38405761d5f Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 14 Jul 2017 16:29:06 +0900 Subject: [PATCH 1345/6294] [Modify] Remove it --- websocket-sharp/Ext.cs | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 8026fbf9d..076b702e6 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -487,16 +487,6 @@ internal static string GetValue (this string nameAndValue, char separator, bool return unquote ? val.Unquote () : val; } - internal static TcpListenerWebSocketContext GetWebSocketContext ( - this TcpClient tcpClient, - string protocol, - bool secure, - ServerSslConfiguration sslConfig, - Logger logger) - { - return new TcpListenerWebSocketContext (tcpClient, protocol, secure, sslConfig, logger); - } - internal static byte[] InternalToByteArray (this ushort value, ByteOrder order) { var bytes = BitConverter.GetBytes (value); From 3479d0a59b08954cef9574745f7f6e9a420de2ee Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 15 Jul 2017 17:57:55 +0900 Subject: [PATCH 1346/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 66e01ac15..06b26fa0c 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -139,7 +139,7 @@ public WebSocketServer (int port) /// /// /// The new instance listens for incoming handshake requests on - /// the local IP address of the host of and + /// the IP address of the host of and /// the port of . /// /// @@ -148,13 +148,12 @@ public WebSocketServer (int port) /// is wss; otherwise, port 80 is used. /// /// - /// That instance provides secure connections if the scheme of + /// The new instance provides secure connections if the scheme of /// is wss. /// /// /// - /// A that represents the WebSocket URL - /// on which to listen. + /// A that represents the WebSocket URL of the server. /// /// /// is . From 441782d24f46902eff9b38946453d6340d965b6f Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 16 Jul 2017 16:23:17 +0900 Subject: [PATCH 1347/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 06b26fa0c..d6ace33db 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -242,8 +242,8 @@ public WebSocketServer (int port, bool secure) /// /// /// - /// A that represents - /// the local IP address on which to listen. + /// A that represents the local + /// IP address on which to listen. /// /// /// An that represents the number of the port From 60a25a9124de16ba93e946a61f4d450e67f9d0e2 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 16 Jul 2017 16:29:14 +0900 Subject: [PATCH 1348/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index d6ace33db..a06a16447 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -273,8 +273,8 @@ public WebSocketServer (System.Net.IPAddress address, int port) /// and . /// /// - /// A that represents - /// the local IP address on which to listen. + /// A that represents the local + /// IP address on which to listen. /// /// /// An that represents the number of the port From d2b36fbd38e717df037eddbe954d2c1b4ac5c1e5 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 17 Jul 2017 16:05:59 +0900 Subject: [PATCH 1349/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index a06a16447..23d49f79f 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -327,16 +327,16 @@ public System.Net.IPAddress Address { } /// - /// Gets or sets a value indicating whether the server accepts - /// a handshake request without checking the request URI. + /// Gets or sets a value indicating whether the server accepts every + /// handshake request without checking the request URI. /// /// - /// The set operation does nothing if the server has already - /// started or it is shutting down. + /// The set operation does nothing if the server has already started or + /// it is shutting down. /// /// /// - /// true if the server accepts a handshake request without + /// true if the server accepts every handshake request without /// checking the request URI; otherwise, false. /// /// From e603aee813bb2330da7962e786a6d62ffff7df07 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 17 Jul 2017 16:10:55 +0900 Subject: [PATCH 1350/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 23d49f79f..716db9472 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -370,8 +370,8 @@ public bool AllowForwardedRequest { /// Gets or sets the scheme used to authenticate the clients. /// /// - /// The set operation does nothing if the server has already - /// started or it is shutting down. + /// The set operation does nothing if the server has already started or + /// it is shutting down. /// /// /// From ea8b8f9efa804a3ca2a8ba9e916e7a1eba5bedba Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 17 Jul 2017 16:18:41 +0900 Subject: [PATCH 1351/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 716db9472..9619689dd 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -440,13 +440,13 @@ public bool IsSecure { /// the inactive sessions periodically. /// /// - /// The set operation does nothing if the server has already - /// started or it is shutting down. + /// The set operation does nothing if the server has already started or + /// it is shutting down. /// /// /// - /// true if the server cleans up the inactive sessions - /// every 60 seconds; otherwise, false. + /// true if the server cleans up the inactive sessions every + /// 60 seconds; otherwise, false. /// /// /// The default value is true. From 3bba0f72087f174eafa6564b74f2e2b4f67933a2 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 18 Jul 2017 15:32:50 +0900 Subject: [PATCH 1352/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 9619689dd..e3ee2973b 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -508,18 +508,17 @@ public int Port { /// /// /// - /// The set operation does nothing if the server has already - /// started or it is shutting down. + /// "SECRET AREA" is used as the realm if the value is + /// or an empty string. /// /// - /// SECRET AREA will be used as the name if the value is - /// or an empty string. + /// The set operation does nothing if the server has + /// already started or it is shutting down. /// /// /// /// - /// A or - /// by default. + /// A or by default. /// /// /// That string represents the name of the realm. From afbecc812784198bc600e3172ffd70a041e8061b Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 18 Jul 2017 15:39:27 +0900 Subject: [PATCH 1353/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index e3ee2973b..0bc25a43f 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -553,13 +553,13 @@ public string Realm { /// /// /// - /// The set operation does nothing if the server has already - /// started or it is shutting down. - /// - /// /// You should set this property to true if you would /// like to resolve to wait for socket in TIME_WAIT state. /// + /// + /// The set operation does nothing if the server has already + /// started or it is shutting down. + /// /// /// /// From e18960815402c611314e2f8b5e5b55c1f56360ef Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 18 Jul 2017 15:56:42 +0900 Subject: [PATCH 1354/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 0bc25a43f..91b293522 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -614,23 +614,24 @@ public ServerSslConfiguration SslConfiguration { } /// - /// Gets or sets the delegate used to find the credentials for - /// an identity. + /// Gets or sets the delegate used to find the credentials + /// for an identity. /// /// /// - /// The set operation does nothing if the server has already - /// started or it is shutting down. - /// - /// /// No credentials are found if the method invoked by /// the delegate returns or /// the value is . /// + /// + /// The set operation does nothing if the server has + /// already started or it is shutting down. + /// /// /// /// - /// A Func<IIdentity, NetworkCredential> delegate or + /// A Func<, + /// > delegate or /// if not needed. /// /// From 559248e94ed1e0981485da482a0daa9aadb4b0c8 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 19 Jul 2017 15:25:55 +0900 Subject: [PATCH 1355/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 91b293522..a63f428bc 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -670,8 +670,8 @@ public Func UserCredentialsFinder { /// the WebSocket Ping or Close. /// /// - /// The set operation does nothing if the server has already - /// started or it is shutting down. + /// The set operation does nothing if the server has + /// already started or it is shutting down. /// /// /// From 556dec8cfc7666a5bff0628ace5bb8a96868b65b Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 19 Jul 2017 15:38:12 +0900 Subject: [PATCH 1356/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index a63f428bc..4488fd647 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -1311,8 +1311,8 @@ public bool RemoveWebSocketService (string path) /// Starts receiving incoming handshake requests. /// /// - /// This method does nothing if the server has already - /// started or it is shutting down. + /// This method does nothing if the server has already started or + /// it is shutting down. /// /// /// From bce851bface2bd006e65df1a789cec0c84d1f6bb Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 19 Jul 2017 15:50:47 +0900 Subject: [PATCH 1357/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 4488fd647..fd9aa50b4 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -1343,8 +1343,8 @@ public void Start () } /// - /// Stops receiving incoming handshake requests and - /// closes each connection. + /// Stops receiving incoming handshake requests and closes + /// each connection. /// /// /// This method does nothing if the server is not started, From 70d097ce7435c047ca051586be85bba1eac7c569 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 20 Jul 2017 17:23:43 +0900 Subject: [PATCH 1358/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index fd9aa50b4..c3e7e1db3 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -1379,8 +1379,12 @@ public void Stop () /// /// /// - /// A that represents the reason for the close. - /// The size must be 123 bytes or less in UTF-8. + /// + /// A that represents the reason for the close. + /// + /// + /// The size must be 123 bytes or less in UTF-8. + /// /// /// /// From 69659803536587506fe72da946a91a3f1ac034cb Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 20 Jul 2017 17:41:49 +0900 Subject: [PATCH 1359/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index c3e7e1db3..c4382cd40 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -1469,12 +1469,13 @@ public void Stop (ushort code, string reason) /// /// /// - /// A that represents the reason for the close. - /// The size must be 123 bytes or less in UTF-8. + /// + /// A that represents the reason for the close. + /// + /// + /// The size must be 123 bytes or less in UTF-8. + /// /// - /// - /// The size of is greater than 123 bytes. - /// /// /// /// is @@ -1495,6 +1496,9 @@ public void Stop (ushort code, string reason) /// could not be UTF-8-encoded. /// /// + /// + /// The size of is greater than 123 bytes. + /// /// /// The underlying has failed to stop. /// From 13f7da800e87daba492c93ac235f7542218b4beb Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 21 Jul 2017 16:34:13 +0900 Subject: [PATCH 1360/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index c4382cd40..fd8f88b43 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -1064,7 +1064,7 @@ private static bool tryCreateUri ( /// /// /// is converted to a URL-decoded string and - /// / is trimmed from the end of the converted string if any. + /// '/' is trimmed from the end of the converted string if any. /// /// /// A that represents an absolute path to @@ -1075,17 +1075,21 @@ private static bool tryCreateUri ( /// A Func<TBehavior> delegate. /// /// - /// It invokes the method called for creating - /// a new session instance for the service. + /// It invokes the method called for creating a new session + /// instance for the service. /// /// - /// The method must create a new instance of - /// the specified behavior class and return it. + /// The method must create a new instance of the specified + /// behavior class and return it. /// /// /// - /// The type of the behavior for the service. It must inherit - /// the class. + /// + /// The type of the behavior for the service. + /// + /// + /// It must inherit the class. + /// /// /// /// From 85577bdb1b2367eebcfa21a03cd54ca5dca7317e Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 21 Jul 2017 16:43:19 +0900 Subject: [PATCH 1361/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index fd8f88b43..d9567d99e 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -1158,16 +1158,20 @@ public void AddWebSocketService ( /// /// /// is converted to a URL-decoded string and - /// / is trimmed from the end of the converted string if any. + /// '/' is trimmed from the end of the converted string if any. /// /// /// A that represents an absolute path to /// the service to add. /// /// - /// The type of the behavior for the service. It must inherit - /// the class and it must have - /// a public parameterless constructor. + /// + /// The type of the behavior for the service. + /// + /// + /// It must inherit the class and + /// have a public parameterless constructor. + /// /// /// /// is . From f0bba05a2ebe0a3c02e096cf651c6ace484027b6 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 21 Jul 2017 16:51:31 +0900 Subject: [PATCH 1362/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index d9567d99e..fb63ab4fb 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -1212,7 +1212,7 @@ public void AddWebSocketService (string path) /// /// /// is converted to a URL-decoded string and - /// / is trimmed from the end of the converted string if any. + /// '/' is trimmed from the end of the converted string if any. /// /// /// A that represents an absolute path to @@ -1229,9 +1229,13 @@ public void AddWebSocketService (string path) /// /// /// - /// The type of the behavior for the service. It must inherit - /// the class and it must have - /// a public parameterless constructor. + /// + /// The type of the behavior for the service. + /// + /// + /// It must inherit the class and + /// have a public parameterless constructor. + /// /// /// /// is . From fa243dbba857addb78fe7ed6c2f19b637978f5e9 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 22 Jul 2017 17:09:24 +0900 Subject: [PATCH 1363/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index fb63ab4fb..b38fea2fe 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -1278,7 +1278,7 @@ public void AddWebSocketService ( /// /// /// is converted to a URL-decoded string and - /// / is trimmed from the end of the converted string if any. + /// '/' is trimmed from the end of the converted string if any. /// /// /// The service is stopped with close status 1001 (going away) @@ -1298,7 +1298,7 @@ public void AddWebSocketService ( /// /// /// - /// is empty. + /// is an empty string. /// /// /// -or- From 79e400d1c58be28d1fbe6fd813453562585b6ba4 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 22 Jul 2017 17:12:00 +0900 Subject: [PATCH 1364/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index b38fea2fe..be95bc814 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -160,7 +160,7 @@ public WebSocketServer (int port) /// /// /// - /// is empty. + /// is an empty string. /// /// /// -or- From 7bdffbdf347e999d0975118037e1d1983f29a2ff Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 22 Jul 2017 17:13:28 +0900 Subject: [PATCH 1365/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index be95bc814..3a82efda0 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -1104,7 +1104,7 @@ private static bool tryCreateUri ( /// /// /// - /// is empty. + /// is an empty string. /// /// /// -or- From f0f27a464c1ff16a236adad89acb53066c803c0e Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 22 Jul 2017 17:14:21 +0900 Subject: [PATCH 1366/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 3a82efda0..ff555cabf 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -1178,7 +1178,7 @@ public void AddWebSocketService ( /// /// /// - /// is empty. + /// is an empty string. /// /// /// -or- From 66880027cbaa0a8b3b6a6ba7b7436aaabeb70848 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 22 Jul 2017 17:15:46 +0900 Subject: [PATCH 1367/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index ff555cabf..6d1a72236 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -1242,7 +1242,7 @@ public void AddWebSocketService (string path) /// /// /// - /// is empty. + /// is an empty string. /// /// /// -or- From 0c360fbf37957da98e374693dbd4eedf2782c631 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 23 Jul 2017 15:15:23 +0900 Subject: [PATCH 1368/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 6d1a72236..9657da323 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -2,8 +2,6 @@ /* * WebSocketServer.cs * - * A C# implementation of the WebSocket protocol server. - * * The MIT License * * Copyright (c) 2012-2015 sta.blockhead From dfb8746cdfdb9ff9716ed3bd6507270ca82d04a1 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 23 Jul 2017 17:40:21 +0900 Subject: [PATCH 1369/6294] [Modify] Throw exceptions --- websocket-sharp/WebSocket.cs | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index cddd220c8..7f43064cd 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2449,12 +2449,19 @@ public void Close () /// public void Close (ushort code) { - string msg; - if (!CheckParametersForClose (code, null, _client, out msg)) { - _logger.Error (msg); - error ("An error has occurred in closing the connection.", null); + if (!code.IsCloseStatusCode ()) { + var msg = "Less than 1000 or greater than 4999."; + throw new ArgumentOutOfRangeException ("code", msg); + } - return; + if (_client && code == 1011) { + var msg = "1011 cannot be used."; + throw new ArgumentException (msg, "code"); + } + + if (!_client && code == 1010) { + var msg = "1010 cannot be used."; + throw new ArgumentException (msg, "code"); } close (code, String.Empty); From 21b880dbccafe5adcdf242db4747d847e7b8989a Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 24 Jul 2017 15:24:51 +0900 Subject: [PATCH 1370/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 7f43064cd..42d0aac63 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2434,19 +2434,39 @@ public void Close () } /// - /// Closes the WebSocket connection with the specified , - /// and releases all associated resources. + /// Closes the connection with the specified . /// /// /// This method does nothing if the current state of the connection is /// Closing or Closed. /// /// - /// A that represents the status code indicating - /// the reason for the close. The status codes are defined in - /// - /// Section 7.4 of RFC 6455. + /// + /// A that represents the status code + /// indicating the reason for the close. + /// + /// + /// The status codes are defined in + /// + /// Section 7.4 of RFC 6455. + /// /// + /// + /// is less than 1000 or greater than 4999. + /// + /// + /// + /// is 1011 (server error) and + /// it cannot be used by clients. + /// + /// + /// -or- + /// + /// + /// is 1010 (mandatory extension) and + /// it cannot be used by servers. + /// + /// public void Close (ushort code) { if (!code.IsCloseStatusCode ()) { From 2306b1a925333d53fdb041eff3ef7282f48b2ddd Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 24 Jul 2017 15:29:15 +0900 Subject: [PATCH 1371/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 42d0aac63..3c23ec6c0 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2422,7 +2422,7 @@ public void AcceptAsync () } /// - /// Closes the WebSocket connection, and releases all associated resources. + /// Closes the connection. /// /// /// This method does nothing if the current state of the connection is From eb379b6f76ea3bf43aff17fbc28e17657e41e332 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 24 Jul 2017 15:37:13 +0900 Subject: [PATCH 1372/6294] [Modify] Throw exceptions --- websocket-sharp/WebSocket.cs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 3c23ec6c0..202da89d0 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2501,12 +2501,14 @@ public void Close (ushort code) /// public void Close (CloseStatusCode code) { - string msg; - if (!CheckParametersForClose (code, null, _client, out msg)) { - _logger.Error (msg); - error ("An error has occurred in closing the connection.", null); + if (_client && code == CloseStatusCode.ServerError) { + var msg = "ServerError cannot be used."; + throw new ArgumentException (msg, "code"); + } - return; + if (!_client && code == CloseStatusCode.MandatoryExtension) { + var msg = "MandatoryExtension cannot be used."; + throw new ArgumentException (msg, "code"); } close ((ushort) code, String.Empty); From 5fd07ec5fe09b9fdd4b789dbcdfc626ce0b7a2ff Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 25 Jul 2017 15:11:24 +0900 Subject: [PATCH 1373/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 202da89d0..f791eca82 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2488,17 +2488,35 @@ public void Close (ushort code) } /// - /// Closes the WebSocket connection with the specified , - /// and releases all associated resources. + /// Closes the connection with the specified . /// /// /// This method does nothing if the current state of the connection is /// Closing or Closed. /// /// - /// One of the enum values that represents - /// the status code indicating the reason for the close. + /// + /// One of the enum values. + /// + /// + /// It represents the status code indicating the reason for the close. + /// /// + /// + /// + /// is + /// . + /// It cannot be used by clients. + /// + /// + /// -or- + /// + /// + /// is + /// . + /// It cannot be used by servers. + /// + /// public void Close (CloseStatusCode code) { if (_client && code == CloseStatusCode.ServerError) { From 4d850eb028c67ded3be1c6ee046499467fcb4e11 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 25 Jul 2017 15:13:58 +0900 Subject: [PATCH 1374/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index f791eca82..242f8ecf5 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2456,15 +2456,15 @@ public void Close () /// /// /// - /// is 1011 (server error) and - /// it cannot be used by clients. + /// is 1011 (server error). + /// It cannot be used by clients. /// /// /// -or- /// /// - /// is 1010 (mandatory extension) and - /// it cannot be used by servers. + /// is 1010 (mandatory extension). + /// It cannot be used by servers. /// /// public void Close (ushort code) From 4cbec283790d18473b7f433d01dee6c6c004a429 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 25 Jul 2017 15:23:19 +0900 Subject: [PATCH 1375/6294] [Modify] Throw exceptions --- websocket-sharp/WebSocket.cs | 35 ++++++++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 242f8ecf5..d06ef020f 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2552,12 +2552,37 @@ public void Close (CloseStatusCode code) /// public void Close (ushort code, string reason) { - string msg; - if (!CheckParametersForClose (code, reason, _client, out msg)) { - _logger.Error (msg); - error ("An error has occurred in closing the connection.", null); + if (!code.IsCloseStatusCode ()) { + var msg = "Less than 1000 or greater than 4999."; + throw new ArgumentOutOfRangeException ("code", msg); + } - return; + if (_client && code == 1011) { + var msg = "1011 cannot be used."; + throw new ArgumentException (msg, "code"); + } + + if (!_client && code == 1010) { + var msg = "1010 cannot be used."; + throw new ArgumentException (msg, "code"); + } + + if (!reason.IsNullOrEmpty ()) { + if (code == 1005) { + var msg = "1005 cannot be used."; + throw new ArgumentException (msg, "code"); + } + + byte[] bytes; + if (!reason.TryGetUTF8EncodedBytes (out bytes)) { + var msg = "It could not be UTF-8-encoded."; + throw new ArgumentException (msg, "reason"); + } + + if (bytes.Length > 123) { + var msg = "Its size is greater than 123 bytes."; + throw new ArgumentOutOfRangeException ("reason", msg); + } } close (code, reason); From a02b212d743d8b17a4b67ca01d5734e28b39c0a3 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 26 Jul 2017 15:03:58 +0900 Subject: [PATCH 1376/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 62 +++++++++++++++++++++++++++++++----- 1 file changed, 54 insertions(+), 8 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index d06ef020f..bdf379340 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2533,23 +2533,69 @@ public void Close (CloseStatusCode code) } /// - /// Closes the WebSocket connection with the specified and - /// , and releases all associated resources. + /// Closes the connection with the specified and + /// . /// /// /// This method does nothing if the current state of the connection is /// Closing or Closed. /// /// - /// A that represents the status code indicating - /// the reason for the close. The status codes are defined in - /// - /// Section 7.4 of RFC 6455. + /// + /// A that represents the status code + /// indicating the reason for the close. + /// + /// + /// The status codes are defined in + /// + /// Section 7.4 of RFC 6455. + /// /// /// - /// A that represents the reason for the close. - /// The size must be 123 bytes or less. + /// + /// A that represents the reason for the close. + /// + /// + /// The size must be 123 bytes or less in UTF-8. + /// /// + /// + /// + /// is less than 1000 or greater than 4999. + /// + /// + /// -or- + /// + /// + /// The size of is greater than 123 bytes. + /// + /// + /// + /// + /// is 1011 (server error). + /// It cannot be used by clients. + /// + /// + /// -or- + /// + /// + /// is 1010 (mandatory extension). + /// It cannot be used by servers. + /// + /// + /// -or- + /// + /// + /// is 1005 (no status) and + /// there is . + /// + /// + /// -or- + /// + /// + /// could not be UTF-8-encoded. + /// + /// public void Close (ushort code, string reason) { if (!code.IsCloseStatusCode ()) { From 5a91fbd3184df66154701fc25587afdd7784a0c9 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 26 Jul 2017 15:16:27 +0900 Subject: [PATCH 1377/6294] [Modify] Throw exceptions --- websocket-sharp/WebSocket.cs | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index bdf379340..e88c5757c 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2652,14 +2652,37 @@ public void Close (ushort code, string reason) /// public void Close (CloseStatusCode code, string reason) { - string msg; - if (!CheckParametersForClose (code, reason, _client, out msg)) { - _logger.Error (msg); - error ("An error has occurred in closing the connection.", null); + if (_client && code == CloseStatusCode.ServerError) { + var msg = "ServerError cannot be used."; + throw new ArgumentException (msg, "code"); + } + if (!_client && code == CloseStatusCode.MandatoryExtension) { + var msg = "MandatoryExtension cannot be used."; + throw new ArgumentException (msg, "code"); + } + + if (reason.IsNullOrEmpty ()) { + close ((ushort) code, String.Empty); return; } + if (code == CloseStatusCode.NoStatus) { + var msg = "NoStatus cannot be used."; + throw new ArgumentException (msg, "code"); + } + + byte[] bytes; + if (!reason.TryGetUTF8EncodedBytes (out bytes)) { + var msg = "It could not be UTF-8-encoded."; + throw new ArgumentException (msg, "reason"); + } + + if (bytes.Length > 123) { + var msg = "Its size is greater than 123 bytes."; + throw new ArgumentOutOfRangeException ("reason", msg); + } + close ((ushort) code, reason); } From 8cfe277d9537c68571fab12bd7b3edb8c46648ef Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 27 Jul 2017 17:25:37 +0900 Subject: [PATCH 1378/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 52 +++++++++++++++++++++++++++++++----- 1 file changed, 46 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index e88c5757c..8e98df97a 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2635,21 +2635,61 @@ public void Close (ushort code, string reason) } /// - /// Closes the WebSocket connection with the specified and - /// , and releases all associated resources. + /// Closes the connection with the specified and + /// . /// /// /// This method does nothing if the current state of the connection is /// Closing or Closed. /// /// - /// One of the enum values that represents - /// the status code indicating the reason for the close. + /// + /// One of the enum values. + /// + /// + /// It represents the status code indicating the reason for the close. + /// /// /// - /// A that represents the reason for the close. - /// The size must be 123 bytes or less. + /// + /// A that represents the reason for the close. + /// + /// + /// The size must be 123 bytes or less in UTF-8. + /// /// + /// + /// + /// is + /// . + /// It cannot be used by clients. + /// + /// + /// -or- + /// + /// + /// is + /// . + /// It cannot be used by servers. + /// + /// + /// -or- + /// + /// + /// is + /// and + /// there is . + /// + /// + /// -or- + /// + /// + /// could not be UTF-8-encoded. + /// + /// + /// + /// The size of is greater than 123 bytes. + /// public void Close (CloseStatusCode code, string reason) { if (_client && code == CloseStatusCode.ServerError) { From c86e317ef1a4ce8bda725f0dc7cf0f0fdb9fc435 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 27 Jul 2017 17:39:08 +0900 Subject: [PATCH 1379/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 8e98df97a..83df01807 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2613,22 +2613,25 @@ public void Close (ushort code, string reason) throw new ArgumentException (msg, "code"); } - if (!reason.IsNullOrEmpty ()) { - if (code == 1005) { - var msg = "1005 cannot be used."; - throw new ArgumentException (msg, "code"); - } + if (reason.IsNullOrEmpty ()) { + close (code, String.Empty); + return; + } - byte[] bytes; - if (!reason.TryGetUTF8EncodedBytes (out bytes)) { - var msg = "It could not be UTF-8-encoded."; - throw new ArgumentException (msg, "reason"); - } + if (code == 1005) { + var msg = "1005 cannot be used."; + throw new ArgumentException (msg, "code"); + } - if (bytes.Length > 123) { - var msg = "Its size is greater than 123 bytes."; - throw new ArgumentOutOfRangeException ("reason", msg); - } + byte[] bytes; + if (!reason.TryGetUTF8EncodedBytes (out bytes)) { + var msg = "It could not be UTF-8-encoded."; + throw new ArgumentException (msg, "reason"); + } + + if (bytes.Length > 123) { + var msg = "Its size is greater than 123 bytes."; + throw new ArgumentOutOfRangeException ("reason", msg); } close (code, reason); From 8df303f1f6ff13b8ea9cd9784d626bf63233423a Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 28 Jul 2017 17:22:55 +0900 Subject: [PATCH 1380/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 83df01807..39e973c45 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2730,16 +2730,15 @@ public void Close (CloseStatusCode code, string reason) } /// - /// Closes the WebSocket connection asynchronously, and releases - /// all associated resources. + /// Closes the connection asynchronously. /// /// /// - /// This method does nothing if the current state of the connection is - /// Closing or Closed. + /// This method does not wait for the close to be complete. /// /// - /// This method does not wait for the close to be complete. + /// And this method does nothing if the current state of + /// the connection is Closing or Closed. /// /// public void CloseAsync () From 9543252eb22445d0a7365a1fe066df534115397a Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 28 Jul 2017 17:27:24 +0900 Subject: [PATCH 1381/6294] [Modify] Throw exceptions --- websocket-sharp/WebSocket.cs | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 39e973c45..58cab3f0a 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2767,12 +2767,19 @@ public void CloseAsync () /// public void CloseAsync (ushort code) { - string msg; - if (!CheckParametersForClose (code, null, _client, out msg)) { - _logger.Error (msg); - error ("An error has occurred in closing the connection.", null); + if (!code.IsCloseStatusCode ()) { + var msg = "Less than 1000 or greater than 4999."; + throw new ArgumentOutOfRangeException ("code", msg); + } - return; + if (_client && code == 1011) { + var msg = "1011 cannot be used."; + throw new ArgumentException (msg, "code"); + } + + if (!_client && code == 1010) { + var msg = "1010 cannot be used."; + throw new ArgumentException (msg, "code"); } closeAsync (code, String.Empty); From 17bc2aaab891f829149abd4ce6b9aed87433eccd Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 28 Jul 2017 17:37:07 +0900 Subject: [PATCH 1382/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 39 +++++++++++++++++++++++++++--------- 1 file changed, 30 insertions(+), 9 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 58cab3f0a..7ad22b2ce 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2747,24 +2747,45 @@ public void CloseAsync () } /// - /// Closes the WebSocket connection asynchronously with the specified - /// , and releases all associated resources. + /// Closes the connection asynchronously with the specified + /// . /// /// /// - /// This method does nothing if the current state of the connection is - /// Closing or Closed. + /// This method does not wait for the close to be complete. /// /// - /// This method does not wait for the close to be complete. + /// And this method does nothing if the current state of + /// the connection is Closing or Closed. /// /// /// - /// A that represents the status code indicating - /// the reason for the close. The status codes are defined in - /// - /// Section 7.4 of RFC 6455. + /// + /// A that represents the status code + /// indicating the reason for the close. + /// + /// + /// The status codes are defined in + /// + /// Section 7.4 of RFC 6455. + /// /// + /// + /// is less than 1000 or greater than 4999. + /// + /// + /// + /// is 1011 (server error). + /// It cannot be used by clients. + /// + /// + /// -or- + /// + /// + /// is 1010 (mandatory extension). + /// It cannot be used by servers. + /// + /// public void CloseAsync (ushort code) { if (!code.IsCloseStatusCode ()) { From 7e62581cc3b8293a32637e9fdded6619c2bc719b Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 28 Jul 2017 17:40:19 +0900 Subject: [PATCH 1383/6294] [Modify] Throw exceptions --- websocket-sharp/WebSocket.cs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 7ad22b2ce..01284f039 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2825,12 +2825,14 @@ public void CloseAsync (ushort code) /// public void CloseAsync (CloseStatusCode code) { - string msg; - if (!CheckParametersForClose (code, null, _client, out msg)) { - _logger.Error (msg); - error ("An error has occurred in closing the connection.", null); + if (_client && code == CloseStatusCode.ServerError) { + var msg = "ServerError cannot be used."; + throw new ArgumentException (msg, "code"); + } - return; + if (!_client && code == CloseStatusCode.MandatoryExtension) { + var msg = "MandatoryExtension cannot be used."; + throw new ArgumentException (msg, "code"); } closeAsync ((ushort) code, String.Empty); From 0fb0198a343bbf0bc982cf92a4699377656319c5 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 29 Jul 2017 18:00:21 +0900 Subject: [PATCH 1384/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 33 ++++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 01284f039..66385ade9 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2807,22 +2807,41 @@ public void CloseAsync (ushort code) } /// - /// Closes the WebSocket connection asynchronously with the specified - /// , and releases all associated resources. + /// Closes the connection asynchronously with the specified + /// . /// /// /// - /// This method does nothing if the current state of the connection is - /// Closing or Closed. + /// This method does not wait for the close to be complete. /// /// - /// This method does not wait for the close to be complete. + /// And this method does nothing if the current state of + /// the connection is Closing or Closed. /// /// /// - /// One of the enum values that represents - /// the status code indicating the reason for the close. + /// + /// One of the enum values. + /// + /// + /// It represents the status code indicating the reason for the close. + /// /// + /// + /// + /// is + /// . + /// It cannot be used by clients. + /// + /// + /// -or- + /// + /// + /// is + /// . + /// It cannot be used by servers. + /// + /// public void CloseAsync (CloseStatusCode code) { if (_client && code == CloseStatusCode.ServerError) { From e9e74300602692579093a233c36883c280453e55 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 30 Jul 2017 15:51:33 +0900 Subject: [PATCH 1385/6294] [Modify] Throw exceptions --- websocket-sharp/WebSocket.cs | 36 ++++++++++++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 66385ade9..9cd873d2f 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2883,14 +2883,42 @@ public void CloseAsync (CloseStatusCode code) /// public void CloseAsync (ushort code, string reason) { - string msg; - if (!CheckParametersForClose (code, reason, _client, out msg)) { - _logger.Error (msg); - error ("An error has occurred in closing the connection.", null); + if (!code.IsCloseStatusCode ()) { + var msg = "Less than 1000 or greater than 4999."; + throw new ArgumentOutOfRangeException ("code", msg); + } + + if (_client && code == 1011) { + var msg = "1011 cannot be used."; + throw new ArgumentException (msg, "code"); + } + + if (!_client && code == 1010) { + var msg = "1010 cannot be used."; + throw new ArgumentException (msg, "code"); + } + if (reason.IsNullOrEmpty ()) { + closeAsync (code, String.Empty); return; } + if (code == 1005) { + var msg = "1005 cannot be used."; + throw new ArgumentException (msg, "code"); + } + + byte[] bytes; + if (!reason.TryGetUTF8EncodedBytes (out bytes)) { + var msg = "It could not be UTF-8-encoded."; + throw new ArgumentException (msg, "reason"); + } + + if (bytes.Length > 123) { + var msg = "Its size is greater than 123 bytes."; + throw new ArgumentOutOfRangeException ("reason", msg); + } + closeAsync (code, reason); } From cf9f3b11e5a9560ca75bf6ed2151963bdff8cb04 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 30 Jul 2017 16:02:38 +0900 Subject: [PATCH 1386/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 69 +++++++++++++++++++++++++++++------- 1 file changed, 57 insertions(+), 12 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 9cd873d2f..f39973c2e 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2858,29 +2858,74 @@ public void CloseAsync (CloseStatusCode code) } /// - /// Closes the WebSocket connection asynchronously with the specified - /// and , and releases - /// all associated resources. + /// Closes the connection asynchronously with the specified + /// and . /// /// /// - /// This method does nothing if the current state of the connection is - /// Closing or Closed. + /// This method does not wait for the close to be complete. /// /// - /// This method does not wait for the close to be complete. + /// And this method does nothing if the current state of + /// the connection is Closing or Closed. /// /// /// - /// A that represents the status code indicating - /// the reason for the close. The status codes are defined in - /// - /// Section 7.4 of RFC 6455. + /// + /// A that represents the status code + /// indicating the reason for the close. + /// + /// + /// The status codes are defined in + /// + /// Section 7.4 of RFC 6455. + /// /// /// - /// A that represents the reason for the close. - /// The size must be 123 bytes or less. + /// + /// A that represents the reason for the close. + /// + /// + /// The size must be 123 bytes or less in UTF-8. + /// /// + /// + /// + /// is less than 1000 or greater than 4999. + /// + /// + /// -or- + /// + /// + /// The size of is greater than 123 bytes. + /// + /// + /// + /// + /// is 1011 (server error). + /// It cannot be used by clients. + /// + /// + /// -or- + /// + /// + /// is 1010 (mandatory extension). + /// It cannot be used by servers. + /// + /// + /// -or- + /// + /// + /// is 1005 (no status) and + /// there is . + /// + /// + /// -or- + /// + /// + /// could not be UTF-8-encoded. + /// + /// public void CloseAsync (ushort code, string reason) { if (!code.IsCloseStatusCode ()) { From 31d4c555f9c01bbbed3d822e540d896459683c4a Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 30 Jul 2017 16:08:41 +0900 Subject: [PATCH 1387/6294] [Modify] Throw exceptions --- websocket-sharp/WebSocket.cs | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index f39973c2e..e10788364 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2991,14 +2991,37 @@ public void CloseAsync (ushort code, string reason) /// public void CloseAsync (CloseStatusCode code, string reason) { - string msg; - if (!CheckParametersForClose (code, reason, _client, out msg)) { - _logger.Error (msg); - error ("An error has occurred in closing the connection.", null); + if (_client && code == CloseStatusCode.ServerError) { + var msg = "ServerError cannot be used."; + throw new ArgumentException (msg, "code"); + } + + if (!_client && code == CloseStatusCode.MandatoryExtension) { + var msg = "MandatoryExtension cannot be used."; + throw new ArgumentException (msg, "code"); + } + if (reason.IsNullOrEmpty ()) { + closeAsync ((ushort) code, String.Empty); return; } + if (code == CloseStatusCode.NoStatus) { + var msg = "NoStatus cannot be used."; + throw new ArgumentException (msg, "code"); + } + + byte[] bytes; + if (!reason.TryGetUTF8EncodedBytes (out bytes)) { + var msg = "It could not be UTF-8-encoded."; + throw new ArgumentException (msg, "reason"); + } + + if (bytes.Length > 123) { + var msg = "Its size is greater than 123 bytes."; + throw new ArgumentOutOfRangeException ("reason", msg); + } + closeAsync ((ushort) code, reason); } From 899f8c83165fe273be225193ae8e3ad4e8dbaba5 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 31 Jul 2017 16:16:45 +0900 Subject: [PATCH 1388/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 59 ++++++++++++++++++++++++++++++------ 1 file changed, 49 insertions(+), 10 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index e10788364..698290c1e 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2968,27 +2968,66 @@ public void CloseAsync (ushort code, string reason) } /// - /// Closes the WebSocket connection asynchronously with the specified - /// and , and releases - /// all associated resources. + /// Closes the connection asynchronously with the specified + /// and . /// /// /// - /// This method does nothing if the current state of the connection is - /// Closing or Closed. + /// This method does not wait for the close to be complete. /// /// - /// This method does not wait for the close to be complete. + /// And this method does nothing if the current state of + /// the connection is Closing or Closed. /// /// /// - /// One of the enum values that represents - /// the status code indicating the reason for the close. + /// + /// One of the enum values. + /// + /// + /// It represents the status code indicating the reason for the close. + /// /// /// - /// A that represents the reason for the close. - /// The size must be 123 bytes or less. + /// + /// A that represents the reason for the close. + /// + /// + /// The size must be 123 bytes or less in UTF-8. + /// /// + /// + /// + /// is + /// . + /// It cannot be used by clients. + /// + /// + /// -or- + /// + /// + /// is + /// . + /// It cannot be used by servers. + /// + /// + /// -or- + /// + /// + /// is + /// and + /// there is . + /// + /// + /// -or- + /// + /// + /// could not be UTF-8-encoded. + /// + /// + /// + /// The size of is greater than 123 bytes. + /// public void CloseAsync (CloseStatusCode code, string reason) { if (_client && code == CloseStatusCode.ServerError) { From 2a89c657626870e4b5264b087997319cf6bdaab1 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 31 Jul 2017 16:31:24 +0900 Subject: [PATCH 1389/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 698290c1e..dc69473ee 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3726,15 +3726,15 @@ public void SetProxy (string url, string username, string password) #region Explicit Interface Implementations /// - /// Closes the WebSocket connection, and releases all associated resources. + /// Closes the connection and releases all associated resources. /// /// /// - /// This method does nothing if the current state of the connection is - /// Closing or Closed. + /// This method closes the connection with close status 1001 (going away). /// /// - /// This method closes the connection with status code 1001 (going away). + /// And this method does nothing if the current state of the connection is + /// Closing or Closed. /// /// void IDisposable.Dispose () From aa8f460d81627f9ff6781dda29b4f8b5361ea7d6 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 31 Jul 2017 16:36:11 +0900 Subject: [PATCH 1390/6294] [Modify] Remove it --- websocket-sharp/WebSocket.cs | 34 ---------------------------------- 1 file changed, 34 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index dc69473ee..5ad89defc 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2074,40 +2074,6 @@ private bool validateSecWebSocketVersionServerHeader (string value) #region Internal Methods - internal static bool CheckParametersForClose ( - ushort code, string reason, bool client, out string message - ) - { - message = null; - - if (!code.IsCloseStatusCode ()) { - message = "'code' is an invalid status code."; - return false; - } - - if (code == (ushort) CloseStatusCode.NoStatus && !reason.IsNullOrEmpty ()) { - message = "'code' cannot have a reason."; - return false; - } - - if (code == (ushort) CloseStatusCode.MandatoryExtension && !client) { - message = "'code' cannot be used by a server."; - return false; - } - - if (code == (ushort) CloseStatusCode.ServerError && client) { - message = "'code' cannot be used by a client."; - return false; - } - - if (!reason.IsNullOrEmpty () && reason.UTF8Encode ().Length > 123) { - message = "The size of 'reason' is greater than the allowable max size."; - return false; - } - - return true; - } - internal static bool CheckParametersForClose ( CloseStatusCode code, string reason, bool client, out string message ) From dc25551563d336379a6b4b7375ed9d07729cc4db Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 31 Jul 2017 16:39:22 +0900 Subject: [PATCH 1391/6294] [Modify] Remove it --- websocket-sharp/WebSocket.cs | 29 ----------------------------- 1 file changed, 29 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 5ad89defc..0c4329795 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2074,35 +2074,6 @@ private bool validateSecWebSocketVersionServerHeader (string value) #region Internal Methods - internal static bool CheckParametersForClose ( - CloseStatusCode code, string reason, bool client, out string message - ) - { - message = null; - - if (code == CloseStatusCode.NoStatus && !reason.IsNullOrEmpty ()) { - message = "'code' cannot have a reason."; - return false; - } - - if (code == CloseStatusCode.MandatoryExtension && !client) { - message = "'code' cannot be used by a server."; - return false; - } - - if (code == CloseStatusCode.ServerError && client) { - message = "'code' cannot be used by a client."; - return false; - } - - if (!reason.IsNullOrEmpty () && reason.UTF8Encode ().Length > 123) { - message = "The size of 'reason' is greater than the allowable max size."; - return false; - } - - return true; - } - internal static string CheckPingParameter (string message, out byte[] bytes) { bytes = message.UTF8Encode (); From 72685d62defba55aa96e549e0a916c561439d229 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 1 Aug 2017 17:23:46 +0900 Subject: [PATCH 1392/6294] [Modify] Remove it --- websocket-sharp/WebSocket.cs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 0c4329795..f76fd8a1c 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2085,11 +2085,6 @@ internal static string CheckSendParameter (byte[] data) return data == null ? "'data' is null." : null; } - internal static string CheckSendParameter (FileInfo file) - { - return file == null ? "'file' is null." : null; - } - internal static string CheckSendParameter (string data) { return data == null ? "'data' is null." : null; From 009c10cc4f3197383284dfc62b406d6027eeb6ab Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 2 Aug 2017 15:23:08 +0900 Subject: [PATCH 1393/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index f76fd8a1c..df4094389 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3082,12 +3082,14 @@ public bool Ping () /// public bool Ping (string message) { - if (message == null) - throw new ArgumentNullException ("message"); + if (message.IsNullOrEmpty ()) + return ping (EmptyBytes); byte[] bytes; - if (!message.TryGetUTF8EncodedBytes (out bytes)) - throw new ArgumentException ("It could not be UTF-8-encoded.", "message"); + if (!message.TryGetUTF8EncodedBytes (out bytes)) { + var msg = "It could not be UTF-8-encoded."; + throw new ArgumentException (msg, "message"); + } if (bytes.Length > 125) { var msg = "Its size is greater than 125 bytes."; From 3a6b0de5b33408bf81817dcfac0cd57e132ab238 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 2 Aug 2017 15:29:08 +0900 Subject: [PATCH 1394/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index df4094389..179db29f7 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3068,12 +3068,13 @@ public bool Ping () /// a pong has been received within a time; otherwise, false. /// /// - /// A that represents the message to send. - /// The size must be 125 bytes or less in UTF-8. + /// + /// A that represents the message to send. + /// + /// + /// The size must be 125 bytes or less in UTF-8. + /// /// - /// - /// is . - /// /// /// could not be UTF-8-encoded. /// From 862eb79f5112fe3a2dcffaecdbc6efe9fee5eada Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 2 Aug 2017 15:40:35 +0900 Subject: [PATCH 1395/6294] [Modify] Throw exception --- websocket-sharp/Server/WebSocketSessionManager.cs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 872b9b2a3..7e649b315 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -566,10 +566,9 @@ public void BroadcastAsync (Stream stream, int length, Action completed) /// public Dictionary Broadping () { - var msg = _state.CheckIfAvailable (false, true, false); - if (msg != null) { - _logger.Error (msg); - return null; + if (_state != ServerState.Start) { + var msg = "The current state of the manager is not Start."; + throw new InvalidOperationException (msg); } return Broadping (WebSocketFrame.EmptyPingBytes, _waitTime); From 9858b8e5a35c6d50461a8274dfcdc90307783997 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 2 Aug 2017 17:08:12 +0900 Subject: [PATCH 1396/6294] [Modify] Edit it --- .../Server/WebSocketSessionManager.cs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 7e649b315..1d2dc6047 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -557,13 +557,21 @@ public void BroadcastAsync (Stream stream, int length, Action completed) } /// - /// Sends a Ping to every client in the WebSocket service. + /// Sends a ping to every client in the WebSocket service. /// /// - /// A Dictionary<string, bool> that contains a collection of pairs of - /// a session ID and a value indicating whether the manager received a Pong from - /// each client in a time. + /// + /// A Dictionary<string, bool>. + /// + /// + /// It represents a collection of pairs of a session ID and + /// a value indicating whether a pong has been received from + /// its client within a time. + /// /// + /// + /// The current state of the manager is not Start. + /// public Dictionary Broadping () { if (_state != ServerState.Start) { From 9fa2b58990823ad7272c9fd912224d2523d45f93 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 2 Aug 2017 17:20:06 +0900 Subject: [PATCH 1397/6294] [Modify] Throw exceptions --- .../Server/WebSocketSessionManager.cs | 26 ++++++++++++------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 1d2dc6047..f27a5534e 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -596,19 +596,27 @@ public Dictionary Broadping () /// public Dictionary Broadping (string message) { - if (message == null || message.Length == 0) - return Broadping (); + if (_state != ServerState.Start) { + var msg = "The current state of the manager is not Start."; + throw new InvalidOperationException (msg); + } - byte[] data = null; - var msg = _state.CheckIfAvailable (false, true, false) ?? - WebSocket.CheckPingParameter (message, out data); + if (message.IsNullOrEmpty ()) + return Broadping (WebSocketFrame.EmptyPingBytes, _waitTime); - if (msg != null) { - _logger.Error (msg); - return null; + byte[] bytes; + if (!message.TryGetUTF8EncodedBytes (out bytes)) { + var msg = "It could not be UTF-8-encoded."; + throw new ArgumentException (msg, "message"); + } + + if (bytes.Length > 125) { + var msg = "Its size is greater than 125 bytes."; + throw new ArgumentOutOfRangeException ("message", msg); } - return Broadping (WebSocketFrame.CreatePingFrame (data, false).ToArray (), _waitTime); + var frame = WebSocketFrame.CreatePingFrame (bytes, false); + return Broadping (frame.ToArray (), _waitTime); } /// From de260fcddf1a0c9204c8d781cd481ffce86096d8 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 3 Aug 2017 15:57:55 +0900 Subject: [PATCH 1398/6294] [Modify] Edit it --- .../Server/WebSocketSessionManager.cs | 31 +++++++++++++++---- 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index f27a5534e..fb4b670d9 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -583,17 +583,36 @@ public Dictionary Broadping () } /// - /// Sends a Ping with the specified to every client in - /// the WebSocket service. + /// Sends a ping with the specified to + /// every client in the WebSocket service. /// /// - /// A Dictionary<string, bool> that contains a collection of pairs of - /// a session ID and a value indicating whether the manager received a Pong from - /// each client in a time. + /// + /// A Dictionary<string, bool>. + /// + /// + /// It represents a collection of pairs of a session ID and + /// a value indicating whether a pong has been received from + /// its client within a time. + /// /// /// - /// A that represents the message to send. + /// + /// A that represents the message to send. + /// + /// + /// The size must be 125 bytes or less in UTF-8. + /// /// + /// + /// The current state of the manager is not Start. + /// + /// + /// could not be UTF-8-encoded. + /// + /// + /// The size of is greater than 125 bytes. + /// public Dictionary Broadping (string message) { if (_state != ServerState.Start) { From 33da8ba41cf9bb8168f03943a7cbcf18ab801697 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 3 Aug 2017 16:09:23 +0900 Subject: [PATCH 1399/6294] [Modify] It will be removed --- websocket-sharp/Server/WebSocketSessionManager.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index fb4b670d9..9863af5eb 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -572,6 +572,7 @@ public void BroadcastAsync (Stream stream, int length, Action completed) /// /// The current state of the manager is not Start. /// + [Obsolete ("This method will be removed.")] public Dictionary Broadping () { if (_state != ServerState.Start) { From fec10593d83923e2285c96f3c1123b2312114dbd Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 3 Aug 2017 16:12:20 +0900 Subject: [PATCH 1400/6294] [Modify] It will be removed --- websocket-sharp/Server/WebSocketSessionManager.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 9863af5eb..abde8189f 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -614,6 +614,7 @@ public Dictionary Broadping () /// /// The size of is greater than 125 bytes. /// + [Obsolete ("This method will be removed.")] public Dictionary Broadping (string message) { if (_state != ServerState.Start) { From 3eb117344d7cbdfa5a1c0608d11d0e21f0add83b Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 3 Aug 2017 16:15:49 +0900 Subject: [PATCH 1401/6294] [Modify] Remove it --- websocket-sharp/WebSocket.cs | 6 ------ 1 file changed, 6 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 179db29f7..3d0477c32 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2074,12 +2074,6 @@ private bool validateSecWebSocketVersionServerHeader (string value) #region Internal Methods - internal static string CheckPingParameter (string message, out byte[] bytes) - { - bytes = message.UTF8Encode (); - return bytes.Length > 125 ? "A message has greater than the allowable max size." : null; - } - internal static string CheckSendParameter (byte[] data) { return data == null ? "'data' is null." : null; From e3f19c6157df00e22f6cfe55c4b6fe7204235851 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 4 Aug 2017 15:18:13 +0900 Subject: [PATCH 1402/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServiceManager.cs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index c52998737..5bb8c4e62 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -765,10 +765,9 @@ public void BroadcastAsync (Stream stream, int length, Action completed) /// A Dictionary<string, Dictionary<string, bool>>. /// /// - /// It represents a collection of pairs of a service path and - /// another collection of pairs of a session ID and a value - /// indicating whether a pong has been received within a time - /// from its client. + /// It represents a collection of pairs of a service path and another + /// collection of pairs of a session ID and a value indicating whether + /// a pong has been received from its client within a time. /// /// /// From 098a10ca4eab465d283b41dc71de4318c1443386 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 4 Aug 2017 15:21:48 +0900 Subject: [PATCH 1403/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketServiceManager.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index 5bb8c4e62..ed82a0ce5 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -823,8 +823,8 @@ public Dictionary> Broadping (string message) throw new InvalidOperationException (msg); } - if (message == null) - throw new ArgumentNullException ("message"); + if (message.IsNullOrEmpty ()) + return broadping (WebSocketFrame.EmptyPingBytes, _waitTime); byte[] bytes; if (!message.TryGetUTF8EncodedBytes (out bytes)) { From 8e77c1592be1d53320c29401676e6bd5883b1b9d Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 4 Aug 2017 15:28:33 +0900 Subject: [PATCH 1404/6294] [Modify] Edit it --- .../Server/WebSocketServiceManager.cs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index ed82a0ce5..57a7db9cb 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -793,22 +793,22 @@ public Dictionary> Broadping () /// A Dictionary<string, Dictionary<string, bool>>. /// /// - /// It represents a collection of pairs of a service path and - /// another collection of pairs of a session ID and a value - /// indicating whether a pong has been received within a time - /// from its client. + /// It represents a collection of pairs of a service path and another + /// collection of pairs of a session ID and a value indicating whether + /// a pong has been received from its client within a time. /// /// /// - /// A that represents a message to send. - /// The size must be 125 bytes or less in UTF-8. + /// + /// A that represents the message to send. + /// + /// + /// The size must be 125 bytes or less in UTF-8. + /// /// /// /// The current state of the manager is not Start. /// - /// - /// is . - /// /// /// could not be UTF-8-encoded. /// From 3c57047e67b3ce4ed0c1c0803360cfaff399a32c Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 4 Aug 2017 15:37:10 +0900 Subject: [PATCH 1405/6294] [Modify] Throw exceptions --- websocket-sharp/Server/WebSocketSessionManager.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index abde8189f..43d553b14 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -407,14 +407,14 @@ internal void Stop (ushort code, string reason) /// public void Broadcast (byte[] data) { - var msg = _state.CheckIfAvailable (false, true, false) ?? - WebSocket.CheckSendParameter (data); - - if (msg != null) { - _logger.Error (msg); - return; + if (_state != ServerState.Start) { + var msg = "The current state of the manager is not Start."; + throw new InvalidOperationException (msg); } + if (data == null) + throw new ArgumentNullException ("data"); + if (data.LongLength <= WebSocket.FragmentLength) broadcast (Opcode.Binary, data, null); else From 9ad9d97466ae6c82fee5431ed544f4100f64de1c Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 4 Aug 2017 15:41:42 +0900 Subject: [PATCH 1406/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketSessionManager.cs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 43d553b14..4dd6d3605 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -400,11 +400,19 @@ internal void Stop (ushort code, string reason) #region Public Methods /// - /// Sends binary to every client in the WebSocket service. + /// Sends the specified to + /// every client in the WebSocket service. /// /// - /// An array of that represents the binary data to send. + /// An array of that represents + /// the binary data to send. /// + /// + /// The current state of the manager is not Start. + /// + /// + /// is . + /// public void Broadcast (byte[] data) { if (_state != ServerState.Start) { From 60a6a8d0b9bc628b1df5e6fc4e629b141db5182e Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 4 Aug 2017 15:46:59 +0900 Subject: [PATCH 1407/6294] [Modify] Throw exceptions --- websocket-sharp/Server/WebSocketSessionManager.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 4dd6d3605..787274fca 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -468,14 +468,14 @@ public void Broadcast (string data) /// public void BroadcastAsync (byte[] data, Action completed) { - var msg = _state.CheckIfAvailable (false, true, false) ?? - WebSocket.CheckSendParameter (data); - - if (msg != null) { - _logger.Error (msg); - return; + if (_state != ServerState.Start) { + var msg = "The current state of the manager is not Start."; + throw new InvalidOperationException (msg); } + if (data == null) + throw new ArgumentNullException ("data"); + if (data.LongLength <= WebSocket.FragmentLength) broadcastAsync (Opcode.Binary, data, completed); else From 8fcfec9682921e30d03de2550fe0c6d1aa21b14d Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 4 Aug 2017 15:53:55 +0900 Subject: [PATCH 1408/6294] [Modify] Edit it --- .../Server/WebSocketSessionManager.cs | 25 ++++++++++++++----- 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 787274fca..1890bf2d8 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -453,19 +453,32 @@ public void Broadcast (string data) } /// - /// Sends binary asynchronously to every client in - /// the WebSocket service. + /// Sends the specified asynchronously to + /// every client in the WebSocket service. /// /// - /// This method doesn't wait for the send to be complete. + /// This method does not wait for the send to be complete. /// /// - /// An array of that represents the binary data to send. + /// An array of that represents + /// the binary data to send. /// /// - /// An delegate that references the method(s) called when - /// the send is complete. + /// + /// An delegate or + /// if not needed. + /// + /// + /// That delegate invokes the method called when + /// the send is complete. + /// /// + /// + /// The current state of the manager is not Start. + /// + /// + /// is . + /// public void BroadcastAsync (byte[] data, Action completed) { if (_state != ServerState.Start) { From 1ac454bd34224e14de74104555a867e34a6a0ca9 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 4 Aug 2017 15:56:45 +0900 Subject: [PATCH 1409/6294] [Modify] Remove it --- websocket-sharp/WebSocket.cs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 3d0477c32..ed5c24863 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2074,11 +2074,6 @@ private bool validateSecWebSocketVersionServerHeader (string value) #region Internal Methods - internal static string CheckSendParameter (byte[] data) - { - return data == null ? "'data' is null." : null; - } - internal static string CheckSendParameter (string data) { return data == null ? "'data' is null." : null; From 3d98fd90b73509643f25f336957c77bf9a36ecaf Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 5 Aug 2017 16:04:40 +0900 Subject: [PATCH 1410/6294] [Modify] Throw exceptions --- .../Server/WebSocketSessionManager.cs | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 1890bf2d8..db5326b16 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -437,15 +437,20 @@ public void Broadcast (byte[] data) /// public void Broadcast (string data) { - var msg = _state.CheckIfAvailable (false, true, false) ?? - WebSocket.CheckSendParameter (data); + if (_state != ServerState.Start) { + var msg = "The current state of the manager is not Start."; + throw new InvalidOperationException (msg); + } - if (msg != null) { - _logger.Error (msg); - return; + if (data == null) + throw new ArgumentNullException ("data"); + + byte[] bytes; + if (!data.TryGetUTF8EncodedBytes (out bytes)) { + var msg = "It could not be UTF-8-encoded."; + throw new ArgumentException (msg, "data"); } - var bytes = data.UTF8Encode (); if (bytes.LongLength <= WebSocket.FragmentLength) broadcast (Opcode.Text, bytes, null); else From 6c82c9ed64f20b198a3c4cbb3e24d77a98e4c091 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 5 Aug 2017 16:15:39 +0900 Subject: [PATCH 1411/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketSessionManager.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index db5326b16..12c0937d9 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -430,11 +430,21 @@ public void Broadcast (byte[] data) } /// - /// Sends text to every client in the WebSocket service. + /// Sends the specified to every client in + /// the WebSocket service. /// /// /// A that represents the text data to send. /// + /// + /// The current state of the manager is not Start. + /// + /// + /// is . + /// + /// + /// could not be UTF-8-encoded. + /// public void Broadcast (string data) { if (_state != ServerState.Start) { From 84e2a1ed42f53ff19b648f631af0a676e33c081a Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 5 Aug 2017 16:20:27 +0900 Subject: [PATCH 1412/6294] [Modify] Throw exceptions --- .../Server/WebSocketSessionManager.cs | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 12c0937d9..b5a59a961 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -526,15 +526,20 @@ public void BroadcastAsync (byte[] data, Action completed) /// public void BroadcastAsync (string data, Action completed) { - var msg = _state.CheckIfAvailable (false, true, false) ?? - WebSocket.CheckSendParameter (data); + if (_state != ServerState.Start) { + var msg = "The current state of the manager is not Start."; + throw new InvalidOperationException (msg); + } - if (msg != null) { - _logger.Error (msg); - return; + if (data == null) + throw new ArgumentNullException ("data"); + + byte[] bytes; + if (!data.TryGetUTF8EncodedBytes (out bytes)) { + var msg = "It could not be UTF-8-encoded."; + throw new ArgumentException (msg, "data"); } - var bytes = data.UTF8Encode (); if (bytes.LongLength <= WebSocket.FragmentLength) broadcastAsync (Opcode.Text, bytes, completed); else From 581a03e08ddf755239777ae18096bba628152ed8 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 5 Aug 2017 16:30:07 +0900 Subject: [PATCH 1413/6294] [Modify] Edit it --- .../Server/WebSocketSessionManager.cs | 24 +++++++++++++++---- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index b5a59a961..3b70eeacd 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -511,19 +511,33 @@ public void BroadcastAsync (byte[] data, Action completed) } /// - /// Sends text asynchronously to every client in - /// the WebSocket service. + /// Sends the specified asynchronously to + /// every client in the WebSocket service. /// /// - /// This method doesn't wait for the send to be complete. + /// This method does not wait for the send to be complete. /// /// /// A that represents the text data to send. /// /// - /// An delegate that references the method(s) called when - /// the send is complete. + /// + /// An delegate or + /// if not needed. + /// + /// + /// That delegate invokes the method called when the send is complete. + /// /// + /// + /// The current state of the manager is not Start. + /// + /// + /// is . + /// + /// + /// could not be UTF-8-encoded. + /// public void BroadcastAsync (string data, Action completed) { if (_state != ServerState.Start) { From d58cfbbb14bdcdd092ab808471175914478cccd5 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 5 Aug 2017 16:32:10 +0900 Subject: [PATCH 1414/6294] [Modify] Remove it --- websocket-sharp/WebSocket.cs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index ed5c24863..60045250e 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2074,11 +2074,6 @@ private bool validateSecWebSocketVersionServerHeader (string value) #region Internal Methods - internal static string CheckSendParameter (string data) - { - return data == null ? "'data' is null." : null; - } - internal static string CheckSendParameters (Stream stream, int length) { return stream == null From 954f3dbbd0c0a282406ea362984282c582287ce2 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 5 Aug 2017 17:25:54 +0900 Subject: [PATCH 1415/6294] [Modify] Throw exceptions --- .../Server/WebSocketSessionManager.cs | 57 ++++++++++--------- 1 file changed, 31 insertions(+), 26 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 3b70eeacd..cb20a5722 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -579,36 +579,41 @@ public void BroadcastAsync (string data, Action completed) /// public void BroadcastAsync (Stream stream, int length, Action completed) { - var msg = _state.CheckIfAvailable (false, true, false) ?? - WebSocket.CheckSendParameters (stream, length); + if (_state != ServerState.Start) { + var msg = "The current state of the manager is not Start."; + throw new InvalidOperationException (msg); + } - if (msg != null) { - _logger.Error (msg); - return; + if (stream == null) + throw new ArgumentNullException ("stream"); + + if (!stream.CanRead) + throw new ArgumentException ("It cannot be read.", "stream"); + + if (length < 1) + throw new ArgumentException ("Less than 1.", "length"); + + var bytes = stream.ReadBytes (length); + + var len = bytes.Length; + if (len == 0) { + var msg = "No data could be read from it."; + throw new ArgumentException (msg, "stream"); } - stream.ReadBytesAsync ( - length, - data => { - var len = data.Length; - if (len == 0) { - _logger.Error ("The data cannot be read from 'stream'."); - return; - } + if (len < length) { + _logger.Warn ( + String.Format ( + "Only {0} byte(s) of data could be read from the specified stream.", + len + ) + ); + } - if (len < length) - _logger.Warn ( - String.Format ( - "The data with 'length' cannot be read from 'stream':\n expected: {0}\n actual: {1}", - length, - len)); - - if (len <= WebSocket.FragmentLength) - broadcast (Opcode.Binary, data, completed); - else - broadcast (Opcode.Binary, new MemoryStream (data), completed); - }, - ex => _logger.Fatal (ex.ToString ())); + if (len <= WebSocket.FragmentLength) + broadcastAsync (Opcode.Binary, bytes, completed); + else + broadcastAsync (Opcode.Binary, new MemoryStream (bytes), completed); } /// From 0c997f395686a53a327e617a281c781626fab7f8 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 6 Aug 2017 15:59:45 +0900 Subject: [PATCH 1416/6294] [Modify] Edit it --- .../Server/WebSocketSessionManager.cs | 41 ++++++++++++++++--- 1 file changed, 35 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index cb20a5722..7c1acc927 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -561,22 +561,51 @@ public void BroadcastAsync (string data, Action completed) } /// - /// Sends binary data from the specified asynchronously to + /// Sends the specified of data from + /// the specified asynchronously to /// every client in the WebSocket service. /// /// - /// This method doesn't wait for the send to be complete. + /// This method does not wait for the send to be complete. /// /// - /// A from which contains the binary data to send. + /// A from which to read the binary data to send. /// /// - /// An that represents the number of bytes to send. + /// An that specifies the number of bytes to send. /// /// - /// An delegate that references the method(s) called when - /// the send is complete. + /// + /// An delegate or + /// if not needed. + /// + /// + /// That delegate invokes the method called when the send is complete. + /// /// + /// + /// The current state of the manager is not Start. + /// + /// + /// is . + /// + /// + /// + /// cannot be read. + /// + /// + /// -or- + /// + /// + /// is less than 1. + /// + /// + /// -or- + /// + /// + /// No data could be read from . + /// + /// public void BroadcastAsync (Stream stream, int length, Action completed) { if (_state != ServerState.Start) { From 039dc6a0daf199714c0accf1039a3be03853e368 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 6 Aug 2017 16:02:02 +0900 Subject: [PATCH 1417/6294] [Modify] Remove it --- websocket-sharp/WebSocket.cs | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 60045250e..7ca78b2d8 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2074,17 +2074,6 @@ private bool validateSecWebSocketVersionServerHeader (string value) #region Internal Methods - internal static string CheckSendParameters (Stream stream, int length) - { - return stream == null - ? "'stream' is null." - : !stream.CanRead - ? "'stream' cannot be read." - : length < 1 - ? "'length' is less than 1." - : null; - } - // As server internal void Close (HttpResponse response) { From 174d3ff00eb2187401547b02ea4d1073128e2e1b Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 7 Aug 2017 15:42:25 +0900 Subject: [PATCH 1418/6294] [Modify] Add it --- .../Server/WebSocketSessionManager.cs | 73 +++++++++++++++++++ 1 file changed, 73 insertions(+) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 7c1acc927..8252ec853 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -467,6 +467,79 @@ public void Broadcast (string data) broadcast (Opcode.Text, new MemoryStream (bytes), null); } + /// + /// Sends the specified of data from + /// the specified to every client in + /// the WebSocket service. + /// + /// + /// A from which to read the binary data to send. + /// + /// + /// An that specifies the number of bytes to send. + /// + /// + /// The current state of the manager is not Start. + /// + /// + /// is . + /// + /// + /// + /// cannot be read. + /// + /// + /// -or- + /// + /// + /// is less than 1. + /// + /// + /// -or- + /// + /// + /// No data could be read from . + /// + /// + public void Broadcast (Stream stream, int length) + { + if (_state != ServerState.Start) { + var msg = "The current state of the manager is not Start."; + throw new InvalidOperationException (msg); + } + + if (stream == null) + throw new ArgumentNullException ("stream"); + + if (!stream.CanRead) + throw new ArgumentException ("It cannot be read.", "stream"); + + if (length < 1) + throw new ArgumentException ("Less than 1.", "length"); + + var bytes = stream.ReadBytes (length); + + var len = bytes.Length; + if (len == 0) { + var msg = "No data could be read from it."; + throw new ArgumentException (msg, "stream"); + } + + if (len < length) { + _logger.Warn ( + String.Format ( + "Only {0} byte(s) of data could be read from the specified stream.", + len + ) + ); + } + + if (len <= WebSocket.FragmentLength) + broadcast (Opcode.Binary, bytes, null); + else + broadcast (Opcode.Binary, new MemoryStream (bytes), null); + } + /// /// Sends the specified asynchronously to /// every client in the WebSocket service. From 51663793c1fbabd71840f9a086c7f354c6d573c8 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 7 Aug 2017 15:56:22 +0900 Subject: [PATCH 1419/6294] [Modify] Throw exceptions --- websocket-sharp/Server/WebSocketSessionManager.cs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 8252ec853..1da634588 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -1052,14 +1052,17 @@ public void Sweep () /// public bool TryGetSession (string id, out IWebSocketSession session) { - var msg = _state.CheckIfAvailable (false, true, false) ?? id.CheckIfValidSessionID (); - if (msg != null) { - _logger.Error (msg); - session = null; - - return false; + if (_state != ServerState.Start) { + var msg = "The current state of the manager is not Start."; + throw new InvalidOperationException (msg); } + if (id == null) + throw new ArgumentNullException ("id"); + + if (id.Length == 0) + throw new ArgumentException ("An empty string.", "id"); + return tryGetSession (id, out session); } From 9dbeb5a7e251272e0838d1e9dd4c56d766506215 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 8 Aug 2017 17:09:02 +0900 Subject: [PATCH 1420/6294] [Modify] Edit it --- .../Server/WebSocketSessionManager.cs | 29 +++++++++++++++---- 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 1da634588..e986722f6 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -1037,19 +1037,36 @@ public void Sweep () } /// - /// Tries to get the session with the specified . + /// Tries to get the session instance with the specified + /// . /// /// - /// true if the session is successfully found; otherwise, false. + /// true if the session is successfully found; + /// otherwise, false. /// /// - /// A that represents the ID of the session to find. + /// A that represents the ID of + /// the session to find. /// /// - /// When this method returns, a instance that - /// provides the access to the information in the session, or - /// if it's not found. This parameter is passed uninitialized. + /// + /// When this method returns, a + /// instance or if not found. + /// + /// + /// That session instance provides the function to access + /// the information in the session. + /// /// + /// + /// The current state of the manager is not Start. + /// + /// + /// is . + /// + /// + /// is an empty string. + /// public bool TryGetSession (string id, out IWebSocketSession session) { if (_state != ServerState.Start) { From 7018bab939093b11429251121544881d8add2aa1 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 8 Aug 2017 17:12:01 +0900 Subject: [PATCH 1421/6294] [Modify] Remove it --- websocket-sharp/Ext.cs | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 076b702e6..5694f34aa 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -163,16 +163,6 @@ internal static byte[] Append (this ushort code, string reason) return ret; } - internal static string CheckIfAvailable ( - this ServerState state, bool ready, bool start, bool shutting) - { - return (!ready && (state == ServerState.Ready || state == ServerState.Stop)) || - (!start && state == ServerState.Start) || - (!shutting && state == ServerState.ShuttingDown) - ? "This operation isn't available in: " + state.ToString ().ToLower () - : null; - } - internal static string CheckIfAvailable ( this WebSocketState state, bool connecting, bool open, bool closing, bool closed) { From 45f0e8b6fc99a3e959100890b0a8f5854df4ccac Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 8 Aug 2017 17:13:51 +0900 Subject: [PATCH 1422/6294] [Modify] Remove it --- websocket-sharp/Ext.cs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 5694f34aa..93c2c3261 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -184,11 +184,6 @@ internal static string CheckIfValidProtocols (this string[] protocols) : null; } - internal static string CheckIfValidSessionID (this string id) - { - return id == null || id.Length == 0 ? "'id' is null or empty." : null; - } - internal static bool CheckWaitTime (this TimeSpan time, out string message) { message = null; From b4bcf2705bf875e9fb6ad27f70e988d1df6029f1 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 8 Aug 2017 17:17:34 +0900 Subject: [PATCH 1423/6294] [Modify] Remove it --- websocket-sharp/Ext.cs | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 93c2c3261..ff85a42cf 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -163,17 +163,6 @@ internal static byte[] Append (this ushort code, string reason) return ret; } - internal static string CheckIfAvailable ( - this WebSocketState state, bool connecting, bool open, bool closing, bool closed) - { - return (!connecting && state == WebSocketState.Connecting) || - (!open && state == WebSocketState.Open) || - (!closing && state == WebSocketState.Closing) || - (!closed && state == WebSocketState.Closed) - ? "This operation isn't available in: " + state.ToString ().ToLower () - : null; - } - internal static string CheckIfValidProtocols (this string[] protocols) { return protocols.Contains ( From 8a095213f6d47523d6ef43858211bc211f080c45 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 9 Aug 2017 17:11:08 +0900 Subject: [PATCH 1424/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketSessionManager.cs | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index e986722f6..e7268c440 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -309,14 +309,8 @@ private void stop (PayloadData payloadData, bool send) private bool tryGetSession (string id, out IWebSocketSession session) { - bool ret; lock (_sync) - ret = _sessions.TryGetValue (id, out session); - - if (!ret) - _logger.Error ("A session with the specified ID isn't found:\n ID: " + id); - - return ret; + return _sessions.TryGetValue (id, out session); } #endregion From 49d17cfa7b9e5cc65e7a147ee53b19c4e58633ba Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 9 Aug 2017 17:55:17 +0900 Subject: [PATCH 1425/6294] [Modify] Throw exceptions --- websocket-sharp/Server/WebSocketSessionManager.cs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index e7268c440..c5be3ec1c 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -162,8 +162,19 @@ public IEnumerable InactiveIDs { /// public IWebSocketSession this[string id] { get { + if (_state != ServerState.Start) { + var msg = "The current state of the manager is not Start."; + throw new InvalidOperationException (msg); + } + + if (id == null) + throw new ArgumentNullException ("id"); + + if (id.Length == 0) + throw new ArgumentException ("An empty string.", "id"); + IWebSocketSession session; - TryGetSession (id, out session); + tryGetSession (id, out session); return session; } From 0425a42cab1c3cfcf263080977f1677e47e835fa Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 10 Aug 2017 16:03:25 +0900 Subject: [PATCH 1426/6294] [Modify] Edit it --- .../Server/WebSocketSessionManager.cs | 24 +++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index c5be3ec1c..ab3b2739e 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -151,15 +151,31 @@ public IEnumerable InactiveIDs { } /// - /// Gets the session with the specified . + /// Gets the session instance with the specified . /// /// - /// A instance that provides the access to - /// the information in the session, or if it's not found. + /// + /// A instance or + /// if not found. + /// + /// + /// That session instance provides the function to + /// access the information in the session. + /// /// /// - /// A that represents the ID of the session to find. + /// A that represents the ID of + /// the session to find. /// + /// + /// The current state of the manager is not Start. + /// + /// + /// is . + /// + /// + /// is an empty string. + /// public IWebSocketSession this[string id] { get { if (_state != ServerState.Start) { From ea03410968edb6f0aaaf0f7a17bf09b226e17179 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 10 Aug 2017 17:21:49 +0900 Subject: [PATCH 1427/6294] [Modify] Return false instead of throwing an exception --- .../Server/WebSocketSessionManager.cs | 27 +++++++------------ 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index ab3b2739e..6c57cd29a 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -167,9 +167,6 @@ public IEnumerable InactiveIDs { /// A that represents the ID of /// the session to find. /// - /// - /// The current state of the manager is not Start. - /// /// /// is . /// @@ -178,11 +175,6 @@ public IEnumerable InactiveIDs { /// public IWebSocketSession this[string id] { get { - if (_state != ServerState.Start) { - var msg = "The current state of the manager is not Start."; - throw new InvalidOperationException (msg); - } - if (id == null) throw new ArgumentNullException ("id"); @@ -336,8 +328,17 @@ private void stop (PayloadData payloadData, bool send) private bool tryGetSession (string id, out IWebSocketSession session) { - lock (_sync) + session = null; + + if (_state != ServerState.Start) + return false; + + lock (_sync) { + if (_state != ServerState.Start) + return false; + return _sessions.TryGetValue (id, out session); + } } #endregion @@ -1079,9 +1080,6 @@ public void Sweep () /// the information in the session. /// /// - /// - /// The current state of the manager is not Start. - /// /// /// is . /// @@ -1090,11 +1088,6 @@ public void Sweep () /// public bool TryGetSession (string id, out IWebSocketSession session) { - if (_state != ServerState.Start) { - var msg = "The current state of the manager is not Start."; - throw new InvalidOperationException (msg); - } - if (id == null) throw new ArgumentNullException ("id"); From 7dcd3cd2e32b9e14a5b0035243a502f3df753627 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 10 Aug 2017 17:34:11 +0900 Subject: [PATCH 1428/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketSessionManager.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 6c57cd29a..46765381f 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -1076,8 +1076,8 @@ public void Sweep () /// instance or if not found. /// /// - /// That session instance provides the function to access - /// the information in the session. + /// That session instance provides the function to + /// access the information in the session. /// /// /// From d774b414747d693dacc2222f4437edf0220ec829 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 11 Aug 2017 15:37:20 +0900 Subject: [PATCH 1429/6294] [Modify] Throw exception --- websocket-sharp/Server/WebSocketSessionManager.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 46765381f..d1e55fe29 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -891,7 +891,12 @@ public void CloseSession (string id, CloseStatusCode code, string reason) public bool PingTo (string id) { IWebSocketSession session; - return TryGetSession (id, out session) && session.Context.WebSocket.Ping (); + if (!TryGetSession (id, out session)) { + var msg = "The session could not be found."; + throw new ArgumentException (msg, "id"); + } + + return session.Context.WebSocket.Ping (); } /// From 73900290cd528b6c9017a7ebb0cab841084efbc7 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 11 Aug 2017 16:38:00 +0900 Subject: [PATCH 1430/6294] [Modify] Edit it --- .../Server/WebSocketSessionManager.cs | 24 +++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index d1e55fe29..2c8e668b0 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -879,15 +879,31 @@ public void CloseSession (string id, CloseStatusCode code, string reason) } /// - /// Sends a Ping to the client on the session with the specified . + /// Sends a ping to the client using the specified session. /// /// - /// true if the manager receives a Pong from the client in a time; - /// otherwise, false. + /// true if the send has done with no error and + /// a pong from the client has been received within + /// a time; otherwise, false. /// /// - /// A that represents the ID of the session to find. + /// A that represents the ID of + /// the session to find. /// + /// + /// is . + /// + /// + /// + /// is an empty string. + /// + /// + /// -or- + /// + /// + /// The session could not be found. + /// + /// public bool PingTo (string id) { IWebSocketSession session; From 82981391c83616b1062262d12d59b449de0d16fb Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 11 Aug 2017 17:13:25 +0900 Subject: [PATCH 1431/6294] [Modify] Throw exception --- websocket-sharp/Server/WebSocketSessionManager.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 2c8e668b0..b541a0298 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -932,7 +932,12 @@ public bool PingTo (string id) public bool PingTo (string message, string id) { IWebSocketSession session; - return TryGetSession (id, out session) && session.Context.WebSocket.Ping (message); + if (!TryGetSession (id, out session)) { + var msg = "The session could not be found."; + throw new ArgumentException (msg, "id"); + } + + return session.Context.WebSocket.Ping (message); } /// From e14739719acc5f86f6e715acbcef7b840f533ac6 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 12 Aug 2017 14:50:27 +0900 Subject: [PATCH 1432/6294] [Modify] Edit it --- .../Server/WebSocketSessionManager.cs | 38 ++++++++++++++++--- 1 file changed, 33 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index b541a0298..b6d6a4576 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -916,19 +916,47 @@ public bool PingTo (string id) } /// - /// Sends a Ping with the specified to the client on - /// the session with the specified . + /// Sends a ping with to the client using + /// the specified session. /// /// - /// true if the manager receives a Pong from the client in a time; - /// otherwise, false. + /// true if the send has done with no error and a pong has been + /// received from the client within a time; otherwise, false. /// /// - /// A that represents the message to send. + /// + /// A that represents the message to send. + /// + /// + /// The size must be 125 bytes or less in UTF-8. + /// /// /// /// A that represents the ID of the session to find. /// + /// + /// is . + /// + /// + /// + /// is an empty string. + /// + /// + /// -or- + /// + /// + /// The session could not be found. + /// + /// + /// -or- + /// + /// + /// could not be UTF-8-encoded. + /// + /// + /// + /// The size of is greater than 125 bytes. + /// public bool PingTo (string message, string id) { IWebSocketSession session; From 66da62f2eccb144a3716e372b5c9bf09bbe00a81 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 12 Aug 2017 14:55:11 +0900 Subject: [PATCH 1433/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 7ca78b2d8..4e00df00b 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3024,8 +3024,8 @@ public void ConnectAsync () /// Sends a ping using the WebSocket connection. /// /// - /// true if the sending a ping has done with no error and - /// a pong has been received within a time; otherwise, false. + /// true if the send has done with no error and a pong has been + /// received within a time; otherwise, false. /// public bool Ping () { From 2d5ac080c59996c0e372d813247a2cff4deb30e4 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 12 Aug 2017 15:02:25 +0900 Subject: [PATCH 1434/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 4e00df00b..bde3c4a4a 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3033,12 +3033,12 @@ public bool Ping () } /// - /// Sends a ping with the specified using - /// the WebSocket connection. + /// Sends a ping with using the WebSocket + /// connection. /// /// - /// true if the sending a ping has done with no error and - /// a pong has been received within a time; otherwise, false. + /// true if the send has done with no error and a pong has been + /// received within a time; otherwise, false. /// /// /// From b872d6d0bcba6c78734f1e74e0e38f46dd62aac9 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 12 Aug 2017 15:06:56 +0900 Subject: [PATCH 1435/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketSessionManager.cs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index b6d6a4576..8ca0b4444 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -882,13 +882,11 @@ public void CloseSession (string id, CloseStatusCode code, string reason) /// Sends a ping to the client using the specified session. /// /// - /// true if the send has done with no error and - /// a pong from the client has been received within - /// a time; otherwise, false. + /// true if the send has done with no error and a pong has been + /// received from the client within a time; otherwise, false. /// /// - /// A that represents the ID of - /// the session to find. + /// A that represents the ID of the session to find. /// /// /// is . From b313ce95bcfe454b63d390520d082a6decfcf2c8 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 12 Aug 2017 15:50:49 +0900 Subject: [PATCH 1436/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketSessionManager.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 8ca0b4444..3ed0a01a7 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -768,8 +768,8 @@ public Dictionary Broadping () } /// - /// Sends a ping with the specified to - /// every client in the WebSocket service. + /// Sends a ping with to every client in + /// the WebSocket service. /// /// /// From dd17dacf53d1f1c7811150a0ee15c2943b55e773 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 12 Aug 2017 15:56:59 +0900 Subject: [PATCH 1437/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServiceManager.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index 57a7db9cb..0149c63d8 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -785,8 +785,8 @@ public Dictionary> Broadping () } /// - /// Sends a ping with the specified to - /// every client in the WebSocket services. + /// Sends a ping with to every client in + /// the WebSocket services. /// /// /// From 5e0ea01ec0097abe4ceae26d12ccd3d075eee574 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 12 Aug 2017 16:02:09 +0900 Subject: [PATCH 1438/6294] [Modify] Throw exception --- websocket-sharp/Server/WebSocketSessionManager.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 3ed0a01a7..75744d5a4 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -979,8 +979,12 @@ public bool PingTo (string message, string id) public void SendTo (byte[] data, string id) { IWebSocketSession session; - if (TryGetSession (id, out session)) - session.Context.WebSocket.Send (data); + if (!TryGetSession (id, out session)) { + var msg = "The session could not be found."; + throw new ArgumentException (msg, "id"); + } + + session.Context.WebSocket.Send (data); } /// From feca7476849c730d2ee14d4dbe3bc7e23b7d42bd Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 13 Aug 2017 15:08:15 +0900 Subject: [PATCH 1439/6294] [Modify] Edit it --- .../Server/WebSocketSessionManager.cs | 30 +++++++++++++++++-- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 75744d5a4..a7328a3bd 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -967,15 +967,39 @@ public bool PingTo (string message, string id) } /// - /// Sends binary to the client on the session with - /// the specified . + /// Sends to the client using the specified session. /// /// /// An array of that represents the binary data to send. /// /// - /// A that represents the ID of the session to find. + /// A that represents the ID of the session. /// + /// + /// + /// is . + /// + /// + /// -or- + /// + /// + /// is . + /// + /// + /// + /// + /// is an empty string. + /// + /// + /// -or- + /// + /// + /// The session could not be found. + /// + /// + /// + /// The current state of the WebSocket connection is not Open. + /// public void SendTo (byte[] data, string id) { IWebSocketSession session; From 0af4c88f6a3365227daa5619f02789e594e2b236 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 13 Aug 2017 15:11:29 +0900 Subject: [PATCH 1440/6294] [Modify] Throw exception --- websocket-sharp/Server/WebSocketSessionManager.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index a7328a3bd..84ca69892 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -1024,8 +1024,12 @@ public void SendTo (byte[] data, string id) public void SendTo (string data, string id) { IWebSocketSession session; - if (TryGetSession (id, out session)) - session.Context.WebSocket.Send (data); + if (!TryGetSession (id, out session)) { + var msg = "The session could not be found."; + throw new ArgumentException (msg, "id"); + } + + session.Context.WebSocket.Send (data); } /// From 9aa88c44f831d305ef970652da1805b797d159ac Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 13 Aug 2017 15:33:51 +0900 Subject: [PATCH 1441/6294] [Modify] Edit it --- .../Server/WebSocketSessionManager.cs | 36 +++++++++++++++++-- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 84ca69892..0f05ab470 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -1012,15 +1012,45 @@ public void SendTo (byte[] data, string id) } /// - /// Sends text to the client on the session with - /// the specified . + /// Sends to the client using the specified session. /// /// /// A that represents the text data to send. /// /// - /// A that represents the ID of the session to find. + /// A that represents the ID of the session. /// + /// + /// + /// is . + /// + /// + /// -or- + /// + /// + /// is . + /// + /// + /// + /// + /// is an empty string. + /// + /// + /// -or- + /// + /// + /// The session could not be found. + /// + /// + /// -or- + /// + /// + /// could not be UTF-8-encoded. + /// + /// + /// + /// The current state of the WebSocket connection is not Open. + /// public void SendTo (string data, string id) { IWebSocketSession session; From 60540f9dc6cc3289433dfe16d7d88e0297c5c669 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 13 Aug 2017 15:36:20 +0900 Subject: [PATCH 1442/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index bde3c4a4a..42a89b848 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3074,7 +3074,7 @@ public bool Ping (string message) } /// - /// Sends the specified using the WebSocket connection. + /// Sends using the WebSocket connection. /// /// /// An array of that represents the binary data to send. From dc5ae5990e73117bdc11ee3e8e90f3985098f9c2 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 13 Aug 2017 15:40:15 +0900 Subject: [PATCH 1443/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 42a89b848..8e2fab937 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3167,8 +3167,10 @@ public void Send (string data) throw new ArgumentNullException ("data"); byte[] bytes; - if (!data.TryGetUTF8EncodedBytes (out bytes)) - throw new ArgumentException ("It could not be UTF-8-encoded.", "data"); + if (!data.TryGetUTF8EncodedBytes (out bytes)) { + var msg = "It could not be UTF-8-encoded."; + throw new ArgumentException (msg, "data"); + } send (Opcode.Text, new MemoryStream (bytes)); } From 59f93c7134b1975360b7c09597619c2b4a032573 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 13 Aug 2017 15:43:48 +0900 Subject: [PATCH 1444/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 8e2fab937..83cfbf482 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3142,7 +3142,7 @@ public void Send (FileInfo fileInfo) } /// - /// Sends the specified using the WebSocket connection. + /// Sends using the WebSocket connection. /// /// /// A that represents the text data to send. From 92dc2cc54b5d78b88c4b911e1cbf9076a0df620c Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 13 Aug 2017 15:49:56 +0900 Subject: [PATCH 1445/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 83cfbf482..e522b1cec 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3131,12 +3131,16 @@ public void Send (FileInfo fileInfo) if (fileInfo == null) throw new ArgumentNullException ("fileInfo"); - if (!fileInfo.Exists) - throw new ArgumentException ("The file does not exist.", "fileInfo"); + if (!fileInfo.Exists) { + var msg = "The file does not exist."; + throw new ArgumentException (msg, "fileInfo"); + } FileStream stream; - if (!fileInfo.TryOpenRead (out stream)) - throw new ArgumentException ("The file could not be opened.", "fileInfo"); + if (!fileInfo.TryOpenRead (out stream)) { + var msg = "The file could not be opened."; + throw new ArgumentException (msg, "fileInfo"); + } send (Opcode.Binary, stream); } From 79dd2a7397c3765e781fcfe34a009fddd47f5bba Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 14 Aug 2017 15:03:03 +0900 Subject: [PATCH 1446/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index e522b1cec..7e262241b 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3099,10 +3099,13 @@ public void Send (byte[] data) } /// - /// Sends the specified file as the binary data using the WebSocket connection. + /// Sends the specified file using the WebSocket connection. /// + /// + /// The file is sent as the binary data. + /// /// - /// A that specifies a file to send. + /// A that specifies the file to send. /// /// /// The current state of the connection is not Open. From 4cc65c4ec5cb263926620644ca3a08485b245698 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 14 Aug 2017 15:18:20 +0900 Subject: [PATCH 1447/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 7e262241b..6a5c5ceb7 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3226,22 +3226,28 @@ public void Send (Stream stream, int length) if (stream == null) throw new ArgumentNullException ("stream"); - if (!stream.CanRead) - throw new ArgumentException ("It cannot be read.", "stream"); + if (!stream.CanRead) { + var msg = "It cannot be read."; + throw new ArgumentException (msg, "stream"); + } - if (length < 1) - throw new ArgumentException ("It is less than 1.", "length"); + if (length < 1) { + var msg = "Less than 1."; + throw new ArgumentException (msg, "length"); + } var bytes = stream.ReadBytes (length); var len = bytes.Length; - if (len == 0) - throw new ArgumentException ("No data could be read from it.", "stream"); + if (len == 0) { + var msg = "No data could be read from it."; + throw new ArgumentException (msg, "stream"); + } if (len < length) { _logger.Warn ( String.Format ( - "Only {0} byte(s) of data could be read from the specified stream.", + "Only {0} byte(s) of data could be read from the stream.", len ) ); From 1f8d3e67356b206b4c991607ca8990644a44fcf1 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 14 Aug 2017 15:52:48 +0900 Subject: [PATCH 1448/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 6a5c5ceb7..91845b3be 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3183,15 +3183,17 @@ public void Send (string data) } /// - /// Sends the specified of data from - /// the specified using the WebSocket + /// Sends the data from using the WebSocket /// connection. /// + /// + /// The data is sent as the binary data. + /// /// - /// A from which reads the binary data to send. + /// A instance from which to read the data to send. /// /// - /// An that specifies the number of bytes to read and send. + /// An that specifies the number of bytes to send. /// /// /// The current state of the connection is not Open. From f3427a3c0590808c648947105f8421c1eb33cca9 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 14 Aug 2017 15:58:32 +0900 Subject: [PATCH 1449/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketSessionManager.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 0f05ab470..032330099 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -422,12 +422,10 @@ internal void Stop (ushort code, string reason) #region Public Methods /// - /// Sends the specified to - /// every client in the WebSocket service. + /// Sends to every client in the WebSocket service. /// /// - /// An array of that represents - /// the binary data to send. + /// An array of that represents the binary data to send. /// /// /// The current state of the manager is not Start. From 8c120440231c456fc02745a9e699564d8244b292 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 14 Aug 2017 16:01:01 +0900 Subject: [PATCH 1450/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketSessionManager.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 032330099..a1145bb62 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -450,8 +450,7 @@ public void Broadcast (byte[] data) } /// - /// Sends the specified to every client in - /// the WebSocket service. + /// Sends to every client in the WebSocket service. /// /// /// A that represents the text data to send. From 168a3352664378e30f172db6de0c85f78ba8eb45 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 14 Aug 2017 16:08:59 +0900 Subject: [PATCH 1451/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketSessionManager.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index a1145bb62..cd8b2ed0c 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -487,12 +487,14 @@ public void Broadcast (string data) } /// - /// Sends the specified of data from - /// the specified to every client in + /// Sends the data from to every client in /// the WebSocket service. /// + /// + /// The data is sent as the binary data. + /// /// - /// A from which to read the binary data to send. + /// A instance from which to read the data to send. /// /// /// An that specifies the number of bytes to send. From fd9d5acbda1635b94aa758914a681dc9f2f0aaa4 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 15 Aug 2017 15:16:09 +0900 Subject: [PATCH 1452/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketSessionManager.cs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index cd8b2ed0c..55d42a723 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -532,11 +532,15 @@ public void Broadcast (Stream stream, int length) if (stream == null) throw new ArgumentNullException ("stream"); - if (!stream.CanRead) - throw new ArgumentException ("It cannot be read.", "stream"); + if (!stream.CanRead) { + var msg = "It cannot be read."; + throw new ArgumentException (msg, "stream"); + } - if (length < 1) - throw new ArgumentException ("Less than 1.", "length"); + if (length < 1) { + var msg = "Less than 1."; + throw new ArgumentException (msg, "length"); + } var bytes = stream.ReadBytes (length); @@ -549,7 +553,7 @@ public void Broadcast (Stream stream, int length) if (len < length) { _logger.Warn ( String.Format ( - "Only {0} byte(s) of data could be read from the specified stream.", + "Only {0} byte(s) of data could be read from the stream.", len ) ); From 4c882a2c0c5e0d8f0256a8fe3b65d38b69a8debd Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 15 Aug 2017 15:24:11 +0900 Subject: [PATCH 1453/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketSessionManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 55d42a723..150610e32 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -889,7 +889,7 @@ public void CloseSession (string id, CloseStatusCode code, string reason) /// received from the client within a time; otherwise, false. /// /// - /// A that represents the ID of the session to find. + /// A that represents the ID of the session. /// /// /// is . From 26c9dbaae0f6d148d49002e6c5735565807e9518 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 15 Aug 2017 15:27:07 +0900 Subject: [PATCH 1454/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketSessionManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 150610e32..d751d4974 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -933,7 +933,7 @@ public bool PingTo (string id) /// /// /// - /// A that represents the ID of the session to find. + /// A that represents the ID of the session. /// /// /// is . From 7afbacd6e04c6c3c40259f0752a130eee69ecaa4 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 15 Aug 2017 15:31:11 +0900 Subject: [PATCH 1455/6294] [Modify] Throw exception --- websocket-sharp/Server/WebSocketSessionManager.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index d751d4974..acde3823a 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -1086,8 +1086,12 @@ public void SendTo (string data, string id) public void SendToAsync (byte[] data, string id, Action completed) { IWebSocketSession session; - if (TryGetSession (id, out session)) - session.Context.WebSocket.SendAsync (data, completed); + if (!TryGetSession (id, out session)) { + var msg = "The session could not be found."; + throw new ArgumentException (msg, "id"); + } + + session.Context.WebSocket.SendAsync (data, completed); } /// From ea19c5d94a207acd98ded0ec1cf72441e0da56f2 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 15 Aug 2017 16:38:45 +0900 Subject: [PATCH 1456/6294] [Modify] Edit it --- .../Server/WebSocketSessionManager.cs | 47 ++++++++++++++++--- 1 file changed, 40 insertions(+), 7 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index acde3823a..ca40c9ab8 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -1066,23 +1066,56 @@ public void SendTo (string data, string id) } /// - /// Sends binary asynchronously to the client on - /// the session with the specified . + /// Sends asynchronously to the client using + /// the specified session. /// /// - /// This method doesn't wait for the send to be complete. + /// This method does not wait for the send to be complete. /// /// /// An array of that represents the binary data to send. /// /// - /// A that represents the ID of the session to find. + /// A that represents the ID of the session. /// /// - /// An Action<bool> delegate that references the method(s) called when - /// the send is complete. A passed to this delegate is true - /// if the send is complete successfully. + /// + /// An Action<bool> delegate or + /// if not needed. + /// + /// + /// That delegate invokes the method called when the send is complete. + /// + /// + /// true is passed to the method if the send has done with + /// no error; otherwise, false. + /// /// + /// + /// + /// is . + /// + /// + /// -or- + /// + /// + /// is . + /// + /// + /// + /// + /// is an empty string. + /// + /// + /// -or- + /// + /// + /// The session could not be found. + /// + /// + /// + /// The current state of the WebSocket connection is not Open. + /// public void SendToAsync (byte[] data, string id, Action completed) { IWebSocketSession session; From e64daf6d81fa580984960709d889cfa1c685d76a Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 15 Aug 2017 16:41:50 +0900 Subject: [PATCH 1457/6294] [Modify] Throw exception --- websocket-sharp/Server/WebSocketSessionManager.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index ca40c9ab8..415774904 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -1148,8 +1148,12 @@ public void SendToAsync (byte[] data, string id, Action completed) public void SendToAsync (string data, string id, Action completed) { IWebSocketSession session; - if (TryGetSession (id, out session)) - session.Context.WebSocket.SendAsync (data, completed); + if (!TryGetSession (id, out session)) { + var msg = "The session could not be found."; + throw new ArgumentException (msg, "id"); + } + + session.Context.WebSocket.SendAsync (data, completed); } /// From 26525b12f3db8f112e0ee09bbcbfdbda530b691d Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 16 Aug 2017 11:41:37 +0900 Subject: [PATCH 1458/6294] [Modify] Edit it --- .../Server/WebSocketSessionManager.cs | 53 ++++++++++++++++--- 1 file changed, 46 insertions(+), 7 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 415774904..6e7cde7d6 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -1128,23 +1128,62 @@ public void SendToAsync (byte[] data, string id, Action completed) } /// - /// Sends text asynchronously to the client on - /// the session with the specified . + /// Sends asynchronously to the client using + /// the specified session. /// /// - /// This method doesn't wait for the send to be complete. + /// This method does not wait for the send to be complete. /// /// /// A that represents the text data to send. /// /// - /// A that represents the ID of the session to find. + /// A that represents the ID of the session. /// /// - /// An Action<bool> delegate that references the method(s) called when - /// the send is complete. A passed to this delegate is true - /// if the send is complete successfully. + /// + /// An Action<bool> delegate or + /// if not needed. + /// + /// + /// The delegate invokes the method called when the send is complete. + /// + /// + /// true is passed to the method if the send has done with + /// no error; otherwise, false. + /// /// + /// + /// + /// is . + /// + /// + /// -or- + /// + /// + /// is . + /// + /// + /// + /// + /// is an empty string. + /// + /// + /// -or- + /// + /// + /// The session could not be found. + /// + /// + /// -or- + /// + /// + /// could not be UTF-8-encoded. + /// + /// + /// + /// The current state of the WebSocket connection is not Open. + /// public void SendToAsync (string data, string id, Action completed) { IWebSocketSession session; From fcc27fd4e27b407cfdf86e8a8b6ce00ba361af57 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 16 Aug 2017 11:46:12 +0900 Subject: [PATCH 1459/6294] [Modify] Throw exception --- websocket-sharp/Server/WebSocketSessionManager.cs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 6e7cde7d6..fac229091 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -1216,11 +1216,17 @@ public void SendToAsync (string data, string id, Action completed) /// the send is complete. A passed to this delegate is true /// if the send is complete successfully. /// - public void SendToAsync (Stream stream, int length, string id, Action completed) + public void SendToAsync ( + Stream stream, int length, string id, Action completed + ) { IWebSocketSession session; - if (TryGetSession (id, out session)) - session.Context.WebSocket.SendAsync (stream, length, completed); + if (!TryGetSession (id, out session)) { + var msg = "The session could not be found."; + throw new ArgumentException (msg, "id"); + } + + session.Context.WebSocket.SendAsync (stream, length, completed); } /// From dfb09e3da0eb265361d08b2419c8ece1a46b8dcf Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 16 Aug 2017 13:13:56 +0900 Subject: [PATCH 1460/6294] [Modify] Edit it --- .../Server/WebSocketSessionManager.cs | 74 ++++++++++++++++--- 1 file changed, 65 insertions(+), 9 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index fac229091..b18c8a27b 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -1196,26 +1196,82 @@ public void SendToAsync (string data, string id, Action completed) } /// - /// Sends binary data from the specified asynchronously to - /// the client on the session with the specified . + /// Sends the data from asynchronously to + /// the client using the specified session. /// /// - /// This method doesn't wait for the send to be complete. + /// + /// The data is sent as the binary data. + /// + /// + /// This method does not wait for the send to be complete. + /// /// /// - /// A from which contains the binary data to send. + /// A instance from which to read the data to send. /// /// - /// An that represents the number of bytes to send. + /// An that specifies the number of bytes to send. /// /// - /// A that represents the ID of the session to find. + /// A that represents the ID of the session. /// /// - /// An Action<bool> delegate that references the method(s) called when - /// the send is complete. A passed to this delegate is true - /// if the send is complete successfully. + /// + /// An Action<bool> delegate or + /// if not needed. + /// + /// + /// The delegate invokes the method called when the send is complete. + /// + /// + /// true is passed to the method if the send has done with + /// no error; otherwise, false. + /// /// + /// + /// + /// is . + /// + /// + /// -or- + /// + /// + /// is . + /// + /// + /// + /// + /// is an empty string. + /// + /// + /// -or- + /// + /// + /// The session could not be found. + /// + /// + /// -or- + /// + /// + /// cannot be read. + /// + /// + /// -or- + /// + /// + /// is less than 1. + /// + /// + /// -or- + /// + /// + /// No data could be read from . + /// + /// + /// + /// The current state of the WebSocket connection is not Open. + /// public void SendToAsync ( Stream stream, int length, string id, Action completed ) From 8ba734a9a9af4b11dd0f3fdac10d4fa33889f146 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 16 Aug 2017 13:25:11 +0900 Subject: [PATCH 1461/6294] [Modify] Add it --- .../Server/WebSocketSessionManager.cs | 70 +++++++++++++++++++ 1 file changed, 70 insertions(+) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index b18c8a27b..0e62599fb 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -1065,6 +1065,76 @@ public void SendTo (string data, string id) session.Context.WebSocket.Send (data); } + /// + /// Sends the data from to the client using + /// the specified session. + /// + /// + /// The data is sent as the binary data. + /// + /// + /// A instance from which to read the data to send. + /// + /// + /// An that specifies the number of bytes to send. + /// + /// + /// A that represents the ID of the session. + /// + /// + /// + /// is . + /// + /// + /// -or- + /// + /// + /// is . + /// + /// + /// + /// + /// is an empty string. + /// + /// + /// -or- + /// + /// + /// The session could not be found. + /// + /// + /// -or- + /// + /// + /// cannot be read. + /// + /// + /// -or- + /// + /// + /// is less than 1. + /// + /// + /// -or- + /// + /// + /// No data could be read from . + /// + /// + /// + /// The current state of the WebSocket connection is not Open. + /// + public void SendTo (Stream stream, int length, string id) + { + IWebSocketSession session; + if (!TryGetSession (id, out session)) { + var msg = "The session could not be found."; + throw new ArgumentException (msg, "id"); + } + + session.Context.WebSocket.Send (stream, length); + } + /// /// Sends asynchronously to the client using /// the specified session. From 998702e56d2d1acc100f0ec727d2a60c141e5e55 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 16 Aug 2017 13:36:01 +0900 Subject: [PATCH 1462/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 91845b3be..4be23b2e4 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3259,8 +3259,8 @@ public void Send (Stream stream, int length) } /// - /// Sends the specified asynchronously using - /// the WebSocket connection. + /// Sends asynchronously using the WebSocket + /// connection. /// /// /// This method does not wait for the send to be complete. @@ -3269,9 +3269,17 @@ public void Send (Stream stream, int length) /// An array of that represents the binary data to send. /// /// - /// An Action<bool> delegate that invokes the method called when - /// the send is complete. A passed to this delegate will be - /// true if the send has done with no error. + /// + /// An Action<bool> delegate or + /// if not needed. + /// + /// + /// The delegate invokes the method called when the send is complete. + /// + /// + /// true is passed to the method if the send has done with + /// no error; otherwise, false. + /// /// /// /// The current state of the connection is not Open. From 76e74741e0b3c5078bef7831d9f69d60770eb723 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 16 Aug 2017 13:39:13 +0900 Subject: [PATCH 1463/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 4be23b2e4..2bd47630c 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3342,12 +3342,16 @@ public void SendAsync (FileInfo fileInfo, Action completed) if (fileInfo == null) throw new ArgumentNullException ("fileInfo"); - if (!fileInfo.Exists) - throw new ArgumentException ("The file does not exist.", "fileInfo"); + if (!fileInfo.Exists) { + var msg = "The file does not exist."; + throw new ArgumentException (msg, "fileInfo"); + } FileStream stream; - if (!fileInfo.TryOpenRead (out stream)) - throw new ArgumentException ("The file could not be opened.", "fileInfo"); + if (!fileInfo.TryOpenRead (out stream)) { + var msg = "The file could not be opened."; + throw new ArgumentException (msg, "fileInfo"); + } sendAsync (Opcode.Binary, stream, completed); } From 0968867f497c6d82d61f706816979a3a318d0432 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 16 Aug 2017 13:52:48 +0900 Subject: [PATCH 1464/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 2bd47630c..c8595a581 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3301,19 +3301,31 @@ public void SendAsync (byte[] data, Action completed) } /// - /// Sends the specified file as the binary data asynchronously using - /// the WebSocket connection. + /// Sends the specified file asynchronously using the WebSocket connection. /// /// - /// This method does not wait for the send to be complete. + /// + /// The file is sent as the binary data. + /// + /// + /// This method does not wait for the send to be complete. + /// /// /// - /// A that specifies a file to send. + /// A that specifies the file to send. /// /// - /// An Action<bool> delegate that invokes the method called when - /// the send is complete. A passed to this delegate will be - /// true if the send has done with no error. + /// + /// An Action<bool> delegate or + /// if not needed. + /// + /// + /// The delegate invokes the method called when the send is complete. + /// + /// + /// true is passed to the method if the send has done with + /// no error; otherwise, false. + /// /// /// /// The current state of the connection is not Open. From 3c792717e8906d037b70312f2f62651a59ecdfa5 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 16 Aug 2017 13:56:09 +0900 Subject: [PATCH 1465/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index c8595a581..6e307cb71 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3403,8 +3403,10 @@ public void SendAsync (string data, Action completed) throw new ArgumentNullException ("data"); byte[] bytes; - if (!data.TryGetUTF8EncodedBytes (out bytes)) - throw new ArgumentException ("It could not be UTF-8-encoded.", "data"); + if (!data.TryGetUTF8EncodedBytes (out bytes)) { + var msg = "It could not be UTF-8-encoded."; + throw new ArgumentException (msg, "data"); + } sendAsync (Opcode.Text, new MemoryStream (bytes), completed); } From 4cd79be0b7f01e6cbbc6208b5b9560ca50a30f2d Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 16 Aug 2017 14:04:03 +0900 Subject: [PATCH 1466/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 6e307cb71..e7b0774f5 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3369,8 +3369,8 @@ public void SendAsync (FileInfo fileInfo, Action completed) } /// - /// Sends the specified asynchronously using - /// the WebSocket connection. + /// Sends asynchronously using the WebSocket + /// connection. /// /// /// This method does not wait for the send to be complete. @@ -3379,9 +3379,17 @@ public void SendAsync (FileInfo fileInfo, Action completed) /// A that represents the text data to send. /// /// - /// An Action<bool> delegate that invokes the method called when - /// the send is complete. A passed to this delegate will be - /// true if the send has done with no error. + /// + /// An Action<bool> delegate or + /// if not needed. + /// + /// + /// The delegate invokes the method called when the send is complete. + /// + /// + /// true is passed to the method if the send has done with + /// no error; otherwise, false. + /// /// /// /// The current state of the connection is not Open. From 0ea4de410a9671a6bf7d78545039a9642137cd3a Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 16 Aug 2017 14:11:03 +0900 Subject: [PATCH 1467/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index e7b0774f5..d524f6325 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3471,22 +3471,28 @@ public void SendAsync (Stream stream, int length, Action completed) if (stream == null) throw new ArgumentNullException ("stream"); - if (!stream.CanRead) - throw new ArgumentException ("It cannot be read.", "stream"); + if (!stream.CanRead) { + var msg = "It cannot be read."; + throw new ArgumentException (msg, "stream"); + } - if (length < 1) - throw new ArgumentException ("It is less than 1.", "length"); + if (length < 1) { + var msg = "Less than 1."; + throw new ArgumentException (msg, "length"); + } var bytes = stream.ReadBytes (length); var len = bytes.Length; - if (len == 0) - throw new ArgumentException ("No data could be read from it.", "stream"); + if (len == 0) { + var msg = "No data could be read from it."; + throw new ArgumentException (msg, "stream"); + } if (len < length) { _logger.Warn ( String.Format ( - "Only {0} byte(s) of data could be read from the specified stream.", + "Only {0} byte(s) of data could be read from the stream.", len ) ); From 8e5d517458c1b7f7025c537d79278e4d046378c7 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 16 Aug 2017 15:07:37 +0900 Subject: [PATCH 1468/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index d524f6325..7dd909f7e 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3420,23 +3420,35 @@ public void SendAsync (string data, Action completed) } /// - /// Sends the specified of data from - /// the specified asynchronously using + /// Sends the data from asynchronously using /// the WebSocket connection. /// /// - /// This method does not wait for the send to be complete. + /// + /// The data is sent as the binary data. + /// + /// + /// This method does not wait for the send to be complete. + /// /// /// - /// A from which reads the binary data to send. + /// A instance from which to read the data to send. /// /// - /// An that specifies the number of bytes to read and send. + /// An that specifies the number of bytes to send. /// /// - /// An Action<bool> delegate that invokes the method called when - /// the send is complete. A passed to this delegate will be - /// true if the send has done with no error. + /// + /// An Action<bool> delegate or + /// if not needed. + /// + /// + /// The delegate invokes the method called when the send is complete. + /// + /// + /// true is passed to the method if the send has done with + /// no error; otherwise, false. + /// /// /// /// The current state of the connection is not Open. From f6ec443461ad75996df1b7254bf3ffc524c40ea8 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 16 Aug 2017 15:17:41 +0900 Subject: [PATCH 1469/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketSessionManager.cs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 0e62599fb..0e7d4fb36 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -566,24 +566,22 @@ public void Broadcast (Stream stream, int length) } /// - /// Sends the specified asynchronously to - /// every client in the WebSocket service. + /// Sends asynchronously to every client in + /// the WebSocket service. /// /// /// This method does not wait for the send to be complete. /// /// - /// An array of that represents - /// the binary data to send. + /// An array of that represents the binary data to send. /// /// /// - /// An delegate or - /// if not needed. + /// An delegate or + /// if not needed. /// /// - /// That delegate invokes the method called when - /// the send is complete. + /// The delegate invokes the method called when the send is complete. /// /// /// From ef777f69e1fb542e69564b17bec5f73ff4849155 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 16 Aug 2017 15:21:06 +0900 Subject: [PATCH 1470/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketSessionManager.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 0e7d4fb36..b2d9e010b 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -607,8 +607,8 @@ public void BroadcastAsync (byte[] data, Action completed) } /// - /// Sends the specified asynchronously to - /// every client in the WebSocket service. + /// Sends asynchronously to every client in + /// the WebSocket service. /// /// /// This method does not wait for the send to be complete. @@ -622,7 +622,7 @@ public void BroadcastAsync (byte[] data, Action completed) /// if not needed. /// /// - /// That delegate invokes the method called when the send is complete. + /// The delegate invokes the method called when the send is complete. /// /// /// From b754c4b6ab0672c3f54babfff2b4726ccb99db0c Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 16 Aug 2017 15:25:29 +0900 Subject: [PATCH 1471/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketSessionManager.cs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index b2d9e010b..8a616a8e8 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -712,11 +712,15 @@ public void BroadcastAsync (Stream stream, int length, Action completed) if (stream == null) throw new ArgumentNullException ("stream"); - if (!stream.CanRead) - throw new ArgumentException ("It cannot be read.", "stream"); + if (!stream.CanRead) { + var msg = "It cannot be read."; + throw new ArgumentException (msg, "stream"); + } - if (length < 1) - throw new ArgumentException ("Less than 1.", "length"); + if (length < 1) { + var msg = "Less than 1."; + throw new ArgumentException (msg, "length"); + } var bytes = stream.ReadBytes (length); @@ -729,7 +733,7 @@ public void BroadcastAsync (Stream stream, int length, Action completed) if (len < length) { _logger.Warn ( String.Format ( - "Only {0} byte(s) of data could be read from the specified stream.", + "Only {0} byte(s) of data could be read from the stream.", len ) ); From 55cf887b337f8ec2a759372bccefe32d2bb9c883 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 16 Aug 2017 15:31:30 +0900 Subject: [PATCH 1472/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketSessionManager.cs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 8a616a8e8..a0fa6cce1 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -657,15 +657,19 @@ public void BroadcastAsync (string data, Action completed) } /// - /// Sends the specified of data from - /// the specified asynchronously to + /// Sends the data from asynchronously to /// every client in the WebSocket service. /// /// - /// This method does not wait for the send to be complete. + /// + /// The data is sent as the binary data. + /// + /// + /// This method does not wait for the send to be complete. + /// /// /// - /// A from which to read the binary data to send. + /// A instance from which to read the data to send. /// /// /// An that specifies the number of bytes to send. @@ -676,7 +680,7 @@ public void BroadcastAsync (string data, Action completed) /// if not needed. /// /// - /// That delegate invokes the method called when the send is complete. + /// The delegate invokes the method called when the send is complete. /// /// /// From 3eb62c34cc143d915969727a94eabeb1e599ac57 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 16 Aug 2017 15:36:43 +0900 Subject: [PATCH 1473/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketSessionManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index a0fa6cce1..08e2e6822 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -759,7 +759,7 @@ public void BroadcastAsync (Stream stream, int length, Action completed) /// /// It represents a collection of pairs of a session ID and /// a value indicating whether a pong has been received from - /// its client within a time. + /// the client within a time. /// /// /// From 19d7c0da890e44c74879f7e02c957b2540a579db Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 16 Aug 2017 15:39:32 +0900 Subject: [PATCH 1474/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketSessionManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 08e2e6822..5944eeade 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -787,7 +787,7 @@ public Dictionary Broadping () /// /// It represents a collection of pairs of a session ID and /// a value indicating whether a pong has been received from - /// its client within a time. + /// the client within a time. /// /// /// From 75d09276ba0f5b9769a7a7f116072e5fc24f1a88 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 16 Aug 2017 15:44:20 +0900 Subject: [PATCH 1475/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketSessionManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 5944eeade..9881cff03 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -1160,7 +1160,7 @@ public void SendTo (Stream stream, int length, string id) /// if not needed. /// /// - /// That delegate invokes the method called when the send is complete. + /// The delegate invokes the method called when the send is complete. /// /// /// true is passed to the method if the send has done with From a62693baafc6971369a11246f6829c06035fab3c Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 17 Aug 2017 15:36:44 +0900 Subject: [PATCH 1476/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServiceManager.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index 0149c63d8..fccad32cf 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -504,12 +504,10 @@ public void AddService ( } /// - /// Sends the specified to - /// every client in the WebSocket services. + /// Sends to every client in the WebSocket services. /// /// - /// An array of that represents - /// the binary data to send. + /// An array of that represents the binary data to send. /// /// /// The current state of the manager is not Start. From 41811a9e40ddf4d8b09294385e7b2a923e1d2019 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 17 Aug 2017 15:39:44 +0900 Subject: [PATCH 1477/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServiceManager.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index fccad32cf..07fec580a 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -533,8 +533,7 @@ public void Broadcast (byte[] data) } /// - /// Sends the specified to - /// every client in the WebSocket services. + /// Sends to every client in the WebSocket services. /// /// /// A that represents the text data to send. From 9652eba0050451feb7c23676ade5047eff7086ec Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 17 Aug 2017 15:45:35 +0900 Subject: [PATCH 1478/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServiceManager.cs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index 07fec580a..24e97187f 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -571,24 +571,22 @@ public void Broadcast (string data) } /// - /// Sends the specified asynchronously to - /// every client in the WebSocket services. + /// Sends asynchronously to every client in + /// the WebSocket services. /// /// /// This method does not wait for the send to be complete. /// /// - /// An array of that represents - /// the binary data to send. + /// An array of that represents the binary data to send. /// /// /// - /// An delegate or - /// if not needed. + /// An delegate or + /// if not needed. /// /// - /// That delegate invokes the method called when - /// the send is complete. + /// The delegate invokes the method called when the send is complete. /// /// /// From 67b7b3a823e8a58f16fd7036148d03bc15abadfc Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 17 Aug 2017 15:48:56 +0900 Subject: [PATCH 1479/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServiceManager.cs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index 24e97187f..a30617d95 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -613,8 +613,8 @@ public void BroadcastAsync (byte[] data, Action completed) } /// - /// Sends the specified asynchronously to - /// every client in the WebSocket services. + /// Sends asynchronously to every client in + /// the WebSocket services. /// /// /// This method does not wait for the send to be complete. @@ -624,12 +624,11 @@ public void BroadcastAsync (byte[] data, Action completed) /// /// /// - /// An delegate or - /// if not needed. + /// An delegate or + /// if not needed. /// /// - /// That delegate invokes the method called when - /// the send is complete. + /// The delegate invokes the method called when the send is complete. /// /// /// From 4ee86966cf3379aac8b8c8b21c6f82d1155fd008 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 17 Aug 2017 15:55:38 +0900 Subject: [PATCH 1480/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketServiceManager.cs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index a30617d95..db09af5d8 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -722,11 +722,15 @@ public void BroadcastAsync (Stream stream, int length, Action completed) if (stream == null) throw new ArgumentNullException ("stream"); - if (!stream.CanRead) - throw new ArgumentException ("It cannot be read.", "stream"); + if (!stream.CanRead) { + var msg = "It cannot be read."; + throw new ArgumentException (msg, "stream"); + } - if (length < 1) - throw new ArgumentException ("It is less than 1.", "length"); + if (length < 1) { + var msg = "Less than 1."; + throw new ArgumentException (msg, "length"); + } var bytes = stream.ReadBytes (length); @@ -739,7 +743,7 @@ public void BroadcastAsync (Stream stream, int length, Action completed) if (len < length) { _log.Warn ( String.Format ( - "Only {0} byte(s) of data could be read from the specified stream.", + "Only {0} byte(s) of data could be read from the stream.", len ) ); From facc205ad9fb12d3568b3a03c38dd82fce540e85 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 17 Aug 2017 16:03:55 +0900 Subject: [PATCH 1481/6294] [Modify] Edit it --- .../Server/WebSocketServiceManager.cs | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index db09af5d8..42f1e3e18 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -664,28 +664,30 @@ public void BroadcastAsync (string data, Action completed) } /// - /// Sends the specified of data from - /// the specified asynchronously to + /// Sends the data from asynchronously to /// every client in the WebSocket services. /// /// - /// This method does not wait for the send to be complete. + /// + /// The data is sent as the binary data. + /// + /// + /// This method does not wait for the send to be complete. + /// /// /// - /// A from which to read the binary data to send. + /// A instance from which to read the data to send. /// /// - /// An that specifies the number of bytes to - /// read and send. + /// An that specifies the number of bytes to send. /// /// /// - /// An delegate or - /// if not needed. + /// An delegate or + /// if not needed. /// /// - /// That delegate invokes the method called when - /// the send is complete. + /// The delegate invokes the method called when the send is complete. /// /// /// From 779175aff0943a3897b7523bec54d4795f371798 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 17 Aug 2017 16:06:08 +0900 Subject: [PATCH 1482/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServiceManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index 42f1e3e18..9b62ad799 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -767,7 +767,7 @@ public void BroadcastAsync (Stream stream, int length, Action completed) /// /// It represents a collection of pairs of a service path and another /// collection of pairs of a session ID and a value indicating whether - /// a pong has been received from its client within a time. + /// a pong has been received from the client within a time. /// /// /// From 29cfc7e124417eaa83b9c4249d40aa8123fefe6d Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 17 Aug 2017 16:08:50 +0900 Subject: [PATCH 1483/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServiceManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index 9b62ad799..b9206b8d1 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -795,7 +795,7 @@ public Dictionary> Broadping () /// /// It represents a collection of pairs of a service path and another /// collection of pairs of a session ID and a value indicating whether - /// a pong has been received from its client within a time. + /// a pong has been received from the client within a time. /// /// /// From 38c8e4117f7f0584657912b6cca0900f7e6e50fb Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 18 Aug 2017 13:50:58 +0900 Subject: [PATCH 1484/6294] [Modify] Throw exception --- websocket-sharp/Server/WebSocketSessionManager.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 9881cff03..211968b93 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -842,8 +842,12 @@ public Dictionary Broadping (string message) public void CloseSession (string id) { IWebSocketSession session; - if (TryGetSession (id, out session)) - session.Context.WebSocket.Close (); + if (!TryGetSession (id, out session)) { + var msg = "The session could not be found."; + throw new ArgumentException (msg, "id"); + } + + session.Context.WebSocket.Close (); } /// From 814b64e0199268ddd2c9b6035630ca7ae22fcc97 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 18 Aug 2017 13:58:30 +0900 Subject: [PATCH 1485/6294] [Modify] Edit it --- .../Server/WebSocketSessionManager.cs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 211968b93..6c554ef84 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -834,11 +834,25 @@ public Dictionary Broadping (string message) } /// - /// Closes the session with the specified . + /// Closes the specified session. /// /// /// A that represents the ID of the session to close. /// + /// + /// is . + /// + /// + /// + /// is an empty string. + /// + /// + /// -or- + /// + /// + /// The session could not be found. + /// + /// public void CloseSession (string id) { IWebSocketSession session; From 189d8b38ec98a607adcb613beda9d9e5dd824af2 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 18 Aug 2017 14:02:28 +0900 Subject: [PATCH 1486/6294] [Modify] Throw exception --- websocket-sharp/Server/WebSocketSessionManager.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 6c554ef84..1fbc0fef2 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -880,8 +880,12 @@ public void CloseSession (string id) public void CloseSession (string id, ushort code, string reason) { IWebSocketSession session; - if (TryGetSession (id, out session)) - session.Context.WebSocket.Close (code, reason); + if (!TryGetSession (id, out session)) { + var msg = "The session could not be found."; + throw new ArgumentException (msg, "id"); + } + + session.Context.WebSocket.Close (code, reason); } /// From 0254b00b9ede473456af0cf85a01730791d26c97 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 18 Aug 2017 14:24:44 +0900 Subject: [PATCH 1487/6294] [Modify] Edit it --- .../Server/WebSocketSessionManager.cs | 65 +++++++++++++++++-- 1 file changed, 61 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 1fbc0fef2..476a77ed0 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -865,18 +865,75 @@ public void CloseSession (string id) } /// - /// Closes the session with the specified , , - /// and . + /// Closes the specified session with and + /// . /// /// /// A that represents the ID of the session to close. /// /// - /// A that represents the status code indicating the reason for the close. + /// + /// A that represents the status code indicating + /// the reason for the close. + /// + /// + /// The status codes are defined in + /// + /// Section 7.4 of RFC 6455. + /// /// /// - /// A that represents the reason for the close. + /// + /// A that represents the reason for the close. + /// + /// + /// The size must be 123 bytes or less in UTF-8. + /// /// + /// + /// is . + /// + /// + /// + /// is an empty string. + /// + /// + /// -or- + /// + /// + /// The session could not be found. + /// + /// + /// -or- + /// + /// + /// is 1010 (mandatory extension). + /// + /// + /// -or- + /// + /// + /// is 1005 (no status) and there is + /// . + /// + /// + /// -or- + /// + /// + /// could not be UTF-8-encoded. + /// + /// + /// + /// + /// is less than 1000 or greater than 4999. + /// + /// + /// -or- + /// + /// + /// The size of is greater than 123 bytes. + /// + /// public void CloseSession (string id, ushort code, string reason) { IWebSocketSession session; From 9a2dc74cbc024439dcc8d508be7a1e0348a6ad67 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 18 Aug 2017 14:27:13 +0900 Subject: [PATCH 1488/6294] [Modify] Throw exception --- websocket-sharp/Server/WebSocketSessionManager.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 476a77ed0..f87d3a0d3 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -962,8 +962,12 @@ public void CloseSession (string id, ushort code, string reason) public void CloseSession (string id, CloseStatusCode code, string reason) { IWebSocketSession session; - if (TryGetSession (id, out session)) - session.Context.WebSocket.Close (code, reason); + if (!TryGetSession (id, out session)) { + var msg = "The session could not be found."; + throw new ArgumentException (msg, "id"); + } + + session.Context.WebSocket.Close (code, reason); } /// From 3acda8050bbb3f53cf4753902a078889bfe6e818 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 18 Aug 2017 14:45:21 +0900 Subject: [PATCH 1489/6294] [Modify] Edit it --- .../Server/WebSocketSessionManager.cs | 57 +++++++++++++++++-- 1 file changed, 52 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index f87d3a0d3..6dca40797 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -946,19 +946,66 @@ public void CloseSession (string id, ushort code, string reason) } /// - /// Closes the session with the specified , , - /// and . + /// Closes the specified session with and + /// . /// /// /// A that represents the ID of the session to close. /// /// - /// One of the enum values, represents the status code - /// indicating the reason for the close. + /// + /// One of the enum values. + /// + /// + /// It represents the status code indicating the reason for the close. + /// /// /// - /// A that represents the reason for the close. + /// + /// A that represents the reason for the close. + /// + /// + /// The size must be 123 bytes or less in UTF-8. + /// /// + /// + /// is . + /// + /// + /// + /// is an empty string. + /// + /// + /// -or- + /// + /// + /// The session could not be found. + /// + /// + /// -or- + /// + /// + /// is + /// . + /// + /// + /// -or- + /// + /// + /// is + /// and there is + /// . + /// + /// + /// -or- + /// + /// + /// could not be UTF-8-encoded. + /// + /// + /// + /// The size of is greater than 123 bytes. + /// public void CloseSession (string id, CloseStatusCode code, string reason) { IWebSocketSession session; From 9006e01c2f62216e915d8d1ce7b6117d57869234 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 18 Aug 2017 14:53:56 +0900 Subject: [PATCH 1490/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketSessionManager.cs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 6dca40797..327737e79 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -1524,16 +1524,14 @@ public void Sweep () } /// - /// Tries to get the session instance with the specified - /// . + /// Tries to get the session instance with . /// /// - /// true if the session is successfully found; - /// otherwise, false. + /// true if the session is successfully found; otherwise, + /// false. /// /// - /// A that represents the ID of - /// the session to find. + /// A that represents the ID of the session to find. /// /// /// @@ -1541,8 +1539,8 @@ public void Sweep () /// instance or if not found. /// /// - /// That session instance provides the function to - /// access the information in the session. + /// The session instance provides the function to access + /// the information in the session. /// /// /// From 669e1ca82151fac5bb8c9946002f01fe4b916fcb Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 18 Aug 2017 15:02:35 +0900 Subject: [PATCH 1491/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketSessionManager.cs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 327737e79..713da47a9 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -151,21 +151,20 @@ public IEnumerable InactiveIDs { } /// - /// Gets the session instance with the specified . + /// Gets the session instance with . /// /// /// - /// A instance or - /// if not found. + /// A instance or + /// if not found. /// /// - /// That session instance provides the function to - /// access the information in the session. + /// The session instance provides the function to access the information + /// in the session. /// /// /// - /// A that represents the ID of - /// the session to find. + /// A that represents the ID of the session to find. /// /// /// is . From d3886a256abd230f0b06cae5ce13f57fa7bc3d53 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 19 Aug 2017 14:54:15 +0900 Subject: [PATCH 1492/6294] [Modify] Throw InvalidOperationException --- websocket-sharp/Server/WebSocketSessionManager.cs | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 713da47a9..c95265221 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -842,22 +842,17 @@ public Dictionary Broadping (string message) /// is . /// /// - /// - /// is an empty string. - /// - /// - /// -or- - /// - /// - /// The session could not be found. - /// + /// is an empty string. + /// + /// + /// The session could not be found. /// public void CloseSession (string id) { IWebSocketSession session; if (!TryGetSession (id, out session)) { var msg = "The session could not be found."; - throw new ArgumentException (msg, "id"); + throw new InvalidOperationException (msg); } session.Context.WebSocket.Close (); From 8d372c037110bb98585b6d43bbbc45ed1132aa11 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 19 Aug 2017 15:09:05 +0900 Subject: [PATCH 1493/6294] [Modify] Throw InvalidOperationException --- websocket-sharp/Server/WebSocketSessionManager.cs | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index c95265221..37fb37e47 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -895,12 +895,6 @@ public void CloseSession (string id) /// -or- /// /// - /// The session could not be found. - /// - /// - /// -or- - /// - /// /// is 1010 (mandatory extension). /// /// @@ -917,6 +911,9 @@ public void CloseSession (string id) /// could not be UTF-8-encoded. /// /// + /// + /// The session could not be found. + /// /// /// /// is less than 1000 or greater than 4999. @@ -933,7 +930,7 @@ public void CloseSession (string id, ushort code, string reason) IWebSocketSession session; if (!TryGetSession (id, out session)) { var msg = "The session could not be found."; - throw new ArgumentException (msg, "id"); + throw new InvalidOperationException (msg); } session.Context.WebSocket.Close (code, reason); From 3d303fbe4a51e635425a66dc535bfc2f91db6cd1 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 19 Aug 2017 15:17:03 +0900 Subject: [PATCH 1494/6294] [Modify] Throw InvalidOperationException --- websocket-sharp/Server/WebSocketSessionManager.cs | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 37fb37e47..6d94a13a5 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -970,12 +970,6 @@ public void CloseSession (string id, ushort code, string reason) /// -or- /// /// - /// The session could not be found. - /// - /// - /// -or- - /// - /// /// is /// . /// @@ -994,6 +988,9 @@ public void CloseSession (string id, ushort code, string reason) /// could not be UTF-8-encoded. /// /// + /// + /// The session could not be found. + /// /// /// The size of is greater than 123 bytes. /// @@ -1002,7 +999,7 @@ public void CloseSession (string id, CloseStatusCode code, string reason) IWebSocketSession session; if (!TryGetSession (id, out session)) { var msg = "The session could not be found."; - throw new ArgumentException (msg, "id"); + throw new InvalidOperationException (msg); } session.Context.WebSocket.Close (code, reason); From 010d6a63c5cbf0538cbbaf907c44556de94108ba Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 19 Aug 2017 15:22:10 +0900 Subject: [PATCH 1495/6294] [Modify] Throw InvalidOperationException --- websocket-sharp/Server/WebSocketSessionManager.cs | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 6d94a13a5..c001163e2 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -1019,22 +1019,17 @@ public void CloseSession (string id, CloseStatusCode code, string reason) /// is . /// /// - /// - /// is an empty string. - /// - /// - /// -or- - /// - /// - /// The session could not be found. - /// + /// is an empty string. + /// + /// + /// The session could not be found. /// public bool PingTo (string id) { IWebSocketSession session; if (!TryGetSession (id, out session)) { var msg = "The session could not be found."; - throw new ArgumentException (msg, "id"); + throw new InvalidOperationException (msg); } return session.Context.WebSocket.Ping (); From c4fcf530bce58d768bd6375211159f30fc2f18ba Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 19 Aug 2017 15:28:23 +0900 Subject: [PATCH 1496/6294] [Modify] Throw InvalidOperationException --- websocket-sharp/Server/WebSocketSessionManager.cs | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index c001163e2..4ee71851c 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -1065,15 +1065,12 @@ public bool PingTo (string id) /// -or- /// /// - /// The session could not be found. - /// - /// - /// -or- - /// - /// /// could not be UTF-8-encoded. /// /// + /// + /// The session could not be found. + /// /// /// The size of is greater than 125 bytes. /// @@ -1082,7 +1079,7 @@ public bool PingTo (string message, string id) IWebSocketSession session; if (!TryGetSession (id, out session)) { var msg = "The session could not be found."; - throw new ArgumentException (msg, "id"); + throw new InvalidOperationException (msg); } return session.Context.WebSocket.Ping (message); From acf89bad96df5e6c1b5b71ca2c997d873f81d366 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 20 Aug 2017 16:00:32 +0900 Subject: [PATCH 1497/6294] [Modify] Throw InvalidOperationException --- websocket-sharp/Server/WebSocketSessionManager.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 4ee71851c..f528d3076 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -1106,25 +1106,25 @@ public bool PingTo (string message, string id) /// /// /// + /// is an empty string. + /// + /// /// - /// is an empty string. + /// The session could not be found. /// /// /// -or- /// /// - /// The session could not be found. + /// The current state of the WebSocket connection is not Open. /// /// - /// - /// The current state of the WebSocket connection is not Open. - /// public void SendTo (byte[] data, string id) { IWebSocketSession session; if (!TryGetSession (id, out session)) { var msg = "The session could not be found."; - throw new ArgumentException (msg, "id"); + throw new InvalidOperationException (msg); } session.Context.WebSocket.Send (data); From d45dc223763e6b6bc9344560e091ddc8b5ec614e Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 20 Aug 2017 16:09:58 +0900 Subject: [PATCH 1498/6294] [Modify] Throw InvalidOperationException --- websocket-sharp/Server/WebSocketSessionManager.cs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index f528d3076..47975fbf9 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -1158,24 +1158,26 @@ public void SendTo (byte[] data, string id) /// -or- /// /// + /// could not be UTF-8-encoded. + /// + /// + /// + /// /// The session could not be found. /// /// /// -or- /// /// - /// could not be UTF-8-encoded. + /// The current state of the WebSocket connection is not Open. /// /// - /// - /// The current state of the WebSocket connection is not Open. - /// public void SendTo (string data, string id) { IWebSocketSession session; if (!TryGetSession (id, out session)) { var msg = "The session could not be found."; - throw new ArgumentException (msg, "id"); + throw new InvalidOperationException (msg); } session.Context.WebSocket.Send (data); From 4748abe65b918eaa0cacb29f42d2130eef18d437 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 20 Aug 2017 16:18:05 +0900 Subject: [PATCH 1499/6294] [Modify] Throw InvalidOperationException --- .../Server/WebSocketSessionManager.cs | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 47975fbf9..e91924d82 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -1218,12 +1218,6 @@ public void SendTo (string data, string id) /// -or- /// /// - /// The session could not be found. - /// - /// - /// -or- - /// - /// /// cannot be read. /// /// @@ -1240,14 +1234,22 @@ public void SendTo (string data, string id) /// /// /// - /// The current state of the WebSocket connection is not Open. + /// + /// The session could not be found. + /// + /// + /// -or- + /// + /// + /// The current state of the WebSocket connection is not Open. + /// /// public void SendTo (Stream stream, int length, string id) { IWebSocketSession session; if (!TryGetSession (id, out session)) { var msg = "The session could not be found."; - throw new ArgumentException (msg, "id"); + throw new InvalidOperationException (msg); } session.Context.WebSocket.Send (stream, length); From 0bb0cd19b8143fafd12ea0f601610c0360a81d67 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 21 Aug 2017 16:10:29 +0900 Subject: [PATCH 1500/6294] [Modify] Throw InvalidOperationException --- websocket-sharp/Server/WebSocketSessionManager.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index e91924d82..d2243667b 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -1293,25 +1293,25 @@ public void SendTo (Stream stream, int length, string id) /// /// /// + /// is an empty string. + /// + /// /// - /// is an empty string. + /// The session could not be found. /// /// /// -or- /// /// - /// The session could not be found. + /// The current state of the WebSocket connection is not Open. /// /// - /// - /// The current state of the WebSocket connection is not Open. - /// public void SendToAsync (byte[] data, string id, Action completed) { IWebSocketSession session; if (!TryGetSession (id, out session)) { var msg = "The session could not be found."; - throw new ArgumentException (msg, "id"); + throw new InvalidOperationException (msg); } session.Context.WebSocket.SendAsync (data, completed); From 065aab72c40b8c0b3af0e7d0cf3c9c4bb48cd41c Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 21 Aug 2017 16:17:26 +0900 Subject: [PATCH 1501/6294] [Modify] Throw InvalidOperationException --- websocket-sharp/Server/WebSocketSessionManager.cs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index d2243667b..43a472f6f 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -1362,24 +1362,26 @@ public void SendToAsync (byte[] data, string id, Action completed) /// -or- /// /// + /// could not be UTF-8-encoded. + /// + /// + /// + /// /// The session could not be found. /// /// /// -or- /// /// - /// could not be UTF-8-encoded. + /// The current state of the WebSocket connection is not Open. /// /// - /// - /// The current state of the WebSocket connection is not Open. - /// public void SendToAsync (string data, string id, Action completed) { IWebSocketSession session; if (!TryGetSession (id, out session)) { var msg = "The session could not be found."; - throw new ArgumentException (msg, "id"); + throw new InvalidOperationException (msg); } session.Context.WebSocket.SendAsync (data, completed); From c03fb0dc0cf8937930841643e13a3dcf0b2fe9de Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 22 Aug 2017 16:36:11 +0900 Subject: [PATCH 1502/6294] [Modify] Throw InvalidOperationException --- .../Server/WebSocketSessionManager.cs | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 43a472f6f..1db8d6cc9 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -1440,12 +1440,6 @@ public void SendToAsync (string data, string id, Action completed) /// -or- /// /// - /// The session could not be found. - /// - /// - /// -or- - /// - /// /// cannot be read. /// /// @@ -1462,7 +1456,15 @@ public void SendToAsync (string data, string id, Action completed) /// /// /// - /// The current state of the WebSocket connection is not Open. + /// + /// The session could not be found. + /// + /// + /// -or- + /// + /// + /// The current state of the WebSocket connection is not Open. + /// /// public void SendToAsync ( Stream stream, int length, string id, Action completed @@ -1471,7 +1473,7 @@ public void SendToAsync ( IWebSocketSession session; if (!TryGetSession (id, out session)) { var msg = "The session could not be found."; - throw new ArgumentException (msg, "id"); + throw new InvalidOperationException (msg); } session.Context.WebSocket.SendAsync (stream, length, completed); From b33f63c344f6febc0560d1b9a843cb1113e55378 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 22 Aug 2017 16:41:52 +0900 Subject: [PATCH 1503/6294] [Modify] Remove it --- websocket-sharp/Server/WebSocketSessionManager.cs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 1db8d6cc9..0959bbf73 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -57,11 +57,6 @@ public class WebSocketSessionManager #region Internal Constructors - internal WebSocketSessionManager () - : this (new Logger ()) - { - } - internal WebSocketSessionManager (Logger logger) { _logger = logger; From f506b79eac3501cb108bbf35c85cc405d158dca6 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 23 Aug 2017 16:54:06 +0900 Subject: [PATCH 1504/6294] [Modify] Rename it --- websocket-sharp/Server/WebSocketSessionManager.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 0959bbf73..4b3c0a039 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -45,7 +45,7 @@ public class WebSocketSessionManager private volatile bool _clean; private object _forSweep; - private Logger _logger; + private Logger _log; private Dictionary _sessions; private volatile ServerState _state; private volatile bool _sweeping; @@ -57,9 +57,9 @@ public class WebSocketSessionManager #region Internal Constructors - internal WebSocketSessionManager (Logger logger) + internal WebSocketSessionManager (Logger log) { - _logger = logger; + _log = log; _clean = true; _forSweep = new object (); @@ -256,7 +256,7 @@ private void broadcast (Opcode opcode, byte[] data, Action completed) completed (); } catch (Exception ex) { - _logger.Fatal (ex.ToString ()); + _log.Fatal (ex.ToString ()); } finally { cache.Clear (); @@ -272,7 +272,7 @@ private void broadcast (Opcode opcode, Stream stream, Action completed) completed (); } catch (Exception ex) { - _logger.Fatal (ex.ToString ()); + _log.Fatal (ex.ToString ()); } finally { foreach (var cached in cache.Values) @@ -545,7 +545,7 @@ public void Broadcast (Stream stream, int length) } if (len < length) { - _logger.Warn ( + _log.Warn ( String.Format ( "Only {0} byte(s) of data could be read from the stream.", len @@ -729,7 +729,7 @@ public void BroadcastAsync (Stream stream, int length, Action completed) } if (len < length) { - _logger.Warn ( + _log.Warn ( String.Format ( "Only {0} byte(s) of data could be read from the stream.", len From 2f114401f128320a96e0ee97ec09c2ef8908324d Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 24 Aug 2017 17:25:37 +0900 Subject: [PATCH 1505/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketSessionManager.cs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 4b3c0a039..eadee9af1 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -250,13 +250,23 @@ internal set { private void broadcast (Opcode opcode, byte[] data, Action completed) { var cache = new Dictionary (); + try { - Broadcast (opcode, data, cache); + foreach (var session in Sessions) { + if (_state != ServerState.Start) { + _log.Error ("The service is shutting down."); + break; + } + + session.Context.WebSocket.Send (opcode, data, cache); + } + if (completed != null) completed (); } catch (Exception ex) { - _log.Fatal (ex.ToString ()); + _log.Error (ex.Message); + _log.Debug (ex.ToString ()); } finally { cache.Clear (); From b0d84ea0224241f910d24cca5cd10a30764f18ee Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 24 Aug 2017 17:34:10 +0900 Subject: [PATCH 1506/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketSessionManager.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index eadee9af1..29a12611d 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -363,11 +363,14 @@ internal string Add (IWebSocketSession session) } internal void Broadcast ( - Opcode opcode, byte[] data, Dictionary cache) + Opcode opcode, byte[] data, Dictionary cache + ) { foreach (var session in Sessions) { - if (_state != ServerState.Start) + if (_state != ServerState.Start) { + _log.Error ("The service is shutting down."); break; + } session.Context.WebSocket.Send (opcode, data, cache); } From 22117c527e968f62b1746ebe058d70dadef35515 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 25 Aug 2017 16:10:59 +0900 Subject: [PATCH 1507/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketServiceManager.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index b9206b8d1..375b0ea8a 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -263,10 +263,13 @@ internal set { private void broadcast (Opcode opcode, byte[] data, Action completed) { var cache = new Dictionary (); + try { foreach (var host in Hosts) { - if (_state != ServerState.Start) + if (_state != ServerState.Start) { + _log.Error ("The server is shutting down."); break; + } host.Sessions.Broadcast (opcode, data, cache); } From be729795753193577369bccfe19fa18e000f8279 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 25 Aug 2017 16:20:30 +0900 Subject: [PATCH 1508/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 7dd909f7e..d79ce65c1 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1770,12 +1770,15 @@ private bool sendBytes (byte[] bytes) { try { _stream.Write (bytes, 0, bytes.Length); - return true; } catch (Exception ex) { - _logger.Error (ex.ToString ()); + _logger.Error (ex.Message); + _logger.Debug (ex.ToString ()); + return false; } + + return true; } // As client From dc9603071617402713fc152d3fe71d8c30ecc652 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 26 Aug 2017 17:42:32 +0900 Subject: [PATCH 1509/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 34 ++++++++++++++-------------------- 1 file changed, 14 insertions(+), 20 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index d79ce65c1..ca549e628 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2213,7 +2213,7 @@ internal bool Ping (byte[] frameAsBytes, TimeSpan timeout) } } - // As server, used to broadcast + // As server internal void Send ( Opcode opcode, byte[] data, Dictionary cache ) @@ -2225,27 +2225,21 @@ internal void Send ( return; } - try { - byte[] found; - if (!cache.TryGetValue (_compression, out found)) { - found = - new WebSocketFrame ( - Fin.Final, - opcode, - data.Compress (_compression), - _compression != CompressionMethod.None, - false - ) - .ToArray (); - - cache.Add (_compression, found); - } + byte[] found; + if (!cache.TryGetValue (_compression, out found)) { + found = new WebSocketFrame ( + Fin.Final, + opcode, + data.Compress (_compression), + _compression != CompressionMethod.None, + false + ) + .ToArray (); - sendBytes (found); - } - catch (Exception ex) { - _logger.Error (ex.ToString ()); + cache.Add (_compression, found); } + + sendBytes (found); } } } From 4c8301cd9cf35bea953e4d26a3bfa2725ac23d3c Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 26 Aug 2017 21:30:57 +0900 Subject: [PATCH 1510/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketSessionManager.cs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 29a12611d..f453d30d5 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -276,13 +276,23 @@ private void broadcast (Opcode opcode, byte[] data, Action completed) private void broadcast (Opcode opcode, Stream stream, Action completed) { var cache = new Dictionary (); + try { - Broadcast (opcode, stream, cache); + foreach (var session in Sessions) { + if (_state != ServerState.Start) { + _log.Error ("The service is shutting down."); + break; + } + + session.Context.WebSocket.Send (opcode, stream, cache); + } + if (completed != null) completed (); } catch (Exception ex) { - _log.Fatal (ex.ToString ()); + _log.Error (ex.Message); + _log.Debug (ex.ToString ()); } finally { foreach (var cached in cache.Values) From a882669fcb6edf566dc99804fea18d8762f99f0f Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 26 Aug 2017 21:33:59 +0900 Subject: [PATCH 1511/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketSessionManager.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index f453d30d5..66256dcdd 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -387,11 +387,14 @@ internal void Broadcast ( } internal void Broadcast ( - Opcode opcode, Stream stream, Dictionary cache) + Opcode opcode, Stream stream, Dictionary cache + ) { foreach (var session in Sessions) { - if (_state != ServerState.Start) + if (_state != ServerState.Start) { + _log.Error ("The service is shutting down."); break; + } session.Context.WebSocket.Send (opcode, stream, cache); } From 53af8740114e8435e411de6149f2c5b8f618c137 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 27 Aug 2017 14:39:37 +0900 Subject: [PATCH 1512/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index ca549e628..e59848661 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2244,27 +2244,22 @@ internal void Send ( } } - // As server, used to broadcast + // As server internal void Send ( Opcode opcode, Stream stream, Dictionary cache ) { lock (_forSend) { - try { - Stream found; - if (!cache.TryGetValue (_compression, out found)) { - found = stream.Compress (_compression); - cache.Add (_compression, found); - } - else { - found.Position = 0; - } - - send (opcode, found, _compression != CompressionMethod.None); + Stream found; + if (!cache.TryGetValue (_compression, out found)) { + found = stream.Compress (_compression); + cache.Add (_compression, found); } - catch (Exception ex) { - _logger.Error (ex.ToString ()); + else { + found.Position = 0; } + + send (opcode, found, _compression != CompressionMethod.None); } } From 048e39a9155fe52ff695449d257de0a9fe5453fc Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 27 Aug 2017 14:51:55 +0900 Subject: [PATCH 1513/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketServiceManager.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index 375b0ea8a..40021255d 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -289,10 +289,13 @@ private void broadcast (Opcode opcode, byte[] data, Action completed) private void broadcast (Opcode opcode, Stream stream, Action completed) { var cache = new Dictionary (); + try { foreach (var host in Hosts) { - if (_state != ServerState.Start) + if (_state != ServerState.Start) { + _log.Error ("The server is shutting down."); break; + } host.Sessions.Broadcast (opcode, stream, cache); } From 20d9e24ef5464409d88c198438190dfea74910e0 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 28 Aug 2017 13:47:05 +0900 Subject: [PATCH 1514/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketSessionManager.cs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 66256dcdd..7c63db23d 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -400,14 +400,20 @@ internal void Broadcast ( } } - internal Dictionary Broadping (byte[] frameAsBytes, TimeSpan timeout) + internal Dictionary Broadping ( + byte[] frameAsBytes, TimeSpan timeout + ) { var ret = new Dictionary (); + foreach (var session in Sessions) { - if (_state != ServerState.Start) + if (_state != ServerState.Start) { + _log.Error ("The service is shutting down."); break; + } - ret.Add (session.ID, session.Context.WebSocket.Ping (frameAsBytes, timeout)); + var res = session.Context.WebSocket.Ping (frameAsBytes, timeout); + ret.Add (session.ID, res); } return ret; From 161bad1d05aaa9d54498c5a46bb7ad8336425d0c Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 28 Aug 2017 13:57:06 +0900 Subject: [PATCH 1515/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketServiceManager.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index 40021255d..f6c191e57 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -336,10 +336,13 @@ private Dictionary> broadping ( var ret = new Dictionary> (); foreach (var host in Hosts) { - if (_state != ServerState.Start) + if (_state != ServerState.Start) { + _log.Error ("The server is shutting down."); break; + } - ret.Add (host.Path, host.Sessions.Broadping (frameAsBytes, timeout)); + var res = host.Sessions.Broadping (frameAsBytes, timeout); + ret.Add (host.Path, res); } return ret; From 20e15d7afcf4fa5eb7a2ffb4fae909d05982a51b Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 29 Aug 2017 19:38:29 +0900 Subject: [PATCH 1516/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index e59848661..c1337d1fa 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2182,6 +2182,7 @@ internal void InternalAccept () open (); } + // As server internal bool Ping (byte[] frameAsBytes, TimeSpan timeout) { if (_readyState != WebSocketState.Open) @@ -2196,10 +2197,8 @@ internal bool Ping (byte[] frameAsBytes, TimeSpan timeout) pongReceived.Reset (); lock (_forState) { - if (_readyState != WebSocketState.Open) { - _logger.Error ("The state of the connection has been changed."); + if (_readyState != WebSocketState.Open) return false; - } if (!sendBytes (frameAsBytes)) return false; From 0ddc48cdcb76925eff7245438613ccda93131d40 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 30 Aug 2017 21:33:13 +0900 Subject: [PATCH 1517/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketSessionManager.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 7c63db23d..48bebacc6 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -37,8 +37,12 @@ namespace WebSocketSharp.Server { /// - /// Manages the sessions in a Websocket service. + /// Provides the management function for the sessions in a WebSocket service. /// + /// + /// This class manages the sessions in a WebSocket service provided by + /// the or . + /// public class WebSocketSessionManager { #region Private Fields From 1481c82088a02426f915e1a387f666aa10d5ba45 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 31 Aug 2017 19:35:16 +0900 Subject: [PATCH 1518/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index c1337d1fa..05cbb705c 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1472,11 +1472,13 @@ private bool processFragmentFrame (WebSocketFrame frame) private bool processPingFrame (WebSocketFrame frame) { + _logger.Trace ("A ping was received."); + var pong = WebSocketFrame.CreatePongFrame (frame.PayloadData, _client); lock (_forState) { if (_readyState != WebSocketState.Open) { - _logger.Error ("The state of the connection has been changed."); + _logger.Error ("The connection is closing."); return true; } From c8c554063f7b056f40ce7d0c111370c86eb2d461 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 1 Sep 2017 19:55:11 +0900 Subject: [PATCH 1519/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 05cbb705c..fdbac509e 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1500,6 +1500,8 @@ private bool processPingFrame (WebSocketFrame frame) private bool processPongFrame (WebSocketFrame frame) { + _logger.Trace ("A pong was received."); + try { _pongReceived.Set (); } @@ -1510,7 +1512,7 @@ private bool processPongFrame (WebSocketFrame frame) return false; } - _logger.Trace ("It has been signaled that a pong was received."); + _logger.Trace ("It has been signaled."); return true; } From c0fb99d51a1aae8d1a769d57c18233a900c0d0a9 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 2 Sep 2017 16:26:59 +0900 Subject: [PATCH 1520/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index fdbac509e..d975673f8 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1486,7 +1486,7 @@ private bool processPingFrame (WebSocketFrame frame) return false; } - _logger.Trace ("A pong has been sent to respond to this ping."); + _logger.Trace ("A pong to this ping has been sent."); if (_emitOnPing) { if (_client) From 9cc63fd5be80cb0b3c7f4254b51a5d686f461ac1 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 3 Sep 2017 17:26:58 +0900 Subject: [PATCH 1521/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index d975673f8..5953fe22d 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1505,10 +1505,16 @@ private bool processPongFrame (WebSocketFrame frame) try { _pongReceived.Set (); } - catch (NullReferenceException) { + catch (NullReferenceException ex) { + _logger.Error (ex.Message); + _logger.Debug (ex.ToString ()); + return false; } - catch (ObjectDisposedException) { + catch (ObjectDisposedException ex) { + _logger.Error (ex.Message); + _logger.Debug (ex.ToString ()); + return false; } From 06167a4613f0834360d19acfb3f1cdde0bab23a8 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 4 Sep 2017 20:12:39 +0900 Subject: [PATCH 1522/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 5953fe22d..6723047c6 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1743,7 +1743,7 @@ private bool send (Fin fin, Opcode opcode, byte[] data, bool compressed) { lock (_forState) { if (_readyState != WebSocketState.Open) { - _logger.Error ("The state of the connection has been changed."); + _logger.Error ("The connection is closing."); return false; } From 565395a70bbdebc8381e498ec8f6a4cf1f9fdbaa Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 5 Sep 2017 21:19:58 +0900 Subject: [PATCH 1523/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 6723047c6..4167d44bf 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2230,7 +2230,7 @@ internal void Send ( lock (_forSend) { lock (_forState) { if (_readyState != WebSocketState.Open) { - _logger.Error ("The state of the connection has been changed."); + _logger.Error ("The connection is closing."); return; } From 9593bf1a8599eaea6503a9cd86de6a6fb2b380ba Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 6 Sep 2017 19:23:34 +0900 Subject: [PATCH 1524/6294] [Modify] Add it --- .../Server/WebSocketSessionManager.cs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 48bebacc6..88b3b2911 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -316,6 +316,23 @@ private void broadcastAsync (Opcode opcode, Stream stream, Action completed) ThreadPool.QueueUserWorkItem (state => broadcast (opcode, stream, completed)); } + private Dictionary broadping (byte[] frameAsBytes) + { + var ret = new Dictionary (); + + foreach (var session in Sessions) { + if (_state != ServerState.Start) { + _log.Error ("The service is shutting down."); + break; + } + + var res = session.Context.WebSocket.Ping (frameAsBytes, _waitTime); + ret.Add (session.ID, res); + } + + return ret; + } + private static string createID () { return Guid.NewGuid ().ToString ("N"); From c9291b17123a835d730db72048abcbc3b114c7d3 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 7 Sep 2017 20:03:06 +0900 Subject: [PATCH 1525/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketSessionManager.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 88b3b2911..e7dc0d195 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -98,9 +98,10 @@ internal ServerState State { /// public IEnumerable ActiveIDs { get { - foreach (var res in Broadping (WebSocketFrame.EmptyPingBytes, _waitTime)) + foreach (var res in broadping (WebSocketFrame.EmptyPingBytes)) { if (res.Value) yield return res.Key; + } } } From 0cb310e0aaf32c0bcd354febcb91742afb3dd111 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 7 Sep 2017 20:15:07 +0900 Subject: [PATCH 1526/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketSessionManager.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index e7dc0d195..bd13f3df5 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -90,11 +90,16 @@ internal ServerState State { #region Public Properties /// - /// Gets the IDs for the active sessions in the Websocket service. + /// Gets the IDs for the active sessions in the WebSocket service. /// /// - /// An IEnumerable<string> instance that provides an enumerator which - /// supports the iteration over the collection of the IDs for the active sessions. + /// + /// An IEnumerable<string> instance. + /// + /// + /// It provides an enumerator which supports the iteration over + /// the collection of the IDs for the active sessions. + /// /// public IEnumerable ActiveIDs { get { From cd0227e8450d0b0f9644fda649f845d169989d8d Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 8 Sep 2017 19:33:12 +0900 Subject: [PATCH 1527/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketSessionManager.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index bd13f3df5..ec059df49 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -149,9 +149,10 @@ public IEnumerable IDs { /// public IEnumerable InactiveIDs { get { - foreach (var res in Broadping (WebSocketFrame.EmptyPingBytes, _waitTime)) + foreach (var res in broadping (WebSocketFrame.EmptyPingBytes)) { if (!res.Value) yield return res.Key; + } } } From cea3ac8a81ded91ed5d3db08b3062bdad7c7bce3 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 8 Sep 2017 19:40:24 +0900 Subject: [PATCH 1528/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketSessionManager.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index ec059df49..2265a46c6 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -141,11 +141,16 @@ public IEnumerable IDs { } /// - /// Gets the IDs for the inactive sessions in the Websocket service. + /// Gets the IDs for the inactive sessions in the WebSocket service. /// /// - /// An IEnumerable<string> instance that provides an enumerator which - /// supports the iteration over the collection of the IDs for the inactive sessions. + /// + /// An IEnumerable<string> instance. + /// + /// + /// It provides an enumerator which supports the iteration over + /// the collection of the IDs for the inactive sessions. + /// /// public IEnumerable InactiveIDs { get { From 49a4c40de640b41f20dbe4a2a5a9ede65a69a80a Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 9 Sep 2017 17:41:32 +0900 Subject: [PATCH 1529/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketSessionManager.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 2265a46c6..8174bca17 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -30,6 +30,7 @@ using System.Collections; using System.Collections.Generic; using System.IO; +using System.Linq; using System.Text; using System.Threading; using System.Timers; @@ -132,11 +133,15 @@ public int Count { /// public IEnumerable IDs { get { - if (_state == ServerState.ShuttingDown) - return new string[0]; + if (_state != ServerState.Start) + return Enumerable.Empty (); + + lock (_sync) { + if (_state != ServerState.Start) + return Enumerable.Empty (); - lock (_sync) return _sessions.Keys.ToList (); + } } } From 29c6bb4745f8ee4c89384d887dff9dbabfa2ed46 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 10 Sep 2017 20:00:42 +0900 Subject: [PATCH 1530/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketSessionManager.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 8174bca17..8e94708ff 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -125,11 +125,16 @@ public int Count { } /// - /// Gets the IDs for the sessions in the Websocket service. + /// Gets the IDs for the sessions in the WebSocket service. /// /// - /// An IEnumerable<string> instance that provides an enumerator which - /// supports the iteration over the collection of the IDs for the sessions. + /// + /// An IEnumerable<string> instance. + /// + /// + /// It provides an enumerator which supports the iteration over + /// the collection of the IDs for the sessions. + /// /// public IEnumerable IDs { get { From 544df68e13779289510bdb3028a2f0154c6df8da Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 11 Sep 2017 17:24:11 +0900 Subject: [PATCH 1531/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketSessionManager.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 8e94708ff..8984445a9 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -240,11 +240,15 @@ internal set { /// public IEnumerable Sessions { get { - if (_state == ServerState.ShuttingDown) - return new IWebSocketSession[0]; + if (_state != ServerState.Start) + return Enumerable.Empty (); + + lock (_sync) { + if (_state != ServerState.Start) + return Enumerable.Empty (); - lock (_sync) return _sessions.Values.ToList (); + } } } From b5813ce2ab949c10b252fd516f5797d5c7c35c13 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 12 Sep 2017 19:10:20 +0900 Subject: [PATCH 1532/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketSessionManager.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 8984445a9..495195f29 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -232,11 +232,16 @@ internal set { } /// - /// Gets the sessions in the Websocket service. + /// Gets the session instances in the WebSocket service. /// /// - /// An IEnumerable<IWebSocketSession> instance that provides an enumerator - /// which supports the iteration over the collection of the sessions in the service. + /// + /// An IEnumerable<IWebSocketSession> instance. + /// + /// + /// It provides an enumerator which supports the iteration over + /// the collection of the session instances. + /// /// public IEnumerable Sessions { get { From 2c92cec6af747b50e70cf3a2d5d9a1b1bbe95b97 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 12 Sep 2017 19:13:43 +0900 Subject: [PATCH 1533/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketSessionManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 495195f29..812161c4a 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -112,7 +112,7 @@ public IEnumerable ActiveIDs { } /// - /// Gets the number of the sessions in the Websocket service. + /// Gets the number of the sessions in the WebSocket service. /// /// /// An that represents the number of the sessions. From f3fc23478ec42d3b08544612ec1c19b1f052e464 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 13 Sep 2017 19:30:15 +0900 Subject: [PATCH 1534/6294] [Modify] Add it --- .../Server/WebSocketSessionManager.cs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 812161c4a..f4c9212a5 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -364,6 +364,23 @@ private Dictionary broadping (byte[] frameAsBytes) return ret; } + private bool canSet (out string message) + { + message = null; + + if (_state == ServerState.Start) { + message = "The service has already started."; + return false; + } + + if (_state == ServerState.ShuttingDown) { + message = "The service is shutting down."; + return false; + } + + return true; + } + private static string createID () { return Guid.NewGuid ().ToString ("N"); From c816cf191a939267ac51dbb0353da70d66d49300 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 14 Sep 2017 21:01:54 +0900 Subject: [PATCH 1535/6294] [Modify] It can be set --- .../Server/WebSocketSessionManager.cs | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index f4c9212a5..eebfc2eae 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -221,13 +221,21 @@ public bool KeepClean { return _clean; } - internal set { - if (!(value ^ _clean)) + set { + string msg; + if (!canSet (out msg)) { + _log.Warn (msg); return; + } + + lock (_sync) { + if (!canSet (out msg)) { + _log.Warn (msg); + return; + } - _clean = value; - if (_state == ServerState.Start) - _sweepTimer.Enabled = value; + _clean = value; + } } } From 5635b713f4ad345f38d3e8072717f2944995619e Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 15 Sep 2017 19:06:38 +0900 Subject: [PATCH 1536/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketSessionManager.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index eebfc2eae..8b2f7cd34 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -209,11 +209,15 @@ public IWebSocketSession this[string id] { } /// - /// Gets a value indicating whether the manager cleans up the inactive sessions in - /// the WebSocket service periodically. + /// Gets or sets a value indicating whether the inactive sessions in + /// the WebSocket service are cleaned up periodically. /// + /// + /// The set operation does nothing if the service has already started or + /// it is shutting down. + /// /// - /// true if the manager cleans up the inactive sessions every 60 seconds; + /// true if the inactive sessions are cleaned up every 60 seconds; /// otherwise, false. /// public bool KeepClean { From bf4112f99948f8995b7ae11a66457ecebba56ae4 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 15 Sep 2017 19:09:18 +0900 Subject: [PATCH 1537/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketServiceHost.cs | 6 ------ 1 file changed, 6 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceHost.cs b/websocket-sharp/Server/WebSocketServiceHost.cs index 416d7d82a..b69fc1bf6 100644 --- a/websocket-sharp/Server/WebSocketServiceHost.cs +++ b/websocket-sharp/Server/WebSocketServiceHost.cs @@ -124,12 +124,6 @@ public bool KeepClean { } set { - string msg; - if (!canSet (out msg)) { - _log.Warn (msg); - return; - } - _sessions.KeepClean = value; } } From 52182f659269886e36c66a160fc617732e199101 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 15 Sep 2017 19:18:12 +0900 Subject: [PATCH 1538/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServiceHost.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceHost.cs b/websocket-sharp/Server/WebSocketServiceHost.cs index b69fc1bf6..7a8c9d476 100644 --- a/websocket-sharp/Server/WebSocketServiceHost.cs +++ b/websocket-sharp/Server/WebSocketServiceHost.cs @@ -115,8 +115,8 @@ protected Logger Log { /// it is shutting down. /// /// - /// true if the service cleans up the inactive sessions every 60 - /// seconds; otherwise, false. + /// true if the service cleans up the inactive sessions every + /// 60 seconds; otherwise, false. /// public bool KeepClean { get { From f28ce31debda898c4aee28bbf7c462a857b8a7e2 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 16 Sep 2017 17:37:51 +0900 Subject: [PATCH 1539/6294] [Modify] It can be set --- .../Server/WebSocketSessionManager.cs | 21 ++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 8b2f7cd34..188db4886 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -280,13 +280,24 @@ public TimeSpan WaitTime { return _waitTime; } - internal set { - if (value == _waitTime) + set { + if (value <= TimeSpan.Zero) + throw new ArgumentOutOfRangeException ("value", "Zero or less."); + + string msg; + if (!canSet (out msg)) { + _log.Warn (msg); return; + } - _waitTime = value; - foreach (var session in Sessions) - session.Context.WebSocket.WaitTime = value; + lock (_sync) { + if (!canSet (out msg)) { + _log.Warn (msg); + return; + } + + _waitTime = value; + } } } From 1c1d9d998c391ae6279bb0813c7e6f98b4571a52 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 17 Sep 2017 14:21:28 +0900 Subject: [PATCH 1540/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketSessionManager.cs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 188db4886..e4d49bad4 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -270,11 +270,19 @@ public IEnumerable Sessions { } /// - /// Gets the wait time for the response to the WebSocket Ping or Close. + /// Gets or sets the time to wait for the response to the WebSocket Ping or + /// Close. /// + /// + /// The set operation does nothing if the service has already started or + /// it is shutting down. + /// /// - /// A that represents the wait time. + /// A to wait for the response. /// + /// + /// The value specified for a set operation is zero or less. + /// public TimeSpan WaitTime { get { return _waitTime; From 0a4bca857d911acb0b6d11f8a54f0fb4fa66d6be Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 17 Sep 2017 14:24:03 +0900 Subject: [PATCH 1541/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketServiceHost.cs | 9 --------- 1 file changed, 9 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceHost.cs b/websocket-sharp/Server/WebSocketServiceHost.cs index 7a8c9d476..8f215c5a9 100644 --- a/websocket-sharp/Server/WebSocketServiceHost.cs +++ b/websocket-sharp/Server/WebSocketServiceHost.cs @@ -184,15 +184,6 @@ public TimeSpan WaitTime { } set { - string msg; - if (!value.CheckWaitTime (out msg)) - throw new ArgumentException (msg, "value"); - - if (!canSet (out msg)) { - _log.Warn (msg); - return; - } - _sessions.WaitTime = value; } } From c3ddedab8e0d479de6e4ad95ddedac2a8472e3df Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 17 Sep 2017 14:27:59 +0900 Subject: [PATCH 1542/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServiceHost.cs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceHost.cs b/websocket-sharp/Server/WebSocketServiceHost.cs index 8f215c5a9..e3376bbf1 100644 --- a/websocket-sharp/Server/WebSocketServiceHost.cs +++ b/websocket-sharp/Server/WebSocketServiceHost.cs @@ -164,7 +164,7 @@ public WebSocketSessionManager Sessions { public abstract Type BehaviorType { get; } /// - /// Gets or sets the wait time for the response to the WebSocket Ping or + /// Gets or sets the time to wait for the response to the WebSocket Ping or /// Close. /// /// @@ -172,10 +172,9 @@ public WebSocketSessionManager Sessions { /// it is shutting down. /// /// - /// A that represents the wait time for - /// the response. + /// A to wait for the response. /// - /// + /// /// The value specified for a set operation is zero or less. /// public TimeSpan WaitTime { From 7e2a5728eb667a2ad2870392bdfd7fb190cb7e59 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 18 Sep 2017 18:07:22 +0900 Subject: [PATCH 1543/6294] [Modify] Remove it --- .../Server/WebSocketServiceHost.cs | 22 ------------------- 1 file changed, 22 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceHost.cs b/websocket-sharp/Server/WebSocketServiceHost.cs index e3376bbf1..1da76427a 100644 --- a/websocket-sharp/Server/WebSocketServiceHost.cs +++ b/websocket-sharp/Server/WebSocketServiceHost.cs @@ -189,28 +189,6 @@ public TimeSpan WaitTime { #endregion - #region Private Methods - - private bool canSet (out string message) - { - message = null; - - var state = _sessions.State; - if (state == ServerState.Start) { - message = "The service has already started."; - return false; - } - - if (state == ServerState.ShuttingDown) { - message = "The service is shutting down."; - return false; - } - - return true; - } - - #endregion - #region Internal Methods internal void Start () From 47a917c5847371ab0b556e68d2a2c6511552b0fe Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 19 Sep 2017 19:13:45 +0900 Subject: [PATCH 1544/6294] [Modify] Add it --- .../Server/WebSocketServiceManager.cs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index f6c191e57..cf8d033fa 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -348,6 +348,23 @@ private Dictionary> broadping ( return ret; } + private bool canSet (out string message) + { + message = null; + + if (_state == ServerState.Start) { + message = "The server has already started."; + return false; + } + + if (_state == ServerState.ShuttingDown) { + message = "The server is shutting down."; + return false; + } + + return true; + } + #endregion #region Internal Methods From d0c065c04103a7ad056a0e0eff279352b3e086f7 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 19 Sep 2017 19:23:38 +0900 Subject: [PATCH 1545/6294] [Modify] It can be set --- websocket-sharp/Server/WebSocketServiceManager.cs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index cf8d033fa..dd4a4dd11 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -184,12 +184,23 @@ public bool KeepClean { return _clean; } - internal set { + set { + string msg; + if (!canSet (out msg)) { + _log.Warn (msg); + return; + } + lock (_sync) { - _clean = value; + if (!canSet (out msg)) { + _log.Warn (msg); + return; + } foreach (var host in _hosts.Values) host.KeepClean = value; + + _clean = value; } } } From 853d78c0cde739552e0dabaebde10ffdb283eb73 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 19 Sep 2017 19:39:03 +0900 Subject: [PATCH 1546/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServiceManager.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index dd4a4dd11..4eb956fff 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -172,12 +172,16 @@ public WebSocketServiceHost this[string path] { } /// - /// Gets a value indicating whether the inactive sessions in + /// Gets or sets a value indicating whether the inactive sessions in /// the WebSocket services are cleaned up periodically. /// + /// + /// The set operation does nothing if the server has already started or + /// it is shutting down. + /// /// - /// true if the inactive sessions in the services are - /// cleaned up every 60 seconds; otherwise, false. + /// true if the inactive sessions are cleaned up every 60 seconds; + /// otherwise, false. /// public bool KeepClean { get { From 9442f9559de73d34a2203f8f0feac71f381865e9 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 20 Sep 2017 15:54:15 +0900 Subject: [PATCH 1547/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketServer.cs | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 9657da323..feccfa306 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -456,20 +456,7 @@ public bool KeepClean { } set { - string msg; - if (!canSet (out msg)) { - _log.Warn (msg); - return; - } - - lock (_sync) { - if (!canSet (out msg)) { - _log.Warn (msg); - return; - } - - _services.KeepClean = value; - } + _services.KeepClean = value; } } From 5f6fcd3be6bac88a18854682536ff7964d9e0508 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 20 Sep 2017 16:01:08 +0900 Subject: [PATCH 1548/6294] [Modify] Polish it --- websocket-sharp/Server/HttpServer.cs | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 46da5414e..55ced8931 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -495,20 +495,7 @@ public bool KeepClean { } set { - string msg; - if (!canSet (out msg)) { - _log.Warn (msg); - return; - } - - lock (_sync) { - if (!canSet (out msg)) { - _log.Warn (msg); - return; - } - - _services.KeepClean = value; - } + _services.KeepClean = value; } } From c223c3d2a2e332c4b730a6fa5fa077730b6a896e Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 21 Sep 2017 19:34:36 +0900 Subject: [PATCH 1549/6294] [Modify] It can be set --- .../Server/WebSocketServiceManager.cs | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index 4eb956fff..0c29136be 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -261,12 +261,26 @@ public TimeSpan WaitTime { return _waitTime; } - internal set { + set { + if (value <= TimeSpan.Zero) + throw new ArgumentOutOfRangeException ("value", "Zero or less."); + + string msg; + if (!canSet (out msg)) { + _log.Warn (msg); + return; + } + lock (_sync) { - _waitTime = value; + if (!canSet (out msg)) { + _log.Warn (msg); + return; + } foreach (var host in _hosts.Values) host.WaitTime = value; + + _waitTime = value; } } } From 0a3ea71729fbb6423bd2791a069437ae2db45fa4 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 21 Sep 2017 19:39:10 +0900 Subject: [PATCH 1550/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServiceManager.cs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index 0c29136be..8706f58fe 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -251,11 +251,19 @@ public int SessionCount { } /// - /// Gets the wait time for the response to the WebSocket Ping or Close. + /// Gets or sets the time to wait for the response to the WebSocket Ping or + /// Close. /// + /// + /// The set operation does nothing if the server has already started or + /// it is shutting down. + /// /// - /// A that represents the wait time for the response. + /// A to wait for the response. /// + /// + /// The value specified for a set operation is zero or less. + /// public TimeSpan WaitTime { get { return _waitTime; From b4a9272f2a352a9e41de045c2adfd631ba557855 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 21 Sep 2017 19:42:07 +0900 Subject: [PATCH 1551/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketServer.cs | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index feccfa306..6b2eb8537 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -675,23 +675,7 @@ public TimeSpan WaitTime { } set { - string msg; - if (!value.CheckWaitTime (out msg)) - throw new ArgumentException (msg, "value"); - - if (!canSet (out msg)) { - _log.Warn (msg); - return; - } - - lock (_sync) { - if (!canSet (out msg)) { - _log.Warn (msg); - return; - } - - _services.WaitTime = value; - } + _services.WaitTime = value; } } From 4c57ccfdbffcaf9019a0ecfaa371cda8c613c55b Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 21 Sep 2017 19:47:24 +0900 Subject: [PATCH 1552/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 6b2eb8537..fc7922fa4 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -651,12 +651,12 @@ public Func UserCredentialsFinder { } /// - /// Gets or sets the time to wait for the response to - /// the WebSocket Ping or Close. + /// Gets or sets the time to wait for the response to the WebSocket Ping or + /// Close. /// /// - /// The set operation does nothing if the server has - /// already started or it is shutting down. + /// The set operation does nothing if the server has already started or + /// it is shutting down. /// /// /// @@ -666,7 +666,7 @@ public Func UserCredentialsFinder { /// The default value is the same as 1 second. /// /// - /// + /// /// The value specified for a set operation is zero or less. /// public TimeSpan WaitTime { From dd58c690a0b368c84bf370ae282cbd2009c40059 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 22 Sep 2017 18:51:52 +0900 Subject: [PATCH 1553/6294] [Modify] Polish it --- websocket-sharp/Server/HttpServer.cs | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 55ced8931..aa9c6d83b 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -711,23 +711,7 @@ public TimeSpan WaitTime { } set { - if (value <= TimeSpan.Zero) - throw new ArgumentException ("Zero or less.", "value"); - - string msg; - if (!canSet (out msg)) { - _log.Warn (msg); - return; - } - - lock (_sync) { - if (!canSet (out msg)) { - _log.Warn (msg); - return; - } - - _services.WaitTime = value; - } + _services.WaitTime = value; } } From 926a51c61195c8582841256ce72da8f848933c56 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 22 Sep 2017 19:02:24 +0900 Subject: [PATCH 1554/6294] [Modify] Edit it --- websocket-sharp/Server/HttpServer.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index aa9c6d83b..270b859a5 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -687,12 +687,12 @@ public Func UserCredentialsFinder { } /// - /// Gets or sets the time to wait for the response to - /// the WebSocket Ping or Close. + /// Gets or sets the time to wait for the response to the WebSocket Ping or + /// Close. /// /// - /// The set operation does nothing if the server has already - /// started or it is shutting down. + /// The set operation does nothing if the server has already started or + /// it is shutting down. /// /// /// @@ -702,7 +702,7 @@ public Func UserCredentialsFinder { /// The default value is the same as 1 second. /// /// - /// + /// /// The value specified for a set operation is zero or less. /// public TimeSpan WaitTime { From b22460273688a17ee05638700522940437b10702 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 23 Sep 2017 20:34:04 +0900 Subject: [PATCH 1555/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketSessionManager.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index e4d49bad4..075c3e1b7 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -370,7 +370,9 @@ private void broadcast (Opcode opcode, Stream stream, Action completed) private void broadcastAsync (Opcode opcode, byte[] data, Action completed) { - ThreadPool.QueueUserWorkItem (state => broadcast (opcode, data, completed)); + ThreadPool.QueueUserWorkItem ( + state => broadcast (opcode, data, completed) + ); } private void broadcastAsync (Opcode opcode, Stream stream, Action completed) From 55aabfbcaf4ca2c15eff9481812f602781a3e6a7 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 23 Sep 2017 20:39:34 +0900 Subject: [PATCH 1556/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketSessionManager.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 075c3e1b7..bfd908b07 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -377,7 +377,9 @@ private void broadcastAsync (Opcode opcode, byte[] data, Action completed) private void broadcastAsync (Opcode opcode, Stream stream, Action completed) { - ThreadPool.QueueUserWorkItem (state => broadcast (opcode, stream, completed)); + ThreadPool.QueueUserWorkItem ( + state => broadcast (opcode, stream, completed) + ); } private Dictionary broadping (byte[] frameAsBytes) From 3ef00d03685beaa38c7c1b50c91e05da79c54922 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 24 Sep 2017 19:47:52 +0900 Subject: [PATCH 1557/6294] [Modify] Polish it --- .../Server/WebSocketSessionManager.cs | 41 ++++++++++++------- 1 file changed, 26 insertions(+), 15 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index bfd908b07..32d59c85e 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -1615,31 +1615,42 @@ public void SendToAsync ( /// public void Sweep () { - if (_state != ServerState.Start || _sweeping || Count == 0) + if (_sweeping) { + _log.Info ("The sweeping is already in progress."); return; + } lock (_forSweep) { + if (_sweeping) { + _log.Info ("The sweeping is already in progress."); + return; + } + _sweeping = true; - foreach (var id in InactiveIDs) { + } + + foreach (var id in InactiveIDs) { + if (_state != ServerState.Start) + break; + + lock (_sync) { if (_state != ServerState.Start) break; - lock (_sync) { - IWebSocketSession session; - if (_sessions.TryGetValue (id, out session)) { - var state = session.State; - if (state == WebSocketState.Open) - session.Context.WebSocket.Close (CloseStatusCode.ProtocolError); - else if (state == WebSocketState.Closing) - continue; - else - _sessions.Remove (id); - } + IWebSocketSession session; + if (_sessions.TryGetValue (id, out session)) { + var state = session.State; + if (state == WebSocketState.Open) + session.Context.WebSocket.Close (CloseStatusCode.Abnormal); + else if (state == WebSocketState.Closing) + continue; + else + _sessions.Remove (id); } } - - _sweeping = false; } + + _sweeping = false; } /// From efec2020b03021c7bc8946108dcbd3d65312c2db Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 25 Sep 2017 19:26:04 +0900 Subject: [PATCH 1558/6294] [Modify] Throw exception --- websocket-sharp/WebSocket.cs | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 4167d44bf..b44cea364 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -608,14 +608,27 @@ public TimeSpan WaitTime { } set { + if (value <= TimeSpan.Zero) + throw new ArgumentOutOfRangeException ("value", "Zero or less."); + + if (_readyState == WebSocketState.Open) { + _logger.Warn ("The connection has already been established."); + return; + } + + if (_readyState == WebSocketState.Closing) { + _logger.Warn ("The connection is closing."); + return; + } + lock (_forState) { - string msg; - if (!checkIfAvailable (true, true, true, false, false, true, out msg) - || !value.CheckWaitTime (out msg) - ) { - _logger.Error (msg); - error ("An error has occurred in setting the wait time.", null); + if (_readyState == WebSocketState.Open) { + _logger.Warn ("The connection has already been established."); + return; + } + if (_readyState == WebSocketState.Closing) { + _logger.Warn ("The connection is closing."); return; } From 10fc1924cc91ab35f6d333b3c5a189c736951b07 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 26 Sep 2017 19:27:17 +0900 Subject: [PATCH 1559/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index b44cea364..b9813d981 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -596,12 +596,24 @@ public Uri Url { } /// - /// Gets or sets the wait time for the response to the Ping or Close. + /// Gets or sets the time to wait for the response to the ping or close. /// + /// + /// The set operation does nothing if the connection has already been + /// established or it is closing. + /// /// - /// A that represents the wait time. The default value is the same as - /// 5 seconds, or 1 second if the is used in a server. + /// + /// A to wait for the response. + /// + /// + /// The default value is the same as 5 seconds if the instance is + /// a client. + /// /// + /// + /// The value specified for a set operation is zero or less. + /// public TimeSpan WaitTime { get { return _waitTime; From 2dae0a101bda11bb25ef7b6ec5f06f9486a0dce0 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 27 Sep 2017 20:36:33 +0900 Subject: [PATCH 1560/6294] [Modify] Remove it --- websocket-sharp/Ext.cs | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index ff85a42cf..394bbf132 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -173,18 +173,6 @@ internal static string CheckIfValidProtocols (this string[] protocols) : null; } - internal static bool CheckWaitTime (this TimeSpan time, out string message) - { - message = null; - - if (time <= TimeSpan.Zero) { - message = "Zero or less."; - return false; - } - - return true; - } - internal static void Close (this HttpListenerResponse response, HttpStatusCode code) { response.StatusCode = (int) code; From 041663623aaf086221d376810127ddc37588a59d Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 28 Sep 2017 17:39:45 +0900 Subject: [PATCH 1561/6294] [Modify] Add it --- websocket-sharp/WebSocket.cs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index b9813d981..e86b27d20 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -942,6 +942,29 @@ private static bool checkParametersForSetProxy ( return true; } + private static bool checkProtocols (string[] protocols, out string message) + { + message = null; + + var invalid = protocols.Contains ( + protocol => protocol == null + || protocol.Length == 0 + || !protocol.IsToken () + ); + + if (invalid) { + message = "It contains an invalid value."; + return false; + } + + if (protocols.ContainsTwice ()) { + message = "It contains a value twice."; + return false; + } + + return true; + } + private bool checkReceivedFrame (WebSocketFrame frame, out string message) { message = null; From 32db15c27a9912f302546d6ad28eecc1e86aa864 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 29 Sep 2017 16:14:05 +0900 Subject: [PATCH 1562/6294] [Modify] Replace it --- websocket-sharp/WebSocket.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index e86b27d20..f510f89ab 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -235,8 +235,7 @@ public WebSocket (string url, params string[] protocols) throw new ArgumentException (msg, "url"); if (protocols != null && protocols.Length > 0) { - msg = protocols.CheckIfValidProtocols (); - if (msg != null) + if (!checkProtocols (protocols, out msg)) throw new ArgumentException (msg, "protocols"); _protocols = protocols; From c87c9615deec18a87fe9367f8b258aa5cf4c747e Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 29 Sep 2017 16:17:18 +0900 Subject: [PATCH 1563/6294] [Modify] Remove it --- websocket-sharp/Ext.cs | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 394bbf132..97d31a030 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -163,16 +163,6 @@ internal static byte[] Append (this ushort code, string reason) return ret; } - internal static string CheckIfValidProtocols (this string[] protocols) - { - return protocols.Contains ( - protocol => protocol == null || protocol.Length == 0 || !protocol.IsToken ()) - ? "Contains an invalid value." - : protocols.ContainsTwice () - ? "Contains a value twice." - : null; - } - internal static void Close (this HttpListenerResponse response, HttpStatusCode code) { response.StatusCode = (int) code; From 678845433ba10065f88c36433b905407063e9862 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 30 Sep 2017 14:17:54 +0900 Subject: [PATCH 1564/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index f510f89ab..195fc7e1c 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -945,13 +945,11 @@ private static bool checkProtocols (string[] protocols, out string message) { message = null; - var invalid = protocols.Contains ( - protocol => protocol == null - || protocol.Length == 0 - || !protocol.IsToken () - ); + Func cond = protocol => protocol == null + || protocol.Length == 0 + || !protocol.IsToken (); - if (invalid) { + if (protocols.Contains (cond)) { message = "It contains an invalid value."; return false; } From 86cd0ec0229e580a39127a8f62409dfaa9831804 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 30 Sep 2017 14:21:42 +0900 Subject: [PATCH 1565/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 97d31a030..20eaba934 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -197,11 +197,14 @@ internal static byte[] CompressToArray (this Stream stream, CompressionMethod me : stream.ToByteArray (); } - internal static bool Contains (this IEnumerable source, Func condition) + internal static bool Contains ( + this IEnumerable source, Func condition + ) { - foreach (T elm in source) + foreach (T elm in source) { if (condition (elm)) return true; + } return false; } From 9f19953490ebe9c6703af37f7b785cf6676451ad Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 1 Oct 2017 18:09:07 +0900 Subject: [PATCH 1566/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 20eaba934..3db99a997 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -212,21 +212,23 @@ this IEnumerable source, Func condition internal static bool ContainsTwice (this string[] values) { var len = values.Length; + var end = len - 1; - Func contains = null; - contains = idx => { - if (idx < len - 1) { - for (var i = idx + 1; i < len; i++) - if (values[i] == values[idx]) - return true; + Func seek = null; + seek = idx => { + if (idx == end) + return false; - return contains (++idx); - } + var val = values[idx]; + for (var i = idx + 1; i < len; i++) { + if (values[i] == val) + return true; + } - return false; - }; + return seek (++idx); + }; - return contains (0); + return seek (0); } internal static T[] Copy (this T[] source, int length) From 243e39927ee31ff84dd2d443df300b4c9bfc1283 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 2 Oct 2017 17:32:10 +0900 Subject: [PATCH 1567/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 3db99a997..100c08e3b 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -536,10 +536,17 @@ internal static bool IsText (this string value) internal static bool IsToken (this string value) { - foreach (var c in value) - if (c < 0x20 || c >= 0x7f || _tspecials.Contains (c)) + foreach (var c in value) { + if (c < 0x20) return false; + if (c >= 0x7f) + return false; + + if (_tspecials.Contains (c)) + return false; + } + return true; } From 241659559f9e94fbc74f29bc7e82fd10270e9cf9 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 3 Oct 2017 22:41:34 +0900 Subject: [PATCH 1568/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 100c08e3b..270a2a84b 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -516,19 +516,28 @@ internal static bool IsSupported (this byte opcode) internal static bool IsText (this string value) { var len = value.Length; + for (var i = 0; i < len; i++) { var c = value[i]; - if (c < 0x20 && !"\r\n\t".Contains (c)) - return false; + if (c < 0x20) { + if (!"\r\n\t".Contains (c)) + return false; - if (c == 0x7f) - return false; + if (c == '\n') { + i++; + if (i == len) + break; - if (c == '\n' && ++i < len) { - c = value[i]; - if (!" \t".Contains (c)) - return false; + c = value[i]; + if (!" \t".Contains (c)) + return false; + } + + continue; } + + if (c == 0x7f) + return false; } return true; From 2df1ee86c119dcda0328a6f6d0c126a00a80b200 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 4 Oct 2017 19:02:35 +0900 Subject: [PATCH 1569/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 195fc7e1c..8398731ca 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -945,8 +945,7 @@ private static bool checkProtocols (string[] protocols, out string message) { message = null; - Func cond = protocol => protocol == null - || protocol.Length == 0 + Func cond = protocol => protocol.IsNullOrEmpty () || !protocol.IsToken (); if (protocols.Contains (cond)) { From de9ac48b40f8113f7ae27151114739c538347b2c Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 5 Oct 2017 14:11:36 +0900 Subject: [PATCH 1570/6294] [Modify] Edit it --- websocket-sharp/Ext.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 270a2a84b..e944d8740 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1394,12 +1394,12 @@ public static bool IsLocal (this System.Net.IPAddress address) } /// - /// Determines whether the specified is - /// or an empty string. + /// Determines whether the specified string is or + /// an empty string. /// /// - /// true if is or - /// an empty string; otherwise, false. + /// true if the string is or an empty string; + /// otherwise, false. /// /// /// A to test. From e2be83657fb65cdd4c1f69259c69c8506da2ca00 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 6 Oct 2017 20:14:05 +0900 Subject: [PATCH 1571/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 33 ++++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 8398731ca..4bc79cb69 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -198,28 +198,47 @@ internal WebSocket (TcpListenerWebSocketContext context, string protocol) /// /// Initializes a new instance of the class with - /// the specified WebSocket URL and subprotocols. + /// and . /// /// - /// A that represents the WebSocket URL to connect. + /// A that specifies the URL of the WebSocket + /// server to connect. /// /// - /// An array of that contains the WebSocket subprotocols if any. - /// Each value of must be a token defined in - /// RFC 2616. + /// + /// An array of that specifies the names of + /// the subprotocols if necessary. + /// + /// + /// Each value of the array must be a token defined in + /// + /// RFC 2616. + /// /// /// /// is . /// /// /// - /// is invalid. + /// is an empty string. + /// + /// + /// -or- + /// + /// + /// is an invalid WebSocket URL string. + /// + /// + /// -or- + /// + /// + /// contains a value that is not a token. /// /// /// -or- /// /// - /// is invalid. + /// contains a value twice. /// /// public WebSocket (string url, params string[] protocols) From bb710e774373b4c58ad047f62a3dd73d5ca021e9 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 7 Oct 2017 14:57:49 +0900 Subject: [PATCH 1572/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 4bc79cb69..6cc944669 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -968,7 +968,7 @@ private static bool checkProtocols (string[] protocols, out string message) || !protocol.IsToken (); if (protocols.Contains (cond)) { - message = "It contains an invalid value."; + message = "It contains a value that is not a token."; return false; } From e7bab7a9a920e77cbf9271f4739a1c83418e2dd1 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 8 Oct 2017 15:49:38 +0900 Subject: [PATCH 1573/6294] [Modify] Throw exception --- websocket-sharp/WebSocket.cs | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 6cc944669..ae715711d 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -334,19 +334,29 @@ public CompressionMethod Compression { } set { - string msg; - if (!checkIfAvailable (true, false, true, false, false, true, out msg)) { - _logger.Error (msg); - error ("An error has occurred in setting the compression.", null); + if (!_client) { + var msg = "The set operation cannot be used by servers."; + throw new InvalidOperationException (msg); + } + if (_readyState == WebSocketState.Open) { + _logger.Warn ("The connection has already been established."); + return; + } + + if (_readyState == WebSocketState.Closing) { + _logger.Warn ("The connection is closing."); return; } lock (_forState) { - if (!checkIfAvailable (true, false, false, true, out msg)) { - _logger.Error (msg); - error ("An error has occurred in setting the compression.", null); + if (_readyState == WebSocketState.Open) { + _logger.Warn ("The connection has already been established."); + return; + } + if (_readyState == WebSocketState.Closing) { + _logger.Warn ("The connection is closing."); return; } From 4722a907381467cfcf63a90af2086c909c6121b0 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 8 Oct 2017 16:33:43 +0900 Subject: [PATCH 1574/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index ae715711d..bdb347581 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -320,14 +320,26 @@ internal bool IsConnected { #region Public Properties /// - /// Gets or sets the compression method used to compress a message on - /// the WebSocket connection. + /// Gets or sets the compression method used to compress a message. /// + /// + /// The set operation does nothing if the connection has already been + /// established or it is closing. + /// /// - /// One of the enum values that specifies - /// the compression method used to compress a message. The default value is - /// . + /// + /// One of the enum values. + /// + /// + /// It represents the compression method used to compress a message. + /// + /// + /// The default value is . + /// /// + /// + /// The set operation cannot be used by servers. + /// public CompressionMethod Compression { get { return _compression; From 78298c551a5919109feb9659fc48ffe52c11e38e Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 9 Oct 2017 15:30:34 +0900 Subject: [PATCH 1575/6294] [Modify] Edit it --- websocket-sharp/CompressionMethod.cs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/CompressionMethod.cs b/websocket-sharp/CompressionMethod.cs index e7f4bcc00..9dc4083c2 100644 --- a/websocket-sharp/CompressionMethod.cs +++ b/websocket-sharp/CompressionMethod.cs @@ -31,18 +31,17 @@ namespace WebSocketSharp { /// - /// Specifies the compression method used to compress a message on - /// the WebSocket connection. + /// Specifies the method for compression. /// /// - /// The compression methods that can be used are defined in + /// The methods are defined in /// /// Compression Extensions for WebSocket. /// public enum CompressionMethod : byte { /// - /// Specifies non compression. + /// Specifies no compression. /// None, /// From 7d4baf587631b490125d30fe9493965a3721afaa Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 9 Oct 2017 15:38:21 +0900 Subject: [PATCH 1576/6294] [Modify] 2017 --- websocket-sharp/CompressionMethod.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/CompressionMethod.cs b/websocket-sharp/CompressionMethod.cs index 9dc4083c2..42ab230a6 100644 --- a/websocket-sharp/CompressionMethod.cs +++ b/websocket-sharp/CompressionMethod.cs @@ -4,7 +4,7 @@ * * The MIT License * - * Copyright (c) 2013-2016 sta.blockhead + * Copyright (c) 2013-2017 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From 4d11a61a588c91b44058324f613384a951092dff Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 10 Oct 2017 15:07:47 +0900 Subject: [PATCH 1577/6294] [Modify] Add it --- websocket-sharp/WebSocket.cs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index bdb347581..e352a0f38 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -781,6 +781,23 @@ private bool acceptHandshake () return sendHttpResponse (createHandshakeResponse ()); } + private bool canSet (out string message) + { + message = null; + + if (_readyState == WebSocketState.Open) { + message = "The connection has already been established."; + return false; + } + + if (_readyState == WebSocketState.Closing) { + message = "The connection is closing."; + return false; + } + + return true; + } + // As server private bool checkHandshakeRequest (WebSocketContext context, out string message) { From c0c05efd5ca8ff9adc8649a257069834a79461a9 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 10 Oct 2017 15:18:36 +0900 Subject: [PATCH 1578/6294] [Modify] Replace it --- websocket-sharp/WebSocket.cs | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index e352a0f38..0ea9dfb62 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -346,29 +346,21 @@ public CompressionMethod Compression { } set { + string msg = null; + if (!_client) { - var msg = "The set operation cannot be used by servers."; + msg = "The set operation cannot be used by servers."; throw new InvalidOperationException (msg); } - if (_readyState == WebSocketState.Open) { - _logger.Warn ("The connection has already been established."); - return; - } - - if (_readyState == WebSocketState.Closing) { - _logger.Warn ("The connection is closing."); + if (!canSet (out msg)) { + _logger.Warn (msg); return; } lock (_forState) { - if (_readyState == WebSocketState.Open) { - _logger.Warn ("The connection has already been established."); - return; - } - - if (_readyState == WebSocketState.Closing) { - _logger.Warn ("The connection is closing."); + if (!canSet (out msg)) { + _logger.Warn (msg); return; } From d69f900c895ac33efb50a75f95041e8be7ea1c96 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 10 Oct 2017 15:23:54 +0900 Subject: [PATCH 1579/6294] [Modify] Replace it --- websocket-sharp/WebSocket.cs | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 0ea9dfb62..2c094b1c4 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -655,24 +655,15 @@ public TimeSpan WaitTime { if (value <= TimeSpan.Zero) throw new ArgumentOutOfRangeException ("value", "Zero or less."); - if (_readyState == WebSocketState.Open) { - _logger.Warn ("The connection has already been established."); - return; - } - - if (_readyState == WebSocketState.Closing) { - _logger.Warn ("The connection is closing."); + string msg; + if (!canSet (out msg)) { + _logger.Warn (msg); return; } lock (_forState) { - if (_readyState == WebSocketState.Open) { - _logger.Warn ("The connection has already been established."); - return; - } - - if (_readyState == WebSocketState.Closing) { - _logger.Warn ("The connection is closing."); + if (!canSet (out msg)) { + _logger.Warn (msg); return; } From 458d345982e2223e248bb4e25040e59aecaa2079 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 11 Oct 2017 14:03:21 +0900 Subject: [PATCH 1580/6294] [Modify] Throw exception --- websocket-sharp/WebSocket.cs | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 2c094b1c4..f24d65e03 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -430,12 +430,21 @@ public bool EnableRedirection { } set { - lock (_forState) { - string msg; - if (!checkIfAvailable (true, false, true, false, false, true, out msg)) { - _logger.Error (msg); - error ("An error has occurred in setting the enable redirection.", null); + string msg = null; + + if (!_client) { + msg = "The set operation cannot be used by servers."; + throw new InvalidOperationException (msg); + } + if (!canSet (out msg)) { + _logger.Warn (msg); + return; + } + + lock (_forState) { + if (!canSet (out msg)) { + _logger.Warn (msg); return; } From 6a4d1c878b0cdb79a78c3494a1a6e68853e99fbc Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 12 Oct 2017 15:40:40 +0900 Subject: [PATCH 1581/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index f24d65e03..a617422cd 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -417,13 +417,25 @@ public bool EmitOnPing { } /// - /// Gets or sets a value indicating whether the redirects - /// the handshake request to the new URL located in the handshake response. + /// Gets or sets a value indicating whether the URL redirection for + /// the handshake request is allowed. /// + /// + /// The set operation does nothing if the connection has already been + /// established or it is closing. + /// /// - /// true if the redirects the handshake request to - /// the new URL; otherwise, false. The default value is false. + /// + /// true if the URL redirection for the handshake request is + /// allowed; otherwise, false. + /// + /// + /// The default value is false. + /// /// + /// + /// The set operation cannot be used by servers. + /// public bool EnableRedirection { get { return _enableRedirection; From fd2398316b5a332751f70888b76753005c85c42e Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 13 Oct 2017 15:50:16 +0900 Subject: [PATCH 1582/6294] [Modify] Throw exceptions --- websocket-sharp/WebSocket.cs | 37 ++++++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index a617422cd..55f7d9b69 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -547,29 +547,38 @@ public string Origin { } set { - lock (_forState) { - string msg; - if (!checkIfAvailable (true, false, true, false, false, true, out msg)) { - _logger.Error (msg); - error ("An error has occurred in setting the origin.", null); + string msg = null; - return; + if (!_client) { + msg = "This instance is not a client."; + throw new InvalidOperationException (msg); + } + + if (!value.IsNullOrEmpty ()) { + Uri uri; + if (!Uri.TryCreate (value, UriKind.Absolute, out uri)) { + msg = "Not an absolute URI string."; + throw new ArgumentException (msg, value); } - if (value.IsNullOrEmpty ()) { - _origin = value; - return; + if (uri.Segments.Length > 1) { + msg = "It includes the path segments."; + throw new ArgumentException (msg, value); } + } - Uri origin; - if (!Uri.TryCreate (value, UriKind.Absolute, out origin) || origin.Segments.Length > 1) { - _logger.Error ("The syntax of an origin must be '://[:]'."); - error ("An error has occurred in setting the origin.", null); + if (!canSet (out msg)) { + _logger.Warn (msg); + return; + } + lock (_forState) { + if (!canSet (out msg)) { + _logger.Warn (msg); return; } - _origin = value.TrimEnd ('/'); + _origin = !value.IsNullOrEmpty () ? value.TrimEnd ('/') : value; } } } From bbc70c53143a488e664362b66a007373b1862c3c Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 14 Oct 2017 14:54:00 +0900 Subject: [PATCH 1583/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 40 +++++++++++++++++++++++++++++------- 1 file changed, 33 insertions(+), 7 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 55f7d9b69..da104d618 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -525,22 +525,48 @@ internal set { /// /// Gets or sets the value of the HTTP Origin header to send with - /// the WebSocket handshake request to the server. + /// the handshake request. /// /// - /// The sends the Origin header if this property has any. + /// + /// The HTTP Origin header is defined in + /// + /// Section 7 of RFC 6454. + /// + /// + /// This instance sends the Origin header if this property has any. + /// + /// + /// The set operation does nothing if the connection has already been + /// established or it is closing. + /// /// /// /// - /// A that represents the value of - /// the Origin header to send. - /// The default value is . + /// A that represents the value of the Origin + /// header to send. /// /// - /// The Origin header has the following syntax: - /// <scheme>://<host>[:<port>] + /// The syntax is <scheme>://<host>[:<port>]. + /// + /// + /// The default value is . /// /// + /// + /// The set operation is not available if this instance is not a client. + /// + /// + /// + /// The value specified for a set operation is not an absolute URI string. + /// + /// + /// -or- + /// + /// + /// The value specified for a set operation includes the path segments. + /// + /// public string Origin { get { return _origin; From 4c9f443beaa2b8da8002e3989629349c6af46e2e Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 15 Oct 2017 14:45:22 +0900 Subject: [PATCH 1584/6294] [Modify] Remove it and throw exception --- websocket-sharp/WebSocket.cs | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index da104d618..8403132cd 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -651,23 +651,20 @@ public WebSocketState ReadyState { /// public ClientSslConfiguration SslConfiguration { get { - return _client - ? (_sslConfig ?? (_sslConfig = new ClientSslConfiguration (_uri.DnsSafeHost))) - : null; - } + if (!_client) { + var msg = "This instance is not a client."; + throw new InvalidOperationException (msg); + } - set { - lock (_forState) { - string msg; - if (!checkIfAvailable (true, false, true, false, false, true, out msg)) { - _logger.Error (msg); - error ("An error has occurred in setting the ssl configuration.", null); + if (!_secure) { + var msg = "The connection is not secure."; + throw new InvalidOperationException (msg); + } - return; - } + if (_sslConfig == null) + _sslConfig = new ClientSslConfiguration (_uri.DnsSafeHost); - _sslConfig = value; - } + return _sslConfig; } } From e536d858b0a2749ce5314872e5fd7a260adeb533 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 16 Oct 2017 15:45:15 +0900 Subject: [PATCH 1585/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 8403132cd..4cc576319 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -641,14 +641,26 @@ public WebSocketState ReadyState { } /// - /// Gets or sets the SSL configuration used to authenticate the server and - /// optionally the client for secure connection. + /// Gets the configuration for secure connection. /// + /// + /// This configuration will be referenced when a secure + /// connection is established, so you must configure it + /// before calling any connect method. + /// /// - /// A that represents the configuration used - /// to authenticate the server and optionally the client for secure connection, - /// or if the is used in a server. + /// A that represents + /// the configuration used to authenticate the server and + /// optionally the client for secure connection. /// + /// + /// + /// This instance is not a client. + /// + /// + /// This instance does not use a secure connection. + /// + /// public ClientSslConfiguration SslConfiguration { get { if (!_client) { From 9c2b8dcc736e1562b5b18e06d889aff7d4fd205a Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 16 Oct 2017 20:03:25 +0900 Subject: [PATCH 1586/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 4cc576319..23a74188d 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -669,7 +669,7 @@ public ClientSslConfiguration SslConfiguration { } if (!_secure) { - var msg = "The connection is not secure."; + var msg = "This instance does not use a secure connection."; throw new InvalidOperationException (msg); } From 28a72b9c292232994dc22de69e22e81dd56b6ba1 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 17 Oct 2017 15:40:12 +0900 Subject: [PATCH 1587/6294] [Modify] Throw exception --- websocket-sharp/Server/WebSocketServer.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index fc7922fa4..30a4aa289 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -591,6 +591,11 @@ public bool ReuseAddress { /// public ServerSslConfiguration SslConfiguration { get { + if (!_secure) { + var msg = "This instance does not provide secure connections."; + throw new InvalidOperationException (msg); + } + if (_sslConfig == null) _sslConfig = new ServerSslConfiguration (); From 6b27b036d20825fa565a6f1699c28b37b2646676 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 17 Oct 2017 16:12:15 +0900 Subject: [PATCH 1588/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 30a4aa289..2aae18e1c 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -582,13 +582,16 @@ public bool ReuseAddress { /// Gets the configuration for secure connections. /// /// - /// The configuration will be referenced when the server starts. - /// So you must configure it before calling the start method. + /// This configuration will be referenced when attempts to start, + /// so it must be configured before the start method is called. /// /// /// A that represents /// the configuration used to provide secure connections. /// + /// + /// This instance does not provide secure connections. + /// public ServerSslConfiguration SslConfiguration { get { if (!_secure) { From 860165eb14966586243ed0e4c29b28fdeb35ad68 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 18 Oct 2017 14:57:04 +0900 Subject: [PATCH 1589/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 23a74188d..1b32a2f77 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -644,14 +644,12 @@ public WebSocketState ReadyState { /// Gets the configuration for secure connection. /// /// - /// This configuration will be referenced when a secure - /// connection is established, so you must configure it - /// before calling any connect method. + /// This configuration will be referenced when attempts to connect, + /// so it must be configured before any connect method is called. /// /// /// A that represents - /// the configuration used to authenticate the server and - /// optionally the client for secure connection. + /// the configuration used to establish a secure connection. /// /// /// From 73a0b51c09b97b8ff68c09cda1f8525b2cca2023 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 18 Oct 2017 15:05:18 +0900 Subject: [PATCH 1590/6294] [Modify] Throw exception --- websocket-sharp/Server/HttpServer.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 270b859a5..c101b6099 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -630,6 +630,11 @@ public bool ReuseAddress { /// public ServerSslConfiguration SslConfiguration { get { + if (!_secure) { + var msg = "This instance does not provide secure connections."; + throw new InvalidOperationException (msg); + } + return _listener.SslConfiguration; } } From ed90f07b3eb38eb48ffb0e719d248c2bec00ba6e Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 19 Oct 2017 14:43:49 +0900 Subject: [PATCH 1591/6294] [Modify] Edit it --- websocket-sharp/Server/HttpServer.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index c101b6099..124d0b151 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -621,13 +621,16 @@ public bool ReuseAddress { /// Gets the configuration for secure connections. /// /// - /// The configuration will be referenced when the server starts. - /// So you must configure it before calling the start method. + /// This configuration will be referenced when attempts to start, + /// so it must be configured before the start method is called. /// /// /// A that represents /// the configuration used to provide secure connections. /// + /// + /// This instance does not provide secure connections. + /// public ServerSslConfiguration SslConfiguration { get { if (!_secure) { From 6faca0b6b4c57c24aacd8ea3af3b723e7a43aad3 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 20 Oct 2017 15:30:41 +0900 Subject: [PATCH 1592/6294] [Modify] Polish them --- websocket-sharp/Server/WebSocketServer.cs | 31 ++++++++++------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 2aae18e1c..0dd0a0910 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -752,22 +752,14 @@ private bool checkHostNameForRequest (string name) || name == _hostname; } - private bool checkSslConfiguration ( + private static bool checkSslConfiguration ( ServerSslConfiguration configuration, out string message ) { message = null; - if (!_secure) - return true; - - if (configuration == null) { - message = "There is no configuration for secure connections."; - return false; - } - if (configuration.ServerCertificate == null) { - message = "There is no certificate in the configuration."; + message = "There is no server certificate for secure connections."; return false; } @@ -782,9 +774,10 @@ private string getRealm () private ServerSslConfiguration getSslConfiguration () { - return _secure && _sslConfig != null - ? new ServerSslConfiguration (_sslConfig) - : null; + if (_sslConfig == null) + _sslConfig = new ServerSslConfiguration (); + + return _sslConfig; } private void init ( @@ -1322,11 +1315,15 @@ public bool RemoveWebSocketService (string path) /// public void Start () { - var sslConfig = getSslConfiguration (); + ServerSslConfiguration sslConfig = null; - string msg; - if (!checkSslConfiguration (sslConfig, out msg)) - throw new InvalidOperationException (msg); + if (_secure) { + sslConfig = new ServerSslConfiguration (getSslConfiguration ()); + + string msg; + if (!checkSslConfiguration (sslConfig, out msg)) + throw new InvalidOperationException (msg); + } start (sslConfig); } From 6a127ca5715de3dfa53a7702552e280d4457de9e Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 20 Oct 2017 15:39:53 +0900 Subject: [PATCH 1593/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 0dd0a0910..ca4eb2527 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -1298,13 +1298,7 @@ public bool RemoveWebSocketService (string path) /// /// /// - /// There is no configuration for secure connections. - /// - /// - /// -or- - /// - /// - /// There is no certificate in the configuration. + /// There is no server certificate for secure connections. /// /// /// -or- From 5221933e32ad4f0926b51f3b863067d8ca20359b Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 21 Oct 2017 13:31:20 +0900 Subject: [PATCH 1594/6294] [Modify] Replace it --- websocket-sharp/Server/WebSocketServer.cs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index ca4eb2527..7e1d4df57 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -599,10 +599,7 @@ public ServerSslConfiguration SslConfiguration { throw new InvalidOperationException (msg); } - if (_sslConfig == null) - _sslConfig = new ServerSslConfiguration (); - - return _sslConfig; + return getSslConfiguration (); } } From e1e40f97de02eec52670bbb00f08b0f6a68c12d6 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 21 Oct 2017 13:52:59 +0900 Subject: [PATCH 1595/6294] [Modify] Polish them --- websocket-sharp/Server/HttpServer.cs | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 124d0b151..6241a689e 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -834,9 +834,6 @@ private bool checkCertificate (out string message) { message = null; - if (!_secure) - return true; - var byUser = _listener.SslConfiguration.ServerCertificate != null; var path = _listener.CertificateFolderPath; @@ -844,13 +841,13 @@ private bool checkCertificate (out string message) var both = byUser && withPort; if (both) { - _log.Warn ("The certificate associated with the port will be used."); + _log.Warn ("A server certificate associated with the port is used."); return true; } var either = byUser || withPort; if (!either) { - message = "There is no certificate used to authenticate the server."; + message = "There is no server certificate for secure connections."; return false; } @@ -1475,9 +1472,11 @@ public bool RemoveWebSocketService (string path) /// public void Start () { - string msg; - if (!checkCertificate (out msg)) - throw new InvalidOperationException (msg); + if (_secure) { + string msg; + if (!checkCertificate (out msg)) + throw new InvalidOperationException (msg); + } start (); } From 838e01d6e1c3f332713d5b5d83ac882ecc448098 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 22 Oct 2017 17:32:33 +0900 Subject: [PATCH 1596/6294] [Modify] Edit it --- websocket-sharp/Server/HttpServer.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 6241a689e..95043dcc8 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -1456,12 +1456,12 @@ public bool RemoveWebSocketService (string path) /// Starts receiving incoming requests. /// /// - /// This method does nothing if the server has already - /// started or it is shutting down. + /// This method does nothing if the server has already started or + /// it is shutting down. /// /// /// - /// There is no certificate used to authenticate the server. + /// There is no server certificate for secure connections. /// /// /// -or- From d058df9b1e50dce8b86139ddc228858c067e432d Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 23 Oct 2017 16:07:25 +0900 Subject: [PATCH 1597/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 1b32a2f77..8289a8ef4 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -349,7 +349,7 @@ public CompressionMethod Compression { string msg = null; if (!_client) { - msg = "The set operation cannot be used by servers."; + msg = "This instance is not a client."; throw new InvalidOperationException (msg); } From b69c255e6eb3786cf8341bb45bf1be2dd653f234 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 23 Oct 2017 16:14:35 +0900 Subject: [PATCH 1598/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 8289a8ef4..d71b01a4d 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -338,7 +338,7 @@ internal bool IsConnected { /// /// /// - /// The set operation cannot be used by servers. + /// The set operation is not available if this instance is not a client. /// public CompressionMethod Compression { get { From 903dd2fc36931a2d1ea7284015985a813a696ebf Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 23 Oct 2017 16:19:32 +0900 Subject: [PATCH 1599/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index d71b01a4d..eb086310a 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -445,7 +445,7 @@ public bool EnableRedirection { string msg = null; if (!_client) { - msg = "The set operation cannot be used by servers."; + msg = "This instance is not a client."; throw new InvalidOperationException (msg); } From e8697400717c11c77bc560473b444f61951ba5ff Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 24 Oct 2017 15:39:53 +0900 Subject: [PATCH 1600/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index eb086310a..b912525a2 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -434,7 +434,7 @@ public bool EmitOnPing { /// /// /// - /// The set operation cannot be used by servers. + /// The set operation is not available if this instance is not a client. /// public bool EnableRedirection { get { From 8ea62153a8a3cfcb661744d9dec231b3f8ff2d49 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 24 Oct 2017 15:48:28 +0900 Subject: [PATCH 1601/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index b912525a2..65b723fd8 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -702,7 +702,7 @@ public Uri Url { /// A to wait for the response. /// /// - /// The default value is the same as 5 seconds if the instance is + /// The default value is the same as 5 seconds if this instance is /// a client. /// /// From e374205aec25f76bdc0b27d6f242a10b488cd99b Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 24 Oct 2017 15:57:06 +0900 Subject: [PATCH 1602/6294] [Modify] Add it --- websocket-sharp/WebSocket.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 65b723fd8..f3f791361 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1441,6 +1441,14 @@ private void fatal (string message, CloseStatusCode code) fatal (message, (ushort) code); } + private ClientSslConfiguration getSslConfiguration () + { + if (_sslConfig == null) + _sslConfig = new ClientSslConfiguration (_uri.DnsSafeHost); + + return _sslConfig; + } + private void init () { _compression = CompressionMethod.None; From dfbab48c0192b3e56573c9e495fabbcfcba5d575 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 24 Oct 2017 16:02:01 +0900 Subject: [PATCH 1603/6294] [Modify] Replace it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index f3f791361..2300661a1 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2078,7 +2078,7 @@ private void setClientStream () } if (_secure) { - var conf = SslConfiguration; + var conf = getSslConfiguration (); var host = conf.TargetHost; if (host != _uri.DnsSafeHost) throw new WebSocketException ( From 83757de06084672390e94cc3dfe39a18e2c2612f Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 25 Oct 2017 17:08:33 +0900 Subject: [PATCH 1604/6294] [Modify] Replace it --- websocket-sharp/WebSocket.cs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 2300661a1..835f7cc89 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -671,10 +671,7 @@ public ClientSslConfiguration SslConfiguration { throw new InvalidOperationException (msg); } - if (_sslConfig == null) - _sslConfig = new ClientSslConfiguration (_uri.DnsSafeHost); - - return _sslConfig; + return getSslConfiguration (); } } From 16e0257d13d738cf4771df47876fd78f5b13f23f Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 25 Oct 2017 17:26:53 +0900 Subject: [PATCH 1605/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 835f7cc89..516a97dd3 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -491,10 +491,10 @@ public bool IsAlive { } /// - /// Gets a value indicating whether the WebSocket connection is secure. + /// Gets a value indicating whether a secure connection is used. /// /// - /// true if the connection is secure; otherwise, false. + /// true if a secure connection is used; otherwise, false. /// public bool IsSecure { get { From 9abe3e0c890854d1ec715cba5ac73d9841e50352 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 25 Oct 2017 17:52:06 +0900 Subject: [PATCH 1606/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 7e1d4df57..490613df3 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -420,12 +420,11 @@ public bool IsListening { } /// - /// Gets a value indicating whether the server provides - /// secure connections. + /// Gets a value indicating whether secure connections are provided. /// /// - /// true if the server provides secure connections; - /// otherwise, false. + /// true if this instance provides secure connections; otherwise, + /// false. /// public bool IsSecure { get { From f79a66ac05510df0cf24bb0a8ad8aad8135cf780 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 25 Oct 2017 17:57:07 +0900 Subject: [PATCH 1607/6294] [Modify] Edit it --- websocket-sharp/Server/HttpServer.cs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 95043dcc8..30b9d79ac 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -459,12 +459,11 @@ public bool IsListening { } /// - /// Gets a value indicating whether the server provides - /// secure connections. + /// Gets a value indicating whether secure connections are provided. /// /// - /// true if the server provides secure connections; - /// otherwise, false. + /// true if this instance provides secure connections; otherwise, + /// false. /// public bool IsSecure { get { From 3eaa7d8f602922c816eb05488f69bd8547056e7e Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 26 Oct 2017 14:49:18 +0900 Subject: [PATCH 1608/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 516a97dd3..593a33324 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -494,7 +494,8 @@ public bool IsAlive { /// Gets a value indicating whether a secure connection is used. /// /// - /// true if a secure connection is used; otherwise, false. + /// true if this instance uses a secure connection; otherwise, + /// false. /// public bool IsSecure { get { From b5fdf85b90640a9600e37ac6d6533c1f02231b4b Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 27 Oct 2017 17:27:22 +0900 Subject: [PATCH 1609/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 593a33324..3a9eae615 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -198,11 +198,17 @@ internal WebSocket (TcpListenerWebSocketContext context, string protocol) /// /// Initializes a new instance of the class with - /// and . + /// and optionally . /// /// - /// A that specifies the URL of the WebSocket - /// server to connect. + /// + /// A that specifies the URL of the WebSocket + /// server to connect. + /// + /// + /// The new instance uses a secure connection if the scheme of + /// the URL is wss. + /// /// /// /// From 0a583e5d20e9aaaaaead150ddbda0aec44a8271d Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 27 Oct 2017 17:34:23 +0900 Subject: [PATCH 1610/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 3a9eae615..cf25c8a60 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2,8 +2,6 @@ /* * WebSocket.cs * - * A C# implementation of the WebSocket interface. - * * This code is derived from WebSocket.java * (http://github.com/adamac/Java-WebSocket-client). * From 8231649bb6b80264c981857f270ad99793563d46 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 28 Oct 2017 17:58:14 +0900 Subject: [PATCH 1611/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index cf25c8a60..a8de69eda 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -59,8 +59,14 @@ namespace WebSocketSharp /// Implements the WebSocket interface. /// /// - /// The WebSocket class provides a set of methods and properties for two-way communication using - /// the WebSocket protocol (RFC 6455). + /// + /// This class provides a set of methods and properties for two-way + /// communication using the WebSocket protocol. + /// + /// + /// The WebSocket protocol is defined in + /// RFC 6455. + /// /// public class WebSocket : IDisposable { From 9649ecb6ec3bb77b13792292ac7f97581f31db55 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 29 Oct 2017 17:52:39 +0900 Subject: [PATCH 1612/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index a8de69eda..3a83191a8 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -687,10 +687,10 @@ public ClientSslConfiguration SslConfiguration { } /// - /// Gets the WebSocket URL used to connect, or accepted. + /// Gets the URL to which to connect. /// /// - /// A that represents the URL used to connect, or accepted. + /// A that represents the URL to which to connect. /// public Uri Url { get { From 34e93539628f58d58a8120453891cbc962ef0033 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 30 Oct 2017 15:45:09 +0900 Subject: [PATCH 1613/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 3a83191a8..bb4c72996 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -206,12 +206,13 @@ internal WebSocket (TcpListenerWebSocketContext context, string protocol) /// /// /// - /// A that specifies the URL of the WebSocket - /// server to connect. + /// A that specifies the URL to which to connect. /// /// - /// The new instance uses a secure connection if the scheme of - /// the URL is wss. + /// The scheme of the URL must be ws or wss. + /// + /// + /// The new instance uses a secure connection if the scheme is wss. /// /// /// From bcf8c87d6245e6526ea74fabc19049bdeca88e29 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 30 Oct 2017 16:15:52 +0900 Subject: [PATCH 1614/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index bb4c72996..986d79b2f 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -639,12 +639,18 @@ internal set { } /// - /// Gets the state of the WebSocket connection. + /// Gets the current state of the connection. /// /// - /// One of the enum values that indicates - /// the current state of the connection. The default value is - /// . + /// + /// One of the enum values. + /// + /// + /// It indicates the current state of the connection. + /// + /// + /// The default value is . + /// /// public WebSocketState ReadyState { get { From 3229d8e38a932b5afbb1e54f8d309724e9ee310a Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 31 Oct 2017 17:27:28 +0900 Subject: [PATCH 1615/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 986d79b2f..ad6a0a716 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -622,11 +622,11 @@ public string Origin { } /// - /// Gets the WebSocket subprotocol selected by the server. + /// Gets the name of the subprotocol selected by server. /// /// - /// A that represents the subprotocol if any. - /// The default value is . + /// A that will be one of the names of the subprotocols + /// specified by client or an empty string if not specified or selected. /// public string Protocol { get { From f6405621e61360018b63f6ab4924d51e7a6eebc9 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 31 Oct 2017 17:34:12 +0900 Subject: [PATCH 1616/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index ad6a0a716..6114a2045 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -515,15 +515,13 @@ public bool IsSecure { } /// - /// Gets the logging functions. + /// Gets the logging function. /// /// - /// The default logging level is . If you would like to change it, - /// you should set this Log.Level property to any of the enum - /// values. + /// The default logging level is . /// /// - /// A that provides the logging functions. + /// A that provides the logging function. /// public Logger Log { get { From ff2ff50a1997c4f71cc59d26267a545474e6a6b2 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 1 Nov 2017 14:38:33 +0900 Subject: [PATCH 1617/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 6114a2045..daea8dde1 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -477,11 +477,12 @@ public bool EnableRedirection { } /// - /// Gets the WebSocket extensions selected by the server. + /// Gets the extensions selected by server. /// /// - /// A that represents the extensions if any. - /// The default value is . + /// A that will be a list of the extensions + /// negotiated between client and server, or an empty string if + /// not specified or selected. /// public string Extensions { get { From 2fae4be285735b47ddc0f7f28f19b05023a50410 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 1 Nov 2017 15:45:13 +0900 Subject: [PATCH 1618/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index daea8dde1..fcd24353c 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -491,8 +491,12 @@ public string Extensions { } /// - /// Gets a value indicating whether the WebSocket connection is alive. + /// Gets a value indicating whether the connection is alive. /// + /// + /// The get operation returns the value by using a ping/pong + /// if the current state of the connection is Open. + /// /// /// true if the connection is alive; otherwise, false. /// From b8e6aa44ce803d6d649f55f5641524fc8c0f9361 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 2 Nov 2017 15:07:39 +0900 Subject: [PATCH 1619/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index fcd24353c..4537bc3ba 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -410,12 +410,17 @@ public NetworkCredential Credentials { } /// - /// Gets or sets a value indicating whether the emits - /// a event when receives a ping. + /// Gets or sets a value indicating whether a event + /// is emitted when a ping is received. /// /// - /// true if the emits a event - /// when receives a ping; otherwise, false. The default value is false. + /// + /// true if this instance emits a event + /// when receives a ping; otherwise, false. + /// + /// + /// The default value is false. + /// /// public bool EmitOnPing { get { From e27221737e501291a5be820585dc8c195ddc3c87 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 2 Nov 2017 15:28:55 +0900 Subject: [PATCH 1620/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 4537bc3ba..9ae7ff63e 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -400,8 +400,13 @@ public IEnumerable Cookies { /// Gets the credentials for the HTTP authentication (Basic/Digest). /// /// - /// A that represents the credentials for - /// the authentication. The default value is . + /// + /// A that represents the credentials + /// used to authenticate the client. + /// + /// + /// The default value is . + /// /// public NetworkCredential Credentials { get { From 7bfe82aa2e7da27e01121811c7c750e2c6cf9f02 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 3 Nov 2017 16:25:21 +0900 Subject: [PATCH 1621/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 9ae7ff63e..9e4ca2821 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -390,9 +390,10 @@ public CompressionMethod Compression { /// public IEnumerable Cookies { get { - lock (_cookies.SyncRoot) + lock (_cookies.SyncRoot) { foreach (Cookie cookie in _cookies) yield return cookie; + } } } From 4de269b5224b4bcc6be30e902175df3f3cb9324b Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 4 Nov 2017 17:02:07 +0900 Subject: [PATCH 1622/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 9e4ca2821..5bc60a7b9 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -381,12 +381,17 @@ public CompressionMethod Compression { } /// - /// Gets the HTTP cookies included in the WebSocket handshake request and response. + /// Gets the HTTP cookies included in the handshake request/response. /// /// - /// An - /// instance that provides an enumerator which supports the iteration over the collection of - /// the cookies. + /// + /// An + /// instance. + /// + /// + /// It provides an enumerator which supports the iteration over + /// the collection of the cookies. + /// /// public IEnumerable Cookies { get { From 21e9bd225b901ff43400eb8e1ff6a5d80619a4e8 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 4 Nov 2017 17:06:18 +0900 Subject: [PATCH 1623/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 5bc60a7b9..71e189328 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -342,7 +342,7 @@ internal bool IsConnected { /// One of the enum values. /// /// - /// It represents the compression method used to compress a message. + /// It specifies the compression method used to compress a message. /// /// /// The default value is . From b9d482cecaf5b85a50b4d8bef2a8f102020ea55c Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 4 Nov 2017 17:14:08 +0900 Subject: [PATCH 1624/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 71e189328..03c8ad440 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -453,8 +453,8 @@ public bool EmitOnPing { /// /// /// - /// true if the URL redirection for the handshake request is - /// allowed; otherwise, false. + /// true if this instance allows the URL redirection for + /// the handshake request; otherwise, false. /// /// /// The default value is false. From a1a09b3462dd167b47440bce48363b8da48c31f5 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 4 Nov 2017 17:19:14 +0900 Subject: [PATCH 1625/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 03c8ad440..a54b169d3 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -645,7 +645,7 @@ public string Origin { /// /// /// A that will be one of the names of the subprotocols - /// specified by client or an empty string if not specified or selected. + /// specified by client, or an empty string if not specified or selected. /// public string Protocol { get { From db3ed340e70bb44018f5bcfec42dd300ec02bc8c Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 5 Nov 2017 17:22:39 +0900 Subject: [PATCH 1626/6294] [Modify] Throw exceptions --- websocket-sharp/WebSocket.cs | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index a54b169d3..fb7a372aa 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3716,26 +3716,24 @@ public void SendAsync (Stream stream, int length, Action completed) /// public void SetCookie (Cookie cookie) { - string msg; - if (!checkIfAvailable (true, false, true, false, false, true, out msg)) { - _logger.Error (msg); - error ("An error has occurred in setting a cookie.", null); + string msg = null; - return; + if (!_client) { + msg = "This instance is not a client."; + throw new InvalidOperationException (msg); } - if (cookie == null) { - _logger.Error ("'cookie' is null."); - error ("An error has occurred in setting a cookie.", null); + if (cookie == null) + throw new ArgumentNullException ("cookie"); + if (!canSet (out msg)) { + _logger.Warn (msg); return; } lock (_forState) { - if (!checkIfAvailable (true, false, false, true, out msg)) { - _logger.Error (msg); - error ("An error has occurred in setting a cookie.", null); - + if (!canSet (out msg)) { + _logger.Warn (msg); return; } From db696c2249e8858f131f033d42df0caf90547299 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 6 Nov 2017 15:40:00 +0900 Subject: [PATCH 1627/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index fb7a372aa..46ea4fadc 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3705,15 +3705,21 @@ public void SendAsync (Stream stream, int length, Action completed) } /// - /// Sets an HTTP to send with - /// the WebSocket handshake request to the server. + /// Sets an HTTP cookie to send with the handshake request. /// /// - /// This method is not available in a server. + /// This method does nothing if the connection has already been + /// established or it is closing. /// /// - /// A that represents a cookie to send. + /// A that represents the cookie to send. /// + /// + /// This instance is not a client. + /// + /// + /// is . + /// public void SetCookie (Cookie cookie) { string msg = null; From d022eba6a1368f96ab89fa6b30731c52f69d4b93 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 7 Nov 2017 15:01:16 +0900 Subject: [PATCH 1628/6294] [Modify] Throw exceptions --- websocket-sharp/WebSocket.cs | 42 ++++++++++++++++++++++++------------ 1 file changed, 28 insertions(+), 14 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 46ea4fadc..4cd8f5adf 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3775,38 +3775,52 @@ public void SetCookie (Cookie cookie) /// public void SetCredentials (string username, string password, bool preAuth) { - string msg; - if (!checkIfAvailable (true, false, true, false, false, true, out msg)) { - _logger.Error (msg); - error ("An error has occurred in setting the credentials.", null); + string msg = null; - return; + if (!_client) { + msg = "This instance is not a client."; + throw new InvalidOperationException (msg); } - if (!checkParametersForSetCredentials (username, password, out msg)) { - _logger.Error (msg); - error ("An error has occurred in setting the credentials.", null); + if (!username.IsNullOrEmpty ()) { + if (username.Contains (':') || !username.IsText ()) { + msg = "It contains an invalid character."; + throw new ArgumentException (msg, "username"); + } + } + + if (!password.IsNullOrEmpty ()) { + if (!password.IsText ()) { + msg = "It contains an invalid character."; + throw new ArgumentException (msg, "password"); + } + } + if (!canSet (out msg)) { + _logger.Warn (msg); return; } lock (_forState) { - if (!checkIfAvailable (true, false, false, true, out msg)) { - _logger.Error (msg); - error ("An error has occurred in setting the credentials.", null); - + if (!canSet (out msg)) { + _logger.Warn (msg); return; } if (username.IsNullOrEmpty ()) { - _logger.Warn ("The credentials are initialized."); + msg = "The credentials are initialized."; + _logger.Warn (msg); + _credentials = null; _preAuth = false; return; } - _credentials = new NetworkCredential (username, password, _uri.PathAndQuery); + _credentials = new NetworkCredential ( + username, password, _uri.PathAndQuery + ); + _preAuth = preAuth; } } From f3751d6e00e0ae26fb712173dc49f24c06e73359 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 8 Nov 2017 16:32:18 +0900 Subject: [PATCH 1629/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 41 ++++++++++++++++++++++++------------ 1 file changed, 28 insertions(+), 13 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 4cd8f5adf..ded35adae 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3749,30 +3749,45 @@ public void SetCookie (Cookie cookie) } /// - /// Sets a pair of and for - /// the HTTP authentication (Basic/Digest). + /// Sets the credentials for the HTTP authentication (Basic/Digest). /// /// - /// This method is not available in a server. - /// - /// /// - /// A that represents the user name used to authenticate. + /// The credentials are initialized if is + /// or an empty string. /// /// - /// If is or empty, - /// the credentials will be initialized and not be sent. + /// This method does nothing if the connection has already been + /// established or it is closing. /// + /// + /// + /// A that represents the username associated with + /// the credentials. /// /// - /// A that represents the password for - /// used to authenticate. + /// A that represents the password for the username + /// associated with the credentials. /// /// - /// true if the sends the credentials for - /// the Basic authentication with the first handshake request to the server; - /// otherwise, false. + /// true if this instance sends the credentials for the Basic + /// authentication with the first handshake request before receiving + /// an authentication challenge; otherwise, false. /// + /// + /// This instance is not a client. + /// + /// + /// + /// contains an invalid character. + /// + /// + /// -or- + /// + /// + /// contains an invalid character. + /// + /// public void SetCredentials (string username, string password, bool preAuth) { string msg = null; From 018b73d82af7871acff0c782441eaa200f730035 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 8 Nov 2017 16:35:20 +0900 Subject: [PATCH 1630/6294] [Modify] Remove it --- websocket-sharp/WebSocket.cs | 25 ------------------------- 1 file changed, 25 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index ded35adae..a05069026 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1017,31 +1017,6 @@ out string message return checkIfAvailable (connecting, open, closing, closed, out message); } - private static bool checkParametersForSetCredentials ( - string username, string password, out string message - ) - { - message = null; - - if (username.IsNullOrEmpty ()) - return true; - - if (username.Contains (':') || !username.IsText ()) { - message = "'username' contains an invalid character."; - return false; - } - - if (password.IsNullOrEmpty ()) - return true; - - if (!password.IsText ()) { - message = "'password' contains an invalid character."; - return false; - } - - return true; - } - private static bool checkParametersForSetProxy ( string url, string username, string password, out string message ) From 7a9899e064859a2c88bf2458e335a5bdc76812ca Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 9 Nov 2017 16:38:56 +0900 Subject: [PATCH 1631/6294] [Modify] Throw exceptions --- websocket-sharp/WebSocket.cs | 78 ++++++++++++++++++++++-------------- 1 file changed, 49 insertions(+), 29 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index a05069026..5b533138e 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3850,50 +3850,70 @@ public void SetCredentials (string username, string password, bool preAuth) /// public void SetProxy (string url, string username, string password) { - string msg; - if (!checkIfAvailable (true, false, true, false, false, true, out msg)) { - _logger.Error (msg); - error ("An error has occurred in setting the proxy.", null); + string msg = null; - return; + if (!_client) { + msg = "This instance is not a client."; + throw new InvalidOperationException (msg); } - if (!checkParametersForSetProxy (url, username, password, out msg)) { - _logger.Error (msg); - error ("An error has occurred in setting the proxy.", null); + if (url == null) + throw new ArgumentNullException ("url"); - return; - } + if (url.Length == 0) + throw new ArgumentException ("An empty string.", "url"); - lock (_forState) { - if (!checkIfAvailable (true, false, false, true, out msg)) { - _logger.Error (msg); - error ("An error has occurred in setting the proxy.", null); + Uri uri; + if (!Uri.TryCreate (url, UriKind.Absolute, out uri)) { + msg = "Not an absolute URI string."; + throw new ArgumentException (msg, "url"); + } - return; - } + if (uri.Scheme != "http") { + msg = "The scheme part is not http."; + throw new ArgumentException (msg, "url"); + } - if (url.IsNullOrEmpty ()) { - _logger.Warn ("The url and credentials for the proxy are initialized."); - _proxyUri = null; - _proxyCredentials = null; + if (uri.Segments.Length > 1) { + msg = "It includes the path segments."; + throw new ArgumentException (msg, "url"); + } - return; + if (!username.IsNullOrEmpty ()) { + if (username.Contains (':') || !username.IsText ()) { + msg = "It contains an invalid character."; + throw new ArgumentException (msg, "username"); } + } - _proxyUri = new Uri (url); + if (!password.IsNullOrEmpty ()) { + if (!password.IsText ()) { + msg = "It contains an invalid character."; + throw new ArgumentException (msg, "password"); + } + } - if (username.IsNullOrEmpty ()) { - _logger.Warn ("The credentials for the proxy are initialized."); - _proxyCredentials = null; + if (!canSet (out msg)) { + _logger.Warn (msg); + return; + } + lock (_forState) { + if (!canSet (out msg)) { + _logger.Warn (msg); return; } - _proxyCredentials = - new NetworkCredential ( - username, password, String.Format ("{0}:{1}", _uri.DnsSafeHost, _uri.Port) - ); + _proxyUri = uri; + _proxyCredentials = !username.IsNullOrEmpty () + ? new NetworkCredential ( + username, + password, + String.Format ( + "{0}:{1}", _uri.DnsSafeHost, _uri.Port + ) + ) + : null; } } From 9127a42c43705f1afc99aa0ce8ea4d13fd6823cf Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 10 Nov 2017 17:57:46 +0900 Subject: [PATCH 1632/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 75 ++++++++++++++++++++++++++++-------- 1 file changed, 60 insertions(+), 15 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 5b533138e..731f4b0f9 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3816,38 +3816,83 @@ public void SetCredentials (string username, string password, bool preAuth) } /// - /// Sets the HTTP proxy server URL to connect through, and if necessary, - /// a pair of and for - /// the proxy server authentication (Basic/Digest). + /// Sets the HTTP proxy server URL through which to connect and + /// the credentials for the HTTP authentication (Basic/Digest) by + /// the proxy server. /// /// - /// This method is not available in a server. + /// This method does nothing if the connection has already been + /// established or it is closing. /// /// /// - /// A that represents the HTTP proxy server URL to - /// connect through. The syntax must be http://<host>[:<port>]. + /// A that represents the proxy server URL through + /// which to connect. /// /// - /// If is or empty, - /// the url and credentials for the proxy will be initialized, - /// and the will not use the proxy to - /// connect through. + /// The syntax is http://<host>[:<port>]. /// /// /// /// - /// A that represents the user name used to authenticate. + /// A that represents the username associated with + /// the credentials. /// /// - /// If is or empty, - /// the credentials for the proxy will be initialized and not be sent. + /// or an empty string if the credentials are not + /// necessary. /// /// /// - /// A that represents the password for - /// used to authenticate. + /// + /// A that represents the password for the username + /// associated with the credentials. + /// + /// + /// or an empty string if not necessary. + /// /// + /// + /// This instance is not a client. + /// + /// + /// is . + /// + /// + /// + /// is an empty string. + /// + /// + /// -or- + /// + /// + /// is not an absolute URI string. + /// + /// + /// -or- + /// + /// + /// The scheme of is not http. + /// + /// + /// -or- + /// + /// + /// includes the path segments. + /// + /// + /// -or- + /// + /// + /// contains an invalid character. + /// + /// + /// -or- + /// + /// + /// contains an invalid character. + /// + /// public void SetProxy (string url, string username, string password) { string msg = null; From 5bbb5bb2f46bd2c89795f4abe476bb306fe4c87f Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 11 Nov 2017 15:47:16 +0900 Subject: [PATCH 1633/6294] [Modify] Remove it --- websocket-sharp/WebSocket.cs | 37 ------------------------------------ 1 file changed, 37 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 731f4b0f9..0ec6a0e58 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1017,43 +1017,6 @@ out string message return checkIfAvailable (connecting, open, closing, closed, out message); } - private static bool checkParametersForSetProxy ( - string url, string username, string password, out string message - ) - { - message = null; - - if (url.IsNullOrEmpty ()) - return true; - - Uri uri; - if (!Uri.TryCreate (url, UriKind.Absolute, out uri) - || uri.Scheme != "http" - || uri.Segments.Length > 1 - ) { - message = "'url' is an invalid URL."; - return false; - } - - if (username.IsNullOrEmpty ()) - return true; - - if (username.Contains (':') || !username.IsText ()) { - message = "'username' contains an invalid character."; - return false; - } - - if (password.IsNullOrEmpty ()) - return true; - - if (!password.IsText ()) { - message = "'password' contains an invalid character."; - return false; - } - - return true; - } - private static bool checkProtocols (string[] protocols, out string message) { message = null; From 1ae5fdfeaacc6d11a403417c7601f9c2ca764a8e Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 11 Nov 2017 15:52:01 +0900 Subject: [PATCH 1634/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 3 --- 1 file changed, 3 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 0ec6a0e58..bd6eb4f64 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3761,9 +3761,6 @@ public void SetCredentials (string username, string password, bool preAuth) } if (username.IsNullOrEmpty ()) { - msg = "The credentials are initialized."; - _logger.Warn (msg); - _credentials = null; _preAuth = false; From 0d3be42f00c59b096a09d6b76f12530e5c54292c Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 12 Nov 2017 16:07:52 +0900 Subject: [PATCH 1635/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index bd6eb4f64..c27bdbe90 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3690,27 +3690,31 @@ public void SetCookie (Cookie cookie) /// Sets the credentials for the HTTP authentication (Basic/Digest). /// /// + /// This method does nothing if the connection has already been + /// established or it is closing. + /// + /// /// - /// The credentials are initialized if is - /// or an empty string. + /// A that represents the username associated with + /// the credentials. /// /// - /// This method does nothing if the connection has already been - /// established or it is closing. + /// or an empty string if initializes + /// the credentials. /// - /// - /// - /// A that represents the username associated with - /// the credentials. /// /// - /// A that represents the password for the username - /// associated with the credentials. + /// + /// A that represents the password for the username + /// associated with the credentials. + /// + /// + /// or an empty string if not necessary. + /// /// /// - /// true if this instance sends the credentials for the Basic - /// authentication with the first handshake request before receiving - /// an authentication challenge; otherwise, false. + /// true if sends the credentials for the Basic authentication in + /// advance with the first handshake request; otherwise, false. /// /// /// This instance is not a client. From fdfc1275300aa8159a4d843ce3a8093164e4a7b7 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 13 Nov 2017 15:08:56 +0900 Subject: [PATCH 1636/6294] [Modify] Polish it To initialize. --- websocket-sharp/WebSocket.cs | 38 ++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index c27bdbe90..2920dcafc 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3866,26 +3866,23 @@ public void SetProxy (string url, string username, string password) throw new InvalidOperationException (msg); } - if (url == null) - throw new ArgumentNullException ("url"); - - if (url.Length == 0) - throw new ArgumentException ("An empty string.", "url"); + Uri uri = null; - Uri uri; - if (!Uri.TryCreate (url, UriKind.Absolute, out uri)) { - msg = "Not an absolute URI string."; - throw new ArgumentException (msg, "url"); - } + if (!url.IsNullOrEmpty ()) { + if (!Uri.TryCreate (url, UriKind.Absolute, out uri)) { + msg = "Not an absolute URI string."; + throw new ArgumentException (msg, "url"); + } - if (uri.Scheme != "http") { - msg = "The scheme part is not http."; - throw new ArgumentException (msg, "url"); - } + if (uri.Scheme != "http") { + msg = "The scheme part is not http."; + throw new ArgumentException (msg, "url"); + } - if (uri.Segments.Length > 1) { - msg = "It includes the path segments."; - throw new ArgumentException (msg, "url"); + if (uri.Segments.Length > 1) { + msg = "It includes the path segments."; + throw new ArgumentException (msg, "url"); + } } if (!username.IsNullOrEmpty ()) { @@ -3913,6 +3910,13 @@ public void SetProxy (string url, string username, string password) return; } + if (url.IsNullOrEmpty ()) { + _proxyUri = null; + _proxyCredentials = null; + + return; + } + _proxyUri = uri; _proxyCredentials = !username.IsNullOrEmpty () ? new NetworkCredential ( From 222077ae1db0d594b387b6f0122d1e56610a6c91 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 14 Nov 2017 15:19:56 +0900 Subject: [PATCH 1637/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 2920dcafc..12aaefe5c 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3780,9 +3780,8 @@ public void SetCredentials (string username, string password, bool preAuth) } /// - /// Sets the HTTP proxy server URL through which to connect and - /// the credentials for the HTTP authentication (Basic/Digest) by - /// the proxy server. + /// Sets the URL of the HTTP proxy server through which to connect and + /// the credentials for the HTTP proxy authentication (Basic/Digest). /// /// /// This method does nothing if the connection has already been @@ -3790,12 +3789,16 @@ public void SetCredentials (string username, string password, bool preAuth) /// /// /// - /// A that represents the proxy server URL through - /// which to connect. + /// A that represents the URL of the proxy server + /// through which to connect. /// /// /// The syntax is http://<host>[:<port>]. /// + /// + /// or an empty string if initializes the URL and + /// the credentials. + /// /// /// /// @@ -3819,17 +3822,8 @@ public void SetCredentials (string username, string password, bool preAuth) /// /// This instance is not a client. /// - /// - /// is . - /// /// /// - /// is an empty string. - /// - /// - /// -or- - /// - /// /// is not an absolute URI string. /// /// From 4299fca67f90ffe11a08214ee60d99b19fa0acab Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 15 Nov 2017 15:55:33 +0900 Subject: [PATCH 1638/6294] [Modify] Throw exception --- websocket-sharp/WebSocket.cs | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 12aaefe5c..492bcd647 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3106,10 +3106,21 @@ public void CloseAsync (CloseStatusCode code, string reason) /// public void Connect () { - string msg; - if (!checkIfAvailable (true, false, true, false, false, true, out msg)) { - _logger.Error (msg); - error ("An error has occurred in connecting.", null); + if (!_client) { + var msg = "This instance is not a client."; + throw new InvalidOperationException (msg); + } + + if (_readyState == WebSocketState.Open) { + var msg = "The connection has already been established."; + _logger.Warn (msg); + + return; + } + + if (_readyState == WebSocketState.Closing) { + var msg = "The close process is in progress."; + _logger.Warn (msg); return; } From ae5398b216803a7e7fe2a19d82e78f267816a4b6 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 15 Nov 2017 16:11:21 +0900 Subject: [PATCH 1639/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 492bcd647..750524f0e 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3099,11 +3099,15 @@ public void CloseAsync (CloseStatusCode code, string reason) } /// - /// Establishes a WebSocket connection. + /// Establishes a connection. /// /// - /// This method is not available in a server. + /// This method does nothing if the current state of the connection is + /// Open or Closing. /// + /// + /// This instance is not a client. + /// public void Connect () { if (!_client) { From 04d8c7f569b3834499f26393bddf6ab7ecd47a85 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 15 Nov 2017 16:16:18 +0900 Subject: [PATCH 1640/6294] [Modify] Throw exception --- websocket-sharp/WebSocket.cs | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 750524f0e..8818633fd 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3146,10 +3146,21 @@ public void Connect () /// public void ConnectAsync () { - string msg; - if (!checkIfAvailable (true, false, true, false, false, true, out msg)) { - _logger.Error (msg); - error ("An error has occurred in connecting.", null); + if (!_client) { + var msg = "This instance is not a client."; + throw new InvalidOperationException (msg); + } + + if (_readyState == WebSocketState.Open) { + var msg = "The connection has already been established."; + _logger.Warn (msg); + + return; + } + + if (_readyState == WebSocketState.Closing) { + var msg = "The close process is in progress."; + _logger.Warn (msg); return; } From 04b29bce21c6ae95ec797bdff786193a0d6ff3ff Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 15 Nov 2017 16:24:54 +0900 Subject: [PATCH 1641/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 8818633fd..a36f0b3b6 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3134,16 +3134,20 @@ public void Connect () } /// - /// Establishes a WebSocket connection asynchronously. + /// Establishes a connection asynchronously. /// /// /// /// This method does not wait for the connect to be complete. /// /// - /// This method is not available in a server. + /// This method does nothing if the current state of the connection is + /// Open or Closing. /// /// + /// + /// This instance is not a client. + /// public void ConnectAsync () { if (!_client) { From bf53fa97d7b32173d68de6e40deca7496f3b24fc Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 16 Nov 2017 15:28:25 +0900 Subject: [PATCH 1642/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index a36f0b3b6..8791fe9c9 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1220,17 +1220,25 @@ private bool closeHandshake ( private bool connect () { lock (_forState) { - string msg; - if (!checkIfAvailable (true, false, false, true, out msg)) { - _logger.Error (msg); - error ("An error has occurred in connecting.", null); + if (_readyState == WebSocketState.Open) { + var msg = "The connection has already been established."; + _logger.Warn (msg); + + return false; + } + + if (_readyState == WebSocketState.Closing) { + var msg = "The close process is in progress."; + _logger.Warn (msg); return false; } if (_retryCountForConnect > _maxRetryCountForConnect) { _retryCountForConnect = 0; - _logger.Fatal ("A series of reconnecting has failed."); + + var msg = "A series of reconnecting has failed."; + _logger.Fatal (msg); return false; } @@ -1242,8 +1250,12 @@ private bool connect () } catch (Exception ex) { _retryCountForConnect++; - _logger.Fatal (ex.ToString ()); - fatal ("An exception has occurred while connecting.", ex); + + _logger.Fatal (ex.Message); + _logger.Debug (ex.ToString ()); + + var msg = "An exception has occurred while connecting."; + fatal (msg, ex); return false; } From 9bce5b03f23e65bc5783ac41b401dce058a055f5 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 17 Nov 2017 16:20:35 +0900 Subject: [PATCH 1643/6294] [Modify] Throw exception --- websocket-sharp/WebSocket.cs | 36 ++++++++++++++---------------------- 1 file changed, 14 insertions(+), 22 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 8791fe9c9..2cfa1d3d2 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1219,6 +1219,13 @@ private bool closeHandshake ( // As client private bool connect () { + if (_readyState == WebSocketState.Open) { + var msg = "The connection has already been established."; + _logger.Warn (msg); + + return false; + } + lock (_forState) { if (_readyState == WebSocketState.Open) { var msg = "The connection has already been established."; @@ -1228,8 +1235,11 @@ private bool connect () } if (_readyState == WebSocketState.Closing) { - var msg = "The close process is in progress."; - _logger.Warn (msg); + var msg = "The close process has set in."; + _logger.Error (msg); + + msg = "An interruption has occurred while attempting to connect."; + error (msg, null); return false; } @@ -3127,18 +3137,9 @@ public void Connect () throw new InvalidOperationException (msg); } - if (_readyState == WebSocketState.Open) { - var msg = "The connection has already been established."; - _logger.Warn (msg); - - return; - } - if (_readyState == WebSocketState.Closing) { var msg = "The close process is in progress."; - _logger.Warn (msg); - - return; + throw new InvalidOperationException (msg); } if (connect ()) @@ -3167,18 +3168,9 @@ public void ConnectAsync () throw new InvalidOperationException (msg); } - if (_readyState == WebSocketState.Open) { - var msg = "The connection has already been established."; - _logger.Warn (msg); - - return; - } - if (_readyState == WebSocketState.Closing) { var msg = "The close process is in progress."; - _logger.Warn (msg); - - return; + throw new InvalidOperationException (msg); } Func connector = connect; From 8e24e07e7599345a9acb298d2cbbfac0eaecbde4 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 18 Nov 2017 15:35:41 +0900 Subject: [PATCH 1644/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 2cfa1d3d2..f1eea1190 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3124,11 +3124,18 @@ public void CloseAsync (CloseStatusCode code, string reason) /// Establishes a connection. /// /// - /// This method does nothing if the current state of the connection is - /// Open or Closing. + /// This method does nothing if the connection has already been established. /// /// - /// This instance is not a client. + /// + /// This instance is not a client. + /// + /// + /// -or- + /// + /// + /// The close process is in progress. + /// /// public void Connect () { From 918d8c4795c7f09a78f4c42f370ae0fe639a53bf Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 18 Nov 2017 15:48:59 +0900 Subject: [PATCH 1645/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index f1eea1190..1fda7d720 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3158,15 +3158,23 @@ public void Connect () /// /// /// - /// This method does not wait for the connect to be complete. + /// This method does not wait for the connect process to be complete. /// /// - /// This method does nothing if the current state of the connection is - /// Open or Closing. + /// This method does nothing if the connection has already been + /// established. /// /// /// - /// This instance is not a client. + /// + /// This instance is not a client. + /// + /// + /// -or- + /// + /// + /// The close process is in progress. + /// /// public void ConnectAsync () { From a3802ec729b4d2043430c03f8d966d9970721a83 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 19 Nov 2017 18:16:26 +0900 Subject: [PATCH 1646/6294] [Modify] Throw exception --- websocket-sharp/WebSocket.cs | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 1fda7d720..54dbf11f2 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1245,10 +1245,11 @@ private bool connect () } if (_retryCountForConnect > _maxRetryCountForConnect) { - _retryCountForConnect = 0; + var msg = "An opportunity for reconnecting has been lost."; + _logger.Error (msg); - var msg = "A series of reconnecting has failed."; - _logger.Fatal (msg); + msg = "An interruption has occurred while attempting to connect."; + error (msg, null); return false; } @@ -3149,6 +3150,11 @@ public void Connect () throw new InvalidOperationException (msg); } + if (_retryCountForConnect > _maxRetryCountForConnect) { + var msg = "A series of reconnecting has failed."; + throw new InvalidOperationException (msg); + } + if (connect ()) open (); } @@ -3188,6 +3194,11 @@ public void ConnectAsync () throw new InvalidOperationException (msg); } + if (_retryCountForConnect > _maxRetryCountForConnect) { + var msg = "A series of reconnecting has failed."; + throw new InvalidOperationException (msg); + } + Func connector = connect; connector.BeginInvoke ( ar => { From 82d555f426caf3cdf333922f4e8e43ed76ae3550 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 20 Nov 2017 15:29:07 +0900 Subject: [PATCH 1647/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 54dbf11f2..6cf22f94b 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3137,6 +3137,12 @@ public void CloseAsync (CloseStatusCode code, string reason) /// /// The close process is in progress. /// + /// + /// -or- + /// + /// + /// A series of reconnecting has failed. + /// /// public void Connect () { From d1e1854fa155b9cf419b9abc06aaa66b24568c60 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 20 Nov 2017 15:32:29 +0900 Subject: [PATCH 1648/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 6cf22f94b..ab78a5c96 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3187,6 +3187,12 @@ public void Connect () /// /// The close process is in progress. /// + /// + /// -or- + /// + /// + /// A series of reconnecting has failed. + /// /// public void ConnectAsync () { From 5b68463a94075d136ac706b92d3974d7de9e1d7b Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 20 Nov 2017 15:49:55 +0900 Subject: [PATCH 1649/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index ab78a5c96..f8f08a2fa 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1265,7 +1265,7 @@ private bool connect () _logger.Fatal (ex.Message); _logger.Debug (ex.ToString ()); - var msg = "An exception has occurred while connecting."; + var msg = "An exception has occurred while attempting to connect."; fatal (msg, ex); return false; From 74f7c090f0763b370b3177cadc300aadd0de2e5f Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 21 Nov 2017 15:53:54 +0900 Subject: [PATCH 1650/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index f8f08a2fa..b8a3f6668 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1412,7 +1412,8 @@ private void error (string message, Exception exception) OnError.Emit (this, new ErrorEventArgs (message, exception)); } catch (Exception ex) { - _logger.Error (ex.ToString ()); + _logger.Error (ex.Message); + _logger.Debug (ex.ToString ()); } } From c00ffc8f7e401715393708cb4c1538684b47c75a Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 22 Nov 2017 15:20:46 +0900 Subject: [PATCH 1651/6294] [Modify] Throw exception --- websocket-sharp/WebSocket.cs | 76 ++++++++++++++++++++++++++++-------- 1 file changed, 59 insertions(+), 17 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index b8a3f6668..e9056b00d 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -800,11 +800,37 @@ public TimeSpan WaitTime { // As server private bool accept () { + if (_readyState == WebSocketState.Open) { + var msg = "The handshake request has already been accepted."; + _logger.Warn (msg); + + return false; + } + lock (_forState) { - string msg; - if (!checkIfAvailable (true, false, false, false, out msg)) { + if (_readyState == WebSocketState.Open) { + var msg = "The handshake request has already been accepted."; + _logger.Warn (msg); + + return false; + } + + if (_readyState == WebSocketState.Closing) { + var msg = "The close process has set in."; _logger.Error (msg); - error ("An error has occurred in accepting.", null); + + msg = "An interruption has occurred while attempting to accept."; + error (msg, null); + + return false; + } + + if (_readyState == WebSocketState.Closed) { + var msg = "The connection has been closed."; + _logger.Error (msg); + + msg = "An interruption has occurred while attempting to accept."; + error (msg, null); return false; } @@ -812,16 +838,18 @@ private bool accept () try { if (!acceptHandshake ()) return false; - - _readyState = WebSocketState.Open; } catch (Exception ex) { - _logger.Fatal (ex.ToString ()); - fatal ("An exception has occurred while accepting.", ex); + _logger.Fatal (ex.Message); + _logger.Debug (ex.ToString ()); + + var msg = "An exception has occurred while attempting to accept."; + fatal (msg, ex); return false; } + _readyState = WebSocketState.Open; return true; } } @@ -2436,12 +2464,19 @@ internal void Send ( /// public void Accept () { - string msg; - if (!checkIfAvailable (false, true, true, false, false, false, out msg)) { - _logger.Error (msg); - error ("An error has occurred in accepting.", null); + if (_client) { + var msg = "This instance is a client."; + throw new InvalidOperationException (msg); + } - return; + if (_readyState == WebSocketState.Closing) { + var msg = "The close process is in progress."; + throw new InvalidOperationException (msg); + } + + if (_readyState == WebSocketState.Closed) { + var msg = "The connection has already been closed."; + throw new InvalidOperationException (msg); } if (accept ()) @@ -2461,12 +2496,19 @@ public void Accept () /// public void AcceptAsync () { - string msg; - if (!checkIfAvailable (false, true, true, false, false, false, out msg)) { - _logger.Error (msg); - error ("An error has occurred in accepting.", null); + if (_client) { + var msg = "This instance is a client."; + throw new InvalidOperationException (msg); + } - return; + if (_readyState == WebSocketState.Closing) { + var msg = "The close process is in progress."; + throw new InvalidOperationException (msg); + } + + if (_readyState == WebSocketState.Closed) { + var msg = "The connection has already been closed."; + throw new InvalidOperationException (msg); } Func acceptor = accept; From 200f996f9f68b3c9b4bcf209be3a5520c9792449 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 22 Nov 2017 15:31:17 +0900 Subject: [PATCH 1652/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index e9056b00d..59ae50b5e 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2457,11 +2457,29 @@ internal void Send ( #region Public Methods /// - /// Accepts the WebSocket handshake request. + /// Accepts the handshake request. /// /// - /// This method is not available in a client. + /// This method does nothing if the handshake request has already been + /// accepted. /// + /// + /// + /// This instance is a client. + /// + /// + /// -or- + /// + /// + /// The close process is in progress. + /// + /// + /// -or- + /// + /// + /// The connection has already been closed. + /// + /// public void Accept () { if (_client) { From 1b4210af0fda1dcda7b28a597f09f11f264bb567 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 22 Nov 2017 15:40:40 +0900 Subject: [PATCH 1653/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 59ae50b5e..d2e5a399c 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2502,16 +2502,34 @@ public void Accept () } /// - /// Accepts the WebSocket handshake request asynchronously. + /// Accepts the handshake request asynchronously. /// /// /// - /// This method does not wait for the accept to be complete. + /// This method does not wait for the accept process to be complete. /// /// - /// This method is not available in a client. + /// This method does nothing if the handshake request has already been + /// accepted. /// /// + /// + /// + /// This instance is a client. + /// + /// + /// -or- + /// + /// + /// The close process is in progress. + /// + /// + /// -or- + /// + /// + /// The connection has already been closed. + /// + /// public void AcceptAsync () { if (_client) { From eb2c76fba9c41b971c81217043dbc877ffb9e0c8 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 22 Nov 2017 15:45:24 +0900 Subject: [PATCH 1654/6294] [Modify] Remove it --- websocket-sharp/WebSocket.cs | 25 ------------------------- 1 file changed, 25 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index d2e5a399c..a11748155 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1020,31 +1020,6 @@ private bool checkIfAvailable ( return true; } - private bool checkIfAvailable ( - bool client, - bool server, - bool connecting, - bool open, - bool closing, - bool closed, - out string message - ) - { - message = null; - - if (!client && _client) { - message = "This operation is not available in: client"; - return false; - } - - if (!server && !_client) { - message = "This operation is not available in: server"; - return false; - } - - return checkIfAvailable (connecting, open, closing, closed, out message); - } - private static bool checkProtocols (string[] protocols, out string message) { message = null; From 74fe94ef052181ccff8c01aeb1be26d484327373 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 22 Nov 2017 15:48:40 +0900 Subject: [PATCH 1655/6294] [Modify] Remove it --- websocket-sharp/WebSocket.cs | 29 ----------------------------- 1 file changed, 29 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index a11748155..dfafa0b1b 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -991,35 +991,6 @@ private bool checkHandshakeResponse (HttpResponse response, out string message) return true; } - private bool checkIfAvailable ( - bool connecting, bool open, bool closing, bool closed, out string message - ) - { - message = null; - - if (!connecting && _readyState == WebSocketState.Connecting) { - message = "This operation is not available in: connecting"; - return false; - } - - if (!open && _readyState == WebSocketState.Open) { - message = "This operation is not available in: open"; - return false; - } - - if (!closing && _readyState == WebSocketState.Closing) { - message = "This operation is not available in: closing"; - return false; - } - - if (!closed && _readyState == WebSocketState.Closed) { - message = "This operation is not available in: closed"; - return false; - } - - return true; - } - private static bool checkProtocols (string[] protocols, out string message) { message = null; From f981eb72870f367b1aec6456d1e81b9704e45463 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 23 Nov 2017 16:34:58 +0900 Subject: [PATCH 1656/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index dfafa0b1b..4eb978b13 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2305,16 +2305,19 @@ internal void InternalAccept () try { if (!acceptHandshake ()) return; - - _readyState = WebSocketState.Open; } catch (Exception ex) { - _logger.Fatal (ex.ToString ()); - fatal ("An exception has occurred while accepting.", ex); + _logger.Fatal (ex.Message); + _logger.Debug (ex.ToString ()); + + var msg = "An exception has occurred while attempting to accept."; + fatal (msg, ex); return; } + _readyState = WebSocketState.Open; + open (); } From f0466795dcdcc306666fe9ce05a9dd15c1215018 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 24 Nov 2017 15:56:43 +0900 Subject: [PATCH 1657/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 4eb978b13..d13bd577e 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -857,23 +857,34 @@ private bool accept () // As server private bool acceptHandshake () { - _logger.Debug (String.Format ("A request from {0}:\n{1}", _context.UserEndPoint, _context)); + var msg = String.Format ( + "A handshake request from {0}:\n{1}", + _context.UserEndPoint, + _context + ); + + _logger.Debug (msg); - string msg; if (!checkHandshakeRequest (_context, out msg)) { - sendHttpResponse (createHandshakeFailureResponse (HttpStatusCode.BadRequest)); + var res = createHandshakeFailureResponse (HttpStatusCode.BadRequest); + sendHttpResponse (res); _logger.Fatal (msg); - fatal ("An error has occurred while accepting.", CloseStatusCode.ProtocolError); + + msg = "A fatal error has occurred while attempting to accept."; + fatal (msg, CloseStatusCode.ProtocolError); return false; } if (!customCheckHandshakeRequest (_context, out msg)) { - sendHttpResponse (createHandshakeFailureResponse (HttpStatusCode.BadRequest)); + var res = createHandshakeFailureResponse (HttpStatusCode.BadRequest); + sendHttpResponse (res); _logger.Fatal (msg); - fatal ("An error has occurred while accepting.", CloseStatusCode.PolicyViolation); + + msg = "A fatal error has occurred while attempting to accept."; + fatal (msg, CloseStatusCode.PolicyViolation); return false; } @@ -883,8 +894,10 @@ private bool acceptHandshake () if (_protocol != null) processSecWebSocketProtocolHeader (_context.SecWebSocketProtocols); - if (!_ignoreExtensions) - processSecWebSocketExtensionsClientHeader (_context.Headers["Sec-WebSocket-Extensions"]); + if (!_ignoreExtensions) { + var val = _context.Headers["Sec-WebSocket-Extensions"]; + processSecWebSocketExtensionsClientHeader (val); + } return sendHttpResponse (createHandshakeResponse ()); } From f557253a8367bcdc0fb393a0ac3618cc86ccab26 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 25 Nov 2017 16:38:38 +0900 Subject: [PATCH 1658/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 47 ++++++++++++++++++++++++------------ 1 file changed, 32 insertions(+), 15 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index d13bd577e..fe376cb69 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -920,43 +920,60 @@ private bool canSet (out string message) } // As server - private bool checkHandshakeRequest (WebSocketContext context, out string message) + private bool checkHandshakeRequest ( + WebSocketContext context, out string message + ) { message = null; - if (context.RequestUri == null) { - message = "Specifies an invalid Request-URI."; + if (!context.IsWebSocketRequest) { + message = "Not a handshake request."; return false; } - if (!context.IsWebSocketRequest) { - message = "Not a WebSocket handshake request."; + if (context.RequestUri == null) { + message = "It specifies an invalid Request-URI."; return false; } var headers = context.Headers; - if (!validateSecWebSocketKeyHeader (headers["Sec-WebSocket-Key"])) { - message = "Includes no Sec-WebSocket-Key header, or it has an invalid value."; + + var key = headers["Sec-WebSocket-Key"]; + if (key == null) { + message = "It includes no Sec-WebSocket-Key header."; return false; } - if (!validateSecWebSocketVersionClientHeader (headers["Sec-WebSocket-Version"])) { - message = "Includes no Sec-WebSocket-Version header, or it has an invalid value."; + if (key.Length == 0) { + message = "It includes an invalid Sec-WebSocket-Key header."; return false; } - if (!validateSecWebSocketProtocolClientHeader (headers["Sec-WebSocket-Protocol"])) { - message = "Includes an invalid Sec-WebSocket-Protocol header."; + var version = headers["Sec-WebSocket-Version"]; + if (version == null) { + message = "It includes no Sec-WebSocket-Version header."; return false; } - if (!_ignoreExtensions - && !validateSecWebSocketExtensionsClientHeader (headers["Sec-WebSocket-Extensions"]) - ) { - message = "Includes an invalid Sec-WebSocket-Extensions header."; + if (!validateSecWebSocketVersionClientHeader (version)) { + message = "It includes an invalid Sec-WebSocket-Version header."; return false; } + var protocol = headers["Sec-WebSocket-Protocol"]; + if (!validateSecWebSocketProtocolClientHeader (protocol)) { + message = "It includes an invalid Sec-WebSocket-Protocol header."; + return false; + } + + if (!_ignoreExtensions) { + var extensions = headers["Sec-WebSocket-Extensions"]; + if (!validateSecWebSocketExtensionsClientHeader (extensions)) { + message = "It includes an invalid Sec-WebSocket-Extensions header."; + return false; + } + } + return true; } From a587d67732a64b5da330383a2d5a53e38ca3ccbf Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 26 Nov 2017 16:48:57 +0900 Subject: [PATCH 1659/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index fe376cb69..a3af817f2 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -955,7 +955,7 @@ private bool checkHandshakeRequest ( return false; } - if (!validateSecWebSocketVersionClientHeader (version)) { + if (version != _version) { message = "It includes an invalid Sec-WebSocket-Version header."; return false; } From 359f932672bc183295e45e3f4853348be9419ad0 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 26 Nov 2017 16:51:42 +0900 Subject: [PATCH 1660/6294] [Modify] Remove it --- websocket-sharp/WebSocket.cs | 6 ------ 1 file changed, 6 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index a3af817f2..7f2bdf047 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2203,12 +2203,6 @@ private bool validateSecWebSocketExtensionsServerHeader (string value) return true; } - // As server - private bool validateSecWebSocketKeyHeader (string value) - { - return value != null && value.Length > 0; - } - // As server private bool validateSecWebSocketProtocolClientHeader (string value) { From a31fc09cf00d346184c7fdee69f5bec22b9835c6 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 26 Nov 2017 16:54:03 +0900 Subject: [PATCH 1661/6294] [Modify] Remove it --- websocket-sharp/WebSocket.cs | 6 ------ 1 file changed, 6 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 7f2bdf047..5249a57a7 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2221,12 +2221,6 @@ private bool validateSecWebSocketProtocolServerHeader (string value) return _protocolsRequested && _protocols.Contains (p => p == value); } - // As server - private bool validateSecWebSocketVersionClientHeader (string value) - { - return value != null && value == _version; - } - // As client private bool validateSecWebSocketVersionServerHeader (string value) { From 8e6040983f4397d4c9e292b825f8f8ff7d588806 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 27 Nov 2017 14:33:46 +0900 Subject: [PATCH 1662/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 5249a57a7..44507b958 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -961,7 +961,7 @@ private bool checkHandshakeRequest ( } var protocol = headers["Sec-WebSocket-Protocol"]; - if (!validateSecWebSocketProtocolClientHeader (protocol)) { + if (protocol != null && protocol.Length == 0) { message = "It includes an invalid Sec-WebSocket-Protocol header."; return false; } From 2cd40af0b09a99cfe060e76957b175ef725bbb17 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 27 Nov 2017 14:34:50 +0900 Subject: [PATCH 1663/6294] [Modify] Remove it --- websocket-sharp/WebSocket.cs | 6 ------ 1 file changed, 6 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 44507b958..a3690cabc 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2203,12 +2203,6 @@ private bool validateSecWebSocketExtensionsServerHeader (string value) return true; } - // As server - private bool validateSecWebSocketProtocolClientHeader (string value) - { - return value == null || value.Length > 0; - } - // As client private bool validateSecWebSocketProtocolServerHeader (string value) { From 909f4914ccfe659b40ae477da07a73e5a5f8da4f Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 27 Nov 2017 14:41:10 +0900 Subject: [PATCH 1664/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index a3690cabc..745a629ca 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -968,7 +968,7 @@ private bool checkHandshakeRequest ( if (!_ignoreExtensions) { var extensions = headers["Sec-WebSocket-Extensions"]; - if (!validateSecWebSocketExtensionsClientHeader (extensions)) { + if (extensions != null && extensions.Length == 0) { message = "It includes an invalid Sec-WebSocket-Extensions header."; return false; } From 09d04cfe8086e826e2e1f68eb33ccd834c62d621 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 27 Nov 2017 14:42:48 +0900 Subject: [PATCH 1665/6294] [Modify] Remove it --- websocket-sharp/WebSocket.cs | 6 ------ 1 file changed, 6 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 745a629ca..8091533ea 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2151,12 +2151,6 @@ private bool validateSecWebSocketAcceptHeader (string value) return value != null && value == CreateResponseKey (_base64Key); } - // As server - private bool validateSecWebSocketExtensionsClientHeader (string value) - { - return value == null || value.Length > 0; - } - // As client private bool validateSecWebSocketExtensionsServerHeader (string value) { From 346b8549d71969a8ea87b5d988ad0dd9040d4c14 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 28 Nov 2017 14:47:17 +0900 Subject: [PATCH 1666/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 8091533ea..5bd20584a 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -866,12 +866,12 @@ private bool acceptHandshake () _logger.Debug (msg); if (!checkHandshakeRequest (_context, out msg)) { + _logger.Error (msg); + var res = createHandshakeFailureResponse (HttpStatusCode.BadRequest); sendHttpResponse (res); - _logger.Fatal (msg); - - msg = "A fatal error has occurred while attempting to accept."; + msg = "A handshake error has occurred while attempting to accept."; fatal (msg, CloseStatusCode.ProtocolError); return false; From f87101d83751469cec88a79b67ea213bf99a4bb7 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 28 Nov 2017 15:04:00 +0900 Subject: [PATCH 1667/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 5bd20584a..7e2b444b7 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1372,11 +1372,17 @@ private HttpResponse createHandshakeResponse () } // As server - private bool customCheckHandshakeRequest (WebSocketContext context, out string message) + private bool customCheckHandshakeRequest ( + WebSocketContext context, out string message + ) { message = null; - return _handshakeRequestChecker == null - || (message = _handshakeRequestChecker (context)) == null; + + if (_handshakeRequestChecker == null) + return true; + + message = _handshakeRequestChecker (context); + return message == null; } private MessageEventArgs dequeueFromMessageEventQueue () From a40bd7b22e0b799b6ef6ffc2bb74012d21d647e2 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 29 Nov 2017 15:49:15 +0900 Subject: [PATCH 1668/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 7e2b444b7..445ace289 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -878,12 +878,12 @@ private bool acceptHandshake () } if (!customCheckHandshakeRequest (_context, out msg)) { + _logger.Error (msg); + var res = createHandshakeFailureResponse (HttpStatusCode.BadRequest); sendHttpResponse (res); - _logger.Fatal (msg); - - msg = "A fatal error has occurred while attempting to accept."; + msg = "A handshake error has occurred while attempting to accept."; fatal (msg, CloseStatusCode.PolicyViolation); return false; From 34c9c7da0f09d03df67aaef556a1529eab3181ac Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 30 Nov 2017 15:36:52 +0900 Subject: [PATCH 1669/6294] [Modify] Add it --- websocket-sharp/WebSocket.cs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 445ace289..5d544e221 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1764,6 +1764,29 @@ private bool processUnsupportedFrame (WebSocketFrame frame) return false; } + // As server + private void refuseHandshake (CloseStatusCode code, string reason) + { + _readyState = WebSocketState.Closing; + + var res = createHandshakeFailureResponse (HttpStatusCode.BadRequest); + sendHttpResponse (res); + + releaseServerResources (); + + _readyState = WebSocketState.Closed; + + var e = new CloseEventArgs (code, reason); + + try { + OnClose.Emit (this, e); + } + catch (Exception ex) { + _logger.Error (ex.Message); + _logger.Debug (ex.ToString ()); + } + } + // As client private void releaseClientResources () { From 1f9ba809cb0d5607ff7cd7c9c22369eb252f75bd Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 1 Dec 2017 16:30:40 +0900 Subject: [PATCH 1670/6294] [Modify] Replace it --- websocket-sharp/WebSocket.cs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 5d544e221..6b443fe25 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -868,11 +868,10 @@ private bool acceptHandshake () if (!checkHandshakeRequest (_context, out msg)) { _logger.Error (msg); - var res = createHandshakeFailureResponse (HttpStatusCode.BadRequest); - sendHttpResponse (res); - - msg = "A handshake error has occurred while attempting to accept."; - fatal (msg, CloseStatusCode.ProtocolError); + refuseHandshake ( + CloseStatusCode.ProtocolError, + "A handshake error has occurred while attempting to accept." + ); return false; } From 7de8f735dfe82553bac6a5a59207f6e6075e707d Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 1 Dec 2017 16:40:28 +0900 Subject: [PATCH 1671/6294] [Modify] Replace it --- websocket-sharp/WebSocket.cs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 6b443fe25..907a81114 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -879,11 +879,10 @@ private bool acceptHandshake () if (!customCheckHandshakeRequest (_context, out msg)) { _logger.Error (msg); - var res = createHandshakeFailureResponse (HttpStatusCode.BadRequest); - sendHttpResponse (res); - - msg = "A handshake error has occurred while attempting to accept."; - fatal (msg, CloseStatusCode.PolicyViolation); + refuseHandshake ( + CloseStatusCode.PolicyViolation, + "A handshake error has occurred while attempting to accept." + ); return false; } From 0e77f996a7b30d7b98cad98c362799eddaf8cb37 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 2 Dec 2017 15:40:38 +0900 Subject: [PATCH 1672/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 907a81114..4d1e7a5c0 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -857,14 +857,13 @@ private bool accept () // As server private bool acceptHandshake () { - var msg = String.Format ( - "A handshake request from {0}:\n{1}", - _context.UserEndPoint, - _context - ); - - _logger.Debug (msg); + _logger.Debug ( + String.Format ( + "A handshake request from {0}:\n{1}", _context.UserEndPoint, _context + ) + ); + string msg; if (!checkHandshakeRequest (_context, out msg)) { _logger.Error (msg); From 92770c3edb5184a01d439e3bf23fe7b57f901bb0 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 3 Dec 2017 16:17:40 +0900 Subject: [PATCH 1673/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 4d1e7a5c0..edf202c15 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2048,7 +2048,12 @@ private HttpResponse sendHttpRequest (HttpRequest request, int millisecondsTimeo // As server private bool sendHttpResponse (HttpResponse response) { - _logger.Debug ("A response to this request:\n" + response.ToString ()); + _logger.Debug ( + String.Format ( + "A response to {0}:\n{1}", _context.UserEndPoint, response + ) + ); + return sendBytes (response.ToByteArray ()); } From 28cdefcd89a11a163329182249bb2dd7672c4b18 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 3 Dec 2017 16:50:25 +0900 Subject: [PATCH 1674/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index edf202c15..1aaad019a 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1747,7 +1747,7 @@ private void processSecWebSocketExtensionsServerHeader (string value) // As server private void processSecWebSocketProtocolHeader (IEnumerable values) { - if (values.Contains (p => p == _protocol)) + if (values.Contains (val => val == _protocol)) return; _protocol = null; From 5c882fd91782b7999df57836dd043cb1b3d58902 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 4 Dec 2017 15:32:15 +0900 Subject: [PATCH 1675/6294] [Modify] Rename it --- websocket-sharp/WebSocket.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 1aaad019a..120849807 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -888,8 +888,10 @@ private bool acceptHandshake () _base64Key = _context.Headers["Sec-WebSocket-Key"]; - if (_protocol != null) - processSecWebSocketProtocolHeader (_context.SecWebSocketProtocols); + if (_protocol != null) { + var vals = _context.SecWebSocketProtocols; + processSecWebSocketProtocolClientHeader (vals); + } if (!_ignoreExtensions) { var val = _context.Headers["Sec-WebSocket-Extensions"]; @@ -1745,7 +1747,9 @@ private void processSecWebSocketExtensionsServerHeader (string value) } // As server - private void processSecWebSocketProtocolHeader (IEnumerable values) + private void processSecWebSocketProtocolClientHeader ( + IEnumerable values + ) { if (values.Contains (val => val == _protocol)) return; From 084750fa8a6e0b1700605642c79bef99eb0a333f Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 5 Dec 2017 15:43:24 +0900 Subject: [PATCH 1676/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 37 ++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 120849807..b2256048d 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1711,28 +1711,33 @@ private void processSecWebSocketExtensionsClientHeader (string value) return; var buff = new StringBuilder (80); - var comp = false; - foreach (var e in value.SplitHeaderValue (',')) { - var ext = e.Trim (); - if (!comp && ext.IsCompressionExtension (CompressionMethod.Deflate)) { - _compression = CompressionMethod.Deflate; - buff.AppendFormat ( - "{0}, ", - _compression.ToExtensionString ( - "client_no_context_takeover", "server_no_context_takeover" - ) - ); - comp = true; + foreach (var val in value.SplitHeaderValue (',')) { + var ext = val.Trim (); + + if (!comp) { + if (ext.IsCompressionExtension (CompressionMethod.Deflate)) { + _compression = CompressionMethod.Deflate; + + buff.AppendFormat ( + "{0}, ", + _compression.ToExtensionString ( + "client_no_context_takeover", "server_no_context_takeover" + ) + ); + + comp = true; + } } } var len = buff.Length; - if (len > 2) { - buff.Length = len - 2; - _extensions = buff.ToString (); - } + if (len <= 2) + return; + + buff.Length = len - 2; + _extensions = buff.ToString (); } // As client From 58b2c43dab233fec0ed780275675eaef4330c449 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 6 Dec 2017 15:51:44 +0900 Subject: [PATCH 1677/6294] [Modify] Polish it --- .../Net/WebSockets/TcpListenerWebSocketContext.cs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs index b177c1c51..fe0074b70 100644 --- a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs @@ -281,10 +281,16 @@ public override string SecWebSocketKey { /// public override IEnumerable SecWebSocketProtocols { get { - var protocols = _request.Headers["Sec-WebSocket-Protocol"]; - if (protocols != null) { - foreach (var protocol in protocols.Split (',')) - yield return protocol.Trim (); + var val = _request.Headers["Sec-WebSocket-Protocol"]; + if (val == null || val.Length == 0) + yield break; + + foreach (var elm in val.Split (',')) { + var protocol = elm.Trim (); + if (protocol.Length == 0) + continue; + + yield return protocol; } } } From a3f6fedd81e5852980e9f38a31041c3cb1913a45 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 6 Dec 2017 16:30:56 +0900 Subject: [PATCH 1678/6294] [Modify] Edit it --- .../WebSockets/TcpListenerWebSocketContext.cs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs index fe0074b70..ed7b16e17 100644 --- a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs @@ -269,15 +269,18 @@ public override string SecWebSocketKey { } /// - /// Gets the values of the Sec-WebSocket-Protocol header included in the request. + /// Gets the value of the Sec-WebSocket-Protocol header included in + /// the handshake request. /// - /// - /// This property represents the subprotocols requested by the client. - /// /// - /// An instance that provides - /// an enumerator which supports the iteration over the values of the Sec-WebSocket-Protocol - /// header. + /// + /// An + /// instance. + /// + /// + /// It provides an enumerator which supports the iteration over + /// the collection of the names of the subprotocols. + /// /// public override IEnumerable SecWebSocketProtocols { get { From ad8ce4a5e5ee69e149a5f4365f70c3c63476b8c7 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 7 Dec 2017 13:38:55 +0900 Subject: [PATCH 1679/6294] [Modify] Polish it --- .../Net/WebSockets/HttpListenerWebSocketContext.cs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs b/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs index 86e4ff053..6cb5d53a6 100644 --- a/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs @@ -224,10 +224,16 @@ public override string SecWebSocketKey { /// public override IEnumerable SecWebSocketProtocols { get { - var protocols = _context.Request.Headers["Sec-WebSocket-Protocol"]; - if (protocols != null) { - foreach (var protocol in protocols.Split (',')) - yield return protocol.Trim (); + var val = _context.Request.Headers["Sec-WebSocket-Protocol"]; + if (val == null || val.Length == 0) + yield break; + + foreach (var elm in val.Split (',')) { + var protocol = elm.Trim (); + if (protocol.Length == 0) + continue; + + yield return protocol; } } } From 8305854bc928f57b3f8669ab6e042fe7ee3de44f Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 7 Dec 2017 13:44:49 +0900 Subject: [PATCH 1680/6294] [Modify] Edit it --- .../WebSockets/HttpListenerWebSocketContext.cs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs b/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs index 6cb5d53a6..bb3592d70 100644 --- a/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs @@ -212,15 +212,18 @@ public override string SecWebSocketKey { } /// - /// Gets the values of the Sec-WebSocket-Protocol header included in the request. + /// Gets the value of the Sec-WebSocket-Protocol header included in + /// the handshake request. /// - /// - /// This property represents the subprotocols requested by the client. - /// /// - /// An instance that provides - /// an enumerator which supports the iteration over the values of the Sec-WebSocket-Protocol - /// header. + /// + /// An + /// instance. + /// + /// + /// It provides an enumerator which supports the iteration over + /// the collection of the names of the subprotocols. + /// /// public override IEnumerable SecWebSocketProtocols { get { From 84eea4161a59ce64289b28faea77aeb4604b1aa4 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 7 Dec 2017 13:50:09 +0900 Subject: [PATCH 1681/6294] [Modify] Edit it --- .../Net/WebSockets/WebSocketContext.cs | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/websocket-sharp/Net/WebSockets/WebSocketContext.cs b/websocket-sharp/Net/WebSockets/WebSocketContext.cs index 9ede501bf..61913ed2f 100644 --- a/websocket-sharp/Net/WebSockets/WebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/WebSocketContext.cs @@ -147,15 +147,18 @@ protected WebSocketContext () public abstract string SecWebSocketKey { get; } /// - /// Gets the values of the Sec-WebSocket-Protocol header included in the request. - /// - /// - /// This property represents the subprotocols requested by the client. - /// - /// - /// An instance that provides - /// an enumerator which supports the iteration over the values of the Sec-WebSocket-Protocol - /// header. + /// Gets the value of the Sec-WebSocket-Protocol header included in + /// the handshake request. + /// + /// + /// + /// An + /// instance. + /// + /// + /// It provides an enumerator which supports the iteration over + /// the collection of the names of the subprotocols. + /// /// public abstract IEnumerable SecWebSocketProtocols { get; } From 64c1cb599c8f11bc566bbd804bd7ff4397126a46 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 8 Dec 2017 15:05:34 +0900 Subject: [PATCH 1682/6294] [Modify] Edit it --- websocket-sharp/Net/WebSockets/WebSocketContext.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/WebSockets/WebSocketContext.cs b/websocket-sharp/Net/WebSockets/WebSocketContext.cs index 61913ed2f..c3491ff97 100644 --- a/websocket-sharp/Net/WebSockets/WebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/WebSocketContext.cs @@ -147,8 +147,8 @@ protected WebSocketContext () public abstract string SecWebSocketKey { get; } /// - /// Gets the value of the Sec-WebSocket-Protocol header included in - /// the handshake request. + /// Gets the names of the subprotocols from the Sec-WebSocket-Protocol + /// header included in the handshake request. /// /// /// From 3664e0f6374935ac1f94100b328dc651e4ce98cf Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 8 Dec 2017 15:09:27 +0900 Subject: [PATCH 1683/6294] [Modify] Edit it --- .../Net/WebSockets/HttpListenerWebSocketContext.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs b/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs index bb3592d70..9935aee06 100644 --- a/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs @@ -212,8 +212,8 @@ public override string SecWebSocketKey { } /// - /// Gets the value of the Sec-WebSocket-Protocol header included in - /// the handshake request. + /// Gets the names of the subprotocols from the Sec-WebSocket-Protocol + /// header included in the handshake request. /// /// /// From d9005a68d6c886549627499cffcf61bff20cc22f Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 8 Dec 2017 15:12:46 +0900 Subject: [PATCH 1684/6294] [Modify] Edit it --- websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs index ed7b16e17..3b54871e3 100644 --- a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs @@ -269,8 +269,8 @@ public override string SecWebSocketKey { } /// - /// Gets the value of the Sec-WebSocket-Protocol header included in - /// the handshake request. + /// Gets the names of the subprotocols from the Sec-WebSocket-Protocol + /// header included in the handshake request. /// /// /// From 9f088753765ea6d3e727e8b469ccdb6cf38bc6f3 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 9 Dec 2017 15:12:40 +0900 Subject: [PATCH 1685/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index b2256048d..7effc8852 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1713,11 +1713,13 @@ private void processSecWebSocketExtensionsClientHeader (string value) var buff = new StringBuilder (80); var comp = false; - foreach (var val in value.SplitHeaderValue (',')) { - var ext = val.Trim (); + foreach (var elm in value.SplitHeaderValue (',')) { + var extension = elm.Trim (); + if (extension.Length == 0) + continue; if (!comp) { - if (ext.IsCompressionExtension (CompressionMethod.Deflate)) { + if (extension.IsCompressionExtension (CompressionMethod.Deflate)) { _compression = CompressionMethod.Deflate; buff.AppendFormat ( From ed9bcaff6b80be540978d0d4632bd44c43bd680b Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 10 Dec 2017 17:45:51 +0900 Subject: [PATCH 1686/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index e944d8740..b9dd7ff1c 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -754,7 +754,8 @@ internal static T[] Reverse (this T[] array) } internal static IEnumerable SplitHeaderValue ( - this string value, params char[] separators) + this string value, params char[] separators + ) { var len = value.Length; var seps = new string (separators); @@ -778,8 +779,8 @@ internal static IEnumerable SplitHeaderValue ( else if (seps.Contains (c)) { if (!quoted) { yield return buff.ToString (); - buff.Length = 0; + buff.Length = 0; continue; } } @@ -789,8 +790,7 @@ internal static IEnumerable SplitHeaderValue ( buff.Append (c); } - if (buff.Length > 0) - yield return buff.ToString (); + yield return buff.ToString (); } internal static byte[] ToByteArray (this Stream stream) From 5c06578ee74daf354110f04d1a8193c9a61c3582 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 10 Dec 2017 17:50:22 +0900 Subject: [PATCH 1687/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index b9dd7ff1c..951e8497c 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -462,7 +462,9 @@ internal static byte[] InternalToByteArray (this ulong value, ByteOrder order) return bytes; } - internal static bool IsCompressionExtension (this string value, CompressionMethod method) + internal static bool IsCompressionExtension ( + this string value, CompressionMethod method + ) { return value.StartsWith (method.ToExtensionString ()); } From 64b39c319f4e5a2384c650aa8ab9b5112005574d Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 11 Dec 2017 17:36:22 +0900 Subject: [PATCH 1688/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 951e8497c..ae7de22f7 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -816,16 +816,19 @@ internal static CompressionMethod ToCompressionMethod (this string value) } internal static string ToExtensionString ( - this CompressionMethod method, params string[] parameters) + this CompressionMethod method, params string[] parameters + ) { if (method == CompressionMethod.None) return String.Empty; - var m = String.Format ("permessage-{0}", method.ToString ().ToLower ()); - if (parameters == null || parameters.Length == 0) - return m; + var name = String.Format ( + "permessage-{0}", method.ToString ().ToLower () + ); - return String.Format ("{0}; {1}", m, parameters.ToString ("; ")); + return parameters != null && parameters.Length > 0 + ? String.Format ("{0}; {1}", name, parameters.ToString ("; ")) + : name; } internal static System.Net.IPAddress ToIPAddress (this string value) From 10761d9e3f62e4b862d51c4e29a599fa0d7028ef Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 12 Dec 2017 15:03:15 +0900 Subject: [PATCH 1689/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index ae7de22f7..4f3fec091 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1900,7 +1900,9 @@ public static string ToString (this T[] array, string separator) separator = String.Empty; var buff = new StringBuilder (64); - (len - 1).Times (i => buff.AppendFormat ("{0}{1}", array[i].ToString (), separator)); + + for (var i = 0; i < len - 1; i++) + buff.AppendFormat ("{0}{1}", array[i], separator); buff.Append (array[len - 1].ToString ()); return buff.ToString (); From 5e19058c40bceef2a7dc031398546d81964d368e Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 13 Dec 2017 16:05:07 +0900 Subject: [PATCH 1690/6294] [Modify] Edit it --- websocket-sharp/Ext.cs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 4f3fec091..7000b042a 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1867,19 +1867,23 @@ public static byte[] ToHostOrder (this byte[] source, ByteOrder sourceOrder) } /// - /// Converts the specified to a that - /// concatenates the each element of across the specified - /// . + /// Converts the specified array to a . /// /// - /// A converted from , - /// or if is empty. + /// + /// A converted by concatenating each element of + /// across . + /// + /// + /// An empty string if is an empty array. + /// /// /// /// An array of T to convert. /// /// - /// A that represents the separator string. + /// A used to separate each element of + /// . /// /// /// The type of elements in . From e8ee51efa94e8c89f7648d758aea989aa2b6bb12 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 14 Dec 2017 15:42:55 +0900 Subject: [PATCH 1691/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 7000b042a..4acf59545 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1863,7 +1863,10 @@ public static byte[] ToHostOrder (this byte[] source, ByteOrder sourceOrder) if (source == null) throw new ArgumentNullException ("source"); - return source.Length > 1 && !sourceOrder.IsHostOrder () ? source.Reverse () : source; + if (source.Length < 2) + return source; + + return !sourceOrder.IsHostOrder () ? source.Reverse () : source; } /// From 8a587772988f4df655ba4fe348d832fefdf22e1c Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 15 Dec 2017 16:11:41 +0900 Subject: [PATCH 1692/6294] [Modify] Edit it --- websocket-sharp/Ext.cs | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 4acf59545..cb6565fc1 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1843,17 +1843,30 @@ public static byte[] ToByteArray (this T value, ByteOrder order) } /// - /// Converts the order of the specified array of to the host byte order. + /// Converts the order of elements in the specified byte array to + /// host (this computer architecture) byte order. /// /// - /// An array of converted from . + /// + /// An array of converted from + /// . + /// + /// + /// Or if the number of elements in it + /// is less than 2 or is same as + /// host byte order. + /// /// /// /// An array of to convert. /// /// - /// One of the enum values, specifies the byte order of - /// . + /// + /// One of the enum values. + /// + /// + /// It specifies the order of elements in . + /// /// /// /// is . From b89a84225f0d4bec9e7bfa9b95eafa6738e61a4c Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 15 Dec 2017 16:36:52 +0900 Subject: [PATCH 1693/6294] [Modify] Edit it --- websocket-sharp/Ext.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index cb6565fc1..ce8a736bd 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1339,14 +1339,15 @@ public static bool IsEnclosedIn (this string value, char c) } /// - /// Determines whether the specified is host (this computer + /// Determines whether the specified byte order is host (this computer /// architecture) byte order. /// /// - /// true if is host byte order; otherwise, false. + /// true if is host byte order; otherwise, + /// false. /// /// - /// One of the enum values, to test. + /// One of the enum values to test. /// public static bool IsHostOrder (this ByteOrder order) { From 90a17e293b787306d23dbcdabc4785f3e81c0746 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 16 Dec 2017 03:54:47 +0900 Subject: [PATCH 1694/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index ce8a736bd..e44964322 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -746,13 +746,13 @@ internal static string RemovePrefix (this string value, params string[] prefixes internal static T[] Reverse (this T[] array) { var len = array.Length; - var reverse = new T[len]; + var ret = new T[len]; var end = len - 1; for (var i = 0; i <= end; i++) - reverse[i] = array[end - i]; + ret[i] = array[end - i]; - return reverse; + return ret; } internal static IEnumerable SplitHeaderValue ( From 0ab9f64b54c8c5f2b54f9e8c7b83890024e959ec Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 16 Dec 2017 03:57:20 +0900 Subject: [PATCH 1695/6294] [Modify] Remove it --- websocket-sharp/Ext.cs | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index e44964322..9caf283be 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -730,19 +730,6 @@ Action error } } - internal static string RemovePrefix (this string value, params string[] prefixes) - { - var idx = 0; - foreach (var prefix in prefixes) { - if (value.StartsWith (prefix)) { - idx = prefix.Length; - break; - } - } - - return idx > 0 ? value.Substring (idx) : value; - } - internal static T[] Reverse (this T[] array) { var len = array.Length; From e8d06a500cec93ffc75b5b90c343bd2b499ea9e9 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 16 Dec 2017 04:10:00 +0900 Subject: [PATCH 1696/6294] [Modify] Edit it --- websocket-sharp/Ext.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 9caf283be..124f9cab4 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1391,8 +1391,8 @@ public static bool IsLocal (this System.Net.IPAddress address) /// an empty string. /// /// - /// true if the string is or an empty string; - /// otherwise, false. + /// true if is or + /// an empty string; otherwise, false. /// /// /// A to test. From 782814ca818bd84307190000f642316976fd5451 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 16 Dec 2017 16:22:48 +0900 Subject: [PATCH 1697/6294] [Modify] Edit it --- websocket-sharp/Ext.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 124f9cab4..1d735c9e5 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1344,14 +1344,13 @@ public static bool IsHostOrder (this ByteOrder order) } /// - /// Determines whether the specified - /// represents a local IP address. + /// Determines whether the specified IP address is a local IP address. /// /// /// This local means NOT REMOTE for the current host. /// /// - /// true if represents a local IP address; + /// true if is a local IP address; /// otherwise, false. /// /// From c6584431c96b736ec1ad03a5e4626f6ad81ff391 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 16 Dec 2017 16:40:32 +0900 Subject: [PATCH 1698/6294] [Modify] Edit it --- websocket-sharp/Ext.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 1d735c9e5..aa2e04a91 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1264,8 +1264,8 @@ public static string GetStatusDescription (this int code) } /// - /// Determines whether the specified is in the - /// range of the status code for the WebSocket connection close. + /// Determines whether the specified ushort is in the range of + /// the status code for the WebSocket connection close. /// /// /// From 5ff5e03c8f2b263cb9dd0e2de78f07fd8cebece8 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 16 Dec 2017 16:49:14 +0900 Subject: [PATCH 1699/6294] [Modify] Edit it --- websocket-sharp/Ext.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index aa2e04a91..2fe85d549 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1304,8 +1304,8 @@ public static bool IsCloseStatusCode (this ushort value) } /// - /// Determines whether the specified is - /// enclosed in the specified . + /// Determines whether the specified string is enclosed in + /// the specified character. /// /// /// true if is enclosed in From b25108b7dc51a89ebe87b8ae045e9b6a338395f5 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 17 Dec 2017 16:09:34 +0900 Subject: [PATCH 1700/6294] [Modify] Edit it --- websocket-sharp/Ext.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 2fe85d549..181d5ce1f 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1402,8 +1402,7 @@ public static bool IsNullOrEmpty (this string value) } /// - /// Determines whether the specified is - /// a predefined scheme. + /// Determines whether the specified string is a predefined scheme. /// /// /// true if is a predefined scheme; From f2827c1f5053abdcf251612bf7d3fcf2dabe0c27 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 17 Dec 2017 16:20:19 +0900 Subject: [PATCH 1701/6294] [Modify] Edit it --- websocket-sharp/Ext.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 181d5ce1f..9578a5c60 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1486,7 +1486,7 @@ public static bool IsUpgradeTo (this HttpListenerRequest request, string protoco } /// - /// Determines whether the specified is a URI string. + /// Determines whether the specified string is a URI string. /// /// /// true if may be a URI string; From 7d3255aa4ba928b0cf80686707689d40c4b8e83e Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 17 Dec 2017 16:28:04 +0900 Subject: [PATCH 1702/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 9578a5c60..6754ad546 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1470,7 +1470,9 @@ public static bool IsPredefinedScheme (this string value) /// /// is empty. /// - public static bool IsUpgradeTo (this HttpListenerRequest request, string protocol) + public static bool IsUpgradeTo ( + this HttpListenerRequest request, string protocol + ) { if (request == null) throw new ArgumentNullException ("request"); @@ -1481,8 +1483,9 @@ public static bool IsUpgradeTo (this HttpListenerRequest request, string protoco if (protocol.Length == 0) throw new ArgumentException ("An empty string.", "protocol"); - return request.Headers.Contains ("Upgrade", protocol) && - request.Headers.Contains ("Connection", "Upgrade"); + var headers = request.Headers; + return headers.Contains ("Upgrade", protocol) + && headers.Contains ("Connection", "Upgrade"); } /// From a89eecc5c54b0ee759c90941802484ac6f8563b4 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 18 Dec 2017 16:02:16 +0900 Subject: [PATCH 1703/6294] [Modify] Edit it --- websocket-sharp/Ext.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 6754ad546..379ea10cb 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1443,18 +1443,18 @@ public static bool IsPredefinedScheme (this string value) } /// - /// Determines whether the specified is - /// an HTTP Upgrade request to switch to the specified . + /// Determines whether the specified HTTP request is an upgrade request to + /// switch to the specified protocol. /// /// - /// true if is an HTTP Upgrade request to switch to - /// ; otherwise, false. + /// true if is an upgrade request to + /// switch to ; otherwise, false. /// /// - /// A that represents the HTTP request. + /// A to test. /// /// - /// A that represents the protocol name. + /// A that represents the name of the protocol. /// /// /// @@ -1468,7 +1468,7 @@ public static bool IsPredefinedScheme (this string value) /// /// /// - /// is empty. + /// is an empty string. /// public static bool IsUpgradeTo ( this HttpListenerRequest request, string protocol From 23fb7c043491f26c1be9f6f0c91e0f4600df8bc4 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 18 Dec 2017 16:28:57 +0900 Subject: [PATCH 1704/6294] [Modify] Add null check --- websocket-sharp/Net/EndPointManager.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/websocket-sharp/Net/EndPointManager.cs b/websocket-sharp/Net/EndPointManager.cs index ebecf459e..02eca4fcd 100644 --- a/websocket-sharp/Net/EndPointManager.cs +++ b/websocket-sharp/Net/EndPointManager.cs @@ -83,6 +83,9 @@ private static void addPrefix (string uriPrefix, HttpListener listener) var pref = new HttpListenerPrefix (uriPrefix); var addr = convertToIPAddress (pref.Host); + if (addr == null) + throw new HttpListenerException (87, "Includes an invalid host."); + if (!addr.IsLocal ()) throw new HttpListenerException (87, "Includes an invalid host."); From 1f8cb5b692cfbcbed83a27de65d18204e27809de Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 18 Dec 2017 16:32:13 +0900 Subject: [PATCH 1705/6294] [Modify] Add null check --- websocket-sharp/Net/EndPointManager.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/websocket-sharp/Net/EndPointManager.cs b/websocket-sharp/Net/EndPointManager.cs index 02eca4fcd..9bc19a6e6 100644 --- a/websocket-sharp/Net/EndPointManager.cs +++ b/websocket-sharp/Net/EndPointManager.cs @@ -136,6 +136,9 @@ private static void removePrefix (string uriPrefix, HttpListener listener) var pref = new HttpListenerPrefix (uriPrefix); var addr = convertToIPAddress (pref.Host); + if (addr == null) + return; + if (!addr.IsLocal ()) return; From 4c7d2c91788ae51a7d87f3e3887ed6f7e823cea9 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 18 Dec 2017 16:45:58 +0900 Subject: [PATCH 1706/6294] [Modify] Polish it --- websocket-sharp/Net/EndPointManager.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/EndPointManager.cs b/websocket-sharp/Net/EndPointManager.cs index 9bc19a6e6..c12349d56 100644 --- a/websocket-sharp/Net/EndPointManager.cs +++ b/websocket-sharp/Net/EndPointManager.cs @@ -128,7 +128,13 @@ private static void addPrefix (string uriPrefix, HttpListener listener) private static IPAddress convertToIPAddress (string hostname) { - return hostname == "*" || hostname == "+" ? IPAddress.Any : hostname.ToIPAddress (); + if (hostname == "*") + return IPAddress.Any; + + if (hostname == "+") + return IPAddress.Any; + + return hostname.ToIPAddress (); } private static void removePrefix (string uriPrefix, HttpListener listener) From fb791129b6e327e4773d8530e16288cad1872085 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 19 Dec 2017 11:22:40 +0900 Subject: [PATCH 1707/6294] [Modify] Throw exception --- websocket-sharp/Ext.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 379ea10cb..a66637e42 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1359,7 +1359,7 @@ public static bool IsHostOrder (this ByteOrder order) public static bool IsLocal (this System.Net.IPAddress address) { if (address == null) - return false; + throw new ArgumentNullException ("address"); if (address.Equals (System.Net.IPAddress.Any)) return true; From ef175961ec8742ce8ccee30e196c859150799bb3 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 19 Dec 2017 11:37:37 +0900 Subject: [PATCH 1708/6294] [Modify] Edit it --- websocket-sharp/Ext.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index a66637e42..310e1e9b5 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1356,6 +1356,9 @@ public static bool IsHostOrder (this ByteOrder order) /// /// A to test. /// + /// + /// is . + /// public static bool IsLocal (this System.Net.IPAddress address) { if (address == null) From 62d4403b43cb5a386d0da3d8ba886fadbbe274ae Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 19 Dec 2017 15:09:11 +0900 Subject: [PATCH 1709/6294] [Modify] Add it --- websocket-sharp/Ext.cs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 310e1e9b5..11422f055 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -197,6 +197,25 @@ internal static byte[] CompressToArray (this Stream stream, CompressionMethod me : stream.ToByteArray (); } + internal static bool Contains ( + this NameValueCollection collection, + string name, + string value, + StringComparison comparisonTypeForValue + ) + { + var val = collection[name]; + if (val == null) + return false; + + foreach (var elm in val.Split (',')) { + if (elm.Trim ().Equals (value, comparisonTypeForValue)) + return true; + } + + return false; + } + internal static bool Contains ( this IEnumerable source, Func condition ) From 74796b0e4fa09a1d04ce2163dc044e6450b664e4 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 19 Dec 2017 15:30:56 +0900 Subject: [PATCH 1710/6294] [Modify] Replace it --- websocket-sharp/Ext.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 11422f055..9b0d75949 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1506,8 +1506,10 @@ public static bool IsUpgradeTo ( throw new ArgumentException ("An empty string.", "protocol"); var headers = request.Headers; - return headers.Contains ("Upgrade", protocol) - && headers.Contains ("Connection", "Upgrade"); + var comparison = StringComparison.OrdinalIgnoreCase; + + return headers.Contains ("Upgrade", protocol, comparison) + && headers.Contains ("Connection", "Upgrade", comparison); } /// From acc3a690940d1373f88fd2302d8c313c3ba5bf81 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 20 Dec 2017 15:37:05 +0900 Subject: [PATCH 1711/6294] [Modify] Replace it --- websocket-sharp/Net/HttpListenerRequest.cs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index 701128120..34edac15f 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -278,10 +278,9 @@ public bool IsSecureConnection { public bool IsWebSocketRequest { get { if (!_websocketRequestSet) { - _websocketRequest = _method == "GET" && - _version > HttpVersion.Version10 && - _headers.Contains ("Upgrade", "websocket") && - _headers.Contains ("Connection", "Upgrade"); + _websocketRequest = _method == "GET" + && _version > HttpVersion.Version10 + && this.IsUpgradeTo ("websocket"); _websocketRequestSet = true; } From 63299a641e287e04974ca9ad2d011492cb29b6be Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 20 Dec 2017 16:00:27 +0900 Subject: [PATCH 1712/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerRequest.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index 34edac15f..7f021c81b 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -270,10 +270,12 @@ public bool IsSecureConnection { } /// - /// Gets a value indicating whether the request is a WebSocket connection request. + /// Gets a value indicating whether the request is a WebSocket handshake + /// request. /// /// - /// true if the request is a WebSocket connection request; otherwise, false. + /// true if the request is a WebSocket handshake request; otherwise, + /// false. /// public bool IsWebSocketRequest { get { From e03538bdc89066a3831a45e862f45dab790b62f5 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 20 Dec 2017 16:13:02 +0900 Subject: [PATCH 1713/6294] [Modify] Add it --- websocket-sharp/Ext.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 9b0d75949..b768d5235 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1022,6 +1022,15 @@ internal static string Unquote (this string value) : value.Substring (start + 1, len).Replace ("\\\"", "\""); } + internal static bool Upgrades ( + this NameValueCollection headers, string protocol + ) + { + var comparison = StringComparison.OrdinalIgnoreCase; + return headers.Contains ("Upgrade", protocol, comparison) + && headers.Contains ("Connection", "Upgrade", comparison); + } + internal static string UTF8Decode (this byte[] bytes) { try { From b6e61c60d75a5af2a0a2d6088f721780dfe95c6d Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 20 Dec 2017 16:19:49 +0900 Subject: [PATCH 1714/6294] [Modify] Replace it --- websocket-sharp/Ext.cs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index b768d5235..500f734ad 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1514,11 +1514,7 @@ public static bool IsUpgradeTo ( if (protocol.Length == 0) throw new ArgumentException ("An empty string.", "protocol"); - var headers = request.Headers; - var comparison = StringComparison.OrdinalIgnoreCase; - - return headers.Contains ("Upgrade", protocol, comparison) - && headers.Contains ("Connection", "Upgrade", comparison); + return request.Headers.Upgrades (protocol); } /// From 0d012bf86ab6a4809cddc594b238f86cee7a15be Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 21 Dec 2017 20:06:50 +0900 Subject: [PATCH 1715/6294] [Modify] Edit it --- websocket-sharp/Ext.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 500f734ad..2d8e1ea2b 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1485,7 +1485,7 @@ public static bool IsPredefinedScheme (this string value) /// A to test. /// /// - /// A that represents the name of the protocol. + /// A that specifies the name of the protocol. /// /// /// From 6ceabd702285eed07ac35cbdf5c500b7f75d3f58 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 21 Dec 2017 20:09:56 +0900 Subject: [PATCH 1716/6294] [Modify] Replace it --- websocket-sharp/Net/HttpListenerRequest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index 7f021c81b..d6d52253e 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -282,7 +282,7 @@ public bool IsWebSocketRequest { if (!_websocketRequestSet) { _websocketRequest = _method == "GET" && _version > HttpVersion.Version10 - && this.IsUpgradeTo ("websocket"); + && _headers.Upgrades ("websocket"); _websocketRequestSet = true; } From 8d1e0d4b1ef0d9d2b6a3225b6b3a5fe019bb8032 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 21 Dec 2017 20:18:03 +0900 Subject: [PATCH 1717/6294] [Modify] Rename it --- websocket-sharp/Ext.cs | 2 +- websocket-sharp/Server/HttpServer.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 2d8e1ea2b..1f32ef8f7 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1501,7 +1501,7 @@ public static bool IsPredefinedScheme (this string value) /// /// is an empty string. /// - public static bool IsUpgradeTo ( + public static bool IsUpgradeRequest ( this HttpListenerRequest request, string protocol ) { diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 30b9d79ac..e3436191a 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -944,7 +944,7 @@ private void receiveRequest () ThreadPool.QueueUserWorkItem ( state => { try { - if (ctx.Request.IsUpgradeTo ("websocket")) { + if (ctx.Request.IsUpgradeRequest ("websocket")) { processRequest (ctx.AcceptWebSocket (null)); return; } From 51d5c3e52caeaa32b53e617ab49dab4409d5d3d4 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 22 Dec 2017 22:21:15 +0900 Subject: [PATCH 1718/6294] [Modify] Add it --- websocket-sharp/Net/HttpListenerRequest.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index d6d52253e..5ca9868a6 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -464,6 +464,14 @@ public string[] UserLanguages { #region Private Methods + private bool keepAlive () + { + var comparison = StringComparison.OrdinalIgnoreCase; + return _version > HttpVersion.Version10 + ? !_headers.Contains ("Connection", "close", comparison) + : _headers.Contains ("Connection", "keep-alive", comparison); + } + private static bool tryCreateVersion (string version, out Version result) { try { From 4e7a151157ae326d911f2870b0c74675fe08d5e0 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 22 Dec 2017 22:41:42 +0900 Subject: [PATCH 1719/6294] [Modify] Replace it --- websocket-sharp/Net/HttpListenerRequest.cs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index 5ca9868a6..81b9ab366 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -300,11 +300,7 @@ public bool IsWebSocketRequest { public bool KeepAlive { get { if (!_keepAliveSet) { - string keepAlive; - _keepAlive = _version > HttpVersion.Version10 || - _headers.Contains ("Connection", "keep-alive") || - ((keepAlive = _headers["Keep-Alive"]) != null && keepAlive != "closed"); - + _keepAlive = keepAlive (); _keepAliveSet = true; } From bacf9282f4c96dc3637b11b21723dd7a35165ea1 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 23 Dec 2017 16:14:11 +0900 Subject: [PATCH 1720/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerRequest.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index 81b9ab366..fe72aa884 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -292,10 +292,12 @@ public bool IsWebSocketRequest { } /// - /// Gets a value indicating whether the client requests a persistent connection. + /// Gets a value indicating whether the client requests a persistent + /// connection. /// /// - /// true if the client requests a persistent connection; otherwise, false. + /// true if the request specifies that the connection is kept open; + /// otherwise, false. /// public bool KeepAlive { get { From 6e68eade57b9a6b22d46fa9413ef03729fd872fa Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 23 Dec 2017 16:26:26 +0900 Subject: [PATCH 1721/6294] [Modify] Move it --- websocket-sharp/Ext.cs | 44 ---------------------- websocket-sharp/Net/HttpListenerRequest.cs | 5 +++ 2 files changed, 5 insertions(+), 44 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 1f32ef8f7..9eadcefd2 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1473,50 +1473,6 @@ public static bool IsPredefinedScheme (this string value) return false; } - /// - /// Determines whether the specified HTTP request is an upgrade request to - /// switch to the specified protocol. - /// - /// - /// true if is an upgrade request to - /// switch to ; otherwise, false. - /// - /// - /// A to test. - /// - /// - /// A that specifies the name of the protocol. - /// - /// - /// - /// is . - /// - /// - /// -or- - /// - /// - /// is . - /// - /// - /// - /// is an empty string. - /// - public static bool IsUpgradeRequest ( - this HttpListenerRequest request, string protocol - ) - { - if (request == null) - throw new ArgumentNullException ("request"); - - if (protocol == null) - throw new ArgumentNullException ("protocol"); - - if (protocol.Length == 0) - throw new ArgumentException ("An empty string.", "protocol"); - - return request.Headers.Upgrades (protocol); - } - /// /// Determines whether the specified string is a URI string. /// diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index fe72aa884..34d9aa8ad 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -610,6 +610,11 @@ internal bool FlushInput () } } + internal bool IsUpgradeRequest (string protocol) + { + return _headers.Upgrades (protocol); + } + internal void SetRequestLine (string requestLine) { var parts = requestLine.Split (new[] { ' ' }, 3); From cf359b901455c1519e095d13f905693439624fef Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 23 Dec 2017 16:36:19 +0900 Subject: [PATCH 1722/6294] [Modify] Replace it --- websocket-sharp/HttpRequest.cs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/HttpRequest.cs b/websocket-sharp/HttpRequest.cs index f9aa5cb33..bb7b9717f 100644 --- a/websocket-sharp/HttpRequest.cs +++ b/websocket-sharp/HttpRequest.cs @@ -99,11 +99,9 @@ public string HttpMethod { public bool IsWebSocketRequest { get { if (!_websocketRequestSet) { - var headers = Headers; - _websocketRequest = _method == "GET" && - ProtocolVersion > HttpVersion.Version10 && - headers.Contains ("Upgrade", "websocket") && - headers.Contains ("Connection", "Upgrade"); + _websocketRequest = _method == "GET" + && ProtocolVersion > HttpVersion.Version10 + && Headers.Upgrades ("websocket"); _websocketRequestSet = true; } From a51f4da2648e81a0402b721da267ea1bec687ae8 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 23 Dec 2017 16:46:14 +0900 Subject: [PATCH 1723/6294] [Modify] Replace it --- websocket-sharp/HttpResponse.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/HttpResponse.cs b/websocket-sharp/HttpResponse.cs index 19315a3f0..111a0d926 100644 --- a/websocket-sharp/HttpResponse.cs +++ b/websocket-sharp/HttpResponse.cs @@ -79,7 +79,8 @@ public CookieCollection Cookies { public bool HasConnectionClose { get { - return Headers.Contains ("Connection", "close"); + var comparison = StringComparison.OrdinalIgnoreCase; + return Headers.Contains ("Connection", "close", comparison); } } From 8cdd7e4b89a09ffcd6ce8a697d36037bdbb3a571 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 23 Dec 2017 16:51:11 +0900 Subject: [PATCH 1724/6294] [Modify] Replace it --- websocket-sharp/HttpResponse.cs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/HttpResponse.cs b/websocket-sharp/HttpResponse.cs index 111a0d926..831b72783 100644 --- a/websocket-sharp/HttpResponse.cs +++ b/websocket-sharp/HttpResponse.cs @@ -104,11 +104,9 @@ public bool IsUnauthorized { public bool IsWebSocketResponse { get { - var headers = Headers; - return ProtocolVersion > HttpVersion.Version10 && - _code == "101" && - headers.Contains ("Upgrade", "websocket") && - headers.Contains ("Connection", "Upgrade"); + return ProtocolVersion > HttpVersion.Version10 + && _code == "101" + && Headers.Upgrades ("websocket"); } } From f828bb02896a47656f796abd2e0ffd4f93da8f86 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 24 Dec 2017 03:40:49 +0900 Subject: [PATCH 1725/6294] [Modify] Remove it --- websocket-sharp/Ext.cs | 33 --------------------------------- 1 file changed, 33 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 9eadcefd2..589410ad9 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1118,39 +1118,6 @@ public static bool Contains (this NameValueCollection collection, string name) return collection != null && collection.Count > 0 ? collection[name] != null : false; } - /// - /// Determines whether the specified contains the entry with - /// the specified both and . - /// - /// - /// true if contains the entry with both - /// and ; otherwise, false. - /// - /// - /// A to test. - /// - /// - /// A that represents the key of the entry to find. - /// - /// - /// A that represents the value of the entry to find. - /// - public static bool Contains (this NameValueCollection collection, string name, string value) - { - if (collection == null || collection.Count == 0) - return false; - - var vals = collection[name]; - if (vals == null) - return false; - - foreach (var val in vals.Split (',')) - if (val.Trim ().Equals (value, StringComparison.OrdinalIgnoreCase)) - return true; - - return false; - } - /// /// Emits the specified delegate if it isn't . /// From 6c62b169776a2565d383944ebb5b772745d4d8fe Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 24 Dec 2017 03:50:58 +0900 Subject: [PATCH 1726/6294] [Modify] To internal --- websocket-sharp/Ext.cs | 26 +++++++------------------- 1 file changed, 7 insertions(+), 19 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 589410ad9..9e7a5538b 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -197,6 +197,13 @@ internal static byte[] CompressToArray (this Stream stream, CompressionMethod me : stream.ToByteArray (); } + internal static bool Contains ( + this NameValueCollection collection, string name + ) + { + return collection[name] != null; + } + internal static bool Contains ( this NameValueCollection collection, string name, @@ -1099,25 +1106,6 @@ public static bool Contains (this string value, params char[] chars) : value.IndexOfAny (chars) > -1; } - /// - /// Determines whether the specified contains - /// the entry with the specified . - /// - /// - /// true if contains the entry with - /// ; otherwise, false. - /// - /// - /// A to test. - /// - /// - /// A that represents the key of the entry to find. - /// - public static bool Contains (this NameValueCollection collection, string name) - { - return collection != null && collection.Count > 0 ? collection[name] != null : false; - } - /// /// Emits the specified delegate if it isn't . /// From 70bf799c20714533168650345f0bee5ef0511bba Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 24 Dec 2017 04:08:42 +0900 Subject: [PATCH 1727/6294] [Modify] To internal --- websocket-sharp/Ext.cs | 31 ++++++++++--------------------- 1 file changed, 10 insertions(+), 21 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 9e7a5538b..0f1ab9093 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -388,6 +388,16 @@ internal static string GetAbsolutePath (this Uri uri) return idx > 0 ? original.Substring (0, idx) : original; } + internal static CookieCollection GetCookies ( + this NameValueCollection headers, bool response + ) + { + var val = headers[response ? "Set-Cookie" : "Cookie"]; + return val != null + ? CookieCollection.Parse (val, response) + : new CookieCollection (); + } + internal static string GetDnsSafeHost (this Uri uri, bool bracketIPv6) { return bracketIPv6 && uri.HostNameType == UriHostNameType.IPv6 @@ -1148,27 +1158,6 @@ public static void Emit ( eventHandler (sender, e); } - /// - /// Gets the collection of the HTTP cookies from the specified HTTP . - /// - /// - /// A that receives a collection of the HTTP cookies. - /// - /// - /// A that contains a collection of the HTTP headers. - /// - /// - /// true if is a collection of the response headers; - /// otherwise, false. - /// - public static CookieCollection GetCookies (this NameValueCollection headers, bool response) - { - var name = response ? "Set-Cookie" : "Cookie"; - return headers != null && headers.Contains (name) - ? CookieCollection.Parse (headers[name], response) - : new CookieCollection (); - } - /// /// Gets the description of the specified HTTP status . /// From 8f2d5a593a28bdb84c16d3a85f3ca111b8ece9b5 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 25 Dec 2017 04:38:58 +0900 Subject: [PATCH 1728/6294] [Modify] Add it --- websocket-sharp/Ext.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 0f1ab9093..4bf90ac9f 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -597,6 +597,16 @@ internal static bool IsToken (this string value) return true; } + internal static bool KeepsAlive ( + this NameValueCollection headers, Version version + ) + { + var comparison = StringComparison.OrdinalIgnoreCase; + return version < HttpVersion.Version11 + ? headers.Contains ("Connection", "keep-alive", comparison) + : !headers.Contains ("Connection", "close", comparison); + } + internal static string Quote (this string value) { return String.Format ("\"{0}\"", value.Replace ("\"", "\\\"")); From 9cf21a78800eab53ca35f9352ad42cf534f5001e Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 25 Dec 2017 04:43:10 +0900 Subject: [PATCH 1729/6294] [Modify] Replace it --- websocket-sharp/Net/HttpListenerRequest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index 34d9aa8ad..feefbc82b 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -302,7 +302,7 @@ public bool IsWebSocketRequest { public bool KeepAlive { get { if (!_keepAliveSet) { - _keepAlive = keepAlive (); + _keepAlive = _headers.KeepsAlive (_version); _keepAliveSet = true; } From 0eabd637008e595603ff97232e01f3273b14fc20 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 25 Dec 2017 04:47:41 +0900 Subject: [PATCH 1730/6294] [Modify] Remove it --- websocket-sharp/Net/HttpListenerRequest.cs | 8 -------- 1 file changed, 8 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index feefbc82b..1327092c9 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -462,14 +462,6 @@ public string[] UserLanguages { #region Private Methods - private bool keepAlive () - { - var comparison = StringComparison.OrdinalIgnoreCase; - return _version > HttpVersion.Version10 - ? !_headers.Contains ("Connection", "close", comparison) - : _headers.Contains ("Connection", "keep-alive", comparison); - } - private static bool tryCreateVersion (string version, out Version result) { try { From c0502fe4e1842f9b033f0ce0027666be43ea7b23 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 25 Dec 2017 16:13:00 +0900 Subject: [PATCH 1731/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerRequest.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index 1327092c9..e58da9142 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -464,14 +464,16 @@ public string[] UserLanguages { private static bool tryCreateVersion (string version, out Version result) { + result = null; + try { result = new Version (version); - return true; } catch { - result = null; return false; } + + return true; } #endregion From 65337146ec8f94ff8d7d673b2286040ac5a584c8 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 26 Dec 2017 16:22:38 +0900 Subject: [PATCH 1732/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerRequest.cs | 46 +++++++++++++++++----- 1 file changed, 37 insertions(+), 9 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index e58da9142..6a4b59ef2 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -612,25 +612,53 @@ internal bool IsUpgradeRequest (string protocol) internal void SetRequestLine (string requestLine) { var parts = requestLine.Split (new[] { ' ' }, 3); - if (parts.Length != 3) { + if (parts.Length < 3) { _context.ErrorMessage = "Invalid request line (parts)"; return; } - _method = parts[0]; - if (!_method.IsToken ()) { + var method = parts[0]; + if (method.Length == 0) { _context.ErrorMessage = "Invalid request line (method)"; return; } - _uri = parts[1]; + if (!method.IsToken ()) { + _context.ErrorMessage = "Invalid request line (method)"; + return; + } + + var uri = parts[1]; + if (uri.Length == 0) { + _context.ErrorMessage = "Invalid request line (uri)"; + return; + } - var ver = parts[2]; - if (ver.Length != 8 || - !ver.StartsWith ("HTTP/") || - !tryCreateVersion (ver.Substring (5), out _version) || - _version.Major < 1) + var rawVer = parts[2]; + if (rawVer.Length != 8) { _context.ErrorMessage = "Invalid request line (version)"; + return; + } + + if (rawVer.IndexOf ("HTTP/") != 0) { + _context.ErrorMessage = "Invalid request line (version)"; + return; + } + + Version ver; + if (!tryCreateVersion (rawVer.Substring (5), out ver)) { + _context.ErrorMessage = "Invalid request line (version)"; + return; + } + + if (ver.Major < 1) { + _context.ErrorMessage = "Invalid request line (version)"; + return; + } + + _method = method; + _uri = uri; + _version = ver; } #endregion From 05e9629652bee3537a5ea43e9e56bed5c7525630 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 27 Dec 2017 14:43:09 +0900 Subject: [PATCH 1733/6294] [Modify] Move it --- websocket-sharp/Ext.cs | 16 ++++++++++++++++ websocket-sharp/Net/HttpListenerRequest.cs | 20 +------------------- 2 files changed, 17 insertions(+), 19 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 4bf90ac9f..5d6452f4c 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -918,6 +918,22 @@ internal static string TrimSlashOrBackslashFromEnd (this string value) return ret.Length > 0 ? ret : value[0].ToString (); } + internal static bool TryCreateVersion ( + this string versionString, out Version result + ) + { + result = null; + + try { + result = new Version (versionString); + } + catch { + return false; + } + + return true; + } + /// /// Tries to create a new for WebSocket with /// the specified . diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index 6a4b59ef2..a444b60d1 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -460,24 +460,6 @@ public string[] UserLanguages { #endregion - #region Private Methods - - private static bool tryCreateVersion (string version, out Version result) - { - result = null; - - try { - result = new Version (version); - } - catch { - return false; - } - - return true; - } - - #endregion - #region Internal Methods internal void AddHeader (string header) @@ -646,7 +628,7 @@ internal void SetRequestLine (string requestLine) } Version ver; - if (!tryCreateVersion (rawVer.Substring (5), out ver)) { + if (!rawVer.Substring (5).TryCreateVersion (out ver)) { _context.ErrorMessage = "Invalid request line (version)"; return; } From 3651d12408401a81cc2ad7e15890e2a77dc2fb4d Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 28 Dec 2017 19:42:07 +0900 Subject: [PATCH 1734/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerRequest.cs | 30 +++++++++++++++------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index a444b60d1..7a8ff15fe 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -462,21 +462,24 @@ public string[] UserLanguages { #region Internal Methods - internal void AddHeader (string header) + internal void AddHeader (string headerLine) { - var colon = header.IndexOf (':'); - if (colon == -1) { - _context.ErrorMessage = "Invalid header"; + var colon = headerLine.IndexOf (':'); + if (colon < 1) { + _context.ErrorMessage = "Invalid header line"; return; } - var name = header.Substring (0, colon).Trim (); - var val = header.Substring (colon + 1).Trim (); + var name = headerLine.Substring (0, colon).Trim (); + var val = colon < headerLine.Length - 1 + ? headerLine.Substring (colon + 1).Trim () + : String.Empty; + _headers.InternalSet (name, val, false); var lower = name.ToLower (CultureInfo.InvariantCulture); if (lower == "accept") { - _acceptTypes = new List (val.SplitHeaderValue (',')).ToArray (); + _acceptTypes = val.SplitHeaderValue (',').ToList ().ToArray (); return; } @@ -509,8 +512,17 @@ internal void AddHeader (string header) return; } - if (lower == "referer") - _referer = val.ToUri (); + if (lower == "referer") { + var referer = val.ToUri (); + if (referer != null) { + _referer = referer; + } + else { + _context.ErrorMessage = "Invalid Referer header"; + } + + return; + } } internal void FinishInitialization () From 86a473caef38cd7f9505542de084aa145b1cb7eb Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 29 Dec 2017 22:00:57 +0900 Subject: [PATCH 1735/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerRequest.cs | 41 +++++++++++++++------- 1 file changed, 28 insertions(+), 13 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index 7a8ff15fe..6955e7600 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -528,35 +528,44 @@ internal void AddHeader (string headerLine) internal void FinishInitialization () { var host = _headers["Host"]; - var nohost = host == null || host.Length == 0; - if (_version > HttpVersion.Version10 && nohost) { + var hasHost = host != null && host.Length > 0; + if (_version > HttpVersion.Version10 && !hasHost) { _context.ErrorMessage = "Invalid Host header"; return; } - if (nohost) - host = UserHostAddress; + _url = HttpUtility.CreateRequestUrl ( + _uri, + hasHost ? host : UserHostAddress, + IsWebSocketRequest, + IsSecureConnection + ); - _url = HttpUtility.CreateRequestUrl (_uri, host, IsWebSocketRequest, IsSecureConnection); if (_url == null) { _context.ErrorMessage = "Invalid request url"; return; } - var enc = Headers["Transfer-Encoding"]; - if (_version > HttpVersion.Version10 && enc != null && enc.Length > 0) { - _chunked = enc.ToLower () == "chunked"; - if (!_chunked) { + var transferEnc = _headers["Transfer-Encoding"]; + if (transferEnc != null) { + if (_version < HttpVersion.Version11) { + _context.ErrorMessage = "Invalid Transfer-Encoding header"; + return; + } + + var comparison = StringComparison.OrdinalIgnoreCase; + if (!transferEnc.Equals ("chunked", comparison)) { _context.ErrorMessage = String.Empty; _context.ErrorStatus = 501; return; } + + _chunked = true; } if (!_chunked && !_contentLengthSet) { - var method = _method.ToLower (); - if (method == "post" || method == "put") { + if (_method == "POST" || _method == "PUT") { _context.ErrorMessage = String.Empty; _context.ErrorStatus = 411; @@ -564,8 +573,14 @@ internal void FinishInitialization () } } - var expect = Headers["Expect"]; - if (expect != null && expect.Length > 0 && expect.ToLower () == "100-continue") { + var expect = _headers["Expect"]; + if (_version > HttpVersion.Version10 && expect != null) { + var comparison = StringComparison.OrdinalIgnoreCase; + if (!expect.Equals ("100-continue", comparison)) { + _context.ErrorMessage = "Invalid Expect header"; + return; + } + var output = _context.Connection.GetResponseStream (); output.InternalWrite (_100continue, 0, _100continue.Length); } From 29cdd3b169b2a2a443c23129151e0838d81be2b6 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 30 Dec 2017 16:42:57 +0900 Subject: [PATCH 1736/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerRequest.cs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index 6955e7600..df6d4e887 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -586,23 +586,25 @@ internal void FinishInitialization () } } - // Returns true is the stream could be reused. internal bool FlushInput () { if (!HasEntityBody) return true; var len = 2048; - if (_contentLength > 0) - len = (int) Math.Min (_contentLength, (long) len); + if (_contentLength > 0 && _contentLength < len) + len = (int) _contentLength; var buff = new byte[len]; + while (true) { - // TODO: Test if MS has a timeout when doing this. try { var ares = InputStream.BeginRead (buff, 0, len, null, null); - if (!ares.IsCompleted && !ares.AsyncWaitHandle.WaitOne (100)) - return false; + if (!ares.IsCompleted) { + var timeout = 100; + if (!ares.AsyncWaitHandle.WaitOne (timeout)) + return false; + } if (InputStream.EndRead (ares) <= 0) return true; From 626e717602d0922fa4d5071d55df6937b14e7afd Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 31 Dec 2017 16:17:13 +0900 Subject: [PATCH 1737/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerRequest.cs | 29 +++++++++++----------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index df6d4e887..acf3aee09 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -462,17 +462,17 @@ public string[] UserLanguages { #region Internal Methods - internal void AddHeader (string headerLine) + internal void AddHeader (string headerField) { - var colon = headerLine.IndexOf (':'); + var colon = headerField.IndexOf (':'); if (colon < 1) { - _context.ErrorMessage = "Invalid header line"; + _context.ErrorMessage = "Invalid header field"; return; } - var name = headerLine.Substring (0, colon).Trim (); - var val = colon < headerLine.Length - 1 - ? headerLine.Substring (colon + 1).Trim () + var name = headerField.Substring (0, colon).Trim (); + var val = colon < headerField.Length - 1 + ? headerField.Substring (colon + 1).Trim () : String.Empty; _headers.InternalSet (name, val, false); @@ -490,14 +490,14 @@ internal void AddHeader (string headerLine) if (lower == "content-length") { long len; - if (Int64.TryParse (val, out len) && len >= 0) { - _contentLength = len; - _contentLengthSet = true; - } - else { + if (!Int64.TryParse (val, out len) || len < 0) { _context.ErrorMessage = "Invalid Content-Length header"; + return; } + _contentLength = len; + _contentLengthSet = true; + return; } @@ -514,13 +514,12 @@ internal void AddHeader (string headerLine) if (lower == "referer") { var referer = val.ToUri (); - if (referer != null) { - _referer = referer; - } - else { + if (referer == null) { _context.ErrorMessage = "Invalid Referer header"; + return; } + _referer = referer; return; } } From 39e2bee87afb3fc345829dd8974249c6b832e7d9 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 1 Jan 2018 15:16:26 +0900 Subject: [PATCH 1738/6294] [Modify] 2018 --- LICENSE.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LICENSE.txt b/LICENSE.txt index bf3375396..c53829dc8 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2010-2017 sta.blockhead +Copyright (c) 2010-2018 sta.blockhead Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal From 0f7d125e60fdbb6bcb0d30f44630d8e6cfa66c46 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 2 Jan 2018 17:11:32 +0900 Subject: [PATCH 1739/6294] [Modify] Add a check for the header name It must be a token. --- websocket-sharp/Net/HttpListenerRequest.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index acf3aee09..56a5cb24b 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -471,6 +471,11 @@ internal void AddHeader (string headerField) } var name = headerField.Substring (0, colon).Trim (); + if (name.Length == 0 || !name.IsToken ()) { + _context.ErrorMessage = "Invalid header name"; + return; + } + var val = colon < headerField.Length - 1 ? headerField.Substring (colon + 1).Trim () : String.Empty; From 71385d5638d34a93aaaaaa3fd3e9cd9a69ecc049 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 3 Jan 2018 15:42:00 +0900 Subject: [PATCH 1740/6294] [Modify] Polish it --- websocket-sharp/Net/HttpUtility.cs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 3e3c78cf6..55728fe6a 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -612,11 +612,12 @@ Func credentialsFinder internal static Encoding GetEncoding (string contentType) { - var parts = contentType.Split (';'); - foreach (var p in parts) { - var part = p.Trim (); - if (part.StartsWith ("charset", StringComparison.OrdinalIgnoreCase)) - return Encoding.GetEncoding (part.GetValue ('=', true)); + foreach (var elm in contentType.Split (';')) { + var part = elm.Trim (); + if (part.IndexOf ("charset", StringComparison.OrdinalIgnoreCase) != 0) + continue; + + return Encoding.GetEncoding (part.GetValue ('=', true)); } return null; From 0e840a5df7c96a01ca44b85b038014e425b6a775 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 3 Jan 2018 16:42:38 +0900 Subject: [PATCH 1741/6294] [Modify] Add it --- websocket-sharp/Net/HttpUtility.cs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 55728fe6a..03223ade3 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -751,6 +751,22 @@ internal static byte[] InternalUrlEncodeUnicodeToBytes (string s) } } + internal static bool TryGetEncoding ( + string contentType, out Encoding result + ) + { + result = null; + + try { + result = GetEncoding (contentType); + } + catch { + return false; + } + + return true; + } + #endregion #region Public Methods From 2a26e222fcedbb5dad717292b170be4d09b1f338 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 4 Jan 2018 19:48:31 +0900 Subject: [PATCH 1742/6294] [Modify] Polish it --- websocket-sharp/Net/HttpUtility.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 03223ade3..1b15d3881 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -764,7 +764,7 @@ internal static bool TryGetEncoding ( return false; } - return true; + return result != null; } #endregion From 3afb60ae8431f46a915ddcd50a9313f409d4b2b8 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 5 Jan 2018 16:43:21 +0900 Subject: [PATCH 1743/6294] [Modify] Use Encoding.UTF8 if not available --- websocket-sharp/Net/HttpListenerRequest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index 56a5cb24b..3bb77c32f 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -141,7 +141,7 @@ public int ClientCertificateError { /// public Encoding ContentEncoding { get { - return _contentEncoding ?? (_contentEncoding = Encoding.Default); + return _contentEncoding ?? Encoding.UTF8; } } From 0b83518ae1ea6179af0417815a89587b313d74c1 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 5 Jan 2018 17:20:40 +0900 Subject: [PATCH 1744/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerRequest.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index 3bb77c32f..8ff663736 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -135,9 +135,14 @@ public int ClientCertificateError { /// Gets the encoding for the entity body data included in the request. /// /// - /// A that represents the encoding for the entity body data, - /// or if the request didn't include the information about - /// the encoding. + /// + /// A that represents the encoding for the entity + /// body data. + /// + /// + /// if the charset value from the Content-Type + /// header is not available. + /// /// public Encoding ContentEncoding { get { From e32194cdc84cac22001449cd3dfe3a74baad1c9b Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 6 Jan 2018 17:32:56 +0900 Subject: [PATCH 1745/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerRequest.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index 8ff663736..8652d38dc 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -151,11 +151,16 @@ public Encoding ContentEncoding { } /// - /// Gets the number of bytes in the entity body data included in the request. + /// Gets the length in bytes of the entity body data included in + /// the request. /// /// - /// A that represents the value of the Content-Length entity-header, - /// or -1 if the value isn't known. + /// + /// A from the value of the Content-Length header. + /// + /// + /// -1 if the value is not known. + /// /// public long ContentLength64 { get { From e93454e95284ca6af8ccc730019de738a3187a87 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 6 Jan 2018 17:38:50 +0900 Subject: [PATCH 1746/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerRequest.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index 8652d38dc..b9e6df984 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -169,10 +169,10 @@ public long ContentLength64 { } /// - /// Gets the media type of the entity body included in the request. + /// Gets the media type of the entity body data included in the request. /// /// - /// A that represents the value of the Content-Type entity-header. + /// A from the value of the Content-Type header. /// public string ContentType { get { From 5878c2f715402afbdc12d37f3b16b2d3cf80c154 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 6 Jan 2018 17:45:22 +0900 Subject: [PATCH 1747/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerRequest.cs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index b9e6df984..37926ee3d 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -136,12 +136,11 @@ public int ClientCertificateError { /// /// /// - /// A that represents the encoding for the entity - /// body data. + /// A from the charset value of the Content-Type + /// header. /// /// - /// if the charset value from the Content-Type - /// header is not available. + /// if the charset value is not available. /// /// public Encoding ContentEncoding { From 40d5046440e20e3ec82ec6b1625f1d3cdce351a1 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 7 Jan 2018 16:36:03 +0900 Subject: [PATCH 1748/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerRequest.cs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index 37926ee3d..59b0b0907 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -235,10 +235,16 @@ public string HttpMethod { /// public Stream InputStream { get { - return _inputStream ?? - (_inputStream = HasEntityBody - ? _context.Connection.GetRequestStream (_contentLength, _chunked) - : Stream.Null); + if (!HasEntityBody) + return Stream.Null; + + if (_inputStream == null) { + _inputStream = _context.Connection.GetRequestStream ( + _contentLength, _chunked + ); + } + + return _inputStream; } } From 42b83ddad39c5129d5a2e989e5448b2125682b6d Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 7 Jan 2018 17:05:29 +0900 Subject: [PATCH 1749/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerRequest.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index 59b0b0907..269d0f937 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -228,10 +228,16 @@ public string HttpMethod { } /// - /// Gets a that contains the entity body data included in the request. + /// Gets a stream that contains the entity body data included in + /// the request. /// /// - /// A that contains the entity body data included in the request. + /// + /// A that contains the entity body data. + /// + /// + /// if no entity body data is included. + /// /// public Stream InputStream { get { From 81afcde3575ad1337cc70b7aeffee39917e474d3 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 7 Jan 2018 17:18:27 +0900 Subject: [PATCH 1750/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerRequest.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index 269d0f937..59df88898 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -192,10 +192,11 @@ public CookieCollection Cookies { } /// - /// Gets a value indicating whether the request has the entity body. + /// Gets a value indicating whether the request has the entity body data. /// /// - /// true if the request has the entity body; otherwise, false. + /// true if the request has the entity body data; otherwise, + /// false. /// public bool HasEntityBody { get { From 40a4cdc2898223c077d51da71c75b73d2df01184 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 8 Jan 2018 16:18:36 +0900 Subject: [PATCH 1751/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerRequest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index 59df88898..b076c50ee 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -590,7 +590,7 @@ internal void FinishInitialization () _chunked = true; } - if (!_chunked && !_contentLengthSet) { + if (_contentLength == -1 && !_chunked) { if (_method == "POST" || _method == "PUT") { _context.ErrorMessage = String.Empty; _context.ErrorStatus = 411; From 99bb6189cee21063853318b35d49778206d40842 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 8 Jan 2018 16:27:35 +0900 Subject: [PATCH 1752/6294] [Modify] Remove it --- websocket-sharp/Net/HttpListenerRequest.cs | 3 --- 1 file changed, 3 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index b076c50ee..96fc58364 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -62,7 +62,6 @@ public sealed class HttpListenerRequest private bool _chunked; private Encoding _contentEncoding; private long _contentLength; - private bool _contentLengthSet; private HttpListenerContext _context; private CookieCollection _cookies; private WebHeaderCollection _headers; @@ -523,8 +522,6 @@ internal void AddHeader (string headerField) } _contentLength = len; - _contentLengthSet = true; - return; } From 1b3622d624ef669b2d1ebeda5f333ab2b5038887 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 8 Jan 2018 16:37:05 +0900 Subject: [PATCH 1753/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerRequest.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index 96fc58364..e1d23fc46 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -516,7 +516,12 @@ internal void AddHeader (string headerField) if (lower == "content-length") { long len; - if (!Int64.TryParse (val, out len) || len < 0) { + if (!Int64.TryParse (val, out len)) { + _context.ErrorMessage = "Invalid Content-Length header"; + return; + } + + if (len < 0) { _context.ErrorMessage = "Invalid Content-Length header"; return; } From 0ad54fde06d119a1f9dadc68b5c3f242aa8cdbdf Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 9 Jan 2018 16:18:45 +0900 Subject: [PATCH 1754/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerRequest.cs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index e1d23fc46..cc1940e86 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -322,12 +322,7 @@ public bool IsWebSocketRequest { /// public bool KeepAlive { get { - if (!_keepAliveSet) { - _keepAlive = _headers.KeepsAlive (_version); - _keepAliveSet = true; - } - - return _keepAlive; + return _headers.KeepsAlive (_version); } } From 7464f67d7c83f59e18f72921d5191e405e762833 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 9 Jan 2018 16:21:17 +0900 Subject: [PATCH 1755/6294] [Modify] Remove it --- websocket-sharp/Net/HttpListenerRequest.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index cc1940e86..b965b7607 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -67,8 +67,6 @@ public sealed class HttpListenerRequest private WebHeaderCollection _headers; private Guid _identifier; private Stream _inputStream; - private bool _keepAlive; - private bool _keepAliveSet; private string _method; private NameValueCollection _queryString; private Uri _referer; From 638daa2a21473fede4233bb93b50b9f9d0d84dcd Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 9 Jan 2018 16:30:05 +0900 Subject: [PATCH 1756/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerRequest.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index b965b7607..293b83212 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -311,8 +311,7 @@ public bool IsWebSocketRequest { } /// - /// Gets a value indicating whether the client requests a persistent - /// connection. + /// Gets a value indicating whether a persistent connection is requested. /// /// /// true if the request specifies that the connection is kept open; From 3b00f0d01dce45f0479f336555e88e5bcd1106f6 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 9 Jan 2018 16:39:06 +0900 Subject: [PATCH 1757/6294] [Modify] Add it --- websocket-sharp/Net/HttpListenerRequest.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index 293b83212..48501b12b 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -60,6 +60,7 @@ public sealed class HttpListenerRequest private static readonly byte[] _100continue; private string[] _acceptTypes; private bool _chunked; + private HttpConnection _connection; private Encoding _contentEncoding; private long _contentLength; private HttpListenerContext _context; @@ -93,6 +94,8 @@ static HttpListenerRequest () internal HttpListenerRequest (HttpListenerContext context) { _context = context; + + _connection = context.Connection; _contentLength = -1; _headers = new WebHeaderCollection (); _identifier = Guid.NewGuid (); From 113c92e8e84c6759844682e1c85340b00cda98d4 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 9 Jan 2018 16:45:19 +0900 Subject: [PATCH 1758/6294] [Modify] Replace it --- websocket-sharp/Net/HttpListenerRequest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index 48501b12b..f5da86688 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -246,7 +246,7 @@ public Stream InputStream { return Stream.Null; if (_inputStream == null) { - _inputStream = _context.Connection.GetRequestStream ( + _inputStream = _connection.GetRequestStream ( _contentLength, _chunked ); } From 9ecebb4c75294b564f217f60c17e6c784f5d0546 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 10 Jan 2018 16:28:46 +0900 Subject: [PATCH 1759/6294] [Modify] Replace it --- websocket-sharp/Net/HttpListenerRequest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index f5da86688..ac767e797 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -287,7 +287,7 @@ public bool IsLocal { /// public bool IsSecureConnection { get { - return _context.Connection.IsSecure; + return _connection.IsSecure; } } From e8407ca467dcb76fdc904726ecaf30a2b7707c28 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 10 Jan 2018 16:56:59 +0900 Subject: [PATCH 1760/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerRequest.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index ac767e797..e333adda0 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -280,10 +280,12 @@ public bool IsLocal { } /// - /// Gets a value indicating whether the HTTP connection is secured using the SSL protocol. + /// Gets a value indicating whether a secure connection is used to send + /// the request. /// /// - /// true if the HTTP connection is secured; otherwise, false. + /// true if the connection is a secure connection; otherwise, + /// false. /// public bool IsSecureConnection { get { From e3107ac32317bb19186f0a87cd3103ed5beb39e2 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 10 Jan 2018 16:59:59 +0900 Subject: [PATCH 1761/6294] [Modify] Replace it --- websocket-sharp/Net/HttpListenerRequest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index e333adda0..7023df05c 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -336,7 +336,7 @@ public bool KeepAlive { /// public System.Net.IPEndPoint LocalEndPoint { get { - return _context.Connection.LocalEndPoint; + return _connection.LocalEndPoint; } } From 2749fb3d72818c473dbe7fdd8f57388029074f95 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 11 Jan 2018 05:03:22 +0900 Subject: [PATCH 1762/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerRequest.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index 7023df05c..5d1dfd909 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -329,10 +329,11 @@ public bool KeepAlive { } /// - /// Gets the server endpoint as an IP address and a port number. + /// Gets the endpoint to which the request is sent. /// /// - /// A that represents the server endpoint. + /// A that represents the server IP + /// address and port number. /// public System.Net.IPEndPoint LocalEndPoint { get { From 5517b7447c18b4c05e8745432b12b4db47cfdbcd Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 11 Jan 2018 05:05:29 +0900 Subject: [PATCH 1763/6294] [Modify] Replace it --- websocket-sharp/Net/HttpListenerRequest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index 5d1dfd909..829cdd2a8 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -386,7 +386,7 @@ public string RawUrl { /// public System.Net.IPEndPoint RemoteEndPoint { get { - return _context.Connection.RemoteEndPoint; + return _connection.RemoteEndPoint; } } From 05d0b110078b6e98331d1ad51656d0556668e1ad Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 11 Jan 2018 16:18:32 +0900 Subject: [PATCH 1764/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerRequest.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index 829cdd2a8..e45d3e7f0 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -379,10 +379,11 @@ public string RawUrl { } /// - /// Gets the client endpoint as an IP address and a port number. + /// Gets the endpoint from which the request is sent. /// /// - /// A that represents the client endpoint. + /// A that represents the client IP + /// address and port number. /// public System.Net.IPEndPoint RemoteEndPoint { get { From 9205494df4c492fe8c11d1770b2e0084804a866e Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 11 Jan 2018 16:22:50 +0900 Subject: [PATCH 1765/6294] [Modify] Replace it --- websocket-sharp/Net/HttpListenerRequest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index e45d3e7f0..ee690b372 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -608,7 +608,7 @@ internal void FinishInitialization () return; } - var output = _context.Connection.GetResponseStream (); + var output = _connection.GetResponseStream (); output.InternalWrite (_100continue, 0, _100continue.Length); } } From c1c941cdd92d7bd157d24ced398bbdcf346eff91 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 12 Jan 2018 04:17:45 +0900 Subject: [PATCH 1766/6294] [Modify] Polish it --- websocket-sharp/Net/HttpConnection.cs | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/websocket-sharp/Net/HttpConnection.cs b/websocket-sharp/Net/HttpConnection.cs index 36d9a461e..2dde21569 100644 --- a/websocket-sharp/Net/HttpConnection.cs +++ b/websocket-sharp/Net/HttpConnection.cs @@ -90,20 +90,25 @@ internal HttpConnection (Socket socket, EndPointListener listener) { _socket = socket; _listener = listener; - _secure = listener.IsSecure; var netStream = new NetworkStream (socket, false); - if (_secure) { - var conf = listener.SslConfiguration; - var sslStream = new SslStream (netStream, false, conf.ClientCertificateValidationCallback); + if (listener.IsSecure) { + var sslConf = listener.SslConfiguration; + var sslStream = new SslStream ( + netStream, + false, + sslConf.ClientCertificateValidationCallback + ); + sslStream.AuthenticateAsServer ( - conf.ServerCertificate, - conf.ClientCertificateRequired, - conf.EnabledSslProtocols, - conf.CheckCertificateRevocation + sslConf.ServerCertificate, + sslConf.ClientCertificateRequired, + sslConf.EnabledSslProtocols, + sslConf.CheckCertificateRevocation ); _stream = sslStream; + _secure = true; } else { _stream = netStream; From 2721fe90d74c757b713f290d12026d8ea93a3c36 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 12 Jan 2018 04:38:59 +0900 Subject: [PATCH 1767/6294] [Modify] Replace it --- websocket-sharp/Net/HttpConnection.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpConnection.cs b/websocket-sharp/Net/HttpConnection.cs index 2dde21569..f231c4b8e 100644 --- a/websocket-sharp/Net/HttpConnection.cs +++ b/websocket-sharp/Net/HttpConnection.cs @@ -70,6 +70,7 @@ internal sealed class HttpConnection private HttpListener _lastListener; private LineState _lineState; private EndPointListener _listener; + private EndPoint _localEndPoint; private ResponseStream _outputStream; private int _position; private MemoryStream _requestBuffer; @@ -91,6 +92,8 @@ internal HttpConnection (Socket socket, EndPointListener listener) _socket = socket; _listener = listener; + _localEndPoint = socket.LocalEndPoint; + var netStream = new NetworkStream (socket, false); if (listener.IsSecure) { var sslConf = listener.SslConfiguration; @@ -140,7 +143,7 @@ public bool IsSecure { public IPEndPoint LocalEndPoint { get { - return (IPEndPoint) _socket.LocalEndPoint; + return (IPEndPoint) _localEndPoint; } } From 392a064147664bc5ec105b98ef22f608b590f983 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 12 Jan 2018 04:44:37 +0900 Subject: [PATCH 1768/6294] [Modify] Replace it --- websocket-sharp/Net/HttpConnection.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpConnection.cs b/websocket-sharp/Net/HttpConnection.cs index f231c4b8e..94565d342 100644 --- a/websocket-sharp/Net/HttpConnection.cs +++ b/websocket-sharp/Net/HttpConnection.cs @@ -73,6 +73,7 @@ internal sealed class HttpConnection private EndPoint _localEndPoint; private ResponseStream _outputStream; private int _position; + private EndPoint _remoteEndPoint; private MemoryStream _requestBuffer; private int _reuses; private bool _secure; @@ -93,6 +94,7 @@ internal HttpConnection (Socket socket, EndPointListener listener) _listener = listener; _localEndPoint = socket.LocalEndPoint; + _remoteEndPoint = socket.RemoteEndPoint; var netStream = new NetworkStream (socket, false); if (listener.IsSecure) { @@ -149,7 +151,7 @@ public IPEndPoint LocalEndPoint { public IPEndPoint RemoteEndPoint { get { - return (IPEndPoint) _socket.RemoteEndPoint; + return (IPEndPoint) _remoteEndPoint; } } From b7ba0466077f9829e2e93a1d6f07be7d0b6ff501 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 12 Jan 2018 04:52:26 +0900 Subject: [PATCH 1769/6294] [Modify] Add it --- websocket-sharp/Net/HttpConnection.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/websocket-sharp/Net/HttpConnection.cs b/websocket-sharp/Net/HttpConnection.cs index 94565d342..70a23f24b 100644 --- a/websocket-sharp/Net/HttpConnection.cs +++ b/websocket-sharp/Net/HttpConnection.cs @@ -137,6 +137,12 @@ public bool IsClosed { } } + public bool IsLocal { + get { + return ((IPEndPoint) _remoteEndPoint).Address.IsLocal (); + } + } + public bool IsSecure { get { return _secure; From c629e207514d7819c8ea6fa87267112351437360 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 12 Jan 2018 16:49:37 +0900 Subject: [PATCH 1770/6294] [Modify] Replace it --- websocket-sharp/Net/HttpListenerRequest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index ee690b372..fc9c92ebb 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -275,7 +275,7 @@ public bool IsAuthenticated { /// public bool IsLocal { get { - return RemoteEndPoint.Address.IsLocal (); + return _connection.IsLocal; } } From d3a09abc28ac46869c5c819b7ee0dfec8205dec2 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 13 Jan 2018 03:46:20 +0900 Subject: [PATCH 1771/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerRequest.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index fc9c92ebb..f95fd5f5b 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -268,10 +268,12 @@ public bool IsAuthenticated { } /// - /// Gets a value indicating whether the request is sent from the local computer. + /// Gets a value indicating whether the request is sent from the local + /// computer. /// /// - /// true if the request is sent from the local computer; otherwise, false. + /// true if the request is sent from the same computer as the server; + /// otherwise, false. /// public bool IsLocal { get { From 7de9b14d3d41b2d00dde383ca0bc6b888480b58a Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 13 Jan 2018 03:51:31 +0900 Subject: [PATCH 1772/6294] [Modify] Replace it --- websocket-sharp/Net/HttpListenerRequest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index f95fd5f5b..2873eac8e 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -450,7 +450,7 @@ public string UserAgent { /// public string UserHostAddress { get { - return LocalEndPoint.ToString (); + return _connection.LocalEndPoint.ToString (); } } From 984d424929aab65908b6c2178c6d443a7ebbee38 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 13 Jan 2018 16:40:49 +0900 Subject: [PATCH 1773/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerRequest.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index 2873eac8e..13883a732 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -443,10 +443,11 @@ public string UserAgent { } /// - /// Gets the server endpoint as an IP address and a port number. + /// Gets the IP address and port number to which the request is sent. /// /// - /// A that represents the server endpoint. + /// A that represents the server IP address and port + /// number. /// public string UserHostAddress { get { From 0ba66fa937b52cb1528bedb0f25c003eb8685ac9 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 13 Jan 2018 16:49:02 +0900 Subject: [PATCH 1774/6294] [Modify] Polish it --- websocket-sharp/Net/HttpConnection.cs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/HttpConnection.cs b/websocket-sharp/Net/HttpConnection.cs index 70a23f24b..44fb84b9d 100644 --- a/websocket-sharp/Net/HttpConnection.cs +++ b/websocket-sharp/Net/HttpConnection.cs @@ -93,9 +93,6 @@ internal HttpConnection (Socket socket, EndPointListener listener) _socket = socket; _listener = listener; - _localEndPoint = socket.LocalEndPoint; - _remoteEndPoint = socket.RemoteEndPoint; - var netStream = new NetworkStream (socket, false); if (listener.IsSecure) { var sslConf = listener.SslConfiguration; @@ -112,13 +109,15 @@ internal HttpConnection (Socket socket, EndPointListener listener) sslConf.CheckCertificateRevocation ); - _stream = sslStream; _secure = true; + _stream = sslStream; } else { _stream = netStream; } + _localEndPoint = socket.LocalEndPoint; + _remoteEndPoint = socket.RemoteEndPoint; _sync = new object (); _timeout = 90000; // 90k ms for first request, 15k ms from then on. _timeoutCanceled = new Dictionary (); From f89b2cd976701fbca3700909970257d3139c8891 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 14 Jan 2018 05:03:14 +0900 Subject: [PATCH 1775/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerRequest.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index 13883a732..d4eb76251 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -187,7 +187,10 @@ public string ContentType { /// public CookieCollection Cookies { get { - return _cookies ?? (_cookies = _headers.GetCookies (false)); + if (_cookies == null) + _cookies = _headers.GetCookies (false); + + return _cookies; } } From 009d6b15196811140d09fb15cb6cee831f4190d9 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 14 Jan 2018 05:18:57 +0900 Subject: [PATCH 1776/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerRequest.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index d4eb76251..d99e3f7b1 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -183,7 +183,12 @@ public string ContentType { /// Gets the cookies included in the request. /// /// - /// A that contains the cookies included in the request. + /// + /// A that contains the cookies. + /// + /// + /// An empty if not included. + /// /// public CookieCollection Cookies { get { From 8a9820d02c9844b07bb37f37e4144988c5a88ff5 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 14 Jan 2018 17:56:07 +0900 Subject: [PATCH 1777/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerRequest.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index d99e3f7b1..4079da7c2 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -371,8 +371,13 @@ public Version ProtocolVersion { /// public NameValueCollection QueryString { get { - return _queryString ?? - (_queryString = HttpUtility.InternalParseQueryString (_url.Query, Encoding.UTF8)); + if (_queryString == null) { + _queryString = HttpUtility.InternalParseQueryString ( + _url.Query, Encoding.UTF8 + ); + } + + return _queryString; } } From c88d64c7213ccf6550f2500d356a37ea52f5ae75 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 15 Jan 2018 16:31:40 +0900 Subject: [PATCH 1778/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerRequest.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index 4079da7c2..63f1870f3 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -367,7 +367,13 @@ public Version ProtocolVersion { /// Gets the query string included in the request. /// /// - /// A that contains the query string parameters. + /// + /// A that contains the query + /// parameters. + /// + /// + /// An empty collection if not included. + /// /// public NameValueCollection QueryString { get { From 7844d57ca6cf671d804c32fed71de4143d028f08 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 15 Jan 2018 16:34:54 +0900 Subject: [PATCH 1779/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerRequest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index 63f1870f3..42bf68f98 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -187,7 +187,7 @@ public string ContentType { /// A that contains the cookies. /// /// - /// An empty if not included. + /// An empty collection if not included. /// /// public CookieCollection Cookies { From 344bbd8b3699593406a63d88674130a0f24977e1 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 16 Jan 2018 17:13:06 +0900 Subject: [PATCH 1780/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerRequest.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index 42bf68f98..3ab4f3cc8 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -48,10 +48,10 @@ namespace WebSocketSharp.Net { /// - /// Provides the access to a request to the . + /// Represents an incoming request to a instance. /// /// - /// The HttpListenerRequest class cannot be inherited. + /// This class cannot be inherited. /// public sealed class HttpListenerRequest { From db049362ecd3cfeb6cd44ad7ea638941276c5716 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 17 Jan 2018 17:18:09 +0900 Subject: [PATCH 1781/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerRequest.cs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index 3ab4f3cc8..e5f8ecf7b 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -106,12 +106,16 @@ internal HttpListenerRequest (HttpListenerContext context) #region Public Properties /// - /// Gets the media types which are acceptable for the response. + /// Gets the media types which are acceptable for the client. /// /// - /// An array of that contains the media type names in - /// the Accept request-header, or if the request didn't include - /// the Accept header. + /// + /// An array of that contains the names of the media + /// types specified in the value of the Accept header. + /// + /// + /// if the request includes no Accept header. + /// /// public string[] AcceptTypes { get { From c3b2726016ed2980e610054b6f27fbfd119ad49f Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 18 Jan 2018 14:36:42 +0900 Subject: [PATCH 1782/6294] [Modify] Not support --- websocket-sharp/Net/HttpListenerRequest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index e5f8ecf7b..698ccc77b 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -131,7 +131,7 @@ public string[] AcceptTypes { /// public int ClientCertificateError { get { - return 0; // TODO: Always returns 0. + throw new NotSupportedException (); } } From eb56ec900e9b1e3c487554c27da2d130458a3844 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 18 Jan 2018 14:48:14 +0900 Subject: [PATCH 1783/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerRequest.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index 698ccc77b..12c5b1a50 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -124,11 +124,15 @@ public string[] AcceptTypes { } /// - /// Gets an error code that identifies a problem with the client's certificate. + /// Gets an error code that identifies a problem with the certificate + /// provided by the client. /// /// - /// Always returns 0. + /// An that represents an error code. /// + /// + /// This property is not supported. + /// public int ClientCertificateError { get { throw new NotSupportedException (); From d7e86529e40d2b0f6cd93d6c631d7b6a8bbdbfe0 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 18 Jan 2018 14:57:23 +0900 Subject: [PATCH 1784/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerRequest.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index 12c5b1a50..8cc09b518 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -179,7 +179,8 @@ public long ContentLength64 { /// Gets the media type of the entity body data included in the request. /// /// - /// A from the value of the Content-Type header. + /// A that represents the value of the Content-Type + /// header. /// public string ContentType { get { From 64ac8862c9a8f41040bebfd34a06efa239c9c818 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 18 Jan 2018 15:12:14 +0900 Subject: [PATCH 1785/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerRequest.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index 8cc09b518..4e6e313e9 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -222,10 +222,10 @@ public bool HasEntityBody { } /// - /// Gets the HTTP headers used in the request. + /// Gets the headers included in the request. /// /// - /// A that contains the HTTP headers used in the request. + /// A that contains the headers. /// public NameValueCollection Headers { get { From 118be8f47200e1c5b7988ad70c42646ad47bdf54 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 18 Jan 2018 15:21:18 +0900 Subject: [PATCH 1786/6294] [Modify] Rename it --- websocket-sharp/Net/HttpListenerRequest.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index 4e6e313e9..6a55d27d6 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -66,9 +66,9 @@ public sealed class HttpListenerRequest private HttpListenerContext _context; private CookieCollection _cookies; private WebHeaderCollection _headers; + private string _httpMethod; private Guid _identifier; private Stream _inputStream; - private string _method; private NameValueCollection _queryString; private Uri _referer; private string _uri; @@ -241,7 +241,7 @@ public NameValueCollection Headers { /// public string HttpMethod { get { - return _method; + return _httpMethod; } } @@ -323,7 +323,7 @@ public bool IsSecureConnection { public bool IsWebSocketRequest { get { if (!_websocketRequestSet) { - _websocketRequest = _method == "GET" + _websocketRequest = _httpMethod == "GET" && _version > HttpVersion.Version10 && _headers.Upgrades ("websocket"); @@ -623,7 +623,7 @@ internal void FinishInitialization () } if (_contentLength == -1 && !_chunked) { - if (_method == "POST" || _method == "PUT") { + if (_httpMethod == "POST" || _httpMethod == "PUT") { _context.ErrorMessage = String.Empty; _context.ErrorStatus = 411; @@ -725,7 +725,7 @@ internal void SetRequestLine (string requestLine) return; } - _method = method; + _httpMethod = method; _uri = uri; _version = ver; } @@ -810,7 +810,7 @@ public X509Certificate2 GetClientCertificate () public override string ToString () { var buff = new StringBuilder (64); - buff.AppendFormat ("{0} {1} HTTP/{2}\r\n", _method, _uri, _version); + buff.AppendFormat ("{0} {1} HTTP/{2}\r\n", _httpMethod, _uri, _version); buff.Append (_headers.ToString ()); return buff.ToString (); From 4d69989e093bc687db4b75d5bac6705bd067d138 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 19 Jan 2018 17:47:48 +0900 Subject: [PATCH 1787/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerRequest.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index 6a55d27d6..517bd5fca 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -234,10 +234,10 @@ public NameValueCollection Headers { } /// - /// Gets the HTTP method used in the request. + /// Gets the HTTP method specified by the client. /// /// - /// A that represents the HTTP method used in the request. + /// A that represents the HTTP method. /// public string HttpMethod { get { From d1f91c9391c05d6e5043d50826117bc52bf1f064 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 19 Jan 2018 17:50:10 +0900 Subject: [PATCH 1788/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerRequest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index 517bd5fca..f56cf9022 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -254,7 +254,7 @@ public string HttpMethod { /// A that contains the entity body data. /// /// - /// if no entity body data is included. + /// if not included. /// /// public Stream InputStream { From 3dd4e6f6b721ce49fa62863b918824959cb3fc35 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 19 Jan 2018 17:57:37 +0900 Subject: [PATCH 1789/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerRequest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index f56cf9022..62f3650f6 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -273,7 +273,7 @@ public Stream InputStream { } /// - /// Gets a value indicating whether the client that sent the request is authenticated. + /// Gets a value indicating whether the client is authenticated. /// /// /// true if the client is authenticated; otherwise, false. From c2b70b8d381c27a0810720dd7592076886ccb16f Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 20 Jan 2018 17:05:52 +0900 Subject: [PATCH 1790/6294] [Modify] Rename it --- websocket-sharp/Net/HttpListenerRequest.cs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index 62f3650f6..a2ac06b33 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -69,12 +69,12 @@ public sealed class HttpListenerRequest private string _httpMethod; private Guid _identifier; private Stream _inputStream; + private Version _protocolVersion; private NameValueCollection _queryString; private Uri _referer; private string _uri; private Uri _url; private string[] _userLanguages; - private Version _version; private bool _websocketRequest; private bool _websocketRequestSet; @@ -324,7 +324,7 @@ public bool IsWebSocketRequest { get { if (!_websocketRequestSet) { _websocketRequest = _httpMethod == "GET" - && _version > HttpVersion.Version10 + && _protocolVersion > HttpVersion.Version10 && _headers.Upgrades ("websocket"); _websocketRequestSet = true; @@ -343,7 +343,7 @@ public bool IsWebSocketRequest { /// public bool KeepAlive { get { - return _headers.KeepsAlive (_version); + return _headers.KeepsAlive (_protocolVersion); } } @@ -368,7 +368,7 @@ public System.Net.IPEndPoint LocalEndPoint { /// public Version ProtocolVersion { get { - return _version; + return _protocolVersion; } } @@ -587,7 +587,7 @@ internal void FinishInitialization () { var host = _headers["Host"]; var hasHost = host != null && host.Length > 0; - if (_version > HttpVersion.Version10 && !hasHost) { + if (_protocolVersion > HttpVersion.Version10 && !hasHost) { _context.ErrorMessage = "Invalid Host header"; return; } @@ -606,7 +606,7 @@ internal void FinishInitialization () var transferEnc = _headers["Transfer-Encoding"]; if (transferEnc != null) { - if (_version < HttpVersion.Version11) { + if (_protocolVersion < HttpVersion.Version11) { _context.ErrorMessage = "Invalid Transfer-Encoding header"; return; } @@ -632,7 +632,7 @@ internal void FinishInitialization () } var expect = _headers["Expect"]; - if (_version > HttpVersion.Version10 && expect != null) { + if (_protocolVersion > HttpVersion.Version10 && expect != null) { var comparison = StringComparison.OrdinalIgnoreCase; if (!expect.Equals ("100-continue", comparison)) { _context.ErrorMessage = "Invalid Expect header"; @@ -727,7 +727,7 @@ internal void SetRequestLine (string requestLine) _httpMethod = method; _uri = uri; - _version = ver; + _protocolVersion = ver; } #endregion @@ -810,7 +810,7 @@ public X509Certificate2 GetClientCertificate () public override string ToString () { var buff = new StringBuilder (64); - buff.AppendFormat ("{0} {1} HTTP/{2}\r\n", _httpMethod, _uri, _version); + buff.AppendFormat ("{0} {1} HTTP/{2}\r\n", _httpMethod, _uri, _protocolVersion); buff.Append (_headers.ToString ()); return buff.ToString (); From 7a9f7be7dae28f147379483453821de22dfdc353 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 20 Jan 2018 17:13:06 +0900 Subject: [PATCH 1791/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerRequest.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index a2ac06b33..a3e45bac8 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -361,10 +361,11 @@ public System.Net.IPEndPoint LocalEndPoint { } /// - /// Gets the HTTP version used in the request. + /// Gets the HTTP version specified by the client. /// /// - /// A that represents the HTTP version used in the request. + /// A that represents the HTTP version specified in + /// the request line. /// public Version ProtocolVersion { get { From 11b9a4abbcd6a2200dcb0016be0496534b24639d Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 20 Jan 2018 17:16:09 +0900 Subject: [PATCH 1792/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerRequest.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index a3e45bac8..19548a44b 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -237,7 +237,8 @@ public NameValueCollection Headers { /// Gets the HTTP method specified by the client. /// /// - /// A that represents the HTTP method. + /// A that represents the HTTP method specified in + /// the request line. /// public string HttpMethod { get { From 0acbc87d37358c5240ac5f6059d2e3749b68380b Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 21 Jan 2018 17:10:31 +0900 Subject: [PATCH 1793/6294] [Modify] Should not --- websocket-sharp/Net/HttpListenerRequest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index 19548a44b..8282bcbe1 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -406,7 +406,7 @@ public NameValueCollection QueryString { /// public string RawUrl { get { - return _url.PathAndQuery; // TODO: Should decode? + return _url.PathAndQuery; } } From a8f3110418f3883dd0a7f34b83f159494db83c9c Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 21 Jan 2018 17:26:06 +0900 Subject: [PATCH 1794/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerRequest.cs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index 8282bcbe1..06d2acad5 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -399,10 +399,17 @@ public NameValueCollection QueryString { } /// - /// Gets the raw URL (without the scheme, host, and port) requested by the client. + /// Gets the raw URL (without the scheme, host, and port) requested by + /// the client. /// /// - /// A that represents the raw URL requested by the client. + /// + /// A that represents the raw URL specified in + /// the request. + /// + /// + /// It includes the query string if present. + /// /// public string RawUrl { get { From e91c07a9806b7c135971e3de1f87a3a9a193644c Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 21 Jan 2018 17:42:14 +0900 Subject: [PATCH 1795/6294] [Modify] Rename it --- websocket-sharp/Net/HttpListenerRequest.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index 06d2acad5..a8a9caff4 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -67,11 +67,11 @@ public sealed class HttpListenerRequest private CookieCollection _cookies; private WebHeaderCollection _headers; private string _httpMethod; - private Guid _identifier; private Stream _inputStream; private Version _protocolVersion; private NameValueCollection _queryString; private Uri _referer; + private Guid _requestTraceIdentifier; private string _uri; private Uri _url; private string[] _userLanguages; @@ -98,7 +98,7 @@ internal HttpListenerRequest (HttpListenerContext context) _connection = context.Connection; _contentLength = -1; _headers = new WebHeaderCollection (); - _identifier = Guid.NewGuid (); + _requestTraceIdentifier = Guid.NewGuid (); } #endregion @@ -438,7 +438,7 @@ public System.Net.IPEndPoint RemoteEndPoint { /// public Guid RequestTraceIdentifier { get { - return _identifier; + return _requestTraceIdentifier; } } From 180db275a624f0e773b1f854876e8bc27a35643a Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 21 Jan 2018 17:52:28 +0900 Subject: [PATCH 1796/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerRequest.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index a8a9caff4..0b5198add 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -431,10 +431,10 @@ public System.Net.IPEndPoint RemoteEndPoint { } /// - /// Gets the request identifier of a incoming HTTP request. + /// Gets the trace identifier of the request. /// /// - /// A that represents the identifier of a request. + /// A that represents the trace identifier. /// public Guid RequestTraceIdentifier { get { From abfcc756cffc81ff1f22e915469d3fe1aa7c8a83 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 22 Jan 2018 16:23:19 +0900 Subject: [PATCH 1797/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerRequest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index 0b5198add..cc8804745 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -446,7 +446,7 @@ public Guid RequestTraceIdentifier { /// Gets the URL requested by the client. /// /// - /// A that represents the URL requested by the client. + /// A that represents the URL specified in the request. /// public Uri Url { get { From d334f1af5f81e021ba2045b3ac40862943f67d89 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 22 Jan 2018 16:27:40 +0900 Subject: [PATCH 1798/6294] [Modify] Rename it --- websocket-sharp/Net/HttpListenerRequest.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index cc8804745..27bad39a5 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -70,10 +70,10 @@ public sealed class HttpListenerRequest private Stream _inputStream; private Version _protocolVersion; private NameValueCollection _queryString; - private Uri _referer; private Guid _requestTraceIdentifier; private string _uri; private Uri _url; + private Uri _urlReferrer; private string[] _userLanguages; private bool _websocketRequest; private bool _websocketRequestSet; @@ -463,7 +463,7 @@ public Uri Url { /// public Uri UrlReferrer { get { - return _referer; + return _urlReferrer; } } @@ -587,7 +587,7 @@ internal void AddHeader (string headerField) return; } - _referer = referer; + _urlReferrer = referer; return; } } From 752411b2aa84661ae19c72af52c84f9f410ca454 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 22 Jan 2018 17:15:07 +0900 Subject: [PATCH 1799/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerRequest.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index 27bad39a5..86624f561 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -455,11 +455,15 @@ public Uri Url { } /// - /// Gets the URL of the resource from which the requested URL was obtained. + /// Gets the URI of the resource from which the requested URL was obtained. /// /// - /// A that represents the value of the Referer request-header, - /// or if the request didn't include an Referer header. + /// + /// A from the value of the Referer header. + /// + /// + /// if the Referer header is not present. + /// /// public Uri UrlReferrer { get { From c610068703f388dc4849c08a4d8e2af86ee4bf8e Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 22 Jan 2018 17:19:05 +0900 Subject: [PATCH 1800/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerRequest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index 86624f561..210f57874 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -114,7 +114,7 @@ internal HttpListenerRequest (HttpListenerContext context) /// types specified in the value of the Accept header. /// /// - /// if the request includes no Accept header. + /// if the Accept header is not present. /// /// public string[] AcceptTypes { From ee5acfa7dc91983968f4c73f348a6374e460d287 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 23 Jan 2018 17:07:15 +0900 Subject: [PATCH 1801/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerRequest.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index 210f57874..0d0aceb6f 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -472,10 +472,16 @@ public Uri UrlReferrer { } /// - /// Gets the information about the user agent originating the request. + /// Gets the user agent from which the request is originated. /// /// - /// A that represents the value of the User-Agent request-header. + /// + /// A that represents the value of the User-Agent + /// header. + /// + /// + /// if the User-Agent header is not present. + /// /// public string UserAgent { get { From 4a38b796476ceb75ff646e9db580d9b90c73040d Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 23 Jan 2018 17:38:16 +0900 Subject: [PATCH 1802/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerRequest.cs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index 0d0aceb6f..f8c9e68c1 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -503,10 +503,18 @@ public string UserHostAddress { } /// - /// Gets the internet host name and port number (if present) specified by the client. + /// Gets the server host name requested by the client. /// /// - /// A that represents the value of the Host request-header. + /// + /// A that represents the value of the Host header. + /// + /// + /// It includes the port number if provided. + /// + /// + /// if the Host header is not present. + /// /// public string UserHostName { get { From 3cc8c02292ba5483e5de8f2b60ad52a88843a794 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 24 Jan 2018 16:48:44 +0900 Subject: [PATCH 1803/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerRequest.cs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index f8c9e68c1..60c62df21 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -523,12 +523,17 @@ public string UserHostName { } /// - /// Gets the natural languages which are preferred for the response. + /// Gets the natural languages which are acceptable for the client. /// /// - /// An array of that contains the natural language names in - /// the Accept-Language request-header, or if the request - /// didn't include an Accept-Language header. + /// + /// An array of that contains the names of the + /// natural languages specified in the value of the Accept-Language + /// header. + /// + /// + /// if the Accept-Language header is not present. + /// /// public string[] UserLanguages { get { From c0dab3e4bb094fd1a13376218791939749f35a90 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 25 Jan 2018 16:56:03 +0900 Subject: [PATCH 1804/6294] [Modify] Move it --- websocket-sharp/Net/HttpListenerRequest.cs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index 60c62df21..8dc8651ce 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -537,6 +537,13 @@ public string UserHostName { /// public string[] UserLanguages { get { + var val = _headers["Accept-Language"]; + if (val == null) + return null; + + if (_userLanguages == null) + _userLanguages = val.Split (','); + return _userLanguages; } } @@ -571,11 +578,6 @@ internal void AddHeader (string headerField) return; } - if (lower == "accept-language") { - _userLanguages = val.Split (','); - return; - } - if (lower == "content-length") { long len; if (!Int64.TryParse (val, out len)) { From 0a0941ed1dab1b5bcfb471de5c1ee3efb66097eb Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 26 Jan 2018 17:02:27 +0900 Subject: [PATCH 1805/6294] [Modify] Add it --- websocket-sharp/Ext.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 5d6452f4c..1203e40bf 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -906,6 +906,12 @@ internal static ulong ToUInt64 (this byte[] source, ByteOrder sourceOrder) return BitConverter.ToUInt64 (source.ToHostOrder (sourceOrder), 0); } + internal static IEnumerable Trim (this IEnumerable source) + { + foreach (var elm in source) + yield return elm.Trim (); + } + internal static string TrimSlashFromEnd (this string value) { var ret = value.TrimEnd ('/'); From e7b2408bad36fda8bfa66c680ad48e99edb1add2 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 26 Jan 2018 17:14:00 +0900 Subject: [PATCH 1806/6294] [Modify] Trim each element --- websocket-sharp/Net/HttpListenerRequest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index 8dc8651ce..2d3334f6c 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -542,7 +542,7 @@ public string[] UserLanguages { return null; if (_userLanguages == null) - _userLanguages = val.Split (','); + _userLanguages = val.Split (',').Trim ().ToList ().ToArray (); return _userLanguages; } From 70f9c0399a6b6ad1e43a2da013b4b64ab57badde Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 26 Jan 2018 17:22:20 +0900 Subject: [PATCH 1807/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerRequest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index 2d3334f6c..ae2c29b06 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -523,7 +523,7 @@ public string UserHostName { } /// - /// Gets the natural languages which are acceptable for the client. + /// Gets the natural languages that are acceptable for the client. /// /// /// From b298b6a70ee5df8aa0000813f34fc6918d11acf5 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 27 Jan 2018 17:23:35 +0900 Subject: [PATCH 1808/6294] [Modify] Move it --- websocket-sharp/Net/HttpListenerRequest.cs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index ae2c29b06..add575e33 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -119,6 +119,13 @@ internal HttpListenerRequest (HttpListenerContext context) /// public string[] AcceptTypes { get { + var val = _headers["Accept"]; + if (val == null) + return null; + + if (_acceptTypes == null) + _acceptTypes = val.SplitHeaderValue (',').ToList ().ToArray (); + return _acceptTypes; } } @@ -573,11 +580,6 @@ internal void AddHeader (string headerField) _headers.InternalSet (name, val, false); var lower = name.ToLower (CultureInfo.InvariantCulture); - if (lower == "accept") { - _acceptTypes = val.SplitHeaderValue (',').ToList ().ToArray (); - return; - } - if (lower == "content-length") { long len; if (!Int64.TryParse (val, out len)) { From 8b2873a6e1e986e4c794e30f105c24ff8c2286fc Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 27 Jan 2018 17:28:36 +0900 Subject: [PATCH 1809/6294] [Modify] Trim each element --- websocket-sharp/Net/HttpListenerRequest.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index add575e33..2e68b0351 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -123,8 +123,13 @@ public string[] AcceptTypes { if (val == null) return null; - if (_acceptTypes == null) - _acceptTypes = val.SplitHeaderValue (',').ToList ().ToArray (); + if (_acceptTypes == null) { + _acceptTypes = val + .SplitHeaderValue (',') + .Trim () + .ToList () + .ToArray (); + } return _acceptTypes; } From b1e8fb231cb9ab9556c1ff66e21bee7ff00cfb06 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 27 Jan 2018 17:32:42 +0900 Subject: [PATCH 1810/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerRequest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index 2e68b0351..4ea2eda2b 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -106,7 +106,7 @@ internal HttpListenerRequest (HttpListenerContext context) #region Public Properties /// - /// Gets the media types which are acceptable for the client. + /// Gets the media types that are acceptable for the client. /// /// /// From 67dbc5e81059e3ecd5e5d0b17b9389be87b2925f Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 28 Jan 2018 16:41:05 +0900 Subject: [PATCH 1811/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerRequest.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index 4ea2eda2b..a74ef1cc7 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -191,8 +191,13 @@ public long ContentLength64 { /// Gets the media type of the entity body data included in the request. /// /// - /// A that represents the value of the Content-Type - /// header. + /// + /// A that represents the value of the Content-Type + /// header. + /// + /// + /// if the Content-Type header is not present. + /// /// public string ContentType { get { From 45c3e9a41ba2834fb6c0ca379185c1b974111a88 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 29 Jan 2018 15:48:58 +0900 Subject: [PATCH 1812/6294] [Modify] Move it --- websocket-sharp/Net/HttpListenerRequest.cs | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index a74ef1cc7..fbf1c2f3c 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -484,6 +484,13 @@ public Uri Url { /// public Uri UrlReferrer { get { + var val = _headers["Referer"]; + if (val == null) + return null; + + if (_urlReferrer == null) + _urlReferrer = val.ToUri (); + return _urlReferrer; } } @@ -616,17 +623,6 @@ internal void AddHeader (string headerField) return; } - - if (lower == "referer") { - var referer = val.ToUri (); - if (referer == null) { - _context.ErrorMessage = "Invalid Referer header"; - return; - } - - _urlReferrer = referer; - return; - } } internal void FinishInitialization () From 89653c239b5a0467dbda3b0ec83c898fb5b22887 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 29 Jan 2018 16:07:34 +0900 Subject: [PATCH 1813/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerRequest.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index fbf1c2f3c..4a1ebaa09 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -476,10 +476,11 @@ public Uri Url { /// /// /// - /// A from the value of the Referer header. + /// A converted from the value of the Referer header. /// /// - /// if the Referer header is not present. + /// if the Referer header is not present or + /// the conversion has failed. /// /// public Uri UrlReferrer { From 4aad50077fb9171b5f5d4803149f05eb235254fa Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 29 Jan 2018 16:46:51 +0900 Subject: [PATCH 1814/6294] [Modify] Edit it --- websocket-sharp/Ext.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 1203e40bf..7fdd8dc13 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1879,11 +1879,15 @@ public static string ToString (this T[] array, string separator) } /// - /// Converts the specified to a . + /// Converts the specified string to a . /// /// - /// A converted from or - /// if the convert has failed. + /// + /// A converted from . + /// + /// + /// if the conversion has failed. + /// /// /// /// A to convert. From 810741c3bafc3d49212a15034316eec9fab035fb Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 30 Jan 2018 16:11:56 +0900 Subject: [PATCH 1815/6294] [Modify] Rename it --- websocket-sharp/Net/HttpListenerRequest.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index 4a1ebaa09..7eb5973f4 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -70,8 +70,8 @@ public sealed class HttpListenerRequest private Stream _inputStream; private Version _protocolVersion; private NameValueCollection _queryString; + private string _rawUrl; private Guid _requestTraceIdentifier; - private string _uri; private Uri _url; private Uri _urlReferrer; private string[] _userLanguages; @@ -636,7 +636,7 @@ internal void FinishInitialization () } _url = HttpUtility.CreateRequestUrl ( - _uri, + _rawUrl, hasHost ? host : UserHostAddress, IsWebSocketRequest, IsSecureConnection @@ -740,9 +740,9 @@ internal void SetRequestLine (string requestLine) return; } - var uri = parts[1]; - if (uri.Length == 0) { - _context.ErrorMessage = "Invalid request line (uri)"; + var target = parts[1]; + if (target.Length == 0) { + _context.ErrorMessage = "Invalid request line (target)"; return; } @@ -769,7 +769,7 @@ internal void SetRequestLine (string requestLine) } _httpMethod = method; - _uri = uri; + _rawUrl = target; _protocolVersion = ver; } @@ -853,7 +853,7 @@ public X509Certificate2 GetClientCertificate () public override string ToString () { var buff = new StringBuilder (64); - buff.AppendFormat ("{0} {1} HTTP/{2}\r\n", _httpMethod, _uri, _protocolVersion); + buff.AppendFormat ("{0} {1} HTTP/{2}\r\n", _httpMethod, _rawUrl, _protocolVersion); buff.Append (_headers.ToString ()); return buff.ToString (); From 6c3f3115d2a4eebb9f7f7ce2cac42e81691d54b6 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 30 Jan 2018 16:16:46 +0900 Subject: [PATCH 1816/6294] [Modify] Replace it --- websocket-sharp/Net/HttpListenerRequest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index 7eb5973f4..49cc58d8f 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -430,7 +430,7 @@ public NameValueCollection QueryString { /// public string RawUrl { get { - return _url.PathAndQuery; + return _rawUrl; } } From 367164ca8d719de103dd02177812762ac4dcc105 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 31 Jan 2018 16:33:39 +0900 Subject: [PATCH 1817/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerRequest.cs | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index 49cc58d8f..70f115e5e 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -416,17 +416,11 @@ public NameValueCollection QueryString { } /// - /// Gets the raw URL (without the scheme, host, and port) requested by - /// the client. + /// Gets the raw URL specified by the client. /// /// - /// - /// A that represents the raw URL specified in - /// the request. - /// - /// - /// It includes the query string if present. - /// + /// A that represents the request target specified in + /// the request line. /// public string RawUrl { get { From f4ae8ab1da7d00b6e387df635581c22e8a5079ce Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 1 Feb 2018 16:29:22 +0900 Subject: [PATCH 1818/6294] [Modify] Add it --- websocket-sharp/Net/HttpListenerRequest.cs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index 70f115e5e..171eaa76b 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -569,6 +569,22 @@ public string[] UserLanguages { #endregion + #region Private Methods + + private Encoding getContentEncoding () + { + var val = _headers["Content-Type"]; + if (val == null) + return null; + + Encoding ret; + HttpUtility.TryGetEncoding (val, out ret); + + return ret; + } + + #endregion + #region Internal Methods internal void AddHeader (string headerField) From 7dfc6488950154d92ff0b25fd2706d1b07e76f52 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 1 Feb 2018 16:38:52 +0900 Subject: [PATCH 1819/6294] [Modify] Replace it --- websocket-sharp/Net/HttpListenerRequest.cs | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index 171eaa76b..62c99ab88 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -165,7 +165,10 @@ public int ClientCertificateError { /// public Encoding ContentEncoding { get { - return _contentEncoding ?? Encoding.UTF8; + if (_contentEncoding == null) + _contentEncoding = getContentEncoding () ?? Encoding.UTF8; + + return _contentEncoding; } } @@ -623,17 +626,6 @@ internal void AddHeader (string headerField) _contentLength = len; return; } - - if (lower == "content-type") { - try { - _contentEncoding = HttpUtility.GetEncoding (val); - } - catch { - _context.ErrorMessage = "Invalid Content-Type header"; - } - - return; - } } internal void FinishInitialization () From edeb1b79ddd7ac7391d134ab9852b93be7fae12e Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 2 Feb 2018 16:19:54 +0900 Subject: [PATCH 1820/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerRequest.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index 62c99ab88..de473f015 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -156,8 +156,8 @@ public int ClientCertificateError { /// /// /// - /// A from the charset value of the Content-Type - /// header. + /// A converted from the charset value of the + /// Content-Type header. /// /// /// if the charset value is not available. From 46731fc93ba96b9a0b9a95d90d40af2802c3d6ed Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 2 Feb 2018 16:32:59 +0900 Subject: [PATCH 1821/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 7fdd8dc13..6829c347d 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -470,7 +470,9 @@ internal static string GetValue (this string nameAndValue, char separator) : null; } - internal static string GetValue (this string nameAndValue, char separator, bool unquote) + internal static string GetValue ( + this string nameAndValue, char separator, bool unquote + ) { var idx = nameAndValue.IndexOf (separator); if (idx < 0 || idx == nameAndValue.Length - 1) From 38aa2fbe8e701f95d4e971b8190d1074bc13cc2d Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 2 Feb 2018 16:39:21 +0900 Subject: [PATCH 1822/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 6829c347d..857ec40ab 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -464,10 +464,7 @@ internal static string GetName (this string nameAndValue, char separator) /// internal static string GetValue (this string nameAndValue, char separator) { - var idx = nameAndValue.IndexOf (separator); - return idx > -1 && idx < nameAndValue.Length - 1 - ? nameAndValue.Substring (idx + 1).Trim () - : null; + return nameAndValue.GetValue (separator, false); } internal static string GetValue ( From fd655abee501346cbe588e80c4342248f5a0e8cd Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 3 Feb 2018 16:56:52 +0900 Subject: [PATCH 1823/6294] [Modify] Edit it --- websocket-sharp/Ext.cs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 857ec40ab..ad3e9ce1e 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -449,18 +449,22 @@ internal static string GetName (this string nameAndValue, char separator) } /// - /// Gets the value from the specified that contains a pair of name and - /// value separated by a separator character. + /// Gets the value from the specified string that contains a pair of + /// name and value separated by a character. /// /// - /// A that represents the value if any; otherwise, null. + /// + /// A that represents the value. + /// + /// + /// if the value is not present. + /// /// /// - /// A that contains a pair of name and value separated by - /// a separator character. + /// A that contains a pair of name and value. /// /// - /// A that represents the separator character. + /// A used to separate name and value. /// internal static string GetValue (this string nameAndValue, char separator) { From 8c0c52240ec4f832e69e8628d5ee785eb2c620a7 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 3 Feb 2018 17:06:28 +0900 Subject: [PATCH 1824/6294] [Modify] Edit it --- websocket-sharp/Ext.cs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index ad3e9ce1e..281674662 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -429,18 +429,22 @@ internal static string GetMessage (this CloseStatusCode code) } /// - /// Gets the name from the specified that contains a pair of name and - /// value separated by a separator character. + /// Gets the name from the specified string that contains a pair of + /// name and value separated by a character. /// /// - /// A that represents the name if any; otherwise, null. + /// + /// A that represents the name. + /// + /// + /// if the name is not present. + /// /// /// - /// A that contains a pair of name and value separated by - /// a separator character. + /// A that contains a pair of name and value. /// /// - /// A that represents the separator character. + /// A used to separate name and value. /// internal static string GetName (this string nameAndValue, char separator) { From e31c0278965d73f116aa35951361eab100b9835b Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 4 Feb 2018 18:05:46 +0900 Subject: [PATCH 1825/6294] [Modify] Edit it --- websocket-sharp/Ext.cs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 281674662..4bf2a1357 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -475,6 +475,28 @@ internal static string GetValue (this string nameAndValue, char separator) return nameAndValue.GetValue (separator, false); } + /// + /// Gets the value from the specified string that contains a pair of + /// name and value separated by a character. + /// + /// + /// + /// A that represents the value. + /// + /// + /// if the value is not present. + /// + /// + /// + /// A that contains a pair of name and value. + /// + /// + /// A used to separate name and value. + /// + /// + /// A : true if unquotes the value; otherwise, + /// false. + /// internal static string GetValue ( this string nameAndValue, char separator, bool unquote ) From 165dce676784ee3f841398bb3abeaf482dea6c47 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 5 Feb 2018 17:06:53 +0900 Subject: [PATCH 1826/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 4bf2a1357..098fa388a 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1087,17 +1087,17 @@ internal static bool TryOpenRead ( internal static string Unquote (this string value) { var start = value.IndexOf ('"'); - if (start < 0) + if (start == -1) return value; var end = value.LastIndexOf ('"'); - var len = end - start - 1; + if (end == start) + return value; - return len < 0 - ? value - : len == 0 - ? String.Empty - : value.Substring (start + 1, len).Replace ("\\\"", "\""); + var len = end - start - 1; + return len > 0 + ? value.Substring (start + 1, len).Replace ("\\\"", "\"") + : String.Empty; } internal static bool Upgrades ( From 2d47d5e663d501d44251319de3263f9bce2768ee Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 6 Feb 2018 17:10:43 +0900 Subject: [PATCH 1827/6294] [Modify] Polish it --- websocket-sharp/Net/HttpUtility.cs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 1b15d3881..26cd92712 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -612,12 +612,19 @@ Func credentialsFinder internal static Encoding GetEncoding (string contentType) { - foreach (var elm in contentType.Split (';')) { + var name = "charset="; + var comparison = StringComparison.OrdinalIgnoreCase; + + foreach (var elm in contentType.SplitHeaderValue (';')) { var part = elm.Trim (); - if (part.IndexOf ("charset", StringComparison.OrdinalIgnoreCase) != 0) + if (part.IndexOf (name, comparison) != 0) continue; - return Encoding.GetEncoding (part.GetValue ('=', true)); + var val = part.GetValue ('=', true); + if (val == null || val.Length == 0) + return null; + + return Encoding.GetEncoding (val); } return null; From e9a9e925c8cb692b6ce012024ab4a4d20cc77d89 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 7 Feb 2018 20:55:05 +0900 Subject: [PATCH 1828/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 43 ++++++++++++++++++++++++++---------------- 1 file changed, 27 insertions(+), 16 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 098fa388a..06066d164 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -825,33 +825,44 @@ internal static IEnumerable SplitHeaderValue ( var seps = new string (separators); var buff = new StringBuilder (32); + var end = len - 1; var escaped = false; var quoted = false; - for (var i = 0; i < len; i++) { + for (var i = 0; i <= end; i++) { var c = value[i]; + buff.Append (c); + if (c == '"') { - if (escaped) - escaped = !escaped; - else - quoted = !quoted; + if (escaped) { + escaped = false; + continue; + } + + quoted = !quoted; + continue; } - else if (c == '\\') { - if (i < len - 1 && value[i + 1] == '"') + + if (c == '\\') { + if (i == end) + break; + + if (value[i + 1] == '"') escaped = true; + + continue; } - else if (seps.Contains (c)) { - if (!quoted) { - yield return buff.ToString (); - buff.Length = 0; + if (seps.Contains (c)) { + if (quoted) continue; - } - } - else { - } - buff.Append (c); + buff.Length -= 1; + yield return buff.ToString (); + + buff.Length = 0; + continue; + } } yield return buff.ToString (); From 0791de41532be8f7ff74224485f5d17cb5e307f7 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 8 Feb 2018 16:48:38 +0900 Subject: [PATCH 1829/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 06066d164..9acd711b0 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -822,7 +822,7 @@ internal static IEnumerable SplitHeaderValue ( ) { var len = value.Length; - var seps = new string (separators); + var separator = new string (separators); var buff = new StringBuilder (32); var end = len - 1; @@ -853,7 +853,7 @@ internal static IEnumerable SplitHeaderValue ( continue; } - if (seps.Contains (c)) { + if (separator.Contains (c)) { if (quoted) continue; From 200153f56f6633b24b1f2e88fad3873341e9698a Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 9 Feb 2018 04:32:03 +0900 Subject: [PATCH 1830/6294] [Modify] Move it --- websocket-sharp/Ext.cs | 44 ++++++++++++++++++++---------------------- 1 file changed, 21 insertions(+), 23 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 9acd711b0..7ba04509b 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -197,6 +197,27 @@ internal static byte[] CompressToArray (this Stream stream, CompressionMethod me : stream.ToByteArray (); } + /// + /// Determines whether the specified contains any of characters in + /// the specified array of . + /// + /// + /// true if contains any of ; + /// otherwise, false. + /// + /// + /// A to test. + /// + /// + /// An array of that contains characters to find. + /// + internal static bool Contains (this string value, params char[] anyOf) + { + return anyOf != null && anyOf.Length > 0 + ? value.IndexOfAny (anyOf) > -1 + : false; + } + internal static bool Contains ( this NameValueCollection collection, string name ) @@ -1165,29 +1186,6 @@ internal static void WriteBytesAsync ( #region Public Methods - /// - /// Determines whether the specified contains any of characters in - /// the specified array of . - /// - /// - /// true if contains any of ; - /// otherwise, false. - /// - /// - /// A to test. - /// - /// - /// An array of that contains characters to find. - /// - public static bool Contains (this string value, params char[] chars) - { - return chars == null || chars.Length == 0 - ? true - : value == null || value.Length == 0 - ? false - : value.IndexOfAny (chars) > -1; - } - /// /// Emits the specified delegate if it isn't . /// From 79cfe5c10c865032dde0bd9b4662a73e431410f4 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 9 Feb 2018 04:52:47 +0900 Subject: [PATCH 1831/6294] [Modify] Edit it --- websocket-sharp/Ext.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 7ba04509b..83514fce5 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -198,18 +198,19 @@ internal static byte[] CompressToArray (this Stream stream, CompressionMethod me } /// - /// Determines whether the specified contains any of characters in + /// Determines whether the specified string contains any of characters in /// the specified array of . /// /// - /// true if contains any of ; - /// otherwise, false. + /// true if contains any of characters in + /// ; otherwise, false. /// /// /// A to test. /// /// - /// An array of that contains characters to find. + /// An array of that contains one or more characters to + /// seek. /// internal static bool Contains (this string value, params char[] anyOf) { From a7ebc2dd5688202aba95664c6f09e43ccfcbf6f7 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 9 Feb 2018 22:44:53 +0900 Subject: [PATCH 1832/6294] [Modify] Replace it --- websocket-sharp/Ext.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 83514fce5..481f06c05 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -875,7 +875,7 @@ internal static IEnumerable SplitHeaderValue ( continue; } - if (separator.Contains (c)) { + if (separator.IndexOf (c) > -1) { if (quoted) continue; From 6da865ac52920c1a5e8970b4e2649bc711e0f1ba Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 10 Feb 2018 16:51:04 +0900 Subject: [PATCH 1833/6294] [Modify] Replace it --- websocket-sharp/Ext.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 481f06c05..16d7805c8 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -844,7 +844,6 @@ internal static IEnumerable SplitHeaderValue ( ) { var len = value.Length; - var separator = new string (separators); var buff = new StringBuilder (32); var end = len - 1; @@ -875,7 +874,7 @@ internal static IEnumerable SplitHeaderValue ( continue; } - if (separator.IndexOf (c) > -1) { + if (Array.IndexOf (separators, c) > -1) { if (quoted) continue; From 9205a669a75daec11d02a4f2da25f1a48edcd134 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 10 Feb 2018 16:58:42 +0900 Subject: [PATCH 1834/6294] [Modify] Replace it --- websocket-sharp/Ext.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 16d7805c8..94f37eb9d 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -641,7 +641,7 @@ internal static bool IsToken (this string value) if (c >= 0x7f) return false; - if (_tspecials.Contains (c)) + if (_tspecials.IndexOf (c) > -1) return false; } From 7ec5daf80b3a5172eb2ab6f5825b7d61a54e2331 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 11 Feb 2018 19:26:48 +0900 Subject: [PATCH 1835/6294] [Modify] Replace them --- websocket-sharp/Ext.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 94f37eb9d..71e84695f 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -609,7 +609,7 @@ internal static bool IsText (this string value) for (var i = 0; i < len; i++) { var c = value[i]; if (c < 0x20) { - if (!"\r\n\t".Contains (c)) + if ("\r\n\t".IndexOf (c) == -1) return false; if (c == '\n') { @@ -618,7 +618,7 @@ internal static bool IsText (this string value) break; c = value[i]; - if (!" \t".Contains (c)) + if (" \t".IndexOf (c) == -1) return false; } From 35e88eed3d4252df6117849253ed6a342ea6e506 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 12 Feb 2018 19:38:44 +0900 Subject: [PATCH 1836/6294] [Modify] Add a check for the Content-Length header --- websocket-sharp/Net/HttpListenerRequest.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index de473f015..4f0628a7a 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -63,6 +63,7 @@ public sealed class HttpListenerRequest private HttpConnection _connection; private Encoding _contentEncoding; private long _contentLength; + private bool _contentLengthSet; private HttpListenerContext _context; private CookieCollection _cookies; private WebHeaderCollection _headers; @@ -612,6 +613,11 @@ internal void AddHeader (string headerField) var lower = name.ToLower (CultureInfo.InvariantCulture); if (lower == "content-length") { + if (_contentLengthSet) { + _context.ErrorMessage = "Invalid Content-Length header"; + return; + } + long len; if (!Int64.TryParse (val, out len)) { _context.ErrorMessage = "Invalid Content-Length header"; @@ -624,6 +630,8 @@ internal void AddHeader (string headerField) } _contentLength = len; + _contentLengthSet = true; + return; } } From f775caf21b15757fba377ca66c528667e5a96305 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 13 Feb 2018 15:50:55 +0900 Subject: [PATCH 1837/6294] [Modify] Add some checks for the Host header --- websocket-sharp/Net/HttpListenerRequest.cs | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index 4f0628a7a..646733f59 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -75,6 +75,8 @@ public sealed class HttpListenerRequest private Guid _requestTraceIdentifier; private Uri _url; private Uri _urlReferrer; + private string _userHostName; + private bool _userHostNameSet; private string[] _userLanguages; private bool _websocketRequest; private bool _websocketRequestSet; @@ -541,7 +543,7 @@ public string UserHostAddress { /// public string UserHostName { get { - return _headers["Host"]; + return _userHostName; } } @@ -612,6 +614,23 @@ internal void AddHeader (string headerField) _headers.InternalSet (name, val, false); var lower = name.ToLower (CultureInfo.InvariantCulture); + if (lower == "host") { + if (_userHostNameSet) { + _context.ErrorMessage = "Invalid Host header"; + return; + } + + if (val.Length == 0) { + _context.ErrorMessage = "Invalid Host header"; + return; + } + + _userHostName = val; + _userHostNameSet = true; + + return; + } + if (lower == "content-length") { if (_contentLengthSet) { _context.ErrorMessage = "Invalid Content-Length header"; From e1fa25f8723264eb6922ff80cca22aad8951a65b Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 14 Feb 2018 22:46:08 +0900 Subject: [PATCH 1838/6294] [Modify] Move it --- websocket-sharp/Net/HttpListenerRequest.cs | 28 ++++++++++++---------- websocket-sharp/Server/HttpServer.cs | 8 ++++++- 2 files changed, 22 insertions(+), 14 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index 646733f59..70821852e 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -75,6 +75,7 @@ public sealed class HttpListenerRequest private Guid _requestTraceIdentifier; private Uri _url; private Uri _urlReferrer; + private bool _urlSet; private string _userHostName; private bool _userHostNameSet; private string[] _userLanguages; @@ -412,8 +413,10 @@ public Version ProtocolVersion { public NameValueCollection QueryString { get { if (_queryString == null) { + var url = Url; _queryString = HttpUtility.InternalParseQueryString ( - _url.Query, Encoding.UTF8 + url != null ? url.Query : null, + Encoding.UTF8 ); } @@ -467,6 +470,17 @@ public Guid RequestTraceIdentifier { /// public Uri Url { get { + if (!_urlSet) { + _url = HttpUtility.CreateRequestUrl ( + _rawUrl, + _userHostName ?? UserHostAddress, + IsWebSocketRequest, + IsSecureConnection + ); + + _urlSet = true; + } + return _url; } } @@ -664,18 +678,6 @@ internal void FinishInitialization () return; } - _url = HttpUtility.CreateRequestUrl ( - _rawUrl, - hasHost ? host : UserHostAddress, - IsWebSocketRequest, - IsSecureConnection - ); - - if (_url == null) { - _context.ErrorMessage = "Invalid request url"; - return; - } - var transferEnc = _headers["Transfer-Encoding"]; if (transferEnc != null) { if (_protocolVersion < HttpVersion.Version11) { diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index e3436191a..7c1129651 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -924,7 +924,13 @@ private void processRequest (HttpListenerContext context) private void processRequest (HttpListenerWebSocketContext context) { - var path = context.RequestUri.AbsolutePath; + var uri = context.RequestUri; + if (uri == null) { + context.Close (HttpStatusCode.BadRequest); + return; + } + + var path = uri.AbsolutePath; WebSocketServiceHost host; if (!_services.InternalTryGetServiceHost (path, out host)) { From 2be3a3626beafcd58dc9e5768e582b69cb552bfb Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 15 Feb 2018 17:29:06 +0900 Subject: [PATCH 1839/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerRequest.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index 70821852e..0682280b3 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -466,7 +466,12 @@ public Guid RequestTraceIdentifier { /// Gets the URL requested by the client. /// /// - /// A that represents the URL specified in the request. + /// + /// A that represents the URL parsed from the request. + /// + /// + /// if the URL cannot be parsed. + /// /// public Uri Url { get { From 05b411a093e7e2c861d6ce603d0f088b53e0cbb1 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 16 Feb 2018 17:03:10 +0900 Subject: [PATCH 1840/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerRequest.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index 0682280b3..5af406115 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -676,10 +676,8 @@ internal void AddHeader (string headerField) internal void FinishInitialization () { - var host = _headers["Host"]; - var hasHost = host != null && host.Length > 0; - if (_protocolVersion > HttpVersion.Version10 && !hasHost) { - _context.ErrorMessage = "Invalid Host header"; + if (_protocolVersion > HttpVersion.Version10 && !_userHostNameSet) { + _context.ErrorMessage = "No Host header"; return; } From 9198ea6cf737e1c487f5e6a88a3e4e8071cbe660 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 17 Feb 2018 17:53:37 +0900 Subject: [PATCH 1841/6294] [Modify] Add it for HTTP/1.0 --- websocket-sharp/Net/HttpListenerRequest.cs | 30 ++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index 5af406115..0c5e73a8d 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -596,6 +596,36 @@ public string[] UserLanguages { #region Private Methods + private void finishInitialization10 () + { + var validMethod = _httpMethod == "GET" + || _httpMethod == "HEAD" + || _httpMethod == "POST"; + + if (!validMethod) { + _context.ErrorMessage = "Invalid request line (method)"; + return; + } + + if (_httpMethod == "POST") { + if (_contentLength == -1) { + _context.ErrorMessage = "Content-Length header required"; + return; + } + + if (_contentLength == 0) { + _context.ErrorMessage = "Invalid Content-Length header"; + return; + } + } + + var transferEnc = _headers["Transfer-Encoding"]; + if (transferEnc != null) { + _context.ErrorMessage = "Invalid Transfer-Encoding header"; + return; + } + } + private Encoding getContentEncoding () { var val = _headers["Content-Type"]; From 7e67cf540cab1131536d7067eeb570cf83828648 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 18 Feb 2018 17:41:55 +0900 Subject: [PATCH 1842/6294] [Modify] Use it --- websocket-sharp/Net/HttpListenerRequest.cs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index 0c5e73a8d..0d43189af 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -706,18 +706,18 @@ internal void AddHeader (string headerField) internal void FinishInitialization () { - if (_protocolVersion > HttpVersion.Version10 && !_userHostNameSet) { - _context.ErrorMessage = "No Host header"; + if (_protocolVersion == HttpVersion.Version10) { + finishInitialization10 (); + return; + } + + if (_userHostName == null) { + _context.ErrorMessage = "Host header required"; return; } var transferEnc = _headers["Transfer-Encoding"]; if (transferEnc != null) { - if (_protocolVersion < HttpVersion.Version11) { - _context.ErrorMessage = "Invalid Transfer-Encoding header"; - return; - } - var comparison = StringComparison.OrdinalIgnoreCase; if (!transferEnc.Equals ("chunked", comparison)) { _context.ErrorMessage = String.Empty; @@ -729,8 +729,8 @@ internal void FinishInitialization () _chunked = true; } - if (_contentLength == -1 && !_chunked) { - if (_httpMethod == "POST" || _httpMethod == "PUT") { + if (_httpMethod == "POST" || _httpMethod == "PUT") { + if (_contentLength <= 0 && !_chunked) { _context.ErrorMessage = String.Empty; _context.ErrorStatus = 411; @@ -739,7 +739,7 @@ internal void FinishInitialization () } var expect = _headers["Expect"]; - if (_protocolVersion > HttpVersion.Version10 && expect != null) { + if (expect != null) { var comparison = StringComparison.OrdinalIgnoreCase; if (!expect.Equals ("100-continue", comparison)) { _context.ErrorMessage = "Invalid Expect header"; From ffda43c459be2a5546b0e8711f9546d2502f3986 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 18 Feb 2018 17:49:49 +0900 Subject: [PATCH 1843/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerRequest.cs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index 0d43189af..f6f9c9570 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -77,7 +77,6 @@ public sealed class HttpListenerRequest private Uri _urlReferrer; private bool _urlSet; private string _userHostName; - private bool _userHostNameSet; private string[] _userLanguages; private bool _websocketRequest; private bool _websocketRequestSet; @@ -664,7 +663,7 @@ internal void AddHeader (string headerField) var lower = name.ToLower (CultureInfo.InvariantCulture); if (lower == "host") { - if (_userHostNameSet) { + if (_userHostName != null) { _context.ErrorMessage = "Invalid Host header"; return; } @@ -675,8 +674,6 @@ internal void AddHeader (string headerField) } _userHostName = val; - _userHostNameSet = true; - return; } From 2390007ffaf72e47d444ca26b721b046b9f43f02 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 19 Feb 2018 20:53:21 +0900 Subject: [PATCH 1844/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerRequest.cs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index f6f9c9570..c50a05c01 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -63,7 +63,6 @@ public sealed class HttpListenerRequest private HttpConnection _connection; private Encoding _contentEncoding; private long _contentLength; - private bool _contentLengthSet; private HttpListenerContext _context; private CookieCollection _cookies; private WebHeaderCollection _headers; @@ -678,7 +677,7 @@ internal void AddHeader (string headerField) } if (lower == "content-length") { - if (_contentLengthSet) { + if (_contentLength > -1) { _context.ErrorMessage = "Invalid Content-Length header"; return; } @@ -695,8 +694,6 @@ internal void AddHeader (string headerField) } _contentLength = len; - _contentLengthSet = true; - return; } } From ec6bfb9955cca299722f474ab56bdf4952b269ff Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 20 Feb 2018 17:51:37 +0900 Subject: [PATCH 1845/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerRequest.cs | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index c50a05c01..049be517a 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -77,8 +77,6 @@ public sealed class HttpListenerRequest private bool _urlSet; private string _userHostName; private string[] _userLanguages; - private bool _websocketRequest; - private bool _websocketRequestSet; #endregion @@ -345,15 +343,9 @@ public bool IsSecureConnection { /// public bool IsWebSocketRequest { get { - if (!_websocketRequestSet) { - _websocketRequest = _httpMethod == "GET" - && _protocolVersion > HttpVersion.Version10 - && _headers.Upgrades ("websocket"); - - _websocketRequestSet = true; - } - - return _websocketRequest; + return _httpMethod == "GET" + && _protocolVersion > HttpVersion.Version10 + && _headers.Upgrades ("websocket"); } } From 9f7ee0829596bf399e0798a6425c2a670614285d Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 21 Feb 2018 17:29:16 +0900 Subject: [PATCH 1846/6294] [Modify] Polish it --- websocket-sharp/Net/HttpConnection.cs | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/websocket-sharp/Net/HttpConnection.cs b/websocket-sharp/Net/HttpConnection.cs index 44fb84b9d..60df3f7b1 100644 --- a/websocket-sharp/Net/HttpConnection.cs +++ b/websocket-sharp/Net/HttpConnection.cs @@ -502,26 +502,34 @@ public void Close () public RequestStream GetRequestStream (long contentLength, bool chunked) { - if (_inputStream != null || _socket == null) - return _inputStream; - lock (_sync) { if (_socket == null) return _inputStream; + if (_inputStream != null) + return _inputStream; + var buff = _requestBuffer.GetBuffer (); var len = (int) _requestBuffer.Length; disposeRequestBuffer (); + if (chunked) { _context.Response.SendChunked = true; - _inputStream = - new ChunkedRequestStream (_stream, buff, _position, len - _position, _context); - } - else { - _inputStream = - new RequestStream (_stream, buff, _position, len - _position, contentLength); + _inputStream = new ChunkedRequestStream ( + _stream, buff, _position, len - _position, _context + ); + + return _inputStream; } + _inputStream = new RequestStream ( + _stream, + buff, + _position, + len - _position, + contentLength + ); + return _inputStream; } } From f34eb021b3ab6b9cc690b3c2d813a508e8d333aa Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 21 Feb 2018 17:43:48 +0900 Subject: [PATCH 1847/6294] [Modify] Add it --- websocket-sharp/Net/HttpListenerRequest.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index 049be517a..5f1ce8c24 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -628,6 +628,13 @@ private Encoding getContentEncoding () return ret; } + private RequestStream getInputStream () + { + return _contentLength > 0 || _chunked + ? _connection.GetRequestStream (_contentLength, _chunked) + : null; + } + #endregion #region Internal Methods From 878626da4ae99b3c2339934d3a4bc824841dbcf4 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 22 Feb 2018 16:50:16 +0900 Subject: [PATCH 1848/6294] [Modify] Replace it --- websocket-sharp/Net/HttpListenerRequest.cs | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index 5f1ce8c24..2f78d3c3f 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -280,14 +280,8 @@ public string HttpMethod { /// public Stream InputStream { get { - if (!HasEntityBody) - return Stream.Null; - - if (_inputStream == null) { - _inputStream = _connection.GetRequestStream ( - _contentLength, _chunked - ); - } + if (_inputStream == null) + _inputStream = getInputStream () ?? Stream.Null; return _inputStream; } From 187022a27ae8acd0d236149c7116d546564dd2b1 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 23 Feb 2018 18:16:34 +0900 Subject: [PATCH 1849/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerRequest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index 2f78d3c3f..ee53344df 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -275,7 +275,7 @@ public string HttpMethod { /// A that contains the entity body data. /// /// - /// if not included. + /// if the entity body data is not available. /// /// public Stream InputStream { From 465949f4f0160992494e85a846ffe0d9943c708a Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 24 Feb 2018 19:31:27 +0900 Subject: [PATCH 1850/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerRequest.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index ee53344df..006882c5f 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -740,7 +740,8 @@ internal void FinishInitialization () internal bool FlushInput () { - if (!HasEntityBody) + var input = InputStream; + if (input == Stream.Null) return true; var len = 2048; @@ -751,14 +752,14 @@ internal bool FlushInput () while (true) { try { - var ares = InputStream.BeginRead (buff, 0, len, null, null); + var ares = input.BeginRead (buff, 0, len, null, null); if (!ares.IsCompleted) { var timeout = 100; if (!ares.AsyncWaitHandle.WaitOne (timeout)) return false; } - if (InputStream.EndRead (ares) <= 0) + if (input.EndRead (ares) <= 0) return true; } catch { From dc6ce0f58ac2d788fb7cae0e58c847b740e54ee0 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 25 Feb 2018 18:02:17 +0900 Subject: [PATCH 1851/6294] [Modify] Polish it --- websocket-sharp/Net/HttpConnection.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpConnection.cs b/websocket-sharp/Net/HttpConnection.cs index 60df3f7b1..5ad2763f7 100644 --- a/websocket-sharp/Net/HttpConnection.cs +++ b/websocket-sharp/Net/HttpConnection.cs @@ -504,7 +504,7 @@ public RequestStream GetRequestStream (long contentLength, bool chunked) { lock (_sync) { if (_socket == null) - return _inputStream; + return null; if (_inputStream != null) return _inputStream; From fa502b0e1ea91bbd971c311df1b647036a9c11bc Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 26 Feb 2018 17:58:09 +0900 Subject: [PATCH 1852/6294] [Modify] Polish it --- websocket-sharp/Net/HttpConnection.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/HttpConnection.cs b/websocket-sharp/Net/HttpConnection.cs index 5ad2763f7..de78400ea 100644 --- a/websocket-sharp/Net/HttpConnection.cs +++ b/websocket-sharp/Net/HttpConnection.cs @@ -538,11 +538,11 @@ public ResponseStream GetResponseStream () { // TODO: Can we get this stream before reading the input? - if (_outputStream != null || _socket == null) - return _outputStream; - lock (_sync) { if (_socket == null) + return null; + + if (_outputStream != null) return _outputStream; var lsnr = _context.Listener; From e5f01af0f0e83a59a3be59f6a2569356e4bc2a99 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 27 Feb 2018 17:27:16 +0900 Subject: [PATCH 1853/6294] [Modify] Polish it --- websocket-sharp/Net/HttpConnection.cs | 36 ++++++++++++++++----------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/websocket-sharp/Net/HttpConnection.cs b/websocket-sharp/Net/HttpConnection.cs index de78400ea..5e177179c 100644 --- a/websocket-sharp/Net/HttpConnection.cs +++ b/websocket-sharp/Net/HttpConnection.cs @@ -452,24 +452,32 @@ internal void Close (bool force) if (_socket == null) return; - if (!force) { - GetResponseStream ().Close (false); - if (!_context.Response.CloseConnection && _context.Request.FlushInput ()) { - // Don't close. Keep working. - _reuses++; - disposeRequestBuffer (); - unregisterContext (); - init (); - BeginReadRequest (); + if (force) { + if (_outputStream != null) + _outputStream.Close (true); - return; - } + close (); + return; + } + + GetResponseStream ().Close (false); + + if (_context.Response.CloseConnection) { + close (); + return; } - else if (_outputStream != null) { - _outputStream.Close (true); + + if (!_context.Request.FlushInput ()) { + close (); + return; } - close (); + disposeRequestBuffer (); + unregisterContext (); + init (); + + _reuses++; + BeginReadRequest (); } } From f1525f2b4c05295095266ac02ba2112ce8c0ac5b Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 28 Feb 2018 19:26:56 +0900 Subject: [PATCH 1854/6294] [Modify] Remove it --- websocket-sharp/Net/HttpConnection.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/websocket-sharp/Net/HttpConnection.cs b/websocket-sharp/Net/HttpConnection.cs index 5e177179c..7345336a8 100644 --- a/websocket-sharp/Net/HttpConnection.cs +++ b/websocket-sharp/Net/HttpConnection.cs @@ -522,7 +522,6 @@ public RequestStream GetRequestStream (long contentLength, bool chunked) disposeRequestBuffer (); if (chunked) { - _context.Response.SendChunked = true; _inputStream = new ChunkedRequestStream ( _stream, buff, _position, len - _position, _context ); From 9e794d890f659632563a6b209c6510d2ec93dcf4 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 1 Mar 2018 17:07:27 +0900 Subject: [PATCH 1855/6294] [Modify] Polish it --- websocket-sharp/Net/HttpConnection.cs | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/websocket-sharp/Net/HttpConnection.cs b/websocket-sharp/Net/HttpConnection.cs index 7345336a8..572d785c2 100644 --- a/websocket-sharp/Net/HttpConnection.cs +++ b/websocket-sharp/Net/HttpConnection.cs @@ -519,24 +519,17 @@ public RequestStream GetRequestStream (long contentLength, bool chunked) var buff = _requestBuffer.GetBuffer (); var len = (int) _requestBuffer.Length; + var cnt = len - _position; disposeRequestBuffer (); - if (chunked) { - _inputStream = new ChunkedRequestStream ( - _stream, buff, _position, len - _position, _context + _inputStream = chunked + ? new ChunkedRequestStream ( + _stream, buff, _position, cnt, _context + ) + : new RequestStream ( + _stream, buff, _position, cnt, contentLength ); - return _inputStream; - } - - _inputStream = new RequestStream ( - _stream, - buff, - _position, - len - _position, - contentLength - ); - return _inputStream; } } From 37c63465082ecfaa8f34d2aca43cf791893ebb6f Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 2 Mar 2018 17:54:10 +0900 Subject: [PATCH 1856/6294] [Modify] Not support --- websocket-sharp/Net/HttpListenerRequest.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index 006882c5f..b6e58f080 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -891,8 +891,7 @@ public X509Certificate2 EndGetClientCertificate (IAsyncResult asyncResult) /// public X509Certificate2 GetClientCertificate () { - // TODO: Not implemented. - throw new NotImplementedException (); + throw new NotSupportedException (); } /// From 54222524c42239c9c1f88d39c1b88ab11d67b944 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 2 Mar 2018 18:14:07 +0900 Subject: [PATCH 1857/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerRequest.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index b6e58f080..3c8a7bf76 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -881,13 +881,14 @@ public X509Certificate2 EndGetClientCertificate (IAsyncResult asyncResult) } /// - /// Gets the client's X.509 v.3 certificate. + /// Gets the certificate provided by the client. /// /// - /// A that contains the client's X.509 v.3 certificate. + /// A that represents an X.509 certificate + /// provided by the client. /// - /// - /// This method isn't implemented. + /// + /// This method is not supported. /// public X509Certificate2 GetClientCertificate () { From 757dac4b8be46c1825c90a5fbdcc6a1107b4e4dd Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 3 Mar 2018 18:01:02 +0900 Subject: [PATCH 1858/6294] [Modify] Not support --- websocket-sharp/Net/HttpListenerRequest.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index 3c8a7bf76..dc64ef151 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -851,10 +851,11 @@ internal void SetRequestLine (string requestLine) /// /// This method isn't implemented. /// - public IAsyncResult BeginGetClientCertificate (AsyncCallback requestCallback, object state) + public IAsyncResult BeginGetClientCertificate ( + AsyncCallback requestCallback, object state + ) { - // TODO: Not implemented. - throw new NotImplementedException (); + throw new NotSupportedException (); } /// From cff3c086dd75b401cbf5f68881173b4d7e28c3fa Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 4 Mar 2018 20:58:52 +0900 Subject: [PATCH 1859/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerRequest.cs | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index dc64ef151..90eb56bba 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -830,26 +830,22 @@ internal void SetRequestLine (string requestLine) #region Public Methods /// - /// Begins getting the client's X.509 v.3 certificate asynchronously. + /// Begins getting the certificate provided by the client asynchronously. /// - /// - /// This asynchronous operation must be completed by calling - /// the method. Typically, - /// that method is invoked by the delegate. - /// /// - /// An that contains the status of the asynchronous operation. + /// An that indicates the status of the + /// operation. /// /// - /// An delegate that references the method(s) called when - /// the asynchronous operation completes. + /// An delegate that invokes the method called + /// when the operation is complete. /// /// - /// An that contains a user defined object to pass to - /// the delegate. + /// An that represents a user defined object to pass to + /// the callback delegate. /// - /// - /// This method isn't implemented. + /// + /// This method is not supported. /// public IAsyncResult BeginGetClientCertificate ( AsyncCallback requestCallback, object state From ce93753311488598ec53960acc6ea1b6198b9154 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 5 Mar 2018 17:40:00 +0900 Subject: [PATCH 1860/6294] [Modify] Not support --- websocket-sharp/Net/HttpListenerRequest.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index 90eb56bba..e5ad7d65a 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -873,8 +873,7 @@ public IAsyncResult BeginGetClientCertificate ( /// public X509Certificate2 EndGetClientCertificate (IAsyncResult asyncResult) { - // TODO: Not implemented. - throw new NotImplementedException (); + throw new NotSupportedException (); } /// From a5b074e1999cf4d7164d12f2467eb9ad57e66be8 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 6 Mar 2018 19:49:20 +0900 Subject: [PATCH 1861/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerRequest.cs | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index e5ad7d65a..1d2196291 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -855,21 +855,19 @@ public IAsyncResult BeginGetClientCertificate ( } /// - /// Ends an asynchronous operation to get the client's X.509 v.3 certificate. + /// Ends an asynchronous operation to get the certificate provided by the + /// client. /// - /// - /// This method completes an asynchronous operation started by calling - /// the method. - /// /// - /// A that contains the client's X.509 v.3 certificate. + /// A that represents an X.509 certificate + /// provided by the client. /// /// - /// An obtained by calling - /// the method. + /// An instance returned when the operation + /// started. /// - /// - /// This method isn't implemented. + /// + /// This method is not supported. /// public X509Certificate2 EndGetClientCertificate (IAsyncResult asyncResult) { From d5326400fa6daa7f30c11d2605dc83cdd70117d5 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 6 Mar 2018 19:54:05 +0900 Subject: [PATCH 1862/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerRequest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index 1d2196291..f67136140 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -833,7 +833,7 @@ internal void SetRequestLine (string requestLine) /// Begins getting the certificate provided by the client asynchronously. /// /// - /// An that indicates the status of the + /// An instance that indicates the status of the /// operation. /// /// From 975295985362a93858b339853c0b7640fdce48a9 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 7 Mar 2018 18:03:53 +0900 Subject: [PATCH 1863/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerRequest.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index f67136140..e16f9f5cb 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -899,8 +899,12 @@ public X509Certificate2 GetClientCertificate () public override string ToString () { var buff = new StringBuilder (64); - buff.AppendFormat ("{0} {1} HTTP/{2}\r\n", _httpMethod, _rawUrl, _protocolVersion); - buff.Append (_headers.ToString ()); + + buff + .AppendFormat ( + "{0} {1} HTTP/{2}\r\n", _httpMethod, _rawUrl, _protocolVersion + ) + .Append (_headers.ToString ()); return buff.ToString (); } From 1692b8cb7fafa5c9455a083ea4833369f655209e Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 8 Mar 2018 19:49:17 +0900 Subject: [PATCH 1864/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerRequest.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index e16f9f5cb..58ccfe997 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -890,11 +890,11 @@ public X509Certificate2 GetClientCertificate () } /// - /// Returns a that represents - /// the current . + /// Returns a string that represents the current instance. /// /// - /// A that represents the current . + /// A that contains the request line and headers + /// included in the request. /// public override string ToString () { From 52eac36a3a0d8cbb891aebe2a437c3f9a5fac4f2 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 9 Mar 2018 17:55:18 +0900 Subject: [PATCH 1865/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerRequest.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index 58ccfe997..3a984d5f8 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -482,8 +482,7 @@ public Uri Url { /// A converted from the value of the Referer header. /// /// - /// if the Referer header is not present or - /// the conversion has failed. + /// if the header value is not available. /// /// public Uri UrlReferrer { From b7223d5bc90e30569251d2bf17c3adc188657cfc Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 9 Mar 2018 17:58:29 +0900 Subject: [PATCH 1866/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerRequest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index 3a984d5f8..7583643ff 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -114,7 +114,7 @@ internal HttpListenerRequest (HttpListenerContext context) /// types specified in the value of the Accept header. /// /// - /// if the Accept header is not present. + /// if the header is not present. /// /// public string[] AcceptTypes { From df7b16bfc5a4ef3b5a4a4daf1678837c3edc28f8 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 10 Mar 2018 18:09:42 +0900 Subject: [PATCH 1867/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerRequest.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index 7583643ff..12353da8b 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -173,15 +173,16 @@ public Encoding ContentEncoding { } /// - /// Gets the length in bytes of the entity body data included in - /// the request. + /// Gets the length in bytes of the entity body data included in the + /// request. /// /// /// - /// A from the value of the Content-Length header. + /// A converted from the value of the Content-Length + /// header. /// /// - /// -1 if the value is not known. + /// -1 if the header is not present. /// /// public long ContentLength64 { From 5feccdf54e994da9f3ccfa27491e238255d7eeb9 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 10 Mar 2018 18:13:50 +0900 Subject: [PATCH 1868/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerRequest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index 12353da8b..a169f02de 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -200,7 +200,7 @@ public long ContentLength64 { /// header. /// /// - /// if the Content-Type header is not present. + /// if the header is not present. /// /// public string ContentType { From b38f25af230638e7f5c14a838e690f75124fa0a2 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 11 Mar 2018 17:56:42 +0900 Subject: [PATCH 1869/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerRequest.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index a169f02de..9af6c6e3f 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -508,7 +508,7 @@ public Uri UrlReferrer { /// header. /// /// - /// if the User-Agent header is not present. + /// if the header is not present. /// /// public string UserAgent { @@ -541,7 +541,7 @@ public string UserHostAddress { /// It includes the port number if provided. /// /// - /// if the Host header is not present. + /// if the header is not present. /// /// public string UserHostName { From 642df2cc9bbb697e0d6a3536f0eb72cceb03b716 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 12 Mar 2018 17:43:25 +0900 Subject: [PATCH 1870/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerRequest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index 9af6c6e3f..a9c30e9c0 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -560,7 +560,7 @@ public string UserHostName { /// header. /// /// - /// if the Accept-Language header is not present. + /// if the header is not present. /// /// public string[] UserLanguages { From 011366f8b65a759d390b0f639ef6d18d0c55b334 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 13 Mar 2018 15:19:47 +0900 Subject: [PATCH 1871/6294] [Modify] Add it --- websocket-sharp/Ext.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 71e84695f..ed92600d1 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -141,6 +141,18 @@ private static byte[] decompressToArray (this Stream stream) } } + private static bool isHttpMethod (this string value) + { + return value == "GET" + || value == "HEAD" + || value == "POST" + || value == "PUT" + || value == "DELETE" + || value == "CONNECT" + || value == "OPTIONS" + || value == "TRACE"; + } + private static void times (this ulong n, Action action) { for (ulong i = 0; i < n; i++) From 1c401b13d2374425af1e6ff0ecb0f45b5ff5b4a6 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 13 Mar 2018 15:24:02 +0900 Subject: [PATCH 1872/6294] [Modify] Add it --- websocket-sharp/Ext.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index ed92600d1..4713ac41b 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -153,6 +153,13 @@ private static bool isHttpMethod (this string value) || value == "TRACE"; } + private static bool isHttpMethod10 (this string value) + { + return value == "GET" + || value == "HEAD" + || value == "POST"; + } + private static void times (this ulong n, Action action) { for (ulong i = 0; i < n; i++) From 9ba935f723af2e395d3e1586a26663fc678a3512 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 14 Mar 2018 16:21:32 +0900 Subject: [PATCH 1873/6294] [Modify] Add it --- websocket-sharp/Ext.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 4713ac41b..5e42b235c 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -595,6 +595,13 @@ internal static bool IsData (this Opcode opcode) return opcode == Opcode.Text || opcode == Opcode.Binary; } + internal static bool IsHttpMethod (this string value, Version version) + { + return version == HttpVersion.Version10 + ? value.isHttpMethod10 () + : value.isHttpMethod (); + } + internal static bool IsPortNumber (this int value) { return value > 0 && value < 65536; From dea8220e69421b89492290697e1cce3231fddc06 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 14 Mar 2018 17:01:06 +0900 Subject: [PATCH 1874/6294] [Modify] Replace it --- websocket-sharp/Net/HttpListenerRequest.cs | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index a9c30e9c0..e25e40f8b 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -582,15 +582,6 @@ public string[] UserLanguages { private void finishInitialization10 () { - var validMethod = _httpMethod == "GET" - || _httpMethod == "HEAD" - || _httpMethod == "POST"; - - if (!validMethod) { - _context.ErrorMessage = "Invalid request line (method)"; - return; - } - if (_httpMethod == "POST") { if (_contentLength == -1) { _context.ErrorMessage = "Content-Length header required"; @@ -820,6 +811,11 @@ internal void SetRequestLine (string requestLine) return; } + if (!method.IsHttpMethod (ver)) { + _context.ErrorMessage = "Invalid request line (method)"; + return; + } + _httpMethod = method; _rawUrl = target; _protocolVersion = ver; From b81756945d97f783ee1aaa904dc606dd4c2e132a Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 15 Mar 2018 17:38:40 +0900 Subject: [PATCH 1875/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerRequest.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index e25e40f8b..29bd6e02b 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -582,6 +582,12 @@ public string[] UserLanguages { private void finishInitialization10 () { + var transferEnc = _headers["Transfer-Encoding"]; + if (transferEnc != null) { + _context.ErrorMessage = "Invalid Transfer-Encoding header"; + return; + } + if (_httpMethod == "POST") { if (_contentLength == -1) { _context.ErrorMessage = "Content-Length header required"; @@ -593,12 +599,6 @@ private void finishInitialization10 () return; } } - - var transferEnc = _headers["Transfer-Encoding"]; - if (transferEnc != null) { - _context.ErrorMessage = "Invalid Transfer-Encoding header"; - return; - } } private Encoding getContentEncoding () From e274c7ac158fd716e5639ad111e303e0c4acb4b3 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 15 Mar 2018 17:48:18 +0900 Subject: [PATCH 1876/6294] [Modify] Remove it --- websocket-sharp/Server/HttpServer.cs | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 7c1129651..04294ffc9 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -765,11 +765,6 @@ public WebSocketServiceManager WebSocketServices { /// public event EventHandler OnOptions; - /// - /// Occurs when the server receives an HTTP PATCH request. - /// - public event EventHandler OnPatch; - /// /// Occurs when the server receives an HTTP POST request. /// @@ -910,9 +905,7 @@ private void processRequest (HttpListenerContext context) ? OnTrace : method == "CONNECT" ? OnConnect - : method == "PATCH" - ? OnPatch - : null; + : null; if (evt != null) evt (this, new HttpRequestEventArgs (context, _docRootPath)); From ca638161282e294cd826563815f47a9a22dcf2c1 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 16 Mar 2018 17:34:40 +0900 Subject: [PATCH 1877/6294] [Modify] Polish it --- websocket-sharp/Server/HttpServer.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 04294ffc9..83de8555c 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -899,12 +899,12 @@ private void processRequest (HttpListenerContext context) ? OnPut : method == "DELETE" ? OnDelete - : method == "OPTIONS" - ? OnOptions - : method == "TRACE" - ? OnTrace - : method == "CONNECT" - ? OnConnect + : method == "CONNECT" + ? OnConnect + : method == "OPTIONS" + ? OnOptions + : method == "TRACE" + ? OnTrace : null; if (evt != null) From 0e75c9fddd2d2508ab9069d496cd3feb905b7bfc Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 17 Mar 2018 18:09:30 +0900 Subject: [PATCH 1878/6294] [Fix] LWS is refused --- websocket-sharp/Net/HttpListenerRequest.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index 29bd6e02b..3526126d3 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -626,6 +626,12 @@ private RequestStream getInputStream () internal void AddHeader (string headerField) { + var start = headerField[0]; + if (start == ' ' || start == '\t') { + _context.ErrorMessage = "Invalid header field"; + return; + } + var colon = headerField.IndexOf (':'); if (colon < 1) { _context.ErrorMessage = "Invalid header field"; From 3b9c76d19ff0e3259ea6a8c3ab709fc3c4e03d6a Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 18 Mar 2018 17:32:57 +0900 Subject: [PATCH 1879/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerRequest.cs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index 3526126d3..880144b87 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -784,11 +784,6 @@ internal void SetRequestLine (string requestLine) return; } - if (!method.IsToken ()) { - _context.ErrorMessage = "Invalid request line (method)"; - return; - } - var target = parts[1]; if (target.Length == 0) { _context.ErrorMessage = "Invalid request line (target)"; From e52c5938e4546e4b31f31a1cfe6af8aa4e2467b5 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 19 Mar 2018 15:47:15 +0900 Subject: [PATCH 1880/6294] [Modify] 2018 --- websocket-sharp/Net/HttpListenerRequest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index 880144b87..4a7d146cf 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -8,7 +8,7 @@ * The MIT License * * Copyright (c) 2005 Novell, Inc. (http://www.novell.com) - * Copyright (c) 2012-2015 sta.blockhead + * Copyright (c) 2012-2018 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From caf364d3390317ff605b4998de65e100a2301f64 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 19 Mar 2018 16:38:51 +0900 Subject: [PATCH 1881/6294] [Modify] Edit it --- .../Net/WebSockets/HttpListenerWebSocketContext.cs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs b/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs index 9935aee06..f4fa491be 100644 --- a/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs @@ -324,12 +324,11 @@ internal void Close (HttpStatusCode code) #region Public Methods /// - /// Returns a that represents - /// the current . + /// Returns a string that represents the current instance. /// /// - /// A that represents - /// the current . + /// A that contains the request line and headers + /// included in the handshake request. /// public override string ToString () { From 49c765aea8e1dc21edd50cf7e31c7adab04de9e8 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 20 Mar 2018 17:28:28 +0900 Subject: [PATCH 1882/6294] [Modify] Polish it --- websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs b/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs index f4fa491be..e4d0baf25 100644 --- a/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs @@ -107,7 +107,7 @@ public override NameValueCollection Headers { /// public override string Host { get { - return _context.Request.Headers["Host"]; + return _context.Request.UserHostName; } } From 1b0c9c58f32d4c75d80d27f9568a8c91f8e152a6 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 20 Mar 2018 17:43:42 +0900 Subject: [PATCH 1883/6294] [Modify] Edit it --- .../Net/WebSockets/HttpListenerWebSocketContext.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs b/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs index e4d0baf25..f4451b182 100644 --- a/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs @@ -100,10 +100,15 @@ public override NameValueCollection Headers { } /// - /// Gets the value of the Host header included in the request. + /// Gets the value of the Host header included in the handshake request. /// /// - /// A that represents the value of the Host header. + /// + /// A that represents the value of the Host header. + /// + /// + /// It includes the port number if provided. + /// /// public override string Host { get { From 52d07060e5a9c233d401c3ed074d5c35a57d98a6 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 21 Mar 2018 17:56:32 +0900 Subject: [PATCH 1884/6294] [Modify] Polish it --- websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs b/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs index f4451b182..32cadb7cd 100644 --- a/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs @@ -124,7 +124,7 @@ public override string Host { /// public override bool IsAuthenticated { get { - return _context.User != null; + return _context.Request.IsAuthenticated; } } From ccd9e187d9b946f001d9091d9e57623e5c9d33d1 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 21 Mar 2018 18:08:27 +0900 Subject: [PATCH 1885/6294] [Modify] Edit it --- .../Net/WebSockets/HttpListenerWebSocketContext.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs b/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs index 32cadb7cd..1055ff229 100644 --- a/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs @@ -129,10 +129,12 @@ public override bool IsAuthenticated { } /// - /// Gets a value indicating whether the client connected from the local computer. + /// Gets a value indicating whether the handshake request is sent from the + /// local computer. /// /// - /// true if the client connected from the local computer; otherwise, false. + /// true if the handshake request is sent from the same computer as + /// the server; otherwise, false. /// public override bool IsLocal { get { From 0c644cdf2df22dbd7f02e0b61f7be603582654b2 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 22 Mar 2018 17:51:54 +0900 Subject: [PATCH 1886/6294] [Modify] Polish it --- websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs b/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs index 1055ff229..b97893d7a 100644 --- a/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs @@ -150,7 +150,7 @@ public override bool IsLocal { /// public override bool IsSecureConnection { get { - return _context.Connection.IsSecure; + return _context.Request.IsSecureConnection; } } From 7424d1d5e91db3dcc06da7f84f9f510a7b7ffc72 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 23 Mar 2018 20:06:02 +0900 Subject: [PATCH 1887/6294] [Modify] Edit it --- .../Net/WebSockets/HttpListenerWebSocketContext.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs b/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs index b97893d7a..d4dfbf781 100644 --- a/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs @@ -143,10 +143,11 @@ public override bool IsLocal { } /// - /// Gets a value indicating whether the WebSocket connection is secured. + /// Gets a value indicating whether a secure connection is used to send + /// the handshake request. /// /// - /// true if the connection is secured; otherwise, false. + /// true if the connection is secure; otherwise, false. /// public override bool IsSecureConnection { get { From c26800dcd6aef207a43a2ee2e358e926d6caf9f1 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 23 Mar 2018 20:09:03 +0900 Subject: [PATCH 1888/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerRequest.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index 4a7d146cf..3de735200 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -319,8 +319,7 @@ public bool IsLocal { /// the request. /// /// - /// true if the connection is a secure connection; otherwise, - /// false. + /// true if the connection is secure; otherwise, false. /// public bool IsSecureConnection { get { From 6a80126d8e33b7015556e2244d6631793874ef41 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 23 Mar 2018 20:15:42 +0900 Subject: [PATCH 1889/6294] [Modify] Edit it --- .../Net/WebSockets/HttpListenerWebSocketContext.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs b/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs index d4dfbf781..d85102b0a 100644 --- a/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs @@ -156,10 +156,12 @@ public override bool IsSecureConnection { } /// - /// Gets a value indicating whether the request is a WebSocket handshake request. + /// Gets a value indicating whether the request is a WebSocket handshake + /// request. /// /// - /// true if the request is a WebSocket handshake request; otherwise, false. + /// true if the request is a WebSocket handshake request; otherwise, + /// false. /// public override bool IsWebSocketRequest { get { From 32e1f2b24b457258adec8323d305613de0ea693e Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 24 Mar 2018 19:33:19 +0900 Subject: [PATCH 1890/6294] [Modify] Edit it --- websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs b/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs index d85102b0a..a4a0eccb9 100644 --- a/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs @@ -170,7 +170,7 @@ public override bool IsWebSocketRequest { } /// - /// Gets the value of the Origin header included in the request. + /// Gets the value of the Origin header included in the handshake request. /// /// /// A that represents the value of the Origin header. From 66ddadb598a35a8d2592d551230ead0f1ec8c9aa Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 24 Mar 2018 19:38:49 +0900 Subject: [PATCH 1891/6294] [Modify] Edit it --- .../Net/WebSockets/HttpListenerWebSocketContext.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs b/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs index a4a0eccb9..0843f930d 100644 --- a/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs @@ -182,10 +182,16 @@ public override string Origin { } /// - /// Gets the query string included in the request. + /// Gets the query string included in the handshake request. /// /// - /// A that contains the query string parameters. + /// + /// A that contains the query + /// parameters. + /// + /// + /// An empty collection if not included. + /// /// public override NameValueCollection QueryString { get { From 8986a323a8383039196890ffef473b3f354e3c99 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 25 Mar 2018 18:15:11 +0900 Subject: [PATCH 1892/6294] [Modify] Edit it --- .../Net/WebSockets/HttpListenerWebSocketContext.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs b/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs index 0843f930d..bb05793ff 100644 --- a/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs @@ -203,7 +203,12 @@ public override NameValueCollection QueryString { /// Gets the URI requested by the client. /// /// - /// A that represents the requested URI. + /// + /// A that represents the URI parsed from the request. + /// + /// + /// if the URI cannot be parsed. + /// /// public override Uri RequestUri { get { From 612194369ad637aa291d68b68977ac1cc0dfa9f6 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 26 Mar 2018 18:13:57 +0900 Subject: [PATCH 1893/6294] [Modify] Edit it --- .../Net/WebSockets/HttpListenerWebSocketContext.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs b/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs index bb05793ff..e926188e9 100644 --- a/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs @@ -217,14 +217,16 @@ public override Uri RequestUri { } /// - /// Gets the value of the Sec-WebSocket-Key header included in the request. + /// Gets the value of the Sec-WebSocket-Key header included in the handshake + /// request. /// /// - /// This property provides a part of the information used by the server to prove that - /// it received a valid WebSocket handshake request. + /// This property provides a part of the information used by the server to + /// prove that it received a valid WebSocket handshake request. /// /// - /// A that represents the value of the Sec-WebSocket-Key header. + /// A that represents the value of the + /// Sec-WebSocket-Key header. /// public override string SecWebSocketKey { get { From f4bfd46bcb4d879985c8168bf9d5ab2309d87bd6 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 27 Mar 2018 13:47:25 +0900 Subject: [PATCH 1894/6294] [Modify] Edit it --- .../Net/WebSockets/HttpListenerWebSocketContext.cs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs b/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs index e926188e9..ef4f6c006 100644 --- a/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs @@ -265,13 +265,11 @@ public override IEnumerable SecWebSocketProtocols { } /// - /// Gets the value of the Sec-WebSocket-Version header included in the request. + /// Gets the value of the Sec-WebSocket-Version header included in the + /// handshake request. /// - /// - /// This property represents the WebSocket protocol version. - /// /// - /// A that represents the value of the Sec-WebSocket-Version header. + /// A that represents the WebSocket protocol version. /// public override string SecWebSocketVersion { get { From 0d755528c808821c44796c033e492db7cbb34792 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 27 Mar 2018 13:50:10 +0900 Subject: [PATCH 1895/6294] [Modify] Polish it --- websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs b/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs index ef4f6c006..a53036aaa 100644 --- a/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs @@ -285,7 +285,7 @@ public override string SecWebSocketVersion { /// public override System.Net.IPEndPoint ServerEndPoint { get { - return _context.Connection.LocalEndPoint; + return _context.Request.LocalEndPoint; } } From ed7f1ed5b64fd1518afba55fec67b6c2cd329e07 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 27 Mar 2018 13:54:38 +0900 Subject: [PATCH 1896/6294] [Modify] Edit it --- .../Net/WebSockets/HttpListenerWebSocketContext.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs b/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs index a53036aaa..492687de4 100644 --- a/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs @@ -278,10 +278,11 @@ public override string SecWebSocketVersion { } /// - /// Gets the server endpoint as an IP address and a port number. + /// Gets the endpoint to which the handshake request is sent. /// /// - /// A that represents the server endpoint. + /// A that represents the server IP + /// address and port number. /// public override System.Net.IPEndPoint ServerEndPoint { get { From a6c40820c7f379e3aa7b712e9757ab9251f222e9 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 27 Mar 2018 15:04:21 +0900 Subject: [PATCH 1897/6294] [Modify] Edit it --- .../Net/WebSockets/HttpListenerWebSocketContext.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs b/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs index 492687de4..e5de69107 100644 --- a/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs @@ -291,10 +291,16 @@ public override System.Net.IPEndPoint ServerEndPoint { } /// - /// Gets the client information (identity, authentication, and security roles). + /// Gets the client information. /// /// - /// A instance that represents the client information. + /// + /// A instance that represents identity, + /// authentication, and security roles for the client. + /// + /// + /// if the client is not authenticated. + /// /// public override IPrincipal User { get { From 996448f08d3ebde2f75728c7592b010b09cc30b9 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 27 Mar 2018 15:07:31 +0900 Subject: [PATCH 1898/6294] [Modify] Polish it --- websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs b/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs index e5de69107..58315b572 100644 --- a/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs @@ -316,7 +316,7 @@ public override IPrincipal User { /// public override System.Net.IPEndPoint UserEndPoint { get { - return _context.Connection.RemoteEndPoint; + return _context.Request.RemoteEndPoint; } } From 8d733b4d05ea6af4e1f4862ab2babf39d55e9cb7 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 28 Mar 2018 17:33:46 +0900 Subject: [PATCH 1899/6294] [Modify] Edit it --- .../Net/WebSockets/HttpListenerWebSocketContext.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs b/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs index 58315b572..d7e850068 100644 --- a/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs @@ -309,10 +309,11 @@ public override IPrincipal User { } /// - /// Gets the client endpoint as an IP address and a port number. + /// Gets the endpoint from which the handshake request is sent. /// /// - /// A that represents the client endpoint. + /// A that represents the client IP + /// address and port number. /// public override System.Net.IPEndPoint UserEndPoint { get { From 4c8efb01573de9a18efe8dbdcb363da4de5190e4 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 29 Mar 2018 17:07:04 +0900 Subject: [PATCH 1900/6294] [Modify] Edit it --- .../Net/WebSockets/HttpListenerWebSocketContext.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs b/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs index d7e850068..f6b5f3a41 100644 --- a/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs @@ -322,11 +322,12 @@ public override System.Net.IPEndPoint UserEndPoint { } /// - /// Gets the instance used for - /// two-way communication between client and server. + /// Gets the WebSocket interface for two-way communication between the + /// client and server. /// /// - /// A . + /// A that provides a set of methods + /// and properties for two-way communication using the WebSocket protocol. /// public override WebSocket WebSocket { get { From 64a6cad950514332202f218df38d4ffc5b3a33c5 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 29 Mar 2018 17:19:27 +0900 Subject: [PATCH 1901/6294] [Modify] Edit it --- .../Net/WebSockets/HttpListenerWebSocketContext.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs b/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs index f6b5f3a41..6e09360df 100644 --- a/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs @@ -76,10 +76,16 @@ internal Stream Stream { #region Public Properties /// - /// Gets the HTTP cookies included in the request. + /// Gets the HTTP cookies included in the handshake request. /// /// - /// A that contains the cookies. + /// + /// A that contains + /// the cookies. + /// + /// + /// An empty collection if not included. + /// /// public override CookieCollection CookieCollection { get { From 574f232fb9fd7d814ef4819352661328b925cc51 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 29 Mar 2018 17:25:58 +0900 Subject: [PATCH 1902/6294] [Modify] Edit it --- websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs b/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs index 6e09360df..419b4aa82 100644 --- a/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs @@ -94,7 +94,7 @@ public override CookieCollection CookieCollection { } /// - /// Gets the HTTP headers included in the request. + /// Gets the HTTP headers included in the handshake request. /// /// /// A that contains the headers. From e57da1b2f83a4e1dc5d619f75c082ad23aa1edc2 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 30 Mar 2018 17:33:01 +0900 Subject: [PATCH 1903/6294] [Modify] Polish it --- .../Net/WebSockets/HttpListenerWebSocketContext.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs b/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs index 419b4aa82..b33d3a56f 100644 --- a/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs @@ -49,7 +49,9 @@ public class HttpListenerWebSocketContext : WebSocketContext #region Internal Constructors - internal HttpListenerWebSocketContext (HttpListenerContext context, string protocol) + internal HttpListenerWebSocketContext ( + HttpListenerContext context, string protocol + ) { _context = context; _websocket = new WebSocket (this, protocol); From fcbd35ea0ce3ae69000ad9bf182bb49d5667b923 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 31 Mar 2018 18:08:06 +0900 Subject: [PATCH 1904/6294] [Modify] Edit it --- .../Net/WebSockets/HttpListenerWebSocketContext.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs b/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs index b33d3a56f..a62beac20 100644 --- a/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs @@ -35,8 +35,8 @@ namespace WebSocketSharp.Net.WebSockets { /// - /// Provides the properties used to access the information in - /// a WebSocket handshake request received by the . + /// Provides the access to the information in a WebSocket handshake request to + /// a instance. /// public class HttpListenerWebSocketContext : WebSocketContext { From 03db354570bef250467173e5986b3073f8db1c8f Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 31 Mar 2018 18:17:50 +0900 Subject: [PATCH 1905/6294] [Modify] Edit it --- websocket-sharp/Net/WebSockets/WebSocketContext.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebSockets/WebSocketContext.cs b/websocket-sharp/Net/WebSockets/WebSocketContext.cs index c3491ff97..465d76804 100644 --- a/websocket-sharp/Net/WebSockets/WebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/WebSocketContext.cs @@ -34,7 +34,7 @@ namespace WebSocketSharp.Net.WebSockets { /// - /// Exposes the properties used to access the information in a WebSocket handshake request. + /// Exposes the access to the information in a WebSocket handshake request. /// /// /// This class is an abstract class. From 071679fd5a78217f2bd20c2e2aba37c6352f8526 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 1 Apr 2018 17:09:47 +0900 Subject: [PATCH 1906/6294] [Modify] Edit it --- websocket-sharp/Net/WebSockets/WebSocketContext.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/WebSockets/WebSocketContext.cs b/websocket-sharp/Net/WebSockets/WebSocketContext.cs index 465d76804..930a7af76 100644 --- a/websocket-sharp/Net/WebSockets/WebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/WebSocketContext.cs @@ -55,10 +55,11 @@ protected WebSocketContext () #region Public Properties /// - /// Gets the HTTP cookies included in the request. + /// Gets the HTTP cookies included in the handshake request. /// /// - /// A that contains the cookies. + /// A that contains + /// the cookies. /// public abstract CookieCollection CookieCollection { get; } From 5a96ee4723a7b322608e800255285e2edb3b15d6 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 1 Apr 2018 17:11:58 +0900 Subject: [PATCH 1907/6294] [Modify] Edit it --- websocket-sharp/Net/WebSockets/WebSocketContext.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebSockets/WebSocketContext.cs b/websocket-sharp/Net/WebSockets/WebSocketContext.cs index 930a7af76..56cb3173c 100644 --- a/websocket-sharp/Net/WebSockets/WebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/WebSocketContext.cs @@ -64,7 +64,7 @@ protected WebSocketContext () public abstract CookieCollection CookieCollection { get; } /// - /// Gets the HTTP headers included in the request. + /// Gets the HTTP headers included in the handshake request. /// /// /// A that contains the headers. From 055e904bf59ff5bccd54d14a4842307af0c91437 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 1 Apr 2018 17:21:02 +0900 Subject: [PATCH 1908/6294] [Modify] Edit it --- websocket-sharp/Net/WebSockets/WebSocketContext.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/WebSockets/WebSocketContext.cs b/websocket-sharp/Net/WebSockets/WebSocketContext.cs index 56cb3173c..1e781830c 100644 --- a/websocket-sharp/Net/WebSockets/WebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/WebSocketContext.cs @@ -72,10 +72,11 @@ protected WebSocketContext () public abstract NameValueCollection Headers { get; } /// - /// Gets the value of the Host header included in the request. + /// Gets the value of the Host header included in the handshake request. /// /// - /// A that represents the value of the Host header. + /// A that represents the server host name requested by + /// the client. /// public abstract string Host { get; } From bb5279b0553435d23289910e343f6daa7b63e7c7 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 1 Apr 2018 17:24:24 +0900 Subject: [PATCH 1909/6294] [Modify] Edit it --- websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs b/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs index a62beac20..8e5be7d43 100644 --- a/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs @@ -112,7 +112,8 @@ public override NameValueCollection Headers { /// /// /// - /// A that represents the value of the Host header. + /// A that represents the server host name requested + /// by the client. /// /// /// It includes the port number if provided. From 99667eb9bee54530ce48bab352c8561e82775adf Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 1 Apr 2018 17:31:03 +0900 Subject: [PATCH 1910/6294] [Modify] Edit it --- websocket-sharp/Net/WebSockets/WebSocketContext.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/WebSockets/WebSocketContext.cs b/websocket-sharp/Net/WebSockets/WebSocketContext.cs index 1e781830c..f6cbe5d15 100644 --- a/websocket-sharp/Net/WebSockets/WebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/WebSocketContext.cs @@ -89,10 +89,12 @@ protected WebSocketContext () public abstract bool IsAuthenticated { get; } /// - /// Gets a value indicating whether the client connected from the local computer. + /// Gets a value indicating whether the handshake request is sent from + /// the local computer. /// /// - /// true if the client connected from the local computer; otherwise, false. + /// true if the handshake request is sent from the same computer + /// as the server; otherwise, false. /// public abstract bool IsLocal { get; } From d38edb8df43e8b8a00ed8447f2c782ecaea517db Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 1 Apr 2018 17:33:01 +0900 Subject: [PATCH 1911/6294] [Modify] Edit it --- .../Net/WebSockets/HttpListenerWebSocketContext.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs b/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs index 8e5be7d43..7670e1bb9 100644 --- a/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs @@ -138,12 +138,12 @@ public override bool IsAuthenticated { } /// - /// Gets a value indicating whether the handshake request is sent from the - /// local computer. + /// Gets a value indicating whether the handshake request is sent from + /// the local computer. /// /// - /// true if the handshake request is sent from the same computer as - /// the server; otherwise, false. + /// true if the handshake request is sent from the same computer + /// as the server; otherwise, false. /// public override bool IsLocal { get { From 10d69460186b315ee4d7322f5d916d73e29b3e9f Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 1 Apr 2018 17:34:21 +0900 Subject: [PATCH 1912/6294] [Modify] Edit it --- websocket-sharp/Net/WebSockets/WebSocketContext.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/WebSockets/WebSocketContext.cs b/websocket-sharp/Net/WebSockets/WebSocketContext.cs index f6cbe5d15..3a5164d35 100644 --- a/websocket-sharp/Net/WebSockets/WebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/WebSocketContext.cs @@ -75,8 +75,8 @@ protected WebSocketContext () /// Gets the value of the Host header included in the handshake request. /// /// - /// A that represents the server host name requested by - /// the client. + /// A that represents the server host name requested + /// by the client. /// public abstract string Host { get; } From bee3ef7486ee604e618804e65bc6ec3b0e361f6b Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 2 Apr 2018 16:30:33 +0900 Subject: [PATCH 1913/6294] [Modify] Edit it --- websocket-sharp/Net/WebSockets/WebSocketContext.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/WebSockets/WebSocketContext.cs b/websocket-sharp/Net/WebSockets/WebSocketContext.cs index 3a5164d35..5b15a8ff4 100644 --- a/websocket-sharp/Net/WebSockets/WebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/WebSocketContext.cs @@ -99,10 +99,11 @@ protected WebSocketContext () public abstract bool IsLocal { get; } /// - /// Gets a value indicating whether the WebSocket connection is secured. + /// Gets a value indicating whether a secure connection is used to send + /// the handshake request. /// /// - /// true if the connection is secured; otherwise, false. + /// true if the connection is secure; otherwise, false. /// public abstract bool IsSecureConnection { get; } From 72634c833197226dbed7b8770f8b914b42d864bd Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 2 Apr 2018 16:33:32 +0900 Subject: [PATCH 1914/6294] [Modify] Edit it --- websocket-sharp/Net/WebSockets/WebSocketContext.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/WebSockets/WebSocketContext.cs b/websocket-sharp/Net/WebSockets/WebSocketContext.cs index 5b15a8ff4..3d9e56ad1 100644 --- a/websocket-sharp/Net/WebSockets/WebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/WebSocketContext.cs @@ -108,10 +108,12 @@ protected WebSocketContext () public abstract bool IsSecureConnection { get; } /// - /// Gets a value indicating whether the request is a WebSocket handshake request. + /// Gets a value indicating whether the request is a WebSocket handshake + /// request. /// /// - /// true if the request is a WebSocket handshake request; otherwise, false. + /// true if the request is a WebSocket handshake request; otherwise, + /// false. /// public abstract bool IsWebSocketRequest { get; } From 38c95c60264ec1af5f3772f99ea3a1c409b772a5 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 3 Apr 2018 16:20:02 +0900 Subject: [PATCH 1915/6294] [Modify] Edit it --- websocket-sharp/Net/WebSockets/WebSocketContext.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebSockets/WebSocketContext.cs b/websocket-sharp/Net/WebSockets/WebSocketContext.cs index 3d9e56ad1..707f7a93a 100644 --- a/websocket-sharp/Net/WebSockets/WebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/WebSocketContext.cs @@ -118,7 +118,7 @@ protected WebSocketContext () public abstract bool IsWebSocketRequest { get; } /// - /// Gets the value of the Origin header included in the request. + /// Gets the value of the Origin header included in the handshake request. /// /// /// A that represents the value of the Origin header. From 78f801d2272e307729f3f815604cf71c968d0b5e Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 3 Apr 2018 16:26:16 +0900 Subject: [PATCH 1916/6294] [Modify] Edit it --- .../Net/WebSockets/HttpListenerWebSocketContext.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs b/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs index 7670e1bb9..2f37e110d 100644 --- a/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs @@ -182,7 +182,12 @@ public override bool IsWebSocketRequest { /// Gets the value of the Origin header included in the handshake request. /// /// - /// A that represents the value of the Origin header. + /// + /// A that represents the value of the Origin header. + /// + /// + /// if the header is not present. + /// /// public override string Origin { get { From b5f48123ecdb493a785414b67ea98aaa0e3d7e6c Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 3 Apr 2018 16:32:21 +0900 Subject: [PATCH 1917/6294] [Modify] Edit it --- websocket-sharp/Net/WebSockets/WebSocketContext.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/WebSockets/WebSocketContext.cs b/websocket-sharp/Net/WebSockets/WebSocketContext.cs index 707f7a93a..aa0ece639 100644 --- a/websocket-sharp/Net/WebSockets/WebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/WebSocketContext.cs @@ -126,10 +126,10 @@ protected WebSocketContext () public abstract string Origin { get; } /// - /// Gets the query string included in the request. + /// Gets the query string included in the handshake request. /// /// - /// A that contains the query string parameters. + /// A that contains the query parameters. /// public abstract NameValueCollection QueryString { get; } From da67449b4e4df8e87cd85fbfa9e0178a70ac1f2b Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 3 Apr 2018 16:38:37 +0900 Subject: [PATCH 1918/6294] [Modify] Edit it --- websocket-sharp/Net/WebSockets/WebSocketContext.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebSockets/WebSocketContext.cs b/websocket-sharp/Net/WebSockets/WebSocketContext.cs index aa0ece639..ca654c8c6 100644 --- a/websocket-sharp/Net/WebSockets/WebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/WebSocketContext.cs @@ -137,7 +137,7 @@ protected WebSocketContext () /// Gets the URI requested by the client. /// /// - /// A that represents the requested URI. + /// A that represents the URI parsed from the request. /// public abstract Uri RequestUri { get; } From e631e2164227d7068ccd044440c47caa824c5635 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 4 Apr 2018 17:12:44 +0900 Subject: [PATCH 1919/6294] [Modify] Edit it --- .../Net/WebSockets/WebSocketContext.cs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Net/WebSockets/WebSocketContext.cs b/websocket-sharp/Net/WebSockets/WebSocketContext.cs index ca654c8c6..c5fae7c5c 100644 --- a/websocket-sharp/Net/WebSockets/WebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/WebSocketContext.cs @@ -142,14 +142,18 @@ protected WebSocketContext () public abstract Uri RequestUri { get; } /// - /// Gets the value of the Sec-WebSocket-Key header included in the request. + /// Gets the value of the Sec-WebSocket-Key header included in + /// the handshake request. /// - /// - /// This property provides a part of the information used by the server to prove that - /// it received a valid WebSocket handshake request. - /// /// - /// A that represents the value of the Sec-WebSocket-Key header. + /// + /// A that represents the value of + /// the Sec-WebSocket-Key header. + /// + /// + /// The value is used to prove that the server received + /// a valid WebSocket handshake request. + /// /// public abstract string SecWebSocketKey { get; } From 7a9f11a92e36ca015777024f80a09302a626173e Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 4 Apr 2018 17:20:32 +0900 Subject: [PATCH 1920/6294] [Modify] Edit it --- .../HttpListenerWebSocketContext.cs | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs b/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs index 2f37e110d..31f015e7d 100644 --- a/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs @@ -231,16 +231,21 @@ public override Uri RequestUri { } /// - /// Gets the value of the Sec-WebSocket-Key header included in the handshake - /// request. + /// Gets the value of the Sec-WebSocket-Key header included in + /// the handshake request. /// - /// - /// This property provides a part of the information used by the server to - /// prove that it received a valid WebSocket handshake request. - /// /// - /// A that represents the value of the - /// Sec-WebSocket-Key header. + /// + /// A that represents the value of + /// the Sec-WebSocket-Key header. + /// + /// + /// The value is used to prove that the server received + /// a valid WebSocket handshake request. + /// + /// + /// if the header is not present. + /// /// public override string SecWebSocketKey { get { From 0311a39b573c8995a7bf5805f17e45888eaa7b12 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 5 Apr 2018 17:17:56 +0900 Subject: [PATCH 1921/6294] [Modify] Edit it --- websocket-sharp/Net/WebSockets/WebSocketContext.cs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Net/WebSockets/WebSocketContext.cs b/websocket-sharp/Net/WebSockets/WebSocketContext.cs index c5fae7c5c..496138a58 100644 --- a/websocket-sharp/Net/WebSockets/WebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/WebSocketContext.cs @@ -174,13 +174,12 @@ protected WebSocketContext () public abstract IEnumerable SecWebSocketProtocols { get; } /// - /// Gets the value of the Sec-WebSocket-Version header included in the request. + /// Gets the value of the Sec-WebSocket-Version header included in + /// the handshake request. /// - /// - /// This property represents the WebSocket protocol version. - /// /// - /// A that represents the value of the Sec-WebSocket-Version header. + /// A that represents the WebSocket protocol + /// version specified by the client. /// public abstract string SecWebSocketVersion { get; } From 13b745be2fefa2fe00ced7c36dbdb6aef224bfc2 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 5 Apr 2018 17:23:47 +0900 Subject: [PATCH 1922/6294] [Modify] Edit it --- .../Net/WebSockets/HttpListenerWebSocketContext.cs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs b/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs index 31f015e7d..7790b37e6 100644 --- a/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs @@ -284,11 +284,17 @@ public override IEnumerable SecWebSocketProtocols { } /// - /// Gets the value of the Sec-WebSocket-Version header included in the - /// handshake request. + /// Gets the value of the Sec-WebSocket-Version header included in + /// the handshake request. /// /// - /// A that represents the WebSocket protocol version. + /// + /// A that represents the WebSocket protocol + /// version specified by the client. + /// + /// + /// if the header is not present. + /// /// public override string SecWebSocketVersion { get { From 5cc734ef376ce22094fce9d3825760a678d6ebab Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 5 Apr 2018 17:27:35 +0900 Subject: [PATCH 1923/6294] [Modify] Edit it --- websocket-sharp/Net/WebSockets/WebSocketContext.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/WebSockets/WebSocketContext.cs b/websocket-sharp/Net/WebSockets/WebSocketContext.cs index 496138a58..1a3921f02 100644 --- a/websocket-sharp/Net/WebSockets/WebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/WebSocketContext.cs @@ -184,10 +184,11 @@ protected WebSocketContext () public abstract string SecWebSocketVersion { get; } /// - /// Gets the server endpoint as an IP address and a port number. + /// Gets the endpoint to which the handshake request is sent. /// /// - /// A that represents the server endpoint. + /// A that represents the server IP + /// address and port number. /// public abstract System.Net.IPEndPoint ServerEndPoint { get; } From 624f9ed898a3e58acdd916ca98a42ad9bfd78f3e Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 5 Apr 2018 17:32:05 +0900 Subject: [PATCH 1924/6294] [Modify] Edit it --- websocket-sharp/Net/WebSockets/WebSocketContext.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/WebSockets/WebSocketContext.cs b/websocket-sharp/Net/WebSockets/WebSocketContext.cs index 1a3921f02..6ed982734 100644 --- a/websocket-sharp/Net/WebSockets/WebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/WebSocketContext.cs @@ -193,10 +193,11 @@ protected WebSocketContext () public abstract System.Net.IPEndPoint ServerEndPoint { get; } /// - /// Gets the client information (identity, authentication, and security roles). + /// Gets the client information. /// /// - /// A instance that represents the client information. + /// A instance that represents identity, + /// authentication, and security roles for the client. /// public abstract IPrincipal User { get; } From 33fc43b120aa413759bda43b0c1e904fbf919175 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 5 Apr 2018 17:35:12 +0900 Subject: [PATCH 1925/6294] [Modify] Edit it --- websocket-sharp/Net/WebSockets/WebSocketContext.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/WebSockets/WebSocketContext.cs b/websocket-sharp/Net/WebSockets/WebSocketContext.cs index 6ed982734..9fd092919 100644 --- a/websocket-sharp/Net/WebSockets/WebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/WebSocketContext.cs @@ -202,10 +202,11 @@ protected WebSocketContext () public abstract IPrincipal User { get; } /// - /// Gets the client endpoint as an IP address and a port number. + /// Gets the endpoint from which the handshake request is sent. /// /// - /// A that represents the client endpoint. + /// A that represents the client IP + /// address and port number. /// public abstract System.Net.IPEndPoint UserEndPoint { get; } From c265c18bded052996694ce8b9a1d8076026e7699 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 6 Apr 2018 17:58:13 +0900 Subject: [PATCH 1926/6294] [Modify] Edit it --- websocket-sharp/Net/WebSockets/WebSocketContext.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/WebSockets/WebSocketContext.cs b/websocket-sharp/Net/WebSockets/WebSocketContext.cs index 9fd092919..65c38f3fe 100644 --- a/websocket-sharp/Net/WebSockets/WebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/WebSocketContext.cs @@ -211,11 +211,12 @@ protected WebSocketContext () public abstract System.Net.IPEndPoint UserEndPoint { get; } /// - /// Gets the instance used for - /// two-way communication between client and server. + /// Gets the WebSocket instance used for two-way communication between + /// the client and server. /// /// - /// A . + /// A used for two-way communication + /// using the WebSocket protocol. /// public abstract WebSocket WebSocket { get; } From dfea8eb3c6a0d06f0162c33be0ce71c54dea3933 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 7 Apr 2018 20:43:16 +0900 Subject: [PATCH 1927/6294] [Modify] Edit it --- websocket-sharp/Net/WebSockets/WebSocketContext.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/websocket-sharp/Net/WebSockets/WebSocketContext.cs b/websocket-sharp/Net/WebSockets/WebSocketContext.cs index 65c38f3fe..149a20d5d 100644 --- a/websocket-sharp/Net/WebSockets/WebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/WebSocketContext.cs @@ -215,8 +215,7 @@ protected WebSocketContext () /// the client and server. /// /// - /// A used for two-way communication - /// using the WebSocket protocol. + /// A . /// public abstract WebSocket WebSocket { get; } From 790073d6a30816b89128e8b149605e9d509331c9 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 7 Apr 2018 20:46:09 +0900 Subject: [PATCH 1928/6294] [Modify] Edit it --- .../Net/WebSockets/HttpListenerWebSocketContext.cs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs b/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs index 7790b37e6..e1e4ed649 100644 --- a/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs @@ -347,12 +347,11 @@ public override System.Net.IPEndPoint UserEndPoint { } /// - /// Gets the WebSocket interface for two-way communication between the - /// client and server. + /// Gets the WebSocket instance used for two-way communication between + /// the client and server. /// /// - /// A that provides a set of methods - /// and properties for two-way communication using the WebSocket protocol. + /// A . /// public override WebSocket WebSocket { get { From 2a1d812ba29d1fbdcc4a87def37cca41c1ab43c0 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 8 Apr 2018 17:55:51 +0900 Subject: [PATCH 1929/6294] [Modify] Edit it --- websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs index 3b54871e3..abe916e33 100644 --- a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs @@ -45,8 +45,8 @@ namespace WebSocketSharp.Net.WebSockets { /// - /// Provides the properties used to access the information in - /// a WebSocket handshake request received by the . + /// Provides the access to the information in a WebSocket handshake request to + /// a instance. /// internal class TcpListenerWebSocketContext : WebSocketContext { From 14186629ce319e641bbeff2cfe16a9fbdda3450d Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 9 Apr 2018 17:32:11 +0900 Subject: [PATCH 1930/6294] [Modify] Polish it --- .../WebSockets/TcpListenerWebSocketContext.cs | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs index abe916e33..e5e7b277e 100644 --- a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs @@ -81,8 +81,11 @@ Logger logger var netStream = tcpClient.GetStream (); if (secure) { - var sslStream = - new SslStream (netStream, false, sslConfig.ClientCertificateValidationCallback); + var sslStream = new SslStream ( + netStream, + false, + sslConfig.ClientCertificateValidationCallback + ); sslStream.AuthenticateAsServer ( sslConfig.ServerCertificate, @@ -98,10 +101,12 @@ Logger logger } _request = HttpRequest.Read (_stream, 90000); - _uri = - HttpUtility.CreateRequestUrl ( - _request.RequestUri, _request.Headers["Host"], _request.IsWebSocketRequest, secure - ); + _uri = HttpUtility.CreateRequestUrl ( + _request.RequestUri, + _request.Headers["Host"], + _request.IsWebSocketRequest, + secure + ); _websocket = new WebSocket (this, protocol); } From d89ca315af62cfd05165f1e5614bc51da3f8307e Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 9 Apr 2018 17:39:22 +0900 Subject: [PATCH 1931/6294] [Modify] Rename it --- .../Net/WebSockets/TcpListenerWebSocketContext.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs index e5e7b277e..a41b6b835 100644 --- a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs @@ -53,7 +53,7 @@ internal class TcpListenerWebSocketContext : WebSocketContext #region Private Fields private CookieCollection _cookies; - private Logger _logger; + private Logger _log; private NameValueCollection _queryString; private HttpRequest _request; private bool _secure; @@ -72,12 +72,12 @@ internal TcpListenerWebSocketContext ( string protocol, bool secure, ServerSslConfiguration sslConfig, - Logger logger + Logger log ) { _tcpClient = tcpClient; _secure = secure; - _logger = logger; + _log = log; var netStream = tcpClient.GetStream (); if (secure) { @@ -117,7 +117,7 @@ Logger logger internal Logger Log { get { - return _logger; + return _log; } } From 95c8bd00396c8cdf119faf27a7b6fc700e344c62 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 10 Apr 2018 17:13:21 +0900 Subject: [PATCH 1932/6294] [Modify] Polish it --- .../WebSockets/TcpListenerWebSocketContext.cs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs index a41b6b835..86f370ec9 100644 --- a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs @@ -235,13 +235,15 @@ public override string Origin { /// public override NameValueCollection QueryString { get { - return _queryString - ?? ( - _queryString = - HttpUtility.InternalParseQueryString ( - _uri != null ? _uri.Query : null, Encoding.UTF8 - ) - ); + if (_queryString == null) { + var uri = RequestUri; + _queryString = HttpUtility.InternalParseQueryString ( + uri != null ? uri.Query : null, + Encoding.UTF8 + ); + } + + return _queryString; } } From be0d8ec526b07b4390002a92eeda52100a01e131 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 10 Apr 2018 17:26:22 +0900 Subject: [PATCH 1933/6294] [Modify] Edit it --- .../Net/WebSockets/TcpListenerWebSocketContext.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs index 86f370ec9..61583877c 100644 --- a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs @@ -228,10 +228,16 @@ public override string Origin { } /// - /// Gets the query string included in the request. + /// Gets the query string included in the handshake request. /// /// - /// A that contains the query string parameters. + /// + /// A that contains the query + /// parameters. + /// + /// + /// An empty collection if not included. + /// /// public override NameValueCollection QueryString { get { From a83a3bab414c568612b25ca9fd32cd4b224e711f Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 11 Apr 2018 19:48:07 +0900 Subject: [PATCH 1934/6294] [Modify] Move it --- .../WebSockets/TcpListenerWebSocketContext.cs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs index 61583877c..90738fcc6 100644 --- a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs @@ -101,13 +101,6 @@ Logger log } _request = HttpRequest.Read (_stream, 90000); - _uri = HttpUtility.CreateRequestUrl ( - _request.RequestUri, - _request.Headers["Host"], - _request.IsWebSocketRequest, - secure - ); - _websocket = new WebSocket (this, protocol); } @@ -261,6 +254,15 @@ public override NameValueCollection QueryString { /// public override Uri RequestUri { get { + if (_uri == null) { + _uri = HttpUtility.CreateRequestUrl ( + _request.RequestUri, + _request.Headers["Host"], + _request.IsWebSocketRequest, + _secure + ); + } + return _uri; } } From 1f0c9f79bb98b7d0289d14788e3a9174c99b1ded Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 11 Apr 2018 19:54:07 +0900 Subject: [PATCH 1935/6294] [Modify] Edit it --- .../Net/WebSockets/TcpListenerWebSocketContext.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs index 90738fcc6..b33f37ceb 100644 --- a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs @@ -250,7 +250,12 @@ public override NameValueCollection QueryString { /// Gets the URI requested by the client. /// /// - /// A that represents the requested URI. + /// + /// A that represents the URI parsed from the request. + /// + /// + /// if the URI cannot be parsed. + /// /// public override Uri RequestUri { get { From ff00cee6ff0b58578f83c9e2d55b5480962f3c15 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 12 Apr 2018 19:38:29 +0900 Subject: [PATCH 1936/6294] [Modify] Edit it --- .../Net/WebSockets/TcpListenerWebSocketContext.cs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs index b33f37ceb..aed0391f1 100644 --- a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs @@ -456,12 +456,11 @@ internal void SendAuthenticationChallenge (string challenge) #region Public Methods /// - /// Returns a that represents - /// the current . + /// Returns a string that represents the current instance. /// /// - /// A that represents - /// the current . + /// A that contains the request line and headers + /// included in the handshake request. /// public override string ToString () { From f58aeb44ea1aecbe8f9515712f66d3b0ac524326 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 12 Apr 2018 19:41:43 +0900 Subject: [PATCH 1937/6294] [Modify] Edit it --- websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs index aed0391f1..ac834e6bc 100644 --- a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs @@ -370,8 +370,8 @@ public override System.Net.IPEndPoint UserEndPoint { } /// - /// Gets the instance used for - /// two-way communication between client and server. + /// Gets the WebSocket instance used for two-way communication between + /// the client and server. /// /// /// A . From a7cb530d0153c58cc0c3dc00892c7c337cb922b5 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 13 Apr 2018 19:59:18 +0900 Subject: [PATCH 1938/6294] [Modify] Polish it --- websocket-sharp/HttpRequest.cs | 14 +++++++++----- .../Net/WebSockets/TcpListenerWebSocketContext.cs | 3 +-- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/websocket-sharp/HttpRequest.cs b/websocket-sharp/HttpRequest.cs index bb7b9717f..a102de92a 100644 --- a/websocket-sharp/HttpRequest.cs +++ b/websocket-sharp/HttpRequest.cs @@ -45,10 +45,11 @@ internal class HttpRequest : HttpBase { #region Private Fields - private string _method; - private string _uri; - private bool _websocketRequest; - private bool _websocketRequestSet; + private CookieCollection _cookies; + private string _method; + private string _uri; + private bool _websocketRequest; + private bool _websocketRequestSet; #endregion @@ -86,7 +87,10 @@ public AuthenticationResponse AuthenticationResponse { public CookieCollection Cookies { get { - return Headers.GetCookies (false); + if (_cookies == null) + _cookies = Headers.GetCookies (false); + + return _cookies; } } diff --git a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs index ac834e6bc..5cfd8e6c5 100644 --- a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs @@ -52,7 +52,6 @@ internal class TcpListenerWebSocketContext : WebSocketContext { #region Private Fields - private CookieCollection _cookies; private Logger _log; private NameValueCollection _queryString; private HttpRequest _request; @@ -132,7 +131,7 @@ internal Stream Stream { /// public override CookieCollection CookieCollection { get { - return _cookies ?? (_cookies = _request.Cookies); + return _request.Cookies; } } From 01e48359ba34fd17ed621d9344ff85f3264b309f Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 13 Apr 2018 20:02:31 +0900 Subject: [PATCH 1939/6294] [Modify] Edit it --- .../Net/WebSockets/TcpListenerWebSocketContext.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs index 5cfd8e6c5..b033ea308 100644 --- a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs @@ -124,10 +124,16 @@ internal Stream Stream { #region Public Properties /// - /// Gets the HTTP cookies included in the request. + /// Gets the HTTP cookies included in the handshake request. /// /// - /// A that contains the cookies. + /// + /// A that contains + /// the cookies. + /// + /// + /// An empty collection if not included. + /// /// public override CookieCollection CookieCollection { get { From a71197f482be1fbe899a1cb243e1c4a5c2d7e581 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 14 Apr 2018 21:23:02 +0900 Subject: [PATCH 1940/6294] [Modify] Polish it --- websocket-sharp/HttpRequest.cs | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/websocket-sharp/HttpRequest.cs b/websocket-sharp/HttpRequest.cs index a102de92a..fe74d5afb 100644 --- a/websocket-sharp/HttpRequest.cs +++ b/websocket-sharp/HttpRequest.cs @@ -48,8 +48,6 @@ internal class HttpRequest : HttpBase private CookieCollection _cookies; private string _method; private string _uri; - private bool _websocketRequest; - private bool _websocketRequestSet; #endregion @@ -102,15 +100,9 @@ public string HttpMethod { public bool IsWebSocketRequest { get { - if (!_websocketRequestSet) { - _websocketRequest = _method == "GET" - && ProtocolVersion > HttpVersion.Version10 - && Headers.Upgrades ("websocket"); - - _websocketRequestSet = true; - } - - return _websocketRequest; + return _method == "GET" + && ProtocolVersion > HttpVersion.Version10 + && Headers.Upgrades ("websocket"); } } From a0fea8f64c1a5bbf1bb49f3c6d4feedc98154ba7 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 14 Apr 2018 21:26:38 +0900 Subject: [PATCH 1941/6294] [Modify] Edit it --- .../Net/WebSockets/TcpListenerWebSocketContext.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs index b033ea308..76270e577 100644 --- a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs @@ -202,10 +202,12 @@ public override bool IsSecureConnection { } /// - /// Gets a value indicating whether the request is a WebSocket handshake request. + /// Gets a value indicating whether the request is a WebSocket handshake + /// request. /// /// - /// true if the request is a WebSocket handshake request; otherwise, false. + /// true if the request is a WebSocket handshake request; otherwise, + /// false. /// public override bool IsWebSocketRequest { get { From 7360b99f2a16ae9df4791c554d98147506a22a29 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 15 Apr 2018 17:02:47 +0900 Subject: [PATCH 1942/6294] [Modify] Edit it --- websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs index 76270e577..55ef6c351 100644 --- a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs @@ -142,7 +142,7 @@ public override CookieCollection CookieCollection { } /// - /// Gets the HTTP headers included in the request. + /// Gets the HTTP headers included in the handshake request. /// /// /// A that contains the headers. From cc9ec50d8e403f1c6b145dbdde04bf295af9b88c Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 15 Apr 2018 17:23:15 +0900 Subject: [PATCH 1943/6294] [Modify] Edit it --- .../Net/WebSockets/TcpListenerWebSocketContext.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs index 55ef6c351..febac31f5 100644 --- a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs @@ -154,10 +154,16 @@ public override NameValueCollection Headers { } /// - /// Gets the value of the Host header included in the request. + /// Gets the value of the Host header included in the handshake request. /// /// - /// A that represents the value of the Host header. + /// + /// A that represents the server host name requested + /// by the client. + /// + /// + /// It includes the port number if provided. + /// /// public override string Host { get { From 27544cc79292f3de7e1e9d027dbbf4e91da9474d Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 16 Apr 2018 17:28:56 +0900 Subject: [PATCH 1944/6294] [Modify] Edit it --- .../Net/WebSockets/TcpListenerWebSocketContext.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs index febac31f5..06a7c43bf 100644 --- a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs @@ -184,10 +184,12 @@ public override bool IsAuthenticated { } /// - /// Gets a value indicating whether the client connected from the local computer. + /// Gets a value indicating whether the handshake request is sent from + /// the local computer. /// /// - /// true if the client connected from the local computer; otherwise, false. + /// true if the handshake request is sent from the same computer + /// as the server; otherwise, false. /// public override bool IsLocal { get { From 498ef95756484d8eea16e1b6878add99d2c496a5 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 16 Apr 2018 17:31:09 +0900 Subject: [PATCH 1945/6294] [Modify] Edit it --- .../Net/WebSockets/TcpListenerWebSocketContext.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs index 06a7c43bf..2a06ea9fd 100644 --- a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs @@ -198,10 +198,11 @@ public override bool IsLocal { } /// - /// Gets a value indicating whether the WebSocket connection is secured. + /// Gets a value indicating whether a secure connection is used to send + /// the handshake request. /// /// - /// true if the connection is secured; otherwise, false. + /// true if the connection is secure; otherwise, false. /// public override bool IsSecureConnection { get { From 3047b5c7c10a00c51b9d4581861b07b542300c9a Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 17 Apr 2018 17:20:52 +0900 Subject: [PATCH 1946/6294] [Modify] Edit it --- .../Net/WebSockets/TcpListenerWebSocketContext.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs index 2a06ea9fd..72dde29fc 100644 --- a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs @@ -225,10 +225,15 @@ public override bool IsWebSocketRequest { } /// - /// Gets the value of the Origin header included in the request. + /// Gets the value of the Origin header included in the handshake request. /// /// - /// A that represents the value of the Origin header. + /// + /// A that represents the value of the Origin header. + /// + /// + /// if the header is not present. + /// /// public override string Origin { get { From 5bfdf5aa195f4193cf5c21dd70e3ff77220af826 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 17 Apr 2018 17:26:59 +0900 Subject: [PATCH 1947/6294] [Modify] Edit it --- .../WebSockets/TcpListenerWebSocketContext.cs | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs index 72dde29fc..032bf5846 100644 --- a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs @@ -294,14 +294,21 @@ public override Uri RequestUri { } /// - /// Gets the value of the Sec-WebSocket-Key header included in the request. + /// Gets the value of the Sec-WebSocket-Key header included in + /// the handshake request. /// - /// - /// This property provides a part of the information used by the server to prove that - /// it received a valid WebSocket handshake request. - /// /// - /// A that represents the value of the Sec-WebSocket-Key header. + /// + /// A that represents the value of + /// the Sec-WebSocket-Key header. + /// + /// + /// The value is used to prove that the server received + /// a valid WebSocket handshake request. + /// + /// + /// if the header is not present. + /// /// public override string SecWebSocketKey { get { From 570b66ea3d6ffc57532a9e2891952880db757223 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 18 Apr 2018 17:23:06 +0900 Subject: [PATCH 1948/6294] [Modify] Edit it --- .../Net/WebSockets/TcpListenerWebSocketContext.cs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs index 032bf5846..4dd726e7e 100644 --- a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs @@ -347,13 +347,17 @@ public override IEnumerable SecWebSocketProtocols { } /// - /// Gets the value of the Sec-WebSocket-Version header included in the request. + /// Gets the value of the Sec-WebSocket-Version header included in + /// the handshake request. /// - /// - /// This property represents the WebSocket protocol version. - /// /// - /// A that represents the value of the Sec-WebSocket-Version header. + /// + /// A that represents the WebSocket protocol + /// version specified by the client. + /// + /// + /// if the header is not present. + /// /// public override string SecWebSocketVersion { get { From 6761edcfa01d66ba79258dc33d2141f767f19f3f Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 18 Apr 2018 17:26:49 +0900 Subject: [PATCH 1949/6294] [Modify] Edit it --- .../Net/WebSockets/TcpListenerWebSocketContext.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs index 4dd726e7e..58119b56d 100644 --- a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs @@ -366,10 +366,11 @@ public override string SecWebSocketVersion { } /// - /// Gets the server endpoint as an IP address and a port number. + /// Gets the endpoint to which the handshake request is sent. /// /// - /// A that represents the server endpoint. + /// A that represents the server IP + /// address and port number. /// public override System.Net.IPEndPoint ServerEndPoint { get { From 2232f34cd90cdb92384c9baa5dc09f27f433b988 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 19 Apr 2018 20:29:12 +0900 Subject: [PATCH 1950/6294] [Modify] Edit it --- .../Net/WebSockets/TcpListenerWebSocketContext.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs index 58119b56d..9d4b1a150 100644 --- a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs @@ -379,10 +379,16 @@ public override System.Net.IPEndPoint ServerEndPoint { } /// - /// Gets the client information (identity, authentication, and security roles). + /// Gets the client information. /// /// - /// A instance that represents the client information. + /// + /// A instance that represents identity, + /// authentication, and security roles for the client. + /// + /// + /// if the client is not authenticated. + /// /// public override IPrincipal User { get { From f3d16101f5d0306ea31bf77e1c5207ddb2b9b373 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 20 Apr 2018 19:09:01 +0900 Subject: [PATCH 1951/6294] [Modify] Edit it --- .../Net/WebSockets/TcpListenerWebSocketContext.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs index 9d4b1a150..0ea716ae3 100644 --- a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs @@ -397,10 +397,11 @@ public override IPrincipal User { } /// - /// Gets the client endpoint as an IP address and a port number. + /// Gets the endpoint from which the handshake request is sent. /// /// - /// A that represents the client endpoint. + /// A that represents the client IP + /// address and port number. /// public override System.Net.IPEndPoint UserEndPoint { get { From e5accd3e690950fa9ff4e235181e3674f1ed778a Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 21 Apr 2018 16:48:11 +0900 Subject: [PATCH 1952/6294] [Modify] Polish it --- .../Net/WebSockets/TcpListenerWebSocketContext.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs index 0ea716ae3..3933cbe28 100644 --- a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs @@ -481,7 +481,12 @@ internal void Close () internal void Close (HttpStatusCode code) { - _websocket.Close (HttpResponse.CreateCloseResponse (code)); + var res = HttpResponse.CreateCloseResponse (code); + var bytes = res.ToByteArray (); + _stream.Write (bytes, 0, bytes.Length); + + _stream.Close (); + _tcpClient.Close (); } internal void SendAuthenticationChallenge (string challenge) From e9a87d2f3f7ecbe31681cfc2de9cc7f6819746fc Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 22 Apr 2018 19:39:26 +0900 Subject: [PATCH 1953/6294] [Modify] Polish it --- .../Net/WebSockets/TcpListenerWebSocketContext.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs index 3933cbe28..d4b196714 100644 --- a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs @@ -491,8 +491,10 @@ internal void Close (HttpStatusCode code) internal void SendAuthenticationChallenge (string challenge) { - var buff = HttpResponse.CreateUnauthorizedResponse (challenge).ToByteArray (); - _stream.Write (buff, 0, buff.Length); + var res = HttpResponse.CreateUnauthorizedResponse (challenge); + var bytes = res.ToByteArray (); + _stream.Write (bytes, 0, bytes.Length); + _request = HttpRequest.Read (_stream, 15000); } From 127878a1efdfee5b9866ff532e908dc2a6752c27 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 23 Apr 2018 21:36:57 +0900 Subject: [PATCH 1954/6294] [Modify] Polish it --- .../WebSockets/TcpListenerWebSocketContext.cs | 27 +++++++++---------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs index d4b196714..8c12eb330 100644 --- a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs @@ -452,22 +452,21 @@ Func credentialsFinder return false; } - var user = - HttpUtility.CreateUser ( - _request.Headers["Authorization"], - scheme, - realm, - _request.HttpMethod, - credentialsFinder - ); - - if (user == null || !user.Identity.IsAuthenticated) { - SendAuthenticationChallenge (chal); - return auth (); + var user = HttpUtility.CreateUser ( + _request.Headers["Authorization"], + scheme, + realm, + _request.HttpMethod, + credentialsFinder + ); + + if (user != null && user.Identity.IsAuthenticated) { + _user = user; + return true; } - _user = user; - return true; + SendAuthenticationChallenge (chal); + return auth (); }; return auth (); From 7c8dcc15a19af880bc223009ed87b936a96774f8 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 24 Apr 2018 19:46:49 +0900 Subject: [PATCH 1955/6294] [Modify] Rename it --- .../WebSockets/TcpListenerWebSocketContext.cs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs index 8c12eb330..a3d394270 100644 --- a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs @@ -55,10 +55,10 @@ internal class TcpListenerWebSocketContext : WebSocketContext private Logger _log; private NameValueCollection _queryString; private HttpRequest _request; + private Uri _requestUri; private bool _secure; private Stream _stream; private TcpClient _tcpClient; - private Uri _uri; private IPrincipal _user; private WebSocket _websocket; @@ -280,16 +280,16 @@ public override NameValueCollection QueryString { /// public override Uri RequestUri { get { - if (_uri == null) { - _uri = HttpUtility.CreateRequestUrl ( - _request.RequestUri, - _request.Headers["Host"], - _request.IsWebSocketRequest, - _secure - ); + if (_requestUri == null) { + _requestUri = HttpUtility.CreateRequestUrl ( + _request.RequestUri, + _request.Headers["Host"], + _request.IsWebSocketRequest, + _secure + ); } - return _uri; + return _requestUri; } } From 5af4f752a73a3cc17a6bbfb4a74befd5e47443cd Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 25 Apr 2018 20:16:08 +0900 Subject: [PATCH 1956/6294] [Modify] Set the endpoints previously --- .../Net/WebSockets/TcpListenerWebSocketContext.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs index a3d394270..34adf0c4d 100644 --- a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs @@ -57,9 +57,11 @@ internal class TcpListenerWebSocketContext : WebSocketContext private HttpRequest _request; private Uri _requestUri; private bool _secure; + private System.Net.EndPoint _serverEndPoint; private Stream _stream; private TcpClient _tcpClient; private IPrincipal _user; + private System.Net.EndPoint _userEndPoint; private WebSocket _websocket; #endregion @@ -99,6 +101,10 @@ Logger log _stream = netStream; } + var sock = tcpClient.Client; + _serverEndPoint = sock.LocalEndPoint; + _userEndPoint = sock.RemoteEndPoint; + _request = HttpRequest.Read (_stream, 90000); _websocket = new WebSocket (this, protocol); } @@ -374,7 +380,7 @@ public override string SecWebSocketVersion { /// public override System.Net.IPEndPoint ServerEndPoint { get { - return (System.Net.IPEndPoint) _tcpClient.Client.LocalEndPoint; + return (System.Net.IPEndPoint) _serverEndPoint; } } @@ -405,7 +411,7 @@ public override IPrincipal User { /// public override System.Net.IPEndPoint UserEndPoint { get { - return (System.Net.IPEndPoint) _tcpClient.Client.RemoteEndPoint; + return (System.Net.IPEndPoint) _userEndPoint; } } From 1af3b26cb99b2bbcbaaa570af0a5aac5f14cb790 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 26 Apr 2018 19:56:52 +0900 Subject: [PATCH 1957/6294] [Modify] Add it --- websocket-sharp/Server/WebSocketServer.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 490613df3..1b91aed93 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -724,6 +724,17 @@ private void abort () _state = ServerState.Stop; } + private bool authenticateClient (TcpListenerWebSocketContext context) + { + if (_authSchemes == AuthenticationSchemes.Anonymous) + return true; + + if (_authSchemes == AuthenticationSchemes.None) + return false; + + return context.Authenticate (_authSchemes, _realmInUse, _userCredFinder); + } + private bool canSet (out string message) { message = null; From c0398c5bc141c9e0b1a52c6e120994fa14b31129 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 27 Apr 2018 19:21:56 +0900 Subject: [PATCH 1958/6294] [Modify] Polish them --- .../Net/WebSockets/TcpListenerWebSocketContext.cs | 12 +----------- websocket-sharp/Server/WebSocketServer.cs | 8 +++++--- 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs index 34adf0c4d..e26d99cb0 100644 --- a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs @@ -438,14 +438,6 @@ internal bool Authenticate ( Func credentialsFinder ) { - if (scheme == AuthenticationSchemes.Anonymous) - return true; - - if (scheme == AuthenticationSchemes.None) { - Close (HttpStatusCode.Forbidden); - return false; - } - var chal = new AuthenticationChallenge (scheme, realm).ToString (); var retry = -1; @@ -453,10 +445,8 @@ Func credentialsFinder auth = () => { retry++; - if (retry > 99) { - Close (HttpStatusCode.Forbidden); + if (retry > 99) return false; - } var user = HttpUtility.CreateUser ( _request.Headers["Authorization"], diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 1b91aed93..ce89d7391 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -806,6 +806,11 @@ private void init ( private void processRequest (TcpListenerWebSocketContext context) { + if (!authenticateClient (context)) { + context.Close (HttpStatusCode.Forbidden); + return; + } + var uri = context.RequestUri; if (uri == null) { context.Close (HttpStatusCode.BadRequest); @@ -846,9 +851,6 @@ private void receiveRequest () cl, null, _secure, _sslConfigInUse, _log ); - if (!ctx.Authenticate (_authSchemes, _realmInUse, _userCredFinder)) - return; - processRequest (ctx); } catch (Exception ex) { From c2dd7beb903ced14c774a7ef63e6ef226e670bd6 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 28 Apr 2018 20:43:06 +0900 Subject: [PATCH 1959/6294] [Modify] Add it --- .../Net/WebSockets/TcpListenerWebSocketContext.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs index e26d99cb0..69f8f7c9d 100644 --- a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs @@ -430,6 +430,19 @@ public override WebSocket WebSocket { #endregion + #region Private Methods + + private HttpRequest sendAuthenticationChallenge (string challenge) + { + var res = HttpResponse.CreateUnauthorizedResponse (challenge); + var bytes = res.ToByteArray (); + _stream.Write (bytes, 0, bytes.Length); + + return HttpRequest.Read (_stream, 15000); + } + + #endregion + #region Internal Methods internal bool Authenticate ( From 1af0b27c278743e0afa1790e4fbbffab8c26eef0 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 29 Apr 2018 19:41:16 +0900 Subject: [PATCH 1960/6294] [Modify] Replace it --- websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs index 69f8f7c9d..04f9c4425 100644 --- a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs @@ -474,7 +474,7 @@ Func credentialsFinder return true; } - SendAuthenticationChallenge (chal); + _request = sendAuthenticationChallenge (chal); return auth (); }; From 000c0a76b4fb2045cabc4f0ae6a80bea03e2663e Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 30 Apr 2018 19:29:09 +0900 Subject: [PATCH 1961/6294] [Modify] Remove it --- .../Net/WebSockets/TcpListenerWebSocketContext.cs | 9 --------- 1 file changed, 9 deletions(-) diff --git a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs index 04f9c4425..473cdb179 100644 --- a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs @@ -497,15 +497,6 @@ internal void Close (HttpStatusCode code) _tcpClient.Close (); } - internal void SendAuthenticationChallenge (string challenge) - { - var res = HttpResponse.CreateUnauthorizedResponse (challenge); - var bytes = res.ToByteArray (); - _stream.Write (bytes, 0, bytes.Length); - - _request = HttpRequest.Read (_stream, 15000); - } - #endregion #region Public Methods From 4a2767aa610d7d1e5e6ac8253a4599991a73731c Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 1 May 2018 19:38:05 +0900 Subject: [PATCH 1962/6294] [Modify] 2018 --- websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs index 473cdb179..e1fe3d032 100644 --- a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs @@ -4,7 +4,7 @@ * * The MIT License * - * Copyright (c) 2012-2016 sta.blockhead + * Copyright (c) 2012-2018 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From 2dfe31ab2d44027df3ba880942f42cc22af127bb Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 2 May 2018 19:43:21 +0900 Subject: [PATCH 1963/6294] [Modify] 2018 --- websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs b/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs index e1e4ed649..eed49ce1c 100644 --- a/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs @@ -4,7 +4,7 @@ * * The MIT License * - * Copyright (c) 2012-2016 sta.blockhead + * Copyright (c) 2012-2018 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From 6f8a2b8d06926d87ee91e9a5c3bdf0244e7e5c7c Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 3 May 2018 19:47:56 +0900 Subject: [PATCH 1964/6294] [Modify] 2018 --- websocket-sharp/Net/WebSockets/WebSocketContext.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebSockets/WebSocketContext.cs b/websocket-sharp/Net/WebSockets/WebSocketContext.cs index 149a20d5d..6921891f7 100644 --- a/websocket-sharp/Net/WebSockets/WebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/WebSocketContext.cs @@ -4,7 +4,7 @@ * * The MIT License * - * Copyright (c) 2012-2016 sta.blockhead + * Copyright (c) 2012-2018 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From 657dd7d7320b41725d16f10ae2f9e15678479ccc Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 4 May 2018 20:04:41 +0900 Subject: [PATCH 1965/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 3bdb4e3c3..2996e6dab 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -34,11 +34,12 @@ namespace WebSocketSharp.Server { /// - /// Exposes the methods and properties used to define the behavior of a WebSocket service - /// provided by the or . + /// Exposes a set of methods and properties used to define the behavior of + /// a WebSocket service provided by the or + /// . /// /// - /// The WebSocketBehavior class is an abstract class. + /// This class is an abstract class. /// public abstract class WebSocketBehavior : IWebSocketSession { From eda5f38d0b8b22deb3680f054738f9befe5de5a3 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 5 May 2018 20:43:17 +0900 Subject: [PATCH 1966/6294] [Modify] Throw exceptions --- websocket-sharp/Server/WebSocketBehavior.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 2996e6dab..43fe9d29c 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -399,8 +399,13 @@ internal void Start (WebSocketContext context, WebSocketSessionManager sessions) /// protected void Error (string message, Exception exception) { - if (message != null && message.Length > 0) - OnError (new ErrorEventArgs (message, exception)); + if (message == null) + throw new ArgumentNullException ("message"); + + if (message.Length == 0) + throw new ArgumentException ("An empty string.", "message"); + + OnError (new ErrorEventArgs (message, exception)); } /// From 26567a53d38e158676f7564fbdd1fa588d78ea70 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 6 May 2018 19:54:58 +0900 Subject: [PATCH 1967/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 43fe9d29c..3019e32c4 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -384,19 +384,21 @@ internal void Start (WebSocketContext context, WebSocketSessionManager sessions) #region Protected Methods /// - /// Calls the method with the specified and - /// . + /// Calls the method with the specified message. /// - /// - /// This method doesn't call the method if is - /// or empty. - /// /// /// A that represents the error message. /// /// - /// An instance that represents the cause of the error if any. + /// An instance that represents the cause of + /// the error if present. /// + /// + /// is . + /// + /// + /// is an empty string. + /// protected void Error (string message, Exception exception) { if (message == null) From 62759babc39301df898bdf9862d5b4c94dbb2902 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 7 May 2018 21:41:51 +0900 Subject: [PATCH 1968/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 3019e32c4..5b42e2c57 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -444,7 +444,8 @@ protected virtual void OnMessage (MessageEventArgs e) } /// - /// Called when the WebSocket connection used in a session has been established. + /// Called when the WebSocket connection used in a session has been + /// established. /// protected virtual void OnOpen () { From c83a9fc193a09bc0ae031d1afa02c155616d8070 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 8 May 2018 21:19:49 +0900 Subject: [PATCH 1969/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 5b42e2c57..2fa95a12c 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -433,11 +433,11 @@ protected virtual void OnError (ErrorEventArgs e) } /// - /// Called when the used in a session receives a message. + /// Called when the WebSocket instance used in a session receives a message. /// /// - /// A that represents the event data passed to - /// a event. + /// A that represents the event data passed + /// from a event. /// protected virtual void OnMessage (MessageEventArgs e) { From 1889a8a060cec5083ccfb6fa2041b825a603e0ce Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 9 May 2018 19:13:25 +0900 Subject: [PATCH 1970/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 2fa95a12c..a91857ae8 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -422,11 +422,11 @@ protected virtual void OnClose (CloseEventArgs e) } /// - /// Called when the used in a session gets an error. + /// Called when the WebSocket instance used in a session gets an error. /// /// - /// A that represents the event data passed to - /// a event. + /// A that represents the event data passed + /// from a event. /// protected virtual void OnError (ErrorEventArgs e) { From 2bcba770aa628f61823832044c8fc0ed13c68aba Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 10 May 2018 19:41:04 +0900 Subject: [PATCH 1971/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index a91857ae8..25d18c1de 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -411,11 +411,11 @@ protected void Error (string message, Exception exception) } /// - /// Called when the WebSocket connection used in a session has been closed. + /// Called when the WebSocket connection for a session has been closed. /// /// - /// A that represents the event data passed to - /// a event. + /// A that represents the event data passed + /// from a event. /// protected virtual void OnClose (CloseEventArgs e) { From 5c60c92f0740a170b4323437a7c1f1f2fba4a99f Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 10 May 2018 19:45:02 +0900 Subject: [PATCH 1972/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 25d18c1de..7154c4e3f 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -422,7 +422,7 @@ protected virtual void OnClose (CloseEventArgs e) } /// - /// Called when the WebSocket instance used in a session gets an error. + /// Called when the WebSocket instance for a session gets an error. /// /// /// A that represents the event data passed From 96356f9e6691d415265040f4d9a5514c90151f36 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 11 May 2018 19:50:49 +0900 Subject: [PATCH 1973/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 7154c4e3f..3979a54b5 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -433,7 +433,7 @@ protected virtual void OnError (ErrorEventArgs e) } /// - /// Called when the WebSocket instance used in a session receives a message. + /// Called when the WebSocket instance for a session receives a message. /// /// /// A that represents the event data passed From 49565452f0a4cd5ac752199dae87ef541987e322 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 12 May 2018 21:41:16 +0900 Subject: [PATCH 1974/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 3979a54b5..cea9c484e 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -444,8 +444,7 @@ protected virtual void OnMessage (MessageEventArgs e) } /// - /// Called when the WebSocket connection used in a session has been - /// established. + /// Called when the WebSocket connection for a session has been established. /// protected virtual void OnOpen () { From 7df96405143a63ed9230b2d1a36a742d29ef4b53 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 13 May 2018 20:00:11 +0900 Subject: [PATCH 1975/6294] [Modify] Throw exception --- websocket-sharp/Server/WebSocketBehavior.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index cea9c484e..7a4624a02 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -461,8 +461,12 @@ protected virtual void OnOpen () /// protected void Send (byte[] data) { - if (_websocket != null) - _websocket.Send (data); + if (_websocket == null) { + var msg = "The current state of the connection is not Open."; + throw new InvalidOperationException (msg); + } + + _websocket.Send (data); } /// From 0d920d15eef9389b8ac947c40200eb5f365dcd9b Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 14 May 2018 19:45:19 +0900 Subject: [PATCH 1976/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 7a4624a02..0298000cd 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -451,14 +451,17 @@ protected virtual void OnOpen () } /// - /// Sends binary to the client on a session. + /// Sends the specified data to a client using the WebSocket connection. /// - /// - /// This method is available after the WebSocket connection has been established. - /// /// /// An array of that represents the binary data to send. /// + /// + /// The current state of the connection is not Open. + /// + /// + /// is . + /// protected void Send (byte[] data) { if (_websocket == null) { From 5d2d5e356892c58af9921c14ba7665bfc4fc98be Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 15 May 2018 19:37:21 +0900 Subject: [PATCH 1977/6294] [Modify] Throw exception --- websocket-sharp/Server/WebSocketBehavior.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 0298000cd..98b92cfec 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -483,8 +483,12 @@ protected void Send (byte[] data) /// protected void Send (FileInfo file) { - if (_websocket != null) - _websocket.Send (file); + if (_websocket == null) { + var msg = "The current state of the connection is not Open."; + throw new InvalidOperationException (msg); + } + + _websocket.Send (file); } /// From bd5b8ded8ce483221a33c22aa34b3ed03f4127dc Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 15 May 2018 19:40:40 +0900 Subject: [PATCH 1978/6294] [Modify] Rename it --- websocket-sharp/Server/WebSocketBehavior.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 98b92cfec..74b5d3fa3 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -481,14 +481,14 @@ protected void Send (byte[] data) /// /// A that represents the file to send. /// - protected void Send (FileInfo file) + protected void Send (FileInfo fileInfo) { if (_websocket == null) { var msg = "The current state of the connection is not Open."; throw new InvalidOperationException (msg); } - _websocket.Send (file); + _websocket.Send (fileInfo); } /// From dc14d57083df109e6c1a99403a9c683cdd7cdf41 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 16 May 2018 19:49:16 +0900 Subject: [PATCH 1979/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 31 +++++++++++++++++---- 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 74b5d3fa3..2a053ffe4 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -473,14 +473,33 @@ protected void Send (byte[] data) } /// - /// Sends the specified as binary data to the client on a session. + /// Sends the specified file to a client using the WebSocket connection. /// - /// - /// This method is available after the WebSocket connection has been established. - /// - /// - /// A that represents the file to send. + /// + /// + /// A that specifies the file to send. + /// + /// + /// The file is sent as the binary data. + /// /// + /// + /// The current state of the connection is not Open. + /// + /// + /// is . + /// + /// + /// + /// The file does not exist. + /// + /// + /// -or- + /// + /// + /// The file could not be opened. + /// + /// protected void Send (FileInfo fileInfo) { if (_websocket == null) { From 5782dd198e1651ae15308613bd0684f47cc9c2b0 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 17 May 2018 19:29:52 +0900 Subject: [PATCH 1980/6294] [Modify] Throw exception --- websocket-sharp/Server/WebSocketBehavior.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 2a053ffe4..fd675e376 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -521,8 +521,12 @@ protected void Send (FileInfo fileInfo) /// protected void Send (string data) { - if (_websocket != null) - _websocket.Send (data); + if (_websocket == null) { + var msg = "The current state of the connection is not Open."; + throw new InvalidOperationException (msg); + } + + _websocket.Send (data); } /// From 421d4cb7f67bec41f19a8ce5ed01a35156671dc6 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 18 May 2018 19:35:34 +0900 Subject: [PATCH 1981/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index fd675e376..5637c2ee4 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -511,14 +511,20 @@ protected void Send (FileInfo fileInfo) } /// - /// Sends text to the client on a session. + /// Sends the specified data to a client using the WebSocket connection. /// - /// - /// This method is available after the WebSocket connection has been established. - /// /// /// A that represents the text data to send. /// + /// + /// The current state of the connection is not Open. + /// + /// + /// is . + /// + /// + /// could not be UTF-8-encoded. + /// protected void Send (string data) { if (_websocket == null) { From 67120df0e57245a0c9f0ee7a420dee438c2f3014 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 19 May 2018 20:28:31 +0900 Subject: [PATCH 1982/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 7effc8852..6177b29d3 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3351,7 +3351,7 @@ public bool Ping (string message) } /// - /// Sends using the WebSocket connection. + /// Sends the specified data using the WebSocket connection. /// /// /// An array of that represents the binary data to send. From 80273adef5dd95f9585a19e976d07e5b76798dfe Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 19 May 2018 20:35:00 +0900 Subject: [PATCH 1983/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 6177b29d3..d7ade7ae9 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3378,11 +3378,13 @@ public void Send (byte[] data) /// /// Sends the specified file using the WebSocket connection. /// - /// - /// The file is sent as the binary data. - /// /// - /// A that specifies the file to send. + /// + /// A that specifies the file to send. + /// + /// + /// The file is sent as the binary data. + /// /// /// /// The current state of the connection is not Open. From 11b49fc673978cf5fe49d71e2bd7fcbbe8062173 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 20 May 2018 19:39:49 +0900 Subject: [PATCH 1984/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index d7ade7ae9..3c887decd 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3428,7 +3428,7 @@ public void Send (FileInfo fileInfo) } /// - /// Sends using the WebSocket connection. + /// Sends the specified data using the WebSocket connection. /// /// /// A that represents the text data to send. From c7baf97417df5f5d728f949cdbac55c43a249ad7 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 21 May 2018 20:01:28 +0900 Subject: [PATCH 1985/6294] [Modify] Throw exception --- websocket-sharp/Server/WebSocketBehavior.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 5637c2ee4..2edb2bd28 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -556,8 +556,12 @@ protected void Send (string data) /// protected void SendAsync (byte[] data, Action completed) { - if (_websocket != null) - _websocket.SendAsync (data, completed); + if (_websocket == null) { + var msg = "The current state of the connection is not Open."; + throw new InvalidOperationException (msg); + } + + _websocket.SendAsync (data, completed); } /// From 612ea7f7e2ac60a4de56cf0a9b71cf855b4fd1f1 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 22 May 2018 19:45:19 +0900 Subject: [PATCH 1986/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 30 ++++++++++++++------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 2edb2bd28..68c3a1b7f 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -536,24 +536,34 @@ protected void Send (string data) } /// - /// Sends binary asynchronously to the client on a session. + /// Sends the specified data to a client asynchronously using the WebSocket + /// connection. /// /// - /// - /// This method is available after the WebSocket connection has been established. - /// - /// - /// This method doesn't wait for the send to be complete. - /// + /// This method does not wait for the send to be complete. /// /// /// An array of that represents the binary data to send. /// /// - /// An Action<bool> delegate that references the method(s) called when - /// the send is complete. A passed to this delegate is true - /// if the send is complete successfully. + /// + /// An Action<bool> delegate or + /// if not needed. + /// + /// + /// The delegate invokes the method called when the send is complete. + /// + /// + /// true is passed to the method if the send has done with + /// no error; otherwise, false. + /// /// + /// + /// The current state of the connection is not Open. + /// + /// + /// is . + /// protected void SendAsync (byte[] data, Action completed) { if (_websocket == null) { From 74cd02dace59cf16183db2b8e062ee61a32cf734 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 23 May 2018 19:02:37 +0900 Subject: [PATCH 1987/6294] [Modify] Throw exception --- websocket-sharp/Server/WebSocketBehavior.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 68c3a1b7f..66f1c36e1 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -596,8 +596,12 @@ protected void SendAsync (byte[] data, Action completed) /// protected void SendAsync (FileInfo file, Action completed) { - if (_websocket != null) - _websocket.SendAsync (file, completed); + if (_websocket == null) { + var msg = "The current state of the connection is not Open."; + throw new InvalidOperationException (msg); + } + + _websocket.SendAsync (file, completed); } /// From c50c33ceca87b0d954aa8f090b6879dc12acc849 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 23 May 2018 19:05:08 +0900 Subject: [PATCH 1988/6294] [Modify] Rename it --- websocket-sharp/Server/WebSocketBehavior.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 66f1c36e1..f68914dce 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -594,14 +594,14 @@ protected void SendAsync (byte[] data, Action completed) /// the send is complete. A passed to this delegate is true /// if the send is complete successfully. /// - protected void SendAsync (FileInfo file, Action completed) + protected void SendAsync (FileInfo fileInfo, Action completed) { if (_websocket == null) { var msg = "The current state of the connection is not Open."; throw new InvalidOperationException (msg); } - _websocket.SendAsync (file, completed); + _websocket.SendAsync (fileInfo, completed); } /// From 540667fd0cdf542ae5d8217f0e002403dedd4a63 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 24 May 2018 18:53:57 +0900 Subject: [PATCH 1989/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 45 ++++++++++++++++----- 1 file changed, 35 insertions(+), 10 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index f68914dce..d531dae36 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -575,25 +575,50 @@ protected void SendAsync (byte[] data, Action completed) } /// - /// Sends the specified as binary data asynchronously to - /// the client on a session. + /// Sends the specified file to a client asynchronously using the WebSocket + /// connection. /// /// + /// This method does not wait for the send to be complete. + /// + /// /// - /// This method is available after the WebSocket connection has been established. + /// A that specifies the file to send. /// /// - /// This method doesn't wait for the send to be complete. + /// The file is sent as the binary data. /// - /// - /// - /// A that represents the file to send. /// /// - /// An Action<bool> delegate that references the method(s) called when - /// the send is complete. A passed to this delegate is true - /// if the send is complete successfully. + /// + /// An Action<bool> delegate or + /// if not needed. + /// + /// + /// The delegate invokes the method called when the send is complete. + /// + /// + /// true is passed to the method if the send has done with + /// no error; otherwise, false. + /// /// + /// + /// The current state of the connection is not Open. + /// + /// + /// is . + /// + /// + /// + /// The file does not exist. + /// + /// + /// -or- + /// + /// + /// The file could not be opened. + /// + /// protected void SendAsync (FileInfo fileInfo, Action completed) { if (_websocket == null) { From ec3d720d3670255bbd036173db79bfb123350caa Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 25 May 2018 19:49:06 +0900 Subject: [PATCH 1990/6294] [Modify] Throw exception --- websocket-sharp/Server/WebSocketBehavior.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index d531dae36..7016d9e0f 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -650,8 +650,12 @@ protected void SendAsync (FileInfo fileInfo, Action completed) /// protected void SendAsync (string data, Action completed) { - if (_websocket != null) - _websocket.SendAsync (data, completed); + if (_websocket == null) { + var msg = "The current state of the connection is not Open."; + throw new InvalidOperationException (msg); + } + + _websocket.SendAsync (data, completed); } /// From 32ba638d4b7ab0eb84f74fc0207f087c8940bb26 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 26 May 2018 17:23:19 +0900 Subject: [PATCH 1991/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 33 ++++++++++++++------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 7016d9e0f..f5d733e70 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -630,24 +630,37 @@ protected void SendAsync (FileInfo fileInfo, Action completed) } /// - /// Sends text asynchronously to the client on a session. + /// Sends the specified data to a client asynchronously using the WebSocket + /// connection. /// /// - /// - /// This method is available after the WebSocket connection has been established. - /// - /// - /// This method doesn't wait for the send to be complete. - /// + /// This method does not wait for the send to be complete. /// /// /// A that represents the text data to send. /// /// - /// An Action<bool> delegate that references the method(s) called when - /// the send is complete. A passed to this delegate is true - /// if the send is complete successfully. + /// + /// An Action<bool> delegate or + /// if not needed. + /// + /// + /// The delegate invokes the method called when the send is complete. + /// + /// + /// true is passed to the method if the send has done with + /// no error; otherwise, false. + /// /// + /// + /// The current state of the connection is not Open. + /// + /// + /// is . + /// + /// + /// could not be UTF-8-encoded. + /// protected void SendAsync (string data, Action completed) { if (_websocket == null) { From a01c2354e1a34b0a847a970ae072a9a1fa268ca8 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 27 May 2018 19:46:26 +0900 Subject: [PATCH 1992/6294] [Modify] Throw exception --- websocket-sharp/Server/WebSocketBehavior.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index f5d733e70..9eda57b8a 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -696,8 +696,12 @@ protected void SendAsync (string data, Action completed) /// protected void SendAsync (Stream stream, int length, Action completed) { - if (_websocket != null) - _websocket.SendAsync (stream, length, completed); + if (_websocket == null) { + var msg = "The current state of the connection is not Open."; + throw new InvalidOperationException (msg); + } + + _websocket.SendAsync (stream, length, completed); } #endregion From 440c3ce20d7939e07fd07c38673c70beca5369a0 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 28 May 2018 19:23:34 +0900 Subject: [PATCH 1993/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 53 ++++++++++++++++----- 1 file changed, 42 insertions(+), 11 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 9eda57b8a..8685b3095 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -672,28 +672,59 @@ protected void SendAsync (string data, Action completed) } /// - /// Sends binary data from the specified asynchronously to - /// the client on a session. + /// Sends the data from the specified stream to a client asynchronously + /// using the WebSocket connection. /// /// + /// This method does not wait for the send to be complete. + /// + /// /// - /// This method is available after the WebSocket connection has been established. + /// A instance from which to read the data to send. /// /// - /// This method doesn't wait for the send to be complete. + /// The data is sent as the binary data. /// - /// - /// - /// A from which contains the binary data to send. /// /// - /// An that represents the number of bytes to send. + /// An that specifies the number of bytes to send. /// /// - /// An Action<bool> delegate that references the method(s) called when - /// the send is complete. A passed to this delegate is true - /// if the send is complete successfully. + /// + /// An Action<bool> delegate or + /// if not needed. + /// + /// + /// The delegate invokes the method called when the send is complete. + /// + /// + /// true is passed to the method if the send has done with + /// no error; otherwise, false. + /// /// + /// + /// The current state of the connection is not Open. + /// + /// + /// is . + /// + /// + /// + /// cannot be read. + /// + /// + /// -or- + /// + /// + /// is less than 1. + /// + /// + /// -or- + /// + /// + /// No data could be read from . + /// + /// protected void SendAsync (Stream stream, int length, Action completed) { if (_websocket == null) { From 904ecf21c4f6b0b0243dfbf708961af23702f7a8 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 29 May 2018 19:30:44 +0900 Subject: [PATCH 1994/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 8685b3095..5f95901b9 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -536,8 +536,8 @@ protected void Send (string data) } /// - /// Sends the specified data to a client asynchronously using the WebSocket - /// connection. + /// Sends the specified data to a client asynchronously using + /// the WebSocket connection. /// /// /// This method does not wait for the send to be complete. From fecec83362e24474c43fc8f77025f2a47e1d9a58 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 29 May 2018 19:33:06 +0900 Subject: [PATCH 1995/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 5f95901b9..f87747039 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -575,8 +575,8 @@ protected void SendAsync (byte[] data, Action completed) } /// - /// Sends the specified file to a client asynchronously using the WebSocket - /// connection. + /// Sends the specified file to a client asynchronously using + /// the WebSocket connection. /// /// /// This method does not wait for the send to be complete. From 969ae1fc7a25e7ae23551bf4d7f9f6b59557d086 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 29 May 2018 19:36:40 +0900 Subject: [PATCH 1996/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index f87747039..471e287bf 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -630,8 +630,8 @@ protected void SendAsync (FileInfo fileInfo, Action completed) } /// - /// Sends the specified data to a client asynchronously using the WebSocket - /// connection. + /// Sends the specified data to a client asynchronously using + /// the WebSocket connection. /// /// /// This method does not wait for the send to be complete. From 874fb7cf86c38bd4ca7d963330b3d13ac50a23ba Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 30 May 2018 19:18:58 +0900 Subject: [PATCH 1997/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 3c887decd..adeccb164 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3538,8 +3538,7 @@ public void Send (Stream stream, int length) } /// - /// Sends asynchronously using the WebSocket - /// connection. + /// Sends the specified data asynchronously using the WebSocket connection. /// /// /// This method does not wait for the send to be complete. From 65212058749ba8271375964bfe943c9640df9159 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 30 May 2018 19:26:14 +0900 Subject: [PATCH 1998/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index adeccb164..c9d11057b 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3582,15 +3582,15 @@ public void SendAsync (byte[] data, Action completed) /// Sends the specified file asynchronously using the WebSocket connection. /// /// + /// This method does not wait for the send to be complete. + /// + /// /// - /// The file is sent as the binary data. + /// A that specifies the file to send. /// /// - /// This method does not wait for the send to be complete. + /// The file is sent as the binary data. /// - /// - /// - /// A that specifies the file to send. /// /// /// From 0766ecb674b62a4420982b2f2d79ced6c7a612b0 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 31 May 2018 19:19:04 +0900 Subject: [PATCH 1999/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index c9d11057b..e9bc8bf0e 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3647,8 +3647,7 @@ public void SendAsync (FileInfo fileInfo, Action completed) } /// - /// Sends asynchronously using the WebSocket - /// connection. + /// Sends the specified data asynchronously using the WebSocket connection. /// /// /// This method does not wait for the send to be complete. From 60e49568bbaad1a63d349fb67b6fbb2d6d59a9b7 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 1 Jun 2018 19:24:57 +0900 Subject: [PATCH 2000/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index e9bc8bf0e..c5f896a27 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3697,19 +3697,19 @@ public void SendAsync (string data, Action completed) } /// - /// Sends the data from asynchronously using + /// Sends the data from the specified stream asynchronously using /// the WebSocket connection. /// /// + /// This method does not wait for the send to be complete. + /// + /// /// - /// The data is sent as the binary data. + /// A instance from which to read the data to send. /// /// - /// This method does not wait for the send to be complete. + /// The data is sent as the binary data. /// - /// - /// - /// A instance from which to read the data to send. /// /// /// An that specifies the number of bytes to send. From 3fab7a8c249969c45643465b0bdf8492ce32222c Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 2 Jun 2018 20:32:04 +0900 Subject: [PATCH 2001/6294] [Modify] Add it --- websocket-sharp/Server/WebSocketBehavior.cs | 48 +++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 471e287bf..9f7894bff 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -535,6 +535,54 @@ protected void Send (string data) _websocket.Send (data); } + /// + /// Sends the data from the specified stream to a client using + /// the WebSocket connection. + /// + /// + /// + /// A instance from which to read the data to send. + /// + /// + /// The data is sent as the binary data. + /// + /// + /// + /// An that specifies the number of bytes to send. + /// + /// + /// The current state of the connection is not Open. + /// + /// + /// is . + /// + /// + /// + /// cannot be read. + /// + /// + /// -or- + /// + /// + /// is less than 1. + /// + /// + /// -or- + /// + /// + /// No data could be read from . + /// + /// + protected void Send (Stream stream, int length) + { + if (_websocket == null) { + var msg = "The current state of the connection is not Open."; + throw new InvalidOperationException (msg); + } + + _websocket.Send (stream, length); + } + /// /// Sends the specified data to a client asynchronously using /// the WebSocket connection. From 2dbc62df9c1171e1a72e00dba223b2fd7de7856d Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 3 Jun 2018 21:45:30 +0900 Subject: [PATCH 2002/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index c5f896a27..e99776673 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3462,14 +3462,15 @@ public void Send (string data) } /// - /// Sends the data from using the WebSocket - /// connection. + /// Sends the data from the specified stream using the WebSocket connection. /// - /// - /// The data is sent as the binary data. - /// /// - /// A instance from which to read the data to send. + /// + /// A instance from which to read the data to send. + /// + /// + /// The data is sent as the binary data. + /// /// /// /// An that specifies the number of bytes to send. From ce10d87c275e5b0a36d54516da6a36980ed86df3 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 4 Jun 2018 19:34:52 +0900 Subject: [PATCH 2003/6294] [Modify] It will be removed --- websocket-sharp/Server/WebSocketBehavior.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 9f7894bff..61a9b9943 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -399,6 +399,7 @@ internal void Start (WebSocketContext context, WebSocketSessionManager sessions) /// /// is an empty string. /// + [Obsolete ("This method will be removed.")] protected void Error (string message, Exception exception) { if (message == null) From 607d16134523c705b67a5742a1eec147278b54c5 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 5 Jun 2018 19:36:01 +0900 Subject: [PATCH 2004/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketBehavior.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 61a9b9943..618f05ecb 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -296,7 +296,9 @@ public DateTime StartTime { /// public WebSocketState State { get { - return _websocket != null ? _websocket.ReadyState : WebSocketState.Connecting; + return _websocket != null + ? _websocket.ReadyState + : WebSocketState.Connecting; } } From 9fb86b2adc4d0c09ab9668a29c0e31e6772d013b Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 6 Jun 2018 19:46:53 +0900 Subject: [PATCH 2005/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 618f05ecb..9632ccaac 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -288,11 +288,19 @@ public DateTime StartTime { } /// - /// Gets the state of the used in a session. + /// Gets the current state of the WebSocket connection for a session. /// /// - /// One of the enum values, indicates the state of - /// the . + /// + /// One of the enum values. + /// + /// + /// It indicates the current state of the connection. + /// + /// + /// if the session has not + /// started yet. + /// /// public WebSocketState State { get { From 665ec5a7617e19deb66011367cb4cd07b46b33ed Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 7 Jun 2018 19:31:43 +0900 Subject: [PATCH 2006/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 9632ccaac..03ef1bed0 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -278,8 +278,13 @@ public string Protocol { /// Gets the time that a session has started. /// /// - /// A that represents the time that the session has started, - /// or if the WebSocket connection isn't established. + /// + /// A that represents the time that the session + /// has started. + /// + /// + /// if the session has not started yet. + /// /// public DateTime StartTime { get { From c03131a5db60c5bb5f943ab84836998668d22881 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 8 Jun 2018 19:43:25 +0900 Subject: [PATCH 2007/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 03ef1bed0..1a2169aa8 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -260,7 +260,7 @@ public Func OriginValidator { /// public string Protocol { get { - return _websocket != null ? _websocket.Protocol : (_protocol ?? String.Empty); + return _protocol ?? String.Empty; } set { From 09fd6ca410e04da10fb512031693ee5e00d728b1 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 9 Jun 2018 20:16:21 +0900 Subject: [PATCH 2008/6294] [Modify] Throw exceptions --- websocket-sharp/Server/WebSocketBehavior.cs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 1a2169aa8..39f82d825 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -264,11 +264,18 @@ public string Protocol { } set { - if (State != WebSocketState.Connecting) - return; + if (State != WebSocketState.Connecting) { + var msg = "The session has already started."; + throw new InvalidOperationException (msg); + } - if (value != null && (value.Length == 0 || !value.IsToken ())) + if (value == null || value.Length == 0) { + _protocol = null; return; + } + + if (!value.IsToken ()) + throw new ArgumentException ("Not a token.", "value"); _protocol = value; } From 044939a181c1dd21d8524062fef6a7159a4c2c77 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 10 Jun 2018 19:53:39 +0900 Subject: [PATCH 2009/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 23 +++++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 39f82d825..f943dc173 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -242,22 +242,27 @@ public Func OriginValidator { } /// - /// Gets or sets the WebSocket subprotocol used in the WebSocket service. + /// Gets or sets the name of subprotocol used in the WebSocket service. /// - /// - /// Set operation of this property is available before the WebSocket connection has - /// been established. - /// /// /// - /// A that represents the subprotocol if any. - /// The default value is . + /// A that represents the name of subprotocol. + /// + /// + /// The value specified for a set must be a token defined in + /// + /// RFC 2616. /// /// - /// The value to set must be a token defined in - /// RFC 2616. + /// The default value is an empty string. /// /// + /// + /// The set operation is not available if the session has already started. + /// + /// + /// The value specified for a set operation is not a token. + /// public string Protocol { get { return _protocol ?? String.Empty; From 955de3d7bcf6734a5311d4c683861c5e46d522e7 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 11 Jun 2018 19:31:59 +0900 Subject: [PATCH 2010/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index e99776673..f65852438 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -641,11 +641,16 @@ public string Origin { } /// - /// Gets the name of the subprotocol selected by server. + /// Gets the name of subprotocol selected by the server. /// /// - /// A that will be one of the names of the subprotocols - /// specified by client, or an empty string if not specified or selected. + /// + /// A that will be one of the names of + /// subprotocols specified by client. + /// + /// + /// An empty string if not specified or selected. + /// /// public string Protocol { get { From af4319b66cc5cef0f19ae4b4d8c93cdfd4cafb99 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 12 Jun 2018 19:14:29 +0900 Subject: [PATCH 2011/6294] [Fix] It must be the name of the parameter --- websocket-sharp/WebSocket.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index f65852438..10c3d795b 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -615,12 +615,12 @@ public string Origin { Uri uri; if (!Uri.TryCreate (value, UriKind.Absolute, out uri)) { msg = "Not an absolute URI string."; - throw new ArgumentException (msg, value); + throw new ArgumentException (msg, "value"); } if (uri.Segments.Length > 1) { msg = "It includes the path segments."; - throw new ArgumentException (msg, value); + throw new ArgumentException (msg, "value"); } } From 4218c134e6501d9fb2ed3206590458996c647a3f Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 13 Jun 2018 19:45:18 +0900 Subject: [PATCH 2012/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 25 +++++++++++---------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index f943dc173..f6e6d5b03 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -208,27 +208,28 @@ public bool IgnoreExtensions { } /// - /// Gets or sets the delegate called to validate the Origin header included in - /// a handshake request to the WebSocket service. + /// Gets or sets the delegate used to validate the Origin header included + /// in a handshake request to the WebSocket service. /// - /// - /// This delegate is called when the used in a session validates - /// the handshake request. - /// /// /// - /// A Func<string, bool> delegate that references the method(s) used to - /// validate the origin header. + /// A Func<string, bool> delegate or + /// if not needed. /// /// - /// parameter passed to this delegate represents the value of - /// the origin header to validate if any. + /// The delegate invokes the method called when the WebSocket instance + /// for a session validates the handshake request. /// /// - /// This delegate should return true if the origin header is valid. + /// The parameter passed to the method is the value + /// of the Origin header or if the header is not + /// present. /// /// - /// The default value is , and it does nothing to validate. + /// The method must return true if the header value is valid. + /// + /// + /// The default value is . /// /// public Func OriginValidator { From 110d1cc112811c0348f9f8ef041d159b1482bc79 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 14 Jun 2018 19:23:38 +0900 Subject: [PATCH 2013/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index f6e6d5b03..c972c39e6 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -194,8 +194,13 @@ public string ID { /// the Sec-WebSocket-Extensions header included in a handshake request. /// /// - /// true if the WebSocket service ignores the extensions requested from - /// a client; otherwise, false. The default value is false. + /// + /// true if the service ignores the extensions requested from + /// a client; otherwise, false. + /// + /// + /// The default value is false. + /// /// public bool IgnoreExtensions { get { From 035ac485572a3192496d2b6bdc885b60b40bfaa6 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 15 Jun 2018 19:36:49 +0900 Subject: [PATCH 2014/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index c972c39e6..33ab2b0bd 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -180,8 +180,12 @@ public bool EmitOnPing { /// Gets the unique ID of a session. /// /// - /// A that represents the unique ID of the session, - /// or if the WebSocket connection isn't established. + /// + /// A that represents the unique ID of the session. + /// + /// + /// if the session has not started yet. + /// /// public string ID { get { From 748de5bdf49bb7e5bfa431e373ca3848152c16f6 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 16 Jun 2018 20:35:29 +0900 Subject: [PATCH 2015/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 33ab2b0bd..bff4ae61e 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -154,12 +154,17 @@ public Func CookiesValidator { } /// - /// Gets or sets a value indicating whether the used in a session emits - /// a event when receives a Ping. + /// Gets or sets a value indicating whether the WebSocket instance for + /// a session emits the message event when receives a ping. /// /// - /// true if the emits a event - /// when receives a Ping; otherwise, false. The default value is false. + /// + /// true if the WebSocket instance emits the message event + /// when receives a ping; otherwise, false. + /// + /// + /// The default value is false. + /// /// public bool EmitOnPing { get { From d7bb1bd22672a57034f0bf2743c612b1d7a6673d Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 17 Jun 2018 19:32:08 +0900 Subject: [PATCH 2016/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 26 ++++++++++----------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index bff4ae61e..73de6c5b0 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -116,31 +116,31 @@ public WebSocketContext Context { } /// - /// Gets or sets the delegate called to validate the HTTP cookies included in + /// Gets or sets the delegate used to validate the HTTP cookies included in /// a handshake request to the WebSocket service. /// - /// - /// This delegate is called when the used in a session validates - /// the handshake request. - /// /// /// - /// A Func<CookieCollection, CookieCollection, bool> delegate that references - /// the method(s) used to validate the cookies. + /// A Func<CookieCollection, CookieCollection, bool> delegate + /// or if not needed. /// /// - /// 1st parameter passed to this delegate contains - /// the cookies to validate if any. + /// The delegate invokes the method called when the WebSocket instance + /// for a session validates the handshake request. /// /// - /// 2nd parameter passed to this delegate receives - /// the cookies to send to the client. + /// 1st parameter passed to the method + /// contains the cookies to validate if present. /// /// - /// This delegate should return true if the cookies are valid. + /// 2nd parameter passed to the method + /// receives the cookies to send to the client. /// /// - /// The default value is , and it does nothing to validate. + /// The method must return true if the cookies are valid. + /// + /// + /// The default value is . /// /// public Func CookiesValidator { From d18bebdb727f6e62eeb070b7c327cf4c3130e4a9 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 18 Jun 2018 20:12:08 +0900 Subject: [PATCH 2017/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 73de6c5b0..2abecbf1a 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -106,8 +106,13 @@ protected WebSocketSessionManager Sessions { /// Gets the information in a handshake request to the WebSocket service. /// /// - /// A instance that provides the access to the handshake request, - /// or if the WebSocket connection isn't established. + /// + /// A instance that provides the access to + /// the information in the handshake request. + /// + /// + /// if the session has not started yet. + /// /// public WebSocketContext Context { get { From daf3e4d83e3d0deff7737aa839310b113cb00ca8 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 19 Jun 2018 20:06:12 +0900 Subject: [PATCH 2018/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 2abecbf1a..3013a405c 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -84,13 +84,18 @@ protected Logger Log { return _websocket != null ? _websocket.Log : null; } } - + /// - /// Gets the access to the sessions in the WebSocket service. + /// Gets the management function for the sessions in the WebSocket service. /// /// - /// A that provides the access to the sessions, - /// or if the WebSocket connection isn't established. + /// + /// A that manages the sessions in + /// the service. + /// + /// + /// if the session has not started yet. + /// /// protected WebSocketSessionManager Sessions { get { From 5c0315a03f6dd09e0738d2207762b8d75fb29dd5 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 20 Jun 2018 19:34:42 +0900 Subject: [PATCH 2019/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 3013a405c..db77a482f 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -73,11 +73,15 @@ protected WebSocketBehavior () #region Protected Properties /// - /// Gets the logging functions. + /// Gets the logging function. /// /// - /// A that provides the logging functions, - /// or if the WebSocket connection isn't established. + /// + /// A that provides the logging function. + /// + /// + /// if the session has not started yet. + /// /// protected Logger Log { get { From a2fa39f9df7931cd2507d52420519e52567db17c Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 21 Jun 2018 19:34:54 +0900 Subject: [PATCH 2020/6294] [Modify] It will be removed --- websocket-sharp/Server/WebSocketBehavior.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index db77a482f..d75ae6167 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -83,6 +83,7 @@ protected WebSocketBehavior () /// if the session has not started yet. /// /// + [Obsolete ("This property will be removed.")] protected Logger Log { get { return _websocket != null ? _websocket.Log : null; From 8f5cd49c0d5f2b1cfcb04b9ba066cbb73549dd43 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 22 Jun 2018 19:50:20 +0900 Subject: [PATCH 2021/6294] [Modify] Edit it --- websocket-sharp/Server/IWebSocketSession.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/IWebSocketSession.cs b/websocket-sharp/Server/IWebSocketSession.cs index 530740a9c..798a404f5 100644 --- a/websocket-sharp/Server/IWebSocketSession.cs +++ b/websocket-sharp/Server/IWebSocketSession.cs @@ -32,7 +32,7 @@ namespace WebSocketSharp.Server { /// - /// Exposes the properties used to access the information in a session in a WebSocket service. + /// Exposes the access to the information in a WebSocket session. /// public interface IWebSocketSession { From 98d6af52b9c763e71383c540e39c6194c9815c1b Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 22 Jun 2018 19:58:14 +0900 Subject: [PATCH 2022/6294] [Modify] Edit it --- websocket-sharp/Server/IWebSocketSession.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/IWebSocketSession.cs b/websocket-sharp/Server/IWebSocketSession.cs index 798a404f5..7ac0d28fd 100644 --- a/websocket-sharp/Server/IWebSocketSession.cs +++ b/websocket-sharp/Server/IWebSocketSession.cs @@ -39,10 +39,11 @@ public interface IWebSocketSession #region Properties /// - /// Gets the information in the connection request to the WebSocket service. + /// Gets the information in the WebSocket handshake request. /// /// - /// A that provides the access to the connection request. + /// A instance that provides the access to + /// the information in the handshake request. /// WebSocketContext Context { get; } From 630d21cc15e35e3e94aec0f099d8dadf0fd58a2f Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 23 Jun 2018 20:27:58 +0900 Subject: [PATCH 2023/6294] [Modify] Edit it --- websocket-sharp/Server/IWebSocketSession.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/IWebSocketSession.cs b/websocket-sharp/Server/IWebSocketSession.cs index 7ac0d28fd..45cc50389 100644 --- a/websocket-sharp/Server/IWebSocketSession.cs +++ b/websocket-sharp/Server/IWebSocketSession.cs @@ -56,10 +56,11 @@ public interface IWebSocketSession string ID { get; } /// - /// Gets the WebSocket subprotocol used in the session. + /// Gets the name of the WebSocket subprotocol used in the session. /// /// - /// A that represents the subprotocol if any. + /// A that represents the name of the subprotocol + /// if present. /// string Protocol { get; } From bb18960e078ed725945b7ef2e8deb7b9ad6b068c Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 24 Jun 2018 21:42:39 +0900 Subject: [PATCH 2024/6294] [Modify] Edit it --- websocket-sharp/Server/IWebSocketSession.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Server/IWebSocketSession.cs b/websocket-sharp/Server/IWebSocketSession.cs index 45cc50389..5041fbec2 100644 --- a/websocket-sharp/Server/IWebSocketSession.cs +++ b/websocket-sharp/Server/IWebSocketSession.cs @@ -68,7 +68,8 @@ public interface IWebSocketSession /// Gets the time that the session has started. /// /// - /// A that represents the time that the session has started. + /// A that represents the time that the session + /// has started. /// DateTime StartTime { get; } From 485baba5355b6f98976a96db91ca03b6752c65ff Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 25 Jun 2018 19:36:04 +0900 Subject: [PATCH 2025/6294] [Modify] Edit it --- websocket-sharp/Server/IWebSocketSession.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Server/IWebSocketSession.cs b/websocket-sharp/Server/IWebSocketSession.cs index 5041fbec2..c323da001 100644 --- a/websocket-sharp/Server/IWebSocketSession.cs +++ b/websocket-sharp/Server/IWebSocketSession.cs @@ -74,11 +74,15 @@ public interface IWebSocketSession DateTime StartTime { get; } /// - /// Gets the state of the used in the session. + /// Gets the current state of the WebSocket connection for the session. /// /// - /// One of the enum values, indicates the state of - /// the used in the session. + /// + /// One of the enum values. + /// + /// + /// It indicates the current state of the connection. + /// /// WebSocketState State { get; } From 7c515d1886b53f0a8ed3d9717c84217d190c426e Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 26 Jun 2018 19:38:48 +0900 Subject: [PATCH 2026/6294] [Modify] Rename it --- websocket-sharp/Server/IWebSocketSession.cs | 26 +++++----- websocket-sharp/Server/WebSocketBehavior.cs | 48 +++++++++---------- .../Server/WebSocketSessionManager.cs | 2 +- 3 files changed, 38 insertions(+), 38 deletions(-) diff --git a/websocket-sharp/Server/IWebSocketSession.cs b/websocket-sharp/Server/IWebSocketSession.cs index c323da001..587776ddb 100644 --- a/websocket-sharp/Server/IWebSocketSession.cs +++ b/websocket-sharp/Server/IWebSocketSession.cs @@ -38,6 +38,19 @@ public interface IWebSocketSession { #region Properties + /// + /// Gets the current state of the WebSocket connection for the session. + /// + /// + /// + /// One of the enum values. + /// + /// + /// It indicates the current state of the connection. + /// + /// + WebSocketState ConnectionState { get; } + /// /// Gets the information in the WebSocket handshake request. /// @@ -73,19 +86,6 @@ public interface IWebSocketSession /// DateTime StartTime { get; } - /// - /// Gets the current state of the WebSocket connection for the session. - /// - /// - /// - /// One of the enum values. - /// - /// - /// It indicates the current state of the connection. - /// - /// - WebSocketState State { get; } - #endregion } } diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index d75ae6167..2d191cb2f 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -112,6 +112,29 @@ protected WebSocketSessionManager Sessions { #region Public Properties + /// + /// Gets the current state of the WebSocket connection for a session. + /// + /// + /// + /// One of the enum values. + /// + /// + /// It indicates the current state of the connection. + /// + /// + /// if the session has not + /// started yet. + /// + /// + public WebSocketState ConnectionState { + get { + return _websocket != null + ? _websocket.ReadyState + : WebSocketState.Connecting; + } + } + /// /// Gets the information in a handshake request to the WebSocket service. /// @@ -299,7 +322,7 @@ public string Protocol { } set { - if (State != WebSocketState.Connecting) { + if (ConnectionState != WebSocketState.Connecting) { var msg = "The session has already started."; throw new InvalidOperationException (msg); } @@ -334,29 +357,6 @@ public DateTime StartTime { } } - /// - /// Gets the current state of the WebSocket connection for a session. - /// - /// - /// - /// One of the enum values. - /// - /// - /// It indicates the current state of the connection. - /// - /// - /// if the session has not - /// started yet. - /// - /// - public WebSocketState State { - get { - return _websocket != null - ? _websocket.ReadyState - : WebSocketState.Connecting; - } - } - #endregion #region Private Methods diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 32d59c85e..f7144b0ce 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -1639,7 +1639,7 @@ public void Sweep () IWebSocketSession session; if (_sessions.TryGetValue (id, out session)) { - var state = session.State; + var state = session.ConnectionState; if (state == WebSocketState.Open) session.Context.WebSocket.Close (CloseStatusCode.Abnormal); else if (state == WebSocketState.Closing) From 906265fb8513a35d8c47d17a3f1576af6b782085 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 27 Jun 2018 19:36:51 +0900 Subject: [PATCH 2027/6294] [Modify] Edit it --- websocket-sharp/Server/IWebSocketSession.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/IWebSocketSession.cs b/websocket-sharp/Server/IWebSocketSession.cs index 587776ddb..4d43652ea 100644 --- a/websocket-sharp/Server/IWebSocketSession.cs +++ b/websocket-sharp/Server/IWebSocketSession.cs @@ -69,7 +69,7 @@ public interface IWebSocketSession string ID { get; } /// - /// Gets the name of the WebSocket subprotocol used in the session. + /// Gets the name of the WebSocket subprotocol for the session. /// /// /// A that represents the name of the subprotocol From 344a31bd2f4f114415398e427cc2ae09a66c77c5 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 28 Jun 2018 20:15:04 +0900 Subject: [PATCH 2028/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 2d191cb2f..0fc045497 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -295,11 +295,11 @@ public Func OriginValidator { } /// - /// Gets or sets the name of subprotocol used in the WebSocket service. + /// Gets or sets the name of the WebSocket subprotocol for the service. /// /// /// - /// A that represents the name of subprotocol. + /// A that represents the name of the subprotocol. /// /// /// The value specified for a set must be a token defined in From f0eea1c5b35abb43f779449db473d9e32dce7808 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 29 Jun 2018 19:26:52 +0900 Subject: [PATCH 2029/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 0fc045497..bc15093e4 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -91,7 +91,7 @@ protected Logger Log { } /// - /// Gets the management function for the sessions in the WebSocket service. + /// Gets the management function for the sessions in the service. /// /// /// From e70586e285c57d02b1429855158cdd272153bbb3 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 29 Jun 2018 19:33:49 +0900 Subject: [PATCH 2030/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index bc15093e4..fe4b486df 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -136,7 +136,7 @@ public WebSocketState ConnectionState { } /// - /// Gets the information in a handshake request to the WebSocket service. + /// Gets the information in a WebSocket handshake request to the service. /// /// /// From 19b0fdc9310dc560644bb650a2b59ccd58fef54d Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 30 Jun 2018 21:04:26 +0900 Subject: [PATCH 2031/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index fe4b486df..57368af7e 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -155,7 +155,7 @@ public WebSocketContext Context { /// /// Gets or sets the delegate used to validate the HTTP cookies included in - /// a handshake request to the WebSocket service. + /// a WebSocket handshake request to the service. /// /// /// From 98861dcb4d293b70b99d346a6881c9e9febe254c Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 1 Jul 2018 21:10:58 +0900 Subject: [PATCH 2032/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 57368af7e..635c8ddcc 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -237,13 +237,14 @@ public string ID { } /// - /// Gets or sets a value indicating whether the WebSocket service ignores - /// the Sec-WebSocket-Extensions header included in a handshake request. + /// Gets or sets a value indicating whether the service ignores + /// the Sec-WebSocket-Extensions header included in a WebSocket + /// handshake request. /// /// /// - /// true if the service ignores the extensions requested from - /// a client; otherwise, false. + /// true if the service ignores the extensions requested + /// from a client; otherwise, false. /// /// /// The default value is false. From 12632e4c13ecb17ea4fd9b2eeb20bbdb59a007d5 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 2 Jul 2018 19:54:03 +0900 Subject: [PATCH 2033/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 635c8ddcc..7b9ac3955 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -261,8 +261,8 @@ public bool IgnoreExtensions { } /// - /// Gets or sets the delegate used to validate the Origin header included - /// in a handshake request to the WebSocket service. + /// Gets or sets the delegate used to validate the Origin header included in + /// a WebSocket handshake request to the service. /// /// /// From d1c5f0b334dafcb5dfb8ea6650fb3d25427f2ae0 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 3 Jul 2018 19:46:11 +0900 Subject: [PATCH 2034/6294] [Modify] 2018 --- websocket-sharp/Server/IWebSocketSession.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/IWebSocketSession.cs b/websocket-sharp/Server/IWebSocketSession.cs index 4d43652ea..296b5bf5a 100644 --- a/websocket-sharp/Server/IWebSocketSession.cs +++ b/websocket-sharp/Server/IWebSocketSession.cs @@ -4,7 +4,7 @@ * * The MIT License * - * Copyright (c) 2013-2014 sta.blockhead + * Copyright (c) 2013-2018 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From eedd814429e6e7d7cf5922c92ea2a511ca989162 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 4 Jul 2018 20:11:47 +0900 Subject: [PATCH 2035/6294] [Modify] Put it back --- websocket-sharp/Server/WebSocketBehavior.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 7b9ac3955..b6c42c164 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -319,7 +319,9 @@ public Func OriginValidator { /// public string Protocol { get { - return _protocol ?? String.Empty; + return _websocket != null + ? _websocket.Protocol + : (_protocol ?? String.Empty); } set { From 9351245a3235303a10560c018be84ffa6906fb60 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 5 Jul 2018 20:38:26 +0900 Subject: [PATCH 2036/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketBehavior.cs | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index b6c42c164..23f5cf262 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -366,12 +366,19 @@ public DateTime StartTime { private string checkHandshakeRequest (WebSocketContext context) { - return _originValidator != null && !_originValidator (context.Origin) - ? "Includes no Origin header, or it has an invalid value." - : _cookiesValidator != null - && !_cookiesValidator (context.CookieCollection, context.WebSocket.CookieCollection) - ? "Includes no cookie, or an invalid cookie exists." - : null; + if (_originValidator != null) { + if (!_originValidator (context.Origin)) + return "It includes no Origin header or an invalid one."; + } + + if (_cookiesValidator != null) { + var req = context.CookieCollection; + var res = context.WebSocket.CookieCollection; + if (!_cookiesValidator (req, res)) + return "It includes no cookie or an invalid one."; + } + + return null; } private void onClose (object sender, CloseEventArgs e) From 7ae8de1c67ac00f67eed076b4935ff2cf0c97e6c Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 6 Jul 2018 19:58:33 +0900 Subject: [PATCH 2037/6294] [Modify] Add it --- websocket-sharp/Server/WebSocketBehavior.cs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 23f5cf262..625c58d79 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -450,6 +450,26 @@ internal void Start (WebSocketContext context, WebSocketSessionManager sessions) #region Protected Methods + /// + /// Closes the WebSocket connection for a session. + /// + /// + /// This method does nothing if the current state of the connection is + /// Closing or Closed. + /// + /// + /// The session has not started yet. + /// + protected void Close () + { + if (_websocket == null) { + var msg = "The session has not started yet."; + throw new InvalidOperationException (msg); + } + + _websocket.Close (); + } + /// /// Calls the method with the specified message. /// From 8d197479f5e2c586b64bd7e5aa892c835a07fbf0 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 7 Jul 2018 21:03:51 +0900 Subject: [PATCH 2038/6294] [Modify] Add it --- websocket-sharp/Server/WebSocketBehavior.cs | 69 +++++++++++++++++++++ 1 file changed, 69 insertions(+) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 625c58d79..1bb7f5199 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -470,6 +470,75 @@ protected void Close () _websocket.Close (); } + /// + /// Closes the WebSocket connection for a session with the specified + /// code and reason. + /// + /// + /// This method does nothing if the current state of the connection is + /// Closing or Closed. + /// + /// + /// + /// A that represents the status code indicating + /// the reason for the close. + /// + /// + /// The status codes are defined in + /// + /// Section 7.4 of RFC 6455. + /// + /// + /// + /// + /// A that represents the reason for the close. + /// + /// + /// The size must be 123 bytes or less in UTF-8. + /// + /// + /// + /// The session has not started yet. + /// + /// + /// + /// is less than 1000 or greater than 4999. + /// + /// + /// -or- + /// + /// + /// The size of is greater than 123 bytes. + /// + /// + /// + /// + /// is 1010 (mandatory extension). + /// + /// + /// -or- + /// + /// + /// is 1005 (no status) and there is + /// . + /// + /// + /// -or- + /// + /// + /// could not be UTF-8-encoded. + /// + /// + protected void Close (ushort code, string reason) + { + if (_websocket == null) { + var msg = "The session has not started yet."; + throw new InvalidOperationException (msg); + } + + _websocket.Close (code, reason); + } + /// /// Calls the method with the specified message. /// From a8fe9496d9d98a56010154b2452dea5adb7da4db Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 8 Jul 2018 21:37:27 +0900 Subject: [PATCH 2039/6294] [Modify] Add it --- websocket-sharp/Server/WebSocketBehavior.cs | 60 +++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 1bb7f5199..9dac4fade 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -539,6 +539,66 @@ protected void Close (ushort code, string reason) _websocket.Close (code, reason); } + /// + /// Closes the WebSocket connection for a session with the specified + /// code and reason. + /// + /// + /// This method does nothing if the current state of the connection is + /// Closing or Closed. + /// + /// + /// + /// One of the enum values. + /// + /// + /// It represents the status code indicating the reason for the close. + /// + /// + /// + /// + /// A that represents the reason for the close. + /// + /// + /// The size must be 123 bytes or less in UTF-8. + /// + /// + /// + /// The session has not started yet. + /// + /// + /// The size of is greater than 123 bytes. + /// + /// + /// + /// is + /// . + /// + /// + /// -or- + /// + /// + /// is + /// and there is + /// . + /// + /// + /// -or- + /// + /// + /// could not be UTF-8-encoded. + /// + /// + protected void Close (CloseStatusCode code, string reason) + { + if (_websocket == null) { + var msg = "The session has not started yet."; + throw new InvalidOperationException (msg); + } + + _websocket.Close (code, reason); + } + /// /// Calls the method with the specified message. /// From d338ccd5d6ce5c4b1bdcc0615a4905973d42e8b0 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 9 Jul 2018 20:21:10 +0900 Subject: [PATCH 2040/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 10c3d795b..708ca6ccc 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2671,8 +2671,7 @@ public void Close (CloseStatusCode code) } /// - /// Closes the connection with the specified and - /// . + /// Closes the connection with the specified code and reason. /// /// /// This method does nothing if the current state of the connection is @@ -2680,8 +2679,8 @@ public void Close (CloseStatusCode code) /// /// /// - /// A that represents the status code - /// indicating the reason for the close. + /// A that represents the status code indicating + /// the reason for the close. /// /// /// The status codes are defined in @@ -2724,8 +2723,7 @@ public void Close (CloseStatusCode code) /// -or- /// /// - /// is 1005 (no status) and - /// there is . + /// is 1005 (no status) and there is reason. /// /// /// -or- From e437c487af77032ff83f4cacbbecb1858437f57b Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 10 Jul 2018 20:35:53 +0900 Subject: [PATCH 2041/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 708ca6ccc..f72b0904b 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2774,8 +2774,7 @@ public void Close (ushort code, string reason) } /// - /// Closes the connection with the specified and - /// . + /// Closes the connection with the specified code and reason. /// /// /// This method does nothing if the current state of the connection is @@ -2816,8 +2815,7 @@ public void Close (ushort code, string reason) /// /// /// is - /// and - /// there is . + /// and there is reason. /// /// /// -or- From a744511aa10d15e05ca8de5af6c0d4cd39fafe75 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 11 Jul 2018 19:50:07 +0900 Subject: [PATCH 2042/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index f72b0904b..6652a5e24 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2572,7 +2572,7 @@ public void Close () } /// - /// Closes the connection with the specified . + /// Closes the connection with the specified code. /// /// /// This method does nothing if the current state of the connection is @@ -2580,8 +2580,8 @@ public void Close () /// /// /// - /// A that represents the status code - /// indicating the reason for the close. + /// A that represents the status code indicating + /// the reason for the close. /// /// /// The status codes are defined in From 60c3a5137e5f4fb4fa6a7ab6fc59b9682a77bc6a Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 12 Jul 2018 20:22:29 +0900 Subject: [PATCH 2043/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 6652a5e24..fe2edad90 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2626,7 +2626,7 @@ public void Close (ushort code) } /// - /// Closes the connection with the specified . + /// Closes the connection with the specified code. /// /// /// This method does nothing if the current state of the connection is From b76a156bc1ea2022016a596e0e265ae0fb63b2cd Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 12 Jul 2018 20:27:17 +0900 Subject: [PATCH 2044/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 9dac4fade..b3653aa3d 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -519,8 +519,7 @@ protected void Close () /// -or- /// /// - /// is 1005 (no status) and there is - /// . + /// is 1005 (no status) and there is reason. /// /// /// -or- From eb21c505ca91c33758cb4337ba8325fdad6e8aa4 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 13 Jul 2018 19:44:15 +0900 Subject: [PATCH 2045/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index b3653aa3d..2c0104aa3 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -578,8 +578,7 @@ protected void Close (ushort code, string reason) /// /// /// is - /// and there is - /// . + /// and there is reason. /// /// /// -or- From b06f3a71c0fb5bd01261195fadd52868c2d2cff3 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 14 Jul 2018 21:00:37 +0900 Subject: [PATCH 2046/6294] [Modify] Add it --- websocket-sharp/Server/WebSocketBehavior.cs | 25 +++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 2c0104aa3..99a0b18cc 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -597,6 +597,31 @@ protected void Close (CloseStatusCode code, string reason) _websocket.Close (code, reason); } + /// + /// Closes the WebSocket connection for a session asynchronously. + /// + /// + /// + /// This method does not wait for the close to be complete. + /// + /// + /// This method does nothing if the current state of the connection is + /// Closing or Closed. + /// + /// + /// + /// The session has not started yet. + /// + protected void CloseAsync () + { + if (_websocket == null) { + var msg = "The session has not started yet."; + throw new InvalidOperationException (msg); + } + + _websocket.CloseAsync (); + } + /// /// Calls the method with the specified message. /// From af335569fef6dac353c475377bb3e3b9b8050cf4 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 15 Jul 2018 21:04:13 +0900 Subject: [PATCH 2047/6294] [Modify] Add it --- websocket-sharp/Server/WebSocketBehavior.cs | 73 +++++++++++++++++++++ 1 file changed, 73 insertions(+) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 99a0b18cc..2f7b9b073 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -622,6 +622,79 @@ protected void CloseAsync () _websocket.CloseAsync (); } + /// + /// Closes the WebSocket connection for a session asynchronously with + /// the specified code and reason. + /// + /// + /// + /// This method does not wait for the close to be complete. + /// + /// + /// This method does nothing if the current state of the connection is + /// Closing or Closed. + /// + /// + /// + /// + /// A that represents the status code indicating + /// the reason for the close. + /// + /// + /// The status codes are defined in + /// + /// Section 7.4 of RFC 6455. + /// + /// + /// + /// + /// A that represents the reason for the close. + /// + /// + /// The size must be 123 bytes or less in UTF-8. + /// + /// + /// + /// The session has not started yet. + /// + /// + /// + /// is less than 1000 or greater than 4999. + /// + /// + /// -or- + /// + /// + /// The size of is greater than 123 bytes. + /// + /// + /// + /// + /// is 1010 (mandatory extension). + /// + /// + /// -or- + /// + /// + /// is 1005 (no status) and there is reason. + /// + /// + /// -or- + /// + /// + /// could not be UTF-8-encoded. + /// + /// + protected void CloseAsync (ushort code, string reason) + { + if (_websocket == null) { + var msg = "The session has not started yet."; + throw new InvalidOperationException (msg); + } + + _websocket.CloseAsync (code, reason); + } + /// /// Calls the method with the specified message. /// From ae3e92744e16d41f0bb27291ce17f143f2001ee1 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 16 Jul 2018 20:12:10 +0900 Subject: [PATCH 2048/6294] [Modify] Add it --- websocket-sharp/Server/WebSocketBehavior.cs | 64 +++++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 2f7b9b073..a4664573d 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -695,6 +695,70 @@ protected void CloseAsync (ushort code, string reason) _websocket.CloseAsync (code, reason); } + /// + /// Closes the WebSocket connection for a session asynchronously with + /// the specified code and reason. + /// + /// + /// + /// This method does not wait for the close to be complete. + /// + /// + /// This method does nothing if the current state of the connection is + /// Closing or Closed. + /// + /// + /// + /// + /// One of the enum values. + /// + /// + /// It represents the status code indicating the reason for the close. + /// + /// + /// + /// + /// A that represents the reason for the close. + /// + /// + /// The size must be 123 bytes or less in UTF-8. + /// + /// + /// + /// The session has not started yet. + /// + /// + /// + /// is + /// . + /// + /// + /// -or- + /// + /// + /// is + /// and there is reason. + /// + /// + /// -or- + /// + /// + /// could not be UTF-8-encoded. + /// + /// + /// + /// The size of is greater than 123 bytes. + /// + protected void CloseAsync (CloseStatusCode code, string reason) + { + if (_websocket == null) { + var msg = "The session has not started yet."; + throw new InvalidOperationException (msg); + } + + _websocket.CloseAsync (code, reason); + } + /// /// Calls the method with the specified message. /// From b63708559a62b0d6c7b4838fb5fe31feb78fad46 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 17 Jul 2018 20:01:55 +0900 Subject: [PATCH 2049/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index fe2edad90..c83c2b476 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2871,8 +2871,8 @@ public void Close (CloseStatusCode code, string reason) /// This method does not wait for the close to be complete. /// /// - /// And this method does nothing if the current state of - /// the connection is Closing or Closed. + /// This method does nothing if the current state of the connection is + /// Closing or Closed. /// /// public void CloseAsync () From 4a63fa5035f28ad489904f926f787106723cf5dc Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 18 Jul 2018 20:33:51 +0900 Subject: [PATCH 2050/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index c83c2b476..74a1558dd 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2881,22 +2881,21 @@ public void CloseAsync () } /// - /// Closes the connection asynchronously with the specified - /// . + /// Closes the connection asynchronously with the specified code. /// /// /// /// This method does not wait for the close to be complete. /// /// - /// And this method does nothing if the current state of - /// the connection is Closing or Closed. + /// This method does nothing if the current state of the connection is + /// Closing or Closed. /// /// /// /// - /// A that represents the status code - /// indicating the reason for the close. + /// A that represents the status code indicating + /// the reason for the close. /// /// /// The status codes are defined in From 8f8c123567a6e241188f4490cb5f4aaf20b438b6 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 19 Jul 2018 19:51:00 +0900 Subject: [PATCH 2051/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 74a1558dd..89f6184c9 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2940,16 +2940,15 @@ public void CloseAsync (ushort code) } /// - /// Closes the connection asynchronously with the specified - /// . + /// Closes the connection asynchronously with the specified code. /// /// /// /// This method does not wait for the close to be complete. /// /// - /// And this method does nothing if the current state of - /// the connection is Closing or Closed. + /// This method does nothing if the current state of the connection is + /// Closing or Closed. /// /// /// From dac30f3edaf4653c2db0aa9a0f62aec7516cf55c Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 20 Jul 2018 20:07:02 +0900 Subject: [PATCH 2052/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 89f6184c9..e1315c29a 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2990,22 +2990,21 @@ public void CloseAsync (CloseStatusCode code) } /// - /// Closes the connection asynchronously with the specified - /// and . + /// Closes the connection asynchronously with the specified code and reason. /// /// /// /// This method does not wait for the close to be complete. /// /// - /// And this method does nothing if the current state of - /// the connection is Closing or Closed. + /// This method does nothing if the current state of the connection is + /// Closing or Closed. /// /// /// /// - /// A that represents the status code - /// indicating the reason for the close. + /// A that represents the status code indicating + /// the reason for the close. /// /// /// The status codes are defined in @@ -3048,8 +3047,7 @@ public void CloseAsync (CloseStatusCode code) /// -or- /// /// - /// is 1005 (no status) and - /// there is . + /// is 1005 (no status) and there is reason. /// /// /// -or- From 934d14392245d72a9c7af5192a0d3c3bdcd4aca1 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 21 Jul 2018 22:20:02 +0900 Subject: [PATCH 2053/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index e1315c29a..93ed5bf4e 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3098,16 +3098,15 @@ public void CloseAsync (ushort code, string reason) } /// - /// Closes the connection asynchronously with the specified - /// and . + /// Closes the connection asynchronously with the specified code and reason. /// /// /// /// This method does not wait for the close to be complete. /// /// - /// And this method does nothing if the current state of - /// the connection is Closing or Closed. + /// This method does nothing if the current state of the connection is + /// Closing or Closed. /// /// /// @@ -3145,8 +3144,7 @@ public void CloseAsync (ushort code, string reason) /// /// /// is - /// and - /// there is . + /// and there is reason. /// /// /// -or- From 051062b7fdd33af50427fb5cfe0878255939fd59 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 22 Jul 2018 22:23:26 +0900 Subject: [PATCH 2054/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index ce89d7391..dda2b9295 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -1348,18 +1348,17 @@ public void Stop () } /// - /// Stops receiving incoming handshake requests and closes each - /// connection with the specified and - /// . + /// Stops receiving incoming handshake requests and closes each connection + /// with the specified code and reason. /// /// - /// This method does nothing if the server is not started, - /// it is shutting down, or it has already stopped. + /// This method does nothing if the server is not started, it is shutting + /// down, or it has already stopped. /// /// /// - /// A that represents the status code - /// indicating the reason for the close. + /// A that represents the status code indicating + /// the reason for the close. /// /// /// The status codes are defined in @@ -1394,8 +1393,7 @@ public void Stop () /// -or- /// /// - /// is 1005 (no status) and - /// there is . + /// is 1005 (no status) and there is reason. /// /// /// -or- From 560c23109f62bfbb9d2b8693a26d6fd71b337909 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 23 Jul 2018 19:58:00 +0900 Subject: [PATCH 2055/6294] [Modify] It will be removed --- websocket-sharp/Server/WebSocketServer.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index dda2b9295..3eccd5271 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -1405,6 +1405,7 @@ public void Stop () /// /// The underlying has failed to stop. /// + [Obsolete ("This method will be removed.")] public void Stop (ushort code, string reason) { if (!code.IsCloseStatusCode ()) { From f7794398986b21c2e890f714c1aa507f9b71bb04 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 24 Jul 2018 21:11:24 +0900 Subject: [PATCH 2056/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 3eccd5271..d11f1a4e3 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -1440,13 +1440,12 @@ public void Stop (ushort code, string reason) } /// - /// Stops receiving incoming handshake requests and closes each - /// connection with the specified and - /// . + /// Stops receiving incoming handshake requests and closes each connection + /// with the specified code and reason. /// /// - /// This method does nothing if the server is not started, - /// it is shutting down, or it has already stopped. + /// This method does nothing if the server is not started, it is shutting + /// down, or it has already stopped. /// /// /// @@ -1474,8 +1473,7 @@ public void Stop (ushort code, string reason) /// /// /// is - /// and - /// there is . + /// and there is reason. /// /// /// -or- From 7b16c2b777bd7a77f4f14ea126e44b69c4a0a961 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 25 Jul 2018 21:03:31 +0900 Subject: [PATCH 2057/6294] [Modify] It will be removed --- websocket-sharp/Server/WebSocketServer.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index d11f1a4e3..3620c37c6 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -1488,6 +1488,7 @@ public void Stop (ushort code, string reason) /// /// The underlying has failed to stop. /// + [Obsolete ("This method will be removed.")] public void Stop (CloseStatusCode code, string reason) { if (code == CloseStatusCode.MandatoryExtension) { From 55abed17ef9f3c8438dff45eaee4234c32b6ff4e Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 26 Jul 2018 21:31:52 +0900 Subject: [PATCH 2058/6294] [Modify] Use 1001 (going away) --- websocket-sharp/Server/WebSocketServer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 3620c37c6..2f0d6236b 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -1344,7 +1344,7 @@ public void Start () /// public void Stop () { - stop (1005, String.Empty); + stop (1001, String.Empty); } /// From 082720fe45930e11ee466b846b5705f5c303176f Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 27 Jul 2018 20:51:57 +0900 Subject: [PATCH 2059/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 2f0d6236b..6607e7d5d 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -1332,13 +1332,8 @@ public void Start () } /// - /// Stops receiving incoming handshake requests and closes - /// each connection. + /// Stops receiving incoming handshake requests. /// - /// - /// This method does nothing if the server is not started, - /// it is shutting down, or it has already stopped. - /// /// /// The underlying has failed to stop. /// From f0f708b22ca94fedfb10e69ad483376401050753 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 28 Jul 2018 21:39:19 +0900 Subject: [PATCH 2060/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 6607e7d5d..ea7416a51 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -1307,7 +1307,7 @@ public bool RemoveWebSocketService (string path) /// /// /// - /// There is no server certificate for secure connections. + /// There is no server certificate for secure connection. /// /// /// -or- From 405e1f2ecd7e645cbf0d41c9c0588f25df9f4204 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 29 Jul 2018 21:50:16 +0900 Subject: [PATCH 2061/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index ea7416a51..ea5992909 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -1346,10 +1346,6 @@ public void Stop () /// Stops receiving incoming handshake requests and closes each connection /// with the specified code and reason. /// - /// - /// This method does nothing if the server is not started, it is shutting - /// down, or it has already stopped. - /// /// /// /// A that represents the status code indicating From be36b0a4a8b3bbcdd4efb97ab9c538ee5a75304c Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 29 Jul 2018 21:53:25 +0900 Subject: [PATCH 2062/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index ea5992909..25ed9e00b 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -1434,10 +1434,6 @@ public void Stop (ushort code, string reason) /// Stops receiving incoming handshake requests and closes each connection /// with the specified code and reason. /// - /// - /// This method does nothing if the server is not started, it is shutting - /// down, or it has already stopped. - /// /// /// /// One of the enum values. From 7af5bf71c62a4786995a00a46eefdbf822e02ab0 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 30 Jul 2018 21:05:16 +0900 Subject: [PATCH 2063/6294] [Modify] It will be removed --- websocket-sharp/Server/HttpServer.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 83de8555c..84860a146 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -1547,6 +1547,7 @@ public void Stop () /// could not be UTF-8-encoded. /// /// + [Obsolete ("This method will be removed.")] public void Stop (ushort code, string reason) { if (!code.IsCloseStatusCode ()) { From f41df03eb63847b4810751669ac0364af169a639 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 31 Jul 2018 19:52:34 +0900 Subject: [PATCH 2064/6294] [Modify] Edit it --- websocket-sharp/Server/HttpServer.cs | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 84860a146..fbfc69541 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -1494,14 +1494,10 @@ public void Stop () /// /// Stops receiving incoming requests and closes each connection. /// - /// - /// This method does nothing if the server is not started, - /// it is shutting down, or it has already stopped. - /// /// /// - /// A that represents the status code - /// indicating the reason for the WebSocket connection close. + /// A that represents the status code indicating + /// the reason for the WebSocket connection close. /// /// /// The status codes are defined in @@ -1511,8 +1507,8 @@ public void Stop () /// /// /// - /// A that represents the reason for - /// the WebSocket connection close. + /// A that represents the reason for the WebSocket + /// connection close. /// /// /// The size must be 123 bytes or less in UTF-8. @@ -1537,8 +1533,7 @@ public void Stop () /// -or- /// /// - /// is 1005 (no status) and - /// there is . + /// is 1005 (no status) and there is reason. /// /// /// -or- From a875f7a88367d690f7b63681b0a13fef1551b331 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 1 Aug 2018 21:13:57 +0900 Subject: [PATCH 2065/6294] [Modify] It will be removed --- websocket-sharp/Server/HttpServer.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index fbfc69541..7db2f6afc 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -1624,6 +1624,7 @@ public void Stop (ushort code, string reason) /// could not be UTF-8-encoded. /// /// + [Obsolete ("This method will be removed.")] public void Stop (CloseStatusCode code, string reason) { if (code == CloseStatusCode.MandatoryExtension) { From 2c72cc5658a0b703e0013009f9ecfda4ff88f9ae Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 2 Aug 2018 22:00:40 +0900 Subject: [PATCH 2066/6294] [Modify] Edit it --- websocket-sharp/Server/HttpServer.cs | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 7db2f6afc..81dc98497 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -1579,23 +1579,19 @@ public void Stop (ushort code, string reason) /// /// Stops receiving incoming requests and closes each connection. /// - /// - /// This method does nothing if the server is not started, - /// it is shutting down, or it has already stopped. - /// /// /// /// One of the enum values. /// /// - /// It represents the status code indicating the reason for - /// the WebSocket connection close. + /// It represents the status code indicating the reason for the WebSocket + /// connection close. /// /// /// /// - /// A that represents the reason for - /// the WebSocket connection close. + /// A that represents the reason for the WebSocket + /// connection close. /// /// /// The size must be 123 bytes or less in UTF-8. @@ -1614,8 +1610,7 @@ public void Stop (ushort code, string reason) /// /// /// is - /// and - /// there is . + /// and there is reason. /// /// /// -or- From 29d962023394aa3ee7bb22b24c1ad1578ac8d1e9 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 3 Aug 2018 21:06:03 +0900 Subject: [PATCH 2067/6294] [Modify] Use 1001 (going away) --- websocket-sharp/Server/HttpServer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 81dc98497..198c6355d 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -1488,7 +1488,7 @@ public void Start () /// public void Stop () { - stop (1005, String.Empty); + stop (1001, String.Empty); } /// From 9b725463cfd93d7bc0f0e77807cd12e4026d92ee Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 4 Aug 2018 20:52:23 +0900 Subject: [PATCH 2068/6294] [Modify] Edit it --- websocket-sharp/Server/HttpServer.cs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 198c6355d..48e5ecd05 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -1480,12 +1480,8 @@ public void Start () } /// - /// Stops receiving incoming requests and closes each connection. + /// Stops receiving incoming requests. /// - /// - /// This method does nothing if the server is not started, - /// it is shutting down, or it has already stopped. - /// public void Stop () { stop (1001, String.Empty); From e200bc744107391ff4bb01c6a98991f6b03c6a62 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 5 Aug 2018 21:15:18 +0900 Subject: [PATCH 2069/6294] [Modify] Edit it --- websocket-sharp/Server/HttpServer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 48e5ecd05..8cf9985c3 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -1459,7 +1459,7 @@ public bool RemoveWebSocketService (string path) /// /// /// - /// There is no server certificate for secure connections. + /// There is no server certificate for secure connection. /// /// /// -or- From 2486492ae70330624e2aa53e8601a0b119c43b27 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 6 Aug 2018 20:54:36 +0900 Subject: [PATCH 2070/6294] [Modify] Polish it --- websocket-sharp/Server/HttpServer.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 8cf9985c3..01d6a1f1f 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -835,13 +835,13 @@ private bool checkCertificate (out string message) var both = byUser && withPort; if (both) { - _log.Warn ("A server certificate associated with the port is used."); + _log.Warn ("The server certificate associated with the port is used."); return true; } var either = byUser || withPort; if (!either) { - message = "There is no server certificate for secure connections."; + message = "There is no server certificate for secure connection."; return false; } From 104d59cb93fd10f82ca1099fa7bdacc74008b19b Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 7 Aug 2018 19:52:35 +0900 Subject: [PATCH 2071/6294] [Modify] Polish it --- websocket-sharp/Server/HttpServer.cs | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 01d6a1f1f..3bdb5ba3f 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -833,18 +833,14 @@ private bool checkCertificate (out string message) var path = _listener.CertificateFolderPath; var withPort = EndPointListener.CertificateExists (_port, path); - var both = byUser && withPort; - if (both) { - _log.Warn ("The server certificate associated with the port is used."); - return true; - } - - var either = byUser || withPort; - if (!either) { + if (!(byUser || withPort)) { message = "There is no server certificate for secure connection."; return false; } + if (byUser && withPort) + _log.Warn ("The server certificate associated with the port is used."); + return true; } From 895daf32bca7c210e9135105dab342fbc57e07b2 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 8 Aug 2018 20:50:59 +0900 Subject: [PATCH 2072/6294] [Modify] Edit it --- websocket-sharp/Server/HttpServer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 3bdb5ba3f..7c6bdf2b6 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -617,7 +617,7 @@ public bool ReuseAddress { } /// - /// Gets the configuration for secure connections. + /// Gets the configuration for secure connection. /// /// /// This configuration will be referenced when attempts to start, From 64f99d1842a77b6ccf998b6220b0b7c59ebdd10f Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 9 Aug 2018 20:38:04 +0900 Subject: [PATCH 2073/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 25ed9e00b..c0a0e2e23 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -578,7 +578,7 @@ public bool ReuseAddress { } /// - /// Gets the configuration for secure connections. + /// Gets the configuration for secure connection. /// /// /// This configuration will be referenced when attempts to start, From fffc3277a2f2b532e34fdac2d7f9b515bdab1d65 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 10 Aug 2018 21:25:37 +0900 Subject: [PATCH 2074/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketServer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index c0a0e2e23..b1b7bf027 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -766,7 +766,7 @@ private static bool checkSslConfiguration ( message = null; if (configuration.ServerCertificate == null) { - message = "There is no server certificate for secure connections."; + message = "There is no server certificate for secure connection."; return false; } From 9fb42cf86fab281beee8a80c946c10ad350a82f7 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 11 Aug 2018 22:23:56 +0900 Subject: [PATCH 2075/6294] [Modify] Add it --- websocket-sharp/Server/WebSocketBehavior.cs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index a4664573d..ca94017f2 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -27,6 +27,7 @@ #endregion using System; +using System.Collections.Specialized; using System.IO; using WebSocketSharp.Net; using WebSocketSharp.Net.WebSockets; @@ -72,6 +73,23 @@ protected WebSocketBehavior () #region Protected Properties + /// + /// Gets the HTTP headers included in a WebSocket handshake request. + /// + /// + /// + /// A that contains the headers. + /// + /// + /// if the session has not started yet. + /// + /// + protected NameValueCollection Headers { + get { + return _context != null ? _context.Headers : null; + } + } + /// /// Gets the logging function. /// From bae1b87fafcb9ed1d3ee5b358d51e770e9a24f2e Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 12 Aug 2018 21:10:56 +0900 Subject: [PATCH 2076/6294] [Modify] Add it --- websocket-sharp/Server/WebSocketBehavior.cs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index ca94017f2..b5e8ffeb7 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -108,6 +108,27 @@ protected Logger Log { } } + /// + /// Gets the query string included in a WebSocket handshake request. + /// + /// + /// + /// A that contains the query + /// parameters. + /// + /// + /// An empty collection if not included. + /// + /// + /// if the session has not started yet. + /// + /// + protected NameValueCollection QueryString { + get { + return _context != null ? _context.QueryString : null; + } + } + /// /// Gets the management function for the sessions in the service. /// From 7cb80a676d919d142e4e1dd16c74d66ffea6b6cc Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 13 Aug 2018 21:34:33 +0900 Subject: [PATCH 2077/6294] [Modify] Polish it --- websocket-sharp/Net/QueryStringCollection.cs | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/websocket-sharp/Net/QueryStringCollection.cs b/websocket-sharp/Net/QueryStringCollection.cs index 6a2285fb6..c04f059f1 100644 --- a/websocket-sharp/Net/QueryStringCollection.cs +++ b/websocket-sharp/Net/QueryStringCollection.cs @@ -50,19 +50,18 @@ internal sealed class QueryStringCollection : NameValueCollection { public override string ToString () { - var cnt = Count; - if (cnt == 0) + if (Count == 0) return String.Empty; - var output = new StringBuilder (); - var keys = AllKeys; - foreach (var key in keys) - output.AppendFormat ("{0}={1}&", key, this [key]); + var buff = new StringBuilder (); - if (output.Length > 0) - output.Length--; + foreach (var key in AllKeys) + buff.AppendFormat ("{0}={1}&", key, this[key]); - return output.ToString (); + if (buff.Length > 0) + buff.Length--; + + return buff.ToString (); } } } From 54440d1211cd96d7a0176e5965a08a3cc3cc7756 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 14 Aug 2018 21:57:19 +0900 Subject: [PATCH 2078/6294] [Modify] Add it --- websocket-sharp/Net/QueryStringCollection.cs | 39 ++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/websocket-sharp/Net/QueryStringCollection.cs b/websocket-sharp/Net/QueryStringCollection.cs index c04f059f1..ab491ba11 100644 --- a/websocket-sharp/Net/QueryStringCollection.cs +++ b/websocket-sharp/Net/QueryStringCollection.cs @@ -48,6 +48,45 @@ namespace WebSocketSharp.Net { internal sealed class QueryStringCollection : NameValueCollection { + public static QueryStringCollection Parse (string query, Encoding encoding) + { + var ret = new QueryStringCollection (); + + if (query == null) + return ret; + + var len = query.Length; + if (len == 0) + return ret; + + if (len == 1 && query[0] == '?') + return ret; + + if (query[0] == '?') + query = query.Substring (1); + + if (encoding == null) + encoding = Encoding.UTF8; + + var components = query.Split ('&'); + foreach (var component in components) { + var i = component.IndexOf ('='); + if (i < 0) { + ret.Add (null, HttpUtility.UrlDecode (component, encoding)); + continue; + } + + var name = HttpUtility.UrlDecode (component.Substring (0, i), encoding); + var val = component.Length > i + 1 + ? HttpUtility.UrlDecode (component.Substring (i + 1), encoding) + : String.Empty; + + ret.Add (name, val); + } + + return ret; + } + public override string ToString () { if (Count == 0) From 52f1f5c6b637be856c72ce254fee4f2fcf675c65 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 15 Aug 2018 20:57:48 +0900 Subject: [PATCH 2079/6294] [Modify] Add it --- websocket-sharp/Net/QueryStringCollection.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/websocket-sharp/Net/QueryStringCollection.cs b/websocket-sharp/Net/QueryStringCollection.cs index ab491ba11..550502f01 100644 --- a/websocket-sharp/Net/QueryStringCollection.cs +++ b/websocket-sharp/Net/QueryStringCollection.cs @@ -48,6 +48,11 @@ namespace WebSocketSharp.Net { internal sealed class QueryStringCollection : NameValueCollection { + public static QueryStringCollection Parse (string query) + { + return Parse (query, Encoding.UTF8); + } + public static QueryStringCollection Parse (string query, Encoding encoding) { var ret = new QueryStringCollection (); From 959baf9ff2d62755e02bce75e5b4ff7f7898e10b Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 16 Aug 2018 21:20:36 +0900 Subject: [PATCH 2080/6294] [Modify] Polish it --- websocket-sharp/Net/QueryStringCollection.cs | 25 +++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/QueryStringCollection.cs b/websocket-sharp/Net/QueryStringCollection.cs index 550502f01..12ecbd343 100644 --- a/websocket-sharp/Net/QueryStringCollection.cs +++ b/websocket-sharp/Net/QueryStringCollection.cs @@ -64,7 +64,7 @@ public static QueryStringCollection Parse (string query, Encoding encoding) if (len == 0) return ret; - if (len == 1 && query[0] == '?') + if (query == "?") return ret; if (query[0] == '?') @@ -75,15 +75,34 @@ public static QueryStringCollection Parse (string query, Encoding encoding) var components = query.Split ('&'); foreach (var component in components) { + len = component.Length; + if (len == 0) + continue; + + if (component == "=") + continue; + var i = component.IndexOf ('='); if (i < 0) { ret.Add (null, HttpUtility.UrlDecode (component, encoding)); continue; } + if (i == 0) { + ret.Add ( + null, HttpUtility.UrlDecode (component.Substring (1), encoding) + ); + + continue; + } + var name = HttpUtility.UrlDecode (component.Substring (0, i), encoding); - var val = component.Length > i + 1 - ? HttpUtility.UrlDecode (component.Substring (i + 1), encoding) + + var start = i + 1; + var val = start < len + ? HttpUtility.UrlDecode ( + component.Substring (start), encoding + ) : String.Empty; ret.Add (name, val); From d04cd7a6c4e7c9da6cc5e2ff0ff2e6be01f8b844 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 17 Aug 2018 19:49:29 +0900 Subject: [PATCH 2081/6294] [Modify] Edit it --- websocket-sharp/Net/QueryStringCollection.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/websocket-sharp/Net/QueryStringCollection.cs b/websocket-sharp/Net/QueryStringCollection.cs index 12ecbd343..9d47e08de 100644 --- a/websocket-sharp/Net/QueryStringCollection.cs +++ b/websocket-sharp/Net/QueryStringCollection.cs @@ -48,6 +48,8 @@ namespace WebSocketSharp.Net { internal sealed class QueryStringCollection : NameValueCollection { + #region Public Methods + public static QueryStringCollection Parse (string query) { return Parse (query, Encoding.UTF8); @@ -126,5 +128,7 @@ public override string ToString () return buff.ToString (); } + + #endregion } } From 0f67ac2646774b710d2c5cfd4b7b787dcd3c2031 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 18 Aug 2018 20:30:45 +0900 Subject: [PATCH 2082/6294] [Modify] Add them --- websocket-sharp/Net/QueryStringCollection.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/websocket-sharp/Net/QueryStringCollection.cs b/websocket-sharp/Net/QueryStringCollection.cs index 9d47e08de..564debdda 100644 --- a/websocket-sharp/Net/QueryStringCollection.cs +++ b/websocket-sharp/Net/QueryStringCollection.cs @@ -48,6 +48,19 @@ namespace WebSocketSharp.Net { internal sealed class QueryStringCollection : NameValueCollection { + #region Public Constructors + + public QueryStringCollection () + { + } + + public QueryStringCollection (int capacity) + : base (capacity) + { + } + + #endregion + #region Public Methods public static QueryStringCollection Parse (string query) From ec89395dc36eb462ef2c72298f41602840890642 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 19 Aug 2018 21:31:42 +0900 Subject: [PATCH 2083/6294] [Modify] Use it --- websocket-sharp/Net/QueryStringCollection.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Net/QueryStringCollection.cs b/websocket-sharp/Net/QueryStringCollection.cs index 564debdda..4a95737c5 100644 --- a/websocket-sharp/Net/QueryStringCollection.cs +++ b/websocket-sharp/Net/QueryStringCollection.cs @@ -70,17 +70,15 @@ public static QueryStringCollection Parse (string query) public static QueryStringCollection Parse (string query, Encoding encoding) { - var ret = new QueryStringCollection (); - if (query == null) - return ret; + return new QueryStringCollection (1); var len = query.Length; if (len == 0) - return ret; + return new QueryStringCollection (1); if (query == "?") - return ret; + return new QueryStringCollection (1); if (query[0] == '?') query = query.Substring (1); @@ -88,6 +86,8 @@ public static QueryStringCollection Parse (string query, Encoding encoding) if (encoding == null) encoding = Encoding.UTF8; + var ret = new QueryStringCollection (); + var components = query.Split ('&'); foreach (var component in components) { len = component.Length; From d252d78e143ca0b457e46e68cd0b145650b2df0f Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 20 Aug 2018 20:51:03 +0900 Subject: [PATCH 2084/6294] [Modify] Edit it --- websocket-sharp/Net/QueryStringCollection.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/QueryStringCollection.cs b/websocket-sharp/Net/QueryStringCollection.cs index 4a95737c5..846c84822 100644 --- a/websocket-sharp/Net/QueryStringCollection.cs +++ b/websocket-sharp/Net/QueryStringCollection.cs @@ -2,7 +2,7 @@ /* * QueryStringCollection.cs * - * This code is derived from System.Net.HttpUtility.cs of Mono + * This code is derived from HttpUtility.cs (System.Net) of Mono * (http://www.mono-project.com). * * The MIT License From 86d41772d82d0f754e712bd82ba41301aa5e5eae Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 20 Aug 2018 20:53:40 +0900 Subject: [PATCH 2085/6294] [Modify] 2018 --- websocket-sharp/Net/QueryStringCollection.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/QueryStringCollection.cs b/websocket-sharp/Net/QueryStringCollection.cs index 846c84822..fd26b29fc 100644 --- a/websocket-sharp/Net/QueryStringCollection.cs +++ b/websocket-sharp/Net/QueryStringCollection.cs @@ -8,7 +8,7 @@ * The MIT License * * Copyright (c) 2005-2009 Novell, Inc. (http://www.novell.com) - * Copyright (c) 2014 sta.blockhead + * Copyright (c) 2018 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From 88cce88ae3432508f5f8d524185591ac7fe5e045 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 21 Aug 2018 20:57:50 +0900 Subject: [PATCH 2086/6294] [Modify] Replace it --- websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs index e1fe3d032..519da7896 100644 --- a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs @@ -263,7 +263,7 @@ public override NameValueCollection QueryString { get { if (_queryString == null) { var uri = RequestUri; - _queryString = HttpUtility.InternalParseQueryString ( + _queryString = QueryStringCollection.Parse ( uri != null ? uri.Query : null, Encoding.UTF8 ); From 1bbe9860b7c3cd186b2cbc4d8e181fb21056646a Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 22 Aug 2018 20:24:17 +0900 Subject: [PATCH 2087/6294] [Modify] Replace it --- websocket-sharp/Net/HttpListenerRequest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index 3de735200..953c9b956 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -398,7 +398,7 @@ public NameValueCollection QueryString { get { if (_queryString == null) { var url = Url; - _queryString = HttpUtility.InternalParseQueryString ( + _queryString = QueryStringCollection.Parse ( url != null ? url.Query : null, Encoding.UTF8 ); From 4c96ed757899f480cbeaf5ea77ee6478f9c63bb5 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 23 Aug 2018 20:30:48 +0900 Subject: [PATCH 2088/6294] [Modify] Remove it --- websocket-sharp/Net/HttpUtility.cs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 26cd92712..739fecd95 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -1019,11 +1019,6 @@ public static void HtmlEncode (string s, TextWriter output) output.Write (HtmlEncode (s)); } - public static NameValueCollection ParseQueryString (string query) - { - return ParseQueryString (query, Encoding.UTF8); - } - public static NameValueCollection ParseQueryString (string query, Encoding encoding) { if (query == null) From 1e6633da4eb3f90de3704c9332dfb1cfe1775bb7 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 23 Aug 2018 20:33:41 +0900 Subject: [PATCH 2089/6294] [Modify] Remove it --- websocket-sharp/Net/HttpUtility.cs | 8 -------- 1 file changed, 8 deletions(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 739fecd95..03fba21bf 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -1019,14 +1019,6 @@ public static void HtmlEncode (string s, TextWriter output) output.Write (HtmlEncode (s)); } - public static NameValueCollection ParseQueryString (string query, Encoding encoding) - { - if (query == null) - throw new ArgumentNullException ("query"); - - return InternalParseQueryString (query, encoding ?? Encoding.UTF8); - } - public static string UrlDecode (string s) { return UrlDecode (s, Encoding.UTF8); From 171e84449a8b8588041195b3c7dc46a6278944b2 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 24 Aug 2018 20:47:52 +0900 Subject: [PATCH 2090/6294] [Modify] Remove it --- websocket-sharp/Net/HttpUtility.cs | 29 ----------------------------- 1 file changed, 29 deletions(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 03fba21bf..fc126e784 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -630,35 +630,6 @@ internal static Encoding GetEncoding (string contentType) return null; } - internal static NameValueCollection InternalParseQueryString (string query, Encoding encoding) - { - int len; - if (query == null || (len = query.Length) == 0 || (len == 1 && query[0] == '?')) - return new NameValueCollection (1); - - if (query[0] == '?') - query = query.Substring (1); - - var res = new QueryStringCollection (); - var components = query.Split ('&'); - foreach (var component in components) { - var i = component.IndexOf ('='); - if (i > -1) { - var name = UrlDecode (component.Substring (0, i), encoding); - var val = component.Length > i + 1 - ? UrlDecode (component.Substring (i + 1), encoding) - : String.Empty; - - res.Add (name, val); - } - else { - res.Add (null, UrlDecode (component, encoding)); - } - } - - return res; - } - internal static string InternalUrlDecode ( byte[] bytes, int offset, int count, Encoding encoding) { From fb323c0ceb1d32cfd30a262f7777948cc84e82e3 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 25 Aug 2018 20:31:53 +0900 Subject: [PATCH 2091/6294] [Modify] Edit it --- websocket-sharp/Net/HttpUtility.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index fc126e784..7d4a1ba34 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -2,7 +2,7 @@ /* * HttpUtility.cs * - * This code is derived from System.Net.HttpUtility.cs of Mono + * This code is derived from HttpUtility.cs (System.Net) of Mono * (http://www.mono-project.com). * * The MIT License From 6c23bc86832fefeffecc654ee93681efb831a9e2 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 26 Aug 2018 21:36:04 +0900 Subject: [PATCH 2092/6294] [Modify] Add it --- websocket-sharp/Net/HttpUtility.cs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 7d4a1ba34..0401a75d7 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -56,8 +56,18 @@ internal sealed class HttpUtility #region Private Fields private static Dictionary _entities; - private static char[] _hexChars = "0123456789abcdef".ToCharArray (); - private static object _sync = new object (); + private static char[] _hexChars; + private static object _sync; + + #endregion + + #region Static Constructor + + static HttpUtility () + { + _hexChars = "0123456789abcdef".ToCharArray (); + _sync = new object (); + } #endregion From b8c12f93f7896f2b90a68b54618410bbd7360b05 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 27 Aug 2018 20:54:09 +0900 Subject: [PATCH 2093/6294] [Modify] To static --- websocket-sharp/Net/HttpUtility.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 0401a75d7..53129b240 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -51,7 +51,7 @@ namespace WebSocketSharp.Net { - internal sealed class HttpUtility + internal static class HttpUtility { #region Private Fields From 76ed2aede16b90b0223a75fc86c303e9306ac877 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 28 Aug 2018 20:45:31 +0900 Subject: [PATCH 2094/6294] [Modify] Polish it --- websocket-sharp/Net/HttpUtility.cs | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 53129b240..4ffaad734 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -761,12 +761,16 @@ internal static bool TryGetEncoding ( public static string HtmlAttributeEncode (string s) { - if (s == null || s.Length == 0 || !s.Contains ('&', '"', '<', '>')) - return s; + if (s == null) + return null; - var output = new StringBuilder (); - foreach (var c in s) - output.Append ( + if (s.Length == 0) + return String.Empty; + + var buff = new StringBuilder (); + + foreach (var c in s) { + buff.Append ( c == '&' ? "&" : c == '"' @@ -775,9 +779,11 @@ public static string HtmlAttributeEncode (string s) ? "<" : c == '>' ? ">" - : c.ToString ()); + : c.ToString () + ); + } - return output.ToString (); + return buff.ToString (); } public static void HtmlAttributeEncode (string s, TextWriter output) From b530875b857699761c66ef8bad38d1a23a5741d6 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 29 Aug 2018 19:48:02 +0900 Subject: [PATCH 2095/6294] [Modify] Polish it --- websocket-sharp/Net/HttpUtility.cs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 4ffaad734..9c0c999ea 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -761,11 +761,8 @@ internal static bool TryGetEncoding ( public static string HtmlAttributeEncode (string s) { - if (s == null) - return null; - - if (s.Length == 0) - return String.Empty; + if (s == null || s.Length == 0) + return s; var buff = new StringBuilder (); From 91fa2dc7b60c23e3efe017bd9fae97e7949c4594 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 30 Aug 2018 21:28:49 +0900 Subject: [PATCH 2096/6294] [Modify] Polish it --- websocket-sharp/Net/HttpUtility.cs | 62 +++++++++++++----------------- 1 file changed, 26 insertions(+), 36 deletions(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 9c0c999ea..48affbc5b 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -930,59 +930,49 @@ public static void HtmlDecode (string s, TextWriter output) output.Write (HtmlDecode (s)); } - /// - /// HTML-encodes a and returns the encoded . - /// - /// - /// A that represents the encoded string. - /// - /// - /// A to encode. - /// public static string HtmlEncode (string s) { if (s == null || s.Length == 0) return s; - var needEncode = false; - foreach (var c in s) { - if (c == '&' || c == '"' || c == '<' || c == '>' || c > 159) { - needEncode = true; - break; - } - } - - if (!needEncode) - return s; + var buff = new StringBuilder (); - var output = new StringBuilder (); foreach (var c in s) { if (c == '&') { - output.Append ("&"); + buff.Append ("&"); + continue; } - else if (c == '"') { - output.Append ("""); + + if (c == '"') { + buff.Append ("""); + continue; } - else if (c == '<') { - output.Append ("<"); + + if (c == '<') { + buff.Append ("<"); + continue; } - else if (c == '>') { - output.Append (">"); + + if (c == '>') { + buff.Append (">"); + continue; } - else if (c > 159) { + + if (c > 159) { // MS starts encoding with &# from 160 and stops at 255. - // We don't do that. One reason is the 65308/65310 unicode + // We do not do that. One reason is the 65308/65310 unicode // characters that look like '<' and '>'. - output.Append ("&#"); - output.Append (((int) c).ToString (CultureInfo.InvariantCulture)); - output.Append (";"); - } - else { - output.Append (c); + buff.Append ("&#"); + buff.Append (((int) c).ToString (CultureInfo.InvariantCulture)); + buff.Append (";"); + + continue; } + + buff.Append (c); } - return output.ToString (); + return buff.ToString (); } /// From e266d354932da9e7da099e828307ade70a798a47 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 31 Aug 2018 21:03:23 +0900 Subject: [PATCH 2097/6294] [Modify] Polish it --- websocket-sharp/Net/HttpUtility.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 48affbc5b..e04190453 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -959,13 +959,11 @@ public static string HtmlEncode (string s) } if (c > 159) { - // MS starts encoding with &# from 160 and stops at 255. + // MS .NET starts encoding with &# from 160 and stops at 255. // We do not do that. One reason is the 65308/65310 unicode // characters that look like '<' and '>'. - buff.Append ("&#"); - buff.Append (((int) c).ToString (CultureInfo.InvariantCulture)); - buff.Append (";"); + buff.AppendFormat ("&#{0};", (int) c); continue; } From b8e0856d096ba28b2f8aa598be94ae4e396fccf5 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 1 Sep 2018 20:28:43 +0900 Subject: [PATCH 2098/6294] [Modify] Polish it --- websocket-sharp/Net/HttpUtility.cs | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index e04190453..c1d9889ac 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -973,16 +973,6 @@ public static string HtmlEncode (string s) return buff.ToString (); } - /// - /// HTML-encodes a and sends the encoded - /// to the specified . - /// - /// - /// A to encode. - /// - /// - /// A that receives the encoded string. - /// public static void HtmlEncode (string s, TextWriter output) { if (output == null) From 61f96f36a165ebedb06c7fdaee9bbfcf17e33380 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 2 Sep 2018 21:51:31 +0900 Subject: [PATCH 2099/6294] [Modify] Polish it --- websocket-sharp/Net/HttpUtility.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index c1d9889ac..75db9ee5a 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -1223,12 +1223,12 @@ public static string UrlPathEncode (string s) if (s == null || s.Length == 0) return s; - using (var res = new MemoryStream ()) { + using (var buff = new MemoryStream ()) { foreach (var c in s) - urlPathEncode (c, res); + urlPathEncode (c, buff); - res.Close (); - return Encoding.ASCII.GetString (res.ToArray ()); + buff.Close (); + return Encoding.ASCII.GetString (buff.ToArray ()); } } From ddb794b3b50dae9e3b1fd91b6178417c6ada2ae2 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 3 Sep 2018 20:37:47 +0900 Subject: [PATCH 2100/6294] [Modify] Polish it --- websocket-sharp/Net/HttpUtility.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 75db9ee5a..407c06644 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -1204,9 +1204,10 @@ public static byte[] UrlEncodeToBytes (byte[] bytes, int offset, int count) public static string UrlEncodeUnicode (string s) { - return s != null && s.Length > 0 - ? Encoding.ASCII.GetString (InternalUrlEncodeUnicodeToBytes (s)) - : s; + if (s == null || s.Length == 0) + return s; + + return Encoding.ASCII.GetString (InternalUrlEncodeUnicodeToBytes (s)); } public static byte[] UrlEncodeUnicodeToBytes (string s) From 1bbac5e3da9b8dd9f3c5e675713990c18a3c5455 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 4 Sep 2018 19:46:29 +0900 Subject: [PATCH 2101/6294] [Modify] Polish it --- websocket-sharp/Net/HttpUtility.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 407c06644..1087a90e9 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -1161,8 +1161,11 @@ public static string UrlEncode (byte[] bytes, int offset, int count) public static byte[] UrlEncodeToBytes (byte[] bytes) { - int len; - return bytes != null && (len = bytes.Length) > 0 + if (bytes == null) + return null; + + var len = bytes.Length; + return len > 0 ? InternalUrlEncodeToBytes (bytes, 0, len) : bytes; } From bb44ff169c059ce936be3c4121d213f38bd2f00e Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 5 Sep 2018 21:09:34 +0900 Subject: [PATCH 2102/6294] [Modify] Polish it --- websocket-sharp/Net/HttpUtility.cs | 46 ++++++++++++++++++------------ 1 file changed, 28 insertions(+), 18 deletions(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 1087a90e9..9a20b4165 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -1170,6 +1170,34 @@ public static byte[] UrlEncodeToBytes (byte[] bytes) : bytes; } + public static byte[] UrlEncodeToBytes (byte[] bytes, int offset, int count) + { + if (bytes == null) { + if (count != 0) + throw new ArgumentNullException ("bytes"); + + return null; + } + + var len = bytes.Length; + if (len == 0) { + if (offset != 0 || count != 0) + throw new ArgumentException ("An empty byte array.", "bytes"); + + return bytes; + } + + if (offset < 0 || offset >= len) + throw new ArgumentOutOfRangeException ("offset"); + + if (count < 0 || count > len - offset) + throw new ArgumentOutOfRangeException ("count"); + + return count > 0 + ? InternalUrlEncodeToBytes (bytes, offset, count) + : new byte[0]; + } + public static byte[] UrlEncodeToBytes (string s) { return UrlEncodeToBytes (s, Encoding.UTF8); @@ -1187,24 +1215,6 @@ public static byte[] UrlEncodeToBytes (string s, Encoding encoding) return InternalUrlEncodeToBytes (bytes, 0, bytes.Length); } - public static byte[] UrlEncodeToBytes (byte[] bytes, int offset, int count) - { - int len; - if (bytes == null || (len = bytes.Length) == 0) - return bytes; - - if (count == 0) - return new byte[0]; - - if (offset < 0 || offset >= len) - throw new ArgumentOutOfRangeException ("offset"); - - if (count < 0 || count > len - offset) - throw new ArgumentOutOfRangeException ("count"); - - return InternalUrlEncodeToBytes (bytes, offset, count); - } - public static string UrlEncodeUnicode (string s) { if (s == null || s.Length == 0) From 36b74f63ada48cd708208301d47cc4f31cf439e7 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 6 Sep 2018 19:49:42 +0900 Subject: [PATCH 2103/6294] [Modify] Polish it --- websocket-sharp/Net/HttpUtility.cs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 9a20b4165..b4d11470f 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -1106,12 +1106,15 @@ public static byte[] UrlDecodeToBytes (byte[] bytes, int offset, int count) public static string UrlEncode (byte[] bytes) { - int len; - return bytes == null - ? null - : (len = bytes.Length) == 0 - ? String.Empty - : Encoding.ASCII.GetString (InternalUrlEncodeToBytes (bytes, 0, len)); + if (bytes == null) + return null; + + var len = bytes.Length; + return len > 0 + ? Encoding.ASCII.GetString ( + InternalUrlEncodeToBytes (bytes, 0, len) + ) + : String.Empty; } public static string UrlEncode (string s) From 883ea8717529152efac4d90c4c98e631ba09278c Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 7 Sep 2018 20:40:53 +0900 Subject: [PATCH 2104/6294] [Modify] Polish it --- websocket-sharp/Net/HttpUtility.cs | 26 ++++++++------------------ 1 file changed, 8 insertions(+), 18 deletions(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index b4d11470f..c83bed919 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -1121,37 +1121,27 @@ public static string UrlEncode (string s) { return UrlEncode (s, Encoding.UTF8); } - + public static string UrlEncode (string s, Encoding encoding) { - int len; - if (s == null || (len = s.Length) == 0) + if (s == null) return s; - var needEncode = false; - foreach (var c in s) { - if ((c < '0') || (c < 'A' && c > '9') || (c > 'Z' && c < 'a') || (c > 'z')) { - if (notEncoded (c)) - continue; - - needEncode = true; - break; - } - } - - if (!needEncode) + var len = s.Length; + if (len == 0) return s; if (encoding == null) encoding = Encoding.UTF8; - // Avoided GetByteCount call. var bytes = new byte[encoding.GetMaxByteCount (len)]; var realLen = encoding.GetBytes (s, 0, len, bytes, 0); - return Encoding.ASCII.GetString (InternalUrlEncodeToBytes (bytes, 0, realLen)); + return Encoding.ASCII.GetString ( + InternalUrlEncodeToBytes (bytes, 0, realLen) + ); } - + public static string UrlEncode (byte[] bytes, int offset, int count) { var encoded = UrlEncodeToBytes (bytes, offset, count); From d00b56de8a8a0debc3dd501f717a011389f83637 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 8 Sep 2018 21:05:08 +0900 Subject: [PATCH 2105/6294] [Modify] Polish it --- websocket-sharp/Net/HttpUtility.cs | 40 ++++++++++++++++++++++-------- 1 file changed, 30 insertions(+), 10 deletions(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index c83bed919..f088b1a94 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -1117,6 +1117,36 @@ public static string UrlEncode (byte[] bytes) : String.Empty; } + public static string UrlEncode (byte[] bytes, int offset, int count) + { + if (bytes == null) { + if (count != 0) + throw new ArgumentNullException ("bytes"); + + return null; + } + + var len = bytes.Length; + if (len == 0) { + if (offset != 0 || count != 0) + throw new ArgumentException ("An empty byte array.", "bytes"); + + return String.Empty; + } + + if (offset < 0 || offset >= len) + throw new ArgumentOutOfRangeException ("offset"); + + if (count < 0 || count > len - offset) + throw new ArgumentOutOfRangeException ("count"); + + return count > 0 + ? Encoding.ASCII.GetString ( + InternalUrlEncodeToBytes (bytes, offset, count) + ) + : String.Empty; + } + public static string UrlEncode (string s) { return UrlEncode (s, Encoding.UTF8); @@ -1142,16 +1172,6 @@ public static string UrlEncode (string s, Encoding encoding) ); } - public static string UrlEncode (byte[] bytes, int offset, int count) - { - var encoded = UrlEncodeToBytes (bytes, offset, count); - return encoded == null - ? null - : encoded.Length == 0 - ? String.Empty - : Encoding.ASCII.GetString (encoded); - } - public static byte[] UrlEncodeToBytes (byte[] bytes) { if (bytes == null) From 0b7c2208faf6897e07c8fecda24c3c598c4f6059 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 9 Sep 2018 21:35:44 +0900 Subject: [PATCH 2106/6294] [Modify] Polish it --- websocket-sharp/Net/HttpUtility.cs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index f088b1a94..3a0e3ec1e 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -716,15 +716,17 @@ internal static byte[] InternalUrlDecodeToBytes (byte[] bytes, int offset, int c } } - internal static byte[] InternalUrlEncodeToBytes (byte[] bytes, int offset, int count) + internal static byte[] InternalUrlEncodeToBytes ( + byte[] bytes, int offset, int count + ) { - using (var res = new MemoryStream ()) { + using (var buff = new MemoryStream ()) { var end = offset + count; for (var i = offset; i < end; i++) - urlEncode ((char) bytes[i], res, false); + urlEncode ((char) bytes[i], buff, false); - res.Close (); - return res.ToArray (); + buff.Close (); + return buff.ToArray (); } } From b7b0db9f196245bd9c2141bc804af955dc831f91 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 10 Sep 2018 21:19:01 +0900 Subject: [PATCH 2107/6294] [Modify] Add it --- websocket-sharp/Net/HttpUtility.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 3a0e3ec1e..073241a08 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -393,6 +393,11 @@ private static void initEntities () _entities.Add ("euro", '\u20AC'); } + private static bool isNumeric (char c) + { + return c >= '0' && c <= '9'; + } + private static bool notEncoded (char c) { return c == '!' || From 73342ac5ae96b9bfa17785e520d3b3353822a500 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 11 Sep 2018 20:51:09 +0900 Subject: [PATCH 2108/6294] [Modify] Add it --- websocket-sharp/Net/HttpUtility.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 073241a08..45c9b8f30 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -393,6 +393,12 @@ private static void initEntities () _entities.Add ("euro", '\u20AC'); } + private static bool isAlphabet (char c) + { + return (c >= 'A' && c <= 'Z') + || (c >= 'a' && c <= 'z'); + } + private static bool isNumeric (char c) { return c >= '0' && c <= '9'; From 50e062c7ffcbf82fd52229edcd16b9828b522add Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 12 Sep 2018 20:36:06 +0900 Subject: [PATCH 2109/6294] [Modify] Add it --- websocket-sharp/Net/HttpUtility.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 45c9b8f30..6772f666d 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -404,6 +404,14 @@ private static bool isNumeric (char c) return c >= '0' && c <= '9'; } + private static bool isUnreserved (char c) + { + return c == '*' + || c == '-' + || c == '.' + || c == '_'; + } + private static bool notEncoded (char c) { return c == '!' || From 03f85bc91d4ef39ce530e26a810765c1420a7eec Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 12 Sep 2018 20:51:08 +0900 Subject: [PATCH 2110/6294] [Modify] Add it --- websocket-sharp/Net/HttpUtility.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 6772f666d..7cca940ee 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -412,6 +412,19 @@ private static bool isUnreserved (char c) || c == '_'; } + private static bool isUnreservedInRfc2396 (char c) + { + return c == '!' + || c == '\'' + || c == '(' + || c == ')' + || c == '*' + || c == '-' + || c == '.' + || c == '_' + || c == '~'; + } + private static bool notEncoded (char c) { return c == '!' || From 58e5ef372a4544337258d9bc914ab09a7ce14d98 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 13 Sep 2018 20:23:54 +0900 Subject: [PATCH 2111/6294] [Modify] Add it --- websocket-sharp/Net/HttpUtility.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 7cca940ee..15ff8e96d 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -425,6 +425,14 @@ private static bool isUnreservedInRfc2396 (char c) || c == '~'; } + private static bool isUnreservedInRfc3986 (char c) + { + return c == '-' + || c == '.' + || c == '_' + || c == '~'; + } + private static bool notEncoded (char c) { return c == '!' || From 9f742aa41578e44604abe00499acb1f29fc25e39 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 13 Sep 2018 20:30:04 +0900 Subject: [PATCH 2112/6294] [Modify] Add it --- websocket-sharp/Net/HttpUtility.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 15ff8e96d..baa046d1c 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -393,6 +393,12 @@ private static void initEntities () _entities.Add ("euro", '\u20AC'); } + private static bool isAlphabet (byte b) + { + return (b >= 65 && b <= 90) + || (b >= 97 && b <= 122); + } + private static bool isAlphabet (char c) { return (c >= 'A' && c <= 'Z') From 67176e17baa7453afc6573c2102ffe8c293c47fe Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 13 Sep 2018 20:34:54 +0900 Subject: [PATCH 2113/6294] [Modify] Add it --- websocket-sharp/Net/HttpUtility.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index baa046d1c..732e8a6bc 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -405,6 +405,11 @@ private static bool isAlphabet (char c) || (c >= 'a' && c <= 'z'); } + private static bool isNumeric (byte b) + { + return b >= 48 && b <= 57; + } + private static bool isNumeric (char c) { return c >= '0' && c <= '9'; From 3989809d430e3030dd8ac94468dbaad1e1c5c145 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 14 Sep 2018 19:48:27 +0900 Subject: [PATCH 2114/6294] [Modify] Add it --- websocket-sharp/Net/HttpUtility.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 732e8a6bc..44ce18b1f 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -415,6 +415,14 @@ private static bool isNumeric (char c) return c >= '0' && c <= '9'; } + private static bool isUnreserved (byte b) + { + return b == 42 + || b == 45 + || b == 46 + || b == 95; + } + private static bool isUnreserved (char c) { return c == '*' From ba62bf08179d4f06c1a514c891f4345ab3c86b44 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 15 Sep 2018 15:22:59 +0900 Subject: [PATCH 2115/6294] [Modify] Add it --- websocket-sharp/Net/HttpUtility.cs | 34 ++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 44ce18b1f..154e7f772 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -464,6 +464,40 @@ private static bool notEncoded (char c) c == '_'; } + private static void urlEncode (byte b, Stream output) + { + if (b > 31 && b < 127) { + if (b == 32) { + output.WriteByte ((byte) '+'); + return; + } + + if (isNumeric (b)) { + output.WriteByte (b); + return; + } + + if (isAlphabet (b)) { + output.WriteByte (b); + return; + } + + if (isUnreserved (b)) { + output.WriteByte (b); + return; + } + } + + output.WriteByte ((byte) '%'); + + var i = (int) b; + var idx = i >> 4; + output.WriteByte ((byte) _hexChars[idx]); + + idx = i & 0x0F; + output.WriteByte ((byte) _hexChars[idx]); + } + private static void urlEncode (char c, Stream result, bool unicode) { if (c > 255) { From b910b6bc9de1dd7790ad6318b84435aca1a559ef Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 16 Sep 2018 15:32:25 +0900 Subject: [PATCH 2116/6294] [Modify] Add it --- websocket-sharp/Net/HttpUtility.cs | 41 ++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 154e7f772..73b36ebe9 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -561,6 +561,47 @@ private static void urlEncode (char c, Stream result, bool unicode) result.WriteByte ((byte) c); } + private static void urlEncodeUnicode (char c, Stream output) + { + if (c > 31 && c < 127) { + if (c == ' ') { + output.WriteByte ((byte) '+'); + return; + } + + if (isNumeric (c)) { + output.WriteByte ((byte) c); + return; + } + + if (isAlphabet (c)) { + output.WriteByte ((byte) c); + return; + } + + if (isUnreserved (c)) { + output.WriteByte ((byte) c); + return; + } + } + + output.WriteByte ((byte) '%'); + output.WriteByte ((byte) 'u'); + + var i = (int) c; + var idx = i >> 12; + output.WriteByte ((byte) _hexChars[idx]); + + idx = (i >> 8) & 0x0F; + output.WriteByte ((byte) _hexChars[idx]); + + idx = (i >> 4) & 0x0F; + output.WriteByte ((byte) _hexChars[idx]); + + idx = i & 0x0F; + output.WriteByte ((byte) _hexChars[idx]); + } + private static void urlPathEncode (char c, Stream result) { if (c < 33 || c > 126) { From f36653e4f9afce79f7d733f223e699a176297b9c Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 17 Sep 2018 16:14:05 +0900 Subject: [PATCH 2117/6294] [Modify] Replace it --- websocket-sharp/Net/HttpUtility.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 73b36ebe9..4e48cd0d8 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -857,7 +857,7 @@ internal static byte[] InternalUrlEncodeToBytes ( using (var buff = new MemoryStream ()) { var end = offset + count; for (var i = offset; i < end; i++) - urlEncode ((char) bytes[i], buff, false); + urlEncode (bytes[i], buff); buff.Close (); return buff.ToArray (); From 8e4fc80f7c204551085f1868df815ff97f786beb Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 17 Sep 2018 16:20:44 +0900 Subject: [PATCH 2118/6294] [Modify] Replace it --- websocket-sharp/Net/HttpUtility.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 4e48cd0d8..26096eef2 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -868,7 +868,7 @@ internal static byte[] InternalUrlEncodeUnicodeToBytes (string s) { using (var res = new MemoryStream ()) { foreach (var c in s) - urlEncode (c, res, true); + urlEncodeUnicode (c, res); res.Close (); return res.ToArray (); From 07caf5c948fbc9c7d8256c25abaac67fca5ddcf7 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 18 Sep 2018 19:38:48 +0900 Subject: [PATCH 2119/6294] [Modify] Polish it --- websocket-sharp/Net/HttpUtility.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 26096eef2..80b833ddc 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -866,12 +866,12 @@ internal static byte[] InternalUrlEncodeToBytes ( internal static byte[] InternalUrlEncodeUnicodeToBytes (string s) { - using (var res = new MemoryStream ()) { + using (var buff = new MemoryStream ()) { foreach (var c in s) - urlEncodeUnicode (c, res); + urlEncodeUnicode (c, buff); - res.Close (); - return res.ToArray (); + buff.Close (); + return buff.ToArray (); } } From 0b853ecf70371c0ef9b827df4b89e6cc761d887f Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 18 Sep 2018 19:43:17 +0900 Subject: [PATCH 2120/6294] [Modify] Remove it --- websocket-sharp/Net/HttpUtility.cs | 63 ------------------------------ 1 file changed, 63 deletions(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 80b833ddc..428758e8a 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -498,69 +498,6 @@ private static void urlEncode (byte b, Stream output) output.WriteByte ((byte) _hexChars[idx]); } - private static void urlEncode (char c, Stream result, bool unicode) - { - if (c > 255) { - // FIXME: What happens when there is an internal error? - //if (!unicode) - // throw new ArgumentOutOfRangeException ("c", c, "Greater than 255."); - - result.WriteByte ((byte) '%'); - result.WriteByte ((byte) 'u'); - - var i = (int) c; - var idx = i >> 12; - result.WriteByte ((byte) _hexChars[idx]); - - idx = (i >> 8) & 0x0F; - result.WriteByte ((byte) _hexChars[idx]); - - idx = (i >> 4) & 0x0F; - result.WriteByte ((byte) _hexChars[idx]); - - idx = i & 0x0F; - result.WriteByte ((byte) _hexChars[idx]); - - return; - } - - if (c > ' ' && notEncoded (c)) { - result.WriteByte ((byte) c); - return; - } - - if (c == ' ') { - result.WriteByte ((byte) '+'); - return; - } - - if ((c < '0') || - (c < 'A' && c > '9') || - (c > 'Z' && c < 'a') || - (c > 'z')) { - if (unicode && c > 127) { - result.WriteByte ((byte) '%'); - result.WriteByte ((byte) 'u'); - result.WriteByte ((byte) '0'); - result.WriteByte ((byte) '0'); - } - else { - result.WriteByte ((byte) '%'); - } - - var i = (int) c; - var idx = i >> 4; - result.WriteByte ((byte) _hexChars[idx]); - - idx = i & 0x0F; - result.WriteByte ((byte) _hexChars[idx]); - - return; - } - - result.WriteByte ((byte) c); - } - private static void urlEncodeUnicode (char c, Stream output) { if (c > 31 && c < 127) { From ea43df2f61cf559870134910328251c0420ccc5c Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 19 Sep 2018 19:42:36 +0900 Subject: [PATCH 2121/6294] [Modify] Polish it --- websocket-sharp/Net/HttpUtility.cs | 33 +++++++++++------------------- 1 file changed, 12 insertions(+), 21 deletions(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 428758e8a..f9a302a90 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -539,33 +539,24 @@ private static void urlEncodeUnicode (char c, Stream output) output.WriteByte ((byte) _hexChars[idx]); } - private static void urlPathEncode (char c, Stream result) + private static void urlPathEncode (char c, Stream output) { - if (c < 33 || c > 126) { - var bytes = Encoding.UTF8.GetBytes (c.ToString ()); - foreach (var b in bytes) { - result.WriteByte ((byte) '%'); - - var i = (int) b; - var idx = i >> 4; - result.WriteByte ((byte) _hexChars[idx]); - - idx = i & 0x0F; - result.WriteByte ((byte) _hexChars[idx]); - } - + if (c > 32 && c < 127) { + output.WriteByte ((byte) c); return; } - if (c == ' ') { - result.WriteByte ((byte) '%'); - result.WriteByte ((byte) '2'); - result.WriteByte ((byte) '0'); + var bytes = Encoding.UTF8.GetBytes (c.ToString ()); + foreach (var b in bytes) { + output.WriteByte ((byte) '%'); - return; - } + var i = (int) b; + var idx = i >> 4; + output.WriteByte ((byte) _hexChars[idx]); - result.WriteByte ((byte) c); + idx = i & 0x0F; + output.WriteByte ((byte) _hexChars[idx]); + } } private static void writeCharBytes (char c, IList buffer, Encoding encoding) From 66a6bbc6f5b9d56072c413380ecfe51e0d8c55dc Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 20 Sep 2018 19:13:42 +0900 Subject: [PATCH 2122/6294] [Modify] Add it --- websocket-sharp/Net/HttpUtility.cs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index f9a302a90..11b2b3efd 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -559,6 +559,20 @@ private static void urlPathEncode (char c, Stream output) } } + private static void urlPathEncode (char c, StringBuilder output) + { + if (c > 32 && c < 127) { + output.Append (c); + return; + } + + var bytes = Encoding.UTF8.GetBytes (new[] { c }); + foreach (var b in bytes) { + var i = (int) b; + output.AppendFormat ("%{0}{1}", _hexChars[i >> 4], _hexChars[i & 0x0F]); + } + } + private static void writeCharBytes (char c, IList buffer, Encoding encoding) { if (c > 255) { From 174954f109d66ab653adeacbe3e30cf57aed10ea Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 20 Sep 2018 19:22:16 +0900 Subject: [PATCH 2123/6294] [Modify] Replace it --- websocket-sharp/Net/HttpUtility.cs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 11b2b3efd..fa51ba901 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -1328,13 +1328,12 @@ public static string UrlPathEncode (string s) if (s == null || s.Length == 0) return s; - using (var buff = new MemoryStream ()) { - foreach (var c in s) - urlPathEncode (c, buff); + var buff = new StringBuilder (); - buff.Close (); - return Encoding.ASCII.GetString (buff.ToArray ()); - } + foreach (var c in s) + urlPathEncode (c, buff); + + return buff.ToString (); } #endregion From 55d848a8bf7fce7236514916e803f32b6c39df0c Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 20 Sep 2018 19:24:36 +0900 Subject: [PATCH 2124/6294] [Modify] Remove it --- websocket-sharp/Net/HttpUtility.cs | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index fa51ba901..15ea05576 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -539,26 +539,6 @@ private static void urlEncodeUnicode (char c, Stream output) output.WriteByte ((byte) _hexChars[idx]); } - private static void urlPathEncode (char c, Stream output) - { - if (c > 32 && c < 127) { - output.WriteByte ((byte) c); - return; - } - - var bytes = Encoding.UTF8.GetBytes (c.ToString ()); - foreach (var b in bytes) { - output.WriteByte ((byte) '%'); - - var i = (int) b; - var idx = i >> 4; - output.WriteByte ((byte) _hexChars[idx]); - - idx = i & 0x0F; - output.WriteByte ((byte) _hexChars[idx]); - } - } - private static void urlPathEncode (char c, StringBuilder output) { if (c > 32 && c < 127) { From 680404686cccb9615800839242f2a49ed482ba92 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 21 Sep 2018 19:35:43 +0900 Subject: [PATCH 2125/6294] [Modify] Throw exception --- websocket-sharp/Net/HttpUtility.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 15ea05576..3859598b8 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -1305,7 +1305,10 @@ public static byte[] UrlEncodeUnicodeToBytes (string s) public static string UrlPathEncode (string s) { - if (s == null || s.Length == 0) + if (s == null) + throw new ArgumentNullException ("s"); + + if (s.Length == 0) return s; var buff = new StringBuilder (); From 0aa1a544f73af8c9506a1b4aa21ddef50a6772fe Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 21 Sep 2018 19:40:49 +0900 Subject: [PATCH 2126/6294] [Modify] Throw exception --- websocket-sharp/Net/HttpUtility.cs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 3859598b8..14c202064 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -1296,11 +1296,12 @@ public static string UrlEncodeUnicode (string s) public static byte[] UrlEncodeUnicodeToBytes (string s) { - return s == null - ? null - : s.Length == 0 - ? new byte[0] - : InternalUrlEncodeUnicodeToBytes (s); + if (s == null) + throw new ArgumentNullException ("s"); + + return s.Length > 0 + ? InternalUrlEncodeUnicodeToBytes (s) + : new byte[0]; } public static string UrlPathEncode (string s) From 503767d31e90f8e82bde54f6d17e19418e04eb1b Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 22 Sep 2018 20:35:55 +0900 Subject: [PATCH 2127/6294] [Modify] Throw exception --- websocket-sharp/Net/HttpUtility.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 14c202064..0d207d77a 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -1288,10 +1288,12 @@ public static byte[] UrlEncodeToBytes (string s, Encoding encoding) public static string UrlEncodeUnicode (string s) { - if (s == null || s.Length == 0) - return s; + if (s == null) + throw new ArgumentNullException ("s"); - return Encoding.ASCII.GetString (InternalUrlEncodeUnicodeToBytes (s)); + return s.Length > 0 + ? Encoding.ASCII.GetString (InternalUrlEncodeUnicodeToBytes (s)) + : s; } public static byte[] UrlEncodeUnicodeToBytes (string s) From 18747d5345b8a073a24866c38830b5312b494966 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 22 Sep 2018 20:40:52 +0900 Subject: [PATCH 2128/6294] [Modify] Throw exception --- websocket-sharp/Net/HttpUtility.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 0d207d77a..9372d6837 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -1165,7 +1165,7 @@ public static byte[] UrlDecodeToBytes (byte[] bytes, int offset, int count) public static string UrlEncode (byte[] bytes) { if (bytes == null) - return null; + throw new ArgumentNullException ("bytes"); var len = bytes.Length; return len > 0 From ff1fb91652451e05cc788a6f285e04ce41dd5328 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 23 Sep 2018 17:19:47 +0900 Subject: [PATCH 2129/6294] [Modify] Polish it --- websocket-sharp/Net/HttpUtility.cs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 9372d6837..50c0ced75 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -1177,12 +1177,8 @@ public static string UrlEncode (byte[] bytes) public static string UrlEncode (byte[] bytes, int offset, int count) { - if (bytes == null) { - if (count != 0) - throw new ArgumentNullException ("bytes"); - - return null; - } + if (bytes == null) + throw new ArgumentNullException ("bytes"); var len = bytes.Length; if (len == 0) { From 17b1b861cdb42d6963ecc959bc3c96fb6e973933 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 23 Sep 2018 17:26:15 +0900 Subject: [PATCH 2130/6294] [Modify] Throw exception --- websocket-sharp/Net/HttpUtility.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 50c0ced75..9c408fa57 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -1209,7 +1209,7 @@ public static string UrlEncode (string s) public static string UrlEncode (string s, Encoding encoding) { if (s == null) - return s; + throw new ArgumentNullException ("s"); var len = s.Length; if (len == 0) From a42611e27d7439824d54fcb544b4651b49e23c23 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 24 Sep 2018 21:10:36 +0900 Subject: [PATCH 2131/6294] [Modify] Throw exception --- websocket-sharp/Net/HttpUtility.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 9c408fa57..b853eece0 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -1229,7 +1229,7 @@ public static string UrlEncode (string s, Encoding encoding) public static byte[] UrlEncodeToBytes (byte[] bytes) { if (bytes == null) - return null; + throw new ArgumentNullException ("bytes"); var len = bytes.Length; return len > 0 From 898ff1b24bcb7bfbcd1cbbab092fbb2f3569aff7 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 24 Sep 2018 21:13:40 +0900 Subject: [PATCH 2132/6294] [Modify] Polish it --- websocket-sharp/Net/HttpUtility.cs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index b853eece0..89533173d 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -1239,12 +1239,8 @@ public static byte[] UrlEncodeToBytes (byte[] bytes) public static byte[] UrlEncodeToBytes (byte[] bytes, int offset, int count) { - if (bytes == null) { - if (count != 0) - throw new ArgumentNullException ("bytes"); - - return null; - } + if (bytes == null) + throw new ArgumentNullException ("bytes"); var len = bytes.Length; if (len == 0) { From 74bb695fa058319dd5eb71595b1075cd1b7014c3 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 25 Sep 2018 19:37:32 +0900 Subject: [PATCH 2133/6294] [Modify] Throw exception --- websocket-sharp/Net/HttpUtility.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 89533173d..7a5de1c73 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -1269,7 +1269,7 @@ public static byte[] UrlEncodeToBytes (string s) public static byte[] UrlEncodeToBytes (string s, Encoding encoding) { if (s == null) - return null; + throw new ArgumentNullException ("s"); if (s.Length == 0) return new byte[0]; From 4b2e166481e47326d082d5f3a49f0eb0eacc5e72 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 25 Sep 2018 19:45:08 +0900 Subject: [PATCH 2134/6294] [Modify] Throw exception --- websocket-sharp/Net/HttpUtility.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 7a5de1c73..97d73dc28 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -819,7 +819,10 @@ internal static bool TryGetEncoding ( public static string HtmlAttributeEncode (string s) { - if (s == null || s.Length == 0) + if (s == null) + throw new ArgumentNullException ("s"); + + if (s.Length == 0) return s; var buff = new StringBuilder (); From 8aedfa8cc81ef96526771aa3909b52d986d9fac2 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 26 Sep 2018 20:34:32 +0900 Subject: [PATCH 2135/6294] [Modify] Throw exception --- websocket-sharp/Net/HttpUtility.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 97d73dc28..7d1b40016 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -846,6 +846,9 @@ public static string HtmlAttributeEncode (string s) public static void HtmlAttributeEncode (string s, TextWriter output) { + if (s == null) + throw new ArgumentNullException ("s"); + if (output == null) throw new ArgumentNullException ("output"); From 904bbdaa3660ae9c3bc99251a45a9ba283cfb7fc Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 26 Sep 2018 20:38:57 +0900 Subject: [PATCH 2136/6294] [Modify] Throw exception --- websocket-sharp/Net/HttpUtility.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 7d1b40016..af2be570f 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -996,7 +996,10 @@ public static void HtmlDecode (string s, TextWriter output) public static string HtmlEncode (string s) { - if (s == null || s.Length == 0) + if (s == null) + throw new ArgumentNullException ("s"); + + if (s.Length == 0) return s; var buff = new StringBuilder (); From 6a3ff4964b8e20ed3efccf8552696d9974fff236 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 27 Sep 2018 19:39:44 +0900 Subject: [PATCH 2137/6294] [Modify] Throw exception --- websocket-sharp/Net/HttpUtility.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index af2be570f..b83694ab4 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -1042,6 +1042,9 @@ public static string HtmlEncode (string s) public static void HtmlEncode (string s, TextWriter output) { + if (s == null) + throw new ArgumentNullException ("s"); + if (output == null) throw new ArgumentNullException ("output"); From 55dc249ee5a1cabec31fec3ef7cd0a87154ea477 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 28 Sep 2018 19:38:55 +0900 Subject: [PATCH 2138/6294] [Modify] Add it --- websocket-sharp/Net/HttpUtility.cs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index b83694ab4..002aad7cd 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -134,6 +134,27 @@ private static int getInt (byte b) : -1; } + private static string htmlAttributeEncode (string s) + { + var buff = new StringBuilder (); + + foreach (var c in s) { + buff.Append ( + c == '"' + ? """ + : c == '&' + ? "&" + : c == '<' + ? "<" + : c == '>' + ? ">" + : c.ToString () + ); + } + + return buff.ToString (); + } + private static void initEntities () { // Build the dictionary of HTML entity references. From 26956822d02d2475517b4ef507e2f7782dfe07fd Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 28 Sep 2018 19:43:20 +0900 Subject: [PATCH 2139/6294] [Modify] Replace it --- websocket-sharp/Net/HttpUtility.cs | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 002aad7cd..a3dfb9cfb 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -846,23 +846,7 @@ public static string HtmlAttributeEncode (string s) if (s.Length == 0) return s; - var buff = new StringBuilder (); - - foreach (var c in s) { - buff.Append ( - c == '&' - ? "&" - : c == '"' - ? """ - : c == '<' - ? "<" - : c == '>' - ? ">" - : c.ToString () - ); - } - - return buff.ToString (); + return htmlAttributeEncode (s); } public static void HtmlAttributeEncode (string s, TextWriter output) From e2cc195808e9d6e650ea902eafe66b37014e0cc6 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 28 Sep 2018 19:50:28 +0900 Subject: [PATCH 2140/6294] [Modify] Replace it --- websocket-sharp/Net/HttpUtility.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index a3dfb9cfb..17e6c9231 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -857,7 +857,7 @@ public static void HtmlAttributeEncode (string s, TextWriter output) if (output == null) throw new ArgumentNullException ("output"); - output.Write (HtmlAttributeEncode (s)); + output.Write (s.Length > 0 ? htmlAttributeEncode (s) : s); } /// From 343c0acf6a896ad7691485571ba6409a908dc194 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 29 Sep 2018 20:41:54 +0900 Subject: [PATCH 2141/6294] [Modify] Polish it --- websocket-sharp/Net/HttpUtility.cs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 17e6c9231..5b520a42c 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -843,10 +843,7 @@ public static string HtmlAttributeEncode (string s) if (s == null) throw new ArgumentNullException ("s"); - if (s.Length == 0) - return s; - - return htmlAttributeEncode (s); + return s.Length > 0 ? htmlAttributeEncode (s) : s; } public static void HtmlAttributeEncode (string s, TextWriter output) From 1c2472c9f331f08d037c857f91330afb4ac8e0cb Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 29 Sep 2018 20:45:20 +0900 Subject: [PATCH 2142/6294] [Modify] Polish it --- websocket-sharp/Net/HttpUtility.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 5b520a42c..a54de11a5 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -854,7 +854,10 @@ public static void HtmlAttributeEncode (string s, TextWriter output) if (output == null) throw new ArgumentNullException ("output"); - output.Write (s.Length > 0 ? htmlAttributeEncode (s) : s); + if (s.Length == 0) + return; + + output.Write (htmlAttributeEncode (s)); } /// From f8a70130e7bfc8a1fa9992366c19c44c30c47819 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 30 Sep 2018 17:58:37 +0900 Subject: [PATCH 2143/6294] [Modify] Add it --- websocket-sharp/Net/HttpUtility.cs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index a54de11a5..08abb41ec 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -155,6 +155,29 @@ private static string htmlAttributeEncode (string s) return buff.ToString (); } + private static string htmlEncode (string s) + { + var buff = new StringBuilder (); + + foreach (var c in s) { + buff.Append ( + c == '"' + ? """ + : c == '&' + ? "&" + : c == '<' + ? "<" + : c == '>' + ? ">" + : c > 159 + ? String.Format ("&#{0};", (int) c) + : c.ToString () + ); + } + + return buff.ToString (); + } + private static void initEntities () { // Build the dictionary of HTML entity references. From 126744f36e0b5982445184a5811a0c3e41c95b44 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 1 Oct 2018 19:53:34 +0900 Subject: [PATCH 2144/6294] [Modify] Replace it --- websocket-sharp/Net/HttpUtility.cs | 40 +----------------------------- 1 file changed, 1 insertion(+), 39 deletions(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 08abb41ec..c436d9ff7 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -1027,45 +1027,7 @@ public static string HtmlEncode (string s) if (s == null) throw new ArgumentNullException ("s"); - if (s.Length == 0) - return s; - - var buff = new StringBuilder (); - - foreach (var c in s) { - if (c == '&') { - buff.Append ("&"); - continue; - } - - if (c == '"') { - buff.Append ("""); - continue; - } - - if (c == '<') { - buff.Append ("<"); - continue; - } - - if (c == '>') { - buff.Append (">"); - continue; - } - - if (c > 159) { - // MS .NET starts encoding with &# from 160 and stops at 255. - // We do not do that. One reason is the 65308/65310 unicode - // characters that look like '<' and '>'. - - buff.AppendFormat ("&#{0};", (int) c); - continue; - } - - buff.Append (c); - } - - return buff.ToString (); + return s.Length > 0 ? htmlEncode (s) : s; } public static void HtmlEncode (string s, TextWriter output) From b740ea771da6ee82176cf7b054df20f648408266 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 1 Oct 2018 19:57:48 +0900 Subject: [PATCH 2145/6294] [Modify] Replace it --- websocket-sharp/Net/HttpUtility.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index c436d9ff7..167da146e 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -1038,7 +1038,10 @@ public static void HtmlEncode (string s, TextWriter output) if (output == null) throw new ArgumentNullException ("output"); - output.Write (HtmlEncode (s)); + if (s.Length == 0) + return; + + output.Write (htmlEncode (s)); } public static string UrlDecode (string s) From 0cd36dc6151d7ce2b1302d0396a47d74a52c9a6d Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 2 Oct 2018 19:42:58 +0900 Subject: [PATCH 2146/6294] [Modify] Add it --- websocket-sharp/Net/HttpUtility.cs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 167da146e..83ba1645b 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -178,6 +178,29 @@ private static string htmlEncode (string s) return buff.ToString (); } + private static string htmlEncode (string s, bool attribute) + { + var buff = new StringBuilder (); + + foreach (var c in s) { + buff.Append ( + c == '"' + ? """ + : c == '&' + ? "&" + : c == '<' + ? "<" + : c == '>' + ? ">" + : !attribute && c > 159 + ? String.Format ("&#{0};", (int) c) + : c.ToString () + ); + } + + return buff.ToString (); + } + private static void initEntities () { // Build the dictionary of HTML entity references. From a1d0d361852980a0784b4655e7e696d319d87563 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 2 Oct 2018 19:46:05 +0900 Subject: [PATCH 2147/6294] [Modify] Replace it --- websocket-sharp/Net/HttpUtility.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 83ba1645b..28177f927 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -889,7 +889,7 @@ public static string HtmlAttributeEncode (string s) if (s == null) throw new ArgumentNullException ("s"); - return s.Length > 0 ? htmlAttributeEncode (s) : s; + return s.Length > 0 ? htmlEncode (s, true) : s; } public static void HtmlAttributeEncode (string s, TextWriter output) From f073aaaa6c8bcd243f60f15aee77a64fa549df51 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 2 Oct 2018 19:49:45 +0900 Subject: [PATCH 2148/6294] [Modify] Replace it --- websocket-sharp/Net/HttpUtility.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 28177f927..68273fc06 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -903,7 +903,7 @@ public static void HtmlAttributeEncode (string s, TextWriter output) if (s.Length == 0) return; - output.Write (htmlAttributeEncode (s)); + output.Write (htmlEncode (s, true)); } /// From 4fb204efc92414f541b4dcc36de148d0127c56e3 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 2 Oct 2018 19:51:31 +0900 Subject: [PATCH 2149/6294] [Modify] Remove it --- websocket-sharp/Net/HttpUtility.cs | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 68273fc06..61654737a 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -134,27 +134,6 @@ private static int getInt (byte b) : -1; } - private static string htmlAttributeEncode (string s) - { - var buff = new StringBuilder (); - - foreach (var c in s) { - buff.Append ( - c == '"' - ? """ - : c == '&' - ? "&" - : c == '<' - ? "<" - : c == '>' - ? ">" - : c.ToString () - ); - } - - return buff.ToString (); - } - private static string htmlEncode (string s) { var buff = new StringBuilder (); From e863edbf2cccae4d5708760d81a787350156be57 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 3 Oct 2018 19:37:26 +0900 Subject: [PATCH 2150/6294] [Modify] Replace it --- websocket-sharp/Net/HttpUtility.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 61654737a..21287ab7a 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -1029,7 +1029,7 @@ public static string HtmlEncode (string s) if (s == null) throw new ArgumentNullException ("s"); - return s.Length > 0 ? htmlEncode (s) : s; + return s.Length > 0 ? htmlEncode (s, false) : s; } public static void HtmlEncode (string s, TextWriter output) From 15492436bb7856ae0d2e0bb93ca036ef26013870 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 4 Oct 2018 20:12:47 +0900 Subject: [PATCH 2151/6294] [Modify] Replace it --- websocket-sharp/Net/HttpUtility.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 21287ab7a..8fdb46d2f 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -1043,7 +1043,7 @@ public static void HtmlEncode (string s, TextWriter output) if (s.Length == 0) return; - output.Write (htmlEncode (s)); + output.Write (htmlEncode (s, false)); } public static string UrlDecode (string s) From bdfbd7d6849fb4b8b95f4e4866f4748a190c7ded Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 5 Oct 2018 20:09:35 +0900 Subject: [PATCH 2152/6294] [Modify] Remove it --- websocket-sharp/Net/HttpUtility.cs | 23 ----------------------- 1 file changed, 23 deletions(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 8fdb46d2f..da3ea74eb 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -134,29 +134,6 @@ private static int getInt (byte b) : -1; } - private static string htmlEncode (string s) - { - var buff = new StringBuilder (); - - foreach (var c in s) { - buff.Append ( - c == '"' - ? """ - : c == '&' - ? "&" - : c == '<' - ? "<" - : c == '>' - ? ">" - : c > 159 - ? String.Format ("&#{0};", (int) c) - : c.ToString () - ); - } - - return buff.ToString (); - } - private static string htmlEncode (string s, bool attribute) { var buff = new StringBuilder (); From f350ac4078ea6e8b3d7304b8e722797ab4f588ab Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 6 Oct 2018 20:26:56 +0900 Subject: [PATCH 2153/6294] [Modify] Remove it --- websocket-sharp/Net/HttpUtility.cs | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index da3ea74eb..f2afb5771 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -475,18 +475,6 @@ private static bool isUnreservedInRfc3986 (char c) || c == '~'; } - private static bool notEncoded (char c) - { - return c == '!' || - c == '\'' || - c == '(' || - c == ')' || - c == '*' || - c == '-' || - c == '.' || - c == '_'; - } - private static void urlEncode (byte b, Stream output) { if (b > 31 && b < 127) { From 5c7a868514f4ac2d06fdae47b7127edf5ff7fc0b Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 7 Oct 2018 20:14:15 +0900 Subject: [PATCH 2154/6294] [Modify] Polish it --- websocket-sharp/Net/HttpUtility.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index f2afb5771..d24db06d6 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -134,7 +134,7 @@ private static int getInt (byte b) : -1; } - private static string htmlEncode (string s, bool attribute) + private static string htmlEncode (string s, bool minimal) { var buff = new StringBuilder (); @@ -148,7 +148,7 @@ private static string htmlEncode (string s, bool attribute) ? "<" : c == '>' ? ">" - : !attribute && c > 159 + : !minimal && c > 159 ? String.Format ("&#{0};", (int) c) : c.ToString () ); From 9e53823de30babd89151b1042d6e2aa72e44ead7 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 8 Oct 2018 21:10:15 +0900 Subject: [PATCH 2155/6294] [Modify] Add it --- websocket-sharp/Net/HttpUtility.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index d24db06d6..0317cc4d5 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -134,6 +134,17 @@ private static int getInt (byte b) : -1; } + private static int getNumber (char c) + { + return c >= '0' && c <= '9' + ? c - '0' + : c >= 'A' && c <= 'F' + ? c - 'A' + 10 + : c >= 'a' && c <= 'f' + ? c - 'a' + 10 + : -1; + } + private static string htmlEncode (string s, bool minimal) { var buff = new StringBuilder (); From 1eeb90a09b4f5f0c43630839e8c80806b3213c41 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 9 Oct 2018 20:43:13 +0900 Subject: [PATCH 2156/6294] [Modify] Add it --- websocket-sharp/Net/HttpUtility.cs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 0317cc4d5..920dbb4db 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -145,6 +145,22 @@ private static int getNumber (char c) : -1; } + private static int getNumber (string s, int offset, int count) + { + var ret = 0; + + var end = offset + count - 1; + for (var i = offset; i <= end; i++) { + var num = getNumber (s[i]); + if (num == -1) + return -1; + + ret = (ret << 4) + num; + } + + return ret; + } + private static string htmlEncode (string s, bool minimal) { var buff = new StringBuilder (); From 79d8f4a6842f583b5c521cc73661918a3c305cb2 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 10 Oct 2018 19:41:38 +0900 Subject: [PATCH 2157/6294] [Modify] Add it --- websocket-sharp/Net/HttpUtility.cs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 920dbb4db..6cadb7488 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -145,6 +145,22 @@ private static int getNumber (char c) : -1; } + private static int getNumber (byte[] bytes, int offset, int count) + { + var ret = 0; + + var end = offset + count - 1; + for (var i = offset; i <= end; i++) { + var num = getNumber ((char) bytes[i]); + if (num == -1) + return -1; + + ret = (ret << 4) + num; + } + + return ret; + } + private static int getNumber (string s, int offset, int count) { var ret = 0; From 4f48f357a590fc766d7e6e26723868b82e6aeac5 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 11 Oct 2018 20:27:02 +0900 Subject: [PATCH 2158/6294] [Modify] Add it --- websocket-sharp/Net/HttpUtility.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 6cadb7488..24d7f0f21 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -518,6 +518,17 @@ private static bool isUnreservedInRfc3986 (char c) || c == '~'; } + private static void urlDecode (byte[] bytes, int offset, Stream output) + { + var num = getNumber (bytes, offset + 1, 2); + if (num == -1) { + output.Write (bytes, offset, 3); + return; + } + + output.WriteByte ((byte) num); + } + private static void urlEncode (byte b, Stream output) { if (b > 31 && b < 127) { From 2a6010ee544d34031b3cf4eeb055698ec9817fcc Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 12 Oct 2018 20:11:45 +0900 Subject: [PATCH 2159/6294] [Modify] Add it --- websocket-sharp/Net/HttpUtility.cs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 24d7f0f21..53919a8df 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -529,6 +529,20 @@ private static void urlDecode (byte[] bytes, int offset, Stream output) output.WriteByte ((byte) num); } + private static void urlDecodeUnicode ( + byte[] bytes, int offset, Stream output + ) + { + var num = getNumber (bytes, offset + 2, 4); + if (num == -1) { + output.Write (bytes, offset, 6); + return; + } + + var decoded = Encoding.Unicode.GetBytes (new[] { (char) num }); + output.Write (decoded, 0, decoded.Length); + } + private static void urlEncode (byte b, Stream output) { if (b > 31 && b < 127) { From 00a7de1508b163bf7e27baadf81532b44d1b6380 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 13 Oct 2018 20:33:31 +0900 Subject: [PATCH 2160/6294] [Modify] Throw exception --- websocket-sharp/Net/HttpUtility.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 53919a8df..1887a07d9 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -1161,8 +1161,11 @@ public static string UrlDecode (byte[] bytes, int offset, int count, Encoding en public static byte[] UrlDecodeToBytes (byte[] bytes) { - int len; - return bytes != null && (len = bytes.Length) > 0 + if (bytes == null) + throw new ArgumentNullException ("bytes"); + + var len = bytes.Length; + return len > 0 ? InternalUrlDecodeToBytes (bytes, 0, len) : bytes; } From 90e5db72f26d7ad7499f3919b2b811c7bce93aba Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 14 Oct 2018 18:17:52 +0900 Subject: [PATCH 2161/6294] [Modify] Throw exception --- websocket-sharp/Net/HttpUtility.cs | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 1887a07d9..584818c5e 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -1189,20 +1189,26 @@ public static byte[] UrlDecodeToBytes (string s, Encoding encoding) public static byte[] UrlDecodeToBytes (byte[] bytes, int offset, int count) { - int len; - if (bytes == null || (len = bytes.Length) == 0) - return bytes; + if (bytes == null) + throw new ArgumentNullException ("bytes"); - if (count == 0) - return new byte[0]; + var len = bytes.Length; + if (len == 0) { + if (offset != 0 || count != 0) + throw new ArgumentException ("An empty byte array.", "bytes"); + + return bytes; + } if (offset < 0 || offset >= len) throw new ArgumentOutOfRangeException ("offset"); - if (count < 0 || count > len - offset ) + if (count < 0 || count > len - offset) throw new ArgumentOutOfRangeException ("count"); - return InternalUrlDecodeToBytes (bytes, offset, count); + return count > 0 + ? InternalUrlDecodeToBytes (bytes, offset, count) + : new byte[0]; } public static string UrlEncode (byte[] bytes) From 6bb744abf5e2b05415267d1751e66de0b10deece Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 15 Oct 2018 19:48:16 +0900 Subject: [PATCH 2162/6294] [Modify] Throw ArgumentOutOfRangeException --- websocket-sharp/Net/HttpUtility.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 584818c5e..b859fab37 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -1194,8 +1194,11 @@ public static byte[] UrlDecodeToBytes (byte[] bytes, int offset, int count) var len = bytes.Length; if (len == 0) { - if (offset != 0 || count != 0) - throw new ArgumentException ("An empty byte array.", "bytes"); + if (offset != 0) + throw new ArgumentOutOfRangeException ("offset"); + + if (count != 0) + throw new ArgumentOutOfRangeException ("count"); return bytes; } From fdec69827332cbc573a05cea384874dc93268d6c Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 16 Oct 2018 19:37:45 +0900 Subject: [PATCH 2163/6294] [Modify] Throw ArgumentOutOfRangeException --- websocket-sharp/Net/HttpUtility.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index b859fab37..94b1946b8 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -1234,8 +1234,11 @@ public static string UrlEncode (byte[] bytes, int offset, int count) var len = bytes.Length; if (len == 0) { - if (offset != 0 || count != 0) - throw new ArgumentException ("An empty byte array.", "bytes"); + if (offset != 0) + throw new ArgumentOutOfRangeException ("offset"); + + if (count != 0) + throw new ArgumentOutOfRangeException ("count"); return String.Empty; } From 3a82d3092158aad74e7801b9e3d4b14957ac4fa0 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 17 Oct 2018 19:35:42 +0900 Subject: [PATCH 2164/6294] [Modify] Throw ArgumentOutOfRangeException --- websocket-sharp/Net/HttpUtility.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 94b1946b8..e19eb6abc 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -1299,8 +1299,11 @@ public static byte[] UrlEncodeToBytes (byte[] bytes, int offset, int count) var len = bytes.Length; if (len == 0) { - if (offset != 0 || count != 0) - throw new ArgumentException ("An empty byte array.", "bytes"); + if (offset != 0) + throw new ArgumentOutOfRangeException ("offset"); + + if (count != 0) + throw new ArgumentOutOfRangeException ("count"); return bytes; } From 157528acf72b33a003ab94b34d1be509e370221a Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 18 Oct 2018 19:40:00 +0900 Subject: [PATCH 2165/6294] [Modify] Throw exception --- websocket-sharp/Net/HttpUtility.cs | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index e19eb6abc..4c2f5e17d 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -1141,14 +1141,23 @@ public static string UrlDecode (byte[] bytes, Encoding encoding) : InternalUrlDecode (bytes, 0, len, encoding ?? Encoding.UTF8); } - public static string UrlDecode (byte[] bytes, int offset, int count, Encoding encoding) + public static string UrlDecode ( + byte[] bytes, int offset, int count, Encoding encoding + ) { if (bytes == null) - return null; + throw new ArgumentNullException ("bytes"); var len = bytes.Length; - if (len == 0 || count == 0) + if (len == 0) { + if (offset != 0) + throw new ArgumentOutOfRangeException ("offset"); + + if (count != 0) + throw new ArgumentOutOfRangeException ("count"); + return String.Empty; + } if (offset < 0 || offset >= len) throw new ArgumentOutOfRangeException ("offset"); @@ -1156,7 +1165,11 @@ public static string UrlDecode (byte[] bytes, int offset, int count, Encoding en if (count < 0 || count > len - offset) throw new ArgumentOutOfRangeException ("count"); - return InternalUrlDecode (bytes, offset, count, encoding ?? Encoding.UTF8); + return count > 0 + ? InternalUrlDecode ( + bytes, offset, count, encoding ?? Encoding.UTF8 + ) + : String.Empty; } public static byte[] UrlDecodeToBytes (byte[] bytes) From def38ed52d1aac43241741e6691a4ae3ea9ac64c Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 19 Oct 2018 19:38:43 +0900 Subject: [PATCH 2166/6294] [Modify] Throw exception --- websocket-sharp/Net/HttpUtility.cs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 4c2f5e17d..35ed58eb4 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -1133,12 +1133,13 @@ public static string UrlDecode (string s, Encoding encoding) public static string UrlDecode (byte[] bytes, Encoding encoding) { - int len; - return bytes == null - ? null - : (len = bytes.Length) == 0 - ? String.Empty - : InternalUrlDecode (bytes, 0, len, encoding ?? Encoding.UTF8); + if (bytes == null) + throw new ArgumentNullException ("bytes"); + + var len = bytes.Length; + return len > 0 + ? InternalUrlDecode (bytes, 0, len, encoding ?? Encoding.UTF8) + : String.Empty; } public static string UrlDecode ( From b79ae8bcd818c0bc5afc9a3aca0339b15a37a6c7 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 20 Oct 2018 20:50:02 +0900 Subject: [PATCH 2167/6294] [Modify] Add it --- websocket-sharp/Net/HttpUtility.cs | 31 ++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 35ed58eb4..26fd90e11 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -529,6 +529,37 @@ private static void urlDecode (byte[] bytes, int offset, Stream output) output.WriteByte ((byte) num); } + private static byte[] urlDecodeToBytes (byte[] bytes, int offset, int count) + { + using (var buff = new MemoryStream ()) { + var end = offset + count - 1; + for (var i = offset; i <= end; i++) { + var b = bytes[i]; + if (b == '%') { + if (i > end - 2) { + buff.Write (bytes, i, end - i + 1); + break; + } + + urlDecode (bytes, i, buff); + i += 2; + + continue; + } + + if (b == '+') { + buff.WriteByte ((byte) ' '); + continue; + } + + buff.WriteByte (b); + } + + buff.Close (); + return buff.ToArray (); + } + } + private static void urlDecodeUnicode ( byte[] bytes, int offset, Stream output ) From 5ea12c5eca0f2733467cfe3a1716e276ba685a75 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 21 Oct 2018 22:10:07 +0900 Subject: [PATCH 2168/6294] [Modify] Replace it --- websocket-sharp/Net/HttpUtility.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 26fd90e11..ff2425410 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -1255,7 +1255,7 @@ public static byte[] UrlDecodeToBytes (byte[] bytes, int offset, int count) throw new ArgumentOutOfRangeException ("count"); return count > 0 - ? InternalUrlDecodeToBytes (bytes, offset, count) + ? urlDecodeToBytes (bytes, offset, count) : new byte[0]; } From 11c1d3cad42a33068bcc38dee3b8e90e12ce3243 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 22 Oct 2018 19:34:10 +0900 Subject: [PATCH 2169/6294] [Modify] Replace it --- websocket-sharp/Net/HttpUtility.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index ff2425410..5b5790f1f 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -1211,7 +1211,7 @@ public static byte[] UrlDecodeToBytes (byte[] bytes) var len = bytes.Length; return len > 0 - ? InternalUrlDecodeToBytes (bytes, 0, len) + ? urlDecodeToBytes (bytes, 0, len) : bytes; } From 148b4ba8879f96cb1a42480b4a40fb16a6016b6d Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 23 Oct 2018 20:14:53 +0900 Subject: [PATCH 2170/6294] [Modify] Replace it --- websocket-sharp/Net/HttpUtility.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 5b5790f1f..1fb897305 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -1197,10 +1197,11 @@ public static string UrlDecode ( if (count < 0 || count > len - offset) throw new ArgumentOutOfRangeException ("count"); + if (encoding == null) + encoding = Encoding.UTF8; + return count > 0 - ? InternalUrlDecode ( - bytes, offset, count, encoding ?? Encoding.UTF8 - ) + ? encoding.GetString (urlDecodeToBytes (bytes, offset, count)) : String.Empty; } From e4789e56a651e27bd393ef7b8f01fbbfd07012cd Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 24 Oct 2018 19:51:51 +0900 Subject: [PATCH 2171/6294] [Modify] Replace it --- websocket-sharp/Net/HttpUtility.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 1fb897305..9cf8a9539 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -1169,7 +1169,9 @@ public static string UrlDecode (byte[] bytes, Encoding encoding) var len = bytes.Length; return len > 0 - ? InternalUrlDecode (bytes, 0, len, encoding ?? Encoding.UTF8) + ? (encoding ?? Encoding.UTF8).GetString ( + urlDecodeToBytes (bytes, 0, len) + ) : String.Empty; } From 551a7ab7bfcc6eee7a90171228e0baba7996345c Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 25 Oct 2018 19:45:48 +0900 Subject: [PATCH 2172/6294] [Modify] Polish it --- websocket-sharp/Net/HttpUtility.cs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 9cf8a9539..cedee8d75 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -1199,11 +1199,10 @@ public static string UrlDecode ( if (count < 0 || count > len - offset) throw new ArgumentOutOfRangeException ("count"); - if (encoding == null) - encoding = Encoding.UTF8; - return count > 0 - ? encoding.GetString (urlDecodeToBytes (bytes, offset, count)) + ? (encoding ?? Encoding.UTF8).GetString ( + urlDecodeToBytes (bytes, offset, count) + ) : String.Empty; } From 5092a2ff3a5fe8558e5965715bbe0a328ac7c4ef Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 26 Oct 2018 20:13:57 +0900 Subject: [PATCH 2173/6294] [Modify] Remove it --- websocket-sharp/Net/HttpUtility.cs | 51 ------------------------------ 1 file changed, 51 deletions(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index cedee8d75..c140efb3c 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -806,57 +806,6 @@ internal static Encoding GetEncoding (string contentType) return null; } - internal static string InternalUrlDecode ( - byte[] bytes, int offset, int count, Encoding encoding) - { - var output = new StringBuilder (); - using (var acc = new MemoryStream ()) { - var end = count + offset; - for (var i = offset; i < end; i++) { - if (bytes[i] == '%' && i + 2 < count && bytes[i + 1] != '%') { - int xchar; - if (bytes[i + 1] == (byte) 'u' && i + 5 < end) { - if (acc.Length > 0) { - output.Append (getChars (acc, encoding)); - acc.SetLength (0); - } - - xchar = getChar (bytes, i + 2, 4); - if (xchar != -1) { - output.Append ((char) xchar); - i += 5; - - continue; - } - } - else if ((xchar = getChar (bytes, i + 1, 2)) != -1) { - acc.WriteByte ((byte) xchar); - i += 2; - - continue; - } - } - - if (acc.Length > 0) { - output.Append (getChars (acc, encoding)); - acc.SetLength (0); - } - - if (bytes[i] == '+') { - output.Append (' '); - continue; - } - - output.Append ((char) bytes[i]); - } - - if (acc.Length > 0) - output.Append (getChars (acc, encoding)); - } - - return output.ToString (); - } - internal static byte[] InternalUrlDecodeToBytes (byte[] bytes, int offset, int count) { using (var res = new MemoryStream ()) { From d4399f618836818135b180500ff20a71498d48a7 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 27 Oct 2018 20:59:36 +0900 Subject: [PATCH 2174/6294] [Modify] Remove it --- websocket-sharp/Net/HttpUtility.cs | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index c140efb3c..72ca95944 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -560,20 +560,6 @@ private static byte[] urlDecodeToBytes (byte[] bytes, int offset, int count) } } - private static void urlDecodeUnicode ( - byte[] bytes, int offset, Stream output - ) - { - var num = getNumber (bytes, offset + 2, 4); - if (num == -1) { - output.Write (bytes, offset, 6); - return; - } - - var decoded = Encoding.Unicode.GetBytes (new[] { (char) num }); - output.Write (decoded, 0, decoded.Length); - } - private static void urlEncode (byte b, Stream output) { if (b > 31 && b < 127) { From b2b5a71c758a84356923578386bb558c97311a95 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 28 Oct 2018 21:19:40 +0900 Subject: [PATCH 2175/6294] [Modify] Add it --- websocket-sharp/Ext.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 5e42b235c..c43d946bc 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1167,6 +1167,11 @@ internal static bool Upgrades ( && headers.Contains ("Connection", "Upgrade", comparison); } + internal static string UrlEncode (this string value, Encoding encoding) + { + return HttpUtility.UrlEncode (value, encoding); + } + internal static string UTF8Decode (this byte[] bytes) { try { From 4781f0b02579b26dfd75f1ef080a5683a96afc50 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 29 Oct 2018 20:58:37 +0900 Subject: [PATCH 2176/6294] [Modify] Add it --- websocket-sharp/Ext.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index c43d946bc..1857bb7ed 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1167,6 +1167,11 @@ internal static bool Upgrades ( && headers.Contains ("Connection", "Upgrade", comparison); } + internal static string UrlDecode (this string value, Encoding encoding) + { + return HttpUtility.UrlDecode (value, encoding); + } + internal static string UrlEncode (this string value, Encoding encoding) { return HttpUtility.UrlEncode (value, encoding); From a878d410d32d828b202788bafe5e510326960d1c Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 30 Oct 2018 20:24:06 +0900 Subject: [PATCH 2177/6294] [Modify] Replace it --- websocket-sharp/Net/Cookie.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/Cookie.cs b/websocket-sharp/Net/Cookie.cs index fffc52730..03ec66877 100644 --- a/websocket-sharp/Net/Cookie.cs +++ b/websocket-sharp/Net/Cookie.cs @@ -670,7 +670,7 @@ private string toResponseStringVersion1 () } if (!_comment.IsNullOrEmpty ()) - output.AppendFormat ("; Comment={0}", _comment.UrlEncode ()); + output.AppendFormat ("; Comment={0}", HttpUtility.UrlEncode (_comment)); if (_commentUri != null) { var url = _commentUri.OriginalString; From e1a5aca94a68731d5e35d9e7600c55c47c14df75 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 31 Oct 2018 20:17:39 +0900 Subject: [PATCH 2178/6294] [Modify] Replace it --- websocket-sharp/Net/CookieCollection.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/CookieCollection.cs b/websocket-sharp/Net/CookieCollection.cs index a4caada92..cbfe39fad 100644 --- a/websocket-sharp/Net/CookieCollection.cs +++ b/websocket-sharp/Net/CookieCollection.cs @@ -332,7 +332,7 @@ private static CookieCollection parseResponse (string value) } else if (pair.StartsWith ("comment", StringComparison.InvariantCultureIgnoreCase)) { if (cookie != null) - cookie.Comment = pair.GetValue ('=').UrlDecode (); + cookie.Comment = HttpUtility.UrlDecode (pair.GetValue ('=')); } else if (pair.StartsWith ("commenturl", StringComparison.InvariantCultureIgnoreCase)) { if (cookie != null) From 3a8d1d97c2fc431ae4032ce19077bb44177659ca Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 1 Nov 2018 19:37:54 +0900 Subject: [PATCH 2179/6294] [Modify] Remove it --- websocket-sharp/Ext.cs | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 1857bb7ed..fdcf00f20 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1993,23 +1993,6 @@ public static string UrlDecode (this string value) : value; } - /// - /// URL-encodes the specified . - /// - /// - /// A that receives the encoded string or - /// if it is or empty. - /// - /// - /// A to encode. - /// - public static string UrlEncode (this string value) - { - return value != null && value.Length > 0 - ? HttpUtility.UrlEncode (value) - : value; - } - /// /// Writes and sends the specified data with the specified /// . From bbc0bd486c9cee7a9c8b7c491cb068e189a1f001 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 2 Nov 2018 20:05:40 +0900 Subject: [PATCH 2180/6294] [Modify] Polish it --- websocket-sharp/Net/Cookie.cs | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/websocket-sharp/Net/Cookie.cs b/websocket-sharp/Net/Cookie.cs index 03ec66877..190d1b287 100644 --- a/websocket-sharp/Net/Cookie.cs +++ b/websocket-sharp/Net/Cookie.cs @@ -650,40 +650,42 @@ private string toResponseStringVersion0 () private string toResponseStringVersion1 () { - var output = new StringBuilder (64); - output.AppendFormat ("{0}={1}; Version={2}", _name, _value, _version); + var buff = new StringBuilder (64); + + buff.AppendFormat ("{0}={1}; Version={2}", _name, _value, _version); if (_expires != DateTime.MinValue) - output.AppendFormat ("; Max-Age={0}", MaxAge); + buff.AppendFormat ("; Max-Age={0}", MaxAge); if (!_path.IsNullOrEmpty ()) - output.AppendFormat ("; Path={0}", _path); + buff.AppendFormat ("; Path={0}", _path); if (!_domain.IsNullOrEmpty ()) - output.AppendFormat ("; Domain={0}", _domain); + buff.AppendFormat ("; Domain={0}", _domain); if (!_port.IsNullOrEmpty ()) { - if (_port == "\"\"") - output.Append ("; Port"); - else - output.AppendFormat ("; Port={0}", _port); + buff.Append ( + _port != "\"\"" ? String.Format ("; Port={0}", _port) : "; Port" + ); } if (!_comment.IsNullOrEmpty ()) - output.AppendFormat ("; Comment={0}", HttpUtility.UrlEncode (_comment)); + buff.AppendFormat ("; Comment={0}", HttpUtility.UrlEncode (_comment)); if (_commentUri != null) { var url = _commentUri.OriginalString; - output.AppendFormat ("; CommentURL={0}", url.IsToken () ? url : url.Quote ()); + buff.AppendFormat ( + "; CommentURL={0}", !url.IsToken () ? url.Quote () : url + ); } if (_discard) - output.Append ("; Discard"); + buff.Append ("; Discard"); if (_secure) - output.Append ("; Secure"); + buff.Append ("; Secure"); - return output.ToString (); + return buff.ToString (); } private static bool tryCreatePorts (string value, out int[] result, out string parseError) From 03f10fff423eb0bce575b9c9a3716d78f09ed393 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 3 Nov 2018 21:36:11 +0900 Subject: [PATCH 2181/6294] [Modify] Remove it --- websocket-sharp/Ext.cs | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index fdcf00f20..bed790ec1 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1976,23 +1976,6 @@ public static Uri ToUri (this string value) return ret; } - /// - /// URL-decodes the specified . - /// - /// - /// A that receives the decoded string or - /// if it is or empty. - /// - /// - /// A to decode. - /// - public static string UrlDecode (this string value) - { - return value != null && value.Length > 0 - ? HttpUtility.UrlDecode (value) - : value; - } - /// /// Writes and sends the specified data with the specified /// . From b922bd7cbdbc431201f0b765c22c9e3285d8ea00 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 4 Nov 2018 21:49:36 +0900 Subject: [PATCH 2182/6294] [Modify] Throw exception --- websocket-sharp/Net/HttpUtility.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 72ca95944..02cbcd255 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -1160,7 +1160,7 @@ public static byte[] UrlDecodeToBytes (string s) public static byte[] UrlDecodeToBytes (string s, Encoding encoding) { if (s == null) - return null; + throw new ArgumentNullException ("s"); if (s.Length == 0) return new byte[0]; From 76a2796d85ef67f35c6efdf665a9fc9aa1750c2b Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 5 Nov 2018 20:10:08 +0900 Subject: [PATCH 2183/6294] [Modify] Replace it --- websocket-sharp/Net/HttpUtility.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 02cbcd255..7bef53659 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -1154,7 +1154,14 @@ public static byte[] UrlDecodeToBytes (byte[] bytes) public static byte[] UrlDecodeToBytes (string s) { - return UrlDecodeToBytes (s, Encoding.UTF8); + if (s == null) + throw new ArgumentNullException ("s"); + + if (s.Length == 0) + return new byte[0]; + + var bytes = Encoding.ASCII.GetBytes (s); + return urlDecodeToBytes (bytes, 0, bytes.Length); } public static byte[] UrlDecodeToBytes (string s, Encoding encoding) From ce5a6f6e4a0c134693e70d1baf78f2139d0ed45c Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 6 Nov 2018 20:32:51 +0900 Subject: [PATCH 2184/6294] [Modify] Remove it --- websocket-sharp/Net/HttpUtility.cs | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 7bef53659..cc4d4ce4e 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -1164,18 +1164,6 @@ public static byte[] UrlDecodeToBytes (string s) return urlDecodeToBytes (bytes, 0, bytes.Length); } - public static byte[] UrlDecodeToBytes (string s, Encoding encoding) - { - if (s == null) - throw new ArgumentNullException ("s"); - - if (s.Length == 0) - return new byte[0]; - - var bytes = (encoding ?? Encoding.UTF8).GetBytes (s); - return InternalUrlDecodeToBytes (bytes, 0, bytes.Length); - } - public static byte[] UrlDecodeToBytes (byte[] bytes, int offset, int count) { if (bytes == null) From ef3a57aba28c1a54e0fe25e417053c44c4a830ff Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 6 Nov 2018 20:37:20 +0900 Subject: [PATCH 2185/6294] [Modify] Remove it --- websocket-sharp/Net/HttpUtility.cs | 25 ------------------------- 1 file changed, 25 deletions(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index cc4d4ce4e..ba6ab8ef6 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -792,31 +792,6 @@ internal static Encoding GetEncoding (string contentType) return null; } - internal static byte[] InternalUrlDecodeToBytes (byte[] bytes, int offset, int count) - { - using (var res = new MemoryStream ()) { - var end = offset + count; - for (var i = offset; i < end; i++) { - var c = (char) bytes[i]; - if (c == '+') { - c = ' '; - } - else if (c == '%' && i < end - 2) { - var xchar = getChar (bytes, i + 1, 2); - if (xchar != -1) { - c = (char) xchar; - i += 2; - } - } - - res.WriteByte ((byte) c); - } - - res.Close (); - return res.ToArray (); - } - } - internal static byte[] InternalUrlEncodeToBytes ( byte[] bytes, int offset, int count ) From e8fee4f3c16e974bdf634f8ecbe7eb4a73f6db53 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 7 Nov 2018 19:46:04 +0900 Subject: [PATCH 2186/6294] [Modify] Remove it --- websocket-sharp/Net/HttpUtility.cs | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index ba6ab8ef6..b74c65718 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -1288,16 +1288,6 @@ public static byte[] UrlEncodeToBytes (string s, Encoding encoding) return InternalUrlEncodeToBytes (bytes, 0, bytes.Length); } - public static string UrlEncodeUnicode (string s) - { - if (s == null) - throw new ArgumentNullException ("s"); - - return s.Length > 0 - ? Encoding.ASCII.GetString (InternalUrlEncodeUnicodeToBytes (s)) - : s; - } - public static byte[] UrlEncodeUnicodeToBytes (string s) { if (s == null) From 8f452670b5780d5ea4baa3a108ced0feb4278c60 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 7 Nov 2018 19:47:23 +0900 Subject: [PATCH 2187/6294] [Modify] Remove it --- websocket-sharp/Net/HttpUtility.cs | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index b74c65718..347bb04d8 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -1288,16 +1288,6 @@ public static byte[] UrlEncodeToBytes (string s, Encoding encoding) return InternalUrlEncodeToBytes (bytes, 0, bytes.Length); } - public static byte[] UrlEncodeUnicodeToBytes (string s) - { - if (s == null) - throw new ArgumentNullException ("s"); - - return s.Length > 0 - ? InternalUrlEncodeUnicodeToBytes (s) - : new byte[0]; - } - public static string UrlPathEncode (string s) { if (s == null) From 5f01dfe31fc68a15aa94d37aa4ec5f8c103078e2 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 7 Nov 2018 19:49:27 +0900 Subject: [PATCH 2188/6294] [Modify] Remove it --- websocket-sharp/Net/HttpUtility.cs | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 347bb04d8..5045c9ba3 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -806,17 +806,6 @@ internal static byte[] InternalUrlEncodeToBytes ( } } - internal static byte[] InternalUrlEncodeUnicodeToBytes (string s) - { - using (var buff = new MemoryStream ()) { - foreach (var c in s) - urlEncodeUnicode (c, buff); - - buff.Close (); - return buff.ToArray (); - } - } - internal static bool TryGetEncoding ( string contentType, out Encoding result ) From b7a095a445d6c994c03946bce22848933b7aff27 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 8 Nov 2018 19:45:52 +0900 Subject: [PATCH 2189/6294] [Modify] Add it --- websocket-sharp/Net/HttpUtility.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 5045c9ba3..4bc8b15e2 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -594,6 +594,18 @@ private static void urlEncode (byte b, Stream output) output.WriteByte ((byte) _hexChars[idx]); } + private static byte[] urlEncodeToBytes (byte[] bytes, int offset, int count) + { + using (var buff = new MemoryStream ()) { + var end = offset + count - 1; + for (var i = offset; i <= end; i++) + urlEncode (bytes[i], buff); + + buff.Close (); + return buff.ToArray (); + } + } + private static void urlEncodeUnicode (char c, Stream output) { if (c > 31 && c < 127) { From b6d1db7af676292c0997468d94f11d1f76e04aa8 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 8 Nov 2018 19:49:53 +0900 Subject: [PATCH 2190/6294] [Modify] Replace it --- websocket-sharp/Net/HttpUtility.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 4bc8b15e2..df3e1cbbe 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -1174,9 +1174,7 @@ public static string UrlEncode (byte[] bytes) var len = bytes.Length; return len > 0 - ? Encoding.ASCII.GetString ( - InternalUrlEncodeToBytes (bytes, 0, len) - ) + ? Encoding.ASCII.GetString (urlEncodeToBytes (bytes, 0, len)) : String.Empty; } From 7658875c6d0c64704fdebfc29db809f829eea085 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 8 Nov 2018 19:52:58 +0900 Subject: [PATCH 2191/6294] [Modify] Replace it --- websocket-sharp/Net/HttpUtility.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index df3e1cbbe..19673a6fb 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -1202,7 +1202,7 @@ public static string UrlEncode (byte[] bytes, int offset, int count) return count > 0 ? Encoding.ASCII.GetString ( - InternalUrlEncodeToBytes (bytes, offset, count) + urlEncodeToBytes (bytes, offset, count) ) : String.Empty; } From ea92e7f7ad5fd01ec704d7ab0ddc09dc0476e70a Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 8 Nov 2018 19:55:45 +0900 Subject: [PATCH 2192/6294] [Modify] Replace it --- websocket-sharp/Net/HttpUtility.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 19673a6fb..3e771cf5c 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -1227,9 +1227,7 @@ public static string UrlEncode (string s, Encoding encoding) var bytes = new byte[encoding.GetMaxByteCount (len)]; var realLen = encoding.GetBytes (s, 0, len, bytes, 0); - return Encoding.ASCII.GetString ( - InternalUrlEncodeToBytes (bytes, 0, realLen) - ); + return Encoding.ASCII.GetString (urlEncodeToBytes (bytes, 0, realLen)); } public static byte[] UrlEncodeToBytes (byte[] bytes) From f7acef9cc127125c1f331a3a7bc08e3e1b87a1f6 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 8 Nov 2018 19:58:06 +0900 Subject: [PATCH 2193/6294] [Modify] Replace it --- websocket-sharp/Net/HttpUtility.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 3e771cf5c..a02eb0aa2 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -1236,9 +1236,7 @@ public static byte[] UrlEncodeToBytes (byte[] bytes) throw new ArgumentNullException ("bytes"); var len = bytes.Length; - return len > 0 - ? InternalUrlEncodeToBytes (bytes, 0, len) - : bytes; + return len > 0 ? urlEncodeToBytes (bytes, 0, len) : bytes; } public static byte[] UrlEncodeToBytes (byte[] bytes, int offset, int count) From f04b04ac4cc2e03e2015300af4d82ace1d342440 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 8 Nov 2018 20:01:21 +0900 Subject: [PATCH 2194/6294] [Modify] Replace it --- websocket-sharp/Net/HttpUtility.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index a02eb0aa2..85320967c 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -1261,9 +1261,7 @@ public static byte[] UrlEncodeToBytes (byte[] bytes, int offset, int count) if (count < 0 || count > len - offset) throw new ArgumentOutOfRangeException ("count"); - return count > 0 - ? InternalUrlEncodeToBytes (bytes, offset, count) - : new byte[0]; + return count > 0 ? urlEncodeToBytes (bytes, offset, count) : new byte[0]; } public static byte[] UrlEncodeToBytes (string s) From 2e673e0b0e95a5e830769b7f819a8f78465a314a Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 8 Nov 2018 20:03:46 +0900 Subject: [PATCH 2195/6294] [Modify] Replace it --- websocket-sharp/Net/HttpUtility.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 85320967c..0124dd699 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -1278,7 +1278,7 @@ public static byte[] UrlEncodeToBytes (string s, Encoding encoding) return new byte[0]; var bytes = (encoding ?? Encoding.UTF8).GetBytes (s); - return InternalUrlEncodeToBytes (bytes, 0, bytes.Length); + return urlEncodeToBytes (bytes, 0, bytes.Length); } public static string UrlPathEncode (string s) From ff1be47f2c5f813ecddc7b2ebcf82c379a6a552f Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 9 Nov 2018 19:54:42 +0900 Subject: [PATCH 2196/6294] [Modify] Remove it --- websocket-sharp/Net/HttpUtility.cs | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 0124dd699..df85dd604 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -804,20 +804,6 @@ internal static Encoding GetEncoding (string contentType) return null; } - internal static byte[] InternalUrlEncodeToBytes ( - byte[] bytes, int offset, int count - ) - { - using (var buff = new MemoryStream ()) { - var end = offset + count; - for (var i = offset; i < end; i++) - urlEncode (bytes[i], buff); - - buff.Close (); - return buff.ToArray (); - } - } - internal static bool TryGetEncoding ( string contentType, out Encoding result ) From f5e98d42c6a48df7faca5ec282120b656b05c32f Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 10 Nov 2018 16:46:49 +0900 Subject: [PATCH 2197/6294] [Modify] Polish it --- websocket-sharp/Net/HttpUtility.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index df85dd604..d49b986e8 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -563,22 +563,23 @@ private static byte[] urlDecodeToBytes (byte[] bytes, int offset, int count) private static void urlEncode (byte b, Stream output) { if (b > 31 && b < 127) { - if (b == 32) { + var c = (char) b; + if (c == ' ') { output.WriteByte ((byte) '+'); return; } - if (isNumeric (b)) { + if (isNumeric (c)) { output.WriteByte (b); return; } - if (isAlphabet (b)) { + if (isAlphabet (c)) { output.WriteByte (b); return; } - if (isUnreserved (b)) { + if (isUnreserved (c)) { output.WriteByte (b); return; } From a35bdbffbf20c6475d0f6c4fce40d2c528904e7a Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 11 Nov 2018 18:02:04 +0900 Subject: [PATCH 2198/6294] [Modify] Remove it --- websocket-sharp/Net/HttpUtility.cs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index d49b986e8..23e3b7175 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -471,11 +471,6 @@ private static bool isAlphabet (char c) || (c >= 'a' && c <= 'z'); } - private static bool isNumeric (byte b) - { - return b >= 48 && b <= 57; - } - private static bool isNumeric (char c) { return c >= '0' && c <= '9'; From c6ba225c41b9ad697194de9c4723101dff85dc19 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 11 Nov 2018 18:03:31 +0900 Subject: [PATCH 2199/6294] [Modify] Remove it --- websocket-sharp/Net/HttpUtility.cs | 6 ------ 1 file changed, 6 deletions(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 23e3b7175..1356bf1fc 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -459,12 +459,6 @@ private static void initEntities () _entities.Add ("euro", '\u20AC'); } - private static bool isAlphabet (byte b) - { - return (b >= 65 && b <= 90) - || (b >= 97 && b <= 122); - } - private static bool isAlphabet (char c) { return (c >= 'A' && c <= 'Z') From f32a2068ecb8f00ced963456b6e08b3bcff24291 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 11 Nov 2018 18:05:14 +0900 Subject: [PATCH 2200/6294] [Modify] Remove it --- websocket-sharp/Net/HttpUtility.cs | 8 -------- 1 file changed, 8 deletions(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 1356bf1fc..cac7fc492 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -470,14 +470,6 @@ private static bool isNumeric (char c) return c >= '0' && c <= '9'; } - private static bool isUnreserved (byte b) - { - return b == 42 - || b == 45 - || b == 46 - || b == 95; - } - private static bool isUnreserved (char c) { return c == '*' From 6eabf96229ce77db0384ae487055a4d521378869 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 12 Nov 2018 21:06:04 +0900 Subject: [PATCH 2201/6294] [Modify] Remove it --- websocket-sharp/Net/HttpUtility.cs | 41 ------------------------------ 1 file changed, 41 deletions(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index cac7fc492..3f5b4d68c 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -588,47 +588,6 @@ private static byte[] urlEncodeToBytes (byte[] bytes, int offset, int count) } } - private static void urlEncodeUnicode (char c, Stream output) - { - if (c > 31 && c < 127) { - if (c == ' ') { - output.WriteByte ((byte) '+'); - return; - } - - if (isNumeric (c)) { - output.WriteByte ((byte) c); - return; - } - - if (isAlphabet (c)) { - output.WriteByte ((byte) c); - return; - } - - if (isUnreserved (c)) { - output.WriteByte ((byte) c); - return; - } - } - - output.WriteByte ((byte) '%'); - output.WriteByte ((byte) 'u'); - - var i = (int) c; - var idx = i >> 12; - output.WriteByte ((byte) _hexChars[idx]); - - idx = (i >> 8) & 0x0F; - output.WriteByte ((byte) _hexChars[idx]); - - idx = (i >> 4) & 0x0F; - output.WriteByte ((byte) _hexChars[idx]); - - idx = i & 0x0F; - output.WriteByte ((byte) _hexChars[idx]); - } - private static void urlPathEncode (char c, StringBuilder output) { if (c > 32 && c < 127) { From 2fbac3f58137b07d6cc7757206b2ec7b5e26f27f Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 13 Nov 2018 19:47:24 +0900 Subject: [PATCH 2202/6294] [Modify] Polish it --- websocket-sharp/Net/HttpUtility.cs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 3f5b4d68c..bd0321488 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -569,11 +569,8 @@ private static void urlEncode (byte b, Stream output) output.WriteByte ((byte) '%'); var i = (int) b; - var idx = i >> 4; - output.WriteByte ((byte) _hexChars[idx]); - - idx = i & 0x0F; - output.WriteByte ((byte) _hexChars[idx]); + output.WriteByte ((byte) _hexChars[i >> 4]); + output.WriteByte ((byte) _hexChars[i & 0x0F]); } private static byte[] urlEncodeToBytes (byte[] bytes, int offset, int count) From dc7c8f0e2c52f5cf8b421ada143f3dfd1fdf9754 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 14 Nov 2018 19:58:45 +0900 Subject: [PATCH 2203/6294] [Modify] Polish it --- websocket-sharp/Net/HttpUtility.cs | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index bd0321488..ddc47a308 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -516,19 +516,29 @@ private static byte[] urlDecodeToBytes (byte[] bytes, int offset, int count) var end = offset + count - 1; for (var i = offset; i <= end; i++) { var b = bytes[i]; - if (b == '%') { + + var c = (char) b; + if (c == '%') { if (i > end - 2) { buff.Write (bytes, i, end - i + 1); break; } - urlDecode (bytes, i, buff); + var num = getNumber (bytes, i + 1, 2); + if (num == -1) { + buff.Write (bytes, i, 3); + i += 2; + + continue; + } + + buff.WriteByte ((byte) num); i += 2; continue; } - if (b == '+') { + if (c == '+') { buff.WriteByte ((byte) ' '); continue; } From ad2046a123e0181aafc4519c6dcbe65960d549ad Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 15 Nov 2018 20:02:28 +0900 Subject: [PATCH 2204/6294] [Modify] Remove it --- websocket-sharp/Net/HttpUtility.cs | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index ddc47a308..231073c7a 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -499,17 +499,6 @@ private static bool isUnreservedInRfc3986 (char c) || c == '~'; } - private static void urlDecode (byte[] bytes, int offset, Stream output) - { - var num = getNumber (bytes, offset + 1, 2); - if (num == -1) { - output.Write (bytes, offset, 3); - return; - } - - output.WriteByte ((byte) num); - } - private static byte[] urlDecodeToBytes (byte[] bytes, int offset, int count) { using (var buff = new MemoryStream ()) { From f2ceac67a4f3817a0e81e5151b5c2745e680bbed Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 16 Nov 2018 19:53:20 +0900 Subject: [PATCH 2205/6294] [Modify] Break if it cannot be decoded --- websocket-sharp/Net/HttpUtility.cs | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 231073c7a..e30982890 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -508,18 +508,12 @@ private static byte[] urlDecodeToBytes (byte[] bytes, int offset, int count) var c = (char) b; if (c == '%') { - if (i > end - 2) { - buff.Write (bytes, i, end - i + 1); + if (i > end - 2) break; - } var num = getNumber (bytes, i + 1, 2); - if (num == -1) { - buff.Write (bytes, i, 3); - i += 2; - - continue; - } + if (num == -1) + break; buff.WriteByte ((byte) num); i += 2; From 656a3e3839d1e52e534dcfefbfc425cacfe2988a Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 17 Nov 2018 21:39:02 +0900 Subject: [PATCH 2206/6294] [Modify] Do not decode --- websocket-sharp/Server/WebSocketServiceManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index 8706f58fe..902e55347 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -409,7 +409,7 @@ private bool canSet (out string message) internal void Add (string path, Func creator) where TBehavior : WebSocketBehavior { - path = HttpUtility.UrlDecode (path).TrimSlashFromEnd (); + path = path.TrimSlashFromEnd (); lock (_sync) { WebSocketServiceHost host; From c60ad8e5f24acab392c3aafa5f9757cbd3baec93 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 18 Nov 2018 21:37:36 +0900 Subject: [PATCH 2207/6294] [Modify] Do not decode --- websocket-sharp/Server/WebSocketServiceManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index 902e55347..da30dcc05 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -437,7 +437,7 @@ internal bool InternalTryGetServiceHost ( string path, out WebSocketServiceHost host ) { - path = HttpUtility.UrlDecode (path).TrimSlashFromEnd (); + path = path.TrimSlashFromEnd (); lock (_sync) return _hosts.TryGetValue (path, out host); From df435e6478b299a46902b7c6c73bb15361ce1d87 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 19 Nov 2018 21:25:34 +0900 Subject: [PATCH 2208/6294] [Modify] Do not decode --- websocket-sharp/Server/WebSocketServiceManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index da30dcc05..d6b618a72 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -542,7 +542,7 @@ public void AddService ( throw new ArgumentException (msg, "path"); } - path = HttpUtility.UrlDecode (path).TrimSlashFromEnd (); + path = path.TrimSlashFromEnd (); lock (_sync) { WebSocketServiceHost host; From 1419610792d93e2fd7c7d97b498f4d14ef94d9a1 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 20 Nov 2018 20:25:31 +0900 Subject: [PATCH 2209/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServiceManager.cs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index d6b618a72..0f1f56cfd 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -473,13 +473,14 @@ internal void Stop (ushort code, string reason) /// Adds a WebSocket service with the specified behavior, /// , and . /// - /// - /// is converted to a URL-decoded string and - /// / is trimmed from the end of the converted string if any. - /// /// - /// A that represents an absolute path to - /// the service to add. + /// + /// A that represents an absolute path to + /// the service to add. + /// + /// + /// / is trimmed from the end of the string if present. + /// /// /// /// From 7c13bba0c0af1b75b590c19ce50967918dedcd5b Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 21 Nov 2018 20:00:45 +0900 Subject: [PATCH 2210/6294] [Modify] Do not decode --- websocket-sharp/Server/WebSocketServiceManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index 0f1f56cfd..cc9ecda8b 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -985,7 +985,7 @@ public bool RemoveService (string path) throw new ArgumentException (msg, "path"); } - path = HttpUtility.UrlDecode (path).TrimSlashFromEnd (); + path = path.TrimSlashFromEnd (); WebSocketServiceHost host; lock (_sync) { From 2a3ad43b21fdfe502222ea687af758ed7fc6c897 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 21 Nov 2018 20:08:36 +0900 Subject: [PATCH 2211/6294] [Modify] Edit it --- .../Server/WebSocketServiceManager.cs | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index cc9ecda8b..351780dcd 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -931,22 +931,21 @@ public void Clear () /// Removes a WebSocket service with the specified . /// /// - /// - /// is converted to a URL-decoded string and - /// / is trimmed from the end of the converted string if any. - /// - /// - /// The service is stopped with close status 1001 (going away) - /// if it has already started. - /// + /// The service is stopped with close status 1001 (going away) + /// if it has already started. /// /// /// true if the service is successfully found and removed; /// otherwise, false. /// /// - /// A that represents an absolute path to - /// the service to remove. + /// + /// A that represents an absolute path to + /// the service to remove. + /// + /// + /// / is trimmed from the end of the string if present. + /// /// /// /// is . From 1880a1598bac826d679fea9a1389ddb514f3aa95 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 22 Nov 2018 20:06:49 +0900 Subject: [PATCH 2212/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServiceManager.cs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index 351780dcd..2a4536aa5 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -109,10 +109,6 @@ public IEnumerable Hosts { /// Gets the host instance for a WebSocket service with /// the specified . /// - /// - /// is converted to a URL-decoded string and - /// / is trimmed from the end of the converted string if any. - /// /// /// /// A instance or @@ -124,8 +120,13 @@ public IEnumerable Hosts { /// /// /// - /// A that represents an absolute path to - /// the service to find. + /// + /// A that represents an absolute path to + /// the service to find. + /// + /// + /// / is trimmed from the end of the string if present. + /// /// /// /// is . From c8f1ca210913e7363b570ad3f53ed7b9a146b505 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 23 Nov 2018 20:49:23 +0900 Subject: [PATCH 2213/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServiceManager.cs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index 2a4536aa5..5d9cad317 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -1005,17 +1005,18 @@ public bool RemoveService (string path) /// Tries to get the host instance for a WebSocket service with /// the specified . /// - /// - /// is converted to a URL-decoded string and - /// / is trimmed from the end of the converted string if any. - /// /// /// true if the service is successfully found; /// otherwise, false. /// /// - /// A that represents an absolute path to - /// the service to find. + /// + /// A that represents an absolute path to + /// the service to find. + /// + /// + /// / is trimmed from the end of the string if present. + /// /// /// /// From 0bbd8785156d65305fa65cb63971943a64f6f915 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 24 Nov 2018 21:50:30 +0900 Subject: [PATCH 2214/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServiceManager.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index 5d9cad317..f447efa41 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -106,8 +106,7 @@ public IEnumerable Hosts { } /// - /// Gets the host instance for a WebSocket service with - /// the specified . + /// Gets the host instance for a WebSocket service with the specified path. /// /// /// @@ -115,7 +114,7 @@ public IEnumerable Hosts { /// if not found. /// /// - /// That host instance provides the function to access + /// The host instance provides the function to access /// the information in the service. /// /// From d2f065ab55a0599bbf4c7489c4d39e1666e17d79 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 25 Nov 2018 18:01:45 +0900 Subject: [PATCH 2215/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServiceManager.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index f447efa41..39279f9b5 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -1002,11 +1002,11 @@ public bool RemoveService (string path) /// /// Tries to get the host instance for a WebSocket service with - /// the specified . + /// the specified path. /// /// - /// true if the service is successfully found; - /// otherwise, false. + /// true if the service is successfully found; otherwise, + /// false. /// /// /// @@ -1023,7 +1023,7 @@ public bool RemoveService (string path) /// instance or if not found. /// /// - /// That host instance provides the function to access + /// The host instance provides the function to access /// the information in the service. /// /// From 02a3bb7c14c12151286e9999de371ece5899619c Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 26 Nov 2018 22:35:49 +0900 Subject: [PATCH 2216/6294] [Modify] Edit it --- .../Server/WebSocketServiceManager.cs | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index 39279f9b5..fcd4f3880 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -470,8 +470,8 @@ internal void Stop (ushort code, string reason) #region Public Methods /// - /// Adds a WebSocket service with the specified behavior, - /// , and . + /// Adds a WebSocket service with the specified behavior, path, + /// and delegate. /// /// /// @@ -488,14 +488,20 @@ internal void Stop (ushort code, string reason) /// if not needed. /// /// - /// That delegate invokes the method called for initializing + /// The delegate invokes the method called when initializing /// a new session instance for the service. /// /// /// - /// The type of the behavior for the service. It must inherit - /// the class and it must have - /// a public parameterless constructor. + /// + /// The type of the behavior for the service. + /// + /// + /// It must inherit the class. + /// + /// + /// And also, it must have a public parameterless constructor. + /// /// /// /// is . From 9c4603605795a40a22897d69146a05b5d2632b1a Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 27 Nov 2018 19:39:28 +0900 Subject: [PATCH 2217/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServiceManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index fcd4f3880..ee1256fcf 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -934,7 +934,7 @@ public void Clear () } /// - /// Removes a WebSocket service with the specified . + /// Removes a WebSocket service with the specified path. /// /// /// The service is stopped with close status 1001 (going away) From 6d1eea5c4eb017c2e310721b080a8eefbf1c1f79 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 28 Nov 2018 19:39:56 +0900 Subject: [PATCH 2218/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index b1b7bf027..c42262207 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -1038,23 +1038,24 @@ private static bool tryCreateUri ( #region Public Methods /// - /// Adds a WebSocket service with the specified behavior, - /// , and . + /// Adds a WebSocket service with the specified behavior, path, + /// and delegate. /// - /// - /// is converted to a URL-decoded string and - /// '/' is trimmed from the end of the converted string if any. - /// /// - /// A that represents an absolute path to - /// the service to add. + /// + /// A that represents an absolute path to + /// the service to add. + /// + /// + /// / is trimmed from the end of the string if present. + /// /// /// /// /// A Func<TBehavior> delegate. /// /// - /// It invokes the method called for creating a new session + /// It invokes the method called when creating a new session /// instance for the service. /// /// From e72e68502f95c637a3e5b22b8582e7f001b2d3f4 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 29 Nov 2018 20:38:01 +0900 Subject: [PATCH 2219/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index c42262207..4d01351ef 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -1133,24 +1133,26 @@ public void AddWebSocketService ( } /// - /// Adds a WebSocket service with the specified behavior and - /// . + /// Adds a WebSocket service with the specified behavior and path. /// - /// - /// is converted to a URL-decoded string and - /// '/' is trimmed from the end of the converted string if any. - /// /// - /// A that represents an absolute path to - /// the service to add. + /// + /// A that represents an absolute path to + /// the service to add. + /// + /// + /// / is trimmed from the end of the string if present. + /// /// /// /// /// The type of the behavior for the service. /// /// - /// It must inherit the class and - /// have a public parameterless constructor. + /// It must inherit the class. + /// + /// + /// And also, it must have a public parameterless constructor. /// /// /// From 56a39a44cbb198cc484b033164f6cb88fd3cdf75 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 30 Nov 2018 17:35:15 +0900 Subject: [PATCH 2220/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 25 +++++++++++++---------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 4d01351ef..2d68ffd0c 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -1189,16 +1189,17 @@ public void AddWebSocketService (string path) } /// - /// Adds a WebSocket service with the specified behavior, - /// , and . + /// Adds a WebSocket service with the specified behavior, path, + /// and delegate. /// - /// - /// is converted to a URL-decoded string and - /// '/' is trimmed from the end of the converted string if any. - /// /// - /// A that represents an absolute path to - /// the service to add. + /// + /// A that represents an absolute path to + /// the service to add. + /// + /// + /// / is trimmed from the end of the string if present. + /// /// /// /// @@ -1206,7 +1207,7 @@ public void AddWebSocketService (string path) /// if not needed. /// /// - /// That delegate invokes the method called for initializing + /// The delegate invokes the method called when initializing /// a new session instance for the service. /// /// @@ -1215,8 +1216,10 @@ public void AddWebSocketService (string path) /// The type of the behavior for the service. /// /// - /// It must inherit the class and - /// have a public parameterless constructor. + /// It must inherit the class. + /// + /// + /// And also, it must have a public parameterless constructor. /// /// /// From d60c2a39ce940fdac07697df9b8dd3af4a219302 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 1 Dec 2018 17:14:16 +0900 Subject: [PATCH 2221/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 2d68ffd0c..665a5dbe2 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -1258,25 +1258,24 @@ public void AddWebSocketService ( } /// - /// Removes a WebSocket service with the specified . + /// Removes a WebSocket service with the specified path. /// /// - /// - /// is converted to a URL-decoded string and - /// '/' is trimmed from the end of the converted string if any. - /// - /// - /// The service is stopped with close status 1001 (going away) - /// if it has already started. - /// + /// The service is stopped with close status 1001 (going away) + /// if it has already started. /// /// /// true if the service is successfully found and removed; /// otherwise, false. /// /// - /// A that represents an absolute path to - /// the service to remove. + /// + /// A that represents an absolute path to + /// the service to remove. + /// + /// + /// / is trimmed from the end of the string if present. + /// /// /// /// is . From 0afef43f8ad0b233d96c7d69f97ac08750fd39a8 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 2 Dec 2018 17:59:02 +0900 Subject: [PATCH 2222/6294] [Modify] Edit it --- websocket-sharp/Server/HttpServer.cs | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 7c6bdf2b6..6b3917d9d 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -1139,28 +1139,29 @@ private static bool tryCreateUri ( #region Public Methods /// - /// Adds a WebSocket service with the specified behavior, - /// , and . + /// Adds a WebSocket service with the specified behavior, path, + /// and delegate. /// - /// - /// is converted to a URL-decoded string and - /// '/' is trimmed from the end of the converted string if any. - /// /// - /// A that represents an absolute path to - /// the service to add. + /// + /// A that represents an absolute path to + /// the service to add. + /// + /// + /// / is trimmed from the end of the string if present. + /// /// /// /// /// A Func<TBehavior> delegate. /// /// - /// It invokes the method called for creating - /// a new session instance for the service. + /// It invokes the method called when creating a new session + /// instance for the service. /// /// - /// The method must create a new instance of - /// the specified behavior class and return it. + /// The method must create a new instance of the specified + /// behavior class and return it. /// /// /// From 5631e78804e8a866f991dee41f1b50d35d76e639 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 3 Dec 2018 20:48:29 +0900 Subject: [PATCH 2223/6294] [Modify] Edit it --- websocket-sharp/Server/HttpServer.cs | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 6b3917d9d..f7362671c 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -1234,24 +1234,26 @@ public void AddWebSocketService ( } /// - /// Adds a WebSocket service with the specified behavior and - /// . + /// Adds a WebSocket service with the specified behavior and path. /// - /// - /// is converted to a URL-decoded string and - /// '/' is trimmed from the end of the converted string if any. - /// /// - /// A that represents an absolute path to - /// the service to add. + /// + /// A that represents an absolute path to + /// the service to add. + /// + /// + /// / is trimmed from the end of the string if present. + /// /// /// /// /// The type of the behavior for the service. /// /// - /// It must inherit the class and - /// must have a public parameterless constructor. + /// It must inherit the class. + /// + /// + /// And also, it must have a public parameterless constructor. /// /// /// From 80d70f8a0f1a607d8b067432d866069727851c6c Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 4 Dec 2018 19:48:51 +0900 Subject: [PATCH 2224/6294] [Modify] Edit it --- websocket-sharp/Server/HttpServer.cs | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index f7362671c..ff2ae4f4e 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -1290,16 +1290,17 @@ public void AddWebSocketService (string path) } /// - /// Adds a WebSocket service with the specified behavior, - /// , and . + /// Adds a WebSocket service with the specified behavior, path, + /// and delegate. /// - /// - /// is converted to a URL-decoded string and - /// '/' is trimmed from the end of the converted string if any. - /// /// - /// A that represents an absolute path to - /// the service to add. + /// + /// A that represents an absolute path to + /// the service to add. + /// + /// + /// / is trimmed from the end of the string if present. + /// /// /// /// @@ -1307,7 +1308,7 @@ public void AddWebSocketService (string path) /// if not needed. /// /// - /// That delegate invokes the method called for initializing + /// The delegate invokes the method called when initializing /// a new session instance for the service. /// /// @@ -1316,8 +1317,10 @@ public void AddWebSocketService (string path) /// The type of the behavior for the service. /// /// - /// It must inherit the class and - /// must have a public parameterless constructor. + /// It must inherit the class. + /// + /// + /// And also, it must have a public parameterless constructor. /// /// /// From eb59c733be1db4b668c0e3b1ecfa0538665e8366 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 5 Dec 2018 20:08:05 +0900 Subject: [PATCH 2225/6294] [Modify] Edit it --- websocket-sharp/Server/HttpServer.cs | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index ff2ae4f4e..5cddfa92d 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -1406,25 +1406,24 @@ public byte[] GetFile (string path) } /// - /// Removes a WebSocket service with the specified . + /// Removes a WebSocket service with the specified path. /// /// - /// - /// is converted to a URL-decoded string and - /// '/' is trimmed from the end of the converted string if any. - /// - /// - /// The service is stopped with close status 1001 (going away) - /// if it has already started. - /// + /// The service is stopped with close status 1001 (going away) + /// if it has already started. /// /// /// true if the service is successfully found and removed; /// otherwise, false. /// /// - /// A that represents an absolute path to - /// the service to remove. + /// + /// A that represents an absolute path to + /// the service to remove. + /// + /// + /// / is trimmed from the end of the string if present. + /// /// /// /// is . From c32f365537c06d0eb6733db866ac22e48d585f04 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 6 Dec 2018 20:17:50 +0900 Subject: [PATCH 2226/6294] [Modify] Add a pre-check for url decode --- websocket-sharp/Server/HttpServer.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 5cddfa92d..56925ac6d 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -920,6 +920,8 @@ private void processRequest (HttpListenerWebSocketContext context) } var path = uri.AbsolutePath; + if (path.IndexOfAny (new[] { '%', '+' }) > -1) + path = HttpUtility.UrlDecode (path, Encoding.UTF8); WebSocketServiceHost host; if (!_services.InternalTryGetServiceHost (path, out host)) { From d5dddf5a89fe2f3dc22994d61a1c1f5d4e7e4a3c Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 7 Dec 2018 20:15:03 +0900 Subject: [PATCH 2227/6294] [Modify] Add a pre-check for url decode --- websocket-sharp/Server/WebSocketServer.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 665a5dbe2..be7bca768 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -829,8 +829,12 @@ private void processRequest (TcpListenerWebSocketContext context) } } + var path = uri.AbsolutePath; + if (path.IndexOfAny (new[] { '%', '+' }) > -1) + path = HttpUtility.UrlDecode (path, Encoding.UTF8); + WebSocketServiceHost host; - if (!_services.InternalTryGetServiceHost (uri.AbsolutePath, out host)) { + if (!_services.InternalTryGetServiceHost (path, out host)) { context.Close (HttpStatusCode.NotImplemented); return; } From c53ec8dc08af0189da65e645b0d9dceb5a032f26 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 8 Dec 2018 18:22:01 +0900 Subject: [PATCH 2228/6294] [Modify] Add it --- websocket-sharp/Net/QueryStringCollection.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/websocket-sharp/Net/QueryStringCollection.cs b/websocket-sharp/Net/QueryStringCollection.cs index fd26b29fc..0cc2f047f 100644 --- a/websocket-sharp/Net/QueryStringCollection.cs +++ b/websocket-sharp/Net/QueryStringCollection.cs @@ -61,6 +61,17 @@ public QueryStringCollection (int capacity) #endregion + #region Private Methods + + private static string urlDecode (string s, Encoding encoding) + { + return s.IndexOfAny (new[] { '%', '+' }) > -1 + ? HttpUtility.UrlDecode (s, encoding) + : s; + } + + #endregion + #region Public Methods public static QueryStringCollection Parse (string query) From 36f4f5653dbf7d66fff07991b64d3311afab217f Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 9 Dec 2018 18:04:59 +0900 Subject: [PATCH 2229/6294] [Modify] Replace them --- websocket-sharp/Net/QueryStringCollection.cs | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/websocket-sharp/Net/QueryStringCollection.cs b/websocket-sharp/Net/QueryStringCollection.cs index 0cc2f047f..bfcda2cb6 100644 --- a/websocket-sharp/Net/QueryStringCollection.cs +++ b/websocket-sharp/Net/QueryStringCollection.cs @@ -110,25 +110,20 @@ public static QueryStringCollection Parse (string query, Encoding encoding) var i = component.IndexOf ('='); if (i < 0) { - ret.Add (null, HttpUtility.UrlDecode (component, encoding)); + ret.Add (null, urlDecode (component, encoding)); continue; } if (i == 0) { - ret.Add ( - null, HttpUtility.UrlDecode (component.Substring (1), encoding) - ); - + ret.Add (null, urlDecode (component.Substring (1), encoding)); continue; } - var name = HttpUtility.UrlDecode (component.Substring (0, i), encoding); + var name = urlDecode (component.Substring (0, i), encoding); var start = i + 1; var val = start < len - ? HttpUtility.UrlDecode ( - component.Substring (start), encoding - ) + ? urlDecode (component.Substring (start), encoding) : String.Empty; ret.Add (name, val); From 0bc6833114ae1c94863aa5d8637189c2ac7f665a Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 10 Dec 2018 21:48:10 +0900 Subject: [PATCH 2230/6294] [Modify] Add it --- websocket-sharp/Net/CookieCollection.cs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/websocket-sharp/Net/CookieCollection.cs b/websocket-sharp/Net/CookieCollection.cs index cbfe39fad..0aaf456a4 100644 --- a/websocket-sharp/Net/CookieCollection.cs +++ b/websocket-sharp/Net/CookieCollection.cs @@ -403,6 +403,25 @@ private static string[] splitCookieHeaderValue (string value) return new List (value.SplitHeaderValue (',', ';')).ToArray (); } + private static string urlDecode (string s, Encoding encoding) + { + if (s == null) + return s; + + if (s.Length == 0) + return s; + + if (s.IndexOfAny (new[] { '%', '+' }) == -1) + return s; + + try { + return HttpUtility.UrlDecode (s, encoding); + } + catch { + return null; + } + } + #endregion #region Internal Methods From c708209d8887c0dae0ddc3120fb514bdc2aa1281 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 11 Dec 2018 19:54:17 +0900 Subject: [PATCH 2231/6294] [Modify] Replace it --- websocket-sharp/Net/CookieCollection.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/CookieCollection.cs b/websocket-sharp/Net/CookieCollection.cs index 0aaf456a4..417b8fd07 100644 --- a/websocket-sharp/Net/CookieCollection.cs +++ b/websocket-sharp/Net/CookieCollection.cs @@ -332,7 +332,7 @@ private static CookieCollection parseResponse (string value) } else if (pair.StartsWith ("comment", StringComparison.InvariantCultureIgnoreCase)) { if (cookie != null) - cookie.Comment = HttpUtility.UrlDecode (pair.GetValue ('=')); + cookie.Comment = urlDecode (pair.GetValue ('='), Encoding.UTF8); } else if (pair.StartsWith ("commenturl", StringComparison.InvariantCultureIgnoreCase)) { if (cookie != null) From 59f51380a63b9a143b2a1441c3a6427762fe59db Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 12 Dec 2018 20:19:15 +0900 Subject: [PATCH 2232/6294] [Modify] Throw exception --- websocket-sharp/Net/HttpUtility.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index e30982890..df7b3b90f 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -945,7 +945,10 @@ public static string UrlDecode (string s) public static string UrlDecode (string s, Encoding encoding) { - if (s == null || s.Length == 0 || !s.Contains ('%', '+')) + if (s == null) + throw new ArgumentNullException ("s"); + + if (s.Length == 0) return s; if (encoding == null) From c164b810ff9774b399097f3eb32f8cd89a80a5e0 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 13 Dec 2018 21:26:22 +0900 Subject: [PATCH 2233/6294] [Modify] Replace it --- websocket-sharp/Net/HttpUtility.cs | 39 ++---------------------------- 1 file changed, 2 insertions(+), 37 deletions(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index df7b3b90f..d386d3f38 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -954,43 +954,8 @@ public static string UrlDecode (string s, Encoding encoding) if (encoding == null) encoding = Encoding.UTF8; - var buff = new List (); - var len = s.Length; - for (var i = 0; i < len; i++) { - var c = s[i]; - if (c == '%' && i + 2 < len && s[i + 1] != '%') { - int xchar; - if (s[i + 1] == 'u' && i + 5 < len) { - // Unicode hex sequence. - xchar = getChar (s, i + 2, 4); - if (xchar != -1) { - writeCharBytes ((char) xchar, buff, encoding); - i += 5; - } - else { - writeCharBytes ('%', buff, encoding); - } - } - else if ((xchar = getChar (s, i + 1, 2)) != -1) { - writeCharBytes ((char) xchar, buff, encoding); - i += 2; - } - else { - writeCharBytes ('%', buff, encoding); - } - - continue; - } - - if (c == '+') { - writeCharBytes (' ', buff, encoding); - continue; - } - - writeCharBytes (c, buff, encoding); - } - - return encoding.GetString (buff.ToArray ()); + var bytes = Encoding.ASCII.GetBytes (s); + return encoding.GetString (urlDecodeToBytes (bytes, 0, bytes.Length)); } public static string UrlDecode (byte[] bytes, Encoding encoding) From 80dffde6ddb2084153d46d47b76e56938af0df83 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 13 Dec 2018 21:33:33 +0900 Subject: [PATCH 2234/6294] [Modify] Polish it --- websocket-sharp/Net/HttpUtility.cs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index d386d3f38..e43962797 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -951,11 +951,10 @@ public static string UrlDecode (string s, Encoding encoding) if (s.Length == 0) return s; - if (encoding == null) - encoding = Encoding.UTF8; - var bytes = Encoding.ASCII.GetBytes (s); - return encoding.GetString (urlDecodeToBytes (bytes, 0, bytes.Length)); + return (encoding ?? Encoding.UTF8).GetString ( + urlDecodeToBytes (bytes, 0, bytes.Length) + ); } public static string UrlDecode (byte[] bytes, Encoding encoding) From e2dab381397b70355c01c32597c4c60c7f8e1e17 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 14 Dec 2018 20:46:59 +0900 Subject: [PATCH 2235/6294] [Modify] Remove it --- websocket-sharp/Net/HttpUtility.cs | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index e43962797..f53ac6e6f 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -592,18 +592,6 @@ private static void urlPathEncode (char c, StringBuilder output) } } - private static void writeCharBytes (char c, IList buffer, Encoding encoding) - { - if (c > 255) { - foreach (var b in encoding.GetBytes (new[] { c })) - buffer.Add (b); - - return; - } - - buffer.Add ((byte) c); - } - #endregion #region Internal Methods From 5b08d5358e7d5abc2b11f91182f5c55fb00ecd88 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 15 Dec 2018 17:24:52 +0900 Subject: [PATCH 2236/6294] [Modify] Polish it --- websocket-sharp/Net/CookieCollection.cs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/websocket-sharp/Net/CookieCollection.cs b/websocket-sharp/Net/CookieCollection.cs index 417b8fd07..fc9df33cc 100644 --- a/websocket-sharp/Net/CookieCollection.cs +++ b/websocket-sharp/Net/CookieCollection.cs @@ -406,10 +406,7 @@ private static string[] splitCookieHeaderValue (string value) private static string urlDecode (string s, Encoding encoding) { if (s == null) - return s; - - if (s.Length == 0) - return s; + return null; if (s.IndexOfAny (new[] { '%', '+' }) == -1) return s; From 25dace2fc98cd893f65595a9dfee90df40aa054e Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 16 Dec 2018 21:30:23 +0900 Subject: [PATCH 2237/6294] [Modify] Polish it --- websocket-sharp/Net/HttpUtility.cs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index f53ac6e6f..0f0ac146c 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -559,11 +559,14 @@ private static void urlEncode (byte b, Stream output) } } - output.WriteByte ((byte) '%'); - var i = (int) b; - output.WriteByte ((byte) _hexChars[i >> 4]); - output.WriteByte ((byte) _hexChars[i & 0x0F]); + + var buff = new byte[3]; + buff[0] = (byte) '%'; + buff[1] = (byte) _hexChars[i >> 4]; + buff[2] = (byte) _hexChars[i & 0x0F]; + + output.Write (buff, 0, 3); } private static byte[] urlEncodeToBytes (byte[] bytes, int offset, int count) From b9f591512c91117467b49823b4835f65f6dc59d2 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 17 Dec 2018 21:37:32 +0900 Subject: [PATCH 2238/6294] [Modify] Polish it --- websocket-sharp/Net/QueryStringCollection.cs | 3 --- 1 file changed, 3 deletions(-) diff --git a/websocket-sharp/Net/QueryStringCollection.cs b/websocket-sharp/Net/QueryStringCollection.cs index bfcda2cb6..2e925e2d1 100644 --- a/websocket-sharp/Net/QueryStringCollection.cs +++ b/websocket-sharp/Net/QueryStringCollection.cs @@ -134,9 +134,6 @@ public static QueryStringCollection Parse (string query, Encoding encoding) public override string ToString () { - if (Count == 0) - return String.Empty; - var buff = new StringBuilder (); foreach (var key in AllKeys) From 0c8d4585216be5bf3735b97e4f6db4150124199d Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 18 Dec 2018 20:59:00 +0900 Subject: [PATCH 2239/6294] [Modify] Throw exception --- websocket-sharp/Net/HttpUtility.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 0f0ac146c..de4dcdf42 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -901,6 +901,9 @@ public static string HtmlDecode (string s) /// public static void HtmlDecode (string s, TextWriter output) { + if (s == null) + throw new ArgumentNullException ("s"); + if (output == null) throw new ArgumentNullException ("output"); From c313056e68d29ab357f9e99a663bf4520e758d63 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 19 Dec 2018 21:49:57 +0900 Subject: [PATCH 2240/6294] [Modify] Add a check --- websocket-sharp/Net/HttpUtility.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index de4dcdf42..9b0444361 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -907,6 +907,9 @@ public static void HtmlDecode (string s, TextWriter output) if (output == null) throw new ArgumentNullException ("output"); + if (s.Length == 0) + return; + output.Write (HtmlDecode (s)); } From 7a2a2718f366589612a81aedb4e34cf5ccc590a2 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 20 Dec 2018 20:22:59 +0900 Subject: [PATCH 2241/6294] [Modify] Remove it --- websocket-sharp/Net/HttpUtility.cs | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 9b0444361..4d9f8ad0d 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -889,16 +889,6 @@ public static string HtmlDecode (string s) return output.ToString (); } - /// - /// Decodes an HTML-encoded and sends the decoded - /// to the specified . - /// - /// - /// A to decode. - /// - /// - /// A that receives the decoded string. - /// public static void HtmlDecode (string s, TextWriter output) { if (s == null) From c57f1dc134b54b7854fe58ca328f2735b98a2cdb Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 21 Dec 2018 20:04:26 +0900 Subject: [PATCH 2242/6294] [Modify] Throw exception --- websocket-sharp/Net/HttpUtility.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 4d9f8ad0d..16cf9bb14 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -779,7 +779,10 @@ public static void HtmlAttributeEncode (string s, TextWriter output) /// public static string HtmlDecode (string s) { - if (s == null || s.Length == 0 || !s.Contains ('&')) + if (s == null) + throw new ArgumentNullException ("s"); + + if (s.Length == 0) return s; var entity = new StringBuilder (); From cd0f0657869b3eaf6331112121978a1ad310c764 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 22 Dec 2018 17:14:34 +0900 Subject: [PATCH 2243/6294] [Modify] Remove it --- websocket-sharp/Net/HttpUtility.cs | 9 --------- 1 file changed, 9 deletions(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 16cf9bb14..419376380 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -768,15 +768,6 @@ public static void HtmlAttributeEncode (string s, TextWriter output) output.Write (htmlEncode (s, true)); } - /// - /// Decodes an HTML-encoded and returns the decoded . - /// - /// - /// A that represents the decoded string. - /// - /// - /// A to decode. - /// public static string HtmlDecode (string s) { if (s == null) From 71bfade226a77e651627c22419fa55f72050d1f1 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 23 Dec 2018 22:37:33 +0900 Subject: [PATCH 2244/6294] [Modify] Add it --- websocket-sharp/Net/HttpUtility.cs | 120 +++++++++++++++++++++++++++++ 1 file changed, 120 insertions(+) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 419376380..a1ccf1a05 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -177,6 +177,126 @@ private static int getNumber (string s, int offset, int count) return ret; } + private static string htmlDecode (string s) + { + var buff = new StringBuilder (); + + // 0: Nothing + // 1: Right after '&' + // 2: Between '&' and ';' but no '#' + // 3: '#' found after '&' and getting numbers + var state = 0; + + var entity = new StringBuilder (); + var number = 0; + var haveTrailingDigits = false; + + foreach (var c in s) { + if (state == 0) { + if (c == '&') { + entity.Append ('&'); + state = 1; + + continue; + } + + buff.Append (c); + continue; + } + + if (c == '&') { + if (haveTrailingDigits) { + entity.Append (number.ToString (CultureInfo.InvariantCulture)); + haveTrailingDigits = false; + } + + buff.Append (entity.ToString ()); + + entity.Length = 0; + entity.Append ('&'); + state = 1; + + continue; + } + + if (state == 1) { + if (c == ';') { + buff.AppendFormat ("{0};", entity.ToString ()); + + entity.Length = 0; + state = 0; + + continue; + } + + number = 0; + + entity.Append (c); + state = c != '#' ? 2 : 3; + + continue; + } + + if (state == 2) { + if (c == ';') { + var key = entity.ToString ().Substring (1); + var entities = getEntities (); + if (entities.ContainsKey (key)) + buff.Append (entities[key]); + else + buff.AppendFormat ("&{0};", key); + + entity.Length = 0; + state = 0; + + continue; + } + + entity.Append (c); + continue; + } + + if (state == 3) { + if (c == ';') { + if (number > 65535) { + buff.AppendFormat ( + "&#{0};", number.ToString (CultureInfo.InvariantCulture) + ); + } + else { + buff.Append ((char) number); + } + + entity.Length = 0; + haveTrailingDigits = false; + state = 0; + } + else if (Char.IsDigit (c)) { + number = number * 10 + ((int) c - '0'); + haveTrailingDigits = true; + } + else { + if (haveTrailingDigits) { + entity.Append (number.ToString (CultureInfo.InvariantCulture)); + haveTrailingDigits = false; + } + + entity.Append (c); + state = 2; + } + + continue; + } + } + + if (entity.Length > 0) + buff.Append (entity.ToString ()); + else if (haveTrailingDigits) + buff.Append (number.ToString (CultureInfo.InvariantCulture)); + + return buff.ToString (); + } + private static string htmlEncode (string s, bool minimal) { var buff = new StringBuilder (); From 4a71717116ae4a5ec4ebbce15ad369997f38b89d Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 24 Dec 2018 17:55:07 +0900 Subject: [PATCH 2245/6294] [Modify] Polish it --- websocket-sharp/Net/HttpUtility.cs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index a1ccf1a05..e23ad343c 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -267,15 +267,14 @@ private static string htmlDecode (string s) buff.Append ((char) number); } - entity.Length = 0; haveTrailingDigits = false; + entity.Length = 0; state = 0; + + continue; } - else if (Char.IsDigit (c)) { - number = number * 10 + ((int) c - '0'); - haveTrailingDigits = true; - } - else { + + if (!Char.IsDigit (c)) { if (haveTrailingDigits) { entity.Append (number.ToString (CultureInfo.InvariantCulture)); haveTrailingDigits = false; @@ -283,8 +282,13 @@ private static string htmlDecode (string s) entity.Append (c); state = 2; + + continue; } + number = number * 10 + (c - '0'); + haveTrailingDigits = true; + continue; } } From e010e2cff3b4f5b3dbe93822def659a664184a92 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 25 Dec 2018 21:31:19 +0900 Subject: [PATCH 2246/6294] [Modify] Polish it --- websocket-sharp/Net/HttpUtility.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index e23ad343c..8fa75feb9 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -293,10 +293,12 @@ private static string htmlDecode (string s) } } - if (entity.Length > 0) + if (entity.Length > 0) { buff.Append (entity.ToString ()); - else if (haveTrailingDigits) - buff.Append (number.ToString (CultureInfo.InvariantCulture)); + + if (haveTrailingDigits) + buff.Append (number.ToString (CultureInfo.InvariantCulture)); + } return buff.ToString (); } From 75c7ab12233700959064a93af0b3afa2e01155ac Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 26 Dec 2018 22:41:34 +0900 Subject: [PATCH 2247/6294] [Modify] Polish it --- websocket-sharp/Net/HttpUtility.cs | 42 ++++++------------------------ 1 file changed, 8 insertions(+), 34 deletions(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 8fa75feb9..fe9e1f274 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -189,7 +189,6 @@ private static string htmlDecode (string s) var entity = new StringBuilder (); var number = 0; - var haveTrailingDigits = false; foreach (var c in s) { if (state == 0) { @@ -205,11 +204,6 @@ private static string htmlDecode (string s) } if (c == '&') { - if (haveTrailingDigits) { - entity.Append (number.ToString (CultureInfo.InvariantCulture)); - haveTrailingDigits = false; - } - buff.Append (entity.ToString ()); entity.Length = 0; @@ -219,9 +213,11 @@ private static string htmlDecode (string s) continue; } + entity.Append (c); + if (state == 1) { if (c == ';') { - buff.AppendFormat ("{0};", entity.ToString ()); + buff.Append (entity.ToString ()); entity.Length = 0; state = 0; @@ -230,8 +226,6 @@ private static string htmlDecode (string s) } number = 0; - - entity.Append (c); state = c != '#' ? 2 : 3; continue; @@ -239,7 +233,7 @@ private static string htmlDecode (string s) if (state == 2) { if (c == ';') { - var key = entity.ToString ().Substring (1); + var key = entity.ToString ().Substring (1, entity.Length - 2); var entities = getEntities (); if (entities.ContainsKey (key)) buff.Append (entities[key]); @@ -252,22 +246,16 @@ private static string htmlDecode (string s) continue; } - entity.Append (c); continue; } if (state == 3) { if (c == ';') { - if (number > 65535) { - buff.AppendFormat ( - "&#{0};", number.ToString (CultureInfo.InvariantCulture) - ); - } - else { + if (number < 160 || number > 65535) + buff.Append (entity.ToString ()); + else buff.Append ((char) number); - } - haveTrailingDigits = false; entity.Length = 0; state = 0; @@ -275,31 +263,17 @@ private static string htmlDecode (string s) } if (!Char.IsDigit (c)) { - if (haveTrailingDigits) { - entity.Append (number.ToString (CultureInfo.InvariantCulture)); - haveTrailingDigits = false; - } - - entity.Append (c); state = 2; - continue; } number = number * 10 + (c - '0'); - haveTrailingDigits = true; - - continue; } } - if (entity.Length > 0) { + if (entity.Length > 0) buff.Append (entity.ToString ()); - if (haveTrailingDigits) - buff.Append (number.ToString (CultureInfo.InvariantCulture)); - } - return buff.ToString (); } From 1e764f6b83b00f11eab3e6610b5240a986d9107c Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 27 Dec 2018 21:06:11 +0900 Subject: [PATCH 2248/6294] [Modify] Polish it --- websocket-sharp/Net/HttpUtility.cs | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index fe9e1f274..9f584aed3 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -187,13 +187,13 @@ private static string htmlDecode (string s) // 3: '#' found after '&' and getting numbers var state = 0; - var entity = new StringBuilder (); + var reference = new StringBuilder (); var number = 0; foreach (var c in s) { if (state == 0) { if (c == '&') { - entity.Append ('&'); + reference.Append ('&'); state = 1; continue; @@ -204,22 +204,22 @@ private static string htmlDecode (string s) } if (c == '&') { - buff.Append (entity.ToString ()); + buff.Append (reference.ToString ()); - entity.Length = 0; - entity.Append ('&'); + reference.Length = 0; + reference.Append ('&'); state = 1; continue; } - entity.Append (c); + reference.Append (c); if (state == 1) { if (c == ';') { - buff.Append (entity.ToString ()); + buff.Append (reference.ToString ()); - entity.Length = 0; + reference.Length = 0; state = 0; continue; @@ -233,14 +233,14 @@ private static string htmlDecode (string s) if (state == 2) { if (c == ';') { - var key = entity.ToString ().Substring (1, entity.Length - 2); + var key = reference.ToString ().Substring (1, reference.Length - 2); var entities = getEntities (); if (entities.ContainsKey (key)) buff.Append (entities[key]); else buff.AppendFormat ("&{0};", key); - entity.Length = 0; + reference.Length = 0; state = 0; continue; @@ -252,11 +252,11 @@ private static string htmlDecode (string s) if (state == 3) { if (c == ';') { if (number < 160 || number > 65535) - buff.Append (entity.ToString ()); + buff.Append (reference.ToString ()); else buff.Append ((char) number); - entity.Length = 0; + reference.Length = 0; state = 0; continue; @@ -271,8 +271,8 @@ private static string htmlDecode (string s) } } - if (entity.Length > 0) - buff.Append (entity.ToString ()); + if (reference.Length > 0) + buff.Append (reference.ToString ()); return buff.ToString (); } From 1312eb967a76614946d44a1d6086d79de1532c00 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 28 Dec 2018 20:55:32 +0900 Subject: [PATCH 2249/6294] [Modify] Polish it --- websocket-sharp/Net/HttpUtility.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 9f584aed3..6d71ae98d 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -233,12 +233,14 @@ private static string htmlDecode (string s) if (state == 2) { if (c == ';') { - var key = reference.ToString ().Substring (1, reference.Length - 2); + var entity = reference.ToString (); + var name = entity.Substring (1, entity.Length - 2); + var entities = getEntities (); - if (entities.ContainsKey (key)) - buff.Append (entities[key]); + if (entities.ContainsKey (name)) + buff.Append (entities[name]); else - buff.AppendFormat ("&{0};", key); + buff.Append (entity); reference.Length = 0; state = 0; From fd62393bf58de5df15c5501618f430b16125de1a Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 29 Dec 2018 22:04:30 +0900 Subject: [PATCH 2250/6294] [Modify] Polish it --- websocket-sharp/Net/HttpUtility.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 6d71ae98d..65416f19d 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -226,7 +226,7 @@ private static string htmlDecode (string s) } number = 0; - state = c != '#' ? 2 : 3; + state = c == '#' ? 3 : 2; continue; } From 759df4f755f71bd7a2f877f12171137a5b50177e Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 30 Dec 2018 22:04:43 +0900 Subject: [PATCH 2251/6294] [Modify] Polish it --- websocket-sharp/Net/HttpUtility.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 65416f19d..4b5da7caa 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -253,10 +253,10 @@ private static string htmlDecode (string s) if (state == 3) { if (c == ';') { - if (number < 160 || number > 65535) - buff.Append (reference.ToString ()); - else + if (reference.Length > 3 && number < 65536) buff.Append ((char) number); + else + buff.Append (reference.ToString ()); reference.Length = 0; state = 0; From 47cfdcdc93898b6db013e0441dc428d2a3ab77e3 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 31 Dec 2018 21:32:31 +0900 Subject: [PATCH 2252/6294] [Modify] Support &#xhhhh; --- websocket-sharp/Net/HttpUtility.cs | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 4b5da7caa..164870610 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -185,6 +185,7 @@ private static string htmlDecode (string s) // 1: Right after '&' // 2: Between '&' and ';' but no '#' // 3: '#' found after '&' and getting numbers + // 4: 'x' found after "&#" and getting numbers var state = 0; var reference = new StringBuilder (); @@ -264,12 +265,40 @@ private static string htmlDecode (string s) continue; } + if (c == 'x') { + state = reference.Length == 3 ? 4 : 2; + continue; + } + if (!Char.IsDigit (c)) { state = 2; continue; } number = number * 10 + (c - '0'); + continue; + } + + if (state == 4) { + if (c == ';') { + if (reference.Length > 4 && number < 65536) + buff.Append ((char) number); + else + buff.Append (reference.ToString ()); + + reference.Length = 0; + state = 0; + + continue; + } + + var n = getNumber (c); + if (n == -1) { + state = 2; + continue; + } + + number = (number << 4) + n; } } From e3cb00778680aa51425485d39459c2bf612e02ef Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 31 Dec 2018 21:36:20 +0900 Subject: [PATCH 2253/6294] [Modify] Polish it --- websocket-sharp/Net/HttpUtility.cs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 164870610..e3cd2d6ab 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -189,7 +189,7 @@ private static string htmlDecode (string s) var state = 0; var reference = new StringBuilder (); - var number = 0; + var num = 0; foreach (var c in s) { if (state == 0) { @@ -226,7 +226,7 @@ private static string htmlDecode (string s) continue; } - number = 0; + num = 0; state = c == '#' ? 3 : 2; continue; @@ -254,8 +254,8 @@ private static string htmlDecode (string s) if (state == 3) { if (c == ';') { - if (reference.Length > 3 && number < 65536) - buff.Append ((char) number); + if (reference.Length > 3 && num < 65536) + buff.Append ((char) num); else buff.Append (reference.ToString ()); @@ -275,14 +275,14 @@ private static string htmlDecode (string s) continue; } - number = number * 10 + (c - '0'); + num = num * 10 + (c - '0'); continue; } if (state == 4) { if (c == ';') { - if (reference.Length > 4 && number < 65536) - buff.Append ((char) number); + if (reference.Length > 4 && num < 65536) + buff.Append ((char) num); else buff.Append (reference.ToString ()); @@ -298,7 +298,7 @@ private static string htmlDecode (string s) continue; } - number = (number << 4) + n; + num = (num << 4) + n; } } From 34dd9c9f60e31f58dca4ea69bae3d0f08c62d0c9 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 1 Jan 2019 16:19:01 +0900 Subject: [PATCH 2254/6294] [Modify] Replace it --- websocket-sharp/Net/HttpUtility.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index e3cd2d6ab..440b748aa 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -1025,7 +1025,7 @@ public static void HtmlDecode (string s, TextWriter output) if (s.Length == 0) return; - output.Write (HtmlDecode (s)); + output.Write (htmlDecode (s)); } public static string HtmlEncode (string s) From a793b5be213ade808b5aea4b4cf3a86a2c0769d5 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 1 Jan 2019 16:22:54 +0900 Subject: [PATCH 2255/6294] [Modify] Replace it --- websocket-sharp/Net/HttpUtility.cs | 106 +---------------------------- 1 file changed, 1 insertion(+), 105 deletions(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 440b748aa..22a5b70d6 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -907,111 +907,7 @@ public static string HtmlDecode (string s) if (s.Length == 0) return s; - var entity = new StringBuilder (); - var output = new StringBuilder (); - - // 0 -> nothing, - // 1 -> right after '&' - // 2 -> between '&' and ';' but no '#' - // 3 -> '#' found after '&' and getting numbers - var state = 0; - - var number = 0; - var haveTrailingDigits = false; - foreach (var c in s) { - if (state == 0) { - if (c == '&') { - entity.Append (c); - state = 1; - } - else { - output.Append (c); - } - - continue; - } - - if (c == '&') { - state = 1; - if (haveTrailingDigits) { - entity.Append (number.ToString (CultureInfo.InvariantCulture)); - haveTrailingDigits = false; - } - - output.Append (entity.ToString ()); - entity.Length = 0; - entity.Append ('&'); - - continue; - } - - if (state == 1) { - if (c == ';') { - state = 0; - output.Append (entity.ToString ()); - output.Append (c); - entity.Length = 0; - } - else { - number = 0; - if (c != '#') - state = 2; - else - state = 3; - - entity.Append (c); - } - } - else if (state == 2) { - entity.Append (c); - if (c == ';') { - var key = entity.ToString (); - var entities = getEntities (); - if (key.Length > 1 && entities.ContainsKey (key.Substring (1, key.Length - 2))) - key = entities[key.Substring (1, key.Length - 2)].ToString (); - - output.Append (key); - state = 0; - entity.Length = 0; - } - } - else if (state == 3) { - if (c == ';') { - if (number > 65535) { - output.Append ("&#"); - output.Append (number.ToString (CultureInfo.InvariantCulture)); - output.Append (";"); - } - else { - output.Append ((char) number); - } - - state = 0; - entity.Length = 0; - haveTrailingDigits = false; - } - else if (Char.IsDigit (c)) { - number = number * 10 + ((int) c - '0'); - haveTrailingDigits = true; - } - else { - state = 2; - if (haveTrailingDigits) { - entity.Append (number.ToString (CultureInfo.InvariantCulture)); - haveTrailingDigits = false; - } - - entity.Append (c); - } - } - } - - if (entity.Length > 0) - output.Append (entity.ToString ()); - else if (haveTrailingDigits) - output.Append (number.ToString (CultureInfo.InvariantCulture)); - - return output.ToString (); + return htmlDecode (s); } public static void HtmlDecode (string s, TextWriter output) From 770eb709919e1a434c064cbde9d4f592b631f4b1 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 1 Jan 2019 16:26:06 +0900 Subject: [PATCH 2256/6294] [Modify] Polish it --- websocket-sharp/Net/HttpUtility.cs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 22a5b70d6..9426779a5 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -904,10 +904,7 @@ public static string HtmlDecode (string s) if (s == null) throw new ArgumentNullException ("s"); - if (s.Length == 0) - return s; - - return htmlDecode (s); + return s.Length > 0 ? htmlDecode (s) : s; } public static void HtmlDecode (string s, TextWriter output) From 7c5cd7f02c8d2b3d402107ce69a040c4e8543bd6 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 1 Jan 2019 16:28:24 +0900 Subject: [PATCH 2257/6294] [Modify] 2019 --- LICENSE.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LICENSE.txt b/LICENSE.txt index c53829dc8..c978848b3 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2010-2018 sta.blockhead +Copyright (c) 2010-2019 sta.blockhead Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal From 35364e5be6a225c798850d3829c5ae0acb6eaf1b Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 2 Jan 2019 16:45:04 +0900 Subject: [PATCH 2258/6294] [Modify] Remove it --- websocket-sharp/Net/HttpUtility.cs | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 9426779a5..e2bd02d3e 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -73,21 +73,6 @@ static HttpUtility () #region Private Methods - private static int getChar (byte[] bytes, int offset, int length) - { - var val = 0; - var end = length + offset; - for (var i = offset; i < end; i++) { - var current = getInt (bytes[i]); - if (current == -1) - return -1; - - val = (val << 4) + current; - } - - return val; - } - private static int getChar (string s, int offset, int length) { var val = 0; From a72210c9dbb70f0794836fdb8e7ac6d5f62f1562 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 2 Jan 2019 16:46:47 +0900 Subject: [PATCH 2259/6294] [Modify] Remove it --- websocket-sharp/Net/HttpUtility.cs | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index e2bd02d3e..9bbc8dbde 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -73,25 +73,6 @@ static HttpUtility () #region Private Methods - private static int getChar (string s, int offset, int length) - { - var val = 0; - var end = length + offset; - for (var i = offset; i < end; i++) { - var c = s[i]; - if (c > 127) - return -1; - - var current = getInt ((byte) c); - if (current == -1) - return -1; - - val = (val << 4) + current; - } - - return val; - } - private static char[] getChars (MemoryStream buffer, Encoding encoding) { return encoding.GetChars (buffer.GetBuffer (), 0, (int) buffer.Length); From 883d90aa181709452db85a2b8ae2e7952add24b8 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 2 Jan 2019 16:48:18 +0900 Subject: [PATCH 2260/6294] [Modify] Remove it --- websocket-sharp/Net/HttpUtility.cs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 9bbc8dbde..fcb2f1234 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -73,11 +73,6 @@ static HttpUtility () #region Private Methods - private static char[] getChars (MemoryStream buffer, Encoding encoding) - { - return encoding.GetChars (buffer.GetBuffer (), 0, (int) buffer.Length); - } - private static Dictionary getEntities () { lock (_sync) { From 455fa52e1f0335e5ea5ede917d6aa5de9ca8927a Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 3 Jan 2019 17:42:46 +0900 Subject: [PATCH 2261/6294] [Modify] Remove it --- websocket-sharp/Net/HttpUtility.cs | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index fcb2f1234..785d2e452 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -83,18 +83,6 @@ private static Dictionary getEntities () } } - private static int getInt (byte b) - { - var c = (char) b; - return c >= '0' && c <= '9' - ? c - '0' - : c >= 'a' && c <= 'f' - ? c - 'a' + 10 - : c >= 'A' && c <= 'F' - ? c - 'A' + 10 - : -1; - } - private static int getNumber (char c) { return c >= '0' && c <= '9' From 0fa08bcb4290d10d470a040c60c10bd52a1d402b Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 3 Jan 2019 17:54:15 +0900 Subject: [PATCH 2262/6294] [Modify] Remove it --- websocket-sharp/Net/HttpUtility.cs | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 785d2e452..de8ace4f1 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -1119,22 +1119,6 @@ public static byte[] UrlEncodeToBytes (string s, Encoding encoding) return urlEncodeToBytes (bytes, 0, bytes.Length); } - public static string UrlPathEncode (string s) - { - if (s == null) - throw new ArgumentNullException ("s"); - - if (s.Length == 0) - return s; - - var buff = new StringBuilder (); - - foreach (var c in s) - urlPathEncode (c, buff); - - return buff.ToString (); - } - #endregion } } From eb5704be1a2191b6f71d799a57bae48b8b5ae1e0 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 3 Jan 2019 17:56:19 +0900 Subject: [PATCH 2263/6294] [Modify] Remove it --- websocket-sharp/Net/HttpUtility.cs | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index de8ace4f1..0f714dbb8 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -661,20 +661,6 @@ private static byte[] urlEncodeToBytes (byte[] bytes, int offset, int count) } } - private static void urlPathEncode (char c, StringBuilder output) - { - if (c > 32 && c < 127) { - output.Append (c); - return; - } - - var bytes = Encoding.UTF8.GetBytes (new[] { c }); - foreach (var b in bytes) { - var i = (int) b; - output.AppendFormat ("%{0}{1}", _hexChars[i >> 4], _hexChars[i & 0x0F]); - } - } - #endregion #region Internal Methods From b7b66db1d6812645c68047a1854bec7149a3da64 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 4 Jan 2019 17:10:07 +0900 Subject: [PATCH 2264/6294] [Modify] Polish it --- websocket-sharp/Net/HttpUtility.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 0f714dbb8..2322159d0 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -640,13 +640,13 @@ private static void urlEncode (byte b, Stream output) } var i = (int) b; + var bytes = new byte[] { + (byte) '%', + (byte) _hexChars[i >> 4], + (byte) _hexChars[i & 0x0F] + }; - var buff = new byte[3]; - buff[0] = (byte) '%'; - buff[1] = (byte) _hexChars[i >> 4]; - buff[2] = (byte) _hexChars[i & 0x0F]; - - output.Write (buff, 0, 3); + output.Write (bytes, 0, 3); } private static byte[] urlEncodeToBytes (byte[] bytes, int offset, int count) From e7b2b1d0e74f14c90df86d941132e451b69d43e5 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 5 Jan 2019 17:27:32 +0900 Subject: [PATCH 2265/6294] [Modify] To uppercase --- websocket-sharp/Net/HttpUtility.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 2322159d0..8d1fd4d3a 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -65,7 +65,7 @@ internal static class HttpUtility static HttpUtility () { - _hexChars = "0123456789abcdef".ToCharArray (); + _hexChars = "0123456789ABCDEF".ToCharArray (); _sync = new object (); } From 17dfa0bea77c39f1ce12baf7336613d7a4b724b5 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 6 Jan 2019 17:17:54 +0900 Subject: [PATCH 2266/6294] [Modify] Replace it --- websocket-sharp/Net/HttpUtility.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 8d1fd4d3a..7458eecd8 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -219,7 +219,7 @@ private static string htmlDecode (string s) continue; } - if (!Char.IsDigit (c)) { + if (!isNumeric (c)) { state = 2; continue; } From 323c66a634337151f68c2d8bf8f85e8994745109 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 7 Jan 2019 22:20:41 +0900 Subject: [PATCH 2267/6294] [Modify] Edit it --- websocket-sharp/Net/HttpUtility.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 7458eecd8..fcd7f895c 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -130,11 +130,11 @@ private static string htmlDecode (string s) { var buff = new StringBuilder (); - // 0: Nothing + // 0: None // 1: Right after '&' - // 2: Between '&' and ';' but no '#' + // 2: Between '&' and ';' but no NCR // 3: '#' found after '&' and getting numbers - // 4: 'x' found after "&#" and getting numbers + // 4: 'x' found after '#' and getting numbers var state = 0; var reference = new StringBuilder (); From e75bbac467bb2a5b603b07cfdb8be073dca47274 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 8 Jan 2019 21:41:56 +0900 Subject: [PATCH 2268/6294] [Modify] Edit it --- websocket-sharp/Net/HttpUtility.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index fcd7f895c..1e9826015 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -280,10 +280,15 @@ private static string htmlEncode (string s, bool minimal) return buff.ToString (); } + /// + /// Initializes the _entities field. + /// + /// + /// This method builds a dictionary of HTML character entity references. + /// This dictionary comes from the HTML 4.01 W3C recommendation. + /// private static void initEntities () { - // Build the dictionary of HTML entity references. - // This list comes from the HTML 4.01 W3C recommendation. _entities = new Dictionary (); _entities.Add ("nbsp", '\u00A0'); _entities.Add ("iexcl", '\u00A1'); From 26cdd4374ffc0254cc2e97bf182b9435b746ce8e Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 9 Jan 2019 22:12:11 +0900 Subject: [PATCH 2269/6294] [Modify] Edit it --- websocket-sharp/Net/HttpUtility.cs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 1e9826015..2982fa883 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -257,6 +257,29 @@ private static string htmlDecode (string s) return buff.ToString (); } + /// + /// Converts the specified string to an HTML-encoded string. + /// + /// + /// + /// MS .NET starts encoding with &# from the character code 160 and + /// stops at the character code 255. + /// + /// + /// This method does not do that. One reason is the unicode characters + /// 65308 and 65310 that look like < and >. + /// + /// + /// + /// A that represents an encoded string. + /// + /// + /// A to encode. + /// + /// + /// A : true if encodes without a NCR; + /// otherwise, false. + /// private static string htmlEncode (string s, bool minimal) { var buff = new StringBuilder (); From 4cbb2d900866af8a1803e8d3dacaddaee62fbef6 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 10 Jan 2019 21:31:58 +0900 Subject: [PATCH 2270/6294] [Modify] Edit it --- websocket-sharp/Net/HttpUtility.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 2982fa883..f9648c0ad 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -262,12 +262,12 @@ private static string htmlDecode (string s) /// /// /// - /// MS .NET starts encoding with &# from the character code 160 and - /// stops at the character code 255. + /// This method starts encoding with a NCR from the character code 160 + /// but does not stop at the character code 255. /// /// - /// This method does not do that. One reason is the unicode characters - /// 65308 and 65310 that look like < and >. + /// One reason is the unicode characters < and > that + /// look like < and >. /// /// /// From 1ee35195b4aeb438d95b67dd9599c7707e726006 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 11 Jan 2019 22:41:54 +0900 Subject: [PATCH 2271/6294] [Modify] Move it --- websocket-sharp/Net/HttpUtility.cs | 34 +++++++++++++++--------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index f9648c0ad..02826b1cb 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -1091,6 +1091,23 @@ public static byte[] UrlEncodeToBytes (byte[] bytes) return len > 0 ? urlEncodeToBytes (bytes, 0, len) : bytes; } + public static byte[] UrlEncodeToBytes (string s) + { + return UrlEncodeToBytes (s, Encoding.UTF8); + } + + public static byte[] UrlEncodeToBytes (string s, Encoding encoding) + { + if (s == null) + throw new ArgumentNullException ("s"); + + if (s.Length == 0) + return new byte[0]; + + var bytes = (encoding ?? Encoding.UTF8).GetBytes (s); + return urlEncodeToBytes (bytes, 0, bytes.Length); + } + public static byte[] UrlEncodeToBytes (byte[] bytes, int offset, int count) { if (bytes == null) @@ -1116,23 +1133,6 @@ public static byte[] UrlEncodeToBytes (byte[] bytes, int offset, int count) return count > 0 ? urlEncodeToBytes (bytes, offset, count) : new byte[0]; } - public static byte[] UrlEncodeToBytes (string s) - { - return UrlEncodeToBytes (s, Encoding.UTF8); - } - - public static byte[] UrlEncodeToBytes (string s, Encoding encoding) - { - if (s == null) - throw new ArgumentNullException ("s"); - - if (s.Length == 0) - return new byte[0]; - - var bytes = (encoding ?? Encoding.UTF8).GetBytes (s); - return urlEncodeToBytes (bytes, 0, bytes.Length); - } - #endregion } } From 2935c8e1cf04e36104af6d62ed33a7580d01311a Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 12 Jan 2019 22:23:00 +0900 Subject: [PATCH 2272/6294] [Modify] Move it --- websocket-sharp/Net/HttpUtility.cs | 46 +++++++++++++++--------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 02826b1cb..c05482f15 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -1030,6 +1030,29 @@ public static string UrlEncode (byte[] bytes) : String.Empty; } + public static string UrlEncode (string s) + { + return UrlEncode (s, Encoding.UTF8); + } + + public static string UrlEncode (string s, Encoding encoding) + { + if (s == null) + throw new ArgumentNullException ("s"); + + var len = s.Length; + if (len == 0) + return s; + + if (encoding == null) + encoding = Encoding.UTF8; + + var bytes = new byte[encoding.GetMaxByteCount (len)]; + var realLen = encoding.GetBytes (s, 0, len, bytes, 0); + + return Encoding.ASCII.GetString (urlEncodeToBytes (bytes, 0, realLen)); + } + public static string UrlEncode (byte[] bytes, int offset, int count) { if (bytes == null) @@ -1059,29 +1082,6 @@ public static string UrlEncode (byte[] bytes, int offset, int count) : String.Empty; } - public static string UrlEncode (string s) - { - return UrlEncode (s, Encoding.UTF8); - } - - public static string UrlEncode (string s, Encoding encoding) - { - if (s == null) - throw new ArgumentNullException ("s"); - - var len = s.Length; - if (len == 0) - return s; - - if (encoding == null) - encoding = Encoding.UTF8; - - var bytes = new byte[encoding.GetMaxByteCount (len)]; - var realLen = encoding.GetBytes (s, 0, len, bytes, 0); - - return Encoding.ASCII.GetString (urlEncodeToBytes (bytes, 0, realLen)); - } - public static byte[] UrlEncodeToBytes (byte[] bytes) { if (bytes == null) From 08f15dcee3a1d6f4e8606d9196eaf81205575a61 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 13 Jan 2019 21:18:26 +0900 Subject: [PATCH 2273/6294] [Modify] Move it --- websocket-sharp/Net/HttpUtility.cs | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index c05482f15..f427da7b4 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -911,6 +911,19 @@ public static string UrlDecode (string s) return UrlDecode (s, Encoding.UTF8); } + public static string UrlDecode (byte[] bytes, Encoding encoding) + { + if (bytes == null) + throw new ArgumentNullException ("bytes"); + + var len = bytes.Length; + return len > 0 + ? (encoding ?? Encoding.UTF8).GetString ( + urlDecodeToBytes (bytes, 0, len) + ) + : String.Empty; + } + public static string UrlDecode (string s, Encoding encoding) { if (s == null) @@ -925,19 +938,6 @@ public static string UrlDecode (string s, Encoding encoding) ); } - public static string UrlDecode (byte[] bytes, Encoding encoding) - { - if (bytes == null) - throw new ArgumentNullException ("bytes"); - - var len = bytes.Length; - return len > 0 - ? (encoding ?? Encoding.UTF8).GetString ( - urlDecodeToBytes (bytes, 0, len) - ) - : String.Empty; - } - public static string UrlDecode ( byte[] bytes, int offset, int count, Encoding encoding ) From c8904fd80ca0bb08ef4784ff965ec66c226fb03d Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 14 Jan 2019 22:34:02 +0900 Subject: [PATCH 2274/6294] [Modify] Polish it --- websocket-sharp/Net/HttpUtility.cs | 45 ++++++++++++++++++++++-------- 1 file changed, 33 insertions(+), 12 deletions(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index f427da7b4..c6a35ff58 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -694,21 +694,37 @@ private static byte[] urlEncodeToBytes (byte[] bytes, int offset, int count) #region Internal Methods internal static Uri CreateRequestUrl ( - string requestUri, string host, bool websocketRequest, bool secure) + string requestUri, string host, bool websocketRequest, bool secure + ) { - if (requestUri == null || requestUri.Length == 0 || host == null || host.Length == 0) + if (requestUri == null) + return null; + + if (host == null) + return null; + + if (requestUri.Length == 0) + return null; + + if (host.Length == 0) return null; string schm = null; string path = null; + if (requestUri.StartsWith ("/")) { path = requestUri; } else if (requestUri.MaybeUri ()) { Uri uri; - var valid = Uri.TryCreate (requestUri, UriKind.Absolute, out uri) && - (((schm = uri.Scheme).StartsWith ("http") && !websocketRequest) || - (schm.StartsWith ("ws") && websocketRequest)); + var valid = Uri.TryCreate (requestUri, UriKind.Absolute, out uri) + && ( + ( + (schm = uri.Scheme).StartsWith ("http") + && !websocketRequest + ) + || (schm.StartsWith ("ws") && websocketRequest) + ); if (!valid) return null; @@ -723,20 +739,25 @@ internal static Uri CreateRequestUrl ( host = requestUri; } - if (schm == null) - schm = (websocketRequest ? "ws" : "http") + (secure ? "s" : String.Empty); + if (schm == null) { + schm = (websocketRequest ? "ws" : "http") + + (secure ? "s" : String.Empty); + } var colon = host.IndexOf (':'); - if (colon == -1) - host = String.Format ("{0}:{1}", host, schm == "http" || schm == "ws" ? 80 : 443); + if (colon == -1) { + host = String.Format ( + "{0}:{1}", host, schm == "http" || schm == "ws" ? 80 : 443 + ); + } var url = String.Format ("{0}://{1}{2}", schm, host, path); - Uri res; - if (!Uri.TryCreate (url, UriKind.Absolute, out res)) + Uri ret; + if (!Uri.TryCreate (url, UriKind.Absolute, out ret)) return null; - return res; + return ret; } internal static IPrincipal CreateUser ( From 84cce50b570c6c3b0c9d6f88b0f5658741a2c980 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 15 Jan 2019 21:20:46 +0900 Subject: [PATCH 2275/6294] [Modify] Polish it --- websocket-sharp/Net/HttpUtility.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index c6a35ff58..bc32a24a6 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -744,8 +744,7 @@ internal static Uri CreateRequestUrl ( + (secure ? "s" : String.Empty); } - var colon = host.IndexOf (':'); - if (colon == -1) { + if (host.IndexOf (':') == -1) { host = String.Format ( "{0}:{1}", host, schm == "http" || schm == "ws" ? 80 : 443 ); From b44feed4c77a2854c5d51c0ac40b7051984b80db Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 15 Jan 2019 21:34:42 +0900 Subject: [PATCH 2276/6294] [Modify] Polish it --- websocket-sharp/Net/HttpUtility.cs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index bc32a24a6..39a785b35 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -744,11 +744,8 @@ internal static Uri CreateRequestUrl ( + (secure ? "s" : String.Empty); } - if (host.IndexOf (':') == -1) { - host = String.Format ( - "{0}:{1}", host, schm == "http" || schm == "ws" ? 80 : 443 - ); - } + if (host.IndexOf (':') == -1) + host = String.Format ("{0}:{1}", host, secure ? 443 : 80); var url = String.Format ("{0}://{1}{2}", schm, host, path); From 78f996b37680af60ff71936a24fb1f04eba18c94 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 16 Jan 2019 21:47:37 +0900 Subject: [PATCH 2277/6294] [Modify] Polish it --- websocket-sharp/Net/HttpUtility.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 39a785b35..2e99252b8 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -740,8 +740,9 @@ internal static Uri CreateRequestUrl ( } if (schm == null) { - schm = (websocketRequest ? "ws" : "http") - + (secure ? "s" : String.Empty); + schm = websocketRequest + ? (secure ? "wss" : "ws") + : (secure ? "https" : "http"); } if (host.IndexOf (':') == -1) From 07a28d24d529783c408ee76c4e32c602c701170d Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 17 Jan 2019 21:28:10 +0900 Subject: [PATCH 2278/6294] [Modify] Polish it --- websocket-sharp/Net/HttpUtility.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 2e99252b8..b64555781 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -712,7 +712,7 @@ internal static Uri CreateRequestUrl ( string schm = null; string path = null; - if (requestUri.StartsWith ("/")) { + if (requestUri.IndexOf ('/') == 0) { path = requestUri; } else if (requestUri.MaybeUri ()) { From fb1e0cdd044d5cb057916ceda74e451c1d729917 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 18 Jan 2019 22:16:55 +0900 Subject: [PATCH 2279/6294] [Modify] Polish it --- websocket-sharp/Net/HttpUtility.cs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index b64555781..999a79395 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -717,14 +717,12 @@ internal static Uri CreateRequestUrl ( } else if (requestUri.MaybeUri ()) { Uri uri; - var valid = Uri.TryCreate (requestUri, UriKind.Absolute, out uri) - && ( - ( - (schm = uri.Scheme).StartsWith ("http") - && !websocketRequest - ) - || (schm.StartsWith ("ws") && websocketRequest) - ); + if (!Uri.TryCreate (requestUri, UriKind.Absolute, out uri)) + return null; + + schm = uri.Scheme; + var valid = (schm.StartsWith ("http") && !websocketRequest) + || (schm.StartsWith ("ws") && websocketRequest); if (!valid) return null; From 1cf3c988a9c2a993202e1411b857b472e3556896 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 19 Jan 2019 22:24:32 +0900 Subject: [PATCH 2280/6294] [Modify] Polish it --- websocket-sharp/Net/HttpUtility.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 999a79395..a43680d1a 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -721,8 +721,9 @@ internal static Uri CreateRequestUrl ( return null; schm = uri.Scheme; - var valid = (schm.StartsWith ("http") && !websocketRequest) - || (schm.StartsWith ("ws") && websocketRequest); + var valid = websocketRequest + ? schm == "ws" || schm == "wss" + : schm == "http" || schm == "https"; if (!valid) return null; From a9eac30aa111e01a886e10d58eb389dd4b07a40c Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 20 Jan 2019 17:38:24 +0900 Subject: [PATCH 2281/6294] [Modify] Polish it --- websocket-sharp/Net/HttpUtility.cs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index a43680d1a..dadb65543 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -750,10 +750,7 @@ internal static Uri CreateRequestUrl ( var url = String.Format ("{0}://{1}{2}", schm, host, path); Uri ret; - if (!Uri.TryCreate (url, UriKind.Absolute, out ret)) - return null; - - return ret; + return Uri.TryCreate (url, UriKind.Absolute, out ret) ? ret : null; } internal static IPrincipal CreateUser ( From 8d8d49d91dfdcfc70166ba9a3a18c100086a2e68 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 21 Jan 2019 20:34:00 +0900 Subject: [PATCH 2282/6294] [Modify] Edit it --- websocket-sharp/Net/HttpUtility.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index dadb65543..276bffc5b 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -734,7 +734,7 @@ internal static Uri CreateRequestUrl ( else if (requestUri == "*") { } else { - // As authority form + // As the authority form. host = requestUri; } From ae9bc482585059a0a05f3735cc7e14fdc8cc4b21 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 21 Jan 2019 21:16:44 +0900 Subject: [PATCH 2283/6294] [Modify] Polish it --- websocket-sharp/Net/HttpUtility.cs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 276bffc5b..cea42b898 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -764,12 +764,6 @@ Func credentialsFinder if (response == null || response.Length == 0) return null; - if (credentialsFinder == null) - return null; - - if (!(scheme == AuthenticationSchemes.Basic || scheme == AuthenticationSchemes.Digest)) - return null; - if (scheme == AuthenticationSchemes.Digest) { if (realm == null || realm.Length == 0) return null; @@ -777,6 +771,13 @@ Func credentialsFinder if (method == null || method.Length == 0) return null; } + else { + if (scheme != AuthenticationSchemes.Basic) + return null; + } + + if (credentialsFinder == null) + return null; if (!response.StartsWith (scheme.ToString (), StringComparison.OrdinalIgnoreCase)) return null; From ac5559b15da2e6f124828a9c1bc868aed163c736 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 22 Jan 2019 21:13:28 +0900 Subject: [PATCH 2284/6294] [Modify] Polish it --- websocket-sharp/Net/HttpUtility.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index cea42b898..817ef5688 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -779,7 +779,8 @@ Func credentialsFinder if (credentialsFinder == null) return null; - if (!response.StartsWith (scheme.ToString (), StringComparison.OrdinalIgnoreCase)) + var comparison = StringComparison.OrdinalIgnoreCase; + if (response.IndexOf (scheme.ToString (), comparison) != 0) return null; var res = AuthenticationResponse.Parse (response); From bfbc42097ec3de856ea898a5ca4ba6669387da67 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 23 Jan 2019 21:21:41 +0900 Subject: [PATCH 2285/6294] [Modify] Polish it --- websocket-sharp/Net/HttpUtility.cs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 817ef5688..bebdb7b7d 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -801,16 +801,16 @@ Func credentialsFinder if (cred == null) return null; - if (scheme == AuthenticationSchemes.Basic - && ((HttpBasicIdentity) id).Password != cred.Password - ) { - return null; + if (scheme == AuthenticationSchemes.Basic) { + var basicId = (HttpBasicIdentity) id; + if (basicId.Password != cred.Password) + return null; } - if (scheme == AuthenticationSchemes.Digest - && !((HttpDigestIdentity) id).IsValid (cred.Password, realm, method, null) - ) { - return null; + if (scheme == AuthenticationSchemes.Digest) { + var digestId = (HttpDigestIdentity) id; + if (!digestId.IsValid (cred.Password, realm, method, null)) + return null; } return new GenericPrincipal (id, cred.Roles); From b3cb11fc645714015e3822ba68c4e8c0291a4536 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 24 Jan 2019 21:21:11 +0900 Subject: [PATCH 2286/6294] [Modify] Polish it --- websocket-sharp/Net/HttpUtility.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index bebdb7b7d..5ec31cdfd 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -806,8 +806,7 @@ Func credentialsFinder if (basicId.Password != cred.Password) return null; } - - if (scheme == AuthenticationSchemes.Digest) { + else { var digestId = (HttpDigestIdentity) id; if (!digestId.IsValid (cred.Password, realm, method, null)) return null; From ac44ad80e944c379a3b3cde3e110da0dfd14c553 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 24 Jan 2019 21:35:10 +0900 Subject: [PATCH 2287/6294] [Modify] Polish it --- websocket-sharp/Net/HttpUtility.cs | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 5ec31cdfd..edd97f7d8 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -803,16 +803,15 @@ Func credentialsFinder if (scheme == AuthenticationSchemes.Basic) { var basicId = (HttpBasicIdentity) id; - if (basicId.Password != cred.Password) - return null; - } - else { - var digestId = (HttpDigestIdentity) id; - if (!digestId.IsValid (cred.Password, realm, method, null)) - return null; + return basicId.Password == cred.Password + ? new GenericPrincipal (id, cred.Roles) + : null; } - return new GenericPrincipal (id, cred.Roles); + var digestId = (HttpDigestIdentity) id; + return digestId.IsValid (cred.Password, realm, method, null) + ? new GenericPrincipal (id, cred.Roles) + : null; } internal static Encoding GetEncoding (string contentType) From 7a4ceaea8ee5d2a8d37ad3dffe88f4aa4c98baad Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 25 Jan 2019 21:49:21 +0900 Subject: [PATCH 2288/6294] [Modify] Polish it --- websocket-sharp/Net/HttpUtility.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index edd97f7d8..95ba882c9 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -779,8 +779,8 @@ Func credentialsFinder if (credentialsFinder == null) return null; - var comparison = StringComparison.OrdinalIgnoreCase; - if (response.IndexOf (scheme.ToString (), comparison) != 0) + var compType = StringComparison.OrdinalIgnoreCase; + if (response.IndexOf (scheme.ToString (), compType) != 0) return null; var res = AuthenticationResponse.Parse (response); From a36b0b7503ee790322bd7a09b6cf92aeba428de3 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 25 Jan 2019 21:57:07 +0900 Subject: [PATCH 2289/6294] [Modify] Polish it --- websocket-sharp/Net/HttpUtility.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 95ba882c9..2965db02d 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -817,11 +817,11 @@ Func credentialsFinder internal static Encoding GetEncoding (string contentType) { var name = "charset="; - var comparison = StringComparison.OrdinalIgnoreCase; + var compType = StringComparison.OrdinalIgnoreCase; foreach (var elm in contentType.SplitHeaderValue (';')) { var part = elm.Trim (); - if (part.IndexOf (name, comparison) != 0) + if (part.IndexOf (name, compType) != 0) continue; var val = part.GetValue ('=', true); From 0b3cc3a369f5e60c8b540c1842eb2ddd924e4af6 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 26 Jan 2019 22:15:06 +0900 Subject: [PATCH 2290/6294] [Modify] Polish it --- websocket-sharp/Net/HttpUtility.cs | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 2965db02d..6d0353a29 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -697,16 +697,10 @@ internal static Uri CreateRequestUrl ( string requestUri, string host, bool websocketRequest, bool secure ) { - if (requestUri == null) + if (requestUri == null || requestUri.Length == 0) return null; - if (host == null) - return null; - - if (requestUri.Length == 0) - return null; - - if (host.Length == 0) + if (host == null || host.Length == 0) return null; string schm = null; From e22444beae6073de46705ea067b0ba421743d0a1 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 27 Jan 2019 22:09:09 +0900 Subject: [PATCH 2291/6294] [Modify] 2019 --- websocket-sharp/Net/HttpUtility.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 6d0353a29..47ea7ee3a 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -8,7 +8,7 @@ * The MIT License * * Copyright (c) 2005-2009 Novell, Inc. (http://www.novell.com) - * Copyright (c) 2012-2016 sta.blockhead + * Copyright (c) 2012-2019 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From 1880af98fc10a5e5cfce62a770557c9524e6b080 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 28 Jan 2019 21:34:56 +0900 Subject: [PATCH 2292/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index bed790ec1..47122fa3f 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -928,9 +928,11 @@ internal static byte[] ToByteArray (this Stream stream) internal static CompressionMethod ToCompressionMethod (this string value) { - foreach (CompressionMethod method in Enum.GetValues (typeof (CompressionMethod))) + var methods = Enum.GetValues (typeof (CompressionMethod)); + foreach (CompressionMethod method in methods) { if (method.ToExtensionString () == value) return method; + } return CompressionMethod.None; } From 846dd0b7d2622484d2fad074f1c308bd3c3559cb Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 29 Jan 2019 20:57:45 +0900 Subject: [PATCH 2293/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 47122fa3f..0e5625e39 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -971,7 +971,9 @@ internal static System.Net.IPAddress ToIPAddress (this string value) } } - internal static List ToList (this IEnumerable source) + internal static List ToList ( + this IEnumerable source + ) { return new List (source); } From c1189241b38d0c13c7c1017e6d8bcfe2c108b0b1 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 29 Jan 2019 21:04:48 +0900 Subject: [PATCH 2294/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 0e5625e39..da31527df 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -982,7 +982,8 @@ internal static string ToString ( this System.Net.IPAddress address, bool bracketIPv6 ) { - return bracketIPv6 && address.AddressFamily == AddressFamily.InterNetworkV6 + return bracketIPv6 + && address.AddressFamily == AddressFamily.InterNetworkV6 ? String.Format ("[{0}]", address.ToString ()) : address.ToString (); } From ef552ed98d330bef1761b19e33b0987b977c7adb Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 30 Jan 2019 21:43:29 +0900 Subject: [PATCH 2295/6294] [Modify] Polish it --- websocket-sharp/Net/Cookie.cs | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/websocket-sharp/Net/Cookie.cs b/websocket-sharp/Net/Cookie.cs index 190d1b287..c19ef6c68 100644 --- a/websocket-sharp/Net/Cookie.cs +++ b/websocket-sharp/Net/Cookie.cs @@ -774,15 +774,23 @@ internal string ToResponseString () /// true if is equal to the current ; /// otherwise, false. /// - public override bool Equals (Object comparand) + public override bool Equals (object comparand) { var cookie = comparand as Cookie; - return cookie != null && - _name.Equals (cookie.Name, StringComparison.InvariantCultureIgnoreCase) && - _value.Equals (cookie.Value, StringComparison.InvariantCulture) && - _path.Equals (cookie.Path, StringComparison.InvariantCulture) && - _domain.Equals (cookie.Domain, StringComparison.InvariantCultureIgnoreCase) && - _version == cookie.Version; + return cookie != null + && _name.Equals ( + cookie._name, StringComparison.InvariantCultureIgnoreCase + ) + && _value.Equals ( + cookie._value, StringComparison.InvariantCulture + ) + && _path.Equals ( + cookie._path, StringComparison.InvariantCulture + ) + && _domain.Equals ( + cookie._domain, StringComparison.InvariantCultureIgnoreCase + ) + && _version == cookie._version; } /// From ceff87c0a00bbef27cad050d8bde6f421340f647 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 31 Jan 2019 22:24:48 +0900 Subject: [PATCH 2296/6294] [Modify] Edit it --- websocket-sharp/Net/Cookie.cs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Net/Cookie.cs b/websocket-sharp/Net/Cookie.cs index c19ef6c68..783fb959f 100644 --- a/websocket-sharp/Net/Cookie.cs +++ b/websocket-sharp/Net/Cookie.cs @@ -764,15 +764,21 @@ internal string ToResponseString () #region Public Methods /// - /// Determines whether the specified is equal to the current - /// . + /// Determines whether the current cookie instance is equal to + /// the specified instance. /// /// - /// An to compare with the current . + /// + /// An instance to compare with + /// the current cookie instance. + /// + /// + /// An reference to a instance. + /// /// /// - /// true if is equal to the current ; - /// otherwise, false. + /// true if the current cookie instance is equal to + /// ; otherwise, false. /// public override bool Equals (object comparand) { From 5d5a161fdfc9b131d40e51c98ad4529a693163c8 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 1 Feb 2019 21:52:36 +0900 Subject: [PATCH 2297/6294] [Modify] Polish it --- websocket-sharp/Net/Cookie.cs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Net/Cookie.cs b/websocket-sharp/Net/Cookie.cs index 783fb959f..a757e84e8 100644 --- a/websocket-sharp/Net/Cookie.cs +++ b/websocket-sharp/Net/Cookie.cs @@ -808,11 +808,12 @@ public override bool Equals (object comparand) public override int GetHashCode () { return hash ( - StringComparer.InvariantCultureIgnoreCase.GetHashCode (_name), - _value.GetHashCode (), - _path.GetHashCode (), - StringComparer.InvariantCultureIgnoreCase.GetHashCode (_domain), - _version); + StringComparer.InvariantCultureIgnoreCase.GetHashCode (_name), + _value.GetHashCode (), + _path.GetHashCode (), + StringComparer.InvariantCultureIgnoreCase.GetHashCode (_domain), + _version + ); } /// From 604df45d0e2dc63a10711daafde1db66e82d958b Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 2 Feb 2019 22:44:28 +0900 Subject: [PATCH 2298/6294] [Modify] Edit it --- websocket-sharp/Net/Cookie.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/Cookie.cs b/websocket-sharp/Net/Cookie.cs index a757e84e8..83f535d8e 100644 --- a/websocket-sharp/Net/Cookie.cs +++ b/websocket-sharp/Net/Cookie.cs @@ -800,10 +800,10 @@ public override bool Equals (object comparand) } /// - /// Serves as a hash function for a object. + /// Gets a hash code for the current cookie instance. /// /// - /// An that represents the hash code for the current . + /// An that represents the hash code. /// public override int GetHashCode () { From 43850ce2a1219a8e86c38381298b84acc9c52f2c Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 3 Feb 2019 21:46:05 +0900 Subject: [PATCH 2299/6294] [Modify] Edit it --- websocket-sharp/Net/Cookie.cs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Net/Cookie.cs b/websocket-sharp/Net/Cookie.cs index 83f535d8e..ba43ac0da 100644 --- a/websocket-sharp/Net/Cookie.cs +++ b/websocket-sharp/Net/Cookie.cs @@ -817,14 +817,11 @@ public override int GetHashCode () } /// - /// Returns a that represents the current . + /// Returns a string that represents the current cookie instance. /// - /// - /// This method returns a to use to send an HTTP Cookie to - /// an origin server. - /// /// - /// A that represents the current . + /// A to use to send an HTTP cookie to + /// an origin server. /// public override string ToString () { From 0dc64a8a02d2ad6fe176d6be03f4cad948e75a45 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 4 Feb 2019 21:37:00 +0900 Subject: [PATCH 2300/6294] [Modify] Edit it --- websocket-sharp/Net/Cookie.cs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/websocket-sharp/Net/Cookie.cs b/websocket-sharp/Net/Cookie.cs index ba43ac0da..b591b5f26 100644 --- a/websocket-sharp/Net/Cookie.cs +++ b/websocket-sharp/Net/Cookie.cs @@ -820,14 +820,10 @@ public override int GetHashCode () /// Returns a string that represents the current cookie instance. /// /// - /// A to use to send an HTTP cookie to - /// an origin server. + /// A that is suitable for the Cookie request header. /// public override string ToString () { - // i.e., only used for clients - // See para 4.2.2 of RFC 2109 and para 3.3.4 of RFC 2965 - // See also bug #316017 return ToRequestString (null); } From 820fa050a799093bf8569f4671f9d3ba93898e69 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 5 Feb 2019 21:26:48 +0900 Subject: [PATCH 2301/6294] [Modify] Polish it --- websocket-sharp/Net/Cookie.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/Cookie.cs b/websocket-sharp/Net/Cookie.cs index b591b5f26..dfbf91856 100644 --- a/websocket-sharp/Net/Cookie.cs +++ b/websocket-sharp/Net/Cookie.cs @@ -755,7 +755,11 @@ internal string ToRequestString (Uri uri) internal string ToResponseString () { return _name.Length > 0 - ? (_version == 0 ? toResponseStringVersion0 () : toResponseStringVersion1 ()) + ? ( + _version == 0 + ? toResponseStringVersion0 () + : toResponseStringVersion1 () + ) : String.Empty; } From 3e14ce12c7461e2933937b57ef221932da159d08 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 6 Feb 2019 21:56:58 +0900 Subject: [PATCH 2302/6294] [Modify] Polish it --- websocket-sharp/Net/Cookie.cs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/websocket-sharp/Net/Cookie.cs b/websocket-sharp/Net/Cookie.cs index dfbf91856..a6e23cfab 100644 --- a/websocket-sharp/Net/Cookie.cs +++ b/websocket-sharp/Net/Cookie.cs @@ -754,13 +754,11 @@ internal string ToRequestString (Uri uri) // From server to client internal string ToResponseString () { - return _name.Length > 0 - ? ( - _version == 0 - ? toResponseStringVersion0 () - : toResponseStringVersion1 () - ) - : String.Empty; + return _name.Length == 0 + ? String.Empty + : _version == 0 + ? toResponseStringVersion0 () + : toResponseStringVersion1 (); } #endregion From 5dc0256571584d8fcadd608be92016c07eeee800 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 7 Feb 2019 21:36:40 +0900 Subject: [PATCH 2303/6294] [Modify] Polish it --- websocket-sharp/Net/Cookie.cs | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/websocket-sharp/Net/Cookie.cs b/websocket-sharp/Net/Cookie.cs index a6e23cfab..0cc921544 100644 --- a/websocket-sharp/Net/Cookie.cs +++ b/websocket-sharp/Net/Cookie.cs @@ -727,28 +727,30 @@ internal string ToRequestString (Uri uri) if (_version == 0) return String.Format ("{0}={1}", _name, _value); - var output = new StringBuilder (64); - output.AppendFormat ("$Version={0}; {1}={2}", _version, _name, _value); + var buff = new StringBuilder (64); + + buff.AppendFormat ("$Version={0}; {1}={2}", _version, _name, _value); if (!_path.IsNullOrEmpty ()) - output.AppendFormat ("; $Path={0}", _path); + buff.AppendFormat ("; $Path={0}", _path); else if (uri != null) - output.AppendFormat ("; $Path={0}", uri.GetAbsolutePath ()); + buff.AppendFormat ("; $Path={0}", uri.GetAbsolutePath ()); else - output.Append ("; $Path=/"); + buff.Append ("; $Path=/"); - var appendDomain = uri == null || uri.Host != _domain; - if (appendDomain && !_domain.IsNullOrEmpty ()) - output.AppendFormat ("; $Domain={0}", _domain); + if (!_domain.IsNullOrEmpty ()) { + if (uri == null || uri.Host != _domain) + buff.AppendFormat ("; $Domain={0}", _domain); + } if (!_port.IsNullOrEmpty ()) { - if (_port == "\"\"") - output.Append ("; $Port"); + if (_port != "\"\"") + buff.AppendFormat ("; $Port={0}", _port); else - output.AppendFormat ("; $Port={0}", _port); + buff.Append ("; $Port"); } - return output.ToString (); + return buff.ToString (); } // From server to client From 65f9232d61701f873d79fc7082c41a4753f55842 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 8 Feb 2019 21:34:29 +0900 Subject: [PATCH 2304/6294] [Modify] Polish it --- websocket-sharp/Net/Cookie.cs | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/websocket-sharp/Net/Cookie.cs b/websocket-sharp/Net/Cookie.cs index 0cc921544..a730b4edb 100644 --- a/websocket-sharp/Net/Cookie.cs +++ b/websocket-sharp/Net/Cookie.cs @@ -623,29 +623,33 @@ private static int hash (int i, int j, int k, int l, int m) private string toResponseStringVersion0 () { - var output = new StringBuilder (64); - output.AppendFormat ("{0}={1}", _name, _value); + var buff = new StringBuilder (64); - if (_expires != DateTime.MinValue) - output.AppendFormat ( + buff.AppendFormat ("{0}={1}", _name, _value); + + if (_expires != DateTime.MinValue) { + buff.AppendFormat ( "; Expires={0}", _expires.ToUniversalTime ().ToString ( "ddd, dd'-'MMM'-'yyyy HH':'mm':'ss 'GMT'", - CultureInfo.CreateSpecificCulture ("en-US"))); + CultureInfo.CreateSpecificCulture ("en-US") + ) + ); + } if (!_path.IsNullOrEmpty ()) - output.AppendFormat ("; Path={0}", _path); + buff.AppendFormat ("; Path={0}", _path); if (!_domain.IsNullOrEmpty ()) - output.AppendFormat ("; Domain={0}", _domain); + buff.AppendFormat ("; Domain={0}", _domain); if (_secure) - output.Append ("; Secure"); + buff.Append ("; Secure"); if (_httpOnly) - output.Append ("; HttpOnly"); + buff.Append ("; HttpOnly"); - return output.ToString (); + return buff.ToString (); } private string toResponseStringVersion1 () From a6269761682a3c70dc755d78411b966b9f402a14 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 8 Feb 2019 21:43:44 +0900 Subject: [PATCH 2305/6294] [Modify] Polish it --- websocket-sharp/Net/Cookie.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/Cookie.cs b/websocket-sharp/Net/Cookie.cs index a730b4edb..5f8cb825f 100644 --- a/websocket-sharp/Net/Cookie.cs +++ b/websocket-sharp/Net/Cookie.cs @@ -668,9 +668,10 @@ private string toResponseStringVersion1 () buff.AppendFormat ("; Domain={0}", _domain); if (!_port.IsNullOrEmpty ()) { - buff.Append ( - _port != "\"\"" ? String.Format ("; Port={0}", _port) : "; Port" - ); + if (_port != "\"\"") + buff.AppendFormat ("; Port={0}", _port); + else + buff.Append ("; Port"); } if (!_comment.IsNullOrEmpty ()) From 41bfb52d02b3296d17c5d14204e0f7db5716a847 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 9 Feb 2019 22:11:28 +0900 Subject: [PATCH 2306/6294] [Modify] Edit it --- websocket-sharp/Net/Cookie.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/websocket-sharp/Net/Cookie.cs b/websocket-sharp/Net/Cookie.cs index 5f8cb825f..6e81e6477 100644 --- a/websocket-sharp/Net/Cookie.cs +++ b/websocket-sharp/Net/Cookie.cs @@ -723,7 +723,6 @@ private static bool tryCreatePorts (string value, out int[] result, out string p #region Internal Methods - // From client to server internal string ToRequestString (Uri uri) { if (_name.Length == 0) From 9ef48c884b4ae73ffff8613afafdb21701aeeb4b Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 9 Feb 2019 22:17:12 +0900 Subject: [PATCH 2307/6294] [Modify] Edit it --- websocket-sharp/Net/Cookie.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/Cookie.cs b/websocket-sharp/Net/Cookie.cs index 6e81e6477..73c2d812e 100644 --- a/websocket-sharp/Net/Cookie.cs +++ b/websocket-sharp/Net/Cookie.cs @@ -757,7 +757,13 @@ internal string ToRequestString (Uri uri) return buff.ToString (); } - // From server to client + /// + /// Returns a string that represents the current cookie instance. + /// + /// + /// A that is suitable for the Set-Cookie response + /// header. + /// internal string ToResponseString () { return _name.Length == 0 From 244057bb234bafa8512575e0c3ea26029d802d5b Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 10 Feb 2019 18:14:17 +0900 Subject: [PATCH 2308/6294] [Modify] Polish it --- websocket-sharp/Net/Cookie.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Net/Cookie.cs b/websocket-sharp/Net/Cookie.cs index 73c2d812e..41d5c7997 100644 --- a/websocket-sharp/Net/Cookie.cs +++ b/websocket-sharp/Net/Cookie.cs @@ -614,11 +614,11 @@ private static bool canSetValue (string value, out string message) private static int hash (int i, int j, int k, int l, int m) { - return i ^ - (j << 13 | j >> 19) ^ - (k << 26 | k >> 6) ^ - (l << 7 | l >> 25) ^ - (m << 20 | m >> 12); + return i + ^ (j << 13 | j >> 19) + ^ (k << 26 | k >> 6) + ^ (l << 7 | l >> 25) + ^ (m << 20 | m >> 12); } private string toResponseStringVersion0 () From 7059a70cdb7fe7e46a301106a3c0cad913b175c4 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 11 Feb 2019 22:46:41 +0900 Subject: [PATCH 2309/6294] [Modify] Polish it --- websocket-sharp/Net/Cookie.cs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/Cookie.cs b/websocket-sharp/Net/Cookie.cs index 41d5c7997..3f6132311 100644 --- a/websocket-sharp/Net/Cookie.cs +++ b/websocket-sharp/Net/Cookie.cs @@ -478,13 +478,19 @@ public string Port { throw new CookieException ( "The value specified for the Port attribute isn't enclosed in double quotes."); + int[] ports; string err; - if (!tryCreatePorts (value, out _ports, out err)) - throw new CookieException ( - String.Format ( - "The value specified for the Port attribute contains an invalid value: {0}", err)); + if (!tryCreatePorts (value, out ports, out err)) { + var msg = String.Format ( + "The value specified for the Port attribute contains an invalid value: {0}", + err + ); + + throw new CookieException (msg); + } _port = value; + _ports = ports; } } From ac12a0e32b7ab866ddf171203a6614b79ca90381 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 12 Feb 2019 21:53:03 +0900 Subject: [PATCH 2310/6294] [Modify] Add it --- websocket-sharp/Net/Cookie.cs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/websocket-sharp/Net/Cookie.cs b/websocket-sharp/Net/Cookie.cs index 3f6132311..67a7d8e91 100644 --- a/websocket-sharp/Net/Cookie.cs +++ b/websocket-sharp/Net/Cookie.cs @@ -699,6 +699,29 @@ private string toResponseStringVersion1 () return buff.ToString (); } + private static bool tryCreatePorts (string value, out int[] result) + { + result = null; + + var ports = value.Trim ('"').Split (','); + var len = ports.Length; + var res = new int[len]; + + for (var i = 0; i < len; i++) { + var port = ports[i].Trim (); + if (port.Length == 0) { + res[i] = Int32.MinValue; + continue; + } + + if (!Int32.TryParse (port, out res[i])) + return false; + } + + result = res; + return true; + } + private static bool tryCreatePorts (string value, out int[] result, out string parseError) { var ports = value.Trim ('"').Split (','); From b7b39203e95cf7a10b07613a273a7b25b39311b3 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 13 Feb 2019 21:25:18 +0900 Subject: [PATCH 2311/6294] [Modify] Replace it --- websocket-sharp/Net/Cookie.cs | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/websocket-sharp/Net/Cookie.cs b/websocket-sharp/Net/Cookie.cs index 67a7d8e91..6e0af0704 100644 --- a/websocket-sharp/Net/Cookie.cs +++ b/websocket-sharp/Net/Cookie.cs @@ -479,13 +479,8 @@ public string Port { "The value specified for the Port attribute isn't enclosed in double quotes."); int[] ports; - string err; - if (!tryCreatePorts (value, out ports, out err)) { - var msg = String.Format ( - "The value specified for the Port attribute contains an invalid value: {0}", - err - ); - + if (!tryCreatePorts (value, out ports)) { + var msg = "The value specified for the Port attribute contains an invalid value."; throw new CookieException (msg); } From 0ee98f87583ac894450fd11e58783cd5f8048066 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 14 Feb 2019 21:30:55 +0900 Subject: [PATCH 2312/6294] [Modify] Polish it --- websocket-sharp/Net/Cookie.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/Cookie.cs b/websocket-sharp/Net/Cookie.cs index 6e0af0704..82d39e660 100644 --- a/websocket-sharp/Net/Cookie.cs +++ b/websocket-sharp/Net/Cookie.cs @@ -474,13 +474,14 @@ public string Port { return; } - if (!value.IsEnclosedIn ('"')) - throw new CookieException ( - "The value specified for the Port attribute isn't enclosed in double quotes."); + if (!value.IsEnclosedIn ('"')) { + var msg = "The value is not enclosed in double quotes."; + throw new CookieException (msg); + } int[] ports; if (!tryCreatePorts (value, out ports)) { - var msg = "The value specified for the Port attribute contains an invalid value."; + var msg = "The value could not be parsed."; throw new CookieException (msg); } From bdded6d3105c8f5764351f93358c29cdc0a27961 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 15 Feb 2019 21:33:43 +0900 Subject: [PATCH 2313/6294] [Modify] Edit it --- websocket-sharp/Net/Cookie.cs | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/Cookie.cs b/websocket-sharp/Net/Cookie.cs index 82d39e660..f499628d2 100644 --- a/websocket-sharp/Net/Cookie.cs +++ b/websocket-sharp/Net/Cookie.cs @@ -455,11 +455,25 @@ public string Path { /// Gets or sets the value of the Port attribute of the cookie. /// /// - /// A that represents the list of TCP ports to which the cookie applies. + /// + /// A that represents the list of TCP ports + /// that the cookie applies to. + /// + /// + /// The default value is an empty string. + /// /// /// - /// The value specified for a set operation isn't enclosed in double quotes or - /// couldn't be parsed. + /// + /// The value specified for a set operation is not enclosed in + /// double quotes. + /// + /// + /// -or- + /// + /// + /// The value specified for a set operation could not be parsed. + /// /// public string Port { get { From 61292954f171d653698cba521962f875ea235269 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 16 Feb 2019 21:45:39 +0900 Subject: [PATCH 2314/6294] [Modify] Remove it --- websocket-sharp/Net/Cookie.cs | 26 -------------------------- 1 file changed, 26 deletions(-) diff --git a/websocket-sharp/Net/Cookie.cs b/websocket-sharp/Net/Cookie.cs index f499628d2..e1b8d5e89 100644 --- a/websocket-sharp/Net/Cookie.cs +++ b/websocket-sharp/Net/Cookie.cs @@ -732,32 +732,6 @@ private static bool tryCreatePorts (string value, out int[] result) return true; } - private static bool tryCreatePorts (string value, out int[] result, out string parseError) - { - var ports = value.Trim ('"').Split (','); - var len = ports.Length; - var res = new int[len]; - for (var i = 0; i < len; i++) { - res[i] = Int32.MinValue; - - var port = ports[i].Trim (); - if (port.Length == 0) - continue; - - if (!Int32.TryParse (port, out res[i])) { - result = new int[0]; - parseError = port; - - return false; - } - } - - result = res; - parseError = String.Empty; - - return true; - } - #endregion #region Internal Methods From 6eadaf2ccd0b64500e7b2b2cc36ce73b92be7c01 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 17 Feb 2019 17:52:40 +0900 Subject: [PATCH 2315/6294] [Modify] Polish it --- websocket-sharp/Net/Cookie.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Net/Cookie.cs b/websocket-sharp/Net/Cookie.cs index e1b8d5e89..8769804b6 100644 --- a/websocket-sharp/Net/Cookie.cs +++ b/websocket-sharp/Net/Cookie.cs @@ -713,18 +713,18 @@ private static bool tryCreatePorts (string value, out int[] result) { result = null; - var ports = value.Trim ('"').Split (','); - var len = ports.Length; + var arr = value.Trim ('"').Split (','); + var len = arr.Length; var res = new int[len]; for (var i = 0; i < len; i++) { - var port = ports[i].Trim (); - if (port.Length == 0) { + var s = arr[i].Trim (); + if (s.Length == 0) { res[i] = Int32.MinValue; continue; } - if (!Int32.TryParse (port, out res[i])) + if (!Int32.TryParse (s, out res[i])) return false; } From 0611e8a276e4ee7a0be5b410f346ac2c55dc1945 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 18 Feb 2019 20:20:36 +0900 Subject: [PATCH 2316/6294] [Modify] Add it --- websocket-sharp/Net/Cookie.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/websocket-sharp/Net/Cookie.cs b/websocket-sharp/Net/Cookie.cs index 8769804b6..9a83f355a 100644 --- a/websocket-sharp/Net/Cookie.cs +++ b/websocket-sharp/Net/Cookie.cs @@ -69,6 +69,7 @@ public sealed class Cookie private Uri _commentUri; private bool _discard; private string _domain; + private static readonly int[] _emptyPorts; private DateTime _expires; private bool _httpOnly; private string _name; @@ -88,6 +89,7 @@ public sealed class Cookie static Cookie () { + _emptyPorts = new int[0]; _reservedCharsForName = new[] { ' ', '=', ';', ',', '\n', '\r', '\t' }; _reservedCharsForValue = new[] { ';', ',' }; } From 884ac97de816bca04e118b882fd2548e5f5c78c4 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 18 Feb 2019 20:27:01 +0900 Subject: [PATCH 2317/6294] [Modify] Use it --- websocket-sharp/Net/Cookie.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/Cookie.cs b/websocket-sharp/Net/Cookie.cs index 9a83f355a..2bfc8f373 100644 --- a/websocket-sharp/Net/Cookie.cs +++ b/websocket-sharp/Net/Cookie.cs @@ -109,7 +109,6 @@ public Cookie () _name = String.Empty; _path = String.Empty; _port = String.Empty; - _ports = new int[0]; _timestamp = DateTime.Now; _value = String.Empty; _version = 0; @@ -272,7 +271,7 @@ internal int MaxAge { internal int[] Ports { get { - return _ports; + return _ports ?? _emptyPorts; } } @@ -485,7 +484,7 @@ public string Port { set { if (value.IsNullOrEmpty ()) { _port = String.Empty; - _ports = new int[0]; + _ports = null; return; } From 28684d8bdfa88cc1d37a11e7ff556871fdd4e171 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 19 Feb 2019 21:49:03 +0900 Subject: [PATCH 2318/6294] [Modify] Polish it --- websocket-sharp/Net/Cookie.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/Cookie.cs b/websocket-sharp/Net/Cookie.cs index 2bfc8f373..f74ecbef4 100644 --- a/websocket-sharp/Net/Cookie.cs +++ b/websocket-sharp/Net/Cookie.cs @@ -108,7 +108,6 @@ public Cookie () _expires = DateTime.MinValue; _name = String.Empty; _path = String.Empty; - _port = String.Empty; _timestamp = DateTime.Now; _value = String.Empty; _version = 0; @@ -478,12 +477,12 @@ public string Path { /// public string Port { get { - return _port; + return _port ?? String.Empty; } set { if (value.IsNullOrEmpty ()) { - _port = String.Empty; + _port = value; _ports = null; return; From 48ce156442c32aec1cca9b45056682b867b70c4e Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 20 Feb 2019 21:13:13 +0900 Subject: [PATCH 2319/6294] [Modify] Polish it --- websocket-sharp/Net/Cookie.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/Cookie.cs b/websocket-sharp/Net/Cookie.cs index f74ecbef4..579235abf 100644 --- a/websocket-sharp/Net/Cookie.cs +++ b/websocket-sharp/Net/Cookie.cs @@ -103,7 +103,6 @@ static Cookie () /// public Cookie () { - _comment = String.Empty; _domain = String.Empty; _expires = DateTime.MinValue; _name = String.Empty; @@ -286,11 +285,11 @@ internal int[] Ports { /// public string Comment { get { - return _comment; + return _comment ?? String.Empty; } set { - _comment = value ?? String.Empty; + _comment = value; } } From 9c9e2f5614a852b4d8f8f96fd658ac8625b3c483 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 20 Feb 2019 21:19:00 +0900 Subject: [PATCH 2320/6294] [Modify] Edit it --- websocket-sharp/Net/Cookie.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/Cookie.cs b/websocket-sharp/Net/Cookie.cs index 579235abf..26ade645e 100644 --- a/websocket-sharp/Net/Cookie.cs +++ b/websocket-sharp/Net/Cookie.cs @@ -281,7 +281,13 @@ internal int[] Ports { /// Gets or sets the value of the Comment attribute of the cookie. /// /// - /// A that represents the comment to document intended use of the cookie. + /// + /// A that represents the comment to document + /// intended use of the cookie. + /// + /// + /// The default value is an empty string. + /// /// public string Comment { get { From d8409c093bee1fe3d3831b9bdc8f11bacb68771e Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 21 Feb 2019 22:12:47 +0900 Subject: [PATCH 2321/6294] [Modify] Edit it --- websocket-sharp/Net/Cookie.cs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/Cookie.cs b/websocket-sharp/Net/Cookie.cs index 26ade645e..3c7957390 100644 --- a/websocket-sharp/Net/Cookie.cs +++ b/websocket-sharp/Net/Cookie.cs @@ -303,8 +303,16 @@ public string Comment { /// Gets or sets the value of the CommentURL attribute of the cookie. /// /// - /// A that represents the URI that provides the comment to document intended - /// use of the cookie. + /// + /// A that represents the URI that provides + /// the comment to document intended use of the cookie. + /// + /// + /// if this attribute is not needed. + /// + /// + /// The default value is . + /// /// public Uri CommentUri { get { From a23d2aae6c95be7bd1b93f709d7aa881cece8459 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 21 Feb 2019 22:16:16 +0900 Subject: [PATCH 2322/6294] [Modify] Edit it --- websocket-sharp/Net/Cookie.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/websocket-sharp/Net/Cookie.cs b/websocket-sharp/Net/Cookie.cs index 3c7957390..16e1151f6 100644 --- a/websocket-sharp/Net/Cookie.cs +++ b/websocket-sharp/Net/Cookie.cs @@ -286,6 +286,9 @@ internal int[] Ports { /// intended use of the cookie. /// /// + /// An empty string if this attribute is not needed. + /// + /// /// The default value is an empty string. /// /// From 9dbfec2dc883fc16efd8ac4ae719ff4b1d7c6dc9 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 22 Feb 2019 21:42:59 +0900 Subject: [PATCH 2323/6294] [Modify] Edit it --- websocket-sharp/Net/Cookie.cs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/Cookie.cs b/websocket-sharp/Net/Cookie.cs index 16e1151f6..c48bc9495 100644 --- a/websocket-sharp/Net/Cookie.cs +++ b/websocket-sharp/Net/Cookie.cs @@ -328,12 +328,17 @@ public Uri CommentUri { } /// - /// Gets or sets a value indicating whether the client discards the cookie unconditionally - /// when the client terminates. + /// Gets or sets a value indicating whether the client discards the cookie + /// unconditionally when the client terminates. /// /// - /// true if the client discards the cookie unconditionally when the client terminates; - /// otherwise, false. The default value is false. + /// + /// true if the client discards the cookie unconditionally + /// when the client terminates; otherwise, false. + /// + /// + /// The default value is false. + /// /// public bool Discard { get { From d3ac13b8e75c505fbed248addbfae14ea9a2762d Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 22 Feb 2019 22:19:06 +0900 Subject: [PATCH 2324/6294] [Modify] Edit it --- websocket-sharp/Net/Cookie.cs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/Cookie.cs b/websocket-sharp/Net/Cookie.cs index c48bc9495..05d6d4c9c 100644 --- a/websocket-sharp/Net/Cookie.cs +++ b/websocket-sharp/Net/Cookie.cs @@ -394,8 +394,16 @@ public bool Expired { /// Gets or sets the value of the Expires attribute of the cookie. /// /// - /// A that represents the date and time at which the cookie expires. - /// The default value is . + /// + /// A that represents the date and time that + /// the cookie expires on. + /// + /// + /// if this attribute is not needed. + /// + /// + /// The default value is . + /// /// public DateTime Expires { get { From 1eb03461704ea67950c6e2830918c308c1017275 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 23 Feb 2019 21:48:00 +0900 Subject: [PATCH 2325/6294] [Modify] Edit it --- websocket-sharp/Net/Cookie.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/Cookie.cs b/websocket-sharp/Net/Cookie.cs index 05d6d4c9c..27a358bb2 100644 --- a/websocket-sharp/Net/Cookie.cs +++ b/websocket-sharp/Net/Cookie.cs @@ -377,8 +377,12 @@ public string Domain { /// Gets or sets a value indicating whether the cookie has expired. /// /// - /// true if the cookie has expired; otherwise, false. - /// The default value is false. + /// + /// true if the cookie has expired; otherwise, false. + /// + /// + /// The default value is false. + /// /// public bool Expired { get { From 1f88f208de5fef752df7e41ea7e510cdb9c835c2 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 23 Feb 2019 21:56:45 +0900 Subject: [PATCH 2326/6294] [Modify] Edit it --- websocket-sharp/Net/Cookie.cs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/Cookie.cs b/websocket-sharp/Net/Cookie.cs index 27a358bb2..7b7bc9d28 100644 --- a/websocket-sharp/Net/Cookie.cs +++ b/websocket-sharp/Net/Cookie.cs @@ -420,11 +420,17 @@ public DateTime Expires { } /// - /// Gets or sets a value indicating whether non-HTTP APIs can access the cookie. + /// Gets or sets a value indicating whether non-HTTP APIs can access + /// the cookie. /// /// - /// true if non-HTTP APIs cannot access the cookie; otherwise, false. - /// The default value is false. + /// + /// true if non-HTTP APIs cannot access the cookie; otherwise, + /// false. + /// + /// + /// The default value is false. + /// /// public bool HttpOnly { get { From 04606f8bad9f874537bb4a57d0e5a33612232299 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 24 Feb 2019 19:29:24 +0900 Subject: [PATCH 2327/6294] [Modify] Edit it --- websocket-sharp/Net/Cookie.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/websocket-sharp/Net/Cookie.cs b/websocket-sharp/Net/Cookie.cs index 7b7bc9d28..4387e7173 100644 --- a/websocket-sharp/Net/Cookie.cs +++ b/websocket-sharp/Net/Cookie.cs @@ -499,6 +499,9 @@ public string Path { /// that the cookie applies to. /// /// + /// An empty string if this attribute is not needed. + /// + /// /// The default value is an empty string. /// /// From df6eafb23fb736d96c974484d1ddec6793679a05 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 25 Feb 2019 21:50:50 +0900 Subject: [PATCH 2328/6294] [Modify] Edit it --- websocket-sharp/Net/Cookie.cs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Net/Cookie.cs b/websocket-sharp/Net/Cookie.cs index 4387e7173..fccbb4bcf 100644 --- a/websocket-sharp/Net/Cookie.cs +++ b/websocket-sharp/Net/Cookie.cs @@ -547,15 +547,21 @@ public string Port { } /// - /// Gets or sets a value indicating whether the security level of the cookie is secure. + /// Gets or sets a value indicating whether the security level of + /// the cookie is secure. /// /// - /// When this property is true, the cookie may be included in the HTTP request - /// only if the request is transmitted over the HTTPS. + /// When this property is true, the cookie may be included in + /// the request only if the request is transmitted over HTTPS. /// /// - /// true if the security level of the cookie is secure; otherwise, false. - /// The default value is false. + /// + /// true if the security level of the cookie is secure; + /// otherwise, false. + /// + /// + /// The default value is false. + /// /// public bool Secure { get { From f796e0307c7c00cc29e9b3d564c5cfe090d065f8 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 26 Feb 2019 21:17:08 +0900 Subject: [PATCH 2329/6294] [Modify] Edit it --- websocket-sharp/Net/Cookie.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/Cookie.cs b/websocket-sharp/Net/Cookie.cs index fccbb4bcf..cef14b0b7 100644 --- a/websocket-sharp/Net/Cookie.cs +++ b/websocket-sharp/Net/Cookie.cs @@ -577,7 +577,8 @@ public bool Secure { /// Gets the time when the cookie was issued. /// /// - /// A that represents the time when the cookie was issued. + /// A that represents the time when + /// the cookie was issued. /// public DateTime TimeStamp { get { From 2d449f8622d79891774286e5fddef33a31953edf Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 26 Feb 2019 21:21:13 +0900 Subject: [PATCH 2330/6294] [Modify] Rename it --- websocket-sharp/Net/Cookie.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/Cookie.cs b/websocket-sharp/Net/Cookie.cs index cef14b0b7..ae2077533 100644 --- a/websocket-sharp/Net/Cookie.cs +++ b/websocket-sharp/Net/Cookie.cs @@ -79,7 +79,7 @@ public sealed class Cookie private static readonly char[] _reservedCharsForName; private static readonly char[] _reservedCharsForValue; private bool _secure; - private DateTime _timestamp; + private DateTime _timeStamp; private string _value; private int _version; @@ -107,7 +107,7 @@ public Cookie () _expires = DateTime.MinValue; _name = String.Empty; _path = String.Empty; - _timestamp = DateTime.Now; + _timeStamp = DateTime.Now; _value = String.Empty; _version = 0; } @@ -582,7 +582,7 @@ public bool Secure { /// public DateTime TimeStamp { get { - return _timestamp; + return _timeStamp; } } From 6f95c2925845452a411c028c57918349c32581a5 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 27 Feb 2019 21:19:54 +0900 Subject: [PATCH 2331/6294] [Modify] Polish it --- websocket-sharp/Net/Cookie.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/Cookie.cs b/websocket-sharp/Net/Cookie.cs index ae2077533..847086680 100644 --- a/websocket-sharp/Net/Cookie.cs +++ b/websocket-sharp/Net/Cookie.cs @@ -635,7 +635,7 @@ public int Version { set { if (value < 0 || value > 1) - throw new ArgumentOutOfRangeException ("value", "Not 0 or 1."); + throw new ArgumentOutOfRangeException ("value", "Not allowed."); _version = value; } From d05bc7c5d09ab42db0d7d339158a0bc985212134 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 28 Feb 2019 21:36:22 +0900 Subject: [PATCH 2332/6294] [Modify] Edit it --- websocket-sharp/Net/Cookie.cs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/Cookie.cs b/websocket-sharp/Net/Cookie.cs index 847086680..941522e87 100644 --- a/websocket-sharp/Net/Cookie.cs +++ b/websocket-sharp/Net/Cookie.cs @@ -622,11 +622,19 @@ public string Value { /// Gets or sets the value of the Version attribute of the cookie. /// /// - /// An that represents the version of the HTTP state management - /// to which the cookie conforms. + /// + /// An that represents the version of HTTP state + /// management that the cookie conforms to. + /// + /// + /// 0 or 1. + /// + /// + /// The default value is 0. + /// /// /// - /// The value specified for a set operation isn't 0 or 1. + /// The value specified for a set operation is not allowed. /// public int Version { get { From 76eb7d157c6e879b4c81ee62e032414c25b4189f Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 28 Feb 2019 21:40:05 +0900 Subject: [PATCH 2333/6294] [Modify] Polish it --- websocket-sharp/Net/Cookie.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/websocket-sharp/Net/Cookie.cs b/websocket-sharp/Net/Cookie.cs index 941522e87..974879561 100644 --- a/websocket-sharp/Net/Cookie.cs +++ b/websocket-sharp/Net/Cookie.cs @@ -109,7 +109,6 @@ public Cookie () _path = String.Empty; _timeStamp = DateTime.Now; _value = String.Empty; - _version = 0; } /// From d732d88ba20784389fc781e3a2a0032b97375567 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 1 Mar 2019 21:43:54 +0900 Subject: [PATCH 2334/6294] [Modify] Polish it --- websocket-sharp/Net/Cookie.cs | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/websocket-sharp/Net/Cookie.cs b/websocket-sharp/Net/Cookie.cs index 974879561..4c9f12978 100644 --- a/websocket-sharp/Net/Cookie.cs +++ b/websocket-sharp/Net/Cookie.cs @@ -361,14 +361,8 @@ public string Domain { } set { - if (value.IsNullOrEmpty ()) { - _domain = String.Empty; - ExactDomain = true; - } - else { - _domain = value; - ExactDomain = value[0] != '.'; - } + _domain = value ?? String.Empty; + ExactDomain = _domain.Length == 0 || _domain[0] != '.'; } } From 789e779048e54d56cc6be104b58c5dcee0b943bc Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 1 Mar 2019 21:55:20 +0900 Subject: [PATCH 2335/6294] [Modify] Move it --- websocket-sharp/Net/Cookie.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/Cookie.cs b/websocket-sharp/Net/Cookie.cs index 4c9f12978..7f339bb42 100644 --- a/websocket-sharp/Net/Cookie.cs +++ b/websocket-sharp/Net/Cookie.cs @@ -247,7 +247,9 @@ public Cookie (string name, string value, string path, string domain) #region Internal Properties internal bool ExactDomain { - get; set; + get { + return _domain.Length == 0 || _domain[0] != '.'; + } } internal int MaxAge { @@ -362,7 +364,6 @@ public string Domain { set { _domain = value ?? String.Empty; - ExactDomain = _domain.Length == 0 || _domain[0] != '.'; } } From 3cc6d8b419f298d068c4d45108a1f6561c58b851 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 2 Mar 2019 21:49:57 +0900 Subject: [PATCH 2336/6294] [Modify] Edit it --- websocket-sharp/Net/Cookie.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/Cookie.cs b/websocket-sharp/Net/Cookie.cs index 7f339bb42..253b40d4c 100644 --- a/websocket-sharp/Net/Cookie.cs +++ b/websocket-sharp/Net/Cookie.cs @@ -355,7 +355,13 @@ public bool Discard { /// Gets or sets the value of the Domain attribute of the cookie. /// /// - /// A that represents the URI for which the cookie is valid. + /// + /// A that represents the domain name that + /// the cookie is valid for. + /// + /// + /// An empty string if this attribute is not needed. + /// /// public string Domain { get { From 0c7312da5f18f035c58845a018b02966ce666a6d Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 3 Mar 2019 22:14:57 +0900 Subject: [PATCH 2337/6294] [Modify] Edit it --- websocket-sharp/Net/Cookie.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/Cookie.cs b/websocket-sharp/Net/Cookie.cs index 253b40d4c..d7f994c6d 100644 --- a/websocket-sharp/Net/Cookie.cs +++ b/websocket-sharp/Net/Cookie.cs @@ -477,8 +477,8 @@ public string Name { /// Gets or sets the value of the Path attribute of the cookie. /// /// - /// A that represents the subset of URI on the origin server - /// to which the cookie applies. + /// A that represents the subset of URI on + /// the origin server that the cookie applies to. /// public string Path { get { From 276b18929d21a448489bb8f1e12c030b53b22f69 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 4 Mar 2019 21:06:37 +0900 Subject: [PATCH 2338/6294] [Modify] Add it --- websocket-sharp/Net/Cookie.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/websocket-sharp/Net/Cookie.cs b/websocket-sharp/Net/Cookie.cs index d7f994c6d..cfc9dc650 100644 --- a/websocket-sharp/Net/Cookie.cs +++ b/websocket-sharp/Net/Cookie.cs @@ -694,6 +694,17 @@ private static int hash (int i, int j, int k, int l, int m) ^ (m << 20 | m >> 12); } + private void init (string name, string value, string path, string domain) + { + _name = name; + _value = value; + _path = path; + _domain = domain; + + _expires = DateTime.MinValue; + _timeStamp = DateTime.Now; + } + private string toResponseStringVersion0 () { var buff = new StringBuilder (64); From f3bb8a792daee89933494b781137d3dbd86c9708 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 5 Mar 2019 21:27:35 +0900 Subject: [PATCH 2339/6294] [Modify] Replace it --- websocket-sharp/Net/Cookie.cs | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/Cookie.cs b/websocket-sharp/Net/Cookie.cs index cfc9dc650..3481cf105 100644 --- a/websocket-sharp/Net/Cookie.cs +++ b/websocket-sharp/Net/Cookie.cs @@ -237,9 +237,29 @@ public Cookie (string name, string value, string path) /// /// public Cookie (string name, string value, string path, string domain) - : this (name, value, path) { - Domain = domain; + if (name == null) + throw new ArgumentNullException ("name"); + + if (value == null) + throw new ArgumentNullException ("value"); + + if (name.Length == 0) + throw new ArgumentException ("An empty string.", "name"); + + if (name[0] == '$' || name.Contains (_reservedCharsForName)) { + var msg = "It contains an invalid character."; + throw new ArgumentException (msg, "name"); + } + + if (value.Contains (_reservedCharsForValue)) { + if (!value.IsEnclosedIn ('"')) { + var msg = "It contains an invalid character."; + throw new ArgumentException (msg, "value"); + } + } + + init (name, value, path ?? String.Empty, domain ?? String.Empty); } #endregion From 04249925c129d26056104d0aff58be63e23cfa0f Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 6 Mar 2019 21:13:28 +0900 Subject: [PATCH 2340/6294] [Modify] Polish it --- websocket-sharp/Net/Cookie.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/Cookie.cs b/websocket-sharp/Net/Cookie.cs index 3481cf105..bacaf9d3b 100644 --- a/websocket-sharp/Net/Cookie.cs +++ b/websocket-sharp/Net/Cookie.cs @@ -247,14 +247,19 @@ public Cookie (string name, string value, string path, string domain) if (name.Length == 0) throw new ArgumentException ("An empty string.", "name"); - if (name[0] == '$' || name.Contains (_reservedCharsForName)) { + if (name[0] == '$') { + var msg = "It starts with a dollar sign."; + throw new ArgumentException (msg, "name"); + } + + if (name.Contains (_reservedCharsForName)) { var msg = "It contains an invalid character."; throw new ArgumentException (msg, "name"); } if (value.Contains (_reservedCharsForValue)) { if (!value.IsEnclosedIn ('"')) { - var msg = "It contains an invalid character."; + var msg = "A string not enclosed in double quotes."; throw new ArgumentException (msg, "value"); } } From 15e723ed995015674959bd3938fd41fadc13dc2a Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 7 Mar 2019 21:13:18 +0900 Subject: [PATCH 2341/6294] [Modify] Edit it --- websocket-sharp/Net/Cookie.cs | 36 +++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/websocket-sharp/Net/Cookie.cs b/websocket-sharp/Net/Cookie.cs index bacaf9d3b..17a176847 100644 --- a/websocket-sharp/Net/Cookie.cs +++ b/websocket-sharp/Net/Cookie.cs @@ -196,43 +196,55 @@ public Cookie (string name, string value, string path) } /// - /// Initializes a new instance of the class with the specified - /// , , , and - /// . + /// Initializes a new instance of the class with + /// the specified name, value, path, and domain. /// /// - /// A that represents the Name of the cookie. + /// A that specifies the Name of the cookie. /// /// - /// A that represents the Value of the cookie. + /// A that specifies the Value of the cookie. /// /// - /// A that represents the value of the Path attribute of the cookie. + /// A that specifies the value of the Path + /// attribute of the cookie. /// /// - /// A that represents the value of the Domain attribute of the cookie. + /// A that specifies the value of the Domain + /// attribute of the cookie. /// - /// + /// /// - /// is or empty. + /// is . /// /// /// - or - /// /// - /// contains an invalid character. + /// is . + /// + /// + /// + /// + /// is an empty string. /// /// /// - or - /// /// - /// is . + /// starts with a dollar sign. /// /// /// - or - /// /// - /// contains a string not enclosed in double quotes + /// contains an invalid character. + /// + /// + /// - or - + /// + /// + /// is a string not enclosed in double quotes /// that contains an invalid character. /// /// From c77250c2c8fccb2da8886ba445a4d7ddebbe6b9f Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 7 Mar 2019 21:17:01 +0900 Subject: [PATCH 2342/6294] [Modify] Replace it --- websocket-sharp/Net/Cookie.cs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/websocket-sharp/Net/Cookie.cs b/websocket-sharp/Net/Cookie.cs index 17a176847..7998f4540 100644 --- a/websocket-sharp/Net/Cookie.cs +++ b/websocket-sharp/Net/Cookie.cs @@ -103,12 +103,7 @@ static Cookie () /// public Cookie () { - _domain = String.Empty; - _expires = DateTime.MinValue; - _name = String.Empty; - _path = String.Empty; - _timeStamp = DateTime.Now; - _value = String.Empty; + init (String.Empty, String.Empty, String.Empty, String.Empty); } /// From 35793552213e6ab0528e112af2cde86ab2678aa5 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 7 Mar 2019 21:21:13 +0900 Subject: [PATCH 2343/6294] [Modify] Replace it --- websocket-sharp/Net/Cookie.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/websocket-sharp/Net/Cookie.cs b/websocket-sharp/Net/Cookie.cs index 7998f4540..c5060a07d 100644 --- a/websocket-sharp/Net/Cookie.cs +++ b/websocket-sharp/Net/Cookie.cs @@ -141,10 +141,8 @@ public Cookie () /// /// public Cookie (string name, string value) - : this () + : this (name, value, String.Empty, String.Empty) { - Name = name; - Value = value; } /// From 3f229f25a4174b058146fd22c77b42915fd7c26c Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 7 Mar 2019 21:27:43 +0900 Subject: [PATCH 2344/6294] [Modify] Edit it --- websocket-sharp/Net/Cookie.cs | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/websocket-sharp/Net/Cookie.cs b/websocket-sharp/Net/Cookie.cs index c5060a07d..5f22aadf2 100644 --- a/websocket-sharp/Net/Cookie.cs +++ b/websocket-sharp/Net/Cookie.cs @@ -107,36 +107,47 @@ public Cookie () } /// - /// Initializes a new instance of the class with the specified - /// and . + /// Initializes a new instance of the class with + /// the specified name and value. /// /// - /// A that represents the Name of the cookie. + /// A that specifies the Name of the cookie. /// /// - /// A that represents the Value of the cookie. + /// A that specifies the Value of the cookie. /// - /// + /// /// - /// is or empty. + /// is . /// /// /// - or - /// /// - /// contains an invalid character. + /// is . + /// + /// + /// + /// + /// is an empty string. /// /// /// - or - /// /// - /// is . + /// starts with a dollar sign. /// /// /// - or - /// /// - /// contains a string not enclosed in double quotes + /// contains an invalid character. + /// + /// + /// - or - + /// + /// + /// is a string not enclosed in double quotes /// that contains an invalid character. /// /// From 1bbc9090b7d0d902e8019cb3a93ec196f5db897e Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 7 Mar 2019 21:30:22 +0900 Subject: [PATCH 2345/6294] [Modify] Replace it --- websocket-sharp/Net/Cookie.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/websocket-sharp/Net/Cookie.cs b/websocket-sharp/Net/Cookie.cs index 5f22aadf2..c8bc2eee6 100644 --- a/websocket-sharp/Net/Cookie.cs +++ b/websocket-sharp/Net/Cookie.cs @@ -194,9 +194,8 @@ public Cookie (string name, string value) /// /// public Cookie (string name, string value, string path) - : this (name, value) + : this (name, value, path, String.Empty) { - Path = path; } /// From 73c3c738b3d43b848667c8e09379a09f7cfcaae4 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 8 Mar 2019 21:56:55 +0900 Subject: [PATCH 2346/6294] [Modify] Edit it --- websocket-sharp/Net/Cookie.cs | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/websocket-sharp/Net/Cookie.cs b/websocket-sharp/Net/Cookie.cs index c8bc2eee6..bac317423 100644 --- a/websocket-sharp/Net/Cookie.cs +++ b/websocket-sharp/Net/Cookie.cs @@ -157,39 +157,51 @@ public Cookie (string name, string value) } /// - /// Initializes a new instance of the class with the specified - /// , , and . + /// Initializes a new instance of the class with + /// the specified name, value, and path. /// /// - /// A that represents the Name of the cookie. + /// A that specifies the Name of the cookie. /// /// - /// A that represents the Value of the cookie. + /// A that specifies the Value of the cookie. /// /// - /// A that represents the value of the Path attribute of the cookie. + /// A that specifies the value of the Path + /// attribute of the cookie. /// - /// + /// /// - /// is or empty. + /// is . /// /// /// - or - /// /// - /// contains an invalid character. + /// is . + /// + /// + /// + /// + /// is an empty string. /// /// /// - or - /// /// - /// is . + /// starts with a dollar sign. /// /// /// - or - /// /// - /// contains a string not enclosed in double quotes + /// contains an invalid character. + /// + /// + /// - or - + /// + /// + /// is a string not enclosed in double quotes /// that contains an invalid character. /// /// From 16c85a524adfe9fbb39cf67fcf75980dea64bcb3 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 9 Mar 2019 21:45:11 +0900 Subject: [PATCH 2347/6294] [Modify] Replace it --- websocket-sharp/Net/Cookie.cs | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/Cookie.cs b/websocket-sharp/Net/Cookie.cs index bac317423..3f3ba7b97 100644 --- a/websocket-sharp/Net/Cookie.cs +++ b/websocket-sharp/Net/Cookie.cs @@ -517,9 +517,21 @@ public string Name { } set { - string msg; - if (!canSetName (value, out msg)) - throw new CookieException (msg); + if (value == null) + throw new ArgumentNullException ("value"); + + if (value.Length == 0) + throw new ArgumentException ("An empty string.", "value"); + + if (value[0] == '$') { + var msg = "It starts with a dollar sign."; + throw new ArgumentException (msg, "value"); + } + + if (value.Contains (_reservedCharsForName)) { + var msg = "It contains an invalid character."; + throw new ArgumentException (msg, "value"); + } _name = value; } From 1230d354a01ed3fa702a54d3b00f443c3b47ae24 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 10 Mar 2019 22:37:57 +0900 Subject: [PATCH 2348/6294] [Modify] Edit it --- websocket-sharp/Net/Cookie.cs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/Cookie.cs b/websocket-sharp/Net/Cookie.cs index 3f3ba7b97..5890f7fa3 100644 --- a/websocket-sharp/Net/Cookie.cs +++ b/websocket-sharp/Net/Cookie.cs @@ -500,9 +500,18 @@ public bool HttpOnly { /// /// A that represents the Name of the cookie. /// - /// + /// + /// The value specified for a set operation is . + /// + /// + /// + /// The value specified for a set operation is an empty string. + /// + /// + /// - or - + /// /// - /// The value specified for a set operation is or empty. + /// The value specified for a set operation starts with a dollar sign. /// /// /// - or - From 4223d1ced92bf17ed8ea3fc8a0578f37db41b0be Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 11 Mar 2019 21:38:17 +0900 Subject: [PATCH 2349/6294] [Modify] Replace it --- websocket-sharp/Net/Cookie.cs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/Cookie.cs b/websocket-sharp/Net/Cookie.cs index 5890f7fa3..317568fbd 100644 --- a/websocket-sharp/Net/Cookie.cs +++ b/websocket-sharp/Net/Cookie.cs @@ -683,9 +683,15 @@ public string Value { } set { - string msg; - if (!canSetValue (value, out msg)) - throw new CookieException (msg); + if (value == null) + throw new ArgumentNullException ("value"); + + if (value.Contains (_reservedCharsForValue)) { + if (!value.IsEnclosedIn ('"')) { + var msg = "A string not enclosed in double quotes."; + throw new ArgumentException (msg, "value"); + } + } _value = value.Length > 0 ? value : "\"\""; } From 69ec79feb0820e607c268e0f9a3b36677e5a27bd Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 12 Mar 2019 21:20:41 +0900 Subject: [PATCH 2350/6294] [Modify] Edit it --- websocket-sharp/Net/Cookie.cs | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/websocket-sharp/Net/Cookie.cs b/websocket-sharp/Net/Cookie.cs index 317568fbd..77a8800ef 100644 --- a/websocket-sharp/Net/Cookie.cs +++ b/websocket-sharp/Net/Cookie.cs @@ -665,17 +665,12 @@ public DateTime TimeStamp { /// /// A that represents the Value of the cookie. /// - /// - /// - /// The value specified for a set operation is . - /// - /// - /// - or - - /// - /// - /// The value specified for a set operation contains a string not enclosed in double quotes - /// that contains an invalid character. - /// + /// + /// The value specified for a set operation is . + /// + /// + /// The value specified for a set operation is a string not enclosed in + /// double quotes that contains an invalid character. /// public string Value { get { From a72c4feb7cd1c8462b7fe4651f96cbce24b6a2d6 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 13 Mar 2019 21:43:52 +0900 Subject: [PATCH 2351/6294] [Modify] Replace it --- websocket-sharp/Net/Cookie.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/Cookie.cs b/websocket-sharp/Net/Cookie.cs index 77a8800ef..f4673f39f 100644 --- a/websocket-sharp/Net/Cookie.cs +++ b/websocket-sharp/Net/Cookie.cs @@ -103,7 +103,7 @@ static Cookie () /// public Cookie () { - init (String.Empty, String.Empty, String.Empty, String.Empty); + init (String.Empty, "\"\"", String.Empty, String.Empty); } /// From d387a06273ed8d1cedff5ee3503b47b1984f4664 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 13 Mar 2019 21:51:03 +0900 Subject: [PATCH 2352/6294] [Modify] Replace it --- websocket-sharp/Net/Cookie.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/Cookie.cs b/websocket-sharp/Net/Cookie.cs index f4673f39f..0613eb09a 100644 --- a/websocket-sharp/Net/Cookie.cs +++ b/websocket-sharp/Net/Cookie.cs @@ -291,7 +291,12 @@ public Cookie (string name, string value, string path, string domain) } } - init (name, value, path ?? String.Empty, domain ?? String.Empty); + init ( + name, + value.Length > 0 ? value : "\"\"", + path ?? String.Empty, + domain ?? String.Empty + ); } #endregion From c5956f861b06ebb8de9c0ac4fb96467e486cf399 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 14 Mar 2019 21:18:25 +0900 Subject: [PATCH 2353/6294] [Modify] Replace them --- websocket-sharp/Net/Cookie.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/Cookie.cs b/websocket-sharp/Net/Cookie.cs index 0613eb09a..3c72d1f42 100644 --- a/websocket-sharp/Net/Cookie.cs +++ b/websocket-sharp/Net/Cookie.cs @@ -609,14 +609,14 @@ public string Port { } if (!value.IsEnclosedIn ('"')) { - var msg = "The value is not enclosed in double quotes."; - throw new CookieException (msg); + var msg = "A string not enclosed in double quotes."; + throw new ArgumentException (msg, "value"); } int[] ports; if (!tryCreatePorts (value, out ports)) { - var msg = "The value could not be parsed."; - throw new CookieException (msg); + var msg = "It could not be parsed."; + throw new ArgumentException (msg, "value"); } _port = value; From d824a8fa7f7f42cb3a7652e3c56b110956e1aef7 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 14 Mar 2019 21:23:51 +0900 Subject: [PATCH 2354/6294] [Modify] Edit it --- websocket-sharp/Net/Cookie.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/Cookie.cs b/websocket-sharp/Net/Cookie.cs index 3c72d1f42..6deee05e6 100644 --- a/websocket-sharp/Net/Cookie.cs +++ b/websocket-sharp/Net/Cookie.cs @@ -583,7 +583,7 @@ public string Path { /// The default value is an empty string. /// /// - /// + /// /// /// The value specified for a set operation is not enclosed in /// double quotes. From 61536a7732aff1093781f0d11681d12acde32f4c Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 15 Mar 2019 21:13:34 +0900 Subject: [PATCH 2355/6294] [Modify] Polish it --- websocket-sharp/Net/Cookie.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/Cookie.cs b/websocket-sharp/Net/Cookie.cs index 6deee05e6..bdb3d31d2 100644 --- a/websocket-sharp/Net/Cookie.cs +++ b/websocket-sharp/Net/Cookie.cs @@ -721,8 +721,10 @@ public int Version { } set { - if (value < 0 || value > 1) - throw new ArgumentOutOfRangeException ("value", "Not allowed."); + if (value < 0 || value > 1) { + var msg = "It is not allowed."; + throw new ArgumentOutOfRangeException ("value", msg); + } _version = value; } From 42122bdad4ed2278c3670227a0a659b3acfc6cf0 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 15 Mar 2019 21:15:46 +0900 Subject: [PATCH 2356/6294] [Modify] Polish it --- websocket-sharp/Net/Cookie.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/Cookie.cs b/websocket-sharp/Net/Cookie.cs index bdb3d31d2..ae0e9e1ff 100644 --- a/websocket-sharp/Net/Cookie.cs +++ b/websocket-sharp/Net/Cookie.cs @@ -609,7 +609,7 @@ public string Port { } if (!value.IsEnclosedIn ('"')) { - var msg = "A string not enclosed in double quotes."; + var msg = "It is not enclosed in double quotes."; throw new ArgumentException (msg, "value"); } From 068e34f5387d06e0bbee086cc0210b241c50797f Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 16 Mar 2019 22:02:43 +0900 Subject: [PATCH 2357/6294] [Modify] Remove it --- websocket-sharp/Net/Cookie.cs | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/websocket-sharp/Net/Cookie.cs b/websocket-sharp/Net/Cookie.cs index ae0e9e1ff..2e6837444 100644 --- a/websocket-sharp/Net/Cookie.cs +++ b/websocket-sharp/Net/Cookie.cs @@ -734,22 +734,6 @@ public int Version { #region Private Methods - private static bool canSetName (string name, out string message) - { - if (name.IsNullOrEmpty ()) { - message = "The value specified for the Name is null or empty."; - return false; - } - - if (name[0] == '$' || name.Contains (_reservedCharsForName)) { - message = "The value specified for the Name contains an invalid character."; - return false; - } - - message = String.Empty; - return true; - } - private static bool canSetValue (string value, out string message) { if (value == null) { From f9cb9bed87f060d2366cd103751ddc7ccd174ff1 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 16 Mar 2019 22:03:51 +0900 Subject: [PATCH 2358/6294] [Modify] Remove it --- websocket-sharp/Net/Cookie.cs | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/websocket-sharp/Net/Cookie.cs b/websocket-sharp/Net/Cookie.cs index 2e6837444..bc52832e6 100644 --- a/websocket-sharp/Net/Cookie.cs +++ b/websocket-sharp/Net/Cookie.cs @@ -734,22 +734,6 @@ public int Version { #region Private Methods - private static bool canSetValue (string value, out string message) - { - if (value == null) { - message = "The value specified for the Value is null."; - return false; - } - - if (value.Contains (_reservedCharsForValue) && !value.IsEnclosedIn ('"')) { - message = "The value specified for the Value contains an invalid character."; - return false; - } - - message = String.Empty; - return true; - } - private static int hash (int i, int j, int k, int l, int m) { return i From 5f00e58116a4ce0cb0e87e65aae3ef6453d0b900 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 17 Mar 2019 22:32:44 +0900 Subject: [PATCH 2359/6294] [Modify] Edit it --- websocket-sharp/Net/Cookie.cs | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Net/Cookie.cs b/websocket-sharp/Net/Cookie.cs index bc52832e6..507c1c401 100644 --- a/websocket-sharp/Net/Cookie.cs +++ b/websocket-sharp/Net/Cookie.cs @@ -47,17 +47,31 @@ namespace WebSocketSharp.Net { /// - /// Provides a set of methods and properties used to manage an HTTP Cookie. + /// Provides a set of methods and properties used to manage an HTTP cookie. /// /// /// - /// The Cookie class supports the following cookie formats: - /// Netscape specification, - /// RFC 2109, and - /// RFC 2965 + /// This class supports the following cookie formats: /// + /// + /// + /// + /// Netscape specification + /// + /// + /// + /// + /// RFC 2109 + /// + /// + /// + /// + /// RFC 2965 + /// + /// + /// /// - /// The Cookie class cannot be inherited. + /// This class cannot be inherited. /// /// [Serializable] From 835814347ade7eb50d650039ce9c424700d7a813 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 18 Mar 2019 21:19:53 +0900 Subject: [PATCH 2360/6294] [Modify] Edit it --- websocket-sharp/Net/Cookie.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/Cookie.cs b/websocket-sharp/Net/Cookie.cs index 507c1c401..4340f1e69 100644 --- a/websocket-sharp/Net/Cookie.cs +++ b/websocket-sharp/Net/Cookie.cs @@ -51,7 +51,7 @@ namespace WebSocketSharp.Net /// /// /// - /// This class supports the following cookie formats: + /// This class refers to the following specifications: /// /// /// From 2274f8ab5f9b3bb8d98f9e6758f5385aa4407579 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 18 Mar 2019 21:29:15 +0900 Subject: [PATCH 2361/6294] [Modify] Edit it --- websocket-sharp/Net/Cookie.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/Cookie.cs b/websocket-sharp/Net/Cookie.cs index 4340f1e69..480290539 100644 --- a/websocket-sharp/Net/Cookie.cs +++ b/websocket-sharp/Net/Cookie.cs @@ -61,7 +61,7 @@ namespace WebSocketSharp.Net /// /// /// - /// RFC 2109 + /// RFC 2109 /// /// /// From 8108fa030c89a39ad98faba90279f7c7cd085960 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 18 Mar 2019 21:31:59 +0900 Subject: [PATCH 2362/6294] [Modify] Edit it --- websocket-sharp/Net/Cookie.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/Cookie.cs b/websocket-sharp/Net/Cookie.cs index 480290539..e9862579b 100644 --- a/websocket-sharp/Net/Cookie.cs +++ b/websocket-sharp/Net/Cookie.cs @@ -66,7 +66,7 @@ namespace WebSocketSharp.Net /// /// /// - /// RFC 2965 + /// RFC 2965 /// /// /// From e28c43166c2b2e37596bc9a8fde0bf6b9592475a Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 19 Mar 2019 22:11:56 +0900 Subject: [PATCH 2363/6294] [Modify] Edit it --- websocket-sharp/Net/Cookie.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/Cookie.cs b/websocket-sharp/Net/Cookie.cs index e9862579b..aba276ab9 100644 --- a/websocket-sharp/Net/Cookie.cs +++ b/websocket-sharp/Net/Cookie.cs @@ -2,7 +2,7 @@ /* * Cookie.cs * - * This code is derived from System.Net.Cookie.cs of Mono + * This code is derived from Cookie.cs (System.Net) of Mono * (http://www.mono-project.com). * * The MIT License From f25684de03cee23c1c5ed78e42b2472ca33d1f4e Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 19 Mar 2019 22:14:44 +0900 Subject: [PATCH 2364/6294] [Modify] 2019 --- websocket-sharp/Net/Cookie.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/Cookie.cs b/websocket-sharp/Net/Cookie.cs index aba276ab9..cf457fce1 100644 --- a/websocket-sharp/Net/Cookie.cs +++ b/websocket-sharp/Net/Cookie.cs @@ -8,7 +8,7 @@ * The MIT License * * Copyright (c) 2004,2009 Novell, Inc. (http://www.novell.com) - * Copyright (c) 2012-2014 sta.blockhead + * Copyright (c) 2012-2019 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From dee7cb9e5f8d42324e564708b75cfe0afd2a92b5 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 20 Mar 2019 22:54:40 +0900 Subject: [PATCH 2365/6294] [Modify] Move it --- websocket-sharp/Net/CookieCollection.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/CookieCollection.cs b/websocket-sharp/Net/CookieCollection.cs index fc9df33cc..8df6d52ec 100644 --- a/websocket-sharp/Net/CookieCollection.cs +++ b/websocket-sharp/Net/CookieCollection.cs @@ -68,6 +68,7 @@ public class CookieCollection : ICollection, IEnumerable public CookieCollection () { _list = new List (); + _sync = ((ICollection) _list).SyncRoot; } #endregion @@ -191,7 +192,7 @@ public Cookie this[string name] { /// public Object SyncRoot { get { - return _sync ?? (_sync = ((ICollection) _list).SyncRoot); + return _sync; } } From b79141f9903b60c007c87a96634e6ad5fb9c43c1 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 20 Mar 2019 22:55:40 +0900 Subject: [PATCH 2366/6294] [Modify] Polish it --- websocket-sharp/Net/CookieCollection.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/CookieCollection.cs b/websocket-sharp/Net/CookieCollection.cs index 8df6d52ec..62ef9c46d 100644 --- a/websocket-sharp/Net/CookieCollection.cs +++ b/websocket-sharp/Net/CookieCollection.cs @@ -190,7 +190,7 @@ public Cookie this[string name] { /// /// An used to synchronize access to the collection. /// - public Object SyncRoot { + public object SyncRoot { get { return _sync; } From 054aae676dce8ddd571f6ee92351681120073cd3 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 21 Mar 2019 21:41:24 +0900 Subject: [PATCH 2367/6294] [Modify] Edit it --- websocket-sharp/Net/CookieCollection.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/CookieCollection.cs b/websocket-sharp/Net/CookieCollection.cs index 62ef9c46d..dfd9a8a18 100644 --- a/websocket-sharp/Net/CookieCollection.cs +++ b/websocket-sharp/Net/CookieCollection.cs @@ -188,7 +188,7 @@ public Cookie this[string name] { /// Gets an object used to synchronize access to the collection. /// /// - /// An used to synchronize access to the collection. + /// An used to synchronize access to the collection. /// public object SyncRoot { get { From 61fbdf3713c5bd064211f21b4947f90a0f1eaeec Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 21 Mar 2019 21:50:36 +0900 Subject: [PATCH 2368/6294] [Modify] Polish it --- websocket-sharp/Net/CookieCollection.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/CookieCollection.cs b/websocket-sharp/Net/CookieCollection.cs index dfd9a8a18..fadf6be4a 100644 --- a/websocket-sharp/Net/CookieCollection.cs +++ b/websocket-sharp/Net/CookieCollection.cs @@ -176,9 +176,12 @@ public Cookie this[string name] { if (name == null) throw new ArgumentNullException ("name"); - foreach (var cookie in Sorted) - if (cookie.Name.Equals (name, StringComparison.InvariantCultureIgnoreCase)) + var compType = StringComparison.InvariantCultureIgnoreCase; + + foreach (var cookie in Sorted) { + if (cookie.Name.Equals (name, compType)) return cookie; + } return null; } From 63653a844d1b148389475df244af9a4ffa8b347a Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 22 Mar 2019 21:16:14 +0900 Subject: [PATCH 2369/6294] [Modify] Edit it --- websocket-sharp/Net/CookieCollection.cs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/CookieCollection.cs b/websocket-sharp/Net/CookieCollection.cs index fadf6be4a..d3ed7baf6 100644 --- a/websocket-sharp/Net/CookieCollection.cs +++ b/websocket-sharp/Net/CookieCollection.cs @@ -159,14 +159,18 @@ public Cookie this[int index] { } /// - /// Gets the with the specified from - /// the collection. + /// Gets the cookie with the specified name from the collection. /// /// - /// A with the specified in the collection. + /// + /// A with the specified name in the collection. + /// + /// + /// if not found. + /// /// /// - /// A that represents the name of the to find. + /// A that specifies the name of the cookie to find. /// /// /// is . From df1f7adbfec40a4126be0be6ef5d99cc6f9b0f75 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 23 Mar 2019 21:56:19 +0900 Subject: [PATCH 2370/6294] [Modify] Edit it --- websocket-sharp/Net/CookieCollection.cs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Net/CookieCollection.cs b/websocket-sharp/Net/CookieCollection.cs index d3ed7baf6..2b24723cb 100644 --- a/websocket-sharp/Net/CookieCollection.cs +++ b/websocket-sharp/Net/CookieCollection.cs @@ -136,18 +136,17 @@ public bool IsSynchronized { } /// - /// Gets the at the specified from - /// the collection. + /// Gets the cookie at the specified index from the collection. /// /// - /// A at the specified in the collection. + /// A at the specified index in the collection. /// /// - /// An that represents the zero-based index of the + /// An that specifies the zero-based index of the cookie /// to find. /// /// - /// is out of allowable range of indexes for the collection. + /// is out of allowable range for the collection. /// public Cookie this[int index] { get { From f36fb1f2a24fecc0d409c12e37c532c964ea69b6 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 24 Mar 2019 21:32:24 +0900 Subject: [PATCH 2371/6294] [Modify] Edit it --- websocket-sharp/Net/CookieCollection.cs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/CookieCollection.cs b/websocket-sharp/Net/CookieCollection.cs index 2b24723cb..e6e0a6169 100644 --- a/websocket-sharp/Net/CookieCollection.cs +++ b/websocket-sharp/Net/CookieCollection.cs @@ -123,11 +123,17 @@ public bool IsReadOnly { } /// - /// Gets a value indicating whether the access to the collection is thread safe. + /// Gets a value indicating whether the access to the collection is + /// thread safe. /// /// - /// true if the access to the collection is thread safe; otherwise, false. - /// The default value is false. + /// + /// true if the access to the collection is thread safe; + /// otherwise, false. + /// + /// + /// The default value is false. + /// /// public bool IsSynchronized { get { From 6cae5c076c4838b3e3b9c9a5899f9af1301e440a Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 24 Mar 2019 21:37:12 +0900 Subject: [PATCH 2372/6294] [Modify] Edit it --- websocket-sharp/Net/CookieCollection.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/CookieCollection.cs b/websocket-sharp/Net/CookieCollection.cs index e6e0a6169..2d31e09ba 100644 --- a/websocket-sharp/Net/CookieCollection.cs +++ b/websocket-sharp/Net/CookieCollection.cs @@ -111,12 +111,14 @@ public int Count { /// Gets a value indicating whether the collection is read-only. /// /// - /// true if the collection is read-only; otherwise, false. - /// The default value is true. + /// + /// true if the collection is read-only; otherwise, false. + /// + /// + /// The default value is true. + /// /// public bool IsReadOnly { - // LAMESPEC: So how is one supposed to create a writable CookieCollection instance? - // We simply ignore this property, as this collection is always writable. get { return true; } From 11f0d2abb439088a0a2424ad198e14d39e469f1c Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 25 Mar 2019 21:14:00 +0900 Subject: [PATCH 2373/6294] [Modify] Edit it --- websocket-sharp/Net/CookieCollection.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/CookieCollection.cs b/websocket-sharp/Net/CookieCollection.cs index 2d31e09ba..c8ef8518e 100644 --- a/websocket-sharp/Net/CookieCollection.cs +++ b/websocket-sharp/Net/CookieCollection.cs @@ -99,7 +99,8 @@ internal IEnumerable Sorted { /// Gets the number of cookies in the collection. /// /// - /// An that represents the number of cookies in the collection. + /// An that represents the number of cookies in + /// the collection. /// public int Count { get { From c864f17998c1fa5f5c6bc4292e09e08e7bd4f0cc Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 26 Mar 2019 21:24:36 +0900 Subject: [PATCH 2374/6294] [Modify] The default value is false --- websocket-sharp/Net/CookieCollection.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/CookieCollection.cs b/websocket-sharp/Net/CookieCollection.cs index c8ef8518e..91b451e3b 100644 --- a/websocket-sharp/Net/CookieCollection.cs +++ b/websocket-sharp/Net/CookieCollection.cs @@ -56,6 +56,7 @@ public class CookieCollection : ICollection, IEnumerable #region Private Fields private List _list; + private bool _readOnly; private object _sync; #endregion @@ -116,12 +117,16 @@ public int Count { /// true if the collection is read-only; otherwise, false. /// /// - /// The default value is true. + /// The default value is false. /// /// public bool IsReadOnly { get { - return true; + return _readOnly; + } + + internal set { + _readOnly = value; } } From ba660e5adb4c09b64cff7fad7176b78c4c9fdea0 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 27 Mar 2019 22:42:45 +0900 Subject: [PATCH 2375/6294] [Modify] Add it --- websocket-sharp/Net/Cookie.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/websocket-sharp/Net/Cookie.cs b/websocket-sharp/Net/Cookie.cs index cf457fce1..c8e303203 100644 --- a/websocket-sharp/Net/Cookie.cs +++ b/websocket-sharp/Net/Cookie.cs @@ -867,6 +867,17 @@ private static bool tryCreatePorts (string value, out int[] result) #region Internal Methods + internal bool EqualsWithoutValue (Cookie cookie) + { + var caseSensitive = StringComparison.InvariantCulture; + var caseInsensitive = StringComparison.InvariantCultureIgnoreCase; + + return _name.Equals (cookie._name, caseInsensitive) + && _path.Equals (cookie._path, caseSensitive) + && _domain.Equals (cookie._domain, caseInsensitive) + && _version == cookie._version; + } + internal string ToRequestString (Uri uri) { if (_name.Length == 0) From 279b6d5efbf3f49e39c300ed9e50e5346f992076 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 27 Mar 2019 22:58:30 +0900 Subject: [PATCH 2376/6294] [Modify] Replace it --- websocket-sharp/Net/CookieCollection.cs | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/websocket-sharp/Net/CookieCollection.cs b/websocket-sharp/Net/CookieCollection.cs index 91b451e3b..6e360efd0 100644 --- a/websocket-sharp/Net/CookieCollection.cs +++ b/websocket-sharp/Net/CookieCollection.cs @@ -402,17 +402,8 @@ private static CookieCollection parseResponse (string value) private int searchCookie (Cookie cookie) { - var name = cookie.Name; - var path = cookie.Path; - var domain = cookie.Domain; - var ver = cookie.Version; - for (var i = _list.Count - 1; i >= 0; i--) { - var c = _list[i]; - if (c.Name.Equals (name, StringComparison.InvariantCultureIgnoreCase) && - c.Path.Equals (path, StringComparison.InvariantCulture) && - c.Domain.Equals (domain, StringComparison.InvariantCultureIgnoreCase) && - c.Version == ver) + if (_list[i].EqualsWithoutValue (cookie)) return i; } From b8c07419142baeb222e454f3f19be2495d3b4cef Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 28 Mar 2019 21:22:28 +0900 Subject: [PATCH 2377/6294] [Modify] Polish it --- websocket-sharp/Net/CookieCollection.cs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/websocket-sharp/Net/CookieCollection.cs b/websocket-sharp/Net/CookieCollection.cs index 6e360efd0..7e01ad424 100644 --- a/websocket-sharp/Net/CookieCollection.cs +++ b/websocket-sharp/Net/CookieCollection.cs @@ -444,20 +444,21 @@ internal static CookieCollection Parse (string value, bool response) internal void SetOrRemove (Cookie cookie) { - var pos = searchCookie (cookie); - if (pos == -1) { - if (!cookie.Expired) - _list.Add (cookie); + var idx = searchCookie (cookie); + if (idx == -1) { + if (cookie.Expired) + return; + _list.Add (cookie); return; } - if (!cookie.Expired) { - _list[pos] = cookie; + if (cookie.Expired) { + _list.RemoveAt (idx); return; } - _list.RemoveAt (pos); + _list[idx] = cookie; } internal void SetOrRemove (CookieCollection cookies) From 08c29e7ee01c66b3fa349bc3c091ebb2e7bdb594 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 28 Mar 2019 21:27:54 +0900 Subject: [PATCH 2378/6294] [Modify] Polish it --- websocket-sharp/Net/CookieCollection.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/CookieCollection.cs b/websocket-sharp/Net/CookieCollection.cs index 7e01ad424..5f407700b 100644 --- a/websocket-sharp/Net/CookieCollection.cs +++ b/websocket-sharp/Net/CookieCollection.cs @@ -486,18 +486,18 @@ internal void Sort () /// /// is . /// - public void Add (Cookie cookie) + public void Add (Cookie cookie) { if (cookie == null) throw new ArgumentNullException ("cookie"); - var pos = searchCookie (cookie); - if (pos == -1) { + var idx = searchCookie (cookie); + if (idx == -1) { _list.Add (cookie); return; } - _list[pos] = cookie; + _list[idx] = cookie; } /// From 68c70e16838f8375dec18b17a4a7067483d9d371 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 28 Mar 2019 21:29:51 +0900 Subject: [PATCH 2379/6294] [Modify] Polish it --- websocket-sharp/Net/CookieCollection.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/CookieCollection.cs b/websocket-sharp/Net/CookieCollection.cs index 5f407700b..bc06951d9 100644 --- a/websocket-sharp/Net/CookieCollection.cs +++ b/websocket-sharp/Net/CookieCollection.cs @@ -509,7 +509,7 @@ public void Add (Cookie cookie) /// /// is . /// - public void Add (CookieCollection cookies) + public void Add (CookieCollection cookies) { if (cookies == null) throw new ArgumentNullException ("cookies"); From e53ae17fc1e49d12cbd7b38dd715a212f5e203f6 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 29 Mar 2019 22:03:11 +0900 Subject: [PATCH 2380/6294] [Modify] Edit it --- websocket-sharp/Net/CookieCollection.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/CookieCollection.cs b/websocket-sharp/Net/CookieCollection.cs index bc06951d9..797b8d5af 100644 --- a/websocket-sharp/Net/CookieCollection.cs +++ b/websocket-sharp/Net/CookieCollection.cs @@ -478,7 +478,7 @@ internal void Sort () #region Public Methods /// - /// Adds the specified to the collection. + /// Adds the specified cookie to the collection. /// /// /// A to add. From 63deae89ba66fca182f1b7778c3246e654ae7ac4 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 29 Mar 2019 22:08:31 +0900 Subject: [PATCH 2381/6294] [Modify] Edit it --- websocket-sharp/Net/CookieCollection.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/CookieCollection.cs b/websocket-sharp/Net/CookieCollection.cs index 797b8d5af..97f886d63 100644 --- a/websocket-sharp/Net/CookieCollection.cs +++ b/websocket-sharp/Net/CookieCollection.cs @@ -501,7 +501,7 @@ public void Add (Cookie cookie) } /// - /// Adds the specified to the collection. + /// Adds the specified cookies to the collection. /// /// /// A that contains the cookies to add. From afe129fd923d8556fab7a00f3c675f6eaba608d5 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 30 Mar 2019 16:53:26 +0900 Subject: [PATCH 2382/6294] [Modify] Add it --- websocket-sharp/Net/CookieCollection.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/websocket-sharp/Net/CookieCollection.cs b/websocket-sharp/Net/CookieCollection.cs index 97f886d63..be66c0091 100644 --- a/websocket-sharp/Net/CookieCollection.cs +++ b/websocket-sharp/Net/CookieCollection.cs @@ -220,6 +220,17 @@ public object SyncRoot { #region Private Methods + private void add (Cookie cookie) + { + var idx = searchCookie (cookie); + if (idx == -1) { + _list.Add (cookie); + return; + } + + _list[idx] = cookie; + } + private static int compareCookieWithinSort (Cookie x, Cookie y) { return (x.Name.Length + x.Value.Length) - (y.Name.Length + y.Value.Length); From 536a7d4381cebadfeec7c66b38c149656cf21618 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 30 Mar 2019 16:56:07 +0900 Subject: [PATCH 2383/6294] [Modify] Replace it --- websocket-sharp/Net/CookieCollection.cs | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/websocket-sharp/Net/CookieCollection.cs b/websocket-sharp/Net/CookieCollection.cs index be66c0091..dac87df20 100644 --- a/websocket-sharp/Net/CookieCollection.cs +++ b/websocket-sharp/Net/CookieCollection.cs @@ -502,13 +502,7 @@ public void Add (Cookie cookie) if (cookie == null) throw new ArgumentNullException ("cookie"); - var idx = searchCookie (cookie); - if (idx == -1) { - _list.Add (cookie); - return; - } - - _list[idx] = cookie; + add (cookie); } /// From 1345efeaff674824ce30c706bb11e748d1368ec8 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 30 Mar 2019 16:57:17 +0900 Subject: [PATCH 2384/6294] [Modify] Replace it --- websocket-sharp/Net/CookieCollection.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/CookieCollection.cs b/websocket-sharp/Net/CookieCollection.cs index dac87df20..2fa6a61e5 100644 --- a/websocket-sharp/Net/CookieCollection.cs +++ b/websocket-sharp/Net/CookieCollection.cs @@ -520,7 +520,7 @@ public void Add (CookieCollection cookies) throw new ArgumentNullException ("cookies"); foreach (Cookie cookie in cookies) - Add (cookie); + add (cookie); } /// From 36217c21a1f3556f6ad7bb9fb551599c775a8062 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 31 Mar 2019 17:53:30 +0900 Subject: [PATCH 2385/6294] [Modify] Polish it --- websocket-sharp/Net/CookieCollection.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/CookieCollection.cs b/websocket-sharp/Net/CookieCollection.cs index 2fa6a61e5..2acfb7fdd 100644 --- a/websocket-sharp/Net/CookieCollection.cs +++ b/websocket-sharp/Net/CookieCollection.cs @@ -233,7 +233,8 @@ private void add (Cookie cookie) private static int compareCookieWithinSort (Cookie x, Cookie y) { - return (x.Name.Length + x.Value.Length) - (y.Name.Length + y.Value.Length); + return (x.Name.Length + x.Value.Length) + - (y.Name.Length + y.Value.Length); } private static int compareCookieWithinSorted (Cookie x, Cookie y) From ec7d54237a9fae25a465248fd7d6014a08d9f8e3 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 1 Apr 2019 20:33:47 +0900 Subject: [PATCH 2386/6294] [Modify] Polish it --- websocket-sharp/Net/CookieCollection.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/CookieCollection.cs b/websocket-sharp/Net/CookieCollection.cs index 2acfb7fdd..3c7850043 100644 --- a/websocket-sharp/Net/CookieCollection.cs +++ b/websocket-sharp/Net/CookieCollection.cs @@ -239,8 +239,8 @@ private static int compareCookieWithinSort (Cookie x, Cookie y) private static int compareCookieWithinSorted (Cookie x, Cookie y) { - var ret = 0; - return (ret = x.Version - y.Version) != 0 + var ret = x.Version - y.Version; + return ret != 0 ? ret : (ret = x.Name.CompareTo (y.Name)) != 0 ? ret From 1d0bc618535ac9d8514a5e0aa8142842fb4f92b6 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 1 Apr 2019 20:37:54 +0900 Subject: [PATCH 2387/6294] [Modify] Rename it --- websocket-sharp/Net/CookieCollection.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/CookieCollection.cs b/websocket-sharp/Net/CookieCollection.cs index 3c7850043..5a2580955 100644 --- a/websocket-sharp/Net/CookieCollection.cs +++ b/websocket-sharp/Net/CookieCollection.cs @@ -222,7 +222,7 @@ public object SyncRoot { private void add (Cookie cookie) { - var idx = searchCookie (cookie); + var idx = search (cookie); if (idx == -1) { _list.Add (cookie); return; @@ -412,7 +412,7 @@ private static CookieCollection parseResponse (string value) return cookies; } - private int searchCookie (Cookie cookie) + private int search (Cookie cookie) { for (var i = _list.Count - 1; i >= 0; i--) { if (_list[i].EqualsWithoutValue (cookie)) @@ -456,7 +456,7 @@ internal static CookieCollection Parse (string value, bool response) internal void SetOrRemove (Cookie cookie) { - var idx = searchCookie (cookie); + var idx = search (cookie); if (idx == -1) { if (cookie.Expired) return; From 9dd0d5e584afe36072b7a32461bee3fc96e5908f Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 1 Apr 2019 20:43:17 +0900 Subject: [PATCH 2388/6294] [Modify] Rename it --- websocket-sharp/Net/CookieCollection.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/CookieCollection.cs b/websocket-sharp/Net/CookieCollection.cs index 5a2580955..5ab8b759c 100644 --- a/websocket-sharp/Net/CookieCollection.cs +++ b/websocket-sharp/Net/CookieCollection.cs @@ -231,7 +231,7 @@ private void add (Cookie cookie) _list[idx] = cookie; } - private static int compareCookieWithinSort (Cookie x, Cookie y) + private static int compareForSort (Cookie x, Cookie y) { return (x.Name.Length + x.Value.Length) - (y.Name.Length + y.Value.Length); @@ -482,7 +482,7 @@ internal void SetOrRemove (CookieCollection cookies) internal void Sort () { if (_list.Count > 1) - _list.Sort (compareCookieWithinSort); + _list.Sort (compareForSort); } #endregion From c792ceaefd76c95268c7b74b0ada3e0771d9b56f Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 2 Apr 2019 21:16:23 +0900 Subject: [PATCH 2389/6294] [Modify] Rename it --- websocket-sharp/Net/CookieCollection.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/CookieCollection.cs b/websocket-sharp/Net/CookieCollection.cs index 5ab8b759c..e76770d78 100644 --- a/websocket-sharp/Net/CookieCollection.cs +++ b/websocket-sharp/Net/CookieCollection.cs @@ -86,7 +86,7 @@ internal IEnumerable Sorted { get { var list = new List (_list); if (list.Count > 1) - list.Sort (compareCookieWithinSorted); + list.Sort (compareForSorted); return list; } @@ -237,7 +237,7 @@ private static int compareForSort (Cookie x, Cookie y) - (y.Name.Length + y.Value.Length); } - private static int compareCookieWithinSorted (Cookie x, Cookie y) + private static int compareForSorted (Cookie x, Cookie y) { var ret = x.Version - y.Version; return ret != 0 From 3949292fbe1a7119acb67793f3b64fa46ac3d46d Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 2 Apr 2019 21:18:32 +0900 Subject: [PATCH 2390/6294] [Modify] Edit it --- websocket-sharp/Net/CookieCollection.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/CookieCollection.cs b/websocket-sharp/Net/CookieCollection.cs index e76770d78..48433495b 100644 --- a/websocket-sharp/Net/CookieCollection.cs +++ b/websocket-sharp/Net/CookieCollection.cs @@ -621,7 +621,8 @@ public void CopyTo (Cookie[] array, int index) /// Gets the enumerator used to iterate through the collection. /// /// - /// An instance used to iterate through the collection. + /// An instance used to iterate through + /// the collection. /// public IEnumerator GetEnumerator () { From 160c57fb827df51a4a425c0078fe266ecca435cf Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 3 Apr 2019 22:03:36 +0900 Subject: [PATCH 2391/6294] [Modify] Polish it --- websocket-sharp/Net/CookieCollection.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/CookieCollection.cs b/websocket-sharp/Net/CookieCollection.cs index 48433495b..d0a05e0a6 100644 --- a/websocket-sharp/Net/CookieCollection.cs +++ b/websocket-sharp/Net/CookieCollection.cs @@ -610,9 +610,10 @@ public void CopyTo (Cookie[] array, int index) if (index < 0) throw new ArgumentOutOfRangeException ("index", "Less than zero."); - if (array.Length - index < _list.Count) - throw new ArgumentException ( - "The number of elements in this collection is greater than the available space of the destination array."); + if (array.Length - index < _list.Count) { + var msg = "The available space of the destination array is not enough."; + throw new ArgumentException (msg); + } _list.CopyTo (array, index); } From a058d53475cf4012ef84d1125280cf25f105ec72 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 4 Apr 2019 17:17:09 +0900 Subject: [PATCH 2392/6294] [Modify] Edit it --- websocket-sharp/Net/CookieCollection.cs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/websocket-sharp/Net/CookieCollection.cs b/websocket-sharp/Net/CookieCollection.cs index d0a05e0a6..a364b6dad 100644 --- a/websocket-sharp/Net/CookieCollection.cs +++ b/websocket-sharp/Net/CookieCollection.cs @@ -581,16 +581,16 @@ public void CopyTo (Array array, int index) } /// - /// Copies the elements of the collection to the specified array of , - /// starting at the specified in the . + /// Copies the elements of the collection to the specified array, + /// starting at the specified index of the array. /// /// - /// An array of that represents the destination of the elements - /// copied from the collection. + /// An array of that specifies the destination of + /// the elements copied from the collection. /// /// - /// An that represents the zero-based index in - /// at which copying begins. + /// An that specifies the zero-based index of + /// the array at which copying starts. /// /// /// is . @@ -599,8 +599,8 @@ public void CopyTo (Array array, int index) /// is less than zero. /// /// - /// The number of elements in the collection is greater than the available space from - /// to the end of the destination . + /// The space from to the end of + /// is not enough to copy to. /// public void CopyTo (Cookie[] array, int index) { From 4a364e5bc51b85b725aa521c463ee7175ac80e43 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 4 Apr 2019 17:19:15 +0900 Subject: [PATCH 2393/6294] [Modify] Polish it --- websocket-sharp/Net/CookieCollection.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/CookieCollection.cs b/websocket-sharp/Net/CookieCollection.cs index a364b6dad..3a86a32a8 100644 --- a/websocket-sharp/Net/CookieCollection.cs +++ b/websocket-sharp/Net/CookieCollection.cs @@ -611,7 +611,7 @@ public void CopyTo (Cookie[] array, int index) throw new ArgumentOutOfRangeException ("index", "Less than zero."); if (array.Length - index < _list.Count) { - var msg = "The available space of the destination array is not enough."; + var msg = "The available space of the array is not enough to copy to."; throw new ArgumentException (msg); } From eac39656fd6c7bb660d0edd403562dc92aa61eda Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 5 Apr 2019 16:03:11 +0900 Subject: [PATCH 2394/6294] [Modify] Polish it --- websocket-sharp/Net/CookieCollection.cs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Net/CookieCollection.cs b/websocket-sharp/Net/CookieCollection.cs index 3a86a32a8..70f542217 100644 --- a/websocket-sharp/Net/CookieCollection.cs +++ b/websocket-sharp/Net/CookieCollection.cs @@ -569,13 +569,16 @@ public void CopyTo (Array array, int index) if (array.Rank > 1) throw new ArgumentException ("Multidimensional.", "array"); - if (array.Length - index < _list.Count) - throw new ArgumentException ( - "The number of elements in this collection is greater than the available space of the destination array."); + if (array.Length - index < _list.Count) { + var msg = "The available space of the array is not enough to copy to."; + throw new ArgumentException (msg); + } - if (!array.GetType ().GetElementType ().IsAssignableFrom (typeof (Cookie))) - throw new InvalidCastException ( - "The elements in this collection cannot be cast automatically to the type of the destination array."); + var elmType = array.GetType ().GetElementType (); + if (!elmType.IsAssignableFrom (typeof (Cookie))) { + var msg = "The element type of the array cannot be assigned."; + throw new InvalidCastException (msg); + } ((IList) _list).CopyTo (array, index); } From a8f1e70d99cc779ca5320cdfaa7add43d197cb42 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 6 Apr 2019 17:20:10 +0900 Subject: [PATCH 2395/6294] [Modify] Edit it --- websocket-sharp/Net/CookieCollection.cs | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/websocket-sharp/Net/CookieCollection.cs b/websocket-sharp/Net/CookieCollection.cs index 70f542217..f74d3d5ef 100644 --- a/websocket-sharp/Net/CookieCollection.cs +++ b/websocket-sharp/Net/CookieCollection.cs @@ -525,16 +525,16 @@ public void Add (CookieCollection cookies) } /// - /// Copies the elements of the collection to the specified , starting at - /// the specified in the . + /// Copies the elements of the collection to the specified array, + /// starting at the specified index. /// /// - /// An that represents the destination of the elements copied from - /// the collection. + /// An that specifies the destination of + /// the elements copied from the collection. /// /// - /// An that represents the zero-based index in - /// at which copying begins. + /// An that specifies the zero-based index in + /// the array at which copying starts. /// /// /// is . @@ -550,13 +550,12 @@ public void Add (CookieCollection cookies) /// -or- /// /// - /// The number of elements in the collection is greater than the available space from - /// to the end of the destination . + /// The space from to the end of + /// is not enough to copy to. /// /// /// - /// The elements in the collection cannot be cast automatically to the type of the destination - /// . + /// The element type of cannot be assigned. /// public void CopyTo (Array array, int index) { From 1c312a935f4a59e71655c63d66b8484948c02b15 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 6 Apr 2019 17:23:30 +0900 Subject: [PATCH 2396/6294] [Modify] Edit it --- websocket-sharp/Net/CookieCollection.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/CookieCollection.cs b/websocket-sharp/Net/CookieCollection.cs index f74d3d5ef..24660d127 100644 --- a/websocket-sharp/Net/CookieCollection.cs +++ b/websocket-sharp/Net/CookieCollection.cs @@ -584,14 +584,14 @@ public void CopyTo (Array array, int index) /// /// Copies the elements of the collection to the specified array, - /// starting at the specified index of the array. + /// starting at the specified index. /// /// /// An array of that specifies the destination of /// the elements copied from the collection. /// /// - /// An that specifies the zero-based index of + /// An that specifies the zero-based index in /// the array at which copying starts. /// /// From 57b5684064b9208dfc8e3664d5fae64e6d0f50b5 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 7 Apr 2019 17:48:53 +0900 Subject: [PATCH 2397/6294] [Modify] Edit it --- websocket-sharp/Net/CookieCollection.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/CookieCollection.cs b/websocket-sharp/Net/CookieCollection.cs index 24660d127..0e10ecbf4 100644 --- a/websocket-sharp/Net/CookieCollection.cs +++ b/websocket-sharp/Net/CookieCollection.cs @@ -48,7 +48,7 @@ namespace WebSocketSharp.Net { /// - /// Provides a collection container for instances of the class. + /// Provides a collection of instances of the class. /// [Serializable] public class CookieCollection : ICollection, IEnumerable From 1363f9ec09e81da52102a994652d60ac37e415da Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 8 Apr 2019 20:47:08 +0900 Subject: [PATCH 2398/6294] [Modify] Edit it --- websocket-sharp/Net/CookieCollection.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/CookieCollection.cs b/websocket-sharp/Net/CookieCollection.cs index 0e10ecbf4..1a7caf543 100644 --- a/websocket-sharp/Net/CookieCollection.cs +++ b/websocket-sharp/Net/CookieCollection.cs @@ -2,7 +2,7 @@ /* * CookieCollection.cs * - * This code is derived from System.Net.CookieCollection.cs of Mono + * This code is derived from CookieCollection.cs (System.Net) of Mono * (http://www.mono-project.com). * * The MIT License From 3a2d5580a19c2652a2152c7f901936694d15fd52 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 8 Apr 2019 20:58:46 +0900 Subject: [PATCH 2399/6294] [Modify] Polish it --- websocket-sharp/Net/Cookie.cs | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/websocket-sharp/Net/Cookie.cs b/websocket-sharp/Net/Cookie.cs index c8e303203..d334dd2fc 100644 --- a/websocket-sharp/Net/Cookie.cs +++ b/websocket-sharp/Net/Cookie.cs @@ -952,19 +952,16 @@ internal string ToResponseString () public override bool Equals (object comparand) { var cookie = comparand as Cookie; - return cookie != null - && _name.Equals ( - cookie._name, StringComparison.InvariantCultureIgnoreCase - ) - && _value.Equals ( - cookie._value, StringComparison.InvariantCulture - ) - && _path.Equals ( - cookie._path, StringComparison.InvariantCulture - ) - && _domain.Equals ( - cookie._domain, StringComparison.InvariantCultureIgnoreCase - ) + if (cookie == null) + return false; + + var caseSensitive = StringComparison.InvariantCulture; + var caseInsensitive = StringComparison.InvariantCultureIgnoreCase; + + return _name.Equals (cookie._name, caseInsensitive) + && _value.Equals (cookie._value, caseSensitive) + && _path.Equals (cookie._path, caseSensitive) + && _domain.Equals (cookie._domain, caseInsensitive) && _version == cookie._version; } From dda0adbd6c00ed0a66e5de0629baa09ccaa05619 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 9 Apr 2019 21:45:44 +0900 Subject: [PATCH 2400/6294] [Modify] Polish it --- websocket-sharp/Net/CookieCollection.cs | 73 ++++++++++++++----------- 1 file changed, 42 insertions(+), 31 deletions(-) diff --git a/websocket-sharp/Net/CookieCollection.cs b/websocket-sharp/Net/CookieCollection.cs index 1a7caf543..79e7769af 100644 --- a/websocket-sharp/Net/CookieCollection.cs +++ b/websocket-sharp/Net/CookieCollection.cs @@ -249,64 +249,75 @@ private static int compareForSorted (Cookie x, Cookie y) private static CookieCollection parseRequest (string value) { - var cookies = new CookieCollection (); + var ret = new CookieCollection (); Cookie cookie = null; + var compType = StringComparison.InvariantCultureIgnoreCase; var ver = 0; + var pairs = splitCookieHeaderValue (value); + for (var i = 0; i < pairs.Length; i++) { var pair = pairs[i].Trim (); if (pair.Length == 0) continue; - if (pair.StartsWith ("$version", StringComparison.InvariantCultureIgnoreCase)) { + if (pair.StartsWith ("$version", compType)) { ver = Int32.Parse (pair.GetValue ('=', true)); + continue; } - else if (pair.StartsWith ("$path", StringComparison.InvariantCultureIgnoreCase)) { + + if (pair.StartsWith ("$path", compType)) { if (cookie != null) cookie.Path = pair.GetValue ('='); + + continue; } - else if (pair.StartsWith ("$domain", StringComparison.InvariantCultureIgnoreCase)) { + + if (pair.StartsWith ("$domain", compType)) { if (cookie != null) cookie.Domain = pair.GetValue ('='); + + continue; } - else if (pair.StartsWith ("$port", StringComparison.InvariantCultureIgnoreCase)) { - var port = pair.Equals ("$port", StringComparison.InvariantCultureIgnoreCase) - ? "\"\"" - : pair.GetValue ('='); - if (cookie != null) - cookie.Port = port; + if (pair.StartsWith ("$port", compType)) { + if (cookie != null) { + cookie.Port = !pair.Equals ("$port", compType) + ? pair.GetValue ('=') + : "\"\""; + } + + continue; } - else { - if (cookie != null) - cookies.Add (cookie); - string name; - string val = String.Empty; + if (cookie != null) + ret.Add (cookie); - var pos = pair.IndexOf ('='); - if (pos == -1) { - name = pair; - } - else if (pos == pair.Length - 1) { - name = pair.Substring (0, pos).TrimEnd (' '); - } - else { - name = pair.Substring (0, pos).TrimEnd (' '); - val = pair.Substring (pos + 1).TrimStart (' '); - } + string name = null; + string val = String.Empty; - cookie = new Cookie (name, val); - if (ver != 0) - cookie.Version = ver; + var idx = pair.IndexOf ('='); + if (idx == -1) { + name = pair; + } + else if (idx == pair.Length - 1) { + name = pair.Substring (0, idx).TrimEnd (' '); } + else { + name = pair.Substring (0, idx).TrimEnd (' '); + val = pair.Substring (idx + 1).TrimStart (' '); + } + + cookie = new Cookie (name, val); + if (ver != 0) + cookie.Version = ver; } if (cookie != null) - cookies.Add (cookie); + ret.Add (cookie); - return cookies; + return ret; } private static CookieCollection parseResponse (string value) From aabb286f424f9525d280999c8697429057b82b67 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 10 Apr 2019 21:24:28 +0900 Subject: [PATCH 2401/6294] [Modify] Polish it --- websocket-sharp/Net/CookieCollection.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/CookieCollection.cs b/websocket-sharp/Net/CookieCollection.cs index 79e7769af..50807c3d7 100644 --- a/websocket-sharp/Net/CookieCollection.cs +++ b/websocket-sharp/Net/CookieCollection.cs @@ -262,26 +262,26 @@ private static CookieCollection parseRequest (string value) if (pair.Length == 0) continue; - if (pair.StartsWith ("$version", compType)) { + if (pair.IndexOf ("$version", compType) == 0) { ver = Int32.Parse (pair.GetValue ('=', true)); continue; } - if (pair.StartsWith ("$path", compType)) { + if (pair.IndexOf ("$path", compType) == 0) { if (cookie != null) cookie.Path = pair.GetValue ('='); continue; } - if (pair.StartsWith ("$domain", compType)) { + if (pair.IndexOf ("$domain", compType) == 0) { if (cookie != null) cookie.Domain = pair.GetValue ('='); continue; } - if (pair.StartsWith ("$port", compType)) { + if (pair.IndexOf ("$port", compType) == 0) { if (cookie != null) { cookie.Port = !pair.Equals ("$port", compType) ? pair.GetValue ('=') From 0cd5632544e7f843e1207b11e0b991a860ca5a8b Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 11 Apr 2019 21:27:39 +0900 Subject: [PATCH 2402/6294] [Modify] Polish it --- websocket-sharp/Net/CookieCollection.cs | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/websocket-sharp/Net/CookieCollection.cs b/websocket-sharp/Net/CookieCollection.cs index 50807c3d7..ec7177fef 100644 --- a/websocket-sharp/Net/CookieCollection.cs +++ b/websocket-sharp/Net/CookieCollection.cs @@ -291,25 +291,22 @@ private static CookieCollection parseRequest (string value) continue; } - if (cookie != null) + if (cookie != null) { ret.Add (cookie); - - string name = null; - string val = String.Empty; + cookie = null; + } var idx = pair.IndexOf ('='); - if (idx == -1) { - name = pair; - } - else if (idx == pair.Length - 1) { - name = pair.Substring (0, idx).TrimEnd (' '); - } - else { - name = pair.Substring (0, idx).TrimEnd (' '); - val = pair.Substring (idx + 1).TrimStart (' '); - } + if (idx == -1) + continue; + if (idx == pair.Length - 1) + continue; + + var name = pair.Substring (0, idx).TrimEnd (' '); + var val = pair.Substring (idx + 1).TrimStart (' '); cookie = new Cookie (name, val); + if (ver != 0) cookie.Version = ver; } From b0370e7ec2f71bd51fb5c1641b6b18398e289ecb Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 12 Apr 2019 21:47:39 +0900 Subject: [PATCH 2403/6294] [Modify] Polish it --- websocket-sharp/Net/CookieCollection.cs | 150 +++++++++++++++--------- 1 file changed, 96 insertions(+), 54 deletions(-) diff --git a/websocket-sharp/Net/CookieCollection.cs b/websocket-sharp/Net/CookieCollection.cs index ec7177fef..98fb8b022 100644 --- a/websocket-sharp/Net/CookieCollection.cs +++ b/websocket-sharp/Net/CookieCollection.cs @@ -319,105 +319,147 @@ private static CookieCollection parseRequest (string value) private static CookieCollection parseResponse (string value) { - var cookies = new CookieCollection (); + var ret = new CookieCollection (); Cookie cookie = null; + var compType = StringComparison.InvariantCultureIgnoreCase; + var pairs = splitCookieHeaderValue (value); + for (var i = 0; i < pairs.Length; i++) { var pair = pairs[i].Trim (); if (pair.Length == 0) continue; - if (pair.StartsWith ("version", StringComparison.InvariantCultureIgnoreCase)) { + if (pair.IndexOf ("version", compType) == 0) { if (cookie != null) cookie.Version = Int32.Parse (pair.GetValue ('=', true)); + + continue; } - else if (pair.StartsWith ("expires", StringComparison.InvariantCultureIgnoreCase)) { - var buff = new StringBuilder (pair.GetValue ('='), 32); - if (i < pairs.Length - 1) - buff.AppendFormat (", {0}", pairs[++i].Trim ()); - - DateTime expires; - if (!DateTime.TryParseExact ( - buff.ToString (), - new[] { "ddd, dd'-'MMM'-'yyyy HH':'mm':'ss 'GMT'", "r" }, - CultureInfo.CreateSpecificCulture ("en-US"), - DateTimeStyles.AdjustToUniversal | DateTimeStyles.AssumeUniversal, - out expires)) - expires = DateTime.Now; - - if (cookie != null && cookie.Expires == DateTime.MinValue) + + if (pair.IndexOf ("expires", compType) == 0) { + if (i == pairs.Length - 1) + break; + + i++; + + if (cookie != null) { + if (cookie.Expires != DateTime.MinValue) + continue; + + var buff = new StringBuilder (pair.GetValue ('='), 32); + buff.AppendFormat (", {0}", pairs[i].Trim ()); + + DateTime expires; + if ( + !DateTime.TryParseExact ( + buff.ToString (), + new[] { "ddd, dd'-'MMM'-'yyyy HH':'mm':'ss 'GMT'", "r" }, + CultureInfo.CreateSpecificCulture ("en-US"), + DateTimeStyles.AdjustToUniversal + | DateTimeStyles.AssumeUniversal, + out expires + ) + ) + expires = DateTime.Now; + cookie.Expires = expires.ToLocalTime (); + } + + continue; } - else if (pair.StartsWith ("max-age", StringComparison.InvariantCultureIgnoreCase)) { - var max = Int32.Parse (pair.GetValue ('=', true)); - var expires = DateTime.Now.AddSeconds ((double) max); - if (cookie != null) + + if (pair.IndexOf ("max-age", compType) == 0) { + if (cookie != null) { + var max = Int32.Parse (pair.GetValue ('=', true)); + var expires = DateTime.Now.AddSeconds ((double) max); cookie.Expires = expires; + } + + continue; } - else if (pair.StartsWith ("path", StringComparison.InvariantCultureIgnoreCase)) { + + if (pair.IndexOf ("path", compType) == 0) { if (cookie != null) cookie.Path = pair.GetValue ('='); + + continue; } - else if (pair.StartsWith ("domain", StringComparison.InvariantCultureIgnoreCase)) { + + if (pair.IndexOf ("domain", compType) == 0) { if (cookie != null) cookie.Domain = pair.GetValue ('='); + + continue; } - else if (pair.StartsWith ("port", StringComparison.InvariantCultureIgnoreCase)) { - var port = pair.Equals ("port", StringComparison.InvariantCultureIgnoreCase) - ? "\"\"" - : pair.GetValue ('='); - if (cookie != null) - cookie.Port = port; + if (pair.IndexOf ("port", compType) == 0) { + if (cookie != null) { + cookie.Port = !pair.Equals ("port", compType) + ? pair.GetValue ('=') + : "\"\""; + } + + continue; } - else if (pair.StartsWith ("comment", StringComparison.InvariantCultureIgnoreCase)) { + + if (pair.IndexOf ("comment", compType) == 0) { if (cookie != null) cookie.Comment = urlDecode (pair.GetValue ('='), Encoding.UTF8); + + continue; } - else if (pair.StartsWith ("commenturl", StringComparison.InvariantCultureIgnoreCase)) { + + if (pair.IndexOf ("commenturl", compType) == 0) { if (cookie != null) cookie.CommentUri = pair.GetValue ('=', true).ToUri (); + + continue; } - else if (pair.StartsWith ("discard", StringComparison.InvariantCultureIgnoreCase)) { + + if (pair.IndexOf ("discard", compType) == 0) { if (cookie != null) cookie.Discard = true; + + continue; } - else if (pair.StartsWith ("secure", StringComparison.InvariantCultureIgnoreCase)) { + + if (pair.IndexOf ("secure", compType) == 0) { if (cookie != null) cookie.Secure = true; + + continue; } - else if (pair.StartsWith ("httponly", StringComparison.InvariantCultureIgnoreCase)) { + + if (pair.IndexOf ("httponly", compType) == 0) { if (cookie != null) cookie.HttpOnly = true; + + continue; + } + + if (cookie != null) { + ret.Add (cookie); + cookie = null; } - else { - if (cookie != null) - cookies.Add (cookie); - string name; - string val = String.Empty; + var idx = pair.IndexOf ('='); + if (idx == -1) + continue; - var pos = pair.IndexOf ('='); - if (pos == -1) { - name = pair; - } - else if (pos == pair.Length - 1) { - name = pair.Substring (0, pos).TrimEnd (' '); - } - else { - name = pair.Substring (0, pos).TrimEnd (' '); - val = pair.Substring (pos + 1).TrimStart (' '); - } + if (idx == pair.Length - 1) + continue; - cookie = new Cookie (name, val); - } + var name = pair.Substring (0, idx).TrimEnd (' '); + var val = pair.Substring (idx + 1).TrimStart (' '); + cookie = new Cookie (name, val); } if (cookie != null) - cookies.Add (cookie); + ret.Add (cookie); - return cookies; + return ret; } private int search (Cookie cookie) From 1d7de51c31b6da7a17a65519f7aa33edbc9adb8e Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 13 Apr 2019 17:55:31 +0900 Subject: [PATCH 2404/6294] [Modify] Polish it --- websocket-sharp/Net/CookieCollection.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/CookieCollection.cs b/websocket-sharp/Net/CookieCollection.cs index 98fb8b022..ba120007f 100644 --- a/websocket-sharp/Net/CookieCollection.cs +++ b/websocket-sharp/Net/CookieCollection.cs @@ -418,21 +418,21 @@ out expires continue; } - if (pair.IndexOf ("discard", compType) == 0) { + if (pair.Equals ("discard", compType)) { if (cookie != null) cookie.Discard = true; continue; } - if (pair.IndexOf ("secure", compType) == 0) { + if (pair.Equals ("secure", compType)) { if (cookie != null) cookie.Secure = true; continue; } - if (pair.IndexOf ("httponly", compType) == 0) { + if (pair.Equals ("httponly", compType)) { if (cookie != null) cookie.HttpOnly = true; From 816272a908cd6f341f8779589ed3c076a4ff5c8f Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 14 Apr 2019 16:35:34 +0900 Subject: [PATCH 2405/6294] [Modify] Continue if name is empty --- websocket-sharp/Net/CookieCollection.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/CookieCollection.cs b/websocket-sharp/Net/CookieCollection.cs index ba120007f..4bc5cafa1 100644 --- a/websocket-sharp/Net/CookieCollection.cs +++ b/websocket-sharp/Net/CookieCollection.cs @@ -448,11 +448,14 @@ out expires if (idx == -1) continue; - if (idx == pair.Length - 1) + if (idx == 0) continue; var name = pair.Substring (0, idx).TrimEnd (' '); - var val = pair.Substring (idx + 1).TrimStart (' '); + var val = idx < pair.Length - 1 + ? pair.Substring (idx + 1).TrimStart (' ') + : String.Empty; + cookie = new Cookie (name, val); } From 3da7b49a477f3859c3ed7788bd813cc83fd6e921 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 15 Apr 2019 21:21:21 +0900 Subject: [PATCH 2406/6294] [Modify] Polish it --- websocket-sharp/Net/CookieCollection.cs | 183 ++++++++++++++---------- 1 file changed, 110 insertions(+), 73 deletions(-) diff --git a/websocket-sharp/Net/CookieCollection.cs b/websocket-sharp/Net/CookieCollection.cs index 4bc5cafa1..69decdd4a 100644 --- a/websocket-sharp/Net/CookieCollection.cs +++ b/websocket-sharp/Net/CookieCollection.cs @@ -331,111 +331,160 @@ private static CookieCollection parseResponse (string value) if (pair.Length == 0) continue; - if (pair.IndexOf ("version", compType) == 0) { - if (cookie != null) - cookie.Version = Int32.Parse (pair.GetValue ('=', true)); - - continue; - } + var idx = pair.IndexOf ('='); + if (idx == -1) { + if (cookie == null) + continue; - if (pair.IndexOf ("expires", compType) == 0) { - if (i == pairs.Length - 1) - break; + if (pair.Equals ("port", compType)) { + cookie.Port = "\"\""; + continue; + } - i++; + if (pair.Equals ("discard", compType)) { + cookie.Discard = true; + continue; + } - if (cookie != null) { - if (cookie.Expires != DateTime.MinValue) - continue; - - var buff = new StringBuilder (pair.GetValue ('='), 32); - buff.AppendFormat (", {0}", pairs[i].Trim ()); - - DateTime expires; - if ( - !DateTime.TryParseExact ( - buff.ToString (), - new[] { "ddd, dd'-'MMM'-'yyyy HH':'mm':'ss 'GMT'", "r" }, - CultureInfo.CreateSpecificCulture ("en-US"), - DateTimeStyles.AdjustToUniversal - | DateTimeStyles.AssumeUniversal, - out expires - ) - ) - expires = DateTime.Now; + if (pair.Equals ("secure", compType)) { + cookie.Secure = true; + continue; + } - cookie.Expires = expires.ToLocalTime (); + if (pair.Equals ("httponly", compType)) { + cookie.HttpOnly = true; + continue; } continue; } - if (pair.IndexOf ("max-age", compType) == 0) { + if (idx == 0) { if (cookie != null) { - var max = Int32.Parse (pair.GetValue ('=', true)); - var expires = DateTime.Now.AddSeconds ((double) max); - cookie.Expires = expires; + ret.Add (cookie); + cookie = null; } continue; } - if (pair.IndexOf ("path", compType) == 0) { - if (cookie != null) - cookie.Path = pair.GetValue ('='); + var name = pair.Substring (0, idx).TrimEnd (' '); + var val = idx < pair.Length - 1 + ? pair.Substring (idx + 1).TrimStart (' ') + : String.Empty; + + if (name.Equals ("version", compType)) { + if (cookie == null) + continue; + if (val.Length == 0) + continue; + + cookie.Version = Int32.Parse (val.Unquote ()); continue; } - if (pair.IndexOf ("domain", compType) == 0) { - if (cookie != null) - cookie.Domain = pair.GetValue ('='); + if (name.Equals ("expires", compType)) { + if (val.Length == 0) + continue; + + if (i == pairs.Length - 1) + break; + + i++; + + if (cookie == null) + continue; + + if (cookie.Expires != DateTime.MinValue) + continue; + var buff = new StringBuilder (val, 32); + buff.AppendFormat (", {0}", pairs[i].Trim ()); + + DateTime expires; + if ( + !DateTime.TryParseExact ( + buff.ToString (), + new[] { "ddd, dd'-'MMM'-'yyyy HH':'mm':'ss 'GMT'", "r" }, + CultureInfo.CreateSpecificCulture ("en-US"), + DateTimeStyles.AdjustToUniversal + | DateTimeStyles.AssumeUniversal, + out expires + ) + ) + expires = DateTime.Now; + + cookie.Expires = expires.ToLocalTime (); continue; } - if (pair.IndexOf ("port", compType) == 0) { - if (cookie != null) { - cookie.Port = !pair.Equals ("port", compType) - ? pair.GetValue ('=') - : "\"\""; - } + if (name.Equals ("max-age", compType)) { + if (cookie == null) + continue; + + if (val.Length == 0) + continue; + + var max = Int32.Parse (val.Unquote ()); + var expires = DateTime.Now.AddSeconds ((double) max); + cookie.Expires = expires; continue; } - if (pair.IndexOf ("comment", compType) == 0) { - if (cookie != null) - cookie.Comment = urlDecode (pair.GetValue ('='), Encoding.UTF8); + if (name.Equals ("path", compType)) { + if (cookie == null) + continue; + + if (val.Length == 0) + continue; + cookie.Path = val; continue; } - if (pair.IndexOf ("commenturl", compType) == 0) { - if (cookie != null) - cookie.CommentUri = pair.GetValue ('=', true).ToUri (); + if (name.Equals ("domain", compType)) { + if (cookie == null) + continue; + + if (val.Length == 0) + continue; + cookie.Domain = val; continue; } - if (pair.Equals ("discard", compType)) { - if (cookie != null) - cookie.Discard = true; + if (name.Equals ("port", compType)) { + if (cookie == null) + continue; + if (val.Length == 0) + continue; + + cookie.Port = val; continue; } - if (pair.Equals ("secure", compType)) { - if (cookie != null) - cookie.Secure = true; + if (name.Equals ("comment", compType)) { + if (cookie == null) + continue; + + if (val.Length == 0) + continue; + cookie.Comment = urlDecode (val, Encoding.UTF8); continue; } - if (pair.Equals ("httponly", compType)) { - if (cookie != null) - cookie.HttpOnly = true; + if (name.Equals ("commenturl", compType)) { + if (cookie == null) + continue; + if (val.Length == 0) + continue; + + cookie.CommentUri = val.Unquote ().ToUri (); continue; } @@ -444,18 +493,6 @@ out expires cookie = null; } - var idx = pair.IndexOf ('='); - if (idx == -1) - continue; - - if (idx == 0) - continue; - - var name = pair.Substring (0, idx).TrimEnd (' '); - var val = idx < pair.Length - 1 - ? pair.Substring (idx + 1).TrimStart (' ') - : String.Empty; - cookie = new Cookie (name, val); } From 983d45b79ca3dd404e8cfd2efd42751c2af3c2df Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 16 Apr 2019 13:51:36 +0900 Subject: [PATCH 2407/6294] [Modify] Replace it --- websocket-sharp/Net/CookieCollection.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/CookieCollection.cs b/websocket-sharp/Net/CookieCollection.cs index 69decdd4a..eb1575238 100644 --- a/websocket-sharp/Net/CookieCollection.cs +++ b/websocket-sharp/Net/CookieCollection.cs @@ -324,9 +324,9 @@ private static CookieCollection parseResponse (string value) Cookie cookie = null; var compType = StringComparison.InvariantCultureIgnoreCase; - var pairs = splitCookieHeaderValue (value); + var pairs = value.SplitHeaderValue (',', ';').ToList (); - for (var i = 0; i < pairs.Length; i++) { + for (var i = 0; i < pairs.Count; i++) { var pair = pairs[i].Trim (); if (pair.Length == 0) continue; @@ -388,7 +388,7 @@ private static CookieCollection parseResponse (string value) if (val.Length == 0) continue; - if (i == pairs.Length - 1) + if (i == pairs.Count - 1) break; i++; From 2cf5a7e7060e23b84cb5024379466639d96c6477 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 16 Apr 2019 13:54:26 +0900 Subject: [PATCH 2408/6294] [Modify] Polish it --- websocket-sharp/Net/CookieCollection.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/websocket-sharp/Net/CookieCollection.cs b/websocket-sharp/Net/CookieCollection.cs index eb1575238..b73f8e524 100644 --- a/websocket-sharp/Net/CookieCollection.cs +++ b/websocket-sharp/Net/CookieCollection.cs @@ -488,10 +488,8 @@ out expires continue; } - if (cookie != null) { + if (cookie != null) ret.Add (cookie); - cookie = null; - } cookie = new Cookie (name, val); } From df1e9fbba0d6d644b401909954b5e27328abc3ae Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 17 Apr 2019 16:07:18 +0900 Subject: [PATCH 2409/6294] [Modify] Polish it --- websocket-sharp/Net/CookieCollection.cs | 71 +++++++++++++++++-------- 1 file changed, 48 insertions(+), 23 deletions(-) diff --git a/websocket-sharp/Net/CookieCollection.cs b/websocket-sharp/Net/CookieCollection.cs index b73f8e524..e769e7205 100644 --- a/websocket-sharp/Net/CookieCollection.cs +++ b/websocket-sharp/Net/CookieCollection.cs @@ -262,49 +262,74 @@ private static CookieCollection parseRequest (string value) if (pair.Length == 0) continue; - if (pair.IndexOf ("$version", compType) == 0) { - ver = Int32.Parse (pair.GetValue ('=', true)); + var idx = pair.IndexOf ('='); + if (idx == -1) { + if (cookie == null) + continue; + + if (pair.Equals ("$port", compType)) { + cookie.Port = "\"\""; + continue; + } + continue; } - if (pair.IndexOf ("$path", compType) == 0) { - if (cookie != null) - cookie.Path = pair.GetValue ('='); + if (idx == 0) { + if (cookie != null) { + ret.Add (cookie); + cookie = null; + } continue; } - if (pair.IndexOf ("$domain", compType) == 0) { - if (cookie != null) - cookie.Domain = pair.GetValue ('='); + var name = pair.Substring (0, idx).TrimEnd (' '); + var val = idx < pair.Length - 1 + ? pair.Substring (idx + 1).TrimStart (' ') + : String.Empty; + if (name.Equals ("$version", compType)) { + ver = val.Length > 0 ? Int32.Parse (val.Unquote ()) : 0; continue; } - if (pair.IndexOf ("$port", compType) == 0) { - if (cookie != null) { - cookie.Port = !pair.Equals ("$port", compType) - ? pair.GetValue ('=') - : "\"\""; - } + if (name.Equals ("$path", compType)) { + if (cookie == null) + continue; + + if (val.Length == 0) + continue; + cookie.Path = val; continue; } - if (cookie != null) { - ret.Add (cookie); - cookie = null; - } + if (name.Equals ("$domain", compType)) { + if (cookie == null) + continue; - var idx = pair.IndexOf ('='); - if (idx == -1) + if (val.Length == 0) + continue; + + cookie.Domain = val; continue; + } - if (idx == pair.Length - 1) + if (name.Equals ("$port", compType)) { + if (cookie == null) + continue; + + if (val.Length == 0) + continue; + + cookie.Port = val; continue; + } + + if (cookie != null) + ret.Add (cookie); - var name = pair.Substring (0, idx).TrimEnd (' '); - var val = pair.Substring (idx + 1).TrimStart (' '); cookie = new Cookie (name, val); if (ver != 0) From 0b7047618e21edc68f64e08081379f100ba03143 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 17 Apr 2019 16:09:11 +0900 Subject: [PATCH 2410/6294] [Modify] Replace it --- websocket-sharp/Net/CookieCollection.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/CookieCollection.cs b/websocket-sharp/Net/CookieCollection.cs index e769e7205..1086d9587 100644 --- a/websocket-sharp/Net/CookieCollection.cs +++ b/websocket-sharp/Net/CookieCollection.cs @@ -255,9 +255,9 @@ private static CookieCollection parseRequest (string value) var compType = StringComparison.InvariantCultureIgnoreCase; var ver = 0; - var pairs = splitCookieHeaderValue (value); + var pairs = value.SplitHeaderValue (',', ';').ToList (); - for (var i = 0; i < pairs.Length; i++) { + for (var i = 0; i < pairs.Count; i++) { var pair = pairs[i].Trim (); if (pair.Length == 0) continue; From e43680d45a5e2c74a876a0d03f590fdfb55c5e49 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 18 Apr 2019 14:10:48 +0900 Subject: [PATCH 2411/6294] [Modify] Remove it --- websocket-sharp/Net/CookieCollection.cs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/websocket-sharp/Net/CookieCollection.cs b/websocket-sharp/Net/CookieCollection.cs index 1086d9587..696d44d9f 100644 --- a/websocket-sharp/Net/CookieCollection.cs +++ b/websocket-sharp/Net/CookieCollection.cs @@ -535,11 +535,6 @@ private int search (Cookie cookie) return -1; } - private static string[] splitCookieHeaderValue (string value) - { - return new List (value.SplitHeaderValue (',', ';')).ToArray (); - } - private static string urlDecode (string s, Encoding encoding) { if (s == null) From 12755ff40444525e669148db985ce36686058b34 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 19 Apr 2019 15:39:32 +0900 Subject: [PATCH 2412/6294] [Modify] Rename it --- websocket-sharp/Net/CookieCollection.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Net/CookieCollection.cs b/websocket-sharp/Net/CookieCollection.cs index 696d44d9f..1da0e1e8a 100644 --- a/websocket-sharp/Net/CookieCollection.cs +++ b/websocket-sharp/Net/CookieCollection.cs @@ -252,9 +252,9 @@ private static CookieCollection parseRequest (string value) var ret = new CookieCollection (); Cookie cookie = null; - var compType = StringComparison.InvariantCultureIgnoreCase; var ver = 0; + var caseInsensitive = StringComparison.InvariantCultureIgnoreCase; var pairs = value.SplitHeaderValue (',', ';').ToList (); for (var i = 0; i < pairs.Count; i++) { @@ -267,7 +267,7 @@ private static CookieCollection parseRequest (string value) if (cookie == null) continue; - if (pair.Equals ("$port", compType)) { + if (pair.Equals ("$port", caseInsensitive)) { cookie.Port = "\"\""; continue; } @@ -289,12 +289,12 @@ private static CookieCollection parseRequest (string value) ? pair.Substring (idx + 1).TrimStart (' ') : String.Empty; - if (name.Equals ("$version", compType)) { + if (name.Equals ("$version", caseInsensitive)) { ver = val.Length > 0 ? Int32.Parse (val.Unquote ()) : 0; continue; } - if (name.Equals ("$path", compType)) { + if (name.Equals ("$path", caseInsensitive)) { if (cookie == null) continue; @@ -305,7 +305,7 @@ private static CookieCollection parseRequest (string value) continue; } - if (name.Equals ("$domain", compType)) { + if (name.Equals ("$domain", caseInsensitive)) { if (cookie == null) continue; @@ -316,7 +316,7 @@ private static CookieCollection parseRequest (string value) continue; } - if (name.Equals ("$port", compType)) { + if (name.Equals ("$port", caseInsensitive)) { if (cookie == null) continue; From 2a7739c428b6ebc8af705aa7577c720aa3cb6b5f Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 19 Apr 2019 15:44:15 +0900 Subject: [PATCH 2413/6294] [Modify] Rename it --- websocket-sharp/Net/CookieCollection.cs | 26 ++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/websocket-sharp/Net/CookieCollection.cs b/websocket-sharp/Net/CookieCollection.cs index 1da0e1e8a..ef74485a9 100644 --- a/websocket-sharp/Net/CookieCollection.cs +++ b/websocket-sharp/Net/CookieCollection.cs @@ -347,8 +347,8 @@ private static CookieCollection parseResponse (string value) var ret = new CookieCollection (); Cookie cookie = null; - var compType = StringComparison.InvariantCultureIgnoreCase; + var caseInsensitive = StringComparison.InvariantCultureIgnoreCase; var pairs = value.SplitHeaderValue (',', ';').ToList (); for (var i = 0; i < pairs.Count; i++) { @@ -361,22 +361,22 @@ private static CookieCollection parseResponse (string value) if (cookie == null) continue; - if (pair.Equals ("port", compType)) { + if (pair.Equals ("port", caseInsensitive)) { cookie.Port = "\"\""; continue; } - if (pair.Equals ("discard", compType)) { + if (pair.Equals ("discard", caseInsensitive)) { cookie.Discard = true; continue; } - if (pair.Equals ("secure", compType)) { + if (pair.Equals ("secure", caseInsensitive)) { cookie.Secure = true; continue; } - if (pair.Equals ("httponly", compType)) { + if (pair.Equals ("httponly", caseInsensitive)) { cookie.HttpOnly = true; continue; } @@ -398,7 +398,7 @@ private static CookieCollection parseResponse (string value) ? pair.Substring (idx + 1).TrimStart (' ') : String.Empty; - if (name.Equals ("version", compType)) { + if (name.Equals ("version", caseInsensitive)) { if (cookie == null) continue; @@ -409,7 +409,7 @@ private static CookieCollection parseResponse (string value) continue; } - if (name.Equals ("expires", compType)) { + if (name.Equals ("expires", caseInsensitive)) { if (val.Length == 0) continue; @@ -444,7 +444,7 @@ out expires continue; } - if (name.Equals ("max-age", compType)) { + if (name.Equals ("max-age", caseInsensitive)) { if (cookie == null) continue; @@ -458,7 +458,7 @@ out expires continue; } - if (name.Equals ("path", compType)) { + if (name.Equals ("path", caseInsensitive)) { if (cookie == null) continue; @@ -469,7 +469,7 @@ out expires continue; } - if (name.Equals ("domain", compType)) { + if (name.Equals ("domain", caseInsensitive)) { if (cookie == null) continue; @@ -480,7 +480,7 @@ out expires continue; } - if (name.Equals ("port", compType)) { + if (name.Equals ("port", caseInsensitive)) { if (cookie == null) continue; @@ -491,7 +491,7 @@ out expires continue; } - if (name.Equals ("comment", compType)) { + if (name.Equals ("comment", caseInsensitive)) { if (cookie == null) continue; @@ -502,7 +502,7 @@ out expires continue; } - if (name.Equals ("commenturl", compType)) { + if (name.Equals ("commenturl", caseInsensitive)) { if (cookie == null) continue; From d8fd3219629f71082741b1e57a56fde47382732d Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 20 Apr 2019 16:44:16 +0900 Subject: [PATCH 2414/6294] [Modify] Rename it --- websocket-sharp/Net/CookieCollection.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/CookieCollection.cs b/websocket-sharp/Net/CookieCollection.cs index ef74485a9..5e73aebad 100644 --- a/websocket-sharp/Net/CookieCollection.cs +++ b/websocket-sharp/Net/CookieCollection.cs @@ -193,10 +193,10 @@ public Cookie this[string name] { if (name == null) throw new ArgumentNullException ("name"); - var compType = StringComparison.InvariantCultureIgnoreCase; + var caseInsensitive = StringComparison.InvariantCultureIgnoreCase; foreach (var cookie in Sorted) { - if (cookie.Name.Equals (name, compType)) + if (cookie.Name.Equals (name, caseInsensitive)) return cookie; } From 449e38c239b74375e7468683bb50ccd01f535f92 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 21 Apr 2019 17:47:05 +0900 Subject: [PATCH 2415/6294] [Modify] Throw an exception if read-only --- websocket-sharp/Net/CookieCollection.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/websocket-sharp/Net/CookieCollection.cs b/websocket-sharp/Net/CookieCollection.cs index 5e73aebad..8f91063a0 100644 --- a/websocket-sharp/Net/CookieCollection.cs +++ b/websocket-sharp/Net/CookieCollection.cs @@ -603,11 +603,19 @@ internal void Sort () /// /// A to add. /// + /// + /// The collection is read-only. + /// /// /// is . /// public void Add (Cookie cookie) { + if (_readOnly) { + var msg = "The collection is read-only."; + throw new InvalidOperationException (msg); + } + if (cookie == null) throw new ArgumentNullException ("cookie"); From e111cc2ee2dab159c73302b4e5ed1381ecf3c901 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 22 Apr 2019 14:15:17 +0900 Subject: [PATCH 2416/6294] [Modify] Throw an exception if read-only --- websocket-sharp/Net/CookieCollection.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/websocket-sharp/Net/CookieCollection.cs b/websocket-sharp/Net/CookieCollection.cs index 8f91063a0..cd454d31f 100644 --- a/websocket-sharp/Net/CookieCollection.cs +++ b/websocket-sharp/Net/CookieCollection.cs @@ -628,11 +628,19 @@ public void Add (Cookie cookie) /// /// A that contains the cookies to add. /// + /// + /// The collection is read-only. + /// /// /// is . /// public void Add (CookieCollection cookies) { + if (_readOnly) { + var msg = "The collection is read-only."; + throw new InvalidOperationException (msg); + } + if (cookies == null) throw new ArgumentNullException ("cookies"); From ecc78958c4a212ecb4909cf788e0a041200ed62f Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 22 Apr 2019 14:19:48 +0900 Subject: [PATCH 2417/6294] [Modify] Polish it --- websocket-sharp/Net/CookieCollection.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/CookieCollection.cs b/websocket-sharp/Net/CookieCollection.cs index cd454d31f..b63344f74 100644 --- a/websocket-sharp/Net/CookieCollection.cs +++ b/websocket-sharp/Net/CookieCollection.cs @@ -644,7 +644,7 @@ public void Add (CookieCollection cookies) if (cookies == null) throw new ArgumentNullException ("cookies"); - foreach (Cookie cookie in cookies) + foreach (var cookie in cookies._list) add (cookie); } From 70ff5dc041efea4f94260a4d8fb6f15ea7ae6ad5 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 23 Apr 2019 13:36:51 +0900 Subject: [PATCH 2418/6294] [Modify] Add it --- websocket-sharp/Net/CookieCollection.cs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/websocket-sharp/Net/CookieCollection.cs b/websocket-sharp/Net/CookieCollection.cs index b63344f74..a466be687 100644 --- a/websocket-sharp/Net/CookieCollection.cs +++ b/websocket-sharp/Net/CookieCollection.cs @@ -648,6 +648,22 @@ public void Add (CookieCollection cookies) add (cookie); } + /// + /// Removes all cookies from the collection. + /// + /// + /// The collection is read-only. + /// + public void Clear () + { + if (_readOnly) { + var msg = "The collection is read-only."; + throw new InvalidOperationException (msg); + } + + _list.Clear (); + } + /// /// Copies the elements of the collection to the specified array, /// starting at the specified index. From 09bcf0520e19e8f3e925b7602f0dcf75ff791b8f Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 24 Apr 2019 16:16:18 +0900 Subject: [PATCH 2419/6294] [Modify] Add it --- websocket-sharp/Net/CookieCollection.cs | 34 +++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/websocket-sharp/Net/CookieCollection.cs b/websocket-sharp/Net/CookieCollection.cs index a466be687..99b5278a5 100644 --- a/websocket-sharp/Net/CookieCollection.cs +++ b/websocket-sharp/Net/CookieCollection.cs @@ -772,6 +772,40 @@ public IEnumerator GetEnumerator () return _list.GetEnumerator (); } + /// + /// Removes the specified cookie from the collection. + /// + /// + /// true if the cookie is successfully found and removed; + /// otherwise, false. + /// + /// + /// A to remove. + /// + /// + /// The collection is read-only. + /// + /// + /// is . + /// + public bool Remove (Cookie cookie) + { + if (_readOnly) { + var msg = "The collection is read-only."; + throw new InvalidOperationException (msg); + } + + if (cookie == null) + throw new ArgumentNullException ("cookie"); + + var idx = search (cookie); + if (idx == -1) + return false; + + _list.RemoveAt (idx); + return true; + } + #endregion } } From bc7063858d2c3eb3da1bd33523e2c8ce894db3a7 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 25 Apr 2019 16:19:11 +0900 Subject: [PATCH 2420/6294] [Modify] Add it --- websocket-sharp/Net/CookieCollection.cs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/websocket-sharp/Net/CookieCollection.cs b/websocket-sharp/Net/CookieCollection.cs index 99b5278a5..022c2b6e3 100644 --- a/websocket-sharp/Net/CookieCollection.cs +++ b/websocket-sharp/Net/CookieCollection.cs @@ -664,6 +664,27 @@ public void Clear () _list.Clear (); } + /// + /// Determines whether the collection contains the specified cookie. + /// + /// + /// true if the cookie is found in the collection; otherwise, + /// false. + /// + /// + /// A to find. + /// + /// + /// is . + /// + public bool Contains (Cookie cookie) + { + if (cookie == null) + throw new ArgumentNullException ("cookie"); + + return search (cookie) > -1; + } + /// /// Copies the elements of the collection to the specified array, /// starting at the specified index. From 7a5b81d389f174418f623ad5ac23f19c878263c1 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 25 Apr 2019 16:32:03 +0900 Subject: [PATCH 2421/6294] [Modify] Edit it --- websocket-sharp/Net/CookieCollection.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/CookieCollection.cs b/websocket-sharp/Net/CookieCollection.cs index 022c2b6e3..5c7a42fab 100644 --- a/websocket-sharp/Net/CookieCollection.cs +++ b/websocket-sharp/Net/CookieCollection.cs @@ -797,8 +797,13 @@ public IEnumerator GetEnumerator () /// Removes the specified cookie from the collection. /// /// - /// true if the cookie is successfully found and removed; - /// otherwise, false. + /// + /// true if the cookie is successfully removed; otherwise, + /// false. + /// + /// + /// false if the cookie is not found in the collection. + /// /// /// /// A to remove. From 302d687a9547e02265bb5e20126496d48bc91000 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 26 Apr 2019 17:01:49 +0900 Subject: [PATCH 2422/6294] [Modify] Inherit the ICollection interface --- websocket-sharp/Net/CookieCollection.cs | 26 ++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Net/CookieCollection.cs b/websocket-sharp/Net/CookieCollection.cs index 5c7a42fab..ede7cfd60 100644 --- a/websocket-sharp/Net/CookieCollection.cs +++ b/websocket-sharp/Net/CookieCollection.cs @@ -51,7 +51,7 @@ namespace WebSocketSharp.Net /// Provides a collection of instances of the class. /// [Serializable] - public class CookieCollection : ICollection, IEnumerable + public class CookieCollection : ICollection { #region Private Fields @@ -782,13 +782,13 @@ public void CopyTo (Cookie[] array, int index) } /// - /// Gets the enumerator used to iterate through the collection. + /// Gets the enumerator that iterates through the collection. /// /// - /// An instance used to iterate through - /// the collection. + /// An + /// instance that can be used to iterate through the collection. /// - public IEnumerator GetEnumerator () + public IEnumerator GetEnumerator () { return _list.GetEnumerator (); } @@ -833,5 +833,21 @@ public bool Remove (Cookie cookie) } #endregion + + #region Explicit Interface Implementations + + /// + /// Gets the enumerator that iterates through the collection. + /// + /// + /// An instance that can be used to iterate + /// through the collection. + /// + IEnumerator IEnumerable.GetEnumerator () + { + return _list.GetEnumerator (); + } + + #endregion } } From 39b40c4e61acda7ef82b6c19b9b3d35253434ba3 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 27 Apr 2019 15:57:32 +0900 Subject: [PATCH 2423/6294] [Modify] Remove it --- websocket-sharp/Net/CookieCollection.cs | 58 ------------------------- 1 file changed, 58 deletions(-) diff --git a/websocket-sharp/Net/CookieCollection.cs b/websocket-sharp/Net/CookieCollection.cs index ede7cfd60..8bfdf0e0c 100644 --- a/websocket-sharp/Net/CookieCollection.cs +++ b/websocket-sharp/Net/CookieCollection.cs @@ -685,64 +685,6 @@ public bool Contains (Cookie cookie) return search (cookie) > -1; } - /// - /// Copies the elements of the collection to the specified array, - /// starting at the specified index. - /// - /// - /// An that specifies the destination of - /// the elements copied from the collection. - /// - /// - /// An that specifies the zero-based index in - /// the array at which copying starts. - /// - /// - /// is . - /// - /// - /// is less than zero. - /// - /// - /// - /// is multidimensional. - /// - /// - /// -or- - /// - /// - /// The space from to the end of - /// is not enough to copy to. - /// - /// - /// - /// The element type of cannot be assigned. - /// - public void CopyTo (Array array, int index) - { - if (array == null) - throw new ArgumentNullException ("array"); - - if (index < 0) - throw new ArgumentOutOfRangeException ("index", "Less than zero."); - - if (array.Rank > 1) - throw new ArgumentException ("Multidimensional.", "array"); - - if (array.Length - index < _list.Count) { - var msg = "The available space of the array is not enough to copy to."; - throw new ArgumentException (msg); - } - - var elmType = array.GetType ().GetElementType (); - if (!elmType.IsAssignableFrom (typeof (Cookie))) { - var msg = "The element type of the array cannot be assigned."; - throw new InvalidCastException (msg); - } - - ((IList) _list).CopyTo (array, index); - } - /// /// Copies the elements of the collection to the specified array, /// starting at the specified index. From 4735c12bfd271dd731f9f01a1b18d1fd2848f8b2 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 27 Apr 2019 16:04:42 +0900 Subject: [PATCH 2424/6294] [Modify] Polish it --- websocket-sharp/Net/CookieCollection.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/CookieCollection.cs b/websocket-sharp/Net/CookieCollection.cs index 8bfdf0e0c..51082f128 100644 --- a/websocket-sharp/Net/CookieCollection.cs +++ b/websocket-sharp/Net/CookieCollection.cs @@ -583,7 +583,7 @@ internal void SetOrRemove (Cookie cookie) internal void SetOrRemove (CookieCollection cookies) { - foreach (Cookie cookie in cookies) + foreach (var cookie in cookies._list) SetOrRemove (cookie); } From 3678e6b797e9262bf1aad1d46ad60ec79ace31aa Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 28 Apr 2019 22:32:11 +0900 Subject: [PATCH 2425/6294] [Modify] 2019 --- websocket-sharp/Net/CookieCollection.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/CookieCollection.cs b/websocket-sharp/Net/CookieCollection.cs index 51082f128..8b80732d5 100644 --- a/websocket-sharp/Net/CookieCollection.cs +++ b/websocket-sharp/Net/CookieCollection.cs @@ -8,7 +8,7 @@ * The MIT License * * Copyright (c) 2004,2009 Novell, Inc. (http://www.novell.com) - * Copyright (c) 2012-2014 sta.blockhead + * Copyright (c) 2012-2019 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From 440698f5496ab84c5af0d5eb16105eac6bc18805 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 28 Apr 2019 22:38:24 +0900 Subject: [PATCH 2426/6294] [Modify] To internal --- websocket-sharp/Net/Cookie.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/Cookie.cs b/websocket-sharp/Net/Cookie.cs index d334dd2fc..cf6b5f86c 100644 --- a/websocket-sharp/Net/Cookie.cs +++ b/websocket-sharp/Net/Cookie.cs @@ -110,16 +110,20 @@ static Cookie () #endregion - #region Public Constructors + #region Internal Constructors /// /// Initializes a new instance of the class. /// - public Cookie () + internal Cookie () { init (String.Empty, "\"\"", String.Empty, String.Empty); } + #endregion + + #region Public Constructors + /// /// Initializes a new instance of the class with /// the specified name and value. From c3b32ec1a461a1bb060367e15347d7640ceddd69 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 29 Apr 2019 15:58:05 +0900 Subject: [PATCH 2427/6294] [Modify] It must be a token --- websocket-sharp/Net/Cookie.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/Cookie.cs b/websocket-sharp/Net/Cookie.cs index cf6b5f86c..a7a976810 100644 --- a/websocket-sharp/Net/Cookie.cs +++ b/websocket-sharp/Net/Cookie.cs @@ -90,7 +90,6 @@ public sealed class Cookie private string _path; private string _port; private int[] _ports; - private static readonly char[] _reservedCharsForName; private static readonly char[] _reservedCharsForValue; private bool _secure; private DateTime _timeStamp; @@ -104,7 +103,6 @@ public sealed class Cookie static Cookie () { _emptyPorts = new int[0]; - _reservedCharsForName = new[] { ' ', '=', ';', ',', '\n', '\r', '\t' }; _reservedCharsForValue = new[] { ';', ',' }; } @@ -297,7 +295,7 @@ public Cookie (string name, string value, string path, string domain) throw new ArgumentException (msg, "name"); } - if (name.Contains (_reservedCharsForName)) { + if (!name.IsToken ()) { var msg = "It contains an invalid character."; throw new ArgumentException (msg, "name"); } @@ -560,7 +558,7 @@ public string Name { throw new ArgumentException (msg, "value"); } - if (value.Contains (_reservedCharsForName)) { + if (!value.IsToken ()) { var msg = "It contains an invalid character."; throw new ArgumentException (msg, "value"); } From d1e6737e07e5f4e35512fbd598db0801a67f66a5 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 30 Apr 2019 17:16:41 +0900 Subject: [PATCH 2428/6294] [Modify] Edit it --- websocket-sharp/Net/Cookie.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/Cookie.cs b/websocket-sharp/Net/Cookie.cs index a7a976810..76a086901 100644 --- a/websocket-sharp/Net/Cookie.cs +++ b/websocket-sharp/Net/Cookie.cs @@ -231,7 +231,14 @@ public Cookie (string name, string value, string path) /// the specified name, value, path, and domain. /// /// - /// A that specifies the Name of the cookie. + /// + /// A that specifies the name of the cookie. + /// + /// + /// The name must be a token defined in + /// + /// RFC 2616. + /// /// /// /// A that specifies the Value of the cookie. From 2a7d9844ea2e7851104fd3782266bc7ebede3292 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 30 Apr 2019 17:24:08 +0900 Subject: [PATCH 2429/6294] [Modify] Edit it --- websocket-sharp/Net/Cookie.cs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/Cookie.cs b/websocket-sharp/Net/Cookie.cs index 76a086901..2f9963230 100644 --- a/websocket-sharp/Net/Cookie.cs +++ b/websocket-sharp/Net/Cookie.cs @@ -523,10 +523,17 @@ public bool HttpOnly { } /// - /// Gets or sets the Name of the cookie. + /// Gets or sets the name of the cookie. /// /// - /// A that represents the Name of the cookie. + /// + /// A that represents the name of the cookie. + /// + /// + /// The name must be a token defined in + /// + /// RFC 2616. + /// /// /// /// The value specified for a set operation is . From a22842c735ba6e840331d0caffdfb8a3809d1fa9 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 1 May 2019 15:30:08 +0900 Subject: [PATCH 2430/6294] [Modify] Edit it --- websocket-sharp/Net/Cookie.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/Cookie.cs b/websocket-sharp/Net/Cookie.cs index 2f9963230..42fc3349f 100644 --- a/websocket-sharp/Net/Cookie.cs +++ b/websocket-sharp/Net/Cookie.cs @@ -127,7 +127,14 @@ internal Cookie () /// the specified name and value. /// /// - /// A that specifies the Name of the cookie. + /// + /// A that specifies the name of the cookie. + /// + /// + /// The name must be a token defined in + /// + /// RFC 2616. + /// /// /// /// A that specifies the Value of the cookie. From 33bb147d307b108de8e41d72a0e7a2f74a6b2eb6 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 2 May 2019 14:20:14 +0900 Subject: [PATCH 2431/6294] [Modify] Edit it --- websocket-sharp/Net/Cookie.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/Cookie.cs b/websocket-sharp/Net/Cookie.cs index 42fc3349f..1aeb302f5 100644 --- a/websocket-sharp/Net/Cookie.cs +++ b/websocket-sharp/Net/Cookie.cs @@ -184,7 +184,14 @@ public Cookie (string name, string value) /// the specified name, value, and path. /// /// - /// A that specifies the Name of the cookie. + /// + /// A that specifies the name of the cookie. + /// + /// + /// The name must be a token defined in + /// + /// RFC 2616. + /// /// /// /// A that specifies the Value of the cookie. From 1ea61947ba870a33764104a5d11bd22293aa0364 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 3 May 2019 17:08:17 +0900 Subject: [PATCH 2432/6294] [Modify] Set an empty string if null --- websocket-sharp/Net/Cookie.cs | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/websocket-sharp/Net/Cookie.cs b/websocket-sharp/Net/Cookie.cs index 1aeb302f5..9a2723f8c 100644 --- a/websocket-sharp/Net/Cookie.cs +++ b/websocket-sharp/Net/Cookie.cs @@ -115,7 +115,7 @@ static Cookie () /// internal Cookie () { - init (String.Empty, "\"\"", String.Empty, String.Empty); + init (String.Empty, String.Empty, String.Empty, String.Empty); } #endregion @@ -305,9 +305,6 @@ public Cookie (string name, string value, string path, string domain) if (name == null) throw new ArgumentNullException ("name"); - if (value == null) - throw new ArgumentNullException ("value"); - if (name.Length == 0) throw new ArgumentException ("An empty string.", "name"); @@ -321,6 +318,9 @@ public Cookie (string name, string value, string path, string domain) throw new ArgumentException (msg, "name"); } + if (value == null) + value = String.Empty; + if (value.Contains (_reservedCharsForValue)) { if (!value.IsEnclosedIn ('"')) { var msg = "A string not enclosed in double quotes."; @@ -328,12 +328,7 @@ public Cookie (string name, string value, string path, string domain) } } - init ( - name, - value.Length > 0 ? value : "\"\"", - path ?? String.Empty, - domain ?? String.Empty - ); + init (name, value, path ?? String.Empty, domain ?? String.Empty); } #endregion @@ -728,7 +723,7 @@ public string Value { set { if (value == null) - throw new ArgumentNullException ("value"); + value = String.Empty; if (value.Contains (_reservedCharsForValue)) { if (!value.IsEnclosedIn ('"')) { @@ -737,7 +732,7 @@ public string Value { } } - _value = value.Length > 0 ? value : "\"\""; + _value = value; } } From 4ff54f25cb1fb0b04195ae687bc53d74147ea989 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 3 May 2019 17:11:49 +0900 Subject: [PATCH 2433/6294] [Modify] Edit it --- websocket-sharp/Net/Cookie.cs | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/websocket-sharp/Net/Cookie.cs b/websocket-sharp/Net/Cookie.cs index 9a2723f8c..f10149f26 100644 --- a/websocket-sharp/Net/Cookie.cs +++ b/websocket-sharp/Net/Cookie.cs @@ -137,18 +137,10 @@ internal Cookie () /// /// /// - /// A that specifies the Value of the cookie. + /// A that specifies the value of the cookie. /// /// - /// - /// is . - /// - /// - /// - or - - /// - /// - /// is . - /// + /// is . /// /// /// From b0b706ee4f2845447d754a9483822193d00c914b Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 4 May 2019 16:19:55 +0900 Subject: [PATCH 2434/6294] [Modify] Edit it --- websocket-sharp/Net/Cookie.cs | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/websocket-sharp/Net/Cookie.cs b/websocket-sharp/Net/Cookie.cs index f10149f26..4b2100ffc 100644 --- a/websocket-sharp/Net/Cookie.cs +++ b/websocket-sharp/Net/Cookie.cs @@ -186,22 +186,14 @@ public Cookie (string name, string value) /// /// /// - /// A that specifies the Value of the cookie. + /// A that specifies the value of the cookie. /// /// /// A that specifies the value of the Path /// attribute of the cookie. /// /// - /// - /// is . - /// - /// - /// - or - - /// - /// - /// is . - /// + /// is . /// /// /// From 4cac405cdd9f4b3d7e0139b568fe1cb1364b0e47 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 4 May 2019 16:22:06 +0900 Subject: [PATCH 2435/6294] [Modify] Edit it --- websocket-sharp/Net/Cookie.cs | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/websocket-sharp/Net/Cookie.cs b/websocket-sharp/Net/Cookie.cs index 4b2100ffc..679105ae3 100644 --- a/websocket-sharp/Net/Cookie.cs +++ b/websocket-sharp/Net/Cookie.cs @@ -239,7 +239,7 @@ public Cookie (string name, string value, string path) /// /// /// - /// A that specifies the Value of the cookie. + /// A that specifies the value of the cookie. /// /// /// A that specifies the value of the Path @@ -250,15 +250,7 @@ public Cookie (string name, string value, string path) /// attribute of the cookie. /// /// - /// - /// is . - /// - /// - /// - or - - /// - /// - /// is . - /// + /// is . /// /// /// From a765f7b53d4468ae5c58c017a2a128183b2c964c Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 5 May 2019 21:53:31 +0900 Subject: [PATCH 2436/6294] [Modify] Edit it --- websocket-sharp/Net/Cookie.cs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Net/Cookie.cs b/websocket-sharp/Net/Cookie.cs index 679105ae3..20b714226 100644 --- a/websocket-sharp/Net/Cookie.cs +++ b/websocket-sharp/Net/Cookie.cs @@ -680,14 +680,11 @@ public DateTime TimeStamp { } /// - /// Gets or sets the Value of the cookie. + /// Gets or sets the value of the cookie. /// /// - /// A that represents the Value of the cookie. + /// A that represents the value of the cookie. /// - /// - /// The value specified for a set operation is . - /// /// /// The value specified for a set operation is a string not enclosed in /// double quotes that contains an invalid character. From 26f9994cbb7deb1517381cc0a7cbed491e5c75e2 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 6 May 2019 16:17:32 +0900 Subject: [PATCH 2437/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index da31527df..26e5ae6c2 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -664,7 +664,7 @@ internal static bool IsToken (this string value) if (c < 0x20) return false; - if (c >= 0x7f) + if (c > 0x7e) return false; if (_tspecials.IndexOf (c) > -1) From 628142460d2819e2ac826d87931e3ec5a9284b95 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 6 May 2019 16:21:51 +0900 Subject: [PATCH 2438/6294] [Modify] Polish it --- websocket-sharp/Net/CookieCollection.cs | 3 --- 1 file changed, 3 deletions(-) diff --git a/websocket-sharp/Net/CookieCollection.cs b/websocket-sharp/Net/CookieCollection.cs index 8b80732d5..69e24804b 100644 --- a/websocket-sharp/Net/CookieCollection.cs +++ b/websocket-sharp/Net/CookieCollection.cs @@ -537,9 +537,6 @@ private int search (Cookie cookie) private static string urlDecode (string s, Encoding encoding) { - if (s == null) - return null; - if (s.IndexOfAny (new[] { '%', '+' }) == -1) return s; From d5ad901c821581834fcc6954c19277f53279af47 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 7 May 2019 21:21:05 +0900 Subject: [PATCH 2439/6294] [Modify] Polish it --- websocket-sharp/Net/CookieException.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/CookieException.cs b/websocket-sharp/Net/CookieException.cs index 06123aec8..390e60c0f 100644 --- a/websocket-sharp/Net/CookieException.cs +++ b/websocket-sharp/Net/CookieException.cs @@ -106,10 +106,15 @@ public CookieException () /// /// A that specifies the destination for the serialization. /// - [SecurityPermission ( - SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.SerializationFormatter)] + [ + SecurityPermission ( + SecurityAction.LinkDemand, + Flags = SecurityPermissionFlag.SerializationFormatter + ) + ] public override void GetObjectData ( - SerializationInfo serializationInfo, StreamingContext streamingContext) + SerializationInfo serializationInfo, StreamingContext streamingContext + ) { base.GetObjectData (serializationInfo, streamingContext); } From b168700dde13b8cf1dcbc8fa1d2d534d57ddecf9 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 8 May 2019 22:22:59 +0900 Subject: [PATCH 2440/6294] [Modify] Edit it --- websocket-sharp/Net/CookieException.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/CookieException.cs b/websocket-sharp/Net/CookieException.cs index 390e60c0f..54b44b85f 100644 --- a/websocket-sharp/Net/CookieException.cs +++ b/websocket-sharp/Net/CookieException.cs @@ -97,15 +97,19 @@ public CookieException () #region Public Methods /// - /// Populates the specified with the data needed to serialize - /// the current . + /// Populates the specified instance with + /// the data needed to serialize the current instance. /// /// /// A that holds the serialized object data. /// /// - /// A that specifies the destination for the serialization. + /// A that specifies the destination for + /// the serialization. /// + /// + /// is . + /// [ SecurityPermission ( SecurityAction.LinkDemand, From ced45f19c13ca3df5b50ca43476d0f8dd2756bb1 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 8 May 2019 22:26:37 +0900 Subject: [PATCH 2441/6294] [Modify] Polish it --- websocket-sharp/Net/CookieException.cs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Net/CookieException.cs b/websocket-sharp/Net/CookieException.cs index 54b44b85f..be1349ea9 100644 --- a/websocket-sharp/Net/CookieException.cs +++ b/websocket-sharp/Net/CookieException.cs @@ -137,12 +137,16 @@ public override void GetObjectData ( /// /// A that specifies the destination for the serialization. /// - [SecurityPermission ( - SecurityAction.LinkDemand, - Flags = SecurityPermissionFlag.SerializationFormatter, - SerializationFormatter = true)] + [ + SecurityPermission ( + SecurityAction.LinkDemand, + Flags = SecurityPermissionFlag.SerializationFormatter, + SerializationFormatter = true + ) + ] void ISerializable.GetObjectData ( - SerializationInfo serializationInfo, StreamingContext streamingContext) + SerializationInfo serializationInfo, StreamingContext streamingContext + ) { base.GetObjectData (serializationInfo, streamingContext); } From 1eee02bb89790c73e65212055531b16b145a7ef4 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 8 May 2019 22:32:05 +0900 Subject: [PATCH 2442/6294] [Modify] Edit it --- websocket-sharp/Net/CookieException.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/CookieException.cs b/websocket-sharp/Net/CookieException.cs index be1349ea9..c211e278b 100644 --- a/websocket-sharp/Net/CookieException.cs +++ b/websocket-sharp/Net/CookieException.cs @@ -128,15 +128,19 @@ public override void GetObjectData ( #region Explicit Interface Implementation /// - /// Populates the specified with the data needed to serialize - /// the current . + /// Populates the specified instance with + /// the data needed to serialize the current instance. /// /// /// A that holds the serialized object data. /// /// - /// A that specifies the destination for the serialization. + /// A that specifies the destination for + /// the serialization. /// + /// + /// is . + /// [ SecurityPermission ( SecurityAction.LinkDemand, From 80747e81e2d78a1ca4f025e9c6ccb717d28800fb Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 9 May 2019 21:49:36 +0900 Subject: [PATCH 2443/6294] [Modify] Polish it --- websocket-sharp/Net/CookieException.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/CookieException.cs b/websocket-sharp/Net/CookieException.cs index c211e278b..5afa56cad 100644 --- a/websocket-sharp/Net/CookieException.cs +++ b/websocket-sharp/Net/CookieException.cs @@ -75,7 +75,8 @@ internal CookieException (string message, Exception innerException) /// A that specifies the source for the deserialization. /// protected CookieException ( - SerializationInfo serializationInfo, StreamingContext streamingContext) + SerializationInfo serializationInfo, StreamingContext streamingContext + ) : base (serializationInfo, streamingContext) { } From 45b20c0e95af2e35959933d284edc3c230daadc5 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 9 May 2019 22:00:10 +0900 Subject: [PATCH 2444/6294] [Modify] Edit it --- websocket-sharp/Net/CookieException.cs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/CookieException.cs b/websocket-sharp/Net/CookieException.cs index 5afa56cad..59a68f7c3 100644 --- a/websocket-sharp/Net/CookieException.cs +++ b/websocket-sharp/Net/CookieException.cs @@ -65,15 +65,19 @@ internal CookieException (string message, Exception innerException) #region Protected Constructors /// - /// Initializes a new instance of the class from - /// the specified and . + /// Initializes a new instance of the class + /// with the serialized data. /// /// - /// A that contains the serialized object data. + /// A that holds the serialized object data. /// /// - /// A that specifies the source for the deserialization. + /// A that specifies the source for + /// the deserialization. /// + /// + /// is . + /// protected CookieException ( SerializationInfo serializationInfo, StreamingContext streamingContext ) From 66359954aa7dd6261e8336649449ba43884300da Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 10 May 2019 20:59:45 +0900 Subject: [PATCH 2445/6294] [Modify] Polish it --- websocket-sharp/Net/CookieException.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/CookieException.cs b/websocket-sharp/Net/CookieException.cs index 59a68f7c3..ef5a682f7 100644 --- a/websocket-sharp/Net/CookieException.cs +++ b/websocket-sharp/Net/CookieException.cs @@ -46,7 +46,7 @@ namespace WebSocketSharp.Net /// The exception that is thrown when a gets an error. /// [Serializable] - public class CookieException : FormatException, ISerializable + public class CookieException : FormatException { #region Internal Constructors From 2541f8cba81bd2f2f7fcf83085d2192d94abe880 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 10 May 2019 21:02:45 +0900 Subject: [PATCH 2446/6294] [Modify] Edit it --- websocket-sharp/Net/CookieException.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/CookieException.cs b/websocket-sharp/Net/CookieException.cs index ef5a682f7..9111efef3 100644 --- a/websocket-sharp/Net/CookieException.cs +++ b/websocket-sharp/Net/CookieException.cs @@ -2,7 +2,7 @@ /* * CookieException.cs * - * This code is derived from System.Net.CookieException.cs of Mono + * This code is derived from CookieException.cs (System.Net) of Mono * (http://www.mono-project.com). * * The MIT License From 15c99a75a790fbc02674b54f8029c977d446657e Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 11 May 2019 21:46:32 +0900 Subject: [PATCH 2447/6294] [Modify] 2019 --- websocket-sharp/Net/CookieException.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/CookieException.cs b/websocket-sharp/Net/CookieException.cs index 9111efef3..e6a942844 100644 --- a/websocket-sharp/Net/CookieException.cs +++ b/websocket-sharp/Net/CookieException.cs @@ -7,7 +7,7 @@ * * The MIT License * - * Copyright (c) 2012-2014 sta.blockhead + * Copyright (c) 2012-2019 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From b2b158db0245588fd64a3fde76c2fe861eece2dd Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 12 May 2019 21:39:54 +0900 Subject: [PATCH 2448/6294] [Modify] Re-throw it --- websocket-sharp/Net/CookieCollection.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/CookieCollection.cs b/websocket-sharp/Net/CookieCollection.cs index 69e24804b..2b9e23fa8 100644 --- a/websocket-sharp/Net/CookieCollection.cs +++ b/websocket-sharp/Net/CookieCollection.cs @@ -554,9 +554,14 @@ private static string urlDecode (string s, Encoding encoding) internal static CookieCollection Parse (string value, bool response) { - return response - ? parseResponse (value) - : parseRequest (value); + try { + return response + ? parseResponse (value) + : parseRequest (value); + } + catch (Exception ex) { + throw new CookieException ("It could not be parsed.", ex); + } } internal void SetOrRemove (Cookie cookie) From ef78f80f121abc06d566cd03f153289d43809a85 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 13 May 2019 21:03:46 +0900 Subject: [PATCH 2449/6294] [Modify] Polish it --- websocket-sharp/Net/CookieCollection.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/CookieCollection.cs b/websocket-sharp/Net/CookieCollection.cs index 2b9e23fa8..bf7591dec 100644 --- a/websocket-sharp/Net/CookieCollection.cs +++ b/websocket-sharp/Net/CookieCollection.cs @@ -277,7 +277,7 @@ private static CookieCollection parseRequest (string value) if (idx == 0) { if (cookie != null) { - ret.Add (cookie); + ret.add (cookie); cookie = null; } @@ -328,7 +328,7 @@ private static CookieCollection parseRequest (string value) } if (cookie != null) - ret.Add (cookie); + ret.add (cookie); cookie = new Cookie (name, val); @@ -337,7 +337,7 @@ private static CookieCollection parseRequest (string value) } if (cookie != null) - ret.Add (cookie); + ret.add (cookie); return ret; } From e60007d9fe5f80aefbf29975bb4e09a27c993141 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 13 May 2019 21:12:00 +0900 Subject: [PATCH 2450/6294] [Modify] Polish it --- websocket-sharp/Net/CookieCollection.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/CookieCollection.cs b/websocket-sharp/Net/CookieCollection.cs index bf7591dec..e36657ef6 100644 --- a/websocket-sharp/Net/CookieCollection.cs +++ b/websocket-sharp/Net/CookieCollection.cs @@ -386,7 +386,7 @@ private static CookieCollection parseResponse (string value) if (idx == 0) { if (cookie != null) { - ret.Add (cookie); + ret.add (cookie); cookie = null; } @@ -514,13 +514,13 @@ out expires } if (cookie != null) - ret.Add (cookie); + ret.add (cookie); cookie = new Cookie (name, val); } if (cookie != null) - ret.Add (cookie); + ret.add (cookie); return ret; } From b69ce394ff94e4a2be28a97a1d7ae80f383f066e Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 14 May 2019 21:13:30 +0900 Subject: [PATCH 2451/6294] [Modify] Edit it --- websocket-sharp/Net/Cookie.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/websocket-sharp/Net/Cookie.cs b/websocket-sharp/Net/Cookie.cs index 20b714226..3d42627a8 100644 --- a/websocket-sharp/Net/Cookie.cs +++ b/websocket-sharp/Net/Cookie.cs @@ -69,6 +69,11 @@ namespace WebSocketSharp.Net /// RFC 2965 /// /// + /// + /// + /// RFC 6265 + /// + /// /// /// /// This class cannot be inherited. From 95bfb940484e8c636cd8c16dee7be57926b4a8f8 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 15 May 2019 19:43:24 +0900 Subject: [PATCH 2452/6294] [Modify] To internal --- websocket-sharp/Net/Cookie.cs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Net/Cookie.cs b/websocket-sharp/Net/Cookie.cs index 3d42627a8..ca8fb00a7 100644 --- a/websocket-sharp/Net/Cookie.cs +++ b/websocket-sharp/Net/Cookie.cs @@ -715,7 +715,7 @@ public string Value { } /// - /// Gets or sets the value of the Version attribute of the cookie. + /// Gets the value of the Version attribute of the cookie. /// /// /// @@ -723,21 +723,18 @@ public string Value { /// management that the cookie conforms to. /// /// - /// 0 or 1. + /// 0 or 1. 0 if the cookie has no Version attribute. /// /// /// The default value is 0. /// /// - /// - /// The value specified for a set operation is not allowed. - /// public int Version { get { return _version; } - set { + internal set { if (value < 0 || value > 1) { var msg = "It is not allowed."; throw new ArgumentOutOfRangeException ("value", msg); From 0615ae75d738b0f29f76afabbfd9b17aef099ece Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 16 May 2019 21:30:34 +0900 Subject: [PATCH 2453/6294] [Modify] To internal --- websocket-sharp/Net/Cookie.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/Cookie.cs b/websocket-sharp/Net/Cookie.cs index ca8fb00a7..5795ddc74 100644 --- a/websocket-sharp/Net/Cookie.cs +++ b/websocket-sharp/Net/Cookie.cs @@ -349,7 +349,7 @@ internal int[] Ports { #region Public Properties /// - /// Gets or sets the value of the Comment attribute of the cookie. + /// Gets the value of the Comment attribute of the cookie. /// /// /// @@ -357,7 +357,7 @@ internal int[] Ports { /// intended use of the cookie. /// /// - /// An empty string if this attribute is not needed. + /// An empty string if the cookie has no Comment attribute. /// /// /// The default value is an empty string. @@ -368,7 +368,7 @@ public string Comment { return _comment ?? String.Empty; } - set { + internal set { _comment = value; } } From 269bc27b429f69020757effbceb250e691cde254 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 17 May 2019 20:56:20 +0900 Subject: [PATCH 2454/6294] [Modify] To internal --- websocket-sharp/Net/Cookie.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/Cookie.cs b/websocket-sharp/Net/Cookie.cs index 5795ddc74..0f8fa04ed 100644 --- a/websocket-sharp/Net/Cookie.cs +++ b/websocket-sharp/Net/Cookie.cs @@ -374,7 +374,7 @@ internal set { } /// - /// Gets or sets the value of the CommentURL attribute of the cookie. + /// Gets the value of the CommentURL attribute of the cookie. /// /// /// @@ -382,7 +382,7 @@ internal set { /// the comment to document intended use of the cookie. /// /// - /// if this attribute is not needed. + /// if the cookie has no CommentURL attribute. /// /// /// The default value is . @@ -393,7 +393,7 @@ public Uri CommentUri { return _commentUri; } - set { + internal set { _commentUri = value; } } From 0be811a795693c80417e117b80d0c0915f1cdc53 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 18 May 2019 17:39:28 +0900 Subject: [PATCH 2455/6294] [Modify] To internal --- websocket-sharp/Net/Cookie.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/Cookie.cs b/websocket-sharp/Net/Cookie.cs index 0f8fa04ed..8fe6df604 100644 --- a/websocket-sharp/Net/Cookie.cs +++ b/websocket-sharp/Net/Cookie.cs @@ -399,7 +399,7 @@ internal set { } /// - /// Gets or sets a value indicating whether the client discards the cookie + /// Gets a value indicating whether the client discards the cookie /// unconditionally when the client terminates. /// /// @@ -416,7 +416,7 @@ public bool Discard { return _discard; } - set { + internal set { _discard = value; } } From ccbaf3bcd0c196a8bf4b3017685661c705034622 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 18 May 2019 17:44:28 +0900 Subject: [PATCH 2456/6294] [Modify] Edit it --- websocket-sharp/Net/Cookie.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/Cookie.cs b/websocket-sharp/Net/Cookie.cs index 8fe6df604..245ec1c09 100644 --- a/websocket-sharp/Net/Cookie.cs +++ b/websocket-sharp/Net/Cookie.cs @@ -382,7 +382,7 @@ internal set { /// the comment to document intended use of the cookie. /// /// - /// if the cookie has no CommentURL attribute. + /// if not present. /// /// /// The default value is . From c7ad1404b4af2ac237000633038b7d0fa06c2e7f Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 19 May 2019 21:00:51 +0900 Subject: [PATCH 2457/6294] [Modify] Edit it --- websocket-sharp/Net/Cookie.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/Cookie.cs b/websocket-sharp/Net/Cookie.cs index 245ec1c09..db8112fd8 100644 --- a/websocket-sharp/Net/Cookie.cs +++ b/websocket-sharp/Net/Cookie.cs @@ -357,7 +357,7 @@ internal int[] Ports { /// intended use of the cookie. /// /// - /// An empty string if the cookie has no Comment attribute. + /// An empty string if not present. /// /// /// The default value is an empty string. From 9c952e3d4d57408a0beef3e92a563162a301449e Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 19 May 2019 21:05:00 +0900 Subject: [PATCH 2458/6294] [Modify] The default value is null --- websocket-sharp/Net/Cookie.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/Cookie.cs b/websocket-sharp/Net/Cookie.cs index db8112fd8..dda5adeb4 100644 --- a/websocket-sharp/Net/Cookie.cs +++ b/websocket-sharp/Net/Cookie.cs @@ -357,15 +357,15 @@ internal int[] Ports { /// intended use of the cookie. /// /// - /// An empty string if not present. + /// if not present. /// /// - /// The default value is an empty string. + /// The default value is . /// /// public string Comment { get { - return _comment ?? String.Empty; + return _comment; } internal set { From 4b39467cea365a324e096b26b46dbb0a0d05582e Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 20 May 2019 20:39:56 +0900 Subject: [PATCH 2459/6294] [Modify] To internal --- websocket-sharp/Net/Cookie.cs | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/websocket-sharp/Net/Cookie.cs b/websocket-sharp/Net/Cookie.cs index dda5adeb4..bdd4f871c 100644 --- a/websocket-sharp/Net/Cookie.cs +++ b/websocket-sharp/Net/Cookie.cs @@ -589,7 +589,7 @@ public string Path { } /// - /// Gets or sets the value of the Port attribute of the cookie. + /// Gets the value of the Port attribute of the cookie. /// /// /// @@ -597,30 +597,18 @@ public string Path { /// that the cookie applies to. /// /// - /// An empty string if this attribute is not needed. + /// An empty string if not present. /// /// /// The default value is an empty string. /// /// - /// - /// - /// The value specified for a set operation is not enclosed in - /// double quotes. - /// - /// - /// -or- - /// - /// - /// The value specified for a set operation could not be parsed. - /// - /// public string Port { get { return _port ?? String.Empty; } - set { + internal set { if (value.IsNullOrEmpty ()) { _port = value; _ports = null; From ffd331db749c01af95ca40d30d1c780cc6cbe318 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 21 May 2019 21:18:40 +0900 Subject: [PATCH 2460/6294] [Modify] The default value is null --- websocket-sharp/Net/Cookie.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/Cookie.cs b/websocket-sharp/Net/Cookie.cs index bdd4f871c..e4a5ceef9 100644 --- a/websocket-sharp/Net/Cookie.cs +++ b/websocket-sharp/Net/Cookie.cs @@ -597,15 +597,15 @@ public string Path { /// that the cookie applies to. /// /// - /// An empty string if not present. + /// if not present. /// /// - /// The default value is an empty string. + /// The default value is . /// /// public string Port { get { - return _port ?? String.Empty; + return _port; } internal set { From 577e510c90062180d70c5f94ce0f6204d7415dd3 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 21 May 2019 21:22:27 +0900 Subject: [PATCH 2461/6294] [Modify] Polish it --- websocket-sharp/Net/Cookie.cs | 7 ------- 1 file changed, 7 deletions(-) diff --git a/websocket-sharp/Net/Cookie.cs b/websocket-sharp/Net/Cookie.cs index e4a5ceef9..7fd32c04e 100644 --- a/websocket-sharp/Net/Cookie.cs +++ b/websocket-sharp/Net/Cookie.cs @@ -609,13 +609,6 @@ public string Port { } internal set { - if (value.IsNullOrEmpty ()) { - _port = value; - _ports = null; - - return; - } - if (!value.IsEnclosedIn ('"')) { var msg = "It is not enclosed in double quotes."; throw new ArgumentException (msg, "value"); From a27ee45cedddad68ea6079a77fa341c7ae00002b Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 22 May 2019 21:39:13 +0900 Subject: [PATCH 2462/6294] [Modify] Edit it --- websocket-sharp/Net/Cookie.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/Cookie.cs b/websocket-sharp/Net/Cookie.cs index 7fd32c04e..f725a0c94 100644 --- a/websocket-sharp/Net/Cookie.cs +++ b/websocket-sharp/Net/Cookie.cs @@ -704,7 +704,7 @@ public string Value { /// management that the cookie conforms to. /// /// - /// 0 or 1. 0 if the cookie has no Version attribute. + /// 0 or 1. 0 if not present. /// /// /// The default value is 0. From d7cb1d71042b9e612ce95b1b525a99c293acc6d9 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 22 May 2019 21:44:26 +0900 Subject: [PATCH 2463/6294] [Modify] Polish it --- websocket-sharp/Net/Cookie.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/Cookie.cs b/websocket-sharp/Net/Cookie.cs index f725a0c94..31d641378 100644 --- a/websocket-sharp/Net/Cookie.cs +++ b/websocket-sharp/Net/Cookie.cs @@ -802,7 +802,7 @@ private string toResponseStringVersion1 () buff.Append ("; Port"); } - if (!_comment.IsNullOrEmpty ()) + if (_comment != null) buff.AppendFormat ("; Comment={0}", HttpUtility.UrlEncode (_comment)); if (_commentUri != null) { From 465e89130d9ee288abb6e8f4cf161014bbeed995 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 23 May 2019 19:50:27 +0900 Subject: [PATCH 2464/6294] [Modify] Polish it --- websocket-sharp/Net/Cookie.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/Cookie.cs b/websocket-sharp/Net/Cookie.cs index 31d641378..bf5a79c1c 100644 --- a/websocket-sharp/Net/Cookie.cs +++ b/websocket-sharp/Net/Cookie.cs @@ -795,7 +795,7 @@ private string toResponseStringVersion1 () if (!_domain.IsNullOrEmpty ()) buff.AppendFormat ("; Domain={0}", _domain); - if (!_port.IsNullOrEmpty ()) { + if (_port != null) { if (_port != "\"\"") buff.AppendFormat ("; Port={0}", _port); else From d24dc162dbe6ac41a3fd4004cc5f324e8e449ef4 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 23 May 2019 19:52:48 +0900 Subject: [PATCH 2465/6294] [Modify] Polish it --- websocket-sharp/Net/Cookie.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/Cookie.cs b/websocket-sharp/Net/Cookie.cs index bf5a79c1c..ab38cb46d 100644 --- a/websocket-sharp/Net/Cookie.cs +++ b/websocket-sharp/Net/Cookie.cs @@ -883,7 +883,7 @@ internal string ToRequestString (Uri uri) buff.AppendFormat ("; $Domain={0}", _domain); } - if (!_port.IsNullOrEmpty ()) { + if (_port != null) { if (_port != "\"\"") buff.AppendFormat ("; $Port={0}", _port); else From 157cb4a3bce0e77b89b7b16082c7263a4fc36cc0 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 24 May 2019 19:44:13 +0900 Subject: [PATCH 2466/6294] [Modify] Move it --- websocket-sharp/Net/Cookie.cs | 4 ++++ websocket-sharp/Net/CookieCollection.cs | 5 +---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/Cookie.cs b/websocket-sharp/Net/Cookie.cs index ab38cb46d..aaaf9dc85 100644 --- a/websocket-sharp/Net/Cookie.cs +++ b/websocket-sharp/Net/Cookie.cs @@ -336,6 +336,10 @@ internal int MaxAge { ? (int) span.TotalSeconds : 0; } + + set { + _expires = DateTime.Now.AddSeconds ((double) value); + } } internal int[] Ports { diff --git a/websocket-sharp/Net/CookieCollection.cs b/websocket-sharp/Net/CookieCollection.cs index e36657ef6..4c8c54803 100644 --- a/websocket-sharp/Net/CookieCollection.cs +++ b/websocket-sharp/Net/CookieCollection.cs @@ -451,10 +451,7 @@ out expires if (val.Length == 0) continue; - var max = Int32.Parse (val.Unquote ()); - var expires = DateTime.Now.AddSeconds ((double) max); - cookie.Expires = expires; - + cookie.MaxAge = Int32.Parse (val.Unquote ()); continue; } From 7e7ae7b0a4ed129b78e145f070be314826ad61d0 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 25 May 2019 20:28:15 +0900 Subject: [PATCH 2467/6294] [Modify] Do not throw --- websocket-sharp/Net/Cookie.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/Cookie.cs b/websocket-sharp/Net/Cookie.cs index aaaf9dc85..57d119965 100644 --- a/websocket-sharp/Net/Cookie.cs +++ b/websocket-sharp/Net/Cookie.cs @@ -720,10 +720,8 @@ public int Version { } internal set { - if (value < 0 || value > 1) { - var msg = "It is not allowed."; - throw new ArgumentOutOfRangeException ("value", msg); - } + if (value < 0 || value > 1) + return; _version = value; } From 74b79c1a39931ed8aaec2ed6bb0edc1f8df9c42e Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 26 May 2019 21:50:54 +0900 Subject: [PATCH 2468/6294] [Modify] Use the try method --- websocket-sharp/Net/CookieCollection.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/CookieCollection.cs b/websocket-sharp/Net/CookieCollection.cs index 4c8c54803..7ba652b4b 100644 --- a/websocket-sharp/Net/CookieCollection.cs +++ b/websocket-sharp/Net/CookieCollection.cs @@ -405,7 +405,11 @@ private static CookieCollection parseResponse (string value) if (val.Length == 0) continue; - cookie.Version = Int32.Parse (val.Unquote ()); + int num; + if (!Int32.TryParse (val.Unquote (), out num)) + continue; + + cookie.Version = num; continue; } From 9209f4c4163ce7db6c35cfa7ee190941ce45d721 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 27 May 2019 21:58:48 +0900 Subject: [PATCH 2469/6294] [Modify] Use the try method --- websocket-sharp/Net/CookieCollection.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/CookieCollection.cs b/websocket-sharp/Net/CookieCollection.cs index 7ba652b4b..8ebfb48c4 100644 --- a/websocket-sharp/Net/CookieCollection.cs +++ b/websocket-sharp/Net/CookieCollection.cs @@ -290,7 +290,14 @@ private static CookieCollection parseRequest (string value) : String.Empty; if (name.Equals ("$version", caseInsensitive)) { - ver = val.Length > 0 ? Int32.Parse (val.Unquote ()) : 0; + if (val.Length == 0) + continue; + + int num; + if (!Int32.TryParse (val.Unquote (), out num)) + continue; + + ver = num; continue; } From c0d777449c498972092396e688fa4f0734951b6a Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 28 May 2019 20:28:44 +0900 Subject: [PATCH 2470/6294] [Modify] Do not throw --- websocket-sharp/Net/Cookie.cs | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/websocket-sharp/Net/Cookie.cs b/websocket-sharp/Net/Cookie.cs index 57d119965..7e0975dfe 100644 --- a/websocket-sharp/Net/Cookie.cs +++ b/websocket-sharp/Net/Cookie.cs @@ -613,16 +613,12 @@ public string Port { } internal set { - if (!value.IsEnclosedIn ('"')) { - var msg = "It is not enclosed in double quotes."; - throw new ArgumentException (msg, "value"); - } + if (!value.IsEnclosedIn ('"')) + return; int[] ports; - if (!tryCreatePorts (value, out ports)) { - var msg = "It could not be parsed."; - throw new ArgumentException (msg, "value"); - } + if (!tryCreatePorts (value, out ports)) + return; _port = value; _ports = ports; From d3946e51e44d873219ea0221afdfee7484784324 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 29 May 2019 20:44:06 +0900 Subject: [PATCH 2471/6294] [Modify] Polish it --- websocket-sharp/Net/Cookie.cs | 3 --- 1 file changed, 3 deletions(-) diff --git a/websocket-sharp/Net/Cookie.cs b/websocket-sharp/Net/Cookie.cs index 7e0975dfe..29ed1263e 100644 --- a/websocket-sharp/Net/Cookie.cs +++ b/websocket-sharp/Net/Cookie.cs @@ -613,9 +613,6 @@ public string Port { } internal set { - if (!value.IsEnclosedIn ('"')) - return; - int[] ports; if (!tryCreatePorts (value, out ports)) return; From 77bf91cfbe118944584b3010dc63216e8eb48227 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 30 May 2019 19:58:31 +0900 Subject: [PATCH 2472/6294] [Modify] Use the try method --- websocket-sharp/Net/CookieCollection.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/CookieCollection.cs b/websocket-sharp/Net/CookieCollection.cs index 8ebfb48c4..6a9499d8f 100644 --- a/websocket-sharp/Net/CookieCollection.cs +++ b/websocket-sharp/Net/CookieCollection.cs @@ -462,7 +462,11 @@ out expires if (val.Length == 0) continue; - cookie.MaxAge = Int32.Parse (val.Unquote ()); + int num; + if (!Int32.TryParse (val.Unquote (), out num)) + continue; + + cookie.MaxAge = num; continue; } From ef12ceed5c19fb6beae815c42e161839a5e47fc9 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 31 May 2019 21:15:51 +0900 Subject: [PATCH 2473/6294] [Modify] It is expired if equal or less than 0 --- websocket-sharp/Net/Cookie.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/Cookie.cs b/websocket-sharp/Net/Cookie.cs index 29ed1263e..773d5c9e1 100644 --- a/websocket-sharp/Net/Cookie.cs +++ b/websocket-sharp/Net/Cookie.cs @@ -338,7 +338,9 @@ internal int MaxAge { } set { - _expires = DateTime.Now.AddSeconds ((double) value); + _expires = value > 0 + ? DateTime.Now.AddSeconds ((double) value) + : DateTime.Now; } } From 62fba4875b751e4680437bcc2035308e5aee6334 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 1 Jun 2019 21:19:23 +0900 Subject: [PATCH 2474/6294] [Modify] Ignore it --- websocket-sharp/Net/CookieCollection.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/CookieCollection.cs b/websocket-sharp/Net/CookieCollection.cs index 6a9499d8f..c0eb82488 100644 --- a/websocket-sharp/Net/CookieCollection.cs +++ b/websocket-sharp/Net/CookieCollection.cs @@ -449,7 +449,7 @@ private static CookieCollection parseResponse (string value) out expires ) ) - expires = DateTime.Now; + continue; cookie.Expires = expires.ToLocalTime (); continue; From a04bc16cdeb099b92efe937fad2abbde210626df Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 2 Jun 2019 22:37:27 +0900 Subject: [PATCH 2475/6294] [Modify] Add it --- websocket-sharp/Net/Cookie.cs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/websocket-sharp/Net/Cookie.cs b/websocket-sharp/Net/Cookie.cs index 773d5c9e1..1be80b479 100644 --- a/websocket-sharp/Net/Cookie.cs +++ b/websocket-sharp/Net/Cookie.cs @@ -906,6 +906,22 @@ internal string ToResponseString () : toResponseStringVersion1 (); } + internal static bool TryCreateCookie ( + string name, string value, out Cookie result + ) + { + result = null; + + try { + result = new Cookie (name, value); + } + catch { + return false; + } + + return true; + } + #endregion #region Public Methods From e07a4bcfff42248a7f41ceda09d50c2eacda78dc Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 3 Jun 2019 21:00:51 +0900 Subject: [PATCH 2476/6294] [Modify] Replace it --- websocket-sharp/Net/CookieCollection.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/CookieCollection.cs b/websocket-sharp/Net/CookieCollection.cs index c0eb82488..a48a07d9c 100644 --- a/websocket-sharp/Net/CookieCollection.cs +++ b/websocket-sharp/Net/CookieCollection.cs @@ -337,7 +337,8 @@ private static CookieCollection parseRequest (string value) if (cookie != null) ret.add (cookie); - cookie = new Cookie (name, val); + if (!Cookie.TryCreateCookie (name, val, out cookie)) + continue; if (ver != 0) cookie.Version = ver; From 541dedf7aee00591e237b89ed9df0f2953751436 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 4 Jun 2019 19:37:04 +0900 Subject: [PATCH 2477/6294] [Modify] Replace it --- websocket-sharp/Net/CookieCollection.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/CookieCollection.cs b/websocket-sharp/Net/CookieCollection.cs index a48a07d9c..93da73e5c 100644 --- a/websocket-sharp/Net/CookieCollection.cs +++ b/websocket-sharp/Net/CookieCollection.cs @@ -529,7 +529,7 @@ out expires if (cookie != null) ret.add (cookie); - cookie = new Cookie (name, val); + Cookie.TryCreateCookie (name, val, out cookie); } if (cookie != null) From cd5a602c8f2f621881dae5e141da3742c389b13e Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 5 Jun 2019 20:12:03 +0900 Subject: [PATCH 2478/6294] [Modify] Rename it --- websocket-sharp/Net/Cookie.cs | 2 +- websocket-sharp/Net/CookieCollection.cs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/Cookie.cs b/websocket-sharp/Net/Cookie.cs index 1be80b479..5fd622fe9 100644 --- a/websocket-sharp/Net/Cookie.cs +++ b/websocket-sharp/Net/Cookie.cs @@ -906,7 +906,7 @@ internal string ToResponseString () : toResponseStringVersion1 (); } - internal static bool TryCreateCookie ( + internal static bool TryCreate ( string name, string value, out Cookie result ) { diff --git a/websocket-sharp/Net/CookieCollection.cs b/websocket-sharp/Net/CookieCollection.cs index 93da73e5c..e59396426 100644 --- a/websocket-sharp/Net/CookieCollection.cs +++ b/websocket-sharp/Net/CookieCollection.cs @@ -337,7 +337,7 @@ private static CookieCollection parseRequest (string value) if (cookie != null) ret.add (cookie); - if (!Cookie.TryCreateCookie (name, val, out cookie)) + if (!Cookie.TryCreate (name, val, out cookie)) continue; if (ver != 0) @@ -529,7 +529,7 @@ out expires if (cookie != null) ret.add (cookie); - Cookie.TryCreateCookie (name, val, out cookie); + Cookie.TryCreate (name, val, out cookie); } if (cookie != null) From b27b8ee742676c9cb557ae8fb6e0d832b04d0979 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 6 Jun 2019 21:05:58 +0900 Subject: [PATCH 2479/6294] [Modify] For the SameSite attribute --- websocket-sharp/Net/Cookie.cs | 14 ++++++++++++++ websocket-sharp/Net/CookieCollection.cs | 11 +++++++++++ 2 files changed, 25 insertions(+) diff --git a/websocket-sharp/Net/Cookie.cs b/websocket-sharp/Net/Cookie.cs index 5fd622fe9..785300c3e 100644 --- a/websocket-sharp/Net/Cookie.cs +++ b/websocket-sharp/Net/Cookie.cs @@ -96,6 +96,7 @@ public sealed class Cookie private string _port; private int[] _ports; private static readonly char[] _reservedCharsForValue; + private string _sameSite; private bool _secure; private DateTime _timeStamp; private string _value; @@ -350,6 +351,16 @@ internal int[] Ports { } } + internal string SameSite { + get { + return _sameSite; + } + + set { + _sameSite = value; + } + } + #endregion #region Public Properties @@ -768,6 +779,9 @@ private string toResponseStringVersion0 () if (!_domain.IsNullOrEmpty ()) buff.AppendFormat ("; Domain={0}", _domain); + if (!_sameSite.IsNullOrEmpty ()) + buff.AppendFormat ("; SameSite={0}", _sameSite); + if (_secure) buff.Append ("; Secure"); diff --git a/websocket-sharp/Net/CookieCollection.cs b/websocket-sharp/Net/CookieCollection.cs index e59396426..8c0322bda 100644 --- a/websocket-sharp/Net/CookieCollection.cs +++ b/websocket-sharp/Net/CookieCollection.cs @@ -526,6 +526,17 @@ out expires continue; } + if (name.Equals ("samesite", caseInsensitive)) { + if (cookie == null) + continue; + + if (val.Length == 0) + continue; + + cookie.SameSite = val.Unquote (); + continue; + } + if (cookie != null) ret.add (cookie); From cfeeb9c9baa0249893d372580feb6103d792bf12 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 7 Jun 2019 19:47:37 +0900 Subject: [PATCH 2480/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 26e5ae6c2..ef6d7bd69 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1402,10 +1402,14 @@ public static bool IsCloseStatusCode (this ushort value) /// public static bool IsEnclosedIn (this string value, char c) { - return value != null - && value.Length > 1 - && value[0] == c - && value[value.Length - 1] == c; + if (value == null) + return false; + + var len = value.Length; + if (len < 2) + return false; + + return value[0] == c && value[len - 1] == c; } /// From 26dadfa1337c66ad0458f32143809a1308d5af46 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 8 Jun 2019 21:43:16 +0900 Subject: [PATCH 2481/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index ef6d7bd69..a8767674b 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1544,7 +1544,10 @@ public static bool IsPredefinedScheme (this string value) /// public static bool MaybeUri (this string value) { - if (value == null || value.Length == 0) + if (value == null) + return false; + + if (value.Length == 0) return false; var idx = value.IndexOf (':'); From ef2dec992c9f9aac189b176c1c61abc8624b28be Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 9 Jun 2019 22:34:21 +0900 Subject: [PATCH 2482/6294] [Modify] Throw exception --- websocket-sharp/Ext.cs | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index a8767674b..72b885990 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1584,15 +1584,25 @@ public static bool MaybeUri (this string value) /// public static T[] SubArray (this T[] array, int startIndex, int length) { - int len; - if (array == null || (len = array.Length) == 0) - return new T[0]; + if (array == null) + throw new ArgumentNullException ("array"); - if (startIndex < 0 || length <= 0 || startIndex + length > len) - return new T[0]; + var len = array.Length; + if (len == 0) { + if (startIndex != 0) + throw new ArgumentOutOfRangeException ("startIndex"); + + if (length != 0) + throw new ArgumentOutOfRangeException ("length"); - if (startIndex == 0 && length == len) return array; + } + + if (startIndex < 0 || startIndex > len - 1) + throw new ArgumentOutOfRangeException ("startIndex"); + + if (length < 0 || length > len - startIndex) + throw new ArgumentOutOfRangeException ("length"); var subArray = new T[length]; Array.Copy (array, startIndex, subArray, 0, length); From 1839fd2b271f816d6c29a6b5cfa53f16ddef7533 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 10 Jun 2019 22:23:47 +0900 Subject: [PATCH 2483/6294] [Modify] Edit it --- websocket-sharp/Ext.cs | 34 +++++++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 72b885990..cb66a7354 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1562,26 +1562,46 @@ public static bool MaybeUri (this string value) } /// - /// Retrieves a sub-array from the specified . A sub-array starts at - /// the specified element position in . + /// Retrieves a sub-array from the specified array. A sub-array starts at + /// the specified index in the array. /// /// - /// An array of T that receives a sub-array, or an empty array of T if any problems with - /// the parameters. + /// An array of T that receives a sub-array. /// /// /// An array of T from which to retrieve a sub-array. /// /// - /// An that represents the zero-based starting position of - /// a sub-array in . + /// An that represents the zero-based index in the array + /// at which retrieving starts. /// /// /// An that represents the number of elements to retrieve. /// /// - /// The type of elements in . + /// The type of elements in the array. /// + /// + /// is . + /// + /// + /// + /// is out of range for the array. + /// + /// + /// -or- + /// + /// + /// is less than zero. + /// + /// + /// -or- + /// + /// + /// is greater than the number of elements from + /// to the end of the array. + /// + /// public static T[] SubArray (this T[] array, int startIndex, int length) { if (array == null) From 6d29f8fa4ca93262ed16ead0e9eb93e302986dac Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 11 Jun 2019 21:34:23 +0900 Subject: [PATCH 2484/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index cb66a7354..9c25ffe25 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1618,7 +1618,7 @@ public static T[] SubArray (this T[] array, int startIndex, int length) return array; } - if (startIndex < 0 || startIndex > len - 1) + if (startIndex < 0 || startIndex >= len) throw new ArgumentOutOfRangeException ("startIndex"); if (length < 0 || length > len - startIndex) From f7f23f92126994cfd6a9446c5de57e773827e46b Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 12 Jun 2019 20:02:46 +0900 Subject: [PATCH 2485/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 9c25ffe25..abff330bd 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1624,6 +1624,12 @@ public static T[] SubArray (this T[] array, int startIndex, int length) if (length < 0 || length > len - startIndex) throw new ArgumentOutOfRangeException ("length"); + if (length == 0) + return new T[0]; + + if (length == len) + return array; + var subArray = new T[length]; Array.Copy (array, startIndex, subArray, 0, length); From 7ca9165fae5567ba57624aca9822811a22553918 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 13 Jun 2019 19:26:51 +0900 Subject: [PATCH 2486/6294] [Modify] Edit it --- websocket-sharp/Ext.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index abff330bd..b2091a9b3 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1586,7 +1586,13 @@ public static bool MaybeUri (this string value) /// /// /// - /// is out of range for the array. + /// is less than zero. + /// + /// + /// -or- + /// + /// + /// is greater than the end of the array. /// /// /// -or- From 2c15560779ec76ec7fe47d61468168c77cbd35ee Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 14 Jun 2019 19:33:42 +0900 Subject: [PATCH 2487/6294] [Modify] Throw exception --- websocket-sharp/Ext.cs | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index b2091a9b3..d6b8a79cd 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1665,14 +1665,30 @@ public static T[] SubArray (this T[] array, int startIndex, int length) /// public static T[] SubArray (this T[] array, long startIndex, long length) { - long len; - if (array == null || (len = array.LongLength) == 0) - return new T[0]; + if (array == null) + throw new ArgumentNullException ("array"); - if (startIndex < 0 || length <= 0 || startIndex + length > len) + var len = array.LongLength; + if (len == 0) { + if (startIndex != 0) + throw new ArgumentOutOfRangeException ("startIndex"); + + if (length != 0) + throw new ArgumentOutOfRangeException ("length"); + + return array; + } + + if (startIndex < 0 || startIndex >= len) + throw new ArgumentOutOfRangeException ("startIndex"); + + if (length < 0 || length > len - startIndex) + throw new ArgumentOutOfRangeException ("length"); + + if (length == 0) return new T[0]; - if (startIndex == 0 && length == len) + if (length == len) return array; var subArray = new T[length]; From 591033f3900e8bff343f683c169ecce6bc16ee15 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 15 Jun 2019 20:45:37 +0900 Subject: [PATCH 2488/6294] [Modify] Edit it --- websocket-sharp/Ext.cs | 40 +++++++++++++++++++++++++++++++++------- 1 file changed, 33 insertions(+), 7 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index d6b8a79cd..72ec7e2ee 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1643,26 +1643,52 @@ public static T[] SubArray (this T[] array, int startIndex, int length) } /// - /// Retrieves a sub-array from the specified . A sub-array starts at - /// the specified element position in . + /// Retrieves a sub-array from the specified array. A sub-array starts at + /// the specified index in the array. /// /// - /// An array of T that receives a sub-array, or an empty array of T if any problems with - /// the parameters. + /// An array of T that receives a sub-array. /// /// /// An array of T from which to retrieve a sub-array. /// /// - /// A that represents the zero-based starting position of - /// a sub-array in . + /// A that represents the zero-based index in the array + /// at which retrieving starts. /// /// /// A that represents the number of elements to retrieve. /// /// - /// The type of elements in . + /// The type of elements in the array. /// + /// + /// is . + /// + /// + /// + /// is less than zero. + /// + /// + /// -or- + /// + /// + /// is greater than the end of the array. + /// + /// + /// -or- + /// + /// + /// is less than zero. + /// + /// + /// -or- + /// + /// + /// is greater than the number of elements from + /// to the end of the array. + /// + /// public static T[] SubArray (this T[] array, long startIndex, long length) { if (array == null) From fb1692d7ae1131fb49142fe7f16ce557b873f8d5 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 16 Jun 2019 17:52:28 +0900 Subject: [PATCH 2489/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 72ec7e2ee..7e90f02a2 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -737,7 +737,10 @@ internal static byte[] ReadBytes (this Stream stream, long length, int bufferLen } internal static void ReadBytesAsync ( - this Stream stream, int length, Action completed, Action error + this Stream stream, + int length, + Action completed, + Action error ) { var buff = new byte[length]; From e91b12161aeb4066e117cfe9a1c52e6b0e25accf Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 17 Jun 2019 20:10:30 +0900 Subject: [PATCH 2490/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 7e90f02a2..07bc05796 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -752,16 +752,23 @@ Action error ar => { try { var nread = stream.EndRead (ar); - if (nread == 0 && retry < _retry) { - retry++; - stream.BeginRead (buff, offset, length, callback, null); + if (nread == 0) { + if (retry < _retry) { + retry++; + stream.BeginRead (buff, offset, length, callback, null); + + return; + } + + if (completed != null) + completed (buff.SubArray (0, offset)); return; } - if (nread == 0 || nread == length) { + if (nread == length) { if (completed != null) - completed (buff.SubArray (0, offset + nread)); + completed (buff); return; } From 66be92d490082b387e19522bf0f3440d5368b360 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 18 Jun 2019 19:41:39 +0900 Subject: [PATCH 2491/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 07bc05796..59509d6a9 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -693,21 +693,17 @@ internal static byte[] ReadBytes (this Stream stream, int length) { var buff = new byte[length]; var offset = 0; - try { - var nread = 0; - while (length > 0) { - nread = stream.Read (buff, offset, length); - if (nread == 0) - break; + var nread = 0; + while (length > 0) { + nread = stream.Read (buff, offset, length); + if (nread == 0) + return buff.SubArray (0, offset); - offset += nread; - length -= nread; - } - } - catch { + offset += nread; + length -= nread; } - return buff.SubArray (0, offset); + return buff; } internal static byte[] ReadBytes (this Stream stream, long length, int bufferLength) From af6e4e534e5aaf9f7e58559733d6b8b79c6ad62a Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 19 Jun 2019 19:35:50 +0900 Subject: [PATCH 2492/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 59509d6a9..6645dad72 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -706,25 +706,23 @@ internal static byte[] ReadBytes (this Stream stream, int length) return buff; } - internal static byte[] ReadBytes (this Stream stream, long length, int bufferLength) + internal static byte[] ReadBytes ( + this Stream stream, long length, int bufferLength + ) { using (var dest = new MemoryStream ()) { - try { - var buff = new byte[bufferLength]; - var nread = 0; - while (length > 0) { - if (length < bufferLength) - bufferLength = (int) length; - - nread = stream.Read (buff, 0, bufferLength); - if (nread == 0) - break; + var buff = new byte[bufferLength]; + var nread = 0; + while (length > 0) { + if (length < bufferLength) + bufferLength = (int) length; + + nread = stream.Read (buff, 0, bufferLength); + if (nread == 0) + break; - dest.Write (buff, 0, nread); - length -= nread; - } - } - catch { + dest.Write (buff, 0, nread); + length -= nread; } dest.Close (); From b802869b0c5c4266cb733bedea60875ce1558e0d Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 20 Jun 2019 20:31:41 +0900 Subject: [PATCH 2493/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 6645dad72..3b549de85 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -712,14 +712,24 @@ internal static byte[] ReadBytes ( { using (var dest = new MemoryStream ()) { var buff = new byte[bufferLength]; + var retry = 0; var nread = 0; + while (length > 0) { if (length < bufferLength) bufferLength = (int) length; nread = stream.Read (buff, 0, bufferLength); - if (nread == 0) + if (nread <= 0) { + if (retry < _retry) { + retry++; + continue; + } + break; + } + + retry = 0; dest.Write (buff, 0, nread); length -= nread; From 976f44a2d13f034d530cc52ac0d4a5fd011e49a0 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 21 Jun 2019 21:40:11 +0900 Subject: [PATCH 2494/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 3b549de85..74f0a79b3 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -693,11 +693,21 @@ internal static byte[] ReadBytes (this Stream stream, int length) { var buff = new byte[length]; var offset = 0; + var retry = 0; var nread = 0; + while (length > 0) { nread = stream.Read (buff, offset, length); - if (nread == 0) + if (nread <= 0) { + if (retry < _retry) { + retry++; + continue; + } + return buff.SubArray (0, offset); + } + + retry = 0; offset += nread; length -= nread; From 7bc9039350e0ce97166c49e672dd46f62d9ed971 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 22 Jun 2019 21:33:21 +0900 Subject: [PATCH 2495/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 74f0a79b3..73a2cba33 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -766,7 +766,7 @@ Action error ar => { try { var nread = stream.EndRead (ar); - if (nread == 0) { + if (nread <= 0) { if (retry < _retry) { retry++; stream.BeginRead (buff, offset, length, callback, null); From 345e7decb10c3295f587a197f54ffaace87420f3 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 23 Jun 2019 20:59:27 +0900 Subject: [PATCH 2496/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 73a2cba33..f311db51c 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -834,17 +834,26 @@ Action error ar => { try { var nread = stream.EndRead (ar); - if (nread > 0) - dest.Write (buff, 0, nread); + if (nread <= 0) { + if (retry < _retry) { + retry++; + read (len); - if (nread == 0 && retry < _retry) { - retry++; - read (len); + return; + } + if (completed != null) { + dest.Close (); + completed (dest.ToArray ()); + } + + dest.Dispose (); return; } - if (nread == 0 || nread == len) { + dest.Write (buff, 0, nread); + + if (nread == len) { if (completed != null) { dest.Close (); completed (dest.ToArray ()); @@ -855,6 +864,7 @@ Action error } retry = 0; + read (len - nread); } catch (Exception ex) { From 8357ed025c82b88a4f99efcab2ffe9e36be22968 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 24 Jun 2019 21:45:32 +0900 Subject: [PATCH 2497/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index f311db51c..d2c064418 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1231,7 +1231,9 @@ internal static byte[] UTF8Encode (this string s) return Encoding.UTF8.GetBytes (s); } - internal static void WriteBytes (this Stream stream, byte[] bytes, int bufferLength) + internal static void WriteBytes ( + this Stream stream, byte[] bytes, int bufferLength + ) { using (var input = new MemoryStream (bytes)) input.CopyTo (stream, bufferLength); From b0cb2ad93e596854e219ee3c13e3c7255d90f5ce Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 24 Jun 2019 21:49:21 +0900 Subject: [PATCH 2498/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index d2c064418..87ed9a7e3 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1240,7 +1240,12 @@ internal static void WriteBytes ( } internal static void WriteBytesAsync ( - this Stream stream, byte[] bytes, int bufferLength, Action completed, Action error) + this Stream stream, + byte[] bytes, + int bufferLength, + Action completed, + Action error + ) { var input = new MemoryStream (bytes); input.CopyToAsync ( @@ -1256,7 +1261,8 @@ internal static void WriteBytesAsync ( input.Dispose (); if (error != null) error (ex); - }); + } + ); } #endregion From 47e53eda0b43a2ba44c524fc086ab6a96a90b7e4 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 25 Jun 2019 19:56:07 +0900 Subject: [PATCH 2499/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 87ed9a7e3..bc93ee6af 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -314,12 +314,16 @@ internal static T[] Copy (this T[] source, long length) return dest; } - internal static void CopyTo (this Stream source, Stream destination, int bufferLength) + internal static void CopyTo ( + this Stream source, Stream destination, int bufferLength + ) { var buff = new byte[bufferLength]; - var nread = 0; - while ((nread = source.Read (buff, 0, bufferLength)) > 0) + var nread = source.Read (buff, 0, bufferLength); + while (nread > 0) { destination.Write (buff, 0, nread); + nread = source.Read (buff, 0, bufferLength); + } } internal static void CopyToAsync ( From 49a090413b9bbeab435bc2116fa73fe83a8fffbd Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 26 Jun 2019 20:26:51 +0900 Subject: [PATCH 2500/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index bc93ee6af..44bfe4660 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -331,29 +331,31 @@ internal static void CopyToAsync ( Stream destination, int bufferLength, Action completed, - Action error) + Action error + ) { var buff = new byte[bufferLength]; AsyncCallback callback = null; - callback = ar => { - try { - var nread = source.EndRead (ar); - if (nread <= 0) { - if (completed != null) - completed (); + callback = + ar => { + try { + var nread = source.EndRead (ar); + if (nread <= 0) { + if (completed != null) + completed (); - return; - } + return; + } - destination.Write (buff, 0, nread); - source.BeginRead (buff, 0, bufferLength, callback, null); - } - catch (Exception ex) { - if (error != null) - error (ex); - } - }; + destination.Write (buff, 0, nread); + source.BeginRead (buff, 0, bufferLength, callback, null); + } + catch (Exception ex) { + if (error != null) + error (ex); + } + }; try { source.BeginRead (buff, 0, bufferLength, callback, null); From e5fefd3abf177f675048d4a29dcae4da969edcd9 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 27 Jun 2019 20:08:30 +0900 Subject: [PATCH 2501/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 44bfe4660..80cdc70b4 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -319,10 +319,14 @@ internal static void CopyTo ( ) { var buff = new byte[bufferLength]; - var nread = source.Read (buff, 0, bufferLength); - while (nread > 0) { - destination.Write (buff, 0, nread); + var nread = 0; + + while (true) { nread = source.Read (buff, 0, bufferLength); + if (nread <= 0) + break; + + destination.Write (buff, 0, nread); } } From 2dfde14d5de6ac7c75d673adc42a2c6e9b7a7707 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 28 Jun 2019 19:49:35 +0900 Subject: [PATCH 2502/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 80cdc70b4..32beea525 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1245,8 +1245,8 @@ internal static void WriteBytes ( this Stream stream, byte[] bytes, int bufferLength ) { - using (var input = new MemoryStream (bytes)) - input.CopyTo (stream, bufferLength); + using (var src = new MemoryStream (bytes)) + src.CopyTo (stream, bufferLength); } internal static void WriteBytesAsync ( From d4237fab1b4b01efa668e2218c3c2621e8d9cae4 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 29 Jun 2019 20:42:52 +0900 Subject: [PATCH 2503/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 32beea525..f94981beb 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1257,18 +1257,18 @@ internal static void WriteBytesAsync ( Action error ) { - var input = new MemoryStream (bytes); - input.CopyToAsync ( + var src = new MemoryStream (bytes); + src.CopyToAsync ( stream, bufferLength, () => { if (completed != null) completed (); - input.Dispose (); + src.Dispose (); }, ex => { - input.Dispose (); + src.Dispose (); if (error != null) error (ex); } From 0259555dea3239e66c95a89cf89c5e283d2b585a Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 30 Jun 2019 21:07:43 +0900 Subject: [PATCH 2504/6294] [Modify] Add it --- websocket-sharp/Ext.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index f94981beb..70f2d7fdf 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -503,6 +503,11 @@ internal static string GetName (this string nameAndValue, char separator) return idx > 0 ? nameAndValue.Substring (0, idx).Trim () : null; } + internal static string GetUTF8DecodedString (this byte[] bytes) + { + return Encoding.UTF8.GetString (bytes); + } + /// /// Gets the value from the specified string that contains a pair of /// name and value separated by a character. From 639d78fd13ac9803e20bab57dc5f1a01c46c64e5 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 30 Jun 2019 21:11:56 +0900 Subject: [PATCH 2505/6294] [Modify] Add it --- websocket-sharp/Ext.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 70f2d7fdf..adca34b27 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -508,6 +508,11 @@ internal static string GetUTF8DecodedString (this byte[] bytes) return Encoding.UTF8.GetString (bytes); } + internal static byte[] GetUTF8EncodedBytes (this string s) + { + return Encoding.UTF8.GetBytes (s); + } + /// /// Gets the value from the specified string that contains a pair of /// name and value separated by a character. From 06fcf94796bf3fd8deb2676d20a15be76e59bfa7 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 1 Jul 2019 21:46:14 +0900 Subject: [PATCH 2506/6294] [Modify] Replace it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 93ed5bf4e..8a4853dc6 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2347,7 +2347,7 @@ internal static string CreateResponseKey (string base64Key) var buff = new StringBuilder (base64Key, 64); buff.Append (_guid); SHA1 sha1 = new SHA1CryptoServiceProvider (); - var src = sha1.ComputeHash (buff.ToString ().UTF8Encode ()); + var src = sha1.ComputeHash (buff.ToString ().GetUTF8EncodedBytes ()); return Convert.ToBase64String (src); } From 8f5f5ba383501ab5e74c3869732f2df7652bdd3f Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 1 Jul 2019 21:47:47 +0900 Subject: [PATCH 2507/6294] [Modify] Remove it --- websocket-sharp/Ext.cs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index adca34b27..9e1fb8f76 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1246,11 +1246,6 @@ internal static string UTF8Decode (this byte[] bytes) } } - internal static byte[] UTF8Encode (this string s) - { - return Encoding.UTF8.GetBytes (s); - } - internal static void WriteBytes ( this Stream stream, byte[] bytes, int bufferLength ) From 6e0962ce692bd9fe2c8720b8bb945cb5d8b1ca25 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 2 Jul 2019 19:50:42 +0900 Subject: [PATCH 2508/6294] [Modify] Replace it --- websocket-sharp/MessageEventArgs.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/MessageEventArgs.cs b/websocket-sharp/MessageEventArgs.cs index adf7391aa..7940f98b7 100644 --- a/websocket-sharp/MessageEventArgs.cs +++ b/websocket-sharp/MessageEventArgs.cs @@ -171,7 +171,10 @@ private void setData () return; } - _data = _rawData.UTF8Decode (); + string data; + if (_rawData.TryGetUTF8DecodedString (out data)) + _data = data; + _dataSet = true; } From 5c487003c6f06e49987436bb0e8af46c23aff38f Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 3 Jul 2019 20:35:49 +0900 Subject: [PATCH 2509/6294] [Modify] Replace it --- websocket-sharp/PayloadData.cs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/PayloadData.cs b/websocket-sharp/PayloadData.cs index 4e629d88c..bf1df3eaf 100644 --- a/websocket-sharp/PayloadData.cs +++ b/websocket-sharp/PayloadData.cs @@ -153,9 +153,18 @@ internal bool HasReservedCode { internal string Reason { get { if (!_reasonSet) { - _reason = _length > 2 - ? _data.SubArray (2, _length - 2).UTF8Decode () - : String.Empty; + if (_length > 2) { + var raw = _data.SubArray (2, _length - 2); + + string reason; + if (!raw.TryGetUTF8DecodedString (out reason)) + reason = String.Empty; + + _reason = reason; + } + else { + _reason = String.Empty; + } _reasonSet = true; } From aa3f136d22e58f566c378d5f123273ae146aacf9 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 4 Jul 2019 19:33:47 +0900 Subject: [PATCH 2510/6294] [Modify] Polish it --- websocket-sharp/CloseEventArgs.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/CloseEventArgs.cs b/websocket-sharp/CloseEventArgs.cs index c665ccde9..81122d4c4 100644 --- a/websocket-sharp/CloseEventArgs.cs +++ b/websocket-sharp/CloseEventArgs.cs @@ -117,7 +117,7 @@ public ushort Code { /// public string Reason { get { - return _payloadData.Reason ?? String.Empty; + return _payloadData.Reason; } } From 14591e9c8324ba8bcae57135badc5b2f0b31d9bb Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 5 Jul 2019 19:35:28 +0900 Subject: [PATCH 2511/6294] [Modify] Edit it --- websocket-sharp/CloseEventArgs.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/CloseEventArgs.cs b/websocket-sharp/CloseEventArgs.cs index 81122d4c4..cbbfa204f 100644 --- a/websocket-sharp/CloseEventArgs.cs +++ b/websocket-sharp/CloseEventArgs.cs @@ -113,7 +113,8 @@ public ushort Code { /// Gets the reason for the close. /// /// - /// A that represents the reason for the close if any. + /// A that represents the reason for the close + /// if present. /// public string Reason { get { From fff778042bb8d013268d05ce1072c8301eb132f3 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 5 Jul 2019 19:37:21 +0900 Subject: [PATCH 2512/6294] [Modify] Edit it --- websocket-sharp/CloseEventArgs.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/CloseEventArgs.cs b/websocket-sharp/CloseEventArgs.cs index cbbfa204f..cb281952d 100644 --- a/websocket-sharp/CloseEventArgs.cs +++ b/websocket-sharp/CloseEventArgs.cs @@ -101,7 +101,8 @@ internal PayloadData PayloadData { /// Gets the status code for the close. /// /// - /// A that represents the status code for the close if any. + /// A that represents the status code for the close + /// if present. /// public ushort Code { get { From 9d8918eae2183ab4820597f15651f2dd899c5edb Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 6 Jul 2019 21:30:54 +0900 Subject: [PATCH 2513/6294] [Modify] Edit it --- websocket-sharp/CloseEventArgs.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/CloseEventArgs.cs b/websocket-sharp/CloseEventArgs.cs index cb281952d..a3445e1e0 100644 --- a/websocket-sharp/CloseEventArgs.cs +++ b/websocket-sharp/CloseEventArgs.cs @@ -127,7 +127,8 @@ public string Reason { /// Gets a value indicating whether the connection has been closed cleanly. /// /// - /// true if the connection has been closed cleanly; otherwise, false. + /// true if the connection has been closed cleanly; otherwise, + /// false. /// public bool WasClean { get { From f717325e8c87d6115efb26639a9873564ee24a2c Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 7 Jul 2019 21:16:39 +0900 Subject: [PATCH 2514/6294] [Modify] Edit it --- websocket-sharp/CloseEventArgs.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/CloseEventArgs.cs b/websocket-sharp/CloseEventArgs.cs index a3445e1e0..78cd6cd87 100644 --- a/websocket-sharp/CloseEventArgs.cs +++ b/websocket-sharp/CloseEventArgs.cs @@ -98,11 +98,11 @@ internal PayloadData PayloadData { #region Public Properties /// - /// Gets the status code for the close. + /// Gets the status code for the connection close. /// /// - /// A that represents the status code for the close - /// if present. + /// A that represents the status code for + /// the connection close if present. /// public ushort Code { get { From 90c07cf910490f6a2bff391f49e9c4870ef69bb7 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 8 Jul 2019 20:53:26 +0900 Subject: [PATCH 2515/6294] [Modify] Edit it --- websocket-sharp/CloseEventArgs.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/CloseEventArgs.cs b/websocket-sharp/CloseEventArgs.cs index 78cd6cd87..0628955de 100644 --- a/websocket-sharp/CloseEventArgs.cs +++ b/websocket-sharp/CloseEventArgs.cs @@ -111,11 +111,11 @@ public ushort Code { } /// - /// Gets the reason for the close. + /// Gets the reason for the connection close. /// /// - /// A that represents the reason for the close - /// if present. + /// A that represents the reason for + /// the connection close if present. /// public string Reason { get { From 4c104ac681a240a43995a6dd84c9e13d30982543 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 8 Jul 2019 20:55:03 +0900 Subject: [PATCH 2516/6294] [Modify] Remove it --- websocket-sharp/CloseEventArgs.cs | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/websocket-sharp/CloseEventArgs.cs b/websocket-sharp/CloseEventArgs.cs index 0628955de..a980c7e8f 100644 --- a/websocket-sharp/CloseEventArgs.cs +++ b/websocket-sharp/CloseEventArgs.cs @@ -85,16 +85,6 @@ internal CloseEventArgs (CloseStatusCode code, string reason) #endregion - #region Internal Properties - - internal PayloadData PayloadData { - get { - return _payloadData; - } - } - - #endregion - #region Public Properties /// From a3e4cea416471640d8d82b9410f7c8d08a9b741a Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 9 Jul 2019 19:48:23 +0900 Subject: [PATCH 2517/6294] [Modify] Edit it --- websocket-sharp/CloseEventArgs.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/CloseEventArgs.cs b/websocket-sharp/CloseEventArgs.cs index a980c7e8f..117f7eb22 100644 --- a/websocket-sharp/CloseEventArgs.cs +++ b/websocket-sharp/CloseEventArgs.cs @@ -38,8 +38,8 @@ namespace WebSocketSharp /// That event occurs when the WebSocket connection has been closed. /// /// - /// If you would like to get the reason for the close, you should access - /// the or property. + /// If you would like to get the reason for the connection close, you should + /// access the or property. /// /// public class CloseEventArgs : EventArgs From 7568292ad627929d8e383eb9ae17f5103d3eb0ca Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 9 Jul 2019 19:50:05 +0900 Subject: [PATCH 2518/6294] [Modify] Remove it --- websocket-sharp/CloseEventArgs.cs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/websocket-sharp/CloseEventArgs.cs b/websocket-sharp/CloseEventArgs.cs index 117f7eb22..67664b105 100644 --- a/websocket-sharp/CloseEventArgs.cs +++ b/websocket-sharp/CloseEventArgs.cs @@ -53,11 +53,6 @@ public class CloseEventArgs : EventArgs #region Internal Constructors - internal CloseEventArgs () - { - _payloadData = PayloadData.Empty; - } - internal CloseEventArgs (ushort code) : this (code, null) { From 4ea2411192075d25c96179b6102d41e631355919 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 9 Jul 2019 19:50:56 +0900 Subject: [PATCH 2519/6294] [Modify] Remove it --- websocket-sharp/CloseEventArgs.cs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/websocket-sharp/CloseEventArgs.cs b/websocket-sharp/CloseEventArgs.cs index 67664b105..245e8988f 100644 --- a/websocket-sharp/CloseEventArgs.cs +++ b/websocket-sharp/CloseEventArgs.cs @@ -53,11 +53,6 @@ public class CloseEventArgs : EventArgs #region Internal Constructors - internal CloseEventArgs (ushort code) - : this (code, null) - { - } - internal CloseEventArgs (CloseStatusCode code) : this ((ushort) code, null) { From 0980c9bebad13c141abbabf8211c3da61fb7aedb Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 9 Jul 2019 19:52:02 +0900 Subject: [PATCH 2520/6294] [Modify] Remove it --- websocket-sharp/CloseEventArgs.cs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/websocket-sharp/CloseEventArgs.cs b/websocket-sharp/CloseEventArgs.cs index 245e8988f..0431cd316 100644 --- a/websocket-sharp/CloseEventArgs.cs +++ b/websocket-sharp/CloseEventArgs.cs @@ -53,11 +53,6 @@ public class CloseEventArgs : EventArgs #region Internal Constructors - internal CloseEventArgs (CloseStatusCode code) - : this ((ushort) code, null) - { - } - internal CloseEventArgs (PayloadData payloadData) { _payloadData = payloadData; From cc009e3bd78715a6cd62b4f45066e1a1dd3e6f9c Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 10 Jul 2019 20:30:58 +0900 Subject: [PATCH 2521/6294] [Modify] 2019 --- websocket-sharp/CloseEventArgs.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/CloseEventArgs.cs b/websocket-sharp/CloseEventArgs.cs index 0431cd316..77b76926f 100644 --- a/websocket-sharp/CloseEventArgs.cs +++ b/websocket-sharp/CloseEventArgs.cs @@ -4,7 +4,7 @@ * * The MIT License * - * Copyright (c) 2012-2016 sta.blockhead + * Copyright (c) 2012-2019 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From 5a78f57f2ded7216dd46bf7d817cbf7bd4f508f2 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 11 Jul 2019 19:47:00 +0900 Subject: [PATCH 2522/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 8a4853dc6..0ef522809 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1141,8 +1141,8 @@ private void close ( OnClose.Emit (this, e); } catch (Exception ex) { - _logger.Error (ex.ToString ()); - error ("An error has occurred during the OnClose event.", ex); + _logger.Error (ex.Message); + _logger.Debug (ex.ToString ()); } } From 19c9fcd87f25b5cb67d258a4eda87da076f3023a Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 12 Jul 2019 19:40:09 +0900 Subject: [PATCH 2523/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 0ef522809..248ddde58 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2329,7 +2329,8 @@ internal void Close (PayloadData payloadData, byte[] frameAsBytes) OnClose.Emit (this, e); } catch (Exception ex) { - _logger.Error (ex.ToString ()); + _logger.Error (ex.Message); + _logger.Debug (ex.ToString ()); } } From bc9fca6b48bf7c32ad2dec1803bdc0d1c2f020c5 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 12 Jul 2019 19:47:04 +0900 Subject: [PATCH 2524/6294] [Modify] Add it --- websocket-sharp/CloseEventArgs.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/websocket-sharp/CloseEventArgs.cs b/websocket-sharp/CloseEventArgs.cs index 77b76926f..764c34640 100644 --- a/websocket-sharp/CloseEventArgs.cs +++ b/websocket-sharp/CloseEventArgs.cs @@ -68,6 +68,12 @@ internal CloseEventArgs (CloseStatusCode code, string reason) { } + internal CloseEventArgs (PayloadData payloadData, bool clean) + { + _payloadData = payloadData; + _clean = clean; + } + #endregion #region Public Properties From 9b1d64ad4376fd2cdf01a2c2e90c6cad51fc6fe5 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 13 Jul 2019 20:46:42 +0900 Subject: [PATCH 2525/6294] [Modify] Polish it --- websocket-sharp/CloseEventArgs.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/CloseEventArgs.cs b/websocket-sharp/CloseEventArgs.cs index 764c34640..322c22b18 100644 --- a/websocket-sharp/CloseEventArgs.cs +++ b/websocket-sharp/CloseEventArgs.cs @@ -54,8 +54,8 @@ public class CloseEventArgs : EventArgs #region Internal Constructors internal CloseEventArgs (PayloadData payloadData) + : this (payloadData, false) { - _payloadData = payloadData; } internal CloseEventArgs (ushort code, string reason) From 63ef6d10678c64df3712e042b430feff6840c3aa Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 13 Jul 2019 20:48:33 +0900 Subject: [PATCH 2526/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 248ddde58..a99a5aa3c 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1134,8 +1134,7 @@ private void close ( _readyState = WebSocketState.Closed; - var e = new CloseEventArgs (payloadData); - e.WasClean = res; + var e = new CloseEventArgs (payloadData, res); try { OnClose.Emit (this, e); From de906341b2873d4467f42de9a26267ab269cb7fa Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 14 Jul 2019 19:22:47 +0900 Subject: [PATCH 2527/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index a99a5aa3c..21d519535 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2321,8 +2321,7 @@ internal void Close (PayloadData payloadData, byte[] frameAsBytes) _readyState = WebSocketState.Closed; - var e = new CloseEventArgs (payloadData); - e.WasClean = res; + var e = new CloseEventArgs (payloadData, res); try { OnClose.Emit (this, e); From d5f45e57679f9c50b99246681d0af6e3a48e313b Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 14 Jul 2019 19:24:34 +0900 Subject: [PATCH 2528/6294] [Modify] Remove it --- websocket-sharp/CloseEventArgs.cs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/websocket-sharp/CloseEventArgs.cs b/websocket-sharp/CloseEventArgs.cs index 322c22b18..88a5b44f1 100644 --- a/websocket-sharp/CloseEventArgs.cs +++ b/websocket-sharp/CloseEventArgs.cs @@ -53,11 +53,6 @@ public class CloseEventArgs : EventArgs #region Internal Constructors - internal CloseEventArgs (PayloadData payloadData) - : this (payloadData, false) - { - } - internal CloseEventArgs (ushort code, string reason) { _payloadData = new PayloadData (code, reason); From f7378d8049a73cd8d55a76a603e855a2067122c1 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 15 Jul 2019 22:05:09 +0900 Subject: [PATCH 2529/6294] [Modify] Add it --- websocket-sharp/CloseEventArgs.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/websocket-sharp/CloseEventArgs.cs b/websocket-sharp/CloseEventArgs.cs index 88a5b44f1..2e1688f5b 100644 --- a/websocket-sharp/CloseEventArgs.cs +++ b/websocket-sharp/CloseEventArgs.cs @@ -69,6 +69,12 @@ internal CloseEventArgs (PayloadData payloadData, bool clean) _clean = clean; } + internal CloseEventArgs (ushort code, string reason, bool clean) + { + _payloadData = new PayloadData (code, reason); + _clean = clean; + } + #endregion #region Public Properties From 13bb6b715e4f9c73ea978fcc82f653adaff0bad5 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 15 Jul 2019 22:08:35 +0900 Subject: [PATCH 2530/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 21d519535..011dee00d 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1788,7 +1788,7 @@ private void refuseHandshake (CloseStatusCode code, string reason) _readyState = WebSocketState.Closed; - var e = new CloseEventArgs (code, reason); + var e = new CloseEventArgs ((ushort) code, reason, false); try { OnClose.Emit (this, e); From 3b615b0033861903f063e4692be549fac5d2d1e9 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 16 Jul 2019 21:26:46 +0900 Subject: [PATCH 2531/6294] [Modify] Remove it --- websocket-sharp/CloseEventArgs.cs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/websocket-sharp/CloseEventArgs.cs b/websocket-sharp/CloseEventArgs.cs index 2e1688f5b..b68d620af 100644 --- a/websocket-sharp/CloseEventArgs.cs +++ b/websocket-sharp/CloseEventArgs.cs @@ -58,11 +58,6 @@ internal CloseEventArgs (ushort code, string reason) _payloadData = new PayloadData (code, reason); } - internal CloseEventArgs (CloseStatusCode code, string reason) - : this ((ushort) code, reason) - { - } - internal CloseEventArgs (PayloadData payloadData, bool clean) { _payloadData = payloadData; From c3a041e943fb98c91a1e12c1c3efa02ed0413838 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 16 Jul 2019 21:27:55 +0900 Subject: [PATCH 2532/6294] [Modify] Remove it --- websocket-sharp/CloseEventArgs.cs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/websocket-sharp/CloseEventArgs.cs b/websocket-sharp/CloseEventArgs.cs index b68d620af..21ee1641f 100644 --- a/websocket-sharp/CloseEventArgs.cs +++ b/websocket-sharp/CloseEventArgs.cs @@ -53,11 +53,6 @@ public class CloseEventArgs : EventArgs #region Internal Constructors - internal CloseEventArgs (ushort code, string reason) - { - _payloadData = new PayloadData (code, reason); - } - internal CloseEventArgs (PayloadData payloadData, bool clean) { _payloadData = payloadData; From beb3a149761ff4aa144037ed2a40725cca02306f Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 17 Jul 2019 21:28:51 +0900 Subject: [PATCH 2533/6294] [Modify] Remove it --- websocket-sharp/CloseEventArgs.cs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/websocket-sharp/CloseEventArgs.cs b/websocket-sharp/CloseEventArgs.cs index 21ee1641f..8127ce418 100644 --- a/websocket-sharp/CloseEventArgs.cs +++ b/websocket-sharp/CloseEventArgs.cs @@ -106,10 +106,6 @@ public bool WasClean { get { return _clean; } - - internal set { - _clean = value; - } } #endregion From 8d94a28a2ec8cdde46ab4a97891aaf5d9297ea15 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 18 Jul 2019 19:57:48 +0900 Subject: [PATCH 2534/6294] [Modify] Polish it --- websocket-sharp/PayloadData.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/PayloadData.cs b/websocket-sharp/PayloadData.cs index bf1df3eaf..d60a8601a 100644 --- a/websocket-sharp/PayloadData.cs +++ b/websocket-sharp/PayloadData.cs @@ -123,7 +123,7 @@ internal PayloadData (ushort code, string reason) internal ushort Code { get { if (!_codeSet) { - _code = _length > 1 + _code = _length >= 2 ? _data.SubArray (0, 2).ToUInt16 (ByteOrder.Big) : (ushort) 1005; From 583383d5f34d0e1d03372c3a6d709211e2db539c Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 19 Jul 2019 19:42:16 +0900 Subject: [PATCH 2535/6294] [Modify] Polish it --- websocket-sharp/PayloadData.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/PayloadData.cs b/websocket-sharp/PayloadData.cs index d60a8601a..4ecec274f 100644 --- a/websocket-sharp/PayloadData.cs +++ b/websocket-sharp/PayloadData.cs @@ -146,7 +146,7 @@ internal long ExtensionDataLength { internal bool HasReservedCode { get { - return _length > 1 && Code.IsReserved (); + return _length >= 2 && Code.IsReserved (); } } From 4a07970d1f9f975e5a976f0f9c340059f29248e6 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 20 Jul 2019 22:30:17 +0900 Subject: [PATCH 2536/6294] [Modify] Replace it --- websocket-sharp/PayloadData.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/PayloadData.cs b/websocket-sharp/PayloadData.cs index 4ecec274f..1ab49d573 100644 --- a/websocket-sharp/PayloadData.cs +++ b/websocket-sharp/PayloadData.cs @@ -74,7 +74,7 @@ internal class PayloadData : IEnumerable static PayloadData () { - Empty = new PayloadData (); + Empty = new PayloadData (WebSocket.EmptyBytes, 0); MaxLength = Int64.MaxValue; } From 542bea6c6087610f6c3498a58b7962d7a93dbe6a Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 21 Jul 2019 21:35:16 +0900 Subject: [PATCH 2537/6294] [Modify] Remove it --- websocket-sharp/PayloadData.cs | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/websocket-sharp/PayloadData.cs b/websocket-sharp/PayloadData.cs index 1ab49d573..96dc0a38f 100644 --- a/websocket-sharp/PayloadData.cs +++ b/websocket-sharp/PayloadData.cs @@ -82,17 +82,6 @@ static PayloadData () #region Internal Constructors - internal PayloadData () - { - _code = 1005; - _reason = String.Empty; - - _data = WebSocket.EmptyBytes; - - _codeSet = true; - _reasonSet = true; - } - internal PayloadData (byte[] data) : this (data, data.LongLength) { From 93f12714fe353db6ad3f7f9a91d2fa7598f8cac7 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 22 Jul 2019 21:25:33 +0900 Subject: [PATCH 2538/6294] [Modify] Polish it --- websocket-sharp/PayloadData.cs | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/websocket-sharp/PayloadData.cs b/websocket-sharp/PayloadData.cs index 96dc0a38f..934aa2ffc 100644 --- a/websocket-sharp/PayloadData.cs +++ b/websocket-sharp/PayloadData.cs @@ -36,8 +36,6 @@ internal class PayloadData : IEnumerable { #region Private Fields - private ushort _code; - private bool _codeSet; private byte[] _data; private long _extDataLength; private long _length; @@ -95,13 +93,11 @@ internal PayloadData (byte[] data, long length) internal PayloadData (ushort code, string reason) { - _code = code; _reason = reason ?? String.Empty; _data = code.Append (reason); _length = _data.LongLength; - _codeSet = true; _reasonSet = true; } @@ -111,15 +107,9 @@ internal PayloadData (ushort code, string reason) internal ushort Code { get { - if (!_codeSet) { - _code = _length >= 2 - ? _data.SubArray (0, 2).ToUInt16 (ByteOrder.Big) - : (ushort) 1005; - - _codeSet = true; - } - - return _code; + return _length >= 2 + ? _data.SubArray (0, 2).ToUInt16 (ByteOrder.Big) + : (ushort) 1005; } } From 14bbf8a3adb80b53c6b81e254f0d4330c1c23fb8 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 23 Jul 2019 21:54:56 +0900 Subject: [PATCH 2539/6294] [Modify] Polish it --- websocket-sharp/PayloadData.cs | 29 +++++++---------------------- 1 file changed, 7 insertions(+), 22 deletions(-) diff --git a/websocket-sharp/PayloadData.cs b/websocket-sharp/PayloadData.cs index 934aa2ffc..b90637dea 100644 --- a/websocket-sharp/PayloadData.cs +++ b/websocket-sharp/PayloadData.cs @@ -39,8 +39,6 @@ internal class PayloadData : IEnumerable private byte[] _data; private long _extDataLength; private long _length; - private string _reason; - private bool _reasonSet; #endregion @@ -93,12 +91,8 @@ internal PayloadData (byte[] data, long length) internal PayloadData (ushort code, string reason) { - _reason = reason ?? String.Empty; - _data = code.Append (reason); _length = _data.LongLength; - - _reasonSet = true; } #endregion @@ -131,24 +125,15 @@ internal bool HasReservedCode { internal string Reason { get { - if (!_reasonSet) { - if (_length > 2) { - var raw = _data.SubArray (2, _length - 2); - - string reason; - if (!raw.TryGetUTF8DecodedString (out reason)) - reason = String.Empty; - - _reason = reason; - } - else { - _reason = String.Empty; - } + if (_length <= 2) + return String.Empty; - _reasonSet = true; - } + var raw = _data.SubArray (2, _length - 2); - return _reason; + string reason; + return raw.TryGetUTF8DecodedString (out reason) + ? reason + : String.Empty; } } From d29f8b55432292f08282233ba6ce0d057fddec20 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 24 Jul 2019 21:08:04 +0900 Subject: [PATCH 2540/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 9e1fb8f76..2d259566e 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -570,13 +570,15 @@ internal static string GetValue ( return unquote ? val.Unquote () : val; } - internal static byte[] InternalToByteArray (this ushort value, ByteOrder order) + internal static byte[] InternalToByteArray ( + this ushort value, ByteOrder order + ) { - var bytes = BitConverter.GetBytes (value); + var ret = BitConverter.GetBytes (value); if (!order.IsHostOrder ()) - Array.Reverse (bytes); + Array.Reverse (ret); - return bytes; + return ret; } internal static byte[] InternalToByteArray (this ulong value, ByteOrder order) From e3201e336f7cb6f58e69741e2655c7768e7e6127 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 25 Jul 2019 20:08:16 +0900 Subject: [PATCH 2541/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 2d259566e..55505d954 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -581,13 +581,16 @@ internal static byte[] InternalToByteArray ( return ret; } - internal static byte[] InternalToByteArray (this ulong value, ByteOrder order) + internal static byte[] InternalToByteArray ( + this ulong value, ByteOrder order + ) { - var bytes = BitConverter.GetBytes (value); + var ret = BitConverter.GetBytes (value); + if (!order.IsHostOrder ()) - Array.Reverse (bytes); + Array.Reverse (ret); - return bytes; + return ret; } internal static bool IsCompressionExtension ( From 36a40ef4abc62ef35c92b5570b8f37ffa9c12221 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 25 Jul 2019 20:10:16 +0900 Subject: [PATCH 2542/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 55505d954..01a343d5c 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -575,6 +575,7 @@ internal static byte[] InternalToByteArray ( ) { var ret = BitConverter.GetBytes (value); + if (!order.IsHostOrder ()) Array.Reverse (ret); From babc702f10b3c844d0c58e20434954e361677356 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 26 Jul 2019 21:02:24 +0900 Subject: [PATCH 2543/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 01a343d5c..26c49eb04 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -172,14 +172,15 @@ private static void times (this ulong n, Action action) internal static byte[] Append (this ushort code, string reason) { - var ret = code.InternalToByteArray (ByteOrder.Big); - if (reason != null && reason.Length > 0) { - var buff = new List (ret); - buff.AddRange (Encoding.UTF8.GetBytes (reason)); - ret = buff.ToArray (); - } + var bytes = code.InternalToByteArray (ByteOrder.Big); - return ret; + if (reason == null || reason.Length == 0) + return bytes; + + var buff = new List (bytes); + buff.AddRange (Encoding.UTF8.GetBytes (reason)); + + return buff.ToArray (); } internal static void Close (this HttpListenerResponse response, HttpStatusCode code) From b811f99e038632beda913e7dc94fac70c79b4dff Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 27 Jul 2019 21:17:22 +0900 Subject: [PATCH 2544/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 26c49eb04..97b3d6626 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -183,7 +183,9 @@ internal static byte[] Append (this ushort code, string reason) return buff.ToArray (); } - internal static void Close (this HttpListenerResponse response, HttpStatusCode code) + internal static void Close ( + this HttpListenerResponse response, HttpStatusCode code + ) { response.StatusCode = (int) code; response.OutputStream.Close (); From 710cbbfcef1c8ab8cc0e35ab1c6de35f48cc3451 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 28 Jul 2019 21:27:12 +0900 Subject: [PATCH 2545/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 97b3d6626..90e14ce26 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -192,7 +192,8 @@ internal static void Close ( } internal static void CloseWithAuthChallenge ( - this HttpListenerResponse response, string challenge) + this HttpListenerResponse response, string challenge + ) { response.Headers.InternalSet ("WWW-Authenticate", challenge, true); response.Close (HttpStatusCode.Unauthorized); From 9da945d4ce34533d322868e2f02f98c9fd6a08ed Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 29 Jul 2019 21:41:13 +0900 Subject: [PATCH 2546/6294] [Modify] Edit it --- websocket-sharp/PayloadData.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/PayloadData.cs b/websocket-sharp/PayloadData.cs index b90637dea..f7dfa68bb 100644 --- a/websocket-sharp/PayloadData.cs +++ b/websocket-sharp/PayloadData.cs @@ -54,12 +54,13 @@ internal class PayloadData : IEnumerable /// /// /// - /// A will occur if the payload data length is - /// greater than the value of this field. + /// A will occur when the length of + /// incoming payload data is greater than the value of this field. /// /// - /// If you would like to change the value, you must set it to a value between - /// WebSocket.FragmentLength and Int64.MaxValue inclusive. + /// If you would like to change the value, you must set it to a value + /// between WebSocket.FragmentLength and Int64.MaxValue + /// inclusive. /// /// public static readonly ulong MaxLength; From 9fdc4dc75d3a645a8858743643b784408964192f Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 30 Jul 2019 21:36:41 +0900 Subject: [PATCH 2547/6294] [Modify] Edit it --- websocket-sharp/PayloadData.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/PayloadData.cs b/websocket-sharp/PayloadData.cs index f7dfa68bb..900faedda 100644 --- a/websocket-sharp/PayloadData.cs +++ b/websocket-sharp/PayloadData.cs @@ -50,7 +50,7 @@ internal class PayloadData : IEnumerable public static readonly PayloadData Empty; /// - /// Represents the allowable max length. + /// Represents the allowable max length of payload data. /// /// /// @@ -58,9 +58,9 @@ internal class PayloadData : IEnumerable /// incoming payload data is greater than the value of this field. /// /// - /// If you would like to change the value, you must set it to a value - /// between WebSocket.FragmentLength and Int64.MaxValue - /// inclusive. + /// If you would like to change the value of this field, it must be + /// a number between and + /// inclusive. /// /// public static readonly ulong MaxLength; From c66fe2d2859d165f1f9d94e244af67f9c1daa4dc Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 31 Jul 2019 21:27:44 +0900 Subject: [PATCH 2548/6294] [Modify] 2019 --- websocket-sharp/PayloadData.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/PayloadData.cs b/websocket-sharp/PayloadData.cs index 900faedda..9e40b9404 100644 --- a/websocket-sharp/PayloadData.cs +++ b/websocket-sharp/PayloadData.cs @@ -4,7 +4,7 @@ * * The MIT License * - * Copyright (c) 2012-2016 sta.blockhead + * Copyright (c) 2012-2019 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From 3d6a3303d6292f2dd2db68b1ec95be94a3c7f242 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 1 Aug 2019 21:31:35 +0900 Subject: [PATCH 2549/6294] [Modify] Polish it --- websocket-sharp/WebSocketFrame.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index 3be6300fe..e56a8db51 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -383,7 +383,9 @@ private static string print (WebSocketFrame frame) var payloadLen = frame._payloadLength; // Extended Payload Length - var extPayloadLen = payloadLen > 125 ? frame.FullPayloadLength.ToString () : String.Empty; + var extPayloadLen = payloadLen > 125 + ? frame.FullPayloadLength.ToString () + : String.Empty; // Masking Key var maskingKey = BitConverter.ToString (frame._maskingKey); From 669fb965e8973dd8b89e66f8d218f7feb8dbef62 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 2 Aug 2019 22:01:51 +0900 Subject: [PATCH 2550/6294] [Modify] Polish it --- websocket-sharp/WebSocketFrame.cs | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index e56a8db51..f4877fc7e 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -412,17 +412,18 @@ private static string print (WebSocketFrame frame) Payload Data: {9}"; return String.Format ( - fmt, - frame._fin, - frame._rsv1, - frame._rsv2, - frame._rsv3, - frame._opcode, - frame._mask, - payloadLen, - extPayloadLen, - maskingKey, - payload); + fmt, + frame._fin, + frame._rsv1, + frame._rsv2, + frame._rsv3, + frame._opcode, + frame._mask, + payloadLen, + extPayloadLen, + maskingKey, + payload + ); } private static WebSocketFrame processHeader (byte[] header) From 9d68cb7c2f4ae945add262d2e0657896a9ef9e99 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 3 Aug 2019 22:22:19 +0900 Subject: [PATCH 2551/6294] [Modify] Polish it --- websocket-sharp/WebSocketFrame.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index f4877fc7e..ec680a5da 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -395,7 +395,12 @@ private static string print (WebSocketFrame frame) ? String.Empty : payloadLen > 125 ? "---" - : frame.IsText && !(frame.IsFragment || frame.IsMasked || frame.IsCompressed) + : frame.IsText + && !( + frame.IsFragment + || frame.IsMasked + || frame.IsCompressed + ) ? frame._payloadData.ApplicationData.UTF8Decode () : frame._payloadData.ToString (); From fe409a16f37bee2fddb610c13967bfedcb85c135 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 4 Aug 2019 22:30:02 +0900 Subject: [PATCH 2552/6294] [Modify] Polish it --- websocket-sharp/WebSocketFrame.cs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index ec680a5da..84159b6ad 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -395,14 +395,12 @@ private static string print (WebSocketFrame frame) ? String.Empty : payloadLen > 125 ? "---" - : frame.IsText - && !( - frame.IsFragment - || frame.IsMasked - || frame.IsCompressed - ) - ? frame._payloadData.ApplicationData.UTF8Decode () - : frame._payloadData.ToString (); + : !frame.IsText + || frame.IsFragment + || frame.IsMasked + || frame.IsCompressed + ? frame._payloadData.ToString () + : frame._payloadData.ApplicationData.UTF8Decode (); var fmt = @" FIN: {0} From 09ab8f01d2667034123bcc13426ade5c00356e06 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 5 Aug 2019 21:46:39 +0900 Subject: [PATCH 2553/6294] [Modify] Add it --- websocket-sharp/WebSocketFrame.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index 84159b6ad..345f10cfc 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -637,6 +637,16 @@ private static void readPayloadDataAsync ( stream.ReadBytesAsync (llen, 1024, compl, error); } + private static string utf8Decode (byte[] bytes) + { + try { + return Encoding.UTF8.GetString (bytes); + } + catch { + return null; + } + } + #endregion #region Internal Methods From 72cab730c9c3be48b522c8588c153dafc8bf7542 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 6 Aug 2019 21:40:33 +0900 Subject: [PATCH 2554/6294] [Modify] Replace it --- websocket-sharp/WebSocketFrame.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index 345f10cfc..b39bcc547 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -400,7 +400,7 @@ private static string print (WebSocketFrame frame) || frame.IsMasked || frame.IsCompressed ? frame._payloadData.ToString () - : frame._payloadData.ApplicationData.UTF8Decode (); + : utf8Decode (frame._payloadData.ApplicationData); var fmt = @" FIN: {0} From a75cf5ed267a94cd878a39806c5398e5d2846af7 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 7 Aug 2019 21:51:45 +0900 Subject: [PATCH 2555/6294] [Modify] Remove it --- websocket-sharp/Ext.cs | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 90e14ce26..cacef8451 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1246,16 +1246,6 @@ internal static string UrlEncode (this string value, Encoding encoding) return HttpUtility.UrlEncode (value, encoding); } - internal static string UTF8Decode (this byte[] bytes) - { - try { - return Encoding.UTF8.GetString (bytes); - } - catch { - return null; - } - } - internal static void WriteBytes ( this Stream stream, byte[] bytes, int bufferLength ) From 2c890cbb2a1561eb40a0c118af326144914c6485 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 8 Aug 2019 21:43:35 +0900 Subject: [PATCH 2556/6294] [Modify] Polish it --- websocket-sharp/WebSocketFrame.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index b39bcc547..ae6db3fc7 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -95,7 +95,9 @@ internal WebSocketFrame (Opcode opcode, PayloadData payloadData, bool mask) { } - internal WebSocketFrame (Fin fin, Opcode opcode, byte[] data, bool compressed, bool mask) + internal WebSocketFrame ( + Fin fin, Opcode opcode, byte[] data, bool compressed, bool mask + ) : this (fin, opcode, new PayloadData (data), compressed, mask) { } From 909cb12717872694f69996db394e9ef0dadd33f4 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 9 Aug 2019 21:50:42 +0900 Subject: [PATCH 2557/6294] [Modify] Polish it --- websocket-sharp/WebSocketFrame.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index ae6db3fc7..2c4d18411 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -103,13 +103,19 @@ internal WebSocketFrame ( } internal WebSocketFrame ( - Fin fin, Opcode opcode, PayloadData payloadData, bool compressed, bool mask) + Fin fin, + Opcode opcode, + PayloadData payloadData, + bool compressed, + bool mask + ) { _fin = fin; + _opcode = opcode; + _rsv1 = opcode.IsData () && compressed ? Rsv.On : Rsv.Off; _rsv2 = Rsv.Off; _rsv3 = Rsv.Off; - _opcode = opcode; var len = payloadData.Length; if (len < 126) { From f9ca46e8403ae5b7c38690ddad2041b2e0512280 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 10 Aug 2019 22:25:44 +0900 Subject: [PATCH 2558/6294] [Modify] Polish it --- websocket-sharp/WebSocketFrame.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index 2c4d18411..67f4fb6e7 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -150,7 +150,11 @@ bool mask internal int ExtendedPayloadLengthCount { get { - return _payloadLength < 126 ? 0 : (_payloadLength == 126 ? 2 : 8); + return _payloadLength < 126 + ? 0 + : _payloadLength == 126 + ? 2 + : 8; } } From e34d14e2f6d1a8d07c3bb0e4ad61b1467c570fb7 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 11 Aug 2019 21:49:52 +0900 Subject: [PATCH 2559/6294] [Modify] Polish it --- websocket-sharp/WebSocketFrame.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index 67f4fb6e7..b857d4f44 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -258,7 +258,9 @@ public bool IsText { public ulong Length { get { - return 2 + (ulong) (_extPayloadLength.Length + _maskingKey.Length) + _payloadData.Length; + return 2 + + (ulong) (_extPayloadLength.Length + _maskingKey.Length) + + _payloadData.Length; } } From fed3dd092e3c8b9fd51473488f30cbc5109d376e Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 12 Aug 2019 21:53:27 +0900 Subject: [PATCH 2560/6294] [Modify] Polish it --- websocket-sharp/WebSocketFrame.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index b857d4f44..86af54efc 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -787,7 +787,10 @@ public byte[] ToArray () header = (header << 4) + (int) _opcode; header = (header << 1) + (int) _mask; header = (header << 7) + (int) _payloadLength; - buff.Write (((ushort) header).InternalToByteArray (ByteOrder.Big), 0, 2); + + buff.Write ( + ((ushort) header).InternalToByteArray (ByteOrder.Big), 0, 2 + ); if (_payloadLength > 125) buff.Write (_extPayloadLength, 0, _payloadLength == 126 ? 2 : 8); @@ -797,6 +800,7 @@ public byte[] ToArray () if (_payloadLength > 0) { var bytes = _payloadData.ToArray (); + if (_payloadLength < 127) buff.Write (bytes, 0, bytes.Length); else From 24901cd01b5302cd881a57cff4f49af8f60ecacc Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 13 Aug 2019 21:52:34 +0900 Subject: [PATCH 2561/6294] [Modify] Polish it --- websocket-sharp/WebSocketFrame.cs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index 86af54efc..1bc9f6d1d 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -494,7 +494,9 @@ private static WebSocketFrame processHeader (byte[] header) return frame; } - private static WebSocketFrame readExtendedPayloadLength (Stream stream, WebSocketFrame frame) + private static WebSocketFrame readExtendedPayloadLength ( + Stream stream, WebSocketFrame frame + ) { var len = frame.ExtendedPayloadLengthCount; if (len == 0) { @@ -503,9 +505,10 @@ private static WebSocketFrame readExtendedPayloadLength (Stream stream, WebSocke } var bytes = stream.ReadBytes (len); - if (bytes.Length != len) - throw new WebSocketException ( - "The extended payload length of a frame cannot be read from the stream."); + if (bytes.Length != len) { + var msg = "The extended payload length of a frame could not be read."; + throw new WebSocketException (msg); + } frame._extPayloadLength = bytes; return frame; From 24f65e4d72d97b75a8ed83e8285e97c16dc477b9 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 14 Aug 2019 22:12:46 +0900 Subject: [PATCH 2562/6294] [Modify] Polish it --- websocket-sharp/WebSocketFrame.cs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index 1bc9f6d1d..dc577dc30 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -518,7 +518,8 @@ private static void readExtendedPayloadLengthAsync ( Stream stream, WebSocketFrame frame, Action completed, - Action error) + Action error + ) { var len = frame.ExtendedPayloadLengthCount; if (len == 0) { @@ -531,14 +532,16 @@ private static void readExtendedPayloadLengthAsync ( stream.ReadBytesAsync ( len, bytes => { - if (bytes.Length != len) - throw new WebSocketException ( - "The extended payload length of a frame cannot be read from the stream."); + if (bytes.Length != len) { + var msg = "The extended payload length of a frame could not be read."; + throw new WebSocketException (msg); + } frame._extPayloadLength = bytes; completed (frame); }, - error); + error + ); } private static WebSocketFrame readHeader (Stream stream) From 1c52fb72aab271945c4d602c8a86b383036f75c2 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 15 Aug 2019 22:05:30 +0900 Subject: [PATCH 2563/6294] [Modify] Polish it --- websocket-sharp/WebSocketFrame.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index dc577dc30..2c1dec6e9 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -550,9 +550,12 @@ private static WebSocketFrame readHeader (Stream stream) } private static void readHeaderAsync ( - Stream stream, Action completed, Action error) + Stream stream, Action completed, Action error + ) { - stream.ReadBytesAsync (2, bytes => completed (processHeader (bytes)), error); + stream.ReadBytesAsync ( + 2, bytes => completed (processHeader (bytes)), error + ); } private static WebSocketFrame readMaskingKey (Stream stream, WebSocketFrame frame) From ced5db7f3522def05229f6e6c1b04d07a875b599 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 15 Aug 2019 22:09:48 +0900 Subject: [PATCH 2564/6294] [Modify] Polish it --- websocket-sharp/WebSocketFrame.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index 2c1dec6e9..61fa92150 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -558,7 +558,9 @@ private static void readHeaderAsync ( ); } - private static WebSocketFrame readMaskingKey (Stream stream, WebSocketFrame frame) + private static WebSocketFrame readMaskingKey ( + Stream stream, WebSocketFrame frame + ) { var len = frame.IsMasked ? 4 : 0; if (len == 0) { @@ -567,8 +569,10 @@ private static WebSocketFrame readMaskingKey (Stream stream, WebSocketFrame fram } var bytes = stream.ReadBytes (len); - if (bytes.Length != len) - throw new WebSocketException ("The masking key of a frame cannot be read from the stream."); + if (bytes.Length != len) { + var msg = "The masking key of a frame could not be read."; + throw new WebSocketException (msg); + } frame._maskingKey = bytes; return frame; From fcc14146d93f5ecbe7ee887089123435d871cfb6 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 16 Aug 2019 21:45:59 +0900 Subject: [PATCH 2565/6294] [Modify] Polish it --- websocket-sharp/WebSocketFrame.cs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index 61fa92150..0a2df9960 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -582,7 +582,8 @@ private static void readMaskingKeyAsync ( Stream stream, WebSocketFrame frame, Action completed, - Action error) + Action error + ) { var len = frame.IsMasked ? 4 : 0; if (len == 0) { @@ -595,14 +596,16 @@ private static void readMaskingKeyAsync ( stream.ReadBytesAsync ( len, bytes => { - if (bytes.Length != len) - throw new WebSocketException ( - "The masking key of a frame cannot be read from the stream."); + if (bytes.Length != len) { + var msg = "The masking key of a frame could not be read."; + throw new WebSocketException (msg); + } frame._maskingKey = bytes; completed (frame); }, - error); + error + ); } private static WebSocketFrame readPayloadData (Stream stream, WebSocketFrame frame) From e44a6c799f516ff32a34dfac4d05651b742b1fda Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 17 Aug 2019 22:01:51 +0900 Subject: [PATCH 2566/6294] [Modify] Polish it --- websocket-sharp/WebSocketFrame.cs | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index 0a2df9960..2b48dcdc4 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -608,7 +608,9 @@ Action error ); } - private static WebSocketFrame readPayloadData (Stream stream, WebSocketFrame frame) + private static WebSocketFrame readPayloadData ( + Stream stream, WebSocketFrame frame + ) { var len = frame.FullPayloadLength; if (len == 0) { @@ -616,17 +618,20 @@ private static WebSocketFrame readPayloadData (Stream stream, WebSocketFrame fra return frame; } - if (len > PayloadData.MaxLength) - throw new WebSocketException (CloseStatusCode.TooBig, "A frame has a long payload length."); + if (len > PayloadData.MaxLength) { + var msg = "A frame has too long payload data length."; + throw new WebSocketException (CloseStatusCode.TooBig, msg); + } var llen = (long) len; var bytes = frame._payloadLength < 127 ? stream.ReadBytes ((int) len) : stream.ReadBytes (llen, 1024); - if (bytes.LongLength != llen) - throw new WebSocketException ( - "The payload data of a frame cannot be read from the stream."); + if (bytes.LongLength != llen) { + var msg = "The payload data of a frame could not be read."; + throw new WebSocketException (msg); + } frame._payloadData = new PayloadData (bytes, llen); return frame; From 6357649fe50b4d9d03de5abb29f777def3d2434a Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 18 Aug 2019 22:38:10 +0900 Subject: [PATCH 2567/6294] [Modify] Polish it --- websocket-sharp/WebSocketFrame.cs | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index 2b48dcdc4..6420aabfe 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -641,7 +641,8 @@ private static void readPayloadDataAsync ( Stream stream, WebSocketFrame frame, Action completed, - Action error) + Action error + ) { var len = frame.FullPayloadLength; if (len == 0) { @@ -651,18 +652,22 @@ private static void readPayloadDataAsync ( return; } - if (len > PayloadData.MaxLength) - throw new WebSocketException (CloseStatusCode.TooBig, "A frame has a long payload length."); + if (len > PayloadData.MaxLength) { + var msg = "A frame has too long payload data length."; + throw new WebSocketException (CloseStatusCode.TooBig, msg); + } var llen = (long) len; - Action compl = bytes => { - if (bytes.LongLength != llen) - throw new WebSocketException ( - "The payload data of a frame cannot be read from the stream."); + Action compl = + bytes => { + if (bytes.LongLength != llen) { + var msg = "The payload data of a frame could not be read."; + throw new WebSocketException (msg); + } - frame._payloadData = new PayloadData (bytes, llen); - completed (frame); - }; + frame._payloadData = new PayloadData (bytes, llen); + completed (frame); + }; if (frame._payloadLength < 127) { stream.ReadBytesAsync ((int) len, compl, error); From 633f13ed59099e3c946216f2c843090c00c62c84 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 19 Aug 2019 20:57:22 +0900 Subject: [PATCH 2568/6294] [Modify] Polish it --- websocket-sharp/WebSocketFrame.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index 6420aabfe..bda2d3be5 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -445,8 +445,10 @@ private static string print (WebSocketFrame frame) private static WebSocketFrame processHeader (byte[] header) { - if (header.Length != 2) - throw new WebSocketException ("The header of a frame cannot be read from the stream."); + if (header.Length != 2) { + var msg = "The header part of a frame could not be read."; + throw new WebSocketException (msg); + } // FIN var fin = (header[0] & 0x80) == 0x80 ? Fin.Final : Fin.More; From c186c4ab56db680661a94230d34542717875a68b Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 20 Aug 2019 20:54:56 +0900 Subject: [PATCH 2569/6294] [Modify] Polish it --- websocket-sharp/WebSocketFrame.cs | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index bda2d3be5..57bd838e1 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -471,18 +471,25 @@ private static WebSocketFrame processHeader (byte[] header) // Payload Length var payloadLen = (byte) (header[1] & 0x7f); - var err = !opcode.IsSupported () - ? "An unsupported opcode." - : !opcode.IsData () && rsv1 == Rsv.On - ? "A non data frame is compressed." - : opcode.IsControl () && fin == Fin.More - ? "A control frame is fragmented." - : opcode.IsControl () && payloadLen > 125 - ? "A control frame has a long payload length." - : null; - - if (err != null) - throw new WebSocketException (CloseStatusCode.ProtocolError, err); + if (!opcode.IsSupported ()) { + var msg = "An unsupported opcode."; + throw new WebSocketException (CloseStatusCode.ProtocolError, msg); + } + + if (!opcode.IsData () && rsv1 == Rsv.On) { + var msg = "A non data frame is compressed."; + throw new WebSocketException (CloseStatusCode.ProtocolError, msg); + } + + if (opcode.IsControl () && fin == Fin.More) { + var msg = "A control frame is fragmented."; + throw new WebSocketException (CloseStatusCode.ProtocolError, msg); + } + + if (opcode.IsControl () && payloadLen > 125) { + var msg = "A control frame has too long payload length."; + throw new WebSocketException (CloseStatusCode.ProtocolError, msg); + } var frame = new WebSocketFrame (); frame._fin = fin; From 39ce4997bddde8a4e35984603f6c93af6fe36762 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 21 Aug 2019 21:31:23 +0900 Subject: [PATCH 2570/6294] [Modify] Polish it --- websocket-sharp/WebSocketFrame.cs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index 57bd838e1..9a71a76fd 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -481,14 +481,16 @@ private static WebSocketFrame processHeader (byte[] header) throw new WebSocketException (CloseStatusCode.ProtocolError, msg); } - if (opcode.IsControl () && fin == Fin.More) { - var msg = "A control frame is fragmented."; - throw new WebSocketException (CloseStatusCode.ProtocolError, msg); - } + if (opcode.IsControl ()) { + if (fin == Fin.More) { + var msg = "A control frame is fragmented."; + throw new WebSocketException (CloseStatusCode.ProtocolError, msg); + } - if (opcode.IsControl () && payloadLen > 125) { - var msg = "A control frame has too long payload length."; - throw new WebSocketException (CloseStatusCode.ProtocolError, msg); + if (payloadLen > 125) { + var msg = "A control frame has too long payload length."; + throw new WebSocketException (CloseStatusCode.ProtocolError, msg); + } } var frame = new WebSocketFrame (); From c3ca92d7518ca3f52726a68a3b1ff5b37991b4bb Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 22 Aug 2019 21:15:25 +0900 Subject: [PATCH 2571/6294] [Modify] Polish it --- websocket-sharp/WebSocketFrame.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index 9a71a76fd..a3c7ac90d 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -472,7 +472,7 @@ private static WebSocketFrame processHeader (byte[] header) var payloadLen = (byte) (header[1] & 0x7f); if (!opcode.IsSupported ()) { - var msg = "An unsupported opcode."; + var msg = "A frame has an unsupported opcode."; throw new WebSocketException (CloseStatusCode.ProtocolError, msg); } From 0274f23b176396c85231351be9bd27fa439c2c39 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 23 Aug 2019 21:40:45 +0900 Subject: [PATCH 2572/6294] [Modify] Polish it --- websocket-sharp/WebSocketFrame.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index a3c7ac90d..4dc91f4c7 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -630,7 +630,7 @@ private static WebSocketFrame readPayloadData ( } if (len > PayloadData.MaxLength) { - var msg = "A frame has too long payload data length."; + var msg = "A frame has too long payload length."; throw new WebSocketException (CloseStatusCode.TooBig, msg); } From 2dccdc7b68496f2aa5df5ef73a0b204a86cb8541 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 23 Aug 2019 21:42:50 +0900 Subject: [PATCH 2573/6294] [Modify] Polish it --- websocket-sharp/WebSocketFrame.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index 4dc91f4c7..6f4223aa5 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -664,7 +664,7 @@ Action error } if (len > PayloadData.MaxLength) { - var msg = "A frame has too long payload data length."; + var msg = "A frame has too long payload length."; throw new WebSocketException (CloseStatusCode.TooBig, msg); } From 7ae2132dc54b902c7ac85613e171ea3fc0a9aeb0 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 24 Aug 2019 22:21:29 +0900 Subject: [PATCH 2574/6294] [Modify] Polish it --- websocket-sharp/WebSocketFrame.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index 6f4223aa5..fd2e3bad4 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -573,13 +573,14 @@ private static WebSocketFrame readMaskingKey ( Stream stream, WebSocketFrame frame ) { - var len = frame.IsMasked ? 4 : 0; - if (len == 0) { + if (!frame.IsMasked) { frame._maskingKey = WebSocket.EmptyBytes; return frame; } + var len = 4; var bytes = stream.ReadBytes (len); + if (bytes.Length != len) { var msg = "The masking key of a frame could not be read."; throw new WebSocketException (msg); From 14f579afc8a3b642d7fdccb5d7abcb655ea80b3d Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 25 Aug 2019 22:05:12 +0900 Subject: [PATCH 2575/6294] [Modify] Polish it --- websocket-sharp/WebSocketFrame.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index fd2e3bad4..962a589cf 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -597,14 +597,15 @@ private static void readMaskingKeyAsync ( Action error ) { - var len = frame.IsMasked ? 4 : 0; - if (len == 0) { + if (!frame.IsMasked) { frame._maskingKey = WebSocket.EmptyBytes; completed (frame); return; } + var len = 4; + stream.ReadBytesAsync ( len, bytes => { From f89ec52bbaedb91e229bc36360f4765cf1af7d49 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 26 Aug 2019 21:08:33 +0900 Subject: [PATCH 2576/6294] [Modify] Polish it --- websocket-sharp/WebSocketFrame.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index 962a589cf..afa1371d6 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -626,16 +626,16 @@ private static WebSocketFrame readPayloadData ( ) { var len = frame.FullPayloadLength; - if (len == 0) { - frame._payloadData = PayloadData.Empty; - return frame; - } - if (len > PayloadData.MaxLength) { var msg = "A frame has too long payload length."; throw new WebSocketException (CloseStatusCode.TooBig, msg); } + if (len == 0) { + frame._payloadData = PayloadData.Empty; + return frame; + } + var llen = (long) len; var bytes = frame._payloadLength < 127 ? stream.ReadBytes ((int) len) From dbffb8bd80d5baa20a4e10536d3a4e2615ea763a Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 27 Aug 2019 21:16:04 +0900 Subject: [PATCH 2577/6294] [Modify] Polish it --- websocket-sharp/WebSocketFrame.cs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index afa1371d6..ba578df61 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -625,28 +625,28 @@ private static WebSocketFrame readPayloadData ( Stream stream, WebSocketFrame frame ) { - var len = frame.FullPayloadLength; - if (len > PayloadData.MaxLength) { + var fullLen = frame.FullPayloadLength; + if (fullLen > PayloadData.MaxLength) { var msg = "A frame has too long payload length."; throw new WebSocketException (CloseStatusCode.TooBig, msg); } - if (len == 0) { + if (fullLen == 0) { frame._payloadData = PayloadData.Empty; return frame; } - var llen = (long) len; + var len = (long) fullLen; var bytes = frame._payloadLength < 127 - ? stream.ReadBytes ((int) len) - : stream.ReadBytes (llen, 1024); + ? stream.ReadBytes ((int) fullLen) + : stream.ReadBytes (len, 1024); - if (bytes.LongLength != llen) { + if (bytes.LongLength != len) { var msg = "The payload data of a frame could not be read."; throw new WebSocketException (msg); } - frame._payloadData = new PayloadData (bytes, llen); + frame._payloadData = new PayloadData (bytes, len); return frame; } From deb476f73351b227f3837e6997d0352133706719 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 28 Aug 2019 22:20:08 +0900 Subject: [PATCH 2578/6294] [Modify] Rename it --- websocket-sharp/WebSocketFrame.cs | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index ba578df61..9653c05be 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -148,23 +148,23 @@ bool mask #region Internal Properties - internal int ExtendedPayloadLengthCount { + internal ulong ExactPayloadLength { get { return _payloadLength < 126 - ? 0 + ? _payloadLength : _payloadLength == 126 - ? 2 - : 8; + ? _extPayloadLength.ToUInt16 (ByteOrder.Big) + : _extPayloadLength.ToUInt64 (ByteOrder.Big); } } - internal ulong FullPayloadLength { + internal int ExtendedPayloadLengthCount { get { return _payloadLength < 126 - ? _payloadLength + ? 0 : _payloadLength == 126 - ? _extPayloadLength.ToUInt16 (ByteOrder.Big) - : _extPayloadLength.ToUInt64 (ByteOrder.Big); + ? 2 + : 8; } } @@ -398,7 +398,7 @@ private static string print (WebSocketFrame frame) // Extended Payload Length var extPayloadLen = payloadLen > 125 - ? frame.FullPayloadLength.ToString () + ? frame.ExactPayloadLength.ToString () : String.Empty; // Masking Key @@ -625,7 +625,7 @@ private static WebSocketFrame readPayloadData ( Stream stream, WebSocketFrame frame ) { - var fullLen = frame.FullPayloadLength; + var fullLen = frame.ExactPayloadLength; if (fullLen > PayloadData.MaxLength) { var msg = "A frame has too long payload length."; throw new WebSocketException (CloseStatusCode.TooBig, msg); @@ -657,7 +657,7 @@ private static void readPayloadDataAsync ( Action error ) { - var len = frame.FullPayloadLength; + var len = frame.ExactPayloadLength; if (len == 0) { frame._payloadData = PayloadData.Empty; completed (frame); From 58b9cb12f4ee3db6b228c878538ac054315c9d21 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 29 Aug 2019 21:35:42 +0900 Subject: [PATCH 2579/6294] [Modify] Polish it --- websocket-sharp/WebSocketFrame.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index 9653c05be..15d9be071 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -625,20 +625,20 @@ private static WebSocketFrame readPayloadData ( Stream stream, WebSocketFrame frame ) { - var fullLen = frame.ExactPayloadLength; - if (fullLen > PayloadData.MaxLength) { + var exactLen = frame.ExactPayloadLength; + if (exactLen > PayloadData.MaxLength) { var msg = "A frame has too long payload length."; throw new WebSocketException (CloseStatusCode.TooBig, msg); } - if (fullLen == 0) { + if (exactLen == 0) { frame._payloadData = PayloadData.Empty; return frame; } - var len = (long) fullLen; + var len = (long) exactLen; var bytes = frame._payloadLength < 127 - ? stream.ReadBytes ((int) fullLen) + ? stream.ReadBytes ((int) exactLen) : stream.ReadBytes (len, 1024); if (bytes.LongLength != len) { From 3944137417587c4999e3a644836ac65b8c052867 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 30 Aug 2019 19:35:24 +0900 Subject: [PATCH 2580/6294] [Modify] Polish it --- websocket-sharp/WebSocketFrame.cs | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index 15d9be071..9f3ec5953 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -657,37 +657,37 @@ private static void readPayloadDataAsync ( Action error ) { - var len = frame.ExactPayloadLength; - if (len == 0) { + var exactLen = frame.ExactPayloadLength; + if (exactLen > PayloadData.MaxLength) { + var msg = "A frame has too long payload length."; + throw new WebSocketException (CloseStatusCode.TooBig, msg); + } + + if (exactLen == 0) { frame._payloadData = PayloadData.Empty; completed (frame); return; } - if (len > PayloadData.MaxLength) { - var msg = "A frame has too long payload length."; - throw new WebSocketException (CloseStatusCode.TooBig, msg); - } - - var llen = (long) len; - Action compl = + var len = (long) exactLen; + Action comp = bytes => { - if (bytes.LongLength != llen) { + if (bytes.LongLength != len) { var msg = "The payload data of a frame could not be read."; throw new WebSocketException (msg); } - frame._payloadData = new PayloadData (bytes, llen); + frame._payloadData = new PayloadData (bytes, len); completed (frame); }; if (frame._payloadLength < 127) { - stream.ReadBytesAsync ((int) len, compl, error); + stream.ReadBytesAsync ((int) exactLen, comp, error); return; } - stream.ReadBytesAsync (llen, 1024, compl, error); + stream.ReadBytesAsync (len, 1024, comp, error); } private static string utf8Decode (byte[] bytes) From a2c8fe8911d0fbcfe42ebbb78cf5dc00286bb269 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 31 Aug 2019 21:23:43 +0900 Subject: [PATCH 2581/6294] [Modify] Rename it --- websocket-sharp/WebSocketFrame.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index 9f3ec5953..8eafa2e72 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -158,7 +158,7 @@ internal ulong ExactPayloadLength { } } - internal int ExtendedPayloadLengthCount { + internal int ExtendedPayloadLengthWidth { get { return _payloadLength < 126 ? 0 @@ -509,7 +509,7 @@ private static WebSocketFrame readExtendedPayloadLength ( Stream stream, WebSocketFrame frame ) { - var len = frame.ExtendedPayloadLengthCount; + var len = frame.ExtendedPayloadLengthWidth; if (len == 0) { frame._extPayloadLength = WebSocket.EmptyBytes; return frame; @@ -532,7 +532,7 @@ private static void readExtendedPayloadLengthAsync ( Action error ) { - var len = frame.ExtendedPayloadLengthCount; + var len = frame.ExtendedPayloadLengthWidth; if (len == 0) { frame._extPayloadLength = WebSocket.EmptyBytes; completed (frame); From 13f7c51c0a2773e02e8a4fea59a8eebaa9bdd500 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 1 Sep 2019 22:22:20 +0900 Subject: [PATCH 2582/6294] [Modify] Polish it --- websocket-sharp/WebSocketFrame.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index 8eafa2e72..32f4cfdee 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -353,7 +353,11 @@ private static string dump (WebSocketFrame frame) var headerFmt = String.Format (@" {0} 01234567 89ABCDEF 01234567 89ABCDEF {0}+--------+--------+--------+--------+\n", spFmt); - var lineFmt = String.Format ("{0}|{{1,8}} {{2,8}} {{3,8}} {{4,8}}|\n", cntFmt); + + var lineFmt = String.Format ( + "{0}|{{1,8}} {{2,8}} {{3,8}} {{4,8}}|\n", cntFmt + ); + var footerFmt = String.Format ("{0}+--------+--------+--------+--------+", spFmt); var output = new StringBuilder (64); From ba851e4d5e68155862c933c64d3aae45e3c30ecc Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 2 Sep 2019 21:10:26 +0900 Subject: [PATCH 2583/6294] [Modify] Polish it --- websocket-sharp/WebSocketFrame.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index 32f4cfdee..90aec83b1 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -358,7 +358,9 @@ private static string dump (WebSocketFrame frame) "{0}|{{1,8}} {{2,8}} {{3,8}} {{4,8}}|\n", cntFmt ); - var footerFmt = String.Format ("{0}+--------+--------+--------+--------+", spFmt); + var footerFmt = String.Format ( + "{0}+--------+--------+--------+--------+", spFmt + ); var output = new StringBuilder (64); Func> linePrinter = () => { From b940336a89d967a51e9609fc55b42e8568f0c215 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 2 Sep 2019 21:21:09 +0900 Subject: [PATCH 2584/6294] [Modify] Polish it --- websocket-sharp/WebSocketFrame.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index 90aec83b1..c66bceac4 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -350,9 +350,13 @@ private static string dump (WebSocketFrame frame) } var spFmt = String.Format ("{{0,{0}}}", cntDigit); - var headerFmt = String.Format (@" + + var headerFmt = String.Format ( + @" {0} 01234567 89ABCDEF 01234567 89ABCDEF -{0}+--------+--------+--------+--------+\n", spFmt); +{0}+--------+--------+--------+--------+\n", + spFmt + ); var lineFmt = String.Format ( "{0}|{{1,8}} {{2,8}} {{3,8}} {{4,8}}|\n", cntFmt From c0fe538d0ff87bc6f2309b88ade87f76784e2b45 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 3 Sep 2019 19:41:57 +0900 Subject: [PATCH 2585/6294] [Modify] Polish it --- websocket-sharp/WebSocketFrame.cs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index c66bceac4..3b30f231e 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -367,11 +367,17 @@ private static string dump (WebSocketFrame frame) ); var output = new StringBuilder (64); - Func> linePrinter = () => { - long lineCnt = 0; - return (arg1, arg2, arg3, arg4) => - output.AppendFormat (lineFmt, ++lineCnt, arg1, arg2, arg3, arg4); - }; + + Func> linePrinter = + () => { + long lineCnt = 0; + return (arg1, arg2, arg3, arg4) => { + output.AppendFormat ( + lineFmt, ++lineCnt, arg1, arg2, arg3, arg4 + ); + }; + }; + var printLine = linePrinter (); output.AppendFormat (headerFmt, String.Empty); From 4033c0bbcdecaeb4792de4980a2e4a86b465d8e9 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 3 Sep 2019 19:50:16 +0900 Subject: [PATCH 2586/6294] [Modify] Polish it --- websocket-sharp/WebSocketFrame.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index 3b30f231e..a706a77a3 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -385,12 +385,14 @@ private static string dump (WebSocketFrame frame) var bytes = frame.ToArray (); for (long i = 0; i <= cnt; i++) { var j = i * 4; + if (i < cnt) { printLine ( Convert.ToString (bytes[j], 2).PadLeft (8, '0'), Convert.ToString (bytes[j + 1], 2).PadLeft (8, '0'), Convert.ToString (bytes[j + 2], 2).PadLeft (8, '0'), - Convert.ToString (bytes[j + 3], 2).PadLeft (8, '0')); + Convert.ToString (bytes[j + 3], 2).PadLeft (8, '0') + ); continue; } From 739d880d7564150b1bf420266735fea271ed8993 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 4 Sep 2019 19:30:30 +0900 Subject: [PATCH 2587/6294] [Modify] Polish it --- websocket-sharp/WebSocketFrame.cs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index a706a77a3..d9576126d 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -397,12 +397,18 @@ private static string dump (WebSocketFrame frame) continue; } - if (rem > 0) + if (rem > 0) { printLine ( Convert.ToString (bytes[j], 2).PadLeft (8, '0'), - rem >= 2 ? Convert.ToString (bytes[j + 1], 2).PadLeft (8, '0') : String.Empty, - rem == 3 ? Convert.ToString (bytes[j + 2], 2).PadLeft (8, '0') : String.Empty, - String.Empty); + rem >= 2 + ? Convert.ToString (bytes[j + 1], 2).PadLeft (8, '0') + : String.Empty, + rem == 3 + ? Convert.ToString (bytes[j + 2], 2).PadLeft (8, '0') + : String.Empty, + String.Empty + ); + } } output.AppendFormat (footerFmt, String.Empty); From 67574e03ecda6236d8c2e2d37d6231c1c1d4edc0 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 4 Sep 2019 19:32:48 +0900 Subject: [PATCH 2588/6294] [Modify] Polish it --- websocket-sharp/WebSocketFrame.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index d9576126d..8f7337878 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -379,10 +379,10 @@ private static string dump (WebSocketFrame frame) }; var printLine = linePrinter (); + var bytes = frame.ToArray (); output.AppendFormat (headerFmt, String.Empty); - var bytes = frame.ToArray (); for (long i = 0; i <= cnt; i++) { var j = i * 4; From fe7e227ecf13ddc1cbce6d400dc597c17481f84a Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 5 Sep 2019 19:51:53 +0900 Subject: [PATCH 2589/6294] [Modify] Polish it --- websocket-sharp/WebSocketFrame.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index 8f7337878..d56646045 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -366,13 +366,13 @@ private static string dump (WebSocketFrame frame) "{0}+--------+--------+--------+--------+", spFmt ); - var output = new StringBuilder (64); + var buff = new StringBuilder (64); Func> linePrinter = () => { long lineCnt = 0; return (arg1, arg2, arg3, arg4) => { - output.AppendFormat ( + buff.AppendFormat ( lineFmt, ++lineCnt, arg1, arg2, arg3, arg4 ); }; @@ -381,7 +381,7 @@ private static string dump (WebSocketFrame frame) var printLine = linePrinter (); var bytes = frame.ToArray (); - output.AppendFormat (headerFmt, String.Empty); + buff.AppendFormat (headerFmt, String.Empty); for (long i = 0; i <= cnt; i++) { var j = i * 4; @@ -411,8 +411,8 @@ private static string dump (WebSocketFrame frame) } } - output.AppendFormat (footerFmt, String.Empty); - return output.ToString (); + buff.AppendFormat (footerFmt, String.Empty); + return buff.ToString (); } private static string print (WebSocketFrame frame) From 4bc45632b937e721c802012ba65d3e1fac46be2e Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 6 Sep 2019 21:46:32 +0900 Subject: [PATCH 2590/6294] [Modify] Edit it --- websocket-sharp/WebSocketFrame.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index d56646045..b439ca468 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -61,11 +61,12 @@ internal class WebSocketFrame : IEnumerable #region Internal Fields /// - /// Represents the ping frame without the payload data as an array of . + /// Represents the ping frame without the payload data as an array of + /// . /// /// - /// The value of this field is created from a non masked frame, so it can only be used to - /// send a ping from a server. + /// The value of this field is created from a non masked ping frame, + /// so it can only be used to send a ping from the server. /// internal static readonly byte[] EmptyPingBytes; From 4c82648c97fe95ad867a34c53ef838805838eff4 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 7 Sep 2019 21:48:25 +0900 Subject: [PATCH 2591/6294] [Modify] 2019 --- websocket-sharp/WebSocketFrame.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index b439ca468..ba0de3cd8 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -4,7 +4,7 @@ * * The MIT License * - * Copyright (c) 2012-2015 sta.blockhead + * Copyright (c) 2012-2019 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From 7dae8486adfc8bd9d7b045865b023256f0953661 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 8 Sep 2019 22:11:09 +0900 Subject: [PATCH 2592/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index cacef8451..ee759db00 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1791,8 +1791,14 @@ public static T[] SubArray (this T[] array, long startIndex, long length) /// public static void Times (this int n, Action action) { - if (n > 0 && action != null) - ((ulong) n).times (action); + if (n <= 0) + return; + + if (action == null) + return; + + for (int i = 0; i < n; i++) + action (); } /// From cb9d0254b539ba8104232d051df8a31334ba7799 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 9 Sep 2019 22:48:21 +0900 Subject: [PATCH 2593/6294] [Modify] Edit it --- websocket-sharp/Ext.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index ee759db00..403b0f930 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1781,13 +1781,14 @@ public static T[] SubArray (this T[] array, long startIndex, long length) } /// - /// Executes the specified delegate times. + /// Executes the specified delegate + /// times. /// /// - /// An is the number of times to execute. + /// An that specifies the number of times to execute. /// /// - /// An delegate that references the method(s) to execute. + /// An delegate to execute. /// public static void Times (this int n, Action action) { From fa4bcaa0baf87afc6e250bd1439221f6c8965e9f Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 10 Sep 2019 21:31:28 +0900 Subject: [PATCH 2594/6294] [Modify] Edit it --- websocket-sharp/Ext.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 403b0f930..86db7b966 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1781,8 +1781,7 @@ public static T[] SubArray (this T[] array, long startIndex, long length) } /// - /// Executes the specified delegate - /// times. + /// Executes the specified delegate the specified times. /// /// /// An that specifies the number of times to execute. From 874e64d8862d116f4186bdce0bd2aa947173a550 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 10 Sep 2019 21:36:28 +0900 Subject: [PATCH 2595/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 86db7b966..ac9457242 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1812,8 +1812,14 @@ public static void Times (this int n, Action action) /// public static void Times (this long n, Action action) { - if (n > 0 && action != null) - ((ulong) n).times (action); + if (n <= 0) + return; + + if (action == null) + return; + + for (long i = 0; i < n; i++) + action (); } /// From e147aff46a9a660971a949bce924ae50fab4eafd Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 11 Sep 2019 22:05:41 +0900 Subject: [PATCH 2596/6294] [Modify] Edit it --- websocket-sharp/Ext.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index ac9457242..bc3a474f2 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1802,13 +1802,13 @@ public static void Times (this int n, Action action) } /// - /// Executes the specified delegate times. + /// Executes the specified delegate the specified times. /// /// - /// A is the number of times to execute. + /// A that specifies the number of times to execute. /// /// - /// An delegate that references the method(s) to execute. + /// An delegate to execute. /// public static void Times (this long n, Action action) { From c4cb334b93848681f1204d3e8bfb8a91811552a4 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 11 Sep 2019 22:08:53 +0900 Subject: [PATCH 2597/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index bc3a474f2..0318a3872 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1833,8 +1833,14 @@ public static void Times (this long n, Action action) /// public static void Times (this uint n, Action action) { - if (n > 0 && action != null) - ((ulong) n).times (action); + if (n <= 0) + return; + + if (action == null) + return; + + for (uint i = 0; i < n; i++) + action (); } /// From bdb759c4e12f38cc44b3f2b162f197f79f692944 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 12 Sep 2019 20:07:23 +0900 Subject: [PATCH 2598/6294] [Modify] Edit it --- websocket-sharp/Ext.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 0318a3872..a3eb501d7 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1823,13 +1823,13 @@ public static void Times (this long n, Action action) } /// - /// Executes the specified delegate times. + /// Executes the specified delegate the specified times. /// /// - /// A is the number of times to execute. + /// A that specifies the number of times to execute. /// /// - /// An delegate that references the method(s) to execute. + /// An delegate to execute. /// public static void Times (this uint n, Action action) { From 9c47c1e861798e1b80e987a23f75340781dddcf3 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 12 Sep 2019 20:11:01 +0900 Subject: [PATCH 2599/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index a3eb501d7..4cff4d189 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1854,8 +1854,14 @@ public static void Times (this uint n, Action action) /// public static void Times (this ulong n, Action action) { - if (n > 0 && action != null) - n.times (action); + if (n <= 0) + return; + + if (action == null) + return; + + for (ulong i = 0; i < n; i++) + action (); } /// From f90066d0002e1b4aa56c5c21466b59b953b75ade Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 13 Sep 2019 19:51:49 +0900 Subject: [PATCH 2600/6294] [Modify] Edit it --- websocket-sharp/Ext.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 4cff4d189..4c6a5839d 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1844,13 +1844,13 @@ public static void Times (this uint n, Action action) } /// - /// Executes the specified delegate times. + /// Executes the specified delegate the specified times. /// /// - /// A is the number of times to execute. + /// A that specifies the number of times to execute. /// /// - /// An delegate that references the method(s) to execute. + /// An delegate to execute. /// public static void Times (this ulong n, Action action) { From 883e09756ddd26f628abab94d3d335aaf4884c42 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 13 Sep 2019 19:53:59 +0900 Subject: [PATCH 2601/6294] [Modify] Remove it --- websocket-sharp/Ext.cs | 6 ------ 1 file changed, 6 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 4c6a5839d..9238c96f1 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -160,12 +160,6 @@ private static bool isHttpMethod10 (this string value) || value == "POST"; } - private static void times (this ulong n, Action action) - { - for (ulong i = 0; i < n; i++) - action (); - } - #endregion #region Internal Methods From 5073993dd46c8aeb27eb61af4a1d49b1567b58b8 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 14 Sep 2019 22:00:06 +0900 Subject: [PATCH 2602/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 9238c96f1..37c266149 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1827,7 +1827,7 @@ public static void Times (this long n, Action action) /// public static void Times (this uint n, Action action) { - if (n <= 0) + if (n == 0) return; if (action == null) From 77d67feaf9dc7bc2ce8427ca77e84b436189e436 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 14 Sep 2019 22:01:18 +0900 Subject: [PATCH 2603/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 37c266149..9206f32a0 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1848,7 +1848,7 @@ public static void Times (this uint n, Action action) /// public static void Times (this ulong n, Action action) { - if (n <= 0) + if (n == 0) return; if (action == null) From 072e7f9a823de1a8f95b530d48636e186a86add5 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 15 Sep 2019 22:01:23 +0900 Subject: [PATCH 2604/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 9206f32a0..b4586bc60 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1871,9 +1871,14 @@ public static void Times (this ulong n, Action action) /// public static void Times (this int n, Action action) { - if (n > 0 && action != null) - for (int i = 0; i < n; i++) - action (i); + if (n <= 0) + return; + + if (action == null) + return; + + for (int i = 0; i < n; i++) + action (i); } /// From 7a0b0db285934bae528a27f462ae311336d9d16b Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 16 Sep 2019 22:11:37 +0900 Subject: [PATCH 2605/6294] [Modify] Edit it --- websocket-sharp/Ext.cs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index b4586bc60..1604ce6b3 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1859,15 +1859,18 @@ public static void Times (this ulong n, Action action) } /// - /// Executes the specified Action<int> delegate times. + /// Executes the specified delegate times. /// /// - /// An is the number of times to execute. + /// An that specifies the number of times to execute. /// /// - /// An Action<int> delegate that references the method(s) to execute. - /// An parameter to pass to the method(s) is the zero-based count of - /// iteration. + /// + /// An Action<int> delegate to execute. + /// + /// + /// The parameter is the zero-based count of iteration. + /// /// public static void Times (this int n, Action action) { From 2bde8d4d68e56e45b13889e84bcd67c8a7762be4 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 17 Sep 2019 19:39:46 +0900 Subject: [PATCH 2606/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 1604ce6b3..86e9e76e9 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1897,9 +1897,14 @@ public static void Times (this int n, Action action) /// public static void Times (this long n, Action action) { - if (n > 0 && action != null) - for (long i = 0; i < n; i++) - action (i); + if (n <= 0) + return; + + if (action == null) + return; + + for (long i = 0; i < n; i++) + action (i); } /// From 7e86a8d77372c4c80d835c70e891b074de2d1c4d Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 18 Sep 2019 19:38:23 +0900 Subject: [PATCH 2607/6294] [Modify] Edit it --- websocket-sharp/Ext.cs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 86e9e76e9..79ec80f99 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1885,15 +1885,18 @@ public static void Times (this int n, Action action) } /// - /// Executes the specified Action<long> delegate times. + /// Executes the specified delegate times. /// /// - /// A is the number of times to execute. + /// A that specifies the number of times to execute. /// /// - /// An Action<long> delegate that references the method(s) to execute. - /// A parameter to pass to the method(s) is the zero-based count of - /// iteration. + /// + /// An Action<long> delegate to execute. + /// + /// + /// The parameter is the zero-based count of iteration. + /// /// public static void Times (this long n, Action action) { From cd890d2eb4771b759c20345531f6bbf99afe9df6 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 19 Sep 2019 21:06:38 +0900 Subject: [PATCH 2608/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 79ec80f99..dddbc2991 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1923,9 +1923,14 @@ public static void Times (this long n, Action action) /// public static void Times (this uint n, Action action) { - if (n > 0 && action != null) - for (uint i = 0; i < n; i++) - action (i); + if (n == 0) + return; + + if (action == null) + return; + + for (uint i = 0; i < n; i++) + action (i); } /// From b03ca4f56e175b3052e46c357212c5f7556abe81 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 19 Sep 2019 21:12:39 +0900 Subject: [PATCH 2609/6294] [Modify] Edit it --- websocket-sharp/Ext.cs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index dddbc2991..6bf75bad0 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1911,15 +1911,18 @@ public static void Times (this long n, Action action) } /// - /// Executes the specified Action<uint> delegate times. + /// Executes the specified delegate times. /// /// - /// A is the number of times to execute. + /// A that specifies the number of times to execute. /// /// - /// An Action<uint> delegate that references the method(s) to execute. - /// A parameter to pass to the method(s) is the zero-based count of - /// iteration. + /// + /// An Action<uint> delegate to execute. + /// + /// + /// The parameter is the zero-based count of iteration. + /// /// public static void Times (this uint n, Action action) { From 1229f2912292b90df8cd2f8832f696f9ca0bf847 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 20 Sep 2019 21:54:21 +0900 Subject: [PATCH 2610/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 6bf75bad0..1098c4f72 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1949,9 +1949,14 @@ public static void Times (this uint n, Action action) /// public static void Times (this ulong n, Action action) { - if (n > 0 && action != null) - for (ulong i = 0; i < n; i++) - action (i); + if (n == 0) + return; + + if (action == null) + return; + + for (ulong i = 0; i < n; i++) + action (i); } /// From dba8b2325c4d62156234ef641e287d7362fddc34 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 21 Sep 2019 20:28:18 +0900 Subject: [PATCH 2611/6294] [Modify] Edit it --- websocket-sharp/Ext.cs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 1098c4f72..fc03f3ac0 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1937,15 +1937,18 @@ public static void Times (this uint n, Action action) } /// - /// Executes the specified Action<ulong> delegate times. + /// Executes the specified delegate times. /// /// - /// A is the number of times to execute. + /// A that specifies the number of times to execute. /// /// - /// An Action<ulong> delegate that references the method(s) to execute. - /// A parameter to pass to this method(s) is the zero-based count of - /// iteration. + /// + /// An Action<ulong> delegate to execute. + /// + /// + /// The parameter is the zero-based count of iteration. + /// /// public static void Times (this ulong n, Action action) { From c5c0bf030f57be23400c79b5af79b11442b519e2 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 22 Sep 2019 21:14:37 +0900 Subject: [PATCH 2612/6294] [Modify] Edit it --- websocket-sharp/Ext.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index fc03f3ac0..8c181f25f 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1775,7 +1775,7 @@ public static T[] SubArray (this T[] array, long startIndex, long length) } /// - /// Executes the specified delegate the specified times. + /// Executes the specified delegate times. /// /// /// An that specifies the number of times to execute. From 4aed0c4a518ae4f6cf7b31aa1d94b1aa08de8e65 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 22 Sep 2019 21:16:16 +0900 Subject: [PATCH 2613/6294] [Modify] Edit it --- websocket-sharp/Ext.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 8c181f25f..f9c5e44a5 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1796,7 +1796,7 @@ public static void Times (this int n, Action action) } /// - /// Executes the specified delegate the specified times. + /// Executes the specified delegate times. /// /// /// A that specifies the number of times to execute. From c19c6f02194120e900ec835fbf9273b70297e6d6 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 23 Sep 2019 21:32:09 +0900 Subject: [PATCH 2614/6294] [Modify] Edit it --- websocket-sharp/Ext.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index f9c5e44a5..0f41829d0 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1817,7 +1817,7 @@ public static void Times (this long n, Action action) } /// - /// Executes the specified delegate the specified times. + /// Executes the specified delegate times. /// /// /// A that specifies the number of times to execute. From f44a6ee16219dd1ad077711f688936a3a304dd7c Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 24 Sep 2019 19:41:00 +0900 Subject: [PATCH 2615/6294] [Modify] Edit it --- websocket-sharp/Ext.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 0f41829d0..5c4c74eb2 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1838,7 +1838,7 @@ public static void Times (this uint n, Action action) } /// - /// Executes the specified delegate the specified times. + /// Executes the specified delegate times. /// /// /// A that specifies the number of times to execute. From 84782afb7e8c2f80f0242ce99f14aab6fb33252c Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 25 Sep 2019 19:44:44 +0900 Subject: [PATCH 2616/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 5c4c74eb2..90ee009d6 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1995,28 +1995,28 @@ public static T To (this byte[] source, ByteOrder sourceOrder) return default (T); var type = typeof (T); - var buff = source.ToHostOrder (sourceOrder); + var val = source.ToHostOrder (sourceOrder); return type == typeof (Boolean) - ? (T)(object) BitConverter.ToBoolean (buff, 0) + ? (T)(object) BitConverter.ToBoolean (val, 0) : type == typeof (Char) - ? (T)(object) BitConverter.ToChar (buff, 0) + ? (T)(object) BitConverter.ToChar (val, 0) : type == typeof (Double) - ? (T)(object) BitConverter.ToDouble (buff, 0) + ? (T)(object) BitConverter.ToDouble (val, 0) : type == typeof (Int16) - ? (T)(object) BitConverter.ToInt16 (buff, 0) + ? (T)(object) BitConverter.ToInt16 (val, 0) : type == typeof (Int32) - ? (T)(object) BitConverter.ToInt32 (buff, 0) + ? (T)(object) BitConverter.ToInt32 (val, 0) : type == typeof (Int64) - ? (T)(object) BitConverter.ToInt64 (buff, 0) + ? (T)(object) BitConverter.ToInt64 (val, 0) : type == typeof (Single) - ? (T)(object) BitConverter.ToSingle (buff, 0) + ? (T)(object) BitConverter.ToSingle (val, 0) : type == typeof (UInt16) - ? (T)(object) BitConverter.ToUInt16 (buff, 0) + ? (T)(object) BitConverter.ToUInt16 (val, 0) : type == typeof (UInt32) - ? (T)(object) BitConverter.ToUInt32 (buff, 0) + ? (T)(object) BitConverter.ToUInt32 (val, 0) : type == typeof (UInt64) - ? (T)(object) BitConverter.ToUInt64 (buff, 0) + ? (T)(object) BitConverter.ToUInt64 (val, 0) : default (T); } From 82d27b0fc1b09902c17a0a0c7bb77a9b0016ca98 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 26 Sep 2019 20:06:26 +0900 Subject: [PATCH 2617/6294] [Modify] Edit it --- websocket-sharp/Ext.cs | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 90ee009d6..f3c2d71f1 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1963,24 +1963,39 @@ public static void Times (this ulong n, Action action) } /// - /// Converts the specified array of to the specified type data. + /// Converts the specified array of to the specified + /// type data. /// /// - /// A T converted from , or a default value of - /// T if is an empty array of or - /// if the type of T isn't , , , - /// , , , , - /// , , or . + /// + /// A T converted from . + /// + /// + /// A default value of T if is an empty array of + /// or if the type of T is not , + /// , , , + /// , , , + /// , , or . + /// /// /// /// An array of to convert. /// /// - /// One of the enum values, specifies the byte order of - /// . + /// + /// One of the enum values. + /// + /// + /// It specifies the byte order of . + /// /// /// - /// The type of the return. The T must be a value type. + /// + /// The type of the return. + /// + /// + /// It must be a value type. + /// /// /// /// is . From 079c09ccb644726dd7166b7fbc34cfc875a77e03 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 27 Sep 2019 20:30:54 +0900 Subject: [PATCH 2618/6294] [Modify] Edit it --- websocket-sharp/Ext.cs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index f3c2d71f1..4e94ebf72 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1964,18 +1964,14 @@ public static void Times (this ulong n, Action action) /// /// Converts the specified array of to the specified - /// type data. + /// type value. /// /// /// /// A T converted from . /// /// - /// A default value of T if is an empty array of - /// or if the type of T is not , - /// , , , - /// , , , - /// , , or . + /// The default value of T if it could not be converted. /// /// /// @@ -1994,7 +1990,10 @@ public static void Times (this ulong n, Action action) /// The type of the return. /// /// - /// It must be a value type. + /// , , , + /// , , , + /// , , , + /// or . /// /// /// From b6011de7cf101fc9c1827d08cea6c9f191327d2d Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 28 Sep 2019 20:30:35 +0900 Subject: [PATCH 2619/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 4e94ebf72..e2cd2fc4f 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -2077,8 +2077,10 @@ public static byte[] ToByteArray (this T value, ByteOrder order) ? BitConverter.GetBytes ((UInt64)(object) value) : WebSocket.EmptyBytes; - if (bytes.Length > 1 && !order.IsHostOrder ()) - Array.Reverse (bytes); + if (bytes.Length > 1) { + if (!order.IsHostOrder ()) + Array.Reverse (bytes); + } return bytes; } From 09d72c99e30fa10b87d0df718b32ed5fb324e9ad Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 29 Sep 2019 21:48:13 +0900 Subject: [PATCH 2620/6294] [Modify] Edit it --- websocket-sharp/Ext.cs | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index e2cd2fc4f..1e2b369e9 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -2035,7 +2035,7 @@ public static T To (this byte[] source, ByteOrder sourceOrder) } /// - /// Converts the specified to an array of . + /// Converts the specified value to an array of . /// /// /// An array of converted from . @@ -2044,10 +2044,23 @@ public static T To (this byte[] source, ByteOrder sourceOrder) /// A T to convert. /// /// - /// One of the enum values, specifies the byte order of the return. + /// + /// One of the enum values. + /// + /// + /// It specifies the byte order of the return. + /// /// /// - /// The type of . The T must be a value type. + /// + /// The type of . + /// + /// + /// , , , + /// , , , + /// , , , + /// , or . + /// /// public static byte[] ToByteArray (this T value, ByteOrder order) where T : struct From 0c4fd70c480a2abdbcabcbd7b81a3dc54ab9c790 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 30 Sep 2019 21:08:42 +0900 Subject: [PATCH 2621/6294] [Modify] Edit it --- websocket-sharp/Ext.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 1e2b369e9..00ad4042c 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -2108,9 +2108,9 @@ public static byte[] ToByteArray (this T value, ByteOrder order) /// . /// /// - /// Or if the number of elements in it - /// is less than 2 or is same as - /// host byte order. + /// if the number of elements in + /// it is less than 2 or is + /// same as host byte order. /// /// /// From cfe8413037f44766367343aaca4e233e279f4cb2 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 1 Oct 2019 19:37:19 +0900 Subject: [PATCH 2622/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 00ad4042c..e8a26a543 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -2135,7 +2135,10 @@ public static byte[] ToHostOrder (this byte[] source, ByteOrder sourceOrder) if (source.Length < 2) return source; - return !sourceOrder.IsHostOrder () ? source.Reverse () : source; + if (sourceOrder.IsHostOrder ()) + return source; + + return source.Reverse (); } /// From d4a45b6ef071c26cf757fc2f20e6b33bee193ed2 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 2 Oct 2019 19:41:11 +0900 Subject: [PATCH 2623/6294] [Modify] Edit it --- websocket-sharp/Ext.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index e8a26a543..e7d8d97cd 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1963,15 +1963,14 @@ public static void Times (this ulong n, Action action) } /// - /// Converts the specified array of to the specified - /// type value. + /// Converts the specified byte array to the specified type value. /// /// /// /// A T converted from . /// /// - /// The default value of T if it could not be converted. + /// The default value of T if not converted. /// /// /// From a6009b94bcc24f66d53ef78970a36e821ceb98c1 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 3 Oct 2019 19:42:47 +0900 Subject: [PATCH 2624/6294] [Modify] It will be removed --- websocket-sharp/Ext.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index e7d8d97cd..e3ce48dc7 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1998,6 +1998,7 @@ public static void Times (this ulong n, Action action) /// /// is . /// + [Obsolete ("This method will be removed.")] public static T To (this byte[] source, ByteOrder sourceOrder) where T : struct { From 9e78bc1e347bc6e02f87cb3f9189703d58dc1191 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 3 Oct 2019 19:47:15 +0900 Subject: [PATCH 2625/6294] [Modify] Edit it --- websocket-sharp/Ext.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index e3ce48dc7..dde85c866 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -2035,7 +2035,7 @@ public static T To (this byte[] source, ByteOrder sourceOrder) } /// - /// Converts the specified value to an array of . + /// Converts the specified value to a byte array. /// /// /// An array of converted from . From cc6ae2410b3e270376c6bed530e3b3d50351cf95 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 4 Oct 2019 19:28:05 +0900 Subject: [PATCH 2626/6294] [Modify] It will be removed --- websocket-sharp/Ext.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index dde85c866..88bcf5fad 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -2062,6 +2062,7 @@ public static T To (this byte[] source, ByteOrder sourceOrder) /// , or . /// /// + [Obsolete ("This method will be removed.")] public static byte[] ToByteArray (this T value, ByteOrder order) where T : struct { From a1cdab106c89a6f451b960cc18148cc06a6c5220 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 5 Oct 2019 21:13:14 +0900 Subject: [PATCH 2627/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 88bcf5fad..abe3f58e1 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -2180,11 +2180,12 @@ public static string ToString (this T[] array, string separator) separator = String.Empty; var buff = new StringBuilder (64); + var end = len - 1; - for (var i = 0; i < len - 1; i++) + for (var i = 0; i < end; i++) buff.AppendFormat ("{0}{1}", array[i], separator); - buff.Append (array[len - 1].ToString ()); + buff.Append (array[end].ToString ()); return buff.ToString (); } From 897ecdaa326de9aca793be537ab537301c4e31c7 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 6 Oct 2019 22:13:17 +0900 Subject: [PATCH 2628/6294] [Modify] Edit it --- websocket-sharp/Ext.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index abe3f58e1..6e5fdbfb7 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -2143,7 +2143,7 @@ public static byte[] ToHostOrder (this byte[] source, ByteOrder sourceOrder) } /// - /// Converts the specified array to a . + /// Converts the specified array to a string. /// /// /// From 563bb8054a5184b948c78100ca215e688fc64d6d Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 7 Oct 2019 21:12:12 +0900 Subject: [PATCH 2629/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 6e5fdbfb7..7b553da26 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -2235,7 +2235,9 @@ public static Uri ToUri (this string value) /// is . /// /// - public static void WriteContent (this HttpListenerResponse response, byte[] content) + public static void WriteContent ( + this HttpListenerResponse response, byte[] content + ) { if (response == null) throw new ArgumentNullException ("response"); @@ -2250,7 +2252,9 @@ public static void WriteContent (this HttpListenerResponse response, byte[] cont } response.ContentLength64 = len; + var output = response.OutputStream; + if (len <= Int32.MaxValue) output.Write (content, 0, (int) len); else From 77bbfca9e148993f95834790e5b3608da4ad4fbe Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 8 Oct 2019 20:41:42 +0900 Subject: [PATCH 2630/6294] [Modify] Edit it --- websocket-sharp/Ext.cs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 7b553da26..cccc0b1b0 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -2214,15 +2214,14 @@ public static Uri ToUri (this string value) } /// - /// Writes and sends the specified data with the specified - /// . + /// Sends the specified content data with the HTTP response. /// /// - /// A that represents the HTTP response used to - /// send the content data. + /// A that represents the HTTP response + /// used to send the content data. /// /// - /// An array of that represents the content data to send. + /// An array of that specifies the content data to send. /// /// /// From 5e45646636f08f3bef6b8e797c8710ceb27b21ea Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 9 Oct 2019 19:35:29 +0900 Subject: [PATCH 2631/6294] [Modify] It will be removed --- websocket-sharp/Ext.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index cccc0b1b0..c6b656302 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -2234,6 +2234,7 @@ public static Uri ToUri (this string value) /// is . /// /// + [Obsolete ("This method will be removed.")] public static void WriteContent ( this HttpListenerResponse response, byte[] content ) From cce2a5ee8c6690784a5751faca3447aeebdd2a48 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 10 Oct 2019 20:59:08 +0900 Subject: [PATCH 2632/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerResponse.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index 92c0a7970..73a1fd468 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -272,8 +272,13 @@ public bool KeepAlive { /// public Stream OutputStream { get { - checkDisposed (); - return _outputStream ?? (_outputStream = _context.Connection.GetResponseStream ()); + if (_disposed) + throw new ObjectDisposedException (GetType ().ToString ()); + + if (_outputStream == null) + _outputStream = _context.Connection.GetResponseStream (); + + return _outputStream; } } From e493291e9a58885345094aabcddf68eaec29b25c Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 11 Oct 2019 19:46:33 +0900 Subject: [PATCH 2633/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerResponse.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index 73a1fd468..57e13c06d 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -262,13 +262,14 @@ public bool KeepAlive { } /// - /// Gets a to use to write the entity body data. + /// Gets a stream instance to which the entity body data can be written. /// /// - /// A to use to write the entity body data. + /// A instance to which the entity body data can be + /// written. /// /// - /// This object is closed. + /// This instance is closed. /// public Stream OutputStream { get { From eadd67a1d44a203d3636f395bf4cc1afd7e85ac1 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 12 Oct 2019 21:34:56 +0900 Subject: [PATCH 2634/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerResponse.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index 57e13c06d..7ae7c7d11 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -136,7 +136,9 @@ public Encoding ContentEncoding { } set { - checkDisposed (); + if (_disposed) + throw new ObjectDisposedException (GetType ().ToString ()); + _contentEncoding = value; } } From 3e6f9e512d4b41848f1903d6ed5ffdad54057db9 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 13 Oct 2019 20:28:19 +0900 Subject: [PATCH 2635/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerResponse.cs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index 7ae7c7d11..6615a3791 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -121,14 +121,20 @@ internal bool HeadersSent { #region Public Properties /// - /// Gets or sets the encoding for the entity body data included in the response. + /// Gets or sets the encoding for the entity body data included in + /// the response. /// /// - /// A that represents the encoding for the entity body data, - /// or if no encoding is specified. + /// + /// A that represents the encoding for + /// the entity body data. + /// + /// + /// if no encoding is specified. + /// /// /// - /// This object is closed. + /// This instance is closed. /// public Encoding ContentEncoding { get { From 1d394de40c162afdf658717a5086c79b417234ea Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 14 Oct 2019 22:11:09 +0900 Subject: [PATCH 2636/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerResponse.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index 6615a3791..a7832b621 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -198,7 +198,9 @@ public string ContentType { } set { - checkDisposed (); + if (_disposed) + throw new ObjectDisposedException (GetType ().ToString ()); + if (value != null && value.Length == 0) throw new ArgumentException ("An empty string.", "value"); From 4729a77679ec8d4f99c012a07197e3b16feba51d Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 15 Oct 2019 21:07:03 +0900 Subject: [PATCH 2637/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerResponse.cs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index a7832b621..8ddd5b0a6 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -182,15 +182,22 @@ public long ContentLength64 { /// Gets or sets the media type of the entity body included in the response. /// /// - /// A that represents the media type of the entity body, - /// or if no media type is specified. This value is - /// used for the value of the Content-Type entity-header. + /// + /// A that represents the media type of the entity + /// body. + /// + /// + /// It is used for the value of the Content-Type entity-header. + /// + /// + /// if no media type is specified. + /// /// /// /// The value specified for a set operation is empty. /// /// - /// This object is closed. + /// This instance is closed. /// public string ContentType { get { From 4c7ebbc8ef3fa264483528dd840e45cd88966103 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 16 Oct 2019 20:52:40 +0900 Subject: [PATCH 2638/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerResponse.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index 8ddd5b0a6..2ac8a7416 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -355,14 +355,19 @@ public string RedirectLocation { } set { - checkDisposed (); + if (_disposed) + throw new ObjectDisposedException (GetType ().ToString ()); + if (value == null) { _location = null; return; } - Uri uri = null; - if (!value.MaybeUri () || !Uri.TryCreate (value, UriKind.Absolute, out uri)) + if (!value.MaybeUri ()) + throw new ArgumentException ("Not an absolute URL.", "value"); + + Uri uri; + if (!Uri.TryCreate (value, UriKind.Absolute, out uri)) throw new ArgumentException ("Not an absolute URL.", "value"); _location = value; From 5e28f4786836a052ac5a705a690530af40980bf8 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 17 Oct 2019 20:22:48 +0900 Subject: [PATCH 2639/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerResponse.cs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index 2ac8a7416..bda181ec9 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -337,17 +337,23 @@ public Version ProtocolVersion { } /// - /// Gets or sets the URL to which the client is redirected to locate a requested resource. + /// Gets or sets the URL to which the client is redirected to locate + /// a requested resource. /// /// - /// A that represents the value of the Location response-header, - /// or if no redirect location is specified. + /// + /// A that represents the value of the Location + /// response-header. + /// + /// + /// if no redirect location is specified. + /// /// /// - /// The value specified for a set operation isn't an absolute URL. + /// The value specified for a set operation is not an absolute URL. /// /// - /// This object is closed. + /// This instance is closed. /// public string RedirectLocation { get { From 1f196b7bb4b503eb929962e84da259f2de73e29e Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 18 Oct 2019 19:38:08 +0900 Subject: [PATCH 2640/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerResponse.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index bda181ec9..fc2ce3b8c 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -741,12 +741,15 @@ public void Close () /// public void Close (byte[] responseEntity, bool willBlock) { - checkDisposed (); + if (_disposed) + throw new ObjectDisposedException (GetType ().ToString ()); + if (responseEntity == null) throw new ArgumentNullException ("responseEntity"); var len = responseEntity.Length; var output = OutputStream; + if (willBlock) { output.Write (responseEntity, 0, len); close (false); @@ -762,7 +765,8 @@ public void Close (byte[] responseEntity, bool willBlock) output.EndWrite (ar); close (false); }, - null); + null + ); } /// From d2356500656a00bdac4e5926492a90dfd7772326 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 19 Oct 2019 21:33:18 +0900 Subject: [PATCH 2641/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerResponse.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index fc2ce3b8c..b457cc1e1 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -723,21 +723,21 @@ public void Close () } /// - /// Returns the response with the specified array of to the client and - /// releases the resources used by this instance. + /// Returns the response with the specified entity body data to the client + /// and releases the resources used by this instance. /// /// - /// An array of that contains the response entity body data. + /// An array of that contains the entity body data. /// /// - /// true if this method blocks execution while flushing the stream to the client; - /// otherwise, false. + /// true if this method blocks execution while flushing the stream to + /// the client; otherwise, false. /// /// /// is . /// /// - /// This object is closed. + /// This instance is closed. /// public void Close (byte[] responseEntity, bool willBlock) { From d21f57827728afe42df3aefe4a0aa51135a671ee Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 19 Oct 2019 21:35:16 +0900 Subject: [PATCH 2642/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerResponse.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index b457cc1e1..47997434d 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -712,7 +712,7 @@ public void AppendHeader (string name, string value) /// /// Returns the response to the client and releases the resources used by - /// this instance. + /// this instance. /// public void Close () { From d0bf684d7c5fd1f25739cf038d7d91026ce69384 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 20 Oct 2019 21:39:39 +0900 Subject: [PATCH 2643/6294] [Modify] Remove it --- websocket-sharp/Net/HttpListenerResponse.cs | 6 ------ 1 file changed, 6 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index 47997434d..8787644d7 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -495,12 +495,6 @@ private bool canAddOrUpdate (Cookie cookie) return false; } - private void checkDisposed () - { - if (_disposed) - throw new ObjectDisposedException (GetType ().ToString ()); - } - private void checkDisposedOrHeadersSent () { if (_disposed) From d0c51a32e04003ae75bd6c7a51f69144fb2a3a7f Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 21 Oct 2019 21:08:33 +0900 Subject: [PATCH 2644/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerResponse.cs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index 8787644d7..a0752fa51 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -170,9 +170,18 @@ public long ContentLength64 { } set { - checkDisposedOrHeadersSent (); - if (value < 0) - throw new ArgumentOutOfRangeException ("Less than zero.", "value"); + if (_disposed) + throw new ObjectDisposedException (GetType ().ToString ()); + + if (_headersSent) { + var msg = "The response has already been sent."; + throw new InvalidOperationException (msg); + } + + if (value < 0) { + var msg = "Less than zero."; + throw new ArgumentOutOfRangeException (msg, "value"); + } _contentLength = value; } From ccd4b85e258f6826a38d624551cc897026c3f06e Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 22 Oct 2019 21:39:27 +0900 Subject: [PATCH 2645/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerResponse.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index a0752fa51..c1097039c 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -150,19 +150,21 @@ public Encoding ContentEncoding { } /// - /// Gets or sets the number of bytes in the entity body data included in the response. + /// Gets or sets the number of bytes in the entity body data included in + /// the response. /// /// - /// A that represents the value of the Content-Length entity-header. + /// A that represents the value of the Content-Length + /// header. /// /// /// The value specified for a set operation is less than zero. /// /// - /// The response has already been sent. + /// The response is already being sent. /// /// - /// This object is closed. + /// This instance is closed. /// public long ContentLength64 { get { From 0eaac91f039fdbe2ca53ba5dbddd288a4bbfbdf6 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 22 Oct 2019 21:40:33 +0900 Subject: [PATCH 2646/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerResponse.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index c1097039c..b85e4fda9 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -176,7 +176,7 @@ public long ContentLength64 { throw new ObjectDisposedException (GetType ().ToString ()); if (_headersSent) { - var msg = "The response has already been sent."; + var msg = "The response is already being sent."; throw new InvalidOperationException (msg); } From f0199454de842b5b921ecaf4a34bb44d856dd043 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 23 Oct 2019 17:12:33 +0900 Subject: [PATCH 2647/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerResponse.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index b85e4fda9..dd3a74a09 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -284,7 +284,14 @@ public bool KeepAlive { } set { - checkDisposedOrHeadersSent (); + if (_disposed) + throw new ObjectDisposedException (GetType ().ToString ()); + + if (_headersSent) { + var msg = "The response is already being sent."; + throw new InvalidOperationException (msg); + } + _keepAlive = value; } } From 53aaee912ccb4c678751f2bcfab26ca252cf3c0b Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 23 Oct 2019 17:19:36 +0900 Subject: [PATCH 2648/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerResponse.cs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index dd3a74a09..a699ad541 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -266,17 +266,23 @@ public WebHeaderCollection Headers { } /// - /// Gets or sets a value indicating whether the server requests a persistent connection. + /// Gets or sets a value indicating whether the server requests + /// a persistent connection. /// /// - /// true if the server requests a persistent connection; otherwise, false. - /// The default value is true. + /// + /// true if the server requests a persistent connection; + /// otherwise, false. + /// + /// + /// The default value is true. + /// /// /// - /// The response has already been sent. + /// The response is already being sent. /// /// - /// This object is closed. + /// This instance is closed. /// public bool KeepAlive { get { From 397e7dabbf78be4a0962be7d1d52a2c6bf40c8d6 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 24 Oct 2019 20:27:12 +0900 Subject: [PATCH 2649/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerResponse.cs | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index a699ad541..a774c9c68 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -349,12 +349,26 @@ public Version ProtocolVersion { } set { - checkDisposedOrHeadersSent (); + if (_disposed) + throw new ObjectDisposedException (GetType ().ToString ()); + + if (_headersSent) { + var msg = "The response is already being sent."; + throw new InvalidOperationException (msg); + } + if (value == null) throw new ArgumentNullException ("value"); - if (value.Major != 1 || (value.Minor != 0 && value.Minor != 1)) - throw new ArgumentException ("Not 1.0 or 1.1.", "value"); + if (value.Major != 1) { + var msg = "Its Major property is not 1."; + throw new ArgumentException (msg, "value"); + } + + if (value.Minor < 0 || value.Minor > 1) { + var msg = "Its Minor property is not 0 or 1."; + throw new ArgumentException (msg, "value"); + } _version = value; } From 365022fa3d9c84e0cd2f1672be3dfa013cfcefbc Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 25 Oct 2019 19:45:20 +0900 Subject: [PATCH 2650/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerResponse.cs | 22 +++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index a774c9c68..18043ff4e 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -325,23 +325,33 @@ public Stream OutputStream { } /// - /// Gets or sets the HTTP version used in the response. + /// Gets or sets the HTTP version used for the response. /// /// - /// A that represents the version used in the response. + /// A that represents the HTTP version used for + /// the response. /// /// /// The value specified for a set operation is . /// /// - /// The value specified for a set operation doesn't have its Major property set to 1 or - /// doesn't have its Minor property set to either 0 or 1. + /// + /// The value specified for a set operation does not have its Major + /// property set to 1. + /// + /// + /// -or- + /// + /// + /// The value specified for a set operation does not have its Minor + /// property set to either 0 or 1. + /// /// /// - /// The response has already been sent. + /// The response is already being sent. /// /// - /// This object is closed. + /// This instance is closed. /// public Version ProtocolVersion { get { From 791dcfe186d8f760f8b4177732e239c623fb8bec Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 26 Oct 2019 17:28:45 +0900 Subject: [PATCH 2651/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerResponse.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index 18043ff4e..d747ac715 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -447,7 +447,14 @@ public bool SendChunked { } set { - checkDisposedOrHeadersSent (); + if (_disposed) + throw new ObjectDisposedException (GetType ().ToString ()); + + if (_headersSent) { + var msg = "The response is already being sent."; + throw new InvalidOperationException (msg); + } + _sendChunked = value; } } From 49777b1ac6a3fbb50697a82221f38568baa1aaba Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 27 Oct 2019 17:39:45 +0900 Subject: [PATCH 2652/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerResponse.cs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index d747ac715..241a75f7c 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -429,17 +429,23 @@ public string RedirectLocation { } /// - /// Gets or sets a value indicating whether the response uses the chunked transfer encoding. + /// Gets or sets a value indicating whether the response uses the chunked + /// transfer encoding. /// /// - /// true if the response uses the chunked transfer encoding; - /// otherwise, false. The default value is false. + /// + /// true if the response uses the chunked transfer encoding; + /// otherwise, false. + /// + /// + /// The default value is false. + /// /// /// - /// The response has already been sent. + /// The response is already being sent. /// /// - /// This object is closed. + /// This instance is closed. /// public bool SendChunked { get { From 43344835619fa387b4be2fe635a756cf9daea4b5 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 28 Oct 2019 21:37:13 +0900 Subject: [PATCH 2653/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerResponse.cs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index 241a75f7c..311162583 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -488,10 +488,18 @@ public int StatusCode { } set { - checkDisposedOrHeadersSent (); - if (value < 100 || value > 999) - throw new System.Net.ProtocolViolationException ( - "A value isn't between 100 and 999 inclusive."); + if (_disposed) + throw new ObjectDisposedException (GetType ().ToString ()); + + if (_headersSent) { + var msg = "The response is already being sent."; + throw new InvalidOperationException (msg); + } + + if (value < 100 || value > 999) { + var msg = "A value is not between 100 and 999 inclusive."; + throw new System.Net.ProtocolViolationException (msg); + } _statusCode = value; _statusDescription = value.GetStatusDescription (); From 131b4ca8c9f88c47a0028a0f8a4a3b406522054f Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 29 Oct 2019 19:48:08 +0900 Subject: [PATCH 2654/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerResponse.cs | 22 +++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index 311162583..fc0254baf 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -469,18 +469,28 @@ public bool SendChunked { /// Gets or sets the HTTP status code returned to the client. /// /// - /// An that represents the status code for the response to - /// the request. The default value is same as . + /// + /// An that represents the HTTP status code for + /// the response to the request. + /// + /// + /// The default value is 200. It is same as + /// . + /// /// /// - /// The response has already been sent. + /// The response is already being sent. /// /// - /// This object is closed. + /// This instance is closed. /// /// - /// The value specified for a set operation is invalid. Valid values are - /// between 100 and 999 inclusive. + /// + /// The value specified for a set operation is invalid. + /// + /// + /// Valid values are between 100 and 999 inclusive. + /// /// public int StatusCode { get { From 697b46a600fe9307610bd3fdae5cd59d025cbdc4 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 30 Oct 2019 21:20:44 +0900 Subject: [PATCH 2655/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerResponse.cs | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index fc0254baf..67826211d 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -540,14 +540,28 @@ public string StatusDescription { } set { - checkDisposedOrHeadersSent (); + if (_disposed) + throw new ObjectDisposedException (GetType ().ToString ()); + + if (_headersSent) { + var msg = "The response is already being sent."; + throw new InvalidOperationException (msg); + } + if (value == null || value.Length == 0) { _statusDescription = _statusCode.GetStatusDescription (); return; } - if (!value.IsText () || value.IndexOfAny (new[] { '\r', '\n' }) > -1) - throw new ArgumentException ("Contains invalid characters.", "value"); + if (!value.IsText ()) { + var msg = "It contains invalid characters."; + throw new ArgumentException (msg, "value"); + } + + if (value.IndexOfAny (new[] { '\r', '\n' }) > -1) { + var msg = "It contains invalid characters."; + throw new ArgumentException (msg, "value"); + } _statusDescription = value; } From 9fe178710b3c217c4a7768aead066fdee46e24d0 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 31 Oct 2019 20:11:33 +0900 Subject: [PATCH 2656/6294] [Modify] Throw an exception --- websocket-sharp/Net/HttpListenerResponse.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index 67826211d..87be5a9b8 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -548,7 +548,10 @@ public string StatusDescription { throw new InvalidOperationException (msg); } - if (value == null || value.Length == 0) { + if (value == null) + throw new ArgumentNullException ("value"); + + if (value.Length == 0) { _statusDescription = _statusCode.GetStatusDescription (); return; } From f9fa2ef4fe8fa52ce6d6167543411931a85c1b66 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 31 Oct 2019 20:15:36 +0900 Subject: [PATCH 2657/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerResponse.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index 87be5a9b8..455ef208e 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -557,12 +557,12 @@ public string StatusDescription { } if (!value.IsText ()) { - var msg = "It contains invalid characters."; + var msg = "It contains an invalid character."; throw new ArgumentException (msg, "value"); } if (value.IndexOfAny (new[] { '\r', '\n' }) > -1) { - var msg = "It contains invalid characters."; + var msg = "It contains an invalid character."; throw new ArgumentException (msg, "value"); } From 11b6f169eccefcec8f70b61cc16a9b8dd449ce91 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 1 Nov 2019 20:07:22 +0900 Subject: [PATCH 2658/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerResponse.cs | 29 +++++++++++++++------ 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index 455ef208e..a3b5efd01 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -517,22 +517,35 @@ public int StatusCode { } /// - /// Gets or sets the description of the HTTP status code returned to the client. + /// Gets or sets the description of the HTTP status code returned to + /// the client. /// /// - /// A that represents the description of the status code. The default - /// value is the RFC 2616 - /// description for the property value, - /// or if an RFC 2616 description doesn't exist. + /// + /// A that represents the description of + /// the HTTP status code for the response to the request. + /// + /// + /// The default value is + /// the + /// RFC 2616 description for the + /// property value. + /// + /// + /// An empty string if an RFC 2616 description does not exist. + /// /// + /// + /// The value specified for a set operation is . + /// /// - /// The value specified for a set operation contains invalid characters. + /// The value specified for a set operation contains an invalid character. /// /// - /// The response has already been sent. + /// The response is already being sent. /// /// - /// This object is closed. + /// This instance is closed. /// public string StatusDescription { get { From f4f101384a64359576ff6b61bce498a813aca6aa Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 2 Nov 2019 21:50:32 +0900 Subject: [PATCH 2659/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerResponse.cs | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index a3b5efd01..c532d73f2 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -931,12 +931,22 @@ public void CopyFrom (HttpListenerResponse templateResponse) /// public void Redirect (string url) { - checkDisposedOrHeadersSent (); + if (_disposed) + throw new ObjectDisposedException (GetType ().ToString ()); + + if (_headersSent) { + var msg = "The response is already being sent."; + throw new InvalidOperationException (msg); + } + if (url == null) throw new ArgumentNullException ("url"); - Uri uri = null; - if (!url.MaybeUri () || !Uri.TryCreate (url, UriKind.Absolute, out uri)) + if (!url.MaybeUri ()) + throw new ArgumentException ("Not an absolute URL.", "url"); + + Uri uri; + if (!Uri.TryCreate (url, UriKind.Absolute, out uri)) throw new ArgumentException ("Not an absolute URL.", "url"); _location = url; From a57af997415c3bae1b7c604c4b672dd1ac25b342 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 3 Nov 2019 21:23:27 +0900 Subject: [PATCH 2660/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerResponse.cs | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index c532d73f2..72c5bdbeb 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -906,28 +906,29 @@ public void CopyFrom (HttpListenerResponse templateResponse) /// /// Configures the response to redirect the client's request to - /// the specified . + /// the specified URL. /// /// - /// This method sets the property to - /// , the property to - /// 302, and the property to + /// This method sets the property to + /// , the property to + /// 302, and the property to /// "Found". /// /// - /// A that represents the URL to redirect the client's request to. + /// A that represents the URL to which the client is + /// redirected to locate a requested resource. /// /// /// is . /// /// - /// isn't an absolute URL. + /// is not an absolute URL. /// /// - /// The response has already been sent. + /// The response is already being sent. /// /// - /// This object is closed. + /// This instance is closed. /// public void Redirect (string url) { From ca49c4eba6ce70fbf13486210b7e2c48e8678d1e Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 4 Nov 2019 21:10:49 +0900 Subject: [PATCH 2661/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerResponse.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index 72c5bdbeb..8e7714e0e 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -911,8 +911,7 @@ public void CopyFrom (HttpListenerResponse templateResponse) /// /// This method sets the property to /// , the property to - /// 302, and the property to - /// "Found". + /// 302, and the property to "Found". /// /// /// A that represents the URL to which the client is From b9966ca2af74964f56d2d4503509d7122d5b9540 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 4 Nov 2019 21:14:44 +0900 Subject: [PATCH 2662/6294] [Modify] Remove it --- websocket-sharp/Net/HttpListenerResponse.cs | 9 --------- 1 file changed, 9 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index 8e7714e0e..7ecde918b 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -604,15 +604,6 @@ private bool canAddOrUpdate (Cookie cookie) return false; } - private void checkDisposedOrHeadersSent () - { - if (_disposed) - throw new ObjectDisposedException (GetType ().ToString ()); - - if (_headersSent) - throw new InvalidOperationException ("Cannot be changed after the headers are sent."); - } - private void close (bool force) { _disposed = true; From 33fb0edf09148032d85cb45ea0b4988664a23f5a Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 5 Nov 2019 20:25:27 +0900 Subject: [PATCH 2663/6294] [Modify] Replace it --- websocket-sharp/Net/HttpListenerResponse.cs | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index 7ecde918b..5bcd3dd6e 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -612,15 +612,13 @@ private void close (bool force) private IEnumerable findCookie (Cookie cookie) { - var name = cookie.Name; - var domain = cookie.Domain; - var path = cookie.Path; - if (_cookies != null) - foreach (Cookie c in _cookies) - if (c.Name.Equals (name, StringComparison.OrdinalIgnoreCase) && - c.Domain.Equals (domain, StringComparison.OrdinalIgnoreCase) && - c.Path.Equals (path, StringComparison.Ordinal)) - yield return c; + if (_cookies == null) + yield break; + + foreach (var c in _cookies) { + if (c.EqualsWithoutValue (cookie)) + yield return c; + } } #endregion From f5cde7ef62f3a8d2459318a8c2b195fba7803ea2 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 6 Nov 2019 21:16:16 +0900 Subject: [PATCH 2664/6294] [Modify] Add it --- websocket-sharp/Net/Cookie.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/websocket-sharp/Net/Cookie.cs b/websocket-sharp/Net/Cookie.cs index 785300c3e..1c5a4bf2d 100644 --- a/websocket-sharp/Net/Cookie.cs +++ b/websocket-sharp/Net/Cookie.cs @@ -870,6 +870,16 @@ internal bool EqualsWithoutValue (Cookie cookie) && _version == cookie._version; } + internal bool EqualsWithoutValueAndVersion (Cookie cookie) + { + var caseSensitive = StringComparison.InvariantCulture; + var caseInsensitive = StringComparison.InvariantCultureIgnoreCase; + + return _name.Equals (cookie._name, caseInsensitive) + && _path.Equals (cookie._path, caseSensitive) + && _domain.Equals (cookie._domain, caseInsensitive); + } + internal string ToRequestString (Uri uri) { if (_name.Length == 0) From 1df9e927a1775a4f80fc42c0b805710dde3b7918 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 6 Nov 2019 21:18:38 +0900 Subject: [PATCH 2665/6294] [Modify] Replace it --- websocket-sharp/Net/HttpListenerResponse.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index 5bcd3dd6e..a395a8799 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -616,7 +616,7 @@ private IEnumerable findCookie (Cookie cookie) yield break; foreach (var c in _cookies) { - if (c.EqualsWithoutValue (cookie)) + if (c.EqualsWithoutValueAndVersion (cookie)) yield return c; } } From 26c764b0d2fce51c691d29897e3edcb184b6f4a0 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 7 Nov 2019 20:07:48 +0900 Subject: [PATCH 2666/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerResponse.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index a395a8799..df339b082 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -612,7 +612,7 @@ private void close (bool force) private IEnumerable findCookie (Cookie cookie) { - if (_cookies == null) + if (_cookies == null || _cookies.Count == 0) yield break; foreach (var c in _cookies) { From 9685acf4ab237e882a62b15f08bc68c6c716e291 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 8 Nov 2019 21:48:11 +0900 Subject: [PATCH 2667/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerResponse.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index df339b082..38eef1210 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -589,17 +589,17 @@ public string StatusDescription { private bool canAddOrUpdate (Cookie cookie) { - if (_cookies == null || _cookies.Count == 0) - return true; - var found = findCookie (cookie).ToList (); + if (found.Count == 0) return true; var ver = cookie.Version; - foreach (var c in found) + + foreach (var c in found) { if (c.Version == ver) return true; + } return false; } From 97862fd1a5b0b72965752863aa6c3ee1edb2d03a Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 9 Nov 2019 17:31:15 +0900 Subject: [PATCH 2668/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerResponse.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index 38eef1210..b2015cf86 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -960,8 +960,10 @@ public void SetCookie (Cookie cookie) if (cookie == null) throw new ArgumentNullException ("cookie"); - if (!canAddOrUpdate (cookie)) - throw new ArgumentException ("Cannot be replaced.", "cookie"); + if (!canAddOrUpdate (cookie)) { + var msg = "It cannot be replaced."; + throw new ArgumentException (msg, "cookie"); + } Cookies.Add (cookie); } From e9c6c5f015d369585f300a46b6ec2b8bf6ef034f Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 10 Nov 2019 17:17:26 +0900 Subject: [PATCH 2669/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerResponse.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index b2015cf86..b2677acd2 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -944,7 +944,7 @@ public void Redirect (string url) } /// - /// Adds or updates a in the cookies sent with the response. + /// Adds or updates a cookie in the cookies sent with the response. /// /// /// A to set. @@ -953,7 +953,8 @@ public void Redirect (string url) /// is . /// /// - /// already exists in the cookies and couldn't be replaced. + /// already exists in the cookies but + /// it can not be updated. /// public void SetCookie (Cookie cookie) { From 5ca24dceb3b34a5315be750468ba7d028d2d6e89 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 10 Nov 2019 17:18:21 +0900 Subject: [PATCH 2670/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerResponse.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index b2677acd2..b25613894 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -954,7 +954,7 @@ public void Redirect (string url) /// /// /// already exists in the cookies but - /// it can not be updated. + /// it cannot be updated. /// public void SetCookie (Cookie cookie) { From b70705ee95ec48718e93b13dd8e342072aed6b90 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 10 Nov 2019 17:19:39 +0900 Subject: [PATCH 2671/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerResponse.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index b25613894..9bae3dc0b 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -962,7 +962,7 @@ public void SetCookie (Cookie cookie) throw new ArgumentNullException ("cookie"); if (!canAddOrUpdate (cookie)) { - var msg = "It cannot be replaced."; + var msg = "It cannot be updated."; throw new ArgumentException (msg, "cookie"); } From 021c8dcf6bcefa61def9f31a4dd20bbf64c0c270 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 11 Nov 2019 21:26:05 +0900 Subject: [PATCH 2672/6294] [Modify] Rename it --- websocket-sharp/Net/HttpListenerResponse.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index 9bae3dc0b..9a566942f 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -587,7 +587,7 @@ public string StatusDescription { #region Private Methods - private bool canAddOrUpdate (Cookie cookie) + private bool canSetCookie (Cookie cookie) { var found = findCookie (cookie).ToList (); @@ -961,7 +961,7 @@ public void SetCookie (Cookie cookie) if (cookie == null) throw new ArgumentNullException ("cookie"); - if (!canAddOrUpdate (cookie)) { + if (!canSetCookie (cookie)) { var msg = "It cannot be updated."; throw new ArgumentException (msg, "cookie"); } From b08d63699f370399973d31146160a681646122f8 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 12 Nov 2019 21:14:43 +0900 Subject: [PATCH 2673/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerResponse.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index 9a566942f..868d6b645 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -754,7 +754,7 @@ public void AddHeader (string name, string value) } /// - /// Appends the specified to the cookies sent with the response. + /// Appends the specified cookie to the cookies sent with the response. /// /// /// A to append. From 6aa463059418a52cef65ef844e629adad871be50 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 13 Nov 2019 20:24:50 +0900 Subject: [PATCH 2674/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerResponse.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index 868d6b645..ad95c4592 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -234,7 +234,10 @@ public string ContentType { /// public CookieCollection Cookies { get { - return _cookies ?? (_cookies = new CookieCollection ()); + if (_cookies == null) + _cookies = new CookieCollection (); + + return _cookies; } set { From 0be5376ff6a6e7e7c9dd73f6146b26e3ca4950c2 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 13 Nov 2019 20:39:20 +0900 Subject: [PATCH 2675/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerResponse.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index ad95c4592..03500a7d7 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -227,10 +227,11 @@ public string ContentType { } /// - /// Gets or sets the cookies sent with the response. + /// Gets or sets the collection of cookies sent with the response. /// /// - /// A that contains the cookies sent with the response. + /// A that contains the cookies sent with + /// the response. /// public CookieCollection Cookies { get { From af263c0b81179aae29de8254c3dcb6c415e5a6c6 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 14 Nov 2019 16:01:36 +0900 Subject: [PATCH 2676/6294] [Fix] Fix for issue #544 Inherit the ISerializable interface again because some build environments get an error. --- websocket-sharp/Net/CookieException.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/CookieException.cs b/websocket-sharp/Net/CookieException.cs index e6a942844..2a5abe98a 100644 --- a/websocket-sharp/Net/CookieException.cs +++ b/websocket-sharp/Net/CookieException.cs @@ -46,7 +46,7 @@ namespace WebSocketSharp.Net /// The exception that is thrown when a gets an error. /// [Serializable] - public class CookieException : FormatException + public class CookieException : FormatException, ISerializable { #region Internal Constructors From fdd3e904d7c8c689a146fa30c06cb8b23d07a54c Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 15 Nov 2019 19:33:31 +0900 Subject: [PATCH 2677/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerResponse.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index 03500a7d7..39e2ad7ae 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -985,7 +985,7 @@ void IDisposable.Dispose () if (_disposed) return; - close (true); // Same as the Abort method. + close (true); } #endregion From b54940a575ada1f7190b0d5767ca926b447964c8 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 16 Nov 2019 17:28:37 +0900 Subject: [PATCH 2678/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerResponse.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index 39e2ad7ae..f53cd796e 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -978,7 +978,7 @@ public void SetCookie (Cookie cookie) #region Explicit Interface Implementations /// - /// Releases all resources used by the . + /// Releases all resources used by this instance. /// void IDisposable.Dispose () { From 7b868fa73cb73bfd82064a73ace79b7eb8ae181d Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 17 Nov 2019 17:04:12 +0900 Subject: [PATCH 2679/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerResponse.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index f53cd796e..a26bd52be 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -712,7 +712,7 @@ internal WebHeaderCollection WriteHeadersTo (MemoryStream destination) #region Public Methods /// - /// Closes the connection to the client without returning a response. + /// Closes the connection to the client without sending a response. /// public void Abort () { From ada795033ae5208e27de1fc54f9c05691409507d Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 18 Nov 2019 21:54:40 +0900 Subject: [PATCH 2680/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerResponse.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index a26bd52be..cce0c069f 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -807,7 +807,7 @@ public void AppendHeader (string name, string value) } /// - /// Returns the response to the client and releases the resources used by + /// Sends the response to the client and releases the resources used by /// this instance. /// public void Close () From b2c4bfa244c4c94cc6ca5b115de25603ff8a3476 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 18 Nov 2019 21:56:26 +0900 Subject: [PATCH 2681/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerResponse.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index cce0c069f..624971375 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -819,7 +819,7 @@ public void Close () } /// - /// Returns the response with the specified entity body data to the client + /// Sends the response with the specified entity body data to the client /// and releases the resources used by this instance. /// /// From 75339294486d21877d4a06feace539093d79cafa Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 19 Nov 2019 20:35:00 +0900 Subject: [PATCH 2682/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerResponse.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index 624971375..3b1dfffab 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -723,8 +723,8 @@ public void Abort () } /// - /// Adds an HTTP header with the specified and - /// to the headers for the response. + /// Adds or updates an HTTP header with the specified name and value in + /// the headers for the response. /// /// /// A that represents the name of the header to add. @@ -737,7 +737,8 @@ public void Abort () /// /// /// - /// or contains invalid characters. + /// or contains + /// an invalid character. /// /// /// -or- @@ -747,7 +748,8 @@ public void Abort () /// /// /// - /// The length of is greater than 65,535 characters. + /// The length of is greater than 65,535 + /// characters. /// /// /// The header cannot be allowed to add to the current headers. From 52811924d14bde874e55577c80c61d9ddc49742a Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 20 Nov 2019 19:42:49 +0900 Subject: [PATCH 2683/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerResponse.cs | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index 3b1dfffab..d9193cf21 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -774,21 +774,24 @@ public void AppendCookie (Cookie cookie) } /// - /// Appends a to the specified HTTP header sent with the response. + /// Appends an HTTP header with the specified name and value to + /// the headers for the response. /// /// - /// A that represents the name of the header to append - /// to. + /// A that represents the name of the header to + /// append. /// /// - /// A that represents the value to append to the header. + /// A that represents the value of the header to + /// append. /// /// /// is or empty. /// /// /// - /// or contains invalid characters. + /// or contains + /// an invalid character. /// /// /// -or- @@ -798,10 +801,11 @@ public void AppendCookie (Cookie cookie) /// /// /// - /// The length of is greater than 65,535 characters. + /// The length of is greater than 65,535 + /// characters. /// /// - /// The current headers cannot allow the header to append a value. + /// The header cannot be allowed to append to the current headers. /// public void AppendHeader (string name, string value) { From 6d85802bda42817b41f0def470d0cdc8d031a87f Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 21 Nov 2019 20:06:49 +0900 Subject: [PATCH 2684/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerResponse.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index d9193cf21..82bf252e3 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -257,7 +257,10 @@ public CookieCollection Cookies { /// public WebHeaderCollection Headers { get { - return _headers ?? (_headers = new WebHeaderCollection (HttpHeaderType.Response, false)); + if (_headers == null) + _headers = new WebHeaderCollection (HttpHeaderType.Response, false); + + return _headers; } set { From bd8b7b246a23ee9490d78f2f74ac03416c47ae1f Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 22 Nov 2019 22:07:49 +0900 Subject: [PATCH 2685/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerResponse.cs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index 82bf252e3..1652e5145 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -264,9 +264,15 @@ public WebHeaderCollection Headers { } set { - if (value != null && value.State != HttpHeaderType.Response) - throw new InvalidOperationException ( - "The specified headers aren't valid for a response."); + if (value == null) { + _headers = null; + return; + } + + if (value.State != HttpHeaderType.Response) { + var msg = "The value is not valid for a response."; + throw new InvalidOperationException (msg); + } _headers = value; } From cca8a9a2d41b446b92fc1f452162764d7834b885 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 23 Nov 2019 17:29:14 +0900 Subject: [PATCH 2686/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerResponse.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index 1652e5145..e6ac58d94 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -247,13 +247,14 @@ public CookieCollection Cookies { } /// - /// Gets or sets the HTTP headers sent to the client. + /// Gets or sets the collection of HTTP headers sent to the client. /// /// - /// A that contains the headers sent to the client. + /// A that contains the headers sent to + /// the client. /// /// - /// The value specified for a set operation isn't valid for a response. + /// The value specified for a set operation is not valid for a response. /// public WebHeaderCollection Headers { get { From fc90a9e9dcd68861b7a02ada77ae1651e5a55c34 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 24 Nov 2019 21:12:35 +0900 Subject: [PATCH 2687/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerResponse.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index e6ac58d94..c4e7eaa0b 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -896,13 +896,15 @@ public void CopyFrom (HttpListenerResponse templateResponse) if (templateResponse == null) throw new ArgumentNullException ("templateResponse"); - if (templateResponse._headers != null) { + var headers = templateResponse._headers; + + if (headers != null) { if (_headers != null) _headers.Clear (); - Headers.Add (templateResponse._headers); + Headers.Add (headers); } - else if (_headers != null) { + else { _headers = null; } From 13a20f45da7075a7fc4a9225b847a0b5441f1149 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 25 Nov 2019 20:54:12 +0900 Subject: [PATCH 2688/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerResponse.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index c4e7eaa0b..5a2bedec6 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -882,8 +882,8 @@ public void Close (byte[] responseEntity, bool willBlock) } /// - /// Copies some properties from the specified to - /// this response. + /// Copies some properties from the specified response instance to + /// this instance. /// /// /// A to copy. From 50084de4b0ca81388c1bca5b079c2f22702d0c8c Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 26 Nov 2019 20:52:31 +0900 Subject: [PATCH 2689/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerResponse.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index 5a2bedec6..aabf71001 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -219,7 +219,12 @@ public string ContentType { if (_disposed) throw new ObjectDisposedException (GetType ().ToString ()); - if (value != null && value.Length == 0) + if (value == null) { + _contentType = null; + return; + } + + if (value.Length == 0) throw new ArgumentException ("An empty string.", "value"); _contentType = value; From 7891e1fa6def10c27df30742a76783f9ca93344a Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 27 Nov 2019 21:13:54 +0900 Subject: [PATCH 2690/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerResponse.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index aabf71001..d5d0ca903 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -198,14 +198,14 @@ public long ContentLength64 { /// body. /// /// - /// It is used for the value of the Content-Type entity-header. + /// It is used for the value of the Content-Type header. /// /// /// if no media type is specified. /// /// /// - /// The value specified for a set operation is empty. + /// The value specified for a set operation is an empty string. /// /// /// This instance is closed. From 2636a9fd4f94f3cf9b310687ad7324902b98989b Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 28 Nov 2019 20:37:46 +0900 Subject: [PATCH 2691/6294] [Modify] Add it --- websocket-sharp/Net/HttpListenerResponse.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index d5d0ca903..b4142ec50 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -629,6 +629,17 @@ private void close (bool force) _context.Connection.Close (force); } + private static string createContentType (string value, Encoding encoding) + { + if (value.IndexOf ("charset=", StringComparison.Ordinal) > -1) + return value; + + if (encoding == null) + return value; + + return String.Format ("{0}; charset={1}", value, encoding.WebName); + } + private IEnumerable findCookie (Cookie cookie) { if (_cookies == null || _cookies.Count == 0) From d75c10708af9e822800163a5d2072b849b8acc0d Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 29 Nov 2019 19:40:54 +0900 Subject: [PATCH 2692/6294] [Modify] Rename it --- websocket-sharp/Net/HttpListenerResponse.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index b4142ec50..c17d12890 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -629,7 +629,9 @@ private void close (bool force) _context.Connection.Close (force); } - private static string createContentType (string value, Encoding encoding) + private static string createContentTypeHeaderText ( + string value, Encoding encoding + ) { if (value.IndexOf ("charset=", StringComparison.Ordinal) > -1) return value; From 203989148fe267d549cc8348771d729967e58d3a Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 30 Nov 2019 22:39:43 +0900 Subject: [PATCH 2693/6294] [Modify] Replace it --- websocket-sharp/Net/HttpListenerResponse.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index c17d12890..893c8fca1 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -660,16 +660,16 @@ private IEnumerable findCookie (Cookie cookie) internal WebHeaderCollection WriteHeadersTo (MemoryStream destination) { var headers = new WebHeaderCollection (HttpHeaderType.Response, true); + if (_headers != null) headers.Add (_headers); if (_contentType != null) { - var type = _contentType.IndexOf ("charset=", StringComparison.Ordinal) == -1 && - _contentEncoding != null - ? String.Format ("{0}; charset={1}", _contentType, _contentEncoding.WebName) - : _contentType; - - headers.InternalSet ("Content-Type", type, true); + headers.InternalSet ( + "Content-Type", + createContentTypeHeaderText (_contentType, _contentEncoding), + true + ); } if (headers["Server"] == null) From 7ca0f85515dca4917bfe6f9968e24320db6cea6e Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 1 Dec 2019 21:07:41 +0900 Subject: [PATCH 2694/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerResponse.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index 893c8fca1..1ea61cb86 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -676,8 +676,12 @@ internal WebHeaderCollection WriteHeadersTo (MemoryStream destination) headers.InternalSet ("Server", "websocket-sharp/1.0", true); var prov = CultureInfo.InvariantCulture; - if (headers["Date"] == null) - headers.InternalSet ("Date", DateTime.UtcNow.ToString ("r", prov), true); + + if (headers["Date"] == null) { + headers.InternalSet ( + "Date", DateTime.UtcNow.ToString ("r", prov), true + ); + } if (!_sendChunked) headers.InternalSet ("Content-Length", _contentLength.ToString (prov), true); From ff0337599aa08518dbd577ffd689ab68a58ad8cc Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 2 Dec 2019 22:07:25 +0900 Subject: [PATCH 2695/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerResponse.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index 1ea61cb86..4bcb03007 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -683,10 +683,14 @@ internal WebHeaderCollection WriteHeadersTo (MemoryStream destination) ); } - if (!_sendChunked) - headers.InternalSet ("Content-Length", _contentLength.ToString (prov), true); - else + if (!_sendChunked) { + headers.InternalSet ( + "Content-Length", _contentLength.ToString (prov), true + ); + } + else { headers.InternalSet ("Transfer-Encoding", "chunked", true); + } /* * Apache forces closing the connection for these status codes: From 8492a0bc181b67b151af6a2b1008690dfc92c857 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 2 Dec 2019 22:11:36 +0900 Subject: [PATCH 2696/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerResponse.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index 4bcb03007..8fe7adb52 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -683,14 +683,14 @@ internal WebHeaderCollection WriteHeadersTo (MemoryStream destination) ); } - if (!_sendChunked) { + if (_sendChunked) { + headers.InternalSet ("Transfer-Encoding", "chunked", true); + } + else { headers.InternalSet ( "Content-Length", _contentLength.ToString (prov), true ); } - else { - headers.InternalSet ("Transfer-Encoding", "chunked", true); - } /* * Apache forces closing the connection for these status codes: From 815f94b98239a9714be6006924d2e76c3e26b6b6 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 3 Dec 2019 22:21:33 +0900 Subject: [PATCH 2697/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerResponse.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index 8fe7adb52..47c18722e 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -675,11 +675,11 @@ internal WebHeaderCollection WriteHeadersTo (MemoryStream destination) if (headers["Server"] == null) headers.InternalSet ("Server", "websocket-sharp/1.0", true); - var prov = CultureInfo.InvariantCulture; - if (headers["Date"] == null) { headers.InternalSet ( - "Date", DateTime.UtcNow.ToString ("r", prov), true + "Date", + DateTime.UtcNow.ToString ("r", CultureInfo.InvariantCulture), + true ); } @@ -688,7 +688,9 @@ internal WebHeaderCollection WriteHeadersTo (MemoryStream destination) } else { headers.InternalSet ( - "Content-Length", _contentLength.ToString (prov), true + "Content-Length", + _contentLength.ToString (CultureInfo.InvariantCulture), + true ); } From 2be71f3231b80b5e6235c729dc63be8747128f84 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 4 Dec 2019 19:39:39 +0900 Subject: [PATCH 2698/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerResponse.cs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index 47c18722e..88342fd2b 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -704,15 +704,15 @@ internal WebHeaderCollection WriteHeadersTo (MemoryStream destination) * - 500 Internal Server Error * - 503 Service Unavailable */ - var closeConn = !_context.Request.KeepAlive || - !_keepAlive || - _statusCode == 400 || - _statusCode == 408 || - _statusCode == 411 || - _statusCode == 413 || - _statusCode == 414 || - _statusCode == 500 || - _statusCode == 503; + var closeConn = !_context.Request.KeepAlive + || !_keepAlive + || _statusCode == 400 + || _statusCode == 408 + || _statusCode == 411 + || _statusCode == 413 + || _statusCode == 414 + || _statusCode == 500 + || _statusCode == 503; var reuses = _context.Connection.Reuses; if (closeConn || reuses >= 100) { From aaf8ea5dab33b9f555614cf4531cf8e02e2f3021 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 5 Dec 2019 22:02:46 +0900 Subject: [PATCH 2699/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerResponse.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index 88342fd2b..5061e63c8 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -715,12 +715,16 @@ internal WebHeaderCollection WriteHeadersTo (MemoryStream destination) || _statusCode == 503; var reuses = _context.Connection.Reuses; + if (closeConn || reuses >= 100) { headers.InternalSet ("Connection", "close", true); } else { headers.InternalSet ( - "Keep-Alive", String.Format ("timeout=15,max={0}", 100 - reuses), true); + "Keep-Alive", + String.Format ("timeout=15,max={0}", 100 - reuses), + true + ); if (_context.Request.ProtocolVersion < HttpVersion.Version11) headers.InternalSet ("Connection", "keep-alive", true); From bd778b45d42d9feea74e05eb8ea46c85813ec4d4 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 6 Dec 2019 21:43:34 +0900 Subject: [PATCH 2700/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerResponse.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index 5061e63c8..ead8365b9 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -733,9 +733,10 @@ internal WebHeaderCollection WriteHeadersTo (MemoryStream destination) if (_location != null) headers.InternalSet ("Location", _location, true); - if (_cookies != null) - foreach (Cookie cookie in _cookies) + if (_cookies != null) { + foreach (var cookie in _cookies) headers.InternalSet ("Set-Cookie", cookie.ToResponseString (), true); + } var enc = _contentEncoding ?? Encoding.Default; var writer = new StreamWriter (destination, enc, 256); From 835820f2c318b9077351384616ab06f09172ea20 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 7 Dec 2019 23:13:54 +0900 Subject: [PATCH 2701/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerResponse.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index ead8365b9..3b7369bee 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -740,7 +740,11 @@ internal WebHeaderCollection WriteHeadersTo (MemoryStream destination) var enc = _contentEncoding ?? Encoding.Default; var writer = new StreamWriter (destination, enc, 256); - writer.Write ("HTTP/{0} {1} {2}\r\n", _version, _statusCode, _statusDescription); + + writer.Write ( + "HTTP/{0} {1} {2}\r\n", _version, _statusCode, _statusDescription + ); + writer.Write (headers.ToStringMultiValue (true)); writer.Flush (); From e56891e80b174b4c9931a0b2ff4b2422ecf6e2dd Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 8 Dec 2019 21:35:41 +0900 Subject: [PATCH 2702/6294] [Modify] Use Encoding.UTF8 --- websocket-sharp/Net/HttpListenerResponse.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index 3b7369bee..b0ab29dd2 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -738,7 +738,7 @@ internal WebHeaderCollection WriteHeadersTo (MemoryStream destination) headers.InternalSet ("Set-Cookie", cookie.ToResponseString (), true); } - var enc = _contentEncoding ?? Encoding.Default; + var enc = Encoding.UTF8; var writer = new StreamWriter (destination, enc, 256); writer.Write ( From 6726e04afdc4402aacc6aef4600d5605e59ef794 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 9 Dec 2019 22:01:37 +0900 Subject: [PATCH 2703/6294] [Modify] Add it --- websocket-sharp/Net/HttpListenerResponse.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index b0ab29dd2..734387607 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -116,6 +116,17 @@ internal bool HeadersSent { } } + internal string StatusLine { + get { + return String.Format ( + "HTTP/{0} {1} {2}\r\n", + _version, + _statusCode, + _statusDescription + ); + } + } + #endregion #region Public Properties From cff65651051eeafdb53d98e8b41168b2d3cddd4d Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 10 Dec 2019 22:02:01 +0900 Subject: [PATCH 2704/6294] [Modify] Add it --- websocket-sharp/Net/HttpListenerResponse.cs | 90 +++++++++++++++++++++ 1 file changed, 90 insertions(+) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index 734387607..326aea408 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -106,6 +106,96 @@ internal bool CloseConnection { } } + internal WebHeaderCollection FullHeaders { + get { + var headers = new WebHeaderCollection (HttpHeaderType.Response, true); + + if (_headers != null) + headers.Add (_headers); + + if (_contentType != null) { + headers.InternalSet ( + "Content-Type", + createContentTypeHeaderText (_contentType, _contentEncoding), + true + ); + } + + if (headers["Server"] == null) + headers.InternalSet ("Server", "websocket-sharp/1.0", true); + + if (headers["Date"] == null) { + headers.InternalSet ( + "Date", + DateTime.UtcNow.ToString ("r", CultureInfo.InvariantCulture), + true + ); + } + + if (_sendChunked) { + headers.InternalSet ("Transfer-Encoding", "chunked", true); + } + else { + headers.InternalSet ( + "Content-Length", + _contentLength.ToString (CultureInfo.InvariantCulture), + true + ); + } + + /* + * Apache forces closing the connection for these status codes: + * - 400 Bad Request + * - 408 Request Timeout + * - 411 Length Required + * - 413 Request Entity Too Large + * - 414 Request-Uri Too Long + * - 500 Internal Server Error + * - 503 Service Unavailable + */ + var closeConn = !_context.Request.KeepAlive + || !_keepAlive + || _statusCode == 400 + || _statusCode == 408 + || _statusCode == 411 + || _statusCode == 413 + || _statusCode == 414 + || _statusCode == 500 + || _statusCode == 503; + + var reuses = _context.Connection.Reuses; + + if (closeConn || reuses >= 100) { + headers.InternalSet ("Connection", "close", true); + } + else { + headers.InternalSet ( + "Keep-Alive", + String.Format ("timeout=15,max={0}", 100 - reuses), + true + ); + + if (_context.Request.ProtocolVersion < HttpVersion.Version11) + headers.InternalSet ("Connection", "keep-alive", true); + } + + if (_location != null) + headers.InternalSet ("Location", _location, true); + + if (_cookies != null) { + foreach (var cookie in _cookies) { + headers.InternalSet ( + "Set-Cookie", + cookie.ToResponseString (), + true + ); + } + } + + return headers; + } + } + internal bool HeadersSent { get { return _headersSent; From 4af602179e99c5f290561d873f4844fe4f0aba7f Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 11 Dec 2019 19:54:20 +0900 Subject: [PATCH 2705/6294] [Modify] Replace it --- websocket-sharp/Net/ResponseStream.cs | 31 +++++++++++++++++++-------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/websocket-sharp/Net/ResponseStream.cs b/websocket-sharp/Net/ResponseStream.cs index 85059a407..0939dfbd3 100644 --- a/websocket-sharp/Net/ResponseStream.cs +++ b/websocket-sharp/Net/ResponseStream.cs @@ -166,21 +166,34 @@ private void flushBody (bool closing) private bool flushHeaders (bool closing) { - using (var buff = new MemoryStream ()) { - var headers = _response.WriteHeadersTo (buff); - var start = buff.Position; - var len = buff.Length - start; - if (len > 32768) + if (!_response.SendChunked) { + if (_response.ContentLength64 != _body.Length) return false; + } + + var statusLine = _response.StatusLine; + var headers = _response.FullHeaders; + + var buff = new MemoryStream (); + var enc = Encoding.UTF8; - if (!_response.SendChunked && _response.ContentLength64 != _body.Length) + using (var writer = new StreamWriter (buff, enc, 256)) { + writer.Write (statusLine); + writer.Write (headers.ToStringMultiValue (true)); + writer.Flush (); + + var start = enc.GetPreamble ().Length; + var len = buff.Length - start; + + if (len > 32768) return false; - _write (buff.GetBuffer (), (int) start, (int) len); - _response.CloseConnection = headers["Connection"] == "close"; - _response.HeadersSent = true; + _write (buff.GetBuffer (), start, (int) len); } + _response.CloseConnection = headers["Connection"] == "close"; + _response.HeadersSent = true; + return true; } From becf1e55fba6c427e073c585781bb8bc17a9e98a Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 12 Dec 2019 21:54:31 +0900 Subject: [PATCH 2706/6294] [Modify] Remove it --- websocket-sharp/Net/HttpListenerResponse.cs | 101 -------------------- 1 file changed, 101 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index 326aea408..543f6875a 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -756,107 +756,6 @@ private IEnumerable findCookie (Cookie cookie) #endregion - #region Internal Methods - - internal WebHeaderCollection WriteHeadersTo (MemoryStream destination) - { - var headers = new WebHeaderCollection (HttpHeaderType.Response, true); - - if (_headers != null) - headers.Add (_headers); - - if (_contentType != null) { - headers.InternalSet ( - "Content-Type", - createContentTypeHeaderText (_contentType, _contentEncoding), - true - ); - } - - if (headers["Server"] == null) - headers.InternalSet ("Server", "websocket-sharp/1.0", true); - - if (headers["Date"] == null) { - headers.InternalSet ( - "Date", - DateTime.UtcNow.ToString ("r", CultureInfo.InvariantCulture), - true - ); - } - - if (_sendChunked) { - headers.InternalSet ("Transfer-Encoding", "chunked", true); - } - else { - headers.InternalSet ( - "Content-Length", - _contentLength.ToString (CultureInfo.InvariantCulture), - true - ); - } - - /* - * Apache forces closing the connection for these status codes: - * - 400 Bad Request - * - 408 Request Timeout - * - 411 Length Required - * - 413 Request Entity Too Large - * - 414 Request-Uri Too Long - * - 500 Internal Server Error - * - 503 Service Unavailable - */ - var closeConn = !_context.Request.KeepAlive - || !_keepAlive - || _statusCode == 400 - || _statusCode == 408 - || _statusCode == 411 - || _statusCode == 413 - || _statusCode == 414 - || _statusCode == 500 - || _statusCode == 503; - - var reuses = _context.Connection.Reuses; - - if (closeConn || reuses >= 100) { - headers.InternalSet ("Connection", "close", true); - } - else { - headers.InternalSet ( - "Keep-Alive", - String.Format ("timeout=15,max={0}", 100 - reuses), - true - ); - - if (_context.Request.ProtocolVersion < HttpVersion.Version11) - headers.InternalSet ("Connection", "keep-alive", true); - } - - if (_location != null) - headers.InternalSet ("Location", _location, true); - - if (_cookies != null) { - foreach (var cookie in _cookies) - headers.InternalSet ("Set-Cookie", cookie.ToResponseString (), true); - } - - var enc = Encoding.UTF8; - var writer = new StreamWriter (destination, enc, 256); - - writer.Write ( - "HTTP/{0} {1} {2}\r\n", _version, _statusCode, _statusDescription - ); - - writer.Write (headers.ToStringMultiValue (true)); - writer.Flush (); - - // Assumes that the destination was at position 0. - destination.Position = enc.GetPreamble ().Length; - - return headers; - } - - #endregion - #region Public Methods /// From 8b396859f40933b66b75420c8a7198c8e6c98d27 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 13 Dec 2019 19:42:31 +0900 Subject: [PATCH 2707/6294] [Modify] Rename it --- websocket-sharp/Net/HttpListenerResponse.cs | 74 ++++++++++----------- 1 file changed, 37 insertions(+), 37 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index 543f6875a..b72309ca1 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -769,43 +769,6 @@ public void Abort () close (true); } - /// - /// Adds or updates an HTTP header with the specified name and value in - /// the headers for the response. - /// - /// - /// A that represents the name of the header to add. - /// - /// - /// A that represents the value of the header to add. - /// - /// - /// is or empty. - /// - /// - /// - /// or contains - /// an invalid character. - /// - /// - /// -or- - /// - /// - /// is a restricted header name. - /// - /// - /// - /// The length of is greater than 65,535 - /// characters. - /// - /// - /// The header cannot be allowed to add to the current headers. - /// - public void AddHeader (string name, string value) - { - Headers.Set (name, value); - } - /// /// Appends the specified cookie to the cookies sent with the response. /// @@ -1028,6 +991,43 @@ public void SetCookie (Cookie cookie) Cookies.Add (cookie); } + /// + /// Adds or updates an HTTP header with the specified name and value in + /// the headers for the response. + /// + /// + /// A that represents the name of the header to add. + /// + /// + /// A that represents the value of the header to add. + /// + /// + /// is or empty. + /// + /// + /// + /// or contains + /// an invalid character. + /// + /// + /// -or- + /// + /// + /// is a restricted header name. + /// + /// + /// + /// The length of is greater than 65,535 + /// characters. + /// + /// + /// The header cannot be allowed to add to the current headers. + /// + public void SetHeader (string name, string value) + { + Headers.Set (name, value); + } + #endregion #region Explicit Interface Implementations From bfa4e21d4c005af82b4681e8683918addc0ad417 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 14 Dec 2019 21:42:33 +0900 Subject: [PATCH 2708/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerResponse.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index b72309ca1..ec7209ef0 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -996,10 +996,10 @@ public void SetCookie (Cookie cookie) /// the headers for the response. /// /// - /// A that represents the name of the header to add. + /// A that represents the name of the header to set. /// /// - /// A that represents the value of the header to add. + /// A that represents the value of the header to set. /// /// /// is or empty. @@ -1021,7 +1021,7 @@ public void SetCookie (Cookie cookie) /// characters. /// /// - /// The header cannot be allowed to add to the current headers. + /// The header cannot be allowed to set in the current headers. /// public void SetHeader (string name, string value) { From 92b2bcbaf0500d231ec1a601ac77679b16e1797f Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 15 Dec 2019 21:39:12 +0900 Subject: [PATCH 2709/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerResponse.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index ec7209ef0..4e0a6059a 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -233,6 +233,9 @@ internal string StatusLine { /// /// if no encoding is specified. /// + /// + /// The default value is . + /// /// /// /// This instance is closed. From 77374c3a9c7daf972ffc73f6440f72d8ab6a90b2 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 16 Dec 2019 21:47:36 +0900 Subject: [PATCH 2710/6294] [Modify] Throw an exception --- websocket-sharp/Net/HttpListenerResponse.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index 4e0a6059a..0db7b7e6c 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -249,6 +249,11 @@ public Encoding ContentEncoding { if (_disposed) throw new ObjectDisposedException (GetType ().ToString ()); + if (_headersSent) { + var msg = "The response is already being sent."; + throw new InvalidOperationException (msg); + } + _contentEncoding = value; } } From 60b6f041855acc0dec3a186be4bbfe316e51b062 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 16 Dec 2019 21:50:10 +0900 Subject: [PATCH 2711/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerResponse.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index 0db7b7e6c..a54275202 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -237,6 +237,9 @@ internal string StatusLine { /// The default value is . /// /// + /// + /// The response is already being sent. + /// /// /// This instance is closed. /// From 7e38b36c682c937cf7edd81d45d77b5ab102ca4b Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 17 Dec 2019 22:13:55 +0900 Subject: [PATCH 2712/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerResponse.cs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index a54275202..59d7b20b9 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -266,8 +266,16 @@ public Encoding ContentEncoding { /// the response. /// /// - /// A that represents the value of the Content-Length - /// header. + /// + /// A that represents the number of bytes in + /// the entity body data. + /// + /// + /// It is used for the value of the Content-Length header. + /// + /// + /// The default value is zero. + /// /// /// /// The value specified for a set operation is less than zero. From 0c39408b6fc81e46c633482a08c7714daff73dfa Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 17 Dec 2019 22:19:06 +0900 Subject: [PATCH 2713/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerResponse.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index 59d7b20b9..ab40ad6d5 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -323,6 +323,9 @@ public long ContentLength64 { /// /// if no media type is specified. /// + /// + /// The default value is . + /// /// /// /// The value specified for a set operation is an empty string. From fffe325d44711bbfae849c7812b967cad124bb8c Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 18 Dec 2019 22:06:48 +0900 Subject: [PATCH 2714/6294] [Modify] Throw an exception --- websocket-sharp/Net/HttpListenerResponse.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index ab40ad6d5..062c1ce4c 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -342,6 +342,11 @@ public string ContentType { if (_disposed) throw new ObjectDisposedException (GetType ().ToString ()); + if (_headersSent) { + var msg = "The response is already being sent."; + throw new InvalidOperationException (msg); + } + if (value == null) { _contentType = null; return; From 813455317c46eb86709cb8a66a05cc654489259f Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 18 Dec 2019 22:08:43 +0900 Subject: [PATCH 2715/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerResponse.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index 062c1ce4c..496578adb 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -330,6 +330,9 @@ public long ContentLength64 { /// /// The value specified for a set operation is an empty string. /// + /// + /// The response is already being sent. + /// /// /// This instance is closed. /// From 7fa9e6242ae2e7c0d59ad59a9550fac50eee5207 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 19 Dec 2019 20:28:19 +0900 Subject: [PATCH 2716/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerResponse.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index 496578adb..241676645 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -546,6 +546,9 @@ public Version ProtocolVersion { /// /// if no redirect location is specified. /// + /// + /// The default value is . + /// /// /// /// The value specified for a set operation is not an absolute URL. From 197166b48b2f116865a73ab6dbf3dab8d0c66431 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 20 Dec 2019 19:38:44 +0900 Subject: [PATCH 2717/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerResponse.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index 241676645..0c72b565f 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -540,8 +540,11 @@ public Version ProtocolVersion { /// /// /// - /// A that represents the value of the Location - /// response-header. + /// A that represents the absolute URL for + /// the redirect location. + /// + /// + /// It is used for the value of the Location header. /// /// /// if no redirect location is specified. From 889e6d30b6b5f9ff3cf19f00706c741e8cd7bff3 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 21 Dec 2019 22:10:26 +0900 Subject: [PATCH 2718/6294] [Modify] Throw an exception --- websocket-sharp/Net/HttpListenerResponse.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index 0c72b565f..a49e3ed07 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -568,6 +568,11 @@ public string RedirectLocation { if (_disposed) throw new ObjectDisposedException (GetType ().ToString ()); + if (_headersSent) { + var msg = "The response is already being sent."; + throw new InvalidOperationException (msg); + } + if (value == null) { _location = null; return; From 2be0c4c9b98ca525da2828127598ac2c6030a04c Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 21 Dec 2019 22:12:38 +0900 Subject: [PATCH 2719/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerResponse.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index a49e3ed07..01b989db9 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -556,6 +556,9 @@ public Version ProtocolVersion { /// /// The value specified for a set operation is not an absolute URL. /// + /// + /// The response is already being sent. + /// /// /// This instance is closed. /// From dcbc93a606f58972f972ec88fd280b8ef8190851 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 22 Dec 2019 21:33:02 +0900 Subject: [PATCH 2720/6294] [Modify] Replace it --- websocket-sharp/Net/HttpListenerResponse.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index 01b989db9..85d75c3f4 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -581,8 +581,8 @@ public string RedirectLocation { return; } - if (!value.MaybeUri ()) - throw new ArgumentException ("Not an absolute URL.", "value"); + if (value.Length == 0) + throw new ArgumentException ("An empty string.", "value"); Uri uri; if (!Uri.TryCreate (value, UriKind.Absolute, out uri)) From 90faa410b7f79c4bfcd39a1910356192fb39ad4a Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 22 Dec 2019 21:38:42 +0900 Subject: [PATCH 2721/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerResponse.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index 85d75c3f4..f26f12340 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -554,7 +554,15 @@ public Version ProtocolVersion { /// /// /// - /// The value specified for a set operation is not an absolute URL. + /// + /// The value specified for a set operation is an empty string. + /// + /// + /// -or- + /// + /// + /// The value specified for a set operation is not an absolute URL. + /// /// /// /// The response is already being sent. From 794c2184b4e14d90500d658fcb7083f929d2e82b Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 23 Dec 2019 22:18:53 +0900 Subject: [PATCH 2722/6294] [Modify] Replace it --- websocket-sharp/Net/HttpListenerResponse.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index f26f12340..6d66e1c03 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -1005,8 +1005,8 @@ public void Redirect (string url) if (url == null) throw new ArgumentNullException ("url"); - if (!url.MaybeUri ()) - throw new ArgumentException ("Not an absolute URL.", "url"); + if (url.Length == 0) + throw new ArgumentException ("An empty string.", "url"); Uri uri; if (!Uri.TryCreate (url, UriKind.Absolute, out uri)) From a568bece8764f163e660c475e5bb2d833dd17b2d Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 23 Dec 2019 22:24:54 +0900 Subject: [PATCH 2723/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerResponse.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index 6d66e1c03..622e556fe 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -984,7 +984,15 @@ public void CopyFrom (HttpListenerResponse templateResponse) /// is . /// /// - /// is not an absolute URL. + /// + /// is an empty string. + /// + /// + /// -or- + /// + /// + /// is not an absolute URL. + /// /// /// /// The response is already being sent. From f9e37388f8954e4031144549fd98e38ee16edfa3 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 23 Dec 2019 22:28:11 +0900 Subject: [PATCH 2724/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerResponse.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index 622e556fe..516a3c974 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -977,8 +977,8 @@ public void CopyFrom (HttpListenerResponse templateResponse) /// 302, and the property to "Found". /// /// - /// A that represents the URL to which the client is - /// redirected to locate a requested resource. + /// A that represents the absolute URL to which + /// the client is redirected to locate a requested resource. /// /// /// is . From 8064569d41d63fb981530a034b7eebf7e9efa9e1 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 24 Dec 2019 16:11:47 +0900 Subject: [PATCH 2725/6294] [Modify] Use the Uri class --- websocket-sharp/Net/HttpListenerResponse.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index 516a3c974..0caddbe00 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -72,7 +72,7 @@ public sealed class HttpListenerResponse : IDisposable private WebHeaderCollection _headers; private bool _headersSent; private bool _keepAlive; - private string _location; + private Uri _location; private ResponseStream _outputStream; private bool _sendChunked; private int _statusCode; @@ -180,7 +180,7 @@ internal WebHeaderCollection FullHeaders { } if (_location != null) - headers.InternalSet ("Location", _location, true); + headers.InternalSet ("Location", _location.AbsoluteUri, true); if (_cookies != null) { foreach (var cookie in _cookies) { @@ -572,7 +572,7 @@ public Version ProtocolVersion { /// public string RedirectLocation { get { - return _location; + return _location != null ? _location.OriginalString : null; } set { @@ -596,7 +596,7 @@ public string RedirectLocation { if (!Uri.TryCreate (value, UriKind.Absolute, out uri)) throw new ArgumentException ("Not an absolute URL.", "value"); - _location = value; + _location = uri; } } @@ -1020,7 +1020,7 @@ public void Redirect (string url) if (!Uri.TryCreate (url, UriKind.Absolute, out uri)) throw new ArgumentException ("Not an absolute URL.", "url"); - _location = url; + _location = uri; _statusCode = 302; _statusDescription = "Found"; } From dfa8c0b248037778cd0d481d2ddf39991792aa30 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 25 Dec 2019 21:45:07 +0900 Subject: [PATCH 2726/6294] [Modify] Rename it --- websocket-sharp/Net/HttpListenerResponse.cs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index 0caddbe00..82439610e 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -72,8 +72,8 @@ public sealed class HttpListenerResponse : IDisposable private WebHeaderCollection _headers; private bool _headersSent; private bool _keepAlive; - private Uri _location; private ResponseStream _outputStream; + private Uri _redirectLocation; private bool _sendChunked; private int _statusCode; private string _statusDescription; @@ -179,8 +179,8 @@ internal WebHeaderCollection FullHeaders { headers.InternalSet ("Connection", "keep-alive", true); } - if (_location != null) - headers.InternalSet ("Location", _location.AbsoluteUri, true); + if (_redirectLocation != null) + headers.InternalSet ("Location", _redirectLocation.AbsoluteUri, true); if (_cookies != null) { foreach (var cookie in _cookies) { @@ -572,7 +572,9 @@ public Version ProtocolVersion { /// public string RedirectLocation { get { - return _location != null ? _location.OriginalString : null; + return _redirectLocation != null + ? _redirectLocation.OriginalString + : null; } set { @@ -585,7 +587,7 @@ public string RedirectLocation { } if (value == null) { - _location = null; + _redirectLocation = null; return; } @@ -596,7 +598,7 @@ public string RedirectLocation { if (!Uri.TryCreate (value, UriKind.Absolute, out uri)) throw new ArgumentException ("Not an absolute URL.", "value"); - _location = uri; + _redirectLocation = uri; } } @@ -1020,7 +1022,7 @@ public void Redirect (string url) if (!Uri.TryCreate (url, UriKind.Absolute, out uri)) throw new ArgumentException ("Not an absolute URL.", "url"); - _location = uri; + _redirectLocation = uri; _statusCode = 302; _statusDescription = "Found"; } From 7df1ec19fc06c95f7fd78477b6c62151145b86c0 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 26 Dec 2019 19:44:37 +0900 Subject: [PATCH 2727/6294] [Modify] Edit it --- websocket-sharp/Ext.cs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index c6b656302..904d4bcde 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1321,13 +1321,19 @@ public static void Emit ( } /// - /// Gets the description of the specified HTTP status . + /// Gets the description of the specified HTTP status code. /// /// - /// A that represents the description of the HTTP status code. + /// A that represents the description of + /// the HTTP status code. /// /// - /// One of enum values, indicates the HTTP status code. + /// + /// One of the enum values. + /// + /// + /// It specifies the HTTP status code. + /// /// public static string GetDescription (this HttpStatusCode code) { From 5ca13f5009f59c675e045d539c60f7933febad6c Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 27 Dec 2019 20:51:47 +0900 Subject: [PATCH 2728/6294] [Modify] Edit it --- websocket-sharp/Ext.cs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 904d4bcde..0102d8cdd 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1341,13 +1341,19 @@ public static string GetDescription (this HttpStatusCode code) } /// - /// Gets the description of the specified HTTP status . + /// Gets the description of the specified HTTP status code. /// /// - /// A that represents the description of the HTTP status code. + /// + /// A that represents the description of + /// the HTTP status code. + /// + /// + /// An empty string if the description is not present. + /// /// /// - /// An that represents the HTTP status code. + /// An that specifies the HTTP status code. /// public static string GetStatusDescription (this int code) { From 0862ed77a94b8dbd1704990ee40e8be2c85e3da4 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 28 Dec 2019 21:54:32 +0900 Subject: [PATCH 2729/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 0102d8cdd..8a87be273 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1290,10 +1290,14 @@ Action error /// /// A that contains no event data. /// - public static void Emit (this EventHandler eventHandler, object sender, EventArgs e) + public static void Emit ( + this EventHandler eventHandler, object sender, EventArgs e + ) { - if (eventHandler != null) - eventHandler (sender, e); + if (eventHandler == null) + return; + + eventHandler (sender, e); } /// From 44129b0c75a5aec41d61b52100c55fe06db329e4 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 28 Dec 2019 21:57:50 +0900 Subject: [PATCH 2730/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 8a87be273..46ff62125 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1317,11 +1317,14 @@ public static void Emit ( /// The type of the event data generated by the event. /// public static void Emit ( - this EventHandler eventHandler, object sender, TEventArgs e) + this EventHandler eventHandler, object sender, TEventArgs e + ) where TEventArgs : EventArgs { - if (eventHandler != null) - eventHandler (sender, e); + if (eventHandler == null) + return; + + eventHandler (sender, e); } /// From 9d164812a29c85f2f3e0f091e020124cc7f72d53 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 29 Dec 2019 19:46:44 +0900 Subject: [PATCH 2731/6294] [Modify] To internal --- websocket-sharp/Ext.cs | 32 ++++++++++---------------------- 1 file changed, 10 insertions(+), 22 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 46ff62125..d43f49524 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -389,6 +389,16 @@ internal static byte[] DecompressToArray (this Stream stream, CompressionMethod : stream.ToByteArray (); } + internal static void Emit ( + this EventHandler eventHandler, object sender, EventArgs e + ) + { + if (eventHandler == null) + return; + + eventHandler (sender, e); + } + /// /// Determines whether the specified equals the specified , /// and invokes the specified Action<int> delegate at the same time. @@ -1278,28 +1288,6 @@ Action error #region Public Methods - /// - /// Emits the specified delegate if it isn't . - /// - /// - /// A to emit. - /// - /// - /// An from which emits this . - /// - /// - /// A that contains no event data. - /// - public static void Emit ( - this EventHandler eventHandler, object sender, EventArgs e - ) - { - if (eventHandler == null) - return; - - eventHandler (sender, e); - } - /// /// Emits the specified EventHandler<TEventArgs> delegate if it isn't /// . From 6493f902389dd77d941b2bf9eb2cd6140943347f Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 30 Dec 2019 20:15:05 +0900 Subject: [PATCH 2732/6294] [Modify] To internal --- websocket-sharp/Ext.cs | 38 +++++++++++--------------------------- 1 file changed, 11 insertions(+), 27 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index d43f49524..027a9b437 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -399,6 +399,17 @@ internal static void Emit ( eventHandler (sender, e); } + internal static void Emit ( + this EventHandler eventHandler, object sender, TEventArgs e + ) + where TEventArgs : EventArgs + { + if (eventHandler == null) + return; + + eventHandler (sender, e); + } + /// /// Determines whether the specified equals the specified , /// and invokes the specified Action<int> delegate at the same time. @@ -1288,33 +1299,6 @@ Action error #region Public Methods - /// - /// Emits the specified EventHandler<TEventArgs> delegate if it isn't - /// . - /// - /// - /// An EventHandler<TEventArgs> to emit. - /// - /// - /// An from which emits this . - /// - /// - /// A TEventArgs that represents the event data. - /// - /// - /// The type of the event data generated by the event. - /// - public static void Emit ( - this EventHandler eventHandler, object sender, TEventArgs e - ) - where TEventArgs : EventArgs - { - if (eventHandler == null) - return; - - eventHandler (sender, e); - } - /// /// Gets the description of the specified HTTP status code. /// From 93db5dba56af6510c38d7d8f9651e695b9762be0 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 31 Dec 2019 17:26:20 +0900 Subject: [PATCH 2733/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerResponse.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index 82439610e..4ddd86a49 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -648,8 +648,8 @@ public bool SendChunked { /// the response to the request. /// /// - /// The default value is 200. It is same as - /// . + /// The default value is 200. It indicates that the request has + /// succeeded. /// /// /// From 21cb8a0e24918a4069c76875ce159e59c11b6868 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 1 Jan 2020 17:10:01 +0900 Subject: [PATCH 2734/6294] [Modify] Add it --- websocket-sharp/Ext.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 027a9b437..b0a50d0f7 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -652,6 +652,19 @@ internal static bool IsPortNumber (this int value) return value > 0 && value < 65536; } + internal static bool IsPrintable (this string value) + { + foreach (var c in value) { + if (c < 0x20) + return false; + + if (c > 0x7e) + return false; + } + + return true; + } + internal static bool IsReserved (this ushort code) { return code == 1004 From 590674929ef51f36d68187c5b82e6452e7fcba3a Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 1 Jan 2020 17:13:11 +0900 Subject: [PATCH 2735/6294] [Modify] 2020 --- LICENSE.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LICENSE.txt b/LICENSE.txt index c978848b3..71d3e3128 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2010-2019 sta.blockhead +Copyright (c) 2010-2020 sta.blockhead Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal From 74fdd0e6884a8de12e3eeace988ca67ee2c41963 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 2 Jan 2020 22:01:22 +0900 Subject: [PATCH 2736/6294] [Modify] Replace it --- websocket-sharp/Net/HttpListenerResponse.cs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index 4ddd86a49..b69466779 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -743,12 +743,7 @@ public string StatusDescription { return; } - if (!value.IsText ()) { - var msg = "It contains an invalid character."; - throw new ArgumentException (msg, "value"); - } - - if (value.IndexOfAny (new[] { '\r', '\n' }) > -1) { + if (!value.IsPrintable ()) { var msg = "It contains an invalid character."; throw new ArgumentException (msg, "value"); } From 18f77fa521f9f8dd8e2b9ee67151737ea9422ef6 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 3 Jan 2020 17:26:41 +0900 Subject: [PATCH 2737/6294] [Modify] Throw an exception --- websocket-sharp/Net/HttpListenerResponse.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index b69466779..a220fd551 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -358,6 +358,11 @@ public string ContentType { if (value.Length == 0) throw new ArgumentException ("An empty string.", "value"); + if (!value.IsPrintable ()) { + var msg = "It contains an invalid character."; + throw new ArgumentException (msg, "value"); + } + _contentType = value; } } From 4f236579d485395e25aad49cf572b888024bc160 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 4 Jan 2020 16:14:07 +0900 Subject: [PATCH 2738/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerResponse.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index a220fd551..62b5edd09 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -328,7 +328,15 @@ public long ContentLength64 { /// /// /// - /// The value specified for a set operation is an empty string. + /// + /// The value specified for a set operation is an empty string. + /// + /// + /// -or- + /// + /// + /// The value specified for a set operation contains an invalid character. + /// /// /// /// The response is already being sent. From 73aef37b0e02fb6041c4f8f0b97c125c4dd21486 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 5 Jan 2020 22:05:18 +0900 Subject: [PATCH 2739/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerResponse.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index 62b5edd09..cec3ee33b 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -249,8 +249,10 @@ public Encoding ContentEncoding { } set { - if (_disposed) - throw new ObjectDisposedException (GetType ().ToString ()); + if (_disposed) { + var name = GetType ().ToString (); + throw new ObjectDisposedException (name); + } if (_headersSent) { var msg = "The response is already being sent."; From 144e78b1b9fedcddc44eef6e17e89f88ad162b24 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 6 Jan 2020 22:15:41 +0900 Subject: [PATCH 2740/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerResponse.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index cec3ee33b..558f5d53a 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -294,8 +294,10 @@ public long ContentLength64 { } set { - if (_disposed) - throw new ObjectDisposedException (GetType ().ToString ()); + if (_disposed) { + var name = GetType ().ToString (); + throw new ObjectDisposedException (name); + } if (_headersSent) { var msg = "The response is already being sent."; From c1ae944c65d8abc960ac70597a1f7514542f26b1 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 7 Jan 2020 22:26:34 +0900 Subject: [PATCH 2741/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerResponse.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index 558f5d53a..8b2354244 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -354,8 +354,10 @@ public string ContentType { } set { - if (_disposed) - throw new ObjectDisposedException (GetType ().ToString ()); + if (_disposed) { + var name = GetType ().ToString (); + throw new ObjectDisposedException (name); + } if (_headersSent) { var msg = "The response is already being sent."; From 90e935f835a38583e2d8cf000c61f45bb9f19aec Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 7 Jan 2020 22:28:36 +0900 Subject: [PATCH 2742/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerResponse.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index 8b2354244..4347e13ed 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -369,8 +369,10 @@ public string ContentType { return; } - if (value.Length == 0) - throw new ArgumentException ("An empty string.", "value"); + if (value.Length == 0) { + var msg = "An empty string."; + throw new ArgumentException (msg, "value"); + } if (!value.IsPrintable ()) { var msg = "It contains an invalid character."; From 897a99e86d2e4c784cb2f9f58a8751d3c7eb47a1 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 8 Jan 2020 21:43:58 +0900 Subject: [PATCH 2743/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerResponse.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index 4347e13ed..610199b49 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -314,12 +314,13 @@ public long ContentLength64 { } /// - /// Gets or sets the media type of the entity body included in the response. + /// Gets or sets the media type of the entity body included in + /// the response. /// /// /// - /// A that represents the media type of the entity - /// body. + /// A that represents the media type of + /// the entity body. /// /// /// It is used for the value of the Content-Type header. @@ -339,7 +340,8 @@ public long ContentLength64 { /// -or- /// /// - /// The value specified for a set operation contains an invalid character. + /// The value specified for a set operation contains + /// an invalid character. /// /// /// From 82265ca289a583fad29f52620979cdbbdb0982ad Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 9 Jan 2020 20:09:23 +0900 Subject: [PATCH 2744/6294] [Modify] Add it --- websocket-sharp/Net/HttpListenerResponse.cs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index 610199b49..394c3afeb 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -826,6 +826,22 @@ private IEnumerable findCookie (Cookie cookie) } } + private static bool isValidForContentType (string value) + { + foreach (var c in value) { + if (c < 0x20) + return false; + + if (c > 0x7e) + return false; + + if ("()<>@:\\[]?{}".IndexOf (c) > -1) + return false; + } + + return true; + } + #endregion #region Public Methods From 759c5f6719422795b438be03530a8919cf3f60c1 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 9 Jan 2020 20:13:04 +0900 Subject: [PATCH 2745/6294] [Modify] Replace it --- websocket-sharp/Net/HttpListenerResponse.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index 394c3afeb..ed3c148bb 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -376,7 +376,7 @@ public string ContentType { throw new ArgumentException (msg, "value"); } - if (!value.IsPrintable ()) { + if (!isValidForContentType (value)) { var msg = "It contains an invalid character."; throw new ArgumentException (msg, "value"); } From c8f022fb8fe747c452405e671013c58997e1fd6c Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 10 Jan 2020 19:45:38 +0900 Subject: [PATCH 2746/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerResponse.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index ed3c148bb..8c53c6f9c 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -463,8 +463,10 @@ public bool KeepAlive { } set { - if (_disposed) - throw new ObjectDisposedException (GetType ().ToString ()); + if (_disposed) { + var name = GetType ().ToString (); + throw new ObjectDisposedException (name); + } if (_headersSent) { var msg = "The response is already being sent."; From a5e9b0cb1766a77190f9134b128ead14b02dd7cf Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 10 Jan 2020 19:49:37 +0900 Subject: [PATCH 2747/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerResponse.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index 8c53c6f9c..d5f243fa3 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -489,8 +489,10 @@ public bool KeepAlive { /// public Stream OutputStream { get { - if (_disposed) - throw new ObjectDisposedException (GetType ().ToString ()); + if (_disposed) { + var name = GetType ().ToString (); + throw new ObjectDisposedException (name); + } if (_outputStream == null) _outputStream = _context.Connection.GetResponseStream (); From f0aa1ed6f5436433ccc6c66fd76071a537e35fe0 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 11 Jan 2020 21:39:30 +0900 Subject: [PATCH 2748/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerResponse.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index d5f243fa3..e12d50ee4 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -536,8 +536,10 @@ public Version ProtocolVersion { } set { - if (_disposed) - throw new ObjectDisposedException (GetType ().ToString ()); + if (_disposed) { + var name = GetType ().ToString (); + throw new ObjectDisposedException (name); + } if (_headersSent) { var msg = "The response is already being sent."; From bfbc8ec186c611ed6b14019608c08d5e2908c334 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 12 Jan 2020 19:33:01 +0900 Subject: [PATCH 2749/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerResponse.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index e12d50ee4..ed4b62cd9 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -607,8 +607,10 @@ public string RedirectLocation { } set { - if (_disposed) - throw new ObjectDisposedException (GetType ().ToString ()); + if (_disposed) { + var name = GetType ().ToString (); + throw new ObjectDisposedException (name); + } if (_headersSent) { var msg = "The response is already being sent."; From ef2d7ac99c79e740a80b6a4caccd058481bb696a Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 12 Jan 2020 19:35:07 +0900 Subject: [PATCH 2750/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerResponse.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index ed4b62cd9..e81557d46 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -622,8 +622,10 @@ public string RedirectLocation { return; } - if (value.Length == 0) - throw new ArgumentException ("An empty string.", "value"); + if (value.Length == 0) { + var msg = "An empty string."; + throw new ArgumentException (msg, "value"); + } Uri uri; if (!Uri.TryCreate (value, UriKind.Absolute, out uri)) From 7284b6f97cbd9be2e728ece21f7856715c9c6b5b Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 13 Jan 2020 22:06:40 +0900 Subject: [PATCH 2751/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerResponse.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index e81557d46..5b72b2f03 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -628,8 +628,10 @@ public string RedirectLocation { } Uri uri; - if (!Uri.TryCreate (value, UriKind.Absolute, out uri)) - throw new ArgumentException ("Not an absolute URL.", "value"); + if (!Uri.TryCreate (value, UriKind.Absolute, out uri)) { + var msg = "Not an absolute URL."; + throw new ArgumentException (msg, "value"); + } _redirectLocation = uri; } From 5ddf6b4b321f0983e8309a5f4d264903689e892c Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 13 Jan 2020 22:10:10 +0900 Subject: [PATCH 2752/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerResponse.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index 5b72b2f03..0cd772c59 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -662,8 +662,10 @@ public bool SendChunked { } set { - if (_disposed) - throw new ObjectDisposedException (GetType ().ToString ()); + if (_disposed) { + var name = GetType ().ToString (); + throw new ObjectDisposedException (name); + } if (_headersSent) { var msg = "The response is already being sent."; From 448231e1c6e9024b69a023d53ae627241fd8730b Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 14 Jan 2020 20:49:11 +0900 Subject: [PATCH 2753/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerResponse.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index 0cd772c59..ec1e3f8d3 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -709,8 +709,10 @@ public int StatusCode { } set { - if (_disposed) - throw new ObjectDisposedException (GetType ().ToString ()); + if (_disposed) { + var name = GetType ().ToString (); + throw new ObjectDisposedException (name); + } if (_headersSent) { var msg = "The response is already being sent."; From fcbff44776ac52ebe23cdbebde16c695568b9cbd Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 14 Jan 2020 20:52:40 +0900 Subject: [PATCH 2754/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerResponse.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index ec1e3f8d3..dd3090e49 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -766,8 +766,10 @@ public string StatusDescription { } set { - if (_disposed) - throw new ObjectDisposedException (GetType ().ToString ()); + if (_disposed) { + var name = GetType ().ToString (); + throw new ObjectDisposedException (name); + } if (_headersSent) { var msg = "The response is already being sent."; From a93c894e60431d934701004f96ae19f993cc58c3 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 15 Jan 2020 19:37:42 +0900 Subject: [PATCH 2755/6294] [Modify] Add it --- websocket-sharp/Net/HttpListenerResponse.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index dd3090e49..4bcb633f4 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -860,6 +860,19 @@ private static bool isValidForContentType (string value) return true; } + private static bool isValidForStatusDescription (string value) + { + foreach (var c in value) { + if (c < 0x20) + return false; + + if (c > 0x7e) + return false; + } + + return true; + } + #endregion #region Public Methods From a1e56b525125ac6a363ee17976658f8cea07782d Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 15 Jan 2020 19:41:27 +0900 Subject: [PATCH 2756/6294] [Modify] Replace it --- websocket-sharp/Net/HttpListenerResponse.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index 4bcb633f4..6b7dc8213 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -784,7 +784,7 @@ public string StatusDescription { return; } - if (!value.IsPrintable ()) { + if (!isValidForStatusDescription (value)) { var msg = "It contains an invalid character."; throw new ArgumentException (msg, "value"); } From 14b0c2f711d3304b35f47994a05bd516638966aa Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 16 Jan 2020 21:45:53 +0900 Subject: [PATCH 2757/6294] [Modify] Remove it --- websocket-sharp/Ext.cs | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index b0a50d0f7..027a9b437 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -652,19 +652,6 @@ internal static bool IsPortNumber (this int value) return value > 0 && value < 65536; } - internal static bool IsPrintable (this string value) - { - foreach (var c in value) { - if (c < 0x20) - return false; - - if (c > 0x7e) - return false; - } - - return true; - } - internal static bool IsReserved (this ushort code) { return code == 1004 From a3b408001b6194a7e07bad688aafd160720642f9 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 16 Jan 2020 21:52:48 +0900 Subject: [PATCH 2758/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerResponse.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index 6b7dc8213..2dff55c68 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -972,8 +972,10 @@ public void Close () /// public void Close (byte[] responseEntity, bool willBlock) { - if (_disposed) - throw new ObjectDisposedException (GetType ().ToString ()); + if (_disposed) { + var name = GetType ().ToString (); + throw new ObjectDisposedException (name); + } if (responseEntity == null) throw new ArgumentNullException ("responseEntity"); From d77475aa0fdd0198688a50aefb0732c164006c0c Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 17 Jan 2020 19:40:55 +0900 Subject: [PATCH 2759/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerResponse.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index 2dff55c68..e8ebada96 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -1071,8 +1071,10 @@ public void CopyFrom (HttpListenerResponse templateResponse) /// public void Redirect (string url) { - if (_disposed) - throw new ObjectDisposedException (GetType ().ToString ()); + if (_disposed) { + var name = GetType ().ToString (); + throw new ObjectDisposedException (name); + } if (_headersSent) { var msg = "The response is already being sent."; From 88ca7f936d6d010531c25fbff6aa64f225e84910 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 17 Jan 2020 19:44:36 +0900 Subject: [PATCH 2760/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerResponse.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index e8ebada96..ed6f695e8 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -1084,8 +1084,10 @@ public void Redirect (string url) if (url == null) throw new ArgumentNullException ("url"); - if (url.Length == 0) - throw new ArgumentException ("An empty string.", "url"); + if (url.Length == 0) { + var msg = "An empty string."; + throw new ArgumentException (msg, "url"); + } Uri uri; if (!Uri.TryCreate (url, UriKind.Absolute, out uri)) From 946bf20b657fd56452a6bfb08895eca55af128a9 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 18 Jan 2020 21:47:52 +0900 Subject: [PATCH 2761/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerResponse.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index ed6f695e8..0c7b8c225 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -1090,8 +1090,10 @@ public void Redirect (string url) } Uri uri; - if (!Uri.TryCreate (url, UriKind.Absolute, out uri)) - throw new ArgumentException ("Not an absolute URL.", "url"); + if (!Uri.TryCreate (url, UriKind.Absolute, out uri)) { + var msg = "Not an absolute URL."; + throw new ArgumentException (msg, "url"); + } _redirectLocation = uri; _statusCode = 302; From 0ef4171add41efc2650888878d0f41dcd95baff8 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 19 Jan 2020 17:22:47 +0900 Subject: [PATCH 2762/6294] [Modify] Add it --- websocket-sharp/Net/HttpListenerResponse.cs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index 0c7b8c225..c06a04e9e 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -820,6 +820,25 @@ private void close (bool force) _context.Connection.Close (force); } + private void close (byte[] responseEntity, int bufferLength, bool willBlock) + { + var output = OutputStream; + + if (willBlock) { + output.WriteBytes (responseEntity, bufferLength); + close (false); + + return; + } + + output.WriteBytesAsync ( + responseEntity, + bufferLength, + () => close (false), + null + ); + } + private static string createContentTypeHeaderText ( string value, Encoding encoding ) From eb10d302201f49166032a440e2fda5df93789afc Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 20 Jan 2020 21:20:20 +0900 Subject: [PATCH 2763/6294] [Modify] For long length data --- websocket-sharp/Net/HttpListenerResponse.cs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index c06a04e9e..62732949b 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -999,11 +999,17 @@ public void Close (byte[] responseEntity, bool willBlock) if (responseEntity == null) throw new ArgumentNullException ("responseEntity"); - var len = responseEntity.Length; + var len = responseEntity.LongLength; + + if (len > Int32.MaxValue) { + close (responseEntity, 1024, willBlock); + return; + } + var output = OutputStream; if (willBlock) { - output.Write (responseEntity, 0, len); + output.Write (responseEntity, 0, (int) len); close (false); return; @@ -1012,7 +1018,7 @@ public void Close (byte[] responseEntity, bool willBlock) output.BeginWrite ( responseEntity, 0, - len, + (int) len, ar => { output.EndWrite (ar); close (false); From 17a5645c25c230d6db7235430e1ded3ed234a0fa Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 20 Jan 2020 21:24:44 +0900 Subject: [PATCH 2764/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerResponse.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index 62732949b..a0bb69dba 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -1006,21 +1006,21 @@ public void Close (byte[] responseEntity, bool willBlock) return; } - var output = OutputStream; + var stream = OutputStream; if (willBlock) { - output.Write (responseEntity, 0, (int) len); + stream.Write (responseEntity, 0, (int) len); close (false); return; } - output.BeginWrite ( + stream.BeginWrite ( responseEntity, 0, (int) len, ar => { - output.EndWrite (ar); + stream.EndWrite (ar); close (false); }, null From ead65d18ec0b68c1f955b0e3dd39bf37d9237c2c Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 21 Jan 2020 21:35:38 +0900 Subject: [PATCH 2765/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerResponse.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index a0bb69dba..ca23216c1 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -980,8 +980,8 @@ public void Close () /// An array of that contains the entity body data. /// /// - /// true if this method blocks execution while flushing the stream to - /// the client; otherwise, false. + /// true if this method blocks execution while flushing the stream + /// to the client; otherwise, false. /// /// /// is . From 4e003b9c7ab618943d2e1e18c642bcbf6bc75b05 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 21 Jan 2020 21:39:20 +0900 Subject: [PATCH 2766/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerResponse.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index ca23216c1..a2cade973 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -822,16 +822,16 @@ private void close (bool force) private void close (byte[] responseEntity, int bufferLength, bool willBlock) { - var output = OutputStream; + var stream = OutputStream; if (willBlock) { - output.WriteBytes (responseEntity, bufferLength); + stream.WriteBytes (responseEntity, bufferLength); close (false); return; } - output.WriteBytesAsync ( + stream.WriteBytesAsync ( responseEntity, bufferLength, () => close (false), From 52d5d6138867b7522fe9b2b41aaa3d3c894145f1 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 22 Jan 2020 19:50:52 +0900 Subject: [PATCH 2767/6294] [Modify] Replace it --- Example3/Program.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Example3/Program.cs b/Example3/Program.cs index 939bfed89..b9699531f 100644 --- a/Example3/Program.cs +++ b/Example3/Program.cs @@ -108,7 +108,8 @@ public static void Main (string[] args) res.ContentEncoding = Encoding.UTF8; } - res.WriteContent (contents); + res.ContentLength64 = contents.LongLength; + res.Close (contents, true); }; // Add the WebSocket services. From 5904d9c044de5382b67ca430ecd559f36f1c6e5f Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 23 Jan 2020 19:44:18 +0900 Subject: [PATCH 2768/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerResponse.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index a2cade973..32c0829bb 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -53,10 +53,11 @@ namespace WebSocketSharp.Net { /// - /// Provides the access to a response to a request received by the . + /// Represents an HTTP response to an HTTP request received by + /// a instance. /// /// - /// The HttpListenerResponse class cannot be inherited. + /// This class cannot be inherited. /// public sealed class HttpListenerResponse : IDisposable { From 3856598928eb0fbd0610b41b768b970400844e31 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 23 Jan 2020 19:48:02 +0900 Subject: [PATCH 2769/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerRequest.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index 953c9b956..375d5cd4f 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -48,7 +48,8 @@ namespace WebSocketSharp.Net { /// - /// Represents an incoming request to a instance. + /// Represents an incoming HTTP request to a + /// instance. /// /// /// This class cannot be inherited. From e6cb2f73d49ba66e2c84dc6f66f969fda937c03d Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 24 Jan 2020 21:46:39 +0900 Subject: [PATCH 2770/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerResponse.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index 32c0829bb..10b5353d4 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -407,7 +407,7 @@ public CookieCollection Cookies { } /// - /// Gets or sets the collection of HTTP headers sent to the client. + /// Gets or sets the collection of the HTTP headers sent to the client. /// /// /// A that contains the headers sent to From 95aa75edf3b517f4a0e9b856c1db03fee4c76601 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 24 Jan 2020 21:48:07 +0900 Subject: [PATCH 2771/6294] [Modify] 2020 --- websocket-sharp/Net/HttpListenerResponse.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index 10b5353d4..b088c94a4 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -8,7 +8,7 @@ * The MIT License * * Copyright (c) 2005 Novell, Inc. (http://www.novell.com) - * Copyright (c) 2012-2015 sta.blockhead + * Copyright (c) 2012-2020 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From 3dd2a299650552309f6216890d6d7fdee3339c57 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 25 Jan 2020 22:51:22 +0900 Subject: [PATCH 2772/6294] [Modify] Polish it --- websocket-sharp/Net/ResponseStream.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/ResponseStream.cs b/websocket-sharp/Net/ResponseStream.cs index 0939dfbd3..3a341c294 100644 --- a/websocket-sharp/Net/ResponseStream.cs +++ b/websocket-sharp/Net/ResponseStream.cs @@ -327,8 +327,10 @@ public override void SetLength (long value) public override void Write (byte[] buffer, int offset, int count) { - if (_disposed) - throw new ObjectDisposedException (GetType ().ToString ()); + if (_disposed) { + var name = GetType ().ToString (); + throw new ObjectDisposedException (name); + } _body.Write (buffer, offset, count); } From 67f467b2e599c9abfadbb33da3039705f2019be1 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 26 Jan 2020 19:54:48 +0900 Subject: [PATCH 2773/6294] [Modify] Polish it --- websocket-sharp/Net/ResponseStream.cs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/ResponseStream.cs b/websocket-sharp/Net/ResponseStream.cs index 3a341c294..4d001e3c9 100644 --- a/websocket-sharp/Net/ResponseStream.cs +++ b/websocket-sharp/Net/ResponseStream.cs @@ -306,8 +306,15 @@ public override void EndWrite (IAsyncResult asyncResult) public override void Flush () { - if (!_disposed && (_sendChunked || _response.SendChunked)) - flush (false); + if (_disposed) + return; + + var sendChunked = _sendChunked || _response.SendChunked; + + if (!sendChunked) + return; + + flush (false); } public override int Read (byte[] buffer, int offset, int count) From 59f54c37afab384f279a870af101a93c6690ed03 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 27 Jan 2020 21:08:25 +0900 Subject: [PATCH 2774/6294] [Modify] Polish it --- websocket-sharp/Net/ResponseStream.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/ResponseStream.cs b/websocket-sharp/Net/ResponseStream.cs index 4d001e3c9..23435d8bc 100644 --- a/websocket-sharp/Net/ResponseStream.cs +++ b/websocket-sharp/Net/ResponseStream.cs @@ -298,8 +298,10 @@ public override int EndRead (IAsyncResult asyncResult) public override void EndWrite (IAsyncResult asyncResult) { - if (_disposed) - throw new ObjectDisposedException (GetType ().ToString ()); + if (_disposed) { + var name = GetType ().ToString (); + throw new ObjectDisposedException (name); + } _body.EndWrite (asyncResult); } From 8f9d7ef2a379392cbf132ac77e65d7a42e3fa2fa Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 27 Jan 2020 21:13:21 +0900 Subject: [PATCH 2775/6294] [Modify] Polish it --- websocket-sharp/Net/ResponseStream.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/ResponseStream.cs b/websocket-sharp/Net/ResponseStream.cs index 23435d8bc..bd4db0eb0 100644 --- a/websocket-sharp/Net/ResponseStream.cs +++ b/websocket-sharp/Net/ResponseStream.cs @@ -273,7 +273,12 @@ public override IAsyncResult BeginRead ( } public override IAsyncResult BeginWrite ( - byte[] buffer, int offset, int count, AsyncCallback callback, object state) + byte[] buffer, + int offset, + int count, + AsyncCallback callback, + object state + ) { if (_disposed) throw new ObjectDisposedException (GetType ().ToString ()); From 5c496b07b4aa6453d74c3099ec0c27bdc23aab12 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 27 Jan 2020 21:15:16 +0900 Subject: [PATCH 2776/6294] [Modify] Polish it --- websocket-sharp/Net/ResponseStream.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/ResponseStream.cs b/websocket-sharp/Net/ResponseStream.cs index bd4db0eb0..ed0386f9d 100644 --- a/websocket-sharp/Net/ResponseStream.cs +++ b/websocket-sharp/Net/ResponseStream.cs @@ -280,8 +280,10 @@ public override IAsyncResult BeginWrite ( object state ) { - if (_disposed) - throw new ObjectDisposedException (GetType ().ToString ()); + if (_disposed) { + var name = GetType ().ToString (); + throw new ObjectDisposedException (name); + } return _body.BeginWrite (buffer, offset, count, callback, state); } From da15c43ded3bc9735f33bdb91842bc49c6516ce7 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 28 Jan 2020 21:15:25 +0900 Subject: [PATCH 2777/6294] [Modify] Polish it --- websocket-sharp/Net/ResponseStream.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/ResponseStream.cs b/websocket-sharp/Net/ResponseStream.cs index ed0386f9d..1213ba1d8 100644 --- a/websocket-sharp/Net/ResponseStream.cs +++ b/websocket-sharp/Net/ResponseStream.cs @@ -267,7 +267,12 @@ internal void InternalWrite (byte[] buffer, int offset, int count) #region Public Methods public override IAsyncResult BeginRead ( - byte[] buffer, int offset, int count, AsyncCallback callback, object state) + byte[] buffer, + int offset, + int count, + AsyncCallback callback, + object state + ) { throw new NotSupportedException (); } From 3f44067a0ce62a312a315e1e549fc4ac8c486e32 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 29 Jan 2020 19:39:51 +0900 Subject: [PATCH 2778/6294] [Modify] Polish it --- websocket-sharp/Net/ResponseStream.cs | 28 ++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/websocket-sharp/Net/ResponseStream.cs b/websocket-sharp/Net/ResponseStream.cs index 1213ba1d8..77ab5fe17 100644 --- a/websocket-sharp/Net/ResponseStream.cs +++ b/websocket-sharp/Net/ResponseStream.cs @@ -238,21 +238,27 @@ internal void Close (bool force) return; _disposed = true; - if (!force && flush (true)) { - _response.Close (); - } - else { - if (_sendChunked) { - var last = getChunkSizeBytes (0, true); - _write (last, 0, last.Length); - } - _body.Dispose (); - _body = null; + if (!force) { + if (flush (true)) { + _response.Close (); + + _response = null; + _stream = null; + + return; + } + } - _response.Abort (); + if (_sendChunked) { + var last = getChunkSizeBytes (0, true); + _write (last, 0, last.Length); } + _body.Dispose (); + _response.Abort (); + + _body = null; _response = null; _stream = null; } From e2e1eba1870170d144a8b780116b09ddee2195d4 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 29 Jan 2020 19:47:33 +0900 Subject: [PATCH 2779/6294] [Modify] Polish it --- websocket-sharp/Net/ResponseStream.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/ResponseStream.cs b/websocket-sharp/Net/ResponseStream.cs index 77ab5fe17..a6e4cc1de 100644 --- a/websocket-sharp/Net/ResponseStream.cs +++ b/websocket-sharp/Net/ResponseStream.cs @@ -62,7 +62,10 @@ internal class ResponseStream : Stream #region Internal Constructors internal ResponseStream ( - Stream stream, HttpListenerResponse response, bool ignoreWriteExceptions) + Stream stream, + HttpListenerResponse response, + bool ignoreWriteExceptions + ) { _stream = stream; _response = response; From d3e5d4f54285bbed25eb18cae16a96e829101868 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 30 Jan 2020 19:38:01 +0900 Subject: [PATCH 2780/6294] [Modify] Polish it --- websocket-sharp/Net/ResponseStream.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/ResponseStream.cs b/websocket-sharp/Net/ResponseStream.cs index a6e4cc1de..4dbe2948b 100644 --- a/websocket-sharp/Net/ResponseStream.cs +++ b/websocket-sharp/Net/ResponseStream.cs @@ -222,7 +222,9 @@ private void writeChunkedWithoutThrowingException (byte[] buffer, int offset, in } } - private void writeWithoutThrowingException (byte[] buffer, int offset, int count) + private void writeWithoutThrowingException ( + byte[] buffer, int offset, int count + ) { try { _stream.Write (buffer, offset, count); From e30629d9aa877927a2785cb24585bce8f0c4df74 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 30 Jan 2020 19:40:48 +0900 Subject: [PATCH 2781/6294] [Modify] Polish it --- websocket-sharp/Net/ResponseStream.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/ResponseStream.cs b/websocket-sharp/Net/ResponseStream.cs index 4dbe2948b..b48d4eec3 100644 --- a/websocket-sharp/Net/ResponseStream.cs +++ b/websocket-sharp/Net/ResponseStream.cs @@ -213,7 +213,9 @@ private void writeChunked (byte[] buffer, int offset, int count) _stream.Write (_crlf, 0, 2); } - private void writeChunkedWithoutThrowingException (byte[] buffer, int offset, int count) + private void writeChunkedWithoutThrowingException ( + byte[] buffer, int offset, int count + ) { try { writeChunked (buffer, offset, count); From b5265bceb1e576ba086254d6b77ffd395ea427c4 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 31 Jan 2020 19:39:57 +0900 Subject: [PATCH 2782/6294] [Modify] Polish it --- websocket-sharp/Net/ResponseStream.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/ResponseStream.cs b/websocket-sharp/Net/ResponseStream.cs index b48d4eec3..c424fb417 100644 --- a/websocket-sharp/Net/ResponseStream.cs +++ b/websocket-sharp/Net/ResponseStream.cs @@ -202,7 +202,8 @@ private bool flushHeaders (bool closing) private static byte[] getChunkSizeBytes (int size, bool final) { - return Encoding.ASCII.GetBytes (String.Format ("{0:x}\r\n{1}", size, final ? "\r\n" : "")); + var chunkSize = String.Format ("{0:x}\r\n{1}", size, final ? "\r\n" : ""); + return Encoding.ASCII.GetBytes (chunkSize); } private void writeChunked (byte[] buffer, int offset, int count) From 6410fca74196b82c2fa92d4ff765977371b455f6 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 31 Jan 2020 19:43:34 +0900 Subject: [PATCH 2783/6294] [Modify] Polish it --- websocket-sharp/Net/ResponseStream.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Net/ResponseStream.cs b/websocket-sharp/Net/ResponseStream.cs index c424fb417..11a38522d 100644 --- a/websocket-sharp/Net/ResponseStream.cs +++ b/websocket-sharp/Net/ResponseStream.cs @@ -209,6 +209,7 @@ private static byte[] getChunkSizeBytes (int size, bool final) private void writeChunked (byte[] buffer, int offset, int count) { var size = getChunkSizeBytes (count, false); + _stream.Write (size, 0, size.Length); _stream.Write (buffer, offset, count); _stream.Write (_crlf, 0, 2); From 9cb5ee3f521b32c9c5cd2f8d0086c3587d837e17 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 1 Feb 2020 21:32:52 +0900 Subject: [PATCH 2784/6294] [Modify] Add it --- websocket-sharp/Net/ResponseStream.cs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/ResponseStream.cs b/websocket-sharp/Net/ResponseStream.cs index 11a38522d..598054f16 100644 --- a/websocket-sharp/Net/ResponseStream.cs +++ b/websocket-sharp/Net/ResponseStream.cs @@ -48,7 +48,7 @@ internal class ResponseStream : Stream #region Private Fields private MemoryStream _body; - private static readonly byte[] _crlf = new byte[] { 13, 10 }; + private static readonly byte[] _crlf; private bool _disposed; private HttpListenerResponse _response; private bool _sendChunked; @@ -59,6 +59,15 @@ internal class ResponseStream : Stream #endregion + #region Static Constructor + + static ResponseStream () + { + _crlf = new byte[] { 13, 10 }; + } + + #endregion + #region Internal Constructors internal ResponseStream ( From 78969c3c3d329c79533bc78ad006005eee9ecb54 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 2 Feb 2020 17:28:22 +0900 Subject: [PATCH 2785/6294] [Modify] Add it --- websocket-sharp/Net/ResponseStream.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/websocket-sharp/Net/ResponseStream.cs b/websocket-sharp/Net/ResponseStream.cs index 598054f16..910e4aead 100644 --- a/websocket-sharp/Net/ResponseStream.cs +++ b/websocket-sharp/Net/ResponseStream.cs @@ -50,6 +50,7 @@ internal class ResponseStream : Stream private MemoryStream _body; private static readonly byte[] _crlf; private bool _disposed; + private static readonly byte[] _lastChunk; private HttpListenerResponse _response; private bool _sendChunked; private Stream _stream; @@ -64,6 +65,7 @@ internal class ResponseStream : Stream static ResponseStream () { _crlf = new byte[] { 13, 10 }; + _lastChunk = new byte[] { 48, 13, 10, 13, 10 }; // "0\r\n\r\n" } #endregion From b95ada27a8ac78d5e07d19daa517e3a8dc6dec64 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 2 Feb 2020 17:30:03 +0900 Subject: [PATCH 2786/6294] [Modify] Polish it --- websocket-sharp/Net/ResponseStream.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/ResponseStream.cs b/websocket-sharp/Net/ResponseStream.cs index 910e4aead..a776b60d8 100644 --- a/websocket-sharp/Net/ResponseStream.cs +++ b/websocket-sharp/Net/ResponseStream.cs @@ -64,7 +64,7 @@ internal class ResponseStream : Stream static ResponseStream () { - _crlf = new byte[] { 13, 10 }; + _crlf = new byte[] { 13, 10 }; // "\r\n" _lastChunk = new byte[] { 48, 13, 10, 13, 10 }; // "0\r\n\r\n" } From 74461c4df5000dd80bf50e6e8f63c10c2f56ae98 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 3 Feb 2020 21:37:04 +0900 Subject: [PATCH 2787/6294] [Modify] Add it --- websocket-sharp/Net/ResponseStream.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/websocket-sharp/Net/ResponseStream.cs b/websocket-sharp/Net/ResponseStream.cs index a776b60d8..d615a8873 100644 --- a/websocket-sharp/Net/ResponseStream.cs +++ b/websocket-sharp/Net/ResponseStream.cs @@ -211,6 +211,12 @@ private bool flushHeaders (bool closing) return true; } + private static byte[] getChunkSizeBytes (int size) + { + var chunkSize = String.Format ("{0:x}\r\n", size); + return Encoding.ASCII.GetBytes (chunkSize); + } + private static byte[] getChunkSizeBytes (int size, bool final) { var chunkSize = String.Format ("{0:x}\r\n{1}", size, final ? "\r\n" : ""); From 00ddd183fefb4b61875684dcc67e2c660989cfc8 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 3 Feb 2020 21:38:54 +0900 Subject: [PATCH 2788/6294] [Modify] Replace it --- websocket-sharp/Net/ResponseStream.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/ResponseStream.cs b/websocket-sharp/Net/ResponseStream.cs index d615a8873..832dd274d 100644 --- a/websocket-sharp/Net/ResponseStream.cs +++ b/websocket-sharp/Net/ResponseStream.cs @@ -225,7 +225,7 @@ private static byte[] getChunkSizeBytes (int size, bool final) private void writeChunked (byte[] buffer, int offset, int count) { - var size = getChunkSizeBytes (count, false); + var size = getChunkSizeBytes (count); _stream.Write (size, 0, size.Length); _stream.Write (buffer, offset, count); From cf1b051f0ee8a02fd081b01304bffcf2d325a02c Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 4 Feb 2020 21:46:03 +0900 Subject: [PATCH 2789/6294] [Modify] Replace it --- websocket-sharp/Net/ResponseStream.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/ResponseStream.cs b/websocket-sharp/Net/ResponseStream.cs index 832dd274d..5ac59b240 100644 --- a/websocket-sharp/Net/ResponseStream.cs +++ b/websocket-sharp/Net/ResponseStream.cs @@ -276,10 +276,8 @@ internal void Close (bool force) } } - if (_sendChunked) { - var last = getChunkSizeBytes (0, true); - _write (last, 0, last.Length); - } + if (_sendChunked) + _write (_lastChunk, 0, 5); _body.Dispose (); _response.Abort (); From 2d67c5cba65a9a75fad1117d0637ba602be384dd Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 4 Feb 2020 21:53:49 +0900 Subject: [PATCH 2790/6294] [Modify] Replace it --- websocket-sharp/Net/ResponseStream.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/ResponseStream.cs b/websocket-sharp/Net/ResponseStream.cs index 5ac59b240..0a3ffaa9f 100644 --- a/websocket-sharp/Net/ResponseStream.cs +++ b/websocket-sharp/Net/ResponseStream.cs @@ -150,10 +150,8 @@ private bool flush (bool closing) } flushBody (closing); - if (closing && _sendChunked) { - var last = getChunkSizeBytes (0, true); - _write (last, 0, last.Length); - } + if (closing && _sendChunked) + _write (_lastChunk, 0, 5); return true; } From f88981c8d8fffc223f17384802ee4d4a443f7559 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 5 Feb 2020 19:41:34 +0900 Subject: [PATCH 2791/6294] [Modify] Remove it --- websocket-sharp/Net/ResponseStream.cs | 6 ------ 1 file changed, 6 deletions(-) diff --git a/websocket-sharp/Net/ResponseStream.cs b/websocket-sharp/Net/ResponseStream.cs index 0a3ffaa9f..03907622b 100644 --- a/websocket-sharp/Net/ResponseStream.cs +++ b/websocket-sharp/Net/ResponseStream.cs @@ -215,12 +215,6 @@ private static byte[] getChunkSizeBytes (int size) return Encoding.ASCII.GetBytes (chunkSize); } - private static byte[] getChunkSizeBytes (int size, bool final) - { - var chunkSize = String.Format ("{0:x}\r\n{1}", size, final ? "\r\n" : ""); - return Encoding.ASCII.GetBytes (chunkSize); - } - private void writeChunked (byte[] buffer, int offset, int count) { var size = getChunkSizeBytes (count); From faffdd170d83648cc0d9649daf80444fc1cd5b63 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 5 Feb 2020 19:43:49 +0900 Subject: [PATCH 2792/6294] [Modify] Polish it --- websocket-sharp/Net/ResponseStream.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Net/ResponseStream.cs b/websocket-sharp/Net/ResponseStream.cs index 03907622b..ae2567298 100644 --- a/websocket-sharp/Net/ResponseStream.cs +++ b/websocket-sharp/Net/ResponseStream.cs @@ -150,6 +150,7 @@ private bool flush (bool closing) } flushBody (closing); + if (closing && _sendChunked) _write (_lastChunk, 0, 5); From 5c4eec3e9d930af0c0fb61e232027b13f1d8dc30 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 6 Feb 2020 21:46:18 +0900 Subject: [PATCH 2793/6294] [Modify] Polish it --- websocket-sharp/Net/ResponseStream.cs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/ResponseStream.cs b/websocket-sharp/Net/ResponseStream.cs index ae2567298..4169e88b1 100644 --- a/websocket-sharp/Net/ResponseStream.cs +++ b/websocket-sharp/Net/ResponseStream.cs @@ -161,13 +161,22 @@ private void flushBody (bool closing) { using (_body) { var len = _body.Length; + if (len > Int32.MaxValue) { _body.Position = 0; + var buffLen = 1024; var buff = new byte[buffLen]; var nread = 0; - while ((nread = _body.Read (buff, 0, buffLen)) > 0) + + while (true) { + nread = _body.Read (buff, 0, buffLen); + + if (nread <= 0) + break; + _writeBody (buff, 0, nread); + } } else if (len > 0) { _writeBody (_body.GetBuffer (), 0, (int) len); From 0d7b507cee5d9d2976f017d425a4312757bc21fa Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 7 Feb 2020 21:48:19 +0900 Subject: [PATCH 2794/6294] [Modify] Move it --- websocket-sharp/Net/ResponseStream.cs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Net/ResponseStream.cs b/websocket-sharp/Net/ResponseStream.cs index 4169e88b1..96f1aeb3e 100644 --- a/websocket-sharp/Net/ResponseStream.cs +++ b/websocket-sharp/Net/ResponseStream.cs @@ -150,10 +150,6 @@ private bool flush (bool closing) } flushBody (closing); - - if (closing && _sendChunked) - _write (_lastChunk, 0, 5); - return true; } @@ -183,7 +179,15 @@ private void flushBody (bool closing) } } - _body = !closing ? new MemoryStream () : null; + if (closing) { + if (_sendChunked) + _write (_lastChunk, 0, 5); + + _body = null; + } + else { + _body = new MemoryStream (); + } } private bool flushHeaders (bool closing) From 30599aa76aadb14efd2b25fa172f17414b60eb18 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 8 Feb 2020 16:56:10 +0900 Subject: [PATCH 2795/6294] [Modify] Polish it --- websocket-sharp/Net/ResponseStream.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/websocket-sharp/Net/ResponseStream.cs b/websocket-sharp/Net/ResponseStream.cs index 96f1aeb3e..1fcb37ac3 100644 --- a/websocket-sharp/Net/ResponseStream.cs +++ b/websocket-sharp/Net/ResponseStream.cs @@ -179,15 +179,15 @@ private void flushBody (bool closing) } } - if (closing) { - if (_sendChunked) - _write (_lastChunk, 0, 5); - - _body = null; - } - else { + if (!closing) { _body = new MemoryStream (); + return; } + + if (_sendChunked) + _write (_lastChunk, 0, 5); + + _body = null; } private bool flushHeaders (bool closing) From 7cf6b82177b2b92c2e004974c76641aeb35fa728 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 9 Feb 2020 17:40:52 +0900 Subject: [PATCH 2796/6294] [Modify] Rename it --- websocket-sharp/Net/ResponseStream.cs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/websocket-sharp/Net/ResponseStream.cs b/websocket-sharp/Net/ResponseStream.cs index 1fcb37ac3..89fa0b3cf 100644 --- a/websocket-sharp/Net/ResponseStream.cs +++ b/websocket-sharp/Net/ResponseStream.cs @@ -50,10 +50,10 @@ internal class ResponseStream : Stream private MemoryStream _body; private static readonly byte[] _crlf; private bool _disposed; + private Stream _innerStream; private static readonly byte[] _lastChunk; private HttpListenerResponse _response; private bool _sendChunked; - private Stream _stream; private Action _write; private Action _writeBody; private Action _writeChunked; @@ -73,12 +73,12 @@ static ResponseStream () #region Internal Constructors internal ResponseStream ( - Stream stream, + Stream innerStream, HttpListenerResponse response, bool ignoreWriteExceptions ) { - _stream = stream; + _innerStream = innerStream; _response = response; if (ignoreWriteExceptions) { @@ -86,7 +86,7 @@ bool ignoreWriteExceptions _writeChunked = writeChunkedWithoutThrowingException; } else { - _write = stream.Write; + _write = innerStream.Write; _writeChunked = writeChunked; } @@ -233,9 +233,9 @@ private void writeChunked (byte[] buffer, int offset, int count) { var size = getChunkSizeBytes (count); - _stream.Write (size, 0, size.Length); - _stream.Write (buffer, offset, count); - _stream.Write (_crlf, 0, 2); + _innerStream.Write (size, 0, size.Length); + _innerStream.Write (buffer, offset, count); + _innerStream.Write (_crlf, 0, 2); } private void writeChunkedWithoutThrowingException ( @@ -254,7 +254,7 @@ private void writeWithoutThrowingException ( ) { try { - _stream.Write (buffer, offset, count); + _innerStream.Write (buffer, offset, count); } catch { } @@ -276,7 +276,7 @@ internal void Close (bool force) _response.Close (); _response = null; - _stream = null; + _innerStream = null; return; } @@ -290,7 +290,7 @@ internal void Close (bool force) _body = null; _response = null; - _stream = null; + _innerStream = null; } internal void InternalWrite (byte[] buffer, int offset, int count) From 8afac96d6d065123e467db2d25ab5c10986813cd Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 10 Feb 2020 20:39:38 +0900 Subject: [PATCH 2797/6294] [Modify] Rename it --- websocket-sharp/Net/ResponseStream.cs | 30 +++++++++++++-------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/websocket-sharp/Net/ResponseStream.cs b/websocket-sharp/Net/ResponseStream.cs index 89fa0b3cf..ec241f50b 100644 --- a/websocket-sharp/Net/ResponseStream.cs +++ b/websocket-sharp/Net/ResponseStream.cs @@ -47,7 +47,7 @@ internal class ResponseStream : Stream { #region Private Fields - private MemoryStream _body; + private MemoryStream _bodyBuffer; private static readonly byte[] _crlf; private bool _disposed; private Stream _innerStream; @@ -90,7 +90,7 @@ bool ignoreWriteExceptions _writeChunked = writeChunked; } - _body = new MemoryStream (); + _bodyBuffer = new MemoryStream (); } #endregion @@ -155,18 +155,18 @@ private bool flush (bool closing) private void flushBody (bool closing) { - using (_body) { - var len = _body.Length; + using (_bodyBuffer) { + var len = _bodyBuffer.Length; if (len > Int32.MaxValue) { - _body.Position = 0; + _bodyBuffer.Position = 0; var buffLen = 1024; var buff = new byte[buffLen]; var nread = 0; while (true) { - nread = _body.Read (buff, 0, buffLen); + nread = _bodyBuffer.Read (buff, 0, buffLen); if (nread <= 0) break; @@ -175,25 +175,25 @@ private void flushBody (bool closing) } } else if (len > 0) { - _writeBody (_body.GetBuffer (), 0, (int) len); + _writeBody (_bodyBuffer.GetBuffer (), 0, (int) len); } } if (!closing) { - _body = new MemoryStream (); + _bodyBuffer = new MemoryStream (); return; } if (_sendChunked) _write (_lastChunk, 0, 5); - _body = null; + _bodyBuffer = null; } private bool flushHeaders (bool closing) { if (!_response.SendChunked) { - if (_response.ContentLength64 != _body.Length) + if (_response.ContentLength64 != _bodyBuffer.Length) return false; } @@ -285,10 +285,10 @@ internal void Close (bool force) if (_sendChunked) _write (_lastChunk, 0, 5); - _body.Dispose (); + _bodyBuffer.Dispose (); _response.Abort (); - _body = null; + _bodyBuffer = null; _response = null; _innerStream = null; } @@ -326,7 +326,7 @@ object state throw new ObjectDisposedException (name); } - return _body.BeginWrite (buffer, offset, count, callback, state); + return _bodyBuffer.BeginWrite (buffer, offset, count, callback, state); } public override void Close () @@ -351,7 +351,7 @@ public override void EndWrite (IAsyncResult asyncResult) throw new ObjectDisposedException (name); } - _body.EndWrite (asyncResult); + _bodyBuffer.EndWrite (asyncResult); } public override void Flush () @@ -389,7 +389,7 @@ public override void Write (byte[] buffer, int offset, int count) throw new ObjectDisposedException (name); } - _body.Write (buffer, offset, count); + _bodyBuffer.Write (buffer, offset, count); } #endregion From 3334a53336c10b75d186e921d6e1beaf76804351 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 11 Feb 2020 22:03:08 +0900 Subject: [PATCH 2798/6294] [Modify] Move it --- websocket-sharp/Net/ResponseStream.cs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Net/ResponseStream.cs b/websocket-sharp/Net/ResponseStream.cs index ec241f50b..1c7fa805d 100644 --- a/websocket-sharp/Net/ResponseStream.cs +++ b/websocket-sharp/Net/ResponseStream.cs @@ -138,12 +138,8 @@ public override long Position { private bool flush (bool closing) { if (!_response.HeadersSent) { - if (!flushHeaders (closing)) { - if (closing) - _response.CloseConnection = true; - + if (!flushHeaders (closing)) return false; - } _sendChunked = _response.SendChunked; _writeBody = _sendChunked ? _writeChunked : _write; @@ -280,6 +276,8 @@ internal void Close (bool force) return; } + + _response.CloseConnection = true; } if (_sendChunked) From 7f6410afff74f80b19baf59138fcea0f47b49546 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 12 Feb 2020 19:46:19 +0900 Subject: [PATCH 2799/6294] [Modify] Move it --- websocket-sharp/Net/ResponseStream.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/ResponseStream.cs b/websocket-sharp/Net/ResponseStream.cs index 1c7fa805d..5d2359043 100644 --- a/websocket-sharp/Net/ResponseStream.cs +++ b/websocket-sharp/Net/ResponseStream.cs @@ -141,6 +141,8 @@ private bool flush (bool closing) if (!flushHeaders (closing)) return false; + _response.HeadersSent = true; + _sendChunked = _response.SendChunked; _writeBody = _sendChunked ? _writeChunked : _write; } @@ -214,8 +216,6 @@ private bool flushHeaders (bool closing) } _response.CloseConnection = headers["Connection"] == "close"; - _response.HeadersSent = true; - return true; } From 11bbb6e2f1b474f2b8eeec3376c3cf8bffaa00fd Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 12 Feb 2020 19:49:44 +0900 Subject: [PATCH 2800/6294] [Modify] Polish it --- websocket-sharp/Net/ResponseStream.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/ResponseStream.cs b/websocket-sharp/Net/ResponseStream.cs index 5d2359043..4aa8fd54a 100644 --- a/websocket-sharp/Net/ResponseStream.cs +++ b/websocket-sharp/Net/ResponseStream.cs @@ -138,7 +138,7 @@ public override long Position { private bool flush (bool closing) { if (!_response.HeadersSent) { - if (!flushHeaders (closing)) + if (!flushHeaders ()) return false; _response.HeadersSent = true; @@ -188,7 +188,7 @@ private void flushBody (bool closing) _bodyBuffer = null; } - private bool flushHeaders (bool closing) + private bool flushHeaders () { if (!_response.SendChunked) { if (_response.ContentLength64 != _bodyBuffer.Length) From 4476a99bf67ea7c6ac6f2855bbea29405c3be076 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 13 Feb 2020 21:00:29 +0900 Subject: [PATCH 2801/6294] [Modify] Add it --- websocket-sharp/Net/ResponseStream.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/websocket-sharp/Net/ResponseStream.cs b/websocket-sharp/Net/ResponseStream.cs index 4aa8fd54a..35a567242 100644 --- a/websocket-sharp/Net/ResponseStream.cs +++ b/websocket-sharp/Net/ResponseStream.cs @@ -52,6 +52,7 @@ internal class ResponseStream : Stream private bool _disposed; private Stream _innerStream; private static readonly byte[] _lastChunk; + private static readonly int _maxHeadersLength; private HttpListenerResponse _response; private bool _sendChunked; private Action _write; @@ -66,6 +67,7 @@ static ResponseStream () { _crlf = new byte[] { 13, 10 }; // "\r\n" _lastChunk = new byte[] { 48, 13, 10, 13, 10 }; // "0\r\n\r\n" + _maxHeadersLength = 32768; } #endregion From 5f44b636073674160fafb22f67496c4d0f59e77e Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 13 Feb 2020 21:03:09 +0900 Subject: [PATCH 2802/6294] [Modify] Replace it --- websocket-sharp/Net/ResponseStream.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/ResponseStream.cs b/websocket-sharp/Net/ResponseStream.cs index 35a567242..bd6caf4e7 100644 --- a/websocket-sharp/Net/ResponseStream.cs +++ b/websocket-sharp/Net/ResponseStream.cs @@ -211,7 +211,7 @@ private bool flushHeaders () var start = enc.GetPreamble ().Length; var len = buff.Length - start; - if (len > 32768) + if (len > _maxHeadersLength) return false; _write (buff.GetBuffer (), start, (int) len); From 1902fb84e14e9ccab36160a0a29faf78ba1714a6 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 13 Feb 2020 21:04:54 +0900 Subject: [PATCH 2803/6294] [Modify] Polish it --- websocket-sharp/Net/ResponseStream.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Net/ResponseStream.cs b/websocket-sharp/Net/ResponseStream.cs index bd6caf4e7..0561d9a80 100644 --- a/websocket-sharp/Net/ResponseStream.cs +++ b/websocket-sharp/Net/ResponseStream.cs @@ -218,6 +218,7 @@ private bool flushHeaders () } _response.CloseConnection = headers["Connection"] == "close"; + return true; } From 07b752e572c76404eab116e31bb604e606d2f9cc Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 14 Feb 2020 19:38:13 +0900 Subject: [PATCH 2804/6294] [Modify] Polish it --- websocket-sharp/Net/ResponseStream.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Net/ResponseStream.cs b/websocket-sharp/Net/ResponseStream.cs index 0561d9a80..2797b955a 100644 --- a/websocket-sharp/Net/ResponseStream.cs +++ b/websocket-sharp/Net/ResponseStream.cs @@ -150,6 +150,7 @@ private bool flush (bool closing) } flushBody (closing); + return true; } From 650ccc9daf2c1b62ea51cbf46a37a22708d31131 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 14 Feb 2020 19:41:32 +0900 Subject: [PATCH 2805/6294] [Modify] Polish it --- websocket-sharp/Net/ResponseStream.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Net/ResponseStream.cs b/websocket-sharp/Net/ResponseStream.cs index 2797b955a..1a39ebfae 100644 --- a/websocket-sharp/Net/ResponseStream.cs +++ b/websocket-sharp/Net/ResponseStream.cs @@ -226,6 +226,7 @@ private bool flushHeaders () private static byte[] getChunkSizeBytes (int size) { var chunkSize = String.Format ("{0:x}\r\n", size); + return Encoding.ASCII.GetBytes (chunkSize); } From cba1a1a3e8a25194b0eceab1a9d3d52062f089b3 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 15 Feb 2020 17:38:25 +0900 Subject: [PATCH 2806/6294] [Modify] Polish it --- websocket-sharp/Net/ResponseStream.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Net/ResponseStream.cs b/websocket-sharp/Net/ResponseStream.cs index 1a39ebfae..ffdcce7f8 100644 --- a/websocket-sharp/Net/ResponseStream.cs +++ b/websocket-sharp/Net/ResponseStream.cs @@ -326,6 +326,7 @@ object state { if (_disposed) { var name = GetType ().ToString (); + throw new ObjectDisposedException (name); } From 10ded9d3fda3aca4bb4351aa11a4ac6a7c1a5888 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 15 Feb 2020 17:39:37 +0900 Subject: [PATCH 2807/6294] [Modify] Polish it --- websocket-sharp/Net/ResponseStream.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Net/ResponseStream.cs b/websocket-sharp/Net/ResponseStream.cs index ffdcce7f8..001156265 100644 --- a/websocket-sharp/Net/ResponseStream.cs +++ b/websocket-sharp/Net/ResponseStream.cs @@ -352,6 +352,7 @@ public override void EndWrite (IAsyncResult asyncResult) { if (_disposed) { var name = GetType ().ToString (); + throw new ObjectDisposedException (name); } From 860fbdb6b5f5da9be48c60c26621e53b8d34f6df Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 15 Feb 2020 17:40:52 +0900 Subject: [PATCH 2808/6294] [Modify] Polish it --- websocket-sharp/Net/ResponseStream.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Net/ResponseStream.cs b/websocket-sharp/Net/ResponseStream.cs index 001156265..0ca42c8c0 100644 --- a/websocket-sharp/Net/ResponseStream.cs +++ b/websocket-sharp/Net/ResponseStream.cs @@ -391,6 +391,7 @@ public override void Write (byte[] buffer, int offset, int count) { if (_disposed) { var name = GetType ().ToString (); + throw new ObjectDisposedException (name); } From ce42b036e3dc2efae8db74cee0e5175510e194f2 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 16 Feb 2020 21:06:10 +0900 Subject: [PATCH 2809/6294] [Modify] 2020 --- websocket-sharp/Net/ResponseStream.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/ResponseStream.cs b/websocket-sharp/Net/ResponseStream.cs index 0ca42c8c0..c91b6e295 100644 --- a/websocket-sharp/Net/ResponseStream.cs +++ b/websocket-sharp/Net/ResponseStream.cs @@ -8,7 +8,7 @@ * The MIT License * * Copyright (c) 2005 Novell, Inc. (http://www.novell.com) - * Copyright (c) 2012-2015 sta.blockhead + * Copyright (c) 2012-2020 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From 4b78b9dc84b5bc5ef076eacd10d1471e947ea4c4 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 17 Feb 2020 21:35:16 +0900 Subject: [PATCH 2810/6294] [Modify] Polish it --- websocket-sharp/Net/WebHeaderCollection.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 8423d2f17..cad6cec0b 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -71,7 +71,10 @@ public class WebHeaderCollection : NameValueCollection, ISerializable static WebHeaderCollection () { _headers = - new Dictionary (StringComparer.InvariantCultureIgnoreCase) { + new Dictionary ( + StringComparer.InvariantCultureIgnoreCase + ) + { { "Accept", new HttpHeaderInfo ( From c521157f87d9179d71208c8f5f33db3a7b567047 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 17 Feb 2020 21:39:19 +0900 Subject: [PATCH 2811/6294] [Modify] Polish it --- websocket-sharp/Net/WebHeaderCollection.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index cad6cec0b..d49b75d95 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -79,7 +79,10 @@ static WebHeaderCollection () "Accept", new HttpHeaderInfo ( "Accept", - HttpHeaderType.Request | HttpHeaderType.Restricted | HttpHeaderType.MultiValue) + HttpHeaderType.Request + | HttpHeaderType.Restricted + | HttpHeaderType.MultiValue + ) }, { "AcceptCharset", From cb7df0a40545108fac660c2377a98ab2cf3a8cff Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 17 Feb 2020 21:42:14 +0900 Subject: [PATCH 2812/6294] [Modify] Polish it --- websocket-sharp/Net/WebHeaderCollection.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index d49b75d95..71344bf1a 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -88,7 +88,8 @@ static WebHeaderCollection () "AcceptCharset", new HttpHeaderInfo ( "Accept-Charset", - HttpHeaderType.Request | HttpHeaderType.MultiValue) + HttpHeaderType.Request | HttpHeaderType.MultiValue + ) }, { "AcceptEncoding", From 5a228a390868e04dd46797f7699f5a82009d7508 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 18 Feb 2020 21:29:21 +0900 Subject: [PATCH 2813/6294] [Modify] Polish it --- websocket-sharp/Net/WebHeaderCollection.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 71344bf1a..128f5e21b 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -95,7 +95,8 @@ static WebHeaderCollection () "AcceptEncoding", new HttpHeaderInfo ( "Accept-Encoding", - HttpHeaderType.Request | HttpHeaderType.MultiValue) + HttpHeaderType.Request | HttpHeaderType.MultiValue + ) }, { "AcceptLanguage", From c5ae2bf19d20d62fce2576232949d9bfa0d33ab9 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 18 Feb 2020 21:30:30 +0900 Subject: [PATCH 2814/6294] [Modify] Polish it --- websocket-sharp/Net/WebHeaderCollection.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 128f5e21b..175f6c034 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -102,7 +102,8 @@ static WebHeaderCollection () "AcceptLanguage", new HttpHeaderInfo ( "Accept-Language", - HttpHeaderType.Request | HttpHeaderType.MultiValue) + HttpHeaderType.Request | HttpHeaderType.MultiValue + ) }, { "AcceptRanges", From 859ee5f7d36abfda79cf36471ed39451bd863797 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 18 Feb 2020 21:31:25 +0900 Subject: [PATCH 2815/6294] [Modify] Polish it --- websocket-sharp/Net/WebHeaderCollection.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 175f6c034..3c554acbc 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -109,7 +109,8 @@ static WebHeaderCollection () "AcceptRanges", new HttpHeaderInfo ( "Accept-Ranges", - HttpHeaderType.Response | HttpHeaderType.MultiValue) + HttpHeaderType.Response | HttpHeaderType.MultiValue + ) }, { "Age", From 1a2d0e2357d5afa7891a17b2faf60c3e21690af2 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 18 Feb 2020 21:33:07 +0900 Subject: [PATCH 2816/6294] [Modify] Polish it --- websocket-sharp/Net/WebHeaderCollection.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 3c554acbc..00514e041 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -116,7 +116,8 @@ static WebHeaderCollection () "Age", new HttpHeaderInfo ( "Age", - HttpHeaderType.Response) + HttpHeaderType.Response + ) }, { "Allow", From b0cf8a1883f0b690d2f374535267551201b1742d Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 18 Feb 2020 21:35:21 +0900 Subject: [PATCH 2817/6294] [Modify] Polish it --- websocket-sharp/Net/WebHeaderCollection.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 00514e041..fe4d2edc3 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -123,7 +123,10 @@ static WebHeaderCollection () "Allow", new HttpHeaderInfo ( "Allow", - HttpHeaderType.Request | HttpHeaderType.Response | HttpHeaderType.MultiValue) + HttpHeaderType.Request + | HttpHeaderType.Response + | HttpHeaderType.MultiValue + ) }, { "Authorization", From 5b0308a9dc2b64f34e0511e0684705254ed70e01 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 18 Feb 2020 21:36:55 +0900 Subject: [PATCH 2818/6294] [Modify] Polish it --- websocket-sharp/Net/WebHeaderCollection.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index fe4d2edc3..6015cca0d 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -132,7 +132,8 @@ static WebHeaderCollection () "Authorization", new HttpHeaderInfo ( "Authorization", - HttpHeaderType.Request | HttpHeaderType.MultiValue) + HttpHeaderType.Request | HttpHeaderType.MultiValue + ) }, { "CacheControl", From 88b9b5ca2d1a0d97d2a0e4bf8c9ceffffcd4ae22 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 18 Feb 2020 21:38:24 +0900 Subject: [PATCH 2819/6294] [Modify] Polish it --- websocket-sharp/Net/WebHeaderCollection.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 6015cca0d..70db1c812 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -139,7 +139,10 @@ static WebHeaderCollection () "CacheControl", new HttpHeaderInfo ( "Cache-Control", - HttpHeaderType.Request | HttpHeaderType.Response | HttpHeaderType.MultiValue) + HttpHeaderType.Request + | HttpHeaderType.Response + | HttpHeaderType.MultiValue + ) }, { "Connection", From a1f952f72f889df8c26e28cbf0f7e992c88857b5 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 18 Feb 2020 21:40:34 +0900 Subject: [PATCH 2820/6294] [Modify] Polish it --- websocket-sharp/Net/WebHeaderCollection.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 70db1c812..e0a30d1fe 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -148,10 +148,11 @@ static WebHeaderCollection () "Connection", new HttpHeaderInfo ( "Connection", - HttpHeaderType.Request | - HttpHeaderType.Response | - HttpHeaderType.Restricted | - HttpHeaderType.MultiValue) + HttpHeaderType.Request + | HttpHeaderType.Response + | HttpHeaderType.Restricted + | HttpHeaderType.MultiValue + ) }, { "ContentEncoding", From 6e1f273b3a507f0596ef234fb3b4de4f62d8651c Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 19 Feb 2020 21:25:12 +0900 Subject: [PATCH 2821/6294] [Modify] Polish it --- websocket-sharp/Net/WebHeaderCollection.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index e0a30d1fe..f4057d4c8 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -158,7 +158,10 @@ static WebHeaderCollection () "ContentEncoding", new HttpHeaderInfo ( "Content-Encoding", - HttpHeaderType.Request | HttpHeaderType.Response | HttpHeaderType.MultiValue) + HttpHeaderType.Request + | HttpHeaderType.Response + | HttpHeaderType.MultiValue + ) }, { "ContentLanguage", From 0f53c2f2d609746d55ab677e3af60dc87ea1024f Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 19 Feb 2020 21:26:42 +0900 Subject: [PATCH 2822/6294] [Modify] Polish it --- websocket-sharp/Net/WebHeaderCollection.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index f4057d4c8..cd9300021 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -167,7 +167,10 @@ static WebHeaderCollection () "ContentLanguage", new HttpHeaderInfo ( "Content-Language", - HttpHeaderType.Request | HttpHeaderType.Response | HttpHeaderType.MultiValue) + HttpHeaderType.Request + | HttpHeaderType.Response + | HttpHeaderType.MultiValue + ) }, { "ContentLength", From eaa9cf7edf619e887874a562bdef42cf0067ca90 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 19 Feb 2020 21:28:11 +0900 Subject: [PATCH 2823/6294] [Modify] Polish it --- websocket-sharp/Net/WebHeaderCollection.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index cd9300021..027e46c5e 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -176,7 +176,10 @@ static WebHeaderCollection () "ContentLength", new HttpHeaderInfo ( "Content-Length", - HttpHeaderType.Request | HttpHeaderType.Response | HttpHeaderType.Restricted) + HttpHeaderType.Request + | HttpHeaderType.Response + | HttpHeaderType.Restricted + ) }, { "ContentLocation", From 12a3fd77a1ef1bfdef53bfb88b8fe6a08d42f6fb Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 19 Feb 2020 21:30:01 +0900 Subject: [PATCH 2824/6294] [Modify] Polish it --- websocket-sharp/Net/WebHeaderCollection.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 027e46c5e..b72df3e77 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -185,7 +185,8 @@ static WebHeaderCollection () "ContentLocation", new HttpHeaderInfo ( "Content-Location", - HttpHeaderType.Request | HttpHeaderType.Response) + HttpHeaderType.Request | HttpHeaderType.Response + ) }, { "ContentMd5", From 1e66d7fa080c78233d66c507d885a285183e8344 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 19 Feb 2020 21:31:49 +0900 Subject: [PATCH 2825/6294] [Modify] Polish it --- websocket-sharp/Net/WebHeaderCollection.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index b72df3e77..857529579 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -192,7 +192,8 @@ static WebHeaderCollection () "ContentMd5", new HttpHeaderInfo ( "Content-MD5", - HttpHeaderType.Request | HttpHeaderType.Response) + HttpHeaderType.Request | HttpHeaderType.Response + ) }, { "ContentRange", From c3f2251623e2c5739ebb340409977b4d7d05bdb2 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 19 Feb 2020 21:32:41 +0900 Subject: [PATCH 2826/6294] [Modify] Polish it --- websocket-sharp/Net/WebHeaderCollection.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 857529579..3b179e6c4 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -199,7 +199,8 @@ static WebHeaderCollection () "ContentRange", new HttpHeaderInfo ( "Content-Range", - HttpHeaderType.Request | HttpHeaderType.Response) + HttpHeaderType.Request | HttpHeaderType.Response + ) }, { "ContentType", From c9288c6b773e9dae4034361cfc4e5cb4020852e9 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 19 Feb 2020 21:34:58 +0900 Subject: [PATCH 2827/6294] [Modify] Polish it --- websocket-sharp/Net/WebHeaderCollection.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 3b179e6c4..4abb74542 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -206,7 +206,10 @@ static WebHeaderCollection () "ContentType", new HttpHeaderInfo ( "Content-Type", - HttpHeaderType.Request | HttpHeaderType.Response | HttpHeaderType.Restricted) + HttpHeaderType.Request + | HttpHeaderType.Response + | HttpHeaderType.Restricted + ) }, { "Cookie", From 43d855ec3408f9f710c4012067c917805e1537dd Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 19 Feb 2020 21:36:00 +0900 Subject: [PATCH 2828/6294] [Modify] Polish it --- websocket-sharp/Net/WebHeaderCollection.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 4abb74542..ed6886247 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -215,7 +215,8 @@ static WebHeaderCollection () "Cookie", new HttpHeaderInfo ( "Cookie", - HttpHeaderType.Request) + HttpHeaderType.Request + ) }, { "Cookie2", From 272c98622566b57e69ddb686019750597216e2b2 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 19 Feb 2020 21:37:27 +0900 Subject: [PATCH 2829/6294] [Modify] Polish it --- websocket-sharp/Net/WebHeaderCollection.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index ed6886247..7550b7d65 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -222,7 +222,8 @@ static WebHeaderCollection () "Cookie2", new HttpHeaderInfo ( "Cookie2", - HttpHeaderType.Request) + HttpHeaderType.Request + ) }, { "Date", From 18fc2e5d195d74746b77b14ad5c2db4c40205ced Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 20 Feb 2020 20:20:53 +0900 Subject: [PATCH 2830/6294] [Modify] Polish it --- websocket-sharp/Net/WebHeaderCollection.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 7550b7d65..14edc971e 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -229,7 +229,10 @@ static WebHeaderCollection () "Date", new HttpHeaderInfo ( "Date", - HttpHeaderType.Request | HttpHeaderType.Response | HttpHeaderType.Restricted) + HttpHeaderType.Request + | HttpHeaderType.Response + | HttpHeaderType.Restricted + ) }, { "Expect", From 728b6cd6625e0d198e353379107a376a9e4e0e24 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 20 Feb 2020 20:22:18 +0900 Subject: [PATCH 2831/6294] [Modify] Polish it --- websocket-sharp/Net/WebHeaderCollection.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 14edc971e..da8e879c7 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -238,7 +238,10 @@ static WebHeaderCollection () "Expect", new HttpHeaderInfo ( "Expect", - HttpHeaderType.Request | HttpHeaderType.Restricted | HttpHeaderType.MultiValue) + HttpHeaderType.Request + | HttpHeaderType.Restricted + | HttpHeaderType.MultiValue + ) }, { "Expires", From f711051c81acd5b2d4317c87165748fa7855989c Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 20 Feb 2020 20:23:07 +0900 Subject: [PATCH 2832/6294] [Modify] Polish it --- websocket-sharp/Net/WebHeaderCollection.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index da8e879c7..cd43065a5 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -247,7 +247,8 @@ static WebHeaderCollection () "Expires", new HttpHeaderInfo ( "Expires", - HttpHeaderType.Request | HttpHeaderType.Response) + HttpHeaderType.Request | HttpHeaderType.Response + ) }, { "ETag", From 0b9be6119323a667a2cadfe4c78f9614da84503a Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 20 Feb 2020 20:24:03 +0900 Subject: [PATCH 2833/6294] [Modify] Polish it --- websocket-sharp/Net/WebHeaderCollection.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index cd43065a5..6c1de1500 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -254,7 +254,8 @@ static WebHeaderCollection () "ETag", new HttpHeaderInfo ( "ETag", - HttpHeaderType.Response) + HttpHeaderType.Response + ) }, { "From", From 94fa12bbb8fb9bdd3faf31619858322d1a944b5e Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 20 Feb 2020 20:24:45 +0900 Subject: [PATCH 2834/6294] [Modify] Polish it --- websocket-sharp/Net/WebHeaderCollection.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 6c1de1500..8bcaf1430 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -261,7 +261,8 @@ static WebHeaderCollection () "From", new HttpHeaderInfo ( "From", - HttpHeaderType.Request) + HttpHeaderType.Request + ) }, { "Host", From 6e3e3f122a7784ab78835cd5e5178bb79ee0a516 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 20 Feb 2020 20:25:33 +0900 Subject: [PATCH 2835/6294] [Modify] Polish it --- websocket-sharp/Net/WebHeaderCollection.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 8bcaf1430..5a79666e2 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -268,7 +268,8 @@ static WebHeaderCollection () "Host", new HttpHeaderInfo ( "Host", - HttpHeaderType.Request | HttpHeaderType.Restricted) + HttpHeaderType.Request | HttpHeaderType.Restricted + ) }, { "IfMatch", From d99b1b660a9aaabd756e07e23a4371ec72e5f846 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 20 Feb 2020 20:26:10 +0900 Subject: [PATCH 2836/6294] [Modify] Polish it --- websocket-sharp/Net/WebHeaderCollection.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 5a79666e2..9ee0f765d 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -275,7 +275,8 @@ static WebHeaderCollection () "IfMatch", new HttpHeaderInfo ( "If-Match", - HttpHeaderType.Request | HttpHeaderType.MultiValue) + HttpHeaderType.Request | HttpHeaderType.MultiValue + ) }, { "IfModifiedSince", From da20a0996eb0d6a22519d8587bc341c6fea47a4b Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 20 Feb 2020 20:26:53 +0900 Subject: [PATCH 2837/6294] [Modify] Polish it --- websocket-sharp/Net/WebHeaderCollection.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 9ee0f765d..37a194f7e 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -282,7 +282,8 @@ static WebHeaderCollection () "IfModifiedSince", new HttpHeaderInfo ( "If-Modified-Since", - HttpHeaderType.Request | HttpHeaderType.Restricted) + HttpHeaderType.Request | HttpHeaderType.Restricted + ) }, { "IfNoneMatch", From 8d3a68ad5b6e5ff6407e492dcd98194a1f41b086 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 20 Feb 2020 20:27:21 +0900 Subject: [PATCH 2838/6294] [Modify] Polish it --- websocket-sharp/Net/WebHeaderCollection.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 37a194f7e..686583756 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -289,7 +289,8 @@ static WebHeaderCollection () "IfNoneMatch", new HttpHeaderInfo ( "If-None-Match", - HttpHeaderType.Request | HttpHeaderType.MultiValue) + HttpHeaderType.Request | HttpHeaderType.MultiValue + ) }, { "IfRange", From 98fb80abc338b295914940d3dea45b4ec17ab2ae Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 20 Feb 2020 20:28:06 +0900 Subject: [PATCH 2839/6294] [Modify] Polish it --- websocket-sharp/Net/WebHeaderCollection.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 686583756..a686bb892 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -296,7 +296,8 @@ static WebHeaderCollection () "IfRange", new HttpHeaderInfo ( "If-Range", - HttpHeaderType.Request) + HttpHeaderType.Request + ) }, { "IfUnmodifiedSince", From c50376243092362587f67f8b1eff470113a32ea9 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 20 Feb 2020 20:28:58 +0900 Subject: [PATCH 2840/6294] [Modify] Polish it --- websocket-sharp/Net/WebHeaderCollection.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index a686bb892..74a3c8665 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -303,7 +303,8 @@ static WebHeaderCollection () "IfUnmodifiedSince", new HttpHeaderInfo ( "If-Unmodified-Since", - HttpHeaderType.Request) + HttpHeaderType.Request + ) }, { "KeepAlive", From 62c977ffbb104c080963211fbf2ebfaa98600c13 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 20 Feb 2020 20:32:40 +0900 Subject: [PATCH 2841/6294] [Modify] Polish it --- websocket-sharp/Net/WebHeaderCollection.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 74a3c8665..77c664e63 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -310,7 +310,10 @@ static WebHeaderCollection () "KeepAlive", new HttpHeaderInfo ( "Keep-Alive", - HttpHeaderType.Request | HttpHeaderType.Response | HttpHeaderType.MultiValue) + HttpHeaderType.Request + | HttpHeaderType.Response + | HttpHeaderType.MultiValue + ) }, { "LastModified", From 363ea793173d320dc89a8c86e5eee21818783cc3 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 21 Feb 2020 19:36:55 +0900 Subject: [PATCH 2842/6294] [Modify] Polish it --- websocket-sharp/Net/WebHeaderCollection.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 77c664e63..3be170140 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -319,7 +319,8 @@ static WebHeaderCollection () "LastModified", new HttpHeaderInfo ( "Last-Modified", - HttpHeaderType.Request | HttpHeaderType.Response) + HttpHeaderType.Request | HttpHeaderType.Response + ) }, { "Location", From 62245a4ac78f693ffb6bea952a9d0b18b668c601 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 21 Feb 2020 19:37:53 +0900 Subject: [PATCH 2843/6294] [Modify] Polish it --- websocket-sharp/Net/WebHeaderCollection.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 3be170140..0c7c7c819 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -326,7 +326,8 @@ static WebHeaderCollection () "Location", new HttpHeaderInfo ( "Location", - HttpHeaderType.Response) + HttpHeaderType.Response + ) }, { "MaxForwards", From 392be113f9d09d7d6590c068b936fcb939e1debf Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 21 Feb 2020 19:38:54 +0900 Subject: [PATCH 2844/6294] [Modify] Polish it --- websocket-sharp/Net/WebHeaderCollection.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 0c7c7c819..d9fbd24e5 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -333,7 +333,8 @@ static WebHeaderCollection () "MaxForwards", new HttpHeaderInfo ( "Max-Forwards", - HttpHeaderType.Request) + HttpHeaderType.Request + ) }, { "Pragma", From 39c2e0a6e5f40089e177f85bcf9e1c9e85894db9 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 21 Feb 2020 19:40:54 +0900 Subject: [PATCH 2845/6294] [Modify] Polish it --- websocket-sharp/Net/WebHeaderCollection.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index d9fbd24e5..e0c242162 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -340,7 +340,8 @@ static WebHeaderCollection () "Pragma", new HttpHeaderInfo ( "Pragma", - HttpHeaderType.Request | HttpHeaderType.Response) + HttpHeaderType.Request | HttpHeaderType.Response + ) }, { "ProxyAuthenticate", From c93d191b45013c7a37ff21feb4dcff0eca150b99 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 21 Feb 2020 19:41:47 +0900 Subject: [PATCH 2846/6294] [Modify] Polish it --- websocket-sharp/Net/WebHeaderCollection.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index e0c242162..ea7fcb354 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -347,7 +347,8 @@ static WebHeaderCollection () "ProxyAuthenticate", new HttpHeaderInfo ( "Proxy-Authenticate", - HttpHeaderType.Response | HttpHeaderType.MultiValue) + HttpHeaderType.Response | HttpHeaderType.MultiValue + ) }, { "ProxyAuthorization", From 541328f526129689482efd17246767b9899a1bdd Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 21 Feb 2020 19:42:36 +0900 Subject: [PATCH 2847/6294] [Modify] Polish it --- websocket-sharp/Net/WebHeaderCollection.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index ea7fcb354..5ad0a8028 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -354,7 +354,8 @@ static WebHeaderCollection () "ProxyAuthorization", new HttpHeaderInfo ( "Proxy-Authorization", - HttpHeaderType.Request) + HttpHeaderType.Request + ) }, { "ProxyConnection", From 6e48d618cf2bc62dc8fd7e478c3bd688c9c78e1b Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 21 Feb 2020 19:44:30 +0900 Subject: [PATCH 2848/6294] [Modify] Polish it --- websocket-sharp/Net/WebHeaderCollection.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 5ad0a8028..deb1aa9a0 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -361,7 +361,10 @@ static WebHeaderCollection () "ProxyConnection", new HttpHeaderInfo ( "Proxy-Connection", - HttpHeaderType.Request | HttpHeaderType.Response | HttpHeaderType.Restricted) + HttpHeaderType.Request + | HttpHeaderType.Response + | HttpHeaderType.Restricted + ) }, { "Public", From 98046538d841439c0ec12b8374ceb0b0ff6844c1 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 21 Feb 2020 19:45:15 +0900 Subject: [PATCH 2849/6294] [Modify] Polish it --- websocket-sharp/Net/WebHeaderCollection.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index deb1aa9a0..b03ab1278 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -370,7 +370,8 @@ static WebHeaderCollection () "Public", new HttpHeaderInfo ( "Public", - HttpHeaderType.Response | HttpHeaderType.MultiValue) + HttpHeaderType.Response | HttpHeaderType.MultiValue + ) }, { "Range", From 85267ad619ce5f508c6991a15f1878da34d1958f Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 21 Feb 2020 19:46:45 +0900 Subject: [PATCH 2850/6294] [Modify] Polish it --- websocket-sharp/Net/WebHeaderCollection.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index b03ab1278..03ac7f0fc 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -377,7 +377,10 @@ static WebHeaderCollection () "Range", new HttpHeaderInfo ( "Range", - HttpHeaderType.Request | HttpHeaderType.Restricted | HttpHeaderType.MultiValue) + HttpHeaderType.Request + | HttpHeaderType.Restricted + | HttpHeaderType.MultiValue + ) }, { "Referer", From 7d0c31ea23572ceeee0872b1a2bf1c3509a6d29b Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 21 Feb 2020 19:47:28 +0900 Subject: [PATCH 2851/6294] [Modify] Polish it --- websocket-sharp/Net/WebHeaderCollection.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 03ac7f0fc..226ff555a 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -386,7 +386,8 @@ static WebHeaderCollection () "Referer", new HttpHeaderInfo ( "Referer", - HttpHeaderType.Request | HttpHeaderType.Restricted) + HttpHeaderType.Request | HttpHeaderType.Restricted + ) }, { "RetryAfter", From c9e41f7c02f3e919ba3dd79f21d22a9eb8b1da41 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 21 Feb 2020 19:48:16 +0900 Subject: [PATCH 2852/6294] [Modify] Polish it --- websocket-sharp/Net/WebHeaderCollection.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 226ff555a..f28a2fe0e 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -393,7 +393,8 @@ static WebHeaderCollection () "RetryAfter", new HttpHeaderInfo ( "Retry-After", - HttpHeaderType.Response) + HttpHeaderType.Response + ) }, { "SecWebSocketAccept", From 691dd1729410b3bb81693873756f8ea0db77ddf9 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 21 Feb 2020 19:49:20 +0900 Subject: [PATCH 2853/6294] [Modify] Polish it --- websocket-sharp/Net/WebHeaderCollection.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index f28a2fe0e..696236f8a 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -400,7 +400,8 @@ static WebHeaderCollection () "SecWebSocketAccept", new HttpHeaderInfo ( "Sec-WebSocket-Accept", - HttpHeaderType.Response | HttpHeaderType.Restricted) + HttpHeaderType.Response | HttpHeaderType.Restricted + ) }, { "SecWebSocketExtensions", From 6a50eb3cb4965e2b31dcb39da6d5bab72c447262 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 21 Feb 2020 19:52:32 +0900 Subject: [PATCH 2854/6294] [Modify] Polish it --- websocket-sharp/Net/WebHeaderCollection.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 696236f8a..241cba449 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -407,10 +407,11 @@ static WebHeaderCollection () "SecWebSocketExtensions", new HttpHeaderInfo ( "Sec-WebSocket-Extensions", - HttpHeaderType.Request | - HttpHeaderType.Response | - HttpHeaderType.Restricted | - HttpHeaderType.MultiValueInRequest) + HttpHeaderType.Request + | HttpHeaderType.Response + | HttpHeaderType.Restricted + | HttpHeaderType.MultiValueInRequest + ) }, { "SecWebSocketKey", From e261e0ec375c1294a42b63e0b5eeacd5f5a47044 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 21 Feb 2020 19:53:21 +0900 Subject: [PATCH 2855/6294] [Modify] Polish it --- websocket-sharp/Net/WebHeaderCollection.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 241cba449..6f84ef1e7 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -417,7 +417,8 @@ static WebHeaderCollection () "SecWebSocketKey", new HttpHeaderInfo ( "Sec-WebSocket-Key", - HttpHeaderType.Request | HttpHeaderType.Restricted) + HttpHeaderType.Request | HttpHeaderType.Restricted + ) }, { "SecWebSocketProtocol", From 20f57f37591f1dc92dd69eeb413f38495637dadc Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 21 Feb 2020 19:54:49 +0900 Subject: [PATCH 2856/6294] [Modify] Polish it --- websocket-sharp/Net/WebHeaderCollection.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 6f84ef1e7..abcde096e 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -424,7 +424,10 @@ static WebHeaderCollection () "SecWebSocketProtocol", new HttpHeaderInfo ( "Sec-WebSocket-Protocol", - HttpHeaderType.Request | HttpHeaderType.Response | HttpHeaderType.MultiValueInRequest) + HttpHeaderType.Request + | HttpHeaderType.Response + | HttpHeaderType.MultiValueInRequest + ) }, { "SecWebSocketVersion", From 7de9e2b1a2dc14db2600f936c22f316d3d590589 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 21 Feb 2020 19:56:49 +0900 Subject: [PATCH 2857/6294] [Modify] Polish it --- websocket-sharp/Net/WebHeaderCollection.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index abcde096e..50bdf81ad 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -433,10 +433,11 @@ static WebHeaderCollection () "SecWebSocketVersion", new HttpHeaderInfo ( "Sec-WebSocket-Version", - HttpHeaderType.Request | - HttpHeaderType.Response | - HttpHeaderType.Restricted | - HttpHeaderType.MultiValueInResponse) + HttpHeaderType.Request + | HttpHeaderType.Response + | HttpHeaderType.Restricted + | HttpHeaderType.MultiValueInResponse + ) }, { "Server", From 1d550afe505af0039a9249ced5524871cdfe9ce6 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 22 Feb 2020 21:27:07 +0900 Subject: [PATCH 2858/6294] [Modify] Polish it --- websocket-sharp/Net/WebHeaderCollection.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 50bdf81ad..c7d50926d 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -443,7 +443,8 @@ static WebHeaderCollection () "Server", new HttpHeaderInfo ( "Server", - HttpHeaderType.Response) + HttpHeaderType.Response + ) }, { "SetCookie", From 272324f4c763c2f2a8d777c27f312a5e7a88cb85 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 22 Feb 2020 21:28:00 +0900 Subject: [PATCH 2859/6294] [Modify] Polish it --- websocket-sharp/Net/WebHeaderCollection.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index c7d50926d..36e4c16f0 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -450,7 +450,8 @@ static WebHeaderCollection () "SetCookie", new HttpHeaderInfo ( "Set-Cookie", - HttpHeaderType.Response | HttpHeaderType.MultiValue) + HttpHeaderType.Response | HttpHeaderType.MultiValue + ) }, { "SetCookie2", From 366484e00002b154ad904f960d5dc3060be76c89 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 22 Feb 2020 21:28:52 +0900 Subject: [PATCH 2860/6294] [Modify] Polish it --- websocket-sharp/Net/WebHeaderCollection.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 36e4c16f0..ded25daad 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -457,7 +457,8 @@ static WebHeaderCollection () "SetCookie2", new HttpHeaderInfo ( "Set-Cookie2", - HttpHeaderType.Response | HttpHeaderType.MultiValue) + HttpHeaderType.Response | HttpHeaderType.MultiValue + ) }, { "Te", From 2ee50959953734da03f53e0e338201dcd4ae3946 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 22 Feb 2020 21:29:39 +0900 Subject: [PATCH 2861/6294] [Modify] Polish it --- websocket-sharp/Net/WebHeaderCollection.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index ded25daad..b54ceabdb 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -464,7 +464,8 @@ static WebHeaderCollection () "Te", new HttpHeaderInfo ( "TE", - HttpHeaderType.Request) + HttpHeaderType.Request + ) }, { "Trailer", From c2263c4213f081031d3041407ec1c49fd21d4c39 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 22 Feb 2020 21:30:20 +0900 Subject: [PATCH 2862/6294] [Modify] Polish it --- websocket-sharp/Net/WebHeaderCollection.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index b54ceabdb..7f4551a7e 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -471,7 +471,8 @@ static WebHeaderCollection () "Trailer", new HttpHeaderInfo ( "Trailer", - HttpHeaderType.Request | HttpHeaderType.Response) + HttpHeaderType.Request | HttpHeaderType.Response + ) }, { "TransferEncoding", From a616325dca4f41200491e571fd1645d1eb76b1e7 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 22 Feb 2020 21:31:53 +0900 Subject: [PATCH 2863/6294] [Modify] Polish it --- websocket-sharp/Net/WebHeaderCollection.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 7f4551a7e..ae6966140 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -478,10 +478,11 @@ static WebHeaderCollection () "TransferEncoding", new HttpHeaderInfo ( "Transfer-Encoding", - HttpHeaderType.Request | - HttpHeaderType.Response | - HttpHeaderType.Restricted | - HttpHeaderType.MultiValue) + HttpHeaderType.Request + | HttpHeaderType.Response + | HttpHeaderType.Restricted + | HttpHeaderType.MultiValue + ) }, { "Translate", From c8a6e88ea93023b8bb631cab3b9df7f1d4cc588e Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 22 Feb 2020 21:32:39 +0900 Subject: [PATCH 2864/6294] [Modify] Polish it --- websocket-sharp/Net/WebHeaderCollection.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index ae6966140..dee02375c 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -488,7 +488,8 @@ static WebHeaderCollection () "Translate", new HttpHeaderInfo ( "Translate", - HttpHeaderType.Request) + HttpHeaderType.Request + ) }, { "Upgrade", From bb1ecfccde28a31ffb2cc5c88064d5deb8d85100 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 22 Feb 2020 21:33:53 +0900 Subject: [PATCH 2865/6294] [Modify] Polish it --- websocket-sharp/Net/WebHeaderCollection.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index dee02375c..bb77262d9 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -495,7 +495,10 @@ static WebHeaderCollection () "Upgrade", new HttpHeaderInfo ( "Upgrade", - HttpHeaderType.Request | HttpHeaderType.Response | HttpHeaderType.MultiValue) + HttpHeaderType.Request + | HttpHeaderType.Response + | HttpHeaderType.MultiValue + ) }, { "UserAgent", From 95e28fc3e2c1cf8475b34092502c4c31af9d6e5c Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 22 Feb 2020 21:34:43 +0900 Subject: [PATCH 2866/6294] [Modify] Polish it --- websocket-sharp/Net/WebHeaderCollection.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index bb77262d9..1486533ce 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -504,7 +504,8 @@ static WebHeaderCollection () "UserAgent", new HttpHeaderInfo ( "User-Agent", - HttpHeaderType.Request | HttpHeaderType.Restricted) + HttpHeaderType.Request | HttpHeaderType.Restricted + ) }, { "Vary", From a525d3e447d6f2fe39deb6b015ec87ff02ea610b Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 22 Feb 2020 21:35:21 +0900 Subject: [PATCH 2867/6294] [Modify] Polish it --- websocket-sharp/Net/WebHeaderCollection.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 1486533ce..1168ed93b 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -511,7 +511,8 @@ static WebHeaderCollection () "Vary", new HttpHeaderInfo ( "Vary", - HttpHeaderType.Response | HttpHeaderType.MultiValue) + HttpHeaderType.Response | HttpHeaderType.MultiValue + ) }, { "Via", From 1c11ac7bbdb9368950f5ef308c5fa8fd08fa79ec Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 22 Feb 2020 21:36:23 +0900 Subject: [PATCH 2868/6294] [Modify] Polish it --- websocket-sharp/Net/WebHeaderCollection.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 1168ed93b..6d984ca73 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -518,7 +518,10 @@ static WebHeaderCollection () "Via", new HttpHeaderInfo ( "Via", - HttpHeaderType.Request | HttpHeaderType.Response | HttpHeaderType.MultiValue) + HttpHeaderType.Request + | HttpHeaderType.Response + | HttpHeaderType.MultiValue + ) }, { "Warning", From 3350fa13d7325859d9be32bbf4049a1f8ddb727a Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 22 Feb 2020 21:37:30 +0900 Subject: [PATCH 2869/6294] [Modify] Polish it --- websocket-sharp/Net/WebHeaderCollection.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 6d984ca73..c80eb26f8 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -527,7 +527,10 @@ static WebHeaderCollection () "Warning", new HttpHeaderInfo ( "Warning", - HttpHeaderType.Request | HttpHeaderType.Response | HttpHeaderType.MultiValue) + HttpHeaderType.Request + | HttpHeaderType.Response + | HttpHeaderType.MultiValue + ) }, { "WwwAuthenticate", From aeb45d5eb6d4c59e3597bf35fb58b91aadea1618 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 22 Feb 2020 21:38:56 +0900 Subject: [PATCH 2870/6294] [Modify] Polish it --- websocket-sharp/Net/WebHeaderCollection.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index c80eb26f8..fe19250b0 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -536,7 +536,10 @@ static WebHeaderCollection () "WwwAuthenticate", new HttpHeaderInfo ( "WWW-Authenticate", - HttpHeaderType.Response | HttpHeaderType.Restricted | HttpHeaderType.MultiValue) + HttpHeaderType.Response + | HttpHeaderType.Restricted + | HttpHeaderType.MultiValue + ) } }; } From b430c71bff5b4370e7ff2582229a259ad1808afb Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 23 Feb 2020 22:02:39 +0900 Subject: [PATCH 2871/6294] [Modify] Polish it --- websocket-sharp/Net/WebHeaderCollection.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index fe19250b0..585f2ba99 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -575,7 +575,8 @@ internal WebHeaderCollection (HttpHeaderType state, bool internallyUsed) /// An element with the specified name isn't found in . /// protected WebHeaderCollection ( - SerializationInfo serializationInfo, StreamingContext streamingContext) + SerializationInfo serializationInfo, StreamingContext streamingContext + ) { if (serializationInfo == null) throw new ArgumentNullException ("serializationInfo"); @@ -585,10 +586,12 @@ protected WebHeaderCollection ( _state = (HttpHeaderType) serializationInfo.GetInt32 ("State"); var cnt = serializationInfo.GetInt32 ("Count"); + for (var i = 0; i < cnt; i++) { base.Add ( serializationInfo.GetString (i.ToString ()), - serializationInfo.GetString ((cnt + i).ToString ())); + serializationInfo.GetString ((cnt + i).ToString ()) + ); } } catch (SerializationException ex) { From f4b57d04ff2c0a9394755d026b63bfd45b9751bb Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 24 Feb 2020 22:20:09 +0900 Subject: [PATCH 2872/6294] [Modify] Edit it --- websocket-sharp/Net/WebHeaderCollection.cs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 585f2ba99..64b0b10a1 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -559,20 +559,24 @@ internal WebHeaderCollection (HttpHeaderType state, bool internallyUsed) #region Protected Constructors /// - /// Initializes a new instance of the class from - /// the specified and . + /// Initializes a new instance of the + /// class from the specified and + /// . /// /// - /// A that contains the serialized object data. + /// A that contains the serialized + /// object data. /// /// - /// A that specifies the source for the deserialization. + /// A that specifies the source for + /// the deserialization. /// /// /// is . /// /// - /// An element with the specified name isn't found in . + /// An element with the specified name is not found in + /// . /// protected WebHeaderCollection ( SerializationInfo serializationInfo, StreamingContext streamingContext From ec8c530313abf7068056d7133ad9e67d957cc4b9 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 25 Feb 2020 21:09:21 +0900 Subject: [PATCH 2873/6294] [Modify] Edit it --- websocket-sharp/Net/WebHeaderCollection.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 64b0b10a1..cba21757b 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -559,9 +559,9 @@ internal WebHeaderCollection (HttpHeaderType state, bool internallyUsed) #region Protected Constructors /// - /// Initializes a new instance of the - /// class from the specified and - /// . + /// Initializes a new instance of the class + /// from the specified instances of the and + /// classes. /// /// /// A that contains the serialized From f0773e34de06286cfb884541ee2cd09530ce7353 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 26 Feb 2020 21:33:29 +0900 Subject: [PATCH 2874/6294] [Modify] Polish it --- websocket-sharp/Net/WebHeaderCollection.cs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index cba21757b..82f39f144 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1262,10 +1262,15 @@ public override string[] GetValues (string header) /// /// is . /// - [SecurityPermission ( - SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.SerializationFormatter)] + [ + SecurityPermission ( + SecurityAction.LinkDemand, + Flags = SecurityPermissionFlag.SerializationFormatter + ) + ] public override void GetObjectData ( - SerializationInfo serializationInfo, StreamingContext streamingContext) + SerializationInfo serializationInfo, StreamingContext streamingContext + ) { if (serializationInfo == null) throw new ArgumentNullException ("serializationInfo"); @@ -1274,12 +1279,15 @@ public override void GetObjectData ( serializationInfo.AddValue ("State", (int) _state); var cnt = Count; + serializationInfo.AddValue ("Count", cnt); + cnt.Times ( i => { serializationInfo.AddValue (i.ToString (), GetKey (i)); serializationInfo.AddValue ((cnt + i).ToString (), Get (i)); - }); + } + ); } /// From 2e19ba724472aee7ad63596ae2ffe9ebdf60e118 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 27 Feb 2020 20:09:27 +0900 Subject: [PATCH 2875/6294] [Modify] Polish it --- websocket-sharp/Net/WebHeaderCollection.cs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 82f39f144..661c1c8c3 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1282,12 +1282,10 @@ public override void GetObjectData ( serializationInfo.AddValue ("Count", cnt); - cnt.Times ( - i => { - serializationInfo.AddValue (i.ToString (), GetKey (i)); - serializationInfo.AddValue ((cnt + i).ToString (), Get (i)); - } - ); + for (var i = 0; i < cnt; i++) { + serializationInfo.AddValue (i.ToString (), GetKey (i)); + serializationInfo.AddValue ((cnt + i).ToString (), Get (i)); + } } /// From c553f8163fcef82e67c15f2d5c73087da5ab8dbb Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 28 Feb 2020 21:53:05 +0900 Subject: [PATCH 2876/6294] [Modify] Edit it --- websocket-sharp/Net/WebHeaderCollection.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 661c1c8c3..e12f078a5 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1250,14 +1250,15 @@ public override string[] GetValues (string header) } /// - /// Populates the specified with the data needed to serialize - /// the . + /// Populates a instance with the data + /// needed to serialize this instance. /// /// - /// A that holds the serialized object data. + /// A to populate with the data. /// /// - /// A that specifies the destination for the serialization. + /// A that specifies the destination for + /// the serialization. /// /// /// is . From 779e2e8d360210ae204199d2265380fdba209323 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 29 Feb 2020 22:55:35 +0900 Subject: [PATCH 2877/6294] [Modify] Edit it --- websocket-sharp/Net/WebHeaderCollection.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index e12f078a5..faf121120 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -608,7 +608,8 @@ protected WebHeaderCollection ( #region Public Constructors /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the + /// class. /// public WebHeaderCollection () { From 145c821d36bb8dca60eb2874e32e80c80abbe44c Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 1 Mar 2020 22:17:05 +0900 Subject: [PATCH 2878/6294] [Modify] Edit it --- websocket-sharp/Net/WebHeaderCollection.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index faf121120..f33745c69 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -52,7 +52,8 @@ namespace WebSocketSharp.Net { /// - /// Provides a collection of the HTTP headers associated with a request or response. + /// Provides a collection of the HTTP headers associated with a request or + /// response. /// [Serializable] [ComVisible (true)] From d71c7e2e9ab9f837fffabf61d5f524daf033f72e Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 2 Mar 2020 17:37:01 +0900 Subject: [PATCH 2879/6294] [Modify] Polish it --- websocket-sharp/Net/WebHeaderCollection.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index f33745c69..a7b305b93 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -793,8 +793,12 @@ private static string checkName (string name) throw new ArgumentNullException ("name"); name = name.Trim (); - if (!IsHeaderName (name)) - throw new ArgumentException ("Contains invalid characters.", "name"); + + if (!IsHeaderName (name)) { + var msg = "It contains an invalid character."; + + throw new ArgumentException (msg, "name"); + } return name; } From de173179bfed43ffd4922db652ded8f3f8cc9431 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 3 Mar 2020 21:17:53 +0900 Subject: [PATCH 2880/6294] [Modify] Polish it --- websocket-sharp/Net/WebHeaderCollection.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index a7b305b93..a9993a5f4 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -789,9 +789,12 @@ private static HttpHeaderType checkHeaderType (string name) private static string checkName (string name) { - if (name == null || name.Length == 0) + if (name == null) throw new ArgumentNullException ("name"); + if (name.Length == 0) + throw new ArgumentException ("An empty string.", "name"); + name = name.Trim (); if (!IsHeaderName (name)) { From 0bb7e462db391d9324259abe6d2c2670a7e6ad60 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 4 Mar 2020 21:28:31 +0900 Subject: [PATCH 2881/6294] [Modify] Polish it --- websocket-sharp/Net/WebHeaderCollection.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index a9993a5f4..66bd70454 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -797,6 +797,9 @@ private static string checkName (string name) name = name.Trim (); + if (name.Length == 0) + throw new ArgumentException ("A string of spaces.", "name"); + if (!IsHeaderName (name)) { var msg = "It contains an invalid character."; From ca80835f27cacfd7917aa5f24c3dad3cb71ee36e Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 5 Mar 2020 21:54:04 +0900 Subject: [PATCH 2882/6294] [Modify] Polish it --- websocket-sharp/Net/WebHeaderCollection.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 66bd70454..4463fdf5e 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -939,7 +939,7 @@ internal void InternalSet (string name, string value, bool response) internal static bool IsHeaderName (string name) { - return name != null && name.Length > 0 && name.IsToken (); + return name.IsToken (); } internal static bool IsHeaderValue (string value) From a0397a14d391dd8cc67b54b3b32bf3b5611c662e Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 6 Mar 2020 19:37:49 +0900 Subject: [PATCH 2883/6294] [Modify] Replace it --- websocket-sharp/Net/WebHeaderCollection.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 4463fdf5e..39bd7f6ed 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -800,7 +800,7 @@ private static string checkName (string name) if (name.Length == 0) throw new ArgumentException ("A string of spaces.", "name"); - if (!IsHeaderName (name)) { + if (!name.IsToken ()) { var msg = "It contains an invalid character."; throw new ArgumentException (msg, "name"); From 21e67e4585a8ee91352a5de36f8f96aeb1b41f1d Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 6 Mar 2020 19:40:14 +0900 Subject: [PATCH 2884/6294] [Modify] Remove it --- websocket-sharp/Net/WebHeaderCollection.cs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 39bd7f6ed..a2d88c7e2 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -937,11 +937,6 @@ internal void InternalSet (string name, string value, bool response) base.Set (name, value); } - internal static bool IsHeaderName (string name) - { - return name.IsToken (); - } - internal static bool IsHeaderValue (string value) { return value.IsText (); From 636119a119955ed4e5f8a1224c90a035b466cf9e Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 7 Mar 2020 21:54:51 +0900 Subject: [PATCH 2885/6294] [Modify] Polish it --- websocket-sharp/Net/WebHeaderCollection.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index a2d88c7e2..a81c92585 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -835,8 +835,12 @@ private static string checkValue (string value) return String.Empty; value = value.Trim (); - if (value.Length > 65535) - throw new ArgumentOutOfRangeException ("value", "Greater than 65,535 characters."); + + if (value.Length > 65535) { + var msg = "The length is greater than 65,535 characters."; + + throw new ArgumentOutOfRangeException ("value", msg); + } if (!IsHeaderValue (value)) throw new ArgumentException ("Contains invalid characters.", "value"); From 617659db6b9560d65f07863ec1e4ce3d62ca84c7 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 8 Mar 2020 22:13:30 +0900 Subject: [PATCH 2886/6294] [Modify] Polish it --- websocket-sharp/Net/WebHeaderCollection.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index a81c92585..2b943019d 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -842,8 +842,11 @@ private static string checkValue (string value) throw new ArgumentOutOfRangeException ("value", msg); } - if (!IsHeaderValue (value)) - throw new ArgumentException ("Contains invalid characters.", "value"); + if (!IsHeaderValue (value)) { + var msg = "It contains an invalid character."; + + throw new ArgumentException (msg, "value"); + } return value; } From 45a72e9b88bcc4d875b45f0063ab0ddb8452e2bf Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 9 Mar 2020 20:53:51 +0900 Subject: [PATCH 2887/6294] [Modify] Polish it --- websocket-sharp/Net/WebHeaderCollection.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 2b943019d..ca66fbe0b 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -831,9 +831,12 @@ private void checkState (bool response) private static string checkValue (string value) { - if (value == null || value.Length == 0) + if (value == null) return String.Empty; + if (value.Length == 0) + return value; + value = value.Trim (); if (value.Length > 65535) { From a08b29ff1c751f0bb01405c32571c9d19c7b1081 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 10 Mar 2020 20:57:36 +0900 Subject: [PATCH 2888/6294] [Modify] Polish it --- websocket-sharp/Net/WebHeaderCollection.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index ca66fbe0b..f3aa0fac4 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -839,7 +839,12 @@ private static string checkValue (string value) value = value.Trim (); - if (value.Length > 65535) { + var len = value.Length; + + if (len == 0) + return value; + + if (len > 65535) { var msg = "The length is greater than 65,535 characters."; throw new ArgumentOutOfRangeException ("value", msg); From ac30edeafdef65b1a1ea94f8aa4c597ed93eb2ee Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 11 Mar 2020 21:42:44 +0900 Subject: [PATCH 2889/6294] [Modify] Polish it --- websocket-sharp/Net/WebHeaderCollection.cs | 3 --- 1 file changed, 3 deletions(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index f3aa0fac4..ad07ca8ad 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -834,9 +834,6 @@ private static string checkValue (string value) if (value == null) return String.Empty; - if (value.Length == 0) - return value; - value = value.Trim (); var len = value.Length; From e7a4729bf83bd58c53ce766c42e9b53f2a3f9683 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 12 Mar 2020 21:29:05 +0900 Subject: [PATCH 2890/6294] [Modify] Replace it --- websocket-sharp/Net/WebHeaderCollection.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index ad07ca8ad..ddaba6ccb 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -847,7 +847,7 @@ private static string checkValue (string value) throw new ArgumentOutOfRangeException ("value", msg); } - if (!IsHeaderValue (value)) { + if (!value.IsText ()) { var msg = "It contains an invalid character."; throw new ArgumentException (msg, "value"); From c86632e529bd520983a9324f7d9c1a3904c5a750 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 12 Mar 2020 21:33:05 +0900 Subject: [PATCH 2891/6294] [Modify] Remove it --- websocket-sharp/Net/WebHeaderCollection.cs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index ddaba6ccb..bf681d1a1 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -949,11 +949,6 @@ internal void InternalSet (string name, string value, bool response) base.Set (name, value); } - internal static bool IsHeaderValue (string value) - { - return value.IsText (); - } - internal static bool IsMultiValue (string headerName, bool response) { if (headerName == null || headerName.Length == 0) From 32efdc25c3630b0173743762e3945fde2dc6d9b0 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 13 Mar 2020 22:23:51 +0900 Subject: [PATCH 2892/6294] [Modify] Polish it --- websocket-sharp/Net/WebHeaderCollection.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index bf681d1a1..894a1cc19 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -811,7 +811,10 @@ private static string checkName (string name) private void checkRestricted (string name) { - if (!_internallyUsed && isRestricted (name, true)) + if (_internallyUsed) + return; + + if (isRestricted (name, true)) throw new ArgumentException ("This header must be modified with the appropiate property."); } From 1d14400c0e3311cd3f36e881b861ac385cf34459 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 14 Mar 2020 21:42:52 +0900 Subject: [PATCH 2893/6294] [Modify] Polish it --- websocket-sharp/Net/WebHeaderCollection.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 894a1cc19..5de951d1d 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -814,8 +814,11 @@ private void checkRestricted (string name) if (_internallyUsed) return; - if (isRestricted (name, true)) - throw new ArgumentException ("This header must be modified with the appropiate property."); + if (isRestricted (name, true)) { + var msg = "This header must be modified with the appropiate property."; + + throw new ArgumentException (msg); + } } private void checkState (bool response) From bb790904086e99d5764805ea9c4011e9dd2adf97 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 15 Mar 2020 22:23:46 +0900 Subject: [PATCH 2894/6294] [Modify] Polish it --- websocket-sharp/Net/WebHeaderCollection.cs | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 5de951d1d..b108002a3 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -826,13 +826,20 @@ private void checkState (bool response) if (_state == HttpHeaderType.Unspecified) return; - if (response && _state == HttpHeaderType.Request) - throw new InvalidOperationException ( - "This collection has already been used to store the request headers."); + if (response) { + if (_state == HttpHeaderType.Response) + return; - if (!response && _state == HttpHeaderType.Response) - throw new InvalidOperationException ( - "This collection has already been used to store the response headers."); + var msg = "This collection has already been used for the request headers."; + + throw new InvalidOperationException (msg); + } + + if (_state == HttpHeaderType.Response) { + var msg = "This collection has already been used for the response headers."; + + throw new InvalidOperationException (msg); + } } private static string checkValue (string value) From 123fc28e70ae2cc6322d235077c1183598d84b48 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 16 Mar 2020 21:05:35 +0900 Subject: [PATCH 2895/6294] [Modify] Polish it --- websocket-sharp/Net/WebHeaderCollection.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index b108002a3..072a9bf19 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -830,7 +830,7 @@ private void checkState (bool response) if (_state == HttpHeaderType.Response) return; - var msg = "This collection has already been used for the request headers."; + var msg = "This collection is already in use for the request headers."; throw new InvalidOperationException (msg); } From 71cfca9ac372b3ed659e76a238476ca33e3317d7 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 16 Mar 2020 21:07:12 +0900 Subject: [PATCH 2896/6294] [Modify] Polish it --- websocket-sharp/Net/WebHeaderCollection.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 072a9bf19..67121258c 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -836,7 +836,7 @@ private void checkState (bool response) } if (_state == HttpHeaderType.Response) { - var msg = "This collection has already been used for the response headers."; + var msg = "This collection is already in use for the response headers."; throw new InvalidOperationException (msg); } From 46f464910621054d6d68df0d5610b5409de9b580 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 17 Mar 2020 21:52:18 +0900 Subject: [PATCH 2897/6294] [Modify] Polish it --- websocket-sharp/Net/WebHeaderCollection.cs | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 67121258c..67f984930 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -888,12 +888,22 @@ private void doWithCheckingState ( } private void doWithCheckingState ( - Action action, string name, string value, bool response, bool setState) + Action action, + string name, + string value, + bool response, + bool setState + ) { checkState (response); action (name, value); - if (setState && _state == HttpHeaderType.Unspecified) - _state = response ? HttpHeaderType.Response : HttpHeaderType.Request; + + setState = setState && _state == HttpHeaderType.Unspecified; + + if (!setState) + return; + + _state = response ? HttpHeaderType.Response : HttpHeaderType.Request; } private void doWithoutCheckingName (Action action, string name, string value) From 5ed71dad8884a29eca2c1dcbb63483f5592ff8b4 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 18 Mar 2020 19:46:15 +0900 Subject: [PATCH 2898/6294] [Modify] Polish it --- websocket-sharp/Net/WebHeaderCollection.cs | 23 +++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 67f984930..4189c9b9e 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -876,15 +876,24 @@ private static string convert (string key) } private void doWithCheckingState ( - Action action, string name, string value, bool setState) + Action action, string name, string value, bool setState + ) { - var type = checkHeaderType (name); - if (type == HttpHeaderType.Request) - doWithCheckingState (action, name, value, false, setState); - else if (type == HttpHeaderType.Response) + var headerType = checkHeaderType (name); + + if (headerType == HttpHeaderType.Response) { doWithCheckingState (action, name, value, true, setState); - else - action (name, value); + + return; + } + + if (headerType == HttpHeaderType.Request) { + doWithCheckingState (action, name, value, false, setState); + + return; + } + + action (name, value); } private void doWithCheckingState ( From 53c941c869271ced90682de5a5210dc78e37ea40 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 19 Mar 2020 21:52:33 +0900 Subject: [PATCH 2899/6294] [Modify] Polish it --- websocket-sharp/Net/WebHeaderCollection.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 4189c9b9e..695af5f30 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -923,9 +923,12 @@ private void doWithoutCheckingName (Action action, string name, private static HttpHeaderInfo getHeaderInfo (string name) { - foreach (var info in _headers.Values) - if (info.Name.Equals (name, StringComparison.InvariantCultureIgnoreCase)) - return info; + var comparison = StringComparison.InvariantCultureIgnoreCase; + + foreach (var headerInfo in _headers.Values) { + if (headerInfo.Name.Equals (name, comparison)) + return headerInfo; + } return null; } From ec2e24aa21b5f881c96530703651c7a07e86718a Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 20 Mar 2020 19:40:31 +0900 Subject: [PATCH 2900/6294] [Modify] Polish it --- websocket-sharp/Net/WebHeaderCollection.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 695af5f30..3a0f2e541 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -935,8 +935,9 @@ private static HttpHeaderInfo getHeaderInfo (string name) private static bool isRestricted (string name, bool response) { - var info = getHeaderInfo (name); - return info != null && info.IsRestricted (response); + var headerInfo = getHeaderInfo (name); + + return headerInfo != null && headerInfo.IsRestricted (response); } private void removeWithoutCheckingName (string name, string unuse) From 37cef1c7734b4eee2661bfe8b5887149585eb0e0 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 21 Mar 2020 21:57:21 +0900 Subject: [PATCH 2901/6294] [Modify] Polish it --- websocket-sharp/Net/WebHeaderCollection.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 3a0f2e541..ccd69de60 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -915,7 +915,9 @@ bool setState _state = response ? HttpHeaderType.Response : HttpHeaderType.Request; } - private void doWithoutCheckingName (Action action, string name, string value) + private void doWithoutCheckingName ( + Action action, string name, string value + ) { checkRestricted (name); action (name, checkValue (value)); From ce21e458ceea277bf9a812040bc92ca143235bfb Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 22 Mar 2020 22:11:18 +0900 Subject: [PATCH 2902/6294] [Modify] Polish it --- websocket-sharp/Net/WebHeaderCollection.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index ccd69de60..d035c3efb 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -920,7 +920,8 @@ private void doWithoutCheckingName ( ) { checkRestricted (name); - action (name, checkValue (value)); + value = checkValue (value); + action (name, value); } private static HttpHeaderInfo getHeaderInfo (string name) From da5e0235b810ccf848966e635fabb6048ae7f963 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 23 Mar 2020 19:48:39 +0900 Subject: [PATCH 2903/6294] [Modify] Polish it --- websocket-sharp/Net/WebHeaderCollection.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index d035c3efb..2bb22cc05 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1359,7 +1359,9 @@ public override void GetObjectData ( /// public static bool IsRestricted (string headerName) { - return isRestricted (checkName (headerName), false); + headerName = checkName (headerName); + + return isRestricted (headerName, false); } /// From 2cdc1ee42b1793205fce88ee700d33b699b65672 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 24 Mar 2020 19:40:43 +0900 Subject: [PATCH 2904/6294] [Modify] Edit it --- websocket-sharp/Net/WebHeaderCollection.cs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 2bb22cc05..932b54ad3 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1343,7 +1343,7 @@ public override void GetObjectData ( } /// - /// Determines whether the specified header can be set for the request. + /// Determines whether the specified HTTP header can be set for the request. /// /// /// true if the header is restricted; otherwise, false. @@ -1352,10 +1352,18 @@ public override void GetObjectData ( /// A that represents the name of the header to test. /// /// - /// is or empty. + /// is . /// /// - /// contains invalid characters. + /// + /// is an empty string. + /// + /// + /// -or- + /// + /// + /// contains an invalid character. + /// /// public static bool IsRestricted (string headerName) { From 91e22c1138c49cfa7b6b19d3adda18f81e1c9ec7 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 24 Mar 2020 19:43:50 +0900 Subject: [PATCH 2905/6294] [Modify] Polish it --- websocket-sharp/Net/WebHeaderCollection.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 932b54ad3..e457c678e 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1392,7 +1392,9 @@ public static bool IsRestricted (string headerName) /// public static bool IsRestricted (string headerName, bool response) { - return isRestricted (checkName (headerName), response); + headerName = checkName (headerName); + + return isRestricted (headerName, response); } /// From b0d860b67decf68cbcd8772e909ea4b69257290b Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 25 Mar 2020 19:51:46 +0900 Subject: [PATCH 2906/6294] [Modify] Edit it --- websocket-sharp/Net/WebHeaderCollection.cs | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index e457c678e..d6c99ac83 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1373,7 +1373,8 @@ public static bool IsRestricted (string headerName) } /// - /// Determines whether the specified header can be set for the request or the response. + /// Determines whether the specified HTTP header can be set for the request + /// or the response. /// /// /// true if the header is restricted; otherwise, false. @@ -1382,13 +1383,22 @@ public static bool IsRestricted (string headerName) /// A that represents the name of the header to test. /// /// - /// true if does the test for the response; for the request, false. + /// A : true if the test is for the response; + /// otherwise, false. /// /// - /// is or empty. + /// is . /// /// - /// contains invalid characters. + /// + /// is an empty string. + /// + /// + /// -or- + /// + /// + /// contains an invalid character. + /// /// public static bool IsRestricted (string headerName, bool response) { From ffb0ced9c70b056e3a80eae11c3f1edb30746520 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 25 Mar 2020 19:57:21 +0900 Subject: [PATCH 2907/6294] [Modify] Edit it --- websocket-sharp/Net/WebHeaderCollection.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index d6c99ac83..7b0dc8ceb 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1397,6 +1397,12 @@ public static bool IsRestricted (string headerName) /// -or- /// /// + /// is a string of spaces. + /// + /// + /// -or- + /// + /// /// contains an invalid character. /// /// From 938943097da01da5996ecec8601ef56f7c1a4bde Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 26 Mar 2020 20:01:11 +0900 Subject: [PATCH 2908/6294] [Modify] Edit it --- websocket-sharp/Net/WebHeaderCollection.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 7b0dc8ceb..d0794df06 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1362,6 +1362,12 @@ public override void GetObjectData ( /// -or- /// /// + /// is a string of spaces. + /// + /// + /// -or- + /// + /// /// contains an invalid character. /// /// From 03c0ed6597bc64b51e5e898a28859d10eb01c8ac Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 26 Mar 2020 20:05:07 +0900 Subject: [PATCH 2909/6294] [Modify] Edit it --- websocket-sharp/Net/WebHeaderCollection.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index d0794df06..d483cb655 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1346,7 +1346,7 @@ public override void GetObjectData ( /// Determines whether the specified HTTP header can be set for the request. /// /// - /// true if the header is restricted; otherwise, false. + /// true if the header cannot be set; otherwise, false. /// /// /// A that represents the name of the header to test. From 41c046fdcdc36de563ac253cf33f360eb41b4c8e Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 26 Mar 2020 20:08:46 +0900 Subject: [PATCH 2910/6294] [Modify] Edit it --- websocket-sharp/Net/WebHeaderCollection.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index d483cb655..15f4b8cb8 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1349,7 +1349,7 @@ public override void GetObjectData ( /// true if the header cannot be set; otherwise, false. /// /// - /// A that represents the name of the header to test. + /// A that specifies the name of the header to test. /// /// /// is . From c1ae4bd0fbe27c2af671cda444d6cb96a196c3e0 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 26 Mar 2020 20:10:36 +0900 Subject: [PATCH 2911/6294] [Modify] Polish it --- websocket-sharp/Net/WebHeaderCollection.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 15f4b8cb8..caa0405e0 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1373,9 +1373,7 @@ public override void GetObjectData ( /// public static bool IsRestricted (string headerName) { - headerName = checkName (headerName); - - return isRestricted (headerName, false); + return IsRestricted (headerName, false); } /// From 0ae6d8d3fe2338c7409ef72dbb9fd9cd587a6602 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 27 Mar 2020 19:35:47 +0900 Subject: [PATCH 2912/6294] [Modify] Edit it --- websocket-sharp/Net/WebHeaderCollection.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index caa0405e0..f2623353e 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1381,7 +1381,7 @@ public static bool IsRestricted (string headerName) /// or the response. /// /// - /// true if the header is restricted; otherwise, false. + /// true if the header cannot be set; otherwise, false. /// /// /// A that represents the name of the header to test. From f56521f6a7d3397d32b0bf41667e5913c2fa1401 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 27 Mar 2020 19:37:09 +0900 Subject: [PATCH 2913/6294] [Modify] Edit it --- websocket-sharp/Net/WebHeaderCollection.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index f2623353e..8b007deaa 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1384,7 +1384,7 @@ public static bool IsRestricted (string headerName) /// true if the header cannot be set; otherwise, false. /// /// - /// A that represents the name of the header to test. + /// A that specifies the name of the header to test. /// /// /// A : true if the test is for the response; From bd249ac6e3937308f70a8693af9e990cc4f6d2f7 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 28 Mar 2020 20:59:59 +0900 Subject: [PATCH 2914/6294] [Modify] Replace it --- websocket-sharp/Net/WebHeaderCollection.cs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 8b007deaa..de947fda5 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1412,7 +1412,22 @@ public static bool IsRestricted (string headerName) /// public static bool IsRestricted (string headerName, bool response) { - headerName = checkName (headerName); + if (headerName == null) + throw new ArgumentNullException ("headerName"); + + if (headerName.Length == 0) + throw new ArgumentException ("An empty string.", "headerName"); + + headerName = headerName.Trim (); + + if (headerName.Length == 0) + throw new ArgumentException ("A string of spaces.", "headerName"); + + if (!headerName.IsToken ()) { + var msg = "It contains an invalid character."; + + throw new ArgumentException (msg, "headerName"); + } return isRestricted (headerName, response); } From 632d065597aac0007022dd90e159eb4358b99f20 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 29 Mar 2020 17:33:41 +0900 Subject: [PATCH 2915/6294] [Modify] Edit it --- websocket-sharp/Net/WebHeaderCollection.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index de947fda5..0ffa6a4e9 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -634,7 +634,8 @@ internal HttpHeaderType State { /// Gets all header names in the collection. /// /// - /// An array of that contains all header names in the collection. + /// An array of that contains all header names in + /// the collection. /// public override string[] AllKeys { get { From 637deadf29a4bb80f2826376fb6018da9bd09037 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 29 Mar 2020 17:34:57 +0900 Subject: [PATCH 2916/6294] [Modify] Edit it --- websocket-sharp/Net/WebHeaderCollection.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 0ffa6a4e9..92c82f20a 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -647,7 +647,8 @@ public override string[] AllKeys { /// Gets the number of headers in the collection. /// /// - /// An that represents the number of headers in the collection. + /// An that represents the number of headers in + /// the collection. /// public override int Count { get { From 89a761b2ac2928d645fdaa0073ee84ecd96d2b58 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 30 Mar 2020 22:50:09 +0900 Subject: [PATCH 2917/6294] [Modify] Edit it --- websocket-sharp/Net/WebHeaderCollection.cs | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 92c82f20a..19376047e 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -657,14 +657,18 @@ public override int Count { } /// - /// Gets or sets the specified request in the collection. + /// Gets or sets the specified request header in the collection. /// /// - /// A that represents the value of the request . + /// A that represents the value of the request header. /// /// - /// One of the enum values, represents - /// the request header to get or set. + /// + /// One of the enum values. + /// + /// + /// It represents the request header to get or set. + /// /// /// /// @@ -674,15 +678,15 @@ public override int Count { /// -or- /// /// - /// contains invalid characters. + /// contains an invalid character. /// /// /// /// The length of is greater than 65,535 characters. /// /// - /// The current instance doesn't allow - /// the request . + /// The current instance does not allow + /// the request header. /// public string this[HttpRequestHeader header] { get { From 55ba6ef40ad118536af0c6b4de6aab0dfb51ec86 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 31 Mar 2020 17:09:48 +0900 Subject: [PATCH 2918/6294] [Modify] Edit it --- websocket-sharp/Net/WebHeaderCollection.cs | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 19376047e..37684af87 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -699,14 +699,18 @@ public string this[HttpRequestHeader header] { } /// - /// Gets or sets the specified response in the collection. + /// Gets or sets the specified response header in the collection. /// /// - /// A that represents the value of the response . + /// A that represents the value of the response header. /// /// - /// One of the enum values, represents - /// the response header to get or set. + /// + /// One of the enum values. + /// + /// + /// It represents the response header to get or set. + /// /// /// /// @@ -716,15 +720,15 @@ public string this[HttpRequestHeader header] { /// -or- /// /// - /// contains invalid characters. + /// contains an invalid character. /// /// /// /// The length of is greater than 65,535 characters. /// /// - /// The current instance doesn't allow - /// the response . + /// The current instance does not allow + /// the response header. /// public string this[HttpResponseHeader header] { get { From 8af604b45db0e91ae3eec5712e3418f714aad5f7 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 1 Apr 2020 19:55:01 +0900 Subject: [PATCH 2919/6294] [Modify] Polish it --- websocket-sharp/Net/WebHeaderCollection.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 37684af87..5908ac7c2 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -881,8 +881,11 @@ private static string checkValue (string value) private static string convert (string key) { - HttpHeaderInfo info; - return _headers.TryGetValue (key, out info) ? info.Name : String.Empty; + HttpHeaderInfo headerInfo; + + return _headers.TryGetValue (key, out headerInfo) + ? headerInfo.Name + : String.Empty; } private void doWithCheckingState ( From 4cd5b328b929a8558171969ef74c504ccde6e0b5 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 2 Apr 2020 20:09:10 +0900 Subject: [PATCH 2920/6294] [Modify] Add it --- websocket-sharp/Net/WebHeaderCollection.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 5908ac7c2..5fa79b7c5 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -949,6 +949,15 @@ private static HttpHeaderInfo getHeaderInfo (string name) return null; } + private static string getHeaderName (string key) + { + HttpHeaderInfo headerInfo; + + return _headers.TryGetValue (key, out headerInfo) + ? headerInfo.Name + : null; + } + private static bool isRestricted (string name, bool response) { var headerInfo = getHeaderInfo (name); From 1c59fc1958ba2533b57047ff4f6372fb4fdf2ee0 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 3 Apr 2020 19:35:53 +0900 Subject: [PATCH 2921/6294] [Modify] Replace it --- websocket-sharp/Net/WebHeaderCollection.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 5fa79b7c5..1e8a799ff 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -690,7 +690,10 @@ public override int Count { /// public string this[HttpRequestHeader header] { get { - return Get (Convert (header)); + var key = header.ToString (); + var name = getHeaderName (key); + + return Get (name); } set { From 855d139dc30f27c4cb0abd5948aca8b7ac522322 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 3 Apr 2020 19:41:31 +0900 Subject: [PATCH 2922/6294] [Modify] Edit it --- websocket-sharp/Net/WebHeaderCollection.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 1e8a799ff..467d66b5f 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -685,8 +685,7 @@ public override int Count { /// The length of is greater than 65,535 characters. /// /// - /// The current instance does not allow - /// the request header. + /// This instance does not allow the request header. /// public string this[HttpRequestHeader header] { get { From 9b9e0740eba6d0118a7606f6ea79efe5b79f2e5a Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 4 Apr 2020 22:28:42 +0900 Subject: [PATCH 2923/6294] [Modify] Edit it --- websocket-sharp/Net/WebHeaderCollection.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 467d66b5f..13d515168 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -682,7 +682,8 @@ public override int Count { /// /// /// - /// The length of is greater than 65,535 characters. + /// The length of is greater than 65,535 + /// characters. /// /// /// This instance does not allow the request header. From 2b869075b0e333cf5ce879b32ea62ca8a51a3679 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 5 Apr 2020 19:14:54 +0900 Subject: [PATCH 2924/6294] [Modify] Replace it --- websocket-sharp/Net/WebHeaderCollection.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 13d515168..56ecd4e37 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -735,7 +735,10 @@ public string this[HttpRequestHeader header] { /// public string this[HttpResponseHeader header] { get { - return Get (Convert (header)); + var key = header.ToString (); + var name = getHeaderName (key); + + return Get (name); } set { From 6c8744224d66cc2c8e91737cc09f9ee41ba0a8f9 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 6 Apr 2020 19:50:38 +0900 Subject: [PATCH 2925/6294] [Modify] Edit it --- websocket-sharp/Net/WebHeaderCollection.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 56ecd4e37..83f190e82 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -730,8 +730,7 @@ public string this[HttpRequestHeader header] { /// The length of is greater than 65,535 characters. /// /// - /// The current instance does not allow - /// the response header. + /// This instance does not allow the response header. /// public string this[HttpResponseHeader header] { get { From 8d1c14eb6680d0dfc775effc37fc45966d03556a Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 6 Apr 2020 19:53:21 +0900 Subject: [PATCH 2926/6294] [Modify] Edit it --- websocket-sharp/Net/WebHeaderCollection.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 83f190e82..c23bd4c6e 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -727,7 +727,8 @@ public string this[HttpRequestHeader header] { /// /// /// - /// The length of is greater than 65,535 characters. + /// The length of is greater than 65,535 + /// characters. /// /// /// This instance does not allow the response header. From d8c768ee177f3294fd3957be00b95cff8bcb1235 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 7 Apr 2020 19:45:12 +0900 Subject: [PATCH 2927/6294] [Modify] Edit it --- websocket-sharp/Net/WebHeaderCollection.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index c23bd4c6e..be5971845 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -657,7 +657,7 @@ public override int Count { } /// - /// Gets or sets the specified request header in the collection. + /// Gets or sets the specified request header. /// /// /// A that represents the value of the request header. From 989eb57af3daa61f7c19182e683a4db440f9690f Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 7 Apr 2020 19:46:52 +0900 Subject: [PATCH 2928/6294] [Modify] Edit it --- websocket-sharp/Net/WebHeaderCollection.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index be5971845..5827988b4 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -702,7 +702,7 @@ public string this[HttpRequestHeader header] { } /// - /// Gets or sets the specified response header in the collection. + /// Gets or sets the specified response header. /// /// /// A that represents the value of the response header. From 16206412e144bff7acb9300122ffdf5d168b3dba Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 8 Apr 2020 20:14:51 +0900 Subject: [PATCH 2929/6294] [Modify] Replace it --- websocket-sharp/Net/WebHeaderCollection.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 5827988b4..c083a2dd2 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1152,7 +1152,10 @@ public void Add (string header) /// public void Add (HttpRequestHeader header, string value) { - doWithCheckingState (addWithoutCheckingName, Convert (header), value, false, true); + var key = header.ToString (); + var name = getHeaderName (key); + + doWithCheckingState (addWithoutCheckingName, name, value, false, true); } /// From caac10ed03d340213c7385e88662eacb5228a3fc Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 9 Apr 2020 20:08:42 +0900 Subject: [PATCH 2930/6294] [Modify] Edit it --- websocket-sharp/Net/WebHeaderCollection.cs | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index c083a2dd2..5d0baaf75 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1122,12 +1122,16 @@ public void Add (string header) } /// - /// Adds the specified request with - /// the specified to the collection. + /// Adds the specified request header with the specified value to + /// the collection. /// /// - /// One of the enum values, represents - /// the request header to add. + /// + /// One of the enum values. + /// + /// + /// It represents the request header to add. + /// /// /// /// A that represents the value of the header to add. @@ -1140,15 +1144,15 @@ public void Add (string header) /// -or- /// /// - /// contains invalid characters. + /// contains an invalid character. /// /// /// - /// The length of is greater than 65,535 characters. + /// The length of is greater than 65,535 + /// characters. /// /// - /// The current instance doesn't allow - /// the request . + /// This instance does not allow the request header. /// public void Add (HttpRequestHeader header, string value) { From 141819bd6eca04eec3786c5332c8d756faaccee2 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 10 Apr 2020 19:41:15 +0900 Subject: [PATCH 2931/6294] [Modify] Edit it --- websocket-sharp/Net/WebHeaderCollection.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 5d0baaf75..28178fc15 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1130,11 +1130,11 @@ public void Add (string header) /// One of the enum values. /// /// - /// It represents the request header to add. + /// It specifies the request header to add. /// /// /// - /// A that represents the value of the header to add. + /// A that specifies the value of the header to add. /// /// /// From bc5c2a6cf366d7dea113f787c8444d91b7da411f Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 11 Apr 2020 21:51:37 +0900 Subject: [PATCH 2932/6294] [Modify] Replace it --- websocket-sharp/Net/WebHeaderCollection.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 28178fc15..864173d75 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1193,7 +1193,10 @@ public void Add (HttpRequestHeader header, string value) /// public void Add (HttpResponseHeader header, string value) { - doWithCheckingState (addWithoutCheckingName, Convert (header), value, true, true); + var key = header.ToString (); + var name = getHeaderName (key); + + doWithCheckingState (addWithoutCheckingName, name, value, true, true); } /// From 2c56cc046a2baaa49ef19ba07f57b73d527f4145 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 12 Apr 2020 17:43:21 +0900 Subject: [PATCH 2933/6294] [Modify] Edit it --- websocket-sharp/Net/WebHeaderCollection.cs | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 864173d75..a71ad402f 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1163,15 +1163,19 @@ public void Add (HttpRequestHeader header, string value) } /// - /// Adds the specified response with - /// the specified to the collection. + /// Adds the specified response header with the specified value to + /// the collection. /// /// - /// One of the enum values, represents - /// the response header to add. + /// + /// One of the enum values. + /// + /// + /// It specifies the response header to add. + /// /// /// - /// A that represents the value of the header to add. + /// A that specifies the value of the header to add. /// /// /// @@ -1181,15 +1185,15 @@ public void Add (HttpRequestHeader header, string value) /// -or- /// /// - /// contains invalid characters. + /// contains an invalid character. /// /// /// - /// The length of is greater than 65,535 characters. + /// The length of is greater than 65,535 + /// characters. /// /// - /// The current instance doesn't allow - /// the response . + /// This instance does not allow the response header. /// public void Add (HttpResponseHeader header, string value) { From 86cad7d93abb67c4a795371a3fbedb8889313033 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 13 Apr 2020 21:45:04 +0900 Subject: [PATCH 2934/6294] [Modify] Replace it --- websocket-sharp/Net/WebHeaderCollection.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index a71ad402f..6f2ae5688 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1501,7 +1501,10 @@ public override void OnDeserialization (object sender) /// public void Remove (HttpRequestHeader header) { - doWithCheckingState (removeWithoutCheckingName, Convert (header), null, false, false); + var key = header.ToString (); + var name = getHeaderName (key); + + doWithCheckingState (removeWithoutCheckingName, name, null, false, false); } /// From 46dbef2f057f687d13f2aed057deaba4dc8794fb Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 13 Apr 2020 21:51:16 +0900 Subject: [PATCH 2935/6294] [Modify] Edit it --- websocket-sharp/Net/WebHeaderCollection.cs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 6f2ae5688..0a013994f 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1486,18 +1486,21 @@ public override void OnDeserialization (object sender) } /// - /// Removes the specified request from the collection. + /// Removes the specified request header from the collection. /// /// - /// One of the enum values, represents - /// the request header to remove. + /// + /// One of the enum values. + /// + /// + /// It specifies the request header to remove. + /// /// /// /// is a restricted header. /// /// - /// The current instance doesn't allow - /// the request . + /// This instance does not allow the request header. /// public void Remove (HttpRequestHeader header) { From aa8cdf7a65e541150d0aef180cd7e2f0e42dd0e9 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 14 Apr 2020 21:44:51 +0900 Subject: [PATCH 2936/6294] [Modify] Replace it --- websocket-sharp/Net/WebHeaderCollection.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 0a013994f..b7b32289a 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1526,7 +1526,10 @@ public void Remove (HttpRequestHeader header) /// public void Remove (HttpResponseHeader header) { - doWithCheckingState (removeWithoutCheckingName, Convert (header), null, true, false); + var key = header.ToString (); + var name = getHeaderName (key); + + doWithCheckingState (removeWithoutCheckingName, name, null, true, false); } /// From 9544db0f609f20f231908ab2c148982ddee6f33d Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 14 Apr 2020 21:51:00 +0900 Subject: [PATCH 2937/6294] [Modify] Edit it --- websocket-sharp/Net/WebHeaderCollection.cs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index b7b32289a..d798a611a 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1511,18 +1511,21 @@ public void Remove (HttpRequestHeader header) } /// - /// Removes the specified response from the collection. + /// Removes the specified response header from the collection. /// /// - /// One of the enum values, represents - /// the response header to remove. + /// + /// One of the enum values. + /// + /// + /// It specifies the response header to remove. + /// /// /// /// is a restricted header. /// /// - /// The current instance doesn't allow - /// the response . + /// This instance does not allow the response header. /// public void Remove (HttpResponseHeader header) { From 514c9439046807091a838ff2172d93336c388820 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 15 Apr 2020 19:36:34 +0900 Subject: [PATCH 2938/6294] [Modify] Replace it --- websocket-sharp/Net/WebHeaderCollection.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index d798a611a..ddea68094 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1594,7 +1594,10 @@ public override void Remove (string name) /// public void Set (HttpRequestHeader header, string value) { - doWithCheckingState (setWithoutCheckingName, Convert (header), value, false, true); + var key = header.ToString (); + var name = getHeaderName (key); + + doWithCheckingState (setWithoutCheckingName, name, value, false, true); } /// From 4cf3a1419a9509076acef1cfca3f8460969f4106 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 15 Apr 2020 19:44:23 +0900 Subject: [PATCH 2939/6294] [Modify] Edit it --- websocket-sharp/Net/WebHeaderCollection.cs | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index ddea68094..061809312 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1565,14 +1565,19 @@ public override void Remove (string name) } /// - /// Sets the specified request to the specified value. + /// Sets the specified request header to the specified value. /// /// - /// One of the enum values, represents - /// the request header to set. + /// + /// One of the enum values. + /// + /// + /// It specifies the request header to set. + /// /// /// - /// A that represents the value of the request header to set. + /// A that specifies the value of the request header + /// to set. /// /// /// @@ -1582,15 +1587,15 @@ public override void Remove (string name) /// -or- /// /// - /// contains invalid characters. + /// contains an invalid character. /// /// /// - /// The length of is greater than 65,535 characters. + /// The length of is greater than 65,535 + /// characters. /// /// - /// The current instance doesn't allow - /// the request . + /// This instance does not allow the request header. /// public void Set (HttpRequestHeader header, string value) { From 35810079e712b313251257bbc8a5feaf5d0e0473 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 16 Apr 2020 19:46:50 +0900 Subject: [PATCH 2940/6294] [Modify] Replace it --- websocket-sharp/Net/WebHeaderCollection.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 061809312..7540d7af6 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1635,7 +1635,10 @@ public void Set (HttpRequestHeader header, string value) /// public void Set (HttpResponseHeader header, string value) { - doWithCheckingState (setWithoutCheckingName, Convert (header), value, true, true); + var key = header.ToString (); + var name = getHeaderName (key); + + doWithCheckingState (setWithoutCheckingName, name, value, true, true); } /// From d7abf98b3d6c6d14787c74759a8995512d500f2f Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 16 Apr 2020 19:52:59 +0900 Subject: [PATCH 2941/6294] [Modify] Edit it --- websocket-sharp/Net/WebHeaderCollection.cs | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 7540d7af6..11c51aa80 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1606,14 +1606,19 @@ public void Set (HttpRequestHeader header, string value) } /// - /// Sets the specified response to the specified value. + /// Sets the specified response header to the specified value. /// /// - /// One of the enum values, represents - /// the response header to set. + /// + /// One of the enum values. + /// + /// + /// It specifies the response header to set. + /// /// /// - /// A that represents the value of the response header to set. + /// A that specifies the value of the response header + /// to set. /// /// /// @@ -1623,15 +1628,15 @@ public void Set (HttpRequestHeader header, string value) /// -or- /// /// - /// contains invalid characters. + /// contains an invalid character. /// /// /// - /// The length of is greater than 65,535 characters. + /// The length of is greater than 65,535 + /// characters. /// /// - /// The current instance doesn't allow - /// the response . + /// This instance does not allow the response header. /// public void Set (HttpResponseHeader header, string value) { From 10b6d66470db9c959e28932531bca77c9bed05e8 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 17 Apr 2020 19:38:07 +0900 Subject: [PATCH 2942/6294] [Modify] Remove it --- websocket-sharp/Net/WebHeaderCollection.cs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 11c51aa80..0e3f6d3e7 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -986,11 +986,6 @@ private void setWithoutCheckingName (string name, string value) #region Internal Methods - internal static string Convert (HttpRequestHeader header) - { - return convert (header.ToString ()); - } - internal static string Convert (HttpResponseHeader header) { return convert (header.ToString ()); From 9f2c637177196cef0fa133b08e4797f3dd568959 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 17 Apr 2020 19:39:35 +0900 Subject: [PATCH 2943/6294] [Modify] Remove it --- websocket-sharp/Net/WebHeaderCollection.cs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 0e3f6d3e7..0bc11fc29 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -986,11 +986,6 @@ private void setWithoutCheckingName (string name, string value) #region Internal Methods - internal static string Convert (HttpResponseHeader header) - { - return convert (header.ToString ()); - } - internal void InternalRemove (string name) { base.Remove (name); From dc5b4ddfd8856fb051e3ffe5e414a5cadac30d57 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 17 Apr 2020 19:41:19 +0900 Subject: [PATCH 2944/6294] [Modify] Remove it --- websocket-sharp/Net/WebHeaderCollection.cs | 9 --------- 1 file changed, 9 deletions(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 0bc11fc29..d7bf99669 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -885,15 +885,6 @@ private static string checkValue (string value) return value; } - private static string convert (string key) - { - HttpHeaderInfo headerInfo; - - return _headers.TryGetValue (key, out headerInfo) - ? headerInfo.Name - : String.Empty; - } - private void doWithCheckingState ( Action action, string name, string value, bool setState ) From 616b1461c15dc6e1c65db6a443b06e8bc05038fd Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 18 Apr 2020 21:42:57 +0900 Subject: [PATCH 2945/6294] [Modify] Add it --- websocket-sharp/Net/WebHeaderCollection.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index d7bf99669..b8d044e2d 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -955,6 +955,13 @@ private static string getHeaderName (string key) : null; } + private static bool isMultiValue (string name, bool response) + { + var headerInfo = getHeaderInfo (name); + + return headerInfo != null && headerInfo.IsMultiValue (response); + } + private static bool isRestricted (string name, bool response) { var headerInfo = getHeaderInfo (name); From 1459769d2fec66aa5e7a80a0d7314fd4bac57ba1 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 19 Apr 2020 21:58:27 +0900 Subject: [PATCH 2946/6294] [Modify] Polish it --- websocket-sharp/Net/WebHeaderCollection.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index b8d044e2d..e3cd5fa45 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -998,10 +998,14 @@ internal void InternalSet (string header, bool response) internal void InternalSet (string name, string value, bool response) { value = checkValue (value); - if (IsMultiValue (name, response)) + + if (IsMultiValue (name, response)) { base.Add (name, value); - else - base.Set (name, value); + + return; + } + + base.Set (name, value); } internal static bool IsMultiValue (string headerName, bool response) From 0123a9ac1babd3a82c0f25d30b62972ac4f0b9ca Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 20 Apr 2020 19:58:28 +0900 Subject: [PATCH 2947/6294] [Modify] Polish it --- websocket-sharp/Net/WebHeaderCollection.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index e3cd5fa45..fa73b1ca2 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1695,9 +1695,15 @@ public byte[] ToByteArray () public override string ToString () { var buff = new StringBuilder (); - Count.Times (i => buff.AppendFormat ("{0}: {1}\r\n", GetKey (i), Get (i))); - return buff.Append ("\r\n").ToString (); + var cnt = Count; + + for (var i = 0; i < cnt; i++) + buff.AppendFormat ("{0}: {1}\r\n", GetKey (i), Get (i)); + + buff.Append ("\r\n"); + + return buff.ToString (); } #endregion From 62d88813ea8377f8d5841ecce30ee4e80ea28ab5 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 21 Apr 2020 20:07:53 +0900 Subject: [PATCH 2948/6294] [Modify] Polish it --- websocket-sharp/Net/WebHeaderCollection.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index fa73b1ca2..dd46b4f1e 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1694,10 +1694,13 @@ public byte[] ToByteArray () /// public override string ToString () { - var buff = new StringBuilder (); - var cnt = Count; + if (cnt == 0) + return "\r\n"; + + var buff = new StringBuilder (); + for (var i = 0; i < cnt; i++) buff.AppendFormat ("{0}: {1}\r\n", GetKey (i), Get (i)); From 9cac1b0d10ff2a4b4e2ca70bbe54c0da66e8a293 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 22 Apr 2020 19:42:41 +0900 Subject: [PATCH 2949/6294] [Modify] Edit it --- websocket-sharp/Net/WebHeaderCollection.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index dd46b4f1e..da306f2d4 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1686,11 +1686,10 @@ public byte[] ToByteArray () } /// - /// Returns a that represents the current - /// . + /// Returns a string that represents the current instance. /// /// - /// A that represents the current . + /// A that represents all headers in the collection. /// public override string ToString () { From bdc32900438e54dba83357e4c11f3f96e7154afb Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 23 Apr 2020 21:22:25 +0900 Subject: [PATCH 2950/6294] [Modify] Edit it --- websocket-sharp/Net/WebHeaderCollection.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index da306f2d4..ed5276c6e 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1674,11 +1674,11 @@ public override void Set (string name, string value) } /// - /// Converts the current to an array of . + /// Converts the current instance to an array of byte. /// /// - /// An array of that receives the converted current - /// . + /// An array of converted from a string that represents + /// the current instance. /// public byte[] ToByteArray () { From 15aa9caf60de8edcd82ec3ec95e78f940010cafb Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 24 Apr 2020 19:37:19 +0900 Subject: [PATCH 2951/6294] [Modify] Polish it --- websocket-sharp/Net/WebHeaderCollection.cs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index ed5276c6e..02ae5aa7b 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1725,12 +1725,16 @@ public override string ToString () /// /// is . /// - [SecurityPermission ( - SecurityAction.LinkDemand, - Flags = SecurityPermissionFlag.SerializationFormatter, - SerializationFormatter = true)] + [ + SecurityPermission ( + SecurityAction.LinkDemand, + Flags = SecurityPermissionFlag.SerializationFormatter, + SerializationFormatter = true + ) + ] void ISerializable.GetObjectData ( - SerializationInfo serializationInfo, StreamingContext streamingContext) + SerializationInfo serializationInfo, StreamingContext streamingContext + ) { GetObjectData (serializationInfo, streamingContext); } From 8af5e31872326ca53faab79055632f6bc6ad5313 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 25 Apr 2020 22:23:10 +0900 Subject: [PATCH 2952/6294] [Modify] Edit it --- websocket-sharp/Net/WebHeaderCollection.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 02ae5aa7b..df3754654 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1713,14 +1713,15 @@ public override string ToString () #region Explicit Interface Implementations /// - /// Populates the specified with the data needed to serialize - /// the current . + /// Populates a instance with the data + /// needed to serialize this instance. /// /// - /// A that holds the serialized object data. + /// A to populate with the data. /// /// - /// A that specifies the destination for the serialization. + /// A that specifies the destination for + /// the serialization. /// /// /// is . From 9c9e0c84c6890d21f14911b5ea809601154a168d Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 26 Apr 2020 22:33:29 +0900 Subject: [PATCH 2953/6294] [Modify] Polish it --- websocket-sharp/Net/WebHeaderCollection.cs | 33 ++++++++++++++-------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index df3754654..5fe322cd0 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1019,18 +1019,29 @@ internal static bool IsMultiValue (string headerName, bool response) internal string ToStringMultiValue (bool response) { + var cnt = Count; + + if (cnt == 0) + return "\r\n"; + var buff = new StringBuilder (); - Count.Times ( - i => { - var key = GetKey (i); - if (IsMultiValue (key, response)) - foreach (var val in GetValues (i)) - buff.AppendFormat ("{0}: {1}\r\n", key, val); - else - buff.AppendFormat ("{0}: {1}\r\n", key, Get (i)); - }); - - return buff.Append ("\r\n").ToString (); + + for (var i = 0; i < cnt; i++) { + var name = GetKey (i); + + if (IsMultiValue (name, response)) { + foreach (var val in GetValues (i)) + buff.AppendFormat ("{0}: {1}\r\n", name, val); + + continue; + } + + buff.AppendFormat ("{0}: {1}\r\n", name, Get (i)); + } + + buff.Append ("\r\n"); + + return buff.ToString (); } #endregion From 5721c45838a9898d825ef828ef4463a9a993f266 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 27 Apr 2020 21:20:16 +0900 Subject: [PATCH 2954/6294] [Modify] Replace it --- websocket-sharp/Net/WebHeaderCollection.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 5fe322cd0..031a35f7d 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1029,7 +1029,7 @@ internal string ToStringMultiValue (bool response) for (var i = 0; i < cnt; i++) { var name = GetKey (i); - if (IsMultiValue (name, response)) { + if (isMultiValue (name, response)) { foreach (var val in GetValues (i)) buff.AppendFormat ("{0}: {1}\r\n", name, val); From 1aa98acc3ca625f56aa7b3fcc8c4157683c0b347 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 27 Apr 2020 21:22:22 +0900 Subject: [PATCH 2955/6294] [Modify] Replace it --- websocket-sharp/Net/WebHeaderCollection.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 031a35f7d..a60d874f4 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -999,7 +999,7 @@ internal void InternalSet (string name, string value, bool response) { value = checkValue (value); - if (IsMultiValue (name, response)) { + if (isMultiValue (name, response)) { base.Add (name, value); return; From d74fe553b96a4279ad00f0f27face27b3b51996e Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 28 Apr 2020 19:50:01 +0900 Subject: [PATCH 2956/6294] [Modify] Remove it --- websocket-sharp/Net/WebHeaderCollection.cs | 9 --------- 1 file changed, 9 deletions(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index a60d874f4..5809e6192 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1008,15 +1008,6 @@ internal void InternalSet (string name, string value, bool response) base.Set (name, value); } - internal static bool IsMultiValue (string headerName, bool response) - { - if (headerName == null || headerName.Length == 0) - return false; - - var info = getHeaderInfo (headerName); - return info != null && info.IsMultiValue (response); - } - internal string ToStringMultiValue (bool response) { var cnt = Count; From 0c746bfcfaa5d9502b4f7e7f39f6fc07b1c777c8 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 29 Apr 2020 19:41:34 +0900 Subject: [PATCH 2957/6294] [Modify] Polish it --- websocket-sharp/Net/WebHeaderCollection.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 5809e6192..671fba07e 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -785,8 +785,12 @@ private void addWithoutCheckingNameAndRestricted (string name, string value) private static int checkColonSeparated (string header) { var idx = header.IndexOf (':'); - if (idx == -1) - throw new ArgumentException ("No colon could be found.", "header"); + + if (idx == -1) { + var msg = "No colon could be found."; + + throw new ArgumentException (msg, "header"); + } return idx; } From 84082ee25a201aa0b9c8564d711e4b4e84930621 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 29 Apr 2020 19:49:53 +0900 Subject: [PATCH 2958/6294] [Modify] Polish it --- websocket-sharp/Net/WebHeaderCollection.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 671fba07e..3bb87b506 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1112,11 +1112,17 @@ protected void AddWithoutValidate (string headerName, string headerValue) /// public void Add (string header) { - if (header == null || header.Length == 0) + if (header == null) throw new ArgumentNullException ("header"); + if (header.Length == 0) + throw new ArgumentException ("An empty string.", "header"); + var pos = checkColonSeparated (header); - add (header.Substring (0, pos), header.Substring (pos + 1), false); + var name = header.Substring (0, pos); + var val = header.Substring (pos + 1); + + add (name, val, false); } /// From 3d4c241c29be72c24d94b7c05e66ac81de456124 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 30 Apr 2020 20:04:54 +0900 Subject: [PATCH 2959/6294] [Modify] Replace it --- websocket-sharp/Net/WebHeaderCollection.cs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 3bb87b506..8a6159ad0 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1118,9 +1118,16 @@ public void Add (string header) if (header.Length == 0) throw new ArgumentException ("An empty string.", "header"); - var pos = checkColonSeparated (header); - var name = header.Substring (0, pos); - var val = header.Substring (pos + 1); + var idx = header.IndexOf (':'); + + if (idx == -1) { + var msg = "No colon could be found."; + + throw new ArgumentException (msg, "header"); + } + + var name = header.Substring (0, idx); + var val = header.Substring (idx + 1); add (name, val, false); } From a22d5a9521615916e95e5f97cd298c99501b93f0 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 1 May 2020 20:26:44 +0900 Subject: [PATCH 2960/6294] [Modify] Edit it --- websocket-sharp/Net/WebHeaderCollection.cs | 43 +++++++++++++++++----- 1 file changed, 33 insertions(+), 10 deletions(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 8a6159ad0..b5996b035 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1076,19 +1076,28 @@ protected void AddWithoutValidate (string headerName, string headerValue) #region Public Methods /// - /// Adds the specified to the collection. + /// Adds the specified header to the collection. /// /// - /// A that represents the header with the name and value separated by - /// a colon (':'). + /// + /// A that specifies the header to add. + /// + /// + /// It has the name and value separated by a colon character (':'). + /// /// /// - /// is , empty, or the name part of - /// is empty. + /// is . /// /// /// - /// doesn't contain a colon. + /// is an empty string. + /// + /// + /// -or- + /// + /// + /// does not contain a colon character. /// /// /// -or- @@ -1100,15 +1109,29 @@ protected void AddWithoutValidate (string headerName, string headerValue) /// -or- /// /// - /// The name or value part of contains invalid characters. + /// The name part of is an empty string. + /// + /// + /// -or- + /// + /// + /// The name part of contains an invalid + /// character. + /// + /// + /// -or- + /// + /// + /// The value part of contains an invalid + /// character. /// /// /// - /// The length of the value part of is greater than 65,535 characters. + /// The length of the value part of is greater + /// than 65,535 characters. /// /// - /// The current instance doesn't allow - /// the . + /// This instance does not allow the header. /// public void Add (string header) { From 26e9edddf264d175bfcfa0f05cc4e25e9ae745a1 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 2 May 2020 22:20:03 +0900 Subject: [PATCH 2961/6294] [Modify] Polish it --- websocket-sharp/Net/WebHeaderCollection.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index b5996b035..c2680e6b6 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1144,7 +1144,7 @@ public void Add (string header) var idx = header.IndexOf (':'); if (idx == -1) { - var msg = "No colon could be found."; + var msg = "It does not contain a colon character."; throw new ArgumentException (msg, "header"); } From c97fd7d97a380e00c8b11c190b44a37e1e1a2702 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 3 May 2020 21:42:35 +0900 Subject: [PATCH 2962/6294] [Modify] Polish it --- websocket-sharp/Net/WebHeaderCollection.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index c2680e6b6..65b92ca24 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1138,8 +1138,11 @@ public void Add (string header) if (header == null) throw new ArgumentNullException ("header"); - if (header.Length == 0) - throw new ArgumentException ("An empty string.", "header"); + if (header.Length == 0) { + var msg = "An empty string."; + + throw new ArgumentException (msg, "header"); + } var idx = header.IndexOf (':'); From 1d2bc734629b1059a65300403cb34879aabc7a67 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 4 May 2020 20:41:43 +0900 Subject: [PATCH 2963/6294] [Modify] Edit it --- websocket-sharp/Net/WebHeaderCollection.cs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 65b92ca24..9d32ee777 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1079,12 +1079,8 @@ protected void AddWithoutValidate (string headerName, string headerValue) /// Adds the specified header to the collection. /// /// - /// - /// A that specifies the header to add. - /// - /// - /// It has the name and value separated by a colon character (':'). - /// + /// A that specifies the header to add, + /// with the name and value separated by a colon character (':'). /// /// /// is . From e3719401f3349c94ffba64a6d085246f1d898d72 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 5 May 2020 20:12:12 +0900 Subject: [PATCH 2964/6294] [Modify] Replace it --- websocket-sharp/Net/WebHeaderCollection.cs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 9d32ee777..15103c304 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -995,8 +995,18 @@ internal void InternalRemove (string name) internal void InternalSet (string header, bool response) { - var pos = checkColonSeparated (header); - InternalSet (header.Substring (0, pos), header.Substring (pos + 1), response); + var idx = header.IndexOf (':'); + + if (idx == -1) { + var msg = "It does not contain a colon character."; + + throw new ArgumentException (msg, "header"); + } + + var name = header.Substring (0, idx); + var val = header.Substring (idx + 1); + + InternalSet (name, val, response); } internal void InternalSet (string name, string value, bool response) From 833cd688e4e6f0c0bb3ca7615f1aabdf3e086072 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 6 May 2020 22:03:00 +0900 Subject: [PATCH 2965/6294] [Modify] Remove it --- websocket-sharp/Net/WebHeaderCollection.cs | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 15103c304..76269de06 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -782,19 +782,6 @@ private void addWithoutCheckingNameAndRestricted (string name, string value) base.Add (name, checkValue (value)); } - private static int checkColonSeparated (string header) - { - var idx = header.IndexOf (':'); - - if (idx == -1) { - var msg = "No colon could be found."; - - throw new ArgumentException (msg, "header"); - } - - return idx; - } - private static HttpHeaderType checkHeaderType (string name) { var info = getHeaderInfo (name); From 6a6a652528d6784e61dbcf4b54f0533c65026cab Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 7 May 2020 20:59:42 +0900 Subject: [PATCH 2966/6294] [Fix] Fix for no value --- websocket-sharp/Net/WebHeaderCollection.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 76269de06..4bf37324d 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -991,7 +991,9 @@ internal void InternalSet (string header, bool response) } var name = header.Substring (0, idx); - var val = header.Substring (idx + 1); + var val = idx < header.Length - 1 + ? header.Substring (idx + 1) + : String.Empty; InternalSet (name, val, response); } From 4172812ad42eec343d4b46b4d7524e52542a1407 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 8 May 2020 19:41:40 +0900 Subject: [PATCH 2967/6294] [Fix] Fix for no value lol --- websocket-sharp/Net/WebHeaderCollection.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 4bf37324d..484d157de 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1133,7 +1133,9 @@ public void Add (string header) if (header == null) throw new ArgumentNullException ("header"); - if (header.Length == 0) { + var len = header.Length; + + if (len == 0) { var msg = "An empty string."; throw new ArgumentException (msg, "header"); @@ -1148,7 +1150,9 @@ public void Add (string header) } var name = header.Substring (0, idx); - var val = header.Substring (idx + 1); + var val = idx < len - 1 + ? header.Substring (idx + 1) + : String.Empty; add (name, val, false); } From ba5697ded635618e7af413a89a60b183cf974798 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 9 May 2020 18:08:34 +0900 Subject: [PATCH 2968/6294] [Modify] Edit it --- websocket-sharp/Net/WebHeaderCollection.cs | 28 ++++++++++++++++------ 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 484d157de..efab13e47 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1047,23 +1047,37 @@ internal string ToStringMultiValue (bool response) /// the restricted header list. /// /// - /// A that represents the name of the header to add. + /// A that specifies the name of the header to add. /// /// - /// A that represents the value of the header to add. + /// A that specifies the value of the header to add. /// /// - /// is or empty. + /// is . /// /// - /// or contains invalid characters. + /// + /// is an empty string. + /// + /// + /// -or- + /// + /// + /// contains an invalid character. + /// + /// + /// -or- + /// + /// + /// contains an invalid character. + /// /// /// - /// The length of is greater than 65,535 characters. + /// The length of is greater than 65,535 + /// characters. /// /// - /// The current instance doesn't allow - /// the . + /// This instance does not allow the header. /// protected void AddWithoutValidate (string headerName, string headerValue) { From 0c97729695cb442671835d3d5871fdcbf39f60f5 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 10 May 2020 21:47:06 +0900 Subject: [PATCH 2969/6294] [Modify] Add it --- websocket-sharp/Net/WebHeaderCollection.cs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index efab13e47..52972eaa0 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -946,6 +946,22 @@ private static string getHeaderName (string key) : null; } + private static HttpHeaderType getHeaderType (string name) + { + var headerInfo = getHeaderInfo (name); + + if (headerInfo == null) + return HttpHeaderType.Unspecified; + + if (headerInfo.IsRequest && !headerInfo.IsResponse) + return HttpHeaderType.Request; + + if (!headerInfo.IsRequest && headerInfo.IsResponse) + return HttpHeaderType.Response; + + return HttpHeaderType.Unspecified; + } + private static bool isMultiValue (string name, bool response) { var headerInfo = getHeaderInfo (name); From 5f3a07dfa8079fc65814ad436d6365b300aba128 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 11 May 2020 21:07:14 +0900 Subject: [PATCH 2970/6294] [Modify] Polish it --- websocket-sharp/Net/WebHeaderCollection.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 52972eaa0..dbf8970a4 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -953,10 +953,14 @@ private static HttpHeaderType getHeaderType (string name) if (headerInfo == null) return HttpHeaderType.Unspecified; - if (headerInfo.IsRequest && !headerInfo.IsResponse) + if (headerInfo.IsRequest) { + if (headerInfo.IsResponse) + return HttpHeaderType.Unspecified; + return HttpHeaderType.Request; + } - if (!headerInfo.IsRequest && headerInfo.IsResponse) + if (headerInfo.IsResponse) return HttpHeaderType.Response; return HttpHeaderType.Unspecified; From 2a7f9bb57f486cf152b2d30693b95c231bd22a35 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 12 May 2020 20:46:45 +0900 Subject: [PATCH 2971/6294] [Modify] Polish it --- websocket-sharp/Net/WebHeaderCollection.cs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index dbf8970a4..2f031124e 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -954,16 +954,14 @@ private static HttpHeaderType getHeaderType (string name) return HttpHeaderType.Unspecified; if (headerInfo.IsRequest) { - if (headerInfo.IsResponse) - return HttpHeaderType.Unspecified; - - return HttpHeaderType.Request; + return !headerInfo.IsResponse + ? HttpHeaderType.Request + : HttpHeaderType.Unspecified; } - if (headerInfo.IsResponse) - return HttpHeaderType.Response; - - return HttpHeaderType.Unspecified; + return headerInfo.IsResponse + ? HttpHeaderType.Response + : HttpHeaderType.Unspecified; } private static bool isMultiValue (string name, bool response) From 357fd2ec82e3fe8c0b8b9b56bf8eae2446c52397 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 13 May 2020 19:35:14 +0900 Subject: [PATCH 2972/6294] [Modify] Replace it --- websocket-sharp/Net/WebHeaderCollection.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 2f031124e..b46423d93 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -880,7 +880,7 @@ private void doWithCheckingState ( Action action, string name, string value, bool setState ) { - var headerType = checkHeaderType (name); + var headerType = getHeaderType (name); if (headerType == HttpHeaderType.Response) { doWithCheckingState (action, name, value, true, setState); From 4cc01943125d83356eac3ea89207ca4b150a065e Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 13 May 2020 19:36:44 +0900 Subject: [PATCH 2973/6294] [Modify] Remove it --- websocket-sharp/Net/WebHeaderCollection.cs | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index b46423d93..4a9761578 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -782,18 +782,6 @@ private void addWithoutCheckingNameAndRestricted (string name, string value) base.Add (name, checkValue (value)); } - private static HttpHeaderType checkHeaderType (string name) - { - var info = getHeaderInfo (name); - return info == null - ? HttpHeaderType.Unspecified - : info.IsRequest && !info.IsResponse - ? HttpHeaderType.Request - : !info.IsRequest && info.IsResponse - ? HttpHeaderType.Response - : HttpHeaderType.Unspecified; - } - private static string checkName (string name) { if (name == null) From b58dc42dc106ad667a972e858cbc75b75cb18143 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 14 May 2020 19:37:05 +0900 Subject: [PATCH 2974/6294] [Modify] Polish it --- websocket-sharp/Net/WebHeaderCollection.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 4a9761578..9dfded93b 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1617,7 +1617,9 @@ public void Remove (HttpResponseHeader header) /// public override void Remove (string name) { - doWithCheckingState (removeWithoutCheckingName, checkName (name), null, false); + name = checkName (name); + + doWithCheckingState (removeWithoutCheckingName, name, null, false); } /// From 43c8b790d584b369f3cde13b7025262dbd78b061 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 15 May 2020 19:36:53 +0900 Subject: [PATCH 2975/6294] [Modify] Edit it --- websocket-sharp/Net/WebHeaderCollection.cs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 9dfded93b..2aed2f4bc 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1595,14 +1595,20 @@ public void Remove (HttpResponseHeader header) /// Removes the specified header from the collection. /// /// - /// A that represents the name of the header to remove. + /// A that specifies the name of the header to remove. /// /// - /// is or empty. + /// is . /// /// /// - /// contains invalid characters. + /// is an empty string. + /// + /// + /// -or- + /// + /// + /// contains an invalid character. /// /// /// -or- @@ -1612,8 +1618,7 @@ public void Remove (HttpResponseHeader header) /// /// /// - /// The current instance doesn't allow - /// the header . + /// This instance does not allow the header. /// public override void Remove (string name) { From c4e7a94383b87d06fbdee79ba8e69448d7e30a95 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 16 May 2020 21:27:48 +0900 Subject: [PATCH 2976/6294] [Modify] Edit it --- websocket-sharp/Net/WebHeaderCollection.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 2aed2f4bc..bc4f6f481 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1608,6 +1608,12 @@ public void Remove (HttpResponseHeader header) /// -or- /// /// + /// is a string of spaces. + /// + /// + /// -or- + /// + /// /// contains an invalid character. /// /// From 9871c906593b096b861b26d059d1637174a994a3 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 17 May 2020 18:12:51 +0900 Subject: [PATCH 2977/6294] [Modify] Add it --- websocket-sharp/Net/WebHeaderCollection.cs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index bc4f6f481..2ea8f7bee 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -782,6 +782,23 @@ private void addWithoutCheckingNameAndRestricted (string name, string value) base.Add (name, checkValue (value)); } + private void checkAllowed (string name) + { + if (_state == HttpHeaderType.Unspecified) + return; + + var headerType = getHeaderType (name); + + if (headerType == HttpHeaderType.Unspecified) + return; + + if (_state != headerType) { + var msg = "This collection does not allow the header."; + + throw new InvalidOperationException (msg); + } + } + private static string checkName (string name) { if (name == null) From 98f7f00b599324f46244b37b01a423770de2e679 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 18 May 2020 19:29:20 +0900 Subject: [PATCH 2978/6294] [Modify] Polish it --- websocket-sharp/Net/WebHeaderCollection.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 2ea8f7bee..91235216d 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -792,7 +792,7 @@ private void checkAllowed (string name) if (headerType == HttpHeaderType.Unspecified) return; - if (_state != headerType) { + if (headerType != _state) { var msg = "This collection does not allow the header."; throw new InvalidOperationException (msg); From 6d78c62023ab4bd81f09dcb05be9d1ffad9f52a6 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 18 May 2020 19:31:58 +0900 Subject: [PATCH 2979/6294] [Modify] Polish it --- websocket-sharp/Net/WebHeaderCollection.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 91235216d..54119988c 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -793,7 +793,7 @@ private void checkAllowed (string name) return; if (headerType != _state) { - var msg = "This collection does not allow the header."; + var msg = "This instance does not allow the header."; throw new InvalidOperationException (msg); } From 1d16b4364d462f95dd8ebdbb1ba7ab73f971d2a0 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 19 May 2020 19:39:53 +0900 Subject: [PATCH 2980/6294] [Modify] Add it --- websocket-sharp/Net/WebHeaderCollection.cs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 54119988c..3520c0f38 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -782,6 +782,22 @@ private void addWithoutCheckingNameAndRestricted (string name, string value) base.Add (name, checkValue (value)); } + private void checkAllowed (bool response) + { + if (_state == HttpHeaderType.Unspecified) + return; + + var headerType = response + ? HttpHeaderType.Response + : HttpHeaderType.Request; + + if (headerType != _state) { + var msg = "This instance does not allow the header."; + + throw new InvalidOperationException (msg); + } + } + private void checkAllowed (string name) { if (_state == HttpHeaderType.Unspecified) From 68036554dbb158b1dde1c55d1f2c0fab75e6dbbe Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 20 May 2020 19:45:20 +0900 Subject: [PATCH 2981/6294] [Modify] Add it --- websocket-sharp/Net/WebHeaderCollection.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 3520c0f38..716cd89e1 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -849,6 +849,18 @@ private void checkRestricted (string name) } } + private void checkRestricted (string name, bool response) + { + if (_internallyUsed) + return; + + if (isRestricted (name, response)) { + var msg = "The header is a restricted header."; + + throw new ArgumentException (msg); + } + } + private void checkState (bool response) { if (_state == HttpHeaderType.Unspecified) From f7283c0043e1e75204dc41a06f035bdd5af1de4d Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 21 May 2020 19:40:46 +0900 Subject: [PATCH 2982/6294] [Modify] Add a check if response or not --- websocket-sharp/Net/WebHeaderCollection.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 716cd89e1..71a5b7b88 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -842,7 +842,10 @@ private void checkRestricted (string name) if (_internallyUsed) return; - if (isRestricted (name, true)) { + var headerType = getHeaderType (name); + var res = headerType == HttpHeaderType.Response; + + if (isRestricted (name, res)) { var msg = "This header must be modified with the appropiate property."; throw new ArgumentException (msg); From f22bb89ff22f5ade6231da8e71b4d2641d1edad8 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 21 May 2020 19:43:10 +0900 Subject: [PATCH 2983/6294] [Modify] Polish it --- websocket-sharp/Net/WebHeaderCollection.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 71a5b7b88..2610490b8 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -846,7 +846,7 @@ private void checkRestricted (string name) var res = headerType == HttpHeaderType.Response; if (isRestricted (name, res)) { - var msg = "This header must be modified with the appropiate property."; + var msg = "The header is a restricted header."; throw new ArgumentException (msg); } From 81a2884cf97ade192c3bc90fc49e11e9b4003b7d Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 22 May 2020 19:38:35 +0900 Subject: [PATCH 2984/6294] [Modify] Replace it --- websocket-sharp/Net/WebHeaderCollection.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 2610490b8..6a21b23da 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1611,7 +1611,9 @@ public void Remove (HttpRequestHeader header) var key = header.ToString (); var name = getHeaderName (key); - doWithCheckingState (removeWithoutCheckingName, name, null, false, false); + checkRestricted (name, false); + checkAllowed (false); + base.Remove (name); } /// From f79f0c023b4b2bcb7daecd81ee9da579b084f555 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 22 May 2020 19:41:44 +0900 Subject: [PATCH 2985/6294] [Modify] Replace it --- websocket-sharp/Net/WebHeaderCollection.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 6a21b23da..89ae2ac62 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1638,7 +1638,9 @@ public void Remove (HttpResponseHeader header) var key = header.ToString (); var name = getHeaderName (key); - doWithCheckingState (removeWithoutCheckingName, name, null, true, false); + checkRestricted (name, true); + checkAllowed (true); + base.Remove (name); } /// From e4dd106af17dbf24a0772f9c86ff13845fef77be Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 23 May 2020 21:38:01 +0900 Subject: [PATCH 2986/6294] [Modify] Replace it --- websocket-sharp/Net/WebHeaderCollection.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 89ae2ac62..f869fe01a 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1682,7 +1682,9 @@ public override void Remove (string name) { name = checkName (name); - doWithCheckingState (removeWithoutCheckingName, name, null, false); + checkRestricted (name); + checkAllowed (name); + base.Remove (name); } /// From 587f1403226d495afa287a3f9314e45d01589d1b Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 24 May 2020 22:07:01 +0900 Subject: [PATCH 2987/6294] [Modify] Remove it --- websocket-sharp/Net/WebHeaderCollection.cs | 6 ------ 1 file changed, 6 deletions(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index f869fe01a..75d5fc7f1 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1014,12 +1014,6 @@ private static bool isRestricted (string name, bool response) return headerInfo != null && headerInfo.IsRestricted (response); } - private void removeWithoutCheckingName (string name, string unuse) - { - checkRestricted (name); - base.Remove (name); - } - private void setWithoutCheckingName (string name, string value) { doWithoutCheckingName (base.Set, name, value); From c3af4cc1f69bcad1e105fb86ac113d80fc617623 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 25 May 2020 21:17:20 +0900 Subject: [PATCH 2988/6294] [Modify] Replace it --- websocket-sharp/Net/WebHeaderCollection.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 75d5fc7f1..a1507f3e8 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1719,7 +1719,17 @@ public void Set (HttpRequestHeader header, string value) var key = header.ToString (); var name = getHeaderName (key); - doWithCheckingState (setWithoutCheckingName, name, value, false, true); + value = checkValue (value); + + checkRestricted (name, false); + checkAllowed (false); + + base.Set (name, value); + + if (_state != HttpHeaderType.Unspecified) + return; + + _state = HttpHeaderType.Request; } /// From c4a9a4fc0f398d9f34743b3235543d5d36e810c1 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 26 May 2020 19:33:57 +0900 Subject: [PATCH 2989/6294] [Modify] Replace it --- websocket-sharp/Net/WebHeaderCollection.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index a1507f3e8..86f7289e0 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1770,7 +1770,17 @@ public void Set (HttpResponseHeader header, string value) var key = header.ToString (); var name = getHeaderName (key); - doWithCheckingState (setWithoutCheckingName, name, value, true, true); + value = checkValue (value); + + checkRestricted (name, true); + checkAllowed (true); + + base.Set (name, value); + + if (_state != HttpHeaderType.Unspecified) + return; + + _state = HttpHeaderType.Response; } /// From 10f2d273bf588a8395b93853ebe4e62df69cfaa8 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 27 May 2020 19:54:00 +0900 Subject: [PATCH 2990/6294] [Modify] Replace it --- websocket-sharp/Net/WebHeaderCollection.cs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 86f7289e0..b24fcc3e0 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1815,7 +1815,23 @@ public void Set (HttpResponseHeader header, string value) /// public override void Set (string name, string value) { - doWithCheckingState (setWithoutCheckingName, checkName (name), value, true); + name = checkName (name); + value = checkValue (value); + + checkRestricted (name); + checkAllowed (name); + + base.Set (name, value); + + if (_state != HttpHeaderType.Unspecified) + return; + + var headerType = getHeaderType (name); + + if (headerType == HttpHeaderType.Unspecified) + return; + + _state = headerType; } /// From 76356dc6608a95312b6a549ecd14a0e3c9c9bbd2 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 27 May 2020 20:01:27 +0900 Subject: [PATCH 2991/6294] [Modify] Edit it --- websocket-sharp/Net/WebHeaderCollection.cs | 26 ++++++++++++++++------ 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index b24fcc3e0..e82493a8d 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1787,17 +1787,29 @@ public void Set (HttpResponseHeader header, string value) /// Sets the specified header to the specified value. /// /// - /// A that represents the name of the header to set. + /// A that specifies the name of the header to set. /// /// - /// A that represents the value of the header to set. + /// A that specifies the value of the header to set. /// /// - /// is or empty. + /// is . /// /// /// - /// or contains invalid characters. + /// is an empty string. + /// + /// + /// -or- + /// + /// + /// contains an invalid character. + /// + /// + /// -or- + /// + /// + /// contains an invalid character. /// /// /// -or- @@ -1807,11 +1819,11 @@ public void Set (HttpResponseHeader header, string value) /// /// /// - /// The length of is greater than 65,535 characters. + /// The length of is greater than 65,535 + /// characters. /// /// - /// The current instance doesn't allow - /// the header . + /// This instance does not allow the header. /// public override void Set (string name, string value) { From d2e06919ece9f16128c6ad11e6dea22103ec4beb Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 28 May 2020 20:01:06 +0900 Subject: [PATCH 2992/6294] [Modify] Add it --- websocket-sharp/Net/WebHeaderCollection.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index e82493a8d..702468621 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1014,6 +1014,19 @@ private static bool isRestricted (string name, bool response) return headerInfo != null && headerInfo.IsRestricted (response); } + private void set (string name, string value, HttpHeaderType headerType) + { + base.Set (name, value); + + if (_state != HttpHeaderType.Unspecified) + return; + + if (headerType == HttpHeaderType.Unspecified) + return; + + _state = headerType; + } + private void setWithoutCheckingName (string name, string value) { doWithoutCheckingName (base.Set, name, value); From cd092a4b5177110bc70ae3f59049b6674f8ac909 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 28 May 2020 20:05:30 +0900 Subject: [PATCH 2993/6294] [Modify] Replace it --- websocket-sharp/Net/WebHeaderCollection.cs | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 702468621..76c55eb31 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1846,17 +1846,9 @@ public override void Set (string name, string value) checkRestricted (name); checkAllowed (name); - base.Set (name, value); - - if (_state != HttpHeaderType.Unspecified) - return; - var headerType = getHeaderType (name); - if (headerType == HttpHeaderType.Unspecified) - return; - - _state = headerType; + set (name, value, headerType); } /// From fc5a7dea8d215fc7ca06e893644c1e6ef922cfac Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 29 May 2020 19:18:36 +0900 Subject: [PATCH 2994/6294] [Modify] Add it --- websocket-sharp/Net/WebHeaderCollection.cs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 76c55eb31..1e49911fc 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -798,6 +798,21 @@ private void checkAllowed (bool response) } } + private void checkAllowed (HttpHeaderType headerType) + { + if (_state == HttpHeaderType.Unspecified) + return; + + if (headerType == HttpHeaderType.Unspecified) + return; + + if (headerType != _state) { + var msg = "This instance does not allow the header."; + + throw new InvalidOperationException (msg); + } + } + private void checkAllowed (string name) { if (_state == HttpHeaderType.Unspecified) From e29cfd970a77721e3e522abe01129dd85b050b10 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 29 May 2020 19:24:24 +0900 Subject: [PATCH 2995/6294] [Modify] Add it --- websocket-sharp/Net/WebHeaderCollection.cs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 1e49911fc..8413b773b 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -879,6 +879,20 @@ private void checkRestricted (string name, bool response) } } + private void checkRestricted (string name, HttpHeaderType headerType) + { + if (_internallyUsed) + return; + + var res = headerType == HttpHeaderType.Response; + + if (isRestricted (name, res)) { + var msg = "The header is a restricted header."; + + throw new ArgumentException (msg); + } + } + private void checkState (bool response) { if (_state == HttpHeaderType.Unspecified) From 7272045445135f15895123e1b730ecbdc5c8fada Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 30 May 2020 21:40:42 +0900 Subject: [PATCH 2996/6294] [Modify] Replace it --- websocket-sharp/Net/WebHeaderCollection.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 8413b773b..1e5f49a65 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1872,11 +1872,10 @@ public override void Set (string name, string value) name = checkName (name); value = checkValue (value); - checkRestricted (name); - checkAllowed (name); - var headerType = getHeaderType (name); + checkRestricted (name, headerType); + checkAllowed (name); set (name, value, headerType); } From eb5e224c8b41656aa50bcc1a2458b3453b722a57 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 30 May 2020 21:41:44 +0900 Subject: [PATCH 2997/6294] [Modify] Replace it --- websocket-sharp/Net/WebHeaderCollection.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 1e5f49a65..66a69cfd4 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1875,7 +1875,7 @@ public override void Set (string name, string value) var headerType = getHeaderType (name); checkRestricted (name, headerType); - checkAllowed (name); + checkAllowed (headerType); set (name, value, headerType); } From 379d73def798dcf42b387e7392c0dc2068dff827 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 31 May 2020 16:24:37 +0900 Subject: [PATCH 2998/6294] [Modify] Replace it --- websocket-sharp/Net/WebHeaderCollection.cs | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 66a69cfd4..9201886a9 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1816,13 +1816,7 @@ public void Set (HttpResponseHeader header, string value) checkRestricted (name, true); checkAllowed (true); - - base.Set (name, value); - - if (_state != HttpHeaderType.Unspecified) - return; - - _state = HttpHeaderType.Response; + set (name, value, HttpHeaderType.Response); } /// From 963a874478b324286bae3198e6654f0030fb6272 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 31 May 2020 16:25:50 +0900 Subject: [PATCH 2999/6294] [Modify] Replace it --- websocket-sharp/Net/WebHeaderCollection.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 9201886a9..76c5f7946 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1814,7 +1814,7 @@ public void Set (HttpResponseHeader header, string value) value = checkValue (value); - checkRestricted (name, true); + checkRestricted (name, HttpHeaderType.Response); checkAllowed (true); set (name, value, HttpHeaderType.Response); } From a14638747bfb158c8432fcaf25b535aede3c9c4d Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 31 May 2020 16:26:42 +0900 Subject: [PATCH 3000/6294] [Modify] Replace it --- websocket-sharp/Net/WebHeaderCollection.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 76c5f7946..22af98e6b 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1815,7 +1815,7 @@ public void Set (HttpResponseHeader header, string value) value = checkValue (value); checkRestricted (name, HttpHeaderType.Response); - checkAllowed (true); + checkAllowed (HttpHeaderType.Response); set (name, value, HttpHeaderType.Response); } From ac9d5a49a7f67291ff38966148988efb2dd46bea Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 31 May 2020 16:28:10 +0900 Subject: [PATCH 3001/6294] [Modify] Polish it --- websocket-sharp/Net/WebHeaderCollection.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 22af98e6b..e5d1dde94 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1809,11 +1809,11 @@ public void Set (HttpRequestHeader header, string value) /// public void Set (HttpResponseHeader header, string value) { + value = checkValue (value); + var key = header.ToString (); var name = getHeaderName (key); - value = checkValue (value); - checkRestricted (name, HttpHeaderType.Response); checkAllowed (HttpHeaderType.Response); set (name, value, HttpHeaderType.Response); From f58a4e544092909ad7324518008796625cc53984 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 1 Jun 2020 19:38:42 +0900 Subject: [PATCH 3002/6294] [Modify] Replace it --- websocket-sharp/Net/WebHeaderCollection.cs | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index e5d1dde94..be22eb5e2 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1765,13 +1765,7 @@ public void Set (HttpRequestHeader header, string value) checkRestricted (name, false); checkAllowed (false); - - base.Set (name, value); - - if (_state != HttpHeaderType.Unspecified) - return; - - _state = HttpHeaderType.Request; + set (name, value, HttpHeaderType.Request); } /// From 909a8458a6bd8a40d3a2c111edf09afcb2e92ccd Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 1 Jun 2020 19:39:42 +0900 Subject: [PATCH 3003/6294] [Modify] Replace it --- websocket-sharp/Net/WebHeaderCollection.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index be22eb5e2..739817a82 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1763,7 +1763,7 @@ public void Set (HttpRequestHeader header, string value) value = checkValue (value); - checkRestricted (name, false); + checkRestricted (name, HttpHeaderType.Request); checkAllowed (false); set (name, value, HttpHeaderType.Request); } From e57c295bc2846606e7dc695adeb297afa79e6e5e Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 1 Jun 2020 19:40:44 +0900 Subject: [PATCH 3004/6294] [Modify] Replace it --- websocket-sharp/Net/WebHeaderCollection.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 739817a82..3cc33af42 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1764,7 +1764,7 @@ public void Set (HttpRequestHeader header, string value) value = checkValue (value); checkRestricted (name, HttpHeaderType.Request); - checkAllowed (false); + checkAllowed (HttpHeaderType.Request); set (name, value, HttpHeaderType.Request); } From 184bc1dd293cbe6fd3aad78587eefe56928f2fb1 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 1 Jun 2020 19:41:47 +0900 Subject: [PATCH 3005/6294] [Modify] Polish it --- websocket-sharp/Net/WebHeaderCollection.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 3cc33af42..891c0aecf 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1758,11 +1758,11 @@ public override void Remove (string name) /// public void Set (HttpRequestHeader header, string value) { + value = checkValue (value); + var key = header.ToString (); var name = getHeaderName (key); - value = checkValue (value); - checkRestricted (name, HttpHeaderType.Request); checkAllowed (HttpHeaderType.Request); set (name, value, HttpHeaderType.Request); From 49c5fafa9e605acc6ee483a5dd93161a8ad524d2 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 2 Jun 2020 15:43:54 +0900 Subject: [PATCH 3006/6294] [Modify] Remove it --- websocket-sharp/Net/WebHeaderCollection.cs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 891c0aecf..a71ed70d4 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1056,11 +1056,6 @@ private void set (string name, string value, HttpHeaderType headerType) _state = headerType; } - private void setWithoutCheckingName (string name, string value) - { - doWithoutCheckingName (base.Set, name, value); - } - #endregion #region Internal Methods From 95f7370c7cdcb63d7e96e2481a3d78b86dc2907e Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 3 Jun 2020 19:36:56 +0900 Subject: [PATCH 3007/6294] [Modify] Replace it --- websocket-sharp/Net/WebHeaderCollection.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index a71ed70d4..3d9aa3835 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1642,7 +1642,7 @@ public void Remove (HttpRequestHeader header) var key = header.ToString (); var name = getHeaderName (key); - checkRestricted (name, false); + checkRestricted (name, HttpHeaderType.Request); checkAllowed (false); base.Remove (name); } From 54a60cff00f4dd319fa8007d42b9c980032553c4 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 3 Jun 2020 19:37:47 +0900 Subject: [PATCH 3008/6294] [Modify] Replace it --- websocket-sharp/Net/WebHeaderCollection.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 3d9aa3835..bfbef7540 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1643,7 +1643,7 @@ public void Remove (HttpRequestHeader header) var name = getHeaderName (key); checkRestricted (name, HttpHeaderType.Request); - checkAllowed (false); + checkAllowed (HttpHeaderType.Request); base.Remove (name); } From ea979f3c64e6583fe64ef37f37a94a2fa20798c2 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 3 Jun 2020 19:40:10 +0900 Subject: [PATCH 3009/6294] [Modify] Replace it --- websocket-sharp/Net/WebHeaderCollection.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index bfbef7540..fdf4827be 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1669,7 +1669,7 @@ public void Remove (HttpResponseHeader header) var key = header.ToString (); var name = getHeaderName (key); - checkRestricted (name, true); + checkRestricted (name, HttpHeaderType.Response); checkAllowed (true); base.Remove (name); } From 5846c38b3deef98517a06ddac85834f9b63e3c3d Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 3 Jun 2020 19:41:11 +0900 Subject: [PATCH 3010/6294] [Modify] Replace it --- websocket-sharp/Net/WebHeaderCollection.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index fdf4827be..5b85fc7a7 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1670,7 +1670,7 @@ public void Remove (HttpResponseHeader header) var name = getHeaderName (key); checkRestricted (name, HttpHeaderType.Response); - checkAllowed (true); + checkAllowed (HttpHeaderType.Response); base.Remove (name); } From d6c696bf2936cf4debafebc453e3c1cef498a4cc Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 4 Jun 2020 19:40:15 +0900 Subject: [PATCH 3011/6294] [Modify] Replace it --- websocket-sharp/Net/WebHeaderCollection.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 5b85fc7a7..1d8a9f3c7 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1713,7 +1713,9 @@ public override void Remove (string name) { name = checkName (name); - checkRestricted (name); + var headerType = getHeaderType (name); + + checkRestricted (name, headerType); checkAllowed (name); base.Remove (name); } From f819f924757c10cb568881e350a45ce0062eedd5 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 4 Jun 2020 19:41:13 +0900 Subject: [PATCH 3012/6294] [Modify] Replace it --- websocket-sharp/Net/WebHeaderCollection.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 1d8a9f3c7..4a35ca03c 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1716,7 +1716,7 @@ public override void Remove (string name) var headerType = getHeaderType (name); checkRestricted (name, headerType); - checkAllowed (name); + checkAllowed (headerType); base.Remove (name); } From 115858e5f9f430ca42854cd7799f9b978f00ccad Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 5 Jun 2020 19:35:39 +0900 Subject: [PATCH 3013/6294] [Modify] Remove it --- websocket-sharp/Net/WebHeaderCollection.cs | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 4a35ca03c..e68dd631f 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -782,22 +782,6 @@ private void addWithoutCheckingNameAndRestricted (string name, string value) base.Add (name, checkValue (value)); } - private void checkAllowed (bool response) - { - if (_state == HttpHeaderType.Unspecified) - return; - - var headerType = response - ? HttpHeaderType.Response - : HttpHeaderType.Request; - - if (headerType != _state) { - var msg = "This instance does not allow the header."; - - throw new InvalidOperationException (msg); - } - } - private void checkAllowed (HttpHeaderType headerType) { if (_state == HttpHeaderType.Unspecified) From ab8ccef958241424ef8e3ed82592bd0b189c2c93 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 5 Jun 2020 19:37:24 +0900 Subject: [PATCH 3014/6294] [Modify] Remove it --- websocket-sharp/Net/WebHeaderCollection.cs | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index e68dd631f..d290422b4 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -797,23 +797,6 @@ private void checkAllowed (HttpHeaderType headerType) } } - private void checkAllowed (string name) - { - if (_state == HttpHeaderType.Unspecified) - return; - - var headerType = getHeaderType (name); - - if (headerType == HttpHeaderType.Unspecified) - return; - - if (headerType != _state) { - var msg = "This instance does not allow the header."; - - throw new InvalidOperationException (msg); - } - } - private static string checkName (string name) { if (name == null) From 6287ab16944384aa92d0005f453c0cdec7100344 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 6 Jun 2020 21:13:44 +0900 Subject: [PATCH 3015/6294] [Modify] Add it --- websocket-sharp/Net/WebHeaderCollection.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index d290422b4..8104c99bd 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -772,6 +772,19 @@ private void add (string name, string value, bool ignoreRestricted) doWithCheckingState (act, checkName (name), value, true); } + private void add (string name, string value, HttpHeaderType headerType) + { + base.Add (name, value); + + if (_state != HttpHeaderType.Unspecified) + return; + + if (headerType == HttpHeaderType.Unspecified) + return; + + _state = headerType; + } + private void addWithoutCheckingName (string name, string value) { doWithoutCheckingName (base.Add, name, value); From 72d3896b9fc8eb08295a9f3015210c8723cab8aa Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 7 Jun 2020 20:52:39 +0900 Subject: [PATCH 3016/6294] [Modify] Replace it --- websocket-sharp/Net/WebHeaderCollection.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 8104c99bd..2e7863b7b 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1146,7 +1146,13 @@ internal string ToStringMultiValue (bool response) /// protected void AddWithoutValidate (string headerName, string headerValue) { - add (headerName, headerValue, true); + headerName = checkName (headerName); + headerValue = checkValue (headerValue); + + var headerType = getHeaderType (headerName); + + checkAllowed (headerType); + add (headerName, headerValue, headerType); } #endregion From d42c7c711cb0204c076e55c7f15c0a455831aacb Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 8 Jun 2020 20:09:40 +0900 Subject: [PATCH 3017/6294] [Modify] Replace it --- websocket-sharp/Net/WebHeaderCollection.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 2e7863b7b..f86c474fc 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1239,7 +1239,14 @@ public void Add (string header) ? header.Substring (idx + 1) : String.Empty; - add (name, val, false); + name = checkName (name); + val = checkValue (val); + + var headerType = getHeaderType (name); + + checkRestricted (name, headerType); + checkAllowed (headerType); + add (name, val, headerType); } /// From 42413085100043e1d97a80bd9cb36dece3669e8a Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 9 Jun 2020 19:47:29 +0900 Subject: [PATCH 3018/6294] [Modify] Replace it --- websocket-sharp/Net/WebHeaderCollection.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index f86c474fc..5cf29296e 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1284,10 +1284,14 @@ public void Add (string header) /// public void Add (HttpRequestHeader header, string value) { + value = checkValue (value); + var key = header.ToString (); var name = getHeaderName (key); - doWithCheckingState (addWithoutCheckingName, name, value, false, true); + checkRestricted (name, HttpHeaderType.Request); + checkAllowed (HttpHeaderType.Request); + add (name, value, HttpHeaderType.Request); } /// From 1788f878b88d8467053db5b0a4a7f2a7a4635d36 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 9 Jun 2020 19:51:16 +0900 Subject: [PATCH 3019/6294] [Modify] Replace it --- websocket-sharp/Net/WebHeaderCollection.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 5cf29296e..e573c0da1 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1329,10 +1329,14 @@ public void Add (HttpRequestHeader header, string value) /// public void Add (HttpResponseHeader header, string value) { + value = checkValue (value); + var key = header.ToString (); var name = getHeaderName (key); - doWithCheckingState (addWithoutCheckingName, name, value, true, true); + checkRestricted (name, HttpHeaderType.Response); + checkAllowed (HttpHeaderType.Response); + add (name, value, HttpHeaderType.Response); } /// From dd8340b134d76b8a79d12db80a89959898013a92 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 10 Jun 2020 19:38:27 +0900 Subject: [PATCH 3020/6294] [Modify] Replace it --- websocket-sharp/Net/WebHeaderCollection.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index e573c0da1..fddebf7f1 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1372,7 +1372,14 @@ public void Add (HttpResponseHeader header, string value) /// public override void Add (string name, string value) { - add (name, value, false); + name = checkName (name); + value = checkValue (value); + + var headerType = getHeaderType (name); + + checkRestricted (name, headerType); + checkAllowed (headerType); + add (name, value, headerType); } /// From 82f146386d86d0d2c8d374c8add2a383ce70b4a6 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 11 Jun 2020 20:01:11 +0900 Subject: [PATCH 3021/6294] [Modify] Edit it --- websocket-sharp/Net/WebHeaderCollection.cs | 29 +++++++++++++++------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index fddebf7f1..3e6e7d4bf 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1340,21 +1340,32 @@ public void Add (HttpResponseHeader header, string value) } /// - /// Adds a header with the specified and - /// to the collection. + /// Adds a header with the specified name and value to the collection. /// /// - /// A that represents the name of the header to add. + /// A that specifies the name of the header to add. /// /// - /// A that represents the value of the header to add. + /// A that specifies the value of the header to add. /// /// - /// is or empty. + /// is . /// /// /// - /// or contains invalid characters. + /// is an empty string. + /// + /// + /// -or- + /// + /// + /// contains an invalid character. + /// + /// + /// -or- + /// + /// + /// contains an invalid character. /// /// /// -or- @@ -1364,11 +1375,11 @@ public void Add (HttpResponseHeader header, string value) /// /// /// - /// The length of is greater than 65,535 characters. + /// The length of is greater than 65,535 + /// characters. /// /// - /// The current instance doesn't allow - /// the header . + /// This instance does not allow the header. /// public override void Add (string name, string value) { From bcd96cacc916d7c70fde551148b3b9e583f5e237 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 12 Jun 2020 19:34:02 +0900 Subject: [PATCH 3022/6294] [Modify] Remove it --- websocket-sharp/Net/WebHeaderCollection.cs | 9 --------- 1 file changed, 9 deletions(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 3e6e7d4bf..dc172cbce 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -763,15 +763,6 @@ public override NameObjectCollectionBase.KeysCollection Keys { #region Private Methods - private void add (string name, string value, bool ignoreRestricted) - { - var act = ignoreRestricted - ? (Action ) addWithoutCheckingNameAndRestricted - : addWithoutCheckingName; - - doWithCheckingState (act, checkName (name), value, true); - } - private void add (string name, string value, HttpHeaderType headerType) { base.Add (name, value); From eeb8f0aeb7a49db885b559d3f42ac2596f11076e Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 12 Jun 2020 19:35:19 +0900 Subject: [PATCH 3023/6294] [Modify] Remove it --- websocket-sharp/Net/WebHeaderCollection.cs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index dc172cbce..41bde8502 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -776,11 +776,6 @@ private void add (string name, string value, HttpHeaderType headerType) _state = headerType; } - private void addWithoutCheckingName (string name, string value) - { - doWithoutCheckingName (base.Add, name, value); - } - private void addWithoutCheckingNameAndRestricted (string name, string value) { base.Add (name, checkValue (value)); From 890c351c0fc07db399a765065cfce3123b5fc1f7 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 12 Jun 2020 19:36:18 +0900 Subject: [PATCH 3024/6294] [Modify] Remove it --- websocket-sharp/Net/WebHeaderCollection.cs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 41bde8502..cf78c44b7 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -776,11 +776,6 @@ private void add (string name, string value, HttpHeaderType headerType) _state = headerType; } - private void addWithoutCheckingNameAndRestricted (string name, string value) - { - base.Add (name, checkValue (value)); - } - private void checkAllowed (HttpHeaderType headerType) { if (_state == HttpHeaderType.Unspecified) From 9e129a9f9e8101f5a2cf777ec5c432c1badfbad7 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 13 Jun 2020 17:56:41 +0900 Subject: [PATCH 3025/6294] [Modify] Remove it --- websocket-sharp/Net/WebHeaderCollection.cs | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index cf78c44b7..4b9cc2d6c 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -902,27 +902,6 @@ private static string checkValue (string value) return value; } - private void doWithCheckingState ( - Action action, string name, string value, bool setState - ) - { - var headerType = getHeaderType (name); - - if (headerType == HttpHeaderType.Response) { - doWithCheckingState (action, name, value, true, setState); - - return; - } - - if (headerType == HttpHeaderType.Request) { - doWithCheckingState (action, name, value, false, setState); - - return; - } - - action (name, value); - } - private void doWithCheckingState ( Action action, string name, From 8862928af5d00b4421e23eacfa44c6ba6d4028c9 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 13 Jun 2020 17:57:38 +0900 Subject: [PATCH 3026/6294] [Modify] Remove it --- websocket-sharp/Net/WebHeaderCollection.cs | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 4b9cc2d6c..bd472e6c8 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -902,25 +902,6 @@ private static string checkValue (string value) return value; } - private void doWithCheckingState ( - Action action, - string name, - string value, - bool response, - bool setState - ) - { - checkState (response); - action (name, value); - - setState = setState && _state == HttpHeaderType.Unspecified; - - if (!setState) - return; - - _state = response ? HttpHeaderType.Response : HttpHeaderType.Request; - } - private void doWithoutCheckingName ( Action action, string name, string value ) From d924ed53ec81ea1891efaf1611d7559f65c3143b Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 13 Jun 2020 17:59:21 +0900 Subject: [PATCH 3027/6294] [Modify] Remove it --- websocket-sharp/Net/WebHeaderCollection.cs | 9 --------- 1 file changed, 9 deletions(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index bd472e6c8..5af8fd5ae 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -902,15 +902,6 @@ private static string checkValue (string value) return value; } - private void doWithoutCheckingName ( - Action action, string name, string value - ) - { - checkRestricted (name); - value = checkValue (value); - action (name, value); - } - private static HttpHeaderInfo getHeaderInfo (string name) { var comparison = StringComparison.InvariantCultureIgnoreCase; From 7cbfe48dcade51cd0a8121a610ed4a1fa7a0d0a3 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 14 Jun 2020 15:45:37 +0900 Subject: [PATCH 3028/6294] [Modify] Remove it --- websocket-sharp/Net/WebHeaderCollection.cs | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 5af8fd5ae..f51e9d5fd 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -813,21 +813,6 @@ private static string checkName (string name) return name; } - private void checkRestricted (string name) - { - if (_internallyUsed) - return; - - var headerType = getHeaderType (name); - var res = headerType == HttpHeaderType.Response; - - if (isRestricted (name, res)) { - var msg = "The header is a restricted header."; - - throw new ArgumentException (msg); - } - } - private void checkRestricted (string name, bool response) { if (_internallyUsed) From 8c600dc49f97f4ccedb591aba50bfbf904b45af9 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 14 Jun 2020 15:47:05 +0900 Subject: [PATCH 3029/6294] [Modify] Remove it --- websocket-sharp/Net/WebHeaderCollection.cs | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index f51e9d5fd..40ad226ce 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -813,18 +813,6 @@ private static string checkName (string name) return name; } - private void checkRestricted (string name, bool response) - { - if (_internallyUsed) - return; - - if (isRestricted (name, response)) { - var msg = "The header is a restricted header."; - - throw new ArgumentException (msg); - } - } - private void checkRestricted (string name, HttpHeaderType headerType) { if (_internallyUsed) From 4ad02488aeeda23e9d446e84098f7178b949c310 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 14 Jun 2020 15:48:30 +0900 Subject: [PATCH 3030/6294] [Modify] Remove it --- websocket-sharp/Net/WebHeaderCollection.cs | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 40ad226ce..3f78517f8 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -827,27 +827,6 @@ private void checkRestricted (string name, HttpHeaderType headerType) } } - private void checkState (bool response) - { - if (_state == HttpHeaderType.Unspecified) - return; - - if (response) { - if (_state == HttpHeaderType.Response) - return; - - var msg = "This collection is already in use for the request headers."; - - throw new InvalidOperationException (msg); - } - - if (_state == HttpHeaderType.Response) { - var msg = "This collection is already in use for the response headers."; - - throw new InvalidOperationException (msg); - } - } - private static string checkValue (string value) { if (value == null) From 5ed134d740e908f7fd1d514c80793b4a227e01a9 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 15 Jun 2020 19:41:24 +0900 Subject: [PATCH 3031/6294] [Modify] Polish it --- websocket-sharp/Net/WebHeaderCollection.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 3f78517f8..a1f506c4a 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -801,8 +801,11 @@ private static string checkName (string name) name = name.Trim (); - if (name.Length == 0) - throw new ArgumentException ("A string of spaces.", "name"); + if (name.Length == 0) { + var msg = "The name is a string of spaces."; + + throw new ArgumentException (msg, "name"); + } if (!name.IsToken ()) { var msg = "It contains an invalid character."; From 2079d70e8888b3fba10e9b800811c4ac1ceccd47 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 15 Jun 2020 19:42:36 +0900 Subject: [PATCH 3032/6294] [Modify] Polish it --- websocket-sharp/Net/WebHeaderCollection.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index a1f506c4a..7e26da6c9 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -808,7 +808,7 @@ private static string checkName (string name) } if (!name.IsToken ()) { - var msg = "It contains an invalid character."; + var msg = "The name contains an invalid character."; throw new ArgumentException (msg, "name"); } From 405e409d903992a248a89fd1b93973eae1967b6a Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 16 Jun 2020 19:39:31 +0900 Subject: [PATCH 3033/6294] [Modify] Polish it --- websocket-sharp/Net/WebHeaderCollection.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 7e26da6c9..d4c5266b4 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -796,8 +796,11 @@ private static string checkName (string name) if (name == null) throw new ArgumentNullException ("name"); - if (name.Length == 0) - throw new ArgumentException ("An empty string.", "name"); + if (name.Length == 0) { + var msg = "The name is an empty string."; + + throw new ArgumentException (msg, "name"); + } name = name.Trim (); From d6963e2bfdd41395871bfd544b1598413e125e47 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 16 Jun 2020 19:42:04 +0900 Subject: [PATCH 3034/6294] [Modify] Polish it --- websocket-sharp/Net/WebHeaderCollection.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index d4c5266b4..cb5cf851d 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -793,8 +793,11 @@ private void checkAllowed (HttpHeaderType headerType) private static string checkName (string name) { - if (name == null) - throw new ArgumentNullException ("name"); + if (name == null) { + var msg = "The name is null."; + + throw new ArgumentNullException ("name", msg); + } if (name.Length == 0) { var msg = "The name is an empty string."; From 50e2a24848da89a2c315d6100e2822d7f8b00184 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 17 Jun 2020 19:36:52 +0900 Subject: [PATCH 3035/6294] [Modify] Polish it --- websocket-sharp/Net/WebHeaderCollection.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index cb5cf851d..8062a3fb2 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -849,7 +849,7 @@ private static string checkValue (string value) return value; if (len > 65535) { - var msg = "The length is greater than 65,535 characters."; + var msg = "The length of the value is greater than 65,535 characters."; throw new ArgumentOutOfRangeException ("value", msg); } From 6e5f23ffe845e8f02e17e39b483ab7f64fbcf3ea Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 17 Jun 2020 19:37:51 +0900 Subject: [PATCH 3036/6294] [Modify] Polish it --- websocket-sharp/Net/WebHeaderCollection.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 8062a3fb2..1fb60dc7a 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -855,7 +855,7 @@ private static string checkValue (string value) } if (!value.IsText ()) { - var msg = "It contains an invalid character."; + var msg = "The value contains an invalid character."; throw new ArgumentException (msg, "value"); } From 4f8143b4f293f65e249240b6b83b98c9f39b6a4e Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 18 Jun 2020 19:43:30 +0900 Subject: [PATCH 3037/6294] [Modify] Edit it --- websocket-sharp/Net/WebHeaderCollection.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 1fb60dc7a..9a12ab972 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1021,6 +1021,12 @@ internal string ToStringMultiValue (bool response) /// -or- /// /// + /// is a string of spaces. + /// + /// + /// -or- + /// + /// /// contains an invalid character. /// /// From 107d9cc2239eb8428c589d180084cb7fad0ea570 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 19 Jun 2020 19:41:00 +0900 Subject: [PATCH 3038/6294] [Modify] Add it --- websocket-sharp/Net/WebHeaderCollection.cs | 31 ++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 9a12ab972..95dbbe533 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -822,6 +822,37 @@ private static string checkName (string name) return name; } + private static string checkName (string name, string paramName) + { + if (name == null) { + var msg = "The name is null."; + + throw new ArgumentNullException (paramName, msg); + } + + if (name.Length == 0) { + var msg = "The name is an empty string."; + + throw new ArgumentException (msg, paramName); + } + + name = name.Trim (); + + if (name.Length == 0) { + var msg = "The name is a string of spaces."; + + throw new ArgumentException (msg, paramName); + } + + if (!name.IsToken ()) { + var msg = "The name contains an invalid character."; + + throw new ArgumentException (msg, paramName); + } + + return name; + } + private void checkRestricted (string name, HttpHeaderType headerType) { if (_internallyUsed) From bab0ef840fd90e8450f60f865bfabac9382ab3fe Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 20 Jun 2020 20:38:01 +0900 Subject: [PATCH 3039/6294] [Modify] Replace it --- websocket-sharp/Net/WebHeaderCollection.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 95dbbe533..02ecee6a0 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1076,7 +1076,7 @@ internal string ToStringMultiValue (bool response) /// protected void AddWithoutValidate (string headerName, string headerValue) { - headerName = checkName (headerName); + headerName = checkName (headerName, "headerName"); headerValue = checkValue (headerValue); var headerType = getHeaderType (headerName); From fa882926cdad03e401724acd18f201499013b4f4 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 21 Jun 2020 17:44:22 +0900 Subject: [PATCH 3040/6294] [Modify] Add it --- websocket-sharp/Net/WebHeaderCollection.cs | 27 ++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 02ecee6a0..daa29cc68 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -894,6 +894,33 @@ private static string checkValue (string value) return value; } + private static string checkValue (string value, string paramName) + { + if (value == null) + return String.Empty; + + value = value.Trim (); + + var len = value.Length; + + if (len == 0) + return value; + + if (len > 65535) { + var msg = "The length of the value is greater than 65,535 characters."; + + throw new ArgumentOutOfRangeException (paramName, msg); + } + + if (!value.IsText ()) { + var msg = "The value contains an invalid character."; + + throw new ArgumentException (msg, paramName); + } + + return value; + } + private static HttpHeaderInfo getHeaderInfo (string name) { var comparison = StringComparison.InvariantCultureIgnoreCase; From 77dcaa1cc0a4aaa31d1e3b588e5877d4cb466db9 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 22 Jun 2020 19:41:29 +0900 Subject: [PATCH 3041/6294] [Modify] Replace it --- websocket-sharp/Net/WebHeaderCollection.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index daa29cc68..02a690c6f 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1104,7 +1104,7 @@ internal string ToStringMultiValue (bool response) protected void AddWithoutValidate (string headerName, string headerValue) { headerName = checkName (headerName, "headerName"); - headerValue = checkValue (headerValue); + headerValue = checkValue (headerValue, "headerValue"); var headerType = getHeaderType (headerName); From e1735637bc68634bce4fb07e9e69f323e61a1063 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 23 Jun 2020 20:05:03 +0900 Subject: [PATCH 3042/6294] [Modify] Replace it --- websocket-sharp/Net/WebHeaderCollection.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 02a690c6f..67e31fd2c 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1196,7 +1196,7 @@ public void Add (string header) ? header.Substring (idx + 1) : String.Empty; - name = checkName (name); + name = checkName (name, "header"); val = checkValue (val); var headerType = getHeaderType (name); From f1d7440dd931f986a0b420da489de54fdc117da2 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 23 Jun 2020 20:06:00 +0900 Subject: [PATCH 3043/6294] [Modify] Replace it --- websocket-sharp/Net/WebHeaderCollection.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 67e31fd2c..501d5d379 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1197,7 +1197,7 @@ public void Add (string header) : String.Empty; name = checkName (name, "header"); - val = checkValue (val); + val = checkValue (val, "header"); var headerType = getHeaderType (name); From d06641234c139b85d8b26bb4d432746d935d20ea Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 24 Jun 2020 20:50:25 +0900 Subject: [PATCH 3044/6294] [Modify] Edit it --- websocket-sharp/Net/WebHeaderCollection.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 501d5d379..9edc62208 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1152,6 +1152,12 @@ protected void AddWithoutValidate (string headerName, string headerValue) /// -or- /// /// + /// The name part of is a string of spaces. + /// + /// + /// -or- + /// + /// /// The name part of contains an invalid /// character. /// From 1019abd92788de10c14d2d30433928bbc7a19905 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 24 Jun 2020 20:52:51 +0900 Subject: [PATCH 3045/6294] [Modify] Edit it --- websocket-sharp/Net/WebHeaderCollection.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 9edc62208..f525e2e9c 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1140,12 +1140,6 @@ protected void AddWithoutValidate (string headerName, string headerValue) /// -or- /// /// - /// is a restricted header. - /// - /// - /// -or- - /// - /// /// The name part of is an empty string. /// /// @@ -1168,6 +1162,12 @@ protected void AddWithoutValidate (string headerName, string headerValue) /// The value part of contains an invalid /// character. /// + /// + /// -or- + /// + /// + /// is a restricted header. + /// /// /// /// The length of the value part of is greater From 6dd2d6f2e0f01e33f613475e6ff4b54da6a26217 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 25 Jun 2020 19:38:49 +0900 Subject: [PATCH 3046/6294] [Modify] Replace it --- websocket-sharp/Net/WebHeaderCollection.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index f525e2e9c..976a1bd9b 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1247,7 +1247,7 @@ public void Add (string header) /// public void Add (HttpRequestHeader header, string value) { - value = checkValue (value); + value = checkValue (value, "value"); var key = header.ToString (); var name = getHeaderName (key); From ce79c75fbf0fa1f149397be61f9ccd0a55228ae6 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 25 Jun 2020 19:41:30 +0900 Subject: [PATCH 3047/6294] [Modify] Edit it --- websocket-sharp/Net/WebHeaderCollection.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 976a1bd9b..62993a579 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1229,13 +1229,13 @@ public void Add (string header) /// /// /// - /// is a restricted header. + /// contains an invalid character. /// /// /// -or- /// /// - /// contains an invalid character. + /// is a restricted header. /// /// /// From 29c51c42e03ae3996dd8d93d38f7f9cc586eb941 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 25 Jun 2020 19:43:02 +0900 Subject: [PATCH 3048/6294] [Modify] Replace it --- websocket-sharp/Net/WebHeaderCollection.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 62993a579..f15eed8c4 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1292,7 +1292,7 @@ public void Add (HttpRequestHeader header, string value) /// public void Add (HttpResponseHeader header, string value) { - value = checkValue (value); + value = checkValue (value, "value"); var key = header.ToString (); var name = getHeaderName (key); From 74f67d3f832bf9679556569214330c630aa3752d Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 25 Jun 2020 19:44:40 +0900 Subject: [PATCH 3049/6294] [Modify] Edit it --- websocket-sharp/Net/WebHeaderCollection.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index f15eed8c4..71c526239 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1274,13 +1274,13 @@ public void Add (HttpRequestHeader header, string value) /// /// /// - /// is a restricted header. + /// contains an invalid character. /// /// /// -or- /// /// - /// contains an invalid character. + /// is a restricted header. /// /// /// From bc982ca90fb61c8a922b3417dac0d9ec5cfd1200 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 26 Jun 2020 19:37:20 +0900 Subject: [PATCH 3050/6294] [Modify] Replace it --- websocket-sharp/Net/WebHeaderCollection.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 71c526239..a41e7c6f5 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1346,7 +1346,7 @@ public void Add (HttpResponseHeader header, string value) /// public override void Add (string name, string value) { - name = checkName (name); + name = checkName (name, "name"); value = checkValue (value); var headerType = getHeaderType (name); From 8360e850f0c9f95d319f21e26fb92c733a30f3d5 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 26 Jun 2020 19:38:04 +0900 Subject: [PATCH 3051/6294] [Modify] Replace it --- websocket-sharp/Net/WebHeaderCollection.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index a41e7c6f5..4a7e518bc 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1347,7 +1347,7 @@ public void Add (HttpResponseHeader header, string value) public override void Add (string name, string value) { name = checkName (name, "name"); - value = checkValue (value); + value = checkValue (value, "value"); var headerType = getHeaderType (name); From 4341afc0e0c90fd923d905a217eecf0c69eed009 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 26 Jun 2020 19:41:18 +0900 Subject: [PATCH 3052/6294] [Modify] Edit it --- websocket-sharp/Net/WebHeaderCollection.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 4a7e518bc..78f1f2cda 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1322,6 +1322,12 @@ public void Add (HttpResponseHeader header, string value) /// -or- /// /// + /// is a string of spaces. + /// + /// + /// -or- + /// + /// /// contains an invalid character. /// /// From ce50e2560e2aa9b106454208fbc76e3a27a2a363 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 27 Jun 2020 21:56:17 +0900 Subject: [PATCH 3053/6294] [Modify] Edit it --- websocket-sharp/Net/WebHeaderCollection.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 78f1f2cda..0625cdf1f 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1372,16 +1372,18 @@ public override void Clear () } /// - /// Get the value of the header at the specified in the collection. + /// Get the value of the header at the specified index in the collection. /// /// /// A that receives the value of the header. /// /// - /// An that represents the zero-based index of the header to find. + /// An that specifies the zero-based index of the header + /// to find. /// /// - /// is out of allowable range of indexes for the collection. + /// is out of allowable range of indexes for + /// the collection. /// public override string Get (int index) { From 2fc3689252675208044fea120376b9d4e03ce2d0 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 28 Jun 2020 21:40:20 +0900 Subject: [PATCH 3054/6294] [Modify] Edit it --- websocket-sharp/Net/WebHeaderCollection.cs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 0625cdf1f..3989580ff 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1391,14 +1391,18 @@ public override string Get (int index) } /// - /// Get the value of the header with the specified in the collection. + /// Get the value of the header with the specified name in the collection. /// /// - /// A that receives the value of the header if found; - /// otherwise, . + /// + /// A that receives the value of the header. + /// + /// + /// if not found. + /// /// /// - /// A that represents the name of the header to find. + /// A that specifies the name of the header to find. /// public override string Get (string name) { From a4f64b2f1d3e7578a6f55d1a9f9f7ac2ec14ac2e Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 28 Jun 2020 21:43:19 +0900 Subject: [PATCH 3055/6294] [Modify] Edit it --- websocket-sharp/Net/WebHeaderCollection.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 3989580ff..9288300b1 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1413,7 +1413,8 @@ public override string Get (string name) /// Gets the enumerator used to iterate through the collection. /// /// - /// An instance used to iterate through the collection. + /// An instance used to iterate through + /// the collection. /// public override IEnumerator GetEnumerator () { From 0e2a8d96d62e0f0dfa0643708be0dfec1740a7f9 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 29 Jun 2020 21:37:24 +0900 Subject: [PATCH 3056/6294] [Modify] Edit it --- websocket-sharp/Net/WebHeaderCollection.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 9288300b1..7d0d2a3df 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1422,16 +1422,18 @@ public override IEnumerator GetEnumerator () } /// - /// Get the name of the header at the specified in the collection. + /// Get the name of the header at the specified index in the collection. /// /// - /// A that receives the header name. + /// A that receives the name of the header. /// /// - /// An that represents the zero-based index of the header to find. + /// An that specifies the zero-based index of the header + /// to find. /// /// - /// is out of allowable range of indexes for the collection. + /// is out of allowable range of indexes for + /// the collection. /// public override string GetKey (int index) { From 6e8bd5c87e3711e7a0e9f981230e1de25ac1b32d Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 30 Jun 2020 19:44:55 +0900 Subject: [PATCH 3057/6294] [Modify] Edit it --- websocket-sharp/Net/WebHeaderCollection.cs | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 7d0d2a3df..d11eecc39 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1441,18 +1441,24 @@ public override string GetKey (int index) } /// - /// Gets an array of header values stored in the specified position of - /// the collection. + /// Get the values of the header at the specified index in the collection. /// /// - /// An array of that receives the header values if found; - /// otherwise, . + /// + /// An array of that receives the values of + /// the header. + /// + /// + /// if not present. + /// /// /// - /// An that represents the zero-based index of the header to find. + /// An that specifies the zero-based index of the header + /// to find. /// /// - /// is out of allowable range of indexes for the collection. + /// is out of allowable range of indexes for + /// the collection. /// public override string[] GetValues (int index) { From 1a191aebb5d90715fed399719d39b66b773da680 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 30 Jun 2020 19:50:53 +0900 Subject: [PATCH 3058/6294] [Modify] Edit it --- websocket-sharp/Net/WebHeaderCollection.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index d11eecc39..6953e6fd2 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1467,11 +1467,16 @@ public override string[] GetValues (int index) } /// - /// Gets an array of header values stored in the specified . + /// Get the values of the header with the specified name in the collection. /// /// - /// An array of that receives the header values if found; - /// otherwise, . + /// + /// An array of that receives the values of + /// the header. + /// + /// + /// if not present. + /// /// /// /// A that represents the name of the header to find. From 25bbafcf20503169458066b198e1dac6027db132 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 1 Jul 2020 19:39:18 +0900 Subject: [PATCH 3059/6294] [Modify] Rename it --- websocket-sharp/Net/WebHeaderCollection.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 6953e6fd2..f1aeb5d1f 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1481,9 +1481,9 @@ public override string[] GetValues (int index) /// /// A that represents the name of the header to find. /// - public override string[] GetValues (string header) + public override string[] GetValues (string name) { - var vals = base.GetValues (header); + var vals = base.GetValues (name); return vals != null && vals.Length > 0 ? vals : null; } From 95f8518d9f37f5551ec90ed8f03a667f6194bed4 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 1 Jul 2020 19:41:05 +0900 Subject: [PATCH 3060/6294] [Modify] Polish it --- websocket-sharp/Net/WebHeaderCollection.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index f1aeb5d1f..0da959d4c 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1484,6 +1484,7 @@ public override string[] GetValues (int index) public override string[] GetValues (string name) { var vals = base.GetValues (name); + return vals != null && vals.Length > 0 ? vals : null; } From 32943d1a22c24cdf6206f158a9d9993c93313b50 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 1 Jul 2020 19:44:02 +0900 Subject: [PATCH 3061/6294] [Modify] Edit it --- websocket-sharp/Net/WebHeaderCollection.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 0da959d4c..0726ada31 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1478,8 +1478,8 @@ public override string[] GetValues (int index) /// if not present. /// /// - /// - /// A that represents the name of the header to find. + /// + /// A that specifies the name of the header to find. /// public override string[] GetValues (string name) { From d291763b054377eeae96e947c0cde9f95c0c3e79 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 1 Jul 2020 19:45:10 +0900 Subject: [PATCH 3062/6294] [Modify] Polish it --- websocket-sharp/Net/WebHeaderCollection.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 0726ada31..fdc3663e0 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1463,6 +1463,7 @@ public override string GetKey (int index) public override string[] GetValues (int index) { var vals = base.GetValues (index); + return vals != null && vals.Length > 0 ? vals : null; } From 9a584f4b80259a914713ffa3d57dfc610857adb4 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 2 Jul 2020 19:43:35 +0900 Subject: [PATCH 3063/6294] [Modify] Replace it --- websocket-sharp/Net/WebHeaderCollection.cs | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index fdc3663e0..759950637 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1599,22 +1599,7 @@ public static bool IsRestricted (string headerName) /// public static bool IsRestricted (string headerName, bool response) { - if (headerName == null) - throw new ArgumentNullException ("headerName"); - - if (headerName.Length == 0) - throw new ArgumentException ("An empty string.", "headerName"); - - headerName = headerName.Trim (); - - if (headerName.Length == 0) - throw new ArgumentException ("A string of spaces.", "headerName"); - - if (!headerName.IsToken ()) { - var msg = "It contains an invalid character."; - - throw new ArgumentException (msg, "headerName"); - } + headerName = checkName (headerName, "headerName"); return isRestricted (headerName, response); } From 9804f89ad05ca4c32bbd2c9f326aae183974e4b9 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 3 Jul 2020 21:21:09 +0900 Subject: [PATCH 3064/6294] [Modify] Edit it --- websocket-sharp/Net/WebHeaderCollection.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 759950637..e40847195 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1605,11 +1605,12 @@ public static bool IsRestricted (string headerName, bool response) } /// - /// Implements the interface and raises the deserialization event - /// when the deserialization is complete. + /// Implements the interface and raises + /// the deserialization event when the deserialization is complete. /// /// - /// An that represents the source of the deserialization event. + /// An instance that represents the source of + /// the deserialization event. /// public override void OnDeserialization (object sender) { From d3d47115b56d6d2cae234c43ec05269519c04cc2 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 4 Jul 2020 20:40:40 +0900 Subject: [PATCH 3065/6294] [Modify] Replace it --- websocket-sharp/Net/WebHeaderCollection.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index e40847195..21680e33f 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1707,7 +1707,7 @@ public void Remove (HttpResponseHeader header) /// public override void Remove (string name) { - name = checkName (name); + name = checkName (name, "name"); var headerType = getHeaderType (name); From d141bb00fac139e968d54238e36bf803f383e7e8 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 5 Jul 2020 19:41:07 +0900 Subject: [PATCH 3066/6294] [Modify] Replace it --- websocket-sharp/Net/WebHeaderCollection.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 21680e33f..ef8761152 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1751,7 +1751,7 @@ public override void Remove (string name) /// public void Set (HttpRequestHeader header, string value) { - value = checkValue (value); + value = checkValue (value, "value"); var key = header.ToString (); var name = getHeaderName (key); From 69ad749f55fedececc40026e0e2d33786e9ea1fa Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 5 Jul 2020 19:43:55 +0900 Subject: [PATCH 3067/6294] [Modify] Edit it --- websocket-sharp/Net/WebHeaderCollection.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index ef8761152..51a728099 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1733,13 +1733,13 @@ public override void Remove (string name) /// /// /// - /// is a restricted header. + /// contains an invalid character. /// /// /// -or- /// /// - /// contains an invalid character. + /// is a restricted header. /// /// /// From 48cada685638396ee34937c845f92c0c4f547230 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 6 Jul 2020 21:15:07 +0900 Subject: [PATCH 3068/6294] [Modify] Replace it --- websocket-sharp/Net/WebHeaderCollection.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 51a728099..431dd6146 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1796,7 +1796,7 @@ public void Set (HttpRequestHeader header, string value) /// public void Set (HttpResponseHeader header, string value) { - value = checkValue (value); + value = checkValue (value, "value"); var key = header.ToString (); var name = getHeaderName (key); From 5b5d7dca2ab704efce862ddfe00238c9e89ae3a7 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 6 Jul 2020 21:17:30 +0900 Subject: [PATCH 3069/6294] [Modify] Edit it --- websocket-sharp/Net/WebHeaderCollection.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 431dd6146..2da712d0d 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1778,13 +1778,13 @@ public void Set (HttpRequestHeader header, string value) /// /// /// - /// is a restricted header. + /// contains an invalid character. /// /// /// -or- /// /// - /// contains an invalid character. + /// is a restricted header. /// /// /// From bcd94584a37778e7902c2e7fab0d1522c12d08bf Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 7 Jul 2020 20:08:39 +0900 Subject: [PATCH 3070/6294] [Modify] Replace it --- websocket-sharp/Net/WebHeaderCollection.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 2da712d0d..add480dfc 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1850,7 +1850,7 @@ public void Set (HttpResponseHeader header, string value) /// public override void Set (string name, string value) { - name = checkName (name); + name = checkName (name, "name"); value = checkValue (value); var headerType = getHeaderType (name); From 7638fcb082907f39653ae4580fb07ad482b4d2b0 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 7 Jul 2020 20:09:47 +0900 Subject: [PATCH 3071/6294] [Modify] Replace it --- websocket-sharp/Net/WebHeaderCollection.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index add480dfc..969db4c51 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1851,7 +1851,7 @@ public void Set (HttpResponseHeader header, string value) public override void Set (string name, string value) { name = checkName (name, "name"); - value = checkValue (value); + value = checkValue (value, "value"); var headerType = getHeaderType (name); From 4506de6491c7e9eca8b57f5a6b7cc153f8de3847 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 7 Jul 2020 20:12:41 +0900 Subject: [PATCH 3072/6294] [Modify] Edit it --- websocket-sharp/Net/WebHeaderCollection.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 969db4c51..e4c65df10 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1826,6 +1826,12 @@ public void Set (HttpResponseHeader header, string value) /// -or- /// /// + /// is a string of spaces. + /// + /// + /// -or- + /// + /// /// contains an invalid character. /// /// From 7d5d77b6605e90e91c05e4817047dd57d6a26785 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 8 Jul 2020 20:27:07 +0900 Subject: [PATCH 3073/6294] [Modify] Remove it --- websocket-sharp/Net/WebHeaderCollection.cs | 31 ---------------------- 1 file changed, 31 deletions(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index e4c65df10..464c5083c 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -791,37 +791,6 @@ private void checkAllowed (HttpHeaderType headerType) } } - private static string checkName (string name) - { - if (name == null) { - var msg = "The name is null."; - - throw new ArgumentNullException ("name", msg); - } - - if (name.Length == 0) { - var msg = "The name is an empty string."; - - throw new ArgumentException (msg, "name"); - } - - name = name.Trim (); - - if (name.Length == 0) { - var msg = "The name is a string of spaces."; - - throw new ArgumentException (msg, "name"); - } - - if (!name.IsToken ()) { - var msg = "The name contains an invalid character."; - - throw new ArgumentException (msg, "name"); - } - - return name; - } - private static string checkName (string name, string paramName) { if (name == null) { From 386cda815ef8fa4f1bf6f674285b3b1706dbc46e Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 8 Jul 2020 20:30:53 +0900 Subject: [PATCH 3074/6294] [Modify] Replace it --- websocket-sharp/Net/WebHeaderCollection.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 464c5083c..e7181f07b 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -985,7 +985,7 @@ internal void InternalSet (string header, bool response) internal void InternalSet (string name, string value, bool response) { - value = checkValue (value); + value = checkValue (value, "value"); if (isMultiValue (name, response)) { base.Add (name, value); From 55d647e48c1c0b7371c54c587637630f0373f37a Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 8 Jul 2020 20:32:30 +0900 Subject: [PATCH 3075/6294] [Modify] Remove it --- websocket-sharp/Net/WebHeaderCollection.cs | 27 ---------------------- 1 file changed, 27 deletions(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index e7181f07b..66c0aec32 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -836,33 +836,6 @@ private void checkRestricted (string name, HttpHeaderType headerType) } } - private static string checkValue (string value) - { - if (value == null) - return String.Empty; - - value = value.Trim (); - - var len = value.Length; - - if (len == 0) - return value; - - if (len > 65535) { - var msg = "The length of the value is greater than 65,535 characters."; - - throw new ArgumentOutOfRangeException ("value", msg); - } - - if (!value.IsText ()) { - var msg = "The value contains an invalid character."; - - throw new ArgumentException (msg, "value"); - } - - return value; - } - private static string checkValue (string value, string paramName) { if (value == null) From 7615c2a8961c569d2f6014f5754aa901f3f9bcc4 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 9 Jul 2020 21:22:04 +0900 Subject: [PATCH 3076/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerResponse.cs | 23 ++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index b088c94a4..0c8b73927 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -935,12 +935,29 @@ public void AppendCookie (Cookie cookie) /// append. /// /// - /// is or empty. + /// is . /// /// /// - /// or contains - /// an invalid character. + /// is an empty string. + /// + /// + /// -or- + /// + /// + /// is a string of spaces. + /// + /// + /// -or- + /// + /// + /// contains an invalid character. + /// + /// + /// -or- + /// + /// + /// contains an invalid character. /// /// /// -or- From eacd38efa6189f5088fec48b2d4edc145f2ee07d Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 10 Jul 2020 20:11:53 +0900 Subject: [PATCH 3077/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerResponse.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index 0c8b73927..ed9dfc150 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -971,7 +971,7 @@ public void AppendCookie (Cookie cookie) /// characters. /// /// - /// The header cannot be allowed to append to the current headers. + /// The current headers do not allow the header. /// public void AppendHeader (string name, string value) { From 4fab32c5847482e294eca5c840eedf9d59cde737 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 11 Jul 2020 21:44:09 +0900 Subject: [PATCH 3078/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerResponse.cs | 25 +++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index ed9dfc150..978ee275d 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -1180,12 +1180,29 @@ public void SetCookie (Cookie cookie) /// A that represents the value of the header to set. /// /// - /// is or empty. + /// is . /// /// /// - /// or contains - /// an invalid character. + /// is an empty string. + /// + /// + /// -or- + /// + /// + /// is a string of spaces. + /// + /// + /// -or- + /// + /// + /// contains an invalid character. + /// + /// + /// -or- + /// + /// + /// contains an invalid character. /// /// /// -or- @@ -1199,7 +1216,7 @@ public void SetCookie (Cookie cookie) /// characters. /// /// - /// The header cannot be allowed to set in the current headers. + /// The current headers do not allow the header. /// public void SetHeader (string name, string value) { From e114c47f34a1633a4977c560259d85105add65b9 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 12 Jul 2020 21:43:12 +0900 Subject: [PATCH 3079/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerResponse.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index 978ee275d..e9a32f89d 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -927,11 +927,11 @@ public void AppendCookie (Cookie cookie) /// the headers for the response. /// /// - /// A that represents the name of the header to + /// A that specifies the name of the header to /// append. /// /// - /// A that represents the value of the header to + /// A that specifies the value of the header to /// append. /// /// From 96786cd890b685f4b104784dcb31dd7ed2ad2f41 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 13 Jul 2020 21:15:44 +0900 Subject: [PATCH 3080/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerResponse.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index e9a32f89d..ce55fcb59 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -1089,7 +1089,7 @@ public void CopyFrom (HttpListenerResponse templateResponse) /// 302, and the property to "Found". /// /// - /// A that represents the absolute URL to which + /// A that specifies the absolute URL to which /// the client is redirected to locate a requested resource. /// /// From b68df3d3cbf48f1214d8106525f082ae00599436 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 13 Jul 2020 21:20:11 +0900 Subject: [PATCH 3081/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerResponse.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index ce55fcb59..5c0d93d3b 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -1174,10 +1174,10 @@ public void SetCookie (Cookie cookie) /// the headers for the response. /// /// - /// A that represents the name of the header to set. + /// A that specifies the name of the header to set. /// /// - /// A that represents the value of the header to set. + /// A that specifies the value of the header to set. /// /// /// is . From 856f7253eece5a26eeded85ca43c8281f9554fc6 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 14 Jul 2020 19:40:31 +0900 Subject: [PATCH 3082/6294] [Modify] Edit it --- websocket-sharp/Net/WebHeaderCollection.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 66c0aec32..e1ddad9d8 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -667,7 +667,7 @@ public override int Count { /// One of the enum values. /// /// - /// It represents the request header to get or set. + /// It specifies the request header to get or set. /// /// /// From c13598ab715af9a910409fbcc60384222df20ae2 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 14 Jul 2020 19:42:49 +0900 Subject: [PATCH 3083/6294] [Modify] Edit it --- websocket-sharp/Net/WebHeaderCollection.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index e1ddad9d8..f641efeeb 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -712,7 +712,7 @@ public string this[HttpRequestHeader header] { /// One of the enum values. /// /// - /// It represents the response header to get or set. + /// It specifies the response header to get or set. /// /// /// From fff361108d64d559789b78bc22ee71ccc2c62050 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 15 Jul 2020 19:48:57 +0900 Subject: [PATCH 3084/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerResponse.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index 5c0d93d3b..da1789fef 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -998,8 +998,8 @@ public void Close () /// An array of that contains the entity body data. /// /// - /// true if this method blocks execution while flushing the stream - /// to the client; otherwise, false. + /// A : true if this method blocks execution while + /// flushing the stream to the client; otherwise, false. /// /// /// is . From 3c1b3f6ced9deb7809c7c160c16d06f2930c8abd Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 16 Jul 2020 19:46:30 +0900 Subject: [PATCH 3085/6294] [Modify] Replace it --- websocket-sharp/Net/WebHeaderCollection.cs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index f641efeeb..550422e21 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -953,7 +953,16 @@ internal void InternalSet (string header, bool response) ? header.Substring (idx + 1) : String.Empty; - InternalSet (name, val, response); + name = checkName (name, "header"); + val = checkValue (val, "header"); + + if (isMultiValue (name, response)) { + base.Add (name, val); + + return; + } + + base.Set (name, val); } internal void InternalSet (string name, string value, bool response) From e77e82e3df09c201e7bce47c35b0618fcb3f05c6 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 17 Jul 2020 19:42:29 +0900 Subject: [PATCH 3086/6294] [Modify] 2020 --- websocket-sharp/Net/WebHeaderCollection.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 550422e21..d031349c9 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -9,7 +9,7 @@ * * Copyright (c) 2003 Ximian, Inc. (http://www.ximian.com) * Copyright (c) 2007 Novell, Inc. (http://www.novell.com) - * Copyright (c) 2012-2015 sta.blockhead + * Copyright (c) 2012-2020 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From c4a1f72df425b3da615e700132b15c843fc460d6 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 18 Jul 2020 21:53:42 +0900 Subject: [PATCH 3087/6294] [Modify] Polish it --- websocket-sharp/Net/HttpHeaderInfo.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpHeaderInfo.cs b/websocket-sharp/Net/HttpHeaderInfo.cs index 717f8f46d..b62205c48 100644 --- a/websocket-sharp/Net/HttpHeaderInfo.cs +++ b/websocket-sharp/Net/HttpHeaderInfo.cs @@ -53,7 +53,8 @@ internal HttpHeaderInfo (string name, HttpHeaderType type) internal bool IsMultiValueInRequest { get { - return (_type & HttpHeaderType.MultiValueInRequest) == HttpHeaderType.MultiValueInRequest; + return (_type & HttpHeaderType.MultiValueInRequest) + == HttpHeaderType.MultiValueInRequest; } } From 64b6c3bcd3ce4a7294dab45dd31176b8de8a0713 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 18 Jul 2020 21:54:30 +0900 Subject: [PATCH 3088/6294] [Modify] Polish it --- websocket-sharp/Net/HttpHeaderInfo.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpHeaderInfo.cs b/websocket-sharp/Net/HttpHeaderInfo.cs index b62205c48..4cf6272f5 100644 --- a/websocket-sharp/Net/HttpHeaderInfo.cs +++ b/websocket-sharp/Net/HttpHeaderInfo.cs @@ -60,7 +60,8 @@ internal bool IsMultiValueInRequest { internal bool IsMultiValueInResponse { get { - return (_type & HttpHeaderType.MultiValueInResponse) == HttpHeaderType.MultiValueInResponse; + return (_type & HttpHeaderType.MultiValueInResponse) + == HttpHeaderType.MultiValueInResponse; } } From 181a3fe5dac3f01df50d532259f4b31ad17c264f Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 19 Jul 2020 21:36:57 +0900 Subject: [PATCH 3089/6294] [Modify] Rename it --- websocket-sharp/Net/HttpHeaderInfo.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpHeaderInfo.cs b/websocket-sharp/Net/HttpHeaderInfo.cs index 4cf6272f5..50c2c8f01 100644 --- a/websocket-sharp/Net/HttpHeaderInfo.cs +++ b/websocket-sharp/Net/HttpHeaderInfo.cs @@ -41,9 +41,9 @@ internal class HttpHeaderInfo #region Internal Constructors - internal HttpHeaderInfo (string name, HttpHeaderType type) + internal HttpHeaderInfo (string headerName, HttpHeaderType type) { - _name = name; + _name = headerName; _type = type; } From 74a5b149077a44f7416768ebfb12f8c507d349a6 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 19 Jul 2020 21:38:45 +0900 Subject: [PATCH 3090/6294] [Modify] Rename it --- websocket-sharp/Net/HttpHeaderInfo.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpHeaderInfo.cs b/websocket-sharp/Net/HttpHeaderInfo.cs index 50c2c8f01..4f4a46131 100644 --- a/websocket-sharp/Net/HttpHeaderInfo.cs +++ b/websocket-sharp/Net/HttpHeaderInfo.cs @@ -41,10 +41,10 @@ internal class HttpHeaderInfo #region Internal Constructors - internal HttpHeaderInfo (string headerName, HttpHeaderType type) + internal HttpHeaderInfo (string headerName, HttpHeaderType headerType) { _name = headerName; - _type = type; + _type = headerType; } #endregion From b97bd787c315eb38110eae259f9d770005b466b4 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 20 Jul 2020 21:17:14 +0900 Subject: [PATCH 3091/6294] [Modify] Rename it --- websocket-sharp/Net/HttpHeaderInfo.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/HttpHeaderInfo.cs b/websocket-sharp/Net/HttpHeaderInfo.cs index 4f4a46131..be33bcf2f 100644 --- a/websocket-sharp/Net/HttpHeaderInfo.cs +++ b/websocket-sharp/Net/HttpHeaderInfo.cs @@ -34,7 +34,7 @@ internal class HttpHeaderInfo { #region Private Fields - private string _name; + private string _headerName; private HttpHeaderType _type; #endregion @@ -43,7 +43,7 @@ internal class HttpHeaderInfo internal HttpHeaderInfo (string headerName, HttpHeaderType headerType) { - _name = headerName; + _headerName = headerName; _type = headerType; } @@ -83,7 +83,7 @@ public bool IsResponse { public string Name { get { - return _name; + return _headerName; } } From e950b9ca06260d4a32fae651edfda2c29ebd2780 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 20 Jul 2020 21:18:36 +0900 Subject: [PATCH 3092/6294] [Modify] Rename it --- websocket-sharp/Net/HttpHeaderInfo.cs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/websocket-sharp/Net/HttpHeaderInfo.cs b/websocket-sharp/Net/HttpHeaderInfo.cs index be33bcf2f..9c19988f4 100644 --- a/websocket-sharp/Net/HttpHeaderInfo.cs +++ b/websocket-sharp/Net/HttpHeaderInfo.cs @@ -35,7 +35,7 @@ internal class HttpHeaderInfo #region Private Fields private string _headerName; - private HttpHeaderType _type; + private HttpHeaderType _headerType; #endregion @@ -44,7 +44,7 @@ internal class HttpHeaderInfo internal HttpHeaderInfo (string headerName, HttpHeaderType headerType) { _headerName = headerName; - _type = headerType; + _headerType = headerType; } #endregion @@ -53,14 +53,14 @@ internal HttpHeaderInfo (string headerName, HttpHeaderType headerType) internal bool IsMultiValueInRequest { get { - return (_type & HttpHeaderType.MultiValueInRequest) + return (_headerType & HttpHeaderType.MultiValueInRequest) == HttpHeaderType.MultiValueInRequest; } } internal bool IsMultiValueInResponse { get { - return (_type & HttpHeaderType.MultiValueInResponse) + return (_headerType & HttpHeaderType.MultiValueInResponse) == HttpHeaderType.MultiValueInResponse; } } @@ -71,13 +71,13 @@ internal bool IsMultiValueInResponse { public bool IsRequest { get { - return (_type & HttpHeaderType.Request) == HttpHeaderType.Request; + return (_headerType & HttpHeaderType.Request) == HttpHeaderType.Request; } } public bool IsResponse { get { - return (_type & HttpHeaderType.Response) == HttpHeaderType.Response; + return (_headerType & HttpHeaderType.Response) == HttpHeaderType.Response; } } @@ -89,7 +89,7 @@ public string Name { public HttpHeaderType Type { get { - return _type; + return _headerType; } } @@ -99,14 +99,14 @@ public HttpHeaderType Type { public bool IsMultiValue (bool response) { - return (_type & HttpHeaderType.MultiValue) == HttpHeaderType.MultiValue + return (_headerType & HttpHeaderType.MultiValue) == HttpHeaderType.MultiValue ? (response ? IsResponse : IsRequest) : (response ? IsMultiValueInResponse : IsMultiValueInRequest); } public bool IsRestricted (bool response) { - return (_type & HttpHeaderType.Restricted) == HttpHeaderType.Restricted + return (_headerType & HttpHeaderType.Restricted) == HttpHeaderType.Restricted ? (response ? IsResponse : IsRequest) : false; } From 4d01d325ec0398ebdb633a3c33d892a7596d0125 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 21 Jul 2020 19:43:05 +0900 Subject: [PATCH 3093/6294] [Modify] Rename it --- websocket-sharp/Net/HttpHeaderInfo.cs | 12 ++++++------ websocket-sharp/Net/WebHeaderCollection.cs | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/websocket-sharp/Net/HttpHeaderInfo.cs b/websocket-sharp/Net/HttpHeaderInfo.cs index 9c19988f4..84274353c 100644 --- a/websocket-sharp/Net/HttpHeaderInfo.cs +++ b/websocket-sharp/Net/HttpHeaderInfo.cs @@ -69,21 +69,21 @@ internal bool IsMultiValueInResponse { #region Public Properties - public bool IsRequest { + public string HeaderName { get { - return (_headerType & HttpHeaderType.Request) == HttpHeaderType.Request; + return _headerName; } } - public bool IsResponse { + public bool IsRequest { get { - return (_headerType & HttpHeaderType.Response) == HttpHeaderType.Response; + return (_headerType & HttpHeaderType.Request) == HttpHeaderType.Request; } } - public string Name { + public bool IsResponse { get { - return _headerName; + return (_headerType & HttpHeaderType.Response) == HttpHeaderType.Response; } } diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index d031349c9..f92fc2915 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -868,7 +868,7 @@ private static HttpHeaderInfo getHeaderInfo (string name) var comparison = StringComparison.InvariantCultureIgnoreCase; foreach (var headerInfo in _headers.Values) { - if (headerInfo.Name.Equals (name, comparison)) + if (headerInfo.HeaderName.Equals (name, comparison)) return headerInfo; } @@ -880,7 +880,7 @@ private static string getHeaderName (string key) HttpHeaderInfo headerInfo; return _headers.TryGetValue (key, out headerInfo) - ? headerInfo.Name + ? headerInfo.HeaderName : null; } From 8e3c6c5855aae0864b6014b89d770178bb8421c5 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 21 Jul 2020 19:46:45 +0900 Subject: [PATCH 3094/6294] [Modify] Rename it --- websocket-sharp/Net/HttpHeaderInfo.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Net/HttpHeaderInfo.cs b/websocket-sharp/Net/HttpHeaderInfo.cs index 84274353c..eece938b7 100644 --- a/websocket-sharp/Net/HttpHeaderInfo.cs +++ b/websocket-sharp/Net/HttpHeaderInfo.cs @@ -75,21 +75,21 @@ public string HeaderName { } } - public bool IsRequest { + public HttpHeaderType HeaderType { get { - return (_headerType & HttpHeaderType.Request) == HttpHeaderType.Request; + return _headerType; } } - public bool IsResponse { + public bool IsRequest { get { - return (_headerType & HttpHeaderType.Response) == HttpHeaderType.Response; + return (_headerType & HttpHeaderType.Request) == HttpHeaderType.Request; } } - public HttpHeaderType Type { + public bool IsResponse { get { - return _headerType; + return (_headerType & HttpHeaderType.Response) == HttpHeaderType.Response; } } From d64ee7533c02e8b54ec9c45c6b779af20fe1be2d Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 22 Jul 2020 20:25:07 +0900 Subject: [PATCH 3095/6294] [Modify] Polish it --- websocket-sharp/Net/HttpHeaderInfo.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpHeaderInfo.cs b/websocket-sharp/Net/HttpHeaderInfo.cs index eece938b7..f6d1afffd 100644 --- a/websocket-sharp/Net/HttpHeaderInfo.cs +++ b/websocket-sharp/Net/HttpHeaderInfo.cs @@ -83,7 +83,9 @@ public HttpHeaderType HeaderType { public bool IsRequest { get { - return (_headerType & HttpHeaderType.Request) == HttpHeaderType.Request; + var headerType = _headerType & HttpHeaderType.Request; + + return headerType == HttpHeaderType.Request; } } From eacf404f6cccb23ff6d31d27f2c88623c33c934b Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 22 Jul 2020 20:27:31 +0900 Subject: [PATCH 3096/6294] [Modify] Polish it --- websocket-sharp/Net/HttpHeaderInfo.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpHeaderInfo.cs b/websocket-sharp/Net/HttpHeaderInfo.cs index f6d1afffd..f7376ef38 100644 --- a/websocket-sharp/Net/HttpHeaderInfo.cs +++ b/websocket-sharp/Net/HttpHeaderInfo.cs @@ -91,7 +91,9 @@ public bool IsRequest { public bool IsResponse { get { - return (_headerType & HttpHeaderType.Response) == HttpHeaderType.Response; + var headerType = _headerType & HttpHeaderType.Response; + + return headerType == HttpHeaderType.Response; } } From 2880ab2e15f8c4312bade398617e8610ab2ac7f1 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 23 Jul 2020 19:34:11 +0900 Subject: [PATCH 3097/6294] [Modify] Polish it --- websocket-sharp/Net/HttpHeaderInfo.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpHeaderInfo.cs b/websocket-sharp/Net/HttpHeaderInfo.cs index f7376ef38..6853ffcf4 100644 --- a/websocket-sharp/Net/HttpHeaderInfo.cs +++ b/websocket-sharp/Net/HttpHeaderInfo.cs @@ -53,8 +53,9 @@ internal HttpHeaderInfo (string headerName, HttpHeaderType headerType) internal bool IsMultiValueInRequest { get { - return (_headerType & HttpHeaderType.MultiValueInRequest) - == HttpHeaderType.MultiValueInRequest; + var headerType = _headerType & HttpHeaderType.MultiValueInRequest; + + return headerType == HttpHeaderType.MultiValueInRequest; } } From 4f64885b91b7b2a37773feadd33df2116892769d Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 23 Jul 2020 19:36:34 +0900 Subject: [PATCH 3098/6294] [Modify] Polish it --- websocket-sharp/Net/HttpHeaderInfo.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpHeaderInfo.cs b/websocket-sharp/Net/HttpHeaderInfo.cs index 6853ffcf4..d6775ccd9 100644 --- a/websocket-sharp/Net/HttpHeaderInfo.cs +++ b/websocket-sharp/Net/HttpHeaderInfo.cs @@ -61,8 +61,9 @@ internal bool IsMultiValueInRequest { internal bool IsMultiValueInResponse { get { - return (_headerType & HttpHeaderType.MultiValueInResponse) - == HttpHeaderType.MultiValueInResponse; + var headerType = _headerType & HttpHeaderType.MultiValueInResponse; + + return headerType == HttpHeaderType.MultiValueInResponse; } } From 15344b966569b08b7cb61480514616e982ded74b Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 24 Jul 2020 19:43:30 +0900 Subject: [PATCH 3099/6294] [Modify] Polish it --- websocket-sharp/Net/HttpHeaderInfo.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpHeaderInfo.cs b/websocket-sharp/Net/HttpHeaderInfo.cs index d6775ccd9..1a56eb2c1 100644 --- a/websocket-sharp/Net/HttpHeaderInfo.cs +++ b/websocket-sharp/Net/HttpHeaderInfo.cs @@ -112,7 +112,9 @@ public bool IsMultiValue (bool response) public bool IsRestricted (bool response) { - return (_headerType & HttpHeaderType.Restricted) == HttpHeaderType.Restricted + var headerType = _headerType & HttpHeaderType.Restricted; + + return headerType == HttpHeaderType.Restricted ? (response ? IsResponse : IsRequest) : false; } From 63a5e9c11bf3e95dd05f92fa31bcdd773cdc73a5 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 25 Jul 2020 20:27:13 +0900 Subject: [PATCH 3100/6294] [Modify] Polish it --- websocket-sharp/Net/HttpHeaderInfo.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/HttpHeaderInfo.cs b/websocket-sharp/Net/HttpHeaderInfo.cs index 1a56eb2c1..dbaac502d 100644 --- a/websocket-sharp/Net/HttpHeaderInfo.cs +++ b/websocket-sharp/Net/HttpHeaderInfo.cs @@ -114,9 +114,10 @@ public bool IsRestricted (bool response) { var headerType = _headerType & HttpHeaderType.Restricted; - return headerType == HttpHeaderType.Restricted - ? (response ? IsResponse : IsRequest) - : false; + if (headerType != HttpHeaderType.Restricted) + return false; + + return response ? IsResponse : IsRequest; } #endregion From 5a437f7d99706191e179f820774182f781946f0f Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 26 Jul 2020 21:59:01 +0900 Subject: [PATCH 3101/6294] [Modify] Polish it --- websocket-sharp/Net/HttpHeaderInfo.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/HttpHeaderInfo.cs b/websocket-sharp/Net/HttpHeaderInfo.cs index dbaac502d..321debb95 100644 --- a/websocket-sharp/Net/HttpHeaderInfo.cs +++ b/websocket-sharp/Net/HttpHeaderInfo.cs @@ -105,9 +105,12 @@ public bool IsResponse { public bool IsMultiValue (bool response) { - return (_headerType & HttpHeaderType.MultiValue) == HttpHeaderType.MultiValue - ? (response ? IsResponse : IsRequest) - : (response ? IsMultiValueInResponse : IsMultiValueInRequest); + var headerType = _headerType & HttpHeaderType.MultiValue; + + if (headerType != HttpHeaderType.MultiValue) + return response ? IsMultiValueInResponse : IsMultiValueInRequest; + + return response ? IsResponse : IsRequest; } public bool IsRestricted (bool response) From ce2cfaf476828c3bb729f09a8dc9f87b254e8ae4 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 27 Jul 2020 20:59:47 +0900 Subject: [PATCH 3102/6294] [Modify] 2020 --- websocket-sharp/Net/HttpHeaderInfo.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpHeaderInfo.cs b/websocket-sharp/Net/HttpHeaderInfo.cs index 321debb95..2b77e3d9d 100644 --- a/websocket-sharp/Net/HttpHeaderInfo.cs +++ b/websocket-sharp/Net/HttpHeaderInfo.cs @@ -4,7 +4,7 @@ * * The MIT License * - * Copyright (c) 2013-2014 sta.blockhead + * Copyright (c) 2013-2020 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From 66376f1b85b843ab6387f87b0e7099ba393ebbbb Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 28 Jul 2020 18:06:27 +0900 Subject: [PATCH 3103/6294] [Modify] Edit it --- websocket-sharp/Net/HttpRequestHeader.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/HttpRequestHeader.cs b/websocket-sharp/Net/HttpRequestHeader.cs index 08785db34..bd1029a9f 100644 --- a/websocket-sharp/Net/HttpRequestHeader.cs +++ b/websocket-sharp/Net/HttpRequestHeader.cs @@ -40,12 +40,12 @@ namespace WebSocketSharp.Net { /// - /// Contains the HTTP headers that may be specified in a client request. + /// Indicates the HTTP header that may be specified in a client request. /// /// - /// The HttpRequestHeader enumeration contains the HTTP request headers defined in - /// RFC 2616 for the HTTP/1.1 and - /// RFC 6455 for the WebSocket. + /// The headers of this enumeration are defined in + /// RFC 2616 or + /// RFC 6455. /// public enum HttpRequestHeader { From 680e1e5ccbbaf134349b1dff379a3955cdbeffb2 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 29 Jul 2020 19:46:43 +0900 Subject: [PATCH 3104/6294] [Modify] Edit it --- websocket-sharp/Net/HttpRequestHeader.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpRequestHeader.cs b/websocket-sharp/Net/HttpRequestHeader.cs index bd1029a9f..3885f5a2c 100644 --- a/websocket-sharp/Net/HttpRequestHeader.cs +++ b/websocket-sharp/Net/HttpRequestHeader.cs @@ -2,7 +2,7 @@ /* * HttpRequestHeader.cs * - * This code is derived from System.Net.HttpRequestHeader.cs of Mono + * This code is derived from HttpRequestHeader.cs (System.Net) of Mono * (http://www.mono-project.com). * * The MIT License From 7fece181f5de120a054eece4a87234274534947e Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 29 Jul 2020 19:48:53 +0900 Subject: [PATCH 3105/6294] [Modify] 2020 --- websocket-sharp/Net/HttpRequestHeader.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpRequestHeader.cs b/websocket-sharp/Net/HttpRequestHeader.cs index 3885f5a2c..aab3497ff 100644 --- a/websocket-sharp/Net/HttpRequestHeader.cs +++ b/websocket-sharp/Net/HttpRequestHeader.cs @@ -8,7 +8,7 @@ * The MIT License * * Copyright (c) 2005 Novell, Inc. (http://www.novell.com) - * Copyright (c) 2014 sta.blockhead + * Copyright (c) 2014-2020 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From 48f3b4744e3e24e1a4f076719334eb6e5382985b Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 30 Jul 2020 19:52:59 +0900 Subject: [PATCH 3106/6294] [Modify] Edit it --- websocket-sharp/Net/HttpResponseHeader.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/HttpResponseHeader.cs b/websocket-sharp/Net/HttpResponseHeader.cs index d8f36ed84..691d65bd0 100644 --- a/websocket-sharp/Net/HttpResponseHeader.cs +++ b/websocket-sharp/Net/HttpResponseHeader.cs @@ -40,12 +40,12 @@ namespace WebSocketSharp.Net { /// - /// Contains the HTTP headers that can be specified in a server response. + /// Indicates the HTTP header that can be specified in a server response. /// /// - /// The HttpResponseHeader enumeration contains the HTTP response headers defined in - /// RFC 2616 for the HTTP/1.1 and - /// RFC 6455 for the WebSocket. + /// The headers of this enumeration are defined in + /// RFC 2616 or + /// RFC 6455. /// public enum HttpResponseHeader { From 8bba87650275727563a9b32ae8e7a04dd2be3239 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 31 Jul 2020 19:43:44 +0900 Subject: [PATCH 3107/6294] [Modify] Edit it --- websocket-sharp/Net/HttpResponseHeader.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpResponseHeader.cs b/websocket-sharp/Net/HttpResponseHeader.cs index 691d65bd0..822e4a9d6 100644 --- a/websocket-sharp/Net/HttpResponseHeader.cs +++ b/websocket-sharp/Net/HttpResponseHeader.cs @@ -2,7 +2,7 @@ /* * HttpResponseHeader.cs * - * This code is derived from System.Net.HttpResponseHeader.cs of Mono + * This code is derived from HttpResponseHeader.cs (System.Net) of Mono * (http://www.mono-project.com). * * The MIT License From 0fef8e0745998142fbbb945bf1b32cdcec9e8e72 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 31 Jul 2020 19:44:47 +0900 Subject: [PATCH 3108/6294] [Modify] 2020 --- websocket-sharp/Net/HttpResponseHeader.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpResponseHeader.cs b/websocket-sharp/Net/HttpResponseHeader.cs index 822e4a9d6..d32afe6c9 100644 --- a/websocket-sharp/Net/HttpResponseHeader.cs +++ b/websocket-sharp/Net/HttpResponseHeader.cs @@ -8,7 +8,7 @@ * The MIT License * * Copyright (c) 2005 Novell, Inc. (http://www.novell.com) - * Copyright (c) 2014 sta.blockhead + * Copyright (c) 2014-2020 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From b0f489b0e959f4832971e166c9349b15eb5e34f1 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 1 Aug 2020 21:34:04 +0900 Subject: [PATCH 3109/6294] [Modify] Edit it --- websocket-sharp/Net/HttpStatusCode.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/HttpStatusCode.cs b/websocket-sharp/Net/HttpStatusCode.cs index 123415f01..e4730d524 100644 --- a/websocket-sharp/Net/HttpStatusCode.cs +++ b/websocket-sharp/Net/HttpStatusCode.cs @@ -39,11 +39,11 @@ namespace WebSocketSharp.Net { /// - /// Contains the values of the HTTP status codes. + /// Indicates the HTTP status code that can be specified in a server response. /// /// - /// The HttpStatusCode enumeration contains the values of the HTTP status codes defined in - /// RFC 2616 for the HTTP/1.1. + /// The values of this enumeration are defined in + /// RFC 2616. /// public enum HttpStatusCode { From 8a395d0b765bf7930b344393baeb6e28c1adc5b9 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 1 Aug 2020 21:36:05 +0900 Subject: [PATCH 3110/6294] [Modify] Edit it --- websocket-sharp/Net/HttpStatusCode.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpStatusCode.cs b/websocket-sharp/Net/HttpStatusCode.cs index e4730d524..2b7d2ca09 100644 --- a/websocket-sharp/Net/HttpStatusCode.cs +++ b/websocket-sharp/Net/HttpStatusCode.cs @@ -48,8 +48,8 @@ namespace WebSocketSharp.Net public enum HttpStatusCode { /// - /// Equivalent to status code 100. - /// Indicates that the client should continue with its request. + /// Equivalent to status code 100. Indicates that the client should continue + /// with its request. /// Continue = 100, /// From 889a57b7cc4cdbd96d7c10b1b9adc437af50613a Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 2 Aug 2020 20:13:39 +0900 Subject: [PATCH 3111/6294] [Modify] Edit it --- websocket-sharp/Net/HttpStatusCode.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpStatusCode.cs b/websocket-sharp/Net/HttpStatusCode.cs index 2b7d2ca09..ea4da5900 100644 --- a/websocket-sharp/Net/HttpStatusCode.cs +++ b/websocket-sharp/Net/HttpStatusCode.cs @@ -53,8 +53,8 @@ public enum HttpStatusCode /// Continue = 100, /// - /// Equivalent to status code 101. - /// Indicates that the server is switching the HTTP version or protocol on the connection. + /// Equivalent to status code 101. Indicates that the server is switching + /// the HTTP version or protocol on the connection. /// SwitchingProtocols = 101, /// From 68e21defd6e3c1ec135f3f96ead55cd04bde7911 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 2 Aug 2020 20:14:46 +0900 Subject: [PATCH 3112/6294] [Modify] Edit it --- websocket-sharp/Net/HttpStatusCode.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpStatusCode.cs b/websocket-sharp/Net/HttpStatusCode.cs index ea4da5900..254d3d589 100644 --- a/websocket-sharp/Net/HttpStatusCode.cs +++ b/websocket-sharp/Net/HttpStatusCode.cs @@ -58,8 +58,8 @@ public enum HttpStatusCode /// SwitchingProtocols = 101, /// - /// Equivalent to status code 200. - /// Indicates that the client's request has succeeded. + /// Equivalent to status code 200. Indicates that the client's request has + /// succeeded. /// OK = 200, /// From f33a9b91446e3f532fa2175ff95c9db8f5516de7 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 2 Aug 2020 20:16:33 +0900 Subject: [PATCH 3113/6294] [Modify] Edit it --- websocket-sharp/Net/HttpStatusCode.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/HttpStatusCode.cs b/websocket-sharp/Net/HttpStatusCode.cs index 254d3d589..2b482d406 100644 --- a/websocket-sharp/Net/HttpStatusCode.cs +++ b/websocket-sharp/Net/HttpStatusCode.cs @@ -63,9 +63,8 @@ public enum HttpStatusCode /// OK = 200, /// - /// Equivalent to status code 201. - /// Indicates that the client's request has been fulfilled and resulted in a new resource being - /// created. + /// Equivalent to status code 201. Indicates that the client's request has + /// been fulfilled and resulted in a new resource being created. /// Created = 201, /// From f0bad5000b6f36576cc4c98cadbd158751a9a378 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 2 Aug 2020 20:18:05 +0900 Subject: [PATCH 3114/6294] [Modify] Edit it --- websocket-sharp/Net/HttpStatusCode.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/HttpStatusCode.cs b/websocket-sharp/Net/HttpStatusCode.cs index 2b482d406..dda42937c 100644 --- a/websocket-sharp/Net/HttpStatusCode.cs +++ b/websocket-sharp/Net/HttpStatusCode.cs @@ -68,9 +68,8 @@ public enum HttpStatusCode /// Created = 201, /// - /// Equivalent to status code 202. - /// Indicates that the client's request has been accepted for processing, but the processing - /// hasn't been completed. + /// Equivalent to status code 202. Indicates that the client's request has + /// been accepted for processing, but the processing has not been completed. /// Accepted = 202, /// From 88cf39565aa38fdf3ea0239b4271631f83490b22 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 2 Aug 2020 20:20:03 +0900 Subject: [PATCH 3115/6294] [Modify] Edit it --- websocket-sharp/Net/HttpStatusCode.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/HttpStatusCode.cs b/websocket-sharp/Net/HttpStatusCode.cs index dda42937c..350125ad2 100644 --- a/websocket-sharp/Net/HttpStatusCode.cs +++ b/websocket-sharp/Net/HttpStatusCode.cs @@ -73,9 +73,8 @@ public enum HttpStatusCode /// Accepted = 202, /// - /// Equivalent to status code 203. - /// Indicates that the returned metainformation is from a local or a third-party copy instead of - /// the origin server. + /// Equivalent to status code 203. Indicates that the returned metainformation + /// is from a local or a third-party copy instead of the origin server. /// NonAuthoritativeInformation = 203, /// From 3298a1817defa7b96568a1b67e6ec1eb5d1289cd Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 2 Aug 2020 20:23:06 +0900 Subject: [PATCH 3116/6294] [Modify] Edit it --- websocket-sharp/Net/HttpStatusCode.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/HttpStatusCode.cs b/websocket-sharp/Net/HttpStatusCode.cs index 350125ad2..fe6700a1d 100644 --- a/websocket-sharp/Net/HttpStatusCode.cs +++ b/websocket-sharp/Net/HttpStatusCode.cs @@ -78,9 +78,8 @@ public enum HttpStatusCode /// NonAuthoritativeInformation = 203, /// - /// Equivalent to status code 204. - /// Indicates that the server has fulfilled the client's request but doesn't need to return - /// an entity-body. + /// Equivalent to status code 204. Indicates that the server has fulfilled + /// the client's request but does not need to return an entity-body. /// NoContent = 204, /// From 1dcce544bc29fd91652c0861920b6fce9d46483b Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 3 Aug 2020 20:39:39 +0900 Subject: [PATCH 3117/6294] [Modify] Edit it --- websocket-sharp/Net/HttpStatusCode.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/HttpStatusCode.cs b/websocket-sharp/Net/HttpStatusCode.cs index fe6700a1d..d862aaf16 100644 --- a/websocket-sharp/Net/HttpStatusCode.cs +++ b/websocket-sharp/Net/HttpStatusCode.cs @@ -83,9 +83,9 @@ public enum HttpStatusCode /// NoContent = 204, /// - /// Equivalent to status code 205. - /// Indicates that the server has fulfilled the client's request, and the user agent should - /// reset the document view which caused the request to be sent. + /// Equivalent to status code 205. Indicates that the server has fulfilled + /// the client's request, and the user agent should reset the document view + /// which caused the request to be sent. /// ResetContent = 205, /// From 3707fa8ba3c2aa798b7a0479d503888c2c83d52e Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 3 Aug 2020 20:41:10 +0900 Subject: [PATCH 3118/6294] [Modify] Edit it --- websocket-sharp/Net/HttpStatusCode.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpStatusCode.cs b/websocket-sharp/Net/HttpStatusCode.cs index d862aaf16..63b613602 100644 --- a/websocket-sharp/Net/HttpStatusCode.cs +++ b/websocket-sharp/Net/HttpStatusCode.cs @@ -89,8 +89,8 @@ public enum HttpStatusCode /// ResetContent = 205, /// - /// Equivalent to status code 206. - /// Indicates that the server has fulfilled the partial GET request for the resource. + /// Equivalent to status code 206. Indicates that the server has fulfilled + /// the partial GET request for the resource. /// PartialContent = 206, /// From 22684a5e589b7e5acb4a624f35cea03252b3ebde Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 3 Aug 2020 20:42:35 +0900 Subject: [PATCH 3119/6294] [Modify] Edit it --- websocket-sharp/Net/HttpStatusCode.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpStatusCode.cs b/websocket-sharp/Net/HttpStatusCode.cs index 63b613602..223dd094d 100644 --- a/websocket-sharp/Net/HttpStatusCode.cs +++ b/websocket-sharp/Net/HttpStatusCode.cs @@ -95,8 +95,8 @@ public enum HttpStatusCode PartialContent = 206, /// /// - /// Equivalent to status code 300. - /// Indicates that the requested resource corresponds to any of multiple representations. + /// Equivalent to status code 300. Indicates that the requested resource + /// corresponds to any of multiple representations. /// /// /// MultipleChoices is a synonym for Ambiguous. From 92cd786aa4e75e5a41ef2d2bfbb267b2293e6eac Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 3 Aug 2020 20:43:40 +0900 Subject: [PATCH 3120/6294] [Modify] Edit it --- websocket-sharp/Net/HttpStatusCode.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpStatusCode.cs b/websocket-sharp/Net/HttpStatusCode.cs index 223dd094d..a35f709f4 100644 --- a/websocket-sharp/Net/HttpStatusCode.cs +++ b/websocket-sharp/Net/HttpStatusCode.cs @@ -105,8 +105,8 @@ public enum HttpStatusCode MultipleChoices = 300, /// /// - /// Equivalent to status code 300. - /// Indicates that the requested resource corresponds to any of multiple representations. + /// Equivalent to status code 300. Indicates that the requested resource + /// corresponds to any of multiple representations. /// /// /// Ambiguous is a synonym for MultipleChoices. From bff957e5d3bf931c36fb275fcd9d57f258ea55a7 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 3 Aug 2020 20:45:32 +0900 Subject: [PATCH 3121/6294] [Modify] Edit it --- websocket-sharp/Net/HttpStatusCode.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/HttpStatusCode.cs b/websocket-sharp/Net/HttpStatusCode.cs index a35f709f4..211796841 100644 --- a/websocket-sharp/Net/HttpStatusCode.cs +++ b/websocket-sharp/Net/HttpStatusCode.cs @@ -115,9 +115,9 @@ public enum HttpStatusCode Ambiguous = 300, /// /// - /// Equivalent to status code 301. - /// Indicates that the requested resource has been assigned a new permanent URI and - /// any future references to this resource should use one of the returned URIs. + /// Equivalent to status code 301. Indicates that the requested resource + /// has been assigned a new permanent URI and any future references to + /// this resource should use one of the returned URIs. /// /// /// MovedPermanently is a synonym for Moved. From 14e3d361f7b58cc94110106802a4aab63465fe5f Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 3 Aug 2020 20:47:15 +0900 Subject: [PATCH 3122/6294] [Modify] Edit it --- websocket-sharp/Net/HttpStatusCode.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/HttpStatusCode.cs b/websocket-sharp/Net/HttpStatusCode.cs index 211796841..2bb7fc73e 100644 --- a/websocket-sharp/Net/HttpStatusCode.cs +++ b/websocket-sharp/Net/HttpStatusCode.cs @@ -126,9 +126,9 @@ public enum HttpStatusCode MovedPermanently = 301, /// /// - /// Equivalent to status code 301. - /// Indicates that the requested resource has been assigned a new permanent URI and - /// any future references to this resource should use one of the returned URIs. + /// Equivalent to status code 301. Indicates that the requested resource + /// has been assigned a new permanent URI and any future references to + /// this resource should use one of the returned URIs. /// /// /// Moved is a synonym for MovedPermanently. From abb575f2571c664392db34d6efc637ea28ffd648 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 4 Aug 2020 19:57:56 +0900 Subject: [PATCH 3123/6294] [Modify] Edit it --- websocket-sharp/Net/HttpStatusCode.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpStatusCode.cs b/websocket-sharp/Net/HttpStatusCode.cs index 2bb7fc73e..7af24ea64 100644 --- a/websocket-sharp/Net/HttpStatusCode.cs +++ b/websocket-sharp/Net/HttpStatusCode.cs @@ -137,8 +137,8 @@ public enum HttpStatusCode Moved = 301, /// /// - /// Equivalent to status code 302. - /// Indicates that the requested resource is located temporarily under a different URI. + /// Equivalent to status code 302. Indicates that the requested resource + /// is located temporarily under a different URI. /// /// /// Found is a synonym for Redirect. From 0faa33717718f97404ac705585c63fa2e546ac75 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 4 Aug 2020 20:00:12 +0900 Subject: [PATCH 3124/6294] [Modify] Edit it --- websocket-sharp/Net/HttpStatusCode.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpStatusCode.cs b/websocket-sharp/Net/HttpStatusCode.cs index 7af24ea64..f8cb46fc3 100644 --- a/websocket-sharp/Net/HttpStatusCode.cs +++ b/websocket-sharp/Net/HttpStatusCode.cs @@ -147,8 +147,8 @@ public enum HttpStatusCode Found = 302, /// /// - /// Equivalent to status code 302. - /// Indicates that the requested resource is located temporarily under a different URI. + /// Equivalent to status code 302. Indicates that the requested resource + /// is located temporarily under a different URI. /// /// /// Redirect is a synonym for Found. From 8313206e16738a4d6fafdac95674b1e883a2963b Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 4 Aug 2020 20:02:18 +0900 Subject: [PATCH 3125/6294] [Modify] Edit it --- websocket-sharp/Net/HttpStatusCode.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/HttpStatusCode.cs b/websocket-sharp/Net/HttpStatusCode.cs index f8cb46fc3..f8fc0461e 100644 --- a/websocket-sharp/Net/HttpStatusCode.cs +++ b/websocket-sharp/Net/HttpStatusCode.cs @@ -157,9 +157,9 @@ public enum HttpStatusCode Redirect = 302, /// /// - /// Equivalent to status code 303. - /// Indicates that the response to the request can be found under a different URI and - /// should be retrieved using a GET method on that resource. + /// Equivalent to status code 303. Indicates that the response to + /// the request can be found under a different URI and should be + /// retrieved using a GET method on that resource. /// /// /// SeeOther is a synonym for RedirectMethod. From 092e988aea99d616dc83c4a917e2723b3689ec7f Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 4 Aug 2020 20:04:01 +0900 Subject: [PATCH 3126/6294] [Modify] Edit it --- websocket-sharp/Net/HttpStatusCode.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/HttpStatusCode.cs b/websocket-sharp/Net/HttpStatusCode.cs index f8fc0461e..0353fdcdb 100644 --- a/websocket-sharp/Net/HttpStatusCode.cs +++ b/websocket-sharp/Net/HttpStatusCode.cs @@ -168,9 +168,9 @@ public enum HttpStatusCode SeeOther = 303, /// /// - /// Equivalent to status code 303. - /// Indicates that the response to the request can be found under a different URI and - /// should be retrieved using a GET method on that resource. + /// Equivalent to status code 303. Indicates that the response to + /// the request can be found under a different URI and should be + /// retrieved using a GET method on that resource. /// /// /// RedirectMethod is a synonym for SeeOther. From 57ef96ff3862c5a168ae95b1037c21c5ddd9fc0c Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 4 Aug 2020 20:07:12 +0900 Subject: [PATCH 3127/6294] [Modify] Edit it --- websocket-sharp/Net/HttpStatusCode.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/HttpStatusCode.cs b/websocket-sharp/Net/HttpStatusCode.cs index 0353fdcdb..4c23db6a8 100644 --- a/websocket-sharp/Net/HttpStatusCode.cs +++ b/websocket-sharp/Net/HttpStatusCode.cs @@ -178,9 +178,9 @@ public enum HttpStatusCode /// RedirectMethod = 303, /// - /// Equivalent to status code 304. - /// Indicates that the client has performed a conditional GET request and access is allowed, - /// but the document hasn't been modified. + /// Equivalent to status code 304. Indicates that the client has performed + /// a conditional GET request and access is allowed, but the document has + /// not been modified. /// NotModified = 304, /// From 1785392b78704ff3a935713dc96bafb58724dbe1 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 5 Aug 2020 20:12:55 +0900 Subject: [PATCH 3128/6294] [Modify] Edit it --- websocket-sharp/Net/HttpStatusCode.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/HttpStatusCode.cs b/websocket-sharp/Net/HttpStatusCode.cs index 4c23db6a8..40d73972e 100644 --- a/websocket-sharp/Net/HttpStatusCode.cs +++ b/websocket-sharp/Net/HttpStatusCode.cs @@ -184,9 +184,8 @@ public enum HttpStatusCode /// NotModified = 304, /// - /// Equivalent to status code 305. - /// Indicates that the requested resource must be accessed through the proxy given by - /// the Location field. + /// Equivalent to status code 305. Indicates that the requested resource + /// must be accessed through the proxy given by the Location field. /// UseProxy = 305, /// From b3bd3ef3a6cb384e6c8171b31ccbf0e93c0ff73b Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 5 Aug 2020 20:15:10 +0900 Subject: [PATCH 3129/6294] [Modify] Edit it --- websocket-sharp/Net/HttpStatusCode.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/HttpStatusCode.cs b/websocket-sharp/Net/HttpStatusCode.cs index 40d73972e..80a53e332 100644 --- a/websocket-sharp/Net/HttpStatusCode.cs +++ b/websocket-sharp/Net/HttpStatusCode.cs @@ -189,9 +189,9 @@ public enum HttpStatusCode /// UseProxy = 305, /// - /// Equivalent to status code 306. - /// This status code was used in a previous version of the specification, is no longer used, - /// and is reserved for future use. + /// Equivalent to status code 306. This status code was used in a previous + /// version of the specification, is no longer used, and is reserved for + /// future use. /// Unused = 306, /// From 35f3aea25c77adee0beff21589d24efe91cca60a Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 5 Aug 2020 20:16:39 +0900 Subject: [PATCH 3130/6294] [Modify] Edit it --- websocket-sharp/Net/HttpStatusCode.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpStatusCode.cs b/websocket-sharp/Net/HttpStatusCode.cs index 80a53e332..70f3838e2 100644 --- a/websocket-sharp/Net/HttpStatusCode.cs +++ b/websocket-sharp/Net/HttpStatusCode.cs @@ -196,8 +196,8 @@ public enum HttpStatusCode Unused = 306, /// /// - /// Equivalent to status code 307. - /// Indicates that the requested resource is located temporarily under a different URI. + /// Equivalent to status code 307. Indicates that the requested resource + /// is located temporarily under a different URI. /// /// /// TemporaryRedirect is a synonym for RedirectKeepVerb. From 7bbe20d00916bb4b93bd7a028a6158b1244739e1 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 5 Aug 2020 20:17:57 +0900 Subject: [PATCH 3131/6294] [Modify] Edit it --- websocket-sharp/Net/HttpStatusCode.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpStatusCode.cs b/websocket-sharp/Net/HttpStatusCode.cs index 70f3838e2..9e6a5043a 100644 --- a/websocket-sharp/Net/HttpStatusCode.cs +++ b/websocket-sharp/Net/HttpStatusCode.cs @@ -206,8 +206,8 @@ public enum HttpStatusCode TemporaryRedirect = 307, /// /// - /// Equivalent to status code 307. - /// Indicates that the requested resource is located temporarily under a different URI. + /// Equivalent to status code 307. Indicates that the requested resource + /// is located temporarily under a different URI. /// /// /// RedirectKeepVerb is a synonym for TemporaryRedirect. From 21f5b87c88504e100f40d7968622d29cb0f1aeec Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 5 Aug 2020 20:19:56 +0900 Subject: [PATCH 3132/6294] [Modify] Edit it --- websocket-sharp/Net/HttpStatusCode.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/HttpStatusCode.cs b/websocket-sharp/Net/HttpStatusCode.cs index 9e6a5043a..5abe2283a 100644 --- a/websocket-sharp/Net/HttpStatusCode.cs +++ b/websocket-sharp/Net/HttpStatusCode.cs @@ -215,9 +215,8 @@ public enum HttpStatusCode /// RedirectKeepVerb = 307, /// - /// Equivalent to status code 400. - /// Indicates that the client's request couldn't be understood by the server due to - /// malformed syntax. + /// Equivalent to status code 400. Indicates that the client's request could + /// not be understood by the server due to malformed syntax. /// BadRequest = 400, /// From b6dc1339be1f80be252a12a93458c88f4652893b Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 5 Aug 2020 20:21:46 +0900 Subject: [PATCH 3133/6294] [Modify] Edit it --- websocket-sharp/Net/HttpStatusCode.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpStatusCode.cs b/websocket-sharp/Net/HttpStatusCode.cs index 5abe2283a..782200b70 100644 --- a/websocket-sharp/Net/HttpStatusCode.cs +++ b/websocket-sharp/Net/HttpStatusCode.cs @@ -220,8 +220,8 @@ public enum HttpStatusCode /// BadRequest = 400, /// - /// Equivalent to status code 401. - /// Indicates that the client's request requires user authentication. + /// Equivalent to status code 401. Indicates that the client's request + /// requires user authentication. /// Unauthorized = 401, /// From 017857212238455cf55fa6b6f7c5699f140ca29f Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 6 Aug 2020 21:20:46 +0900 Subject: [PATCH 3134/6294] [Modify] Edit it --- websocket-sharp/Net/HttpStatusCode.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpStatusCode.cs b/websocket-sharp/Net/HttpStatusCode.cs index 782200b70..a5debf084 100644 --- a/websocket-sharp/Net/HttpStatusCode.cs +++ b/websocket-sharp/Net/HttpStatusCode.cs @@ -225,8 +225,8 @@ public enum HttpStatusCode /// Unauthorized = 401, /// - /// Equivalent to status code 402. - /// This status code is reserved for future use. + /// Equivalent to status code 402. This status code is reserved for future + /// use. /// PaymentRequired = 402, /// From 3b1509fcb41a3e706f32999912f5461bfeb64622 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 6 Aug 2020 21:22:01 +0900 Subject: [PATCH 3135/6294] [Modify] Edit it --- websocket-sharp/Net/HttpStatusCode.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpStatusCode.cs b/websocket-sharp/Net/HttpStatusCode.cs index a5debf084..6431c4bdf 100644 --- a/websocket-sharp/Net/HttpStatusCode.cs +++ b/websocket-sharp/Net/HttpStatusCode.cs @@ -230,8 +230,8 @@ public enum HttpStatusCode /// PaymentRequired = 402, /// - /// Equivalent to status code 403. - /// Indicates that the server understood the client's request but is refusing to fulfill it. + /// Equivalent to status code 403. Indicates that the server understood + /// the client's request but is refusing to fulfill it. /// Forbidden = 403, /// From d39dee1a7a2c68d7a470a096a276b61b55cbfea7 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 6 Aug 2020 21:23:04 +0900 Subject: [PATCH 3136/6294] [Modify] Edit it --- websocket-sharp/Net/HttpStatusCode.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpStatusCode.cs b/websocket-sharp/Net/HttpStatusCode.cs index 6431c4bdf..8f8e50f52 100644 --- a/websocket-sharp/Net/HttpStatusCode.cs +++ b/websocket-sharp/Net/HttpStatusCode.cs @@ -235,8 +235,8 @@ public enum HttpStatusCode /// Forbidden = 403, /// - /// Equivalent to status code 404. - /// Indicates that the server hasn't found anything matching the request URI. + /// Equivalent to status code 404. Indicates that the server has not found + /// anything matching the request URI. /// NotFound = 404, /// From ea080409ab108bfa8f2195aeac256dea6ebe60e6 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 6 Aug 2020 21:26:07 +0900 Subject: [PATCH 3137/6294] [Modify] Edit it --- websocket-sharp/Net/HttpStatusCode.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/HttpStatusCode.cs b/websocket-sharp/Net/HttpStatusCode.cs index 8f8e50f52..7e04e9dd6 100644 --- a/websocket-sharp/Net/HttpStatusCode.cs +++ b/websocket-sharp/Net/HttpStatusCode.cs @@ -240,9 +240,9 @@ public enum HttpStatusCode /// NotFound = 404, /// - /// Equivalent to status code 405. - /// Indicates that the method specified in the request line isn't allowed for the resource - /// identified by the request URI. + /// Equivalent to status code 405. Indicates that the method specified + /// in the request line is not allowed for the resource identified by + /// the request URI. /// MethodNotAllowed = 405, /// From 970ff37a54b93f71c39f7eb5bbafb95f7d541b66 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 6 Aug 2020 21:28:37 +0900 Subject: [PATCH 3138/6294] [Modify] Edit it --- websocket-sharp/Net/HttpStatusCode.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/HttpStatusCode.cs b/websocket-sharp/Net/HttpStatusCode.cs index 7e04e9dd6..5b7cbdc84 100644 --- a/websocket-sharp/Net/HttpStatusCode.cs +++ b/websocket-sharp/Net/HttpStatusCode.cs @@ -246,9 +246,9 @@ public enum HttpStatusCode /// MethodNotAllowed = 405, /// - /// Equivalent to status code 406. - /// Indicates that the server doesn't have the appropriate resource to respond to the Accept - /// headers in the client's request. + /// Equivalent to status code 406. Indicates that the server does not + /// have the appropriate resource to respond to the Accept headers in + /// the client's request. /// NotAcceptable = 406, /// From 3948b2beb584d520b4ac313a5cdb45be4fc7d793 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 6 Aug 2020 21:31:27 +0900 Subject: [PATCH 3139/6294] [Modify] Edit it --- websocket-sharp/Net/HttpStatusCode.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpStatusCode.cs b/websocket-sharp/Net/HttpStatusCode.cs index 5b7cbdc84..3d6ccfde9 100644 --- a/websocket-sharp/Net/HttpStatusCode.cs +++ b/websocket-sharp/Net/HttpStatusCode.cs @@ -252,8 +252,8 @@ public enum HttpStatusCode /// NotAcceptable = 406, /// - /// Equivalent to status code 407. - /// Indicates that the client must first authenticate itself with the proxy. + /// Equivalent to status code 407. Indicates that the client must first + /// authenticate itself with the proxy. /// ProxyAuthenticationRequired = 407, /// From 92c570ebb0ee59cfd5694980dc8c016fd9711e08 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 7 Aug 2020 19:40:22 +0900 Subject: [PATCH 3140/6294] [Modify] Edit it --- websocket-sharp/Net/HttpStatusCode.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/HttpStatusCode.cs b/websocket-sharp/Net/HttpStatusCode.cs index 3d6ccfde9..f141fa1b2 100644 --- a/websocket-sharp/Net/HttpStatusCode.cs +++ b/websocket-sharp/Net/HttpStatusCode.cs @@ -257,9 +257,8 @@ public enum HttpStatusCode /// ProxyAuthenticationRequired = 407, /// - /// Equivalent to status code 408. - /// Indicates that the client didn't produce a request within the time that the server was - /// prepared to wait. + /// Equivalent to status code 408. Indicates that the client did not produce + /// a request within the time that the server was prepared to wait. /// RequestTimeout = 408, /// From bd30b3971c2b0ce4af07d9fe5cfc98ebff0ce3af Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 7 Aug 2020 19:41:40 +0900 Subject: [PATCH 3141/6294] [Modify] Edit it --- websocket-sharp/Net/HttpStatusCode.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpStatusCode.cs b/websocket-sharp/Net/HttpStatusCode.cs index f141fa1b2..d59bae347 100644 --- a/websocket-sharp/Net/HttpStatusCode.cs +++ b/websocket-sharp/Net/HttpStatusCode.cs @@ -262,8 +262,8 @@ public enum HttpStatusCode /// RequestTimeout = 408, /// - /// Equivalent to status code 409. - /// Indicates that the client's request couldn't be completed due to a conflict on the server. + /// Equivalent to status code 409. Indicates that the client's request could + /// not be completed due to a conflict on the server. /// Conflict = 409, /// From 4d3be6041f7b8811954e274c3e37b60e811517ed Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 7 Aug 2020 19:42:47 +0900 Subject: [PATCH 3142/6294] [Modify] Edit it --- websocket-sharp/Net/HttpStatusCode.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/HttpStatusCode.cs b/websocket-sharp/Net/HttpStatusCode.cs index d59bae347..6151c131e 100644 --- a/websocket-sharp/Net/HttpStatusCode.cs +++ b/websocket-sharp/Net/HttpStatusCode.cs @@ -267,9 +267,8 @@ public enum HttpStatusCode /// Conflict = 409, /// - /// Equivalent to status code 410. - /// Indicates that the requested resource is no longer available at the server and - /// no forwarding address is known. + /// Equivalent to status code 410. Indicates that the requested resource is + /// no longer available at the server and no forwarding address is known. /// Gone = 410, /// From b3fa762711300b5c2232c841d03beed4ffa1dc43 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 7 Aug 2020 19:44:12 +0900 Subject: [PATCH 3143/6294] [Modify] Edit it --- websocket-sharp/Net/HttpStatusCode.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/HttpStatusCode.cs b/websocket-sharp/Net/HttpStatusCode.cs index 6151c131e..17aa828ba 100644 --- a/websocket-sharp/Net/HttpStatusCode.cs +++ b/websocket-sharp/Net/HttpStatusCode.cs @@ -272,9 +272,8 @@ public enum HttpStatusCode /// Gone = 410, /// - /// Equivalent to status code 411. - /// Indicates that the server refuses to accept the client's request without a defined - /// Content-Length. + /// Equivalent to status code 411. Indicates that the server refuses to + /// accept the client's request without a defined Content-Length. /// LengthRequired = 411, /// From 28d468977b0be1879b484659de1730ef56fc2b0f Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 7 Aug 2020 19:46:17 +0900 Subject: [PATCH 3144/6294] [Modify] Edit it --- websocket-sharp/Net/HttpStatusCode.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/HttpStatusCode.cs b/websocket-sharp/Net/HttpStatusCode.cs index 17aa828ba..46ee9958d 100644 --- a/websocket-sharp/Net/HttpStatusCode.cs +++ b/websocket-sharp/Net/HttpStatusCode.cs @@ -277,9 +277,9 @@ public enum HttpStatusCode /// LengthRequired = 411, /// - /// Equivalent to status code 412. - /// Indicates that the precondition given in one or more of the request headers evaluated to - /// false when it was tested on the server. + /// Equivalent to status code 412. Indicates that the precondition given in + /// one or more of the request headers evaluated to false when it was tested + /// on the server. /// PreconditionFailed = 412, /// From d51bf56c991ba71eca5b5abd364ce9ee0282125e Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 7 Aug 2020 19:48:58 +0900 Subject: [PATCH 3145/6294] [Modify] Edit it --- websocket-sharp/Net/HttpStatusCode.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/HttpStatusCode.cs b/websocket-sharp/Net/HttpStatusCode.cs index 46ee9958d..44f84a0d9 100644 --- a/websocket-sharp/Net/HttpStatusCode.cs +++ b/websocket-sharp/Net/HttpStatusCode.cs @@ -283,9 +283,8 @@ public enum HttpStatusCode /// PreconditionFailed = 412, /// - /// Equivalent to status code 413. - /// Indicates that the entity of the client's request is larger than the server is willing or - /// able to process. + /// Equivalent to status code 413. Indicates that the entity of the client's + /// request is larger than the server is willing or able to process. /// RequestEntityTooLarge = 413, /// From 6ee2cc193fb6195a9e23f3cde671282029fe00cf Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 8 Aug 2020 22:26:20 +0900 Subject: [PATCH 3146/6294] [Modify] Edit it --- websocket-sharp/Net/HttpStatusCode.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpStatusCode.cs b/websocket-sharp/Net/HttpStatusCode.cs index 44f84a0d9..4a370025a 100644 --- a/websocket-sharp/Net/HttpStatusCode.cs +++ b/websocket-sharp/Net/HttpStatusCode.cs @@ -288,8 +288,8 @@ public enum HttpStatusCode /// RequestEntityTooLarge = 413, /// - /// Equivalent to status code 414. - /// Indicates that the request URI is longer than the server is willing to interpret. + /// Equivalent to status code 414. Indicates that the request URI is longer + /// than the server is willing to interpret. /// RequestUriTooLong = 414, /// From 86bb2c1dae23934444a4e42dd574853d810e462f Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 8 Aug 2020 22:28:37 +0900 Subject: [PATCH 3147/6294] [Modify] Edit it --- websocket-sharp/Net/HttpStatusCode.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/HttpStatusCode.cs b/websocket-sharp/Net/HttpStatusCode.cs index 4a370025a..75e220907 100644 --- a/websocket-sharp/Net/HttpStatusCode.cs +++ b/websocket-sharp/Net/HttpStatusCode.cs @@ -293,9 +293,9 @@ public enum HttpStatusCode /// RequestUriTooLong = 414, /// - /// Equivalent to status code 415. - /// Indicates that the entity of the client's request is in a format not supported by - /// the requested resource for the requested method. + /// Equivalent to status code 415. Indicates that the entity of the client's + /// request is in a format not supported by the requested resource for the + /// requested method. /// UnsupportedMediaType = 415, /// From 642b80834c425ff76d417f42d20654d6de0b8f00 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 8 Aug 2020 22:31:23 +0900 Subject: [PATCH 3148/6294] [Modify] Edit it --- websocket-sharp/Net/HttpStatusCode.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/HttpStatusCode.cs b/websocket-sharp/Net/HttpStatusCode.cs index 75e220907..7ca3f285c 100644 --- a/websocket-sharp/Net/HttpStatusCode.cs +++ b/websocket-sharp/Net/HttpStatusCode.cs @@ -299,9 +299,9 @@ public enum HttpStatusCode /// UnsupportedMediaType = 415, /// - /// Equivalent to status code 416. - /// Indicates that none of the range specifier values in a Range request header overlap - /// the current extent of the selected resource. + /// Equivalent to status code 416. Indicates that none of the range + /// specifier values in a Range request header overlap the current + /// extent of the selected resource. /// RequestedRangeNotSatisfiable = 416, /// From 77632bb5f3b572d78116a585912fb837cc7d39b0 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 8 Aug 2020 22:33:07 +0900 Subject: [PATCH 3149/6294] [Modify] Edit it --- websocket-sharp/Net/HttpStatusCode.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/HttpStatusCode.cs b/websocket-sharp/Net/HttpStatusCode.cs index 7ca3f285c..1df3cc8ad 100644 --- a/websocket-sharp/Net/HttpStatusCode.cs +++ b/websocket-sharp/Net/HttpStatusCode.cs @@ -305,9 +305,8 @@ public enum HttpStatusCode /// RequestedRangeNotSatisfiable = 416, /// - /// Equivalent to status code 417. - /// Indicates that the expectation given in an Expect request header couldn't be met by - /// the server. + /// Equivalent to status code 417. Indicates that the expectation given in + /// an Expect request header could not be met by the server. /// ExpectationFailed = 417, /// From cbbdcaaa09f43d65c343f1c0c5b009ef03cc02fc Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 8 Aug 2020 22:36:03 +0900 Subject: [PATCH 3150/6294] [Modify] Edit it --- websocket-sharp/Net/HttpStatusCode.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/HttpStatusCode.cs b/websocket-sharp/Net/HttpStatusCode.cs index 1df3cc8ad..dbdfc763a 100644 --- a/websocket-sharp/Net/HttpStatusCode.cs +++ b/websocket-sharp/Net/HttpStatusCode.cs @@ -310,9 +310,9 @@ public enum HttpStatusCode /// ExpectationFailed = 417, /// - /// Equivalent to status code 500. - /// Indicates that the server encountered an unexpected condition which prevented it from - /// fulfilling the client's request. + /// Equivalent to status code 500. Indicates that the server encountered + /// an unexpected condition which prevented it from fulfilling the client's + /// request. /// InternalServerError = 500, /// From 35b650336e51fdc370750a30f3307ef189f86f4a Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 9 Aug 2020 22:26:30 +0900 Subject: [PATCH 3151/6294] [Modify] Edit it --- websocket-sharp/Net/HttpStatusCode.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/HttpStatusCode.cs b/websocket-sharp/Net/HttpStatusCode.cs index dbdfc763a..cd2fa2333 100644 --- a/websocket-sharp/Net/HttpStatusCode.cs +++ b/websocket-sharp/Net/HttpStatusCode.cs @@ -316,9 +316,8 @@ public enum HttpStatusCode /// InternalServerError = 500, /// - /// Equivalent to status code 501. - /// Indicates that the server doesn't support the functionality required to fulfill the client's - /// request. + /// Equivalent to status code 501. Indicates that the server does not + /// support the functionality required to fulfill the client's request. /// NotImplemented = 501, /// From 5b316b5220d83b9a7ee7cd04c21ffd1c8a223e6f Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 9 Aug 2020 22:27:39 +0900 Subject: [PATCH 3152/6294] [Modify] Edit it --- websocket-sharp/Net/HttpStatusCode.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/HttpStatusCode.cs b/websocket-sharp/Net/HttpStatusCode.cs index cd2fa2333..244905479 100644 --- a/websocket-sharp/Net/HttpStatusCode.cs +++ b/websocket-sharp/Net/HttpStatusCode.cs @@ -321,9 +321,8 @@ public enum HttpStatusCode /// NotImplemented = 501, /// - /// Equivalent to status code 502. - /// Indicates that a gateway or proxy server received an invalid response from the upstream - /// server. + /// Equivalent to status code 502. Indicates that a gateway or proxy server + /// received an invalid response from the upstream server. /// BadGateway = 502, /// From 68b356ad9333c6d1826c573b8533fb594b4340ad Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 9 Aug 2020 22:29:37 +0900 Subject: [PATCH 3153/6294] [Modify] Edit it --- websocket-sharp/Net/HttpStatusCode.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/HttpStatusCode.cs b/websocket-sharp/Net/HttpStatusCode.cs index 244905479..6d4ba7c55 100644 --- a/websocket-sharp/Net/HttpStatusCode.cs +++ b/websocket-sharp/Net/HttpStatusCode.cs @@ -326,9 +326,9 @@ public enum HttpStatusCode /// BadGateway = 502, /// - /// Equivalent to status code 503. - /// Indicates that the server is currently unable to handle the client's request due to - /// a temporary overloading or maintenance of the server. + /// Equivalent to status code 503. Indicates that the server is currently + /// unable to handle the client's request due to a temporary overloading + /// or maintenance of the server. /// ServiceUnavailable = 503, /// From 40d3293c8a68f4b0f7ead5e5bfb22a37f5aa4c28 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 9 Aug 2020 22:31:29 +0900 Subject: [PATCH 3154/6294] [Modify] Edit it --- websocket-sharp/Net/HttpStatusCode.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/HttpStatusCode.cs b/websocket-sharp/Net/HttpStatusCode.cs index 6d4ba7c55..12e4ee714 100644 --- a/websocket-sharp/Net/HttpStatusCode.cs +++ b/websocket-sharp/Net/HttpStatusCode.cs @@ -332,9 +332,9 @@ public enum HttpStatusCode /// ServiceUnavailable = 503, /// - /// Equivalent to status code 504. - /// Indicates that a gateway or proxy server didn't receive a timely response from the upstream - /// server or some other auxiliary server. + /// Equivalent to status code 504. Indicates that a gateway or proxy server + /// did not receive a timely response from the upstream server or some other + /// auxiliary server. /// GatewayTimeout = 504, /// From 7a8177ba2cb13159598adbe102881b5171a67ecb Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 10 Aug 2020 21:28:38 +0900 Subject: [PATCH 3155/6294] [Modify] Edit it --- websocket-sharp/Net/HttpStatusCode.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpStatusCode.cs b/websocket-sharp/Net/HttpStatusCode.cs index 12e4ee714..c8fc78671 100644 --- a/websocket-sharp/Net/HttpStatusCode.cs +++ b/websocket-sharp/Net/HttpStatusCode.cs @@ -338,8 +338,8 @@ public enum HttpStatusCode /// GatewayTimeout = 504, /// - /// Equivalent to status code 505. - /// Indicates that the server doesn't support the HTTP version used in the client's request. + /// Equivalent to status code 505. Indicates that the server does not + /// support the HTTP version used in the client's request. /// HttpVersionNotSupported = 505, } From 87ea112b0dc9db501650a87745c752ca86bb7eac Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 10 Aug 2020 21:41:36 +0900 Subject: [PATCH 3156/6294] [Modify] Edit it --- websocket-sharp/Net/HttpStatusCode.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpStatusCode.cs b/websocket-sharp/Net/HttpStatusCode.cs index c8fc78671..c543cc31b 100644 --- a/websocket-sharp/Net/HttpStatusCode.cs +++ b/websocket-sharp/Net/HttpStatusCode.cs @@ -2,7 +2,7 @@ /* * HttpStatusCode.cs * - * This code is derived from System.Net.HttpStatusCode.cs of Mono + * This code is derived from HttpStatusCode.cs (System.Net) of Mono * (http://www.mono-project.com). * * It was automatically generated from ECMA CLI XML Library Specification. From cacd3658767ff80fbbdb604f0ec8f96f99aa938a Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 11 Aug 2020 21:02:25 +0900 Subject: [PATCH 3157/6294] [Modify] 2020 --- websocket-sharp/Net/HttpStatusCode.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpStatusCode.cs b/websocket-sharp/Net/HttpStatusCode.cs index c543cc31b..b773a4964 100644 --- a/websocket-sharp/Net/HttpStatusCode.cs +++ b/websocket-sharp/Net/HttpStatusCode.cs @@ -14,7 +14,7 @@ * The MIT License * * Copyright (c) 2001 Ximian, Inc. (http://www.ximian.com) - * Copyright (c) 2012-2014 sta.blockhead + * Copyright (c) 2012-2020 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From e605784f6d4a522fe94864cb50f7217e303c58c0 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 12 Aug 2020 21:37:19 +0900 Subject: [PATCH 3158/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerPrefixCollection.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerPrefixCollection.cs b/websocket-sharp/Net/HttpListenerPrefixCollection.cs index 6373b8d65..72c52b368 100644 --- a/websocket-sharp/Net/HttpListenerPrefixCollection.cs +++ b/websocket-sharp/Net/HttpListenerPrefixCollection.cs @@ -50,7 +50,8 @@ namespace WebSocketSharp.Net /// The responds to the request which has a requested URI that /// the prefixes most closely match. /// - public class HttpListenerPrefixCollection : ICollection, IEnumerable, IEnumerable + public class HttpListenerPrefixCollection + : ICollection, IEnumerable, IEnumerable { #region Private Fields From a7e50b47c9d582017303c619b19a0953a6eb9fab Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 13 Aug 2020 21:54:58 +0900 Subject: [PATCH 3159/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerPrefixCollection.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerPrefixCollection.cs b/websocket-sharp/Net/HttpListenerPrefixCollection.cs index 72c52b368..35c30145a 100644 --- a/websocket-sharp/Net/HttpListenerPrefixCollection.cs +++ b/websocket-sharp/Net/HttpListenerPrefixCollection.cs @@ -44,11 +44,12 @@ namespace WebSocketSharp.Net { /// - /// Provides the collection used to store the URI prefixes for the . + /// Provides a collection used to store the URI prefixes for a instance of + /// the class. /// /// - /// The responds to the request which has a requested URI that - /// the prefixes most closely match. + /// The instance responds to the request which has + /// a requested URI that the prefixes most closely match. /// public class HttpListenerPrefixCollection : ICollection, IEnumerable, IEnumerable From 1e48247f8a70986e8fa3112969556c4665936e6d Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 14 Aug 2020 21:57:36 +0900 Subject: [PATCH 3160/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerPrefixCollection.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerPrefixCollection.cs b/websocket-sharp/Net/HttpListenerPrefixCollection.cs index 35c30145a..e0064316f 100644 --- a/websocket-sharp/Net/HttpListenerPrefixCollection.cs +++ b/websocket-sharp/Net/HttpListenerPrefixCollection.cs @@ -86,7 +86,8 @@ public int Count { } /// - /// Gets a value indicating whether the access to the collection is read-only. + /// Gets a value indicating whether the access to the collection is + /// read-only. /// /// /// Always returns false. From 412070f47f30ab6136a8272ebae276a90215aac7 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 14 Aug 2020 22:00:52 +0900 Subject: [PATCH 3161/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerPrefixCollection.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerPrefixCollection.cs b/websocket-sharp/Net/HttpListenerPrefixCollection.cs index e0064316f..e1215ac2f 100644 --- a/websocket-sharp/Net/HttpListenerPrefixCollection.cs +++ b/websocket-sharp/Net/HttpListenerPrefixCollection.cs @@ -99,7 +99,8 @@ public bool IsReadOnly { } /// - /// Gets a value indicating whether the access to the collection is synchronized. + /// Gets a value indicating whether the access to the collection is + /// synchronized. /// /// /// Always returns false. From 41dd8b89d108ad01ef22583fd8314499f573b342 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 15 Aug 2020 22:30:33 +0900 Subject: [PATCH 3162/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerPrefixCollection.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerPrefixCollection.cs b/websocket-sharp/Net/HttpListenerPrefixCollection.cs index e1215ac2f..4c3e038d6 100644 --- a/websocket-sharp/Net/HttpListenerPrefixCollection.cs +++ b/websocket-sharp/Net/HttpListenerPrefixCollection.cs @@ -134,13 +134,18 @@ public bool IsSynchronized { public void Add (string uriPrefix) { _listener.CheckDisposed (); + HttpListenerPrefix.CheckPrefix (uriPrefix); + if (_prefixes.Contains (uriPrefix)) return; _prefixes.Add (uriPrefix); - if (_listener.IsListening) - EndPointManager.AddPrefix (uriPrefix, _listener); + + if (!_listener.IsListening) + return; + + EndPointManager.AddPrefix (uriPrefix, _listener); } /// From a4da7191e4a145c7fbb254af432042aa2a534195 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 16 Aug 2020 22:04:29 +0900 Subject: [PATCH 3163/6294] [Modify] Edit it --- .../Net/HttpListenerPrefixCollection.cs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerPrefixCollection.cs b/websocket-sharp/Net/HttpListenerPrefixCollection.cs index 4c3e038d6..cc70d2ffd 100644 --- a/websocket-sharp/Net/HttpListenerPrefixCollection.cs +++ b/websocket-sharp/Net/HttpListenerPrefixCollection.cs @@ -116,11 +116,16 @@ public bool IsSynchronized { #region Public Methods /// - /// Adds the specified to the collection. + /// Adds the specified URI prefix to the collection. /// /// - /// A that represents the URI prefix to add. The prefix must be - /// a well-formed URI prefix with http or https scheme, and must end with a '/'. + /// + /// A that specifies the URI prefix to add. + /// + /// + /// It must be a well-formed URI prefix with http or https scheme, + /// and must end with a '/'. + /// /// /// /// is . @@ -129,7 +134,8 @@ public bool IsSynchronized { /// is invalid. /// /// - /// The associated with this collection is closed. + /// The instance associated with this collection + /// is closed. /// public void Add (string uriPrefix) { From 94adee0aaf0c482129d3dbb1cc42ea70e22767c5 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 17 Aug 2020 22:09:37 +0900 Subject: [PATCH 3164/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerPrefixCollection.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerPrefixCollection.cs b/websocket-sharp/Net/HttpListenerPrefixCollection.cs index cc70d2ffd..450c29860 100644 --- a/websocket-sharp/Net/HttpListenerPrefixCollection.cs +++ b/websocket-sharp/Net/HttpListenerPrefixCollection.cs @@ -139,9 +139,8 @@ public bool IsSynchronized { /// public void Add (string uriPrefix) { - _listener.CheckDisposed (); - HttpListenerPrefix.CheckPrefix (uriPrefix); + _listener.CheckDisposed (); if (_prefixes.Contains (uriPrefix)) return; From 8c622ba1882c249e741659be7b5e5c4ba267b291 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 17 Aug 2020 22:14:26 +0900 Subject: [PATCH 3165/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerPrefixCollection.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerPrefixCollection.cs b/websocket-sharp/Net/HttpListenerPrefixCollection.cs index 450c29860..6e2b2118a 100644 --- a/websocket-sharp/Net/HttpListenerPrefixCollection.cs +++ b/websocket-sharp/Net/HttpListenerPrefixCollection.cs @@ -163,8 +163,11 @@ public void Clear () { _listener.CheckDisposed (); _prefixes.Clear (); - if (_listener.IsListening) - EndPointManager.RemoveListener (_listener); + + if (!_listener.IsListening) + return; + + EndPointManager.RemoveListener (_listener); } /// From 063aae69b3c18ad32234301ae8977f7d0d6b7e86 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 18 Aug 2020 21:16:20 +0900 Subject: [PATCH 3166/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerPrefixCollection.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerPrefixCollection.cs b/websocket-sharp/Net/HttpListenerPrefixCollection.cs index 6e2b2118a..4a7257045 100644 --- a/websocket-sharp/Net/HttpListenerPrefixCollection.cs +++ b/websocket-sharp/Net/HttpListenerPrefixCollection.cs @@ -157,7 +157,8 @@ public void Add (string uriPrefix) /// Removes all URI prefixes from the collection. /// /// - /// The associated with this collection is closed. + /// The instance associated with this collection + /// is closed. /// public void Clear () { From c8de370195d17fe551b7fd4f741bdf8610babb81 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 18 Aug 2020 21:19:38 +0900 Subject: [PATCH 3167/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerPrefixCollection.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerPrefixCollection.cs b/websocket-sharp/Net/HttpListenerPrefixCollection.cs index 4a7257045..1e5851940 100644 --- a/websocket-sharp/Net/HttpListenerPrefixCollection.cs +++ b/websocket-sharp/Net/HttpListenerPrefixCollection.cs @@ -190,10 +190,11 @@ public void Clear () /// public bool Contains (string uriPrefix) { - _listener.CheckDisposed (); if (uriPrefix == null) throw new ArgumentNullException ("uriPrefix"); + _listener.CheckDisposed (); + return _prefixes.Contains (uriPrefix); } From 1550bfd86dc4cec35a528feee62eea52d84fc73a Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 19 Aug 2020 21:18:21 +0900 Subject: [PATCH 3168/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerPrefixCollection.cs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerPrefixCollection.cs b/websocket-sharp/Net/HttpListenerPrefixCollection.cs index 1e5851940..06fc76fcf 100644 --- a/websocket-sharp/Net/HttpListenerPrefixCollection.cs +++ b/websocket-sharp/Net/HttpListenerPrefixCollection.cs @@ -173,20 +173,21 @@ public void Clear () /// /// Returns a value indicating whether the collection contains the specified - /// . + /// URI prefix. /// /// - /// true if the collection contains ; - /// otherwise, false. + /// true if the collection contains the URI prefix; otherwise, + /// false. /// /// - /// A that represents the URI prefix to test. + /// A that specifies the URI prefix to test. /// /// /// is . /// /// - /// The associated with this collection is closed. + /// The instance associated with this collection + /// is closed. /// public bool Contains (string uriPrefix) { From 355f1cd0cca7a2d78cbeb328bb504d9a266fc818 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 20 Aug 2020 21:50:21 +0900 Subject: [PATCH 3169/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerPrefixCollection.cs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerPrefixCollection.cs b/websocket-sharp/Net/HttpListenerPrefixCollection.cs index 06fc76fcf..096317368 100644 --- a/websocket-sharp/Net/HttpListenerPrefixCollection.cs +++ b/websocket-sharp/Net/HttpListenerPrefixCollection.cs @@ -200,17 +200,19 @@ public bool Contains (string uriPrefix) } /// - /// Copies the contents of the collection to the specified . + /// Copies the contents of the collection to the specified array. /// /// - /// An that receives the URI prefix strings in the collection. + /// An that receives the URI prefix strings in + /// the collection. /// /// - /// An that represents the zero-based index in - /// at which copying begins. + /// An that specifies the zero-based index in + /// the array at which copying begins. /// /// - /// The associated with this collection is closed. + /// The instance associated with + /// this collection is closed. /// public void CopyTo (Array array, int offset) { From 657e80d57c47320812e7791e26b9c464a71862d7 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 20 Aug 2020 21:54:52 +0900 Subject: [PATCH 3170/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerPrefixCollection.cs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerPrefixCollection.cs b/websocket-sharp/Net/HttpListenerPrefixCollection.cs index 096317368..77fc7c074 100644 --- a/websocket-sharp/Net/HttpListenerPrefixCollection.cs +++ b/websocket-sharp/Net/HttpListenerPrefixCollection.cs @@ -221,17 +221,19 @@ public void CopyTo (Array array, int offset) } /// - /// Copies the contents of the collection to the specified array of . + /// Copies the contents of the collection to the specified array of string. /// /// - /// An array of that receives the URI prefix strings in the collection. + /// An array of that receives the URI prefix strings in + /// the collection. /// /// - /// An that represents the zero-based index in - /// at which copying begins. + /// An that represents the zero-based index in + /// the array at which copying begins. /// /// - /// The associated with this collection is closed. + /// The instance associated with + /// this collection is closed. /// public void CopyTo (string[] array, int offset) { From 4aa68d262742b3227a0d1e98f6c91e04f53b5af2 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 21 Aug 2020 22:14:21 +0900 Subject: [PATCH 3171/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerPrefixCollection.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerPrefixCollection.cs b/websocket-sharp/Net/HttpListenerPrefixCollection.cs index 77fc7c074..9339c0da9 100644 --- a/websocket-sharp/Net/HttpListenerPrefixCollection.cs +++ b/websocket-sharp/Net/HttpListenerPrefixCollection.cs @@ -242,11 +242,11 @@ public void CopyTo (string[] array, int offset) } /// - /// Gets the enumerator used to iterate through the . + /// Gets the enumerator that iterates through the collection. /// /// - /// An instance used to iterate - /// through the collection. + /// An + /// instance that can be used to iterate through the collection. /// public IEnumerator GetEnumerator () { From f58b099f1691d47279cfe693bfce79b03003a438 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 22 Aug 2020 22:09:10 +0900 Subject: [PATCH 3172/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerPrefixCollection.cs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerPrefixCollection.cs b/websocket-sharp/Net/HttpListenerPrefixCollection.cs index 9339c0da9..ecc71bcd7 100644 --- a/websocket-sharp/Net/HttpListenerPrefixCollection.cs +++ b/websocket-sharp/Net/HttpListenerPrefixCollection.cs @@ -272,12 +272,19 @@ public IEnumerator GetEnumerator () public bool Remove (string uriPrefix) { _listener.CheckDisposed (); + if (uriPrefix == null) throw new ArgumentNullException ("uriPrefix"); var ret = _prefixes.Remove (uriPrefix); - if (ret && _listener.IsListening) - EndPointManager.RemovePrefix (uriPrefix, _listener); + + if (!ret) + return ret; + + if (!_listener.IsListening) + return ret; + + EndPointManager.RemovePrefix (uriPrefix, _listener); return ret; } From 793149bd441c9e48068bbae8dc7b1eb9adf29377 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 23 Aug 2020 21:33:51 +0900 Subject: [PATCH 3173/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerPrefixCollection.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerPrefixCollection.cs b/websocket-sharp/Net/HttpListenerPrefixCollection.cs index ecc71bcd7..6e8550259 100644 --- a/websocket-sharp/Net/HttpListenerPrefixCollection.cs +++ b/websocket-sharp/Net/HttpListenerPrefixCollection.cs @@ -254,20 +254,21 @@ public IEnumerator GetEnumerator () } /// - /// Removes the specified from the collection. + /// Removes the specified URI prefix from the collection. /// /// - /// true if is successfully found and removed; + /// true if the URI prefix is successfully found and removed; /// otherwise, false. /// /// - /// A that represents the URI prefix to remove. + /// A that specifies the URI prefix to remove. /// /// /// is . /// /// - /// The associated with this collection is closed. + /// The instance associated with this collection + /// is closed. /// public bool Remove (string uriPrefix) { From bfc005466d4769f519050890b9c24ba244ba68f5 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 24 Aug 2020 21:28:28 +0900 Subject: [PATCH 3174/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerPrefixCollection.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerPrefixCollection.cs b/websocket-sharp/Net/HttpListenerPrefixCollection.cs index 6e8550259..eb2be0c4e 100644 --- a/websocket-sharp/Net/HttpListenerPrefixCollection.cs +++ b/websocket-sharp/Net/HttpListenerPrefixCollection.cs @@ -295,10 +295,11 @@ public bool Remove (string uriPrefix) #region Explicit Interface Implementations /// - /// Gets the enumerator used to iterate through the . + /// Gets the enumerator that iterates through the collection. /// /// - /// An instance used to iterate through the collection. + /// An instance that can be used to iterate + /// through the collection. /// IEnumerator IEnumerable.GetEnumerator () { From c4b2b1c88bd581faf443acf00e62f1e43756a863 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 25 Aug 2020 21:17:40 +0900 Subject: [PATCH 3175/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerPrefixCollection.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerPrefixCollection.cs b/websocket-sharp/Net/HttpListenerPrefixCollection.cs index eb2be0c4e..b5b893547 100644 --- a/websocket-sharp/Net/HttpListenerPrefixCollection.cs +++ b/websocket-sharp/Net/HttpListenerPrefixCollection.cs @@ -257,8 +257,8 @@ public IEnumerator GetEnumerator () /// Removes the specified URI prefix from the collection. /// /// - /// true if the URI prefix is successfully found and removed; - /// otherwise, false. + /// true if the URI prefix is successfully removed; otherwise, + /// false. /// /// /// A that specifies the URI prefix to remove. From 946874eb0452f45c2b26b757ff4951ea52142293 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 25 Aug 2020 21:21:20 +0900 Subject: [PATCH 3176/6294] [Modify] Remove it --- .../Net/HttpListenerPrefixCollection.cs | 21 ------------------- 1 file changed, 21 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerPrefixCollection.cs b/websocket-sharp/Net/HttpListenerPrefixCollection.cs index b5b893547..4b47ed3b2 100644 --- a/websocket-sharp/Net/HttpListenerPrefixCollection.cs +++ b/websocket-sharp/Net/HttpListenerPrefixCollection.cs @@ -199,27 +199,6 @@ public bool Contains (string uriPrefix) return _prefixes.Contains (uriPrefix); } - /// - /// Copies the contents of the collection to the specified array. - /// - /// - /// An that receives the URI prefix strings in - /// the collection. - /// - /// - /// An that specifies the zero-based index in - /// the array at which copying begins. - /// - /// - /// The instance associated with - /// this collection is closed. - /// - public void CopyTo (Array array, int offset) - { - _listener.CheckDisposed (); - ((ICollection) _prefixes).CopyTo (array, offset); - } - /// /// Copies the contents of the collection to the specified array of string. /// From b4d46dedeb533a05374f715a30171bc11b69bb21 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 26 Aug 2020 22:02:33 +0900 Subject: [PATCH 3177/6294] [Modify] Edit it --- .../Net/HttpListenerPrefixCollection.cs | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerPrefixCollection.cs b/websocket-sharp/Net/HttpListenerPrefixCollection.cs index 4b47ed3b2..469654cac 100644 --- a/websocket-sharp/Net/HttpListenerPrefixCollection.cs +++ b/websocket-sharp/Net/HttpListenerPrefixCollection.cs @@ -203,13 +203,23 @@ public bool Contains (string uriPrefix) /// Copies the contents of the collection to the specified array of string. /// /// - /// An array of that receives the URI prefix strings in - /// the collection. + /// An array of that specifies the destination of + /// the URI prefix strings copied from the collection. /// /// - /// An that represents the zero-based index in + /// An that specifies the zero-based index in /// the array at which copying begins. /// + /// + /// is . + /// + /// + /// is less than zero. + /// + /// + /// The space from to the end of + /// is not enough to copy to. + /// /// /// The instance associated with /// this collection is closed. From f3a7f1259dc79daf50706111fba156b6de3332ec Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 27 Aug 2020 22:09:20 +0900 Subject: [PATCH 3178/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerPrefixCollection.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerPrefixCollection.cs b/websocket-sharp/Net/HttpListenerPrefixCollection.cs index 469654cac..6510dcd04 100644 --- a/websocket-sharp/Net/HttpListenerPrefixCollection.cs +++ b/websocket-sharp/Net/HttpListenerPrefixCollection.cs @@ -51,8 +51,7 @@ namespace WebSocketSharp.Net /// The instance responds to the request which has /// a requested URI that the prefixes most closely match. /// - public class HttpListenerPrefixCollection - : ICollection, IEnumerable, IEnumerable + public class HttpListenerPrefixCollection : ICollection { #region Private Fields From 0212b9355879abafb4f98930bfb49b2ae6830553 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 28 Aug 2020 22:03:43 +0900 Subject: [PATCH 3179/6294] [Modify] Replace it --- websocket-sharp/Net/HttpListenerPrefixCollection.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerPrefixCollection.cs b/websocket-sharp/Net/HttpListenerPrefixCollection.cs index 6510dcd04..ab0001f84 100644 --- a/websocket-sharp/Net/HttpListenerPrefixCollection.cs +++ b/websocket-sharp/Net/HttpListenerPrefixCollection.cs @@ -138,8 +138,10 @@ public bool IsSynchronized { /// public void Add (string uriPrefix) { + if (_listener.IsDisposed) + throw new ObjectDisposedException (_listener.GetType ().ToString ()); + HttpListenerPrefix.CheckPrefix (uriPrefix); - _listener.CheckDisposed (); if (_prefixes.Contains (uriPrefix)) return; From 4c6bc003419f33b8413318ff05621d9f69c880ab Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 29 Aug 2020 22:32:00 +0900 Subject: [PATCH 3180/6294] [Modify] Replace it --- websocket-sharp/Net/HttpListenerPrefixCollection.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerPrefixCollection.cs b/websocket-sharp/Net/HttpListenerPrefixCollection.cs index ab0001f84..66afe7877 100644 --- a/websocket-sharp/Net/HttpListenerPrefixCollection.cs +++ b/websocket-sharp/Net/HttpListenerPrefixCollection.cs @@ -163,7 +163,9 @@ public void Add (string uriPrefix) /// public void Clear () { - _listener.CheckDisposed (); + if (_listener.IsDisposed) + throw new ObjectDisposedException (_listener.GetType ().ToString ()); + _prefixes.Clear (); if (!_listener.IsListening) From f9be77d0f7c2e139b43bf12521e5fda92555ecaf Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 30 Aug 2020 22:36:35 +0900 Subject: [PATCH 3181/6294] [Modify] Replace it --- websocket-sharp/Net/HttpListenerPrefixCollection.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerPrefixCollection.cs b/websocket-sharp/Net/HttpListenerPrefixCollection.cs index 66afe7877..dcc544760 100644 --- a/websocket-sharp/Net/HttpListenerPrefixCollection.cs +++ b/websocket-sharp/Net/HttpListenerPrefixCollection.cs @@ -194,11 +194,12 @@ public void Clear () /// public bool Contains (string uriPrefix) { + if (_listener.IsDisposed) + throw new ObjectDisposedException (_listener.GetType ().ToString ()); + if (uriPrefix == null) throw new ArgumentNullException ("uriPrefix"); - _listener.CheckDisposed (); - return _prefixes.Contains (uriPrefix); } From 1cbe07b8a0b101203dfc1aa210f20785774f34c9 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 31 Aug 2020 21:00:09 +0900 Subject: [PATCH 3182/6294] [Modify] Replace it --- websocket-sharp/Net/HttpListenerPrefixCollection.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerPrefixCollection.cs b/websocket-sharp/Net/HttpListenerPrefixCollection.cs index dcc544760..6b0bc0c05 100644 --- a/websocket-sharp/Net/HttpListenerPrefixCollection.cs +++ b/websocket-sharp/Net/HttpListenerPrefixCollection.cs @@ -230,7 +230,9 @@ public bool Contains (string uriPrefix) /// public void CopyTo (string[] array, int offset) { - _listener.CheckDisposed (); + if (_listener.IsDisposed) + throw new ObjectDisposedException (_listener.GetType ().ToString ()); + _prefixes.CopyTo (array, offset); } From cf8dcc54ced704bb720ee3730ba9db3ab88c7616 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 1 Sep 2020 22:08:44 +0900 Subject: [PATCH 3183/6294] [Modify] Replace it --- websocket-sharp/Net/HttpListenerPrefixCollection.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerPrefixCollection.cs b/websocket-sharp/Net/HttpListenerPrefixCollection.cs index 6b0bc0c05..14e0012b4 100644 --- a/websocket-sharp/Net/HttpListenerPrefixCollection.cs +++ b/websocket-sharp/Net/HttpListenerPrefixCollection.cs @@ -267,7 +267,8 @@ public IEnumerator GetEnumerator () /// public bool Remove (string uriPrefix) { - _listener.CheckDisposed (); + if (_listener.IsDisposed) + throw new ObjectDisposedException (_listener.GetType ().ToString ()); if (uriPrefix == null) throw new ArgumentNullException ("uriPrefix"); From 537692cc71a9a03a22cd807e395b12b805a36927 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 2 Sep 2020 22:02:54 +0900 Subject: [PATCH 3184/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerPrefixCollection.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerPrefixCollection.cs b/websocket-sharp/Net/HttpListenerPrefixCollection.cs index 14e0012b4..6b27685f0 100644 --- a/websocket-sharp/Net/HttpListenerPrefixCollection.cs +++ b/websocket-sharp/Net/HttpListenerPrefixCollection.cs @@ -262,8 +262,8 @@ public IEnumerator GetEnumerator () /// is . /// /// - /// The instance associated with this collection - /// is closed. + /// The instance associated with this + /// collection is closed. /// public bool Remove (string uriPrefix) { From 37e79ef5cb40abfbcb5022584462338b749c159c Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 2 Sep 2020 22:05:58 +0900 Subject: [PATCH 3185/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerPrefixCollection.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerPrefixCollection.cs b/websocket-sharp/Net/HttpListenerPrefixCollection.cs index 6b27685f0..255314629 100644 --- a/websocket-sharp/Net/HttpListenerPrefixCollection.cs +++ b/websocket-sharp/Net/HttpListenerPrefixCollection.cs @@ -225,8 +225,8 @@ public bool Contains (string uriPrefix) /// is not enough to copy to. /// /// - /// The instance associated with - /// this collection is closed. + /// The instance associated with this + /// collection is closed. /// public void CopyTo (string[] array, int offset) { From 67e42bcbd90a576acc519ae497a84f2570aaf315 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 3 Sep 2020 21:35:16 +0900 Subject: [PATCH 3186/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerPrefixCollection.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerPrefixCollection.cs b/websocket-sharp/Net/HttpListenerPrefixCollection.cs index 255314629..3bdf50637 100644 --- a/websocket-sharp/Net/HttpListenerPrefixCollection.cs +++ b/websocket-sharp/Net/HttpListenerPrefixCollection.cs @@ -175,8 +175,8 @@ public void Clear () } /// - /// Returns a value indicating whether the collection contains the specified - /// URI prefix. + /// Returns a value indicating whether the collection contains the + /// specified URI prefix. /// /// /// true if the collection contains the URI prefix; otherwise, @@ -189,8 +189,8 @@ public void Clear () /// is . /// /// - /// The instance associated with this collection - /// is closed. + /// The instance associated with this + /// collection is closed. /// public bool Contains (string uriPrefix) { From a8995ebf653083365a10d4f3f68c854ce4fec1b3 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 3 Sep 2020 21:37:26 +0900 Subject: [PATCH 3187/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerPrefixCollection.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerPrefixCollection.cs b/websocket-sharp/Net/HttpListenerPrefixCollection.cs index 3bdf50637..b79601198 100644 --- a/websocket-sharp/Net/HttpListenerPrefixCollection.cs +++ b/websocket-sharp/Net/HttpListenerPrefixCollection.cs @@ -158,8 +158,8 @@ public void Add (string uriPrefix) /// Removes all URI prefixes from the collection. /// /// - /// The instance associated with this collection - /// is closed. + /// The instance associated with this + /// collection is closed. /// public void Clear () { From 70852b1267cfff4393563948634f1d1579a9615c Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 3 Sep 2020 21:39:33 +0900 Subject: [PATCH 3188/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerPrefixCollection.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerPrefixCollection.cs b/websocket-sharp/Net/HttpListenerPrefixCollection.cs index b79601198..014ddb1d6 100644 --- a/websocket-sharp/Net/HttpListenerPrefixCollection.cs +++ b/websocket-sharp/Net/HttpListenerPrefixCollection.cs @@ -133,8 +133,8 @@ public bool IsSynchronized { /// is invalid. /// /// - /// The instance associated with this collection - /// is closed. + /// The instance associated with this + /// collection is closed. /// public void Add (string uriPrefix) { From 8573a4eb228c764c5a1d82d0e95ad249160dec36 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 4 Sep 2020 21:55:23 +0900 Subject: [PATCH 3189/6294] [Modify] 2020 --- websocket-sharp/Net/HttpListenerPrefixCollection.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerPrefixCollection.cs b/websocket-sharp/Net/HttpListenerPrefixCollection.cs index 014ddb1d6..53532a1f2 100644 --- a/websocket-sharp/Net/HttpListenerPrefixCollection.cs +++ b/websocket-sharp/Net/HttpListenerPrefixCollection.cs @@ -8,7 +8,7 @@ * The MIT License * * Copyright (c) 2005 Novell, Inc. (http://www.novell.com) - * Copyright (c) 2012-2015 sta.blockhead + * Copyright (c) 2012-2020 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From aecd6ffef54ee36ba78e38987b1448aec30b9281 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 5 Sep 2020 22:14:18 +0900 Subject: [PATCH 3190/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerPrefix.cs | 68 +++++++++++++++++------ 1 file changed, 52 insertions(+), 16 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerPrefix.cs b/websocket-sharp/Net/HttpListenerPrefix.cs index 960d02edf..3c408d9ef 100644 --- a/websocket-sharp/Net/HttpListenerPrefix.cs +++ b/websocket-sharp/Net/HttpListenerPrefix.cs @@ -158,31 +158,67 @@ public static void CheckPrefix (string uriPrefix) throw new ArgumentNullException ("uriPrefix"); var len = uriPrefix.Length; - if (len == 0) - throw new ArgumentException ("An empty string.", "uriPrefix"); - if (!(uriPrefix.StartsWith ("http://") || uriPrefix.StartsWith ("https://"))) - throw new ArgumentException ("The scheme isn't 'http' or 'https'.", "uriPrefix"); + if (len == 0) { + var msg = "An empty string."; + + throw new ArgumentException (msg, "uriPrefix"); + } + + var schm = uriPrefix.StartsWith ("http://") + || uriPrefix.StartsWith ("https://"); + + if (!schm) { + var msg = "The scheme is not 'http' or 'https'."; + + throw new ArgumentException (msg, "uriPrefix"); + } var startHost = uriPrefix.IndexOf (':') + 3; - if (startHost >= len) - throw new ArgumentException ("No host is specified.", "uriPrefix"); - if (uriPrefix[startHost] == ':') - throw new ArgumentException ("No host is specified.", "uriPrefix"); + if (startHost >= len) { + var msg = "No host is specified."; + + throw new ArgumentException (msg, "uriPrefix"); + } + + if (uriPrefix[startHost] == ':') { + var msg = "No host is specified."; + + throw new ArgumentException (msg, "uriPrefix"); + } var root = uriPrefix.IndexOf ('/', startHost, len - startHost); - if (root == startHost) - throw new ArgumentException ("No host is specified.", "uriPrefix"); - if (root == -1 || uriPrefix[len - 1] != '/') - throw new ArgumentException ("Ends without '/'.", "uriPrefix"); + if (root == startHost) { + var msg = "No host is specified."; - if (uriPrefix[root - 1] == ':') - throw new ArgumentException ("No port is specified.", "uriPrefix"); + throw new ArgumentException (msg, "uriPrefix"); + } - if (root == len - 2) - throw new ArgumentException ("No path is specified.", "uriPrefix"); + if (root == -1) { + var msg = "Ends without '/'."; + + throw new ArgumentException (msg, "uriPrefix"); + } + + if (uriPrefix[len - 1] != '/') { + var msg = "Ends without '/'."; + + throw new ArgumentException (msg, "uriPrefix"); + } + + if (uriPrefix[root - 1] == ':') { + var msg = "No port is specified."; + + throw new ArgumentException (msg, "uriPrefix"); + } + + if (root == len - 2) { + var msg = "No path is specified."; + + throw new ArgumentException (msg, "uriPrefix"); + } } /// From 6f56255cca4f36917d2576dca7685d2c0d7d3306 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 6 Sep 2020 21:49:17 +0900 Subject: [PATCH 3191/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerPrefix.cs | 6 ------ 1 file changed, 6 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerPrefix.cs b/websocket-sharp/Net/HttpListenerPrefix.cs index 3c408d9ef..657d05721 100644 --- a/websocket-sharp/Net/HttpListenerPrefix.cs +++ b/websocket-sharp/Net/HttpListenerPrefix.cs @@ -196,12 +196,6 @@ public static void CheckPrefix (string uriPrefix) throw new ArgumentException (msg, "uriPrefix"); } - if (root == -1) { - var msg = "Ends without '/'."; - - throw new ArgumentException (msg, "uriPrefix"); - } - if (uriPrefix[len - 1] != '/') { var msg = "Ends without '/'."; From 8ff8b1d4c487ebc9fd2c2a435b8d9712841ba73d Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 6 Sep 2020 21:53:43 +0900 Subject: [PATCH 3192/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerPrefix.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerPrefix.cs b/websocket-sharp/Net/HttpListenerPrefix.cs index 657d05721..fbc0697f6 100644 --- a/websocket-sharp/Net/HttpListenerPrefix.cs +++ b/websocket-sharp/Net/HttpListenerPrefix.cs @@ -197,7 +197,7 @@ public static void CheckPrefix (string uriPrefix) } if (uriPrefix[len - 1] != '/') { - var msg = "Ends without '/'."; + var msg = "It ends without '/'."; throw new ArgumentException (msg, "uriPrefix"); } From 2bfaa0422cac7018d8f4bea1808c358ccd6b3c3f Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 7 Sep 2020 21:20:25 +0900 Subject: [PATCH 3193/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerPrefix.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerPrefix.cs b/websocket-sharp/Net/HttpListenerPrefix.cs index fbc0697f6..1f166b002 100644 --- a/websocket-sharp/Net/HttpListenerPrefix.cs +++ b/websocket-sharp/Net/HttpListenerPrefix.cs @@ -174,23 +174,23 @@ public static void CheckPrefix (string uriPrefix) throw new ArgumentException (msg, "uriPrefix"); } - var startHost = uriPrefix.IndexOf (':') + 3; + var host = uriPrefix.IndexOf (':') + 3; - if (startHost >= len) { + if (host >= len) { var msg = "No host is specified."; throw new ArgumentException (msg, "uriPrefix"); } - if (uriPrefix[startHost] == ':') { + if (uriPrefix[host] == ':') { var msg = "No host is specified."; throw new ArgumentException (msg, "uriPrefix"); } - var root = uriPrefix.IndexOf ('/', startHost, len - startHost); + var root = uriPrefix.IndexOf ('/', host, len - host); - if (root == startHost) { + if (root == host) { var msg = "No host is specified."; throw new ArgumentException (msg, "uriPrefix"); From d82d95c56f8fb950d4c355cf6338353ed2a0e90f Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 8 Sep 2020 21:32:08 +0900 Subject: [PATCH 3194/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerPrefix.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerPrefix.cs b/websocket-sharp/Net/HttpListenerPrefix.cs index 1f166b002..5a051834b 100644 --- a/websocket-sharp/Net/HttpListenerPrefix.cs +++ b/websocket-sharp/Net/HttpListenerPrefix.cs @@ -175,8 +175,9 @@ public static void CheckPrefix (string uriPrefix) } var host = uriPrefix.IndexOf (':') + 3; + var end = len - 1; - if (host >= len) { + if (host > end) { var msg = "No host is specified."; throw new ArgumentException (msg, "uriPrefix"); @@ -196,7 +197,7 @@ public static void CheckPrefix (string uriPrefix) throw new ArgumentException (msg, "uriPrefix"); } - if (uriPrefix[len - 1] != '/') { + if (uriPrefix[end] != '/') { var msg = "It ends without '/'."; throw new ArgumentException (msg, "uriPrefix"); From 549a9c6d572d4d32e269a3868fdd202af3b85475 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 9 Sep 2020 20:01:32 +0900 Subject: [PATCH 3195/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerPrefix.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerPrefix.cs b/websocket-sharp/Net/HttpListenerPrefix.cs index 5a051834b..1a449048e 100644 --- a/websocket-sharp/Net/HttpListenerPrefix.cs +++ b/websocket-sharp/Net/HttpListenerPrefix.cs @@ -209,7 +209,7 @@ public static void CheckPrefix (string uriPrefix) throw new ArgumentException (msg, "uriPrefix"); } - if (root == len - 2) { + if (root == end - 1) { var msg = "No path is specified."; throw new ArgumentException (msg, "uriPrefix"); From 8014e28c7f25aa9c96c258c762f55ba5bc20712f Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 10 Sep 2020 20:11:10 +0900 Subject: [PATCH 3196/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerPrefix.cs | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerPrefix.cs b/websocket-sharp/Net/HttpListenerPrefix.cs index 1a449048e..82268ddd1 100644 --- a/websocket-sharp/Net/HttpListenerPrefix.cs +++ b/websocket-sharp/Net/HttpListenerPrefix.cs @@ -174,34 +174,29 @@ public static void CheckPrefix (string uriPrefix) throw new ArgumentException (msg, "uriPrefix"); } - var host = uriPrefix.IndexOf (':') + 3; var end = len - 1; - if (host > end) { - var msg = "No host is specified."; + if (uriPrefix[end] != '/') { + var msg = "It ends without '/'."; throw new ArgumentException (msg, "uriPrefix"); } - if (uriPrefix[host] == ':') { + var host = uriPrefix.IndexOf (':') + 3; + + if (host >= end) { var msg = "No host is specified."; throw new ArgumentException (msg, "uriPrefix"); } - var root = uriPrefix.IndexOf ('/', host, len - host); - - if (root == host) { + if (uriPrefix[host] == ':') { var msg = "No host is specified."; throw new ArgumentException (msg, "uriPrefix"); } - if (uriPrefix[end] != '/') { - var msg = "It ends without '/'."; - - throw new ArgumentException (msg, "uriPrefix"); - } + var root = uriPrefix.IndexOf ('/', host, len - host); if (uriPrefix[root - 1] == ':') { var msg = "No port is specified."; From a0cafe5b402d35eee83ae75766c4a46dbead3963 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 11 Sep 2020 20:57:56 +0900 Subject: [PATCH 3197/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerPrefix.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerPrefix.cs b/websocket-sharp/Net/HttpListenerPrefix.cs index 82268ddd1..8c149ca78 100644 --- a/websocket-sharp/Net/HttpListenerPrefix.cs +++ b/websocket-sharp/Net/HttpListenerPrefix.cs @@ -60,14 +60,14 @@ internal sealed class HttpListenerPrefix #region Internal Constructors /// - /// Initializes a new instance of the class with - /// the specified . + /// Initializes a new instance of the class + /// with the specified URI prefix. /// /// /// This constructor must be called after calling the CheckPrefix method. /// /// - /// A that represents the URI prefix. + /// A that specifies the URI prefix. /// internal HttpListenerPrefix (string uriPrefix) { From d3085f0c4b079b1b297d390db72d9083a3a45228 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 12 Sep 2020 22:09:48 +0900 Subject: [PATCH 3198/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerPrefix.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerPrefix.cs b/websocket-sharp/Net/HttpListenerPrefix.cs index 8c149ca78..ee864fd79 100644 --- a/websocket-sharp/Net/HttpListenerPrefix.cs +++ b/websocket-sharp/Net/HttpListenerPrefix.cs @@ -133,6 +133,7 @@ private void parse (string uriPrefix) var root = uriPrefix.IndexOf ('/', startHost + 1, len - startHost - 1); var colon = uriPrefix.LastIndexOf (':', root - 1, root - startHost - 1); + if (uriPrefix[root - 1] != ']' && colon > startHost) { _host = uriPrefix.Substring (startHost, colon - startHost); _port = uriPrefix.Substring (colon + 1, root - colon - 1); @@ -144,8 +145,13 @@ private void parse (string uriPrefix) _path = uriPrefix.Substring (root); - _prefix = - String.Format ("http{0}://{1}:{2}{3}", _secure ? "s" : "", _host, _port, _path); + _prefix = String.Format ( + "http{0}://{1}:{2}{3}", + _secure ? "s" : "", + _host, + _port, + _path + ); } #endregion From c7b746bdaf74b18d9dcbee74432ae9a3c25c2827 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 13 Sep 2020 22:43:37 +0900 Subject: [PATCH 3199/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerPrefix.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerPrefix.cs b/websocket-sharp/Net/HttpListenerPrefix.cs index ee864fd79..809e48868 100644 --- a/websocket-sharp/Net/HttpListenerPrefix.cs +++ b/websocket-sharp/Net/HttpListenerPrefix.cs @@ -129,17 +129,17 @@ private void parse (string uriPrefix) _secure = true; var len = uriPrefix.Length; - var startHost = uriPrefix.IndexOf (':') + 3; - var root = uriPrefix.IndexOf ('/', startHost + 1, len - startHost - 1); + var host = uriPrefix.IndexOf (':') + 3; + var root = uriPrefix.IndexOf ('/', host + 1, len - host - 1); - var colon = uriPrefix.LastIndexOf (':', root - 1, root - startHost - 1); + var colon = uriPrefix.LastIndexOf (':', root - 1, root - host - 1); - if (uriPrefix[root - 1] != ']' && colon > startHost) { - _host = uriPrefix.Substring (startHost, colon - startHost); + if (uriPrefix[root - 1] != ']' && colon > host) { + _host = uriPrefix.Substring (host, colon - host); _port = uriPrefix.Substring (colon + 1, root - colon - 1); } else { - _host = uriPrefix.Substring (startHost, root - startHost); + _host = uriPrefix.Substring (host, root - host); _port = _secure ? "443" : "80"; } From c63dd9a9ccd580ab29f6e84e4486699cf9a64ebc Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 14 Sep 2020 19:49:10 +0900 Subject: [PATCH 3200/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerPrefix.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/websocket-sharp/Net/HttpListenerPrefix.cs b/websocket-sharp/Net/HttpListenerPrefix.cs index 809e48868..3b1ee763e 100644 --- a/websocket-sharp/Net/HttpListenerPrefix.cs +++ b/websocket-sharp/Net/HttpListenerPrefix.cs @@ -204,6 +204,12 @@ public static void CheckPrefix (string uriPrefix) var root = uriPrefix.IndexOf ('/', host, len - host); + if (root == host) { + var msg = "No host is specified."; + + throw new ArgumentException (msg, "uriPrefix"); + } + if (uriPrefix[root - 1] == ':') { var msg = "No port is specified."; From 39e6a29186c352f6d79addca51744031e4500660 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 15 Sep 2020 19:37:14 +0900 Subject: [PATCH 3201/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerPrefix.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Net/HttpListenerPrefix.cs b/websocket-sharp/Net/HttpListenerPrefix.cs index 3b1ee763e..ffe07c17b 100644 --- a/websocket-sharp/Net/HttpListenerPrefix.cs +++ b/websocket-sharp/Net/HttpListenerPrefix.cs @@ -239,6 +239,7 @@ public static void CheckPrefix (string uriPrefix) public override bool Equals (Object obj) { var pref = obj as HttpListenerPrefix; + return pref != null && pref._prefix == _prefix; } From 0238699c17a8f5eb2929920c4c0708171729241c Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 15 Sep 2020 20:01:18 +0900 Subject: [PATCH 3202/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerPrefix.cs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerPrefix.cs b/websocket-sharp/Net/HttpListenerPrefix.cs index ffe07c17b..e1cd8cda4 100644 --- a/websocket-sharp/Net/HttpListenerPrefix.cs +++ b/websocket-sharp/Net/HttpListenerPrefix.cs @@ -224,17 +224,23 @@ public static void CheckPrefix (string uriPrefix) } /// - /// Determines whether this instance and the specified have the same value. + /// Determines whether the current instance is equal to the specified + /// instance. /// /// /// This method will be required to detect duplicates in any collection. /// /// - /// An to compare to this instance. + /// + /// An instance to compare to the current instance. + /// + /// + /// An reference to a instance. + /// /// /// - /// true if is a and - /// its value is the same as this instance; otherwise, false. + /// true if the current instance is equal to ; + /// otherwise, false. /// public override bool Equals (Object obj) { From 7b08d831a2ff7a7e554afc9bfa840ba87bed0f7f Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 16 Sep 2020 20:13:04 +0900 Subject: [PATCH 3203/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerPrefix.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerPrefix.cs b/websocket-sharp/Net/HttpListenerPrefix.cs index e1cd8cda4..117a017ea 100644 --- a/websocket-sharp/Net/HttpListenerPrefix.cs +++ b/websocket-sharp/Net/HttpListenerPrefix.cs @@ -242,7 +242,7 @@ public static void CheckPrefix (string uriPrefix) /// true if the current instance is equal to ; /// otherwise, false. /// - public override bool Equals (Object obj) + public override bool Equals (object obj) { var pref = obj as HttpListenerPrefix; From 4a1689fc763bf3d8b85634569c99e88bb818c2f2 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 16 Sep 2020 20:15:16 +0900 Subject: [PATCH 3204/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerPrefix.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerPrefix.cs b/websocket-sharp/Net/HttpListenerPrefix.cs index 117a017ea..111df15df 100644 --- a/websocket-sharp/Net/HttpListenerPrefix.cs +++ b/websocket-sharp/Net/HttpListenerPrefix.cs @@ -225,14 +225,14 @@ public static void CheckPrefix (string uriPrefix) /// /// Determines whether the current instance is equal to the specified - /// instance. + /// instance. /// /// /// This method will be required to detect duplicates in any collection. /// /// /// - /// An instance to compare to the current instance. + /// An instance to compare to the current instance. /// /// /// An reference to a instance. From 46c37076265e8d1434c9b8c822e96c308dd03705 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 17 Sep 2020 20:04:53 +0900 Subject: [PATCH 3205/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerPrefix.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerPrefix.cs b/websocket-sharp/Net/HttpListenerPrefix.cs index 111df15df..49912dd22 100644 --- a/websocket-sharp/Net/HttpListenerPrefix.cs +++ b/websocket-sharp/Net/HttpListenerPrefix.cs @@ -239,8 +239,8 @@ public static void CheckPrefix (string uriPrefix) /// /// /// - /// true if the current instance is equal to ; - /// otherwise, false. + /// true if the current instance and have + /// the same URI prefix; otherwise, false. /// public override bool Equals (object obj) { From 7d2d067ffb4b8e09a1dbdb9cf7d2607ce64385d5 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 17 Sep 2020 20:09:43 +0900 Subject: [PATCH 3206/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerPrefix.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerPrefix.cs b/websocket-sharp/Net/HttpListenerPrefix.cs index 49912dd22..9b7888f82 100644 --- a/websocket-sharp/Net/HttpListenerPrefix.cs +++ b/websocket-sharp/Net/HttpListenerPrefix.cs @@ -246,7 +246,7 @@ public override bool Equals (object obj) { var pref = obj as HttpListenerPrefix; - return pref != null && pref._prefix == _prefix; + return pref != null && _prefix.Equals (pref._prefix); } /// From 8b13eb52f41f58e6c68e1eed0964393a4da70451 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 18 Sep 2020 19:33:29 +0900 Subject: [PATCH 3207/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerPrefix.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerPrefix.cs b/websocket-sharp/Net/HttpListenerPrefix.cs index 9b7888f82..a8f4f2934 100644 --- a/websocket-sharp/Net/HttpListenerPrefix.cs +++ b/websocket-sharp/Net/HttpListenerPrefix.cs @@ -250,7 +250,7 @@ public override bool Equals (object obj) } /// - /// Gets the hash code for this instance. + /// Gets the hash code for the current instance. /// /// /// This method will be required to detect duplicates in any collection. From b07e3673514171655a58b7301c46515953dfa79b Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 19 Sep 2020 20:33:59 +0900 Subject: [PATCH 3208/6294] [Modify] 2020 --- websocket-sharp/Net/HttpListenerPrefix.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerPrefix.cs b/websocket-sharp/Net/HttpListenerPrefix.cs index a8f4f2934..1efb67d75 100644 --- a/websocket-sharp/Net/HttpListenerPrefix.cs +++ b/websocket-sharp/Net/HttpListenerPrefix.cs @@ -8,7 +8,7 @@ * The MIT License * * Copyright (c) 2005 Novell, Inc. (http://www.novell.com) - * Copyright (c) 2012-2016 sta.blockhead + * Copyright (c) 2012-2020 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From cb824723f07f77762dbfb873226388e3922b9945 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 19 Sep 2020 20:36:18 +0900 Subject: [PATCH 3209/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerPrefix.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerPrefix.cs b/websocket-sharp/Net/HttpListenerPrefix.cs index 1efb67d75..450aefe4d 100644 --- a/websocket-sharp/Net/HttpListenerPrefix.cs +++ b/websocket-sharp/Net/HttpListenerPrefix.cs @@ -146,8 +146,8 @@ private void parse (string uriPrefix) _path = uriPrefix.Substring (root); _prefix = String.Format ( - "http{0}://{1}:{2}{3}", - _secure ? "s" : "", + "{0}://{1}:{2}{3}", + _secure ? "https" : "http", _host, _port, _path From 1bb32309f23ceb86bb37ded3d82d247134b3332a Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 20 Sep 2020 21:43:48 +0900 Subject: [PATCH 3210/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerPrefix.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerPrefix.cs b/websocket-sharp/Net/HttpListenerPrefix.cs index 450aefe4d..7484138ad 100644 --- a/websocket-sharp/Net/HttpListenerPrefix.cs +++ b/websocket-sharp/Net/HttpListenerPrefix.cs @@ -39,7 +39,6 @@ #endregion using System; -using System.Net; namespace WebSocketSharp.Net { From 3a5fc43dbcc8da82bad2356202887bda4ff0f81d Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 21 Sep 2020 21:26:02 +0900 Subject: [PATCH 3211/6294] [Modify] Add it --- websocket-sharp/Net/HttpListenerPrefix.cs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/websocket-sharp/Net/HttpListenerPrefix.cs b/websocket-sharp/Net/HttpListenerPrefix.cs index 7484138ad..a0233d2ab 100644 --- a/websocket-sharp/Net/HttpListenerPrefix.cs +++ b/websocket-sharp/Net/HttpListenerPrefix.cs @@ -74,6 +74,27 @@ internal HttpListenerPrefix (string uriPrefix) parse (uriPrefix); } + /// + /// Initializes a new instance of the class + /// with the specified URI prefix and HTTP listener. + /// + /// + /// This constructor must be called after calling the CheckPrefix method. + /// + /// + /// A that specifies the URI prefix. + /// + /// + /// A that specifies the HTTP listener. + /// + internal HttpListenerPrefix (string uriPrefix, HttpListener listener) + { + _original = uriPrefix; + _listener = listener; + + parse (uriPrefix); + } + #endregion #region Public Properties From d7f4495f81e0ad53b11d098457e8949b7d9f35f0 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 22 Sep 2020 21:21:20 +0900 Subject: [PATCH 3212/6294] [Modify] Add it --- websocket-sharp/Net/EndPointListener.cs | 59 +++++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/websocket-sharp/Net/EndPointListener.cs b/websocket-sharp/Net/EndPointListener.cs index 67fa26393..23d3d802d 100644 --- a/websocket-sharp/Net/EndPointListener.cs +++ b/websocket-sharp/Net/EndPointListener.cs @@ -390,6 +390,65 @@ internal bool TrySearchHttpListener (Uri uri, out HttpListener listener) #region Public Methods + public void AddPrefix (HttpListenerPrefix prefix) + { + List current, future; + + if (prefix.Host == "*") { + do { + current = _unhandled; + future = current != null + ? new List (current) + : new List (); + + addSpecial (future, prefix); + } + while ( + Interlocked.CompareExchange (ref _unhandled, future, current) != current + ); + + return; + } + + if (prefix.Host == "+") { + do { + current = _all; + future = current != null + ? new List (current) + : new List (); + + addSpecial (future, prefix); + } + while ( + Interlocked.CompareExchange (ref _all, future, current) != current + ); + + return; + } + + Dictionary prefs, prefs2; + + do { + prefs = _prefixes; + + if (prefs.ContainsKey (prefix)) { + if (prefs[prefix] != prefix.Listener) { + throw new HttpListenerException ( + 87, String.Format ("There's another listener for {0}.", prefix) + ); + } + + return; + } + + prefs2 = new Dictionary (prefs); + prefs2[prefix] = prefix.Listener; + } + while ( + Interlocked.CompareExchange (ref _prefixes, prefs2, prefs) != prefs + ); + } + public void AddPrefix (HttpListenerPrefix prefix, HttpListener listener) { List current, future; From 8e9cb4ffd5a84b602cf64da610ca6cefd97b2cae Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 23 Sep 2020 20:28:58 +0900 Subject: [PATCH 3213/6294] [Modify] Polish it --- websocket-sharp/Net/EndPointListener.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/EndPointListener.cs b/websocket-sharp/Net/EndPointListener.cs index 23d3d802d..2be87facd 100644 --- a/websocket-sharp/Net/EndPointListener.cs +++ b/websocket-sharp/Net/EndPointListener.cs @@ -433,9 +433,11 @@ public void AddPrefix (HttpListenerPrefix prefix) if (prefs.ContainsKey (prefix)) { if (prefs[prefix] != prefix.Listener) { - throw new HttpListenerException ( - 87, String.Format ("There's another listener for {0}.", prefix) - ); + var msg = String.Format ( + "There is another listener for {0}.", prefix + ); + + throw new HttpListenerException (87, msg); } return; From 71fa2da4b9d932309c0b5ab6a4eb23cd54f80414 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 23 Sep 2020 20:34:51 +0900 Subject: [PATCH 3214/6294] [Modify] Polish it --- websocket-sharp/Net/EndPointListener.cs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/EndPointListener.cs b/websocket-sharp/Net/EndPointListener.cs index 2be87facd..1f34db269 100644 --- a/websocket-sharp/Net/EndPointListener.cs +++ b/websocket-sharp/Net/EndPointListener.cs @@ -153,12 +153,18 @@ public ServerSslConfiguration SslConfiguration { #region Private Methods - private static void addSpecial (List prefixes, HttpListenerPrefix prefix) + private static void addSpecial ( + List prefixes, HttpListenerPrefix prefix + ) { var path = prefix.Path; + foreach (var pref in prefixes) { - if (pref.Path == path) - throw new HttpListenerException (87, "The prefix is already in use."); + if (pref.Path == path) { + var msg = "The prefix is already in use."; + + throw new HttpListenerException (87, msg); + } } prefixes.Add (prefix); From 518ca925265fb1156a4212fae3efd916a742854d Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 24 Sep 2020 20:12:48 +0900 Subject: [PATCH 3215/6294] [Modify] Add it --- websocket-sharp/Net/EndPointListener.cs | 64 +++++++++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/websocket-sharp/Net/EndPointListener.cs b/websocket-sharp/Net/EndPointListener.cs index 1f34db269..7e9c20ff9 100644 --- a/websocket-sharp/Net/EndPointListener.cs +++ b/websocket-sharp/Net/EndPointListener.cs @@ -528,6 +528,70 @@ public void Close () conns[i].Close (true); } + public void RemovePrefix (HttpListenerPrefix prefix) + { + List current, future; + + if (prefix.Host == "*") { + do { + current = _unhandled; + + if (current == null) + break; + + future = new List (current); + + if (!removeSpecial (future, prefix)) + break; + } + while ( + Interlocked.CompareExchange (ref _unhandled, future, current) != current + ); + + leaveIfNoPrefix (); + + return; + } + + if (prefix.Host == "+") { + do { + current = _all; + + if (current == null) + break; + + future = new List (current); + + if (!removeSpecial (future, prefix)) + break; + } + while ( + Interlocked.CompareExchange (ref _all, future, current) != current + ); + + leaveIfNoPrefix (); + + return; + } + + Dictionary prefs, prefs2; + + do { + prefs = _prefixes; + + if (!prefs.ContainsKey (prefix)) + break; + + prefs2 = new Dictionary (prefs); + prefs2.Remove (prefix); + } + while ( + Interlocked.CompareExchange (ref _prefixes, prefs2, prefs) != prefs + ); + + leaveIfNoPrefix (); + } + public void RemovePrefix (HttpListenerPrefix prefix, HttpListener listener) { List current, future; From 24aef191cc3f30d45a153bc980c98bde0f69a8c6 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 25 Sep 2020 20:53:13 +0900 Subject: [PATCH 3216/6294] [Modify] Polish it --- websocket-sharp/Net/EndPointListener.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/EndPointListener.cs b/websocket-sharp/Net/EndPointListener.cs index 7e9c20ff9..75bc7ce32 100644 --- a/websocket-sharp/Net/EndPointListener.cs +++ b/websocket-sharp/Net/EndPointListener.cs @@ -274,13 +274,17 @@ private static void processAccepted (Socket socket, EndPointListener listener) } } - private static bool removeSpecial (List prefixes, HttpListenerPrefix prefix) + private static bool removeSpecial ( + List prefixes, HttpListenerPrefix prefix + ) { var path = prefix.Path; var cnt = prefixes.Count; + for (var i = 0; i < cnt; i++) { if (prefixes[i].Path == path) { prefixes.RemoveAt (i); + return true; } } From 1980b75b26797237a085a98ba3059e8bc277d17c Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 25 Sep 2020 21:04:16 +0900 Subject: [PATCH 3217/6294] [Modify] Replace it --- websocket-sharp/Net/EndPointManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/EndPointManager.cs b/websocket-sharp/Net/EndPointManager.cs index c12349d56..5ad7dfd60 100644 --- a/websocket-sharp/Net/EndPointManager.cs +++ b/websocket-sharp/Net/EndPointManager.cs @@ -171,7 +171,7 @@ private static void removePrefix (string uriPrefix, HttpListener listener) if (lsnr.IsSecure ^ pref.IsSecure) return; - lsnr.RemovePrefix (pref, listener); + lsnr.RemovePrefix (pref); } #endregion From f9e6b1155bb2237fed12a56ddb86b5bbd7363526 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 26 Sep 2020 21:13:45 +0900 Subject: [PATCH 3218/6294] [Modify] Polish it --- websocket-sharp/Net/EndPointManager.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/websocket-sharp/Net/EndPointManager.cs b/websocket-sharp/Net/EndPointManager.cs index 5ad7dfd60..e07761005 100644 --- a/websocket-sharp/Net/EndPointManager.cs +++ b/websocket-sharp/Net/EndPointManager.cs @@ -142,6 +142,7 @@ private static void removePrefix (string uriPrefix, HttpListener listener) var pref = new HttpListenerPrefix (uriPrefix); var addr = convertToIPAddress (pref.Host); + if (addr == null) return; @@ -149,6 +150,7 @@ private static void removePrefix (string uriPrefix, HttpListener listener) return; int port; + if (!Int32.TryParse (pref.Port, out port)) return; @@ -156,6 +158,7 @@ private static void removePrefix (string uriPrefix, HttpListener listener) return; var path = pref.Path; + if (path.IndexOf ('%') != -1) return; @@ -165,6 +168,7 @@ private static void removePrefix (string uriPrefix, HttpListener listener) var endpoint = new IPEndPoint (addr, port); EndPointListener lsnr; + if (!_endpoints.TryGetValue (endpoint, out lsnr)) return; From 40a78fb1ccc8fd877ee9d1d38e0d805c288c0078 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 26 Sep 2020 21:14:48 +0900 Subject: [PATCH 3219/6294] [Modify] Replace it --- websocket-sharp/Net/EndPointManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/EndPointManager.cs b/websocket-sharp/Net/EndPointManager.cs index e07761005..5d804e996 100644 --- a/websocket-sharp/Net/EndPointManager.cs +++ b/websocket-sharp/Net/EndPointManager.cs @@ -139,7 +139,7 @@ private static IPAddress convertToIPAddress (string hostname) private static void removePrefix (string uriPrefix, HttpListener listener) { - var pref = new HttpListenerPrefix (uriPrefix); + var pref = new HttpListenerPrefix (uriPrefix, listener); var addr = convertToIPAddress (pref.Host); From 5bbcac08e0dc518a0bac8442616329ad3f4a3d3a Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 27 Sep 2020 19:38:28 +0900 Subject: [PATCH 3220/6294] [Modify] Polish it --- websocket-sharp/Net/EndPointManager.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Net/EndPointManager.cs b/websocket-sharp/Net/EndPointManager.cs index 5d804e996..1454e7873 100644 --- a/websocket-sharp/Net/EndPointManager.cs +++ b/websocket-sharp/Net/EndPointManager.cs @@ -203,6 +203,7 @@ internal static bool RemoveEndPoint (IPEndPoint endpoint) public static void AddListener (HttpListener listener) { var added = new List (); + lock (((ICollection) _endpoints).SyncRoot) { try { foreach (var pref in listener.Prefixes) { From 430173bf43e22ff89c96b49c43ce4a1147ceb6d0 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 27 Sep 2020 19:40:07 +0900 Subject: [PATCH 3221/6294] [Modify] Polish it --- websocket-sharp/Net/EndPointManager.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Net/EndPointManager.cs b/websocket-sharp/Net/EndPointManager.cs index 1454e7873..d8711f796 100644 --- a/websocket-sharp/Net/EndPointManager.cs +++ b/websocket-sharp/Net/EndPointManager.cs @@ -186,6 +186,7 @@ internal static bool RemoveEndPoint (IPEndPoint endpoint) { lock (((ICollection) _endpoints).SyncRoot) { EndPointListener lsnr; + if (!_endpoints.TryGetValue (endpoint, out lsnr)) return false; From 9ec4a086d33ef0afbdbb5a41bded91687ebc86d2 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 28 Sep 2020 21:49:44 +0900 Subject: [PATCH 3222/6294] [Modify] Remove it --- websocket-sharp/Net/EndPointListener.cs | 49 ------------------------- 1 file changed, 49 deletions(-) diff --git a/websocket-sharp/Net/EndPointListener.cs b/websocket-sharp/Net/EndPointListener.cs index 75bc7ce32..504589727 100644 --- a/websocket-sharp/Net/EndPointListener.cs +++ b/websocket-sharp/Net/EndPointListener.cs @@ -596,55 +596,6 @@ public void RemovePrefix (HttpListenerPrefix prefix) leaveIfNoPrefix (); } - public void RemovePrefix (HttpListenerPrefix prefix, HttpListener listener) - { - List current, future; - if (prefix.Host == "*") { - do { - current = _unhandled; - if (current == null) - break; - - future = new List (current); - if (!removeSpecial (future, prefix)) - break; // The prefix wasn't found. - } - while (Interlocked.CompareExchange (ref _unhandled, future, current) != current); - - leaveIfNoPrefix (); - return; - } - - if (prefix.Host == "+") { - do { - current = _all; - if (current == null) - break; - - future = new List (current); - if (!removeSpecial (future, prefix)) - break; // The prefix wasn't found. - } - while (Interlocked.CompareExchange (ref _all, future, current) != current); - - leaveIfNoPrefix (); - return; - } - - Dictionary prefs, prefs2; - do { - prefs = _prefixes; - if (!prefs.ContainsKey (prefix)) - break; - - prefs2 = new Dictionary (prefs); - prefs2.Remove (prefix); - } - while (Interlocked.CompareExchange (ref _prefixes, prefs2, prefs) != prefs); - - leaveIfNoPrefix (); - } - #endregion } } From 30e576297b0bab57e1c5d92f03c01396421e926e Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 28 Sep 2020 21:58:35 +0900 Subject: [PATCH 3223/6294] [Modify] Polish it --- websocket-sharp/Net/EndPointManager.cs | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/websocket-sharp/Net/EndPointManager.cs b/websocket-sharp/Net/EndPointManager.cs index d8711f796..bcdc63748 100644 --- a/websocket-sharp/Net/EndPointManager.cs +++ b/websocket-sharp/Net/EndPointManager.cs @@ -83,6 +83,7 @@ private static void addPrefix (string uriPrefix, HttpListener listener) var pref = new HttpListenerPrefix (uriPrefix); var addr = convertToIPAddress (pref.Host); + if (addr == null) throw new HttpListenerException (87, "Includes an invalid host."); @@ -90,6 +91,7 @@ private static void addPrefix (string uriPrefix, HttpListener listener) throw new HttpListenerException (87, "Includes an invalid host."); int port; + if (!Int32.TryParse (pref.Port, out port)) throw new HttpListenerException (87, "Includes an invalid port."); @@ -97,6 +99,7 @@ private static void addPrefix (string uriPrefix, HttpListener listener) throw new HttpListenerException (87, "Includes an invalid port."); var path = pref.Path; + if (path.IndexOf ('%') != -1) throw new HttpListenerException (87, "Includes an invalid path."); @@ -106,19 +109,19 @@ private static void addPrefix (string uriPrefix, HttpListener listener) var endpoint = new IPEndPoint (addr, port); EndPointListener lsnr; + if (_endpoints.TryGetValue (endpoint, out lsnr)) { if (lsnr.IsSecure ^ pref.IsSecure) throw new HttpListenerException (87, "Includes an invalid scheme."); } else { - lsnr = - new EndPointListener ( - endpoint, - pref.IsSecure, - listener.CertificateFolderPath, - listener.SslConfiguration, - listener.ReuseAddress - ); + lsnr = new EndPointListener ( + endpoint, + pref.IsSecure, + listener.CertificateFolderPath, + listener.SslConfiguration, + listener.ReuseAddress + ); _endpoints.Add (endpoint, lsnr); } From 59537da25b9e2469856e64b60d3ea286d0977438 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 29 Sep 2020 22:05:39 +0900 Subject: [PATCH 3224/6294] [Modify] Polish it --- websocket-sharp/Net/EndPointManager.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/EndPointManager.cs b/websocket-sharp/Net/EndPointManager.cs index bcdc63748..99d4f6cb9 100644 --- a/websocket-sharp/Net/EndPointManager.cs +++ b/websocket-sharp/Net/EndPointManager.cs @@ -84,8 +84,11 @@ private static void addPrefix (string uriPrefix, HttpListener listener) var addr = convertToIPAddress (pref.Host); - if (addr == null) - throw new HttpListenerException (87, "Includes an invalid host."); + if (addr == null) { + var msg = "The URI prefix includes an invalid host."; + + throw new HttpListenerException (87, msg); + } if (!addr.IsLocal ()) throw new HttpListenerException (87, "Includes an invalid host."); From e15ac24761b9602775f344ff5158736ef7584708 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 30 Sep 2020 19:38:31 +0900 Subject: [PATCH 3225/6294] [Modify] Polish it --- websocket-sharp/Net/EndPointManager.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/EndPointManager.cs b/websocket-sharp/Net/EndPointManager.cs index 99d4f6cb9..cce761691 100644 --- a/websocket-sharp/Net/EndPointManager.cs +++ b/websocket-sharp/Net/EndPointManager.cs @@ -90,8 +90,11 @@ private static void addPrefix (string uriPrefix, HttpListener listener) throw new HttpListenerException (87, msg); } - if (!addr.IsLocal ()) - throw new HttpListenerException (87, "Includes an invalid host."); + if (!addr.IsLocal ()) { + var msg = "The URI prefix includes an invalid host."; + + throw new HttpListenerException (87, msg); + } int port; From 39941992574f375c018355fe40781811c7bc6eae Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 30 Sep 2020 19:41:47 +0900 Subject: [PATCH 3226/6294] [Modify] Polish it --- websocket-sharp/Net/EndPointManager.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/EndPointManager.cs b/websocket-sharp/Net/EndPointManager.cs index cce761691..a2091a51c 100644 --- a/websocket-sharp/Net/EndPointManager.cs +++ b/websocket-sharp/Net/EndPointManager.cs @@ -98,8 +98,11 @@ private static void addPrefix (string uriPrefix, HttpListener listener) int port; - if (!Int32.TryParse (pref.Port, out port)) - throw new HttpListenerException (87, "Includes an invalid port."); + if (!Int32.TryParse (pref.Port, out port)) { + var msg = "The URI prefix includes an invalid port."; + + throw new HttpListenerException (87, msg); + } if (!port.IsPortNumber ()) throw new HttpListenerException (87, "Includes an invalid port."); From e268168e6a7fa81b8ff3f2a7b0825d0e11c3fb8d Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 30 Sep 2020 19:44:57 +0900 Subject: [PATCH 3227/6294] [Modify] Polish it --- websocket-sharp/Net/EndPointManager.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/EndPointManager.cs b/websocket-sharp/Net/EndPointManager.cs index a2091a51c..6929d4260 100644 --- a/websocket-sharp/Net/EndPointManager.cs +++ b/websocket-sharp/Net/EndPointManager.cs @@ -104,8 +104,11 @@ private static void addPrefix (string uriPrefix, HttpListener listener) throw new HttpListenerException (87, msg); } - if (!port.IsPortNumber ()) - throw new HttpListenerException (87, "Includes an invalid port."); + if (!port.IsPortNumber ()) { + var msg = "The URI prefix includes an invalid port."; + + throw new HttpListenerException (87, msg); + } var path = pref.Path; From 2974c5fa22f0d7f2c9d3444cbab76c9340c0638a Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 1 Oct 2020 19:36:19 +0900 Subject: [PATCH 3228/6294] [Modify] Polish it --- websocket-sharp/Net/EndPointManager.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/EndPointManager.cs b/websocket-sharp/Net/EndPointManager.cs index 6929d4260..500a47440 100644 --- a/websocket-sharp/Net/EndPointManager.cs +++ b/websocket-sharp/Net/EndPointManager.cs @@ -112,8 +112,11 @@ private static void addPrefix (string uriPrefix, HttpListener listener) var path = pref.Path; - if (path.IndexOf ('%') != -1) - throw new HttpListenerException (87, "Includes an invalid path."); + if (path.IndexOf ('%') != -1) { + var msg = "The URI prefix includes an invalid path."; + + throw new HttpListenerException (87, msg); + } if (path.IndexOf ("//", StringComparison.Ordinal) != -1) throw new HttpListenerException (87, "Includes an invalid path."); From cad362a75d5b884e28c6f06cb0d7103c53b37074 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 1 Oct 2020 19:38:19 +0900 Subject: [PATCH 3229/6294] [Modify] Polish it --- websocket-sharp/Net/EndPointManager.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/EndPointManager.cs b/websocket-sharp/Net/EndPointManager.cs index 500a47440..bf1153c8f 100644 --- a/websocket-sharp/Net/EndPointManager.cs +++ b/websocket-sharp/Net/EndPointManager.cs @@ -118,8 +118,11 @@ private static void addPrefix (string uriPrefix, HttpListener listener) throw new HttpListenerException (87, msg); } - if (path.IndexOf ("//", StringComparison.Ordinal) != -1) - throw new HttpListenerException (87, "Includes an invalid path."); + if (path.IndexOf ("//", StringComparison.Ordinal) != -1) { + var msg = "The URI prefix includes an invalid path."; + + throw new HttpListenerException (87, msg); + } var endpoint = new IPEndPoint (addr, port); From ba41292a36f4c2716de2d19e9cbb53247b8ec9b2 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 1 Oct 2020 19:41:26 +0900 Subject: [PATCH 3230/6294] [Modify] Polish it --- websocket-sharp/Net/EndPointManager.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/EndPointManager.cs b/websocket-sharp/Net/EndPointManager.cs index bf1153c8f..1fe0aaee0 100644 --- a/websocket-sharp/Net/EndPointManager.cs +++ b/websocket-sharp/Net/EndPointManager.cs @@ -129,8 +129,11 @@ private static void addPrefix (string uriPrefix, HttpListener listener) EndPointListener lsnr; if (_endpoints.TryGetValue (endpoint, out lsnr)) { - if (lsnr.IsSecure ^ pref.IsSecure) - throw new HttpListenerException (87, "Includes an invalid scheme."); + if (lsnr.IsSecure ^ pref.IsSecure) { + var msg = "The URI prefix includes an invalid scheme."; + + throw new HttpListenerException (87, msg); + } } else { lsnr = new EndPointListener ( From b96a12afd357a9efd448862c2ced0d20dd5bb761 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 2 Oct 2020 19:35:18 +0900 Subject: [PATCH 3231/6294] [Modify] Replace it --- websocket-sharp/Net/EndPointManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/EndPointManager.cs b/websocket-sharp/Net/EndPointManager.cs index 1fe0aaee0..5503f7378 100644 --- a/websocket-sharp/Net/EndPointManager.cs +++ b/websocket-sharp/Net/EndPointManager.cs @@ -80,7 +80,7 @@ private EndPointManager () private static void addPrefix (string uriPrefix, HttpListener listener) { - var pref = new HttpListenerPrefix (uriPrefix); + var pref = new HttpListenerPrefix (uriPrefix, listener); var addr = convertToIPAddress (pref.Host); From a2ae6dc1097fd58abd3c74b89d359c11252b1b72 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 2 Oct 2020 19:36:21 +0900 Subject: [PATCH 3232/6294] [Modify] Replace it --- websocket-sharp/Net/EndPointManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/EndPointManager.cs b/websocket-sharp/Net/EndPointManager.cs index 5503f7378..18b23bf7e 100644 --- a/websocket-sharp/Net/EndPointManager.cs +++ b/websocket-sharp/Net/EndPointManager.cs @@ -147,7 +147,7 @@ private static void addPrefix (string uriPrefix, HttpListener listener) _endpoints.Add (endpoint, lsnr); } - lsnr.AddPrefix (pref, listener); + lsnr.AddPrefix (pref); } private static IPAddress convertToIPAddress (string hostname) From d06a902a3172d0aab8f7853041ebb06604cf1257 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 3 Oct 2020 21:21:26 +0900 Subject: [PATCH 3233/6294] [Modify] Remove it --- websocket-sharp/Net/EndPointListener.cs | 52 ------------------------- 1 file changed, 52 deletions(-) diff --git a/websocket-sharp/Net/EndPointListener.cs b/websocket-sharp/Net/EndPointListener.cs index 504589727..770f131e7 100644 --- a/websocket-sharp/Net/EndPointListener.cs +++ b/websocket-sharp/Net/EndPointListener.cs @@ -461,58 +461,6 @@ public void AddPrefix (HttpListenerPrefix prefix) ); } - public void AddPrefix (HttpListenerPrefix prefix, HttpListener listener) - { - List current, future; - if (prefix.Host == "*") { - do { - current = _unhandled; - future = current != null - ? new List (current) - : new List (); - - prefix.Listener = listener; - addSpecial (future, prefix); - } - while (Interlocked.CompareExchange (ref _unhandled, future, current) != current); - - return; - } - - if (prefix.Host == "+") { - do { - current = _all; - future = current != null - ? new List (current) - : new List (); - - prefix.Listener = listener; - addSpecial (future, prefix); - } - while (Interlocked.CompareExchange (ref _all, future, current) != current); - - return; - } - - Dictionary prefs, prefs2; - do { - prefs = _prefixes; - if (prefs.ContainsKey (prefix)) { - if (prefs[prefix] != listener) { - throw new HttpListenerException ( - 87, String.Format ("There's another listener for {0}.", prefix) - ); - } - - return; - } - - prefs2 = new Dictionary (prefs); - prefs2[prefix] = listener; - } - while (Interlocked.CompareExchange (ref _prefixes, prefs2, prefs) != prefs); - } - public void Close () { _socket.Close (); From f200cbabbf8d5db99bc370b45f89d5eaa9773bb6 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 3 Oct 2020 21:22:38 +0900 Subject: [PATCH 3234/6294] [Modify] Remove it --- websocket-sharp/Net/HttpListenerPrefix.cs | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerPrefix.cs b/websocket-sharp/Net/HttpListenerPrefix.cs index a0233d2ab..d66de982a 100644 --- a/websocket-sharp/Net/HttpListenerPrefix.cs +++ b/websocket-sharp/Net/HttpListenerPrefix.cs @@ -58,22 +58,6 @@ internal sealed class HttpListenerPrefix #region Internal Constructors - /// - /// Initializes a new instance of the class - /// with the specified URI prefix. - /// - /// - /// This constructor must be called after calling the CheckPrefix method. - /// - /// - /// A that specifies the URI prefix. - /// - internal HttpListenerPrefix (string uriPrefix) - { - _original = uriPrefix; - parse (uriPrefix); - } - /// /// Initializes a new instance of the class /// with the specified URI prefix and HTTP listener. From 69582c3095d7febc6ac5f8251897d8eb1f1c2885 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 4 Oct 2020 20:51:08 +0900 Subject: [PATCH 3235/6294] [Modify] Remove it --- websocket-sharp/Net/HttpListenerPrefix.cs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerPrefix.cs b/websocket-sharp/Net/HttpListenerPrefix.cs index d66de982a..3c9b0f8ae 100644 --- a/websocket-sharp/Net/HttpListenerPrefix.cs +++ b/websocket-sharp/Net/HttpListenerPrefix.cs @@ -99,10 +99,6 @@ public HttpListener Listener { get { return _listener; } - - set { - _listener = value; - } } public string Original { From 09e33b2c3376392d560b3deefc81b37123340872 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 5 Oct 2020 14:54:12 +0900 Subject: [PATCH 3236/6294] [Modify] 2020 --- websocket-sharp/Net/EndPointManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/EndPointManager.cs b/websocket-sharp/Net/EndPointManager.cs index 18b23bf7e..166f11640 100644 --- a/websocket-sharp/Net/EndPointManager.cs +++ b/websocket-sharp/Net/EndPointManager.cs @@ -8,7 +8,7 @@ * The MIT License * * Copyright (c) 2005 Novell, Inc. (http://www.novell.com) - * Copyright (c) 2012-2016 sta.blockhead + * Copyright (c) 2012-2020 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From c0815b2781f145ed21d72355c00fdf0f4b7bfd73 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 6 Oct 2020 17:57:14 +0900 Subject: [PATCH 3237/6294] [Fix] Clear after calling the EndPointManager.RemoveListener method --- websocket-sharp/Net/HttpListenerPrefixCollection.cs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerPrefixCollection.cs b/websocket-sharp/Net/HttpListenerPrefixCollection.cs index 53532a1f2..9d2416330 100644 --- a/websocket-sharp/Net/HttpListenerPrefixCollection.cs +++ b/websocket-sharp/Net/HttpListenerPrefixCollection.cs @@ -166,12 +166,10 @@ public void Clear () if (_listener.IsDisposed) throw new ObjectDisposedException (_listener.GetType ().ToString ()); - _prefixes.Clear (); + if (_listener.IsListening) + EndPointManager.RemoveListener (_listener); - if (!_listener.IsListening) - return; - - EndPointManager.RemoveListener (_listener); + _prefixes.Clear (); } /// From 204fd79dfc96025a708145393eedd80ebad08004 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 7 Oct 2020 19:40:01 +0900 Subject: [PATCH 3238/6294] [Modify] Polish it --- .../Net/HttpListenerPrefixCollection.cs | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerPrefixCollection.cs b/websocket-sharp/Net/HttpListenerPrefixCollection.cs index 9d2416330..42bc55a07 100644 --- a/websocket-sharp/Net/HttpListenerPrefixCollection.cs +++ b/websocket-sharp/Net/HttpListenerPrefixCollection.cs @@ -271,17 +271,13 @@ public bool Remove (string uriPrefix) if (uriPrefix == null) throw new ArgumentNullException ("uriPrefix"); - var ret = _prefixes.Remove (uriPrefix); - - if (!ret) - return ret; - - if (!_listener.IsListening) - return ret; + if (!_prefixes.Contains (uriPrefix)) + return false; - EndPointManager.RemovePrefix (uriPrefix, _listener); + if (_listener.IsListening) + EndPointManager.RemovePrefix (uriPrefix, _listener); - return ret; + return _prefixes.Remove (uriPrefix); } #endregion From 04fe7d5ad11139db0238a1dfe85d74ac7d5d2889 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 7 Oct 2020 19:50:22 +0900 Subject: [PATCH 3239/6294] [Modify] Polish it --- websocket-sharp/Net/EndPointListener.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/websocket-sharp/Net/EndPointListener.cs b/websocket-sharp/Net/EndPointListener.cs index 770f131e7..2f9889496 100644 --- a/websocket-sharp/Net/EndPointListener.cs +++ b/websocket-sharp/Net/EndPointListener.cs @@ -213,10 +213,12 @@ private void leaveIfNoPrefix () return; var prefs = _unhandled; + if (prefs != null && prefs.Count > 0) return; prefs = _all; + if (prefs != null && prefs.Count > 0) return; From 6c3706602c9322e5999978b322e9b7d90435f66f Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 8 Oct 2020 19:36:47 +0900 Subject: [PATCH 3240/6294] [Modify] Polish it --- websocket-sharp/Net/EndPointListener.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/websocket-sharp/Net/EndPointListener.cs b/websocket-sharp/Net/EndPointListener.cs index 2f9889496..048d8ad11 100644 --- a/websocket-sharp/Net/EndPointListener.cs +++ b/websocket-sharp/Net/EndPointListener.cs @@ -468,12 +468,14 @@ public void Close () _socket.Close (); HttpConnection[] conns = null; + lock (_unregisteredSync) { if (_unregistered.Count == 0) return; var keys = _unregistered.Keys; conns = new HttpConnection[keys.Count]; + keys.CopyTo (conns, 0); _unregistered.Clear (); } From 2ba4ff2b8eaae29d0728b3f35cbb36cbb64f15a5 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 9 Oct 2020 22:10:42 +0900 Subject: [PATCH 3241/6294] [Modify] Polish it --- websocket-sharp/Net/EndPointManager.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/websocket-sharp/Net/EndPointManager.cs b/websocket-sharp/Net/EndPointManager.cs index 166f11640..37f34f9c9 100644 --- a/websocket-sharp/Net/EndPointManager.cs +++ b/websocket-sharp/Net/EndPointManager.cs @@ -214,10 +214,9 @@ internal static bool RemoveEndPoint (IPEndPoint endpoint) if (!_endpoints.TryGetValue (endpoint, out lsnr)) return false; - _endpoints.Remove (endpoint); lsnr.Close (); - return true; + return _endpoints.Remove (endpoint); } } From ad495cc60b29abbf0564c3ec362c1f1f471cb968 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 10 Oct 2020 17:47:01 +0900 Subject: [PATCH 3242/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerPrefixCollection.cs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerPrefixCollection.cs b/websocket-sharp/Net/HttpListenerPrefixCollection.cs index 42bc55a07..765213de0 100644 --- a/websocket-sharp/Net/HttpListenerPrefixCollection.cs +++ b/websocket-sharp/Net/HttpListenerPrefixCollection.cs @@ -146,12 +146,10 @@ public void Add (string uriPrefix) if (_prefixes.Contains (uriPrefix)) return; - _prefixes.Add (uriPrefix); - - if (!_listener.IsListening) - return; + if (_listener.IsListening) + EndPointManager.AddPrefix (uriPrefix, _listener); - EndPointManager.AddPrefix (uriPrefix, _listener); + _prefixes.Add (uriPrefix); } /// From 2a3bcdf5250aa54b2b0c994cafcafa244d7e44e0 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 11 Oct 2020 17:32:47 +0900 Subject: [PATCH 3243/6294] [Modify] Polish it --- websocket-sharp/Net/EndPointListener.cs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/EndPointListener.cs b/websocket-sharp/Net/EndPointListener.cs index 048d8ad11..a3216e281 100644 --- a/websocket-sharp/Net/EndPointListener.cs +++ b/websocket-sharp/Net/EndPointListener.cs @@ -356,19 +356,24 @@ internal bool TrySearchHttpListener (Uri uri, out HttpListener listener) if (host != null && host.Length > 0) { var bestLen = -1; + foreach (var pref in _prefixes.Keys) { if (dns) { var prefHost = pref.Host; - if (Uri.CheckHostName (prefHost) == UriHostNameType.Dns && prefHost != host) - continue; + var prefDns = Uri.CheckHostName (prefHost) == UriHostNameType.Dns; + + if (prefDns) { + if (prefHost != host) + continue; + } } if (pref.Port != port) continue; var prefPath = pref.Path; - var len = prefPath.Length; + if (len < bestLen) continue; @@ -384,6 +389,7 @@ internal bool TrySearchHttpListener (Uri uri, out HttpListener listener) var prefs = _unhandled; listener = searchHttpListenerFromSpecial (path, prefs); + if (listener == null && pathSlash != path) listener = searchHttpListenerFromSpecial (pathSlash, prefs); @@ -392,6 +398,7 @@ internal bool TrySearchHttpListener (Uri uri, out HttpListener listener) prefs = _all; listener = searchHttpListenerFromSpecial (path, prefs); + if (listener == null && pathSlash != path) listener = searchHttpListenerFromSpecial (pathSlash, prefs); From 2c2e772e9516f2e292b0931438007f0ecfb70392 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 12 Oct 2020 21:35:21 +0900 Subject: [PATCH 3244/6294] [Modify] Polish it --- websocket-sharp/Net/EndPointListener.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/EndPointListener.cs b/websocket-sharp/Net/EndPointListener.cs index a3216e281..366d25dc7 100644 --- a/websocket-sharp/Net/EndPointListener.cs +++ b/websocket-sharp/Net/EndPointListener.cs @@ -301,23 +301,24 @@ private static HttpListener searchHttpListenerFromSpecial ( if (prefixes == null) return null; - HttpListener bestMatch = null; + HttpListener ret = null; var bestLen = -1; + foreach (var pref in prefixes) { var prefPath = pref.Path; - var len = prefPath.Length; + if (len < bestLen) continue; if (path.StartsWith (prefPath)) { bestLen = len; - bestMatch = pref.Listener; + ret = pref.Listener; } } - return bestMatch; + return ret; } #endregion From 578f394de4257bd9f3e9949e57e6e953a75598d5 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 12 Oct 2020 21:37:19 +0900 Subject: [PATCH 3245/6294] [Modify] Polish it --- websocket-sharp/Net/EndPointListener.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/EndPointListener.cs b/websocket-sharp/Net/EndPointListener.cs index 366d25dc7..a60cc1ce1 100644 --- a/websocket-sharp/Net/EndPointListener.cs +++ b/websocket-sharp/Net/EndPointListener.cs @@ -380,7 +380,7 @@ internal bool TrySearchHttpListener (Uri uri, out HttpListener listener) if (path.StartsWith (prefPath) || pathSlash.StartsWith (prefPath)) { bestLen = len; - listener = _prefixes[pref]; + listener = pref.Listener; } } From c29d31492d34e11f573a0d84001b0bbc1eebc31f Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 13 Oct 2020 19:39:38 +0900 Subject: [PATCH 3246/6294] [Modify] Polish it --- websocket-sharp/Net/EndPointListener.cs | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/websocket-sharp/Net/EndPointListener.cs b/websocket-sharp/Net/EndPointListener.cs index a60cc1ce1..cb719c5da 100644 --- a/websocket-sharp/Net/EndPointListener.cs +++ b/websocket-sharp/Net/EndPointListener.cs @@ -353,7 +353,9 @@ internal bool TrySearchHttpListener (Uri uri, out HttpListener listener) var dns = Uri.CheckHostName (host) == UriHostNameType.Dns; var port = uri.Port.ToString (); var path = HttpUtility.UrlDecode (uri.AbsolutePath); - var pathSlash = path[path.Length - 1] != '/' ? path + "/" : path; + + if (path[path.Length - 1] != '/') + path += "/"; if (host != null && host.Length > 0) { var bestLen = -1; @@ -378,7 +380,7 @@ internal bool TrySearchHttpListener (Uri uri, out HttpListener listener) if (len < bestLen) continue; - if (path.StartsWith (prefPath) || pathSlash.StartsWith (prefPath)) { + if (path.StartsWith (prefPath)) { bestLen = len; listener = pref.Listener; } @@ -391,18 +393,12 @@ internal bool TrySearchHttpListener (Uri uri, out HttpListener listener) var prefs = _unhandled; listener = searchHttpListenerFromSpecial (path, prefs); - if (listener == null && pathSlash != path) - listener = searchHttpListenerFromSpecial (pathSlash, prefs); - if (listener != null) return true; prefs = _all; listener = searchHttpListenerFromSpecial (path, prefs); - if (listener == null && pathSlash != path) - listener = searchHttpListenerFromSpecial (pathSlash, prefs); - return listener != null; } From 293cef6ae4d6703ad1f7d9899eeb1e172794a2d3 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 13 Oct 2020 19:43:01 +0900 Subject: [PATCH 3247/6294] [Modify] Polish it --- websocket-sharp/Net/EndPointListener.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/EndPointListener.cs b/websocket-sharp/Net/EndPointListener.cs index cb719c5da..c9711ebb1 100644 --- a/websocket-sharp/Net/EndPointListener.cs +++ b/websocket-sharp/Net/EndPointListener.cs @@ -390,14 +390,12 @@ internal bool TrySearchHttpListener (Uri uri, out HttpListener listener) return true; } - var prefs = _unhandled; - listener = searchHttpListenerFromSpecial (path, prefs); + listener = searchHttpListenerFromSpecial (path, _unhandled); if (listener != null) return true; - prefs = _all; - listener = searchHttpListenerFromSpecial (path, prefs); + listener = searchHttpListenerFromSpecial (path, _all); return listener != null; } From a091ddd2c016a00158e41e47b0f4f88a2a0c7579 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 14 Oct 2020 19:58:15 +0900 Subject: [PATCH 3248/6294] [Modify] Replace it --- websocket-sharp/Net/EndPointListener.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/EndPointListener.cs b/websocket-sharp/Net/EndPointListener.cs index c9711ebb1..d7ba2af9e 100644 --- a/websocket-sharp/Net/EndPointListener.cs +++ b/websocket-sharp/Net/EndPointListener.cs @@ -380,7 +380,7 @@ internal bool TrySearchHttpListener (Uri uri, out HttpListener listener) if (len < bestLen) continue; - if (path.StartsWith (prefPath)) { + if (path.StartsWith (prefPath, StringComparison.Ordinal)) { bestLen = len; listener = pref.Listener; } From 94ca3ee723e9ec6dfecf7c6f473460f2ffada787 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 14 Oct 2020 20:00:03 +0900 Subject: [PATCH 3249/6294] [Modify] Replace it --- websocket-sharp/Net/EndPointListener.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/EndPointListener.cs b/websocket-sharp/Net/EndPointListener.cs index d7ba2af9e..088057f95 100644 --- a/websocket-sharp/Net/EndPointListener.cs +++ b/websocket-sharp/Net/EndPointListener.cs @@ -312,7 +312,7 @@ private static HttpListener searchHttpListenerFromSpecial ( if (len < bestLen) continue; - if (path.StartsWith (prefPath)) { + if (path.StartsWith (prefPath, StringComparison.Ordinal)) { bestLen = len; ret = pref.Listener; } From 067f2cd4f9e00c6ebcbc62aff4fc06ea70d4c01c Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 15 Oct 2020 20:03:14 +0900 Subject: [PATCH 3250/6294] [Modify] Move them --- websocket-sharp/Net/EndPointListener.cs | 4 +++- websocket-sharp/Net/EndPointManager.cs | 10 +--------- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/websocket-sharp/Net/EndPointListener.cs b/websocket-sharp/Net/EndPointListener.cs index 088057f95..8e8b2a968 100644 --- a/websocket-sharp/Net/EndPointListener.cs +++ b/websocket-sharp/Net/EndPointListener.cs @@ -222,7 +222,7 @@ private void leaveIfNoPrefix () if (prefs != null && prefs.Count > 0) return; - EndPointManager.RemoveEndPoint (_endpoint); + Close (); } private static void onAccept (IAsyncResult asyncResult) @@ -484,6 +484,8 @@ public void Close () for (var i = conns.Length - 1; i >= 0; i--) conns[i].Close (true); + + EndPointManager.RemoveEndPoint (_endpoint); } public void RemovePrefix (HttpListenerPrefix prefix) diff --git a/websocket-sharp/Net/EndPointManager.cs b/websocket-sharp/Net/EndPointManager.cs index 37f34f9c9..ac4582b24 100644 --- a/websocket-sharp/Net/EndPointManager.cs +++ b/websocket-sharp/Net/EndPointManager.cs @@ -208,16 +208,8 @@ private static void removePrefix (string uriPrefix, HttpListener listener) internal static bool RemoveEndPoint (IPEndPoint endpoint) { - lock (((ICollection) _endpoints).SyncRoot) { - EndPointListener lsnr; - - if (!_endpoints.TryGetValue (endpoint, out lsnr)) - return false; - - lsnr.Close (); - + lock (((ICollection) _endpoints).SyncRoot) return _endpoints.Remove (endpoint); - } } #endregion From 34ef69cd2c4f935e4648b78eb6ac47125e62a9b6 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 16 Oct 2020 19:38:33 +0900 Subject: [PATCH 3251/6294] [Modify] Polish it --- websocket-sharp/Net/EndPointListener.cs | 34 ++++++++++++++++++------- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/websocket-sharp/Net/EndPointListener.cs b/websocket-sharp/Net/EndPointListener.cs index 8e8b2a968..1b88a8e58 100644 --- a/websocket-sharp/Net/EndPointListener.cs +++ b/websocket-sharp/Net/EndPointListener.cs @@ -94,27 +94,43 @@ internal EndPointListener ( bool reuseAddress ) { + _endpoint = endpoint; + if (secure) { - var cert = - getCertificate (endpoint.Port, certificateFolderPath, sslConfig.ServerCertificate); + var cert = getCertificate ( + endpoint.Port, + certificateFolderPath, + sslConfig.ServerCertificate + ); - if (cert == null) - throw new ArgumentException ("No server certificate could be found."); + if (cert == null) { + var msg = "No server certificate could be found."; + + throw new ArgumentException (msg); + } _secure = true; _sslConfig = new ServerSslConfiguration (sslConfig); _sslConfig.ServerCertificate = cert; } - _endpoint = endpoint; _prefixes = new Dictionary (); _unregistered = new Dictionary (); _unregisteredSync = ((ICollection) _unregistered).SyncRoot; - _socket = - new Socket (endpoint.Address.AddressFamily, SocketType.Stream, ProtocolType.Tcp); - if (reuseAddress) - _socket.SetSocketOption (SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true); + _socket = new Socket ( + endpoint.Address.AddressFamily, + SocketType.Stream, + ProtocolType.Tcp + ); + + if (reuseAddress) { + _socket.SetSocketOption ( + SocketOptionLevel.Socket, + SocketOptionName.ReuseAddress, + true + ); + } _socket.Bind (endpoint); _socket.Listen (500); From 4ce742e1b921d236bbbcbd874b73520885895a97 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 16 Oct 2020 19:46:29 +0900 Subject: [PATCH 3252/6294] [Modify] Polish it --- websocket-sharp/Net/EndPointListener.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Net/EndPointListener.cs b/websocket-sharp/Net/EndPointListener.cs index 1b88a8e58..8d28eacca 100644 --- a/websocket-sharp/Net/EndPointListener.cs +++ b/websocket-sharp/Net/EndPointListener.cs @@ -210,6 +210,7 @@ private static X509Certificate2 getCertificate ( try { var cer = Path.Combine (folderPath, String.Format ("{0}.cer", port)); var key = Path.Combine (folderPath, String.Format ("{0}.key", port)); + if (File.Exists (cer) && File.Exists (key)) { var cert = new X509Certificate2 (cer); cert.PrivateKey = createRSAFromFile (key); From ff8311511b89decb95442986ce994803430765a1 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 17 Oct 2020 17:12:20 +0900 Subject: [PATCH 3253/6294] [Modify] Replace it --- websocket-sharp/Net/EndPointListener.cs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Net/EndPointListener.cs b/websocket-sharp/Net/EndPointListener.cs index 8d28eacca..a3094b3ca 100644 --- a/websocket-sharp/Net/EndPointListener.cs +++ b/websocket-sharp/Net/EndPointListener.cs @@ -188,13 +188,9 @@ private static void addSpecial ( private static RSACryptoServiceProvider createRSAFromFile (string filename) { - byte[] pvk = null; - using (var fs = File.Open (filename, FileMode.Open, FileAccess.Read, FileShare.Read)) { - pvk = new byte[fs.Length]; - fs.Read (pvk, 0, pvk.Length); - } - var rsa = new RSACryptoServiceProvider (); + + var pvk = File.ReadAllBytes (filename); rsa.ImportCspBlob (pvk); return rsa; From 8f0cdb0bb7738460f7ba9a16686be92e4a534d16 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 18 Oct 2020 16:13:22 +0900 Subject: [PATCH 3254/6294] [Modify] Polish it --- websocket-sharp/Net/EndPointListener.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/EndPointListener.cs b/websocket-sharp/Net/EndPointListener.cs index a3094b3ca..8e1bb5221 100644 --- a/websocket-sharp/Net/EndPointListener.cs +++ b/websocket-sharp/Net/EndPointListener.cs @@ -243,11 +243,12 @@ private static void onAccept (IAsyncResult asyncResult) var lsnr = (EndPointListener) asyncResult.AsyncState; Socket sock = null; + try { sock = lsnr._socket.EndAccept (asyncResult); } catch (SocketException) { - // TODO: Should log the error code when this class has a logging. + // TODO: Logging. } catch (ObjectDisposedException) { return; From 4ca94607be6787c982c97610d1fe196b71fd5244 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 18 Oct 2020 16:18:49 +0900 Subject: [PATCH 3255/6294] [Modify] Polish it --- websocket-sharp/Net/EndPointListener.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/EndPointListener.cs b/websocket-sharp/Net/EndPointListener.cs index 8e1bb5221..9ac8370ff 100644 --- a/websocket-sharp/Net/EndPointListener.cs +++ b/websocket-sharp/Net/EndPointListener.cs @@ -270,11 +270,15 @@ private static void onAccept (IAsyncResult asyncResult) processAccepted (sock, lsnr); } - private static void processAccepted (Socket socket, EndPointListener listener) + private static void processAccepted ( + Socket socket, EndPointListener listener + ) { HttpConnection conn = null; + try { conn = new HttpConnection (socket, listener); + lock (listener._unregisteredSync) listener._unregistered[conn] = conn; @@ -283,6 +287,7 @@ private static void processAccepted (Socket socket, EndPointListener listener) catch { if (conn != null) { conn.Close (true); + return; } From fa1538250cda016157b4a454183e0ac3b29f7a43 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 19 Oct 2020 20:17:49 +0900 Subject: [PATCH 3256/6294] [Modify] Use List --- websocket-sharp/Net/EndPointListener.cs | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/websocket-sharp/Net/EndPointListener.cs b/websocket-sharp/Net/EndPointListener.cs index 9ac8370ff..ae525f714 100644 --- a/websocket-sharp/Net/EndPointListener.cs +++ b/websocket-sharp/Net/EndPointListener.cs @@ -64,7 +64,7 @@ internal sealed class EndPointListener private List _all; // host == '+' private static readonly string _defaultCertFolderPath; private IPEndPoint _endpoint; - private Dictionary _prefixes; + private List _prefixes; private bool _secure; private Socket _socket; private ServerSslConfiguration _sslConfig; @@ -114,7 +114,7 @@ bool reuseAddress _sslConfig.ServerCertificate = cert; } - _prefixes = new Dictionary (); + _prefixes = new List (); _unregistered = new Dictionary (); _unregisteredSync = ((ICollection) _unregistered).SyncRoot; @@ -377,9 +377,10 @@ internal bool TrySearchHttpListener (Uri uri, out HttpListener listener) path += "/"; if (host != null && host.Length > 0) { + var prefs = _prefixes; var bestLen = -1; - foreach (var pref in _prefixes.Keys) { + foreach (var pref in prefs) { if (dns) { var prefHost = pref.Host; var prefDns = Uri.CheckHostName (prefHost) == UriHostNameType.Dns; @@ -459,13 +460,14 @@ public void AddPrefix (HttpListenerPrefix prefix) return; } - Dictionary prefs, prefs2; + List prefs, prefs2; do { prefs = _prefixes; + var idx = prefs.IndexOf (prefix); - if (prefs.ContainsKey (prefix)) { - if (prefs[prefix] != prefix.Listener) { + if (idx > -1) { + if (prefs[idx].Listener != prefix.Listener) { var msg = String.Format ( "There is another listener for {0}.", prefix ); @@ -476,8 +478,8 @@ public void AddPrefix (HttpListenerPrefix prefix) return; } - prefs2 = new Dictionary (prefs); - prefs2[prefix] = prefix.Listener; + prefs2 = new List (prefs); + prefs2.Add (prefix); } while ( Interlocked.CompareExchange (ref _prefixes, prefs2, prefs) != prefs @@ -553,15 +555,15 @@ public void RemovePrefix (HttpListenerPrefix prefix) return; } - Dictionary prefs, prefs2; + List prefs, prefs2; do { prefs = _prefixes; - if (!prefs.ContainsKey (prefix)) + if (!prefs.Contains (prefix)) break; - prefs2 = new Dictionary (prefs); + prefs2 = new List (prefs); prefs2.Remove (prefix); } while ( From 596237e0c7dbc8fe3a3ae87790653de8e223e1ff Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 19 Oct 2020 20:20:09 +0900 Subject: [PATCH 3257/6294] [Modify] Polish it --- websocket-sharp/Net/EndPointListener.cs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/websocket-sharp/Net/EndPointListener.cs b/websocket-sharp/Net/EndPointListener.cs index ae525f714..05c3cf8c3 100644 --- a/websocket-sharp/Net/EndPointListener.cs +++ b/websocket-sharp/Net/EndPointListener.cs @@ -61,16 +61,16 @@ internal sealed class EndPointListener { #region Private Fields - private List _all; // host == '+' - private static readonly string _defaultCertFolderPath; - private IPEndPoint _endpoint; - private List _prefixes; - private bool _secure; - private Socket _socket; - private ServerSslConfiguration _sslConfig; - private List _unhandled; // host == '*' - private Dictionary _unregistered; - private object _unregisteredSync; + private List _all; // host == '+' + private static readonly string _defaultCertFolderPath; + private IPEndPoint _endpoint; + private List _prefixes; + private bool _secure; + private Socket _socket; + private ServerSslConfiguration _sslConfig; + private List _unhandled; // host == '*' + private Dictionary _unregistered; + private object _unregisteredSync; #endregion From c122e2dc7260137b0a8e7b5390656cc6d9f977c9 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 20 Oct 2020 19:18:38 +0900 Subject: [PATCH 3258/6294] [Modify] Polish it --- websocket-sharp/Net/EndPointListener.cs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/websocket-sharp/Net/EndPointListener.cs b/websocket-sharp/Net/EndPointListener.cs index 05c3cf8c3..406f4e4cb 100644 --- a/websocket-sharp/Net/EndPointListener.cs +++ b/websocket-sharp/Net/EndPointListener.cs @@ -460,14 +460,12 @@ public void AddPrefix (HttpListenerPrefix prefix) return; } - List prefs, prefs2; - do { - prefs = _prefixes; - var idx = prefs.IndexOf (prefix); + current = _prefixes; + var idx = current.IndexOf (prefix); if (idx > -1) { - if (prefs[idx].Listener != prefix.Listener) { + if (current[idx].Listener != prefix.Listener) { var msg = String.Format ( "There is another listener for {0}.", prefix ); @@ -478,11 +476,11 @@ public void AddPrefix (HttpListenerPrefix prefix) return; } - prefs2 = new List (prefs); - prefs2.Add (prefix); + future = new List (current); + future.Add (prefix); } while ( - Interlocked.CompareExchange (ref _prefixes, prefs2, prefs) != prefs + Interlocked.CompareExchange (ref _prefixes, future, current) != current ); } From 22a24c462cc7628c76f7c031c381497462d789f0 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 20 Oct 2020 19:26:42 +0900 Subject: [PATCH 3259/6294] [Modify] Polish it --- websocket-sharp/Net/EndPointListener.cs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/websocket-sharp/Net/EndPointListener.cs b/websocket-sharp/Net/EndPointListener.cs index 406f4e4cb..139c16398 100644 --- a/websocket-sharp/Net/EndPointListener.cs +++ b/websocket-sharp/Net/EndPointListener.cs @@ -553,19 +553,17 @@ public void RemovePrefix (HttpListenerPrefix prefix) return; } - List prefs, prefs2; - do { - prefs = _prefixes; + current = _prefixes; - if (!prefs.Contains (prefix)) + if (!current.Contains (prefix)) break; - prefs2 = new List (prefs); - prefs2.Remove (prefix); + future = new List (current); + future.Remove (prefix); } while ( - Interlocked.CompareExchange (ref _prefixes, prefs2, prefs) != prefs + Interlocked.CompareExchange (ref _prefixes, future, current) != current ); leaveIfNoPrefix (); From fdd52f3d4e1962e9c85b985bea20786a4b2fe0cb Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 21 Oct 2020 19:33:24 +0900 Subject: [PATCH 3260/6294] [Modify] Polish it --- websocket-sharp/Net/EndPointListener.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/EndPointListener.cs b/websocket-sharp/Net/EndPointListener.cs index 139c16398..891546de0 100644 --- a/websocket-sharp/Net/EndPointListener.cs +++ b/websocket-sharp/Net/EndPointListener.cs @@ -78,8 +78,9 @@ internal sealed class EndPointListener static EndPointListener () { - _defaultCertFolderPath = - Environment.GetFolderPath (Environment.SpecialFolder.ApplicationData); + _defaultCertFolderPath = Environment.GetFolderPath ( + Environment.SpecialFolder.ApplicationData + ); } #endregion From a64125b4a3d81dec5543ddfe8a1bfac9ffccf2e5 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 21 Oct 2020 19:36:09 +0900 Subject: [PATCH 3261/6294] [Modify] Polish it --- websocket-sharp/Net/EndPointListener.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/EndPointListener.cs b/websocket-sharp/Net/EndPointListener.cs index 891546de0..3a9c2cfa8 100644 --- a/websocket-sharp/Net/EndPointListener.cs +++ b/websocket-sharp/Net/EndPointListener.cs @@ -187,11 +187,11 @@ private static void addSpecial ( prefixes.Add (prefix); } - private static RSACryptoServiceProvider createRSAFromFile (string filename) + private static RSACryptoServiceProvider createRSAFromFile (string path) { var rsa = new RSACryptoServiceProvider (); - var pvk = File.ReadAllBytes (filename); + var pvk = File.ReadAllBytes (path); rsa.ImportCspBlob (pvk); return rsa; From 99034c14d271fe74d9e569949ff712b0f4edfe21 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 22 Oct 2020 19:07:52 +0900 Subject: [PATCH 3262/6294] [Modify] Polish it --- websocket-sharp/Net/EndPointListener.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/EndPointListener.cs b/websocket-sharp/Net/EndPointListener.cs index 3a9c2cfa8..2fbb19691 100644 --- a/websocket-sharp/Net/EndPointListener.cs +++ b/websocket-sharp/Net/EndPointListener.cs @@ -191,8 +191,8 @@ private static RSACryptoServiceProvider createRSAFromFile (string path) { var rsa = new RSACryptoServiceProvider (); - var pvk = File.ReadAllBytes (path); - rsa.ImportCspBlob (pvk); + var key = File.ReadAllBytes (path); + rsa.ImportCspBlob (key); return rsa; } From 651c4f5ae7e3bf02a868b9ebae4477db3cac4f0e Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 23 Oct 2020 19:30:21 +0900 Subject: [PATCH 3263/6294] [Modify] Use List --- websocket-sharp/Net/EndPointListener.cs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/websocket-sharp/Net/EndPointListener.cs b/websocket-sharp/Net/EndPointListener.cs index 2fbb19691..2981c152d 100644 --- a/websocket-sharp/Net/EndPointListener.cs +++ b/websocket-sharp/Net/EndPointListener.cs @@ -69,7 +69,7 @@ internal sealed class EndPointListener private Socket _socket; private ServerSslConfiguration _sslConfig; private List _unhandled; // host == '*' - private Dictionary _unregistered; + private List _unregistered; private object _unregisteredSync; #endregion @@ -116,7 +116,7 @@ bool reuseAddress } _prefixes = new List (); - _unregistered = new Dictionary (); + _unregistered = new List (); _unregisteredSync = ((ICollection) _unregistered).SyncRoot; _socket = new Socket ( @@ -281,7 +281,7 @@ private static void processAccepted ( conn = new HttpConnection (socket, listener); lock (listener._unregisteredSync) - listener._unregistered[conn] = conn; + listener._unregistered.Add (conn); conn.BeginReadRequest (); } @@ -492,13 +492,14 @@ public void Close () HttpConnection[] conns = null; lock (_unregisteredSync) { - if (_unregistered.Count == 0) + var cnt = _unregistered.Count; + + if (cnt == 0) return; - var keys = _unregistered.Keys; - conns = new HttpConnection[keys.Count]; + conns = new HttpConnection[cnt]; - keys.CopyTo (conns, 0); + _unregistered.CopyTo (conns, 0); _unregistered.Clear (); } From 7e407fc38d26e53a238df924c43cb057958b98eb Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 23 Oct 2020 19:32:20 +0900 Subject: [PATCH 3264/6294] [Modify] Polish it --- websocket-sharp/Net/EndPointListener.cs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/websocket-sharp/Net/EndPointListener.cs b/websocket-sharp/Net/EndPointListener.cs index 2981c152d..1d31c2649 100644 --- a/websocket-sharp/Net/EndPointListener.cs +++ b/websocket-sharp/Net/EndPointListener.cs @@ -61,16 +61,16 @@ internal sealed class EndPointListener { #region Private Fields - private List _all; // host == '+' - private static readonly string _defaultCertFolderPath; - private IPEndPoint _endpoint; - private List _prefixes; - private bool _secure; - private Socket _socket; - private ServerSslConfiguration _sslConfig; - private List _unhandled; // host == '*' - private List _unregistered; - private object _unregisteredSync; + private List _all; // host == '+' + private static readonly string _defaultCertFolderPath; + private IPEndPoint _endpoint; + private List _prefixes; + private bool _secure; + private Socket _socket; + private ServerSslConfiguration _sslConfig; + private List _unhandled; // host == '*' + private List _unregistered; + private object _unregisteredSync; #endregion From 393cfb3dcaf3ebff24ebab672d29d6cb243f5d92 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 24 Oct 2020 17:29:20 +0900 Subject: [PATCH 3265/6294] [Modify] Add it --- websocket-sharp/Net/EndPointListener.cs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/websocket-sharp/Net/EndPointListener.cs b/websocket-sharp/Net/EndPointListener.cs index 1d31c2649..812b95072 100644 --- a/websocket-sharp/Net/EndPointListener.cs +++ b/websocket-sharp/Net/EndPointListener.cs @@ -187,6 +187,28 @@ private static void addSpecial ( prefixes.Add (prefix); } + private void clearConnections () + { + HttpConnection[] conns = null; + + var cnt = 0; + + lock (_unregisteredSync) { + cnt = _unregistered.Count; + + if (cnt == 0) + return; + + conns = new HttpConnection[cnt]; + + _unregistered.CopyTo (conns, 0); + _unregistered.Clear (); + } + + for (var i = cnt - 1; i >= 0; i--) + conns[i].Close (true); + } + private static RSACryptoServiceProvider createRSAFromFile (string path) { var rsa = new RSACryptoServiceProvider (); From 9bc49eb327880bea028f0160f4138c2d3263cd8b Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 25 Oct 2020 17:42:20 +0900 Subject: [PATCH 3266/6294] [Modify] Replace it --- websocket-sharp/Net/EndPointListener.cs | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/websocket-sharp/Net/EndPointListener.cs b/websocket-sharp/Net/EndPointListener.cs index 812b95072..8a0af0406 100644 --- a/websocket-sharp/Net/EndPointListener.cs +++ b/websocket-sharp/Net/EndPointListener.cs @@ -511,23 +511,7 @@ public void Close () { _socket.Close (); - HttpConnection[] conns = null; - - lock (_unregisteredSync) { - var cnt = _unregistered.Count; - - if (cnt == 0) - return; - - conns = new HttpConnection[cnt]; - - _unregistered.CopyTo (conns, 0); - _unregistered.Clear (); - } - - for (var i = conns.Length - 1; i >= 0; i--) - conns[i].Close (true); - + clearConnections (); EndPointManager.RemoveEndPoint (_endpoint); } From b711565a347d1ca5e86dbc44cde2eaf1677932b1 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 25 Oct 2020 17:45:52 +0900 Subject: [PATCH 3267/6294] [Modify] 2020 --- websocket-sharp/Net/EndPointListener.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/EndPointListener.cs b/websocket-sharp/Net/EndPointListener.cs index 8a0af0406..e059d097c 100644 --- a/websocket-sharp/Net/EndPointListener.cs +++ b/websocket-sharp/Net/EndPointListener.cs @@ -8,7 +8,7 @@ * The MIT License * * Copyright (c) 2005 Novell, Inc. (http://www.novell.com) - * Copyright (c) 2012-2016 sta.blockhead + * Copyright (c) 2012-2020 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From 9dcf1cb427618a42e4b73c7157e3cd03d37c3910 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 26 Oct 2020 21:45:41 +0900 Subject: [PATCH 3268/6294] [Modify] Polish it --- websocket-sharp/Net/HttpConnection.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/websocket-sharp/Net/HttpConnection.cs b/websocket-sharp/Net/HttpConnection.cs index 572d785c2..26965c35d 100644 --- a/websocket-sharp/Net/HttpConnection.cs +++ b/websocket-sharp/Net/HttpConnection.cs @@ -254,6 +254,7 @@ private void init () private static void onRead (IAsyncResult asyncResult) { var conn = (HttpConnection) asyncResult.AsyncState; + if (conn._socket == null) return; @@ -263,29 +264,35 @@ private static void onRead (IAsyncResult asyncResult) var nread = -1; var len = 0; + try { var current = conn._reuses; + if (!conn._timeoutCanceled[current]) { conn._timer.Change (Timeout.Infinite, Timeout.Infinite); conn._timeoutCanceled[current] = true; } nread = conn._stream.EndRead (asyncResult); + conn._requestBuffer.Write (conn._buffer, 0, nread); len = (int) conn._requestBuffer.Length; } catch (Exception ex) { if (conn._requestBuffer != null && conn._requestBuffer.Length > 0) { conn.SendError (ex.Message, 400); + return; } conn.close (); + return; } if (nread <= 0) { conn.close (); + return; } @@ -295,19 +302,24 @@ private static void onRead (IAsyncResult asyncResult) if (conn._context.HasError) { conn.SendError (); + return; } HttpListener lsnr; + if (!conn._listener.TrySearchHttpListener (conn._context.Request.Url, out lsnr)) { conn.SendError (null, 404); + return; } if (conn._lastListener != lsnr) { conn.removeConnection (); + if (!lsnr.AddConnection (conn)) { conn.close (); + return; } @@ -315,6 +327,7 @@ private static void onRead (IAsyncResult asyncResult) } conn._context.Listener = lsnr; + if (!conn._context.Authenticate ()) return; From 2ee42e4a948191b970dd1da70de8b3998163e390 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 27 Oct 2020 19:37:49 +0900 Subject: [PATCH 3269/6294] [Modify] Polish it --- websocket-sharp/Net/HttpConnection.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Net/HttpConnection.cs b/websocket-sharp/Net/HttpConnection.cs index 26965c35d..67cd0543e 100644 --- a/websocket-sharp/Net/HttpConnection.cs +++ b/websocket-sharp/Net/HttpConnection.cs @@ -345,6 +345,7 @@ private static void onTimeout (object state) { var conn = (HttpConnection) state; var current = conn._reuses; + if (conn._socket == null) return; From eac4c259b0fd0523716259d316c693df23bd2ce9 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 27 Oct 2020 19:48:42 +0900 Subject: [PATCH 3270/6294] [Modify] Move it --- websocket-sharp/Net/HttpConnection.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Net/HttpConnection.cs b/websocket-sharp/Net/HttpConnection.cs index 67cd0543e..bdcf0028e 100644 --- a/websocket-sharp/Net/HttpConnection.cs +++ b/websocket-sharp/Net/HttpConnection.cs @@ -275,6 +275,12 @@ private static void onRead (IAsyncResult asyncResult) nread = conn._stream.EndRead (asyncResult); + if (nread <= 0) { + conn.close (); + + return; + } + conn._requestBuffer.Write (conn._buffer, 0, nread); len = (int) conn._requestBuffer.Length; } @@ -290,12 +296,6 @@ private static void onRead (IAsyncResult asyncResult) return; } - if (nread <= 0) { - conn.close (); - - return; - } - if (conn.processInput (conn._requestBuffer.GetBuffer (), len)) { if (!conn._context.HasError) conn._context.Request.FinishInitialization (); From 72e9a85d54362c43becd1a7e84a5be178b22468f Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 27 Oct 2020 19:52:01 +0900 Subject: [PATCH 3271/6294] [Modify] Polish it --- websocket-sharp/Net/HttpConnection.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpConnection.cs b/websocket-sharp/Net/HttpConnection.cs index bdcf0028e..7cab00797 100644 --- a/websocket-sharp/Net/HttpConnection.cs +++ b/websocket-sharp/Net/HttpConnection.cs @@ -262,7 +262,6 @@ private static void onRead (IAsyncResult asyncResult) if (conn._socket == null) return; - var nread = -1; var len = 0; try { @@ -273,7 +272,7 @@ private static void onRead (IAsyncResult asyncResult) conn._timeoutCanceled[current] = true; } - nread = conn._stream.EndRead (asyncResult); + var nread = conn._stream.EndRead (asyncResult); if (nread <= 0) { conn.close (); From 3ef52d473fdcfd8ec97dadb09cf7eca3f5b73fa7 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 28 Oct 2020 19:39:14 +0900 Subject: [PATCH 3272/6294] [Modify] Polish it --- websocket-sharp/Net/HttpConnection.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpConnection.cs b/websocket-sharp/Net/HttpConnection.cs index 7cab00797..01647c640 100644 --- a/websocket-sharp/Net/HttpConnection.cs +++ b/websocket-sharp/Net/HttpConnection.cs @@ -284,7 +284,7 @@ private static void onRead (IAsyncResult asyncResult) len = (int) conn._requestBuffer.Length; } catch (Exception ex) { - if (conn._requestBuffer != null && conn._requestBuffer.Length > 0) { + if (conn._requestBuffer.Length > 0) { conn.SendError (ex.Message, 400); return; From 364c264e851e1da15139f00b69c01cd695f37516 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 28 Oct 2020 19:42:59 +0900 Subject: [PATCH 3273/6294] [Modify] Polish it --- websocket-sharp/Net/HttpConnection.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Net/HttpConnection.cs b/websocket-sharp/Net/HttpConnection.cs index 01647c640..16f4e946f 100644 --- a/websocket-sharp/Net/HttpConnection.cs +++ b/websocket-sharp/Net/HttpConnection.cs @@ -533,6 +533,7 @@ public RequestStream GetRequestStream (long contentLength, bool chunked) var buff = _requestBuffer.GetBuffer (); var len = (int) _requestBuffer.Length; var cnt = len - _position; + disposeRequestBuffer (); _inputStream = chunked From 38870ae67d9c9f23f719ee5c7281b2375596d4c9 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 29 Oct 2020 19:39:55 +0900 Subject: [PATCH 3274/6294] [Modify] Polish it --- websocket-sharp/Net/HttpConnection.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Net/HttpConnection.cs b/websocket-sharp/Net/HttpConnection.cs index 16f4e946f..1fa9e8ab5 100644 --- a/websocket-sharp/Net/HttpConnection.cs +++ b/websocket-sharp/Net/HttpConnection.cs @@ -94,6 +94,7 @@ internal HttpConnection (Socket socket, EndPointListener listener) _listener = listener; var netStream = new NetworkStream (socket, false); + if (listener.IsSecure) { var sslConf = listener.SslConfiguration; var sslStream = new SslStream ( From bdbebe5f79dd73e884b2779a6ed3b944709c9bd2 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 29 Oct 2020 19:45:35 +0900 Subject: [PATCH 3275/6294] [Modify] Polish it --- websocket-sharp/Net/HttpConnection.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Net/HttpConnection.cs b/websocket-sharp/Net/HttpConnection.cs index 1fa9e8ab5..9100fa86c 100644 --- a/websocket-sharp/Net/HttpConnection.cs +++ b/websocket-sharp/Net/HttpConnection.cs @@ -202,6 +202,7 @@ private void closeSocket () } _socket.Close (); + _socket = null; } From c32edb8247a6ee3bc4d0c298157f987e0c8d7019 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 29 Oct 2020 19:46:49 +0900 Subject: [PATCH 3276/6294] [Modify] Polish it --- websocket-sharp/Net/HttpConnection.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Net/HttpConnection.cs b/websocket-sharp/Net/HttpConnection.cs index 9100fa86c..434724c63 100644 --- a/websocket-sharp/Net/HttpConnection.cs +++ b/websocket-sharp/Net/HttpConnection.cs @@ -212,6 +212,7 @@ private void disposeRequestBuffer () return; _requestBuffer.Dispose (); + _requestBuffer = null; } From 4732c4396c1dc5d0fcf313ccc97c8500566c9298 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 29 Oct 2020 19:48:35 +0900 Subject: [PATCH 3277/6294] [Modify] Polish it --- websocket-sharp/Net/HttpConnection.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Net/HttpConnection.cs b/websocket-sharp/Net/HttpConnection.cs index 434724c63..50f92f7a4 100644 --- a/websocket-sharp/Net/HttpConnection.cs +++ b/websocket-sharp/Net/HttpConnection.cs @@ -225,6 +225,7 @@ private void disposeStream () _outputStream = null; _stream.Dispose (); + _stream = null; } From 2548f5e202a65b6084e5fd125dc8e58df974f8cf Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 29 Oct 2020 19:50:24 +0900 Subject: [PATCH 3278/6294] [Modify] Polish it --- websocket-sharp/Net/HttpConnection.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Net/HttpConnection.cs b/websocket-sharp/Net/HttpConnection.cs index 50f92f7a4..2b0ea51ee 100644 --- a/websocket-sharp/Net/HttpConnection.cs +++ b/websocket-sharp/Net/HttpConnection.cs @@ -241,6 +241,7 @@ private void disposeTimer () } _timer.Dispose (); + _timer = null; } From 1a693a850207317027a215a5b871444e0224883a Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 30 Oct 2020 19:39:20 +0900 Subject: [PATCH 3279/6294] [Modify] Polish it --- websocket-sharp/Net/HttpConnection.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/websocket-sharp/Net/HttpConnection.cs b/websocket-sharp/Net/HttpConnection.cs index 2b0ea51ee..6d72902b0 100644 --- a/websocket-sharp/Net/HttpConnection.cs +++ b/websocket-sharp/Net/HttpConnection.cs @@ -372,10 +372,13 @@ private bool processInput (byte[] data, int length) _currentLine = new StringBuilder (64); var nread = 0; + try { string line; + while ((line = readLineFrom (data, _position, length, out nread)) != null) { _position += nread; + if (line.Length == 0) { if (_inputState == InputState.RequestLine) continue; @@ -384,6 +387,7 @@ private bool processInput (byte[] data, int length) _context.ErrorMessage = "Headers too long"; _currentLine = null; + return true; } @@ -401,12 +405,15 @@ private bool processInput (byte[] data, int length) } catch (Exception ex) { _context.ErrorMessage = ex.Message; + return true; } _position += nread; + if (_position >= 32768) { _context.ErrorMessage = "Headers too long"; + return true; } From a1d396490d9791c60251d1b3b76d586c470c07e1 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 31 Oct 2020 17:24:38 +0900 Subject: [PATCH 3280/6294] [Modify] Polish it --- websocket-sharp/Net/HttpConnection.cs | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/websocket-sharp/Net/HttpConnection.cs b/websocket-sharp/Net/HttpConnection.cs index 6d72902b0..0d59fccd2 100644 --- a/websocket-sharp/Net/HttpConnection.cs +++ b/websocket-sharp/Net/HttpConnection.cs @@ -420,31 +420,41 @@ private bool processInput (byte[] data, int length) return false; } - private string readLineFrom (byte[] buffer, int offset, int length, out int read) + private string readLineFrom ( + byte[] buffer, int offset, int length, out int read + ) { read = 0; - for (var i = offset; i < length && _lineState != LineState.Lf; i++) { + for (var i = offset; i < length; i++) { read++; var b = buffer[i]; - if (b == 13) + + if (b == 13) { _lineState = LineState.Cr; - else if (b == 10) + + continue; + } + + if (b == 10) { _lineState = LineState.Lf; - else - _currentLine.Append ((char) b); + + break; + } + + _currentLine.Append ((char) b); } if (_lineState != LineState.Lf) return null; - var line = _currentLine.ToString (); + var ret = _currentLine.ToString (); _currentLine.Length = 0; _lineState = LineState.None; - return line; + return ret; } private void removeConnection () From 60adfd7362ed5824059f3976dd282de026429fca Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 1 Nov 2020 17:37:07 +0900 Subject: [PATCH 3281/6294] [Modify] Polish it --- websocket-sharp/Net/HttpConnection.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Net/HttpConnection.cs b/websocket-sharp/Net/HttpConnection.cs index 0d59fccd2..76df915a2 100644 --- a/websocket-sharp/Net/HttpConnection.cs +++ b/websocket-sharp/Net/HttpConnection.cs @@ -371,14 +371,16 @@ private bool processInput (byte[] data, int length) if (_currentLine == null) _currentLine = new StringBuilder (64); - var nread = 0; - try { - string line; + while (true) { + int nread; + var line = readLineFrom (data, _position, length, out nread); - while ((line = readLineFrom (data, _position, length, out nread)) != null) { _position += nread; + if (line == null) + break; + if (line.Length == 0) { if (_inputState == InputState.RequestLine) continue; @@ -409,8 +411,6 @@ private bool processInput (byte[] data, int length) return true; } - _position += nread; - if (_position >= 32768) { _context.ErrorMessage = "Headers too long"; From 6458a28ec3cdd0e49b346df0d4578dcae1c2f7ef Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 2 Nov 2020 20:58:45 +0900 Subject: [PATCH 3282/6294] [Modify] Edit it --- websocket-sharp/Net/HttpConnection.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpConnection.cs b/websocket-sharp/Net/HttpConnection.cs index 76df915a2..601cb55a8 100644 --- a/websocket-sharp/Net/HttpConnection.cs +++ b/websocket-sharp/Net/HttpConnection.cs @@ -364,10 +364,12 @@ private static void onTimeout (object state) } } - // true -> Done processing. - // false -> Need more input. private bool processInput (byte[] data, int length) { + // This method returns a bool: + // - true Done processing + // - false Need more input + if (_currentLine == null) _currentLine = new StringBuilder (64); From a82345b72ddc3e88174b193c7be3f7a659932b71 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 2 Nov 2020 21:01:05 +0900 Subject: [PATCH 3283/6294] [Modify] Polish it --- websocket-sharp/Net/HttpConnection.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/HttpConnection.cs b/websocket-sharp/Net/HttpConnection.cs index 601cb55a8..c7352e916 100644 --- a/websocket-sharp/Net/HttpConnection.cs +++ b/websocket-sharp/Net/HttpConnection.cs @@ -423,13 +423,13 @@ private bool processInput (byte[] data, int length) } private string readLineFrom ( - byte[] buffer, int offset, int length, out int read + byte[] buffer, int offset, int length, out int nread ) { - read = 0; + nread = 0; for (var i = offset; i < length; i++) { - read++; + nread++; var b = buffer[i]; From bfa211ba1f59be9fce063b1618d3d3a6c8c7bf80 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 3 Nov 2020 19:41:57 +0900 Subject: [PATCH 3284/6294] [Modify] Polish it --- websocket-sharp/Net/HttpConnection.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/HttpConnection.cs b/websocket-sharp/Net/HttpConnection.cs index c7352e916..5fb0b66e4 100644 --- a/websocket-sharp/Net/HttpConnection.cs +++ b/websocket-sharp/Net/HttpConnection.cs @@ -461,10 +461,13 @@ private string readLineFrom ( private void removeConnection () { - if (_lastListener != null) - _lastListener.RemoveConnection (this); - else + if (_lastListener == null) { _listener.RemoveConnection (this); + + return; + } + + _lastListener.RemoveConnection (this); } private void unregisterContext () From 35384a9d3108795fe7cd78e5c19e56250ccaccfe Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 3 Nov 2020 19:43:22 +0900 Subject: [PATCH 3285/6294] [Modify] Polish it --- websocket-sharp/Net/HttpConnection.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Net/HttpConnection.cs b/websocket-sharp/Net/HttpConnection.cs index 5fb0b66e4..7b65444ea 100644 --- a/websocket-sharp/Net/HttpConnection.cs +++ b/websocket-sharp/Net/HttpConnection.cs @@ -476,6 +476,7 @@ private void unregisterContext () return; _context.Unregister (); + _contextRegistered = false; } From 3088a51a6b116ec5e3c08d89e6698dbf3b5f2125 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 4 Nov 2020 20:06:21 +0900 Subject: [PATCH 3286/6294] [Modify] Polish it --- websocket-sharp/Net/HttpConnection.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/websocket-sharp/Net/HttpConnection.cs b/websocket-sharp/Net/HttpConnection.cs index 7b65444ea..af7b5bb91 100644 --- a/websocket-sharp/Net/HttpConnection.cs +++ b/websocket-sharp/Net/HttpConnection.cs @@ -498,6 +498,7 @@ internal void Close (bool force) _outputStream.Close (true); close (); + return; } @@ -505,11 +506,13 @@ internal void Close (bool force) if (_context.Response.CloseConnection) { close (); + return; } if (!_context.Request.FlushInput ()) { close (); + return; } @@ -518,6 +521,7 @@ internal void Close (bool force) init (); _reuses++; + BeginReadRequest (); } } From bdcf479931ce33572d342656d897bacfdf14ca6a Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 5 Nov 2020 19:58:55 +0900 Subject: [PATCH 3287/6294] [Modify] Polish it --- websocket-sharp/Net/HttpConnection.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpConnection.cs b/websocket-sharp/Net/HttpConnection.cs index af7b5bb91..fef71ed9b 100644 --- a/websocket-sharp/Net/HttpConnection.cs +++ b/websocket-sharp/Net/HttpConnection.cs @@ -619,7 +619,10 @@ public void SendError (string message, int status) res.ContentType = "text/html"; var content = new StringBuilder (64); - content.AppendFormat ("

{0} {1}", status, res.StatusDescription); + content.AppendFormat ( + "

{0} {1}", status, res.StatusDescription + ); + if (message != null && message.Length > 0) content.AppendFormat (" ({0})

", message); else From 07705dde6d52d2da2bc81bfa5f4f55a4644adaab Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 6 Nov 2020 19:35:22 +0900 Subject: [PATCH 3288/6294] [Modify] Polish it --- websocket-sharp/Net/HttpConnection.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpConnection.cs b/websocket-sharp/Net/HttpConnection.cs index fef71ed9b..673a6780d 100644 --- a/websocket-sharp/Net/HttpConnection.cs +++ b/websocket-sharp/Net/HttpConnection.cs @@ -310,9 +310,10 @@ private static void onRead (IAsyncResult asyncResult) return; } + var url = conn._context.Request.Url; HttpListener lsnr; - if (!conn._listener.TrySearchHttpListener (conn._context.Request.Url, out lsnr)) { + if (!conn._listener.TrySearchHttpListener (url, out lsnr)) { conn.SendError (null, 404); return; From 631da19ff291d718e85e6e67a45e9a7ca8b013f1 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 7 Nov 2020 17:36:15 +0900 Subject: [PATCH 3289/6294] [Modify] Add it --- websocket-sharp/Net/HttpConnection.cs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/websocket-sharp/Net/HttpConnection.cs b/websocket-sharp/Net/HttpConnection.cs index 673a6780d..60bc295d4 100644 --- a/websocket-sharp/Net/HttpConnection.cs +++ b/websocket-sharp/Net/HttpConnection.cs @@ -460,6 +460,31 @@ private string readLineFrom ( return ret; } + private void registerContext (HttpListener listener) + { + if (_lastListener != listener) { + removeConnection (); + + if (!listener.AddConnection (this)) { + close (); + + return; + } + + _lastListener = listener; + } + + _context.Listener = listener; + + if (!_context.Authenticate ()) + return; + + if (!_context.Register ()) + return; + + _contextRegistered = true; + } + private void removeConnection () { if (_lastListener == null) { From af62f88d88341971bb05e76c2bc1463d017da4e0 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 8 Nov 2020 17:59:58 +0900 Subject: [PATCH 3290/6294] [Modify] Replace it --- websocket-sharp/Net/HttpConnection.cs | 24 +++--------------------- 1 file changed, 3 insertions(+), 21 deletions(-) diff --git a/websocket-sharp/Net/HttpConnection.cs b/websocket-sharp/Net/HttpConnection.cs index 60bc295d4..a1d70a960 100644 --- a/websocket-sharp/Net/HttpConnection.cs +++ b/websocket-sharp/Net/HttpConnection.cs @@ -313,31 +313,13 @@ private static void onRead (IAsyncResult asyncResult) var url = conn._context.Request.Url; HttpListener lsnr; - if (!conn._listener.TrySearchHttpListener (url, out lsnr)) { - conn.SendError (null, 404); + if (conn._listener.TrySearchHttpListener (url, out lsnr)) { + conn.registerContext (lsnr); return; } - if (conn._lastListener != lsnr) { - conn.removeConnection (); - - if (!lsnr.AddConnection (conn)) { - conn.close (); - - return; - } - - conn._lastListener = lsnr; - } - - conn._context.Listener = lsnr; - - if (!conn._context.Authenticate ()) - return; - - if (conn._context.Register ()) - conn._contextRegistered = true; + conn.SendError (null, 404); return; } From 307d4e45b8bd8a8dcf571e2786869e93cbead9ae Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 9 Nov 2020 22:31:33 +0900 Subject: [PATCH 3291/6294] [Modify] Move it --- websocket-sharp/Net/HttpConnection.cs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/websocket-sharp/Net/HttpConnection.cs b/websocket-sharp/Net/HttpConnection.cs index a1d70a960..abf1a98b2 100644 --- a/websocket-sharp/Net/HttpConnection.cs +++ b/websocket-sharp/Net/HttpConnection.cs @@ -248,6 +248,7 @@ private void disposeTimer () private void init () { _context = new HttpListenerContext (this); + _currentLine = new StringBuilder (64); _inputState = InputState.RequestLine; _inputStream = null; _lineState = LineState.None; @@ -353,9 +354,6 @@ private bool processInput (byte[] data, int length) // - true Done processing // - false Need more input - if (_currentLine == null) - _currentLine = new StringBuilder (64); - try { while (true) { int nread; @@ -373,8 +371,6 @@ private bool processInput (byte[] data, int length) if (_position > 32768) _context.ErrorMessage = "Headers too long"; - _currentLine = null; - return true; } From 8faeda2171f60f986ba10abef650661ee7d7da05 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 10 Nov 2020 19:42:58 +0900 Subject: [PATCH 3292/6294] [Modify] Polish it --- websocket-sharp/Net/HttpConnection.cs | 3 --- 1 file changed, 3 deletions(-) diff --git a/websocket-sharp/Net/HttpConnection.cs b/websocket-sharp/Net/HttpConnection.cs index abf1a98b2..006e363cf 100644 --- a/websocket-sharp/Net/HttpConnection.cs +++ b/websocket-sharp/Net/HttpConnection.cs @@ -221,9 +221,6 @@ private void disposeStream () if (_stream == null) return; - _inputStream = null; - _outputStream = null; - _stream.Dispose (); _stream = null; From 12bf1f597ce50676f8346eafd209dc79dfad7265 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 10 Nov 2020 19:46:43 +0900 Subject: [PATCH 3293/6294] [Modify] Polish it --- websocket-sharp/Net/HttpConnection.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/websocket-sharp/Net/HttpConnection.cs b/websocket-sharp/Net/HttpConnection.cs index 006e363cf..cffec8b3f 100644 --- a/websocket-sharp/Net/HttpConnection.cs +++ b/websocket-sharp/Net/HttpConnection.cs @@ -583,8 +583,6 @@ public RequestStream GetRequestStream (long contentLength, bool chunked) public ResponseStream GetResponseStream () { - // TODO: Can we get this stream before reading the input? - lock (_sync) { if (_socket == null) return null; From 1287df8ed6efcf476495cb02d23d4a5a49ef0d9e Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 11 Nov 2020 21:33:36 +0900 Subject: [PATCH 3294/6294] [Modify] Remove it --- websocket-sharp/Net/HttpConnection.cs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Net/HttpConnection.cs b/websocket-sharp/Net/HttpConnection.cs index cffec8b3f..cea698759 100644 --- a/websocket-sharp/Net/HttpConnection.cs +++ b/websocket-sharp/Net/HttpConnection.cs @@ -286,12 +286,8 @@ private static void onRead (IAsyncResult asyncResult) conn._requestBuffer.Write (conn._buffer, 0, nread); len = (int) conn._requestBuffer.Length; } - catch (Exception ex) { - if (conn._requestBuffer.Length > 0) { - conn.SendError (ex.Message, 400); - - return; - } + catch (Exception) { + // TODO: Logging. conn.close (); From 1388fd89d80be3a1c498a042be2553a16b437f55 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 12 Nov 2020 21:34:37 +0900 Subject: [PATCH 3295/6294] [Modify] Add it --- websocket-sharp/Net/HttpConnection.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/websocket-sharp/Net/HttpConnection.cs b/websocket-sharp/Net/HttpConnection.cs index cea698759..6f10d8ece 100644 --- a/websocket-sharp/Net/HttpConnection.cs +++ b/websocket-sharp/Net/HttpConnection.cs @@ -71,6 +71,7 @@ internal sealed class HttpConnection private LineState _lineState; private EndPointListener _listener; private EndPoint _localEndPoint; + private static readonly int _maxInputLength; private ResponseStream _outputStream; private int _position; private EndPoint _remoteEndPoint; @@ -86,6 +87,15 @@ internal sealed class HttpConnection #endregion + #region Static Constructor + + static HttpConnection () + { + _maxInputLength = 32768; + } + + #endregion + #region Internal Constructors internal HttpConnection (Socket socket, EndPointListener listener) From 8d69e8e87b817cb910af78fb653bd053b9e4bbe2 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 12 Nov 2020 21:39:27 +0900 Subject: [PATCH 3296/6294] [Modify] Replace it --- websocket-sharp/Net/HttpConnection.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpConnection.cs b/websocket-sharp/Net/HttpConnection.cs index 6f10d8ece..299b37188 100644 --- a/websocket-sharp/Net/HttpConnection.cs +++ b/websocket-sharp/Net/HttpConnection.cs @@ -371,7 +371,7 @@ private bool processInput (byte[] data, int length) if (_inputState == InputState.RequestLine) continue; - if (_position > 32768) + if (_position > _maxInputLength) _context.ErrorMessage = "Headers too long"; return true; @@ -395,7 +395,7 @@ private bool processInput (byte[] data, int length) return true; } - if (_position >= 32768) { + if (_position >= _maxInputLength) { _context.ErrorMessage = "Headers too long"; return true; From 7f856131eb69141d90c89656867a6672e69c3038 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 13 Nov 2020 19:37:47 +0900 Subject: [PATCH 3297/6294] [Modify] Move it --- websocket-sharp/Net/HttpConnection.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpConnection.cs b/websocket-sharp/Net/HttpConnection.cs index 299b37188..2b5b3f491 100644 --- a/websocket-sharp/Net/HttpConnection.cs +++ b/websocket-sharp/Net/HttpConnection.cs @@ -61,7 +61,7 @@ internal sealed class HttpConnection #region Private Fields private byte[] _buffer; - private const int _bufferLength = 8192; + private static readonly int _bufferLength; private HttpListenerContext _context; private bool _contextRegistered; private StringBuilder _currentLine; @@ -91,6 +91,7 @@ internal sealed class HttpConnection static HttpConnection () { + _bufferLength = 8192; _maxInputLength = 32768; } From 80921f0dd82b3d8a958b287986c1df7af1112635 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 14 Nov 2020 17:46:31 +0900 Subject: [PATCH 3298/6294] [Modify] Move it --- websocket-sharp/Net/HttpConnection.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/websocket-sharp/Net/HttpConnection.cs b/websocket-sharp/Net/HttpConnection.cs index 2b5b3f491..95acd0ab1 100644 --- a/websocket-sharp/Net/HttpConnection.cs +++ b/websocket-sharp/Net/HttpConnection.cs @@ -128,6 +128,7 @@ internal HttpConnection (Socket socket, EndPointListener listener) _stream = netStream; } + _buffer = new byte[_bufferLength]; _localEndPoint = socket.LocalEndPoint; _remoteEndPoint = socket.RemoteEndPoint; _sync = new object (); @@ -540,9 +541,6 @@ internal void Close (bool force) public void BeginReadRequest () { - if (_buffer == null) - _buffer = new byte[_bufferLength]; - if (_reuses == 1) _timeout = 15000; From 1b8bb77cebe63659d71e917cbf8afc48d2f1dc86 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 15 Nov 2020 16:59:32 +0900 Subject: [PATCH 3299/6294] [Modify] Add it --- websocket-sharp/Net/HttpConnection.cs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/websocket-sharp/Net/HttpConnection.cs b/websocket-sharp/Net/HttpConnection.cs index 95acd0ab1..b26084cfe 100644 --- a/websocket-sharp/Net/HttpConnection.cs +++ b/websocket-sharp/Net/HttpConnection.cs @@ -266,6 +266,20 @@ private void init () _requestBuffer = new MemoryStream (); } + private void init (int timeout) + { + _timeout = timeout; + + _context = new HttpListenerContext (this); + _currentLine = new StringBuilder (64); + _inputState = InputState.RequestLine; + _inputStream = null; + _lineState = LineState.None; + _outputStream = null; + _position = 0; + _requestBuffer = new MemoryStream (); + } + private static void onRead (IAsyncResult asyncResult) { var conn = (HttpConnection) asyncResult.AsyncState; From b3661a3cdf26008690434a29be25843d4add04d9 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 16 Nov 2020 18:46:16 +0900 Subject: [PATCH 3300/6294] [Modify] Replace it --- websocket-sharp/Net/HttpConnection.cs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Net/HttpConnection.cs b/websocket-sharp/Net/HttpConnection.cs index b26084cfe..0feebe1bb 100644 --- a/websocket-sharp/Net/HttpConnection.cs +++ b/websocket-sharp/Net/HttpConnection.cs @@ -132,11 +132,10 @@ internal HttpConnection (Socket socket, EndPointListener listener) _localEndPoint = socket.LocalEndPoint; _remoteEndPoint = socket.RemoteEndPoint; _sync = new object (); - _timeout = 90000; // 90k ms for first request, 15k ms from then on. _timeoutCanceled = new Dictionary (); _timer = new Timer (onTimeout, this, Timeout.Infinite, Timeout.Infinite); - init (); + init (90000); // 90k ms for first request, 15k ms from then on. } #endregion @@ -541,10 +540,10 @@ internal void Close (bool force) disposeRequestBuffer (); unregisterContext (); - init (); _reuses++; + init (15000); BeginReadRequest (); } } @@ -555,9 +554,6 @@ internal void Close (bool force) public void BeginReadRequest () { - if (_reuses == 1) - _timeout = 15000; - try { _timeoutCanceled.Add (_reuses, false); _timer.Change (_timeout, Timeout.Infinite); From beb70d6f735df8f3f31363676fe8b587d60830e2 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 16 Nov 2020 18:48:22 +0900 Subject: [PATCH 3301/6294] [Modify] Remove it --- websocket-sharp/Net/HttpConnection.cs | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/websocket-sharp/Net/HttpConnection.cs b/websocket-sharp/Net/HttpConnection.cs index 0feebe1bb..642300126 100644 --- a/websocket-sharp/Net/HttpConnection.cs +++ b/websocket-sharp/Net/HttpConnection.cs @@ -253,18 +253,6 @@ private void disposeTimer () _timer = null; } - private void init () - { - _context = new HttpListenerContext (this); - _currentLine = new StringBuilder (64); - _inputState = InputState.RequestLine; - _inputStream = null; - _lineState = LineState.None; - _outputStream = null; - _position = 0; - _requestBuffer = new MemoryStream (); - } - private void init (int timeout) { _timeout = timeout; From 474c6ebf3fe212a5b25d4b58812439f7b3db4e07 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 17 Nov 2020 20:42:21 +0900 Subject: [PATCH 3302/6294] [Modify] Polish it --- websocket-sharp/Net/HttpConnection.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpConnection.cs b/websocket-sharp/Net/HttpConnection.cs index 642300126..2f1a80e05 100644 --- a/websocket-sharp/Net/HttpConnection.cs +++ b/websocket-sharp/Net/HttpConnection.cs @@ -331,7 +331,14 @@ private static void onRead (IAsyncResult asyncResult) return; } - conn._stream.BeginRead (conn._buffer, 0, _bufferLength, onRead, conn); + try { + conn._stream.BeginRead (conn._buffer, 0, _bufferLength, onRead, conn); + } + catch (Exception) { + // TODO: Logging. + + conn.close (); + } } } From e8e0bdbdf915806cdb977dcbbc1fcae4e172cdce Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 18 Nov 2020 19:45:54 +0900 Subject: [PATCH 3303/6294] [Modify] Polish it --- websocket-sharp/Net/HttpConnection.cs | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/websocket-sharp/Net/HttpConnection.cs b/websocket-sharp/Net/HttpConnection.cs index 2f1a80e05..82f3aaf81 100644 --- a/websocket-sharp/Net/HttpConnection.cs +++ b/websocket-sharp/Net/HttpConnection.cs @@ -278,7 +278,7 @@ private static void onRead (IAsyncResult asyncResult) if (conn._socket == null) return; - var len = 0; + var nread = 0; try { var current = conn._reuses; @@ -288,16 +288,7 @@ private static void onRead (IAsyncResult asyncResult) conn._timeoutCanceled[current] = true; } - var nread = conn._stream.EndRead (asyncResult); - - if (nread <= 0) { - conn.close (); - - return; - } - - conn._requestBuffer.Write (conn._buffer, 0, nread); - len = (int) conn._requestBuffer.Length; + nread = conn._stream.EndRead (asyncResult); } catch (Exception) { // TODO: Logging. @@ -307,6 +298,15 @@ private static void onRead (IAsyncResult asyncResult) return; } + if (nread <= 0) { + conn.close (); + + return; + } + + conn._requestBuffer.Write (conn._buffer, 0, nread); + var len = (int) conn._requestBuffer.Length; + if (conn.processInput (conn._requestBuffer.GetBuffer (), len)) { if (!conn._context.HasError) conn._context.Request.FinishInitialization (); From fb544cad416630bed2ebeea3d976d9a9074987c9 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 19 Nov 2020 20:06:13 +0900 Subject: [PATCH 3304/6294] [Modify] Polish it --- websocket-sharp/Net/HttpConnection.cs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/websocket-sharp/Net/HttpConnection.cs b/websocket-sharp/Net/HttpConnection.cs index 82f3aaf81..d663f810f 100644 --- a/websocket-sharp/Net/HttpConnection.cs +++ b/websocket-sharp/Net/HttpConnection.cs @@ -270,6 +270,7 @@ private void init (int timeout) private static void onRead (IAsyncResult asyncResult) { var conn = (HttpConnection) asyncResult.AsyncState; + var current = conn._reuses; if (conn._socket == null) return; @@ -278,16 +279,14 @@ private static void onRead (IAsyncResult asyncResult) if (conn._socket == null) return; + if (!conn._timeoutCanceled[current]) { + conn._timer.Change (Timeout.Infinite, Timeout.Infinite); + conn._timeoutCanceled[current] = true; + } + var nread = 0; try { - var current = conn._reuses; - - if (!conn._timeoutCanceled[current]) { - conn._timer.Change (Timeout.Infinite, Timeout.Infinite); - conn._timeoutCanceled[current] = true; - } - nread = conn._stream.EndRead (asyncResult); } catch (Exception) { From 128d70a29480bf3c432e13270011c31f9f4814e6 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 20 Nov 2020 19:35:01 +0900 Subject: [PATCH 3305/6294] [Modify] Polish it --- websocket-sharp/Net/HttpConnection.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpConnection.cs b/websocket-sharp/Net/HttpConnection.cs index d663f810f..8dfbf8e48 100644 --- a/websocket-sharp/Net/HttpConnection.cs +++ b/websocket-sharp/Net/HttpConnection.cs @@ -548,12 +548,15 @@ internal void Close (bool force) public void BeginReadRequest () { + _timeoutCanceled.Add (_reuses, false); + _timer.Change (_timeout, Timeout.Infinite); + try { - _timeoutCanceled.Add (_reuses, false); - _timer.Change (_timeout, Timeout.Infinite); _stream.BeginRead (_buffer, 0, _bufferLength, onRead, this); } catch { + // TODO: Logging. + close (); } } From 004f51574efdc0279c1be64649a54e82b12c1a70 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 20 Nov 2020 19:37:37 +0900 Subject: [PATCH 3306/6294] [Modify] Move it --- websocket-sharp/Net/HttpConnection.cs | 30 +++++++++++++-------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/websocket-sharp/Net/HttpConnection.cs b/websocket-sharp/Net/HttpConnection.cs index 8dfbf8e48..a98b0a69b 100644 --- a/websocket-sharp/Net/HttpConnection.cs +++ b/websocket-sharp/Net/HttpConnection.cs @@ -500,6 +500,21 @@ private void unregisterContext () #region Internal Methods + internal void BeginReadRequest () + { + _timeoutCanceled.Add (_reuses, false); + _timer.Change (_timeout, Timeout.Infinite); + + try { + _stream.BeginRead (_buffer, 0, _bufferLength, onRead, this); + } + catch { + // TODO: Logging. + + close (); + } + } + internal void Close (bool force) { if (_socket == null) @@ -546,21 +561,6 @@ internal void Close (bool force) #region Public Methods - public void BeginReadRequest () - { - _timeoutCanceled.Add (_reuses, false); - _timer.Change (_timeout, Timeout.Infinite); - - try { - _stream.BeginRead (_buffer, 0, _bufferLength, onRead, this); - } - catch { - // TODO: Logging. - - close (); - } - } - public void Close () { Close (false); From 061159b4bf707a06eadc738f1caf0469cdbc976c Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 21 Nov 2020 17:14:53 +0900 Subject: [PATCH 3307/6294] [Modify] Polish it --- websocket-sharp/Net/EndPointListener.cs | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/websocket-sharp/Net/EndPointListener.cs b/websocket-sharp/Net/EndPointListener.cs index e059d097c..08c5c8884 100644 --- a/websocket-sharp/Net/EndPointListener.cs +++ b/websocket-sharp/Net/EndPointListener.cs @@ -301,21 +301,19 @@ private static void processAccepted ( try { conn = new HttpConnection (socket, listener); + } + catch (Exception) { + // TODO: Logging. - lock (listener._unregisteredSync) - listener._unregistered.Add (conn); + socket.Close (); - conn.BeginReadRequest (); + return; } - catch { - if (conn != null) { - conn.Close (true); - return; - } + lock (listener._unregisteredSync) + listener._unregistered.Add (conn); - socket.Close (); - } + conn.BeginReadRequest (); } private static bool removeSpecial ( From 96d7e62d6bb3b66126be627df156526945556f43 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 22 Nov 2020 17:07:10 +0900 Subject: [PATCH 3308/6294] [Modify] Polish it --- websocket-sharp/Net/EndPointListener.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/EndPointListener.cs b/websocket-sharp/Net/EndPointListener.cs index 08c5c8884..86402f72a 100644 --- a/websocket-sharp/Net/EndPointListener.cs +++ b/websocket-sharp/Net/EndPointListener.cs @@ -270,17 +270,19 @@ private static void onAccept (IAsyncResult asyncResult) try { sock = lsnr._socket.EndAccept (asyncResult); } - catch (SocketException) { - // TODO: Logging. - } catch (ObjectDisposedException) { return; } + catch (Exception) { + // TODO: Logging. + } try { lsnr._socket.BeginAccept (onAccept, lsnr); } - catch { + catch (Exception) { + // TODO: Logging. + if (sock != null) sock.Close (); From e348cfcf524b6e0d46ff05daa16fa5e72bd63300 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 22 Nov 2020 17:10:43 +0900 Subject: [PATCH 3309/6294] [Modify] Polish it --- websocket-sharp/Net/HttpConnection.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpConnection.cs b/websocket-sharp/Net/HttpConnection.cs index a98b0a69b..7399e2f99 100644 --- a/websocket-sharp/Net/HttpConnection.cs +++ b/websocket-sharp/Net/HttpConnection.cs @@ -508,7 +508,7 @@ internal void BeginReadRequest () try { _stream.BeginRead (_buffer, 0, _bufferLength, onRead, this); } - catch { + catch (Exception) { // TODO: Logging. close (); From 8e14fddd518d7abdf289ea9206a8f7a5413c6c00 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 23 Nov 2020 17:17:01 +0900 Subject: [PATCH 3310/6294] [Modify] 2020 --- websocket-sharp/Net/HttpConnection.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpConnection.cs b/websocket-sharp/Net/HttpConnection.cs index 7399e2f99..05ffb796e 100644 --- a/websocket-sharp/Net/HttpConnection.cs +++ b/websocket-sharp/Net/HttpConnection.cs @@ -8,7 +8,7 @@ * The MIT License * * Copyright (c) 2005 Novell, Inc. (http://www.novell.com) - * Copyright (c) 2012-2016 sta.blockhead + * Copyright (c) 2012-2020 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From 9f6eaebd1fbce1ddabf69689425a70453fe57fc2 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 24 Nov 2020 19:43:13 +0900 Subject: [PATCH 3311/6294] [Modify] Use None instead of Default --- websocket-sharp/Net/ClientSslConfiguration.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/ClientSslConfiguration.cs b/websocket-sharp/Net/ClientSslConfiguration.cs index 800bcb30d..0cae24a64 100644 --- a/websocket-sharp/Net/ClientSslConfiguration.cs +++ b/websocket-sharp/Net/ClientSslConfiguration.cs @@ -64,7 +64,7 @@ public class ClientSslConfiguration ///
public ClientSslConfiguration () { - _enabledSslProtocols = SslProtocols.Default; + _enabledSslProtocols = SslProtocols.None; } /// @@ -77,7 +77,7 @@ public ClientSslConfiguration () public ClientSslConfiguration (string targetHost) { _targetHost = targetHost; - _enabledSslProtocols = SslProtocols.Default; + _enabledSslProtocols = SslProtocols.None; } /// @@ -195,7 +195,7 @@ public LocalCertificateSelectionCallback ClientCertificateSelectionCallback { /// the protocols used for authentication. /// /// - /// The default value is . + /// The default value is . /// /// public SslProtocols EnabledSslProtocols { From f0dd2a03e855795176d9d4d8a82dccb5b64cda69 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 25 Nov 2020 19:37:44 +0900 Subject: [PATCH 3312/6294] [Modify] Add a null check --- websocket-sharp/Net/ClientSslConfiguration.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/websocket-sharp/Net/ClientSslConfiguration.cs b/websocket-sharp/Net/ClientSslConfiguration.cs index 0cae24a64..baccc0cf2 100644 --- a/websocket-sharp/Net/ClientSslConfiguration.cs +++ b/websocket-sharp/Net/ClientSslConfiguration.cs @@ -76,7 +76,11 @@ public ClientSslConfiguration () /// public ClientSslConfiguration (string targetHost) { + if (targetHost == null) + throw new ArgumentNullException ("targetHost"); + _targetHost = targetHost; + _enabledSslProtocols = SslProtocols.None; } From d9454a89d4dc2e45f2c34046d5043266a4ebd893 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 25 Nov 2020 19:41:43 +0900 Subject: [PATCH 3313/6294] [Modify] Edit it --- websocket-sharp/Net/ClientSslConfiguration.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/websocket-sharp/Net/ClientSslConfiguration.cs b/websocket-sharp/Net/ClientSslConfiguration.cs index baccc0cf2..53004cb30 100644 --- a/websocket-sharp/Net/ClientSslConfiguration.cs +++ b/websocket-sharp/Net/ClientSslConfiguration.cs @@ -74,6 +74,9 @@ public ClientSslConfiguration () /// /// A that represents the target host server name. /// + /// + /// is . + /// public ClientSslConfiguration (string targetHost) { if (targetHost == null) From 710465a9e9e2d02d3935fd65ee9863db43004b47 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 25 Nov 2020 19:48:22 +0900 Subject: [PATCH 3314/6294] [Modify] Edit it --- websocket-sharp/Net/ClientSslConfiguration.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/ClientSslConfiguration.cs b/websocket-sharp/Net/ClientSslConfiguration.cs index 53004cb30..812114b0f 100644 --- a/websocket-sharp/Net/ClientSslConfiguration.cs +++ b/websocket-sharp/Net/ClientSslConfiguration.cs @@ -68,11 +68,11 @@ public ClientSslConfiguration () } /// - /// Initializes a new instance of the class - /// with the specified . + /// Initializes a new instance of the + /// class with the specified target host server name. /// /// - /// A that represents the target host server name. + /// A that specifies the target host server name. /// /// /// is . From 587bf34c1877f68f8790cdb97e99aaa9c26f88de Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 26 Nov 2020 20:14:50 +0900 Subject: [PATCH 3315/6294] [Modify] Add an empty check --- websocket-sharp/Net/ClientSslConfiguration.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/websocket-sharp/Net/ClientSslConfiguration.cs b/websocket-sharp/Net/ClientSslConfiguration.cs index 812114b0f..823a6969c 100644 --- a/websocket-sharp/Net/ClientSslConfiguration.cs +++ b/websocket-sharp/Net/ClientSslConfiguration.cs @@ -82,6 +82,9 @@ public ClientSslConfiguration (string targetHost) if (targetHost == null) throw new ArgumentNullException ("targetHost"); + if (targetHost.Length == 0) + throw new ArgumentException ("An empty string.", "targetHost"); + _targetHost = targetHost; _enabledSslProtocols = SslProtocols.None; From aa6763b8832f5a684bc7fc21e2e92f3bcc211b58 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 26 Nov 2020 20:17:06 +0900 Subject: [PATCH 3316/6294] [Modify] Edit it --- websocket-sharp/Net/ClientSslConfiguration.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/websocket-sharp/Net/ClientSslConfiguration.cs b/websocket-sharp/Net/ClientSslConfiguration.cs index 823a6969c..73fcf50f3 100644 --- a/websocket-sharp/Net/ClientSslConfiguration.cs +++ b/websocket-sharp/Net/ClientSslConfiguration.cs @@ -77,6 +77,9 @@ public ClientSslConfiguration () /// /// is . /// + /// + /// is an empty string. + /// public ClientSslConfiguration (string targetHost) { if (targetHost == null) From 8607caab317e850be214fd316787e2ff4b54baa8 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 27 Nov 2020 19:13:02 +0900 Subject: [PATCH 3317/6294] [Modify] Add them --- websocket-sharp/Net/ClientSslConfiguration.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/websocket-sharp/Net/ClientSslConfiguration.cs b/websocket-sharp/Net/ClientSslConfiguration.cs index 73fcf50f3..2092fc497 100644 --- a/websocket-sharp/Net/ClientSslConfiguration.cs +++ b/websocket-sharp/Net/ClientSslConfiguration.cs @@ -270,6 +270,12 @@ public string TargetHost { } set { + if (value == null) + throw new ArgumentNullException ("value"); + + if (value.Length == 0) + throw new ArgumentException ("An empty string.", "value"); + _targetHost = value; } } From 0346b9a798b3907e0cec7d24e9080a11ef5a55a3 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 27 Nov 2020 19:17:28 +0900 Subject: [PATCH 3318/6294] [Modify] Edit it --- websocket-sharp/Net/ClientSslConfiguration.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/websocket-sharp/Net/ClientSslConfiguration.cs b/websocket-sharp/Net/ClientSslConfiguration.cs index 2092fc497..cefb33aca 100644 --- a/websocket-sharp/Net/ClientSslConfiguration.cs +++ b/websocket-sharp/Net/ClientSslConfiguration.cs @@ -264,6 +264,12 @@ public RemoteCertificateValidationCallback ServerCertificateValidationCallback { /// will share a secure connection with a client. /// /// + /// + /// The value specified for a set operation is . + /// + /// + /// The value specified for a set operation is an empty string. + /// public string TargetHost { get { return _targetHost; From df697458f17bde6e3d9a2856337020bcaea551ab Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 27 Nov 2020 19:20:47 +0900 Subject: [PATCH 3319/6294] [Modify] Edit it --- websocket-sharp/Net/ClientSslConfiguration.cs | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/websocket-sharp/Net/ClientSslConfiguration.cs b/websocket-sharp/Net/ClientSslConfiguration.cs index cefb33aca..fc7bebe93 100644 --- a/websocket-sharp/Net/ClientSslConfiguration.cs +++ b/websocket-sharp/Net/ClientSslConfiguration.cs @@ -255,14 +255,8 @@ public RemoteCertificateValidationCallback ServerCertificateValidationCallback { /// Gets or sets the target host server name. /// /// - /// - /// A or - /// if not specified. - /// - /// - /// That string represents the name of the server that - /// will share a secure connection with a client. - /// + /// A that represents the name of the server that + /// will share a secure connection with a client. /// /// /// The value specified for a set operation is . From 287bb1bbf4df11723f80569e077017bfb91e79e2 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 27 Nov 2020 19:23:32 +0900 Subject: [PATCH 3320/6294] [Modify] Remove it --- websocket-sharp/Net/ClientSslConfiguration.cs | 8 -------- 1 file changed, 8 deletions(-) diff --git a/websocket-sharp/Net/ClientSslConfiguration.cs b/websocket-sharp/Net/ClientSslConfiguration.cs index fc7bebe93..2ca769cb6 100644 --- a/websocket-sharp/Net/ClientSslConfiguration.cs +++ b/websocket-sharp/Net/ClientSslConfiguration.cs @@ -59,14 +59,6 @@ public class ClientSslConfiguration #region Public Constructors - /// - /// Initializes a new instance of the class. - /// - public ClientSslConfiguration () - { - _enabledSslProtocols = SslProtocols.None; - } - /// /// Initializes a new instance of the /// class with the specified target host server name. From c2a76388def4d20efed156bbbec3eb774700423e Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 28 Nov 2020 17:04:21 +0900 Subject: [PATCH 3321/6294] [Modify] Edit it --- websocket-sharp/Net/ClientSslConfiguration.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/ClientSslConfiguration.cs b/websocket-sharp/Net/ClientSslConfiguration.cs index 2ca769cb6..cc57dc21f 100644 --- a/websocket-sharp/Net/ClientSslConfiguration.cs +++ b/websocket-sharp/Net/ClientSslConfiguration.cs @@ -86,8 +86,8 @@ public ClientSslConfiguration (string targetHost) } /// - /// Copies the parameters from the specified to - /// a new instance of the class. + /// Initializes a new instance of the + /// class that stores the parameters copied from the specified configuration. /// /// /// A from which to copy. From 0f8df3fa513ca0c9295e2a59f57abf46d7555e6d Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 29 Nov 2020 17:36:25 +0900 Subject: [PATCH 3322/6294] [Modify] Edit it --- websocket-sharp/Net/ClientSslConfiguration.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/ClientSslConfiguration.cs b/websocket-sharp/Net/ClientSslConfiguration.cs index cc57dc21f..d4c0944a7 100644 --- a/websocket-sharp/Net/ClientSslConfiguration.cs +++ b/websocket-sharp/Net/ClientSslConfiguration.cs @@ -136,15 +136,15 @@ public bool CheckCertificateRevocation { } /// - /// Gets or sets the certificates from which to select one to - /// supply to the server. + /// Gets or sets the collection of client certificates from which to select + /// one to supply to the server. /// /// /// /// A or . /// /// - /// That collection contains client certificates from which to select. + /// The collection contains client certificates from which to select. /// /// /// The default value is . From 91f757677ebc1f2a0fa1df184c93dce8e0c72dcd Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 30 Nov 2020 16:51:30 +0900 Subject: [PATCH 3323/6294] [Modify] Edit it --- websocket-sharp/Net/ClientSslConfiguration.cs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Net/ClientSslConfiguration.cs b/websocket-sharp/Net/ClientSslConfiguration.cs index d4c0944a7..6200ca90f 100644 --- a/websocket-sharp/Net/ClientSslConfiguration.cs +++ b/websocket-sharp/Net/ClientSslConfiguration.cs @@ -161,12 +161,11 @@ public X509CertificateCollection ClientCertificates { } /// - /// Gets or sets the callback used to select the certificate to - /// supply to the server. + /// Gets or sets the callback used to select the certificate to supply to + /// the server. /// /// - /// No certificate is supplied if the callback returns - /// . + /// No certificate is supplied if the callback returns . /// /// /// @@ -174,8 +173,8 @@ public X509CertificateCollection ClientCertificates { /// invokes the method called for selecting the certificate. /// /// - /// The default value is a delegate that invokes a method that - /// only returns . + /// The default value is a delegate that invokes a method that only + /// returns . /// /// public LocalCertificateSelectionCallback ClientCertificateSelectionCallback { From 59af13083453fa1b1dcbf2512c7fe5bc01765671 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 30 Nov 2020 17:05:29 +0900 Subject: [PATCH 3324/6294] [Modify] Edit it --- websocket-sharp/Net/ClientSslConfiguration.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/ClientSslConfiguration.cs b/websocket-sharp/Net/ClientSslConfiguration.cs index 6200ca90f..f5b071b4d 100644 --- a/websocket-sharp/Net/ClientSslConfiguration.cs +++ b/websocket-sharp/Net/ClientSslConfiguration.cs @@ -195,8 +195,10 @@ public LocalCertificateSelectionCallback ClientCertificateSelectionCallback { /// /// /// - /// The enum values that represent - /// the protocols used for authentication. + /// Any of the enum values. + /// + /// + /// It represent the protocols used for authentication. /// /// /// The default value is . From a4403ce528c80badf9aaf0e6e8609ecac8b34ab1 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 1 Dec 2020 19:43:48 +0900 Subject: [PATCH 3325/6294] [Modify] Edit it --- websocket-sharp/Net/ClientSslConfiguration.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/ClientSslConfiguration.cs b/websocket-sharp/Net/ClientSslConfiguration.cs index f5b071b4d..8b3142c36 100644 --- a/websocket-sharp/Net/ClientSslConfiguration.cs +++ b/websocket-sharp/Net/ClientSslConfiguration.cs @@ -215,8 +215,8 @@ public SslProtocols EnabledSslProtocols { } /// - /// Gets or sets the callback used to validate the certificate - /// supplied by the server. + /// Gets or sets the callback used to validate the certificate supplied by + /// the server. /// /// /// The certificate is valid if the callback returns true. @@ -227,8 +227,8 @@ public SslProtocols EnabledSslProtocols { /// invokes the method called for validating the certificate. /// /// - /// The default value is a delegate that invokes a method that - /// only returns true. + /// The default value is a delegate that invokes a method that only + /// returns true. /// /// public RemoteCertificateValidationCallback ServerCertificateValidationCallback { From f729f4a4bc44218d526967208bc9282e88db3541 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 1 Dec 2020 19:51:25 +0900 Subject: [PATCH 3326/6294] [Modify] 2020 --- websocket-sharp/Net/ClientSslConfiguration.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/ClientSslConfiguration.cs b/websocket-sharp/Net/ClientSslConfiguration.cs index 8b3142c36..c5f4ee073 100644 --- a/websocket-sharp/Net/ClientSslConfiguration.cs +++ b/websocket-sharp/Net/ClientSslConfiguration.cs @@ -5,7 +5,7 @@ * The MIT License * * Copyright (c) 2014 liryna - * Copyright (c) 2014-2017 sta.blockhead + * Copyright (c) 2014-2020 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From d1f8a508c2ae3c39f42d3dc292373fd7f0282876 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 2 Dec 2020 19:39:34 +0900 Subject: [PATCH 3327/6294] [Modify] Edit it --- websocket-sharp/Net/ServerSslConfiguration.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/ServerSslConfiguration.cs b/websocket-sharp/Net/ServerSslConfiguration.cs index ad9b9e7c2..884f36f74 100644 --- a/websocket-sharp/Net/ServerSslConfiguration.cs +++ b/websocket-sharp/Net/ServerSslConfiguration.cs @@ -153,8 +153,8 @@ public bool ClientCertificateRequired { } /// - /// Gets or sets the callback used to validate the certificate - /// supplied by the client. + /// Gets or sets the callback used to validate the certificate supplied by + /// the client. /// /// /// The certificate is valid if the callback returns true. @@ -165,8 +165,8 @@ public bool ClientCertificateRequired { /// invokes the method called for validating the certificate. /// /// - /// The default value is a delegate that invokes a method that - /// only returns true. + /// The default value is a delegate that invokes a method that only + /// returns true. /// /// public RemoteCertificateValidationCallback ClientCertificateValidationCallback { From b401fef5e8e0e6bcf9679c9db3b2e337468556b9 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 2 Dec 2020 19:42:06 +0900 Subject: [PATCH 3328/6294] [Modify] Use None instead of Default --- websocket-sharp/Net/ServerSslConfiguration.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/ServerSslConfiguration.cs b/websocket-sharp/Net/ServerSslConfiguration.cs index 884f36f74..cfdcc9fcd 100644 --- a/websocket-sharp/Net/ServerSslConfiguration.cs +++ b/websocket-sharp/Net/ServerSslConfiguration.cs @@ -63,7 +63,7 @@ public class ServerSslConfiguration /// public ServerSslConfiguration () { - _enabledSslProtocols = SslProtocols.Default; + _enabledSslProtocols = SslProtocols.None; } /// @@ -77,7 +77,7 @@ public ServerSslConfiguration () public ServerSslConfiguration (X509Certificate2 serverCertificate) { _serverCert = serverCertificate; - _enabledSslProtocols = SslProtocols.Default; + _enabledSslProtocols = SslProtocols.None; } /// @@ -191,7 +191,7 @@ public RemoteCertificateValidationCallback ClientCertificateValidationCallback { /// the protocols used for authentication. /// /// - /// The default value is . + /// The default value is . /// /// public SslProtocols EnabledSslProtocols { From 2fd5202b1776a30e3b2cfb99ee540a868d57bc9c Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 2 Dec 2020 19:47:07 +0900 Subject: [PATCH 3329/6294] [Modify] Edit it --- websocket-sharp/Net/ServerSslConfiguration.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/ServerSslConfiguration.cs b/websocket-sharp/Net/ServerSslConfiguration.cs index cfdcc9fcd..6eeca0f55 100644 --- a/websocket-sharp/Net/ServerSslConfiguration.cs +++ b/websocket-sharp/Net/ServerSslConfiguration.cs @@ -187,8 +187,10 @@ public RemoteCertificateValidationCallback ClientCertificateValidationCallback { /// /// /// - /// The enum values that represent - /// the protocols used for authentication. + /// Any of the enum values. + /// + /// + /// It represents the protocols used for authentication. /// /// /// The default value is . From 2445d595c0cc8b07bf0f824fb54cf0734df8db0c Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 3 Dec 2020 19:58:24 +0900 Subject: [PATCH 3330/6294] [Modify] Edit it --- websocket-sharp/Net/ServerSslConfiguration.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/ServerSslConfiguration.cs b/websocket-sharp/Net/ServerSslConfiguration.cs index 6eeca0f55..7ed8f1e48 100644 --- a/websocket-sharp/Net/ServerSslConfiguration.cs +++ b/websocket-sharp/Net/ServerSslConfiguration.cs @@ -211,11 +211,10 @@ public SslProtocols EnabledSslProtocols { /// /// /// - /// A or - /// if not specified. + /// A or . /// /// - /// That instance represents an X.509 certificate. + /// The certificate represents an X.509 certificate. /// /// public X509Certificate2 ServerCertificate { From 3e8818da2edfb48f28e9a6945e38517e2b5e199b Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 3 Dec 2020 20:01:45 +0900 Subject: [PATCH 3331/6294] [Modify] Remove it --- websocket-sharp/Net/ServerSslConfiguration.cs | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/websocket-sharp/Net/ServerSslConfiguration.cs b/websocket-sharp/Net/ServerSslConfiguration.cs index 7ed8f1e48..d6a19252b 100644 --- a/websocket-sharp/Net/ServerSslConfiguration.cs +++ b/websocket-sharp/Net/ServerSslConfiguration.cs @@ -66,20 +66,6 @@ public ServerSslConfiguration () _enabledSslProtocols = SslProtocols.None; } - /// - /// Initializes a new instance of the class - /// with the specified . - /// - /// - /// A that represents the certificate used to - /// authenticate the server. - /// - public ServerSslConfiguration (X509Certificate2 serverCertificate) - { - _serverCert = serverCertificate; - _enabledSslProtocols = SslProtocols.None; - } - /// /// Copies the parameters from the specified to /// a new instance of the class. From 2b2fccf09cae879113834e50b3ecc728e7d76528 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 3 Dec 2020 20:05:59 +0900 Subject: [PATCH 3332/6294] [Modify] Edit it --- websocket-sharp/Net/ServerSslConfiguration.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/websocket-sharp/Net/ServerSslConfiguration.cs b/websocket-sharp/Net/ServerSslConfiguration.cs index d6a19252b..57890ff9e 100644 --- a/websocket-sharp/Net/ServerSslConfiguration.cs +++ b/websocket-sharp/Net/ServerSslConfiguration.cs @@ -202,6 +202,9 @@ public SslProtocols EnabledSslProtocols { /// /// The certificate represents an X.509 certificate. /// + /// + /// The default value is . + /// /// public X509Certificate2 ServerCertificate { get { From 9ab4ea8074de4c5bc4a3997b7031ae1bc03ffc15 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 3 Dec 2020 20:08:40 +0900 Subject: [PATCH 3333/6294] [Modify] Edit it --- websocket-sharp/Net/ServerSslConfiguration.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/ServerSslConfiguration.cs b/websocket-sharp/Net/ServerSslConfiguration.cs index 57890ff9e..e902f60d2 100644 --- a/websocket-sharp/Net/ServerSslConfiguration.cs +++ b/websocket-sharp/Net/ServerSslConfiguration.cs @@ -59,7 +59,8 @@ public class ServerSslConfiguration #region Public Constructors /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the + /// class. /// public ServerSslConfiguration () { From 147812cf4aa521410db45219a7e60309b0e65fc5 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 4 Dec 2020 19:35:36 +0900 Subject: [PATCH 3334/6294] [Modify] Edit it --- websocket-sharp/Net/ServerSslConfiguration.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/ServerSslConfiguration.cs b/websocket-sharp/Net/ServerSslConfiguration.cs index e902f60d2..4566e2f9c 100644 --- a/websocket-sharp/Net/ServerSslConfiguration.cs +++ b/websocket-sharp/Net/ServerSslConfiguration.cs @@ -68,8 +68,8 @@ public ServerSslConfiguration () } /// - /// Copies the parameters from the specified to - /// a new instance of the class. + /// Initializes a new instance of the + /// class that stores the parameters copied from the specified configuration. /// /// /// A from which to copy. From 68d4e46fad2744453b4d06d03b6fc6c51a7d9e1b Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 4 Dec 2020 19:41:11 +0900 Subject: [PATCH 3335/6294] [Modify] 2020 --- websocket-sharp/Net/ServerSslConfiguration.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/ServerSslConfiguration.cs b/websocket-sharp/Net/ServerSslConfiguration.cs index 4566e2f9c..47541f435 100644 --- a/websocket-sharp/Net/ServerSslConfiguration.cs +++ b/websocket-sharp/Net/ServerSslConfiguration.cs @@ -5,7 +5,7 @@ * The MIT License * * Copyright (c) 2014 liryna - * Copyright (c) 2014-2017 sta.blockhead + * Copyright (c) 2014-2020 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From 688cb155c4d0ce5354be7198735b6a82afcb489f Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 5 Dec 2020 21:27:23 +0900 Subject: [PATCH 3336/6294] [Modify] Edit it --- websocket-sharp/Net/ClientSslConfiguration.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/ClientSslConfiguration.cs b/websocket-sharp/Net/ClientSslConfiguration.cs index c5f4ee073..7816e0301 100644 --- a/websocket-sharp/Net/ClientSslConfiguration.cs +++ b/websocket-sharp/Net/ClientSslConfiguration.cs @@ -198,7 +198,7 @@ public LocalCertificateSelectionCallback ClientCertificateSelectionCallback { /// Any of the enum values. /// /// - /// It represent the protocols used for authentication. + /// It represents the protocols used for authentication. /// /// /// The default value is . From 26479fca1aa0614fc285f5f4a5f1f503e39554b8 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 6 Dec 2020 21:45:02 +0900 Subject: [PATCH 3337/6294] [Modify] Add it --- websocket-sharp/Net/HttpListenerContext.cs | 29 ++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/websocket-sharp/Net/HttpListenerContext.cs b/websocket-sharp/Net/HttpListenerContext.cs index 638078d4f..fad373e42 100644 --- a/websocket-sharp/Net/HttpListenerContext.cs +++ b/websocket-sharp/Net/HttpListenerContext.cs @@ -39,6 +39,7 @@ using System; using System.Security.Principal; +using System.Text; using WebSocketSharp.Net.WebSockets; namespace WebSocketSharp.Net @@ -200,6 +201,34 @@ internal bool Register () return _listener.RegisterContext (this); } + internal void SendError () + { + try { + _response.StatusCode = _errorStatus; + _response.ContentType = "text/html"; + + var content = new StringBuilder (64); + content.AppendFormat ( + "

{0} {1}", _errorStatus, _response.StatusDescription + ); + + if (_error != null && _error.Length > 0) + content.AppendFormat (" ({0})

", _error); + else + content.Append (""); + + var enc = Encoding.UTF8; + var entity = enc.GetBytes (content.ToString ()); + _response.ContentEncoding = enc; + _response.ContentLength64 = entity.LongLength; + + _response.Close (entity, true); + } + catch { + _connection.Close (true); + } + } + internal void Unregister () { _listener.UnregisterContext (this); From b858df112d207119b80445f84ebd3688c8b8eb44 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 7 Dec 2020 20:58:34 +0900 Subject: [PATCH 3338/6294] [Modify] Replace it --- websocket-sharp/Net/HttpConnection.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpConnection.cs b/websocket-sharp/Net/HttpConnection.cs index 05ffb796e..b3cc0a971 100644 --- a/websocket-sharp/Net/HttpConnection.cs +++ b/websocket-sharp/Net/HttpConnection.cs @@ -356,7 +356,9 @@ private static void onTimeout (object state) if (conn._timeoutCanceled[current]) return; - conn.SendError (null, 408); + conn._context.ErrorStatus = 408; + + conn._context.SendError (); } } From 6184f51ce3884f588c3dd95dcdc591d910cf6e53 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 7 Dec 2020 21:02:17 +0900 Subject: [PATCH 3339/6294] [Modify] Replace it --- websocket-sharp/Net/HttpConnection.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpConnection.cs b/websocket-sharp/Net/HttpConnection.cs index b3cc0a971..d36d74989 100644 --- a/websocket-sharp/Net/HttpConnection.cs +++ b/websocket-sharp/Net/HttpConnection.cs @@ -325,7 +325,9 @@ private static void onRead (IAsyncResult asyncResult) return; } - conn.SendError (null, 404); + conn._context.ErrorStatus = 404; + + conn._context.SendError (); return; } From 25ad2859b4bf1baf2fd130dac298dd7113e86b47 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 7 Dec 2020 21:04:11 +0900 Subject: [PATCH 3340/6294] [Modify] Replace it --- websocket-sharp/Net/HttpConnection.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpConnection.cs b/websocket-sharp/Net/HttpConnection.cs index d36d74989..c099bbe95 100644 --- a/websocket-sharp/Net/HttpConnection.cs +++ b/websocket-sharp/Net/HttpConnection.cs @@ -311,7 +311,7 @@ private static void onRead (IAsyncResult asyncResult) conn._context.Request.FinishInitialization (); if (conn._context.HasError) { - conn.SendError (); + conn._context.SendError (); return; } From 9505b6f4ec569d03844cd9d0451c3abba5352590 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 8 Dec 2020 16:29:42 +0900 Subject: [PATCH 3341/6294] [Modify] Remove it --- websocket-sharp/Net/HttpConnection.cs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/websocket-sharp/Net/HttpConnection.cs b/websocket-sharp/Net/HttpConnection.cs index c099bbe95..ca1490453 100644 --- a/websocket-sharp/Net/HttpConnection.cs +++ b/websocket-sharp/Net/HttpConnection.cs @@ -614,11 +614,6 @@ public ResponseStream GetResponseStream () } } - public void SendError () - { - SendError (_context.ErrorMessage, _context.ErrorStatus); - } - public void SendError (string message, int status) { if (_socket == null) From 1db27cd69eab7232f8e1479a975092586753d7e7 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 8 Dec 2020 16:40:01 +0900 Subject: [PATCH 3342/6294] [Modify] Replace it --- websocket-sharp/Net/ChunkedRequestStream.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/ChunkedRequestStream.cs b/websocket-sharp/Net/ChunkedRequestStream.cs index 913b505c3..0eb366a5e 100644 --- a/websocket-sharp/Net/ChunkedRequestStream.cs +++ b/websocket-sharp/Net/ChunkedRequestStream.cs @@ -105,7 +105,9 @@ private void onRead (IAsyncResult asyncResult) base.BeginRead (ares.Buffer, ares.Offset, ares.Count, onRead, rstate); } catch (Exception ex) { - _context.Connection.SendError (ex.Message, 400); + _context.ErrorMessage = ex.Message; + _context.SendError (); + ares.Complete (ex); } } From 51596564fc8da2576caa2bb95331ad29310327e0 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 8 Dec 2020 16:41:09 +0900 Subject: [PATCH 3343/6294] [Modify] Remove it --- websocket-sharp/Net/HttpConnection.cs | 37 --------------------------- 1 file changed, 37 deletions(-) diff --git a/websocket-sharp/Net/HttpConnection.cs b/websocket-sharp/Net/HttpConnection.cs index ca1490453..d2aa9fe90 100644 --- a/websocket-sharp/Net/HttpConnection.cs +++ b/websocket-sharp/Net/HttpConnection.cs @@ -614,43 +614,6 @@ public ResponseStream GetResponseStream () } } - public void SendError (string message, int status) - { - if (_socket == null) - return; - - lock (_sync) { - if (_socket == null) - return; - - try { - var res = _context.Response; - res.StatusCode = status; - res.ContentType = "text/html"; - - var content = new StringBuilder (64); - content.AppendFormat ( - "

{0} {1}", status, res.StatusDescription - ); - - if (message != null && message.Length > 0) - content.AppendFormat (" ({0})

", message); - else - content.Append (""); - - var enc = Encoding.UTF8; - var entity = enc.GetBytes (content.ToString ()); - res.ContentEncoding = enc; - res.ContentLength64 = entity.LongLength; - - res.Close (entity, true); - } - catch { - Close (true); - } - } - } - #endregion } } From e6fcd43fa590ba47229a30cb8a4dbd1eec500a26 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 9 Dec 2020 16:56:04 +0900 Subject: [PATCH 3344/6294] [Modify] Rename it --- websocket-sharp/Net/HttpListenerContext.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerContext.cs b/websocket-sharp/Net/HttpListenerContext.cs index fad373e42..021e3aaac 100644 --- a/websocket-sharp/Net/HttpListenerContext.cs +++ b/websocket-sharp/Net/HttpListenerContext.cs @@ -56,7 +56,7 @@ public sealed class HttpListenerContext #region Private Fields private HttpConnection _connection; - private string _error; + private string _errorMessage; private int _errorStatus; private HttpListener _listener; private HttpListenerRequest _request; @@ -88,11 +88,11 @@ internal HttpConnection Connection { internal string ErrorMessage { get { - return _error; + return _errorMessage; } set { - _error = value; + _errorMessage = value; } } @@ -108,7 +108,7 @@ internal int ErrorStatus { internal bool HasError { get { - return _error != null; + return _errorMessage != null; } } @@ -212,8 +212,8 @@ internal void SendError () "

{0} {1}", _errorStatus, _response.StatusDescription ); - if (_error != null && _error.Length > 0) - content.AppendFormat (" ({0})

", _error); + if (_errorMessage != null && _errorMessage.Length > 0) + content.AppendFormat (" ({0})", _errorMessage); else content.Append (""); From 3bea54d60fd1b77490ecc6e8447445ab5cad9e96 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 9 Dec 2020 17:00:35 +0900 Subject: [PATCH 3345/6294] [Modify] Rename it --- websocket-sharp/Net/HttpConnection.cs | 6 +++--- websocket-sharp/Net/HttpListenerContext.cs | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/HttpConnection.cs b/websocket-sharp/Net/HttpConnection.cs index d2aa9fe90..e0fa5f329 100644 --- a/websocket-sharp/Net/HttpConnection.cs +++ b/websocket-sharp/Net/HttpConnection.cs @@ -307,10 +307,10 @@ private static void onRead (IAsyncResult asyncResult) var len = (int) conn._requestBuffer.Length; if (conn.processInput (conn._requestBuffer.GetBuffer (), len)) { - if (!conn._context.HasError) + if (!conn._context.HasErrorMessage) conn._context.Request.FinishInitialization (); - if (conn._context.HasError) { + if (conn._context.HasErrorMessage) { conn._context.SendError (); return; @@ -398,7 +398,7 @@ private bool processInput (byte[] data, int length) _context.Request.AddHeader (line); } - if (_context.HasError) + if (_context.HasErrorMessage) return true; } } diff --git a/websocket-sharp/Net/HttpListenerContext.cs b/websocket-sharp/Net/HttpListenerContext.cs index 021e3aaac..aaf3ae59b 100644 --- a/websocket-sharp/Net/HttpListenerContext.cs +++ b/websocket-sharp/Net/HttpListenerContext.cs @@ -106,7 +106,7 @@ internal int ErrorStatus { } } - internal bool HasError { + internal bool HasErrorMessage { get { return _errorMessage != null; } From 9ac578fa0e5aaec1650df21279cb7f93a3123836 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 10 Dec 2020 19:45:43 +0900 Subject: [PATCH 3346/6294] [Modify] Add it --- websocket-sharp/Net/HttpListenerContext.cs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/websocket-sharp/Net/HttpListenerContext.cs b/websocket-sharp/Net/HttpListenerContext.cs index aaf3ae59b..c228880cd 100644 --- a/websocket-sharp/Net/HttpListenerContext.cs +++ b/websocket-sharp/Net/HttpListenerContext.cs @@ -164,6 +164,28 @@ public IPrincipal User { #endregion + #region Private Methods + + private static string createErrorContent ( + int statusCode, string statusDescription, string message + ) + { + return message != null && message.Length > 0 + ? String.Format ( + "

{0} {1} ({2})

", + statusCode, + statusDescription, + message + ) + : String.Format ( + "

{0} {1}

", + statusCode, + statusDescription + ); + } + + #endregion + #region Internal Methods internal bool Authenticate () From bbd545d6572eefaf3554df97cae2c9cd62fab020 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 10 Dec 2020 19:52:54 +0900 Subject: [PATCH 3347/6294] [Modify] Replace it --- websocket-sharp/Net/HttpListenerContext.cs | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerContext.cs b/websocket-sharp/Net/HttpListenerContext.cs index c228880cd..30410677d 100644 --- a/websocket-sharp/Net/HttpListenerContext.cs +++ b/websocket-sharp/Net/HttpListenerContext.cs @@ -229,15 +229,11 @@ internal void SendError () _response.StatusCode = _errorStatus; _response.ContentType = "text/html"; - var content = new StringBuilder (64); - content.AppendFormat ( - "

{0} {1}", _errorStatus, _response.StatusDescription - ); - - if (_errorMessage != null && _errorMessage.Length > 0) - content.AppendFormat (" ({0})

", _errorMessage); - else - content.Append (""); + var content = createErrorContent ( + _errorStatus, + _response.StatusDescription, + _errorMessage + ); var enc = Encoding.UTF8; var entity = enc.GetBytes (content.ToString ()); From fe4b95a2d5f4c931a93d04862d45c788dee77e24 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 11 Dec 2020 19:36:40 +0900 Subject: [PATCH 3348/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerContext.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerContext.cs b/websocket-sharp/Net/HttpListenerContext.cs index 30410677d..3ef2727af 100644 --- a/websocket-sharp/Net/HttpListenerContext.cs +++ b/websocket-sharp/Net/HttpListenerContext.cs @@ -236,7 +236,7 @@ internal void SendError () ); var enc = Encoding.UTF8; - var entity = enc.GetBytes (content.ToString ()); + var entity = enc.GetBytes (content); _response.ContentEncoding = enc; _response.ContentLength64 = entity.LongLength; From 7615410759fa6944ba81a5db2fafff7aef3254fd Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 11 Dec 2020 19:40:52 +0900 Subject: [PATCH 3349/6294] [Modify] Rename it --- websocket-sharp/Net/HttpListenerContext.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerContext.cs b/websocket-sharp/Net/HttpListenerContext.cs index 3ef2727af..5b88a4b8f 100644 --- a/websocket-sharp/Net/HttpListenerContext.cs +++ b/websocket-sharp/Net/HttpListenerContext.cs @@ -57,7 +57,7 @@ public sealed class HttpListenerContext private HttpConnection _connection; private string _errorMessage; - private int _errorStatus; + private int _errorStatusCode; private HttpListener _listener; private HttpListenerRequest _request; private HttpListenerResponse _response; @@ -71,7 +71,7 @@ public sealed class HttpListenerContext internal HttpListenerContext (HttpConnection connection) { _connection = connection; - _errorStatus = 400; + _errorStatusCode = 400; _request = new HttpListenerRequest (this); _response = new HttpListenerResponse (this); } @@ -98,11 +98,11 @@ internal string ErrorMessage { internal int ErrorStatus { get { - return _errorStatus; + return _errorStatusCode; } set { - _errorStatus = value; + _errorStatusCode = value; } } @@ -226,11 +226,11 @@ internal bool Register () internal void SendError () { try { - _response.StatusCode = _errorStatus; + _response.StatusCode = _errorStatusCode; _response.ContentType = "text/html"; var content = createErrorContent ( - _errorStatus, + _errorStatusCode, _response.StatusDescription, _errorMessage ); From b4b4443e491927b6d7f36faf776f424af93d8ec1 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 12 Dec 2020 17:34:05 +0900 Subject: [PATCH 3350/6294] [Modify] Rename it --- websocket-sharp/Net/HttpConnection.cs | 4 ++-- websocket-sharp/Net/HttpListenerContext.cs | 2 +- websocket-sharp/Net/HttpListenerRequest.cs | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Net/HttpConnection.cs b/websocket-sharp/Net/HttpConnection.cs index e0fa5f329..7c6140d95 100644 --- a/websocket-sharp/Net/HttpConnection.cs +++ b/websocket-sharp/Net/HttpConnection.cs @@ -325,7 +325,7 @@ private static void onRead (IAsyncResult asyncResult) return; } - conn._context.ErrorStatus = 404; + conn._context.ErrorStatusCode = 404; conn._context.SendError (); @@ -358,7 +358,7 @@ private static void onTimeout (object state) if (conn._timeoutCanceled[current]) return; - conn._context.ErrorStatus = 408; + conn._context.ErrorStatusCode = 408; conn._context.SendError (); } diff --git a/websocket-sharp/Net/HttpListenerContext.cs b/websocket-sharp/Net/HttpListenerContext.cs index 5b88a4b8f..4c1cc906a 100644 --- a/websocket-sharp/Net/HttpListenerContext.cs +++ b/websocket-sharp/Net/HttpListenerContext.cs @@ -96,7 +96,7 @@ internal string ErrorMessage { } } - internal int ErrorStatus { + internal int ErrorStatusCode { get { return _errorStatusCode; } diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index 375d5cd4f..fa0042fd2 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -705,7 +705,7 @@ internal void FinishInitialization () var comparison = StringComparison.OrdinalIgnoreCase; if (!transferEnc.Equals ("chunked", comparison)) { _context.ErrorMessage = String.Empty; - _context.ErrorStatus = 501; + _context.ErrorStatusCode = 501; return; } @@ -716,7 +716,7 @@ internal void FinishInitialization () if (_httpMethod == "POST" || _httpMethod == "PUT") { if (_contentLength <= 0 && !_chunked) { _context.ErrorMessage = String.Empty; - _context.ErrorStatus = 411; + _context.ErrorStatusCode = 411; return; } From ed87e2d46dbcb48e8cb87a396b3a6dfc0b73fd60 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 12 Dec 2020 17:35:36 +0900 Subject: [PATCH 3351/6294] [Modify] Polish it --- websocket-sharp/Net/HttpConnection.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/websocket-sharp/Net/HttpConnection.cs b/websocket-sharp/Net/HttpConnection.cs index 7c6140d95..3e8c22f6f 100644 --- a/websocket-sharp/Net/HttpConnection.cs +++ b/websocket-sharp/Net/HttpConnection.cs @@ -359,7 +359,6 @@ private static void onTimeout (object state) return; conn._context.ErrorStatusCode = 408; - conn._context.SendError (); } } From 1732e8b0937823b88cd2be0fc7c24c9736aaa958 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 13 Dec 2020 17:43:48 +0900 Subject: [PATCH 3352/6294] [Modify] Polish it --- websocket-sharp/Net/HttpConnection.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/websocket-sharp/Net/HttpConnection.cs b/websocket-sharp/Net/HttpConnection.cs index 3e8c22f6f..e9ee9e46d 100644 --- a/websocket-sharp/Net/HttpConnection.cs +++ b/websocket-sharp/Net/HttpConnection.cs @@ -326,7 +326,6 @@ private static void onRead (IAsyncResult asyncResult) } conn._context.ErrorStatusCode = 404; - conn._context.SendError (); return; From ad38a23eb991e2bb25463ee4aaad2d750abcdedb Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 14 Dec 2020 21:16:58 +0900 Subject: [PATCH 3353/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerContext.cs | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerContext.cs b/websocket-sharp/Net/HttpListenerContext.cs index 4c1cc906a..390ca5637 100644 --- a/websocket-sharp/Net/HttpListenerContext.cs +++ b/websocket-sharp/Net/HttpListenerContext.cs @@ -191,30 +191,34 @@ private static string createErrorContent ( internal bool Authenticate () { var schm = _listener.SelectAuthenticationScheme (_request); + if (schm == AuthenticationSchemes.Anonymous) return true; if (schm == AuthenticationSchemes.None) { _response.Close (HttpStatusCode.Forbidden); + return false; } var realm = _listener.GetRealm (); - var user = - HttpUtility.CreateUser ( - _request.Headers["Authorization"], - schm, - realm, - _request.HttpMethod, - _listener.GetUserCredentialsFinder () - ); + var user = HttpUtility.CreateUser ( + _request.Headers["Authorization"], + schm, + realm, + _request.HttpMethod, + _listener.GetUserCredentialsFinder () + ); if (user == null || !user.Identity.IsAuthenticated) { - _response.CloseWithAuthChallenge (new AuthenticationChallenge (schm, realm).ToString ()); + var chal = new AuthenticationChallenge (schm, realm).ToString (); + _response.CloseWithAuthChallenge (chal); + return false; } _user = user; + return true; } From dc4f17ef00fca4acfe3752389a88663ad2464112 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 15 Dec 2020 19:45:16 +0900 Subject: [PATCH 3354/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerContext.cs | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerContext.cs b/websocket-sharp/Net/HttpListenerContext.cs index 390ca5637..ca4e04664 100644 --- a/websocket-sharp/Net/HttpListenerContext.cs +++ b/websocket-sharp/Net/HttpListenerContext.cs @@ -287,18 +287,28 @@ internal void Unregister () /// public HttpListenerWebSocketContext AcceptWebSocket (string protocol) { - if (_websocketContext != null) - throw new InvalidOperationException ("The accepting is already in progress."); + if (_websocketContext != null) { + var msg = "The accepting is already in progress."; + + throw new InvalidOperationException (msg); + } if (protocol != null) { - if (protocol.Length == 0) - throw new ArgumentException ("An empty string.", "protocol"); + if (protocol.Length == 0) { + var msg = "An empty string."; + + throw new ArgumentException (msg, "protocol"); + } - if (!protocol.IsToken ()) - throw new ArgumentException ("Contains an invalid character.", "protocol"); + if (!protocol.IsToken ()) { + var msg = "It contains an invalid character."; + + throw new ArgumentException (msg, "protocol"); + } } _websocketContext = new HttpListenerWebSocketContext (this, protocol); + return _websocketContext; } From 4ee4554af63b80ad2595c8056a60436748e35054 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 16 Dec 2020 19:36:17 +0900 Subject: [PATCH 3355/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerContext.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerContext.cs b/websocket-sharp/Net/HttpListenerContext.cs index ca4e04664..84f66c0dd 100644 --- a/websocket-sharp/Net/HttpListenerContext.cs +++ b/websocket-sharp/Net/HttpListenerContext.cs @@ -268,8 +268,8 @@ internal void Unregister () /// the WebSocket handshake request. /// /// - /// A that represents the subprotocol supported on - /// this WebSocket connection. + /// A that specifies the subprotocol supported on + /// the WebSocket connection. /// /// /// From caf61a5beee0b464a52be4d44b78027dd2ee8578 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 17 Dec 2020 19:39:12 +0900 Subject: [PATCH 3356/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerContext.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerContext.cs b/websocket-sharp/Net/HttpListenerContext.cs index 84f66c0dd..6622bcf2b 100644 --- a/websocket-sharp/Net/HttpListenerContext.cs +++ b/websocket-sharp/Net/HttpListenerContext.cs @@ -46,7 +46,7 @@ namespace WebSocketSharp.Net { /// /// Provides the access to the HTTP request and response objects used by - /// the . + /// the class. /// /// /// This class cannot be inherited. From d0825c4f5eda6efd0d783874dd925a6c538a0a95 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 17 Dec 2020 19:56:04 +0900 Subject: [PATCH 3357/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerContext.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerContext.cs b/websocket-sharp/Net/HttpListenerContext.cs index 6622bcf2b..a134f7c8e 100644 --- a/websocket-sharp/Net/HttpListenerContext.cs +++ b/websocket-sharp/Net/HttpListenerContext.cs @@ -142,7 +142,8 @@ public HttpListenerRequest Request { /// Gets the HTTP response object used to send a response to the client. ///
/// - /// A that represents a response to the client request. + /// A that represents a response to + /// the client request. /// public HttpListenerResponse Response { get { From 332801e79459d01a53badf33ecc9baee2809fa6e Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 18 Dec 2020 19:36:31 +0900 Subject: [PATCH 3358/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerContext.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerContext.cs b/websocket-sharp/Net/HttpListenerContext.cs index a134f7c8e..d65555e94 100644 --- a/websocket-sharp/Net/HttpListenerContext.cs +++ b/websocket-sharp/Net/HttpListenerContext.cs @@ -155,7 +155,13 @@ public HttpListenerResponse Response { /// Gets the client information (identity, authentication, and security roles). ///
/// - /// A instance that represents the client information. + /// + /// A instance or if not + /// authenticated. + /// + /// + /// The instance describes the client. + /// /// public IPrincipal User { get { From 5daaff6ab7c8284fdb127a22d4d2fa968982136d Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 19 Dec 2020 21:25:55 +0900 Subject: [PATCH 3359/6294] [Modify] Replace it --- websocket-sharp/Net/HttpListenerContext.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerContext.cs b/websocket-sharp/Net/HttpListenerContext.cs index d65555e94..828ca5f7f 100644 --- a/websocket-sharp/Net/HttpListenerContext.cs +++ b/websocket-sharp/Net/HttpListenerContext.cs @@ -203,7 +203,9 @@ internal bool Authenticate () return true; if (schm == AuthenticationSchemes.None) { - _response.Close (HttpStatusCode.Forbidden); + _errorStatusCode = 403; + _errorMessage = "Authentication not allowed"; + SendError (); return false; } From a334aa021f750a856d6a6af426b82d311a3d60b5 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 20 Dec 2020 21:47:01 +0900 Subject: [PATCH 3360/6294] [Modify] Add it --- websocket-sharp/Net/HttpListenerContext.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/websocket-sharp/Net/HttpListenerContext.cs b/websocket-sharp/Net/HttpListenerContext.cs index 828ca5f7f..d9e86efe1 100644 --- a/websocket-sharp/Net/HttpListenerContext.cs +++ b/websocket-sharp/Net/HttpListenerContext.cs @@ -191,6 +191,14 @@ private static string createErrorContent ( ); } + private void sendAuthenticationChallenge (string challenge) + { + _response.StatusCode = 401; + _response.Headers.InternalSet ("WWW-Authenticate", challenge, true); + + _response.Close (); + } + #endregion #region Internal Methods From 38dd04a9c129e01d91571078109a0f8be6a9816e Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 21 Dec 2020 21:15:07 +0900 Subject: [PATCH 3361/6294] [Modify] Replace it --- websocket-sharp/Net/HttpListenerContext.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerContext.cs b/websocket-sharp/Net/HttpListenerContext.cs index d9e86efe1..9c38755f9 100644 --- a/websocket-sharp/Net/HttpListenerContext.cs +++ b/websocket-sharp/Net/HttpListenerContext.cs @@ -229,7 +229,7 @@ internal bool Authenticate () if (user == null || !user.Identity.IsAuthenticated) { var chal = new AuthenticationChallenge (schm, realm).ToString (); - _response.CloseWithAuthChallenge (chal); + sendAuthenticationChallenge (chal); return false; } From 2d41e3478e847499fc32edee2015cbdc35b415b8 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 21 Dec 2020 21:17:03 +0900 Subject: [PATCH 3362/6294] [Modify] Remove it --- websocket-sharp/Ext.cs | 8 -------- 1 file changed, 8 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 027a9b437..b868850fa 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -185,14 +185,6 @@ internal static void Close ( response.OutputStream.Close (); } - internal static void CloseWithAuthChallenge ( - this HttpListenerResponse response, string challenge - ) - { - response.Headers.InternalSet ("WWW-Authenticate", challenge, true); - response.Close (HttpStatusCode.Unauthorized); - } - internal static byte[] Compress (this byte[] data, CompressionMethod method) { return method == CompressionMethod.Deflate From 55370bfb785c17e068e1c5d356bb4525798595c3 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 22 Dec 2020 19:42:58 +0900 Subject: [PATCH 3363/6294] [Modify] Replace it --- websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs b/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs index eed49ce1c..ac963c785 100644 --- a/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs @@ -370,7 +370,8 @@ internal void Close () internal void Close (HttpStatusCode code) { - _context.Response.Close (code); + _context.Response.StatusCode = (int) code; + _context.Response.Close (); } #endregion From 419a042a657363262e017c086984678bb06bb3e6 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 22 Dec 2020 19:44:51 +0900 Subject: [PATCH 3364/6294] [Modify] Remove it --- websocket-sharp/Ext.cs | 8 -------- 1 file changed, 8 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index b868850fa..00745ddc0 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -177,14 +177,6 @@ internal static byte[] Append (this ushort code, string reason) return buff.ToArray (); } - internal static void Close ( - this HttpListenerResponse response, HttpStatusCode code - ) - { - response.StatusCode = (int) code; - response.OutputStream.Close (); - } - internal static byte[] Compress (this byte[] data, CompressionMethod method) { return method == CompressionMethod.Deflate From ff81a0ac6bc2b144d19b8c9169b7756369268585 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 23 Dec 2020 19:39:04 +0900 Subject: [PATCH 3365/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerContext.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Net/HttpListenerContext.cs b/websocket-sharp/Net/HttpListenerContext.cs index 9c38755f9..eac93fb5d 100644 --- a/websocket-sharp/Net/HttpListenerContext.cs +++ b/websocket-sharp/Net/HttpListenerContext.cs @@ -71,6 +71,7 @@ public sealed class HttpListenerContext internal HttpListenerContext (HttpConnection connection) { _connection = connection; + _errorStatusCode = 400; _request = new HttpListenerRequest (this); _response = new HttpListenerResponse (this); From 86921077de296282796ac90dfe7516cccb4ce699 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 24 Dec 2020 22:46:42 +0900 Subject: [PATCH 3366/6294] [Modify] Add it --- websocket-sharp/Net/HttpListenerContext.cs | 24 ++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/websocket-sharp/Net/HttpListenerContext.cs b/websocket-sharp/Net/HttpListenerContext.cs index eac93fb5d..643465cc1 100644 --- a/websocket-sharp/Net/HttpListenerContext.cs +++ b/websocket-sharp/Net/HttpListenerContext.cs @@ -240,6 +240,30 @@ internal bool Authenticate () return true; } + internal HttpListenerWebSocketContext GetWebSocketContext (string protocol) + { + if (_websocketContext != null) + return _websocketContext; + + if (protocol != null) { + if (protocol.Length == 0) { + var msg = "An empty string."; + + throw new ArgumentException (msg, "protocol"); + } + + if (!protocol.IsToken ()) { + var msg = "It contains an invalid character."; + + throw new ArgumentException (msg, "protocol"); + } + } + + _websocketContext = new HttpListenerWebSocketContext (this, protocol); + + return _websocketContext; + } + internal bool Register () { return _listener.RegisterContext (this); From f5d9dffc951af042a57e270a43e7c20d7130f41f Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 25 Dec 2020 19:56:13 +0900 Subject: [PATCH 3367/6294] [Modify] Add it --- websocket-sharp/Net/HttpListenerContext.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/websocket-sharp/Net/HttpListenerContext.cs b/websocket-sharp/Net/HttpListenerContext.cs index 643465cc1..478c24aa2 100644 --- a/websocket-sharp/Net/HttpListenerContext.cs +++ b/websocket-sharp/Net/HttpListenerContext.cs @@ -240,6 +240,16 @@ internal bool Authenticate () return true; } + internal HttpListenerWebSocketContext GetWebSocketContext () + { + if (_websocketContext != null) + return _websocketContext; + + _websocketContext = new HttpListenerWebSocketContext (this, null); + + return _websocketContext; + } + internal HttpListenerWebSocketContext GetWebSocketContext (string protocol) { if (_websocketContext != null) From 1a2a4d78457f3355842a026a91e5b51c7633499a Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 26 Dec 2020 22:25:05 +0900 Subject: [PATCH 3368/6294] [Modify] Polish it --- websocket-sharp/Server/HttpServer.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 56925ac6d..b00382bb7 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -936,13 +936,16 @@ private void receiveRequest () { while (true) { HttpListenerContext ctx = null; + try { ctx = _listener.GetContext (); + ThreadPool.QueueUserWorkItem ( state => { try { if (ctx.Request.IsUpgradeRequest ("websocket")) { processRequest (ctx.AcceptWebSocket (null)); + return; } @@ -959,10 +962,12 @@ private void receiveRequest () } catch (HttpListenerException) { _log.Info ("The underlying listener is stopped."); + break; } catch (InvalidOperationException) { _log.Info ("The underlying listener is stopped."); + break; } catch (Exception ex) { From 8ce8cf02f3f9eee31dfd3d0a8a511084bf08a995 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 27 Dec 2020 21:50:24 +0900 Subject: [PATCH 3369/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerContext.cs | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerContext.cs b/websocket-sharp/Net/HttpListenerContext.cs index 478c24aa2..137bb728e 100644 --- a/websocket-sharp/Net/HttpListenerContext.cs +++ b/websocket-sharp/Net/HttpListenerContext.cs @@ -252,23 +252,6 @@ internal HttpListenerWebSocketContext GetWebSocketContext () internal HttpListenerWebSocketContext GetWebSocketContext (string protocol) { - if (_websocketContext != null) - return _websocketContext; - - if (protocol != null) { - if (protocol.Length == 0) { - var msg = "An empty string."; - - throw new ArgumentException (msg, "protocol"); - } - - if (!protocol.IsToken ()) { - var msg = "It contains an invalid character."; - - throw new ArgumentException (msg, "protocol"); - } - } - _websocketContext = new HttpListenerWebSocketContext (this, protocol); return _websocketContext; From 5568531c69a946968a92f5c3528aba6d0ebde4f5 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 27 Dec 2020 21:54:20 +0900 Subject: [PATCH 3370/6294] [Modify] Replace it --- websocket-sharp/Net/HttpListenerContext.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerContext.cs b/websocket-sharp/Net/HttpListenerContext.cs index 137bb728e..1b65d2fe1 100644 --- a/websocket-sharp/Net/HttpListenerContext.cs +++ b/websocket-sharp/Net/HttpListenerContext.cs @@ -342,9 +342,7 @@ public HttpListenerWebSocketContext AcceptWebSocket (string protocol) } } - _websocketContext = new HttpListenerWebSocketContext (this, protocol); - - return _websocketContext; + return GetWebSocketContext (protocol); } #endregion From 571db9f76aa633623d7b3d60281c1588a58faac9 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 28 Dec 2020 19:40:29 +0900 Subject: [PATCH 3371/6294] [Modify] Replace it --- websocket-sharp/Server/HttpServer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index b00382bb7..112c52271 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -944,7 +944,7 @@ private void receiveRequest () state => { try { if (ctx.Request.IsUpgradeRequest ("websocket")) { - processRequest (ctx.AcceptWebSocket (null)); + processRequest (ctx.GetWebSocketContext (null)); return; } From 747361a86f96c7dd16004bf7c64cc2bfecb9fa1c Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 28 Dec 2020 19:48:27 +0900 Subject: [PATCH 3372/6294] [Modify] Polish it --- websocket-sharp/Server/HttpServer.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 112c52271..a243a6f3f 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -914,18 +914,23 @@ private void processRequest (HttpListenerContext context) private void processRequest (HttpListenerWebSocketContext context) { var uri = context.RequestUri; + if (uri == null) { context.Close (HttpStatusCode.BadRequest); + return; } var path = uri.AbsolutePath; + if (path.IndexOfAny (new[] { '%', '+' }) > -1) path = HttpUtility.UrlDecode (path, Encoding.UTF8); WebSocketServiceHost host; + if (!_services.InternalTryGetServiceHost (path, out host)) { context.Close (HttpStatusCode.NotImplemented); + return; } From 9a9ae4852d5beb49f317518a574c311e067c03e1 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 29 Dec 2020 19:38:11 +0900 Subject: [PATCH 3373/6294] [Modify] Remove it --- websocket-sharp/Net/HttpListenerContext.cs | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerContext.cs b/websocket-sharp/Net/HttpListenerContext.cs index 1b65d2fe1..c8e71a9b4 100644 --- a/websocket-sharp/Net/HttpListenerContext.cs +++ b/websocket-sharp/Net/HttpListenerContext.cs @@ -240,16 +240,6 @@ internal bool Authenticate () return true; } - internal HttpListenerWebSocketContext GetWebSocketContext () - { - if (_websocketContext != null) - return _websocketContext; - - _websocketContext = new HttpListenerWebSocketContext (this, null); - - return _websocketContext; - } - internal HttpListenerWebSocketContext GetWebSocketContext (string protocol) { _websocketContext = new HttpListenerWebSocketContext (this, protocol); From 9a9b3e43bd2e0d10113fcdcbe2319281b4bbd58c Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 29 Dec 2020 19:40:13 +0900 Subject: [PATCH 3374/6294] [Modify] 2020 --- websocket-sharp/Net/HttpListenerContext.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerContext.cs b/websocket-sharp/Net/HttpListenerContext.cs index c8e71a9b4..3de938d28 100644 --- a/websocket-sharp/Net/HttpListenerContext.cs +++ b/websocket-sharp/Net/HttpListenerContext.cs @@ -8,7 +8,7 @@ * The MIT License * * Copyright (c) 2005 Novell, Inc. (http://www.novell.com) - * Copyright (c) 2012-2016 sta.blockhead + * Copyright (c) 2012-2020 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From 605ae9173ea66d9b6c67c24d1cf41b79d9555f70 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 30 Dec 2020 21:44:45 +0900 Subject: [PATCH 3375/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerRequest.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index fa0042fd2..b051e1852 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -692,17 +692,21 @@ internal void FinishInitialization () { if (_protocolVersion == HttpVersion.Version10) { finishInitialization10 (); + return; } if (_userHostName == null) { _context.ErrorMessage = "Host header required"; + return; } var transferEnc = _headers["Transfer-Encoding"]; + if (transferEnc != null) { var comparison = StringComparison.OrdinalIgnoreCase; + if (!transferEnc.Equals ("chunked", comparison)) { _context.ErrorMessage = String.Empty; _context.ErrorStatusCode = 501; @@ -723,10 +727,13 @@ internal void FinishInitialization () } var expect = _headers["Expect"]; + if (expect != null) { var comparison = StringComparison.OrdinalIgnoreCase; + if (!expect.Equals ("100-continue", comparison)) { _context.ErrorMessage = "Invalid Expect header"; + return; } From 45db0ea4772c7befdd5df3e0b1a826cd42b81a1c Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 31 Dec 2020 17:30:31 +0900 Subject: [PATCH 3376/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerRequest.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index b051e1852..19dc4fa96 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -583,19 +583,23 @@ public string[] UserLanguages { private void finishInitialization10 () { var transferEnc = _headers["Transfer-Encoding"]; + if (transferEnc != null) { _context.ErrorMessage = "Invalid Transfer-Encoding header"; + return; } if (_httpMethod == "POST") { if (_contentLength == -1) { _context.ErrorMessage = "Content-Length header required"; + return; } if (_contentLength == 0) { _context.ErrorMessage = "Invalid Content-Length header"; + return; } } From 34cb6432734df6cf4818ef1033b5e4cab6f37fc1 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 1 Jan 2021 17:43:55 +0900 Subject: [PATCH 3377/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerRequest.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index 19dc4fa96..372d26974 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -784,47 +784,60 @@ internal bool IsUpgradeRequest (string protocol) internal void SetRequestLine (string requestLine) { var parts = requestLine.Split (new[] { ' ' }, 3); + if (parts.Length < 3) { _context.ErrorMessage = "Invalid request line (parts)"; + return; } var method = parts[0]; + if (method.Length == 0) { _context.ErrorMessage = "Invalid request line (method)"; + return; } var target = parts[1]; + if (target.Length == 0) { _context.ErrorMessage = "Invalid request line (target)"; + return; } var rawVer = parts[2]; + if (rawVer.Length != 8) { _context.ErrorMessage = "Invalid request line (version)"; + return; } if (rawVer.IndexOf ("HTTP/") != 0) { _context.ErrorMessage = "Invalid request line (version)"; + return; } Version ver; + if (!rawVer.Substring (5).TryCreateVersion (out ver)) { _context.ErrorMessage = "Invalid request line (version)"; + return; } if (ver.Major < 1) { _context.ErrorMessage = "Invalid request line (version)"; + return; } if (!method.IsHttpMethod (ver)) { _context.ErrorMessage = "Invalid request line (method)"; + return; } From 4cbd1e0ccdbf9f5cb322a7c14e3c84e19db5dee1 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 1 Jan 2021 17:48:04 +0900 Subject: [PATCH 3378/6294] [Modify] 2021 --- LICENSE.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LICENSE.txt b/LICENSE.txt index 71d3e3128..4d4e56322 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2010-2020 sta.blockhead +Copyright (c) 2010-2021 sta.blockhead Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal From b75699010ac202d716479a9566466d265704e761 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 2 Jan 2021 22:35:40 +0900 Subject: [PATCH 3379/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerRequest.cs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index 372d26974..e04666fe6 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -631,20 +631,26 @@ private RequestStream getInputStream () internal void AddHeader (string headerField) { var start = headerField[0]; + if (start == ' ' || start == '\t') { _context.ErrorMessage = "Invalid header field"; + return; } var colon = headerField.IndexOf (':'); + if (colon < 1) { _context.ErrorMessage = "Invalid header field"; + return; } var name = headerField.Substring (0, colon).Trim (); + if (name.Length == 0 || !name.IsToken ()) { _context.ErrorMessage = "Invalid header name"; + return; } @@ -655,39 +661,48 @@ internal void AddHeader (string headerField) _headers.InternalSet (name, val, false); var lower = name.ToLower (CultureInfo.InvariantCulture); + if (lower == "host") { if (_userHostName != null) { _context.ErrorMessage = "Invalid Host header"; + return; } if (val.Length == 0) { _context.ErrorMessage = "Invalid Host header"; + return; } _userHostName = val; + return; } if (lower == "content-length") { if (_contentLength > -1) { _context.ErrorMessage = "Invalid Content-Length header"; + return; } long len; + if (!Int64.TryParse (val, out len)) { _context.ErrorMessage = "Invalid Content-Length header"; + return; } if (len < 0) { _context.ErrorMessage = "Invalid Content-Length header"; + return; } _contentLength = len; + return; } } From c403715c1d8d386b5676874d563542b50b4bf99d Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 3 Jan 2021 22:08:56 +0900 Subject: [PATCH 3380/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerRequest.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index e04666fe6..d8e7c235d 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -764,10 +764,12 @@ internal void FinishInitialization () internal bool FlushInput () { var input = InputStream; + if (input == Stream.Null) return true; var len = 2048; + if (_contentLength > 0 && _contentLength < len) len = (int) _contentLength; @@ -776,8 +778,10 @@ internal bool FlushInput () while (true) { try { var ares = input.BeginRead (buff, 0, len, null, null); + if (!ares.IsCompleted) { var timeout = 100; + if (!ares.AsyncWaitHandle.WaitOne (timeout)) return false; } From 5a3fc5f4cc9d6f76828e9398913d95c56bb4f9da Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 4 Jan 2021 22:31:31 +0900 Subject: [PATCH 3381/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerRequest.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index d8e7c235d..4d10f1d0d 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -608,6 +608,7 @@ private void finishInitialization10 () private Encoding getContentEncoding () { var val = _headers["Content-Type"]; + if (val == null) return null; From d7baef3c483b639a2b377412211cd35206192f57 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 5 Jan 2021 21:36:08 +0900 Subject: [PATCH 3382/6294] [Modify] Replace it --- websocket-sharp/Net/HttpListenerRequest.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index 4d10f1d0d..8ac1ceacf 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -282,8 +282,12 @@ public string HttpMethod { /// public Stream InputStream { get { - if (_inputStream == null) - _inputStream = getInputStream () ?? Stream.Null; + if (_inputStream == null) { + _inputStream = _contentLength > 0 || _chunked + ? _connection + .GetRequestStream (_contentLength, _chunked) + : Stream.Null; + } return _inputStream; } From 18f8fd00e7211ad5d8fa6906e3d10960ceb7402d Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 6 Jan 2021 20:06:21 +0900 Subject: [PATCH 3383/6294] [Modify] Remove it --- websocket-sharp/Net/HttpListenerRequest.cs | 7 ------- 1 file changed, 7 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index 8ac1ceacf..6ce8a3803 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -622,13 +622,6 @@ private Encoding getContentEncoding () return ret; } - private RequestStream getInputStream () - { - return _contentLength > 0 || _chunked - ? _connection.GetRequestStream (_contentLength, _chunked) - : null; - } - #endregion #region Internal Methods From 4fe77c4330fa06ba4f11ea9e0bd6ec9451155b0e Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 7 Jan 2021 21:15:47 +0900 Subject: [PATCH 3384/6294] [Modify] Polish it --- websocket-sharp/Net/HttpUtility.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 47ea7ee3a..d111cd50f 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -815,10 +815,12 @@ internal static Encoding GetEncoding (string contentType) foreach (var elm in contentType.SplitHeaderValue (';')) { var part = elm.Trim (); + if (part.IndexOf (name, compType) != 0) continue; var val = part.GetValue ('=', true); + if (val == null || val.Length == 0) return null; From 28c5fd3cc78d225e0973728935bb1403d848a8d2 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 8 Jan 2021 19:44:06 +0900 Subject: [PATCH 3385/6294] [Modify] Return the default encoding --- websocket-sharp/Net/HttpListenerRequest.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index 6ce8a3803..b3dc796e5 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -614,12 +614,13 @@ private Encoding getContentEncoding () var val = _headers["Content-Type"]; if (val == null) - return null; + return Encoding.UTF8; Encoding ret; - HttpUtility.TryGetEncoding (val, out ret); - return ret; + return HttpUtility.TryGetEncoding (val, out ret) + ? ret + : Encoding.UTF8; } #endregion From 7e1294db0afe5a63958385422ec5011daf79004f Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 9 Jan 2021 21:41:09 +0900 Subject: [PATCH 3386/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerRequest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index b3dc796e5..5b368e49d 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -167,7 +167,7 @@ public int ClientCertificateError { public Encoding ContentEncoding { get { if (_contentEncoding == null) - _contentEncoding = getContentEncoding () ?? Encoding.UTF8; + _contentEncoding = getContentEncoding (); return _contentEncoding; } From 2ef2c9a95ad05cd04068cc827595d7f7b237e4d7 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 10 Jan 2021 21:56:30 +0900 Subject: [PATCH 3387/6294] [Modify] Replace it --- websocket-sharp/Net/HttpUtility.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index d111cd50f..407c1cad3 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -816,7 +816,7 @@ internal static Encoding GetEncoding (string contentType) foreach (var elm in contentType.SplitHeaderValue (';')) { var part = elm.Trim (); - if (part.IndexOf (name, compType) != 0) + if (!part.StartsWith (name, compType)) continue; var val = part.GetValue ('=', true); From 7002dc56ac34d6524c833f6811d758ccf50dc7f8 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 11 Jan 2021 21:40:55 +0900 Subject: [PATCH 3388/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerRequest.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index 5b368e49d..d5e9e4351 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -121,6 +121,7 @@ internal HttpListenerRequest (HttpListenerContext context) public string[] AcceptTypes { get { var val = _headers["Accept"]; + if (val == null) return null; From 677361354475a9507f2d440b0a3abf7de6fce12e Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 12 Jan 2021 21:23:56 +0900 Subject: [PATCH 3389/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerRequest.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index d5e9e4351..9c9bb4662 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -404,7 +404,9 @@ public NameValueCollection QueryString { get { if (_queryString == null) { var url = Url; - _queryString = QueryStringCollection.Parse ( + + _queryString = QueryStringCollection + .Parse ( url != null ? url.Query : null, Encoding.UTF8 ); From b5c7c7386c5564d68c094a808ae15bd67e629559 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 13 Jan 2021 21:45:44 +0900 Subject: [PATCH 3390/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerRequest.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index 9c9bb4662..804d07dd7 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -468,7 +468,8 @@ public Guid RequestTraceIdentifier { public Uri Url { get { if (!_urlSet) { - _url = HttpUtility.CreateRequestUrl ( + _url = HttpUtility + .CreateRequestUrl ( _rawUrl, _userHostName ?? UserHostAddress, IsWebSocketRequest, From 4ab91cd68838e248e633dfc94d598ee41138c986 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 13 Jan 2021 21:51:58 +0900 Subject: [PATCH 3391/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerRequest.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index 804d07dd7..f41e6000f 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -497,6 +497,7 @@ public Uri Url { public Uri UrlReferrer { get { var val = _headers["Referer"]; + if (val == null) return null; From 6295f623494a1c5b0e350774375b0a507d7b7462 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 14 Jan 2021 21:14:04 +0900 Subject: [PATCH 3392/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerRequest.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index f41e6000f..1a5a121a0 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -575,6 +575,7 @@ public string UserHostName { public string[] UserLanguages { get { var val = _headers["Accept-Language"]; + if (val == null) return null; From c6e1c936b25a985a1af48b15a66745a657a43514 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 15 Jan 2021 21:55:54 +0900 Subject: [PATCH 3393/6294] [Modify] Polish it --- websocket-sharp/Net/HttpUtility.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 407c1cad3..90461d073 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -711,6 +711,7 @@ internal static Uri CreateRequestUrl ( } else if (requestUri.MaybeUri ()) { Uri uri; + if (!Uri.TryCreate (requestUri, UriKind.Absolute, out uri)) return null; @@ -729,6 +730,7 @@ internal static Uri CreateRequestUrl ( } else { // As the authority form. + host = requestUri; } @@ -742,8 +744,8 @@ internal static Uri CreateRequestUrl ( host = String.Format ("{0}:{1}", host, secure ? 443 : 80); var url = String.Format ("{0}://{1}{2}", schm, host, path); - Uri ret; + return Uri.TryCreate (url, UriKind.Absolute, out ret) ? ret : null; } From 5605fb8825e7e6e3015b78af6a08cce89889fe7b Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 16 Jan 2021 22:45:53 +0900 Subject: [PATCH 3394/6294] [Modify] Add it --- websocket-sharp/Ext.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 00745ddc0..5e8e235dd 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1067,6 +1067,14 @@ internal static IEnumerable Trim (this IEnumerable source) yield return elm.Trim (); } + internal static IEnumerable TrimEach ( + this IEnumerable source + ) + { + foreach (var elm in source) + yield return elm.Trim (); + } + internal static string TrimSlashFromEnd (this string value) { var ret = value.TrimEnd ('/'); From 6876900413dada64dc70797d11b296e41d19cac4 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 17 Jan 2021 22:03:56 +0900 Subject: [PATCH 3395/6294] [Modify] Replace it --- websocket-sharp/Net/HttpListenerRequest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index 1a5a121a0..96977a38b 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -580,7 +580,7 @@ public string[] UserLanguages { return null; if (_userLanguages == null) - _userLanguages = val.Split (',').Trim ().ToList ().ToArray (); + _userLanguages = val.Split (',').TrimEach ().ToList ().ToArray (); return _userLanguages; } From b6f8364fdb016ea0f7eabe91db6a6258904ccebd Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 17 Jan 2021 22:05:26 +0900 Subject: [PATCH 3396/6294] [Modify] Replace it --- websocket-sharp/Net/HttpListenerRequest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index 96977a38b..6d7d6c26e 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -128,7 +128,7 @@ public string[] AcceptTypes { if (_acceptTypes == null) { _acceptTypes = val .SplitHeaderValue (',') - .Trim () + .TrimEach () .ToList () .ToArray (); } From 06fc05ee040a1d3013c1cfff190bdb97996f583a Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 18 Jan 2021 21:12:02 +0900 Subject: [PATCH 3397/6294] [Modify] Remove it --- websocket-sharp/Ext.cs | 6 ------ 1 file changed, 6 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 5e8e235dd..10c30bc60 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1061,12 +1061,6 @@ internal static ulong ToUInt64 (this byte[] source, ByteOrder sourceOrder) return BitConverter.ToUInt64 (source.ToHostOrder (sourceOrder), 0); } - internal static IEnumerable Trim (this IEnumerable source) - { - foreach (var elm in source) - yield return elm.Trim (); - } - internal static IEnumerable TrimEach ( this IEnumerable source ) From 8e76ae15f9efa0799231baff0d21c04baa64fc38 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 19 Jan 2021 21:22:19 +0900 Subject: [PATCH 3398/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 10c30bc60..72d941794 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -933,9 +933,9 @@ internal static IEnumerable SplitHeaderValue ( ) { var len = value.Length; + var end = len - 1; var buff = new StringBuilder (32); - var end = len - 1; var escaped = false; var quoted = false; @@ -946,10 +946,12 @@ internal static IEnumerable SplitHeaderValue ( if (c == '"') { if (escaped) { escaped = false; + continue; } quoted = !quoted; + continue; } @@ -968,9 +970,11 @@ internal static IEnumerable SplitHeaderValue ( continue; buff.Length -= 1; + yield return buff.ToString (); buff.Length = 0; + continue; } } From 9b7feae07608e36ce5f0f9b011922e2c5b83f531 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 20 Jan 2021 19:47:19 +0900 Subject: [PATCH 3399/6294] [Modify] Only support HTTP/1.1 --- websocket-sharp/Net/HttpListenerResponse.cs | 51 +-------------------- 1 file changed, 1 insertion(+), 50 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index da1789fef..9fb76f925 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -503,65 +503,16 @@ public Stream OutputStream { } /// - /// Gets or sets the HTTP version used for the response. + /// Gets the HTTP version used for the response. /// /// /// A that represents the HTTP version used for /// the response. /// - /// - /// The value specified for a set operation is . - /// - /// - /// - /// The value specified for a set operation does not have its Major - /// property set to 1. - /// - /// - /// -or- - /// - /// - /// The value specified for a set operation does not have its Minor - /// property set to either 0 or 1. - /// - /// - /// - /// The response is already being sent. - /// - /// - /// This instance is closed. - /// public Version ProtocolVersion { get { return _version; } - - set { - if (_disposed) { - var name = GetType ().ToString (); - throw new ObjectDisposedException (name); - } - - if (_headersSent) { - var msg = "The response is already being sent."; - throw new InvalidOperationException (msg); - } - - if (value == null) - throw new ArgumentNullException ("value"); - - if (value.Major != 1) { - var msg = "Its Major property is not 1."; - throw new ArgumentException (msg, "value"); - } - - if (value.Minor < 0 || value.Minor > 1) { - var msg = "Its Minor property is not 0 or 1."; - throw new ArgumentException (msg, "value"); - } - - _version = value; - } } /// From ddda8a444cc304857bc978c155931d58a6d931c7 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 21 Jan 2021 19:44:27 +0900 Subject: [PATCH 3400/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerResponse.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index 9fb76f925..d6f591dca 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -506,8 +506,13 @@ public Stream OutputStream { /// Gets the HTTP version used for the response. /// /// - /// A that represents the HTTP version used for - /// the response. + /// + /// A that represents the HTTP version used for + /// the response. + /// + /// + /// Always returns same as 1.1. + /// /// public Version ProtocolVersion { get { From 3c9eb649e43933cf602c21742894be49c9e982ae Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 22 Jan 2021 19:47:29 +0900 Subject: [PATCH 3401/6294] [Modify] Only support HTTP/1.1 --- websocket-sharp/Net/HttpListenerRequest.cs | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index 6d7d6c26e..2b06d7dde 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -343,9 +343,7 @@ public bool IsSecureConnection { /// public bool IsWebSocketRequest { get { - return _httpMethod == "GET" - && _protocolVersion > HttpVersion.Version10 - && _headers.Upgrades ("websocket"); + return _httpMethod == "GET" && _headers.Upgrades ("websocket"); } } @@ -714,12 +712,6 @@ internal void AddHeader (string headerField) internal void FinishInitialization () { - if (_protocolVersion == HttpVersion.Version10) { - finishInitialization10 (); - - return; - } - if (_userHostName == null) { _context.ErrorMessage = "Host header required"; @@ -853,8 +845,9 @@ internal void SetRequestLine (string requestLine) return; } - if (ver.Major < 1) { + if (ver != HttpVersion.Version11) { _context.ErrorMessage = "Invalid request line (version)"; + _context.ErrorStatusCode = 505; return; } From b7aa691defba62dfe9b4c190593bf677958eaf14 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 23 Jan 2021 22:00:00 +0900 Subject: [PATCH 3402/6294] [Modify] Remove it --- websocket-sharp/Net/HttpListenerRequest.cs | 25 ---------------------- 1 file changed, 25 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index 2b06d7dde..26fe2301b 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -588,31 +588,6 @@ public string[] UserLanguages { #region Private Methods - private void finishInitialization10 () - { - var transferEnc = _headers["Transfer-Encoding"]; - - if (transferEnc != null) { - _context.ErrorMessage = "Invalid Transfer-Encoding header"; - - return; - } - - if (_httpMethod == "POST") { - if (_contentLength == -1) { - _context.ErrorMessage = "Content-Length header required"; - - return; - } - - if (_contentLength == 0) { - _context.ErrorMessage = "Invalid Content-Length header"; - - return; - } - } - } - private Encoding getContentEncoding () { var val = _headers["Content-Type"]; From d24fb88d0eeb73fbdaa985cbda31cf2f36b60c7e Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 24 Jan 2021 21:46:47 +0900 Subject: [PATCH 3403/6294] [Modify] Replace it --- websocket-sharp/Net/HttpListenerRequest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index 26fe2301b..642bb194b 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -806,7 +806,7 @@ internal void SetRequestLine (string requestLine) return; } - if (rawVer.IndexOf ("HTTP/") != 0) { + if (!rawVer.StartsWith ("HTTP/", StringComparison.Ordinal)) { _context.ErrorMessage = "Invalid request line (version)"; return; From af8f3303fc2d48f8102859aa0574fc38706a95dc Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 25 Jan 2021 21:31:42 +0900 Subject: [PATCH 3404/6294] [Modify] Replace it --- websocket-sharp/Net/HttpListenerRequest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index 642bb194b..2ee9382f6 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -699,7 +699,7 @@ internal void FinishInitialization () var comparison = StringComparison.OrdinalIgnoreCase; if (!transferEnc.Equals ("chunked", comparison)) { - _context.ErrorMessage = String.Empty; + _context.ErrorMessage = "Invalid Transfer-Encoding header"; _context.ErrorStatusCode = 501; return; From 4c32647993e2e5321fe83608cd842a709eebe1b5 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 26 Jan 2021 21:55:23 +0900 Subject: [PATCH 3405/6294] [Modify] 501 --- websocket-sharp/Net/HttpListenerRequest.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index 2ee9382f6..6f24f5d95 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -829,6 +829,7 @@ internal void SetRequestLine (string requestLine) if (!method.IsHttpMethod (ver)) { _context.ErrorMessage = "Invalid request line (method)"; + _context.ErrorStatusCode = 501; return; } From dbdbb68131426bbeec99cbe48d957bcbcc7c0ec7 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 27 Jan 2021 19:39:47 +0900 Subject: [PATCH 3406/6294] [Modify] 2021 --- websocket-sharp/Net/HttpListenerRequest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index 6f24f5d95..fec36551a 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -8,7 +8,7 @@ * The MIT License * * Copyright (c) 2005 Novell, Inc. (http://www.novell.com) - * Copyright (c) 2012-2018 sta.blockhead + * Copyright (c) 2012-2021 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From a4aba13d6ba723bc8eb803923337a1f1a8b5a690 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 27 Jan 2021 19:41:56 +0900 Subject: [PATCH 3407/6294] [Modify] 2021 --- websocket-sharp/Net/HttpListenerResponse.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index d6f591dca..492f51021 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -8,7 +8,7 @@ * The MIT License * * Copyright (c) 2005 Novell, Inc. (http://www.novell.com) - * Copyright (c) 2012-2020 sta.blockhead + * Copyright (c) 2012-2021 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From 70bd4e11ae41221c71c68299ede745739fc27f93 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 27 Jan 2021 19:47:15 +0900 Subject: [PATCH 3408/6294] [Modify] Polish it --- websocket-sharp/Net/RequestStream.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/RequestStream.cs b/websocket-sharp/Net/RequestStream.cs index dd40b3784..d4687baa7 100644 --- a/websocket-sharp/Net/RequestStream.cs +++ b/websocket-sharp/Net/RequestStream.cs @@ -63,7 +63,8 @@ internal RequestStream (Stream stream, byte[] buffer, int offset, int count) } internal RequestStream ( - Stream stream, byte[] buffer, int offset, int count, long contentLength) + Stream stream, byte[] buffer, int offset, int count, long contentLength + ) { _stream = stream; _buffer = buffer; From d41e20750fab456cedcaed19347f8d5f0515e1fc Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 28 Jan 2021 21:56:00 +0900 Subject: [PATCH 3409/6294] [Modify] Polish it --- websocket-sharp/Net/RequestStream.cs | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Net/RequestStream.cs b/websocket-sharp/Net/RequestStream.cs index d4687baa7..26ff6d4a2 100644 --- a/websocket-sharp/Net/RequestStream.cs +++ b/websocket-sharp/Net/RequestStream.cs @@ -115,11 +115,13 @@ public override long Position { #region Private Methods - // Returns 0 if we can keep reading from the base stream, - // > 0 if we read something from the buffer, - // -1 if we had a content length set and we finished reading that many bytes. private int fillFromBuffer (byte[] buffer, int offset, int count) { + // This method returns a int: + // - > 0 If we read something from the buffer + // - 0 If we can keep reading from the base stream + // - -1 If we had a content length set and we finished reading that many bytes + if (buffer == null) throw new ArgumentNullException ("buffer"); @@ -130,9 +132,12 @@ private int fillFromBuffer (byte[] buffer, int offset, int count) throw new ArgumentOutOfRangeException ("count", "A negative value."); var len = buffer.Length; - if (offset + count > len) - throw new ArgumentException ( - "The sum of 'offset' and 'count' is greater than 'buffer' length."); + + if (offset + count > len) { + var msg = "The sum of 'offset' and 'count' is greater than the length of 'buffer'."; + + throw new ArgumentException (msg); + } if (_bodyLeft == 0) return -1; @@ -147,8 +152,10 @@ private int fillFromBuffer (byte[] buffer, int offset, int count) count = (int) _bodyLeft; Buffer.BlockCopy (_buffer, _offset, buffer, offset, count); + _offset += count; _count -= count; + if (_bodyLeft > 0) _bodyLeft -= count; From a688bbf1155e98a2f8110754f6611e3d1238b6d4 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 29 Jan 2021 19:36:32 +0900 Subject: [PATCH 3410/6294] [Modify] Polish it --- websocket-sharp/Net/RequestStream.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/RequestStream.cs b/websocket-sharp/Net/RequestStream.cs index 26ff6d4a2..69cef07c2 100644 --- a/websocket-sharp/Net/RequestStream.cs +++ b/websocket-sharp/Net/RequestStream.cs @@ -148,7 +148,7 @@ private int fillFromBuffer (byte[] buffer, int offset, int count) if (count > _count) count = _count; - if (_bodyLeft > 0 && count > _bodyLeft) + if (_bodyLeft > 0 && _bodyLeft < count) count = (int) _bodyLeft; Buffer.BlockCopy (_buffer, _offset, buffer, offset, count); From 82a214129b20746a435e6182e2768c07ce984c43 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 30 Jan 2021 22:22:49 +0900 Subject: [PATCH 3411/6294] [Modify] Edit it --- websocket-sharp/Net/RequestStream.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/RequestStream.cs b/websocket-sharp/Net/RequestStream.cs index 69cef07c2..0ed6c6eec 100644 --- a/websocket-sharp/Net/RequestStream.cs +++ b/websocket-sharp/Net/RequestStream.cs @@ -118,9 +118,9 @@ public override long Position { private int fillFromBuffer (byte[] buffer, int offset, int count) { // This method returns a int: - // - > 0 If we read something from the buffer - // - 0 If we can keep reading from the base stream - // - -1 If we had a content length set and we finished reading that many bytes + // - > 0 The number of bytes read from the internal buffer + // - 0 0 byte read from the internal buffer + // - -1 No more content data if (buffer == null) throw new ArgumentNullException ("buffer"); From aaf9ab849530779b1b48ad4d995eaabaf85c4657 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 31 Jan 2021 21:57:50 +0900 Subject: [PATCH 3412/6294] [Modify] Polish it --- websocket-sharp/Net/RequestStream.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/RequestStream.cs b/websocket-sharp/Net/RequestStream.cs index 0ed6c6eec..40381779d 100644 --- a/websocket-sharp/Net/RequestStream.cs +++ b/websocket-sharp/Net/RequestStream.cs @@ -125,8 +125,11 @@ private int fillFromBuffer (byte[] buffer, int offset, int count) if (buffer == null) throw new ArgumentNullException ("buffer"); - if (offset < 0) - throw new ArgumentOutOfRangeException ("offset", "A negative value."); + if (offset < 0) { + var msg = "A negative value."; + + throw new ArgumentOutOfRangeException ("offset", msg); + } if (count < 0) throw new ArgumentOutOfRangeException ("count", "A negative value."); From 0e633fa6e9b465ff2fc8e370ec1e0643a60c3b72 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 1 Feb 2021 21:17:48 +0900 Subject: [PATCH 3413/6294] [Modify] Polish it --- websocket-sharp/Net/RequestStream.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/RequestStream.cs b/websocket-sharp/Net/RequestStream.cs index 40381779d..bceacfa91 100644 --- a/websocket-sharp/Net/RequestStream.cs +++ b/websocket-sharp/Net/RequestStream.cs @@ -131,8 +131,11 @@ private int fillFromBuffer (byte[] buffer, int offset, int count) throw new ArgumentOutOfRangeException ("offset", msg); } - if (count < 0) - throw new ArgumentOutOfRangeException ("count", "A negative value."); + if (count < 0) { + var msg = "A negative value."; + + throw new ArgumentOutOfRangeException ("count", msg); + } var len = buffer.Length; From f698486de338f314902bdb4f95f3eeee97664858 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 2 Feb 2021 21:25:20 +0900 Subject: [PATCH 3414/6294] [Modify] Polish it --- websocket-sharp/Net/RequestStream.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/RequestStream.cs b/websocket-sharp/Net/RequestStream.cs index bceacfa91..0e6a09eb8 100644 --- a/websocket-sharp/Net/RequestStream.cs +++ b/websocket-sharp/Net/RequestStream.cs @@ -246,15 +246,16 @@ public override int Read (byte[] buffer, int offset, int count) if (_disposed) throw new ObjectDisposedException (GetType ().ToString ()); - // Call the fillFromBuffer method to check for buffer boundaries even when _bodyLeft is 0. var nread = fillFromBuffer (buffer, offset, count); - if (nread == -1) // No more bytes available (Content-Length). + + if (nread == -1) return 0; if (nread > 0) return nread; nread = _stream.Read (buffer, offset, count); + if (nread > 0 && _bodyLeft > 0) _bodyLeft -= nread; From 3db97ec838aa6c2d9454b6a1d05d8aa4c31c2fa8 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 3 Feb 2021 19:38:48 +0900 Subject: [PATCH 3415/6294] [Modify] Polish it --- websocket-sharp/Net/RequestStream.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/RequestStream.cs b/websocket-sharp/Net/RequestStream.cs index 0e6a09eb8..990c25b3b 100644 --- a/websocket-sharp/Net/RequestStream.cs +++ b/websocket-sharp/Net/RequestStream.cs @@ -218,14 +218,15 @@ public override int EndRead (IAsyncResult asyncResult) if (asyncResult is HttpStreamAsyncResult) { var ares = (HttpStreamAsyncResult) asyncResult; + if (!ares.IsCompleted) ares.AsyncWaitHandle.WaitOne (); return ares.SyncRead; } - // Close on exception? var nread = _stream.EndRead (asyncResult); + if (nread > 0 && _bodyLeft > 0) _bodyLeft -= nread; From bcfc3c6863d7b5cd7bbf919c228ce2ad6ef6826a Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 3 Feb 2021 19:40:35 +0900 Subject: [PATCH 3416/6294] [Modify] Polish it --- websocket-sharp/Net/RequestStream.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/RequestStream.cs b/websocket-sharp/Net/RequestStream.cs index 990c25b3b..6bac41bf0 100644 --- a/websocket-sharp/Net/RequestStream.cs +++ b/websocket-sharp/Net/RequestStream.cs @@ -198,7 +198,8 @@ public override IAsyncResult BeginRead ( } public override IAsyncResult BeginWrite ( - byte[] buffer, int offset, int count, AsyncCallback callback, object state) + byte[] buffer, int offset, int count, AsyncCallback callback, object state + ) { throw new NotSupportedException (); } From c3927a497027f4e80a1edeb1ed7e35770d528ae7 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 4 Feb 2021 19:40:29 +0900 Subject: [PATCH 3417/6294] [Modify] Polish it --- websocket-sharp/Net/RequestStream.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/RequestStream.cs b/websocket-sharp/Net/RequestStream.cs index 6bac41bf0..44f96fe55 100644 --- a/websocket-sharp/Net/RequestStream.cs +++ b/websocket-sharp/Net/RequestStream.cs @@ -173,13 +173,15 @@ private int fillFromBuffer (byte[] buffer, int offset, int count) #region Public Methods public override IAsyncResult BeginRead ( - byte[] buffer, int offset, int count, AsyncCallback callback, object state) + byte[] buffer, int offset, int count, AsyncCallback callback, object state + ) { if (_disposed) throw new ObjectDisposedException (GetType ().ToString ()); var nread = fillFromBuffer (buffer, offset, count); - if (nread > 0 || nread == -1) { + + if (nread != 0) { var ares = new HttpStreamAsyncResult (callback, state); ares.Buffer = buffer; ares.Offset = offset; @@ -190,8 +192,7 @@ public override IAsyncResult BeginRead ( return ares; } - // Avoid reading past the end of the request to allow for HTTP pipelining. - if (_bodyLeft >= 0 && count > _bodyLeft) + if (_bodyLeft >= 0 && _bodyLeft < count) count = (int) _bodyLeft; return _stream.BeginRead (buffer, offset, count, callback, state); From 4f50810791ac879a8838b4d0751198ba2ecde921 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 5 Feb 2021 19:47:12 +0900 Subject: [PATCH 3418/6294] [Modify] Move it --- websocket-sharp/Net/RequestStream.cs | 77 +++++++++++++++++++--------- 1 file changed, 53 insertions(+), 24 deletions(-) diff --git a/websocket-sharp/Net/RequestStream.cs b/websocket-sharp/Net/RequestStream.cs index 44f96fe55..1a4e3f8ad 100644 --- a/websocket-sharp/Net/RequestStream.cs +++ b/websocket-sharp/Net/RequestStream.cs @@ -122,33 +122,10 @@ private int fillFromBuffer (byte[] buffer, int offset, int count) // - 0 0 byte read from the internal buffer // - -1 No more content data - if (buffer == null) - throw new ArgumentNullException ("buffer"); - - if (offset < 0) { - var msg = "A negative value."; - - throw new ArgumentOutOfRangeException ("offset", msg); - } - - if (count < 0) { - var msg = "A negative value."; - - throw new ArgumentOutOfRangeException ("count", msg); - } - - var len = buffer.Length; - - if (offset + count > len) { - var msg = "The sum of 'offset' and 'count' is greater than the length of 'buffer'."; - - throw new ArgumentException (msg); - } - if (_bodyLeft == 0) return -1; - if (_count == 0 || count == 0) + if (_count == 0) return 0; if (count > _count) @@ -179,6 +156,32 @@ public override IAsyncResult BeginRead ( if (_disposed) throw new ObjectDisposedException (GetType ().ToString ()); + if (buffer == null) + throw new ArgumentNullException ("buffer"); + + if (offset < 0) { + var msg = "A negative value."; + + throw new ArgumentOutOfRangeException ("offset", msg); + } + + if (count < 0) { + var msg = "A negative value."; + + throw new ArgumentOutOfRangeException ("count", msg); + } + + var len = buffer.Length; + + if (offset + count > len) { + var msg = "The sum of 'offset' and 'count' is greater than the length of 'buffer'."; + + throw new ArgumentException (msg); + } + + if (count == 0) + return _stream.BeginRead (buffer, offset, count, callback, state); + var nread = fillFromBuffer (buffer, offset, count); if (nread != 0) { @@ -249,6 +252,32 @@ public override int Read (byte[] buffer, int offset, int count) if (_disposed) throw new ObjectDisposedException (GetType ().ToString ()); + if (buffer == null) + throw new ArgumentNullException ("buffer"); + + if (offset < 0) { + var msg = "A negative value."; + + throw new ArgumentOutOfRangeException ("offset", msg); + } + + if (count < 0) { + var msg = "A negative value."; + + throw new ArgumentOutOfRangeException ("count", msg); + } + + var len = buffer.Length; + + if (offset + count > len) { + var msg = "The sum of 'offset' and 'count' is greater than the length of 'buffer'."; + + throw new ArgumentException (msg); + } + + if (count == 0) + return 0; + var nread = fillFromBuffer (buffer, offset, count); if (nread == -1) From e34a51a23a4812e5ce0e18a00b7a4e407c4e40c0 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 6 Feb 2021 21:44:38 +0900 Subject: [PATCH 3419/6294] [Modify] Polish it --- websocket-sharp/Net/RequestStream.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/RequestStream.cs b/websocket-sharp/Net/RequestStream.cs index 1a4e3f8ad..6e5945c32 100644 --- a/websocket-sharp/Net/RequestStream.cs +++ b/websocket-sharp/Net/RequestStream.cs @@ -180,7 +180,7 @@ public override IAsyncResult BeginRead ( } if (count == 0) - return _stream.BeginRead (buffer, offset, count, callback, state); + return _stream.BeginRead (buffer, offset, 0, callback, state); var nread = fillFromBuffer (buffer, offset, count); From e029fa5c78cc195aa6cf0a1212eecbf9f96c9cb6 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 7 Feb 2021 22:11:04 +0900 Subject: [PATCH 3420/6294] [Modify] Edit it --- websocket-sharp/Net/RequestStream.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/RequestStream.cs b/websocket-sharp/Net/RequestStream.cs index 6e5945c32..1cf17a9f1 100644 --- a/websocket-sharp/Net/RequestStream.cs +++ b/websocket-sharp/Net/RequestStream.cs @@ -119,7 +119,7 @@ private int fillFromBuffer (byte[] buffer, int offset, int count) { // This method returns a int: // - > 0 The number of bytes read from the internal buffer - // - 0 0 byte read from the internal buffer + // - 0 No more bytes read from the internal buffer // - -1 No more content data if (_bodyLeft == 0) From 82637a8b11d5553445471a984d8b4e73c4fb24ec Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 7 Feb 2021 22:15:40 +0900 Subject: [PATCH 3421/6294] [Modify] Polish it --- websocket-sharp/Net/RequestStream.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/RequestStream.cs b/websocket-sharp/Net/RequestStream.cs index 1cf17a9f1..2129c5534 100644 --- a/websocket-sharp/Net/RequestStream.cs +++ b/websocket-sharp/Net/RequestStream.cs @@ -153,8 +153,11 @@ public override IAsyncResult BeginRead ( byte[] buffer, int offset, int count, AsyncCallback callback, object state ) { - if (_disposed) - throw new ObjectDisposedException (GetType ().ToString ()); + if (_disposed) { + var name = GetType ().ToString (); + + throw new ObjectDisposedException (name); + } if (buffer == null) throw new ArgumentNullException ("buffer"); From 3a5d4a03f025e7e2c6750bf9b17feb47e36bc560 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 8 Feb 2021 21:35:17 +0900 Subject: [PATCH 3422/6294] [Modify] Polish it --- websocket-sharp/Net/RequestStream.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/RequestStream.cs b/websocket-sharp/Net/RequestStream.cs index 2129c5534..8cf636697 100644 --- a/websocket-sharp/Net/RequestStream.cs +++ b/websocket-sharp/Net/RequestStream.cs @@ -252,8 +252,11 @@ public override void Flush () public override int Read (byte[] buffer, int offset, int count) { - if (_disposed) - throw new ObjectDisposedException (GetType ().ToString ()); + if (_disposed) { + var name = GetType ().ToString (); + + throw new ObjectDisposedException (name); + } if (buffer == null) throw new ArgumentNullException ("buffer"); From c4c475dc33b3620b32f9fdc87f5de7a174cbe74d Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 8 Feb 2021 21:37:02 +0900 Subject: [PATCH 3423/6294] [Modify] Polish it --- websocket-sharp/Net/RequestStream.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/RequestStream.cs b/websocket-sharp/Net/RequestStream.cs index 8cf636697..f5bf784e3 100644 --- a/websocket-sharp/Net/RequestStream.cs +++ b/websocket-sharp/Net/RequestStream.cs @@ -218,8 +218,11 @@ public override void Close () public override int EndRead (IAsyncResult asyncResult) { - if (_disposed) - throw new ObjectDisposedException (GetType ().ToString ()); + if (_disposed) { + var name = GetType ().ToString (); + + throw new ObjectDisposedException (name); + } if (asyncResult == null) throw new ArgumentNullException ("asyncResult"); From 2da360a825d4887a447b31ff254e5453300eab87 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 9 Feb 2021 19:49:31 +0900 Subject: [PATCH 3424/6294] [Modify] Polish it --- websocket-sharp/Net/RequestStream.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Net/RequestStream.cs b/websocket-sharp/Net/RequestStream.cs index f5bf784e3..51d4d779b 100644 --- a/websocket-sharp/Net/RequestStream.cs +++ b/websocket-sharp/Net/RequestStream.cs @@ -46,12 +46,12 @@ internal class RequestStream : Stream { #region Private Fields - private long _bodyLeft; - private byte[] _buffer; - private int _count; - private bool _disposed; - private int _offset; - private Stream _stream; + private long _bodyLeft; + private byte[] _buffer; + private int _count; + private bool _disposed; + private int _offset; + private Stream _stream; #endregion From 31944e58705693c26d8a8c319196f57aa07eeaa4 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 9 Feb 2021 19:50:38 +0900 Subject: [PATCH 3425/6294] [Modify] 2021 --- websocket-sharp/Net/RequestStream.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/RequestStream.cs b/websocket-sharp/Net/RequestStream.cs index 51d4d779b..df40250aa 100644 --- a/websocket-sharp/Net/RequestStream.cs +++ b/websocket-sharp/Net/RequestStream.cs @@ -8,7 +8,7 @@ * The MIT License * * Copyright (c) 2005 Novell, Inc. (http://www.novell.com) - * Copyright (c) 2012-2015 sta.blockhead + * Copyright (c) 2012-2021 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From 90021a804e134f3ae3ba0002d0439998860ad349 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 10 Feb 2021 19:46:54 +0900 Subject: [PATCH 3426/6294] [Modify] Polish it --- websocket-sharp/Net/HttpStreamAsyncResult.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Net/HttpStreamAsyncResult.cs b/websocket-sharp/Net/HttpStreamAsyncResult.cs index 44189303c..9de82e130 100644 --- a/websocket-sharp/Net/HttpStreamAsyncResult.cs +++ b/websocket-sharp/Net/HttpStreamAsyncResult.cs @@ -165,6 +165,7 @@ internal void Complete () return; _completed = true; + if (_waitHandle != null) _waitHandle.Set (); From 9a1c27d489d1e0fa09dd7155244a369a7be17aef Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 10 Feb 2021 19:50:24 +0900 Subject: [PATCH 3427/6294] [Modify] Polish it --- websocket-sharp/Net/HttpStreamAsyncResult.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Net/HttpStreamAsyncResult.cs b/websocket-sharp/Net/HttpStreamAsyncResult.cs index 9de82e130..4c4e67291 100644 --- a/websocket-sharp/Net/HttpStreamAsyncResult.cs +++ b/websocket-sharp/Net/HttpStreamAsyncResult.cs @@ -65,6 +65,7 @@ internal HttpStreamAsyncResult (AsyncCallback callback, object state) { _callback = callback; _state = state; + _sync = new object (); } From c56eae9207907b5114d620f435eabef9afa1214f Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 11 Feb 2021 21:37:44 +0900 Subject: [PATCH 3428/6294] [Modify] Polish it --- websocket-sharp/Net/HttpStreamAsyncResult.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpStreamAsyncResult.cs b/websocket-sharp/Net/HttpStreamAsyncResult.cs index 4c4e67291..3bbbcb0fd 100644 --- a/websocket-sharp/Net/HttpStreamAsyncResult.cs +++ b/websocket-sharp/Net/HttpStreamAsyncResult.cs @@ -137,8 +137,12 @@ public object AsyncState { public WaitHandle AsyncWaitHandle { get { - lock (_sync) - return _waitHandle ?? (_waitHandle = new ManualResetEvent (_completed)); + lock (_sync) { + if (_waitHandle == null) + _waitHandle = new ManualResetEvent (_completed); + + return _waitHandle; + } } } From 89b0d866be002c7b19ca629628f1e3a73cbc6265 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 12 Feb 2021 19:40:13 +0900 Subject: [PATCH 3429/6294] [Modify] Replace it --- websocket-sharp/Net/HttpStreamAsyncResult.cs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpStreamAsyncResult.cs b/websocket-sharp/Net/HttpStreamAsyncResult.cs index 3bbbcb0fd..daac51cbd 100644 --- a/websocket-sharp/Net/HttpStreamAsyncResult.cs +++ b/websocket-sharp/Net/HttpStreamAsyncResult.cs @@ -181,8 +181,19 @@ internal void Complete () internal void Complete (Exception exception) { - _exception = exception; - Complete (); + lock (_sync) { + if (_completed) + return; + + _completed = true; + _exception = exception; + + if (_waitHandle != null) + _waitHandle.Set (); + + if (_callback != null) + _callback.BeginInvoke (this, ar => _callback.EndInvoke (ar), null); + } } #endregion From 808fd5b646660b9b83b4b3df6f8048cdce3032d8 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 13 Feb 2021 21:52:36 +0900 Subject: [PATCH 3430/6294] [Modify] 2021 --- websocket-sharp/Net/HttpStreamAsyncResult.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpStreamAsyncResult.cs b/websocket-sharp/Net/HttpStreamAsyncResult.cs index daac51cbd..09447ea21 100644 --- a/websocket-sharp/Net/HttpStreamAsyncResult.cs +++ b/websocket-sharp/Net/HttpStreamAsyncResult.cs @@ -8,7 +8,7 @@ * The MIT License * * Copyright (c) 2005 Novell, Inc. (http://www.novell.com) - * Copyright (c) 2012-2015 sta.blockhead + * Copyright (c) 2012-2021 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From dd3147ae2dd778b8204f1b61dca4f3f305a5781c Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 14 Feb 2021 22:14:12 +0900 Subject: [PATCH 3431/6294] [Modify] Polish it --- websocket-sharp/Net/ChunkedRequestStream.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Net/ChunkedRequestStream.cs b/websocket-sharp/Net/ChunkedRequestStream.cs index 0eb366a5e..bb42b0e4e 100644 --- a/websocket-sharp/Net/ChunkedRequestStream.cs +++ b/websocket-sharp/Net/ChunkedRequestStream.cs @@ -205,6 +205,7 @@ public override int EndRead (IAsyncResult asyncResult) public override int Read (byte[] buffer, int offset, int count) { var ares = BeginRead (buffer, offset, count, null, null); + return EndRead (ares); } From 95c13ace798f0a91ef6995d246b5bbddebc9dc0a Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 15 Feb 2021 21:49:38 +0900 Subject: [PATCH 3432/6294] [Modify] Polish it --- websocket-sharp/Net/ChunkedRequestStream.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Net/ChunkedRequestStream.cs b/websocket-sharp/Net/ChunkedRequestStream.cs index bb42b0e4e..3194ebb34 100644 --- a/websocket-sharp/Net/ChunkedRequestStream.cs +++ b/websocket-sharp/Net/ChunkedRequestStream.cs @@ -190,6 +190,7 @@ public override int EndRead (IAsyncResult asyncResult) throw new ArgumentNullException ("asyncResult"); var ares = asyncResult as HttpStreamAsyncResult; + if (ares == null) throw new ArgumentException ("A wrong IAsyncResult.", "asyncResult"); From 237c500d6b0584046d41a0a783ff86d7925d1198 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 15 Feb 2021 21:59:57 +0900 Subject: [PATCH 3433/6294] [Modify] Polish it --- websocket-sharp/Net/ChunkedRequestStream.cs | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Net/ChunkedRequestStream.cs b/websocket-sharp/Net/ChunkedRequestStream.cs index 3194ebb34..e64e69235 100644 --- a/websocket-sharp/Net/ChunkedRequestStream.cs +++ b/websocket-sharp/Net/ChunkedRequestStream.cs @@ -183,22 +183,31 @@ public override void Close () public override int EndRead (IAsyncResult asyncResult) { - if (_disposed) - throw new ObjectDisposedException (GetType ().ToString ()); + if (_disposed) { + var name = GetType ().ToString (); + + throw new ObjectDisposedException (name); + } if (asyncResult == null) throw new ArgumentNullException ("asyncResult"); var ares = asyncResult as HttpStreamAsyncResult; - if (ares == null) - throw new ArgumentException ("A wrong IAsyncResult.", "asyncResult"); + if (ares == null) { + var msg = "A wrong IAsyncResult instance."; + + throw new ArgumentException (msg, "asyncResult"); + } if (!ares.IsCompleted) ares.AsyncWaitHandle.WaitOne (); - if (ares.HasException) - throw new HttpListenerException (400, "I/O operation aborted."); + if (ares.HasException) { + var msg = "I/O operation aborted."; + + throw new HttpListenerException (400, msg); + } return ares.Count; } From 7c626bdece5ee5d7e1ae91117d1f83c047ad88b4 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 16 Feb 2021 19:43:46 +0900 Subject: [PATCH 3434/6294] [Modify] 995 --- websocket-sharp/Net/ChunkedRequestStream.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/ChunkedRequestStream.cs b/websocket-sharp/Net/ChunkedRequestStream.cs index e64e69235..6505eba0f 100644 --- a/websocket-sharp/Net/ChunkedRequestStream.cs +++ b/websocket-sharp/Net/ChunkedRequestStream.cs @@ -204,9 +204,9 @@ public override int EndRead (IAsyncResult asyncResult) ares.AsyncWaitHandle.WaitOne (); if (ares.HasException) { - var msg = "I/O operation aborted."; + var msg = "The I/O operation has been aborted."; - throw new HttpListenerException (400, msg); + throw new HttpListenerException (995, msg); } return ares.Count; From 8bddc2e2c4ac756bad6d2ab271a0fd11ffcf5a40 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 16 Feb 2021 19:45:14 +0900 Subject: [PATCH 3435/6294] [Modify] Polish it --- websocket-sharp/Net/ChunkedRequestStream.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Net/ChunkedRequestStream.cs b/websocket-sharp/Net/ChunkedRequestStream.cs index 6505eba0f..dace2d709 100644 --- a/websocket-sharp/Net/ChunkedRequestStream.cs +++ b/websocket-sharp/Net/ChunkedRequestStream.cs @@ -178,6 +178,7 @@ public override void Close () return; _disposed = true; + base.Close (); } From f1741f912b49c7578a5174905b0b8711a1b7f0b5 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 17 Feb 2021 21:03:38 +0900 Subject: [PATCH 3436/6294] [Modify] Polish it --- websocket-sharp/Net/ChunkedRequestStream.cs | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Net/ChunkedRequestStream.cs b/websocket-sharp/Net/ChunkedRequestStream.cs index dace2d709..11912daee 100644 --- a/websocket-sharp/Net/ChunkedRequestStream.cs +++ b/websocket-sharp/Net/ChunkedRequestStream.cs @@ -117,7 +117,8 @@ private void onRead (IAsyncResult asyncResult) #region Public Methods public override IAsyncResult BeginRead ( - byte[] buffer, int offset, int count, AsyncCallback callback, object state) + byte[] buffer, int offset, int count, AsyncCallback callback, object state + ) { if (_disposed) throw new ObjectDisposedException (GetType ().ToString ()); @@ -132,21 +133,27 @@ public override IAsyncResult BeginRead ( throw new ArgumentOutOfRangeException ("count", "A negative value."); var len = buffer.Length; - if (offset + count > len) - throw new ArgumentException ( - "The sum of 'offset' and 'count' is greater than 'buffer' length."); + + if (offset + count > len) { + var msg = "The sum of 'offset' and 'count' is greater than the length of 'buffer'."; + + throw new ArgumentException (msg); + } var ares = new HttpStreamAsyncResult (callback, state); + if (_noMoreData) { ares.Complete (); + return ares; } var nread = _decoder.Read (buffer, offset, count); + offset += nread; count -= nread; + if (count == 0) { - // Got all we wanted, no need to bother the decoder yet. ares.Count = nread; ares.Complete (); @@ -155,6 +162,7 @@ public override IAsyncResult BeginRead ( if (!_decoder.WantMore) { _noMoreData = nread == 0; + ares.Count = nread; ares.Complete (); @@ -167,6 +175,7 @@ public override IAsyncResult BeginRead ( var rstate = new ReadBufferState (buffer, offset, count, ares); rstate.InitialCount += nread; + base.BeginRead (ares.Buffer, ares.Offset, ares.Count, onRead, rstate); return ares; From da0ae5dfd3600ce3dc34314e38009143116389b6 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 17 Feb 2021 21:10:15 +0900 Subject: [PATCH 3437/6294] [Modify] Polish it --- websocket-sharp/Net/ChunkedRequestStream.cs | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Net/ChunkedRequestStream.cs b/websocket-sharp/Net/ChunkedRequestStream.cs index 11912daee..17a5bf2b2 100644 --- a/websocket-sharp/Net/ChunkedRequestStream.cs +++ b/websocket-sharp/Net/ChunkedRequestStream.cs @@ -120,17 +120,26 @@ public override IAsyncResult BeginRead ( byte[] buffer, int offset, int count, AsyncCallback callback, object state ) { - if (_disposed) - throw new ObjectDisposedException (GetType ().ToString ()); + if (_disposed) { + var name = GetType ().ToString (); + + throw new ObjectDisposedException (name); + } if (buffer == null) throw new ArgumentNullException ("buffer"); - if (offset < 0) - throw new ArgumentOutOfRangeException ("offset", "A negative value."); + if (offset < 0) { + var msg = "A negative value."; + + throw new ArgumentOutOfRangeException ("offset", msg); + } - if (count < 0) - throw new ArgumentOutOfRangeException ("count", "A negative value."); + if (count < 0) { + var msg = "A negative value."; + + throw new ArgumentOutOfRangeException ("count", msg); + } var len = buffer.Length; From b0a242681040c825418d35dacf5bec2779ba296d Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 18 Feb 2021 21:14:48 +0900 Subject: [PATCH 3438/6294] [Modify] Polish it --- websocket-sharp/Net/ChunkedRequestStream.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/websocket-sharp/Net/ChunkedRequestStream.cs b/websocket-sharp/Net/ChunkedRequestStream.cs index 17a5bf2b2..6b88302aa 100644 --- a/websocket-sharp/Net/ChunkedRequestStream.cs +++ b/websocket-sharp/Net/ChunkedRequestStream.cs @@ -86,14 +86,19 @@ private void onRead (IAsyncResult asyncResult) { var rstate = (ReadBufferState) asyncResult.AsyncState; var ares = rstate.AsyncResult; + try { var nread = base.EndRead (asyncResult); + _decoder.Write (ares.Buffer, ares.Offset, nread); nread = _decoder.Read (rstate.Buffer, rstate.Offset, rstate.Count); + rstate.Offset += nread; rstate.Count -= nread; + if (rstate.Count == 0 || !_decoder.WantMore || nread == 0) { _noMoreData = !_decoder.WantMore && nread == 0; + ares.Count = rstate.InitialCount - rstate.Count; ares.Complete (); @@ -102,6 +107,7 @@ private void onRead (IAsyncResult asyncResult) ares.Offset = 0; ares.Count = Math.Min (_bufferLength, _decoder.ChunkLeft + 6); + base.BeginRead (ares.Buffer, ares.Offset, ares.Count, onRead, rstate); } catch (Exception ex) { From 3d9bdd3592b70f79e59d6b28fd9a5b0b410399be Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 18 Feb 2021 21:20:00 +0900 Subject: [PATCH 3439/6294] [Modify] Polish it --- websocket-sharp/Net/ChunkedRequestStream.cs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/ChunkedRequestStream.cs b/websocket-sharp/Net/ChunkedRequestStream.cs index 6b88302aa..713d7dd6c 100644 --- a/websocket-sharp/Net/ChunkedRequestStream.cs +++ b/websocket-sharp/Net/ChunkedRequestStream.cs @@ -57,11 +57,19 @@ internal class ChunkedRequestStream : RequestStream #region Internal Constructors internal ChunkedRequestStream ( - Stream stream, byte[] buffer, int offset, int count, HttpListenerContext context) + Stream stream, + byte[] buffer, + int offset, + int count, + HttpListenerContext context + ) : base (stream, buffer, offset, count) { _context = context; - _decoder = new ChunkStream ((WebHeaderCollection) context.Request.Headers); + + _decoder = new ChunkStream ( + (WebHeaderCollection) context.Request.Headers + ); } #endregion From 1084d515ddb0564ecce2db0ad924125635da20f3 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 19 Feb 2021 19:37:39 +0900 Subject: [PATCH 3440/6294] [Modify] Polish it --- websocket-sharp/Net/ChunkedRequestStream.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/ChunkedRequestStream.cs b/websocket-sharp/Net/ChunkedRequestStream.cs index 713d7dd6c..dfb919230 100644 --- a/websocket-sharp/Net/ChunkedRequestStream.cs +++ b/websocket-sharp/Net/ChunkedRequestStream.cs @@ -63,7 +63,7 @@ internal ChunkedRequestStream ( int count, HttpListenerContext context ) - : base (stream, buffer, offset, count) + : base (stream, buffer, offset, count, -1) { _context = context; From 319564a1fb27ab00b9b019b6bfc4f24d9bca6a58 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 19 Feb 2021 19:40:22 +0900 Subject: [PATCH 3441/6294] [Modify] Remove it --- websocket-sharp/Net/RequestStream.cs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/websocket-sharp/Net/RequestStream.cs b/websocket-sharp/Net/RequestStream.cs index df40250aa..a8d9eabae 100644 --- a/websocket-sharp/Net/RequestStream.cs +++ b/websocket-sharp/Net/RequestStream.cs @@ -57,11 +57,6 @@ internal class RequestStream : Stream #region Internal Constructors - internal RequestStream (Stream stream, byte[] buffer, int offset, int count) - : this (stream, buffer, offset, count, -1) - { - } - internal RequestStream ( Stream stream, byte[] buffer, int offset, int count, long contentLength ) From 1d201689154b26de34f4f2c085387e0b6dc0a817 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 20 Feb 2021 21:37:54 +0900 Subject: [PATCH 3442/6294] [Modify] Replace it --- websocket-sharp/Net/ChunkedRequestStream.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/ChunkedRequestStream.cs b/websocket-sharp/Net/ChunkedRequestStream.cs index dfb919230..c266f37fd 100644 --- a/websocket-sharp/Net/ChunkedRequestStream.cs +++ b/websocket-sharp/Net/ChunkedRequestStream.cs @@ -119,7 +119,7 @@ private void onRead (IAsyncResult asyncResult) base.BeginRead (ares.Buffer, ares.Offset, ares.Count, onRead, rstate); } catch (Exception ex) { - _context.ErrorMessage = ex.Message; + _context.ErrorMessage = "I/O operation aborted"; _context.SendError (); ares.Complete (ex); From 00929e01c99aba0e678f28b9505ae12b8c10196a Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 21 Feb 2021 22:07:19 +0900 Subject: [PATCH 3443/6294] [Modify] Use readonly --- websocket-sharp/Net/ChunkedRequestStream.cs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/ChunkedRequestStream.cs b/websocket-sharp/Net/ChunkedRequestStream.cs index c266f37fd..661a3564f 100644 --- a/websocket-sharp/Net/ChunkedRequestStream.cs +++ b/websocket-sharp/Net/ChunkedRequestStream.cs @@ -46,7 +46,7 @@ internal class ChunkedRequestStream : RequestStream { #region Private Fields - private const int _bufferLength = 8192; + private static readonly int _bufferLength; private HttpListenerContext _context; private ChunkStream _decoder; private bool _disposed; @@ -54,6 +54,15 @@ internal class ChunkedRequestStream : RequestStream #endregion + #region Static Constructor + + static ChunkedRequestStream () + { + _bufferLength = 8192; + } + + #endregion + #region Internal Constructors internal ChunkedRequestStream ( From ffc4d4212b577b350650a3220e3e7be40ec695de Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 22 Feb 2021 21:51:22 +0900 Subject: [PATCH 3444/6294] [Modify] 2021 --- websocket-sharp/Net/ChunkedRequestStream.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/ChunkedRequestStream.cs b/websocket-sharp/Net/ChunkedRequestStream.cs index 661a3564f..925bcf1c6 100644 --- a/websocket-sharp/Net/ChunkedRequestStream.cs +++ b/websocket-sharp/Net/ChunkedRequestStream.cs @@ -8,7 +8,7 @@ * The MIT License * * Copyright (c) 2005 Novell, Inc. (http://www.novell.com) - * Copyright (c) 2012-2015 sta.blockhead + * Copyright (c) 2012-2021 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From 3adf4a1aa88214af221e34a8d50ca6527e9afa3e Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 22 Feb 2021 21:54:11 +0900 Subject: [PATCH 3445/6294] [Modify] Polish it --- websocket-sharp/Net/ReadBufferState.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/ReadBufferState.cs b/websocket-sharp/Net/ReadBufferState.cs index 780a69b5a..039d3c9aa 100644 --- a/websocket-sharp/Net/ReadBufferState.cs +++ b/websocket-sharp/Net/ReadBufferState.cs @@ -56,7 +56,8 @@ internal class ReadBufferState #region Public Constructors public ReadBufferState ( - byte[] buffer, int offset, int count, HttpStreamAsyncResult asyncResult) + byte[] buffer, int offset, int count, HttpStreamAsyncResult asyncResult + ) { _buffer = buffer; _offset = offset; From 8178271aac1e615c00d42a9209d39c7586bb6d9c Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 23 Feb 2021 20:10:47 +0900 Subject: [PATCH 3446/6294] [Modify] Polish it --- websocket-sharp/Net/ReadBufferState.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/ReadBufferState.cs b/websocket-sharp/Net/ReadBufferState.cs index 039d3c9aa..b967b4a43 100644 --- a/websocket-sharp/Net/ReadBufferState.cs +++ b/websocket-sharp/Net/ReadBufferState.cs @@ -62,8 +62,9 @@ public ReadBufferState ( _buffer = buffer; _offset = offset; _count = count; - _initialCount = count; _asyncResult = asyncResult; + + _initialCount = count; } #endregion From 604f2f5ed3fd1131bd0767c09d2cb9537931540e Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 23 Feb 2021 20:12:51 +0900 Subject: [PATCH 3447/6294] [Modify] 2021 --- websocket-sharp/Net/ReadBufferState.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/ReadBufferState.cs b/websocket-sharp/Net/ReadBufferState.cs index b967b4a43..1d8280f00 100644 --- a/websocket-sharp/Net/ReadBufferState.cs +++ b/websocket-sharp/Net/ReadBufferState.cs @@ -8,7 +8,7 @@ * The MIT License * * Copyright (c) 2005 Novell, Inc. (http://www.novell.com) - * Copyright (c) 2014-2015 sta.blockhead + * Copyright (c) 2014-2021 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From 2b5d9eb1f218f027904cd35678aef974116910b5 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 24 Feb 2021 20:21:39 +0900 Subject: [PATCH 3448/6294] [Modify] Polish it --- websocket-sharp/Net/ChunkStream.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Net/ChunkStream.cs b/websocket-sharp/Net/ChunkStream.cs index a5271b573..071e1b476 100644 --- a/websocket-sharp/Net/ChunkStream.cs +++ b/websocket-sharp/Net/ChunkStream.cs @@ -67,6 +67,7 @@ internal class ChunkStream public ChunkStream (WebHeaderCollection headers) { _headers = headers; + _chunkSize = -1; _chunks = new List (); _saved = new StringBuilder (); From 16ca3825a8a9ea97bdf31d4193ccb06137745165 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 24 Feb 2021 20:23:29 +0900 Subject: [PATCH 3449/6294] [Modify] Polish it --- websocket-sharp/Net/ChunkStream.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/ChunkStream.cs b/websocket-sharp/Net/ChunkStream.cs index 071e1b476..67d986687 100644 --- a/websocket-sharp/Net/ChunkStream.cs +++ b/websocket-sharp/Net/ChunkStream.cs @@ -73,7 +73,9 @@ public ChunkStream (WebHeaderCollection headers) _saved = new StringBuilder (); } - public ChunkStream (byte[] buffer, int offset, int count, WebHeaderCollection headers) + public ChunkStream ( + byte[] buffer, int offset, int count, WebHeaderCollection headers + ) : this (headers) { Write (buffer, offset, count); From fc2236c18123f94e98aa0e0403827557cd873d7f Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 25 Feb 2021 20:04:18 +0900 Subject: [PATCH 3450/6294] [Modify] Polish it --- websocket-sharp/Net/ChunkStream.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/ChunkStream.cs b/websocket-sharp/Net/ChunkStream.cs index 67d986687..4dd786540 100644 --- a/websocket-sharp/Net/ChunkStream.cs +++ b/websocket-sharp/Net/ChunkStream.cs @@ -114,19 +114,22 @@ public bool WantMore { private int read (byte[] buffer, int offset, int count) { var nread = 0; - var cnt = _chunks.Count; + for (var i = 0; i < cnt; i++) { var chunk = _chunks[i]; + if (chunk == null) continue; if (chunk.ReadLeft == 0) { _chunks[i] = null; + continue; } nread += chunk.Read (buffer, offset + nread, count - nread); + if (nread == count) break; } From 614be2504480978cb13000d51970cec3b54044ef Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 25 Feb 2021 20:15:44 +0900 Subject: [PATCH 3451/6294] [Modify] Polish it --- websocket-sharp/Net/ChunkStream.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Net/ChunkStream.cs b/websocket-sharp/Net/ChunkStream.cs index 4dd786540..12b84fb44 100644 --- a/websocket-sharp/Net/ChunkStream.cs +++ b/websocket-sharp/Net/ChunkStream.cs @@ -140,6 +140,7 @@ private int read (byte[] buffer, int offset, int count) private static string removeChunkExtension (string value) { var idx = value.IndexOf (';'); + return idx > -1 ? value.Substring (0, idx) : value; } From fa470026cbe1f9e42c83742b96aeea53831b0a73 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 25 Feb 2021 20:19:44 +0900 Subject: [PATCH 3452/6294] [Modify] Polish it --- websocket-sharp/Net/ChunkStream.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Net/ChunkStream.cs b/websocket-sharp/Net/ChunkStream.cs index 12b84fb44..204608cce 100644 --- a/websocket-sharp/Net/ChunkStream.cs +++ b/websocket-sharp/Net/ChunkStream.cs @@ -151,6 +151,7 @@ private InputChunkState seekCrLf (byte[] buffer, ref int offset, int length) throwProtocolViolation ("CR is expected."); _sawCr = true; + if (offset == length) return InputChunkState.DataEnded; } From 642dd28b61c484b66a1125ebc4c58471b4eeb6fa Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 26 Feb 2021 20:00:03 +0900 Subject: [PATCH 3453/6294] [Modify] Polish it --- websocket-sharp/Net/ChunkStream.cs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/ChunkStream.cs b/websocket-sharp/Net/ChunkStream.cs index 204608cce..ff8756333 100644 --- a/websocket-sharp/Net/ChunkStream.cs +++ b/websocket-sharp/Net/ChunkStream.cs @@ -162,11 +162,15 @@ private InputChunkState seekCrLf (byte[] buffer, ref int offset, int length) return InputChunkState.None; } - private InputChunkState setChunkSize (byte[] buffer, ref int offset, int length) + private InputChunkState setChunkSize ( + byte[] buffer, ref int offset, int length + ) { byte b = 0; + while (offset < length) { b = buffer[offset++]; + if (_sawCr) { if (b != 10) throwProtocolViolation ("LF is expected."); @@ -176,6 +180,7 @@ private InputChunkState setChunkSize (byte[] buffer, ref int offset, int length) if (b == 13) { _sawCr = true; + continue; } @@ -196,9 +201,12 @@ private InputChunkState setChunkSize (byte[] buffer, ref int offset, int length) return InputChunkState.None; _chunkRead = 0; + try { _chunkSize = Int32.Parse ( - removeChunkExtension (_saved.ToString ()), NumberStyles.HexNumber); + removeChunkExtension (_saved.ToString ()), + NumberStyles.HexNumber + ); } catch { throwProtocolViolation ("The chunk size cannot be parsed."); @@ -206,6 +214,7 @@ private InputChunkState setChunkSize (byte[] buffer, ref int offset, int length) if (_chunkSize == 0) { _trailerState = 2; + return InputChunkState.Trailer; } From db7203aa0b4f6ec7b79ec07b638a2212b0cd2f67 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 27 Feb 2021 21:26:52 +0900 Subject: [PATCH 3454/6294] [Modify] Polish it --- websocket-sharp/Net/ChunkStream.cs | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/ChunkStream.cs b/websocket-sharp/Net/ChunkStream.cs index ff8756333..c4f11ad1b 100644 --- a/websocket-sharp/Net/ChunkStream.cs +++ b/websocket-sharp/Net/ChunkStream.cs @@ -221,13 +221,17 @@ private InputChunkState setChunkSize ( return InputChunkState.Data; } - private InputChunkState setTrailer (byte[] buffer, ref int offset, int length) + private InputChunkState setTrailer ( + byte[] buffer, ref int offset, int length + ) { // Check if no trailer. if (_trailerState == 2 && buffer[offset] == 13 && _saved.Length == 0) { offset++; + if (offset < length && buffer[offset] == 10) { offset++; + return InputChunkState.End; } @@ -237,6 +241,7 @@ private InputChunkState setTrailer (byte[] buffer, ref int offset, int length) while (offset < length && _trailerState < 4) { var b = buffer[offset++]; _saved.Append ((char) b); + if (_saved.Length > 4196) throwProtocolViolation ("The trailer is too long."); @@ -245,11 +250,13 @@ private InputChunkState setTrailer (byte[] buffer, ref int offset, int length) throwProtocolViolation ("LF is expected."); _trailerState++; + continue; } if (b == 13) { _trailerState++; + continue; } @@ -265,9 +272,14 @@ private InputChunkState setTrailer (byte[] buffer, ref int offset, int length) _saved.Length -= 2; var reader = new StringReader (_saved.ToString ()); - string line; - while ((line = reader.ReadLine ()) != null && line.Length > 0) + while (true) { + var line = reader.ReadLine (); + + if (line == null || line.Length == 0) + break; + _headers.Add (line); + } return InputChunkState.End; } From aa1b31b439cda82beee14821a622557b2102660b Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 27 Feb 2021 21:28:10 +0900 Subject: [PATCH 3455/6294] [Modify] Polish it --- websocket-sharp/Net/ChunkStream.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/ChunkStream.cs b/websocket-sharp/Net/ChunkStream.cs index c4f11ad1b..772d7a36f 100644 --- a/websocket-sharp/Net/ChunkStream.cs +++ b/websocket-sharp/Net/ChunkStream.cs @@ -286,7 +286,9 @@ private InputChunkState setTrailer ( private static void throwProtocolViolation (string message) { - throw new WebException (message, null, WebExceptionStatus.ServerProtocolViolation, null); + throw new WebException ( + message, null, WebExceptionStatus.ServerProtocolViolation, null + ); } private void write (byte[] buffer, ref int offset, int length) From 26b108ae29e66704b7db09a8dbe1a7d05c027d98 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 28 Feb 2021 22:07:24 +0900 Subject: [PATCH 3456/6294] [Modify] Polish it --- websocket-sharp/Net/ChunkStream.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/websocket-sharp/Net/ChunkStream.cs b/websocket-sharp/Net/ChunkStream.cs index 772d7a36f..124f8bad7 100644 --- a/websocket-sharp/Net/ChunkStream.cs +++ b/websocket-sharp/Net/ChunkStream.cs @@ -298,6 +298,7 @@ private void write (byte[] buffer, ref int offset, int length) if (_state == InputChunkState.None) { _state = setChunkSize (buffer, ref offset, length); + if (_state == InputChunkState.None) return; @@ -308,12 +309,14 @@ private void write (byte[] buffer, ref int offset, int length) if (_state == InputChunkState.Data && offset < length) { _state = writeData (buffer, ref offset, length); + if (_state == InputChunkState.Data) return; } if (_state == InputChunkState.DataEnded && offset < length) { _state = seekCrLf (buffer, ref offset, length); + if (_state == InputChunkState.DataEnded) return; @@ -322,6 +325,7 @@ private void write (byte[] buffer, ref int offset, int length) if (_state == InputChunkState.Trailer && offset < length) { _state = setTrailer (buffer, ref offset, length); + if (_state == InputChunkState.Trailer) return; From 94ef38537ca9add5d8fa6ebc58eb0e6f97035270 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 1 Mar 2021 21:24:30 +0900 Subject: [PATCH 3457/6294] [Modify] Polish it --- websocket-sharp/Net/ChunkStream.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/ChunkStream.cs b/websocket-sharp/Net/ChunkStream.cs index 124f8bad7..ba2707063 100644 --- a/websocket-sharp/Net/ChunkStream.cs +++ b/websocket-sharp/Net/ChunkStream.cs @@ -336,10 +336,13 @@ private void write (byte[] buffer, ref int offset, int length) write (buffer, ref offset, length); } - private InputChunkState writeData (byte[] buffer, ref int offset, int length) + private InputChunkState writeData ( + byte[] buffer, ref int offset, int length + ) { var cnt = length - offset; var left = _chunkSize - _chunkRead; + if (cnt > left) cnt = left; @@ -350,7 +353,9 @@ private InputChunkState writeData (byte[] buffer, ref int offset, int length) offset += cnt; _chunkRead += cnt; - return _chunkRead == _chunkSize ? InputChunkState.DataEnded : InputChunkState.Data; + return _chunkRead == _chunkSize + ? InputChunkState.DataEnded + : InputChunkState.Data; } #endregion From 4b1c10be3dce21e72145e8454a8bcad1ac08543a Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 1 Mar 2021 21:26:26 +0900 Subject: [PATCH 3458/6294] [Modify] Polish it --- websocket-sharp/Net/ChunkStream.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Net/ChunkStream.cs b/websocket-sharp/Net/ChunkStream.cs index ba2707063..15418e57c 100644 --- a/websocket-sharp/Net/ChunkStream.cs +++ b/websocket-sharp/Net/ChunkStream.cs @@ -366,6 +366,7 @@ internal void ResetBuffer () { _chunkRead = 0; _chunkSize = -1; + _chunks.Clear (); } From 0ffec334bb9b5dc3318f1160ad3e4bfb2935f009 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 2 Mar 2021 19:34:33 +0900 Subject: [PATCH 3459/6294] [Modify] Polish it --- websocket-sharp/Net/ChunkStream.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/ChunkStream.cs b/websocket-sharp/Net/ChunkStream.cs index 15418e57c..fb495ab80 100644 --- a/websocket-sharp/Net/ChunkStream.cs +++ b/websocket-sharp/Net/ChunkStream.cs @@ -370,9 +370,12 @@ internal void ResetBuffer () _chunks.Clear (); } - internal int WriteAndReadBack (byte[] buffer, int offset, int writeCount, int readCount) + internal int WriteAndReadBack ( + byte[] buffer, int offset, int writeCount, int readCount + ) { Write (buffer, offset, writeCount); + return Read (buffer, offset, readCount); } From f6c5c70cd9bcbb9e02bc9006f1de9c9c28b228fb Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 2 Mar 2021 19:40:21 +0900 Subject: [PATCH 3460/6294] [Modify] Polish it --- websocket-sharp/Net/Chunk.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/Chunk.cs b/websocket-sharp/Net/Chunk.cs index 7b6268b7f..869136b33 100644 --- a/websocket-sharp/Net/Chunk.cs +++ b/websocket-sharp/Net/Chunk.cs @@ -74,13 +74,15 @@ public int ReadLeft { public int Read (byte[] buffer, int offset, int count) { var left = _data.Length - _offset; + if (left == 0) - return left; + return 0; if (count > left) count = left; Buffer.BlockCopy (_data, _offset, buffer, offset, count); + _offset += count; return count; From b2e7ca6777efa3e7fca393a1e1674e5ffd320156 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 3 Mar 2021 19:54:14 +0900 Subject: [PATCH 3461/6294] [Modify] 2021 --- websocket-sharp/Net/Chunk.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/Chunk.cs b/websocket-sharp/Net/Chunk.cs index 869136b33..9ed28f864 100644 --- a/websocket-sharp/Net/Chunk.cs +++ b/websocket-sharp/Net/Chunk.cs @@ -8,7 +8,7 @@ * The MIT License * * Copyright (c) 2003 Ximian, Inc (http://www.ximian.com) - * Copyright (c) 2014-2015 sta.blockhead + * Copyright (c) 2014-2021 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From c251d3eff75475b02d6e3dd0d489f16eaa8a12e8 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 3 Mar 2021 19:57:34 +0900 Subject: [PATCH 3462/6294] [Modify] Remove it --- websocket-sharp/Net/ChunkStream.cs | 9 --------- 1 file changed, 9 deletions(-) diff --git a/websocket-sharp/Net/ChunkStream.cs b/websocket-sharp/Net/ChunkStream.cs index fb495ab80..711bf3c54 100644 --- a/websocket-sharp/Net/ChunkStream.cs +++ b/websocket-sharp/Net/ChunkStream.cs @@ -370,15 +370,6 @@ internal void ResetBuffer () _chunks.Clear (); } - internal int WriteAndReadBack ( - byte[] buffer, int offset, int writeCount, int readCount - ) - { - Write (buffer, offset, writeCount); - - return Read (buffer, offset, readCount); - } - #endregion #region Public Methods From 7796d803c4e5f3444fef3ab46259701658f46394 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 4 Mar 2021 20:15:28 +0900 Subject: [PATCH 3463/6294] [Modify] Polish it --- websocket-sharp/Net/ChunkStream.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/ChunkStream.cs b/websocket-sharp/Net/ChunkStream.cs index 711bf3c54..b77bb545b 100644 --- a/websocket-sharp/Net/ChunkStream.cs +++ b/websocket-sharp/Net/ChunkStream.cs @@ -291,7 +291,7 @@ private static void throwProtocolViolation (string message) ); } - private void write (byte[] buffer, ref int offset, int length) + private void write (byte[] buffer, int offset, int length) { if (_state == InputChunkState.End) throwProtocolViolation ("The chunks were ended."); @@ -333,7 +333,7 @@ private void write (byte[] buffer, ref int offset, int length) } if (offset < length) - write (buffer, ref offset, length); + write (buffer, offset, length); } private InputChunkState writeData ( @@ -387,7 +387,7 @@ public void Write (byte[] buffer, int offset, int count) if (count <= 0) return; - write (buffer, ref offset, offset + count); + write (buffer, offset, offset + count); } #endregion From 764eb2c1331159816c960317cee9cccbb5e455c5 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 5 Mar 2021 19:37:01 +0900 Subject: [PATCH 3464/6294] [Modify] Remove it --- websocket-sharp/Net/ChunkStream.cs | 8 -------- 1 file changed, 8 deletions(-) diff --git a/websocket-sharp/Net/ChunkStream.cs b/websocket-sharp/Net/ChunkStream.cs index b77bb545b..a019ea8e7 100644 --- a/websocket-sharp/Net/ChunkStream.cs +++ b/websocket-sharp/Net/ChunkStream.cs @@ -73,14 +73,6 @@ public ChunkStream (WebHeaderCollection headers) _saved = new StringBuilder (); } - public ChunkStream ( - byte[] buffer, int offset, int count, WebHeaderCollection headers - ) - : this (headers) - { - Write (buffer, offset, count); - } - #endregion #region Internal Properties From dc54e949144b264a7fe7eefa02b37f13a598abb6 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 6 Mar 2021 22:07:47 +0900 Subject: [PATCH 3465/6294] [Modify] Polish it --- websocket-sharp/Net/ChunkStream.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/ChunkStream.cs b/websocket-sharp/Net/ChunkStream.cs index a019ea8e7..0339e2a1c 100644 --- a/websocket-sharp/Net/ChunkStream.cs +++ b/websocket-sharp/Net/ChunkStream.cs @@ -299,7 +299,10 @@ private void write (byte[] buffer, int offset, int length) _gotIt = false; } - if (_state == InputChunkState.Data && offset < length) { + if (_state == InputChunkState.Data) { + if (offset >= length) + return; + _state = writeData (buffer, ref offset, length); if (_state == InputChunkState.Data) From 48266527a5c23743ff814d7669ab1723bcaf3282 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 6 Mar 2021 22:11:14 +0900 Subject: [PATCH 3466/6294] [Modify] Polish it --- websocket-sharp/Net/ChunkStream.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/ChunkStream.cs b/websocket-sharp/Net/ChunkStream.cs index 0339e2a1c..c1f574b19 100644 --- a/websocket-sharp/Net/ChunkStream.cs +++ b/websocket-sharp/Net/ChunkStream.cs @@ -309,7 +309,10 @@ private void write (byte[] buffer, int offset, int length) return; } - if (_state == InputChunkState.DataEnded && offset < length) { + if (_state == InputChunkState.DataEnded) { + if (offset >= length) + return; + _state = seekCrLf (buffer, ref offset, length); if (_state == InputChunkState.DataEnded) From 7790de7846aa92d4dbe605df519e90d8ad253953 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 7 Mar 2021 21:23:40 +0900 Subject: [PATCH 3467/6294] [Modify] Polish it --- websocket-sharp/Net/ChunkStream.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/ChunkStream.cs b/websocket-sharp/Net/ChunkStream.cs index c1f574b19..910644854 100644 --- a/websocket-sharp/Net/ChunkStream.cs +++ b/websocket-sharp/Net/ChunkStream.cs @@ -321,7 +321,10 @@ private void write (byte[] buffer, int offset, int length) _sawCr = false; } - if (_state == InputChunkState.Trailer && offset < length) { + if (_state == InputChunkState.Trailer) { + if (offset >= length) + return; + _state = setTrailer (buffer, ref offset, length); if (_state == InputChunkState.Trailer) From 1c842fedaf900e59988e356b92da1f1ce10a77d8 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 8 Mar 2021 21:12:35 +0900 Subject: [PATCH 3468/6294] [Modify] Polish it --- websocket-sharp/Net/ChunkStream.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/ChunkStream.cs b/websocket-sharp/Net/ChunkStream.cs index 910644854..083da8f65 100644 --- a/websocket-sharp/Net/ChunkStream.cs +++ b/websocket-sharp/Net/ChunkStream.cs @@ -333,8 +333,10 @@ private void write (byte[] buffer, int offset, int length) _saved.Length = 0; } - if (offset < length) - write (buffer, offset, length); + if (offset >= length) + return; + + write (buffer, offset, length); } private InputChunkState writeData ( From 8058f23f96c3a678366f1ed7e1182120ef946e4f Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 9 Mar 2021 19:44:09 +0900 Subject: [PATCH 3469/6294] [Modify] Polish it --- websocket-sharp/Net/ChunkStream.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/ChunkStream.cs b/websocket-sharp/Net/ChunkStream.cs index 083da8f65..4af1a28b1 100644 --- a/websocket-sharp/Net/ChunkStream.cs +++ b/websocket-sharp/Net/ChunkStream.cs @@ -230,7 +230,10 @@ private InputChunkState setTrailer ( offset--; } - while (offset < length && _trailerState < 4) { + while (offset < length) { + if (_trailerState == 4) + break; + var b = buffer[offset++]; _saved.Append ((char) b); From 99ded81873c3b20726cbd32fb187f5e287db07e5 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 10 Mar 2021 19:35:27 +0900 Subject: [PATCH 3470/6294] [Modify] Polish it --- websocket-sharp/Net/ChunkStream.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/ChunkStream.cs b/websocket-sharp/Net/ChunkStream.cs index 4af1a28b1..b2acd6535 100644 --- a/websocket-sharp/Net/ChunkStream.cs +++ b/websocket-sharp/Net/ChunkStream.cs @@ -231,7 +231,7 @@ private InputChunkState setTrailer ( } while (offset < length) { - if (_trailerState == 4) + if (_trailerState == 4) // CR LF CR LF break; var b = buffer[offset++]; @@ -240,7 +240,7 @@ private InputChunkState setTrailer ( if (_saved.Length > 4196) throwProtocolViolation ("The trailer is too long."); - if (_trailerState == 1 || _trailerState == 3) { + if (_trailerState == 1 || _trailerState == 3) { // CR or CR LF CR if (b != 10) throwProtocolViolation ("LF is expected."); From e9f3e05fd2db82647a2115ff47777ac1fca58581 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 11 Mar 2021 19:38:23 +0900 Subject: [PATCH 3471/6294] [Modify] Remove it --- websocket-sharp/Net/ChunkStream.cs | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/websocket-sharp/Net/ChunkStream.cs b/websocket-sharp/Net/ChunkStream.cs index b2acd6535..7da45e3fe 100644 --- a/websocket-sharp/Net/ChunkStream.cs +++ b/websocket-sharp/Net/ChunkStream.cs @@ -217,19 +217,6 @@ private InputChunkState setTrailer ( byte[] buffer, ref int offset, int length ) { - // Check if no trailer. - if (_trailerState == 2 && buffer[offset] == 13 && _saved.Length == 0) { - offset++; - - if (offset < length && buffer[offset] == 10) { - offset++; - - return InputChunkState.End; - } - - offset--; - } - while (offset < length) { if (_trailerState == 4) // CR LF CR LF break; @@ -264,6 +251,9 @@ private InputChunkState setTrailer ( if (_trailerState < 4) return InputChunkState.Trailer; + if (_saved.Length == 2) + return InputChunkState.End; + _saved.Length -= 2; var reader = new StringReader (_saved.ToString ()); From 5e50439d4c5e1b38acb5262a8047cb6f0cf7185a Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 11 Mar 2021 19:41:37 +0900 Subject: [PATCH 3472/6294] [Modify] Move it --- websocket-sharp/Net/ChunkStream.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/ChunkStream.cs b/websocket-sharp/Net/ChunkStream.cs index 7da45e3fe..29bddabff 100644 --- a/websocket-sharp/Net/ChunkStream.cs +++ b/websocket-sharp/Net/ChunkStream.cs @@ -224,9 +224,6 @@ private InputChunkState setTrailer ( var b = buffer[offset++]; _saved.Append ((char) b); - if (_saved.Length > 4196) - throwProtocolViolation ("The trailer is too long."); - if (_trailerState == 1 || _trailerState == 3) { // CR or CR LF CR if (b != 10) throwProtocolViolation ("LF is expected."); @@ -248,6 +245,9 @@ private InputChunkState setTrailer ( _trailerState = 0; } + if (_saved.Length > 4196) + throwProtocolViolation ("The trailer is too long."); + if (_trailerState < 4) return InputChunkState.Trailer; From 5880514b235daf25415c9379ffc2066a7190169d Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 12 Mar 2021 20:26:16 +0900 Subject: [PATCH 3473/6294] [Modify] Polish it --- websocket-sharp/Net/ChunkStream.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/ChunkStream.cs b/websocket-sharp/Net/ChunkStream.cs index 29bddabff..8515764de 100644 --- a/websocket-sharp/Net/ChunkStream.cs +++ b/websocket-sharp/Net/ChunkStream.cs @@ -245,16 +245,18 @@ private InputChunkState setTrailer ( _trailerState = 0; } - if (_saved.Length > 4196) + var len = _saved.Length; + + if (len > 4196) throwProtocolViolation ("The trailer is too long."); if (_trailerState < 4) return InputChunkState.Trailer; - if (_saved.Length == 2) + if (len == 2) return InputChunkState.End; - _saved.Length -= 2; + _saved.Length = len - 2; var reader = new StringReader (_saved.ToString ()); while (true) { From 0df1c1e922831f8a11e74ad510eaa4ac614694c1 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 13 Mar 2021 21:45:34 +0900 Subject: [PATCH 3474/6294] [Modify] Move it --- websocket-sharp/Net/ChunkStream.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/ChunkStream.cs b/websocket-sharp/Net/ChunkStream.cs index 8515764de..18aaef414 100644 --- a/websocket-sharp/Net/ChunkStream.cs +++ b/websocket-sharp/Net/ChunkStream.cs @@ -184,11 +184,11 @@ private InputChunkState setChunkSize ( if (!_gotIt) _saved.Append ((char) b); - - if (_saved.Length > 20) - throwProtocolViolation ("The chunk size is too long."); } + if (_saved.Length > 20) + throwProtocolViolation ("The chunk size is too long."); + if (!_sawCr || b != 10) return InputChunkState.None; From 7df5756ab724631f72fd0ce44c95a968f8758577 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 14 Mar 2021 22:03:25 +0900 Subject: [PATCH 3475/6294] [Modify] Polish it --- websocket-sharp/Net/ChunkStream.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/ChunkStream.cs b/websocket-sharp/Net/ChunkStream.cs index 18aaef414..449902710 100644 --- a/websocket-sharp/Net/ChunkStream.cs +++ b/websocket-sharp/Net/ChunkStream.cs @@ -182,8 +182,10 @@ private InputChunkState setChunkSize ( if (b == 32) // SP _gotIt = true; - if (!_gotIt) - _saved.Append ((char) b); + if (_gotIt) + continue; + + _saved.Append ((char) b); } if (_saved.Length > 20) From d936140090b8aa32bd680e3a47d02641f60ff82a Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 15 Mar 2021 21:11:28 +0900 Subject: [PATCH 3476/6294] [Modify] Polish it --- websocket-sharp/Net/ChunkStream.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/ChunkStream.cs b/websocket-sharp/Net/ChunkStream.cs index 449902710..447853ad0 100644 --- a/websocket-sharp/Net/ChunkStream.cs +++ b/websocket-sharp/Net/ChunkStream.cs @@ -191,7 +191,7 @@ private InputChunkState setChunkSize ( if (_saved.Length > 20) throwProtocolViolation ("The chunk size is too long."); - if (!_sawCr || b != 10) + if (b != 10) return InputChunkState.None; _chunkRead = 0; From de7cfbc7d5cdf81332c54ffd0cb0f49a8a9d9d84 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 16 Mar 2021 20:15:26 +0900 Subject: [PATCH 3477/6294] [Modify] Polish it --- websocket-sharp/Net/ChunkStream.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/ChunkStream.cs b/websocket-sharp/Net/ChunkStream.cs index 447853ad0..52ad379cc 100644 --- a/websocket-sharp/Net/ChunkStream.cs +++ b/websocket-sharp/Net/ChunkStream.cs @@ -348,7 +348,9 @@ private InputChunkState writeData ( var data = new byte[cnt]; Buffer.BlockCopy (buffer, offset, data, 0, cnt); - _chunks.Add (new Chunk (data)); + + var chunk = new Chunk (data); + _chunks.Add (chunk); offset += cnt; _chunkRead += cnt; From d46096a5ac4f2bacb0e88f1baa21bcfcc932a273 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 16 Mar 2021 20:23:58 +0900 Subject: [PATCH 3478/6294] [Modify] Polish it --- websocket-sharp/Net/ChunkStream.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/ChunkStream.cs b/websocket-sharp/Net/ChunkStream.cs index 52ad379cc..368237311 100644 --- a/websocket-sharp/Net/ChunkStream.cs +++ b/websocket-sharp/Net/ChunkStream.cs @@ -259,7 +259,8 @@ private InputChunkState setTrailer ( return InputChunkState.End; _saved.Length = len - 2; - var reader = new StringReader (_saved.ToString ()); + var val = _saved.ToString (); + var reader = new StringReader (val); while (true) { var line = reader.ReadLine (); From b0fa93b9f992f9a232c083bf616836d41642102a Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 17 Mar 2021 21:02:54 +0900 Subject: [PATCH 3479/6294] [Modify] Polish it --- websocket-sharp/Net/ChunkStream.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/ChunkStream.cs b/websocket-sharp/Net/ChunkStream.cs index 368237311..4cf9c409f 100644 --- a/websocket-sharp/Net/ChunkStream.cs +++ b/websocket-sharp/Net/ChunkStream.cs @@ -196,11 +196,11 @@ private InputChunkState setChunkSize ( _chunkRead = 0; + var val = _saved.ToString (); + var s = removeChunkExtension (val); + try { - _chunkSize = Int32.Parse ( - removeChunkExtension (_saved.ToString ()), - NumberStyles.HexNumber - ); + _chunkSize = Int32.Parse (s, NumberStyles.HexNumber); } catch { throwProtocolViolation ("The chunk size cannot be parsed."); From 3fc87d18ea7a3d10dec54527d9c665fa5a9bac65 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 17 Mar 2021 21:04:45 +0900 Subject: [PATCH 3480/6294] [Modify] Polish it --- websocket-sharp/Net/ChunkStream.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/ChunkStream.cs b/websocket-sharp/Net/ChunkStream.cs index 4cf9c409f..8a95b4d82 100644 --- a/websocket-sharp/Net/ChunkStream.cs +++ b/websocket-sharp/Net/ChunkStream.cs @@ -194,8 +194,6 @@ private InputChunkState setChunkSize ( if (b != 10) return InputChunkState.None; - _chunkRead = 0; - var val = _saved.ToString (); var s = removeChunkExtension (val); @@ -206,6 +204,8 @@ private InputChunkState setChunkSize ( throwProtocolViolation ("The chunk size cannot be parsed."); } + _chunkRead = 0; + if (_chunkSize == 0) { _trailerState = 2; From da1cc9fba6a7fd02811e4c6e6eec3f5ca07a47f7 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 18 Mar 2021 19:28:13 +0900 Subject: [PATCH 3481/6294] [Modify] Polish it --- websocket-sharp/Net/ChunkStream.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/ChunkStream.cs b/websocket-sharp/Net/ChunkStream.cs index 8a95b4d82..d0b2f6b80 100644 --- a/websocket-sharp/Net/ChunkStream.cs +++ b/websocket-sharp/Net/ChunkStream.cs @@ -179,11 +179,14 @@ private InputChunkState setChunkSize ( if (b == 10) throwProtocolViolation ("LF is unexpected."); - if (b == 32) // SP + if (_gotIt) + continue; + + if (b == 32) { // SP _gotIt = true; - if (_gotIt) continue; + } _saved.Append ((char) b); } From 470f7b281a9c50fa0325661b0d748e879ce8c902 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 19 Mar 2021 19:36:20 +0900 Subject: [PATCH 3482/6294] [Modify] Polish it --- websocket-sharp/Net/ChunkStream.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/ChunkStream.cs b/websocket-sharp/Net/ChunkStream.cs index d0b2f6b80..a8a9ca11f 100644 --- a/websocket-sharp/Net/ChunkStream.cs +++ b/websocket-sharp/Net/ChunkStream.cs @@ -182,7 +182,7 @@ private InputChunkState setChunkSize ( if (_gotIt) continue; - if (b == 32) { // SP + if (b == 32 || b == 59) { // SP or ';' _gotIt = true; continue; @@ -197,8 +197,7 @@ private InputChunkState setChunkSize ( if (b != 10) return InputChunkState.None; - var val = _saved.ToString (); - var s = removeChunkExtension (val); + var s = _saved.ToString (); try { _chunkSize = Int32.Parse (s, NumberStyles.HexNumber); From a2c0ced5caeb3f20e2acb92246a1be1976d9d9e4 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 19 Mar 2021 19:40:52 +0900 Subject: [PATCH 3483/6294] [Modify] Polish it --- websocket-sharp/Net/ChunkStream.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/ChunkStream.cs b/websocket-sharp/Net/ChunkStream.cs index a8a9ca11f..8ca45eb8b 100644 --- a/websocket-sharp/Net/ChunkStream.cs +++ b/websocket-sharp/Net/ChunkStream.cs @@ -192,7 +192,7 @@ private InputChunkState setChunkSize ( } if (_saved.Length > 20) - throwProtocolViolation ("The chunk size is too long."); + throwProtocolViolation ("The chunk size is too big."); if (b != 10) return InputChunkState.None; From e52d89407c2e63ca447f3f6e7fbea171bf33ad0d Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 20 Mar 2021 21:24:33 +0900 Subject: [PATCH 3484/6294] [Modify] Remove it --- websocket-sharp/Net/ChunkStream.cs | 7 ------- 1 file changed, 7 deletions(-) diff --git a/websocket-sharp/Net/ChunkStream.cs b/websocket-sharp/Net/ChunkStream.cs index 8ca45eb8b..b8240e3cd 100644 --- a/websocket-sharp/Net/ChunkStream.cs +++ b/websocket-sharp/Net/ChunkStream.cs @@ -129,13 +129,6 @@ private int read (byte[] buffer, int offset, int count) return nread; } - private static string removeChunkExtension (string value) - { - var idx = value.IndexOf (';'); - - return idx > -1 ? value.Substring (0, idx) : value; - } - private InputChunkState seekCrLf (byte[] buffer, ref int offset, int length) { if (!_sawCr) { From a260fe154e4cf642ed3989eb89ce22ad665c5b38 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 20 Mar 2021 21:27:43 +0900 Subject: [PATCH 3485/6294] [Modify] 2021 --- websocket-sharp/Net/ChunkStream.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/ChunkStream.cs b/websocket-sharp/Net/ChunkStream.cs index b8240e3cd..53ae061a2 100644 --- a/websocket-sharp/Net/ChunkStream.cs +++ b/websocket-sharp/Net/ChunkStream.cs @@ -8,7 +8,7 @@ * The MIT License * * Copyright (c) 2003 Ximian, Inc (http://www.ximian.com) - * Copyright (c) 2012-2015 sta.blockhead + * Copyright (c) 2012-2021 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From 897a579980793d16bce19ecc46d0f1ad3bacca89 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 21 Mar 2021 21:27:37 +0900 Subject: [PATCH 3486/6294] [Modify] Polish it --- websocket-sharp/Net/ChunkedRequestStream.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/ChunkedRequestStream.cs b/websocket-sharp/Net/ChunkedRequestStream.cs index 925bcf1c6..e76cec236 100644 --- a/websocket-sharp/Net/ChunkedRequestStream.cs +++ b/websocket-sharp/Net/ChunkedRequestStream.cs @@ -123,7 +123,7 @@ private void onRead (IAsyncResult asyncResult) } ares.Offset = 0; - ares.Count = Math.Min (_bufferLength, _decoder.ChunkLeft + 6); + ares.Count = _bufferLength; base.BeginRead (ares.Buffer, ares.Offset, ares.Count, onRead, rstate); } From 84a41f25197c0c2bc93cf63c0bffcbee2695ac1d Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 22 Mar 2021 21:11:10 +0900 Subject: [PATCH 3487/6294] [Modify] Remove it --- websocket-sharp/Net/ChunkStream.cs | 6 ------ 1 file changed, 6 deletions(-) diff --git a/websocket-sharp/Net/ChunkStream.cs b/websocket-sharp/Net/ChunkStream.cs index 53ae061a2..4f81db004 100644 --- a/websocket-sharp/Net/ChunkStream.cs +++ b/websocket-sharp/Net/ChunkStream.cs @@ -87,12 +87,6 @@ internal WebHeaderCollection Headers { #region Public Properties - public int ChunkLeft { - get { - return _chunkSize - _chunkRead; - } - } - public bool WantMore { get { return _state != InputChunkState.End; From 511927c19494673ecf2e36eef2b024a477defa46 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 23 Mar 2021 19:41:51 +0900 Subject: [PATCH 3488/6294] [Modify] Polish it --- websocket-sharp/Net/ChunkedRequestStream.cs | 3 --- 1 file changed, 3 deletions(-) diff --git a/websocket-sharp/Net/ChunkedRequestStream.cs b/websocket-sharp/Net/ChunkedRequestStream.cs index e76cec236..0180cded2 100644 --- a/websocket-sharp/Net/ChunkedRequestStream.cs +++ b/websocket-sharp/Net/ChunkedRequestStream.cs @@ -122,9 +122,6 @@ private void onRead (IAsyncResult asyncResult) return; } - ares.Offset = 0; - ares.Count = _bufferLength; - base.BeginRead (ares.Buffer, ares.Offset, ares.Count, onRead, rstate); } catch (Exception ex) { From 67d973d02ab89b35f8ad5f6d296302a4393d5b00 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 23 Mar 2021 19:50:16 +0900 Subject: [PATCH 3489/6294] [Modify] Remove it --- websocket-sharp/Net/ChunkedRequestStream.cs | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/websocket-sharp/Net/ChunkedRequestStream.cs b/websocket-sharp/Net/ChunkedRequestStream.cs index 0180cded2..1009b1581 100644 --- a/websocket-sharp/Net/ChunkedRequestStream.cs +++ b/websocket-sharp/Net/ChunkedRequestStream.cs @@ -83,20 +83,6 @@ HttpListenerContext context #endregion - #region Internal Properties - - internal ChunkStream Decoder { - get { - return _decoder; - } - - set { - _decoder = value; - } - } - - #endregion - #region Private Methods private void onRead (IAsyncResult asyncResult) From 6b10c41bab72c4b5a94782bdbb9d85b8a09ee2d6 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 24 Mar 2021 19:34:38 +0900 Subject: [PATCH 3490/6294] [Modify] Polish it --- websocket-sharp/Net/ChunkStream.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/ChunkStream.cs b/websocket-sharp/Net/ChunkStream.cs index 4f81db004..9e0e94783 100644 --- a/websocket-sharp/Net/ChunkStream.cs +++ b/websocket-sharp/Net/ChunkStream.cs @@ -89,7 +89,7 @@ internal WebHeaderCollection Headers { public bool WantMore { get { - return _state != InputChunkState.End; + return _state < InputChunkState.End; } } From 177323e1dad11ca0772752fa74899bd06e6c03d2 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 24 Mar 2021 19:36:53 +0900 Subject: [PATCH 3491/6294] [Modify] Rename it --- websocket-sharp/Net/ChunkStream.cs | 2 +- websocket-sharp/Net/ChunkedRequestStream.cs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/ChunkStream.cs b/websocket-sharp/Net/ChunkStream.cs index 9e0e94783..802498ebe 100644 --- a/websocket-sharp/Net/ChunkStream.cs +++ b/websocket-sharp/Net/ChunkStream.cs @@ -87,7 +87,7 @@ internal WebHeaderCollection Headers { #region Public Properties - public bool WantMore { + public bool WantsMore { get { return _state < InputChunkState.End; } diff --git a/websocket-sharp/Net/ChunkedRequestStream.cs b/websocket-sharp/Net/ChunkedRequestStream.cs index 1009b1581..2db4b0401 100644 --- a/websocket-sharp/Net/ChunkedRequestStream.cs +++ b/websocket-sharp/Net/ChunkedRequestStream.cs @@ -99,8 +99,8 @@ private void onRead (IAsyncResult asyncResult) rstate.Offset += nread; rstate.Count -= nread; - if (rstate.Count == 0 || !_decoder.WantMore || nread == 0) { - _noMoreData = !_decoder.WantMore && nread == 0; + if (rstate.Count == 0 || !_decoder.WantsMore || nread == 0) { + _noMoreData = !_decoder.WantsMore && nread == 0; ares.Count = rstate.InitialCount - rstate.Count; ares.Complete (); @@ -175,7 +175,7 @@ public override IAsyncResult BeginRead ( return ares; } - if (!_decoder.WantMore) { + if (!_decoder.WantsMore) { _noMoreData = nread == 0; ares.Count = nread; From 4ccf6358d017aa4adb7c1826f8ff453164bb2827 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 25 Mar 2021 19:38:09 +0900 Subject: [PATCH 3492/6294] [Modify] Move it --- websocket-sharp/Net/ChunkStream.cs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Net/ChunkStream.cs b/websocket-sharp/Net/ChunkStream.cs index 802498ebe..6081113b7 100644 --- a/websocket-sharp/Net/ChunkStream.cs +++ b/websocket-sharp/Net/ChunkStream.cs @@ -75,18 +75,14 @@ public ChunkStream (WebHeaderCollection headers) #endregion - #region Internal Properties + #region Public Properties - internal WebHeaderCollection Headers { + public WebHeaderCollection Headers { get { return _headers; } } - #endregion - - #region Public Properties - public bool WantsMore { get { return _state < InputChunkState.End; From caa23026082ae9fd32f7b917f09316a212c045fe Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 26 Mar 2021 19:38:58 +0900 Subject: [PATCH 3493/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListener.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 07970e14d..b8dad7164 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -802,10 +802,12 @@ public void Start () public void Stop () { CheckDisposed (); + if (!_listening) return; _listening = false; + EndPointManager.RemoveListener (this); lock (_ctxRegistrySync) @@ -813,7 +815,9 @@ public void Stop () cleanupContextRegistry (); cleanupConnections (); - cleanupWaitQueue (new HttpListenerException (995, "The listener is stopped.")); + + var ex = new HttpListenerException (995, "The listener is stopped."); + cleanupWaitQueue (ex); } #endregion From 206f1f473013ec8bfbc34e81bc67d39139b78def Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 27 Mar 2021 21:37:35 +0900 Subject: [PATCH 3494/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListener.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index b8dad7164..96b42e05a 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -786,10 +786,12 @@ public HttpListenerContext GetContext () public void Start () { CheckDisposed (); + if (_listening) return; EndPointManager.AddListener (this); + _listening = true; } From 054e3ef03eb822c4bf795f89b293ff95bbbd5b5b Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 28 Mar 2021 22:00:53 +0900 Subject: [PATCH 3495/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListener.cs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 96b42e05a..feba1a109 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -765,11 +765,18 @@ public HttpListenerContext EndGetContext (IAsyncResult asyncResult) public HttpListenerContext GetContext () { CheckDisposed (); - if (_prefixes.Count == 0) - throw new InvalidOperationException ("The listener has no URI prefix on which listens."); - if (!_listening) - throw new InvalidOperationException ("The listener hasn't been started."); + if (_prefixes.Count == 0) { + var msg = "The listener has no URI prefix on which listens."; + + throw new InvalidOperationException (msg); + } + + if (!_listening) { + var msg = "The listener has not been started."; + + throw new InvalidOperationException (msg); + } var ares = BeginGetContext (new HttpListenerAsyncResult (null, null)); ares.InGet = true; From ad5f5aeb0cf4467107f1c0d9a42eb32065f2a893 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 29 Mar 2021 17:31:29 +0900 Subject: [PATCH 3496/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListener.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index feba1a109..c72072505 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -743,7 +743,8 @@ public HttpListenerContext EndGetContext (IAsyncResult asyncResult) /// Gets an incoming request. ///
/// - /// This method waits for an incoming request, and returns when a request is received. + /// This method waits for an incoming request and returns when a request is + /// received. /// /// /// A that represents a request. @@ -756,7 +757,7 @@ public HttpListenerContext EndGetContext (IAsyncResult asyncResult) /// -or- /// /// - /// This listener hasn't been started, or is currently stopped. + /// This listener has not been started or is currently stopped. /// /// /// From 7fa4cc4f0c5faa3ff3dde3bf8c1946ca6e80a518 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 29 Mar 2021 17:41:37 +0900 Subject: [PATCH 3497/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListener.cs | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index c72072505..918b6ed0e 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -722,17 +722,26 @@ public void Close () public HttpListenerContext EndGetContext (IAsyncResult asyncResult) { CheckDisposed (); + if (asyncResult == null) throw new ArgumentNullException ("asyncResult"); var ares = asyncResult as HttpListenerAsyncResult; - if (ares == null) - throw new ArgumentException ("A wrong IAsyncResult.", "asyncResult"); - if (ares.EndCalled) - throw new InvalidOperationException ("This IAsyncResult cannot be reused."); + if (ares == null) { + var msg = "A wrong IAsyncResult instance."; + + throw new ArgumentException (msg, "asyncResult"); + } + + if (ares.EndCalled) { + var msg = "This IAsyncResult instance cannot be reused."; + + throw new InvalidOperationException (msg); + } ares.EndCalled = true; + if (!ares.IsCompleted) ares.AsyncWaitHandle.WaitOne (); From 4e5c5f2f66bf52d7efc0e46d5da273a9a5309deb Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 30 Mar 2021 21:55:46 +0900 Subject: [PATCH 3498/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListener.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 918b6ed0e..a17350ffd 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -699,22 +699,24 @@ public void Close () ///
/// /// This method completes an asynchronous operation started by calling - /// the BeginGetContext method. + /// the BeginGetContext method. /// /// /// A that represents a request. /// /// - /// An obtained by calling the BeginGetContext method. + /// An instance obtained by calling + /// the BeginGetContext method. /// /// /// is . /// /// - /// wasn't obtained by calling the BeginGetContext method. + /// was not obtained by calling + /// the BeginGetContext method. /// /// - /// This method was already called for the specified . + /// This method was already called for . /// /// /// This listener has been closed. From b1fb4a171f51b7cdbb9e2b320148764d68fb178b Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 31 Mar 2021 19:50:37 +0900 Subject: [PATCH 3499/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListener.cs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index a17350ffd..55c17b610 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -674,11 +674,18 @@ public void Abort () public IAsyncResult BeginGetContext (AsyncCallback callback, Object state) { CheckDisposed (); - if (_prefixes.Count == 0) - throw new InvalidOperationException ("The listener has no URI prefix on which listens."); - if (!_listening) - throw new InvalidOperationException ("The listener hasn't been started."); + if (_prefixes.Count == 0) { + var msg = "The listener has no URI prefix on which listens."; + + throw new InvalidOperationException (msg); + } + + if (!_listening) { + var msg = "The listener has not been started."; + + throw new InvalidOperationException (msg); + } return BeginGetContext (new HttpListenerAsyncResult (callback, state)); } From d8e58aae80ff8b3271cfa7f6b0d97c4483e30eb8 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 1 Apr 2021 20:10:38 +0900 Subject: [PATCH 3500/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListener.cs | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 55c17b610..e7da1488d 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -643,19 +643,26 @@ public void Abort () /// Begins getting an incoming request asynchronously. ///
/// - /// This asynchronous operation must be completed by calling the EndGetContext method. - /// Typically, the method is invoked by the delegate. + /// + /// This asynchronous operation must be completed by calling + /// the EndGetContext method. + /// + /// + /// Typically, the EndGetContext method is called by + /// . + /// /// /// - /// An that represents the status of the asynchronous operation. + /// An that represents the status of + /// the asynchronous operation. /// /// - /// An delegate that references the method to invoke when - /// the asynchronous operation completes. + /// An delegate that references the method to + /// invoke when the asynchronous operation completes. /// /// - /// An that represents a user defined object to pass to - /// the delegate. + /// An that represents a user defined object to + /// pass to . /// /// /// @@ -665,7 +672,7 @@ public void Abort () /// -or- /// /// - /// This listener hasn't been started, or is currently stopped. + /// This listener has not been started or is currently stopped. /// /// /// From 0398153b543c42b0eccac577d0aa0f9ba9ca5b38 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 1 Apr 2021 20:14:46 +0900 Subject: [PATCH 3501/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListener.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index e7da1488d..78c73fa69 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -604,9 +604,12 @@ internal void RemoveConnection (HttpConnection connection) _connections.Remove (connection); } - internal AuthenticationSchemes SelectAuthenticationScheme (HttpListenerRequest request) + internal AuthenticationSchemes SelectAuthenticationScheme ( + HttpListenerRequest request + ) { var selector = _authSchemeSelector; + if (selector == null) return _authSchemes; From 01cb8f9449eb068c06ef4989c7e13a514895ce80 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 2 Apr 2021 20:38:13 +0900 Subject: [PATCH 3502/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListener.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 78c73fa69..1cced0a2a 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -589,6 +589,7 @@ internal bool RegisterContext (HttpListenerContext context) _ctxRegistry[context] = context; var ares = getAsyncResultFromQueue (); + if (ares == null) _ctxQueue.Add (context); else From 7707872368a16ecff6b861bb4caed16bb622220e Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 2 Apr 2021 20:40:55 +0900 Subject: [PATCH 3503/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListener.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 1cced0a2a..f38ad2422 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -569,6 +569,7 @@ internal void CheckDisposed () internal string GetRealm () { var realm = _realm; + return realm != null && realm.Length > 0 ? realm : _defaultRealm; } From e2223f4c6c9df4ae6fdb9029e43595c3cf9cdf89 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 3 Apr 2021 21:16:57 +0900 Subject: [PATCH 3504/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListener.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index f38ad2422..44634fa23 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -544,13 +544,16 @@ internal bool AddConnection (HttpConnection connection) } } - internal HttpListenerAsyncResult BeginGetContext (HttpListenerAsyncResult asyncResult) + internal HttpListenerAsyncResult BeginGetContext ( + HttpListenerAsyncResult asyncResult + ) { lock (_ctxRegistrySync) { if (!_listening) throw new HttpListenerException (995); var ctx = getContextFromQueue (); + if (ctx == null) _waitQueue.Add (asyncResult); else From 61dac4bd8a2d65c9a0c485a7136a7b13844eb0ea Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 3 Apr 2021 21:18:07 +0900 Subject: [PATCH 3505/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListener.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 44634fa23..eb879df42 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -540,6 +540,7 @@ internal bool AddConnection (HttpConnection connection) return false; _connections[connection] = connection; + return true; } } From c49c58d41af8835c0506a2190d7c746f4c8704d3 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 4 Apr 2021 22:45:13 +0900 Subject: [PATCH 3506/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListener.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index eb879df42..514590376 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -520,10 +520,11 @@ private HttpListenerContext getContextFromQueue () if (_ctxQueue.Count == 0) return null; - var ctx = _ctxQueue[0]; + var ret = _ctxQueue[0]; + _ctxQueue.RemoveAt (0); - return ctx; + return ret; } #endregion From 8b6f5cf2b78820f084b2e93304de4aa1f7de8523 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 4 Apr 2021 22:46:20 +0900 Subject: [PATCH 3507/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListener.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 514590376..eefff7b1a 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -509,10 +509,11 @@ private HttpListenerAsyncResult getAsyncResultFromQueue () if (_waitQueue.Count == 0) return null; - var ares = _waitQueue[0]; + var ret = _waitQueue[0]; + _waitQueue.RemoveAt (0); - return ares; + return ret; } private HttpListenerContext getContextFromQueue () From 76ecc3fbbf579fd6cdd45ac4ae7867df6c7f40e3 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 5 Apr 2021 21:15:24 +0900 Subject: [PATCH 3508/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListener.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index eefff7b1a..6311613f0 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -491,6 +491,7 @@ private void close (bool force) { if (_listening) { _listening = false; + EndPointManager.RemoveListener (this); } @@ -499,7 +500,9 @@ private void close (bool force) cleanupContextRegistry (); cleanupConnections (); - cleanupWaitQueue (new ObjectDisposedException (GetType ().ToString ())); + + var ex = new ObjectDisposedException (GetType ().ToString ()); + cleanupWaitQueue (ex); _disposed = true; } From ce577ff0f711ec4a1366f1d78f8b3a7c055c9b46 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 5 Apr 2021 21:18:01 +0900 Subject: [PATCH 3509/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListener.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 6311613f0..4cef3c622 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -475,11 +475,13 @@ private void cleanupContextRegistry () private void cleanupWaitQueue (Exception exception) { HttpListenerAsyncResult[] aress = null; + lock (_waitQueueSync) { if (_waitQueue.Count == 0) return; aress = _waitQueue.ToArray (); + _waitQueue.Clear (); } From ee3cadf19c04992af12f0db9c77d1a9e0053782c Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 6 Apr 2021 19:39:50 +0900 Subject: [PATCH 3510/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListener.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 4cef3c622..32f784fb3 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -457,6 +457,7 @@ private void cleanupContextQueue (bool sendServiceUnavailable) private void cleanupContextRegistry () { HttpListenerContext[] ctxs = null; + lock (_ctxRegistrySync) { if (_ctxRegistry.Count == 0) return; @@ -465,6 +466,7 @@ private void cleanupContextRegistry () var keys = _ctxRegistry.Keys; ctxs = new HttpListenerContext[keys.Count]; keys.CopyTo (ctxs, 0); + _ctxRegistry.Clear (); } From b9fd153759d3da786d3de0d416b9e54e18fd46b4 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 6 Apr 2021 19:46:52 +0900 Subject: [PATCH 3511/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListener.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 32f784fb3..b3aea9ba7 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -436,11 +436,13 @@ private void cleanupConnections () private void cleanupContextQueue (bool sendServiceUnavailable) { HttpListenerContext[] ctxs = null; + lock (_ctxQueueSync) { if (_ctxQueue.Count == 0) return; ctxs = _ctxQueue.ToArray (); + _ctxQueue.Clear (); } @@ -449,7 +451,8 @@ private void cleanupContextQueue (bool sendServiceUnavailable) foreach (var ctx in ctxs) { var res = ctx.Response; - res.StatusCode = (int) HttpStatusCode.ServiceUnavailable; + res.StatusCode = 503; + res.Close (); } } From 27afa4ebe54d577c263d6f9eb2c3ee677575999f Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 7 Apr 2021 20:59:49 +0900 Subject: [PATCH 3512/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListener.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index b3aea9ba7..bc0f1a73c 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -418,6 +418,7 @@ public Func UserCredentialsFinder { private void cleanupConnections () { HttpConnection[] conns = null; + lock (_connectionsSync) { if (_connections.Count == 0) return; @@ -426,6 +427,7 @@ private void cleanupConnections () var keys = _connections.Keys; conns = new HttpConnection[keys.Count]; keys.CopyTo (conns, 0); + _connections.Clear (); } From 5b1f6be2584d4dc365d9b6334a37347b449d3a11 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 8 Apr 2021 20:13:50 +0900 Subject: [PATCH 3513/6294] [Modify] Rename it --- websocket-sharp/Net/HttpListener.cs | 30 ++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index bc0f1a73c..162fcf69f 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -68,8 +68,8 @@ public sealed class HttpListener : IDisposable private object _connectionsSync; private List _ctxQueue; private object _ctxQueueSync; - private Dictionary _ctxRegistry; - private object _ctxRegistrySync; + private Dictionary _contextRegistry; + private object _contextRegistrySync; private static readonly string _defaultRealm; private bool _disposed; private bool _ignoreWriteExceptions; @@ -109,8 +109,8 @@ public HttpListener () _ctxQueue = new List (); _ctxQueueSync = ((ICollection) _ctxQueue).SyncRoot; - _ctxRegistry = new Dictionary (); - _ctxRegistrySync = ((ICollection) _ctxRegistry).SyncRoot; + _contextRegistry = new Dictionary (); + _contextRegistrySync = ((ICollection) _contextRegistry).SyncRoot; _logger = new Logger (); @@ -463,16 +463,16 @@ private void cleanupContextRegistry () { HttpListenerContext[] ctxs = null; - lock (_ctxRegistrySync) { - if (_ctxRegistry.Count == 0) + lock (_contextRegistrySync) { + if (_contextRegistry.Count == 0) return; // Need to copy this since closing will call the UnregisterContext method. - var keys = _ctxRegistry.Keys; + var keys = _contextRegistry.Keys; ctxs = new HttpListenerContext[keys.Count]; keys.CopyTo (ctxs, 0); - _ctxRegistry.Clear (); + _contextRegistry.Clear (); } for (var i = ctxs.Length - 1; i >= 0; i--) @@ -504,7 +504,7 @@ private void close (bool force) EndPointManager.RemoveListener (this); } - lock (_ctxRegistrySync) + lock (_contextRegistrySync) cleanupContextQueue (!force); cleanupContextRegistry (); @@ -563,7 +563,7 @@ internal HttpListenerAsyncResult BeginGetContext ( HttpListenerAsyncResult asyncResult ) { - lock (_ctxRegistrySync) { + lock (_contextRegistrySync) { if (!_listening) throw new HttpListenerException (995); @@ -601,11 +601,11 @@ internal bool RegisterContext (HttpListenerContext context) if (!_listening) return false; - lock (_ctxRegistrySync) { + lock (_contextRegistrySync) { if (!_listening) return false; - _ctxRegistry[context] = context; + _contextRegistry[context] = context; var ares = getAsyncResultFromQueue (); @@ -643,8 +643,8 @@ HttpListenerRequest request internal void UnregisterContext (HttpListenerContext context) { - lock (_ctxRegistrySync) - _ctxRegistry.Remove (context); + lock (_contextRegistrySync) + _contextRegistry.Remove (context); } #endregion @@ -868,7 +868,7 @@ public void Stop () EndPointManager.RemoveListener (this); - lock (_ctxRegistrySync) + lock (_contextRegistrySync) cleanupContextQueue (true); cleanupContextRegistry (); From 5aa03ab8387b731804e38a6767831ca80038f94b Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 9 Apr 2021 19:42:19 +0900 Subject: [PATCH 3514/6294] [Modify] Use the LinkedList class instead --- websocket-sharp/Net/HttpListener.cs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 162fcf69f..59494cf77 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -68,7 +68,7 @@ public sealed class HttpListener : IDisposable private object _connectionsSync; private List _ctxQueue; private object _ctxQueueSync; - private Dictionary _contextRegistry; + private LinkedList _contextRegistry; private object _contextRegistrySync; private static readonly string _defaultRealm; private bool _disposed; @@ -109,7 +109,7 @@ public HttpListener () _ctxQueue = new List (); _ctxQueueSync = ((ICollection) _ctxQueue).SyncRoot; - _contextRegistry = new Dictionary (); + _contextRegistry = new LinkedList (); _contextRegistrySync = ((ICollection) _contextRegistry).SyncRoot; _logger = new Logger (); @@ -468,9 +468,8 @@ private void cleanupContextRegistry () return; // Need to copy this since closing will call the UnregisterContext method. - var keys = _contextRegistry.Keys; - ctxs = new HttpListenerContext[keys.Count]; - keys.CopyTo (ctxs, 0); + ctxs = new HttpListenerContext[_contextRegistry.Count]; + _contextRegistry.CopyTo (ctxs, 0); _contextRegistry.Clear (); } @@ -605,7 +604,7 @@ internal bool RegisterContext (HttpListenerContext context) if (!_listening) return false; - _contextRegistry[context] = context; + _contextRegistry.AddLast (context); var ares = getAsyncResultFromQueue (); From 62ec87342edae1918303b55c00768bcb8e632d2a Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 9 Apr 2021 19:45:57 +0900 Subject: [PATCH 3515/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListener.cs | 42 ++++++++++++++--------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 59494cf77..3eb5f574f 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -61,27 +61,27 @@ public sealed class HttpListener : IDisposable { #region Private Fields - private AuthenticationSchemes _authSchemes; - private Func _authSchemeSelector; - private string _certFolderPath; - private Dictionary _connections; - private object _connectionsSync; - private List _ctxQueue; - private object _ctxQueueSync; - private LinkedList _contextRegistry; - private object _contextRegistrySync; - private static readonly string _defaultRealm; - private bool _disposed; - private bool _ignoreWriteExceptions; - private volatile bool _listening; - private Logger _logger; - private HttpListenerPrefixCollection _prefixes; - private string _realm; - private bool _reuseAddress; - private ServerSslConfiguration _sslConfig; - private Func _userCredFinder; - private List _waitQueue; - private object _waitQueueSync; + private AuthenticationSchemes _authSchemes; + private Func _authSchemeSelector; + private string _certFolderPath; + private Dictionary _connections; + private object _connectionsSync; + private List _ctxQueue; + private object _ctxQueueSync; + private LinkedList _contextRegistry; + private object _contextRegistrySync; + private static readonly string _defaultRealm; + private bool _disposed; + private bool _ignoreWriteExceptions; + private volatile bool _listening; + private Logger _logger; + private HttpListenerPrefixCollection _prefixes; + private string _realm; + private bool _reuseAddress; + private ServerSslConfiguration _sslConfig; + private Func _userCredFinder; + private List _waitQueue; + private object _waitQueueSync; #endregion From caa0fb541d294ad1f0c0b2d2b269883c4436475e Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 9 Apr 2021 19:55:47 +0900 Subject: [PATCH 3516/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListener.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 3eb5f574f..96a18b1f6 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -464,11 +464,13 @@ private void cleanupContextRegistry () HttpListenerContext[] ctxs = null; lock (_contextRegistrySync) { - if (_contextRegistry.Count == 0) + var cnt = _contextRegistry.Count; + + if (cnt == 0) return; // Need to copy this since closing will call the UnregisterContext method. - ctxs = new HttpListenerContext[_contextRegistry.Count]; + ctxs = new HttpListenerContext[cnt]; _contextRegistry.CopyTo (ctxs, 0); _contextRegistry.Clear (); From 1d705aa052490e79b11bdadbd8ca9e219d0039ea Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 9 Apr 2021 19:57:43 +0900 Subject: [PATCH 3517/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListener.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 96a18b1f6..f07e28ec1 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -469,7 +469,6 @@ private void cleanupContextRegistry () if (cnt == 0) return; - // Need to copy this since closing will call the UnregisterContext method. ctxs = new HttpListenerContext[cnt]; _contextRegistry.CopyTo (ctxs, 0); From 3c9daa9bb0796eb564656d6f8ba682a9eaa04bc6 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 10 Apr 2021 16:58:27 +0900 Subject: [PATCH 3518/6294] [Modify] Rename it --- websocket-sharp/Net/HttpListener.cs | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index f07e28ec1..6aedffd0b 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -66,8 +66,8 @@ public sealed class HttpListener : IDisposable private string _certFolderPath; private Dictionary _connections; private object _connectionsSync; - private List _ctxQueue; - private object _ctxQueueSync; + private List _contextQueue; + private object _contextQueueSync; private LinkedList _contextRegistry; private object _contextRegistrySync; private static readonly string _defaultRealm; @@ -106,8 +106,8 @@ public HttpListener () _connections = new Dictionary (); _connectionsSync = ((ICollection) _connections).SyncRoot; - _ctxQueue = new List (); - _ctxQueueSync = ((ICollection) _ctxQueue).SyncRoot; + _contextQueue = new List (); + _contextQueueSync = ((ICollection) _contextQueue).SyncRoot; _contextRegistry = new LinkedList (); _contextRegistrySync = ((ICollection) _contextRegistry).SyncRoot; @@ -439,13 +439,13 @@ private void cleanupContextQueue (bool sendServiceUnavailable) { HttpListenerContext[] ctxs = null; - lock (_ctxQueueSync) { - if (_ctxQueue.Count == 0) + lock (_contextQueueSync) { + if (_contextQueue.Count == 0) return; - ctxs = _ctxQueue.ToArray (); + ctxs = _contextQueue.ToArray (); - _ctxQueue.Clear (); + _contextQueue.Clear (); } if (!sendServiceUnavailable) @@ -530,12 +530,12 @@ private HttpListenerAsyncResult getAsyncResultFromQueue () private HttpListenerContext getContextFromQueue () { - if (_ctxQueue.Count == 0) + if (_contextQueue.Count == 0) return null; - var ret = _ctxQueue[0]; + var ret = _contextQueue[0]; - _ctxQueue.RemoveAt (0); + _contextQueue.RemoveAt (0); return ret; } @@ -610,7 +610,7 @@ internal bool RegisterContext (HttpListenerContext context) var ares = getAsyncResultFromQueue (); if (ares == null) - _ctxQueue.Add (context); + _contextQueue.Add (context); else ares.Complete (context); From c761dc4c6f10682cb69d40a3ef4922bef5c641b1 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 11 Apr 2021 16:24:04 +0900 Subject: [PATCH 3519/6294] [Modify] Use the Queue class instead --- websocket-sharp/Net/HttpListener.cs | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 6aedffd0b..edf3af912 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -66,7 +66,7 @@ public sealed class HttpListener : IDisposable private string _certFolderPath; private Dictionary _connections; private object _connectionsSync; - private List _contextQueue; + private Queue _contextQueue; private object _contextQueueSync; private LinkedList _contextRegistry; private object _contextRegistrySync; @@ -106,7 +106,7 @@ public HttpListener () _connections = new Dictionary (); _connectionsSync = ((ICollection) _connections).SyncRoot; - _contextQueue = new List (); + _contextQueue = new Queue (); _contextQueueSync = ((ICollection) _contextQueue).SyncRoot; _contextRegistry = new LinkedList (); @@ -533,11 +533,7 @@ private HttpListenerContext getContextFromQueue () if (_contextQueue.Count == 0) return null; - var ret = _contextQueue[0]; - - _contextQueue.RemoveAt (0); - - return ret; + return _contextQueue.Dequeue (); } #endregion @@ -610,7 +606,7 @@ internal bool RegisterContext (HttpListenerContext context) var ares = getAsyncResultFromQueue (); if (ares == null) - _contextQueue.Add (context); + _contextQueue.Enqueue (context); else ares.Complete (context); From 58dc23f1c13aeca28901d74b675d5e24ec7f56f6 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 11 Apr 2021 16:32:45 +0900 Subject: [PATCH 3520/6294] [Modify] Replace it --- websocket-sharp/Net/HttpListener.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index edf3af912..84481f676 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -452,10 +452,8 @@ private void cleanupContextQueue (bool sendServiceUnavailable) return; foreach (var ctx in ctxs) { - var res = ctx.Response; - res.StatusCode = 503; - - res.Close (); + ctx.ErrorStatusCode = 503; + ctx.SendError (); } } From b0361e18675cba05ee3ebdf2d80b2f07575cc344 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 11 Apr 2021 16:37:12 +0900 Subject: [PATCH 3521/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListener.cs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 84481f676..efc1ae2d7 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -528,10 +528,7 @@ private HttpListenerAsyncResult getAsyncResultFromQueue () private HttpListenerContext getContextFromQueue () { - if (_contextQueue.Count == 0) - return null; - - return _contextQueue.Dequeue (); + return _contextQueue.Count > 0 ? _contextQueue.Dequeue () : null; } #endregion From c26470ff215355ea5821da764361ac9f7386f231 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 12 Apr 2021 16:14:13 +0900 Subject: [PATCH 3522/6294] [Modify] Use the Queue class instead --- websocket-sharp/Net/HttpListener.cs | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index efc1ae2d7..ae611d2c5 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -80,7 +80,7 @@ public sealed class HttpListener : IDisposable private bool _reuseAddress; private ServerSslConfiguration _sslConfig; private Func _userCredFinder; - private List _waitQueue; + private Queue _waitQueue; private object _waitQueueSync; #endregion @@ -116,7 +116,7 @@ public HttpListener () _prefixes = new HttpListenerPrefixCollection (this); - _waitQueue = new List (); + _waitQueue = new Queue (); _waitQueueSync = ((ICollection) _waitQueue).SyncRoot; } @@ -516,14 +516,7 @@ private void close (bool force) private HttpListenerAsyncResult getAsyncResultFromQueue () { - if (_waitQueue.Count == 0) - return null; - - var ret = _waitQueue[0]; - - _waitQueue.RemoveAt (0); - - return ret; + return _waitQueue.Count > 0 ? _waitQueue.Dequeue () : null; } private HttpListenerContext getContextFromQueue () @@ -561,7 +554,7 @@ HttpListenerAsyncResult asyncResult var ctx = getContextFromQueue (); if (ctx == null) - _waitQueue.Add (asyncResult); + _waitQueue.Enqueue (asyncResult); else asyncResult.Complete (ctx, true); From b4bc583991bb20f8aabe1beaf7fafa845dd09335 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 13 Apr 2021 19:38:57 +0900 Subject: [PATCH 3523/6294] [Modify] Use the LinkedList class instead --- websocket-sharp/Net/EndPointListener.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/EndPointListener.cs b/websocket-sharp/Net/EndPointListener.cs index 86402f72a..e78ef32ca 100644 --- a/websocket-sharp/Net/EndPointListener.cs +++ b/websocket-sharp/Net/EndPointListener.cs @@ -69,7 +69,7 @@ internal sealed class EndPointListener private Socket _socket; private ServerSslConfiguration _sslConfig; private List _unhandled; // host == '*' - private List _unregistered; + private LinkedList _unregistered; private object _unregisteredSync; #endregion @@ -116,7 +116,7 @@ bool reuseAddress } _prefixes = new List (); - _unregistered = new List (); + _unregistered = new LinkedList (); _unregisteredSync = ((ICollection) _unregistered).SyncRoot; _socket = new Socket ( @@ -313,7 +313,7 @@ private static void processAccepted ( } lock (listener._unregisteredSync) - listener._unregistered.Add (conn); + listener._unregistered.AddLast (conn); conn.BeginReadRequest (); } From 77c7306ca47236db19ca34be1f19de055f68b433 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 13 Apr 2021 19:40:07 +0900 Subject: [PATCH 3524/6294] [Modify] Polish it --- websocket-sharp/Net/EndPointListener.cs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/websocket-sharp/Net/EndPointListener.cs b/websocket-sharp/Net/EndPointListener.cs index e78ef32ca..f26660aa6 100644 --- a/websocket-sharp/Net/EndPointListener.cs +++ b/websocket-sharp/Net/EndPointListener.cs @@ -61,16 +61,16 @@ internal sealed class EndPointListener { #region Private Fields - private List _all; // host == '+' - private static readonly string _defaultCertFolderPath; - private IPEndPoint _endpoint; - private List _prefixes; - private bool _secure; - private Socket _socket; - private ServerSslConfiguration _sslConfig; - private List _unhandled; // host == '*' + private List _all; // host == '+' + private static readonly string _defaultCertFolderPath; + private IPEndPoint _endpoint; + private List _prefixes; + private bool _secure; + private Socket _socket; + private ServerSslConfiguration _sslConfig; + private List _unhandled; // host == '*' private LinkedList _unregistered; - private object _unregisteredSync; + private object _unregisteredSync; #endregion From ff548a462289b10ae64f9ba53e8cd70d70d2c6ac Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 14 Apr 2021 19:39:42 +0900 Subject: [PATCH 3525/6294] [Modify] Polish it --- websocket-sharp/Net/EndPointListener.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/EndPointListener.cs b/websocket-sharp/Net/EndPointListener.cs index f26660aa6..7f5a3af41 100644 --- a/websocket-sharp/Net/EndPointListener.cs +++ b/websocket-sharp/Net/EndPointListener.cs @@ -200,8 +200,8 @@ private void clearConnections () return; conns = new HttpConnection[cnt]; - _unregistered.CopyTo (conns, 0); + _unregistered.Clear (); } From fb6ed6a467e5cbe41e11429de50af63b05cf2e98 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 15 Apr 2021 19:44:31 +0900 Subject: [PATCH 3526/6294] [Modify] Goodbye, The last listener --- websocket-sharp/Net/HttpConnection.cs | 27 ++++++--------------------- 1 file changed, 6 insertions(+), 21 deletions(-) diff --git a/websocket-sharp/Net/HttpConnection.cs b/websocket-sharp/Net/HttpConnection.cs index e9ee9e46d..77de12d2d 100644 --- a/websocket-sharp/Net/HttpConnection.cs +++ b/websocket-sharp/Net/HttpConnection.cs @@ -67,7 +67,6 @@ internal sealed class HttpConnection private StringBuilder _currentLine; private InputState _inputState; private RequestStream _inputStream; - private HttpListener _lastListener; private LineState _lineState; private EndPointListener _listener; private EndPoint _localEndPoint; @@ -454,38 +453,24 @@ private string readLineFrom ( private void registerContext (HttpListener listener) { - if (_lastListener != listener) { - removeConnection (); - - if (!listener.AddConnection (this)) { - close (); - - return; - } - - _lastListener = listener; - } - _context.Listener = listener; if (!_context.Authenticate ()) return; - if (!_context.Register ()) + if (!_context.Register ()) { + _context.ErrorStatusCode = 503; + _context.SendError (); + return; + } _contextRegistered = true; } private void removeConnection () { - if (_lastListener == null) { - _listener.RemoveConnection (this); - - return; - } - - _lastListener.RemoveConnection (this); + _listener.RemoveConnection (this); } private void unregisterContext () From 14a28b3394b7d71e992db846440f8d10e61e3abc Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 15 Apr 2021 19:47:32 +0900 Subject: [PATCH 3527/6294] [Modify] Replace it --- websocket-sharp/Net/HttpConnection.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpConnection.cs b/websocket-sharp/Net/HttpConnection.cs index 77de12d2d..907bfbe40 100644 --- a/websocket-sharp/Net/HttpConnection.cs +++ b/websocket-sharp/Net/HttpConnection.cs @@ -200,7 +200,7 @@ private void close () } unregisterContext (); - removeConnection (); + _listener.RemoveConnection (this); } private void closeSocket () From 770c46f6c5e0178b0b90d9094e0c8519aa7ccaf5 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 15 Apr 2021 19:48:52 +0900 Subject: [PATCH 3528/6294] [Modify] Remove it --- websocket-sharp/Net/HttpConnection.cs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/websocket-sharp/Net/HttpConnection.cs b/websocket-sharp/Net/HttpConnection.cs index 907bfbe40..8adf80fd6 100644 --- a/websocket-sharp/Net/HttpConnection.cs +++ b/websocket-sharp/Net/HttpConnection.cs @@ -468,11 +468,6 @@ private void registerContext (HttpListener listener) _contextRegistered = true; } - private void removeConnection () - { - _listener.RemoveConnection (this); - } - private void unregisterContext () { if (!_contextRegistered) From 3d82a51cab896c321e63e8ef4e28a41e5c8c5103 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 16 Apr 2021 19:37:02 +0900 Subject: [PATCH 3529/6294] [Modify] Rename it --- websocket-sharp/Net/EndPointListener.cs | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/websocket-sharp/Net/EndPointListener.cs b/websocket-sharp/Net/EndPointListener.cs index 7f5a3af41..a691e2106 100644 --- a/websocket-sharp/Net/EndPointListener.cs +++ b/websocket-sharp/Net/EndPointListener.cs @@ -69,8 +69,8 @@ internal sealed class EndPointListener private Socket _socket; private ServerSslConfiguration _sslConfig; private List _unhandled; // host == '*' - private LinkedList _unregistered; - private object _unregisteredSync; + private LinkedList _connections; + private object _connectionsSync; #endregion @@ -116,8 +116,8 @@ bool reuseAddress } _prefixes = new List (); - _unregistered = new LinkedList (); - _unregisteredSync = ((ICollection) _unregistered).SyncRoot; + _connections = new LinkedList (); + _connectionsSync = ((ICollection) _connections).SyncRoot; _socket = new Socket ( endpoint.Address.AddressFamily, @@ -193,16 +193,16 @@ private void clearConnections () var cnt = 0; - lock (_unregisteredSync) { - cnt = _unregistered.Count; + lock (_connectionsSync) { + cnt = _connections.Count; if (cnt == 0) return; conns = new HttpConnection[cnt]; - _unregistered.CopyTo (conns, 0); + _connections.CopyTo (conns, 0); - _unregistered.Clear (); + _connections.Clear (); } for (var i = cnt - 1; i >= 0; i--) @@ -312,8 +312,8 @@ private static void processAccepted ( return; } - lock (listener._unregisteredSync) - listener._unregistered.AddLast (conn); + lock (listener._connectionsSync) + listener._connections.AddLast (conn); conn.BeginReadRequest (); } @@ -380,8 +380,8 @@ internal static bool CertificateExists (int port, string folderPath) internal void RemoveConnection (HttpConnection connection) { - lock (_unregisteredSync) - _unregistered.Remove (connection); + lock (_connectionsSync) + _connections.Remove (connection); } internal bool TrySearchHttpListener (Uri uri, out HttpListener listener) From 4a7666d9b08734cb4c88aecbf992fc0e2b0dabd7 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 16 Apr 2021 19:37:57 +0900 Subject: [PATCH 3530/6294] [Modify] Polish it --- websocket-sharp/Net/EndPointListener.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/EndPointListener.cs b/websocket-sharp/Net/EndPointListener.cs index a691e2106..06ff7c27b 100644 --- a/websocket-sharp/Net/EndPointListener.cs +++ b/websocket-sharp/Net/EndPointListener.cs @@ -62,6 +62,8 @@ internal sealed class EndPointListener #region Private Fields private List _all; // host == '+' + private LinkedList _connections; + private object _connectionsSync; private static readonly string _defaultCertFolderPath; private IPEndPoint _endpoint; private List _prefixes; @@ -69,8 +71,6 @@ internal sealed class EndPointListener private Socket _socket; private ServerSslConfiguration _sslConfig; private List _unhandled; // host == '*' - private LinkedList _connections; - private object _connectionsSync; #endregion From 033c07eca60fb7433aa4dfd407a800fdfb06fb53 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 17 Apr 2021 21:43:55 +0900 Subject: [PATCH 3531/6294] [Modify] Use the Dictionary class instead --- websocket-sharp/Net/EndPointListener.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/EndPointListener.cs b/websocket-sharp/Net/EndPointListener.cs index 06ff7c27b..d359fbdeb 100644 --- a/websocket-sharp/Net/EndPointListener.cs +++ b/websocket-sharp/Net/EndPointListener.cs @@ -62,7 +62,7 @@ internal sealed class EndPointListener #region Private Fields private List _all; // host == '+' - private LinkedList _connections; + private Dictionary _connections; private object _connectionsSync; private static readonly string _defaultCertFolderPath; private IPEndPoint _endpoint; @@ -116,7 +116,7 @@ bool reuseAddress } _prefixes = new List (); - _connections = new LinkedList (); + _connections = new Dictionary (); _connectionsSync = ((ICollection) _connections).SyncRoot; _socket = new Socket ( @@ -200,7 +200,9 @@ private void clearConnections () return; conns = new HttpConnection[cnt]; - _connections.CopyTo (conns, 0); + + var vals = _connections.Values; + vals.CopyTo (conns, 0); _connections.Clear (); } @@ -313,7 +315,7 @@ private static void processAccepted ( } lock (listener._connectionsSync) - listener._connections.AddLast (conn); + listener._connections.Add (conn, conn); conn.BeginReadRequest (); } From 4615c6958e75f4c51e2d0a48920dfb667cbeb444 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 17 Apr 2021 21:46:15 +0900 Subject: [PATCH 3532/6294] [Modify] Polish it --- websocket-sharp/Net/EndPointListener.cs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/websocket-sharp/Net/EndPointListener.cs b/websocket-sharp/Net/EndPointListener.cs index d359fbdeb..2d2c1081d 100644 --- a/websocket-sharp/Net/EndPointListener.cs +++ b/websocket-sharp/Net/EndPointListener.cs @@ -61,16 +61,16 @@ internal sealed class EndPointListener { #region Private Fields - private List _all; // host == '+' + private List _all; // host == '+' private Dictionary _connections; - private object _connectionsSync; - private static readonly string _defaultCertFolderPath; - private IPEndPoint _endpoint; - private List _prefixes; - private bool _secure; - private Socket _socket; - private ServerSslConfiguration _sslConfig; - private List _unhandled; // host == '*' + private object _connectionsSync; + private static readonly string _defaultCertFolderPath; + private IPEndPoint _endpoint; + private List _prefixes; + private bool _secure; + private Socket _socket; + private ServerSslConfiguration _sslConfig; + private List _unhandled; // host == '*' #endregion From 5adc1ca3b24450d50245c0c742af6d02112d2495 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 17 Apr 2021 21:51:59 +0900 Subject: [PATCH 3533/6294] [Modify] Polish it --- websocket-sharp/Net/EndPointListener.cs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Net/EndPointListener.cs b/websocket-sharp/Net/EndPointListener.cs index 2d2c1081d..b372a2524 100644 --- a/websocket-sharp/Net/EndPointListener.cs +++ b/websocket-sharp/Net/EndPointListener.cs @@ -191,10 +191,8 @@ private void clearConnections () { HttpConnection[] conns = null; - var cnt = 0; - lock (_connectionsSync) { - cnt = _connections.Count; + var cnt = _connections.Count; if (cnt == 0) return; @@ -207,8 +205,8 @@ private void clearConnections () _connections.Clear (); } - for (var i = cnt - 1; i >= 0; i--) - conns[i].Close (true); + foreach (var conn in conns) + conn.Close (true); } private static RSACryptoServiceProvider createRSAFromFile (string path) From 502641cf11bc619ec95f86e9af615a6080fc613b Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 18 Apr 2021 16:13:29 +0900 Subject: [PATCH 3534/6294] [Modify] Remove it --- websocket-sharp/Net/HttpListener.cs | 6 ------ 1 file changed, 6 deletions(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index ae611d2c5..05467ba4a 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -602,12 +602,6 @@ internal bool RegisterContext (HttpListenerContext context) } } - internal void RemoveConnection (HttpConnection connection) - { - lock (_connectionsSync) - _connections.Remove (connection); - } - internal AuthenticationSchemes SelectAuthenticationScheme ( HttpListenerRequest request ) From b64f8ebaa2e3bfcdaa7dcb806e0f2e3015b7b492 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 18 Apr 2021 16:15:18 +0900 Subject: [PATCH 3535/6294] [Modify] Remove it --- websocket-sharp/Net/HttpListener.cs | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 05467ba4a..e40138c03 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -528,21 +528,6 @@ private HttpListenerContext getContextFromQueue () #region Internal Methods - internal bool AddConnection (HttpConnection connection) - { - if (!_listening) - return false; - - lock (_connectionsSync) { - if (!_listening) - return false; - - _connections[connection] = connection; - - return true; - } - } - internal HttpListenerAsyncResult BeginGetContext ( HttpListenerAsyncResult asyncResult ) From e9be6a7b3ac373ad78c7df1d43aad3a0856dc46c Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 18 Apr 2021 16:17:43 +0900 Subject: [PATCH 3536/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListener.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index e40138c03..089cc2644 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -835,7 +835,6 @@ public void Stop () cleanupContextQueue (true); cleanupContextRegistry (); - cleanupConnections (); var ex = new HttpListenerException (995, "The listener is stopped."); cleanupWaitQueue (ex); From bf710ba6e7b26e89fcce7d89de7799295528a630 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 18 Apr 2021 16:19:09 +0900 Subject: [PATCH 3537/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListener.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 089cc2644..2a82cdf57 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -506,7 +506,6 @@ private void close (bool force) cleanupContextQueue (!force); cleanupContextRegistry (); - cleanupConnections (); var ex = new ObjectDisposedException (GetType ().ToString ()); cleanupWaitQueue (ex); From 28e5c28f8e031e36ebf322a745d98c5d007caa3a Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 18 Apr 2021 16:20:55 +0900 Subject: [PATCH 3538/6294] [Modify] Remove it --- websocket-sharp/Net/HttpListener.cs | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 2a82cdf57..b3799ac54 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -415,26 +415,6 @@ public Func UserCredentialsFinder { #region Private Methods - private void cleanupConnections () - { - HttpConnection[] conns = null; - - lock (_connectionsSync) { - if (_connections.Count == 0) - return; - - // Need to copy this since closing will call the RemoveConnection method. - var keys = _connections.Keys; - conns = new HttpConnection[keys.Count]; - keys.CopyTo (conns, 0); - - _connections.Clear (); - } - - for (var i = conns.Length - 1; i >= 0; i--) - conns[i].Close (true); - } - private void cleanupContextQueue (bool sendServiceUnavailable) { HttpListenerContext[] ctxs = null; From d1c3b6c9a271e5238bf5f49dd1d3d312a376e603 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 18 Apr 2021 16:23:04 +0900 Subject: [PATCH 3539/6294] [Modify] Remove them --- websocket-sharp/Net/HttpListener.cs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index b3799ac54..784e4c183 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -64,8 +64,6 @@ public sealed class HttpListener : IDisposable private AuthenticationSchemes _authSchemes; private Func _authSchemeSelector; private string _certFolderPath; - private Dictionary _connections; - private object _connectionsSync; private Queue _contextQueue; private object _contextQueueSync; private LinkedList _contextRegistry; @@ -103,9 +101,6 @@ public HttpListener () { _authSchemes = AuthenticationSchemes.Anonymous; - _connections = new Dictionary (); - _connectionsSync = ((ICollection) _connections).SyncRoot; - _contextQueue = new Queue (); _contextQueueSync = ((ICollection) _contextQueue).SyncRoot; From bea69ddebc240afab8c61a4cfb9fec1bcada5f64 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 19 Apr 2021 21:28:23 +0900 Subject: [PATCH 3540/6294] [Modify] Replace it --- websocket-sharp/Net/HttpListener.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 784e4c183..23c72b1ab 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -550,12 +550,13 @@ internal bool RegisterContext (HttpListenerContext context) _contextRegistry.AddLast (context); - var ares = getAsyncResultFromQueue (); - - if (ares == null) + if (_waitQueue.Count == 0) { _contextQueue.Enqueue (context); - else + } + else { + var ares = _waitQueue.Dequeue (); ares.Complete (context); + } return true; } From ff4686c12879369a12ebec1ac7d3bc88f3760783 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 19 Apr 2021 21:29:15 +0900 Subject: [PATCH 3541/6294] [Modify] Remove it --- websocket-sharp/Net/HttpListener.cs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 23c72b1ab..8579232f2 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -488,11 +488,6 @@ private void close (bool force) _disposed = true; } - private HttpListenerAsyncResult getAsyncResultFromQueue () - { - return _waitQueue.Count > 0 ? _waitQueue.Dequeue () : null; - } - private HttpListenerContext getContextFromQueue () { return _contextQueue.Count > 0 ? _contextQueue.Dequeue () : null; From b6816681f23b3944958ae42efae3390aa3dbf665 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 19 Apr 2021 21:35:33 +0900 Subject: [PATCH 3542/6294] [Modify] Replace it --- websocket-sharp/Net/HttpListener.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 8579232f2..96402c47f 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -505,12 +505,13 @@ HttpListenerAsyncResult asyncResult if (!_listening) throw new HttpListenerException (995); - var ctx = getContextFromQueue (); - - if (ctx == null) + if (_contextQueue.Count == 0) { _waitQueue.Enqueue (asyncResult); - else + } + else { + var ctx = _contextQueue.Dequeue (); asyncResult.Complete (ctx, true); + } return asyncResult; } From 5f73b1bfe314b2394f20d93a2b704b46b63893e7 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 19 Apr 2021 21:37:05 +0900 Subject: [PATCH 3543/6294] [Modify] Remove it --- websocket-sharp/Net/HttpListener.cs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 96402c47f..19a547365 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -488,11 +488,6 @@ private void close (bool force) _disposed = true; } - private HttpListenerContext getContextFromQueue () - { - return _contextQueue.Count > 0 ? _contextQueue.Dequeue () : null; - } - #endregion #region Internal Methods From 3447e692867a4790a220a3aeaf602910028fa69a Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 20 Apr 2021 19:35:07 +0900 Subject: [PATCH 3544/6294] [Modify] Lock it --- websocket-sharp/Net/HttpListener.cs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 19a547365..403e1aaf2 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -775,9 +775,16 @@ public void Start () if (_listening) return; - EndPointManager.AddListener (this); + lock (_contextRegistrySync) { + CheckDisposed (); + + if (_listening) + return; + + EndPointManager.AddListener (this); - _listening = true; + _listening = true; + } } /// From 9bf82164e04c13f21bf5817fbf2abb5a42c6bcd2 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 20 Apr 2021 19:41:23 +0900 Subject: [PATCH 3545/6294] [Modify] Lock it --- websocket-sharp/Net/HttpListener.cs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 403e1aaf2..37f8586a0 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -800,17 +800,20 @@ public void Stop () if (!_listening) return; - _listening = false; + lock (_contextRegistrySync) { + if (!_listening) + return; - EndPointManager.RemoveListener (this); + EndPointManager.RemoveListener (this); - lock (_contextRegistrySync) cleanupContextQueue (true); + cleanupContextRegistry (); - cleanupContextRegistry (); + var ex = new HttpListenerException (995, "The listener is stopped."); + cleanupWaitQueue (ex); - var ex = new HttpListenerException (995, "The listener is stopped."); - cleanupWaitQueue (ex); + _listening = false; + } } #endregion From bcca8fe1b736b510ae9c4bb8e59a7225cb5266f0 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 20 Apr 2021 19:50:42 +0900 Subject: [PATCH 3546/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListener.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 37f8586a0..b23fdb0aa 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -809,7 +809,8 @@ public void Stop () cleanupContextQueue (true); cleanupContextRegistry (); - var ex = new HttpListenerException (995, "The listener is stopped."); + var msg = "The listener is stopped."; + var ex = new HttpListenerException (995, msg); cleanupWaitQueue (ex); _listening = false; From 0385be837d4a85690697939a81c1a2630a5b186f Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 20 Apr 2021 19:57:04 +0900 Subject: [PATCH 3547/6294] [Modify] Lock it --- websocket-sharp/Net/HttpListener.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index b23fdb0aa..375cd9d52 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -588,7 +588,12 @@ public void Abort () if (_disposed) return; - close (true); + lock (_contextRegistrySync) { + if (_disposed) + return; + + close (true); + } } /// From d15690bc400a2fe3c89e02b55fdfd28d6e02e123 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 20 Apr 2021 19:59:11 +0900 Subject: [PATCH 3548/6294] [Modify] Lock it --- websocket-sharp/Net/HttpListener.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 375cd9d52..4fe7745f4 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -662,7 +662,12 @@ public void Close () if (_disposed) return; - close (false); + lock (_contextRegistrySync) { + if (_disposed) + return; + + close (false); + } } /// From 27a23446fb29e80fa820e1609dcc55bdf6bda8c4 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 20 Apr 2021 20:00:34 +0900 Subject: [PATCH 3549/6294] [Modify] Lock it --- websocket-sharp/Net/HttpListener.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 4fe7745f4..8d770d2a7 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -839,7 +839,12 @@ void IDisposable.Dispose () if (_disposed) return; - close (true); + lock (_contextRegistrySync) { + if (_disposed) + return; + + close (true); + } } #endregion From d7b3fef56d2b576ec0f5ddb481b110e925f9cd07 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 20 Apr 2021 20:16:33 +0900 Subject: [PATCH 3550/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListener.cs | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 8d770d2a7..e99122c5d 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -472,18 +472,17 @@ private void cleanupWaitQueue (Exception exception) private void close (bool force) { if (_listening) { - _listening = false; - - EndPointManager.RemoveListener (this); - } - - lock (_contextRegistrySync) cleanupContextQueue (!force); + cleanupContextRegistry (); + + var name = GetType ().ToString (); + var ex = new ObjectDisposedException (name); + cleanupWaitQueue (ex); - cleanupContextRegistry (); + EndPointManager.RemoveListener (this); - var ex = new ObjectDisposedException (GetType ().ToString ()); - cleanupWaitQueue (ex); + _listening = false; + } _disposed = true; } From 526fb635c9361dd16c6aefaa4f9dfe665952dbe2 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 20 Apr 2021 20:20:49 +0900 Subject: [PATCH 3551/6294] [Modify] Move it --- websocket-sharp/Net/HttpListener.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index e99122c5d..9e771a7b8 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -813,8 +813,6 @@ public void Stop () if (!_listening) return; - EndPointManager.RemoveListener (this); - cleanupContextQueue (true); cleanupContextRegistry (); @@ -822,6 +820,8 @@ public void Stop () var ex = new HttpListenerException (995, msg); cleanupWaitQueue (ex); + EndPointManager.RemoveListener (this); + _listening = false; } } From 928fd0755f05b274a7450c3461ad99f4bbc7103a Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 21 Apr 2021 19:40:00 +0900 Subject: [PATCH 3552/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListener.cs | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 9e771a7b8..70384c6a0 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -412,19 +412,18 @@ public Func UserCredentialsFinder { private void cleanupContextQueue (bool sendServiceUnavailable) { - HttpListenerContext[] ctxs = null; - - lock (_contextQueueSync) { - if (_contextQueue.Count == 0) - return; - - ctxs = _contextQueue.ToArray (); + if (_contextQueue.Count == 0) + return; + if (!sendServiceUnavailable) { _contextQueue.Clear (); - } - if (!sendServiceUnavailable) return; + } + + var ctxs = _contextQueue.ToArray (); + + _contextQueue.Clear (); foreach (var ctx in ctxs) { ctx.ErrorStatusCode = 503; From dc420c7b7e1d35f2376c852929b3dafea424edd8 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 21 Apr 2021 19:46:58 +0900 Subject: [PATCH 3553/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListener.cs | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 70384c6a0..fea43aac2 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -433,22 +433,18 @@ private void cleanupContextQueue (bool sendServiceUnavailable) private void cleanupContextRegistry () { - HttpListenerContext[] ctxs = null; + var cnt = _contextRegistry.Count; - lock (_contextRegistrySync) { - var cnt = _contextRegistry.Count; - - if (cnt == 0) - return; + if (cnt == 0) + return; - ctxs = new HttpListenerContext[cnt]; - _contextRegistry.CopyTo (ctxs, 0); + var ctxs = new HttpListenerContext[cnt]; + _contextRegistry.CopyTo (ctxs, 0); - _contextRegistry.Clear (); - } + _contextRegistry.Clear (); - for (var i = ctxs.Length - 1; i >= 0; i--) - ctxs[i].Connection.Close (true); + foreach (var ctx in ctxs) + ctx.Connection.Close (true); } private void cleanupWaitQueue (Exception exception) From 9b6c7d300edbbd9423c9582dd2aed63e46602ec5 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 21 Apr 2021 19:49:53 +0900 Subject: [PATCH 3554/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListener.cs | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index fea43aac2..06dfb8cc6 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -449,16 +449,12 @@ private void cleanupContextRegistry () private void cleanupWaitQueue (Exception exception) { - HttpListenerAsyncResult[] aress = null; - - lock (_waitQueueSync) { - if (_waitQueue.Count == 0) - return; + if (_waitQueue.Count == 0) + return; - aress = _waitQueue.ToArray (); + var aress = _waitQueue.ToArray (); - _waitQueue.Clear (); - } + _waitQueue.Clear (); foreach (var ares in aress) ares.Complete (exception); From 3daac29bc45b1e95f15ecbbc955279c8404cad91 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 21 Apr 2021 19:53:46 +0900 Subject: [PATCH 3555/6294] [Modify] Remove them --- websocket-sharp/Net/HttpListener.cs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 06dfb8cc6..89376c48d 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -65,7 +65,6 @@ public sealed class HttpListener : IDisposable private Func _authSchemeSelector; private string _certFolderPath; private Queue _contextQueue; - private object _contextQueueSync; private LinkedList _contextRegistry; private object _contextRegistrySync; private static readonly string _defaultRealm; @@ -79,7 +78,6 @@ public sealed class HttpListener : IDisposable private ServerSslConfiguration _sslConfig; private Func _userCredFinder; private Queue _waitQueue; - private object _waitQueueSync; #endregion @@ -102,7 +100,6 @@ public HttpListener () _authSchemes = AuthenticationSchemes.Anonymous; _contextQueue = new Queue (); - _contextQueueSync = ((ICollection) _contextQueue).SyncRoot; _contextRegistry = new LinkedList (); _contextRegistrySync = ((ICollection) _contextRegistry).SyncRoot; @@ -112,7 +109,6 @@ public HttpListener () _prefixes = new HttpListenerPrefixCollection (this); _waitQueue = new Queue (); - _waitQueueSync = ((ICollection) _waitQueue).SyncRoot; } #endregion From 6d6e2e694171197fbbc80312a5a4f3757804ecbe Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 21 Apr 2021 19:55:04 +0900 Subject: [PATCH 3556/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListener.cs | 3 --- 1 file changed, 3 deletions(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 89376c48d..e3d78acbe 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -98,16 +98,13 @@ static HttpListener () public HttpListener () { _authSchemes = AuthenticationSchemes.Anonymous; - _contextQueue = new Queue (); _contextRegistry = new LinkedList (); _contextRegistrySync = ((ICollection) _contextRegistry).SyncRoot; _logger = new Logger (); - _prefixes = new HttpListenerPrefixCollection (this); - _waitQueue = new Queue (); } From a751b8140759696c5a19772ca6a829cf44b2f85f Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 22 Apr 2021 19:48:53 +0900 Subject: [PATCH 3557/6294] [Modify] Move it --- websocket-sharp/Net/HttpListener.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index e3d78acbe..45c9e9580 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -797,6 +797,8 @@ public void Stop () if (!_listening) return; + _listening = false; + cleanupContextQueue (true); cleanupContextRegistry (); @@ -805,8 +807,6 @@ public void Stop () cleanupWaitQueue (ex); EndPointManager.RemoveListener (this); - - _listening = false; } } From e8634d9831ac801abf34ac5939886874aab4118a Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 22 Apr 2021 19:51:53 +0900 Subject: [PATCH 3558/6294] [Modify] Move it --- websocket-sharp/Net/HttpListener.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 45c9e9580..86101d395 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -456,6 +456,8 @@ private void cleanupWaitQueue (Exception exception) private void close (bool force) { if (_listening) { + _listening = false; + cleanupContextQueue (!force); cleanupContextRegistry (); @@ -464,8 +466,6 @@ private void close (bool force) cleanupWaitQueue (ex); EndPointManager.RemoveListener (this); - - _listening = false; } _disposed = true; From 51418c3dd41cd93104116323125646ddc17ed0d1 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 23 Apr 2021 19:34:58 +0900 Subject: [PATCH 3559/6294] [Modify] Rename it --- websocket-sharp/Net/HttpListener.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 86101d395..7abb7cb8d 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -403,12 +403,12 @@ public Func UserCredentialsFinder { #region Private Methods - private void cleanupContextQueue (bool sendServiceUnavailable) + private void cleanupContextQueue (bool force) { if (_contextQueue.Count == 0) return; - if (!sendServiceUnavailable) { + if (force) { _contextQueue.Clear (); return; @@ -458,7 +458,7 @@ private void close (bool force) if (_listening) { _listening = false; - cleanupContextQueue (!force); + cleanupContextQueue (force); cleanupContextRegistry (); var name = GetType ().ToString (); @@ -799,7 +799,7 @@ public void Stop () _listening = false; - cleanupContextQueue (true); + cleanupContextQueue (false); cleanupContextRegistry (); var msg = "The listener is stopped."; From 4b348e258a64d3dd5f51018ced656b170e864778 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 24 Apr 2021 21:37:55 +0900 Subject: [PATCH 3560/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListener.cs | 3 --- 1 file changed, 3 deletions(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 7abb7cb8d..cf2870b20 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -790,9 +790,6 @@ public void Stop () { CheckDisposed (); - if (!_listening) - return; - lock (_contextRegistrySync) { if (!_listening) return; From 5faef220081ae9dd5f1e944107a20412573a46ea Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 25 Apr 2021 22:07:00 +0900 Subject: [PATCH 3561/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListener.cs | 3 --- 1 file changed, 3 deletions(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index cf2870b20..b7de73f02 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -765,9 +765,6 @@ public void Start () { CheckDisposed (); - if (_listening) - return; - lock (_contextRegistrySync) { CheckDisposed (); From 1ebf72c95770f01c9d8376079dc62b03e300e874 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 26 Apr 2021 20:54:17 +0900 Subject: [PATCH 3562/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListener.cs | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index b7de73f02..7c0be5370 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -455,18 +455,22 @@ private void cleanupWaitQueue (Exception exception) private void close (bool force) { - if (_listening) { - _listening = false; + if (!_listening) { + _disposed = true; - cleanupContextQueue (force); - cleanupContextRegistry (); + return; + } - var name = GetType ().ToString (); - var ex = new ObjectDisposedException (name); - cleanupWaitQueue (ex); + _listening = false; - EndPointManager.RemoveListener (this); - } + cleanupContextQueue (force); + cleanupContextRegistry (); + + var name = GetType ().ToString (); + var ex = new ObjectDisposedException (name); + cleanupWaitQueue (ex); + + EndPointManager.RemoveListener (this); _disposed = true; } From 600c5389d0d888d1729585500ccd6247876209be Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 27 Apr 2021 19:49:00 +0900 Subject: [PATCH 3563/6294] [Modify] Add it --- websocket-sharp/Net/HttpListener.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 7c0be5370..01e0fccf2 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -72,6 +72,7 @@ public sealed class HttpListener : IDisposable private bool _ignoreWriteExceptions; private volatile bool _listening; private Logger _logger; + private string _objectName; private HttpListenerPrefixCollection _prefixes; private string _realm; private bool _reuseAddress; @@ -104,6 +105,7 @@ public HttpListener () _contextRegistrySync = ((ICollection) _contextRegistry).SyncRoot; _logger = new Logger (); + _objectName = GetType ().ToString (); _prefixes = new HttpListenerPrefixCollection (this); _waitQueue = new Queue (); } From c3a5680f94381621275f7a2bb31ae6da4067f15b Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 27 Apr 2021 19:52:21 +0900 Subject: [PATCH 3564/6294] [Modify] Replace it --- websocket-sharp/Net/HttpListener.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 01e0fccf2..3393db6ec 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -147,7 +147,9 @@ internal bool ReuseAddress { /// public AuthenticationSchemes AuthenticationSchemes { get { - CheckDisposed (); + if (_disposed) + throw new ObjectDisposedException (_objectName); + return _authSchemes; } From 553121dae362f710610e03dd708eab3a8d237402 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 28 Apr 2021 19:35:06 +0900 Subject: [PATCH 3565/6294] [Modify] Replace it --- websocket-sharp/Net/HttpListener.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 3393db6ec..1dba0d1bc 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -154,7 +154,9 @@ public AuthenticationSchemes AuthenticationSchemes { } set { - CheckDisposed (); + if (_disposed) + throw new ObjectDisposedException (_objectName); + _authSchemes = value; } } From 0e550b860edd7c4adce8881acefbb1bc7398c52e Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 28 Apr 2021 19:41:38 +0900 Subject: [PATCH 3566/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListener.cs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 1dba0d1bc..134d77096 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -138,9 +138,17 @@ internal bool ReuseAddress { /// Gets or sets the scheme used to authenticate the clients. /// /// - /// One of the enum values, - /// represents the scheme used to authenticate the clients. The default value is - /// . + /// + /// One of the + /// enum values. + /// + /// + /// It represents the scheme used to authenticate the clients. + /// + /// + /// The default value is + /// . + /// /// /// /// This listener has been closed. From 31d1496ffc2926c7b63eb85945804d1d3e964b2a Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 29 Apr 2021 19:34:07 +0900 Subject: [PATCH 3567/6294] [Modify] Replace it --- websocket-sharp/Net/HttpListener.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 134d77096..8ec57f26d 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -188,7 +188,9 @@ public AuthenticationSchemes AuthenticationSchemes { /// public Func AuthenticationSchemeSelector { get { - CheckDisposed (); + if (_disposed) + throw new ObjectDisposedException (_objectName); + return _authSchemeSelector; } From c255e33da5b7ac7020dfe4a0c831e3613db256b0 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 29 Apr 2021 19:35:20 +0900 Subject: [PATCH 3568/6294] [Modify] Replace it --- websocket-sharp/Net/HttpListener.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 8ec57f26d..11f2a3638 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -195,7 +195,9 @@ public Func AuthenticationSchemeSele } set { - CheckDisposed (); + if (_disposed) + throw new ObjectDisposedException (_objectName); + _authSchemeSelector = value; } } From 0d5d829ea780dab7cd2e971e1d78ae22a4743883 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 30 Apr 2021 20:34:19 +0900 Subject: [PATCH 3569/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListener.cs | 31 +++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 11f2a3638..78d14f084 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -170,18 +170,33 @@ public AuthenticationSchemes AuthenticationSchemes { } /// - /// Gets or sets the delegate called to select the scheme used to authenticate the clients. + /// Gets or sets the delegate called to select the scheme used to + /// authenticate the clients. /// /// - /// If you set this property, the listener uses the authentication scheme selected by - /// the delegate for each request. Or if you don't set, the listener uses the value of - /// the property as the authentication - /// scheme for all requests. + /// + /// If this property is set, the listener uses the authentication + /// scheme selected by the delegate for each request. + /// + /// + /// Or if this property is not set, the listener uses the value of + /// the property + /// as the authentication scheme for all requests. + /// /// /// - /// A Func<, > - /// delegate that references the method used to select an authentication scheme. The default - /// value is . + /// + /// A Func<, + /// > delegate or + /// if not needed. + /// + /// + /// The delegate references the method used to select + /// an authentication scheme. + /// + /// + /// The default value is . + /// /// /// /// This listener has been closed. From f55f17de4e2f513141153509bb5045ca573aaf3e Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 30 Apr 2021 20:36:28 +0900 Subject: [PATCH 3570/6294] [Modify] Replace it --- websocket-sharp/Net/HttpListener.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 78d14f084..962baf8b4 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -243,7 +243,9 @@ public Func AuthenticationSchemeSele /// public string CertificateFolderPath { get { - CheckDisposed (); + if (_disposed) + throw new ObjectDisposedException (_objectName); + return _certFolderPath; } From b30e5e52fea7c484c85a9e26d573ae6f6d503ca1 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 30 Apr 2021 20:37:15 +0900 Subject: [PATCH 3571/6294] [Modify] Replace it --- websocket-sharp/Net/HttpListener.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 962baf8b4..d5f18950f 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -250,7 +250,9 @@ public string CertificateFolderPath { } set { - CheckDisposed (); + if (_disposed) + throw new ObjectDisposedException (_objectName); + _certFolderPath = value; } } From 47fbc7c5b0eaf57c9802c635f319df61a58fe2dd Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 1 May 2021 21:50:23 +0900 Subject: [PATCH 3572/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListener.cs | 31 +++++++++++++++++++---------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index d5f18950f..65b959b0d 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -218,25 +218,34 @@ public Func AuthenticationSchemeSele } /// - /// Gets or sets the path to the folder in which stores the certificate files used to - /// authenticate the server on the secure connection. + /// Gets or sets the path to the folder in which stores the certificate + /// files used to authenticate the server on the secure connection. /// /// /// - /// This property represents the path to the folder in which stores the certificate files - /// associated with each port number of added URI prefixes. A set of the certificate files - /// is a pair of the 'port number'.cer (DER) and 'port number'.key - /// (DER, RSA Private Key). + /// This property represents the path to the folder in which stores + /// the certificate files associated with each port number of added + /// URI prefixes. /// /// - /// If this property is or empty, the result of - /// System.Environment.GetFolderPath - /// () is used as the default path. + /// A set of the certificate files is a pair of <port number>.cer + /// (DER) and <port number>.key (DER, RSA Private Key). + /// + /// + /// If this property is or an empty string, + /// the result of System.Environment.GetFolderPath ( + /// ) + /// is used as the default path. /// /// /// - /// A that represents the path to the folder in which stores - /// the certificate files. The default value is . + /// + /// A that represents the path to the folder + /// in which stores the certificate files. + /// + /// + /// The default value is . + /// /// /// /// This listener has been closed. From a37af8db8f5ba384d0342cfe7f1f7b721d521822 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 1 May 2021 21:52:44 +0900 Subject: [PATCH 3573/6294] [Modify] Replace it --- websocket-sharp/Net/HttpListener.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 65b959b0d..d6732d302 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -279,7 +279,9 @@ public string CertificateFolderPath { /// public bool IgnoreWriteExceptions { get { - CheckDisposed (); + if (_disposed) + throw new ObjectDisposedException (_objectName); + return _ignoreWriteExceptions; } From 4501a951810b2a5cbe4fe79501772c4d9766772e Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 1 May 2021 21:53:36 +0900 Subject: [PATCH 3574/6294] [Modify] Replace it --- websocket-sharp/Net/HttpListener.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index d6732d302..f6471e621 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -286,7 +286,9 @@ public bool IgnoreWriteExceptions { } set { - CheckDisposed (); + if (_disposed) + throw new ObjectDisposedException (_objectName); + _ignoreWriteExceptions = value; } } From 15d5caf82252791e6737176181960467b5af98b2 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 2 May 2021 21:48:24 +0900 Subject: [PATCH 3575/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListener.cs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index f6471e621..fbf869d28 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -267,12 +267,17 @@ public string CertificateFolderPath { } /// - /// Gets or sets a value indicating whether the listener returns exceptions that occur when - /// sending the response to the client. + /// Gets or sets a value indicating whether the listener returns + /// exceptions that occur when sending the response to the client. /// /// - /// true if the listener shouldn't return those exceptions; otherwise, false. - /// The default value is false. + /// + /// true if the listener should not return those exceptions; + /// otherwise, false. + /// + /// + /// The default value is false. + /// /// /// /// This listener has been closed. From 8237a384bc5573e1ecc27b000e691fd2bb855547 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 2 May 2021 21:51:25 +0900 Subject: [PATCH 3576/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListener.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index fbf869d28..883110076 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -311,7 +311,8 @@ public bool IsListening { } /// - /// Gets a value indicating whether the listener can be used with the current operating system. + /// Gets a value indicating whether the listener can be used with + /// the current operating system. /// /// /// true. From 6314847213c6cc7dbc21490de1986a1fd637991f Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 2 May 2021 21:55:07 +0900 Subject: [PATCH 3577/6294] [Modify] Rename it --- websocket-sharp/Net/HttpListener.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 883110076..a9a85f010 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -71,7 +71,7 @@ public sealed class HttpListener : IDisposable private bool _disposed; private bool _ignoreWriteExceptions; private volatile bool _listening; - private Logger _logger; + private Logger _log; private string _objectName; private HttpListenerPrefixCollection _prefixes; private string _realm; @@ -104,7 +104,7 @@ public HttpListener () _contextRegistry = new LinkedList (); _contextRegistrySync = ((ICollection) _contextRegistry).SyncRoot; - _logger = new Logger (); + _log = new Logger (); _objectName = GetType ().ToString (); _prefixes = new HttpListenerPrefixCollection (this); _waitQueue = new Queue (); @@ -336,7 +336,7 @@ public static bool IsSupported { /// public Logger Log { get { - return _logger; + return _log; } } From faebf0305fb1bbc5f1248887db630db8af67d04d Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 3 May 2021 21:19:03 +0900 Subject: [PATCH 3578/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListener.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index a9a85f010..175ee1a23 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -327,9 +327,13 @@ public static bool IsSupported { /// Gets the logging functions. /// /// - /// The default logging level is . If you would like to change it, - /// you should set the Log.Level property to any of the enum - /// values. + /// + /// The default logging level is . + /// + /// + /// If you would like to change it, you should set the Log.Level + /// property to any of the enum values. + /// /// /// /// A that provides the logging functions. From 6ccf3c277f05fd25abcae71786d4bb6d8b1f92d3 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 3 May 2021 21:21:04 +0900 Subject: [PATCH 3579/6294] [Modify] Replace it --- websocket-sharp/Net/HttpListener.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 175ee1a23..d68f9a5e0 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -355,7 +355,9 @@ public Logger Log { /// public HttpListenerPrefixCollection Prefixes { get { - CheckDisposed (); + if (_disposed) + throw new ObjectDisposedException (_objectName); + return _prefixes; } } From d1912f4ae63e27bf764c5f8a41b1e4c1ebfb4c08 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 3 May 2021 21:23:18 +0900 Subject: [PATCH 3580/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListener.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index d68f9a5e0..ce6cf15e2 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -348,7 +348,8 @@ public Logger Log { /// Gets the URI prefixes handled by the listener. /// /// - /// A that contains the URI prefixes. + /// A that contains the URI + /// prefixes. /// /// /// This listener has been closed. From af9f135637ffc8586cf4139123a937f794729232 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 3 May 2021 21:24:51 +0900 Subject: [PATCH 3581/6294] [Modify] Replace it --- websocket-sharp/Net/HttpListener.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index ce6cf15e2..8fb699995 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -379,7 +379,9 @@ public HttpListenerPrefixCollection Prefixes { /// public string Realm { get { - CheckDisposed (); + if (_disposed) + throw new ObjectDisposedException (_objectName); + return _realm; } From 618c6724159dd2e6802c4b1e99001bbe025682e6 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 3 May 2021 21:25:38 +0900 Subject: [PATCH 3582/6294] [Modify] Replace it --- websocket-sharp/Net/HttpListener.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 8fb699995..e7a923f26 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -386,7 +386,9 @@ public string Realm { } set { - CheckDisposed (); + if (_disposed) + throw new ObjectDisposedException (_objectName); + _realm = value; } } From 41b5ee00a8aa9fd5a32caeb4a08fea151c44b7f7 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 4 May 2021 22:34:46 +0900 Subject: [PATCH 3583/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListener.cs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index e7a923f26..6dab43420 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -367,12 +367,16 @@ public HttpListenerPrefixCollection Prefixes { /// Gets or sets the name of the realm associated with the listener. ///
/// - /// If this property is or empty, "SECRET AREA" will be used as - /// the name of the realm. + /// If this property is or an empty string, + /// "SECRET AREA" will be used as the name of the realm. /// /// - /// A that represents the name of the realm. The default value is - /// . + /// + /// A that represents the name of the realm. + /// + /// + /// The default value is . + /// /// /// /// This listener has been closed. From d6eeed4a0cf798e68af06d3ead14786de951ad33 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 4 May 2021 22:35:59 +0900 Subject: [PATCH 3584/6294] [Modify] Replace it --- websocket-sharp/Net/HttpListener.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 6dab43420..54908ec7e 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -410,7 +410,9 @@ public string Realm { /// public ServerSslConfiguration SslConfiguration { get { - CheckDisposed (); + if (_disposed) + throw new ObjectDisposedException (_objectName); + return _sslConfig ?? (_sslConfig = new ServerSslConfiguration ()); } From 53dd507ae30ff770e1b650bf9948e8730737580c Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 4 May 2021 22:36:47 +0900 Subject: [PATCH 3585/6294] [Modify] Replace it --- websocket-sharp/Net/HttpListener.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 54908ec7e..eb4a56143 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -417,7 +417,9 @@ public ServerSslConfiguration SslConfiguration { } set { - CheckDisposed (); + if (_disposed) + throw new ObjectDisposedException (_objectName); + _sslConfig = value; } } From 6979b62f04fcfbd35e2404238c181ce06433abc5 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 4 May 2021 22:39:15 +0900 Subject: [PATCH 3586/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListener.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index eb4a56143..9ad0c15fe 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -413,7 +413,10 @@ public ServerSslConfiguration SslConfiguration { if (_disposed) throw new ObjectDisposedException (_objectName); - return _sslConfig ?? (_sslConfig = new ServerSslConfiguration ()); + if (_sslConfig == null) + _sslConfig = new ServerSslConfiguration (); + + return _sslConfig; } set { From ffcc8cbc6368ac908a2d31f65e750ad98776ab42 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 5 May 2021 20:28:26 +0900 Subject: [PATCH 3587/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListener.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 9ad0c15fe..9e36d56e9 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -398,12 +398,12 @@ public string Realm { } /// - /// Gets or sets the SSL configuration used to authenticate the server and - /// optionally the client for secure connection. + /// Gets or sets the SSL configuration used to authenticate the server + /// and optionally the client for secure connection. /// /// - /// A that represents the configuration used to - /// authenticate the server and optionally the client for secure connection. + /// A that represents the SSL + /// configuration for secure connection. /// /// /// This listener has been closed. From 44446ca8e1b536874e3adfa215e0c315ba519219 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 5 May 2021 20:33:56 +0900 Subject: [PATCH 3588/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListener.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 9e36d56e9..0d35698da 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -433,7 +433,7 @@ public ServerSslConfiguration SslConfiguration { /// additional requests on the same connection. ///
/// - /// This property isn't currently supported and always throws + /// This property is not currently supported and always throws /// a . /// /// From 8c425331f64a046266014032ca7866f914277067 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 5 May 2021 20:35:35 +0900 Subject: [PATCH 3589/6294] [Modify] Replace it --- websocket-sharp/Net/HttpListener.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 0d35698da..ca8d3b21f 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -467,7 +467,9 @@ public bool UnsafeConnectionNtlmAuthentication { /// public Func UserCredentialsFinder { get { - CheckDisposed (); + if (_disposed) + throw new ObjectDisposedException (_objectName); + return _userCredFinder; } From f76b71b0da30709d5e79ceb1416d97c2b28153b3 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 5 May 2021 20:36:24 +0900 Subject: [PATCH 3590/6294] [Modify] Replace it --- websocket-sharp/Net/HttpListener.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index ca8d3b21f..c40fa376a 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -474,7 +474,9 @@ public Func UserCredentialsFinder { } set { - CheckDisposed (); + if (_disposed) + throw new ObjectDisposedException (_objectName); + _userCredFinder = value; } } From 3ee3d386b55993cf098e508d3a248f6c03f74dcb Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 6 May 2021 19:39:48 +0900 Subject: [PATCH 3591/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListener.cs | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index c40fa376a..f46729e57 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -454,13 +454,21 @@ public bool UnsafeConnectionNtlmAuthentication { } /// - /// Gets or sets the delegate called to find the credentials for an identity used to - /// authenticate a client. + /// Gets or sets the delegate called to find the credentials for + /// an identity used to authenticate a client. /// /// - /// A Func<, > delegate - /// that references the method used to find the credentials. The default value is - /// . + /// + /// A Func<, + /// > delegate or + /// if not needed. + /// + /// + /// It references the method used to find the credentials. + /// + /// + /// The default value is . + /// /// /// /// This listener has been closed. From 048077c8373a6cb520e3d9e7682cb7739e9f30aa Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 7 May 2021 19:08:10 +0900 Subject: [PATCH 3592/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListener.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index f46729e57..220495cd6 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -556,8 +556,7 @@ private void close (bool force) cleanupContextQueue (force); cleanupContextRegistry (); - var name = GetType ().ToString (); - var ex = new ObjectDisposedException (name); + var ex = new ObjectDisposedException (_objectName); cleanupWaitQueue (ex); EndPointManager.RemoveListener (this); From d9e436488ca2eca29b83371c8b8fcd37cf31dfd2 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 7 May 2021 19:09:59 +0900 Subject: [PATCH 3593/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListener.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 220495cd6..1e11028cc 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -591,7 +591,7 @@ HttpListenerAsyncResult asyncResult internal void CheckDisposed () { if (_disposed) - throw new ObjectDisposedException (GetType ().ToString ()); + throw new ObjectDisposedException (_objectName); } internal string GetRealm () From 26f3a5682f4ede840892af0c9205089cbf9e5a86 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 7 May 2021 19:13:02 +0900 Subject: [PATCH 3594/6294] [Modify] Replace it --- websocket-sharp/Net/HttpListener.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 1e11028cc..2af94166b 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -713,7 +713,8 @@ public void Abort () /// public IAsyncResult BeginGetContext (AsyncCallback callback, Object state) { - CheckDisposed (); + if (_disposed) + throw new ObjectDisposedException (_objectName); if (_prefixes.Count == 0) { var msg = "The listener has no URI prefix on which listens."; From 196d5d78992bff64ae6113adcb58955d34e95b35 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 7 May 2021 19:15:58 +0900 Subject: [PATCH 3595/6294] [Modify] Replace it --- websocket-sharp/Net/HttpListener.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 2af94166b..927557b46 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -776,7 +776,8 @@ public void Close () /// public HttpListenerContext EndGetContext (IAsyncResult asyncResult) { - CheckDisposed (); + if (_disposed) + throw new ObjectDisposedException (_objectName); if (asyncResult == null) throw new ArgumentNullException ("asyncResult"); From f7b4e1a31c2a33cef9a4094ab3fcc3eef1f3d69f Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 7 May 2021 19:18:37 +0900 Subject: [PATCH 3596/6294] [Modify] Replace it --- websocket-sharp/Net/HttpListener.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 927557b46..a64f135d8 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -830,7 +830,8 @@ public HttpListenerContext EndGetContext (IAsyncResult asyncResult) /// public HttpListenerContext GetContext () { - CheckDisposed (); + if (_disposed) + throw new ObjectDisposedException (_objectName); if (_prefixes.Count == 0) { var msg = "The listener has no URI prefix on which listens."; From acaab2076cdd9657e7b6fce1ffd5abaa2f12e877 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 8 May 2021 20:29:52 +0900 Subject: [PATCH 3597/6294] [Modify] Replace them --- websocket-sharp/Net/HttpListener.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index a64f135d8..590b12c2d 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -859,10 +859,12 @@ public HttpListenerContext GetContext () /// public void Start () { - CheckDisposed (); + if (_disposed) + throw new ObjectDisposedException (_objectName); lock (_contextRegistrySync) { - CheckDisposed (); + if (_disposed) + throw new ObjectDisposedException (_objectName); if (_listening) return; From fdcb83c494297a76406b279c06554ca00a2cbff2 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 8 May 2021 20:32:35 +0900 Subject: [PATCH 3598/6294] [Modify] Replace it --- websocket-sharp/Net/HttpListener.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 590b12c2d..b69fa7b49 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -883,7 +883,8 @@ public void Start () /// public void Stop () { - CheckDisposed (); + if (_disposed) + throw new ObjectDisposedException (_objectName); lock (_contextRegistrySync) { if (!_listening) From 691477b338fad6d85b26b41fa2e42ae6ba31e3b1 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 8 May 2021 20:40:54 +0900 Subject: [PATCH 3599/6294] [Modify] Replace it --- websocket-sharp/Net/HttpListenerPrefixCollection.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerPrefixCollection.cs b/websocket-sharp/Net/HttpListenerPrefixCollection.cs index 765213de0..2eabd8529 100644 --- a/websocket-sharp/Net/HttpListenerPrefixCollection.cs +++ b/websocket-sharp/Net/HttpListenerPrefixCollection.cs @@ -138,8 +138,7 @@ public bool IsSynchronized { /// public void Add (string uriPrefix) { - if (_listener.IsDisposed) - throw new ObjectDisposedException (_listener.GetType ().ToString ()); + _listener.CheckDisposed (); HttpListenerPrefix.CheckPrefix (uriPrefix); From 8aaef1ef0dd93ea3b19fec28eace948b8b09c8e9 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 8 May 2021 20:42:51 +0900 Subject: [PATCH 3600/6294] [Modify] Replace it --- websocket-sharp/Net/HttpListenerPrefixCollection.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerPrefixCollection.cs b/websocket-sharp/Net/HttpListenerPrefixCollection.cs index 2eabd8529..7459267ee 100644 --- a/websocket-sharp/Net/HttpListenerPrefixCollection.cs +++ b/websocket-sharp/Net/HttpListenerPrefixCollection.cs @@ -160,8 +160,7 @@ public void Add (string uriPrefix) /// public void Clear () { - if (_listener.IsDisposed) - throw new ObjectDisposedException (_listener.GetType ().ToString ()); + _listener.CheckDisposed (); if (_listener.IsListening) EndPointManager.RemoveListener (_listener); From 467a79531c36664c76d2f1d55d43e6c479455985 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 8 May 2021 20:44:05 +0900 Subject: [PATCH 3601/6294] [Modify] Replace it --- websocket-sharp/Net/HttpListenerPrefixCollection.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerPrefixCollection.cs b/websocket-sharp/Net/HttpListenerPrefixCollection.cs index 7459267ee..ba250d27b 100644 --- a/websocket-sharp/Net/HttpListenerPrefixCollection.cs +++ b/websocket-sharp/Net/HttpListenerPrefixCollection.cs @@ -188,8 +188,7 @@ public void Clear () /// public bool Contains (string uriPrefix) { - if (_listener.IsDisposed) - throw new ObjectDisposedException (_listener.GetType ().ToString ()); + _listener.CheckDisposed (); if (uriPrefix == null) throw new ArgumentNullException ("uriPrefix"); From ecb1c3ad22130d3ba3d471823197c9596e8101a9 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 8 May 2021 20:45:25 +0900 Subject: [PATCH 3602/6294] [Modify] Replace it --- websocket-sharp/Net/HttpListenerPrefixCollection.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerPrefixCollection.cs b/websocket-sharp/Net/HttpListenerPrefixCollection.cs index ba250d27b..6871a351c 100644 --- a/websocket-sharp/Net/HttpListenerPrefixCollection.cs +++ b/websocket-sharp/Net/HttpListenerPrefixCollection.cs @@ -223,8 +223,7 @@ public bool Contains (string uriPrefix) /// public void CopyTo (string[] array, int offset) { - if (_listener.IsDisposed) - throw new ObjectDisposedException (_listener.GetType ().ToString ()); + _listener.CheckDisposed (); _prefixes.CopyTo (array, offset); } From 9f9415a43d3238b4062be8c87c3512f07bcb0e15 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 8 May 2021 20:46:43 +0900 Subject: [PATCH 3603/6294] [Modify] Replace it --- websocket-sharp/Net/HttpListenerPrefixCollection.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerPrefixCollection.cs b/websocket-sharp/Net/HttpListenerPrefixCollection.cs index 6871a351c..cbe062ee1 100644 --- a/websocket-sharp/Net/HttpListenerPrefixCollection.cs +++ b/websocket-sharp/Net/HttpListenerPrefixCollection.cs @@ -259,8 +259,7 @@ public IEnumerator GetEnumerator () /// public bool Remove (string uriPrefix) { - if (_listener.IsDisposed) - throw new ObjectDisposedException (_listener.GetType ().ToString ()); + _listener.CheckDisposed (); if (uriPrefix == null) throw new ArgumentNullException ("uriPrefix"); From 79300881ae87a6ab9a16124b6929fa4847b591ca Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 9 May 2021 21:45:00 +0900 Subject: [PATCH 3604/6294] [Modify] Remove it --- websocket-sharp/Net/HttpListener.cs | 6 ------ 1 file changed, 6 deletions(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index b69fa7b49..0829fe2db 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -114,12 +114,6 @@ public HttpListener () #region Internal Properties - internal bool IsDisposed { - get { - return _disposed; - } - } - internal bool ReuseAddress { get { return _reuseAddress; From 8aeb1421984c291fcd18460a6d5eb41c3bb0475b Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 10 May 2021 21:45:24 +0900 Subject: [PATCH 3605/6294] [Modify] Add it --- websocket-sharp/Net/HttpListenerContext.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/websocket-sharp/Net/HttpListenerContext.cs b/websocket-sharp/Net/HttpListenerContext.cs index 3de938d28..d561adefb 100644 --- a/websocket-sharp/Net/HttpListenerContext.cs +++ b/websocket-sharp/Net/HttpListenerContext.cs @@ -252,6 +252,18 @@ internal bool Register () return _listener.RegisterContext (this); } + internal void SendAuthenticationChallenge ( + AuthenticationSchemes scheme, string realm + ) + { + var chal = new AuthenticationChallenge (scheme, realm).ToString (); + + _response.StatusCode = 401; + _response.Headers.InternalSet ("WWW-Authenticate", chal, true); + + _response.Close (); + } + internal void SendError () { try { From ac513b92e67b2bef984a86165d1bec7f443f9413 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 11 May 2021 19:39:23 +0900 Subject: [PATCH 3606/6294] [Modify] Add it --- websocket-sharp/Net/HttpListenerContext.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/websocket-sharp/Net/HttpListenerContext.cs b/websocket-sharp/Net/HttpListenerContext.cs index d561adefb..a3e700663 100644 --- a/websocket-sharp/Net/HttpListenerContext.cs +++ b/websocket-sharp/Net/HttpListenerContext.cs @@ -168,6 +168,10 @@ public IPrincipal User { get { return _user; } + + internal set { + _user = value; + } } #endregion From d53dd63d6f6860d3a625488ed126ff17e4aa0de1 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 11 May 2021 19:41:49 +0900 Subject: [PATCH 3607/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerContext.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerContext.cs b/websocket-sharp/Net/HttpListenerContext.cs index a3e700663..7dae410f9 100644 --- a/websocket-sharp/Net/HttpListenerContext.cs +++ b/websocket-sharp/Net/HttpListenerContext.cs @@ -153,12 +153,13 @@ public HttpListenerResponse Response { } /// - /// Gets the client information (identity, authentication, and security roles). + /// Gets the client information (identity, authentication, and security + /// roles). /// /// /// - /// A instance or if not - /// authenticated. + /// A instance or + /// if not authenticated. /// /// /// The instance describes the client. From f5747717240b9ff79fcb47c8b999b86cefadc39b Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 12 May 2021 19:40:17 +0900 Subject: [PATCH 3608/6294] [Modify] Add it --- websocket-sharp/Net/HttpListener.cs | 37 +++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 0829fe2db..1739b0085 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -562,6 +562,43 @@ private void close (bool force) #region Internal Methods + internal bool AuthenticateContext (HttpListenerContext context) + { + var req = context.Request; + var schm = SelectAuthenticationScheme (req); + + if (schm == AuthenticationSchemes.Anonymous) + return true; + + if (schm == AuthenticationSchemes.None) { + context.ErrorStatusCode = 403; + context.ErrorMessage = "Authentication not allowed"; + + context.SendError (); + + return false; + } + + var realm = GetRealm (); + var user = HttpUtility.CreateUser ( + req.Headers["Authorization"], + schm, + realm, + req.HttpMethod, + _userCredFinder + ); + + if (user == null || !user.Identity.IsAuthenticated) { + context.SendAuthenticationChallenge (schm, realm); + + return false; + } + + context.User = user; + + return true; + } + internal HttpListenerAsyncResult BeginGetContext ( HttpListenerAsyncResult asyncResult ) From 85ab9ccb54dafda933814b1973c9ebb002378b3e Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 12 May 2021 19:47:24 +0900 Subject: [PATCH 3609/6294] [Modify] Replace it --- websocket-sharp/Net/HttpConnection.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpConnection.cs b/websocket-sharp/Net/HttpConnection.cs index 8adf80fd6..a4869a399 100644 --- a/websocket-sharp/Net/HttpConnection.cs +++ b/websocket-sharp/Net/HttpConnection.cs @@ -455,7 +455,7 @@ private void registerContext (HttpListener listener) { _context.Listener = listener; - if (!_context.Authenticate ()) + if (!listener.AuthenticateContext (_context)) return; if (!_context.Register ()) { From 4e0f2902de29b7d9c515c3e96d4a5f283e24ce81 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 12 May 2021 19:54:24 +0900 Subject: [PATCH 3610/6294] [Modify] Move it --- websocket-sharp/Net/HttpConnection.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/HttpConnection.cs b/websocket-sharp/Net/HttpConnection.cs index a4869a399..801f71de7 100644 --- a/websocket-sharp/Net/HttpConnection.cs +++ b/websocket-sharp/Net/HttpConnection.cs @@ -319,6 +319,9 @@ private static void onRead (IAsyncResult asyncResult) HttpListener lsnr; if (conn._listener.TrySearchHttpListener (url, out lsnr)) { + if (!lsnr.AuthenticateContext (conn._context)) + return; + conn.registerContext (lsnr); return; @@ -455,9 +458,6 @@ private void registerContext (HttpListener listener) { _context.Listener = listener; - if (!listener.AuthenticateContext (_context)) - return; - if (!_context.Register ()) { _context.ErrorStatusCode = 503; _context.SendError (); From ebbc0a0bf9de300de4fc25b9331a4c2748f61746 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 12 May 2021 19:59:19 +0900 Subject: [PATCH 3611/6294] [Modify] Replace it --- websocket-sharp/Net/HttpConnection.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpConnection.cs b/websocket-sharp/Net/HttpConnection.cs index 801f71de7..718a4432a 100644 --- a/websocket-sharp/Net/HttpConnection.cs +++ b/websocket-sharp/Net/HttpConnection.cs @@ -458,7 +458,7 @@ private void registerContext (HttpListener listener) { _context.Listener = listener; - if (!_context.Register ()) { + if (!listener.RegisterContext (_context)) { _context.ErrorStatusCode = 503; _context.SendError (); From 42f695ef301fc8affe6cbf991ade92b5584dadf2 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 12 May 2021 20:08:56 +0900 Subject: [PATCH 3612/6294] [Modify] Move it --- websocket-sharp/Net/HttpConnection.cs | 2 -- websocket-sharp/Net/HttpListener.cs | 2 ++ 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpConnection.cs b/websocket-sharp/Net/HttpConnection.cs index 718a4432a..ef7abfe6f 100644 --- a/websocket-sharp/Net/HttpConnection.cs +++ b/websocket-sharp/Net/HttpConnection.cs @@ -456,8 +456,6 @@ private string readLineFrom ( private void registerContext (HttpListener listener) { - _context.Listener = listener; - if (!listener.RegisterContext (_context)) { _context.ErrorStatusCode = 503; _context.SendError (); diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 1739b0085..79290a221 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -646,6 +646,8 @@ internal bool RegisterContext (HttpListenerContext context) if (!_listening) return false; + context.Listener = this; + _contextRegistry.AddLast (context); if (_waitQueue.Count == 0) { From 685f777c7e91a85353773437db0f75a86059b51e Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 13 May 2021 19:36:15 +0900 Subject: [PATCH 3613/6294] [Modify] Remove it --- websocket-sharp/Net/HttpListenerContext.cs | 36 ---------------------- 1 file changed, 36 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerContext.cs b/websocket-sharp/Net/HttpListenerContext.cs index 7dae410f9..bb054de06 100644 --- a/websocket-sharp/Net/HttpListenerContext.cs +++ b/websocket-sharp/Net/HttpListenerContext.cs @@ -209,42 +209,6 @@ private void sendAuthenticationChallenge (string challenge) #region Internal Methods - internal bool Authenticate () - { - var schm = _listener.SelectAuthenticationScheme (_request); - - if (schm == AuthenticationSchemes.Anonymous) - return true; - - if (schm == AuthenticationSchemes.None) { - _errorStatusCode = 403; - _errorMessage = "Authentication not allowed"; - SendError (); - - return false; - } - - var realm = _listener.GetRealm (); - var user = HttpUtility.CreateUser ( - _request.Headers["Authorization"], - schm, - realm, - _request.HttpMethod, - _listener.GetUserCredentialsFinder () - ); - - if (user == null || !user.Identity.IsAuthenticated) { - var chal = new AuthenticationChallenge (schm, realm).ToString (); - sendAuthenticationChallenge (chal); - - return false; - } - - _user = user; - - return true; - } - internal HttpListenerWebSocketContext GetWebSocketContext (string protocol) { _websocketContext = new HttpListenerWebSocketContext (this, protocol); From a1ef1f90917cef528f0c84dd5c461b5e5c4a9256 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 13 May 2021 19:37:20 +0900 Subject: [PATCH 3614/6294] [Modify] Remove it --- websocket-sharp/Net/HttpListenerContext.cs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerContext.cs b/websocket-sharp/Net/HttpListenerContext.cs index bb054de06..12ed245b7 100644 --- a/websocket-sharp/Net/HttpListenerContext.cs +++ b/websocket-sharp/Net/HttpListenerContext.cs @@ -216,11 +216,6 @@ internal HttpListenerWebSocketContext GetWebSocketContext (string protocol) return _websocketContext; } - internal bool Register () - { - return _listener.RegisterContext (this); - } - internal void SendAuthenticationChallenge ( AuthenticationSchemes scheme, string realm ) From df30241fe3d81eb1e8b389a2782a08642355a665 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 13 May 2021 19:38:08 +0900 Subject: [PATCH 3615/6294] [Modify] Remove it --- websocket-sharp/Net/HttpListenerContext.cs | 8 -------- 1 file changed, 8 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerContext.cs b/websocket-sharp/Net/HttpListenerContext.cs index 12ed245b7..960409760 100644 --- a/websocket-sharp/Net/HttpListenerContext.cs +++ b/websocket-sharp/Net/HttpListenerContext.cs @@ -197,14 +197,6 @@ private static string createErrorContent ( ); } - private void sendAuthenticationChallenge (string challenge) - { - _response.StatusCode = 401; - _response.Headers.InternalSet ("WWW-Authenticate", challenge, true); - - _response.Close (); - } - #endregion #region Internal Methods From 967097ea9a1f4692b44ef18e0381c4302d8d8def Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 13 May 2021 19:44:02 +0900 Subject: [PATCH 3616/6294] [Modify] Add a null check --- websocket-sharp/Net/HttpListenerContext.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/websocket-sharp/Net/HttpListenerContext.cs b/websocket-sharp/Net/HttpListenerContext.cs index 960409760..6488a978f 100644 --- a/websocket-sharp/Net/HttpListenerContext.cs +++ b/websocket-sharp/Net/HttpListenerContext.cs @@ -246,6 +246,9 @@ internal void SendError () internal void Unregister () { + if (_listener == null) + return; + _listener.UnregisterContext (this); } From 36c34616009d7e2c988546400865dcb0bc910f04 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 14 May 2021 19:35:08 +0900 Subject: [PATCH 3617/6294] [Modify] Replace it --- websocket-sharp/Net/HttpConnection.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpConnection.cs b/websocket-sharp/Net/HttpConnection.cs index ef7abfe6f..6b9b743e8 100644 --- a/websocket-sharp/Net/HttpConnection.cs +++ b/websocket-sharp/Net/HttpConnection.cs @@ -322,7 +322,14 @@ private static void onRead (IAsyncResult asyncResult) if (!lsnr.AuthenticateContext (conn._context)) return; - conn.registerContext (lsnr); + if (!lsnr.RegisterContext (conn._context)) { + conn._context.ErrorStatusCode = 503; + conn._context.SendError (); + + return; + } + + conn._contextRegistered = true; return; } From eb140af0824003d9d7c97cd1620cc4dfa68b74ff Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 14 May 2021 19:37:02 +0900 Subject: [PATCH 3618/6294] [Modify] Remove it --- websocket-sharp/Net/HttpConnection.cs | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/websocket-sharp/Net/HttpConnection.cs b/websocket-sharp/Net/HttpConnection.cs index 6b9b743e8..45a4b9c43 100644 --- a/websocket-sharp/Net/HttpConnection.cs +++ b/websocket-sharp/Net/HttpConnection.cs @@ -461,18 +461,6 @@ private string readLineFrom ( return ret; } - private void registerContext (HttpListener listener) - { - if (!listener.RegisterContext (_context)) { - _context.ErrorStatusCode = 503; - _context.SendError (); - - return; - } - - _contextRegistered = true; - } - private void unregisterContext () { if (!_contextRegistered) From 3d91cfe3b2ccbccbd0cfb91066ce4253bc3941b1 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 14 May 2021 19:40:25 +0900 Subject: [PATCH 3619/6294] [Modify] Replace it --- websocket-sharp/Net/HttpConnection.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpConnection.cs b/websocket-sharp/Net/HttpConnection.cs index 45a4b9c43..d7563504d 100644 --- a/websocket-sharp/Net/HttpConnection.cs +++ b/websocket-sharp/Net/HttpConnection.cs @@ -199,7 +199,7 @@ private void close () closeSocket (); } - unregisterContext (); + _context.Unregister (); _listener.RemoveConnection (this); } From 68de6e03e2bb258d965c55cf4de817400d6d4a33 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 14 May 2021 19:41:49 +0900 Subject: [PATCH 3620/6294] [Modify] Replace it --- websocket-sharp/Net/HttpConnection.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpConnection.cs b/websocket-sharp/Net/HttpConnection.cs index d7563504d..3ff5b9b99 100644 --- a/websocket-sharp/Net/HttpConnection.cs +++ b/websocket-sharp/Net/HttpConnection.cs @@ -523,7 +523,7 @@ internal void Close (bool force) } disposeRequestBuffer (); - unregisterContext (); + _context.Unregister (); _reuses++; From dd1574e17dbd632aa5e29188d352997f291a57a4 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 14 May 2021 19:42:52 +0900 Subject: [PATCH 3621/6294] [Modify] Remove it --- websocket-sharp/Net/HttpConnection.cs | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/websocket-sharp/Net/HttpConnection.cs b/websocket-sharp/Net/HttpConnection.cs index 3ff5b9b99..75f5be9ad 100644 --- a/websocket-sharp/Net/HttpConnection.cs +++ b/websocket-sharp/Net/HttpConnection.cs @@ -461,16 +461,6 @@ private string readLineFrom ( return ret; } - private void unregisterContext () - { - if (!_contextRegistered) - return; - - _context.Unregister (); - - _contextRegistered = false; - } - #endregion #region Internal Methods From 63a09e5706a98702136202a073d2e95ba1313d73 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 14 May 2021 19:45:21 +0900 Subject: [PATCH 3622/6294] [Modify] Remove it --- websocket-sharp/Net/HttpConnection.cs | 3 --- 1 file changed, 3 deletions(-) diff --git a/websocket-sharp/Net/HttpConnection.cs b/websocket-sharp/Net/HttpConnection.cs index 75f5be9ad..d3626073c 100644 --- a/websocket-sharp/Net/HttpConnection.cs +++ b/websocket-sharp/Net/HttpConnection.cs @@ -63,7 +63,6 @@ internal sealed class HttpConnection private byte[] _buffer; private static readonly int _bufferLength; private HttpListenerContext _context; - private bool _contextRegistered; private StringBuilder _currentLine; private InputState _inputState; private RequestStream _inputStream; @@ -329,8 +328,6 @@ private static void onRead (IAsyncResult asyncResult) return; } - conn._contextRegistered = true; - return; } From 37f150f9be9184dff427b493cf57aaa7948baa49 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 15 May 2021 22:35:19 +0900 Subject: [PATCH 3623/6294] [Modify] Remove it --- websocket-sharp/Net/HttpListener.cs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 79290a221..5d5bac035 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -632,11 +632,6 @@ internal string GetRealm () return realm != null && realm.Length > 0 ? realm : _defaultRealm; } - internal Func GetUserCredentialsFinder () - { - return _userCredFinder; - } - internal bool RegisterContext (HttpListenerContext context) { if (!_listening) From f638659bc7f181191c504ee507eddb2aa788d833 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 15 May 2021 22:37:01 +0900 Subject: [PATCH 3624/6294] [Modify] Add it --- websocket-sharp/Net/HttpListener.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 5d5bac035..2758617dc 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -558,6 +558,13 @@ private void close (bool force) _disposed = true; } + private string getRealm () + { + var realm = _realm; + + return realm != null && realm.Length > 0 ? realm : _defaultRealm; + } + #endregion #region Internal Methods From 7147b86cce9edf63eb32b618f42224927e413296 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 15 May 2021 22:38:13 +0900 Subject: [PATCH 3625/6294] [Modify] Replace it --- websocket-sharp/Net/HttpListener.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 2758617dc..159301d77 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -586,7 +586,7 @@ internal bool AuthenticateContext (HttpListenerContext context) return false; } - var realm = GetRealm (); + var realm = getRealm (); var user = HttpUtility.CreateUser ( req.Headers["Authorization"], schm, From 7c86f7635aae062e8f441a46947713fd8bdfe51a Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 15 May 2021 22:39:09 +0900 Subject: [PATCH 3626/6294] [Modify] Remove it --- websocket-sharp/Net/HttpListener.cs | 7 ------- 1 file changed, 7 deletions(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 159301d77..a336f4dfb 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -632,13 +632,6 @@ internal void CheckDisposed () throw new ObjectDisposedException (_objectName); } - internal string GetRealm () - { - var realm = _realm; - - return realm != null && realm.Length > 0 ? realm : _defaultRealm; - } - internal bool RegisterContext (HttpListenerContext context) { if (!_listening) From db2659bd4be6eede5fc83dee81d5c24c3bb844f1 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 16 May 2021 15:36:47 +0900 Subject: [PATCH 3627/6294] [Modify] Add it --- websocket-sharp/Net/HttpListener.cs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index a336f4dfb..ad313939a 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -565,6 +565,23 @@ private string getRealm () return realm != null && realm.Length > 0 ? realm : _defaultRealm; } + private AuthenticationSchemes selectAuthenticationScheme ( + HttpListenerRequest request + ) + { + var selector = _authSchemeSelector; + + if (selector == null) + return _authSchemes; + + try { + return selector (request); + } + catch { + return AuthenticationSchemes.None; + } + } + #endregion #region Internal Methods From e67bea14a083f1e0a3e8ce6da38cd886ff660881 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 16 May 2021 15:37:50 +0900 Subject: [PATCH 3628/6294] [Modify] Replace it --- websocket-sharp/Net/HttpListener.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index ad313939a..1890cc643 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -589,7 +589,7 @@ HttpListenerRequest request internal bool AuthenticateContext (HttpListenerContext context) { var req = context.Request; - var schm = SelectAuthenticationScheme (req); + var schm = selectAuthenticationScheme (req); if (schm == AuthenticationSchemes.Anonymous) return true; From d021f1e20ad306aecefa2db281619ed83396ff24 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 16 May 2021 15:39:04 +0900 Subject: [PATCH 3629/6294] [Modify] Remove it --- websocket-sharp/Net/HttpListener.cs | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 1890cc643..197ca8a26 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -674,23 +674,6 @@ internal bool RegisterContext (HttpListenerContext context) } } - internal AuthenticationSchemes SelectAuthenticationScheme ( - HttpListenerRequest request - ) - { - var selector = _authSchemeSelector; - - if (selector == null) - return _authSchemes; - - try { - return selector (request); - } - catch { - return AuthenticationSchemes.None; - } - } - internal void UnregisterContext (HttpListenerContext context) { lock (_contextRegistrySync) From 381f207b9111a6f53d7e37d1d49538ee000102ea Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 17 May 2021 21:13:38 +0900 Subject: [PATCH 3630/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListener.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 197ca8a26..2b58b418b 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -612,7 +612,9 @@ internal bool AuthenticateContext (HttpListenerContext context) _userCredFinder ); - if (user == null || !user.Identity.IsAuthenticated) { + var authenticated = user != null && user.Identity.IsAuthenticated; + + if (!authenticated) { context.SendAuthenticationChallenge (schm, realm); return false; From 2e2c7d34c85390bbb78a9d8e3f3f080a970f0e9c Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 18 May 2021 19:42:57 +0900 Subject: [PATCH 3631/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListener.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 2b58b418b..e4f11cf8a 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -227,8 +227,8 @@ public Func AuthenticationSchemeSele /// /// /// If this property is or an empty string, - /// the result of System.Environment.GetFolderPath ( - /// ) + /// the result of System.Environment.GetFolderPath () /// is used as the default path. /// /// From e61d5bc67fcf34f50e680b6b4110227c87a3b943 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 19 May 2021 19:50:48 +0900 Subject: [PATCH 3632/6294] [Modify] Use it instead --- websocket-sharp/Net/HttpConnection.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/HttpConnection.cs b/websocket-sharp/Net/HttpConnection.cs index d3626073c..3af1b2b76 100644 --- a/websocket-sharp/Net/HttpConnection.cs +++ b/websocket-sharp/Net/HttpConnection.cs @@ -60,6 +60,7 @@ internal sealed class HttpConnection { #region Private Fields + private int _attempts; private byte[] _buffer; private static readonly int _bufferLength; private HttpListenerContext _context; @@ -268,7 +269,7 @@ private void init (int timeout) private static void onRead (IAsyncResult asyncResult) { var conn = (HttpConnection) asyncResult.AsyncState; - var current = conn._reuses; + var current = conn._attempts; if (conn._socket == null) return; @@ -351,7 +352,7 @@ private static void onRead (IAsyncResult asyncResult) private static void onTimeout (object state) { var conn = (HttpConnection) state; - var current = conn._reuses; + var current = conn._attempts; if (conn._socket == null) return; @@ -464,7 +465,9 @@ private string readLineFrom ( internal void BeginReadRequest () { - _timeoutCanceled.Add (_reuses, false); + _attempts++; + + _timeoutCanceled.Add (_attempts, false); _timer.Change (_timeout, Timeout.Infinite); try { From 1bcfe395e4ef5e89f4daace409de297c638cccef Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 20 May 2021 19:43:44 +0900 Subject: [PATCH 3633/6294] [Modify] Replace it --- websocket-sharp/Net/HttpConnection.cs | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/websocket-sharp/Net/HttpConnection.cs b/websocket-sharp/Net/HttpConnection.cs index 3af1b2b76..2bec7d484 100644 --- a/websocket-sharp/Net/HttpConnection.cs +++ b/websocket-sharp/Net/HttpConnection.cs @@ -338,14 +338,7 @@ private static void onRead (IAsyncResult asyncResult) return; } - try { - conn._stream.BeginRead (conn._buffer, 0, _bufferLength, onRead, conn); - } - catch (Exception) { - // TODO: Logging. - - conn.close (); - } + conn.BeginReadRequest (); } } From 0f871058a44a36c8395037544b605f8b9bffc837 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 21 May 2021 19:35:08 +0900 Subject: [PATCH 3634/6294] [Modify] Polish it --- websocket-sharp/Net/HttpConnection.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/HttpConnection.cs b/websocket-sharp/Net/HttpConnection.cs index 2bec7d484..46285c5cc 100644 --- a/websocket-sharp/Net/HttpConnection.cs +++ b/websocket-sharp/Net/HttpConnection.cs @@ -278,10 +278,8 @@ private static void onRead (IAsyncResult asyncResult) if (conn._socket == null) return; - if (!conn._timeoutCanceled[current]) { - conn._timer.Change (Timeout.Infinite, Timeout.Infinite); - conn._timeoutCanceled[current] = true; - } + conn._timer.Change (Timeout.Infinite, Timeout.Infinite); + conn._timeoutCanceled[current] = true; var nread = 0; From ec462b5ec27e1d70bd96764e2d9cf8f803ac1fbf Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 21 May 2021 19:38:46 +0900 Subject: [PATCH 3635/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerAsyncResult.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Net/HttpListenerAsyncResult.cs b/websocket-sharp/Net/HttpListenerAsyncResult.cs index a1c737421..3b759560a 100644 --- a/websocket-sharp/Net/HttpListenerAsyncResult.cs +++ b/websocket-sharp/Net/HttpListenerAsyncResult.cs @@ -72,6 +72,7 @@ internal HttpListenerAsyncResult (AsyncCallback callback, object state) { _callback = callback; _state = state; + _sync = new object (); } From c16b0a8b2ea630839ac0f139fa743e4adf418ddd Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 22 May 2021 21:38:49 +0900 Subject: [PATCH 3636/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerAsyncResult.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerAsyncResult.cs b/websocket-sharp/Net/HttpListenerAsyncResult.cs index 3b759560a..37d43615e 100644 --- a/websocket-sharp/Net/HttpListenerAsyncResult.cs +++ b/websocket-sharp/Net/HttpListenerAsyncResult.cs @@ -112,8 +112,12 @@ public object AsyncState { public WaitHandle AsyncWaitHandle { get { - lock (_sync) - return _waitHandle ?? (_waitHandle = new ManualResetEvent (_completed)); + lock (_sync) { + if (_waitHandle == null) + _waitHandle = new ManualResetEvent (_completed); + + return _waitHandle; + } } } From f1cb4cf1e6b91b424b6268f1b165e68efb4a7209 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 22 May 2021 21:41:32 +0900 Subject: [PATCH 3637/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerAsyncResult.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/websocket-sharp/Net/HttpListenerAsyncResult.cs b/websocket-sharp/Net/HttpListenerAsyncResult.cs index 37d43615e..9fe13a2f6 100644 --- a/websocket-sharp/Net/HttpListenerAsyncResult.cs +++ b/websocket-sharp/Net/HttpListenerAsyncResult.cs @@ -144,11 +144,13 @@ private static void complete (HttpListenerAsyncResult asyncResult) asyncResult._completed = true; var waitHandle = asyncResult._waitHandle; + if (waitHandle != null) waitHandle.Set (); } var callback = asyncResult._callback; + if (callback == null) return; From 05d24f72d2276a44acb5bf0156f0ad1cfe374a58 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 22 May 2021 21:45:08 +0900 Subject: [PATCH 3638/6294] [Modify] Replace it --- websocket-sharp/Net/HttpListenerAsyncResult.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerAsyncResult.cs b/websocket-sharp/Net/HttpListenerAsyncResult.cs index 9fe13a2f6..373f65cf6 100644 --- a/websocket-sharp/Net/HttpListenerAsyncResult.cs +++ b/websocket-sharp/Net/HttpListenerAsyncResult.cs @@ -181,7 +181,9 @@ internal void Complete (Exception exception) internal void Complete (HttpListenerContext context) { - Complete (context, false); + _context = context; + + complete (this); } internal void Complete (HttpListenerContext context, bool syncCompleted) From 40abc9b7f219478ac25b50799e24def922c40923 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 23 May 2021 22:16:52 +0900 Subject: [PATCH 3639/6294] [Modify] Add it --- websocket-sharp/Net/HttpListenerAsyncResult.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/websocket-sharp/Net/HttpListenerAsyncResult.cs b/websocket-sharp/Net/HttpListenerAsyncResult.cs index 373f65cf6..16d4f97c0 100644 --- a/websocket-sharp/Net/HttpListenerAsyncResult.cs +++ b/websocket-sharp/Net/HttpListenerAsyncResult.cs @@ -80,6 +80,16 @@ internal HttpListenerAsyncResult (AsyncCallback callback, object state) #region Internal Properties + internal HttpListenerContext Context + { + get { + if (_exception != null) + throw _exception; + + return _context; + } + } + internal bool EndCalled { get { return _endCalled; From df8b31fcaf17c5c950db05c2245c44b0c147ce02 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 23 May 2021 22:18:51 +0900 Subject: [PATCH 3640/6294] [Modify] Replace it --- websocket-sharp/Net/HttpListener.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index e4f11cf8a..6f0e0939f 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -831,7 +831,7 @@ public HttpListenerContext EndGetContext (IAsyncResult asyncResult) if (!ares.IsCompleted) ares.AsyncWaitHandle.WaitOne (); - return ares.GetContext (); // This may throw an exception. + return ares.Context; } /// From 3d45ae67793004f217d434923f33d45043729d85 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 23 May 2021 22:20:02 +0900 Subject: [PATCH 3641/6294] [Modify] Remove it --- websocket-sharp/Net/HttpListenerAsyncResult.cs | 8 -------- 1 file changed, 8 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerAsyncResult.cs b/websocket-sharp/Net/HttpListenerAsyncResult.cs index 16d4f97c0..006f0a2b3 100644 --- a/websocket-sharp/Net/HttpListenerAsyncResult.cs +++ b/websocket-sharp/Net/HttpListenerAsyncResult.cs @@ -204,14 +204,6 @@ internal void Complete (HttpListenerContext context, bool syncCompleted) complete (this); } - internal HttpListenerContext GetContext () - { - if (_exception != null) - throw _exception; - - return _context; - } - #endregion } } From da4a11c0d492beac71cf9f1b8e95eb628f9050f5 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 23 May 2021 22:23:58 +0900 Subject: [PATCH 3642/6294] [Modify] Replace it --- websocket-sharp/Net/HttpListener.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 6f0e0939f..1c472a40f 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -669,7 +669,7 @@ internal bool RegisterContext (HttpListenerContext context) } else { var ares = _waitQueue.Dequeue (); - ares.Complete (context); + ares.Complete (context, false); } return true; From d9519aacaa06cba148d9b9d0fbbbfca744616cc8 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 23 May 2021 22:24:44 +0900 Subject: [PATCH 3643/6294] [Modify] Remove it --- websocket-sharp/Net/HttpListenerAsyncResult.cs | 7 ------- 1 file changed, 7 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerAsyncResult.cs b/websocket-sharp/Net/HttpListenerAsyncResult.cs index 006f0a2b3..5a78d0701 100644 --- a/websocket-sharp/Net/HttpListenerAsyncResult.cs +++ b/websocket-sharp/Net/HttpListenerAsyncResult.cs @@ -189,13 +189,6 @@ internal void Complete (Exception exception) complete (this); } - internal void Complete (HttpListenerContext context) - { - _context = context; - - complete (this); - } - internal void Complete (HttpListenerContext context, bool syncCompleted) { _context = context; From bc070a309fd66a849558d00967709a81e01fae6a Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 24 May 2021 20:59:07 +0900 Subject: [PATCH 3644/6294] [Modify] Add it --- .../Net/HttpListenerAsyncResult.cs | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/websocket-sharp/Net/HttpListenerAsyncResult.cs b/websocket-sharp/Net/HttpListenerAsyncResult.cs index 5a78d0701..f440662c0 100644 --- a/websocket-sharp/Net/HttpListenerAsyncResult.cs +++ b/websocket-sharp/Net/HttpListenerAsyncResult.cs @@ -148,6 +148,30 @@ public bool IsCompleted { #region Private Methods + private void complete () + { + lock (_sync) { + _completed = true; + + if (_waitHandle != null) + _waitHandle.Set (); + } + + if (_callback == null) + return; + + ThreadPool.QueueUserWorkItem ( + state => { + try { + _callback (this); + } + catch { + } + }, + null + ); + } + private static void complete (HttpListenerAsyncResult asyncResult) { lock (asyncResult._sync) { From a8ca33983654e69676273f72be4f093e132b5769 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 24 May 2021 21:00:39 +0900 Subject: [PATCH 3645/6294] [Modify] Replace it --- websocket-sharp/Net/HttpListenerAsyncResult.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerAsyncResult.cs b/websocket-sharp/Net/HttpListenerAsyncResult.cs index f440662c0..0cd4150f5 100644 --- a/websocket-sharp/Net/HttpListenerAsyncResult.cs +++ b/websocket-sharp/Net/HttpListenerAsyncResult.cs @@ -210,7 +210,7 @@ internal void Complete (Exception exception) ? new HttpListenerException (995, "The listener is closed.") : exception; - complete (this); + complete (); } internal void Complete (HttpListenerContext context, bool syncCompleted) From ab5d5e7354cbd7de4ee7939330b69fd7ca11628b Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 24 May 2021 21:01:36 +0900 Subject: [PATCH 3646/6294] [Modify] Replace it --- websocket-sharp/Net/HttpListenerAsyncResult.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerAsyncResult.cs b/websocket-sharp/Net/HttpListenerAsyncResult.cs index 0cd4150f5..de359daf6 100644 --- a/websocket-sharp/Net/HttpListenerAsyncResult.cs +++ b/websocket-sharp/Net/HttpListenerAsyncResult.cs @@ -218,7 +218,7 @@ internal void Complete (HttpListenerContext context, bool syncCompleted) _context = context; _syncCompleted = syncCompleted; - complete (this); + complete (); } #endregion From 491005117103ce4cb0b0bc12134ea3518b527de5 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 24 May 2021 21:03:07 +0900 Subject: [PATCH 3647/6294] [Modify] Remove it --- .../Net/HttpListenerAsyncResult.cs | 28 ------------------- 1 file changed, 28 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerAsyncResult.cs b/websocket-sharp/Net/HttpListenerAsyncResult.cs index de359daf6..1994d0ba5 100644 --- a/websocket-sharp/Net/HttpListenerAsyncResult.cs +++ b/websocket-sharp/Net/HttpListenerAsyncResult.cs @@ -172,34 +172,6 @@ private void complete () ); } - private static void complete (HttpListenerAsyncResult asyncResult) - { - lock (asyncResult._sync) { - asyncResult._completed = true; - - var waitHandle = asyncResult._waitHandle; - - if (waitHandle != null) - waitHandle.Set (); - } - - var callback = asyncResult._callback; - - if (callback == null) - return; - - ThreadPool.QueueUserWorkItem ( - state => { - try { - callback (asyncResult); - } - catch { - } - }, - null - ); - } - #endregion #region Internal Methods From bcd67362ed34ac527cdd26336330b01f7a926234 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 25 May 2021 15:52:51 +0900 Subject: [PATCH 3648/6294] [Modify] Add it --- websocket-sharp/Net/HttpListener.cs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 1c472a40f..ffea782a8 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -487,6 +487,28 @@ public Func UserCredentialsFinder { #region Private Methods + private HttpListenerAsyncResult beginGetContext ( + AsyncCallback callback, object state + ) + { + lock (_contextRegistrySync) { + if (!_listening) + throw new HttpListenerException (995); + + var ares = new HttpListenerAsyncResult (callback, state); + + if (_contextQueue.Count == 0) { + _waitQueue.Enqueue (ares); + } + else { + var ctx = _contextQueue.Dequeue (); + ares.Complete (ctx, true); + } + + return ares; + } + } + private void cleanupContextQueue (bool force) { if (_contextQueue.Count == 0) From 80f99bd5c362212e607b98a93391fe8e104aff6d Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 25 May 2021 15:55:27 +0900 Subject: [PATCH 3649/6294] [Modify] Replace it --- websocket-sharp/Net/HttpListener.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index ffea782a8..802a4c862 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -780,7 +780,7 @@ public IAsyncResult BeginGetContext (AsyncCallback callback, Object state) throw new InvalidOperationException (msg); } - return BeginGetContext (new HttpListenerAsyncResult (callback, state)); + return beginGetContext (callback, state); } /// From 5f7986a0a1df02c059c8f8da55cdd0402fce25f2 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 25 May 2021 15:57:26 +0900 Subject: [PATCH 3650/6294] [Modify] Replace it --- websocket-sharp/Net/HttpListener.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 802a4c862..c82167e59 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -897,7 +897,7 @@ public HttpListenerContext GetContext () throw new InvalidOperationException (msg); } - var ares = BeginGetContext (new HttpListenerAsyncResult (null, null)); + var ares = beginGetContext (null, null); ares.InGet = true; return EndGetContext (ares); From 4373798c8cc0f307837afe01d6c87f35f8235631 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 25 May 2021 15:58:53 +0900 Subject: [PATCH 3651/6294] [Modify] Remove it --- websocket-sharp/Net/HttpListener.cs | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index c82167e59..cd0d575aa 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -647,26 +647,6 @@ internal bool AuthenticateContext (HttpListenerContext context) return true; } - internal HttpListenerAsyncResult BeginGetContext ( - HttpListenerAsyncResult asyncResult - ) - { - lock (_contextRegistrySync) { - if (!_listening) - throw new HttpListenerException (995); - - if (_contextQueue.Count == 0) { - _waitQueue.Enqueue (asyncResult); - } - else { - var ctx = _contextQueue.Dequeue (); - asyncResult.Complete (ctx, true); - } - - return asyncResult; - } - } - internal void CheckDisposed () { if (_disposed) From bed9d4e60ed2dfd517b7c4bb449540790b9df0be Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 26 May 2021 16:43:23 +0900 Subject: [PATCH 3652/6294] [Modify] Replace it --- websocket-sharp/Net/HttpListener.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index cd0d575aa..ac8c09492 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -879,8 +879,12 @@ public HttpListenerContext GetContext () var ares = beginGetContext (null, null); ares.InGet = true; + ares.EndCalled = true; - return EndGetContext (ares); + if (!ares.IsCompleted) + ares.AsyncWaitHandle.WaitOne (); + + return ares.Context; } /// From 41d89493a5c63e0aa1ba22c4bf7e0d49de2d6870 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 26 May 2021 16:46:56 +0900 Subject: [PATCH 3653/6294] [Modify] Add it --- websocket-sharp/Net/HttpListenerAsyncResult.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/websocket-sharp/Net/HttpListenerAsyncResult.cs b/websocket-sharp/Net/HttpListenerAsyncResult.cs index 1994d0ba5..2a994e9b5 100644 --- a/websocket-sharp/Net/HttpListenerAsyncResult.cs +++ b/websocket-sharp/Net/HttpListenerAsyncResult.cs @@ -110,6 +110,12 @@ internal bool InGet { } } + internal object SyncRoot { + get { + return _sync; + } + } + #endregion #region Public Properties From b4c82165c6ca87365cbbafd6de00f1ee887cab39 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 26 May 2021 16:53:48 +0900 Subject: [PATCH 3654/6294] [Modify] Lock it --- websocket-sharp/Net/HttpListener.cs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index ac8c09492..a59ae3369 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -822,13 +822,15 @@ public HttpListenerContext EndGetContext (IAsyncResult asyncResult) throw new ArgumentException (msg, "asyncResult"); } - if (ares.EndCalled) { - var msg = "This IAsyncResult instance cannot be reused."; + lock (ares.SyncRoot) { + if (ares.EndCalled) { + var msg = "This IAsyncResult instance cannot be reused."; - throw new InvalidOperationException (msg); - } + throw new InvalidOperationException (msg); + } - ares.EndCalled = true; + ares.EndCalled = true; + } if (!ares.IsCompleted) ares.AsyncWaitHandle.WaitOne (); From 07cd1f4108653ecc2e9526cffdf4a9d3628e86c9 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 27 May 2021 19:39:31 +0900 Subject: [PATCH 3655/6294] [Modify] Replace it --- websocket-sharp/Net/HttpListener.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index a59ae3369..2d88d9fe0 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -572,7 +572,8 @@ private void close (bool force) cleanupContextQueue (force); cleanupContextRegistry (); - var ex = new ObjectDisposedException (_objectName); + var msg = "The listener is closed."; + var ex = new HttpListenerException (995, msg); cleanupWaitQueue (ex); EndPointManager.RemoveListener (this); From 6852892f024be72ef9d04ce9cc7f46fbd201b63f Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 27 May 2021 19:42:57 +0900 Subject: [PATCH 3656/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerAsyncResult.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerAsyncResult.cs b/websocket-sharp/Net/HttpListenerAsyncResult.cs index 2a994e9b5..861fde6a7 100644 --- a/websocket-sharp/Net/HttpListenerAsyncResult.cs +++ b/websocket-sharp/Net/HttpListenerAsyncResult.cs @@ -184,9 +184,7 @@ private void complete () internal void Complete (Exception exception) { - _exception = _inGet && (exception is ObjectDisposedException) - ? new HttpListenerException (995, "The listener is closed.") - : exception; + _exception = exception; complete (); } From 588916e23214f7d8e3b30b0dccd76cf726dfa105 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 27 May 2021 19:44:22 +0900 Subject: [PATCH 3657/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListener.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 2d88d9fe0..baaf01fd3 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -881,7 +881,6 @@ public HttpListenerContext GetContext () } var ares = beginGetContext (null, null); - ares.InGet = true; ares.EndCalled = true; if (!ares.IsCompleted) From 64206f0f639737c1fddd9143d8f7b435a03aa5b5 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 27 May 2021 19:47:38 +0900 Subject: [PATCH 3658/6294] [Modify] Remove it --- websocket-sharp/Net/HttpListenerAsyncResult.cs | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerAsyncResult.cs b/websocket-sharp/Net/HttpListenerAsyncResult.cs index 861fde6a7..d7f6d2e24 100644 --- a/websocket-sharp/Net/HttpListenerAsyncResult.cs +++ b/websocket-sharp/Net/HttpListenerAsyncResult.cs @@ -58,7 +58,6 @@ internal class HttpListenerAsyncResult : IAsyncResult private HttpListenerContext _context; private bool _endCalled; private Exception _exception; - private bool _inGet; private object _state; private object _sync; private bool _syncCompleted; @@ -100,16 +99,6 @@ internal bool EndCalled { } } - internal bool InGet { - get { - return _inGet; - } - - set { - _inGet = value; - } - } - internal object SyncRoot { get { return _sync; From 8ca500bbe9052f85f63b9ba24ef4e6ca8a845d3b Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 28 May 2021 20:02:59 +0900 Subject: [PATCH 3659/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListener.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index baaf01fd3..e0f40edc2 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -741,6 +741,9 @@ public void Abort () /// This listener has not been started or is currently stopped. /// /// + /// + /// This method is canceled. + /// /// /// This listener has been closed. /// From 701b8efa25f9546df5f62e6bdb1375b17999bace Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 28 May 2021 20:03:48 +0900 Subject: [PATCH 3660/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListener.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index e0f40edc2..4e083ac5e 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -747,7 +747,7 @@ public void Abort () /// /// This listener has been closed. /// - public IAsyncResult BeginGetContext (AsyncCallback callback, Object state) + public IAsyncResult BeginGetContext (AsyncCallback callback, object state) { if (_disposed) throw new ObjectDisposedException (_objectName); From 21a48508db1daac30d72a4c4e84ecdfb00c0aaaa Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 28 May 2021 20:06:11 +0900 Subject: [PATCH 3661/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListener.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 4e083ac5e..9f0a306d5 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -807,6 +807,9 @@ public void Close () /// /// This method was already called for . /// + /// + /// This method is canceled. + /// /// /// This listener has been closed. /// From daa731618b95422b27fd8af86bf57cef2760478b Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 28 May 2021 20:08:22 +0900 Subject: [PATCH 3662/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListener.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 9f0a306d5..1359cf5c3 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -866,6 +866,9 @@ public HttpListenerContext EndGetContext (IAsyncResult asyncResult) /// This listener has not been started or is currently stopped. /// /// + /// + /// This method is canceled. + /// /// /// This listener has been closed. /// From bb8010577b7219453edec251a49409b7ba998f1a Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 29 May 2021 22:10:37 +0900 Subject: [PATCH 3663/6294] [Modify] Rename it --- websocket-sharp/Net/HttpListenerAsyncResult.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerAsyncResult.cs b/websocket-sharp/Net/HttpListenerAsyncResult.cs index d7f6d2e24..1b020b3d5 100644 --- a/websocket-sharp/Net/HttpListenerAsyncResult.cs +++ b/websocket-sharp/Net/HttpListenerAsyncResult.cs @@ -60,7 +60,7 @@ internal class HttpListenerAsyncResult : IAsyncResult private Exception _exception; private object _state; private object _sync; - private bool _syncCompleted; + private bool _completedSynchronously; private ManualResetEvent _waitHandle; #endregion @@ -128,7 +128,7 @@ public WaitHandle AsyncWaitHandle { public bool CompletedSynchronously { get { - return _syncCompleted; + return _completedSynchronously; } } @@ -178,10 +178,10 @@ internal void Complete (Exception exception) complete (); } - internal void Complete (HttpListenerContext context, bool syncCompleted) + internal void Complete (HttpListenerContext context, bool completedSynchronously) { _context = context; - _syncCompleted = syncCompleted; + _completedSynchronously = completedSynchronously; complete (); } From ad7d512dce88f154d67469e441d7c8d088735e1d Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 29 May 2021 22:11:57 +0900 Subject: [PATCH 3664/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerAsyncResult.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerAsyncResult.cs b/websocket-sharp/Net/HttpListenerAsyncResult.cs index 1b020b3d5..33552d6b2 100644 --- a/websocket-sharp/Net/HttpListenerAsyncResult.cs +++ b/websocket-sharp/Net/HttpListenerAsyncResult.cs @@ -178,7 +178,9 @@ internal void Complete (Exception exception) complete (); } - internal void Complete (HttpListenerContext context, bool completedSynchronously) + internal void Complete ( + HttpListenerContext context, bool completedSynchronously + ) { _context = context; _completedSynchronously = completedSynchronously; From 9f87fc2c5ef446db9a4eabaf15ff03dbd92d5c13 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 29 May 2021 22:13:07 +0900 Subject: [PATCH 3665/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerAsyncResult.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerAsyncResult.cs b/websocket-sharp/Net/HttpListenerAsyncResult.cs index 33552d6b2..e1621b60b 100644 --- a/websocket-sharp/Net/HttpListenerAsyncResult.cs +++ b/websocket-sharp/Net/HttpListenerAsyncResult.cs @@ -55,12 +55,12 @@ internal class HttpListenerAsyncResult : IAsyncResult private AsyncCallback _callback; private bool _completed; + private bool _completedSynchronously; private HttpListenerContext _context; private bool _endCalled; private Exception _exception; private object _state; private object _sync; - private bool _completedSynchronously; private ManualResetEvent _waitHandle; #endregion From 0566aead241b13a4234c722959de8222031d84ab Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 29 May 2021 22:17:58 +0900 Subject: [PATCH 3666/6294] [Modify] 2021 --- websocket-sharp/Net/HttpListenerAsyncResult.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerAsyncResult.cs b/websocket-sharp/Net/HttpListenerAsyncResult.cs index e1621b60b..abd9e1aea 100644 --- a/websocket-sharp/Net/HttpListenerAsyncResult.cs +++ b/websocket-sharp/Net/HttpListenerAsyncResult.cs @@ -8,7 +8,7 @@ * The MIT License * * Copyright (c) 2005 Ximian, Inc. (http://www.ximian.com) - * Copyright (c) 2012-2016 sta.blockhead + * Copyright (c) 2012-2021 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From fa0880b1d0932eacd4fed581d46bc19daca1e325 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 30 May 2021 21:25:12 +0900 Subject: [PATCH 3667/6294] [Modify] Add it --- websocket-sharp/Net/HttpListener.cs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 1359cf5c3..942020626 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -559,6 +559,22 @@ private void cleanupWaitQueue (Exception exception) ares.Complete (exception); } + private void cleanupWaitQueue (string message) + { + if (_waitQueue.Count == 0) + return; + + var aress = _waitQueue.ToArray (); + + _waitQueue.Clear (); + + foreach (var ares in aress) { + var ex = new HttpListenerException (995, message); + + ares.Complete (ex); + } + } + private void close (bool force) { if (!_listening) { From 097565ce3b12465539b41d2133b581c5ed59ce9f Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 30 May 2021 21:26:47 +0900 Subject: [PATCH 3668/6294] [Modify] Replace it --- websocket-sharp/Net/HttpListener.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 942020626..f50d17ee1 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -589,8 +589,7 @@ private void close (bool force) cleanupContextRegistry (); var msg = "The listener is closed."; - var ex = new HttpListenerException (995, msg); - cleanupWaitQueue (ex); + cleanupWaitQueue (msg); EndPointManager.RemoveListener (this); From 7ae38b54946cae37c2711515885334dd2252fce1 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 30 May 2021 21:28:01 +0900 Subject: [PATCH 3669/6294] [Modify] Replace it --- websocket-sharp/Net/HttpListener.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index f50d17ee1..629d419b9 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -958,8 +958,7 @@ public void Stop () cleanupContextRegistry (); var msg = "The listener is stopped."; - var ex = new HttpListenerException (995, msg); - cleanupWaitQueue (ex); + cleanupWaitQueue (msg); EndPointManager.RemoveListener (this); } From f05c916ac35c31d15ae0bb8550f682133dbe1fab Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 30 May 2021 21:29:37 +0900 Subject: [PATCH 3670/6294] [Modify] Remove it --- websocket-sharp/Net/HttpListener.cs | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 629d419b9..f3eac64a0 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -546,19 +546,6 @@ private void cleanupContextRegistry () ctx.Connection.Close (true); } - private void cleanupWaitQueue (Exception exception) - { - if (_waitQueue.Count == 0) - return; - - var aress = _waitQueue.ToArray (); - - _waitQueue.Clear (); - - foreach (var ares in aress) - ares.Complete (exception); - } - private void cleanupWaitQueue (string message) { if (_waitQueue.Count == 0) From 7d038db8a8c9c3ec662f057ce26c4908e4bd0cb6 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 31 May 2021 20:47:10 +0900 Subject: [PATCH 3671/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListener.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index f3eac64a0..7dfce4cbe 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -492,8 +492,13 @@ private HttpListenerAsyncResult beginGetContext ( ) { lock (_contextRegistrySync) { - if (!_listening) - throw new HttpListenerException (995); + if (!_listening) { + var msg = _disposed + ? "The listener is closed." + : "The listener is stopped."; + + throw new HttpListenerException (995, msg); + } var ares = new HttpListenerAsyncResult (callback, state); From 7f667e2016b754c2ca44639eb400afdf70719444 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 31 May 2021 20:48:14 +0900 Subject: [PATCH 3672/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListener.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 7dfce4cbe..183033911 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -562,7 +562,6 @@ private void cleanupWaitQueue (string message) foreach (var ares in aress) { var ex = new HttpListenerException (995, message); - ares.Complete (ex); } } From 559ee7a1afdcf012cbef6f7a371774be3736c5ce Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 1 Jun 2021 19:17:48 +0900 Subject: [PATCH 3673/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerException.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerException.cs b/websocket-sharp/Net/HttpListenerException.cs index a52eeec03..674595d5a 100644 --- a/websocket-sharp/Net/HttpListenerException.cs +++ b/websocket-sharp/Net/HttpListenerException.cs @@ -63,7 +63,8 @@ public class HttpListenerException : Win32Exception /// A that specifies the source for the deserialization. /// protected HttpListenerException ( - SerializationInfo serializationInfo, StreamingContext streamingContext) + SerializationInfo serializationInfo, StreamingContext streamingContext + ) : base (serializationInfo, streamingContext) { } From 75cb4240573e605e2d138aac2449dd9e7edcea9e Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 2 Jun 2021 19:36:15 +0900 Subject: [PATCH 3674/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerException.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerException.cs b/websocket-sharp/Net/HttpListenerException.cs index 674595d5a..e0942fa8f 100644 --- a/websocket-sharp/Net/HttpListenerException.cs +++ b/websocket-sharp/Net/HttpListenerException.cs @@ -44,8 +44,8 @@ namespace WebSocketSharp.Net { /// - /// The exception that is thrown when a gets an error - /// processing an HTTP request. + /// The exception that is thrown when a instance + /// gets an error processing an HTTP request. /// [Serializable] public class HttpListenerException : Win32Exception From 1f860d80ee983cab3ae4ce785b880f704abdb9ff Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 2 Jun 2021 19:37:22 +0900 Subject: [PATCH 3675/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerException.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerException.cs b/websocket-sharp/Net/HttpListenerException.cs index e0942fa8f..3bc0fb24d 100644 --- a/websocket-sharp/Net/HttpListenerException.cs +++ b/websocket-sharp/Net/HttpListenerException.cs @@ -74,7 +74,8 @@ protected HttpListenerException ( #region Public Constructors /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the + /// class. /// public HttpListenerException () { From 6e516ffc33ecf6557fba5baab501e70a32f4de02 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 2 Jun 2021 19:40:40 +0900 Subject: [PATCH 3676/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerException.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerException.cs b/websocket-sharp/Net/HttpListenerException.cs index 3bc0fb24d..1ebaf458b 100644 --- a/websocket-sharp/Net/HttpListenerException.cs +++ b/websocket-sharp/Net/HttpListenerException.cs @@ -82,11 +82,11 @@ public HttpListenerException () } /// - /// Initializes a new instance of the class - /// with the specified . + /// Initializes a new instance of the + /// class with the specified error code. /// /// - /// An that identifies the error. + /// An that specifies the error code. /// public HttpListenerException (int errorCode) : base (errorCode) From 333085138dce934af860e798bbe03954f865082d Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 3 Jun 2021 19:38:56 +0900 Subject: [PATCH 3677/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerException.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerException.cs b/websocket-sharp/Net/HttpListenerException.cs index 1ebaf458b..a844392fc 100644 --- a/websocket-sharp/Net/HttpListenerException.cs +++ b/websocket-sharp/Net/HttpListenerException.cs @@ -94,14 +94,14 @@ public HttpListenerException (int errorCode) } /// - /// Initializes a new instance of the class - /// with the specified and . + /// Initializes a new instance of the + /// class with the specified error code and message. /// /// - /// An that identifies the error. + /// An that specifies the error code. /// /// - /// A that describes the error. + /// A that specifies the message. /// public HttpListenerException (int errorCode, string message) : base (errorCode, message) From 3c5807366501e93200ae836f6ac9c58ed518451d Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 3 Jun 2021 19:41:33 +0900 Subject: [PATCH 3678/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerException.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerException.cs b/websocket-sharp/Net/HttpListenerException.cs index a844392fc..42356e078 100644 --- a/websocket-sharp/Net/HttpListenerException.cs +++ b/websocket-sharp/Net/HttpListenerException.cs @@ -116,7 +116,7 @@ public HttpListenerException (int errorCode, string message) /// Gets the error code that identifies the error that occurred. /// /// - /// An that identifies the error. + /// An that represents the error code. /// public override int ErrorCode { get { From d3a0fe617ffd0de5983afa93c5fb1f88c61fb3ac Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 4 Jun 2021 19:35:46 +0900 Subject: [PATCH 3679/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerException.cs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerException.cs b/websocket-sharp/Net/HttpListenerException.cs index 42356e078..7168717a3 100644 --- a/websocket-sharp/Net/HttpListenerException.cs +++ b/websocket-sharp/Net/HttpListenerException.cs @@ -53,14 +53,17 @@ public class HttpListenerException : Win32Exception #region Protected Constructors /// - /// Initializes a new instance of the class from - /// the specified and . + /// Initializes a new instance of the + /// class from the specified instances of the + /// and classes. /// /// - /// A that contains the serialized object data. + /// A that contains the serialized + /// object data. /// /// - /// A that specifies the source for the deserialization. + /// A that specifies the source for + /// the deserialization. /// protected HttpListenerException ( SerializationInfo serializationInfo, StreamingContext streamingContext From cb45d929e7163f276f7ade7cdc83a9e458d4b807 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 4 Jun 2021 19:38:51 +0900 Subject: [PATCH 3680/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerException.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerException.cs b/websocket-sharp/Net/HttpListenerException.cs index 7168717a3..58484de9a 100644 --- a/websocket-sharp/Net/HttpListenerException.cs +++ b/websocket-sharp/Net/HttpListenerException.cs @@ -44,8 +44,8 @@ namespace WebSocketSharp.Net { /// - /// The exception that is thrown when a instance - /// gets an error processing an HTTP request. + /// The exception that is thrown when an error occurres processing + /// an HTTP request. /// [Serializable] public class HttpListenerException : Win32Exception From 402af72bcd872e40aad7c3dd8b469f3ecfdeea3e Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 5 Jun 2021 21:57:41 +0900 Subject: [PATCH 3681/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerException.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerException.cs b/websocket-sharp/Net/HttpListenerException.cs index 58484de9a..fe3f78621 100644 --- a/websocket-sharp/Net/HttpListenerException.cs +++ b/websocket-sharp/Net/HttpListenerException.cs @@ -44,7 +44,7 @@ namespace WebSocketSharp.Net { /// - /// The exception that is thrown when an error occurres processing + /// The exception that is thrown when an error occurs processing /// an HTTP request. /// [Serializable] From a4f5f4816aa1ce70aca1a3eabacd96592c898bb4 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 5 Jun 2021 22:00:04 +0900 Subject: [PATCH 3682/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerException.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerException.cs b/websocket-sharp/Net/HttpListenerException.cs index fe3f78621..6722e87ea 100644 --- a/websocket-sharp/Net/HttpListenerException.cs +++ b/websocket-sharp/Net/HttpListenerException.cs @@ -2,7 +2,7 @@ /* * HttpListenerException.cs * - * This code is derived from System.Net.HttpListenerException.cs of Mono + * This code is derived from HttpListenerException.cs (System.Net) of Mono * (http://www.mono-project.com). * * The MIT License From 259ea1f5ce0d3d90a59d7f763af85660c10620dc Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 6 Jun 2021 22:15:22 +0900 Subject: [PATCH 3683/6294] [Modify] 2021 --- websocket-sharp/Net/HttpListenerException.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerException.cs b/websocket-sharp/Net/HttpListenerException.cs index 6722e87ea..fc8188f3d 100644 --- a/websocket-sharp/Net/HttpListenerException.cs +++ b/websocket-sharp/Net/HttpListenerException.cs @@ -8,7 +8,7 @@ * The MIT License * * Copyright (c) 2005 Novell, Inc. (http://www.novell.com) - * Copyright (c) 2012-2014 sta.blockhead + * Copyright (c) 2012-2021 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From 15e2d7bbf79efa259601559fae028ba3a5a99f20 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 7 Jun 2021 21:22:45 +0900 Subject: [PATCH 3684/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerException.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerException.cs b/websocket-sharp/Net/HttpListenerException.cs index fc8188f3d..4102c21b8 100644 --- a/websocket-sharp/Net/HttpListenerException.cs +++ b/websocket-sharp/Net/HttpListenerException.cs @@ -119,7 +119,12 @@ public HttpListenerException (int errorCode, string message) /// Gets the error code that identifies the error that occurred. /// /// - /// An that represents the error code. + /// + /// An that represents the error code. + /// + /// + /// It is any of Win32 error codes. + /// /// public override int ErrorCode { get { From f68ae216f5d21c34d5faea0b86e960a790c66ed5 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 8 Jun 2021 19:37:37 +0900 Subject: [PATCH 3685/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerException.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerException.cs b/websocket-sharp/Net/HttpListenerException.cs index 4102c21b8..64b7c1d82 100644 --- a/websocket-sharp/Net/HttpListenerException.cs +++ b/websocket-sharp/Net/HttpListenerException.cs @@ -123,7 +123,7 @@ public HttpListenerException (int errorCode, string message) /// An that represents the error code. /// /// - /// It is any of Win32 error codes. + /// It is any of the Win32 error codes. /// /// public override int ErrorCode { From 1a57bbeb8397a2321fdd97dd148d6639b864c839 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 8 Jun 2021 19:39:33 +0900 Subject: [PATCH 3686/6294] [Modify] 2021 --- websocket-sharp/Net/HttpConnection.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpConnection.cs b/websocket-sharp/Net/HttpConnection.cs index 46285c5cc..1ae17f381 100644 --- a/websocket-sharp/Net/HttpConnection.cs +++ b/websocket-sharp/Net/HttpConnection.cs @@ -8,7 +8,7 @@ * The MIT License * * Copyright (c) 2005 Novell, Inc. (http://www.novell.com) - * Copyright (c) 2012-2020 sta.blockhead + * Copyright (c) 2012-2021 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From 9b0b5241ea1439c7916fe08219b432fc76daf9cd Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 9 Jun 2021 19:17:40 +0900 Subject: [PATCH 3687/6294] [Modify] Remove it --- websocket-sharp/Net/HttpListener.cs | 7 ------- 1 file changed, 7 deletions(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 183033911..a7d5e1b47 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -412,13 +412,6 @@ public ServerSslConfiguration SslConfiguration { return _sslConfig; } - - set { - if (_disposed) - throw new ObjectDisposedException (_objectName); - - _sslConfig = value; - } } /// From d2803a65757beba3c90052af2e4f5af3ca9de615 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 10 Jun 2021 20:25:26 +0900 Subject: [PATCH 3688/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListener.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index a7d5e1b47..14c785aea 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -392,8 +392,8 @@ public string Realm { } /// - /// Gets or sets the SSL configuration used to authenticate the server - /// and optionally the client for secure connection. + /// Gets the SSL configuration used to authenticate the server and + /// optionally the client for secure connection. /// /// /// A that represents the SSL From 17dfa4d2b519f9ccf83d61458c307a9dfb195e05 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 11 Jun 2021 19:54:57 +0900 Subject: [PATCH 3689/6294] [Modify] 2021 --- websocket-sharp/Net/HttpListener.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 14c785aea..a1a6a6ab3 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -8,7 +8,7 @@ * The MIT License * * Copyright (c) 2005 Novell, Inc. (http://www.novell.com) - * Copyright (c) 2012-2016 sta.blockhead + * Copyright (c) 2012-2021 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From f928f680148aaa73bad8bce764315de664d4ba72 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 12 Jun 2021 20:37:32 +0900 Subject: [PATCH 3690/6294] [Modify] Polish it --- websocket-sharp/Server/HttpServer.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index a243a6f3f..6cf2fe04e 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -334,14 +334,17 @@ public AuthenticationSchemes AuthenticationSchemes { set { string msg; + if (!canSet (out msg)) { _log.Warn (msg); + return; } lock (_sync) { if (!canSet (out msg)) { _log.Warn (msg); + return; } From 078ca38763a03d713b803f768d5e24c996d2f64f Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 13 Jun 2021 21:45:49 +0900 Subject: [PATCH 3691/6294] [Modify] Polish it --- websocket-sharp/Server/HttpServer.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 6cf2fe04e..5d4002ae3 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -557,14 +557,17 @@ public string Realm { set { string msg; + if (!canSet (out msg)) { _log.Warn (msg); + return; } lock (_sync) { if (!canSet (out msg)) { _log.Warn (msg); + return; } From 406087acea434421a80b8de2414c33ec2461fd11 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 14 Jun 2021 20:40:58 +0900 Subject: [PATCH 3692/6294] [Modify] Polish it --- websocket-sharp/Server/HttpServer.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 5d4002ae3..7a65f4ec3 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -819,11 +819,13 @@ private bool canSet (out string message) if (_state == ServerState.Start) { message = "The server has already started."; + return false; } if (_state == ServerState.ShuttingDown) { message = "The server is shutting down."; + return false; } From cf8cb2e17459c8f5b0b37a1267de645cca113b5a Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 15 Jun 2021 19:37:47 +0900 Subject: [PATCH 3693/6294] [Modify] Polish it --- websocket-sharp/Server/HttpServer.cs | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 7a65f4ec3..ce1df004d 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -333,15 +333,9 @@ public AuthenticationSchemes AuthenticationSchemes { } set { - string msg; - - if (!canSet (out msg)) { - _log.Warn (msg); - - return; - } - lock (_sync) { + string msg; + if (!canSet (out msg)) { _log.Warn (msg); From 9856d26233464800b3023aa6eade38c459cbaa9d Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 15 Jun 2021 19:42:54 +0900 Subject: [PATCH 3694/6294] [Modify] Polish it --- websocket-sharp/Server/HttpServer.cs | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index ce1df004d..604bd1825 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -550,15 +550,9 @@ public string Realm { } set { - string msg; - - if (!canSet (out msg)) { - _log.Warn (msg); - - return; - } - lock (_sync) { + string msg; + if (!canSet (out msg)) { _log.Warn (msg); From 63de0b5f3d08a99c578e1f2312df3d771341f18c Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 16 Jun 2021 19:54:12 +0900 Subject: [PATCH 3695/6294] [Modify] Edit it --- websocket-sharp/Server/HttpServer.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 604bd1825..f979d40a5 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -538,10 +538,11 @@ public int Port { /// /// /// - /// A or by default. + /// A that represents the name of + /// the realm or . /// /// - /// That string represents the name of the realm. + /// The default value is . /// /// public string Realm { From 94a41065efceb5819a3e4cbc032c27382d519be9 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 16 Jun 2021 19:57:33 +0900 Subject: [PATCH 3696/6294] [Modify] Polish it --- websocket-sharp/Server/HttpServer.cs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index f979d40a5..cb1f64873 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -594,15 +594,12 @@ public bool ReuseAddress { } set { - string msg; - if (!canSet (out msg)) { - _log.Warn (msg); - return; - } - lock (_sync) { + string msg; + if (!canSet (out msg)) { _log.Warn (msg); + return; } From c90ee44e8bed3e497911860e795979d074dd4eab Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 17 Jun 2021 19:11:16 +0900 Subject: [PATCH 3697/6294] [Modify] Polish it --- websocket-sharp/Server/HttpServer.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index cb1f64873..10c7911d2 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -626,6 +626,7 @@ public ServerSslConfiguration SslConfiguration { get { if (!_secure) { var msg = "This instance does not provide secure connections."; + throw new InvalidOperationException (msg); } From ca85c785a3d202900c1ea70dc0dc762fc2feb2ae Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 18 Jun 2021 19:49:43 +0900 Subject: [PATCH 3698/6294] [Modify] Polish it --- websocket-sharp/Server/HttpServer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 10c7911d2..33dc86a8d 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -625,7 +625,7 @@ public bool ReuseAddress { public ServerSslConfiguration SslConfiguration { get { if (!_secure) { - var msg = "This instance does not provide secure connections."; + var msg = "The server does not provide secure connections."; throw new InvalidOperationException (msg); } From c3061b7d7f5b97fd1e6a199735955ee8fe46351d Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 18 Jun 2021 19:53:18 +0900 Subject: [PATCH 3699/6294] [Modify] Edit it --- websocket-sharp/Server/HttpServer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 33dc86a8d..833c3e7fb 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -620,7 +620,7 @@ public bool ReuseAddress { /// the configuration used to provide secure connections. /// /// - /// This instance does not provide secure connections. + /// This server does not provide secure connections. /// public ServerSslConfiguration SslConfiguration { get { From e803fa303ba041ba1d78d70e23920eadbd28b43b Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 18 Jun 2021 19:56:37 +0900 Subject: [PATCH 3700/6294] [Modify] Edit it --- websocket-sharp/Server/HttpServer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 833c3e7fb..1eb6111de 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -612,7 +612,7 @@ public bool ReuseAddress { /// Gets the configuration for secure connection. /// /// - /// This configuration will be referenced when attempts to start, + /// The configuration will be referenced when attempts to start, /// so it must be configured before the start method is called. /// /// From 8898e1b3e0891a08144850ce94df41bc51d9e227 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 19 Jun 2021 20:28:37 +0900 Subject: [PATCH 3701/6294] [Modify] Polish it --- websocket-sharp/Server/HttpServer.cs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 1eb6111de..5a11c100a 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -669,15 +669,12 @@ public Func UserCredentialsFinder { } set { - string msg; - if (!canSet (out msg)) { - _log.Warn (msg); - return; - } - lock (_sync) { + string msg; + if (!canSet (out msg)) { _log.Warn (msg); + return; } From 166841e7686f0540edf8a12337c163f5bda7fc9e Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 20 Jun 2021 21:21:01 +0900 Subject: [PATCH 3702/6294] [Modify] Edit it --- websocket-sharp/Server/HttpServer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 5a11c100a..429f22303 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -656,7 +656,7 @@ public ServerSslConfiguration SslConfiguration { /// if not needed. /// /// - /// That delegate invokes the method called for finding + /// The delegate invokes the method called for finding /// the credentials used to authenticate a client. /// /// From ebdc6092a488cd899c04d97570ed8ae44ed8a5c4 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 21 Jun 2021 21:08:11 +0900 Subject: [PATCH 3703/6294] [Modify] Edit it --- websocket-sharp/Server/HttpServer.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 429f22303..e32cab481 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -684,8 +684,8 @@ public Func UserCredentialsFinder { } /// - /// Gets or sets the time to wait for the response to the WebSocket Ping or - /// Close. + /// Gets or sets the time to wait for the response to the WebSocket + /// Ping or Close. /// /// /// The set operation does nothing if the server has already started or From 8488518b4a8171f12733a6dc626ff49b16adb75e Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 22 Jun 2021 19:33:35 +0900 Subject: [PATCH 3704/6294] [Modify] Polish it --- websocket-sharp/Server/HttpServer.cs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index e32cab481..2bbf9b0a6 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -426,15 +426,12 @@ public string DocumentRootPath { if (full.Length == 2 && full[1] == ':') throw new ArgumentException ("An absolute root.", "value"); - string msg; - if (!canSet (out msg)) { - _log.Warn (msg); - return; - } - lock (_sync) { + string msg; + if (!canSet (out msg)) { _log.Warn (msg); + return; } From 12abf615833e2cabaee7ab729981b7c6cad58e26 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 23 Jun 2021 19:46:56 +0900 Subject: [PATCH 3705/6294] [Modify] Polish it --- websocket-sharp/Server/HttpServer.cs | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 2bbf9b0a6..f4dacdb56 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -402,14 +402,6 @@ public string DocumentRootPath { value = value.TrimSlashOrBackslashFromEnd (); - string full = null; - try { - full = Path.GetFullPath (value); - } - catch (Exception ex) { - throw new ArgumentException ("An invalid path string.", "value", ex); - } - if (value == "/") throw new ArgumentException ("An absolute root.", "value"); @@ -419,10 +411,20 @@ public string DocumentRootPath { if (value.Length == 2 && value[1] == ':') throw new ArgumentException ("An absolute root.", "value"); + string full = null; + + try { + full = Path.GetFullPath (value); + } + catch (Exception ex) { + throw new ArgumentException ("An invalid path string.", "value", ex); + } + if (full == "/") throw new ArgumentException ("An absolute root.", "value"); full = full.TrimSlashOrBackslashFromEnd (); + if (full.Length == 2 && full[1] == ':') throw new ArgumentException ("An absolute root.", "value"); From 4b757bb20558bbd6317ab53cdfbea0b317e2b1e7 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 24 Jun 2021 20:05:13 +0900 Subject: [PATCH 3706/6294] [Modify] Edit it --- websocket-sharp/Server/HttpServer.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index f4dacdb56..2c9ba30cf 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -379,13 +379,13 @@ public AuthenticationSchemes AuthenticationSchemes { /// -or- /// /// - /// The value specified for a set operation is an invalid path string. + /// The value specified for a set operation is an absolute root. /// /// /// -or- /// /// - /// The value specified for a set operation is an absolute root. + /// The value specified for a set operation is an invalid path string. /// /// public string DocumentRootPath { From 7c907396d5b3a410f57bb24515c28578232cd71d Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 24 Jun 2021 20:11:00 +0900 Subject: [PATCH 3707/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 72d941794..78d2e7324 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1082,6 +1082,7 @@ internal static string TrimSlashFromEnd (this string value) internal static string TrimSlashOrBackslashFromEnd (this string value) { var ret = value.TrimEnd ('/', '\\'); + return ret.Length > 0 ? ret : value[0].ToString (); } From 94046e1c12bbc9aa9a2e60f3605ba8c85f50fd00 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 25 Jun 2021 19:35:56 +0900 Subject: [PATCH 3708/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 78d2e7324..63205553f 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1076,6 +1076,7 @@ this IEnumerable source internal static string TrimSlashFromEnd (this string value) { var ret = value.TrimEnd ('/'); + return ret.Length > 0 ? ret : "/"; } From 2e59e80b09398aa4fd9a65e4f76844ee008ed06a Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 25 Jun 2021 19:38:55 +0900 Subject: [PATCH 3709/6294] [Modify] Polish it --- websocket-sharp/Server/HttpServer.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 2c9ba30cf..3bace8d5e 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -1476,6 +1476,7 @@ public void Start () { if (_secure) { string msg; + if (!checkCertificate (out msg)) throw new InvalidOperationException (msg); } From 238ecd12503f0203e69f7816a057f84a2058ab63 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 26 Jun 2021 21:53:42 +0900 Subject: [PATCH 3710/6294] [Modify] Polish it --- websocket-sharp/Server/HttpServer.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 3bace8d5e..c3e7eec86 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -824,12 +824,17 @@ private bool checkCertificate (out string message) var path = _listener.CertificateFolderPath; var withPort = EndPointListener.CertificateExists (_port, path); - if (!(byUser || withPort)) { + var exists = byUser || withPort; + + if (!exists) { message = "There is no server certificate for secure connection."; + return false; } - if (byUser && withPort) + var both = byUser && withPort; + + if (both) _log.Warn ("The server certificate associated with the port is used."); return true; From bb1684255f28aede305180bf32168cb35152b752 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 27 Jun 2021 22:25:52 +0900 Subject: [PATCH 3711/6294] [Modify] Polish it --- websocket-sharp/Server/HttpServer.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index c3e7eec86..a6ed9c260 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -834,8 +834,11 @@ private bool checkCertificate (out string message) var both = byUser && withPort; - if (both) - _log.Warn ("The server certificate associated with the port is used."); + if (both) { + var msg = "The server certificate associated with the port is used."; + + _log.Warn (msg); + } return true; } From 9755a44fc5a547d0c9281d46b8f61f9f53cd43e7 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 28 Jun 2021 21:04:07 +0900 Subject: [PATCH 3712/6294] [Modify] Polish it --- websocket-sharp/Server/HttpServer.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index a6ed9c260..34b3bd66d 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -824,9 +824,9 @@ private bool checkCertificate (out string message) var path = _listener.CertificateFolderPath; var withPort = EndPointListener.CertificateExists (_port, path); - var exists = byUser || withPort; + var either = byUser || withPort; - if (!exists) { + if (!either) { message = "There is no server certificate for secure connection."; return false; From c095eb38c45f03a014abc0d983216f82bb61ee53 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 29 Jun 2021 19:36:52 +0900 Subject: [PATCH 3713/6294] [Modify] Polish it --- websocket-sharp/Server/HttpServer.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 34b3bd66d..9d3a01d57 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -1019,6 +1019,7 @@ private void start () } catch { _services.Stop (1011, String.Empty); + throw; } From 6620690afef309e84a06a5d9fb0cd8db1fd63171 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 29 Jun 2021 19:39:18 +0900 Subject: [PATCH 3714/6294] [Modify] Polish it --- websocket-sharp/Server/HttpServer.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 9d3a01d57..4ece225f9 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -993,22 +993,26 @@ private void start () { if (_state == ServerState.Start) { _log.Info ("The server has already started."); + return; } if (_state == ServerState.ShuttingDown) { _log.Warn ("The server is shutting down."); + return; } lock (_sync) { if (_state == ServerState.Start) { _log.Info ("The server has already started."); + return; } if (_state == ServerState.ShuttingDown) { _log.Warn ("The server is shutting down."); + return; } From 4ccfe0aa623192f3cfc91d4289fe18e11cc0487b Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 30 Jun 2021 20:08:07 +0900 Subject: [PATCH 3715/6294] [Modify] Polish it --- websocket-sharp/Server/HttpServer.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 4ece225f9..56680785a 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -1038,11 +1038,13 @@ private void startReceiving () } catch (Exception ex) { var msg = "The underlying listener has failed to start."; + throw new InvalidOperationException (msg, ex); } _receiveThread = new Thread (new ThreadStart (receiveRequest)); _receiveThread.IsBackground = true; + _receiveThread.Start (); } From 6c12b638fd3f646279cd3eeb2aceffe8407c8a70 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 1 Jul 2021 20:11:43 +0900 Subject: [PATCH 3716/6294] [Modify] Polish it --- websocket-sharp/Server/HttpServer.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 56680785a..2840c8483 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -1081,11 +1081,13 @@ private void stop (ushort code, string reason) try { var threw = false; + try { _services.Stop (code, reason); } catch { threw = true; + throw; } finally { From 34868bed04815f60ead057213f1bf2ef963dbb8e Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 2 Jul 2021 20:38:58 +0900 Subject: [PATCH 3717/6294] [Modify] Polish it --- websocket-sharp/Server/HttpServer.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 2840c8483..ff7ef66bb 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -1052,27 +1052,32 @@ private void stop (ushort code, string reason) { if (_state == ServerState.Ready) { _log.Info ("The server is not started."); + return; } if (_state == ServerState.ShuttingDown) { _log.Info ("The server is shutting down."); + return; } if (_state == ServerState.Stop) { _log.Info ("The server has already stopped."); + return; } lock (_sync) { if (_state == ServerState.ShuttingDown) { _log.Info ("The server is shutting down."); + return; } if (_state == ServerState.Stop) { _log.Info ("The server has already stopped."); + return; } From d8eaefc3c75672a0c46e6218f3190b9a69fbba06 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 3 Jul 2021 21:38:32 +0900 Subject: [PATCH 3718/6294] [Modify] Polish it --- websocket-sharp/Server/HttpServer.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index ff7ef66bb..fe0a0123e 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -1124,38 +1124,47 @@ private static bool tryCreateUri ( message = null; var uri = uriString.ToUri (); + if (uri == null) { message = "An invalid URI string."; + return false; } if (!uri.IsAbsoluteUri) { message = "A relative URI."; + return false; } var schm = uri.Scheme; + if (!(schm == "http" || schm == "https")) { message = "The scheme part is not 'http' or 'https'."; + return false; } if (uri.PathAndQuery != "/") { message = "It includes either or both path and query components."; + return false; } if (uri.Fragment.Length > 0) { message = "It includes the fragment component."; + return false; } if (uri.Port == 0) { message = "The port part is zero."; + return false; } result = uri; + return true; } From d0af40181e4d56762457b0fa704c6b1d42fde194 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 4 Jul 2021 21:27:57 +0900 Subject: [PATCH 3719/6294] [Modify] Polish it --- websocket-sharp/Server/HttpServer.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index fe0a0123e..be4b66a11 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -1138,8 +1138,9 @@ private static bool tryCreateUri ( } var schm = uri.Scheme; + var http = schm == "http" || schm == "https"; - if (!(schm == "http" || schm == "https")) { + if (!http) { message = "The scheme part is not 'http' or 'https'."; return false; From f81c6e99aa5fc7a73e3aab4e2eb5094e853ebe07 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 5 Jul 2021 20:42:13 +0900 Subject: [PATCH 3720/6294] [Modify] Polish it --- websocket-sharp/Server/HttpServer.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index be4b66a11..9889f0a52 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -161,19 +161,22 @@ public HttpServer (string url) Uri uri; string msg; + if (!tryCreateUri (url, out uri, out msg)) throw new ArgumentException (msg, "url"); var host = uri.GetDnsSafeHost (true); - var addr = host.ToIPAddress (); + if (addr == null) { msg = "The host part could not be converted to an IP address."; + throw new ArgumentException (msg, "url"); } if (!addr.IsLocal ()) { msg = "The IP address of the host is not a local IP address."; + throw new ArgumentException (msg, "url"); } From dda277fe80a0a747fb5c5cffa386ec1b5f3b3dfe Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 6 Jul 2021 19:48:27 +0900 Subject: [PATCH 3721/6294] [Modify] Edit it --- websocket-sharp/Server/HttpServer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 9889f0a52..4da54e8e2 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -142,7 +142,7 @@ public HttpServer (int port) /// /// /// - /// is empty. + /// is an empty string. /// /// /// -or- From ddc1758d59b18265b0501f0708be1e6645301494 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 6 Jul 2021 19:50:43 +0900 Subject: [PATCH 3722/6294] [Modify] Edit it --- websocket-sharp/Server/HttpServer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 4da54e8e2..3d463d262 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -117,7 +117,7 @@ public HttpServer (int port) /// /// Initializes a new instance of the class with - /// the specified . + /// the specified URL. /// /// /// From 8aeb5e7c047ac0155404f4c650152937341206ab Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 7 Jul 2021 19:37:30 +0900 Subject: [PATCH 3723/6294] [Modify] Edit it --- websocket-sharp/Server/HttpServer.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 3d463d262..c89d3cba9 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -121,8 +121,8 @@ public HttpServer (int port) /// /// /// - /// The new instance listens for incoming requests on the IP address of the - /// host of and the port of . + /// The new instance listens for incoming requests on the IP address and + /// port of . /// /// /// Either port 80 or 443 is used if includes From 8eada83d0693d3edb580cdc730069b1d74d84903 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 7 Jul 2021 19:41:57 +0900 Subject: [PATCH 3724/6294] [Modify] Edit it --- websocket-sharp/Server/HttpServer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index c89d3cba9..d76f9910f 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -135,7 +135,7 @@ public HttpServer (int port) /// /// /// - /// A that represents the HTTP URL of the server. + /// A that specifies the HTTP URL of the server. /// /// /// is . From 73c94ccfc583d62387a4822ed6ca7b9e6db078ed Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 8 Jul 2021 19:16:37 +0900 Subject: [PATCH 3725/6294] [Modify] Edit it --- websocket-sharp/Server/HttpServer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index d76f9910f..f41f29de7 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -92,7 +92,7 @@ public HttpServer () /// /// Initializes a new instance of the class with - /// the specified . + /// the specified port. /// /// /// From 8aebf24d2ac0c3207ce65b700296f5224f11c484 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 8 Jul 2021 19:20:30 +0900 Subject: [PATCH 3726/6294] [Modify] Edit it --- websocket-sharp/Server/HttpServer.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index f41f29de7..357313cc3 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -104,8 +104,8 @@ public HttpServer () /// /// /// - /// An that represents the number of the port - /// on which to listen. + /// An that specifies the number of the port on which + /// to listen. /// /// /// is less than 1 or greater than 65535. From b5208c9c09732114c4c40444d1b1e17b054211d8 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 9 Jul 2021 19:32:28 +0900 Subject: [PATCH 3727/6294] [Modify] Polish it --- websocket-sharp/Server/HttpServer.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 357313cc3..de63c22ef 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -205,7 +205,8 @@ public HttpServer (string url) public HttpServer (int port, bool secure) { if (!port.IsPortNumber ()) { - var msg = "Less than 1 or greater than 65535."; + var msg = "It is less than 1 or greater than 65535."; + throw new ArgumentOutOfRangeException ("port", msg); } From 0dd7541fc740a64192f859b86d3a8bbd002d37b0 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 10 Jul 2021 21:12:47 +0900 Subject: [PATCH 3728/6294] [Modify] Edit it --- websocket-sharp/Server/HttpServer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index de63c22ef..d3481f0d1 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -185,7 +185,7 @@ public HttpServer (string url) /// /// Initializes a new instance of the class with - /// the specified and . + /// the specified port and boolean if secure or not. /// /// /// The new instance listens for incoming requests on From 4c1d7d4a101f8da366741e81823623255cbd93c4 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 10 Jul 2021 21:15:28 +0900 Subject: [PATCH 3729/6294] [Modify] Edit it --- websocket-sharp/Server/HttpServer.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index d3481f0d1..a838f64e9 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -192,8 +192,8 @@ public HttpServer (string url) /// and . /// /// - /// An that represents the number of the port - /// on which to listen. + /// An that specifies the number of the port on which + /// to listen. /// /// /// A : true if the new instance provides From efac8b83a1b9323679211a21930bdf3954bfc558 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 11 Jul 2021 21:33:08 +0900 Subject: [PATCH 3730/6294] [Modify] Edit it --- websocket-sharp/Server/HttpServer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index a838f64e9..1f14213b5 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -215,7 +215,7 @@ public HttpServer (int port, bool secure) /// /// Initializes a new instance of the class with - /// the specified and . + /// the specified IP address and port. /// /// /// From 18afd64c5bd311bc9d1ea29e97666920be713ea7 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 11 Jul 2021 21:35:32 +0900 Subject: [PATCH 3731/6294] [Modify] Edit it --- websocket-sharp/Server/HttpServer.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 1f14213b5..e2ce56d35 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -227,8 +227,8 @@ public HttpServer (int port, bool secure) /// /// /// - /// A that represents - /// the local IP address on which to listen. + /// A that specifies the local IP address + /// on which to listen. /// /// /// An that represents the number of the port From 58b5c971b704dbe3a8367833f4ae1a28552c5897 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 12 Jul 2021 21:07:29 +0900 Subject: [PATCH 3732/6294] [Modify] Edit it --- websocket-sharp/Server/HttpServer.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index e2ce56d35..bbdac14e3 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -231,8 +231,8 @@ public HttpServer (int port, bool secure) /// on which to listen. /// /// - /// An that represents the number of the port - /// on which to listen. + /// An that specifies the number of the port on which + /// to listen. /// /// /// is . From 1aacb446294062d843cc1dca85b29de8248aa6a8 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 12 Jul 2021 21:11:00 +0900 Subject: [PATCH 3733/6294] [Modify] Polish it --- websocket-sharp/Server/HttpServer.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index bbdac14e3..dfda88e00 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -287,7 +287,8 @@ public HttpServer (System.Net.IPAddress address, int port, bool secure) throw new ArgumentException ("Not a local IP address.", "address"); if (!port.IsPortNumber ()) { - var msg = "Less than 1 or greater than 65535."; + var msg = "It is less than 1 or greater than 65535."; + throw new ArgumentOutOfRangeException ("port", msg); } From b67e64c3f92756cdb30eb7be0f15f59b1dee69db Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 13 Jul 2021 19:35:03 +0900 Subject: [PATCH 3734/6294] [Modify] Polish it --- websocket-sharp/Server/HttpServer.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index dfda88e00..fe2fc4edf 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -283,8 +283,11 @@ public HttpServer (System.Net.IPAddress address, int port, bool secure) if (address == null) throw new ArgumentNullException ("address"); - if (!address.IsLocal ()) - throw new ArgumentException ("Not a local IP address.", "address"); + if (!address.IsLocal ()) { + var msg = "It is not a local IP address."; + + throw new ArgumentException (msg, "address"); + } if (!port.IsPortNumber ()) { var msg = "It is less than 1 or greater than 65535."; From 41fa7bfac08eba8baaf3bf94bcd1c5274efbc36a Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 13 Jul 2021 19:38:34 +0900 Subject: [PATCH 3735/6294] [Modify] Edit it --- websocket-sharp/Server/HttpServer.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index fe2fc4edf..801406ac5 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -250,8 +250,7 @@ public HttpServer (System.Net.IPAddress address, int port) /// /// Initializes a new instance of the class with - /// the specified , , - /// and . + /// the specified IP address, port, and boolean if secure or not. /// /// /// The new instance listens for incoming requests on From d87e2d867ad80d21001b09109b60d29ecb7856b5 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 14 Jul 2021 19:36:32 +0900 Subject: [PATCH 3736/6294] [Modify] Edit it --- websocket-sharp/Server/HttpServer.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 801406ac5..025dbfaf1 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -257,8 +257,8 @@ public HttpServer (System.Net.IPAddress address, int port) /// and . /// /// - /// A that represents - /// the local IP address on which to listen. + /// A that specifies the local IP address + /// on which to listen. /// /// /// An that represents the number of the port From 2694059ef29d27caefc71d2d2abed04acb69bfc8 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 14 Jul 2021 19:40:36 +0900 Subject: [PATCH 3737/6294] [Modify] Edit it --- websocket-sharp/Server/HttpServer.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 025dbfaf1..6833f5bf6 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -261,8 +261,8 @@ public HttpServer (System.Net.IPAddress address, int port) /// on which to listen. /// /// - /// An that represents the number of the port - /// on which to listen. + /// An that specifies the number of the port on which + /// to listen. /// /// /// A : true if the new instance provides From 732ec706715105e94fd6b563d26639f9b4a511b1 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 15 Jul 2021 19:36:16 +0900 Subject: [PATCH 3738/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 63205553f..0d9bc6c07 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1501,6 +1501,7 @@ public static bool IsLocal (this System.Net.IPAddress address) var host = System.Net.Dns.GetHostName (); var addrs = System.Net.Dns.GetHostAddresses (host); + foreach (var addr in addrs) { if (address.Equals (addr)) return true; From 4f8e34da943a9c1fc18f43018c8c2d0cff070de8 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 16 Jul 2021 19:34:37 +0900 Subject: [PATCH 3739/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 0d9bc6c07..5f598e193 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1499,8 +1499,8 @@ public static bool IsLocal (this System.Net.IPAddress address) return true; } - var host = System.Net.Dns.GetHostName (); - var addrs = System.Net.Dns.GetHostAddresses (host); + var name = System.Net.Dns.GetHostName (); + var addrs = System.Net.Dns.GetHostAddresses (name); foreach (var addr in addrs) { if (address.Equals (addr)) From 13a4d4533cacc507508d951c26257d367bfd6f53 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 17 Jul 2021 21:46:13 +0900 Subject: [PATCH 3740/6294] [Modify] Edit it --- websocket-sharp/Server/HttpServer.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 6833f5bf6..b65d30727 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -227,8 +227,8 @@ public HttpServer (int port, bool secure) ///
/// /// - /// A that specifies the local IP address - /// on which to listen. + /// A that specifies the local IP + /// address on which to listen. /// /// /// An that specifies the number of the port on which From aaa373aefdad4af735b85b382de3ad4698a935a2 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 18 Jul 2021 21:47:36 +0900 Subject: [PATCH 3741/6294] [Modify] Edit it --- websocket-sharp/Server/HttpServer.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index b65d30727..0deba7473 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -257,8 +257,8 @@ public HttpServer (System.Net.IPAddress address, int port) /// and . /// /// - /// A that specifies the local IP address - /// on which to listen. + /// A that specifies the local IP + /// address on which to listen. /// /// /// An that specifies the number of the port on which From 79c3fc58cbf6bc39c5bc34575843fa73f4c71615 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 19 Jul 2021 21:23:56 +0900 Subject: [PATCH 3742/6294] [Modify] Edit it --- websocket-sharp/Server/HttpServer.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 0deba7473..0191f722f 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -52,11 +52,15 @@ namespace WebSocketSharp.Server { /// - /// Provides a simple HTTP server that allows to accept - /// WebSocket handshake requests. + /// Provides a simple HTTP server. /// /// - /// This class can provide multiple WebSocket services. + /// + /// The server allows to accept WebSocket handshake requests. + /// + /// + /// This class can provide multiple WebSocket services. + /// /// public class HttpServer { From d6108a327ed3c7ce81e5a8a9f8662f27029c0b83 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 20 Jul 2021 20:00:56 +0900 Subject: [PATCH 3743/6294] [Modify] Edit it --- websocket-sharp/Server/HttpServer.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 0191f722f..4065a10e9 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -56,7 +56,10 @@ namespace WebSocketSharp.Server ///
/// /// - /// The server allows to accept WebSocket handshake requests. + /// The server supports HTTP/1.1 version request and response. + /// + /// + /// And the server allows to accept WebSocket handshake requests. /// /// /// This class can provide multiple WebSocket services. From 200e13a2da2bebe5ea9459aef259610e61358477 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 21 Jul 2021 19:52:31 +0900 Subject: [PATCH 3744/6294] [Modify] Edit it --- websocket-sharp/Server/HttpServer.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 4065a10e9..255614a1e 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -2,8 +2,6 @@ /* * HttpServer.cs * - * A simple HTTP server that allows to accept WebSocket handshake requests. - * * The MIT License * * Copyright (c) 2012-2016 sta.blockhead From 03fd189483c75370e84de8aad7981d13cb11a227 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 21 Jul 2021 19:57:32 +0900 Subject: [PATCH 3745/6294] [Modify] Polish it --- websocket-sharp/Server/HttpServer.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 255614a1e..16a6a16ca 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -858,6 +858,7 @@ private bool checkCertificate (out string message) private string createFilePath (string childPath) { childPath = childPath.TrimStart ('/', '\\'); + return new StringBuilder (_docRootPath, 32) .AppendFormat ("/{0}", childPath) .ToString () From bdd1bbde7141b93bffa40d545bcbc19d2bd23948 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 22 Jul 2021 19:38:23 +0900 Subject: [PATCH 3746/6294] [Modify] Polish it --- websocket-sharp/Server/HttpServer.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 16a6a16ca..50b89a564 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -1450,6 +1450,7 @@ public byte[] GetFile (string path) throw new ArgumentException ("It contains '..'.", "path"); path = createFilePath (path); + return File.Exists (path) ? File.ReadAllBytes (path) : null; } From 2c293201c623edd0e1e85816fae0df7fa6539e42 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 23 Jul 2021 19:37:30 +0900 Subject: [PATCH 3747/6294] [Modify] Remove it --- websocket-sharp/Server/HttpServer.cs | 48 ---------------------------- 1 file changed, 48 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 50b89a564..871d1c8f9 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -1406,54 +1406,6 @@ public void AddWebSocketService ( _services.AddService (path, initializer); } - /// - /// Gets the contents of the specified file from the document - /// folder of the server. - /// - /// - /// - /// An array of or - /// if it fails. - /// - /// - /// That array represents the contents of the file. - /// - /// - /// - /// A that represents a virtual path to - /// find the file from the document folder. - /// - /// - /// is . - /// - /// - /// - /// is an empty string. - /// - /// - /// -or- - /// - /// - /// contains "..". - /// - /// - [Obsolete ("This method will be removed.")] - public byte[] GetFile (string path) - { - if (path == null) - throw new ArgumentNullException ("path"); - - if (path.Length == 0) - throw new ArgumentException ("An empty string.", "path"); - - if (path.IndexOf ("..") > -1) - throw new ArgumentException ("It contains '..'.", "path"); - - path = createFilePath (path); - - return File.Exists (path) ? File.ReadAllBytes (path) : null; - } - /// /// Removes a WebSocket service with the specified path. /// From 8c8be0c2190de4740458dcc85d193c0c3dc88f89 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 24 Jul 2021 21:05:39 +0900 Subject: [PATCH 3748/6294] [Modify] Remove it --- websocket-sharp/Server/HttpServer.cs | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 871d1c8f9..1bbe8667f 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -855,16 +855,6 @@ private bool checkCertificate (out string message) return true; } - private string createFilePath (string childPath) - { - childPath = childPath.TrimStart ('/', '\\'); - - return new StringBuilder (_docRootPath, 32) - .AppendFormat ("/{0}", childPath) - .ToString () - .Replace ('\\', '/'); - } - private static HttpListener createListener ( string hostname, int port, bool secure ) From 34c2cd55c72394ff8f6284ab878f2686616b3734 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 25 Jul 2021 21:25:39 +0900 Subject: [PATCH 3749/6294] [Modify] Polish it --- websocket-sharp/Server/HttpRequestEventArgs.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Server/HttpRequestEventArgs.cs b/websocket-sharp/Server/HttpRequestEventArgs.cs index ee76cbab3..2e9b4f1d9 100644 --- a/websocket-sharp/Server/HttpRequestEventArgs.cs +++ b/websocket-sharp/Server/HttpRequestEventArgs.cs @@ -127,6 +127,7 @@ public IPrincipal User { private string createFilePath (string childPath) { childPath = childPath.TrimStart ('/', '\\'); + return new StringBuilder (_docRootPath, 32) .AppendFormat ("/{0}", childPath) .ToString () From 3ae8b6152b6bb438f64d804a27c942b68dedafe4 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 26 Jul 2021 21:40:42 +0900 Subject: [PATCH 3750/6294] [Modify] Polish it --- websocket-sharp/Server/HttpRequestEventArgs.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Server/HttpRequestEventArgs.cs b/websocket-sharp/Server/HttpRequestEventArgs.cs index 2e9b4f1d9..eb7b401ab 100644 --- a/websocket-sharp/Server/HttpRequestEventArgs.cs +++ b/websocket-sharp/Server/HttpRequestEventArgs.cs @@ -198,6 +198,7 @@ public byte[] ReadFile (string path) throw new ArgumentException ("It contains '..'.", "path"); byte[] contents; + tryReadFile (createFilePath (path), out contents); return contents; From 266e64bd82d7f8ac0e4933889720c919afa32ba0 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 27 Jul 2021 19:57:34 +0900 Subject: [PATCH 3751/6294] [Modify] Edit it --- websocket-sharp/Server/HttpRequestEventArgs.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/HttpRequestEventArgs.cs b/websocket-sharp/Server/HttpRequestEventArgs.cs index eb7b401ab..17ba1f316 100644 --- a/websocket-sharp/Server/HttpRequestEventArgs.cs +++ b/websocket-sharp/Server/HttpRequestEventArgs.cs @@ -35,8 +35,8 @@ namespace WebSocketSharp.Server { /// - /// Represents the event data for the HTTP request events of - /// the . + /// Represents the event data for the HTTP request events of the + /// class. /// /// /// From e2ef1feaa5b0e84f530b53019d8b2d4c9e9eedbf Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 27 Jul 2021 19:59:00 +0900 Subject: [PATCH 3752/6294] [Modify] Edit it --- websocket-sharp/Server/HttpRequestEventArgs.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/HttpRequestEventArgs.cs b/websocket-sharp/Server/HttpRequestEventArgs.cs index 17ba1f316..0f90f0644 100644 --- a/websocket-sharp/Server/HttpRequestEventArgs.cs +++ b/websocket-sharp/Server/HttpRequestEventArgs.cs @@ -41,7 +41,7 @@ namespace WebSocketSharp.Server /// /// /// An HTTP request event occurs when the - /// receives an HTTP request. + /// instance receives an HTTP request. /// /// /// You should access the property if you would From 3f85ebbd7a527846aa0e0bbc44a29444a9c07dcd Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 28 Jul 2021 19:54:05 +0900 Subject: [PATCH 3753/6294] [Modify] Edit it --- websocket-sharp/Server/HttpRequestEventArgs.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/HttpRequestEventArgs.cs b/websocket-sharp/Server/HttpRequestEventArgs.cs index 0f90f0644..779b824d4 100644 --- a/websocket-sharp/Server/HttpRequestEventArgs.cs +++ b/websocket-sharp/Server/HttpRequestEventArgs.cs @@ -48,8 +48,8 @@ namespace WebSocketSharp.Server /// like to get the request data sent from a client. /// /// - /// And you should access the property if you would - /// like to get the response data to return to the client. + /// And you should access the property if you + /// would like to get the response data to return to the client. /// /// public class HttpRequestEventArgs : EventArgs From e80a7e844ca4eb5fd8a01487fbb94aba9c25f45e Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 28 Jul 2021 19:58:35 +0900 Subject: [PATCH 3754/6294] [Modify] Edit it --- websocket-sharp/Server/HttpRequestEventArgs.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/HttpRequestEventArgs.cs b/websocket-sharp/Server/HttpRequestEventArgs.cs index 779b824d4..9ab11f6db 100644 --- a/websocket-sharp/Server/HttpRequestEventArgs.cs +++ b/websocket-sharp/Server/HttpRequestEventArgs.cs @@ -156,8 +156,8 @@ private static bool tryReadFile (string path, out byte[] contents) #region Public Methods /// - /// Reads the specified file from the document folder of - /// the . + /// Reads the specified file from the document folder of the + /// class. /// /// /// From 48479a75e906e7bb02e851f789850cc0dd1d54c4 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 29 Jul 2021 19:38:07 +0900 Subject: [PATCH 3755/6294] [Modify] Edit it --- websocket-sharp/Server/HttpRequestEventArgs.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/HttpRequestEventArgs.cs b/websocket-sharp/Server/HttpRequestEventArgs.cs index 9ab11f6db..ea852b70b 100644 --- a/websocket-sharp/Server/HttpRequestEventArgs.cs +++ b/websocket-sharp/Server/HttpRequestEventArgs.cs @@ -169,7 +169,7 @@ private static bool tryReadFile (string path, out byte[] contents) /// /// /// - /// A that represents a virtual path to + /// A that specifies a virtual path to /// find the file from the document folder. /// /// From 7a9211d5837f7647815ddbcbe0b264f2bec51ba0 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 29 Jul 2021 19:40:40 +0900 Subject: [PATCH 3756/6294] [Modify] Edit it --- websocket-sharp/Server/HttpRequestEventArgs.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/HttpRequestEventArgs.cs b/websocket-sharp/Server/HttpRequestEventArgs.cs index ea852b70b..e827727a3 100644 --- a/websocket-sharp/Server/HttpRequestEventArgs.cs +++ b/websocket-sharp/Server/HttpRequestEventArgs.cs @@ -206,7 +206,7 @@ public byte[] ReadFile (string path) /// /// Tries to read the specified file from the document folder of - /// the . + /// the class. /// /// /// true if it succeeds to read; otherwise, false. From 4b23c190f471f070fc54789ed821b66ee0069124 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 30 Jul 2021 19:31:10 +0900 Subject: [PATCH 3757/6294] [Modify] Edit it --- websocket-sharp/Server/HttpRequestEventArgs.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/HttpRequestEventArgs.cs b/websocket-sharp/Server/HttpRequestEventArgs.cs index e827727a3..4997dad3f 100644 --- a/websocket-sharp/Server/HttpRequestEventArgs.cs +++ b/websocket-sharp/Server/HttpRequestEventArgs.cs @@ -212,8 +212,8 @@ public byte[] ReadFile (string path) /// true if it succeeds to read; otherwise, false. /// /// - /// A that represents a virtual path to - /// find the file from the document folder. + /// A that specifies a virtual path to find + /// the file from the document folder. /// /// /// From b6e8d76df1c8d2ba2c6900617a1ed09f8bcfac56 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 31 Jul 2021 21:56:05 +0900 Subject: [PATCH 3758/6294] [Modify] Polish it --- websocket-sharp/Server/HttpRequestEventArgs.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Server/HttpRequestEventArgs.cs b/websocket-sharp/Server/HttpRequestEventArgs.cs index 4997dad3f..6cae4f27e 100644 --- a/websocket-sharp/Server/HttpRequestEventArgs.cs +++ b/websocket-sharp/Server/HttpRequestEventArgs.cs @@ -249,7 +249,9 @@ public bool TryReadFile (string path, out byte[] contents) if (path.IndexOf ("..") > -1) throw new ArgumentException ("It contains '..'.", "path"); - return tryReadFile (createFilePath (path), out contents); + path = createFilePath (path); + + return tryReadFile (path, out contents); } #endregion From 9cd89f828bfc4aa2b7712959ff1d9671de985495 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 1 Aug 2021 22:04:18 +0900 Subject: [PATCH 3759/6294] [Modify] Polish it --- websocket-sharp/Server/HttpRequestEventArgs.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Server/HttpRequestEventArgs.cs b/websocket-sharp/Server/HttpRequestEventArgs.cs index 6cae4f27e..6f9ed4e2a 100644 --- a/websocket-sharp/Server/HttpRequestEventArgs.cs +++ b/websocket-sharp/Server/HttpRequestEventArgs.cs @@ -197,9 +197,10 @@ public byte[] ReadFile (string path) if (path.IndexOf ("..") > -1) throw new ArgumentException ("It contains '..'.", "path"); + path = createFilePath (path); byte[] contents; - tryReadFile (createFilePath (path), out contents); + tryReadFile (path, out contents); return contents; } From a1bd88ba404f5777ba46c3522cd432021f6721c7 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 2 Aug 2021 21:28:25 +0900 Subject: [PATCH 3760/6294] [Modify] 2021 --- websocket-sharp/Server/HttpRequestEventArgs.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/HttpRequestEventArgs.cs b/websocket-sharp/Server/HttpRequestEventArgs.cs index 6f9ed4e2a..722fe8b93 100644 --- a/websocket-sharp/Server/HttpRequestEventArgs.cs +++ b/websocket-sharp/Server/HttpRequestEventArgs.cs @@ -4,7 +4,7 @@ * * The MIT License * - * Copyright (c) 2012-2017 sta.blockhead + * Copyright (c) 2012-2021 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From 7be26f98b3ebe275a9e6501f38f3fd490465625b Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 3 Aug 2021 20:59:41 +0900 Subject: [PATCH 3761/6294] [Modify] Remove it --- websocket-sharp/Server/HttpServer.cs | 72 ---------------------------- 1 file changed, 72 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 1bbe8667f..81b8c0cba 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -1565,78 +1565,6 @@ public void Stop (ushort code, string reason) stop (code, reason); } - /// - /// Stops receiving incoming requests and closes each connection. - /// - /// - /// - /// One of the enum values. - /// - /// - /// It represents the status code indicating the reason for the WebSocket - /// connection close. - /// - /// - /// - /// - /// A that represents the reason for the WebSocket - /// connection close. - /// - /// - /// The size must be 123 bytes or less in UTF-8. - /// - /// - /// - /// The size of is greater than 123 bytes. - /// - /// - /// - /// is - /// . - /// - /// - /// -or- - /// - /// - /// is - /// and there is reason. - /// - /// - /// -or- - /// - /// - /// could not be UTF-8-encoded. - /// - /// - [Obsolete ("This method will be removed.")] - public void Stop (CloseStatusCode code, string reason) - { - if (code == CloseStatusCode.MandatoryExtension) { - var msg = "MandatoryExtension cannot be used."; - throw new ArgumentException (msg, "code"); - } - - if (!reason.IsNullOrEmpty ()) { - if (code == CloseStatusCode.NoStatus) { - var msg = "NoStatus cannot be used."; - throw new ArgumentException (msg, "code"); - } - - byte[] bytes; - if (!reason.TryGetUTF8EncodedBytes (out bytes)) { - var msg = "It could not be UTF-8-encoded."; - throw new ArgumentException (msg, "reason"); - } - - if (bytes.Length > 123) { - var msg = "Its size is greater than 123 bytes."; - throw new ArgumentOutOfRangeException ("reason", msg); - } - } - - stop ((ushort) code, reason); - } - #endregion } } From d05afaeea1024afca8845ef35ceb0c8514bdc03e Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 4 Aug 2021 21:33:23 +0900 Subject: [PATCH 3762/6294] [Modify] Remove it --- websocket-sharp/Server/HttpServer.cs | 85 ---------------------------- 1 file changed, 85 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 81b8c0cba..71bb52bf2 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -1480,91 +1480,6 @@ public void Stop () stop (1001, String.Empty); } - /// - /// Stops receiving incoming requests and closes each connection. - /// - /// - /// - /// A that represents the status code indicating - /// the reason for the WebSocket connection close. - /// - /// - /// The status codes are defined in - /// - /// Section 7.4 of RFC 6455. - /// - /// - /// - /// - /// A that represents the reason for the WebSocket - /// connection close. - /// - /// - /// The size must be 123 bytes or less in UTF-8. - /// - /// - /// - /// - /// is less than 1000 or greater than 4999. - /// - /// - /// -or- - /// - /// - /// The size of is greater than 123 bytes. - /// - /// - /// - /// - /// is 1010 (mandatory extension). - /// - /// - /// -or- - /// - /// - /// is 1005 (no status) and there is reason. - /// - /// - /// -or- - /// - /// - /// could not be UTF-8-encoded. - /// - /// - [Obsolete ("This method will be removed.")] - public void Stop (ushort code, string reason) - { - if (!code.IsCloseStatusCode ()) { - var msg = "Less than 1000 or greater than 4999."; - throw new ArgumentOutOfRangeException ("code", msg); - } - - if (code == 1010) { - var msg = "1010 cannot be used."; - throw new ArgumentException (msg, "code"); - } - - if (!reason.IsNullOrEmpty ()) { - if (code == 1005) { - var msg = "1005 cannot be used."; - throw new ArgumentException (msg, "code"); - } - - byte[] bytes; - if (!reason.TryGetUTF8EncodedBytes (out bytes)) { - var msg = "It could not be UTF-8-encoded."; - throw new ArgumentException (msg, "reason"); - } - - if (bytes.Length > 123) { - var msg = "Its size is greater than 123 bytes."; - throw new ArgumentOutOfRangeException ("reason", msg); - } - } - - stop (code, reason); - } - #endregion } } From 6b8b0ba745f3c75543dae8774cc9794642b3c758 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 5 Aug 2021 21:57:09 +0900 Subject: [PATCH 3763/6294] [Modify] Polish it --- websocket-sharp/Server/HttpServer.cs | 36 ++++++++++++++-------------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 71bb52bf2..e651e0247 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -1053,24 +1053,6 @@ private void startReceiving () private void stop (ushort code, string reason) { - if (_state == ServerState.Ready) { - _log.Info ("The server is not started."); - - return; - } - - if (_state == ServerState.ShuttingDown) { - _log.Info ("The server is shutting down."); - - return; - } - - if (_state == ServerState.Stop) { - _log.Info ("The server has already stopped."); - - return; - } - lock (_sync) { if (_state == ServerState.ShuttingDown) { _log.Info ("The server is shutting down."); @@ -1477,6 +1459,24 @@ public void Start () ///
public void Stop () { + if (_state == ServerState.Ready) { + _log.Info ("The server is not started."); + + return; + } + + if (_state == ServerState.ShuttingDown) { + _log.Info ("The server is shutting down."); + + return; + } + + if (_state == ServerState.Stop) { + _log.Info ("The server has already stopped."); + + return; + } + stop (1001, String.Empty); } From 5faf02fd119710daa7ac905e4b692ebc06ebeeae Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 6 Aug 2021 21:41:22 +0900 Subject: [PATCH 3764/6294] [Modify] Polish it --- websocket-sharp/Server/HttpServer.cs | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index e651e0247..99c1d6b34 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -994,18 +994,6 @@ private void receiveRequest () private void start () { - if (_state == ServerState.Start) { - _log.Info ("The server has already started."); - - return; - } - - if (_state == ServerState.ShuttingDown) { - _log.Warn ("The server is shutting down."); - - return; - } - lock (_sync) { if (_state == ServerState.Start) { _log.Info ("The server has already started."); @@ -1451,6 +1439,18 @@ public void Start () throw new InvalidOperationException (msg); } + if (_state == ServerState.Start) { + _log.Info ("The server has already started."); + + return; + } + + if (_state == ServerState.ShuttingDown) { + _log.Warn ("The server is shutting down."); + + return; + } + start (); } From 757ff4d67787a70dc39030edc0f3110536b7702c Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 7 Aug 2021 22:13:28 +0900 Subject: [PATCH 3765/6294] [Modify] Remove it --- websocket-sharp/Server/HttpServer.cs | 95 ---------------------------- 1 file changed, 95 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 99c1d6b34..da0526617 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -1146,101 +1146,6 @@ private static bool tryCreateUri ( #region Public Methods - /// - /// Adds a WebSocket service with the specified behavior, path, - /// and delegate. - /// - /// - /// - /// A that represents an absolute path to - /// the service to add. - /// - /// - /// / is trimmed from the end of the string if present. - /// - /// - /// - /// - /// A Func<TBehavior> delegate. - /// - /// - /// It invokes the method called when creating a new session - /// instance for the service. - /// - /// - /// The method must create a new instance of the specified - /// behavior class and return it. - /// - /// - /// - /// - /// The type of the behavior for the service. - /// - /// - /// It must inherit the class. - /// - /// - /// - /// - /// is . - /// - /// - /// -or- - /// - /// - /// is . - /// - /// - /// - /// - /// is an empty string. - /// - /// - /// -or- - /// - /// - /// is not an absolute path. - /// - /// - /// -or- - /// - /// - /// includes either or both - /// query and fragment components. - /// - /// - /// -or- - /// - /// - /// is already in use. - /// - /// - [Obsolete ("This method will be removed. Use added one instead.")] - public void AddWebSocketService ( - string path, Func creator - ) - where TBehavior : WebSocketBehavior - { - if (path == null) - throw new ArgumentNullException ("path"); - - if (creator == null) - throw new ArgumentNullException ("creator"); - - if (path.Length == 0) - throw new ArgumentException ("An empty string.", "path"); - - if (path[0] != '/') - throw new ArgumentException ("Not an absolute path.", "path"); - - if (path.IndexOfAny (new[] { '?', '#' }) > -1) { - var msg = "It includes either or both query and fragment components."; - throw new ArgumentException (msg, "path"); - } - - _services.Add (path, creator); - } - /// /// Adds a WebSocket service with the specified behavior and path. /// From 02c074ab157bb5947e565a23ae0ba6c78f266f4c Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 8 Aug 2021 21:35:59 +0900 Subject: [PATCH 3766/6294] [Modify] Polish it --- websocket-sharp/Server/HttpServer.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index da0526617..fbe449a8d 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -1196,10 +1196,10 @@ private static bool tryCreateUri ( /// is already in use. ///
/// - public void AddWebSocketService (string path) - where TBehaviorWithNew : WebSocketBehavior, new () + public void AddWebSocketService (string path) + where TBehavior : WebSocketBehavior, new () { - _services.AddService (path, null); + _services.AddService (path, null); } /// From 68aa732f8fb2e33624ee4796be61334811d440ac Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 9 Aug 2021 21:30:07 +0900 Subject: [PATCH 3767/6294] [Modify] Edit it --- websocket-sharp/Server/HttpServer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index fbe449a8d..f06910d02 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -1158,7 +1158,7 @@ private static bool tryCreateUri ( /// / is trimmed from the end of the string if present. /// /// - /// + /// /// /// The type of the behavior for the service. /// From 50a57fe7ba3bb912503bf7a10b054212c550cc00 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 9 Aug 2021 21:32:45 +0900 Subject: [PATCH 3768/6294] [Modify] Edit it --- websocket-sharp/Server/HttpServer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index f06910d02..97bda4b26 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -1151,7 +1151,7 @@ private static bool tryCreateUri ( /// /// /// - /// A that represents an absolute path to + /// A that specifies an absolute path to /// the service to add. /// /// From f5047126543ce9b735cb657c2a270e4a6470b80c Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 10 Aug 2021 20:00:33 +0900 Subject: [PATCH 3769/6294] [Modify] Polish it --- websocket-sharp/Server/HttpServer.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 97bda4b26..6a8b1382a 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -1263,12 +1263,12 @@ public void AddWebSocketService (string path) /// is already in use. /// /// - public void AddWebSocketService ( - string path, Action initializer + public void AddWebSocketService ( + string path, Action initializer ) - where TBehaviorWithNew : WebSocketBehavior, new () + where TBehavior : WebSocketBehavior, new () { - _services.AddService (path, initializer); + _services.AddService (path, initializer); } /// From 685747a43841ad4e750433e6851ea95b921bd0e2 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 10 Aug 2021 20:03:55 +0900 Subject: [PATCH 3770/6294] [Modify] Edit it --- websocket-sharp/Server/HttpServer.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 6a8b1382a..dc2dd2620 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -1217,7 +1217,7 @@ public void AddWebSocketService (string path) /// /// /// - /// An Action<TBehaviorWithNew> delegate or + /// An Action<TBehavior> delegate or /// if not needed. /// /// @@ -1225,7 +1225,7 @@ public void AddWebSocketService (string path) /// a new session instance for the service. /// /// - /// + /// /// /// The type of the behavior for the service. /// From 55afdf4825a1ec3db3ccddc414e12a2501dd8317 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 11 Aug 2021 19:41:49 +0900 Subject: [PATCH 3771/6294] [Modify] Edit it --- websocket-sharp/Server/HttpServer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index dc2dd2620..fb15d65c1 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -1208,7 +1208,7 @@ public void AddWebSocketService (string path) /// /// /// - /// A that represents an absolute path to + /// A that specifies an absolute path to /// the service to add. /// /// From 597c9209e57882f19d245c5a90c5dd3c61dcd83a Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 12 Aug 2021 21:44:47 +0900 Subject: [PATCH 3772/6294] [Modify] Edit it --- websocket-sharp/Server/HttpServer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index fb15d65c1..59849e3a7 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -1284,7 +1284,7 @@ public void AddWebSocketService ( /// /// /// - /// A that represents an absolute path to + /// A that specifies an absolute path to /// the service to remove. /// /// From 7a67c0b3d63767454b62825850aa07363edc6833 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 13 Aug 2021 19:50:19 +0900 Subject: [PATCH 3773/6294] [Modify] Edit it --- websocket-sharp/Server/HttpServer.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 59849e3a7..5c6110c93 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -1362,6 +1362,10 @@ public void Start () /// /// Stops receiving incoming requests. /// + /// + /// This method does nothing if the server is not started, + /// it is shutting down, or it has already stopped. + /// public void Stop () { if (_state == ServerState.Ready) { From 05a94817d3bb1f1f9eb7c3607ee4e00d505869b2 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 14 Aug 2021 21:36:09 +0900 Subject: [PATCH 3774/6294] [Modify] Polish it --- websocket-sharp/Server/HttpServer.cs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 5c6110c93..9bcb3aa12 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -905,11 +905,14 @@ private void processRequest (HttpListenerContext context) ? OnTrace : null; - if (evt != null) - evt (this, new HttpRequestEventArgs (context, _docRootPath)); - else - context.Response.StatusCode = 501; // Not Implemented + if (evt == null) { + context.ErrorStatusCode = 501; + context.SendError (); + return; + } + + evt (this, new HttpRequestEventArgs (context, _docRootPath)); context.Response.Close (); } From aa006eb9a873f2600963944ba72cdb021d2f9f47 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 15 Aug 2021 22:02:01 +0900 Subject: [PATCH 3775/6294] [Modify] Polish it --- websocket-sharp/Server/HttpServer.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 9bcb3aa12..0487fc6cb 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -912,7 +912,9 @@ private void processRequest (HttpListenerContext context) return; } - evt (this, new HttpRequestEventArgs (context, _docRootPath)); + var e = new HttpRequestEventArgs (context, _docRootPath); + evt (this, e); + context.Response.Close (); } From 25d3f093504153ff402a0cd01ee5ddcfbd2ebd7e Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 16 Aug 2021 19:38:54 +0900 Subject: [PATCH 3776/6294] [Modify] 2021 --- websocket-sharp/Server/HttpServer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 0487fc6cb..7c65fd70c 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -4,7 +4,7 @@ * * The MIT License * - * Copyright (c) 2012-2016 sta.blockhead + * Copyright (c) 2012-2021 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From 0fd9748c160eeca14517392964fee5a8e7de96dd Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 16 Aug 2021 19:46:04 +0900 Subject: [PATCH 3777/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketServer.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index be7bca768..0abc9d4b5 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -741,11 +741,13 @@ private bool canSet (out string message) if (_state == ServerState.Start) { message = "The server has already started."; + return false; } if (_state == ServerState.ShuttingDown) { message = "The server is shutting down."; + return false; } From e4a27a912102bba9979cac159609ff5972e94adb Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 17 Aug 2021 19:39:15 +0900 Subject: [PATCH 3778/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketServer.cs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 0abc9d4b5..81741fb34 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -347,15 +347,12 @@ public bool AllowForwardedRequest { } set { - string msg; - if (!canSet (out msg)) { - _log.Warn (msg); - return; - } - lock (_sync) { + string msg; + if (!canSet (out msg)) { _log.Warn (msg); + return; } From 36ceb5b5580cb6cb8b0f1f0b7004aa2c820ec4e3 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 17 Aug 2021 19:41:44 +0900 Subject: [PATCH 3779/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketServer.cs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 81741fb34..97d8eeb5f 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -387,15 +387,12 @@ public AuthenticationSchemes AuthenticationSchemes { } set { - string msg; - if (!canSet (out msg)) { - _log.Warn (msg); - return; - } - lock (_sync) { + string msg; + if (!canSet (out msg)) { _log.Warn (msg); + return; } From 5ff4c01bccc4a6a806fbd3de46cfdc39422351be Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 18 Aug 2021 19:36:13 +0900 Subject: [PATCH 3780/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketServer.cs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 97d8eeb5f..bbf033cac 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -508,15 +508,12 @@ public string Realm { } set { - string msg; - if (!canSet (out msg)) { - _log.Warn (msg); - return; - } - lock (_sync) { + string msg; + if (!canSet (out msg)) { _log.Warn (msg); + return; } From feaabed7698da7b780e7eeee6618def622662c07 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 19 Aug 2021 19:54:42 +0900 Subject: [PATCH 3781/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index bbf033cac..19a9953b9 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -482,24 +482,25 @@ public int Port { } /// - /// Gets or sets the realm used for authentication. + /// Gets or sets the name of the realm associated with the server. /// /// /// - /// "SECRET AREA" is used as the realm if the value is + /// "SECRET AREA" is used as the name of the realm if the value is /// or an empty string. /// /// - /// The set operation does nothing if the server has - /// already started or it is shutting down. + /// The set operation does nothing if the server has already started + /// or it is shutting down. /// /// /// /// - /// A or by default. + /// A that represents the name of the realm or + /// . /// /// - /// That string represents the name of the realm. + /// The default value is . /// /// public string Realm { From 622746e1492a65d9f3d7244aad254b9f5c3ca4ba Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 19 Aug 2021 19:56:45 +0900 Subject: [PATCH 3782/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketServer.cs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 19a9953b9..1f969edf7 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -552,15 +552,12 @@ public bool ReuseAddress { } set { - string msg; - if (!canSet (out msg)) { - _log.Warn (msg); - return; - } - lock (_sync) { + string msg; + if (!canSet (out msg)) { _log.Warn (msg); + return; } From 05b21bef3847424fe82f0b84938edd451092d020 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 20 Aug 2021 20:06:43 +0900 Subject: [PATCH 3783/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketServer.cs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 1f969edf7..41acafbf3 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -626,15 +626,12 @@ public Func UserCredentialsFinder { } set { - string msg; - if (!canSet (out msg)) { - _log.Warn (msg); - return; - } - lock (_sync) { + string msg; + if (!canSet (out msg)) { _log.Warn (msg); + return; } From 7003e24bd76683ed9bf408b7782b0e1e777ce6e9 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 20 Aug 2021 20:12:15 +0900 Subject: [PATCH 3784/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketServer.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 41acafbf3..cb45cb215 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -583,7 +583,8 @@ public bool ReuseAddress { public ServerSslConfiguration SslConfiguration { get { if (!_secure) { - var msg = "This instance does not provide secure connections."; + var msg = "The server does not provide secure connections."; + throw new InvalidOperationException (msg); } From 336e63809657807a628e3210f22d3a08ea4ba90b Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 21 Aug 2021 21:20:32 +0900 Subject: [PATCH 3785/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index cb45cb215..d090bc875 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -570,7 +570,7 @@ public bool ReuseAddress { /// Gets the configuration for secure connection. ///
/// - /// This configuration will be referenced when attempts to start, + /// The configuration will be referenced when attempts to start, /// so it must be configured before the start method is called. /// /// From fd8b32dcf0bbfd70105443a174657a3edc7926c8 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 21 Aug 2021 21:21:46 +0900 Subject: [PATCH 3786/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index d090bc875..0e126f74b 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -578,7 +578,7 @@ public bool ReuseAddress { /// the configuration used to provide secure connections. /// /// - /// This instance does not provide secure connections. + /// The server does not provide secure connections. /// public ServerSslConfiguration SslConfiguration { get { From a1ae8ea1a56312bf48eebb1be0b08f3b32839e4a Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 22 Aug 2021 22:05:22 +0900 Subject: [PATCH 3787/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 0e126f74b..b338b3559 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -417,7 +417,7 @@ public bool IsListening { /// Gets a value indicating whether secure connections are provided. ///
/// - /// true if this instance provides secure connections; otherwise, + /// true if the server provides secure connections; otherwise, /// false. /// public bool IsSecure { From 95c0944a5b0a74771a65ccdf222be1eb834792a2 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 22 Aug 2021 22:10:46 +0900 Subject: [PATCH 3788/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index b338b3559..9fe8daa5c 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -642,8 +642,8 @@ public Func UserCredentialsFinder { } /// - /// Gets or sets the time to wait for the response to the WebSocket Ping or - /// Close. + /// Gets or sets the time to wait for the response to the WebSocket + /// Ping or Close. /// /// /// The set operation does nothing if the server has already started or From f42a030d914239788ee3eb90ea54baddea1903e8 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 23 Aug 2021 21:35:01 +0900 Subject: [PATCH 3789/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketServer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 9fe8daa5c..24c96f4a3 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -1320,8 +1320,8 @@ public void Start () if (_secure) { sslConfig = new ServerSslConfiguration (getSslConfiguration ()); - string msg; + if (!checkSslConfiguration (sslConfig, out msg)) throw new InvalidOperationException (msg); } From bfac1672e45d46ab7408d99db2eee7c2c9db2e50 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 23 Aug 2021 21:37:50 +0900 Subject: [PATCH 3790/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketServer.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 24c96f4a3..65c2936d3 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -756,6 +756,7 @@ private static bool checkSslConfiguration ( if (configuration.ServerCertificate == null) { message = "There is no server certificate for secure connection."; + return false; } From 3c9197de967c0a271a0124c5d0a865a77d3e1642 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 24 Aug 2021 19:32:14 +0900 Subject: [PATCH 3791/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketServer.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 65c2936d3..b1a54c195 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -766,6 +766,7 @@ private static bool checkSslConfiguration ( private string getRealm () { var realm = _realm; + return realm != null && realm.Length > 0 ? realm : _defaultRealm; } From bd9ac326995f0426568ffa5bc357201e4733489e Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 24 Aug 2021 19:38:41 +0900 Subject: [PATCH 3792/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketServer.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index b1a54c195..017437482 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -1322,10 +1322,12 @@ public void Start () if (_secure) { sslConfig = new ServerSslConfiguration (getSslConfiguration ()); - string msg; - if (!checkSslConfiguration (sslConfig, out msg)) + if (sslConfig.ServerCertificate == null) { + var msg = "There is no server certificate for secure connection."; + throw new InvalidOperationException (msg); + } } start (sslConfig); From f1306eb140b23c99ea1e6b68d993dee9f3307ff9 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 25 Aug 2021 19:36:27 +0900 Subject: [PATCH 3793/6294] [Modify] Remove it --- websocket-sharp/Server/WebSocketServer.cs | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 017437482..4ff982e25 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -748,21 +748,6 @@ private bool checkHostNameForRequest (string name) || name == _hostname; } - private static bool checkSslConfiguration ( - ServerSslConfiguration configuration, out string message - ) - { - message = null; - - if (configuration.ServerCertificate == null) { - message = "There is no server certificate for secure connection."; - - return false; - } - - return true; - } - private string getRealm () { var realm = _realm; From fa4d12297d7f1fa9e2a386395ebe8f83ef54e217 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 25 Aug 2021 19:40:05 +0900 Subject: [PATCH 3794/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketServer.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 4ff982e25..4f2b22583 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -1306,7 +1306,8 @@ public void Start () ServerSslConfiguration sslConfig = null; if (_secure) { - sslConfig = new ServerSslConfiguration (getSslConfiguration ()); + var src = getSslConfiguration (); + sslConfig = new ServerSslConfiguration (src); if (sslConfig.ServerCertificate == null) { var msg = "There is no server certificate for secure connection."; From 509df2d81446a33190d940aa7c4f57dc32db1f29 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 26 Aug 2021 19:34:45 +0900 Subject: [PATCH 3795/6294] [Modify] Remove it --- websocket-sharp/Server/WebSocketServer.cs | 88 ----------------------- 1 file changed, 88 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 4f2b22583..b6510adb8 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -1330,94 +1330,6 @@ public void Stop () stop (1001, String.Empty); } - /// - /// Stops receiving incoming handshake requests and closes each connection - /// with the specified code and reason. - /// - /// - /// - /// A that represents the status code indicating - /// the reason for the close. - /// - /// - /// The status codes are defined in - /// - /// Section 7.4 of RFC 6455. - /// - /// - /// - /// - /// A that represents the reason for the close. - /// - /// - /// The size must be 123 bytes or less in UTF-8. - /// - /// - /// - /// - /// is less than 1000 or greater than 4999. - /// - /// - /// -or- - /// - /// - /// The size of is greater than 123 bytes. - /// - /// - /// - /// - /// is 1010 (mandatory extension). - /// - /// - /// -or- - /// - /// - /// is 1005 (no status) and there is reason. - /// - /// - /// -or- - /// - /// - /// could not be UTF-8-encoded. - /// - /// - /// - /// The underlying has failed to stop. - /// - [Obsolete ("This method will be removed.")] - public void Stop (ushort code, string reason) - { - if (!code.IsCloseStatusCode ()) { - var msg = "Less than 1000 or greater than 4999."; - throw new ArgumentOutOfRangeException ("code", msg); - } - - if (code == 1010) { - var msg = "1010 cannot be used."; - throw new ArgumentException (msg, "code"); - } - - if (!reason.IsNullOrEmpty ()) { - if (code == 1005) { - var msg = "1005 cannot be used."; - throw new ArgumentException (msg, "code"); - } - - byte[] bytes; - if (!reason.TryGetUTF8EncodedBytes (out bytes)) { - var msg = "It could not be UTF-8-encoded."; - throw new ArgumentException (msg, "reason"); - } - - if (bytes.Length > 123) { - var msg = "Its size is greater than 123 bytes."; - throw new ArgumentOutOfRangeException ("reason", msg); - } - } - - stop (code, reason); - } - /// /// Stops receiving incoming handshake requests and closes each connection /// with the specified code and reason. From daf4e9e4880baa374a67175caac1afafdcdae21a Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 26 Aug 2021 19:37:43 +0900 Subject: [PATCH 3796/6294] [Modify] Remove it --- websocket-sharp/Server/WebSocketServer.cs | 74 ----------------------- 1 file changed, 74 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index b6510adb8..ee9b27b93 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -1330,80 +1330,6 @@ public void Stop () stop (1001, String.Empty); } - /// - /// Stops receiving incoming handshake requests and closes each connection - /// with the specified code and reason. - /// - /// - /// - /// One of the enum values. - /// - /// - /// It represents the status code indicating the reason for the close. - /// - /// - /// - /// - /// A that represents the reason for the close. - /// - /// - /// The size must be 123 bytes or less in UTF-8. - /// - /// - /// - /// - /// is - /// . - /// - /// - /// -or- - /// - /// - /// is - /// and there is reason. - /// - /// - /// -or- - /// - /// - /// could not be UTF-8-encoded. - /// - /// - /// - /// The size of is greater than 123 bytes. - /// - /// - /// The underlying has failed to stop. - /// - [Obsolete ("This method will be removed.")] - public void Stop (CloseStatusCode code, string reason) - { - if (code == CloseStatusCode.MandatoryExtension) { - var msg = "MandatoryExtension cannot be used."; - throw new ArgumentException (msg, "code"); - } - - if (!reason.IsNullOrEmpty ()) { - if (code == CloseStatusCode.NoStatus) { - var msg = "NoStatus cannot be used."; - throw new ArgumentException (msg, "code"); - } - - byte[] bytes; - if (!reason.TryGetUTF8EncodedBytes (out bytes)) { - var msg = "It could not be UTF-8-encoded."; - throw new ArgumentException (msg, "reason"); - } - - if (bytes.Length > 123) { - var msg = "Its size is greater than 123 bytes."; - throw new ArgumentOutOfRangeException ("reason", msg); - } - } - - stop ((ushort) code, reason); - } - #endregion } } From 6670006ef755d5c10b6c42dcf667fa07a7f4d878 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 27 Aug 2021 20:06:45 +0900 Subject: [PATCH 3797/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketServer.cs | 33 ++++++++++++----------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index ee9b27b93..cc7cbc9af 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -930,21 +930,6 @@ private void startReceiving () private void stop (ushort code, string reason) { - if (_state == ServerState.Ready) { - _log.Info ("The server is not started."); - return; - } - - if (_state == ServerState.ShuttingDown) { - _log.Info ("The server is shutting down."); - return; - } - - if (_state == ServerState.Stop) { - _log.Info ("The server has already stopped."); - return; - } - lock (_sync) { if (_state == ServerState.ShuttingDown) { _log.Info ("The server is shutting down."); @@ -1327,6 +1312,24 @@ public void Start () /// public void Stop () { + if (_state == ServerState.Ready) { + _log.Info ("The server is not started."); + + return; + } + + if (_state == ServerState.ShuttingDown) { + _log.Info ("The server is shutting down."); + + return; + } + + if (_state == ServerState.Stop) { + _log.Info ("The server has already stopped."); + + return; + } + stop (1001, String.Empty); } From 7dbdeafca2b74f673b1b32501fb03469256934c2 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 27 Aug 2021 20:09:35 +0900 Subject: [PATCH 3798/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index cc7cbc9af..24398677e 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -1307,6 +1307,10 @@ public void Start () /// /// Stops receiving incoming handshake requests. /// + /// + /// This method does nothing if the server is not started, + /// it is shutting down, or it has already stopped. + /// /// /// The underlying has failed to stop. /// From 04308645b50d65b713a37cc7078c55db91df5522 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 28 Aug 2021 21:02:53 +0900 Subject: [PATCH 3799/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketServer.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 24398677e..db4c73d03 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -933,11 +933,13 @@ private void stop (ushort code, string reason) lock (_sync) { if (_state == ServerState.ShuttingDown) { _log.Info ("The server is shutting down."); + return; } if (_state == ServerState.Stop) { _log.Info ("The server has already stopped."); + return; } @@ -946,11 +948,13 @@ private void stop (ushort code, string reason) try { var threw = false; + try { stopReceiving (5000); } catch { threw = true; + throw; } finally { From 911d58872def8867878a0b030cefafcbc5c17ec4 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 28 Aug 2021 21:06:51 +0900 Subject: [PATCH 3800/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketServer.cs | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index db4c73d03..600717617 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -870,16 +870,6 @@ private void receiveRequest () private void start (ServerSslConfiguration sslConfig) { - if (_state == ServerState.Start) { - _log.Info ("The server has already started."); - return; - } - - if (_state == ServerState.ShuttingDown) { - _log.Warn ("The server is shutting down."); - return; - } - lock (_sync) { if (_state == ServerState.Start) { _log.Info ("The server has already started."); @@ -1292,6 +1282,18 @@ public bool RemoveWebSocketService (string path) /// public void Start () { + if (_state == ServerState.Start) { + _log.Info ("The server has already started."); + + return; + } + + if (_state == ServerState.ShuttingDown) { + _log.Warn ("The server is shutting down."); + + return; + } + ServerSslConfiguration sslConfig = null; if (_secure) { From 99415050639963275154639c8335ac1114e46e09 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 29 Aug 2021 21:05:38 +0900 Subject: [PATCH 3801/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketServer.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 600717617..2c6f3af28 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -873,11 +873,13 @@ private void start (ServerSslConfiguration sslConfig) lock (_sync) { if (_state == ServerState.Start) { _log.Info ("The server has already started."); + return; } if (_state == ServerState.ShuttingDown) { _log.Warn ("The server is shutting down."); + return; } @@ -885,11 +887,13 @@ private void start (ServerSslConfiguration sslConfig) _realmInUse = getRealm (); _services.Start (); + try { startReceiving (); } catch { _services.Stop (1011, String.Empty); + throw; } From 835fdaeacb1c5819e46c7ea71a1e1e4444883c50 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 30 Aug 2021 20:12:04 +0900 Subject: [PATCH 3802/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketServer.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 2c6f3af28..edc207a39 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -914,11 +914,13 @@ private void startReceiving () } catch (Exception ex) { var msg = "The underlying listener has failed to start."; + throw new InvalidOperationException (msg, ex); } _receiveThread = new Thread (new ThreadStart (receiveRequest)); _receiveThread.IsBackground = true; + _receiveThread.Start (); } From f11a8c30c273f740d60436f303132b808ede4093 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 30 Aug 2021 20:17:16 +0900 Subject: [PATCH 3803/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketServer.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index edc207a39..abe476638 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -822,8 +822,10 @@ private void receiveRequest () { while (true) { TcpClient cl = null; + try { cl = _listener.AcceptTcpClient (); + ThreadPool.QueueUserWorkItem ( state => { try { @@ -845,6 +847,7 @@ private void receiveRequest () catch (SocketException ex) { if (_state == ServerState.ShuttingDown) { _log.Info ("The underlying listener is stopped."); + break; } From 1a5f82ce01bfc50acac7312c81f9c304f2669847 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 31 Aug 2021 19:36:49 +0900 Subject: [PATCH 3804/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketServer.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index abe476638..d3fe45b98 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -784,34 +784,42 @@ private void processRequest (TcpListenerWebSocketContext context) { if (!authenticateClient (context)) { context.Close (HttpStatusCode.Forbidden); + return; } var uri = context.RequestUri; + if (uri == null) { context.Close (HttpStatusCode.BadRequest); + return; } if (!_allowForwardedRequest) { if (uri.Port != _port) { context.Close (HttpStatusCode.BadRequest); + return; } if (!checkHostNameForRequest (uri.DnsSafeHost)) { context.Close (HttpStatusCode.NotFound); + return; } } var path = uri.AbsolutePath; + if (path.IndexOfAny (new[] { '%', '+' }) > -1) path = HttpUtility.UrlDecode (path, Encoding.UTF8); WebSocketServiceHost host; + if (!_services.InternalTryGetServiceHost (path, out host)) { context.Close (HttpStatusCode.NotImplemented); + return; } From e87dd17b5f3910bfc08c44a7ff868d3b62cee10b Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 31 Aug 2021 19:39:34 +0900 Subject: [PATCH 3805/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketServer.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index d3fe45b98..55a55f5c4 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -986,6 +986,7 @@ private void stopReceiving (int millisecondsTimeout) } catch (Exception ex) { var msg = "The underlying listener has failed to stop."; + throw new InvalidOperationException (msg, ex); } From 4b75dab0dc95692314b3ab3484dd332428799af5 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 1 Sep 2021 19:32:11 +0900 Subject: [PATCH 3806/6294] [Modify] Remove it --- websocket-sharp/Server/WebSocketServer.cs | 95 ----------------------- 1 file changed, 95 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 55a55f5c4..f0b9ba164 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -1014,101 +1014,6 @@ private static bool tryCreateUri ( #region Public Methods - /// - /// Adds a WebSocket service with the specified behavior, path, - /// and delegate. - /// - /// - /// - /// A that represents an absolute path to - /// the service to add. - /// - /// - /// / is trimmed from the end of the string if present. - /// - /// - /// - /// - /// A Func<TBehavior> delegate. - /// - /// - /// It invokes the method called when creating a new session - /// instance for the service. - /// - /// - /// The method must create a new instance of the specified - /// behavior class and return it. - /// - /// - /// - /// - /// The type of the behavior for the service. - /// - /// - /// It must inherit the class. - /// - /// - /// - /// - /// is . - /// - /// - /// -or- - /// - /// - /// is . - /// - /// - /// - /// - /// is an empty string. - /// - /// - /// -or- - /// - /// - /// is not an absolute path. - /// - /// - /// -or- - /// - /// - /// includes either or both - /// query and fragment components. - /// - /// - /// -or- - /// - /// - /// is already in use. - /// - /// - [Obsolete ("This method will be removed. Use added one instead.")] - public void AddWebSocketService ( - string path, Func creator - ) - where TBehavior : WebSocketBehavior - { - if (path == null) - throw new ArgumentNullException ("path"); - - if (creator == null) - throw new ArgumentNullException ("creator"); - - if (path.Length == 0) - throw new ArgumentException ("An empty string.", "path"); - - if (path[0] != '/') - throw new ArgumentException ("Not an absolute path.", "path"); - - if (path.IndexOfAny (new[] { '?', '#' }) > -1) { - var msg = "It includes either or both query and fragment components."; - throw new ArgumentException (msg, "path"); - } - - _services.Add (path, creator); - } - /// /// Adds a WebSocket service with the specified behavior and path. /// From 0ceb093c3c625ead83391d6146dfafe5e3fc1b24 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 1 Sep 2021 19:33:45 +0900 Subject: [PATCH 3807/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketServer.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index f0b9ba164..2aa35ce97 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -1064,10 +1064,10 @@ private static bool tryCreateUri ( /// is already in use. /// /// - public void AddWebSocketService (string path) - where TBehaviorWithNew : WebSocketBehavior, new () + public void AddWebSocketService (string path) + where TBehavior : WebSocketBehavior, new () { - _services.AddService (path, null); + _services.AddService (path, null); } /// From 5d01c16a4bf0a35dc0b7dbd2a6e50e29a5336bca Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 2 Sep 2021 19:18:55 +0900 Subject: [PATCH 3808/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 2aa35ce97..3b3ac421a 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -1026,7 +1026,7 @@ private static bool tryCreateUri ( /// / is trimmed from the end of the string if present. /// /// - /// + /// /// /// The type of the behavior for the service. /// From 25ee637c5a4ce1190003d806c635b7bafcbfb08f Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 2 Sep 2021 19:21:26 +0900 Subject: [PATCH 3809/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 3b3ac421a..588dc99ea 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -1019,7 +1019,7 @@ private static bool tryCreateUri ( /// /// /// - /// A that represents an absolute path to + /// A that specifies an absolute path to /// the service to add. /// /// From 91fa15564e1a78e099302f5b1705fcc52bb91de4 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 3 Sep 2021 19:42:35 +0900 Subject: [PATCH 3810/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketServer.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 588dc99ea..7ff26f863 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -1131,12 +1131,12 @@ public void AddWebSocketService (string path) /// is already in use. /// /// - public void AddWebSocketService ( - string path, Action initializer + public void AddWebSocketService ( + string path, Action initializer ) - where TBehaviorWithNew : WebSocketBehavior, new () + where TBehavior : WebSocketBehavior, new () { - _services.AddService (path, initializer); + _services.AddService (path, initializer); } /// From 8d5d06e7af53048f76e66f1d705ec53900390902 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 3 Sep 2021 19:44:20 +0900 Subject: [PATCH 3811/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 7ff26f863..63d416e6f 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -1085,7 +1085,7 @@ public void AddWebSocketService (string path) /// /// /// - /// An Action<TBehaviorWithNew> delegate or + /// An Action<TBehavior> delegate or /// if not needed. /// /// @@ -1093,7 +1093,7 @@ public void AddWebSocketService (string path) /// a new session instance for the service. /// /// - /// + /// /// /// The type of the behavior for the service. /// From 2c87161976d89ace0fa50d764ca7d7d98841ee27 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 3 Sep 2021 19:45:42 +0900 Subject: [PATCH 3812/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 63d416e6f..84b08f02b 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -1076,7 +1076,7 @@ public void AddWebSocketService (string path) /// /// /// - /// A that represents an absolute path to + /// A that specifies an absolute path to /// the service to add. /// /// From e326553b350bc8a31d55751111d245a1864a77e1 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 4 Sep 2021 19:49:59 +0900 Subject: [PATCH 3813/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 84b08f02b..631e09341 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -1152,7 +1152,7 @@ public void AddWebSocketService ( /// /// /// - /// A that represents an absolute path to + /// A that specifies an absolute path to /// the service to remove. /// /// From f6576503064e549023f669b5f06d7dbbcd3d1f06 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 5 Sep 2021 20:38:22 +0900 Subject: [PATCH 3814/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketServer.cs | 24 +++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 631e09341..7a59a4578 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -1205,18 +1205,6 @@ public bool RemoveWebSocketService (string path) /// public void Start () { - if (_state == ServerState.Start) { - _log.Info ("The server has already started."); - - return; - } - - if (_state == ServerState.ShuttingDown) { - _log.Warn ("The server is shutting down."); - - return; - } - ServerSslConfiguration sslConfig = null; if (_secure) { @@ -1230,6 +1218,18 @@ public void Start () } } + if (_state == ServerState.Start) { + _log.Info ("The server has already started."); + + return; + } + + if (_state == ServerState.ShuttingDown) { + _log.Warn ("The server is shutting down."); + + return; + } + start (sslConfig); } From e5d6a30235ba7bc63aaff63b8d8ba2d4ad859bae Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 6 Sep 2021 20:13:43 +0900 Subject: [PATCH 3815/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketServer.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 7a59a4578..5ca326f40 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -102,6 +102,7 @@ static WebSocketServer () public WebSocketServer () { var addr = System.Net.IPAddress.Any; + init (addr.ToString (), addr, 80, false); } From df5758a9138b22d10107d3166f971b7f399535c3 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 6 Sep 2021 20:17:27 +0900 Subject: [PATCH 3816/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 5ca326f40..abe01fe56 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -108,7 +108,7 @@ public WebSocketServer () /// /// Initializes a new instance of the class - /// with the specified . + /// with the specified port. /// /// /// From 02c986811ff4a4d9c76ceedc2d2dbb9dad3f0121 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 6 Sep 2021 20:20:42 +0900 Subject: [PATCH 3817/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index abe01fe56..2c5a02ee3 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -120,8 +120,8 @@ public WebSocketServer () /// /// /// - /// An that represents the number of the port - /// on which to listen. + /// An that specifies the number of the port on which + /// to listen. /// /// /// is less than 1 or greater than 65535. From 7db92ec3501d5c80a3d06bd0416f058907b3f76d Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 7 Sep 2021 19:35:00 +0900 Subject: [PATCH 3818/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketServer.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 2c5a02ee3..1d2c0f1cc 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -178,19 +178,22 @@ public WebSocketServer (string url) Uri uri; string msg; + if (!tryCreateUri (url, out uri, out msg)) throw new ArgumentException (msg, "url"); var host = uri.DnsSafeHost; - var addr = host.ToIPAddress (); + if (addr == null) { msg = "The host part could not be converted to an IP address."; + throw new ArgumentException (msg, "url"); } if (!addr.IsLocal ()) { msg = "The IP address of the host is not a local IP address."; + throw new ArgumentException (msg, "url"); } From c084840b614348505f24772ea6a39f4f5da592f1 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 7 Sep 2021 19:36:52 +0900 Subject: [PATCH 3819/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 1d2c0f1cc..373d3981e 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -133,7 +133,7 @@ public WebSocketServer (int port) /// /// Initializes a new instance of the class - /// with the specified . + /// with the specified URL. /// /// /// From ed1c82ee069511678fc118c67eda7067bdd3faaa Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 7 Sep 2021 19:41:43 +0900 Subject: [PATCH 3820/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 373d3981e..6901c26cb 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -138,8 +138,7 @@ public WebSocketServer (int port) /// /// /// The new instance listens for incoming handshake requests on - /// the IP address of the host of and - /// the port of . + /// the IP address and port of . /// /// /// Either port 80 or 443 is used if includes From 5914aadddd46c44a9126551ed5040b1e8abf6696 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 7 Sep 2021 19:43:52 +0900 Subject: [PATCH 3821/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 6901c26cb..14368a3d0 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -151,7 +151,7 @@ public WebSocketServer (int port) /// /// /// - /// A that represents the WebSocket URL of the server. + /// A that specifies the WebSocket URL of the server. /// /// /// is . From 43bd7d27210c89dd902e7ab28398dea52e14cdfb Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 8 Sep 2021 19:21:36 +0900 Subject: [PATCH 3822/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketServer.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 14368a3d0..89ff6fff4 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -221,11 +221,13 @@ public WebSocketServer (string url) public WebSocketServer (int port, bool secure) { if (!port.IsPortNumber ()) { - var msg = "Less than 1 or greater than 65535."; + var msg = "It is less than 1 or greater than 65535."; + throw new ArgumentOutOfRangeException ("port", msg); } var addr = System.Net.IPAddress.Any; + init (addr.ToString (), addr, port, secure); } From 4989f2da6652c046197e418c16e723849290579d Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 8 Sep 2021 19:23:25 +0900 Subject: [PATCH 3823/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 89ff6fff4..7da23f110 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -201,7 +201,7 @@ public WebSocketServer (string url) /// /// Initializes a new instance of the class - /// with the specified and . + /// with the specified port and boolean if secure or not. /// /// /// The new instance listens for incoming handshake requests on From 661f06ba3b4b85b89b8de03a837419f1bc9fbbb7 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 8 Sep 2021 19:25:31 +0900 Subject: [PATCH 3824/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 7da23f110..eff22fb6b 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -208,8 +208,8 @@ public WebSocketServer (string url) /// and . /// /// - /// An that represents the number of the port - /// on which to listen. + /// An that specifies the number of the port on which + /// to listen. /// /// /// A : true if the new instance provides From e29a0e7c539ad75df784d47232029d9ab9b5d1fe Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 9 Sep 2021 19:07:17 +0900 Subject: [PATCH 3825/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index eff22fb6b..dda647798 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -233,7 +233,7 @@ public WebSocketServer (int port, bool secure) /// /// Initializes a new instance of the class - /// with the specified and . + /// with the specified IP address and port. /// /// /// From f6db8ed83cb27d7f646b3a83966dc17d3782f0e9 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 9 Sep 2021 19:08:59 +0900 Subject: [PATCH 3826/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index dda647798..4dc39c3cb 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -245,8 +245,8 @@ public WebSocketServer (int port, bool secure) /// /// /// - /// A that represents the local - /// IP address on which to listen. + /// A that specifies the local IP + /// address on which to listen. /// /// /// An that represents the number of the port From 50f57b38c9cc911d74d32a495914c2e60640decd Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 9 Sep 2021 19:10:25 +0900 Subject: [PATCH 3827/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 4dc39c3cb..c29a63278 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -249,8 +249,8 @@ public WebSocketServer (int port, bool secure) /// address on which to listen. /// /// - /// An that represents the number of the port - /// on which to listen. + /// An that specifies the number of the port on which + /// to listen. /// /// /// is . From bd6b3d45d1448232879a0ef439832761812a164b Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 10 Sep 2021 19:08:59 +0900 Subject: [PATCH 3828/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketServer.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index c29a63278..d02e8bea4 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -305,7 +305,8 @@ public WebSocketServer (System.Net.IPAddress address, int port, bool secure) throw new ArgumentException ("Not a local IP address.", "address"); if (!port.IsPortNumber ()) { - var msg = "Less than 1 or greater than 65535."; + var msg = "It is less than 1 or greater than 65535."; + throw new ArgumentOutOfRangeException ("port", msg); } From 3558b4e02df27b47dc53e68532c9e9b0454dd502 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 10 Sep 2021 19:11:12 +0900 Subject: [PATCH 3829/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketServer.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index d02e8bea4..28e8c2442 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -301,8 +301,11 @@ public WebSocketServer (System.Net.IPAddress address, int port, bool secure) if (address == null) throw new ArgumentNullException ("address"); - if (!address.IsLocal ()) - throw new ArgumentException ("Not a local IP address.", "address"); + if (!address.IsLocal ()) { + var msg = "It is not a local IP address."; + + throw new ArgumentException (msg, "address"); + } if (!port.IsPortNumber ()) { var msg = "It is less than 1 or greater than 65535."; From 11160d77046ec3148ba8dbc7efff95b81460bb96 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 11 Sep 2021 20:37:57 +0900 Subject: [PATCH 3830/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 28e8c2442..8526cbe9b 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -268,8 +268,7 @@ public WebSocketServer (System.Net.IPAddress address, int port) /// /// Initializes a new instance of the class - /// with the specified , , - /// and . + /// with the specified IP address, port, and boolean if secure or not. /// /// /// The new instance listens for incoming handshake requests on From 69432752941cde12b125b6df82cab788c9765a85 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 12 Sep 2021 13:59:54 +0900 Subject: [PATCH 3831/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 8526cbe9b..b334dff9e 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -275,8 +275,8 @@ public WebSocketServer (System.Net.IPAddress address, int port) /// and . /// /// - /// A that represents the local - /// IP address on which to listen. + /// A that specifies the local IP + /// address on which to listen. /// /// /// An that represents the number of the port From a8013aa875ccab845c57543565e46055fb23907f Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 12 Sep 2021 14:02:33 +0900 Subject: [PATCH 3832/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index b334dff9e..2f0a255a7 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -279,8 +279,8 @@ public WebSocketServer (System.Net.IPAddress address, int port) /// address on which to listen. /// /// - /// An that represents the number of the port - /// on which to listen. + /// An that specifies the number of the port on which + /// to listen. /// /// /// A : true if the new instance provides From 213c6ec12ace10d573048f3836f613e41e4b3db4 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 13 Sep 2021 20:11:51 +0900 Subject: [PATCH 3833/6294] [Modify] Edit it --- websocket-sharp/Server/HttpServer.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 7c65fd70c..c1965295b 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -323,8 +323,8 @@ public System.Net.IPAddress Address { /// Gets or sets the scheme used to authenticate the clients. /// /// - /// The set operation does nothing if the server has already - /// started or it is shutting down. + /// The set operation does nothing if the server has already started or + /// it is shutting down. /// /// /// From c53c6c99c3103770b9cd049ac6df49ef1992757e Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 13 Sep 2021 20:21:37 +0900 Subject: [PATCH 3834/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 2f0a255a7..176935b8e 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -323,8 +323,8 @@ public WebSocketServer (System.Net.IPAddress address, int port, bool secure) /// Gets the IP address of the server. ///
/// - /// A that represents the local - /// IP address on which to listen for incoming handshake requests. + /// A that represents the local IP + /// address on which to listen for incoming handshake requests. /// public System.Net.IPAddress Address { get { From 85b410a0ab29e712e29f98bceebc8b68b7b0e8dc Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 14 Sep 2021 19:21:14 +0900 Subject: [PATCH 3835/6294] [Modify] Edit it --- websocket-sharp/Server/HttpServer.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index c1965295b..3123c0689 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -310,8 +310,8 @@ public HttpServer (System.Net.IPAddress address, int port, bool secure) /// Gets the IP address of the server. ///
/// - /// A that represents the local - /// IP address on which to listen for incoming requests. + /// A that represents the local IP + /// address on which to listen for incoming requests. /// public System.Net.IPAddress Address { get { From 9587f9d9c524d649b96ef184135b7cb874fe36b7 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 14 Sep 2021 19:23:27 +0900 Subject: [PATCH 3836/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 176935b8e..27bfc3a01 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -435,8 +435,8 @@ public bool IsSecure { } /// - /// Gets or sets a value indicating whether the server cleans up - /// the inactive sessions periodically. + /// Gets or sets a value indicating whether the server cleans up the + /// inactive sessions periodically. /// /// /// The set operation does nothing if the server has already started or From 0e61497a0ba5ea71ed32a490232fa4be5284826f Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 14 Sep 2021 19:26:15 +0900 Subject: [PATCH 3837/6294] [Modify] Edit it --- websocket-sharp/Server/HttpServer.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 3123c0689..bfcf56f94 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -480,17 +480,17 @@ public bool IsSecure { } /// - /// Gets or sets a value indicating whether the server cleans up - /// the inactive sessions periodically. + /// Gets or sets a value indicating whether the server cleans up the + /// inactive sessions periodically. /// /// - /// The set operation does nothing if the server has already - /// started or it is shutting down. + /// The set operation does nothing if the server has already started or + /// it is shutting down. /// /// /// - /// true if the server cleans up the inactive sessions - /// every 60 seconds; otherwise, false. + /// true if the server cleans up the inactive sessions every + /// 60 seconds; otherwise, false. /// /// /// The default value is true. From 4ac774d08457435db40eff05e6f755b6e9acb5cd Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 14 Sep 2021 19:27:43 +0900 Subject: [PATCH 3838/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 27bfc3a01..3c66a60ba 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -480,8 +480,8 @@ public Logger Log { /// Gets the port of the server. ///
/// - /// An that represents the number of the port - /// on which to listen for incoming handshake requests. + /// An that represents the number of the port on which + /// to listen for incoming handshake requests. /// public int Port { get { From 493ae16ca038a3c0762ed1642fe6b10fcc5292c1 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 15 Sep 2021 19:20:41 +0900 Subject: [PATCH 3839/6294] [Modify] Edit it --- websocket-sharp/Server/HttpServer.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index bfcf56f94..c76f212e2 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -525,8 +525,8 @@ public Logger Log { /// Gets the port of the server. ///
/// - /// An that represents the number of the port - /// on which to listen for incoming requests. + /// An that represents the number of the port on which + /// to listen for incoming requests. /// public int Port { get { From 22bacd87bae0791ee9cb3d8ce77dd5d4ab49c7dc Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 15 Sep 2021 19:25:12 +0900 Subject: [PATCH 3840/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 3c66a60ba..5b74674bb 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -537,12 +537,12 @@ public string Realm { ///
/// /// - /// You should set this property to true if you would - /// like to resolve to wait for socket in TIME_WAIT state. + /// You should set this property to true if you would like to + /// resolve to wait for socket in TIME_WAIT state. /// /// - /// The set operation does nothing if the server has already - /// started or it is shutting down. + /// The set operation does nothing if the server has already started + /// or it is shutting down. /// /// /// From 6381d104483e72dd81f638d3b1636fb4eff8840b Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 15 Sep 2021 19:27:25 +0900 Subject: [PATCH 3841/6294] [Modify] Edit it --- websocket-sharp/Server/HttpServer.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index c76f212e2..9f45f84b2 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -582,12 +582,12 @@ public string Realm { ///
/// /// - /// You should set this property to true if you would - /// like to resolve to wait for socket in TIME_WAIT state. + /// You should set this property to true if you would like to + /// resolve to wait for socket in TIME_WAIT state. /// /// - /// The set operation does nothing if the server has already - /// started or it is shutting down. + /// The set operation does nothing if the server has already started + /// or it is shutting down. /// /// /// From 57e443c657353c23d893d6928007ceaa2f277a40 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 16 Sep 2021 19:23:06 +0900 Subject: [PATCH 3842/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 5b74674bb..be0dcb442 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -601,8 +601,8 @@ public ServerSslConfiguration SslConfiguration { } /// - /// Gets or sets the delegate used to find the credentials - /// for an identity. + /// Gets or sets the delegate used to find the credentials for + /// an identity. /// /// /// @@ -622,7 +622,7 @@ public ServerSslConfiguration SslConfiguration { /// if not needed. /// /// - /// That delegate invokes the method called for finding + /// The delegate invokes the method called for finding /// the credentials used to authenticate a client. /// /// From c62095c82abfbfb9306ef68315be6df543f988eb Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 16 Sep 2021 19:27:01 +0900 Subject: [PATCH 3843/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index be0dcb442..60f853a70 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -679,12 +679,12 @@ public TimeSpan WaitTime { } /// - /// Gets the management function for the WebSocket services - /// provided by the server. + /// Gets the management function for the WebSocket services provided by + /// the server. /// /// - /// A that manages - /// the WebSocket services provided by the server. + /// A that manages the WebSocket + /// services provided by the server. /// public WebSocketServiceManager WebSocketServices { get { From 711672203266f33f0510baec6f25b9e36ab706b6 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 16 Sep 2021 19:29:34 +0900 Subject: [PATCH 3844/6294] [Modify] Edit it --- websocket-sharp/Server/HttpServer.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 9f45f84b2..47f5b73ec 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -724,12 +724,12 @@ public TimeSpan WaitTime { } /// - /// Gets the management function for the WebSocket services - /// provided by the server. + /// Gets the management function for the WebSocket services provided by + /// the server. /// /// - /// A that manages - /// the WebSocket services provided by the server. + /// A that manages the WebSocket + /// services provided by the server. /// public WebSocketServiceManager WebSocketServices { get { From 81c053192263b35cd6136ca2802f4f20b69d7588 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 17 Sep 2021 19:33:31 +0900 Subject: [PATCH 3845/6294] [Modify] Edit it --- websocket-sharp/Server/HttpServer.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 47f5b73ec..310653263 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -535,22 +535,22 @@ public int Port { } /// - /// Gets or sets the realm used for authentication. + /// Gets or sets the name of the realm associated with the server. /// /// /// - /// "SECRET AREA" is used as the realm if the value is + /// "SECRET AREA" is used as the name of the realm if the value is /// or an empty string. /// /// - /// The set operation does nothing if the server has - /// already started or it is shutting down. + /// The set operation does nothing if the server has already started + /// or it is shutting down. /// /// /// /// - /// A that represents the name of - /// the realm or . + /// A that represents the name of the realm or + /// . /// /// /// The default value is . From e9f2b730a8433ba5cb931fb618da60f4ca85cfc2 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 18 Sep 2021 20:59:18 +0900 Subject: [PATCH 3846/6294] [Modify] Edit it --- websocket-sharp/Server/HttpServer.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 310653263..f6cde2166 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -646,8 +646,8 @@ public ServerSslConfiguration SslConfiguration { } /// - /// Gets or sets the delegate used to find the credentials - /// for an identity. + /// Gets or sets the delegate used to find the credentials for + /// an identity. /// /// /// From a86667378fb68f5e9c52545d004c6bee3f401ff7 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 19 Sep 2021 20:58:08 +0900 Subject: [PATCH 3847/6294] [Modify] 2021 --- websocket-sharp/Server/WebSocketServer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 60f853a70..a42f99212 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -4,7 +4,7 @@ * * The MIT License * - * Copyright (c) 2012-2015 sta.blockhead + * Copyright (c) 2012-2021 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From fa70e8d059e52c24eac6d89c7a2fb7748dc57701 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 20 Sep 2021 20:14:55 +0900 Subject: [PATCH 3848/6294] [Modify] Remove it --- .../Server/WebSocketServiceManager.cs | 27 ------------------- 1 file changed, 27 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index ee1256fcf..27acb0078 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -406,33 +406,6 @@ private bool canSet (out string message) #region Internal Methods - internal void Add (string path, Func creator) - where TBehavior : WebSocketBehavior - { - path = path.TrimSlashFromEnd (); - - lock (_sync) { - WebSocketServiceHost host; - if (_hosts.TryGetValue (path, out host)) - throw new ArgumentException ("Already in use.", "path"); - - host = new WebSocketServiceHost ( - path, creator, null, _log - ); - - if (!_clean) - host.KeepClean = false; - - if (_waitTime != host.WaitTime) - host.WaitTime = _waitTime; - - if (_state == ServerState.Start) - host.Start (); - - _hosts.Add (path, host); - } - } - internal bool InternalTryGetServiceHost ( string path, out WebSocketServiceHost host ) From cf50e89001317d36fbb1bb9561c524f43b5f23c5 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 21 Sep 2021 19:43:53 +0900 Subject: [PATCH 3849/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketServiceManager.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index 27acb0078..cc9dc7455 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -515,10 +515,11 @@ public void AddService ( throw new ArgumentException ("An empty string.", "path"); if (path[0] != '/') - throw new ArgumentException ("Not an absolute path.", "path"); + throw new ArgumentException ("It is not an absolute path.", "path"); if (path.IndexOfAny (new[] { '?', '#' }) > -1) { var msg = "It includes either or both query and fragment components."; + throw new ArgumentException (msg, "path"); } @@ -526,8 +527,9 @@ public void AddService ( lock (_sync) { WebSocketServiceHost host; + if (_hosts.TryGetValue (path, out host)) - throw new ArgumentException ("Already in use.", "path"); + throw new ArgumentException ("It is already in use.", "path"); host = new WebSocketServiceHost ( path, () => new TBehavior (), initializer, _log From 7fe5be25358dec2577c41e47791ff565845651a9 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 21 Sep 2021 19:46:33 +0900 Subject: [PATCH 3850/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketServiceManager.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index cc9dc7455..57ff84a34 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -528,8 +528,11 @@ public void AddService ( lock (_sync) { WebSocketServiceHost host; - if (_hosts.TryGetValue (path, out host)) - throw new ArgumentException ("It is already in use.", "path"); + if (_hosts.TryGetValue (path, out host)) { + var msg = "It is already in use."; + + throw new ArgumentException (msg, "path"); + } host = new WebSocketServiceHost ( path, () => new TBehavior (), initializer, _log From 7ed4bb34e34ed62d5f3dbe1e351fe9ac216d1f17 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 22 Sep 2021 19:26:18 +0900 Subject: [PATCH 3851/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketServiceManager.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index 57ff84a34..acc16f5e6 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -514,8 +514,11 @@ public void AddService ( if (path.Length == 0) throw new ArgumentException ("An empty string.", "path"); - if (path[0] != '/') - throw new ArgumentException ("It is not an absolute path.", "path"); + if (path[0] != '/') { + var msg = "It is not an absolute path."; + + throw new ArgumentException (msg, "path"); + } if (path.IndexOfAny (new[] { '?', '#' }) > -1) { var msg = "It includes either or both query and fragment components."; From 439889c9a11f34426bdd2c0cb3b4f28269533d3e Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 22 Sep 2021 19:28:38 +0900 Subject: [PATCH 3852/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServiceManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index acc16f5e6..b2921d863 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -448,7 +448,7 @@ internal void Stop (ushort code, string reason) ///
/// /// - /// A that represents an absolute path to + /// A that specifies an absolute path to /// the service to add. /// /// From 21b16251c76b6e26ccb9347de70d76f3fee26ed2 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 22 Sep 2021 19:31:46 +0900 Subject: [PATCH 3853/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServiceManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index b2921d863..553bb19de 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -481,7 +481,7 @@ internal void Stop (ushort code, string reason) /// /// /// - /// is empty. + /// is an empty string. /// /// /// -or- From 8becafea92f3ce64cdaa11507b6a69ff8b4005bb Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 23 Sep 2021 19:31:52 +0900 Subject: [PATCH 3854/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketServiceManager.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index 553bb19de..b80826dcb 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -963,17 +963,21 @@ public bool RemoveService (string path) if (path.Length == 0) throw new ArgumentException ("An empty string.", "path"); - if (path[0] != '/') - throw new ArgumentException ("Not an absolute path.", "path"); + if (path[0] != '/') { + var msg = "It is not an absolute path."; + + throw new ArgumentException (msg, "path"); + } if (path.IndexOfAny (new[] { '?', '#' }) > -1) { var msg = "It includes either or both query and fragment components."; + throw new ArgumentException (msg, "path"); } path = path.TrimSlashFromEnd (); - WebSocketServiceHost host; + lock (_sync) { if (!_hosts.TryGetValue (path, out host)) return false; From 92ffd3af814fb3fb0257b3cee372f1f7ff368502 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 24 Sep 2021 19:19:33 +0900 Subject: [PATCH 3855/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServiceManager.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index b80826dcb..2344de9ea 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -927,7 +927,7 @@ public void Clear () /// /// /// - /// A that represents an absolute path to + /// A that specifies an absolute path to /// the service to remove. /// /// @@ -939,7 +939,7 @@ public void Clear () /// /// /// - /// is empty. + /// is an empty string. /// /// /// -or- From b270b548ab3b727aedb9c1576d754a6d3346418b Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 25 Sep 2021 20:43:05 +0900 Subject: [PATCH 3856/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketServiceManager.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index 2344de9ea..a3a2654b1 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -1047,11 +1047,15 @@ public bool TryGetServiceHost (string path, out WebSocketServiceHost host) if (path.Length == 0) throw new ArgumentException ("An empty string.", "path"); - if (path[0] != '/') - throw new ArgumentException ("Not an absolute path.", "path"); + if (path[0] != '/') { + var msg = "It is not an absolute path."; + + throw new ArgumentException (msg, "path"); + } if (path.IndexOfAny (new[] { '?', '#' }) > -1) { var msg = "It includes either or both query and fragment components."; + throw new ArgumentException (msg, "path"); } From e4b960dcf825fe419f9d58eff9764705d07d7f88 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 26 Sep 2021 20:51:52 +0900 Subject: [PATCH 3857/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServiceManager.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index a3a2654b1..6bd718614 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -1001,7 +1001,7 @@ public bool RemoveService (string path) /// /// /// - /// A that represents an absolute path to + /// A that specifies an absolute path to /// the service to find. /// /// @@ -1023,7 +1023,7 @@ public bool RemoveService (string path) /// /// /// - /// is empty. + /// is an empty string. /// /// /// -or- From 9e7c43cb8b6b5a615cb853c3d0924d9b35083d77 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 27 Sep 2021 20:11:29 +0900 Subject: [PATCH 3858/6294] [Modify] Remove it --- .../Server/WebSocketServiceManager.cs | 29 ------------------- 1 file changed, 29 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index 6bd718614..4b6018d0e 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -554,35 +554,6 @@ public void AddService ( } } - /// - /// Sends to every client in the WebSocket services. - /// - /// - /// An array of that represents the binary data to send. - /// - /// - /// The current state of the manager is not Start. - /// - /// - /// is . - /// - [Obsolete ("This method will be removed.")] - public void Broadcast (byte[] data) - { - if (_state != ServerState.Start) { - var msg = "The current state of the manager is not Start."; - throw new InvalidOperationException (msg); - } - - if (data == null) - throw new ArgumentNullException ("data"); - - if (data.LongLength <= WebSocket.FragmentLength) - broadcast (Opcode.Binary, data, null); - else - broadcast (Opcode.Binary, new MemoryStream (data), null); - } - /// /// Sends to every client in the WebSocket services. /// From af895d5f331cffb693e8b6c482f81c5da5d56430 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 27 Sep 2021 20:12:41 +0900 Subject: [PATCH 3859/6294] [Modify] Remove it --- .../Server/WebSocketServiceManager.cs | 38 ------------------- 1 file changed, 38 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index 4b6018d0e..1ebe75b9f 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -554,44 +554,6 @@ public void AddService ( } } - /// - /// Sends to every client in the WebSocket services. - /// - /// - /// A that represents the text data to send. - /// - /// - /// The current state of the manager is not Start. - /// - /// - /// is . - /// - /// - /// could not be UTF-8-encoded. - /// - [Obsolete ("This method will be removed.")] - public void Broadcast (string data) - { - if (_state != ServerState.Start) { - var msg = "The current state of the manager is not Start."; - throw new InvalidOperationException (msg); - } - - if (data == null) - throw new ArgumentNullException ("data"); - - byte[] bytes; - if (!data.TryGetUTF8EncodedBytes (out bytes)) { - var msg = "It could not be UTF-8-encoded."; - throw new ArgumentException (msg, "data"); - } - - if (bytes.LongLength <= WebSocket.FragmentLength) - broadcast (Opcode.Text, bytes, null); - else - broadcast (Opcode.Text, new MemoryStream (bytes), null); - } - /// /// Sends asynchronously to every client in /// the WebSocket services. From 00b94045dc4320bc207911173f15c95d92170a34 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 28 Sep 2021 19:08:12 +0900 Subject: [PATCH 3860/6294] [Modify] Remove it --- .../Server/WebSocketServiceManager.cs | 42 ------------------- 1 file changed, 42 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index 1ebe75b9f..47a3dd378 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -554,48 +554,6 @@ public void AddService ( } } - /// - /// Sends asynchronously to every client in - /// the WebSocket services. - /// - /// - /// This method does not wait for the send to be complete. - /// - /// - /// An array of that represents the binary data to send. - /// - /// - /// - /// An delegate or - /// if not needed. - /// - /// - /// The delegate invokes the method called when the send is complete. - /// - /// - /// - /// The current state of the manager is not Start. - /// - /// - /// is . - /// - [Obsolete ("This method will be removed.")] - public void BroadcastAsync (byte[] data, Action completed) - { - if (_state != ServerState.Start) { - var msg = "The current state of the manager is not Start."; - throw new InvalidOperationException (msg); - } - - if (data == null) - throw new ArgumentNullException ("data"); - - if (data.LongLength <= WebSocket.FragmentLength) - broadcastAsync (Opcode.Binary, data, completed); - else - broadcastAsync (Opcode.Binary, new MemoryStream (data), completed); - } - /// /// Sends asynchronously to every client in /// the WebSocket services. From 0958cef33a4a0baa061c0388e461ccafee258708 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 28 Sep 2021 19:09:27 +0900 Subject: [PATCH 3861/6294] [Modify] Remove it --- .../Server/WebSocketServiceManager.cs | 51 ------------------- 1 file changed, 51 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index 47a3dd378..3ee37b5cf 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -554,57 +554,6 @@ public void AddService ( } } - /// - /// Sends asynchronously to every client in - /// the WebSocket services. - /// - /// - /// This method does not wait for the send to be complete. - /// - /// - /// A that represents the text data to send. - /// - /// - /// - /// An delegate or - /// if not needed. - /// - /// - /// The delegate invokes the method called when the send is complete. - /// - /// - /// - /// The current state of the manager is not Start. - /// - /// - /// is . - /// - /// - /// could not be UTF-8-encoded. - /// - [Obsolete ("This method will be removed.")] - public void BroadcastAsync (string data, Action completed) - { - if (_state != ServerState.Start) { - var msg = "The current state of the manager is not Start."; - throw new InvalidOperationException (msg); - } - - if (data == null) - throw new ArgumentNullException ("data"); - - byte[] bytes; - if (!data.TryGetUTF8EncodedBytes (out bytes)) { - var msg = "It could not be UTF-8-encoded."; - throw new ArgumentException (msg, "data"); - } - - if (bytes.LongLength <= WebSocket.FragmentLength) - broadcastAsync (Opcode.Text, bytes, completed); - else - broadcastAsync (Opcode.Text, new MemoryStream (bytes), completed); - } - /// /// Sends the data from asynchronously to /// every client in the WebSocket services. From 2dd3fa139d69815e3189c3407f828a2904dfc13c Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 28 Sep 2021 19:11:08 +0900 Subject: [PATCH 3862/6294] [Modify] Remove it --- .../Server/WebSocketServiceManager.cs | 94 ------------------- 1 file changed, 94 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index 3ee37b5cf..d6453165a 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -554,100 +554,6 @@ public void AddService ( } } - /// - /// Sends the data from asynchronously to - /// every client in the WebSocket services. - /// - /// - /// - /// The data is sent as the binary data. - /// - /// - /// This method does not wait for the send to be complete. - /// - /// - /// - /// A instance from which to read the data to send. - /// - /// - /// An that specifies the number of bytes to send. - /// - /// - /// - /// An delegate or - /// if not needed. - /// - /// - /// The delegate invokes the method called when the send is complete. - /// - /// - /// - /// The current state of the manager is not Start. - /// - /// - /// is . - /// - /// - /// - /// cannot be read. - /// - /// - /// -or- - /// - /// - /// is less than 1. - /// - /// - /// -or- - /// - /// - /// No data could be read from . - /// - /// - [Obsolete ("This method will be removed.")] - public void BroadcastAsync (Stream stream, int length, Action completed) - { - if (_state != ServerState.Start) { - var msg = "The current state of the manager is not Start."; - throw new InvalidOperationException (msg); - } - - if (stream == null) - throw new ArgumentNullException ("stream"); - - if (!stream.CanRead) { - var msg = "It cannot be read."; - throw new ArgumentException (msg, "stream"); - } - - if (length < 1) { - var msg = "Less than 1."; - throw new ArgumentException (msg, "length"); - } - - var bytes = stream.ReadBytes (length); - - var len = bytes.Length; - if (len == 0) { - var msg = "No data could be read from it."; - throw new ArgumentException (msg, "stream"); - } - - if (len < length) { - _log.Warn ( - String.Format ( - "Only {0} byte(s) of data could be read from the stream.", - len - ) - ); - } - - if (len <= WebSocket.FragmentLength) - broadcastAsync (Opcode.Binary, bytes, completed); - else - broadcastAsync (Opcode.Binary, new MemoryStream (bytes), completed); - } - /// /// Sends a ping to every client in the WebSocket services. /// From f4241368a8fc1fbd9bc1285ff924a19f91f5191b Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 29 Sep 2021 19:14:26 +0900 Subject: [PATCH 3863/6294] [Modify] Remove it --- .../Server/WebSocketServiceManager.cs | 27 ------------------- 1 file changed, 27 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index d6453165a..b410a45ed 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -554,33 +554,6 @@ public void AddService ( } } - /// - /// Sends a ping to every client in the WebSocket services. - /// - /// - /// - /// A Dictionary<string, Dictionary<string, bool>>. - /// - /// - /// It represents a collection of pairs of a service path and another - /// collection of pairs of a session ID and a value indicating whether - /// a pong has been received from the client within a time. - /// - /// - /// - /// The current state of the manager is not Start. - /// - [Obsolete ("This method will be removed.")] - public Dictionary> Broadping () - { - if (_state != ServerState.Start) { - var msg = "The current state of the manager is not Start."; - throw new InvalidOperationException (msg); - } - - return broadping (WebSocketFrame.EmptyPingBytes, _waitTime); - } - /// /// Sends a ping with to every client in /// the WebSocket services. From 9b8ce2b9134a617cbab075ac9127f78151fd5b56 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 29 Sep 2021 19:16:38 +0900 Subject: [PATCH 3864/6294] [Modify] Remove it --- .../Server/WebSocketServiceManager.cs | 57 ------------------- 1 file changed, 57 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index b410a45ed..d30f46550 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -554,63 +554,6 @@ public void AddService ( } } - /// - /// Sends a ping with to every client in - /// the WebSocket services. - /// - /// - /// - /// A Dictionary<string, Dictionary<string, bool>>. - /// - /// - /// It represents a collection of pairs of a service path and another - /// collection of pairs of a session ID and a value indicating whether - /// a pong has been received from the client within a time. - /// - /// - /// - /// - /// A that represents the message to send. - /// - /// - /// The size must be 125 bytes or less in UTF-8. - /// - /// - /// - /// The current state of the manager is not Start. - /// - /// - /// could not be UTF-8-encoded. - /// - /// - /// The size of is greater than 125 bytes. - /// - [Obsolete ("This method will be removed.")] - public Dictionary> Broadping (string message) - { - if (_state != ServerState.Start) { - var msg = "The current state of the manager is not Start."; - throw new InvalidOperationException (msg); - } - - if (message.IsNullOrEmpty ()) - return broadping (WebSocketFrame.EmptyPingBytes, _waitTime); - - byte[] bytes; - if (!message.TryGetUTF8EncodedBytes (out bytes)) { - var msg = "It could not be UTF-8-encoded."; - throw new ArgumentException (msg, "message"); - } - - if (bytes.Length > 125) { - var msg = "Its size is greater than 125 bytes."; - throw new ArgumentOutOfRangeException ("message", msg); - } - - var frame = WebSocketFrame.CreatePingFrame (bytes, false); - return broadping (frame.ToArray (), _waitTime); - } - /// /// Removes all WebSocket services managed by the manager. /// From 6b2fa7ab88cb6e7600dce1655cb982395a045bb6 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 30 Sep 2021 20:02:29 +0900 Subject: [PATCH 3865/6294] [Modify] Remove it --- websocket-sharp/Server/WebSocketServiceManager.cs | 7 ------- 1 file changed, 7 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index d30f46550..fac080c0e 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -352,13 +352,6 @@ private void broadcast (Opcode opcode, Stream stream, Action completed) } } - private void broadcastAsync (Opcode opcode, byte[] data, Action completed) - { - ThreadPool.QueueUserWorkItem ( - state => broadcast (opcode, data, completed) - ); - } - private void broadcastAsync (Opcode opcode, Stream stream, Action completed) { ThreadPool.QueueUserWorkItem ( From ff89f96a0dee4b53f7ea1832ffad5d5ed97394b5 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 30 Sep 2021 20:03:31 +0900 Subject: [PATCH 3866/6294] [Modify] Remove it --- websocket-sharp/Server/WebSocketServiceManager.cs | 7 ------- 1 file changed, 7 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index fac080c0e..514f5f35a 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -352,13 +352,6 @@ private void broadcast (Opcode opcode, Stream stream, Action completed) } } - private void broadcastAsync (Opcode opcode, Stream stream, Action completed) - { - ThreadPool.QueueUserWorkItem ( - state => broadcast (opcode, stream, completed) - ); - } - private Dictionary> broadping ( byte[] frameAsBytes, TimeSpan timeout ) From 53864513ba80d6be4fede7fa1b186af9d9f99e5a Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 30 Sep 2021 20:04:44 +0900 Subject: [PATCH 3867/6294] [Modify] Remove it --- .../Server/WebSocketServiceManager.cs | 26 ------------------- 1 file changed, 26 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index 514f5f35a..030feeb8e 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -297,32 +297,6 @@ public TimeSpan WaitTime { #region Private Methods - private void broadcast (Opcode opcode, byte[] data, Action completed) - { - var cache = new Dictionary (); - - try { - foreach (var host in Hosts) { - if (_state != ServerState.Start) { - _log.Error ("The server is shutting down."); - break; - } - - host.Sessions.Broadcast (opcode, data, cache); - } - - if (completed != null) - completed (); - } - catch (Exception ex) { - _log.Error (ex.Message); - _log.Debug (ex.ToString ()); - } - finally { - cache.Clear (); - } - } - private void broadcast (Opcode opcode, Stream stream, Action completed) { var cache = new Dictionary (); From 01714eb27478352fd60698a05aab15978c77b54b Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 30 Sep 2021 20:05:54 +0900 Subject: [PATCH 3868/6294] [Modify] Remove it --- .../Server/WebSocketServiceManager.cs | 29 ------------------- 1 file changed, 29 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index 030feeb8e..e4905c952 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -297,35 +297,6 @@ public TimeSpan WaitTime { #region Private Methods - private void broadcast (Opcode opcode, Stream stream, Action completed) - { - var cache = new Dictionary (); - - try { - foreach (var host in Hosts) { - if (_state != ServerState.Start) { - _log.Error ("The server is shutting down."); - break; - } - - host.Sessions.Broadcast (opcode, stream, cache); - } - - if (completed != null) - completed (); - } - catch (Exception ex) { - _log.Error (ex.Message); - _log.Debug (ex.ToString ()); - } - finally { - foreach (var cached in cache.Values) - cached.Dispose (); - - cache.Clear (); - } - } - private Dictionary> broadping ( byte[] frameAsBytes, TimeSpan timeout ) From 464db404c76c2965ab54662b44e5702b9b71fbc9 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 1 Oct 2021 19:13:30 +0900 Subject: [PATCH 3869/6294] [Modify] Remove it --- .../Server/WebSocketServiceManager.cs | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index e4905c952..ad7c2ee94 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -297,25 +297,6 @@ public TimeSpan WaitTime { #region Private Methods - private Dictionary> broadping ( - byte[] frameAsBytes, TimeSpan timeout - ) - { - var ret = new Dictionary> (); - - foreach (var host in Hosts) { - if (_state != ServerState.Start) { - _log.Error ("The server is shutting down."); - break; - } - - var res = host.Sessions.Broadping (frameAsBytes, timeout); - ret.Add (host.Path, res); - } - - return ret; - } - private bool canSet (out string message) { message = null; From 510defe622b6feb607b8fcf9a56e24218c611c8e Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 1 Oct 2021 19:15:56 +0900 Subject: [PATCH 3870/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketServiceManager.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index ad7c2ee94..b05105bc2 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -303,11 +303,13 @@ private bool canSet (out string message) if (_state == ServerState.Start) { message = "The server has already started."; + return false; } if (_state == ServerState.ShuttingDown) { message = "The server is shutting down."; + return false; } From d541737c2e53302b6ac0aa116ddbb1f5f0ce7a04 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 2 Oct 2021 20:28:17 +0900 Subject: [PATCH 3871/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketServiceManager.cs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index b05105bc2..7e5ada1a5 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -189,15 +189,12 @@ public bool KeepClean { } set { - string msg; - if (!canSet (out msg)) { - _log.Warn (msg); - return; - } - lock (_sync) { + string msg; + if (!canSet (out msg)) { _log.Warn (msg); + return; } From b9fe231a93c03671a8e5e553c3e38cf9585f4650 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 3 Oct 2021 20:55:54 +0900 Subject: [PATCH 3872/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServiceManager.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index 7e5ada1a5..c1ea2b139 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -180,8 +180,13 @@ public WebSocketServiceHost this[string path] { /// it is shutting down. /// /// - /// true if the inactive sessions are cleaned up every 60 seconds; - /// otherwise, false. + /// + /// true if the inactive sessions are cleaned up every 60 + /// seconds; otherwise, false. + /// + /// + /// The default value is true. + /// /// public bool KeepClean { get { From 6c172f78437fab41f0b09d2a393ad8382873e326 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 3 Oct 2021 20:59:40 +0900 Subject: [PATCH 3873/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketServiceManager.cs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index c1ea2b139..7191eabd2 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -275,15 +275,12 @@ public TimeSpan WaitTime { if (value <= TimeSpan.Zero) throw new ArgumentOutOfRangeException ("value", "Zero or less."); - string msg; - if (!canSet (out msg)) { - _log.Warn (msg); - return; - } - lock (_sync) { + string msg; + if (!canSet (out msg)) { _log.Warn (msg); + return; } From f9380683f8321916a13fc291d35140bb304aa17f Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 4 Oct 2021 20:05:53 +0900 Subject: [PATCH 3874/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketServiceManager.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index 7191eabd2..2cb868f10 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -272,8 +272,11 @@ public TimeSpan WaitTime { } set { - if (value <= TimeSpan.Zero) - throw new ArgumentOutOfRangeException ("value", "Zero or less."); + if (value <= TimeSpan.Zero) { + var msg = "It is zero or less."; + + throw new ArgumentOutOfRangeException ("value", msg); + } lock (_sync) { string msg; From 163fc26bfcfe02f4b0c15c999608048b59a32b64 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 4 Oct 2021 20:10:43 +0900 Subject: [PATCH 3875/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServiceManager.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index 2cb868f10..46c7a831e 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -253,15 +253,20 @@ public int SessionCount { } /// - /// Gets or sets the time to wait for the response to the WebSocket Ping or - /// Close. + /// Gets or sets the time to wait for the response to the WebSocket Ping + /// or Close. /// /// /// The set operation does nothing if the server has already started or /// it is shutting down. /// /// - /// A to wait for the response. + /// + /// A to wait for the response. + /// + /// + /// The default value is the same as 1 second. + /// /// /// /// The value specified for a set operation is zero or less. From 8f1efb750061eddbba14af0510bd2769d5fdea9d Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 5 Oct 2021 19:19:52 +0900 Subject: [PATCH 3876/6294] [Modify] Rename it --- websocket-sharp/Server/WebSocketServiceManager.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index 46c7a831e..3db91d9b6 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -47,7 +47,7 @@ public class WebSocketServiceManager { #region Private Fields - private volatile bool _clean; + private volatile bool _keepClean; private Dictionary _hosts; private Logger _log; private volatile ServerState _state; @@ -62,7 +62,7 @@ internal WebSocketServiceManager (Logger log) { _log = log; - _clean = true; + _keepClean = true; _hosts = new Dictionary (); _state = ServerState.Ready; _sync = ((ICollection) _hosts).SyncRoot; @@ -190,7 +190,7 @@ public WebSocketServiceHost this[string path] { /// public bool KeepClean { get { - return _clean; + return _keepClean; } set { @@ -206,7 +206,7 @@ public bool KeepClean { foreach (var host in _hosts.Values) host.KeepClean = value; - _clean = value; + _keepClean = value; } } } @@ -462,7 +462,7 @@ public void AddService ( path, () => new TBehavior (), initializer, _log ); - if (!_clean) + if (!_keepClean) host.KeepClean = false; if (_waitTime != host.WaitTime) From 18818f6362c5e1926bce84b6c45fb2036f9676e5 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 5 Oct 2021 19:21:48 +0900 Subject: [PATCH 3877/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketServiceManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index 3db91d9b6..443ac3946 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -47,8 +47,8 @@ public class WebSocketServiceManager { #region Private Fields - private volatile bool _keepClean; private Dictionary _hosts; + private volatile bool _keepClean; private Logger _log; private volatile ServerState _state; private object _sync; From c4fd537ad759f272a5316501e745aac4b2d7300b Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 5 Oct 2021 19:22:27 +0900 Subject: [PATCH 3878/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketServiceManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index 443ac3946..4f1927592 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -62,8 +62,8 @@ internal WebSocketServiceManager (Logger log) { _log = log; - _keepClean = true; _hosts = new Dictionary (); + _keepClean = true; _state = ServerState.Ready; _sync = ((ICollection) _hosts).SyncRoot; _waitTime = TimeSpan.FromSeconds (1); From 98f477ab089fc083cb43b6f5fb521633ed6d3d29 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 6 Oct 2021 19:34:34 +0900 Subject: [PATCH 3879/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketServiceManager.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index 4f1927592..985821b0a 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -156,15 +156,20 @@ public WebSocketServiceHost this[string path] { if (path.Length == 0) throw new ArgumentException ("An empty string.", "path"); - if (path[0] != '/') - throw new ArgumentException ("Not an absolute path.", "path"); + if (path[0] != '/') { + var msg = "It is not an absolute path."; + + throw new ArgumentException (msg, "path"); + } if (path.IndexOfAny (new[] { '?', '#' }) > -1) { var msg = "It includes either or both query and fragment components."; + throw new ArgumentException (msg, "path"); } WebSocketServiceHost host; + InternalTryGetServiceHost (path, out host); return host; From 902a8d5fc025a3c280bfe119f9b862bb793e0006 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 6 Oct 2021 19:38:04 +0900 Subject: [PATCH 3880/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServiceManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index 985821b0a..3edde6772 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -132,7 +132,7 @@ public IEnumerable Hosts { /// /// /// - /// is empty. + /// is an empty string. /// /// /// -or- From 2b7238d7ca1ffdc50b8306b3569b3719f09c31e2 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 6 Oct 2021 19:40:07 +0900 Subject: [PATCH 3881/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServiceManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index 3edde6772..ef49ad3a4 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -120,7 +120,7 @@ public IEnumerable Hosts { /// /// /// - /// A that represents an absolute path to + /// A that specifies an absolute path to /// the service to find. /// /// From 9a4f2ee93357e59fd254e3bc2915b90d15dda7fe Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 7 Oct 2021 19:21:20 +0900 Subject: [PATCH 3882/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServiceManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index ef49ad3a4..0eae3fed4 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -114,7 +114,7 @@ public IEnumerable Hosts { /// if not found. /// /// - /// The host instance provides the function to access + /// The service host instance provides the function to access /// the information in the service. /// /// From e91ec7a0254943fca11f372fbe75e7e54e5436d3 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 7 Oct 2021 19:22:46 +0900 Subject: [PATCH 3883/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServiceManager.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index 0eae3fed4..4fb4baa2c 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -106,7 +106,8 @@ public IEnumerable Hosts { } /// - /// Gets the host instance for a WebSocket service with the specified path. + /// Gets the service host instance for a WebSocket service with + /// the specified path. /// /// /// From 87682067ce2b7151c519403d7edfa4b417a51152 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 7 Oct 2021 19:25:53 +0900 Subject: [PATCH 3884/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServiceManager.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index 4fb4baa2c..3a7284bfb 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -87,7 +87,7 @@ public int Count { } /// - /// Gets the host instances for the WebSocket services. + /// Gets the service host instances for the WebSocket services. /// /// /// @@ -95,7 +95,7 @@ public int Count { /// /// /// It provides an enumerator which supports the iteration over - /// the collection of the host instances. + /// the collection of the service host instances. /// /// public IEnumerable Hosts { From 43a0b57efede80966562f2ca56cdab7442f59563 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 8 Oct 2021 19:17:29 +0900 Subject: [PATCH 3885/6294] [Modify] Remove it --- .../Server/WebSocketServiceManager.cs | 22 ------------------- 1 file changed, 22 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index 3a7284bfb..238229584 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -236,28 +236,6 @@ public IEnumerable Paths { } } - /// - /// Gets the total number of the sessions in the WebSocket services. - /// - /// - /// An that represents the total number of - /// the sessions in the services. - /// - [Obsolete ("This property will be removed.")] - public int SessionCount { - get { - var cnt = 0; - foreach (var host in Hosts) { - if (_state != ServerState.Start) - break; - - cnt += host.Sessions.Count; - } - - return cnt; - } - } - /// /// Gets or sets the time to wait for the response to the WebSocket Ping /// or Close. From 48dafac5a1a12a8986b2ed7c4441de11a859429a Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 9 Oct 2021 20:55:51 +0900 Subject: [PATCH 3886/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketServiceManager.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index 238229584..597b68517 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -472,6 +472,7 @@ public void Clear () lock (_sync) { hosts = _hosts.Values.ToList (); + _hosts.Clear (); } From a7d0732c4d204d2e67c60ed0d8cfd879f4c30536 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 10 Oct 2021 20:54:45 +0900 Subject: [PATCH 3887/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServiceManager.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index 597b68517..af17a20d2 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -560,7 +560,7 @@ public bool RemoveService (string path) } /// - /// Tries to get the host instance for a WebSocket service with + /// Tries to get the service host instance for a WebSocket service with /// the specified path. /// /// @@ -582,7 +582,7 @@ public bool RemoveService (string path) /// instance or if not found. /// /// - /// The host instance provides the function to access + /// The service host instance provides the function to access /// the information in the service. /// /// From c496cbbe3bc93df3bb11cb275f1466a52c03182b Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 11 Oct 2021 21:23:40 +0900 Subject: [PATCH 3888/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServiceManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index af17a20d2..ad02b5b71 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -41,7 +41,7 @@ namespace WebSocketSharp.Server /// /// /// This class manages the WebSocket services provided by - /// the or . + /// the or class. /// public class WebSocketServiceManager { From 7d635849b3397177c58622e735427702348fded7 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 11 Oct 2021 21:25:51 +0900 Subject: [PATCH 3889/6294] [Modify] 2021 --- websocket-sharp/Server/WebSocketServiceManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index ad02b5b71..de9e796ba 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -4,7 +4,7 @@ * * The MIT License * - * Copyright (c) 2012-2015 sta.blockhead + * Copyright (c) 2012-2021 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From 55f01e43bedb2363fa447f44938a41514a35516e Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 12 Oct 2021 19:28:56 +0900 Subject: [PATCH 3890/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServiceHost.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceHost.cs b/websocket-sharp/Server/WebSocketServiceHost.cs index 1da76427a..4ca2e17f2 100644 --- a/websocket-sharp/Server/WebSocketServiceHost.cs +++ b/websocket-sharp/Server/WebSocketServiceHost.cs @@ -164,8 +164,8 @@ public WebSocketSessionManager Sessions { public abstract Type BehaviorType { get; } /// - /// Gets or sets the time to wait for the response to the WebSocket Ping or - /// Close. + /// Gets or sets the time to wait for the response to the WebSocket Ping + /// or Close. /// /// /// The set operation does nothing if the service has already started or From bcc74af86ba43b1c170565e47e7e292edb5e7a8a Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 12 Oct 2021 19:36:33 +0900 Subject: [PATCH 3891/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServiceHost.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceHost.cs b/websocket-sharp/Server/WebSocketServiceHost.cs index 4ca2e17f2..fd976b73d 100644 --- a/websocket-sharp/Server/WebSocketServiceHost.cs +++ b/websocket-sharp/Server/WebSocketServiceHost.cs @@ -107,8 +107,8 @@ protected Logger Log { #region Public Properties /// - /// Gets or sets a value indicating whether the service cleans up - /// the inactive sessions periodically. + /// Gets or sets a value indicating whether the service cleans up the + /// inactive sessions periodically. /// /// /// The set operation does nothing if the service has already started or From 8188f4b3f84a608c0ab7f1366c9b58ed754b590f Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 13 Oct 2021 19:21:47 +0900 Subject: [PATCH 3892/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServiceHost.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServiceHost.cs b/websocket-sharp/Server/WebSocketServiceHost.cs index fd976b73d..677291f47 100644 --- a/websocket-sharp/Server/WebSocketServiceHost.cs +++ b/websocket-sharp/Server/WebSocketServiceHost.cs @@ -155,7 +155,7 @@ public WebSocketSessionManager Sessions { } /// - /// Gets the of the behavior of the service. + /// Gets the type of the behavior of the service. /// /// /// A that represents the type of the behavior of From 9e77ed9770261446f6dc4663565d65250fd2b608 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 13 Oct 2021 19:29:33 +0900 Subject: [PATCH 3893/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServiceHost.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceHost.cs b/websocket-sharp/Server/WebSocketServiceHost.cs index 677291f47..4d4540436 100644 --- a/websocket-sharp/Server/WebSocketServiceHost.cs +++ b/websocket-sharp/Server/WebSocketServiceHost.cs @@ -59,14 +59,16 @@ public abstract class WebSocketServiceHost #region Protected Constructors /// - /// Initializes a new instance of the class - /// with the specified and . + /// Initializes a new instance of the + /// class with the specified path and logging function. /// /// - /// A that represents the absolute path to the service. + /// A that specifies the absolute path to + /// the service. /// /// - /// A that represents the logging function for the service. + /// A that specifies the logging function for + /// the service. /// protected WebSocketServiceHost (string path, Logger log) { From a3fda85b3e1f2393eceb0a216a1af73d6b309bb2 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 14 Oct 2021 19:09:08 +0900 Subject: [PATCH 3894/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServiceHost.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServiceHost.cs b/websocket-sharp/Server/WebSocketServiceHost.cs index 4d4540436..b416f94ad 100644 --- a/websocket-sharp/Server/WebSocketServiceHost.cs +++ b/websocket-sharp/Server/WebSocketServiceHost.cs @@ -41,7 +41,7 @@ namespace WebSocketSharp.Server /// /// Exposes the methods and properties used to access the information in /// a WebSocket service provided by the or - /// . + /// class. /// /// /// This class is an abstract class. From 9f88c864ed64f1e179197cb06b1ae46b5d39b2f4 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 14 Oct 2021 19:10:28 +0900 Subject: [PATCH 3895/6294] [Modify] 2021 --- websocket-sharp/Server/WebSocketServiceHost.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServiceHost.cs b/websocket-sharp/Server/WebSocketServiceHost.cs index b416f94ad..dd138bc3f 100644 --- a/websocket-sharp/Server/WebSocketServiceHost.cs +++ b/websocket-sharp/Server/WebSocketServiceHost.cs @@ -4,7 +4,7 @@ * * The MIT License * - * Copyright (c) 2012-2017 sta.blockhead + * Copyright (c) 2012-2021 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From c4f54dc876f1f39a0166c64e6683b835de66ebe1 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 15 Oct 2021 19:13:41 +0900 Subject: [PATCH 3896/6294] [Modify] Remove it --- websocket-sharp/Server/WebSocketServiceHost`1.cs | 7 ------- 1 file changed, 7 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceHost`1.cs b/websocket-sharp/Server/WebSocketServiceHost`1.cs index d4ca6a2d1..037e7e783 100644 --- a/websocket-sharp/Server/WebSocketServiceHost`1.cs +++ b/websocket-sharp/Server/WebSocketServiceHost`1.cs @@ -41,13 +41,6 @@ internal class WebSocketServiceHost : WebSocketServiceHost #region Internal Constructors - internal WebSocketServiceHost ( - string path, Func creator, Logger log - ) - : this (path, creator, null, log) - { - } - internal WebSocketServiceHost ( string path, Func creator, From 41c674ca2d9088b54cc1afa8b80beba6d8d0f93c Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 15 Oct 2021 19:16:00 +0900 Subject: [PATCH 3897/6294] [Modify] With new --- websocket-sharp/Server/WebSocketServiceHost`1.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServiceHost`1.cs b/websocket-sharp/Server/WebSocketServiceHost`1.cs index 037e7e783..2eb59e829 100644 --- a/websocket-sharp/Server/WebSocketServiceHost`1.cs +++ b/websocket-sharp/Server/WebSocketServiceHost`1.cs @@ -31,7 +31,7 @@ namespace WebSocketSharp.Server { internal class WebSocketServiceHost : WebSocketServiceHost - where TBehavior : WebSocketBehavior + where TBehavior : WebSocketBehavior, new () { #region Private Fields From 7f21d2fae4fbace5a54a7bea2ea7a167e83e8840 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 15 Oct 2021 19:20:36 +0900 Subject: [PATCH 3898/6294] [Modify] Add it --- websocket-sharp/Server/WebSocketServiceHost`1.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/websocket-sharp/Server/WebSocketServiceHost`1.cs b/websocket-sharp/Server/WebSocketServiceHost`1.cs index 2eb59e829..c06dc0697 100644 --- a/websocket-sharp/Server/WebSocketServiceHost`1.cs +++ b/websocket-sharp/Server/WebSocketServiceHost`1.cs @@ -36,11 +36,20 @@ internal class WebSocketServiceHost : WebSocketServiceHost #region Private Fields private Func _creator; + private Action _initializer; #endregion #region Internal Constructors + internal WebSocketServiceHost ( + string path, Action initializer, Logger log + ) + : base (path, log) + { + _initializer = initializer; + } + internal WebSocketServiceHost ( string path, Func creator, From da702f9508563613cc2ad0fdeb835c0b73ec8713 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 16 Oct 2021 17:15:03 +0900 Subject: [PATCH 3899/6294] [Modify] Add it --- websocket-sharp/Server/WebSocketServiceHost`1.cs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/websocket-sharp/Server/WebSocketServiceHost`1.cs b/websocket-sharp/Server/WebSocketServiceHost`1.cs index c06dc0697..565d1426b 100644 --- a/websocket-sharp/Server/WebSocketServiceHost`1.cs +++ b/websocket-sharp/Server/WebSocketServiceHost`1.cs @@ -75,6 +75,20 @@ public override Type BehaviorType { #region Private Methods + private Func createCreator (Action initializer) + { + if (initializer == null) + return () => new TBehavior (); + + return () => { + var ret = new TBehavior (); + + initializer (ret); + + return ret; + }; + } + private Func createCreator ( Func creator, Action initializer ) From 4e1a9e034d6c7a81e17445c13188db61ac2eabe7 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 16 Oct 2021 17:17:18 +0900 Subject: [PATCH 3900/6294] [Modify] Use it --- websocket-sharp/Server/WebSocketServiceHost`1.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceHost`1.cs b/websocket-sharp/Server/WebSocketServiceHost`1.cs index 565d1426b..a93b43029 100644 --- a/websocket-sharp/Server/WebSocketServiceHost`1.cs +++ b/websocket-sharp/Server/WebSocketServiceHost`1.cs @@ -36,7 +36,6 @@ internal class WebSocketServiceHost : WebSocketServiceHost #region Private Fields private Func _creator; - private Action _initializer; #endregion @@ -47,7 +46,7 @@ internal WebSocketServiceHost ( ) : base (path, log) { - _initializer = initializer; + _creator = createCreator (initializer); } internal WebSocketServiceHost ( From d0f5e08a47a34a3d323e0fce46402658a609049b Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 17 Oct 2021 21:43:20 +0900 Subject: [PATCH 3901/6294] [Modify] Replace it --- websocket-sharp/Server/WebSocketServiceManager.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index de9e796ba..4242dcfbf 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -442,9 +442,7 @@ public void AddService ( throw new ArgumentException (msg, "path"); } - host = new WebSocketServiceHost ( - path, () => new TBehavior (), initializer, _log - ); + host = new WebSocketServiceHost (path, initializer, _log); if (!_keepClean) host.KeepClean = false; From 1c053760ee5bef707bda584f0769fc678d236d16 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 17 Oct 2021 21:44:41 +0900 Subject: [PATCH 3902/6294] [Modify] Remove it --- websocket-sharp/Server/WebSocketServiceHost`1.cs | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceHost`1.cs b/websocket-sharp/Server/WebSocketServiceHost`1.cs index a93b43029..6de2ab1ad 100644 --- a/websocket-sharp/Server/WebSocketServiceHost`1.cs +++ b/websocket-sharp/Server/WebSocketServiceHost`1.cs @@ -49,17 +49,6 @@ internal WebSocketServiceHost ( _creator = createCreator (initializer); } - internal WebSocketServiceHost ( - string path, - Func creator, - Action initializer, - Logger log - ) - : base (path, log) - { - _creator = createCreator (creator, initializer); - } - #endregion #region Public Properties From 6140cbbaa2cd05d5f75db8f9335007ad4f1f22aa Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 17 Oct 2021 21:45:27 +0900 Subject: [PATCH 3903/6294] [Modify] Remove it --- websocket-sharp/Server/WebSocketServiceHost`1.cs | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceHost`1.cs b/websocket-sharp/Server/WebSocketServiceHost`1.cs index 6de2ab1ad..8a9046e3f 100644 --- a/websocket-sharp/Server/WebSocketServiceHost`1.cs +++ b/websocket-sharp/Server/WebSocketServiceHost`1.cs @@ -77,21 +77,6 @@ private Func createCreator (Action initializer) }; } - private Func createCreator ( - Func creator, Action initializer - ) - { - if (initializer == null) - return creator; - - return () => { - var ret = creator (); - initializer (ret); - - return ret; - }; - } - #endregion #region Protected Methods From fe156936bd0d0ada4c581f0513a53ccc3c8f3959 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 18 Oct 2021 21:07:19 +0900 Subject: [PATCH 3904/6294] [Modify] Rename it --- websocket-sharp/Server/WebSocketServiceHost`1.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceHost`1.cs b/websocket-sharp/Server/WebSocketServiceHost`1.cs index 8a9046e3f..8cfebe7bd 100644 --- a/websocket-sharp/Server/WebSocketServiceHost`1.cs +++ b/websocket-sharp/Server/WebSocketServiceHost`1.cs @@ -46,7 +46,7 @@ internal WebSocketServiceHost ( ) : base (path, log) { - _creator = createCreator (initializer); + _creator = createSessionCreator (initializer); } #endregion @@ -63,7 +63,7 @@ public override Type BehaviorType { #region Private Methods - private Func createCreator (Action initializer) + private Func createSessionCreator (Action initializer) { if (initializer == null) return () => new TBehavior (); From e6f6692f5287eb672d8724d33b3d29e77d78c533 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 19 Oct 2021 19:19:40 +0900 Subject: [PATCH 3905/6294] [Modify] To be static --- websocket-sharp/Server/WebSocketServiceHost`1.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServiceHost`1.cs b/websocket-sharp/Server/WebSocketServiceHost`1.cs index 8cfebe7bd..559a1c3a1 100644 --- a/websocket-sharp/Server/WebSocketServiceHost`1.cs +++ b/websocket-sharp/Server/WebSocketServiceHost`1.cs @@ -63,7 +63,9 @@ public override Type BehaviorType { #region Private Methods - private Func createSessionCreator (Action initializer) + private static Func createSessionCreator ( + Action initializer + ) { if (initializer == null) return () => new TBehavior (); From b687e23c3c53afe7faff8826603a9ec66002064f Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 19 Oct 2021 19:21:29 +0900 Subject: [PATCH 3906/6294] [Modify] 2021 --- websocket-sharp/Server/WebSocketServiceHost`1.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServiceHost`1.cs b/websocket-sharp/Server/WebSocketServiceHost`1.cs index 559a1c3a1..f311251c0 100644 --- a/websocket-sharp/Server/WebSocketServiceHost`1.cs +++ b/websocket-sharp/Server/WebSocketServiceHost`1.cs @@ -4,7 +4,7 @@ * * The MIT License * - * Copyright (c) 2015-2017 sta.blockhead + * Copyright (c) 2015-2021 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From e4527a850a4c3a4a032ae353cb5fd148b36132d5 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 20 Oct 2021 19:34:52 +0900 Subject: [PATCH 3907/6294] [Modify] Remove it --- websocket-sharp/Server/WebSocketBehavior.cs | 7 ------- 1 file changed, 7 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index b5e8ffeb7..94f7219cb 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -457,13 +457,6 @@ private void onOpen (object sender, EventArgs e) internal void Start (WebSocketContext context, WebSocketSessionManager sessions) { - if (_websocket != null) { - _websocket.Log.Error ("A session instance cannot be reused."); - context.WebSocket.Close (HttpStatusCode.ServiceUnavailable); - - return; - } - _context = context; _sessions = sessions; From 610abae444e5799d5b037babfefb29e31d8d1202 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 20 Oct 2021 19:43:10 +0900 Subject: [PATCH 3908/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketBehavior.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 94f7219cb..c4621fd26 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -467,6 +467,7 @@ internal void Start (WebSocketContext context, WebSocketSessionManager sessions) _websocket.Protocol = _protocol; var waitTime = sessions.WaitTime; + if (waitTime != _websocket.WaitTime) _websocket.WaitTime = waitTime; From 6ef64b54de6659b18e91a4374de3f20c764a9b8c Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 21 Oct 2021 20:09:13 +0900 Subject: [PATCH 3909/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketBehavior.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index c4621fd26..9004d3761 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -455,7 +455,9 @@ private void onOpen (object sender, EventArgs e) #region Internal Methods - internal void Start (WebSocketContext context, WebSocketSessionManager sessions) + internal void Start ( + WebSocketContext context, WebSocketSessionManager sessions + ) { _context = context; _sessions = sessions; From e2da8302c849fb62a20081ab689d0270c6779416 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 21 Oct 2021 20:13:34 +0900 Subject: [PATCH 3910/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketBehavior.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 9004d3761..c3488d724 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -413,6 +413,7 @@ private string checkHandshakeRequest (WebSocketContext context) if (_cookiesValidator != null) { var req = context.CookieCollection; var res = context.WebSocket.CookieCollection; + if (!_cookiesValidator (req, res)) return "It includes no cookie or an invalid one."; } From 3ac538dde429e8d49391c86d9ee3fc8b938c739f Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 21 Oct 2021 20:16:11 +0900 Subject: [PATCH 3911/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketBehavior.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index c3488d724..1a64f45a7 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -427,6 +427,7 @@ private void onClose (object sender, CloseEventArgs e) return; _sessions.Remove (_id); + OnClose (e); } From 7d234b5ab86539f20befe205db811854207e2e30 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 21 Oct 2021 20:23:22 +0900 Subject: [PATCH 3912/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketBehavior.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 1a64f45a7..5a2652a3b 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -444,12 +444,15 @@ private void onMessage (object sender, MessageEventArgs e) private void onOpen (object sender, EventArgs e) { _id = _sessions.Add (this); + if (_id == null) { _websocket.Close (CloseStatusCode.Away); + return; } _startTime = DateTime.Now; + OnOpen (); } From 558dee93383e947fb02faba8a904348ee8db0e22 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 22 Oct 2021 19:36:00 +0900 Subject: [PATCH 3913/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketBehavior.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 5a2652a3b..fceb533ac 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -504,6 +504,7 @@ protected void Close () { if (_websocket == null) { var msg = "The session has not started yet."; + throw new InvalidOperationException (msg); } From 40e322efcd03ef8c0a27181f175b865069e821b0 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 22 Oct 2021 19:38:04 +0900 Subject: [PATCH 3914/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketBehavior.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index fceb533ac..20437f986 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -573,6 +573,7 @@ protected void Close (ushort code, string reason) { if (_websocket == null) { var msg = "The session has not started yet."; + throw new InvalidOperationException (msg); } From a682cf75bb583f623b7c468c961c4e16f9501ad6 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 22 Oct 2021 19:43:53 +0900 Subject: [PATCH 3915/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 20437f986..c424d32fc 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -521,7 +521,7 @@ protected void Close () /// /// /// - /// A that represents the status code indicating + /// A that specifies the status code indicating /// the reason for the close. /// /// @@ -532,7 +532,7 @@ protected void Close () /// /// /// - /// A that represents the reason for the close. + /// A that specifies the reason for the close. /// /// /// The size must be 123 bytes or less in UTF-8. From 853b3ed9362b5ba62359842a20d043a6cee582ff Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 22 Oct 2021 19:46:00 +0900 Subject: [PATCH 3916/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketBehavior.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index c424d32fc..676a7fc90 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -633,6 +633,7 @@ protected void Close (CloseStatusCode code, string reason) { if (_websocket == null) { var msg = "The session has not started yet."; + throw new InvalidOperationException (msg); } From f21d1f27aae634a6c2e2882c53d46392f3dbb899 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 22 Oct 2021 19:49:12 +0900 Subject: [PATCH 3917/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 676a7fc90..fd93d4123 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -593,12 +593,12 @@ protected void Close (ushort code, string reason) /// One of the enum values. /// /// - /// It represents the status code indicating the reason for the close. + /// It specifies the status code indicating the reason for the close. /// /// /// /// - /// A that represents the reason for the close. + /// A that specifies the reason for the close. /// /// /// The size must be 123 bytes or less in UTF-8. From 09050aff22511d69db28e2e6918166c149eeb6fd Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 23 Oct 2021 21:34:54 +0900 Subject: [PATCH 3918/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketBehavior.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index fd93d4123..bbbe0e358 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -659,6 +659,7 @@ protected void CloseAsync () { if (_websocket == null) { var msg = "The session has not started yet."; + throw new InvalidOperationException (msg); } From 044032690ca92d78c58902a8f061e0a15c183d75 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 23 Oct 2021 21:36:29 +0900 Subject: [PATCH 3919/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketBehavior.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index bbbe0e358..004350cc6 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -733,6 +733,7 @@ protected void CloseAsync (ushort code, string reason) { if (_websocket == null) { var msg = "The session has not started yet."; + throw new InvalidOperationException (msg); } From c46c8b8380640248ccc997107f328299dc4186ac Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 23 Oct 2021 21:40:02 +0900 Subject: [PATCH 3920/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 004350cc6..b13d784a9 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -681,7 +681,7 @@ protected void CloseAsync () /// /// /// - /// A that represents the status code indicating + /// A that specifies the status code indicating /// the reason for the close. /// /// @@ -692,7 +692,7 @@ protected void CloseAsync () /// /// /// - /// A that represents the reason for the close. + /// A that specifies the reason for the close. /// /// /// The size must be 123 bytes or less in UTF-8. From 3b3a3510a00399504b839caf7cb9e061feffd987 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 23 Oct 2021 21:41:03 +0900 Subject: [PATCH 3921/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketBehavior.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index b13d784a9..5dc2aff33 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -798,6 +798,7 @@ protected void CloseAsync (CloseStatusCode code, string reason) { if (_websocket == null) { var msg = "The session has not started yet."; + throw new InvalidOperationException (msg); } From 44109be29940f70017c4d8a24214a65aca688c60 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 23 Oct 2021 21:43:28 +0900 Subject: [PATCH 3922/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 5dc2aff33..f76a870b3 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -758,12 +758,12 @@ protected void CloseAsync (ushort code, string reason) /// One of the enum values. /// /// - /// It represents the status code indicating the reason for the close. + /// It specifies the status code indicating the reason for the close. /// /// /// /// - /// A that represents the reason for the close. + /// A that specifies the reason for the close. /// /// /// The size must be 123 bytes or less in UTF-8. From 659266067291b2069b6ee5280481e5e661fc9f2f Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 24 Oct 2021 22:24:53 +0900 Subject: [PATCH 3923/6294] [Modify] Remove it --- websocket-sharp/Server/WebSocketBehavior.cs | 28 --------------------- 1 file changed, 28 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index f76a870b3..ba3efd342 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -805,34 +805,6 @@ protected void CloseAsync (CloseStatusCode code, string reason) _websocket.CloseAsync (code, reason); } - /// - /// Calls the method with the specified message. - /// - /// - /// A that represents the error message. - /// - /// - /// An instance that represents the cause of - /// the error if present. - /// - /// - /// is . - /// - /// - /// is an empty string. - /// - [Obsolete ("This method will be removed.")] - protected void Error (string message, Exception exception) - { - if (message == null) - throw new ArgumentNullException ("message"); - - if (message.Length == 0) - throw new ArgumentException ("An empty string.", "message"); - - OnError (new ErrorEventArgs (message, exception)); - } - /// /// Called when the WebSocket connection for a session has been closed. /// From 63805dfdce2308d243f7e9d2dbffeb4aacd66a97 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 25 Oct 2021 21:02:28 +0900 Subject: [PATCH 3924/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketBehavior.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index ba3efd342..9c62a0234 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -861,6 +861,7 @@ protected void Send (byte[] data) { if (_websocket == null) { var msg = "The current state of the connection is not Open."; + throw new InvalidOperationException (msg); } From c3b090e60ba3cacfa5dc3cca5110237175456166 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 25 Oct 2021 21:06:00 +0900 Subject: [PATCH 3925/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 9c62a0234..b45d0ffa9 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -849,7 +849,7 @@ protected virtual void OnOpen () /// Sends the specified data to a client using the WebSocket connection. /// /// - /// An array of that represents the binary data to send. + /// An array of that specifies the binary data to send. /// /// /// The current state of the connection is not Open. From bff70be481a5d7929825ea7d643867723b88e313 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 25 Oct 2021 21:07:55 +0900 Subject: [PATCH 3926/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketBehavior.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index b45d0ffa9..430c392c6 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -900,6 +900,7 @@ protected void Send (FileInfo fileInfo) { if (_websocket == null) { var msg = "The current state of the connection is not Open."; + throw new InvalidOperationException (msg); } From d45eaf01e182170eb5e99733597717499c17c42e Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 25 Oct 2021 21:10:18 +0900 Subject: [PATCH 3927/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketBehavior.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 430c392c6..1035443d6 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -926,6 +926,7 @@ protected void Send (string data) { if (_websocket == null) { var msg = "The current state of the connection is not Open."; + throw new InvalidOperationException (msg); } From 98648d38b0e9d865da6952e30f7a78f0c5b60555 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 25 Oct 2021 21:12:31 +0900 Subject: [PATCH 3928/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 1035443d6..b259d0f80 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -911,7 +911,7 @@ protected void Send (FileInfo fileInfo) /// Sends the specified data to a client using the WebSocket connection. /// /// - /// A that represents the text data to send. + /// A that specifies the text data to send. /// /// /// The current state of the connection is not Open. From 5bd87466868e10addfefb77968c54bb8d25f4ed1 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 25 Oct 2021 21:13:40 +0900 Subject: [PATCH 3929/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketBehavior.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index b259d0f80..6c50b5bac 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -975,6 +975,7 @@ protected void Send (Stream stream, int length) { if (_websocket == null) { var msg = "The current state of the connection is not Open."; + throw new InvalidOperationException (msg); } From b71e7263c3034f11991ed63f5bbd68c0ad6afd80 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 25 Oct 2021 21:19:13 +0900 Subject: [PATCH 3930/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 6c50b5bac..065423f7e 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -934,7 +934,7 @@ protected void Send (string data) } /// - /// Sends the data from the specified stream to a client using + /// Sends the data from the specified stream instance to a client using /// the WebSocket connection. /// /// From 32622b71e58128d00b431b9e1933dd26a81caa62 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 26 Oct 2021 19:34:42 +0900 Subject: [PATCH 3931/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketBehavior.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 065423f7e..902762d59 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -1015,6 +1015,7 @@ protected void SendAsync (byte[] data, Action completed) { if (_websocket == null) { var msg = "The current state of the connection is not Open."; + throw new InvalidOperationException (msg); } From eed3abc99a2fb032ade90712b769b9d651720722 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 26 Oct 2021 19:40:00 +0900 Subject: [PATCH 3932/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 902762d59..1e54f88c3 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -983,14 +983,14 @@ protected void Send (Stream stream, int length) } /// - /// Sends the specified data to a client asynchronously using - /// the WebSocket connection. + /// Sends the specified data to a client asynchronously using the WebSocket + /// connection. /// /// /// This method does not wait for the send to be complete. /// /// - /// An array of that represents the binary data to send. + /// An array of that specifies the binary data to send. /// /// /// From 4af39b591d844b265afb85f119786d3842acdebc Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 26 Oct 2021 19:40:58 +0900 Subject: [PATCH 3933/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketBehavior.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 1e54f88c3..9cd00ac75 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -1071,6 +1071,7 @@ protected void SendAsync (FileInfo fileInfo, Action completed) { if (_websocket == null) { var msg = "The current state of the connection is not Open."; + throw new InvalidOperationException (msg); } From 5fda79812e1675226bbb15350f0d47f59931420a Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 27 Oct 2021 19:36:23 +0900 Subject: [PATCH 3934/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketBehavior.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 9cd00ac75..9bb089c1f 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -1114,6 +1114,7 @@ protected void SendAsync (string data, Action completed) { if (_websocket == null) { var msg = "The current state of the connection is not Open."; + throw new InvalidOperationException (msg); } From 7fd2a2acbbdc01665a556ad589e3822d3366e5dd Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 27 Oct 2021 19:38:52 +0900 Subject: [PATCH 3935/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 9bb089c1f..6aa23fd34 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -1086,7 +1086,7 @@ protected void SendAsync (FileInfo fileInfo, Action completed) /// This method does not wait for the send to be complete. /// /// - /// A that represents the text data to send. + /// A that specifies the text data to send. /// /// /// From 9d035733f09f84f443a825675b73cb045b53ff8b Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 27 Oct 2021 19:40:10 +0900 Subject: [PATCH 3936/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketBehavior.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 6aa23fd34..6512929a1 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -1179,6 +1179,7 @@ protected void SendAsync (Stream stream, int length, Action completed) { if (_websocket == null) { var msg = "The current state of the connection is not Open."; + throw new InvalidOperationException (msg); } From 200208bc717294310561c4efcace80e691bcf6b8 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 27 Oct 2021 19:43:56 +0900 Subject: [PATCH 3937/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 6512929a1..70d0e97d1 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -1122,8 +1122,8 @@ protected void SendAsync (string data, Action completed) } /// - /// Sends the data from the specified stream to a client asynchronously - /// using the WebSocket connection. + /// Sends the data from the specified stream instance to a client + /// asynchronously using the WebSocket connection. /// /// /// This method does not wait for the send to be complete. From 2f3873eafeedb655e7389f951ba18a9abcf637e2 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 27 Oct 2021 19:46:46 +0900 Subject: [PATCH 3938/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 70d0e97d1..0075b7051 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -983,8 +983,8 @@ protected void Send (Stream stream, int length) } /// - /// Sends the specified data to a client asynchronously using the WebSocket - /// connection. + /// Sends the specified data to a client asynchronously using + /// the WebSocket connection. /// /// /// This method does not wait for the send to be complete. From 2f924b18403463d43e021c6ec295c0a5b95a9cec Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 28 Oct 2021 20:05:23 +0900 Subject: [PATCH 3939/6294] [Modify] Remove it --- websocket-sharp/Server/WebSocketBehavior.cs | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 0075b7051..5c82143f6 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -90,24 +90,6 @@ protected NameValueCollection Headers { } } - /// - /// Gets the logging function. - /// - /// - /// - /// A that provides the logging function. - /// - /// - /// if the session has not started yet. - /// - /// - [Obsolete ("This property will be removed.")] - protected Logger Log { - get { - return _websocket != null ? _websocket.Log : null; - } - } - /// /// Gets the query string included in a WebSocket handshake request. /// From 78cc325f97a5bed28058789f024c5ca0a32e10e1 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 28 Oct 2021 20:14:02 +0900 Subject: [PATCH 3940/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketBehavior.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 5c82143f6..f062ce65f 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -233,6 +233,7 @@ public bool EmitOnPing { set { if (_websocket != null) { _websocket.EmitOnPing = value; + return; } From 457a60b6cd10fab6160b022316d601b065f71b49 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 29 Oct 2021 19:35:08 +0900 Subject: [PATCH 3941/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketBehavior.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index f062ce65f..b406d9823 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -349,16 +349,21 @@ public string Protocol { set { if (ConnectionState != WebSocketState.Connecting) { var msg = "The session has already started."; + throw new InvalidOperationException (msg); } if (value == null || value.Length == 0) { _protocol = null; + return; } - if (!value.IsToken ()) - throw new ArgumentException ("Not a token.", "value"); + if (!value.IsToken ()) { + var msg = "It is not a token."; + + throw new ArgumentException (msg, "value"); + } _protocol = value; } From 5539e05478da068a87099a5b88104812e6e6936c Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 29 Oct 2021 19:51:50 +0900 Subject: [PATCH 3942/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index b406d9823..613c9780c 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -347,7 +347,7 @@ public string Protocol { } set { - if (ConnectionState != WebSocketState.Connecting) { + if (_websocket != null) { var msg = "The session has already started."; throw new InvalidOperationException (msg); From 99e0bf006bf8a3e22414af20261291e73951e6b6 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 30 Oct 2021 21:59:15 +0900 Subject: [PATCH 3943/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 613c9780c..7cfe56352 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -37,7 +37,7 @@ namespace WebSocketSharp.Server /// /// Exposes a set of methods and properties used to define the behavior of /// a WebSocket service provided by the or - /// . + /// class. /// /// /// This class is an abstract class. From 15a99cef6a7abd3dbdba31398321dd56bd6125f0 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 31 Oct 2021 21:31:44 +0900 Subject: [PATCH 3944/6294] [Modify] 2021 --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 7cfe56352..49292c2a2 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -4,7 +4,7 @@ * * The MIT License * - * Copyright (c) 2012-2016 sta.blockhead + * Copyright (c) 2012-2021 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From 0816ad97c559fcaa85d7f12aa187aa4b25bfdd21 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 1 Nov 2021 20:46:19 +0900 Subject: [PATCH 3945/6294] [Modify] Add it --- websocket-sharp/Server/WebSocketBehavior.cs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 49292c2a2..6e47872e3 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -833,6 +833,27 @@ protected virtual void OnOpen () { } + /// + /// Sends a ping to a client using the WebSocket connection. + /// + /// + /// true if the send has done with no error and a pong has been + /// received within a time; otherwise, false. + /// + /// + /// The session has not started yet. + /// + protected bool Ping () + { + if (_websocket == null) { + var msg = "The session has not started yet."; + + throw new InvalidOperationException (msg); + } + + return _websocket.Ping (); + } + /// /// Sends the specified data to a client using the WebSocket connection. /// From 98c41afd3bd4bb054d61335eb6334b0f4e423385 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 2 Nov 2021 19:37:07 +0900 Subject: [PATCH 3946/6294] [Modify] Add it --- websocket-sharp/Server/WebSocketBehavior.cs | 36 +++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 6e47872e3..b2a5dd217 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -854,6 +854,42 @@ protected bool Ping () return _websocket.Ping (); } + /// + /// Sends a ping with the specified message to a client using + /// the WebSocket connection. + /// + /// + /// true if the send has done with no error and a pong has been + /// received within a time; otherwise, false. + /// + /// + /// + /// A that specifies the message to send. + /// + /// + /// The size must be 125 bytes or less in UTF-8. + /// + /// + /// + /// The session has not started yet. + /// + /// + /// could not be UTF-8-encoded. + /// + /// + /// The size of is greater than 125 bytes. + /// + protected bool Ping (string message) + { + if (_websocket == null) { + var msg = "The session has not started yet."; + + throw new InvalidOperationException (msg); + } + + return _websocket.Ping (message); + } + /// /// Sends the specified data to a client using the WebSocket connection. /// From 7defb573efdd893b7a4e959b2ec9364da6190863 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 3 Nov 2021 19:33:33 +0900 Subject: [PATCH 3947/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketSessionManager.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index f7144b0ce..dbed3d919 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -405,11 +405,13 @@ private bool canSet (out string message) if (_state == ServerState.Start) { message = "The service has already started."; + return false; } if (_state == ServerState.ShuttingDown) { message = "The service is shutting down."; + return false; } From 18616fb8aaf58ccc5374e6ac6206622d7808a9e4 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 4 Nov 2021 20:04:50 +0900 Subject: [PATCH 3948/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketSessionManager.cs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index dbed3d919..ca9ce5f15 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -226,15 +226,12 @@ public bool KeepClean { } set { - string msg; - if (!canSet (out msg)) { - _log.Warn (msg); - return; - } - lock (_sync) { + string msg; + if (!canSet (out msg)) { _log.Warn (msg); + return; } From 4461c7afbc3dc2b1ebdeb48d9494ba3c80554c05 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 4 Nov 2021 20:07:39 +0900 Subject: [PATCH 3949/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketSessionManager.cs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index ca9ce5f15..2963d6c16 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -289,15 +289,12 @@ public TimeSpan WaitTime { if (value <= TimeSpan.Zero) throw new ArgumentOutOfRangeException ("value", "Zero or less."); - string msg; - if (!canSet (out msg)) { - _log.Warn (msg); - return; - } - lock (_sync) { + string msg; + if (!canSet (out msg)) { _log.Warn (msg); + return; } From 01148aaa46aacba63aae66c02845e95730200953 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 4 Nov 2021 20:15:26 +0900 Subject: [PATCH 3950/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketSessionManager.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 2963d6c16..e3558c84e 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -286,8 +286,11 @@ public TimeSpan WaitTime { } set { - if (value <= TimeSpan.Zero) - throw new ArgumentOutOfRangeException ("value", "Zero or less."); + if (value <= TimeSpan.Zero) { + var msg = "It is zero or less."; + + throw new ArgumentOutOfRangeException ("value", msg); + } lock (_sync) { string msg; From c95ec4ae2ff346f100cdb36db285b55c9fb4187c Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 5 Nov 2021 19:34:55 +0900 Subject: [PATCH 3951/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketSessionManager.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index e3558c84e..590c14a68 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -267,8 +267,8 @@ public IEnumerable Sessions { } /// - /// Gets or sets the time to wait for the response to the WebSocket Ping or - /// Close. + /// Gets or sets the time to wait for the response to the WebSocket Ping + /// or Close. /// /// /// The set operation does nothing if the service has already started or From 47b90511e196b517ad6b101d1880650e6b20a16a Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 5 Nov 2021 19:38:46 +0900 Subject: [PATCH 3952/6294] [Modify] Rename it --- websocket-sharp/Server/WebSocketSessionManager.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 590c14a68..8cc7115a1 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -48,7 +48,7 @@ public class WebSocketSessionManager { #region Private Fields - private volatile bool _clean; + private volatile bool _keepClean; private object _forSweep; private Logger _log; private Dictionary _sessions; @@ -66,7 +66,7 @@ internal WebSocketSessionManager (Logger log) { _log = log; - _clean = true; + _keepClean = true; _forSweep = new object (); _sessions = new Dictionary (); _state = ServerState.Ready; @@ -222,7 +222,7 @@ public IWebSocketSession this[string id] { /// public bool KeepClean { get { - return _clean; + return _keepClean; } set { @@ -235,7 +235,7 @@ public bool KeepClean { return; } - _clean = value; + _keepClean = value; } } } @@ -531,7 +531,7 @@ internal bool Remove (string id) internal void Start () { lock (_sync) { - _sweepTimer.Enabled = _clean; + _sweepTimer.Enabled = _keepClean; _state = ServerState.Start; } } From 0a83818e0cb6d52be80e5f50809d6d53999a266c Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 5 Nov 2021 19:40:32 +0900 Subject: [PATCH 3953/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketSessionManager.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 8cc7115a1..485aa8ad5 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -48,8 +48,8 @@ public class WebSocketSessionManager { #region Private Fields - private volatile bool _keepClean; private object _forSweep; + private volatile bool _keepClean; private Logger _log; private Dictionary _sessions; private volatile ServerState _state; @@ -66,8 +66,8 @@ internal WebSocketSessionManager (Logger log) { _log = log; - _keepClean = true; _forSweep = new object (); + _keepClean = true; _sessions = new Dictionary (); _state = ServerState.Ready; _sync = ((ICollection) _sessions).SyncRoot; From 8baeba75cee3b6e98b0a55059b7db402127903b3 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 6 Nov 2021 21:03:56 +0900 Subject: [PATCH 3954/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketSessionManager.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 485aa8ad5..72cb4b252 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -41,8 +41,8 @@ namespace WebSocketSharp.Server /// Provides the management function for the sessions in a WebSocket service. /// /// - /// This class manages the sessions in a WebSocket service provided by - /// the or . + /// This class manages the sessions in a WebSocket service provided by the + /// or class. /// public class WebSocketSessionManager { From a1f12207db87682cf61ac25c50c7f74fe1467ec1 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 6 Nov 2021 21:12:40 +0900 Subject: [PATCH 3955/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketSessionManager.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 72cb4b252..88d4f9211 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -172,7 +172,7 @@ public IEnumerable InactiveIDs { } /// - /// Gets the session instance with . + /// Gets the session instance with the specified ID. /// /// /// @@ -185,7 +185,7 @@ public IEnumerable InactiveIDs { /// /// /// - /// A that represents the ID of the session to find. + /// A that specifies the ID of the session to find. /// /// /// is . From bcfae8122f1993aa91c000c57743a906fd4f1f5d Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 7 Nov 2021 22:13:54 +0900 Subject: [PATCH 3956/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketSessionManager.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 88d4f9211..c80e0886c 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -202,6 +202,7 @@ public IWebSocketSession this[string id] { throw new ArgumentException ("An empty string.", "id"); IWebSocketSession session; + tryGetSession (id, out session); return session; From 32889bd50397d3301ec65555c0477b39811d4ed3 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 8 Nov 2021 21:09:05 +0900 Subject: [PATCH 3957/6294] [Modify] Add it --- websocket-sharp/Server/WebSocketSessionManager.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index c80e0886c..50227ba76 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -397,6 +397,11 @@ private Dictionary broadping (byte[] frameAsBytes) return ret; } + private bool canSet () + { + return _state == ServerState.Ready || _state == ServerState.Stop; + } + private bool canSet (out string message) { message = null; From 7cec07ef319b633e48be5986514c37925a5ed5b1 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 8 Nov 2021 21:13:18 +0900 Subject: [PATCH 3958/6294] [Modify] Replace it --- websocket-sharp/Server/WebSocketSessionManager.cs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 50227ba76..74c81c088 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -228,13 +228,8 @@ public bool KeepClean { set { lock (_sync) { - string msg; - - if (!canSet (out msg)) { - _log.Warn (msg); - + if (!canSet ()) return; - } _keepClean = value; } From 2904c087a29b09e65848bf568133d011163506bc Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 9 Nov 2021 19:38:08 +0900 Subject: [PATCH 3959/6294] [Modify] Replace it --- websocket-sharp/Server/WebSocketSessionManager.cs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 74c81c088..50f11c945 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -289,13 +289,8 @@ public TimeSpan WaitTime { } lock (_sync) { - string msg; - - if (!canSet (out msg)) { - _log.Warn (msg); - + if (!canSet ()) return; - } _waitTime = value; } From a4c482ffde1c07836a8a208cc07c7ce89d2b4415 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 9 Nov 2021 19:41:02 +0900 Subject: [PATCH 3960/6294] [Modify] Remove it --- .../Server/WebSocketSessionManager.cs | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 50f11c945..e02860bec 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -392,25 +392,6 @@ private bool canSet () return _state == ServerState.Ready || _state == ServerState.Stop; } - private bool canSet (out string message) - { - message = null; - - if (_state == ServerState.Start) { - message = "The service has already started."; - - return false; - } - - if (_state == ServerState.ShuttingDown) { - message = "The service is shutting down."; - - return false; - } - - return true; - } - private static string createID () { return Guid.NewGuid ().ToString ("N"); From 4e1a19b26710996e510030e61325c098ea241de8 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 10 Nov 2021 19:38:14 +0900 Subject: [PATCH 3961/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketSessionManager.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index e02860bec..4a2434484 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -542,7 +542,8 @@ internal void Stop (ushort code, string reason) public void Broadcast (byte[] data) { if (_state != ServerState.Start) { - var msg = "The current state of the manager is not Start."; + var msg = "The current state of the service is not Start."; + throw new InvalidOperationException (msg); } From d6b75d5642bb96ea37e2afd547b76c6ebc28e84e Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 10 Nov 2021 19:42:43 +0900 Subject: [PATCH 3962/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketSessionManager.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 4a2434484..ee7d50b55 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -528,13 +528,13 @@ internal void Stop (ushort code, string reason) #region Public Methods /// - /// Sends to every client in the WebSocket service. + /// Sends the specified data to every client in the WebSocket service. /// /// - /// An array of that represents the binary data to send. + /// An array of that specifies the binary data to send. /// /// - /// The current state of the manager is not Start. + /// The current state of the service is not Start. /// /// /// is . From cab8ce2ceb0f005dc5f9b27c5172f49a3a2a2fae Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 10 Nov 2021 19:45:40 +0900 Subject: [PATCH 3963/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketSessionManager.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index ee7d50b55..91cb7d728 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -574,7 +574,8 @@ public void Broadcast (byte[] data) public void Broadcast (string data) { if (_state != ServerState.Start) { - var msg = "The current state of the manager is not Start."; + var msg = "The current state of the service is not Start."; + throw new InvalidOperationException (msg); } @@ -582,8 +583,10 @@ public void Broadcast (string data) throw new ArgumentNullException ("data"); byte[] bytes; + if (!data.TryGetUTF8EncodedBytes (out bytes)) { var msg = "It could not be UTF-8-encoded."; + throw new ArgumentException (msg, "data"); } From f7bb97123eb1f4526065c128f58a41f6e9cb7f86 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 10 Nov 2021 19:48:43 +0900 Subject: [PATCH 3964/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketSessionManager.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 91cb7d728..fbf3007d8 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -557,13 +557,13 @@ public void Broadcast (byte[] data) } /// - /// Sends to every client in the WebSocket service. + /// Sends the specified data to every client in the WebSocket service. /// /// - /// A that represents the text data to send. + /// A that specifies the text data to send. /// /// - /// The current state of the manager is not Start. + /// The current state of the service is not Start. /// /// /// is . From a1629e89caee9ded90776b1bdd0a7063a289f39a Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 11 Nov 2021 20:39:17 +0900 Subject: [PATCH 3965/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketSessionManager.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index fbf3007d8..731a4a77b 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -635,7 +635,8 @@ public void Broadcast (string data) public void Broadcast (Stream stream, int length) { if (_state != ServerState.Start) { - var msg = "The current state of the manager is not Start."; + var msg = "The current state of the service is not Start."; + throw new InvalidOperationException (msg); } @@ -644,19 +645,22 @@ public void Broadcast (Stream stream, int length) if (!stream.CanRead) { var msg = "It cannot be read."; + throw new ArgumentException (msg, "stream"); } if (length < 1) { - var msg = "Less than 1."; + var msg = "It is less than 1."; + throw new ArgumentException (msg, "length"); } var bytes = stream.ReadBytes (length); - var len = bytes.Length; + if (len == 0) { var msg = "No data could be read from it."; + throw new ArgumentException (msg, "stream"); } From eb845aa70a36e89fccc9ad233376b294939ce3bc Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 11 Nov 2021 20:43:25 +0900 Subject: [PATCH 3966/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketSessionManager.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 731a4a77b..aabb83739 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -665,12 +665,12 @@ public void Broadcast (Stream stream, int length) } if (len < length) { - _log.Warn ( - String.Format ( - "Only {0} byte(s) of data could be read from the stream.", - len - ) - ); + var msg = String.Format ( + "Only {0} byte(s) of data could be read from the stream.", + len + ); + + _log.Warn (msg); } if (len <= WebSocket.FragmentLength) From 04cb8f4901d99f3290b6a52ce1bf3da7d890eb61 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 11 Nov 2021 20:46:55 +0900 Subject: [PATCH 3967/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketSessionManager.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index aabb83739..27f91505e 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -665,10 +665,8 @@ public void Broadcast (Stream stream, int length) } if (len < length) { - var msg = String.Format ( - "Only {0} byte(s) of data could be read from the stream.", - len - ); + var fmt = "Only {0} byte(s) of data could be read from the stream."; + var msg = String.Format (fmt, len); _log.Warn (msg); } From 708cd4e2014474675f7afcbc483dede7a7649886 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 12 Nov 2021 19:37:42 +0900 Subject: [PATCH 3968/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketSessionManager.cs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 27f91505e..40053dc1b 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -597,20 +597,22 @@ public void Broadcast (string data) } /// - /// Sends the data from to every client in + /// Sends the data from the specified stream instance to every client in /// the WebSocket service. /// - /// - /// The data is sent as the binary data. - /// /// - /// A instance from which to read the data to send. + /// + /// A instance from which to read the data to send. + /// + /// + /// The data is sent as the binary data. + /// /// /// /// An that specifies the number of bytes to send. /// /// - /// The current state of the manager is not Start. + /// The current state of the service is not Start. /// /// /// is . From 11141253f1889eb9d7f02d7a6296efdce9b167bd Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 12 Nov 2021 19:39:44 +0900 Subject: [PATCH 3969/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketSessionManager.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 40053dc1b..515800806 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -707,7 +707,8 @@ public void Broadcast (Stream stream, int length) public void BroadcastAsync (byte[] data, Action completed) { if (_state != ServerState.Start) { - var msg = "The current state of the manager is not Start."; + var msg = "The current state of the service is not Start."; + throw new InvalidOperationException (msg); } From e01148acff93eeea124ee70dbcfb0ca2d23e99be Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 12 Nov 2021 19:44:49 +0900 Subject: [PATCH 3970/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketSessionManager.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 515800806..d9dca21e3 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -680,14 +680,14 @@ public void Broadcast (Stream stream, int length) } /// - /// Sends asynchronously to every client in + /// Sends the specified data asynchronously to every client in /// the WebSocket service. /// /// /// This method does not wait for the send to be complete. /// /// - /// An array of that represents the binary data to send. + /// An array of that specifies the binary data to send. /// /// /// @@ -699,7 +699,7 @@ public void Broadcast (Stream stream, int length) /// /// /// - /// The current state of the manager is not Start. + /// The current state of the service is not Start. /// /// /// is . From ebca14a624441056018617cb65d37ab093910686 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 13 Nov 2021 21:50:43 +0900 Subject: [PATCH 3971/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketSessionManager.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index d9dca21e3..163cbb61b 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -752,7 +752,8 @@ public void BroadcastAsync (byte[] data, Action completed) public void BroadcastAsync (string data, Action completed) { if (_state != ServerState.Start) { - var msg = "The current state of the manager is not Start."; + var msg = "The current state of the service is not Start."; + throw new InvalidOperationException (msg); } @@ -760,8 +761,10 @@ public void BroadcastAsync (string data, Action completed) throw new ArgumentNullException ("data"); byte[] bytes; + if (!data.TryGetUTF8EncodedBytes (out bytes)) { var msg = "It could not be UTF-8-encoded."; + throw new ArgumentException (msg, "data"); } From 7f7498e8e869486a5500d4c49fd4dbbe4b6a0762 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 13 Nov 2021 21:54:07 +0900 Subject: [PATCH 3972/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketSessionManager.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 163cbb61b..b2ffb6c46 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -722,14 +722,14 @@ public void BroadcastAsync (byte[] data, Action completed) } /// - /// Sends asynchronously to every client in + /// Sends the specified data asynchronously to every client in /// the WebSocket service. /// /// /// This method does not wait for the send to be complete. /// /// - /// A that represents the text data to send. + /// A that specifies the text data to send. /// /// /// @@ -741,7 +741,7 @@ public void BroadcastAsync (byte[] data, Action completed) /// /// /// - /// The current state of the manager is not Start. + /// The current state of the service is not Start. /// /// /// is . From 64a390c66a432305dbdb02f4be8e34183898aec5 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 14 Nov 2021 22:10:41 +0900 Subject: [PATCH 3973/6294] [Modify] Polish it --- .../Server/WebSocketSessionManager.cs | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index b2ffb6c46..03a2d4769 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -827,7 +827,8 @@ public void BroadcastAsync (string data, Action completed) public void BroadcastAsync (Stream stream, int length, Action completed) { if (_state != ServerState.Start) { - var msg = "The current state of the manager is not Start."; + var msg = "The current state of the service is not Start."; + throw new InvalidOperationException (msg); } @@ -836,29 +837,30 @@ public void BroadcastAsync (Stream stream, int length, Action completed) if (!stream.CanRead) { var msg = "It cannot be read."; + throw new ArgumentException (msg, "stream"); } if (length < 1) { - var msg = "Less than 1."; + var msg = "It is less than 1."; + throw new ArgumentException (msg, "length"); } var bytes = stream.ReadBytes (length); - var len = bytes.Length; + if (len == 0) { var msg = "No data could be read from it."; + throw new ArgumentException (msg, "stream"); } if (len < length) { - _log.Warn ( - String.Format ( - "Only {0} byte(s) of data could be read from the stream.", - len - ) - ); + var fmt = "Only {0} byte(s) of data could be read from the stream."; + var msg = String.Format (fmt, len); + + _log.Warn (msg); } if (len <= WebSocket.FragmentLength) From 4403d6b676d4c2b31faf332abc55c9e6acfc9ea4 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 14 Nov 2021 22:17:55 +0900 Subject: [PATCH 3974/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketSessionManager.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 03a2d4769..2a7358857 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -775,19 +775,19 @@ public void BroadcastAsync (string data, Action completed) } /// - /// Sends the data from asynchronously to + /// Sends the data from the specified stream instance asynchronously to /// every client in the WebSocket service. /// /// + /// This method does not wait for the send to be complete. + /// + /// /// - /// The data is sent as the binary data. + /// A instance from which to read the data to send. /// /// - /// This method does not wait for the send to be complete. + /// The data is sent as the binary data. /// - /// - /// - /// A instance from which to read the data to send. /// /// /// An that specifies the number of bytes to send. @@ -802,7 +802,7 @@ public void BroadcastAsync (string data, Action completed) /// /// /// - /// The current state of the manager is not Start. + /// The current state of the service is not Start. /// /// /// is . From ec86a30a7c95fc3df615c86196347b810ecd863f Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 15 Nov 2021 21:08:59 +0900 Subject: [PATCH 3975/6294] [Modify] Remove it --- .../Server/WebSocketSessionManager.cs | 27 ------------------- 1 file changed, 27 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 2a7358857..86d6581a5 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -869,33 +869,6 @@ public void BroadcastAsync (Stream stream, int length, Action completed) broadcastAsync (Opcode.Binary, new MemoryStream (bytes), completed); } - /// - /// Sends a ping to every client in the WebSocket service. - /// - /// - /// - /// A Dictionary<string, bool>. - /// - /// - /// It represents a collection of pairs of a session ID and - /// a value indicating whether a pong has been received from - /// the client within a time. - /// - /// - /// - /// The current state of the manager is not Start. - /// - [Obsolete ("This method will be removed.")] - public Dictionary Broadping () - { - if (_state != ServerState.Start) { - var msg = "The current state of the manager is not Start."; - throw new InvalidOperationException (msg); - } - - return Broadping (WebSocketFrame.EmptyPingBytes, _waitTime); - } - /// /// Sends a ping with to every client in /// the WebSocket service. From f0a944912a9f5e62780fad3635ed7e849adfdaf4 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 15 Nov 2021 21:10:04 +0900 Subject: [PATCH 3976/6294] [Modify] Remove it --- .../Server/WebSocketSessionManager.cs | 57 ------------------- 1 file changed, 57 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 86d6581a5..3a752937b 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -869,63 +869,6 @@ public void BroadcastAsync (Stream stream, int length, Action completed) broadcastAsync (Opcode.Binary, new MemoryStream (bytes), completed); } - /// - /// Sends a ping with to every client in - /// the WebSocket service. - /// - /// - /// - /// A Dictionary<string, bool>. - /// - /// - /// It represents a collection of pairs of a session ID and - /// a value indicating whether a pong has been received from - /// the client within a time. - /// - /// - /// - /// - /// A that represents the message to send. - /// - /// - /// The size must be 125 bytes or less in UTF-8. - /// - /// - /// - /// The current state of the manager is not Start. - /// - /// - /// could not be UTF-8-encoded. - /// - /// - /// The size of is greater than 125 bytes. - /// - [Obsolete ("This method will be removed.")] - public Dictionary Broadping (string message) - { - if (_state != ServerState.Start) { - var msg = "The current state of the manager is not Start."; - throw new InvalidOperationException (msg); - } - - if (message.IsNullOrEmpty ()) - return Broadping (WebSocketFrame.EmptyPingBytes, _waitTime); - - byte[] bytes; - if (!message.TryGetUTF8EncodedBytes (out bytes)) { - var msg = "It could not be UTF-8-encoded."; - throw new ArgumentException (msg, "message"); - } - - if (bytes.Length > 125) { - var msg = "Its size is greater than 125 bytes."; - throw new ArgumentOutOfRangeException ("message", msg); - } - - var frame = WebSocketFrame.CreatePingFrame (bytes, false); - return Broadping (frame.ToArray (), _waitTime); - } - /// /// Closes the specified session. /// From 4717fa3acb64b5cb5cf19f083cfed4bb7f4784e3 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 16 Nov 2021 19:51:09 +0900 Subject: [PATCH 3977/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketSessionManager.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 3a752937b..380dbfa21 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -887,8 +887,10 @@ public void BroadcastAsync (Stream stream, int length, Action completed) public void CloseSession (string id) { IWebSocketSession session; + if (!TryGetSession (id, out session)) { var msg = "The session could not be found."; + throw new InvalidOperationException (msg); } From bf482bf84faaeb19afae04c7ea13daaef1915f00 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 16 Nov 2021 19:57:12 +0900 Subject: [PATCH 3978/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketSessionManager.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 380dbfa21..1578237db 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -870,10 +870,10 @@ public void BroadcastAsync (Stream stream, int length, Action completed) } /// - /// Closes the specified session. + /// Closes the session with the specified ID. /// /// - /// A that represents the ID of the session to close. + /// A that specifies the ID of the session to close. /// /// /// is . From 6493ac1f1bf5f6c578313cb99a702e4de661709c Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 16 Nov 2021 19:58:40 +0900 Subject: [PATCH 3979/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketSessionManager.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 1578237db..6306df0a5 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -967,8 +967,10 @@ public void CloseSession (string id) public void CloseSession (string id, ushort code, string reason) { IWebSocketSession session; + if (!TryGetSession (id, out session)) { var msg = "The session could not be found."; + throw new InvalidOperationException (msg); } From 46b576581765f10a7b135ac84f68934e1bc163e2 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 17 Nov 2021 19:41:43 +0900 Subject: [PATCH 3980/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketSessionManager.cs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 6306df0a5..a530560cd 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -898,15 +898,14 @@ public void CloseSession (string id) } /// - /// Closes the specified session with and - /// . + /// Closes the session with the specified ID, code, and reason. /// /// - /// A that represents the ID of the session to close. + /// A that specifies the ID of the session to close. /// /// /// - /// A that represents the status code indicating + /// A that specifies the status code indicating /// the reason for the close. /// /// @@ -917,7 +916,7 @@ public void CloseSession (string id) /// /// /// - /// A that represents the reason for the close. + /// A that specifies the reason for the close. /// /// /// The size must be 123 bytes or less in UTF-8. @@ -940,8 +939,7 @@ public void CloseSession (string id) /// -or- /// /// - /// is 1005 (no status) and there is - /// . + /// is 1005 (no status) and there is reason. /// /// /// -or- From 8fbee675c94bab7491ac48de5aef5425874fd4ba Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 17 Nov 2021 19:43:11 +0900 Subject: [PATCH 3981/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketSessionManager.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index a530560cd..7218459af 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -1036,8 +1036,10 @@ public void CloseSession (string id, ushort code, string reason) public void CloseSession (string id, CloseStatusCode code, string reason) { IWebSocketSession session; + if (!TryGetSession (id, out session)) { var msg = "The session could not be found."; + throw new InvalidOperationException (msg); } From ef4c46640a3b3969cad2f705353b29bd0b8c70b0 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 17 Nov 2021 19:49:50 +0900 Subject: [PATCH 3982/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketSessionManager.cs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 7218459af..f24971a38 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -976,23 +976,22 @@ public void CloseSession (string id, ushort code, string reason) } /// - /// Closes the specified session with and - /// . + /// Closes the session with the specified ID, code, and reason. /// /// - /// A that represents the ID of the session to close. + /// A that specifies the ID of the session to close. /// /// /// /// One of the enum values. /// /// - /// It represents the status code indicating the reason for the close. + /// It specifies the status code indicating the reason for the close. /// /// /// /// - /// A that represents the reason for the close. + /// A that specifies the reason for the close. /// /// /// The size must be 123 bytes or less in UTF-8. @@ -1017,8 +1016,7 @@ public void CloseSession (string id, ushort code, string reason) /// /// /// is - /// and there is - /// . + /// and there is reason. /// /// /// -or- From f1fd8ebf740691495504ed8f9b01895fa88cda44 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 18 Nov 2021 20:09:30 +0900 Subject: [PATCH 3983/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketSessionManager.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index f24971a38..8741862fa 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -1066,8 +1066,10 @@ public void CloseSession (string id, CloseStatusCode code, string reason) public bool PingTo (string id) { IWebSocketSession session; + if (!TryGetSession (id, out session)) { var msg = "The session could not be found."; + throw new InvalidOperationException (msg); } From 7e633dace8199dd1c6cf7eaf90a0e07053edb419 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 18 Nov 2021 20:13:23 +0900 Subject: [PATCH 3984/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketSessionManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 8741862fa..9c36856d4 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -1052,7 +1052,7 @@ public void CloseSession (string id, CloseStatusCode code, string reason) /// received from the client within a time; otherwise, false. /// /// - /// A that represents the ID of the session. + /// A that specifies the ID of the session. /// /// /// is . From 7b80d2e8f5a516b867b0f18772e44ccdd8d29dec Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 18 Nov 2021 20:16:43 +0900 Subject: [PATCH 3985/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketSessionManager.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 9c36856d4..223e4d84f 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -1118,8 +1118,10 @@ public bool PingTo (string id) public bool PingTo (string message, string id) { IWebSocketSession session; + if (!TryGetSession (id, out session)) { var msg = "The session could not be found."; + throw new InvalidOperationException (msg); } From 8532a1f44e4e5a2cc03e4ff6306e6e79bffaed10 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 18 Nov 2021 20:22:36 +0900 Subject: [PATCH 3986/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketSessionManager.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 223e4d84f..c48488f99 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -1077,7 +1077,7 @@ public bool PingTo (string id) } /// - /// Sends a ping with to the client using + /// Sends a ping with the specified message to the client using /// the specified session. /// /// @@ -1086,14 +1086,14 @@ public bool PingTo (string id) /// /// /// - /// A that represents the message to send. + /// A that specifies the message to send. /// /// /// The size must be 125 bytes or less in UTF-8. /// /// /// - /// A that represents the ID of the session. + /// A that specifies the ID of the session. /// /// /// is . From e284fbde64cdbd658e097ee2fb6038fd8615804c Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 19 Nov 2021 19:35:01 +0900 Subject: [PATCH 3987/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketSessionManager.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index c48488f99..8ffb1082f 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -1165,8 +1165,10 @@ public bool PingTo (string message, string id) public void SendTo (byte[] data, string id) { IWebSocketSession session; + if (!TryGetSession (id, out session)) { var msg = "The session could not be found."; + throw new InvalidOperationException (msg); } From 636e61e8b97572d22b83f885e411331597592088 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 19 Nov 2021 19:39:02 +0900 Subject: [PATCH 3988/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketSessionManager.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 8ffb1082f..c932f2a4d 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -1129,13 +1129,13 @@ public bool PingTo (string message, string id) } /// - /// Sends to the client using the specified session. + /// Sends the specified data to the client using the specified session. /// /// - /// An array of that represents the binary data to send. + /// An array of that specifies the binary data to send. /// /// - /// A that represents the ID of the session. + /// A that specifies the ID of the session. /// /// /// From 838845f34205718b8ba03a03d9ed449e933db4c9 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 19 Nov 2021 19:40:26 +0900 Subject: [PATCH 3989/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketSessionManager.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index c932f2a4d..b6dde2244 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -1220,8 +1220,10 @@ public void SendTo (byte[] data, string id) public void SendTo (string data, string id) { IWebSocketSession session; + if (!TryGetSession (id, out session)) { var msg = "The session could not be found."; + throw new InvalidOperationException (msg); } From 6a3f4974aae531586b5eb13b49cebffe9a29bc8d Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 19 Nov 2021 19:44:36 +0900 Subject: [PATCH 3990/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketSessionManager.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index b6dde2244..b8935f12b 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -1176,13 +1176,13 @@ public void SendTo (byte[] data, string id) } /// - /// Sends to the client using the specified session. + /// Sends the specified data to the client using the specified session. /// /// - /// A that represents the text data to send. + /// A that specifies the text data to send. /// /// - /// A that represents the ID of the session. + /// A that specifies the ID of the session. /// /// /// From 9335b2e4cee6393d7717f8d5dbc4a97a42679ad2 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 20 Nov 2021 23:20:05 +0900 Subject: [PATCH 3991/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketSessionManager.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index b8935f12b..dbd486cbe 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -1294,8 +1294,10 @@ public void SendTo (string data, string id) public void SendTo (Stream stream, int length, string id) { IWebSocketSession session; + if (!TryGetSession (id, out session)) { var msg = "The session could not be found."; + throw new InvalidOperationException (msg); } From 818b5df9baccd0b531ab9c92af4ae429b1b7d31e Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 20 Nov 2021 23:25:11 +0900 Subject: [PATCH 3992/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketSessionManager.cs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index dbd486cbe..e11f7870f 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -1231,20 +1231,22 @@ public void SendTo (string data, string id) } /// - /// Sends the data from to the client using + /// Sends the data from the specified stream instance to the client using /// the specified session. /// - /// - /// The data is sent as the binary data. - /// /// - /// A instance from which to read the data to send. + /// + /// A instance from which to read the data to send. + /// + /// + /// The data is sent as the binary data. + /// /// /// /// An that specifies the number of bytes to send. /// /// - /// A that represents the ID of the session. + /// A that specifies the ID of the session. /// /// /// From 2c4b23f20f030298c0144e69a6b3b9d646d15829 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 21 Nov 2021 17:27:32 +0900 Subject: [PATCH 3993/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketSessionManager.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index e11f7870f..b9bdebaf9 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -1360,8 +1360,10 @@ public void SendTo (Stream stream, int length, string id) public void SendToAsync (byte[] data, string id, Action completed) { IWebSocketSession session; + if (!TryGetSession (id, out session)) { var msg = "The session could not be found."; + throw new InvalidOperationException (msg); } From 9f519e064695422d7c102f3741cdaa65f878d8ac Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 21 Nov 2021 17:33:07 +0900 Subject: [PATCH 3994/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketSessionManager.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index b9bdebaf9..7fdcfacc2 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -1307,17 +1307,17 @@ public void SendTo (Stream stream, int length, string id) } /// - /// Sends asynchronously to the client using + /// Sends the specified data asynchronously to the client using /// the specified session. /// /// /// This method does not wait for the send to be complete. /// /// - /// An array of that represents the binary data to send. + /// An array of that specifies the binary data to send. /// /// - /// A that represents the ID of the session. + /// A that specifies the ID of the session. /// /// /// From 78e15a566eb301529b08cb6cb140d274194e2767 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 21 Nov 2021 17:34:45 +0900 Subject: [PATCH 3995/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketSessionManager.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 7fdcfacc2..4b7859aa2 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -1432,8 +1432,10 @@ public void SendToAsync (byte[] data, string id, Action completed) public void SendToAsync (string data, string id, Action completed) { IWebSocketSession session; + if (!TryGetSession (id, out session)) { var msg = "The session could not be found."; + throw new InvalidOperationException (msg); } From e0f101bd47925bc2c4fd4e6fb41fbf27aa4dc9c8 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 21 Nov 2021 17:39:50 +0900 Subject: [PATCH 3996/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketSessionManager.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 4b7859aa2..9fd96177e 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -1371,17 +1371,17 @@ public void SendToAsync (byte[] data, string id, Action completed) } /// - /// Sends asynchronously to the client using + /// Sends the specified data asynchronously to the client using /// the specified session. /// /// /// This method does not wait for the send to be complete. /// /// - /// A that represents the text data to send. + /// A that specifies the text data to send. /// /// - /// A that represents the ID of the session. + /// A that specifies the ID of the session. /// /// /// From eed0410df3160f138223bcc58d033b3cf169abed Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 22 Nov 2021 21:13:36 +0900 Subject: [PATCH 3997/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketSessionManager.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 9fd96177e..52060f19e 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -1526,8 +1526,10 @@ public void SendToAsync ( ) { IWebSocketSession session; + if (!TryGetSession (id, out session)) { var msg = "The session could not be found."; + throw new InvalidOperationException (msg); } From 65f34f5307e3cff89de09d6f854aed8cde915f25 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 22 Nov 2021 21:19:23 +0900 Subject: [PATCH 3998/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketSessionManager.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 52060f19e..f0fe6e63c 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -1443,25 +1443,25 @@ public void SendToAsync (string data, string id, Action completed) } /// - /// Sends the data from asynchronously to + /// Sends the data from the specified stream instance asynchronously to /// the client using the specified session. /// /// + /// This method does not wait for the send to be complete. + /// + /// /// - /// The data is sent as the binary data. + /// A instance from which to read the data to send. /// /// - /// This method does not wait for the send to be complete. + /// The data is sent as the binary data. /// - /// - /// - /// A instance from which to read the data to send. /// /// /// An that specifies the number of bytes to send. /// /// - /// A that represents the ID of the session. + /// A that specifies the ID of the session. /// /// /// From 898d399c467c8a8d7a9ff0f27a2d63cd0fba95f8 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 23 Nov 2021 21:21:58 +0900 Subject: [PATCH 3999/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketSessionManager.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index f0fe6e63c..59e5e3703 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -1543,12 +1543,14 @@ public void Sweep () { if (_sweeping) { _log.Info ("The sweeping is already in progress."); + return; } lock (_forSweep) { if (_sweeping) { _log.Info ("The sweeping is already in progress."); + return; } @@ -1564,8 +1566,10 @@ public void Sweep () break; IWebSocketSession session; + if (_sessions.TryGetValue (id, out session)) { var state = session.ConnectionState; + if (state == WebSocketState.Open) session.Context.WebSocket.Close (CloseStatusCode.Abnormal); else if (state == WebSocketState.Closing) From e9dfccfc84655ee6ee5467ae7f59ebea9f08fe7d Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 23 Nov 2021 21:31:13 +0900 Subject: [PATCH 4000/6294] [Modify] Polish it --- .../Server/WebSocketSessionManager.cs | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 59e5e3703..cb2f02527 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -1567,16 +1567,21 @@ public void Sweep () IWebSocketSession session; - if (_sessions.TryGetValue (id, out session)) { - var state = session.ConnectionState; - - if (state == WebSocketState.Open) - session.Context.WebSocket.Close (CloseStatusCode.Abnormal); - else if (state == WebSocketState.Closing) - continue; - else - _sessions.Remove (id); + if (!_sessions.TryGetValue (id, out session)) + continue; + + var state = session.ConnectionState; + + if (state == WebSocketState.Open) { + session.Context.WebSocket.Close (CloseStatusCode.Abnormal); + + continue; } + + if (state == WebSocketState.Closing) + continue; + + _sessions.Remove (id); } } From eaca164eaf87d08b9294b5e87309ca9f73ffec35 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 24 Nov 2021 21:20:23 +0900 Subject: [PATCH 4001/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketSessionManager.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index cb2f02527..eed2cfddb 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -1589,14 +1589,14 @@ public void Sweep () } /// - /// Tries to get the session instance with . + /// Tries to get the session instance with the specified ID. /// /// /// true if the session is successfully found; otherwise, /// false. /// /// - /// A that represents the ID of the session to find. + /// A that specifies the ID of the session to find. /// /// /// From 592912b10dee5ca44f3d45274a599f8ac85b0353 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 25 Nov 2021 21:39:22 +0900 Subject: [PATCH 4002/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketSessionManager.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index eed2cfddb..95035f160 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -515,12 +515,16 @@ internal void Start () internal void Stop (ushort code, string reason) { - if (code == 1005) { // == no status + if (code == 1005) { stop (PayloadData.Empty, true); + return; } - stop (new PayloadData (code, reason), !code.IsReserved ()); + var payloadData = new PayloadData (code, reason); + var send = !code.IsReserved (); + + stop (payloadData, send); } #endregion From 02dacca582c5b14946cee5119ab87c42f9867a3c Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 26 Nov 2021 21:10:41 +0900 Subject: [PATCH 4003/6294] [Modify] Remove it --- .../Server/WebSocketSessionManager.cs | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 95035f160..5a4348a9a 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -480,25 +480,6 @@ internal void Broadcast ( } } - internal Dictionary Broadping ( - byte[] frameAsBytes, TimeSpan timeout - ) - { - var ret = new Dictionary (); - - foreach (var session in Sessions) { - if (_state != ServerState.Start) { - _log.Error ("The service is shutting down."); - break; - } - - var res = session.Context.WebSocket.Ping (frameAsBytes, timeout); - ret.Add (session.ID, res); - } - - return ret; - } - internal bool Remove (string id) { lock (_sync) From eb26537791cfb4dd47114460d24b468f7745158f Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 26 Nov 2021 21:11:54 +0900 Subject: [PATCH 4004/6294] [Modify] Remove it --- websocket-sharp/Server/WebSocketSessionManager.cs | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 5a4348a9a..bcc3103f1 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -466,20 +466,6 @@ internal void Broadcast ( } } - internal void Broadcast ( - Opcode opcode, Stream stream, Dictionary cache - ) - { - foreach (var session in Sessions) { - if (_state != ServerState.Start) { - _log.Error ("The service is shutting down."); - break; - } - - session.Context.WebSocket.Send (opcode, stream, cache); - } - } - internal bool Remove (string id) { lock (_sync) From d4441dc8994911735b66598a09c20dbda8f6f735 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 26 Nov 2021 21:13:26 +0900 Subject: [PATCH 4005/6294] [Modify] Remove it --- websocket-sharp/Server/WebSocketSessionManager.cs | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index bcc3103f1..5695afb27 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -452,20 +452,6 @@ internal string Add (IWebSocketSession session) } } - internal void Broadcast ( - Opcode opcode, byte[] data, Dictionary cache - ) - { - foreach (var session in Sessions) { - if (_state != ServerState.Start) { - _log.Error ("The service is shutting down."); - break; - } - - session.Context.WebSocket.Send (opcode, data, cache); - } - } - internal bool Remove (string id) { lock (_sync) From dd733fe01f90f993c3efbd58cbcb4df253f800f6 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 27 Nov 2021 22:27:26 +0900 Subject: [PATCH 4006/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketSessionManager.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 5695afb27..a8df50f86 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -446,6 +446,7 @@ internal string Add (IWebSocketSession session) return null; var id = createID (); + _sessions.Add (id, session); return id; From 5aba0a4cc2fd26402c8144dc9f3a8efcf39cb0b9 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 28 Nov 2021 21:56:19 +0900 Subject: [PATCH 4007/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketSessionManager.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index a8df50f86..869b5c8b6 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -406,13 +406,15 @@ private void setSweepTimer (double interval) private void stop (PayloadData payloadData, bool send) { var bytes = send - ? WebSocketFrame.CreateCloseFrame (payloadData, false).ToArray () + ? WebSocketFrame + .CreateCloseFrame (payloadData, false) + .ToArray () : null; lock (_sync) { _state = ServerState.ShuttingDown; - _sweepTimer.Enabled = false; + foreach (var session in _sessions.Values.ToList ()) session.Context.WebSocket.Close (payloadData, bytes); From d0c0ab5c1381c5ea98e280bab36c51c858b32140 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 29 Nov 2021 22:08:05 +0900 Subject: [PATCH 4008/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketSessionManager.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 869b5c8b6..c819aaca9 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -309,6 +309,7 @@ private void broadcast (Opcode opcode, byte[] data, Action completed) foreach (var session in Sessions) { if (_state != ServerState.Start) { _log.Error ("The service is shutting down."); + break; } From 9d0e93b3d47da1730fd9eb62e746a1c895b325e0 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 29 Nov 2021 22:11:05 +0900 Subject: [PATCH 4009/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketSessionManager.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index c819aaca9..146f8e784 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -336,6 +336,7 @@ private void broadcast (Opcode opcode, Stream stream, Action completed) foreach (var session in Sessions) { if (_state != ServerState.Start) { _log.Error ("The service is shutting down."); + break; } From 345c2f6495cd1dd04c7df495c91952b8500ee267 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 30 Nov 2021 21:58:15 +0900 Subject: [PATCH 4010/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketSessionManager.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 146f8e784..b4289d680 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -379,10 +379,12 @@ private Dictionary broadping (byte[] frameAsBytes) foreach (var session in Sessions) { if (_state != ServerState.Start) { _log.Error ("The service is shutting down."); + break; } var res = session.Context.WebSocket.Ping (frameAsBytes, _waitTime); + ret.Add (session.ID, res); } From 70e1e348aebaa34bf10ade62988cd06a7778ce73 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 1 Dec 2021 21:13:02 +0900 Subject: [PATCH 4011/6294] [Modify] 2021 --- websocket-sharp/Server/WebSocketSessionManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index b4289d680..8c384bc8f 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -4,7 +4,7 @@ * * The MIT License * - * Copyright (c) 2012-2015 sta.blockhead + * Copyright (c) 2012-2021 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From 2f9c418073afd14e02f28e2cfcb1229cb610bd47 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 2 Dec 2021 21:18:15 +0900 Subject: [PATCH 4012/6294] [Modify] Add it --- websocket-sharp/Server/WebSocketSessionManager.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 8c384bc8f..67a10f8ab 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -48,6 +48,7 @@ public class WebSocketSessionManager { #region Private Fields + private static readonly byte[] _emptyPingFrameAsBytes; private object _forSweep; private volatile bool _keepClean; private Logger _log; @@ -60,6 +61,17 @@ public class WebSocketSessionManager #endregion + #region Static Constructor + + static WebSocketSessionManager () + { + _emptyPingFrameAsBytes = WebSocketFrame + .CreatePingFrame (false) + .ToArray (); + } + + #endregion + #region Internal Constructors internal WebSocketSessionManager (Logger log) From 61b25683277dd7bd8dda74f4b983511f711babb2 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 3 Dec 2021 19:36:56 +0900 Subject: [PATCH 4013/6294] [Modify] Replace it --- websocket-sharp/Server/WebSocketSessionManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 67a10f8ab..b412350e4 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -116,7 +116,7 @@ internal ServerState State { /// public IEnumerable ActiveIDs { get { - foreach (var res in broadping (WebSocketFrame.EmptyPingBytes)) { + foreach (var res in broadping (_emptyPingFrameAsBytes)) { if (res.Value) yield return res.Key; } From f806c4f6e4b492fd00889e535708d8ec02e8711e Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 3 Dec 2021 19:38:58 +0900 Subject: [PATCH 4014/6294] [Modify] Replace it --- websocket-sharp/Server/WebSocketSessionManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index b412350e4..6229abaff 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -176,7 +176,7 @@ public IEnumerable IDs { /// public IEnumerable InactiveIDs { get { - foreach (var res in broadping (WebSocketFrame.EmptyPingBytes)) { + foreach (var res in broadping (_emptyPingFrameAsBytes)) { if (!res.Value) yield return res.Key; } From 4f14f34d67895096dd768deee1e15cdeea32592a Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 4 Dec 2021 21:52:14 +0900 Subject: [PATCH 4015/6294] [Modify] Remove it --- websocket-sharp/WebSocketFrame.cs | 23 ----------------------- 1 file changed, 23 deletions(-) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index ba0de3cd8..3b61c69fb 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -58,29 +58,6 @@ internal class WebSocketFrame : IEnumerable #endregion - #region Internal Fields - - /// - /// Represents the ping frame without the payload data as an array of - /// . - /// - /// - /// The value of this field is created from a non masked ping frame, - /// so it can only be used to send a ping from the server. - /// - internal static readonly byte[] EmptyPingBytes; - - #endregion - - #region Static Constructor - - static WebSocketFrame () - { - EmptyPingBytes = CreatePingFrame (false).ToArray (); - } - - #endregion - #region Private Constructors private WebSocketFrame () From 9b7af82d8824c92cf55b4e1c0f9e205e2dab6df9 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 5 Dec 2021 22:10:50 +0900 Subject: [PATCH 4016/6294] [Modify] Polish it --- websocket-sharp/WebSocketFrame.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index 3b61c69fb..02ee16fe7 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -96,6 +96,7 @@ bool mask _rsv3 = Rsv.Off; var len = payloadData.Length; + if (len < 126) { _payloadLength = (byte) len; _extPayloadLength = WebSocket.EmptyBytes; @@ -112,6 +113,7 @@ bool mask if (mask) { _mask = Mask.On; _maskingKey = createMaskingKey (); + payloadData.Mask (_maskingKey); } else { From d316d4fe0f4491291aec5aa621be93d2b7ccaa7c Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 5 Dec 2021 22:14:19 +0900 Subject: [PATCH 4017/6294] [Modify] Polish it --- websocket-sharp/WebSocketFrame.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index 02ee16fe7..1155983cf 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -299,6 +299,7 @@ public Rsv Rsv3 { private static byte[] createMaskingKey () { var key = new byte[4]; + WebSocket.RandomNumber.GetBytes (key); return key; From d3c92a8a0216ee614de784d7ba9bb31e66453bd3 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 6 Dec 2021 21:42:04 +0900 Subject: [PATCH 4018/6294] [Modify] Polish it --- websocket-sharp/WebSocketFrame.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index 1155983cf..a26e4e19a 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -313,6 +313,7 @@ private static string dump (WebSocketFrame frame) int cntDigit; string cntFmt; + if (cnt < 10000) { cntDigit = 4; cntFmt = "{0,4}"; @@ -352,6 +353,7 @@ private static string dump (WebSocketFrame frame) Func> linePrinter = () => { long lineCnt = 0; + return (arg1, arg2, arg3, arg4) => { buff.AppendFormat ( lineFmt, ++lineCnt, arg1, arg2, arg3, arg4 @@ -393,6 +395,7 @@ private static string dump (WebSocketFrame frame) } buff.AppendFormat (footerFmt, String.Empty); + return buff.ToString (); } From 805d54748050bc60325ef41b665e5f2038c09bf4 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 6 Dec 2021 21:49:35 +0900 Subject: [PATCH 4019/6294] [Modify] Polish it --- websocket-sharp/WebSocketFrame.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index a26e4e19a..2c82502cc 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -455,6 +455,7 @@ private static WebSocketFrame processHeader (byte[] header) { if (header.Length != 2) { var msg = "The header part of a frame could not be read."; + throw new WebSocketException (msg); } @@ -481,22 +482,26 @@ private static WebSocketFrame processHeader (byte[] header) if (!opcode.IsSupported ()) { var msg = "A frame has an unsupported opcode."; + throw new WebSocketException (CloseStatusCode.ProtocolError, msg); } if (!opcode.IsData () && rsv1 == Rsv.On) { var msg = "A non data frame is compressed."; + throw new WebSocketException (CloseStatusCode.ProtocolError, msg); } if (opcode.IsControl ()) { if (fin == Fin.More) { var msg = "A control frame is fragmented."; + throw new WebSocketException (CloseStatusCode.ProtocolError, msg); } if (payloadLen > 125) { var msg = "A control frame has too long payload length."; + throw new WebSocketException (CloseStatusCode.ProtocolError, msg); } } From 4f7c66f05190c65249420383416ad62439978e6b Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 7 Dec 2021 19:48:56 +0900 Subject: [PATCH 4020/6294] [Modify] Polish it --- websocket-sharp/WebSocketFrame.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index 2c82502cc..a744f2bc3 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -523,18 +523,23 @@ private static WebSocketFrame readExtendedPayloadLength ( ) { var len = frame.ExtendedPayloadLengthWidth; + if (len == 0) { frame._extPayloadLength = WebSocket.EmptyBytes; + return frame; } var bytes = stream.ReadBytes (len); + if (bytes.Length != len) { var msg = "The extended payload length of a frame could not be read."; + throw new WebSocketException (msg); } frame._extPayloadLength = bytes; + return frame; } From e8ffd88514beda8e0a683400ed7bf7643ceaf225 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 7 Dec 2021 19:51:53 +0900 Subject: [PATCH 4021/6294] [Modify] Polish it --- websocket-sharp/WebSocketFrame.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index a744f2bc3..3b1305e7e 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -551,8 +551,10 @@ Action error ) { var len = frame.ExtendedPayloadLengthWidth; + if (len == 0) { frame._extPayloadLength = WebSocket.EmptyBytes; + completed (frame); return; @@ -563,10 +565,12 @@ Action error bytes => { if (bytes.Length != len) { var msg = "The extended payload length of a frame could not be read."; + throw new WebSocketException (msg); } frame._extPayloadLength = bytes; + completed (frame); }, error From 23b9a59700d17171ae5609712a9055e8e21760da Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 7 Dec 2021 19:56:49 +0900 Subject: [PATCH 4022/6294] [Modify] Polish it --- websocket-sharp/WebSocketFrame.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index 3b1305e7e..d609b4ebd 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -597,6 +597,7 @@ private static WebSocketFrame readMaskingKey ( { if (!frame.IsMasked) { frame._maskingKey = WebSocket.EmptyBytes; + return frame; } @@ -605,10 +606,12 @@ private static WebSocketFrame readMaskingKey ( if (bytes.Length != len) { var msg = "The masking key of a frame could not be read."; + throw new WebSocketException (msg); } frame._maskingKey = bytes; + return frame; } From 0f2c16f9edfdfd365272aa8bf2a415c439783223 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 7 Dec 2021 20:00:31 +0900 Subject: [PATCH 4023/6294] [Modify] Polish it --- websocket-sharp/WebSocketFrame.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index d609b4ebd..ff0d2ee43 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -624,6 +624,7 @@ Action error { if (!frame.IsMasked) { frame._maskingKey = WebSocket.EmptyBytes; + completed (frame); return; @@ -636,10 +637,12 @@ Action error bytes => { if (bytes.Length != len) { var msg = "The masking key of a frame could not be read."; + throw new WebSocketException (msg); } frame._maskingKey = bytes; + completed (frame); }, error From 735f7bf7183cb23ee067ef85cd29ed72d77bfbd0 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 8 Dec 2021 19:37:47 +0900 Subject: [PATCH 4024/6294] [Modify] Polish it --- websocket-sharp/WebSocketFrame.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index ff0d2ee43..c900d4832 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -579,7 +579,9 @@ Action error private static WebSocketFrame readHeader (Stream stream) { - return processHeader (stream.ReadBytes (2)); + var bytes = stream.ReadBytes (2); + + return processHeader (bytes); } private static void readHeaderAsync ( From 8828432149fa7059822ae36911682f1813653a5f Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 8 Dec 2021 19:42:30 +0900 Subject: [PATCH 4025/6294] [Modify] Polish it --- websocket-sharp/WebSocketFrame.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index c900d4832..1a023b32c 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -589,7 +589,13 @@ private static void readHeaderAsync ( ) { stream.ReadBytesAsync ( - 2, bytes => completed (processHeader (bytes)), error + 2, + bytes => { + var frame = processHeader (bytes); + + completed (frame); + }, + error ); } From a06e8ea4c2e237c60ff58bcfdcf02ad1f5d0c954 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 8 Dec 2021 19:49:29 +0900 Subject: [PATCH 4026/6294] [Modify] Polish it --- websocket-sharp/WebSocketFrame.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index 1a023b32c..d610f2dbe 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -662,13 +662,16 @@ private static WebSocketFrame readPayloadData ( ) { var exactLen = frame.ExactPayloadLength; + if (exactLen > PayloadData.MaxLength) { var msg = "A frame has too long payload length."; + throw new WebSocketException (CloseStatusCode.TooBig, msg); } if (exactLen == 0) { frame._payloadData = PayloadData.Empty; + return frame; } @@ -679,10 +682,12 @@ private static WebSocketFrame readPayloadData ( if (bytes.LongLength != len) { var msg = "The payload data of a frame could not be read."; + throw new WebSocketException (msg); } frame._payloadData = new PayloadData (bytes, len); + return frame; } From a0104e901b6f477d6f95b7569e0c6f45f1798044 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 8 Dec 2021 19:55:29 +0900 Subject: [PATCH 4027/6294] [Modify] Polish it --- websocket-sharp/WebSocketFrame.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index d610f2dbe..deee054ba 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -699,32 +699,39 @@ Action error ) { var exactLen = frame.ExactPayloadLength; + if (exactLen > PayloadData.MaxLength) { var msg = "A frame has too long payload length."; + throw new WebSocketException (CloseStatusCode.TooBig, msg); } if (exactLen == 0) { frame._payloadData = PayloadData.Empty; + completed (frame); return; } var len = (long) exactLen; + Action comp = bytes => { if (bytes.LongLength != len) { var msg = "The payload data of a frame could not be read."; + throw new WebSocketException (msg); } frame._payloadData = new PayloadData (bytes, len); + completed (frame); }; if (frame._payloadLength < 127) { stream.ReadBytesAsync ((int) exactLen, comp, error); + return; } From fc780e4b3573d0ece09c21f6fa54569f53950587 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 9 Dec 2021 20:04:48 +0900 Subject: [PATCH 4028/6294] [Modify] Polish it --- websocket-sharp/WebSocketFrame.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index deee054ba..a529c493e 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -787,6 +787,7 @@ internal static WebSocketFrame CreatePongFrame ( internal static WebSocketFrame ReadFrame (Stream stream, bool unmask) { var frame = readHeader (stream); + readExtendedPayloadLength (stream, frame); readMaskingKey (stream, frame); readPayloadData (stream, frame); From 5bd077f20b2de20639298cc6ea07ce75270300d0 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 9 Dec 2021 20:13:32 +0900 Subject: [PATCH 4029/6294] [Modify] Polish it --- websocket-sharp/WebSocketFrame.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index a529c493e..d66dd2895 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -841,7 +841,9 @@ internal void Unmask () return; _mask = Mask.Off; + _payloadData.Mask (_maskingKey); + _maskingKey = WebSocket.EmptyBytes; } From a817fc0014afc7452442901cc02fdb74c7cea0b5 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 9 Dec 2021 20:22:26 +0900 Subject: [PATCH 4030/6294] [Modify] Polish it --- websocket-sharp/WebSocketFrame.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index d66dd2895..3a0b89660 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -898,6 +898,7 @@ public byte[] ToArray () } buff.Close (); + return buff.ToArray (); } } From 6358944cac47d2edc807302834dce657a2568347 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 10 Dec 2021 19:43:41 +0900 Subject: [PATCH 4031/6294] [Modify] Polish it --- websocket-sharp/WebSocketFrame.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index 3a0b89660..2b5e58ab3 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -840,11 +840,10 @@ internal void Unmask () if (_mask == Mask.Off) return; - _mask = Mask.Off; - _payloadData.Mask (_maskingKey); _maskingKey = WebSocket.EmptyBytes; + _mask = Mask.Off; } #endregion From 06ea197dbcfb11ff670f42668b2c209df7ea2bef Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 10 Dec 2021 19:47:13 +0900 Subject: [PATCH 4032/6294] [Modify] Polish it --- websocket-sharp/WebSocketFrame.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index 2b5e58ab3..41ef442f1 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -858,7 +858,9 @@ public IEnumerator GetEnumerator () public void Print (bool dumped) { - Console.WriteLine (dumped ? dump (this) : print (this)); + var val = dumped ? dump (this) : print (this); + + Console.WriteLine (val); } public string PrintToString (bool dumped) From 0e0fa28662a6a054373a61a4cc960e1a462f4653 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 11 Dec 2021 21:43:57 +0900 Subject: [PATCH 4033/6294] [Modify] Polish it --- websocket-sharp/WebSocketFrame.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index 41ef442f1..29f6dd8bf 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -906,7 +906,9 @@ public byte[] ToArray () public override string ToString () { - return BitConverter.ToString (ToArray ()); + var val = ToArray (); + + return BitConverter.ToString (val); } #endregion From 27847e04dc06d6453de0b710d3df85151c723a2f Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 12 Dec 2021 21:57:12 +0900 Subject: [PATCH 4034/6294] [Modify] Polish it --- websocket-sharp/WebSocketFrame.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index 29f6dd8bf..d080ac812 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -883,8 +883,11 @@ public byte[] ToArray () ((ushort) header).InternalToByteArray (ByteOrder.Big), 0, 2 ); - if (_payloadLength > 125) - buff.Write (_extPayloadLength, 0, _payloadLength == 126 ? 2 : 8); + if (_payloadLength > 125) { + var cnt = _payloadLength == 126 ? 2 : 8; + + buff.Write (_extPayloadLength, 0, cnt); + } if (_mask == Mask.On) buff.Write (_maskingKey, 0, 4); From 3495d8811ab0bc62ed03b78c1a680129ee970a1b Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 13 Dec 2021 21:24:41 +0900 Subject: [PATCH 4035/6294] [Modify] Polish it --- websocket-sharp/WebSocketFrame.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index d080ac812..b10396ffd 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -879,9 +879,10 @@ public byte[] ToArray () header = (header << 1) + (int) _mask; header = (header << 7) + (int) _payloadLength; - buff.Write ( - ((ushort) header).InternalToByteArray (ByteOrder.Big), 0, 2 - ); + var headerAsUshort = (ushort) header; + var headerAsBytes = headerAsUshort.InternalToByteArray (ByteOrder.Big); + + buff.Write (headerAsBytes, 0, 2); if (_payloadLength > 125) { var cnt = _payloadLength == 126 ? 2 : 8; From e188dc3980e2700b8a485d18eb250956d8a9ffd1 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 14 Dec 2021 19:50:40 +0900 Subject: [PATCH 4036/6294] [Modify] 2021 --- websocket-sharp/WebSocketFrame.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index b10396ffd..db8a73415 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -4,7 +4,7 @@ * * The MIT License * - * Copyright (c) 2012-2019 sta.blockhead + * Copyright (c) 2012-2021 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From 6760f3237e909d4bf75b0e300b5e0578bce91665 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 14 Dec 2021 20:01:30 +0900 Subject: [PATCH 4037/6294] [Modify] Add it --- websocket-sharp/Server/WebSocketServiceManager.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index 4242dcfbf..75f09726e 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -288,6 +288,11 @@ public TimeSpan WaitTime { #region Private Methods + private bool canSet () + { + return _state == ServerState.Ready || _state == ServerState.Stop; + } + private bool canSet (out string message) { message = null; From 55aaa620e5f9f594e9ae48709bb4d2f2957bd391 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 15 Dec 2021 19:46:15 +0900 Subject: [PATCH 4038/6294] [Modify] Replace it --- websocket-sharp/Server/WebSocketServiceManager.cs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index 75f09726e..9e5aa56ad 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -201,13 +201,8 @@ public bool KeepClean { set { lock (_sync) { - string msg; - - if (!canSet (out msg)) { - _log.Warn (msg); - + if (!canSet ()) return; - } foreach (var host in _hosts.Values) host.KeepClean = value; From 1de175fb5cae90f56d3e4b42c99a384c742a6d60 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 15 Dec 2021 19:48:47 +0900 Subject: [PATCH 4039/6294] [Modify] Replace it --- websocket-sharp/Server/WebSocketServiceManager.cs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index 9e5aa56ad..588611153 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -263,13 +263,8 @@ public TimeSpan WaitTime { } lock (_sync) { - string msg; - - if (!canSet (out msg)) { - _log.Warn (msg); - + if (!canSet ()) return; - } foreach (var host in _hosts.Values) host.WaitTime = value; From 6689101848273d2c6f9a93bfc7a490b002bf2258 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 15 Dec 2021 19:51:18 +0900 Subject: [PATCH 4040/6294] [Modify] Remove it --- .../Server/WebSocketServiceManager.cs | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index 588611153..787873d1c 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -283,25 +283,6 @@ private bool canSet () return _state == ServerState.Ready || _state == ServerState.Stop; } - private bool canSet (out string message) - { - message = null; - - if (_state == ServerState.Start) { - message = "The server has already started."; - - return false; - } - - if (_state == ServerState.ShuttingDown) { - message = "The server is shutting down."; - - return false; - } - - return true; - } - #endregion #region Internal Methods From 2006f56e971303634110bab7e17dd813929b6052 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 16 Dec 2021 21:28:30 +0900 Subject: [PATCH 4041/6294] [Modify] Add it --- websocket-sharp/Server/WebSocketServer.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index a42f99212..8b46d40bd 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -730,6 +730,11 @@ private bool authenticateClient (TcpListenerWebSocketContext context) return context.Authenticate (_authSchemes, _realmInUse, _userCredFinder); } + private bool canSet () + { + return _state == ServerState.Ready || _state == ServerState.Stop; + } + private bool canSet (out string message) { message = null; From ce59365de92cef1ee8ccd628a84a561138da8d7e Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 16 Dec 2021 21:31:35 +0900 Subject: [PATCH 4042/6294] [Modify] Replace it --- websocket-sharp/Server/WebSocketServer.cs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 8b46d40bd..cd0549a77 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -356,13 +356,8 @@ public bool AllowForwardedRequest { set { lock (_sync) { - string msg; - - if (!canSet (out msg)) { - _log.Warn (msg); - + if (!canSet ()) return; - } _allowForwardedRequest = value; } From f93ec070511c2f5ce20a56fa9491236e99465f92 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 17 Dec 2021 19:53:37 +0900 Subject: [PATCH 4043/6294] [Modify] Replace it --- websocket-sharp/Server/WebSocketServer.cs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index cd0549a77..cf1a25385 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -391,13 +391,8 @@ public AuthenticationSchemes AuthenticationSchemes { set { lock (_sync) { - string msg; - - if (!canSet (out msg)) { - _log.Warn (msg); - + if (!canSet ()) return; - } _authSchemes = value; } From b345377bfd8a1272fea9da39982dae18681cd507 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 17 Dec 2021 19:56:33 +0900 Subject: [PATCH 4044/6294] [Modify] Replace it --- websocket-sharp/Server/WebSocketServer.cs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index cf1a25385..15b685ad1 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -508,13 +508,8 @@ public string Realm { set { lock (_sync) { - string msg; - - if (!canSet (out msg)) { - _log.Warn (msg); - + if (!canSet ()) return; - } _realm = value; } From b18a078cd4949aeb1cb6186893c65b6f393847cb Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 18 Dec 2021 22:25:50 +0900 Subject: [PATCH 4045/6294] [Modify] Replace it --- websocket-sharp/Server/WebSocketServer.cs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 15b685ad1..c1f5a185e 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -546,13 +546,8 @@ public bool ReuseAddress { set { lock (_sync) { - string msg; - - if (!canSet (out msg)) { - _log.Warn (msg); - + if (!canSet ()) return; - } _reuseAddress = value; } From a91043641b3a2c418a7fe67bbdf1f15248f3d427 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 18 Dec 2021 22:28:31 +0900 Subject: [PATCH 4046/6294] [Modify] Replace it --- websocket-sharp/Server/WebSocketServer.cs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index c1f5a185e..72281b36f 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -616,13 +616,8 @@ public Func UserCredentialsFinder { set { lock (_sync) { - string msg; - - if (!canSet (out msg)) { - _log.Warn (msg); - + if (!canSet ()) return; - } _userCredFinder = value; } From b96e35d164df2731c6a7b836b818b215fd4e8231 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 19 Dec 2021 22:18:16 +0900 Subject: [PATCH 4047/6294] [Modify] Remove it --- websocket-sharp/Server/WebSocketServer.cs | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 72281b36f..11298e0de 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -710,25 +710,6 @@ private bool canSet () return _state == ServerState.Ready || _state == ServerState.Stop; } - private bool canSet (out string message) - { - message = null; - - if (_state == ServerState.Start) { - message = "The server has already started."; - - return false; - } - - if (_state == ServerState.ShuttingDown) { - message = "The server is shutting down."; - - return false; - } - - return true; - } - private bool checkHostNameForRequest (string name) { return !_dnsStyle From 0ed6179c00d9bc31f48ebf52a2da66a968a7acea Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 20 Dec 2021 21:35:00 +0900 Subject: [PATCH 4048/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketServer.cs | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 11298e0de..170d6be82 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -1187,17 +1187,8 @@ public void Start () } } - if (_state == ServerState.Start) { - _log.Info ("The server has already started."); - + if (_state == ServerState.Start || _state == ServerState.ShuttingDown) return; - } - - if (_state == ServerState.ShuttingDown) { - _log.Warn ("The server is shutting down."); - - return; - } start (sslConfig); } From 328e521249ee601377f62570bbe61514ae95fa3b Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 21 Dec 2021 19:14:49 +0900 Subject: [PATCH 4049/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketServer.cs | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 170d6be82..f7bfc0a43 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -851,17 +851,8 @@ private void receiveRequest () private void start (ServerSslConfiguration sslConfig) { lock (_sync) { - if (_state == ServerState.Start) { - _log.Info ("The server has already started."); - + if (_state == ServerState.Start || _state == ServerState.ShuttingDown) return; - } - - if (_state == ServerState.ShuttingDown) { - _log.Warn ("The server is shutting down."); - - return; - } _sslConfigInUse = sslConfig; _realmInUse = getRealm (); From 2e146900c6cbbbc522fc1766b181631dd5666d38 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 22 Dec 2021 19:44:15 +0900 Subject: [PATCH 4050/6294] [Modify] Add it --- websocket-sharp/Server/WebSocketServer.cs | 36 +++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index f7bfc0a43..8ad34bd3a 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -848,6 +848,42 @@ private void receiveRequest () abort (); } + private void start () + { + lock (_sync) { + if (_state == ServerState.Start || _state == ServerState.ShuttingDown) + return; + + if (_secure) { + var src = getSslConfiguration (); + var conf = new ServerSslConfiguration (src); + + if (conf.ServerCertificate == null) { + var msg = "There is no server certificate for secure connection."; + + throw new InvalidOperationException (msg); + } + + _sslConfigInUse = conf; + } + + _realmInUse = getRealm (); + + _services.Start (); + + try { + startReceiving (); + } + catch { + _services.Stop (1011, String.Empty); + + throw; + } + + _state = ServerState.Start; + } + } + private void start (ServerSslConfiguration sslConfig) { lock (_sync) { From f514c5244f5b9e2ced2ab7ab4644f3ed0816eae3 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 23 Dec 2021 20:00:59 +0900 Subject: [PATCH 4051/6294] [Modify] Replace it --- websocket-sharp/Server/WebSocketServer.cs | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 8ad34bd3a..c4884bc49 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -1201,23 +1201,10 @@ public bool RemoveWebSocketService (string path) /// public void Start () { - ServerSslConfiguration sslConfig = null; - - if (_secure) { - var src = getSslConfiguration (); - sslConfig = new ServerSslConfiguration (src); - - if (sslConfig.ServerCertificate == null) { - var msg = "There is no server certificate for secure connection."; - - throw new InvalidOperationException (msg); - } - } - if (_state == ServerState.Start || _state == ServerState.ShuttingDown) return; - start (sslConfig); + start (); } /// From 035b08a2c61c1534c22faecf9f1ae6d5fd202bc7 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 23 Dec 2021 20:03:31 +0900 Subject: [PATCH 4052/6294] [Modify] Remove it --- websocket-sharp/Server/WebSocketServer.cs | 24 ----------------------- 1 file changed, 24 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index c4884bc49..efef7d787 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -884,30 +884,6 @@ private void start () } } - private void start (ServerSslConfiguration sslConfig) - { - lock (_sync) { - if (_state == ServerState.Start || _state == ServerState.ShuttingDown) - return; - - _sslConfigInUse = sslConfig; - _realmInUse = getRealm (); - - _services.Start (); - - try { - startReceiving (); - } - catch { - _services.Stop (1011, String.Empty); - - throw; - } - - _state = ServerState.Start; - } - } - private void startReceiving () { if (_reuseAddress) { From ef33547bec53dab77b6fcae2dc0b58cde26c10f5 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 24 Dec 2021 22:08:11 +0900 Subject: [PATCH 4053/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketServer.cs | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index efef7d787..bae6c4264 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -1195,23 +1195,8 @@ public void Start () /// public void Stop () { - if (_state == ServerState.Ready) { - _log.Info ("The server is not started."); - - return; - } - - if (_state == ServerState.ShuttingDown) { - _log.Info ("The server is shutting down."); - + if (_state != ServerState.Start) return; - } - - if (_state == ServerState.Stop) { - _log.Info ("The server has already stopped."); - - return; - } stop (1001, String.Empty); } From 50ae677b2ddbf9dc4a7df5c289b625996d762340 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 24 Dec 2021 22:14:05 +0900 Subject: [PATCH 4054/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketServer.cs | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index bae6c4264..2de220fc7 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -910,17 +910,8 @@ private void startReceiving () private void stop (ushort code, string reason) { lock (_sync) { - if (_state == ServerState.ShuttingDown) { - _log.Info ("The server is shutting down."); - - return; - } - - if (_state == ServerState.Stop) { - _log.Info ("The server has already stopped."); - + if (_state != ServerState.Start) return; - } _state = ServerState.ShuttingDown; } From b0e67956582f5ed63c3f88f36c7d7a6c9d5de5d1 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 25 Dec 2021 23:02:29 +0900 Subject: [PATCH 4055/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketServer.cs | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 2de220fc7..5b876dc7e 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -681,14 +681,19 @@ private void abort () } try { - try { - _listener.Stop (); - } - finally { - _services.Stop (1006, String.Empty); - } + _listener.Stop (); } - catch { + catch (Exception ex) { + _log.Error (ex.Message); + _log.Debug (ex.ToString ()); + } + + try { + _services.Stop (1006, String.Empty); + } + catch (Exception ex) { + _log.Error (ex.Message); + _log.Debug (ex.ToString ()); } _state = ServerState.Stop; From 7be15df2ce6a0ba7f397b91a654c47d3dbc7bb8b Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 26 Dec 2021 22:27:51 +0900 Subject: [PATCH 4056/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketServer.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 5b876dc7e..53612ff2e 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -684,7 +684,7 @@ private void abort () _listener.Stop (); } catch (Exception ex) { - _log.Error (ex.Message); + _log.Fatal (ex.Message); _log.Debug (ex.ToString ()); } @@ -692,7 +692,7 @@ private void abort () _services.Stop (1006, String.Empty); } catch (Exception ex) { - _log.Error (ex.Message); + _log.Fatal (ex.Message); _log.Debug (ex.ToString ()); } From ca78024530f744cacad027d5374fabd569159f93 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 27 Dec 2021 21:24:12 +0900 Subject: [PATCH 4057/6294] [Modify] Do not throw --- websocket-sharp/Server/WebSocketServer.cs | 33 +++++++++-------------- 1 file changed, 13 insertions(+), 20 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 53612ff2e..a9d5d1be7 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -922,29 +922,22 @@ private void stop (ushort code, string reason) } try { - var threw = false; - - try { - stopReceiving (5000); - } - catch { - threw = true; + stopReceiving (5000); + } + catch (Exception ex) { + _log.Fatal (ex.Message); + _log.Debug (ex.ToString ()); + } - throw; - } - finally { - try { - _services.Stop (code, reason); - } - catch { - if (!threw) - throw; - } - } + try { + _services.Stop (code, reason); } - finally { - _state = ServerState.Stop; + catch (Exception ex) { + _log.Fatal (ex.Message); + _log.Debug (ex.ToString ()); } + + _state = ServerState.Stop; } private void stopReceiving (int millisecondsTimeout) From f3b930f6a642bbcb9c86ba2446ea1724de1db571 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 28 Dec 2021 19:38:05 +0900 Subject: [PATCH 4058/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketServer.cs | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index a9d5d1be7..6adffd25d 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -942,15 +942,7 @@ private void stop (ushort code, string reason) private void stopReceiving (int millisecondsTimeout) { - try { - _listener.Stop (); - } - catch (Exception ex) { - var msg = "The underlying listener has failed to stop."; - - throw new InvalidOperationException (msg, ex); - } - + _listener.Stop (); _receiveThread.Join (millisecondsTimeout); } From ef1ef082bc496a6caf832469e1fffef43ce623da Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 29 Dec 2021 21:23:37 +0900 Subject: [PATCH 4059/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 3 --- 1 file changed, 3 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 6adffd25d..086f0d18c 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -1171,9 +1171,6 @@ public void Start () /// This method does nothing if the server is not started, /// it is shutting down, or it has already stopped. /// - /// - /// The underlying has failed to stop. - /// public void Stop () { if (_state != ServerState.Start) From 3e91b1167029e39af35f0be945c2257026915737 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 30 Dec 2021 21:15:51 +0900 Subject: [PATCH 4060/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketServer.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 086f0d18c..445e6eacd 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -906,7 +906,8 @@ private void startReceiving () throw new InvalidOperationException (msg, ex); } - _receiveThread = new Thread (new ThreadStart (receiveRequest)); + var receiver = new ThreadStart (receiveRequest); + _receiveThread = new Thread (receiver); _receiveThread.IsBackground = true; _receiveThread.Start (); From ef75faf763f508520b1897271857f1526f884124 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 31 Dec 2021 17:09:24 +0900 Subject: [PATCH 4061/6294] [Modify] Add it --- websocket-sharp/Server/HttpServer.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index f6cde2166..f16d64792 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -808,6 +808,11 @@ private void abort () _state = ServerState.Stop; } + private bool canSet () + { + return _state == ServerState.Ready || _state == ServerState.Stop; + } + private bool canSet (out string message) { message = null; From e855a140bc10ea085cf62d4bfbf3fc96fa62ed61 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 31 Dec 2021 17:12:08 +0900 Subject: [PATCH 4062/6294] [Modify] Replace it --- websocket-sharp/Server/HttpServer.cs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index f16d64792..d3964d14f 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -346,13 +346,8 @@ public AuthenticationSchemes AuthenticationSchemes { set { lock (_sync) { - string msg; - - if (!canSet (out msg)) { - _log.Warn (msg); - + if (!canSet ()) return; - } _listener.AuthenticationSchemes = value; } From 5f2fb2ad55e3d016971fbcdec5d0ac6349ffa052 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 1 Jan 2022 17:25:00 +0900 Subject: [PATCH 4063/6294] [Modify] 2022 --- LICENSE.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LICENSE.txt b/LICENSE.txt index 4d4e56322..f7473a9b6 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2010-2021 sta.blockhead +Copyright (c) 2010-2022 sta.blockhead Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal From d70bf58dba7a6400ec47f1d15b8d6b44e56efda6 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 1 Jan 2022 17:27:18 +0900 Subject: [PATCH 4064/6294] [Modify] Replace it --- websocket-sharp/Server/HttpServer.cs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index d3964d14f..f8db63728 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -436,13 +436,8 @@ public string DocumentRootPath { throw new ArgumentException ("An absolute root.", "value"); lock (_sync) { - string msg; - - if (!canSet (out msg)) { - _log.Warn (msg); - + if (!canSet ()) return; - } _docRootPath = value; } From 8ab45316d632c75d54c58135b2acda7947ae5368 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 1 Jan 2022 17:31:46 +0900 Subject: [PATCH 4065/6294] [Modify] Replace it --- websocket-sharp/Server/HttpServer.cs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index f8db63728..6105872f8 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -553,13 +553,8 @@ public string Realm { set { lock (_sync) { - string msg; - - if (!canSet (out msg)) { - _log.Warn (msg); - + if (!canSet ()) return; - } _listener.Realm = value; } From 0a23e1ee12d010b9b7b4cbcf6adc7711da63d7c4 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 2 Jan 2022 17:42:53 +0900 Subject: [PATCH 4066/6294] [Modify] Replace it --- websocket-sharp/Server/HttpServer.cs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 6105872f8..5bcd3abbf 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -591,13 +591,8 @@ public bool ReuseAddress { set { lock (_sync) { - string msg; - - if (!canSet (out msg)) { - _log.Warn (msg); - + if (!canSet ()) return; - } _listener.ReuseAddress = value; } From dcb8dcef46719018af0faff0e938bfb1594e4ca3 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 2 Jan 2022 17:45:05 +0900 Subject: [PATCH 4067/6294] [Modify] Replace it --- websocket-sharp/Server/HttpServer.cs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 5bcd3abbf..8692f77dc 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -661,13 +661,8 @@ public Func UserCredentialsFinder { set { lock (_sync) { - string msg; - - if (!canSet (out msg)) { - _log.Warn (msg); - + if (!canSet ()) return; - } _listener.UserCredentialsFinder = value; } From 3f3bbb39b3a3eff76561575a75aa06df112c40dd Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 3 Jan 2022 19:16:38 +0900 Subject: [PATCH 4068/6294] [Modify] Remove it --- websocket-sharp/Server/HttpServer.cs | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 8692f77dc..5b9c150de 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -788,25 +788,6 @@ private bool canSet () return _state == ServerState.Ready || _state == ServerState.Stop; } - private bool canSet (out string message) - { - message = null; - - if (_state == ServerState.Start) { - message = "The server has already started."; - - return false; - } - - if (_state == ServerState.ShuttingDown) { - message = "The server is shutting down."; - - return false; - } - - return true; - } - private bool checkCertificate (out string message) { message = null; From a79b966144a716b1225a534fa580a638ce4990b7 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 4 Jan 2022 22:07:14 +0900 Subject: [PATCH 4069/6294] [Modify] Polish it --- websocket-sharp/Server/HttpServer.cs | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 5b9c150de..06a45663c 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -1334,23 +1334,8 @@ public void Start () /// public void Stop () { - if (_state == ServerState.Ready) { - _log.Info ("The server is not started."); - - return; - } - - if (_state == ServerState.ShuttingDown) { - _log.Info ("The server is shutting down."); - + if (_state != ServerState.Start) return; - } - - if (_state == ServerState.Stop) { - _log.Info ("The server has already stopped."); - - return; - } stop (1001, String.Empty); } From 2d0a35c690082f3131cd4a1038ce7a158231a92b Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 4 Jan 2022 22:09:38 +0900 Subject: [PATCH 4070/6294] [Modify] Polish it --- websocket-sharp/Server/HttpServer.cs | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 06a45663c..710c6b128 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -1310,17 +1310,8 @@ public void Start () throw new InvalidOperationException (msg); } - if (_state == ServerState.Start) { - _log.Info ("The server has already started."); - - return; - } - - if (_state == ServerState.ShuttingDown) { - _log.Warn ("The server is shutting down."); - + if (_state == ServerState.Start || _state == ServerState.ShuttingDown) return; - } start (); } From e65f761fbd7448443d53780ddde6fb75cb7ec237 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 5 Jan 2022 20:18:04 +0900 Subject: [PATCH 4071/6294] [Modify] Polish it --- websocket-sharp/Server/HttpServer.cs | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 710c6b128..383e37c90 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -961,17 +961,8 @@ private void receiveRequest () private void start () { lock (_sync) { - if (_state == ServerState.Start) { - _log.Info ("The server has already started."); - + if (_state == ServerState.Start || _state == ServerState.ShuttingDown) return; - } - - if (_state == ServerState.ShuttingDown) { - _log.Warn ("The server is shutting down."); - - return; - } _services.Start (); From 5b496bdc997d2da1c0a93763a2ac88379c2853ae Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 5 Jan 2022 20:21:57 +0900 Subject: [PATCH 4072/6294] [Modify] Move it --- websocket-sharp/Server/HttpServer.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 383e37c90..6cb798498 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -964,6 +964,13 @@ private void start () if (_state == ServerState.Start || _state == ServerState.ShuttingDown) return; + if (_secure) { + string msg; + + if (!checkCertificate (out msg)) + throw new InvalidOperationException (msg); + } + _services.Start (); try { @@ -1294,13 +1301,6 @@ public bool RemoveWebSocketService (string path) /// public void Start () { - if (_secure) { - string msg; - - if (!checkCertificate (out msg)) - throw new InvalidOperationException (msg); - } - if (_state == ServerState.Start || _state == ServerState.ShuttingDown) return; From b5d62e06cd27c257af12cbf17d97ae4e08751edd Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 6 Jan 2022 21:01:11 +0900 Subject: [PATCH 4073/6294] [Modify] Polish it --- websocket-sharp/Server/HttpServer.cs | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 6cb798498..4fbc5af00 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -1006,17 +1006,8 @@ private void startReceiving () private void stop (ushort code, string reason) { lock (_sync) { - if (_state == ServerState.ShuttingDown) { - _log.Info ("The server is shutting down."); - - return; - } - - if (_state == ServerState.Stop) { - _log.Info ("The server has already stopped."); - + if (_state != ServerState.Start) return; - } _state = ServerState.ShuttingDown; } From 06edc3beaecba4e99ebac2cdaefe0fad89cec2ef Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 6 Jan 2022 21:10:20 +0900 Subject: [PATCH 4074/6294] [Modify] Do not throw --- websocket-sharp/Server/HttpServer.cs | 33 +++++++++++----------------- 1 file changed, 13 insertions(+), 20 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 4fbc5af00..55d93b834 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -1013,29 +1013,22 @@ private void stop (ushort code, string reason) } try { - var threw = false; - - try { - _services.Stop (code, reason); - } - catch { - threw = true; + _services.Stop (code, reason); + } + catch (Exception ex) { + _log.Fatal (ex.Message); + _log.Debug (ex.ToString ()); + } - throw; - } - finally { - try { - stopReceiving (5000); - } - catch { - if (!threw) - throw; - } - } + try { + stopReceiving (5000); } - finally { - _state = ServerState.Stop; + catch (Exception ex) { + _log.Fatal (ex.Message); + _log.Debug (ex.ToString ()); } + + _state = ServerState.Stop; } private void stopReceiving (int millisecondsTimeout) From 958cf8a8f38832e05296a66c199fe656ed43cc1b Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 7 Jan 2022 19:53:13 +0900 Subject: [PATCH 4075/6294] [Modify] Polish it --- websocket-sharp/Server/HttpServer.cs | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 55d93b834..77091937b 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -770,14 +770,19 @@ private void abort () } try { - try { - _services.Stop (1006, String.Empty); - } - finally { - _listener.Abort (); - } + _services.Stop (1006, String.Empty); + } + catch (Exception ex) { + _log.Fatal (ex.Message); + _log.Debug (ex.ToString ()); } - catch { + + try { + _listener.Abort (); + } + catch (Exception ex) { + _log.Fatal (ex.Message); + _log.Debug (ex.ToString ()); } _state = ServerState.Stop; From 6ff583a74a37961225a28e942497853524b5a70f Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 8 Jan 2022 22:07:53 +0900 Subject: [PATCH 4076/6294] [Modify] Polish it --- websocket-sharp/Server/HttpServer.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 77091937b..fb8080c5f 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -1002,7 +1002,8 @@ private void startReceiving () throw new InvalidOperationException (msg, ex); } - _receiveThread = new Thread (new ThreadStart (receiveRequest)); + var receiver = new ThreadStart (receiveRequest); + _receiveThread = new Thread (receiver); _receiveThread.IsBackground = true; _receiveThread.Start (); From 95d96fa06ca71310b50860b805c42185fa7d10a2 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 9 Jan 2022 19:04:02 +0900 Subject: [PATCH 4077/6294] [Modify] Polish it --- websocket-sharp/Server/HttpServer.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index fb8080c5f..99a6f2b74 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -959,8 +959,10 @@ private void receiveRequest () } } - if (_state != ServerState.ShuttingDown) - abort (); + if (_state == ServerState.ShuttingDown) + return; + + abort (); } private void start () From 45e8d444a24d7b1629f2e27a37e99cd630ad172f Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 10 Jan 2022 21:13:39 +0900 Subject: [PATCH 4078/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketServer.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 445e6eacd..b4595a35c 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -830,7 +830,7 @@ private void receiveRequest () if (_state == ServerState.ShuttingDown) { _log.Info ("The underlying listener is stopped."); - break; + return; } _log.Fatal (ex.Message); @@ -845,12 +845,14 @@ private void receiveRequest () if (cl != null) cl.Close (); + if (_state == ServerState.ShuttingDown) + return; + break; } } - if (_state != ServerState.ShuttingDown) - abort (); + abort (); } private void start () From 9680857c95698e280184143de1f0809cc347414a Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 11 Jan 2022 19:57:15 +0900 Subject: [PATCH 4079/6294] [Modify] Add a catch --- websocket-sharp/Server/WebSocketServer.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index b4595a35c..4b33e064b 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -838,6 +838,18 @@ private void receiveRequest () break; } + catch (InvalidOperationException ex) { + if (_state == ServerState.ShuttingDown) { + _log.Info ("The underlying listener is stopped."); + + return; + } + + _log.Fatal (ex.Message); + _log.Debug (ex.ToString ()); + + break; + } catch (Exception ex) { _log.Fatal (ex.Message); _log.Debug (ex.ToString ()); From c6d6d5de3be61c99bdfc44d36b604d8990405341 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 11 Jan 2022 19:59:06 +0900 Subject: [PATCH 4080/6294] [Modify] 2022 --- websocket-sharp/Server/WebSocketServer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 4b33e064b..e1a775afb 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -4,7 +4,7 @@ * * The MIT License * - * Copyright (c) 2012-2021 sta.blockhead + * Copyright (c) 2012-2022 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From 7a29844836300be0e7b114b39967dd3acd9f383e Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 12 Jan 2022 19:38:13 +0900 Subject: [PATCH 4081/6294] [Modify] Polish it --- websocket-sharp/Server/HttpServer.cs | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 99a6f2b74..b28b4076e 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -938,13 +938,27 @@ private void receiveRequest () } ); } - catch (HttpListenerException) { - _log.Info ("The underlying listener is stopped."); + catch (HttpListenerException ex) { + if (_state == ServerState.ShuttingDown) { + _log.Info ("The underlying listener is stopped."); + + return; + } + + _log.Fatal (ex.Message); + _log.Debug (ex.ToString ()); break; } - catch (InvalidOperationException) { - _log.Info ("The underlying listener is stopped."); + catch (InvalidOperationException ex) { + if (_state == ServerState.ShuttingDown) { + _log.Info ("The underlying listener is stopped."); + + return; + } + + _log.Fatal (ex.Message); + _log.Debug (ex.ToString ()); break; } @@ -955,13 +969,13 @@ private void receiveRequest () if (ctx != null) ctx.Connection.Close (true); + if (_state == ServerState.ShuttingDown) + return; + break; } } - if (_state == ServerState.ShuttingDown) - return; - abort (); } From 7505b4ba8e5b88d238b88af4c356564964105965 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 12 Jan 2022 19:41:20 +0900 Subject: [PATCH 4082/6294] [Modify] Polish it --- websocket-sharp/Server/HttpServer.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index b28b4076e..19d92eea8 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -829,6 +829,7 @@ private static HttpListener createListener ( var schm = secure ? "https" : "http"; var pref = String.Format ("{0}://{1}:{2}/", schm, hostname, port); + lsnr.Prefixes.Add (pref); return lsnr; From 694ff38670079404bd8bd7b94f459be1e53446fa Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 13 Jan 2022 21:27:35 +0900 Subject: [PATCH 4083/6294] [Modify] Replace it --- websocket-sharp/Server/HttpServer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 19d92eea8..751f84148 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -931,7 +931,7 @@ private void receiveRequest () processRequest (ctx); } catch (Exception ex) { - _log.Fatal (ex.Message); + _log.Error (ex.Message); _log.Debug (ex.ToString ()); ctx.Connection.Close (true); From eb478185a78420b7e0aedac49542401be89cc262 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 13 Jan 2022 21:30:19 +0900 Subject: [PATCH 4084/6294] [Modify] 2022 --- websocket-sharp/Server/HttpServer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 751f84148..82284f8f3 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -4,7 +4,7 @@ * * The MIT License * - * Copyright (c) 2012-2021 sta.blockhead + * Copyright (c) 2012-2022 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From 5f346e16513d59b4a6cf60d65d3bd4c92f3edc8a Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 14 Jan 2022 19:47:24 +0900 Subject: [PATCH 4085/6294] [Modify] Edit it Those methods were obsolete. --- README.md | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/README.md b/README.md index e7049b224..4ceac2a2c 100644 --- a/README.md +++ b/README.md @@ -404,13 +404,9 @@ wssv.Start (); Stopping the WebSocket server. ```csharp -wssv.Stop (code, reason); +wssv.Stop (); ``` -The `WebSocketServer.Stop` method is overloaded. - -You can use the `WebSocketServer.Stop ()`, `WebSocketServer.Stop (ushort, string)`, or `WebSocketServer.Stop (WebSocketSharp.CloseStatusCode, string)` method to stop the server. - ### HTTP Server with the WebSocket ### I have modified the `System.Net.HttpListener`, `System.Net.HttpListenerContext`, and some other classes from **[Mono]** to create an HTTP server that allows to accept the WebSocket handshake requests. From f271ed448f76203781d8ed805746197bee764c95 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 15 Jan 2022 17:45:26 +0900 Subject: [PATCH 4086/6294] [Modify] Edit it --- README.md | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 4ceac2a2c..6dd58ef98 100644 --- a/README.md +++ b/README.md @@ -340,13 +340,18 @@ public class Chat : WebSocketBehavior private string _suffix; public Chat () - : this (null) { + _suffix = String.Empty; } - public Chat (string suffix) - { - _suffix = suffix ?? String.Empty; + public string Suffix { + get { + return _suffix; + } + + set { + _suffix = value ?? String.Empty; + } } protected override void OnMessage (MessageEventArgs e) From 16500570b944c86b6fb803fad555f50025004e9b Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 16 Jan 2022 21:27:19 +0900 Subject: [PATCH 4087/6294] [Modify] Edit it --- README.md | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 6dd58ef98..a28a9860e 100644 --- a/README.md +++ b/README.md @@ -379,16 +379,15 @@ Creating a new instance of the `WebSocketServer` class. ```csharp var wssv = new WebSocketServer (4649); + wssv.AddWebSocketService ("/Echo"); wssv.AddWebSocketService ("/Chat"); -wssv.AddWebSocketService ("/ChatWithNyan", () => new Chat (" Nyan!")); +wssv.AddWebSocketService ("/ChatWithNyan", s => s.Suffix = " Nyan!"); ``` -You can add any WebSocket service to your `WebSocketServer` with the specified behavior and absolute path to the service, by using the `WebSocketServer.AddWebSocketService (string)` or `WebSocketServer.AddWebSocketService (string, Func)` method. - -The type of `TBehaviorWithNew` must inherit the `WebSocketBehavior` class, and must have a public parameterless constructor. +You can add any WebSocket service to your `WebSocketServer` with the specified behavior and absolute path to the service, by using the `WebSocketServer.AddWebSocketService (string)` or `WebSocketServer.AddWebSocketService (string, Action)` method. -The type of `TBehavior` must inherit the `WebSocketBehavior` class. +The type of `TBehavior` must inherit the `WebSocketBehavior` class, and must have a public parameterless constructor. So you can use a class in the above Step 2 to add the service. From 03f523740d00147cf59d50b33f578310e8175646 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 17 Jan 2022 17:34:40 +0900 Subject: [PATCH 4088/6294] [Modify] Edit it --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index a28a9860e..6a7e8ece1 100644 --- a/README.md +++ b/README.md @@ -417,13 +417,14 @@ I have modified the `System.Net.HttpListener`, `System.Net.HttpListenerContext`, So websocket-sharp provides the `WebSocketSharp.Server.HttpServer` class. -You can add any WebSocket service to your `HttpServer` with the specified behavior and path to the service, by using the `HttpServer.AddWebSocketService (string)` or `HttpServer.AddWebSocketService (string, Func)` method. +You can add any WebSocket service to your `HttpServer` with the specified behavior and path to the service, by using the `HttpServer.AddWebSocketService (string)` or `HttpServer.AddWebSocketService (string, Action)` method. ```csharp var httpsv = new HttpServer (4649); + httpsv.AddWebSocketService ("/Echo"); httpsv.AddWebSocketService ("/Chat"); -httpsv.AddWebSocketService ("/ChatWithNyan", () => new Chat (" Nyan!")); +httpsv.AddWebSocketService ("/ChatWithNyan", s => s.Suffix = " Nyan!"); ``` For more information, would you see **[Example3]**? From 53ade2eb47a57d780348f9406fb671d7bedd73fb Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 18 Jan 2022 21:21:29 +0900 Subject: [PATCH 4089/6294] [Modify] Edit it --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 6a7e8ece1..dbc04b6cb 100644 --- a/README.md +++ b/README.md @@ -277,7 +277,7 @@ namespace Example protected override void OnMessage (MessageEventArgs e) { var msg = e.Data == "BALUS" - ? "I've been balused already..." + ? "Are you kidding?" : "I'm not available now."; Send (msg); @@ -289,6 +289,7 @@ namespace Example public static void Main (string[] args) { var wssv = new WebSocketServer ("ws://dragonsnest.far"); + wssv.AddWebSocketService ("/Laputa"); wssv.Start (); Console.ReadKey (true); From b4b54b327743f857d6bc068663be1fd03033a73f Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 19 Jan 2022 20:08:36 +0900 Subject: [PATCH 4090/6294] [Modify] Replace it --- Example2/Chat.cs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/Example2/Chat.cs b/Example2/Chat.cs index a6b367d96..c68539a17 100644 --- a/Example2/Chat.cs +++ b/Example2/Chat.cs @@ -12,13 +12,18 @@ public class Chat : WebSocketBehavior private string _prefix; public Chat () - : this (null) { + _prefix = "anon#"; } - public Chat (string prefix) - { - _prefix = !prefix.IsNullOrEmpty () ? prefix : "anon#"; + public string Prefix { + get { + return _prefix; + } + + set { + _prefix = !value.IsNullOrEmpty () ? value : "anon#"; + } } private string getName () From 9b7910c14570691e9c7828dc9b07e68c36a9fc4f Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 19 Jan 2022 20:14:30 +0900 Subject: [PATCH 4091/6294] [Modify] Polish it --- Example2/Chat.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Example2/Chat.cs b/Example2/Chat.cs index c68539a17..d5977bec7 100644 --- a/Example2/Chat.cs +++ b/Example2/Chat.cs @@ -28,7 +28,8 @@ public string Prefix { private string getName () { - var name = Context.QueryString["name"]; + var name = QueryString["name"]; + return !name.IsNullOrEmpty () ? name : _prefix + getNumber (); } From a85e637d5b828b101029b210cbdf05b575ff78b7 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 20 Jan 2022 21:01:31 +0900 Subject: [PATCH 4092/6294] [Modify] Polish it --- Example2/Chat.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Example2/Chat.cs b/Example2/Chat.cs index d5977bec7..1e98db75a 100644 --- a/Example2/Chat.cs +++ b/Example2/Chat.cs @@ -40,7 +40,10 @@ private static int getNumber () protected override void OnClose (CloseEventArgs e) { - Sessions.Broadcast (String.Format ("{0} got logged off...", _name)); + var fmt = "{0} got logged off..."; + var msg = String.Format (fmt, _name); + + Sessions.Broadcast (msg); } protected override void OnMessage (MessageEventArgs e) From 728f13d1dedd3f93513b9c5d459deb5f97f29f1d Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 20 Jan 2022 21:05:25 +0900 Subject: [PATCH 4093/6294] [Modify] Polish it --- Example2/Chat.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Example2/Chat.cs b/Example2/Chat.cs index 1e98db75a..eb6370f52 100644 --- a/Example2/Chat.cs +++ b/Example2/Chat.cs @@ -48,7 +48,10 @@ protected override void OnClose (CloseEventArgs e) protected override void OnMessage (MessageEventArgs e) { - Sessions.Broadcast (String.Format ("{0}: {1}", _name, e.Data)); + var fmt = "{0}: {1}"; + var msg = String.Format (fmt, _name, e.Data); + + Sessions.Broadcast (msg); } protected override void OnOpen () From a135180ecfcefc477f67d786cd88d2df2c000f50 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 21 Jan 2022 19:41:10 +0900 Subject: [PATCH 4094/6294] [Modify] Polish it --- Example2/Chat.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Example2/Chat.cs b/Example2/Chat.cs index eb6370f52..940830b65 100644 --- a/Example2/Chat.cs +++ b/Example2/Chat.cs @@ -57,6 +57,11 @@ protected override void OnMessage (MessageEventArgs e) protected override void OnOpen () { _name = getName (); + + var fmt = "{0} has logged in!"; + var msg = String.Format (fmt, _name); + + Sessions.Broadcast (msg); } } } From ee3a00a6e268b3e4e9aeecf3783eab342ac30fb6 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 22 Jan 2022 17:52:21 +0900 Subject: [PATCH 4095/6294] [Modify] Polish it --- Example2/Echo.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Example2/Echo.cs b/Example2/Echo.cs index dd780c8d1..73552921f 100644 --- a/Example2/Echo.cs +++ b/Example2/Echo.cs @@ -8,8 +8,12 @@ public class Echo : WebSocketBehavior { protected override void OnMessage (MessageEventArgs e) { - var name = Context.QueryString["name"]; - Send (!name.IsNullOrEmpty () ? String.Format ("\"{0}\" to {1}", e.Data, name) : e.Data); + var name = QueryString["name"]; + var msg = !name.IsNullOrEmpty () + ? String.Format ("\"{0}\" to {1}", e.Data, name) + : e.Data; + + Send (msg); } } } From 21e8bed00264eb53636bf3c6eadf5b9543013b8a Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 23 Jan 2022 17:36:12 +0900 Subject: [PATCH 4096/6294] [Modify] Polish it --- Example2/Echo.cs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/Example2/Echo.cs b/Example2/Echo.cs index 73552921f..edc8872f9 100644 --- a/Example2/Echo.cs +++ b/Example2/Echo.cs @@ -8,12 +8,7 @@ public class Echo : WebSocketBehavior { protected override void OnMessage (MessageEventArgs e) { - var name = QueryString["name"]; - var msg = !name.IsNullOrEmpty () - ? String.Format ("\"{0}\" to {1}", e.Data, name) - : e.Data; - - Send (msg); + Send (e.Data); } } } From 421bf4b6b724bc1b4ab16c085e32c991fd78ce23 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 24 Jan 2022 22:14:17 +0900 Subject: [PATCH 4097/6294] [Modify] Replace it --- Example2/Program.cs | 60 +++++++++++++++++++++++++-------------------- 1 file changed, 33 insertions(+), 27 deletions(-) diff --git a/Example2/Program.cs b/Example2/Program.cs index c9bd7ef3d..39a96b616 100644 --- a/Example2/Program.cs +++ b/Example2/Program.cs @@ -88,34 +88,40 @@ public static void Main (string[] args) /* wssv.AddWebSocketService ( "/Chat", - () => - new Chat ("Anon#") { - // To send the Sec-WebSocket-Protocol header that has a subprotocol name. - Protocol = "chat", - // To ignore the Sec-WebSocket-Extensions header. - IgnoreExtensions = true, - // To emit a WebSocket.OnMessage event when receives a ping. - EmitOnPing = true, - // To validate the Origin header. - OriginValidator = val => { - // Check the value of the Origin header, and return true if valid. - Uri origin; - return !val.IsNullOrEmpty () - && Uri.TryCreate (val, UriKind.Absolute, out origin) - && origin.Host == "localhost"; - }, - // To validate the cookies. - CookiesValidator = (req, res) => { - // Check the cookies in 'req', and set the cookies to send to - // the client with 'res' if necessary. - foreach (Cookie cookie in req) { - cookie.Expired = true; - res.Add (cookie); - } - - return true; // If valid. + s => { + s.Prefix = "Anon#"; + + // To send the Sec-WebSocket-Protocol header that has a subprotocol name. + s.Protocol = "chat"; + + // To ignore the Sec-WebSocket-Extensions header. + s.IgnoreExtensions = true; + + // To emit a WebSocket.OnMessage event when receives a ping. + s.EmitOnPing = true; + + // To validate the Origin header. + s.OriginValidator = val => { + // Check the value of the Origin header, and return true if valid. + Uri origin; + + return !val.IsNullOrEmpty () + && Uri.TryCreate (val, UriKind.Absolute, out origin) + && origin.Host == "localhost"; + }; + + // To validate the cookies. + s.CookiesValidator = (req, res) => { + // Check the cookies in 'req', and set the cookies to send to + // the client with 'res' if necessary. + foreach (Cookie cookie in req) { + cookie.Expired = true; + res.Add (cookie); } - } + + return true; // If valid. + }; + } ); */ From 227925a40cf31bd603d3cbc409ff26a2db5a7382 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 24 Jan 2022 22:16:13 +0900 Subject: [PATCH 4098/6294] [Modify] Polish it --- Example2/Program.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Example2/Program.cs b/Example2/Program.cs index 39a96b616..f15f277da 100644 --- a/Example2/Program.cs +++ b/Example2/Program.cs @@ -126,8 +126,10 @@ public static void Main (string[] args) */ wssv.Start (); + if (wssv.IsListening) { Console.WriteLine ("Listening on port {0}, and providing WebSocket services:", wssv.Port); + foreach (var path in wssv.WebSocketServices.Paths) Console.WriteLine ("- {0}", path); } From 8b9eb8f118962e9ba9c02cba9e7491ca51436d32 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 25 Jan 2022 21:15:02 +0900 Subject: [PATCH 4099/6294] [Modify] Edit it --- Example2/Program.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Example2/Program.cs b/Example2/Program.cs index f15f277da..87f0eb29a 100644 --- a/Example2/Program.cs +++ b/Example2/Program.cs @@ -73,7 +73,7 @@ public static void Main (string[] args) // Return user name, password, and roles. return name == "nobita" ? new NetworkCredential (name, "password", "gunfighter") - : null; // If the user credentials aren't found. + : null; // If the user credentials are not found. }; */ From ac5bcba7a1ff940a6025bd45bc55d7ab8158aaff Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 26 Jan 2022 19:34:24 +0900 Subject: [PATCH 4100/6294] [Modify] Polish it --- Example3/Echo.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Example3/Echo.cs b/Example3/Echo.cs index eb7c33410..01e2f16af 100644 --- a/Example3/Echo.cs +++ b/Example3/Echo.cs @@ -8,8 +8,7 @@ public class Echo : WebSocketBehavior { protected override void OnMessage (MessageEventArgs e) { - var name = Context.QueryString["name"]; - Send (!name.IsNullOrEmpty () ? String.Format ("\"{0}\" to {1}", e.Data, name) : e.Data); + Send (e.Data); } } } From 6f4a9c7f52bd6618aa29e66f3cd413d3621f7909 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 26 Jan 2022 19:37:19 +0900 Subject: [PATCH 4101/6294] [Modify] Replace it --- Example3/Chat.cs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/Example3/Chat.cs b/Example3/Chat.cs index b1a3f4d7d..2aee3e3a2 100644 --- a/Example3/Chat.cs +++ b/Example3/Chat.cs @@ -12,13 +12,18 @@ public class Chat : WebSocketBehavior private string _prefix; public Chat () - : this (null) { + _prefix = "anon#"; } - public Chat (string prefix) - { - _prefix = !prefix.IsNullOrEmpty () ? prefix : "anon#"; + public string Prefix { + get { + return _prefix; + } + + set { + _prefix = !value.IsNullOrEmpty () ? value : "anon#"; + } } private string getName () From 590a3eba2ca5269394a7ff7b018251d5ba311c26 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 26 Jan 2022 19:39:12 +0900 Subject: [PATCH 4102/6294] [Modify] Polish it --- Example3/Chat.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Example3/Chat.cs b/Example3/Chat.cs index 2aee3e3a2..0c93a3e9e 100644 --- a/Example3/Chat.cs +++ b/Example3/Chat.cs @@ -28,7 +28,8 @@ public string Prefix { private string getName () { - var name = Context.QueryString["name"]; + var name = QueryString["name"]; + return !name.IsNullOrEmpty () ? name : _prefix + getNumber (); } From 843c789b8a3005712959b1375cb8e8e99571fa2b Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 27 Jan 2022 21:03:30 +0900 Subject: [PATCH 4103/6294] [Modify] Polish it --- Example3/Chat.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Example3/Chat.cs b/Example3/Chat.cs index 0c93a3e9e..31f718f8c 100644 --- a/Example3/Chat.cs +++ b/Example3/Chat.cs @@ -40,7 +40,10 @@ private static int getNumber () protected override void OnClose (CloseEventArgs e) { - Sessions.Broadcast (String.Format ("{0} got logged off...", _name)); + var fmt = "{0} got logged off..."; + var msg = String.Format (fmt, _name); + + Sessions.Broadcast (msg); } protected override void OnMessage (MessageEventArgs e) From d6a98c3f63c2acc76e01477829691ecf3d47b724 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 27 Jan 2022 21:07:29 +0900 Subject: [PATCH 4104/6294] [Modify] Add a null check --- Example3/Chat.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Example3/Chat.cs b/Example3/Chat.cs index 31f718f8c..bfc431832 100644 --- a/Example3/Chat.cs +++ b/Example3/Chat.cs @@ -40,6 +40,9 @@ private static int getNumber () protected override void OnClose (CloseEventArgs e) { + if (_name == null) + return; + var fmt = "{0} got logged off..."; var msg = String.Format (fmt, _name); From 5c7c3e171b21674e2d2af67b2eccc9d7a237dc01 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 27 Jan 2022 21:17:01 +0900 Subject: [PATCH 4105/6294] [Modify] Add a null check --- Example2/Chat.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Example2/Chat.cs b/Example2/Chat.cs index 940830b65..2391bf313 100644 --- a/Example2/Chat.cs +++ b/Example2/Chat.cs @@ -40,6 +40,9 @@ private static int getNumber () protected override void OnClose (CloseEventArgs e) { + if (_name == null) + return; + var fmt = "{0} got logged off..."; var msg = String.Format (fmt, _name); From 750c71e1bed8a194fdc5ed755fe9f8bf6632c64b Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 28 Jan 2022 20:21:34 +0900 Subject: [PATCH 4106/6294] [Modify] Polish it --- Example3/Chat.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Example3/Chat.cs b/Example3/Chat.cs index bfc431832..fd85b5316 100644 --- a/Example3/Chat.cs +++ b/Example3/Chat.cs @@ -51,7 +51,10 @@ protected override void OnClose (CloseEventArgs e) protected override void OnMessage (MessageEventArgs e) { - Sessions.Broadcast (String.Format ("{0}: {1}", _name, e.Data)); + var fmt = "{0}: {1}"; + var msg = String.Format (fmt, _name, e.Data); + + Sessions.Broadcast (msg); } protected override void OnOpen () From 468119790c716b8281e07ff834facb0ff719203c Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 28 Jan 2022 20:24:13 +0900 Subject: [PATCH 4107/6294] [Modify] Polish it --- Example3/Chat.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Example3/Chat.cs b/Example3/Chat.cs index fd85b5316..0e3f38214 100644 --- a/Example3/Chat.cs +++ b/Example3/Chat.cs @@ -60,6 +60,11 @@ protected override void OnMessage (MessageEventArgs e) protected override void OnOpen () { _name = getName (); + + var fmt = "{0} has logged in!"; + var msg = String.Format (fmt, _name); + + Sessions.Broadcast (msg); } } } From d6ce6370007ab9ec9a525e0d5308ced8226d71ec Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 29 Jan 2022 21:34:25 +0900 Subject: [PATCH 4108/6294] [Modify] Replace it --- Example3/Program.cs | 60 +++++++++++++++++++++++++-------------------- 1 file changed, 33 insertions(+), 27 deletions(-) diff --git a/Example3/Program.cs b/Example3/Program.cs index b9699531f..83f4e8611 100644 --- a/Example3/Program.cs +++ b/Example3/Program.cs @@ -120,34 +120,40 @@ public static void Main (string[] args) /* httpsv.AddWebSocketService ( "/Chat", - () => - new Chat ("Anon#") { - // To send the Sec-WebSocket-Protocol header that has a subprotocol name. - Protocol = "chat", - // To ignore the Sec-WebSocket-Extensions header. - IgnoreExtensions = true, - // To emit a WebSocket.OnMessage event when receives a ping. - EmitOnPing = true, - // To validate the Origin header. - OriginValidator = val => { - // Check the value of the Origin header, and return true if valid. - Uri origin; - return !val.IsNullOrEmpty () - && Uri.TryCreate (val, UriKind.Absolute, out origin) - && origin.Host == "localhost"; - }, - // To validate the cookies. - CookiesValidator = (req, res) => { - // Check the cookies in 'req', and set the cookies to send to - // the client with 'res' if necessary. - foreach (Cookie cookie in req) { - cookie.Expired = true; - res.Add (cookie); - } - - return true; // If valid. + s => { + s.Prefix = "Anon#"; + + // To send the Sec-WebSocket-Protocol header that has a subprotocol name. + s.Protocol = "chat"; + + // To ignore the Sec-WebSocket-Extensions header. + s.IgnoreExtensions = true; + + // To emit a WebSocket.OnMessage event when receives a ping. + s.EmitOnPing = true; + + // To validate the Origin header. + s.OriginValidator = val => { + // Check the value of the Origin header, and return true if valid. + Uri origin; + + return !val.IsNullOrEmpty () + && Uri.TryCreate (val, UriKind.Absolute, out origin) + && origin.Host == "localhost"; + }; + + // To validate the cookies. + s.CookiesValidator = (req, res) => { + // Check the cookies in 'req', and set the cookies to send to + // the client with 'res' if necessary. + foreach (var cookie in req) { + cookie.Expired = true; + res.Add (cookie); } - } + + return true; // If valid. + }; + } ); */ From 7f916edafa8d54b03494aecb508178e7b670a442 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 29 Jan 2022 21:36:02 +0900 Subject: [PATCH 4109/6294] [Modify] Polish it --- Example2/Program.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Example2/Program.cs b/Example2/Program.cs index 87f0eb29a..645fc4d95 100644 --- a/Example2/Program.cs +++ b/Example2/Program.cs @@ -114,7 +114,7 @@ public static void Main (string[] args) s.CookiesValidator = (req, res) => { // Check the cookies in 'req', and set the cookies to send to // the client with 'res' if necessary. - foreach (Cookie cookie in req) { + foreach (var cookie in req) { cookie.Expired = true; res.Add (cookie); } From 6f6c110dc96495f39f4cee71b502482a6baff76c Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 30 Jan 2022 22:16:15 +0900 Subject: [PATCH 4110/6294] [Modify] Polish it --- Example3/Program.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Example3/Program.cs b/Example3/Program.cs index 83f4e8611..58fb125f9 100644 --- a/Example3/Program.cs +++ b/Example3/Program.cs @@ -158,8 +158,10 @@ public static void Main (string[] args) */ httpsv.Start (); + if (httpsv.IsListening) { Console.WriteLine ("Listening on port {0}, and providing WebSocket services:", httpsv.Port); + foreach (var path in httpsv.WebSocketServices.Paths) Console.WriteLine ("- {0}", path); } From 5ffe299ebe2d902780b672288f96421870c9a33e Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 30 Jan 2022 22:22:43 +0900 Subject: [PATCH 4111/6294] [Modify] Polish it --- Example3/Program.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Example3/Program.cs b/Example3/Program.cs index 58fb125f9..81a405cb7 100644 --- a/Example3/Program.cs +++ b/Example3/Program.cs @@ -90,12 +90,15 @@ public static void Main (string[] args) var res = e.Response; var path = req.RawUrl; + if (path == "/") path += "index.html"; byte[] contents; + if (!e.TryReadFile (path, out contents)) { res.StatusCode = (int) HttpStatusCode.NotFound; + return; } @@ -109,6 +112,7 @@ public static void Main (string[] args) } res.ContentLength64 = contents.LongLength; + res.Close (contents, true); }; From 7951ef012ff2021346c4b8fa47ac20caee9c1a70 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 31 Jan 2022 21:57:51 +0900 Subject: [PATCH 4112/6294] [Modify] Edit it --- Example3/Program.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Example3/Program.cs b/Example3/Program.cs index 81a405cb7..b6c82fce2 100644 --- a/Example3/Program.cs +++ b/Example3/Program.cs @@ -74,7 +74,7 @@ public static void Main (string[] args) // Return user name, password, and roles. return name == "nobita" ? new NetworkCredential (name, "password", "gunfighter") - : null; // If the user credentials aren't found. + : null; // If the user credentials are not found. }; */ From ef8907c1d0ba3d93201430145deca1b3b23f2d58 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 1 Feb 2022 21:14:45 +0900 Subject: [PATCH 4113/6294] [Modify] Edit it --- Example3/Program.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Example3/Program.cs b/Example3/Program.cs index b6c82fce2..b338e10b3 100644 --- a/Example3/Program.cs +++ b/Example3/Program.cs @@ -15,8 +15,8 @@ public static void Main (string[] args) // Create a new instance of the HttpServer class. // // If you would like to provide the secure connection, you should - // create a new instance with the 'secure' parameter set to true, - // or an https scheme HTTP URL. + // create a new instance with the 'secure' parameter set to true or + // with an https scheme HTTP URL. var httpsv = new HttpServer (4649); //var httpsv = new HttpServer (5963, true); From 1c9fa6b2cf9668b2714c670cf931fac80f71fde4 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 1 Feb 2022 21:18:04 +0900 Subject: [PATCH 4114/6294] [Modify] Edit it --- Example2/Program.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Example2/Program.cs b/Example2/Program.cs index 645fc4d95..7b024a0ee 100644 --- a/Example2/Program.cs +++ b/Example2/Program.cs @@ -14,8 +14,8 @@ public static void Main (string[] args) // Create a new instance of the WebSocketServer class. // // If you would like to provide the secure connection, you should - // create a new instance with the 'secure' parameter set to true, - // or a wss scheme WebSocket URL. + // create a new instance with the 'secure' parameter set to true or + // with a wss scheme WebSocket URL. var wssv = new WebSocketServer (4649); //var wssv = new WebSocketServer (5963, true); From a845aa1230a50d6d41fbdc4dff7cb84b1cb022c1 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 2 Feb 2022 22:06:03 +0900 Subject: [PATCH 4115/6294] [Delete] Example1 --- Example1/AssemblyInfo.cs | 26 ----- Example1/AudioStreamer.cs | 192 -------------------------------- Example1/BinaryMessage.cs | 74 ------------ Example1/Example1.csproj | 77 ------------- Example1/NotificationMessage.cs | 24 ---- Example1/Notifier.cs | 81 -------------- Example1/Program.cs | 37 ------ Example1/TextMessage.cs | 33 ------ websocket-sharp.sln | 10 -- 9 files changed, 554 deletions(-) delete mode 100644 Example1/AssemblyInfo.cs delete mode 100644 Example1/AudioStreamer.cs delete mode 100644 Example1/BinaryMessage.cs delete mode 100644 Example1/Example1.csproj delete mode 100644 Example1/NotificationMessage.cs delete mode 100644 Example1/Notifier.cs delete mode 100644 Example1/Program.cs delete mode 100644 Example1/TextMessage.cs diff --git a/Example1/AssemblyInfo.cs b/Example1/AssemblyInfo.cs deleted file mode 100644 index a78e6c6de..000000000 --- a/Example1/AssemblyInfo.cs +++ /dev/null @@ -1,26 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; - -// Information about this assembly is defined by the following attributes. -// Change them to the values specific to your project. - -[assembly: AssemblyTitle("Example1")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("")] -[assembly: AssemblyCopyright("sta.blockhead")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}". -// The form "{Major}.{Minor}.*" will automatically update the build and revision, -// and "{Major}.{Minor}.{Build}.*" will update just the revision. - -[assembly: AssemblyVersion("1.0.*")] - -// The following attributes are used to specify the signing key for the assembly, -// if desired. See the Mono documentation for more information about signing. - -//[assembly: AssemblyDelaySign(false)] -//[assembly: AssemblyKeyFile("")] diff --git a/Example1/AudioStreamer.cs b/Example1/AudioStreamer.cs deleted file mode 100644 index 711694e9a..000000000 --- a/Example1/AudioStreamer.cs +++ /dev/null @@ -1,192 +0,0 @@ -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using System; -using System.Collections; -using System.Collections.Generic; -using System.Text; -using System.Threading; -using WebSocketSharp; - -namespace Example1 -{ - internal class AudioStreamer : IDisposable - { - private Dictionary _audioBox; - private uint? _id; - private string _name; - private Notifier _notifier; - private Timer _timer; - private WebSocket _websocket; - - public AudioStreamer (string url) - { - _websocket = new WebSocket (url); - - _audioBox = new Dictionary (); - _id = null; - _notifier = new Notifier (); - _timer = new Timer (sendHeartbeat, null, -1, -1); - - configure (); - } - - private void configure () - { -#if DEBUG - _websocket.Log.Level = LogLevel.Trace; -#endif - _websocket.OnOpen += (sender, e) => - _websocket.Send (createTextMessage ("connection", String.Empty)); - - _websocket.OnMessage += (sender, e) => { - if (e.IsText) { - _notifier.Notify (processTextMessage (e.Data)); - return; - } - - if (e.IsBinary) { - processBinaryMessage (e.RawData); - return; - } - }; - - _websocket.OnError += (sender, e) => - _notifier.Notify ( - new NotificationMessage { - Summary = "AudioStreamer (error)", - Body = e.Message, - Icon = "notification-message-im" - } - ); - - _websocket.OnClose += (sender, e) => - _notifier.Notify ( - new NotificationMessage { - Summary = "AudioStreamer (disconnect)", - Body = String.Format ("code: {0} reason: {1}", e.Code, e.Reason), - Icon = "notification-message-im" - } - ); - } - - private byte[] createBinaryMessage (float[,] bufferArray) - { - return new BinaryMessage { - UserID = (uint) _id, - ChannelNumber = (byte) bufferArray.GetLength (0), - BufferLength = (uint) bufferArray.GetLength (1), - BufferArray = bufferArray - } - .ToArray (); - } - - private string createTextMessage (string type, string message) - { - return new TextMessage { - UserID = _id, - Name = _name, - Type = type, - Message = message - } - .ToString (); - } - - private void processBinaryMessage (byte[] data) - { - var msg = BinaryMessage.Parse (data); - - var id = msg.UserID; - if (id == _id) - return; - - Queue queue; - if (_audioBox.TryGetValue (id, out queue)) { - queue.Enqueue (msg.BufferArray); - return; - } - - queue = Queue.Synchronized (new Queue ()); - queue.Enqueue (msg.BufferArray); - _audioBox.Add (id, queue); - } - - private NotificationMessage processTextMessage (string data) - { - var json = JObject.Parse (data); - var id = (uint) json["user_id"]; - var name = (string) json["name"]; - var type = (string) json["type"]; - - string body; - if (type == "message") { - body = String.Format ("{0}: {1}", name, (string) json["message"]); - } - else if (type == "start_music") { - body = String.Format ("{0}: Started playing music!", name); - } - else if (type == "connection") { - var users = (JArray) json["message"]; - var buff = new StringBuilder ("Now keeping connections:"); - foreach (JToken user in users) { - buff.AppendFormat ( - "\n- user_id: {0} name: {1}", (uint) user["user_id"], (string) user["name"] - ); - } - - body = buff.ToString (); - } - else if (type == "connected") { - _id = id; - _timer.Change (30000, 30000); - - body = String.Format ("user_id: {0} name: {1}", id, name); - } - else { - body = "Received unknown type message."; - } - - return new NotificationMessage { - Summary = String.Format ("AudioStreamer ({0})", type), - Body = body, - Icon = "notification-message-im" - }; - } - - private void sendHeartbeat (object state) - { - _websocket.Send (createTextMessage ("heartbeat", String.Empty)); - } - - public void Close () - { - Disconnect (); - _timer.Dispose (); - _notifier.Close (); - } - - public void Connect (string username) - { - _name = username; - _websocket.Connect (); - } - - public void Disconnect () - { - _timer.Change (-1, -1); - _websocket.Close (CloseStatusCode.Away); - _audioBox.Clear (); - _id = null; - _name = null; - } - - public void Write (string message) - { - _websocket.Send (createTextMessage ("message", message)); - } - - void IDisposable.Dispose () - { - Close (); - } - } -} diff --git a/Example1/BinaryMessage.cs b/Example1/BinaryMessage.cs deleted file mode 100644 index eafa7aa98..000000000 --- a/Example1/BinaryMessage.cs +++ /dev/null @@ -1,74 +0,0 @@ -using System; -using System.Collections.Generic; -using WebSocketSharp; - -namespace Example1 -{ - internal class BinaryMessage - { - public uint UserID { - get; set; - } - - public byte ChannelNumber { - get; set; - } - - public uint BufferLength { - get; set; - } - - public float[,] BufferArray { - get; set; - } - - public static BinaryMessage Parse (byte[] data) - { - var id = data.SubArray (0, 4).To (ByteOrder.Big); - var num = data.SubArray (4, 1)[0]; - var len = data.SubArray (5, 4).To (ByteOrder.Big); - var arr = new float[num, len]; - - var offset = 9; - ((uint) num).Times ( - i => - len.Times ( - j => { - arr[i, j] = data.SubArray (offset, 4).To (ByteOrder.Big); - offset += 4; - } - ) - ); - - return new BinaryMessage { - UserID = id, - ChannelNumber = num, - BufferLength = len, - BufferArray = arr - }; - } - - public byte[] ToArray () - { - var buff = new List (); - - var id = UserID; - var num = ChannelNumber; - var len = BufferLength; - var arr = BufferArray; - - buff.AddRange (id.ToByteArray (ByteOrder.Big)); - buff.Add (num); - buff.AddRange (len.ToByteArray (ByteOrder.Big)); - - ((uint) num).Times ( - i => - len.Times ( - j => buff.AddRange (arr[i, j].ToByteArray (ByteOrder.Big)) - ) - ); - - return buff.ToArray (); - } - } -} diff --git a/Example1/Example1.csproj b/Example1/Example1.csproj deleted file mode 100644 index 81c52eff2..000000000 --- a/Example1/Example1.csproj +++ /dev/null @@ -1,77 +0,0 @@ - - - - Debug - AnyCPU - 9.0.21022 - 2.0 - {390E2568-57B7-4D17-91E5-C29336368CCF} - Exe - Example - example1 - v3.5 - - - true - full - false - bin\Debug - DEBUG; - prompt - 4 - true - - - none - false - bin\Release - prompt - 4 - true - - - true - full - false - bin\Debug_Ubuntu - DEBUG;UBUNTU - prompt - 4 - true - - - none - false - bin\Release_Ubuntu - prompt - 4 - true - UBUNTU - - - - - False - notify-sharp - - - False - - - - - - - - - - - - - - - {B357BAC7-529E-4D81-A0D2-71041B19C8DE} - websocket-sharp - - - \ No newline at end of file diff --git a/Example1/NotificationMessage.cs b/Example1/NotificationMessage.cs deleted file mode 100644 index 01f1692a8..000000000 --- a/Example1/NotificationMessage.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System; - -namespace Example1 -{ - internal class NotificationMessage - { - public string Body { - get; set; - } - - public string Icon { - get; set; - } - - public string Summary { - get; set; - } - - public override string ToString () - { - return String.Format ("{0}: {1}", Summary, Body); - } - } -} diff --git a/Example1/Notifier.cs b/Example1/Notifier.cs deleted file mode 100644 index adf53ec9a..000000000 --- a/Example1/Notifier.cs +++ /dev/null @@ -1,81 +0,0 @@ -#if UBUNTU -using Notifications; -#endif -using System; -using System.Collections; -using System.Collections.Generic; -using System.Threading; - -namespace Example1 -{ - internal class Notifier : IDisposable - { - private volatile bool _enabled; - private ManualResetEvent _exited; - private Queue _queue; - private object _sync; - - public Notifier () - { - _enabled = true; - _exited = new ManualResetEvent (false); - _queue = new Queue (); - _sync = ((ICollection) _queue).SyncRoot; - - ThreadPool.QueueUserWorkItem ( - state => { - while (_enabled || Count > 0) { - var msg = dequeue (); - if (msg != null) { -#if UBUNTU - var nf = new Notification (msg.Summary, msg.Body, msg.Icon); - nf.AddHint ("append", "allowed"); - nf.Show (); -#else - Console.WriteLine (msg); -#endif - } - else { - Thread.Sleep (500); - } - } - - _exited.Set (); - } - ); - } - - public int Count { - get { - lock (_sync) - return _queue.Count; - } - } - - private NotificationMessage dequeue () - { - lock (_sync) - return _queue.Count > 0 ? _queue.Dequeue () : null; - } - - public void Close () - { - _enabled = false; - _exited.WaitOne (); - _exited.Close (); - } - - public void Notify (NotificationMessage message) - { - lock (_sync) { - if (_enabled) - _queue.Enqueue (message); - } - } - - void IDisposable.Dispose () - { - Close (); - } - } -} diff --git a/Example1/Program.cs b/Example1/Program.cs deleted file mode 100644 index 88c0bedfe..000000000 --- a/Example1/Program.cs +++ /dev/null @@ -1,37 +0,0 @@ -using System; -using System.Threading; - -namespace Example1 -{ - public class Program - { - public static void Main (string[] args) - { - // The AudioStreamer class provides a client (chat) for AudioStreamer - // (https://github.com/agektmr/AudioStreamer). - - using (var streamer = new AudioStreamer ("ws://localhost:3000/socket")) - { - string name; - do { - Console.Write ("Input your name> "); - name = Console.ReadLine (); - } - while (name.Length == 0); - - streamer.Connect (name); - - Console.WriteLine ("\nType 'exit' to exit.\n"); - while (true) { - Thread.Sleep (1000); - Console.Write ("> "); - var msg = Console.ReadLine (); - if (msg == "exit") - break; - - streamer.Write (msg); - } - } - } - } -} diff --git a/Example1/TextMessage.cs b/Example1/TextMessage.cs deleted file mode 100644 index 2b177d845..000000000 --- a/Example1/TextMessage.cs +++ /dev/null @@ -1,33 +0,0 @@ -using Newtonsoft.Json; -using System; - -namespace Example1 -{ - internal class TextMessage - { - [JsonProperty ("user_id")] - public uint? UserID { - get; set; - } - - [JsonProperty ("name")] - public string Name { - get; set; - } - - [JsonProperty ("type")] - public string Type { - get; set; - } - - [JsonProperty ("message")] - public string Message { - get; set; - } - - public override string ToString () - { - return JsonConvert.SerializeObject (this); - } - } -} diff --git a/websocket-sharp.sln b/websocket-sharp.sln index 3c20e06a0..6ff1c0362 100644 --- a/websocket-sharp.sln +++ b/websocket-sharp.sln @@ -5,8 +5,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "websocket-sharp", "websocke EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Example", "Example\Example.csproj", "{52805AEC-EFB1-4F42-BB8E-3ED4E692C568}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Example1", "Example1\Example1.csproj", "{390E2568-57B7-4D17-91E5-C29336368CCF}" -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Example2", "Example2\Example2.csproj", "{B81A24C8-25BB-42B2-AF99-1E1EACCE74C7}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Example3", "Example3\Example3.csproj", "{C648BA25-77E5-4A40-A97F-D0AA37B9FB26}" @@ -19,14 +17,6 @@ Global Release_Ubuntu|Any CPU = Release_Ubuntu|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {390E2568-57B7-4D17-91E5-C29336368CCF}.Debug_Ubuntu|Any CPU.ActiveCfg = Debug_Ubuntu|Any CPU - {390E2568-57B7-4D17-91E5-C29336368CCF}.Debug_Ubuntu|Any CPU.Build.0 = Debug_Ubuntu|Any CPU - {390E2568-57B7-4D17-91E5-C29336368CCF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {390E2568-57B7-4D17-91E5-C29336368CCF}.Debug|Any CPU.Build.0 = Debug|Any CPU - {390E2568-57B7-4D17-91E5-C29336368CCF}.Release_Ubuntu|Any CPU.ActiveCfg = Release_Ubuntu|Any CPU - {390E2568-57B7-4D17-91E5-C29336368CCF}.Release_Ubuntu|Any CPU.Build.0 = Release_Ubuntu|Any CPU - {390E2568-57B7-4D17-91E5-C29336368CCF}.Release|Any CPU.ActiveCfg = Release|Any CPU - {390E2568-57B7-4D17-91E5-C29336368CCF}.Release|Any CPU.Build.0 = Release|Any CPU {52805AEC-EFB1-4F42-BB8E-3ED4E692C568}.Debug_Ubuntu|Any CPU.ActiveCfg = Debug_Ubuntu|Any CPU {52805AEC-EFB1-4F42-BB8E-3ED4E692C568}.Debug_Ubuntu|Any CPU.Build.0 = Debug_Ubuntu|Any CPU {52805AEC-EFB1-4F42-BB8E-3ED4E692C568}.Debug|Any CPU.ActiveCfg = Debug|Any CPU From 8ce5146185367815879b44797e0c28488ca614da Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 2 Feb 2022 22:14:10 +0900 Subject: [PATCH 4116/6294] [Modify] Remove it --- websocket-sharp/Ext.cs | 50 ------------------------------------------ 1 file changed, 50 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 5f598e193..e29ab664b 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -2197,56 +2197,6 @@ public static Uri ToUri (this string value) return ret; } - /// - /// Sends the specified content data with the HTTP response. - /// - /// - /// A that represents the HTTP response - /// used to send the content data. - /// - /// - /// An array of that specifies the content data to send. - /// - /// - /// - /// is . - /// - /// - /// -or- - /// - /// - /// is . - /// - /// - [Obsolete ("This method will be removed.")] - public static void WriteContent ( - this HttpListenerResponse response, byte[] content - ) - { - if (response == null) - throw new ArgumentNullException ("response"); - - if (content == null) - throw new ArgumentNullException ("content"); - - var len = content.LongLength; - if (len == 0) { - response.Close (); - return; - } - - response.ContentLength64 = len; - - var output = response.OutputStream; - - if (len <= Int32.MaxValue) - output.Write (content, 0, (int) len); - else - output.WriteBytes (content, 1024); - - output.Close (); - } - #endregion } } From 6f5e69eaf2f61a098da745731c80a0ad34194b9a Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 3 Feb 2022 21:09:30 +0900 Subject: [PATCH 4117/6294] [Modify] Remove it --- websocket-sharp/Ext.cs | 72 ------------------------------------------ 1 file changed, 72 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index e29ab664b..64bde7e98 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1946,78 +1946,6 @@ public static void Times (this ulong n, Action action) action (i); } - /// - /// Converts the specified byte array to the specified type value. - /// - /// - /// - /// A T converted from . - /// - /// - /// The default value of T if not converted. - /// - /// - /// - /// An array of to convert. - /// - /// - /// - /// One of the enum values. - /// - /// - /// It specifies the byte order of . - /// - /// - /// - /// - /// The type of the return. - /// - /// - /// , , , - /// , , , - /// , , , - /// or . - /// - /// - /// - /// is . - /// - [Obsolete ("This method will be removed.")] - public static T To (this byte[] source, ByteOrder sourceOrder) - where T : struct - { - if (source == null) - throw new ArgumentNullException ("source"); - - if (source.Length == 0) - return default (T); - - var type = typeof (T); - var val = source.ToHostOrder (sourceOrder); - - return type == typeof (Boolean) - ? (T)(object) BitConverter.ToBoolean (val, 0) - : type == typeof (Char) - ? (T)(object) BitConverter.ToChar (val, 0) - : type == typeof (Double) - ? (T)(object) BitConverter.ToDouble (val, 0) - : type == typeof (Int16) - ? (T)(object) BitConverter.ToInt16 (val, 0) - : type == typeof (Int32) - ? (T)(object) BitConverter.ToInt32 (val, 0) - : type == typeof (Int64) - ? (T)(object) BitConverter.ToInt64 (val, 0) - : type == typeof (Single) - ? (T)(object) BitConverter.ToSingle (val, 0) - : type == typeof (UInt16) - ? (T)(object) BitConverter.ToUInt16 (val, 0) - : type == typeof (UInt32) - ? (T)(object) BitConverter.ToUInt32 (val, 0) - : type == typeof (UInt64) - ? (T)(object) BitConverter.ToUInt64 (val, 0) - : default (T); - } - /// /// Converts the specified value to a byte array. /// From f93a1890e4cbfb6fbde7019a458819d68bfbfe38 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 3 Feb 2022 21:10:59 +0900 Subject: [PATCH 4118/6294] [Modify] Remove it --- websocket-sharp/Ext.cs | 65 ------------------------------------------ 1 file changed, 65 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 64bde7e98..1ab0d670d 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1946,71 +1946,6 @@ public static void Times (this ulong n, Action action) action (i); } - /// - /// Converts the specified value to a byte array. - /// - /// - /// An array of converted from . - /// - /// - /// A T to convert. - /// - /// - /// - /// One of the enum values. - /// - /// - /// It specifies the byte order of the return. - /// - /// - /// - /// - /// The type of . - /// - /// - /// , , , - /// , , , - /// , , , - /// , or . - /// - /// - [Obsolete ("This method will be removed.")] - public static byte[] ToByteArray (this T value, ByteOrder order) - where T : struct - { - var type = typeof (T); - var bytes = type == typeof (Boolean) - ? BitConverter.GetBytes ((Boolean)(object) value) - : type == typeof (Byte) - ? new byte[] { (Byte)(object) value } - : type == typeof (Char) - ? BitConverter.GetBytes ((Char)(object) value) - : type == typeof (Double) - ? BitConverter.GetBytes ((Double)(object) value) - : type == typeof (Int16) - ? BitConverter.GetBytes ((Int16)(object) value) - : type == typeof (Int32) - ? BitConverter.GetBytes ((Int32)(object) value) - : type == typeof (Int64) - ? BitConverter.GetBytes ((Int64)(object) value) - : type == typeof (Single) - ? BitConverter.GetBytes ((Single)(object) value) - : type == typeof (UInt16) - ? BitConverter.GetBytes ((UInt16)(object) value) - : type == typeof (UInt32) - ? BitConverter.GetBytes ((UInt32)(object) value) - : type == typeof (UInt64) - ? BitConverter.GetBytes ((UInt64)(object) value) - : WebSocket.EmptyBytes; - - if (bytes.Length > 1) { - if (!order.IsHostOrder ()) - Array.Reverse (bytes); - } - - return bytes; - } - /// /// Converts the order of elements in the specified byte array to /// host (this computer architecture) byte order. From 5e43180aaac71ac26462cd4cadb30c880b1971ae Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 4 Feb 2022 19:40:00 +0900 Subject: [PATCH 4119/6294] [Modify] Edit it --- README.md | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/README.md b/README.md index dbc04b6cb..31230a0c9 100644 --- a/README.md +++ b/README.md @@ -457,11 +457,7 @@ As a WebSocket server, if you would like to ignore the extensions requested from ```csharp wssv.AddWebSocketService ( "/Chat", - () => - new Chat () { - // To ignore the extensions requested from a client. - IgnoreExtensions = true - } + s => s.IgnoreExtensions = true // To ignore the extensions requested from a client. ); ``` From bcb05f04ce1a7cc3300e9c07d8a25c768cb88540 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 4 Feb 2022 19:43:19 +0900 Subject: [PATCH 4120/6294] [Modify] Edit it --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 31230a0c9..1e532d204 100644 --- a/README.md +++ b/README.md @@ -493,8 +493,9 @@ As a WebSocket server, you should create a new instance of the `WebSocketServer` ```csharp var wssv = new WebSocketServer (5963, true); -wssv.SslConfiguration.ServerCertificate = - new X509Certificate2 ("/path/to/cert.pfx", "password for cert.pfx"); +wssv.SslConfiguration.ServerCertificate = new X509Certificate2 ( + "/path/to/cert.pfx", "password for cert.pfx" + ); ``` ### HTTP Authentication ### From b8fa74b1a1f7429aa06f75d986ff04db3dc72532 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 5 Feb 2022 21:52:19 +0900 Subject: [PATCH 4121/6294] [Modify] Edit it --- README.md | 45 +++++++++++++++++++++++---------------------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index 1e532d204..8005105ce 100644 --- a/README.md +++ b/README.md @@ -553,7 +553,7 @@ And if you would like to send the cookies in the handshake request, you should s ws.SetCookie (new Cookie ("name", "nobita")); ``` -As a WebSocket server, if you would like to get the query string included in a handshake request, you should access the `WebSocketBehavior.Context.QueryString` property, such as the following. +As a WebSocket server, if you would like to get the query string included in a handshake request, you should access the `WebSocketBehavior.QueryString` property, such as the following. ```csharp public class Chat : WebSocketBehavior @@ -563,7 +563,7 @@ public class Chat : WebSocketBehavior protected override void OnOpen () { - _name = Context.QueryString["name"]; + _name = QueryString["name"]; } ... @@ -574,31 +574,32 @@ If you would like to get the value of the Origin header included in a handshake If you would like to get the cookies included in a handshake request, you should access the `WebSocketBehavior.Context.CookieCollection` property. -And if you would like to validate the Origin header, cookies, or both, you should set each validation for it with your `WebSocketBehavior`, for example, by using the `WebSocketServer.AddWebSocketService (string, Func)` method with initializing, such as the following. +And if you would like to validate the Origin header, cookies, or both, you should set each validation for it with your `WebSocketBehavior`, for example, by using the `WebSocketServer.AddWebSocketService (string, Action)` method with initializing, such as the following. ```csharp wssv.AddWebSocketService ( "/Chat", - () => - new Chat () { - OriginValidator = val => { - // Check the value of the Origin header, and return true if valid. - Uri origin; - return !val.IsNullOrEmpty () - && Uri.TryCreate (val, UriKind.Absolute, out origin) - && origin.Host == "example.com"; - }, - CookiesValidator = (req, res) => { - // Check the cookies in 'req', and set the cookies to send to - // the client with 'res' if necessary. - foreach (Cookie cookie in req) { - cookie.Expired = true; - res.Add (cookie); - } - - return true; // If valid. + s => { + s.OriginValidator = val => { + // Check the value of the Origin header, and return true if valid. + Uri origin; + + return !val.IsNullOrEmpty () + && Uri.TryCreate (val, UriKind.Absolute, out origin) + && origin.Host == "example.com"; + }; + + s.CookiesValidator = (req, res) => { + // Check the cookies in 'req', and set the cookies to send to + // the client with 'res' if necessary. + foreach (var cookie in req) { + cookie.Expired = true; + res.Add (cookie); } - } + + return true; // If valid. + }; + } ); ``` From 0b896304846d55479236f640f921cb9a93084e53 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 6 Feb 2022 22:02:04 +0900 Subject: [PATCH 4122/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 1ab0d670d..edc72badd 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1440,6 +1440,7 @@ public static bool IsEnclosedIn (this string value, char c) return false; var len = value.Length; + if (len < 2) return false; From 21e813c343e976bdde8e3d7ad70f0d2371dce7fd Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 7 Feb 2022 21:15:29 +0900 Subject: [PATCH 4123/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index edc72badd..8a7394fed 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1441,10 +1441,7 @@ public static bool IsEnclosedIn (this string value, char c) var len = value.Length; - if (len < 2) - return false; - - return value[0] == c && value[len - 1] == c; + return len > 1 ? value[0] == c && value[len - 1] == c : false; } /// From 74f7cae254d3eb58277df44501d74293ec74321c Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 7 Feb 2022 21:25:54 +0900 Subject: [PATCH 4124/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 8a7394fed..f0830bcef 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1540,6 +1540,7 @@ public static bool IsPredefinedScheme (this string value) return false; var c = value[0]; + if (c == 'h') return value == "http" || value == "https"; @@ -1557,6 +1558,7 @@ public static bool IsPredefinedScheme (this string value) if (c == 'n') { c = value[1]; + return c == 'e' ? value == "news" || value == "net.pipe" || value == "net.tcp" : value == "nntp"; From b56281b7f9934939caa4f750852d31be7f394836 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 7 Feb 2022 21:29:45 +0900 Subject: [PATCH 4125/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index f0830bcef..c436b501c 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1586,6 +1586,7 @@ public static bool MaybeUri (this string value) return false; var idx = value.IndexOf (':'); + if (idx == -1) return false; @@ -1593,6 +1594,7 @@ public static bool MaybeUri (this string value) return false; var schm = value.Substring (0, idx); + return schm.IsPredefinedScheme (); } From df01a1e1994cd806143a5855cb112f92c142b563 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 8 Feb 2022 19:50:19 +0900 Subject: [PATCH 4126/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index c436b501c..469b40422 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1651,6 +1651,7 @@ public static T[] SubArray (this T[] array, int startIndex, int length) throw new ArgumentNullException ("array"); var len = array.Length; + if (len == 0) { if (startIndex != 0) throw new ArgumentOutOfRangeException ("startIndex"); @@ -1673,10 +1674,11 @@ public static T[] SubArray (this T[] array, int startIndex, int length) if (length == len) return array; - var subArray = new T[length]; - Array.Copy (array, startIndex, subArray, 0, length); + var ret = new T[length]; - return subArray; + Array.Copy (array, startIndex, ret, 0, length); + + return ret; } /// From 093de440911c43d66dda61456b0d39bae9c8b105 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 8 Feb 2022 19:58:04 +0900 Subject: [PATCH 4127/6294] [Modify] Edit it --- websocket-sharp/Ext.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 469b40422..126f11dd9 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1609,11 +1609,11 @@ public static bool MaybeUri (this string value) /// An array of T from which to retrieve a sub-array. /// /// - /// An that represents the zero-based index in the array + /// An that specifies the zero-based index in the array /// at which retrieving starts. /// /// - /// An that represents the number of elements to retrieve. + /// An that specifies the number of elements to retrieve. /// /// /// The type of elements in the array. From 2a74ed88be826fd876440649475e20d025a25d84 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 8 Feb 2022 20:01:38 +0900 Subject: [PATCH 4128/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 126f11dd9..717cbf928 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1734,6 +1734,7 @@ public static T[] SubArray (this T[] array, long startIndex, long length) throw new ArgumentNullException ("array"); var len = array.LongLength; + if (len == 0) { if (startIndex != 0) throw new ArgumentOutOfRangeException ("startIndex"); @@ -1756,10 +1757,11 @@ public static T[] SubArray (this T[] array, long startIndex, long length) if (length == len) return array; - var subArray = new T[length]; - Array.Copy (array, startIndex, subArray, 0, length); + var ret = new T[length]; - return subArray; + Array.Copy (array, startIndex, ret, 0, length); + + return ret; } /// From c8b4fd6621d9e3537b97286cfb270ba510b38fa7 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 8 Feb 2022 20:05:19 +0900 Subject: [PATCH 4129/6294] [Modify] Edit it --- websocket-sharp/Ext.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 717cbf928..15784c24f 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1692,11 +1692,11 @@ public static T[] SubArray (this T[] array, int startIndex, int length) /// An array of T from which to retrieve a sub-array. /// /// - /// A that represents the zero-based index in the array + /// A that specifies the zero-based index in the array /// at which retrieving starts. /// /// - /// A that represents the number of elements to retrieve. + /// A that specifies the number of elements to retrieve. /// /// /// The type of elements in the array. From 25dcba3a9edf94ea682362c6c8ae854d3eb67cd0 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 9 Feb 2022 19:35:24 +0900 Subject: [PATCH 4130/6294] [Modify] Remove it --- websocket-sharp/Ext.cs | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 15784c24f..5a5fecdee 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1764,27 +1764,6 @@ public static T[] SubArray (this T[] array, long startIndex, long length) return ret; } - /// - /// Executes the specified delegate times. - /// - /// - /// An that specifies the number of times to execute. - /// - /// - /// An delegate to execute. - /// - public static void Times (this int n, Action action) - { - if (n <= 0) - return; - - if (action == null) - return; - - for (int i = 0; i < n; i++) - action (); - } - /// /// Executes the specified delegate times. /// From 1ee2a84016b0d3060fb24ed5f95b15670b9acaa8 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 9 Feb 2022 19:36:09 +0900 Subject: [PATCH 4131/6294] [Modify] Remove it --- websocket-sharp/Ext.cs | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 5a5fecdee..7d5b27b8e 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1764,27 +1764,6 @@ public static T[] SubArray (this T[] array, long startIndex, long length) return ret; } - /// - /// Executes the specified delegate times. - /// - /// - /// A that specifies the number of times to execute. - /// - /// - /// An delegate to execute. - /// - public static void Times (this long n, Action action) - { - if (n <= 0) - return; - - if (action == null) - return; - - for (long i = 0; i < n; i++) - action (); - } - /// /// Executes the specified delegate times. /// From 2cf8ea9055dffd879cdda45a23d6f1e6b912c8b6 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 9 Feb 2022 19:36:53 +0900 Subject: [PATCH 4132/6294] [Modify] Remove it --- websocket-sharp/Ext.cs | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 7d5b27b8e..d5a839b04 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1764,27 +1764,6 @@ public static T[] SubArray (this T[] array, long startIndex, long length) return ret; } - /// - /// Executes the specified delegate times. - /// - /// - /// A that specifies the number of times to execute. - /// - /// - /// An delegate to execute. - /// - public static void Times (this uint n, Action action) - { - if (n == 0) - return; - - if (action == null) - return; - - for (uint i = 0; i < n; i++) - action (); - } - /// /// Executes the specified delegate times. /// From 89a01d3dc794d98cdd7ef0d3ec7cd0d1198e5918 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 9 Feb 2022 19:37:32 +0900 Subject: [PATCH 4133/6294] [Modify] Remove it --- websocket-sharp/Ext.cs | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index d5a839b04..22222ad8a 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1764,27 +1764,6 @@ public static T[] SubArray (this T[] array, long startIndex, long length) return ret; } - /// - /// Executes the specified delegate times. - /// - /// - /// A that specifies the number of times to execute. - /// - /// - /// An delegate to execute. - /// - public static void Times (this ulong n, Action action) - { - if (n == 0) - return; - - if (action == null) - return; - - for (ulong i = 0; i < n; i++) - action (); - } - /// /// Executes the specified delegate times. /// From e3772bdeeed9b17fd16fa8514992bdd87bddfdea Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 9 Feb 2022 19:38:32 +0900 Subject: [PATCH 4134/6294] [Modify] Remove it --- websocket-sharp/Ext.cs | 26 -------------------------- 1 file changed, 26 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 22222ad8a..2cfe5a93b 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1816,32 +1816,6 @@ public static void Times (this long n, Action action) action (i); } - /// - /// Executes the specified delegate times. - /// - /// - /// A that specifies the number of times to execute. - /// - /// - /// - /// An Action<uint> delegate to execute. - /// - /// - /// The parameter is the zero-based count of iteration. - /// - /// - public static void Times (this uint n, Action action) - { - if (n == 0) - return; - - if (action == null) - return; - - for (uint i = 0; i < n; i++) - action (i); - } - /// /// Executes the specified delegate times. /// From feb359af7d2f56dba7845a5883c573b00c8c96d9 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 9 Feb 2022 19:39:42 +0900 Subject: [PATCH 4135/6294] [Modify] Remove it --- websocket-sharp/Ext.cs | 26 -------------------------- 1 file changed, 26 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 2cfe5a93b..955fa21e8 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1816,32 +1816,6 @@ public static void Times (this long n, Action action) action (i); } - /// - /// Executes the specified delegate times. - /// - /// - /// A that specifies the number of times to execute. - /// - /// - /// - /// An Action<ulong> delegate to execute. - /// - /// - /// The parameter is the zero-based count of iteration. - /// - /// - public static void Times (this ulong n, Action action) - { - if (n == 0) - return; - - if (action == null) - return; - - for (ulong i = 0; i < n; i++) - action (i); - } - /// /// Converts the order of elements in the specified byte array to /// host (this computer architecture) byte order. From cc2a50cd0f295fa49d91fc6f848d9f2f4af0704e Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 10 Feb 2022 19:41:35 +0900 Subject: [PATCH 4136/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 955fa21e8..16c51d24c 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1890,19 +1890,18 @@ public static string ToString (this T[] array, string separator) throw new ArgumentNullException ("array"); var len = array.Length; + if (len == 0) return String.Empty; - if (separator == null) - separator = String.Empty; - var buff = new StringBuilder (64); var end = len - 1; for (var i = 0; i < end; i++) buff.AppendFormat ("{0}{1}", array[i], separator); - buff.Append (array[end].ToString ()); + buff.AppendFormat ("{0}", array[end]); + return buff.ToString (); } From 9d7ab3443303892fecd96d461be81b57e65f68eb Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 11 Feb 2022 21:40:59 +0900 Subject: [PATCH 4137/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 16c51d24c..be4bfe363 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1921,10 +1921,10 @@ public static string ToString (this T[] array, string separator) /// public static Uri ToUri (this string value) { + var kind = value.MaybeUri () ? UriKind.Absolute : UriKind.Relative; Uri ret; - Uri.TryCreate ( - value, value.MaybeUri () ? UriKind.Absolute : UriKind.Relative, out ret - ); + + Uri.TryCreate (value, kind, out ret); return ret; } From a9ad092a738d10411b2f3e8e5a11c462ae2347f3 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 12 Feb 2022 21:41:55 +0900 Subject: [PATCH 4138/6294] [Modify] To private --- websocket-sharp/Ext.cs | 80 ++++++++++++++++++------------------------ 1 file changed, 35 insertions(+), 45 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index be4bfe363..e37c5d8f5 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -4,7 +4,7 @@ * * Some parts of this code are derived from Mono (http://www.mono-project.com): * - GetStatusDescription is derived from HttpListenerResponse.cs (System.Net) - * - IsPredefinedScheme is derived from Uri.cs (System) + * - isPredefinedScheme is derived from Uri.cs (System) * - MaybeUri is derived from Uri.cs (System) * * The MIT License @@ -160,6 +160,39 @@ private static bool isHttpMethod10 (this string value) || value == "POST"; } + private static bool isPredefinedScheme (this string value) + { + if (value.Length < 2) + return false; + + var c = value[0]; + + if (c == 'h') + return value == "http" || value == "https"; + + if (c == 'w') + return value == "ws" || value == "wss"; + + if (c == 'f') + return value == "file" || value == "ftp"; + + if (c == 'g') + return value == "gopher"; + + if (c == 'm') + return value == "mailto"; + + if (c == 'n') { + c = value[1]; + + return c == 'e' + ? value == "news" || value == "net.pipe" || value == "net.tcp" + : value == "nntp"; + } + + return false; + } + #endregion #region Internal Methods @@ -1524,49 +1557,6 @@ public static bool IsNullOrEmpty (this string value) return value == null || value.Length == 0; } - /// - /// Determines whether the specified string is a predefined scheme. - /// - /// - /// true if is a predefined scheme; - /// otherwise, false. - /// - /// - /// A to test. - /// - public static bool IsPredefinedScheme (this string value) - { - if (value == null || value.Length < 2) - return false; - - var c = value[0]; - - if (c == 'h') - return value == "http" || value == "https"; - - if (c == 'w') - return value == "ws" || value == "wss"; - - if (c == 'f') - return value == "file" || value == "ftp"; - - if (c == 'g') - return value == "gopher"; - - if (c == 'm') - return value == "mailto"; - - if (c == 'n') { - c = value[1]; - - return c == 'e' - ? value == "news" || value == "net.pipe" || value == "net.tcp" - : value == "nntp"; - } - - return false; - } - /// /// Determines whether the specified string is a URI string. /// @@ -1595,7 +1585,7 @@ public static bool MaybeUri (this string value) var schm = value.Substring (0, idx); - return schm.IsPredefinedScheme (); + return schm.isPredefinedScheme (); } /// From c91277c186fbdc06c2869baa7bbfbf8970bd8d89 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 13 Feb 2022 22:12:24 +0900 Subject: [PATCH 4139/6294] [Modify] To internal --- websocket-sharp/Ext.cs | 49 ++++++++++++++++-------------------------- 1 file changed, 18 insertions(+), 31 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index e37c5d8f5..7d594e232 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -746,6 +746,21 @@ internal static bool KeepsAlive ( : !headers.Contains ("Connection", "close", comparison); } + internal static bool MaybeUri (this string value) + { + var idx = value.IndexOf (':'); + + if (idx == -1) + return false; + + if (idx >= 10) + return false; + + var schm = value.Substring (0, idx); + + return schm.isPredefinedScheme (); + } + internal static string Quote (this string value) { return String.Format ("\"{0}\"", value.Replace ("\"", "\\\"")); @@ -1557,37 +1572,6 @@ public static bool IsNullOrEmpty (this string value) return value == null || value.Length == 0; } - /// - /// Determines whether the specified string is a URI string. - /// - /// - /// true if may be a URI string; - /// otherwise, false. - /// - /// - /// A to test. - /// - public static bool MaybeUri (this string value) - { - if (value == null) - return false; - - if (value.Length == 0) - return false; - - var idx = value.IndexOf (':'); - - if (idx == -1) - return false; - - if (idx >= 10) - return false; - - var schm = value.Substring (0, idx); - - return schm.isPredefinedScheme (); - } - /// /// Retrieves a sub-array from the specified array. A sub-array starts at /// the specified index in the array. @@ -1911,6 +1895,9 @@ public static string ToString (this T[] array, string separator) /// public static Uri ToUri (this string value) { + if (value == null || value.Length == 0) + return null; + var kind = value.MaybeUri () ? UriKind.Absolute : UriKind.Relative; Uri ret; From 7f1fb159b85a13f12e1112cf9f12ede11506dbc3 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 14 Feb 2022 21:08:53 +0900 Subject: [PATCH 4140/6294] [Modify] Edit it --- websocket-sharp/Ext.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 7d594e232..96dfdaffd 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -4,8 +4,8 @@ * * Some parts of this code are derived from Mono (http://www.mono-project.com): * - GetStatusDescription is derived from HttpListenerResponse.cs (System.Net) - * - isPredefinedScheme is derived from Uri.cs (System) * - MaybeUri is derived from Uri.cs (System) + * - isPredefinedScheme is derived from Uri.cs (System) * * The MIT License * From e19035ffeb112bda4207c6602a1a2ca0315a1d41 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 14 Feb 2022 21:21:23 +0900 Subject: [PATCH 4141/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 96dfdaffd..a55151d0a 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -162,9 +162,6 @@ private static bool isHttpMethod10 (this string value) private static bool isPredefinedScheme (this string value) { - if (value.Length < 2) - return false; - var c = value[0]; if (c == 'h') @@ -750,10 +747,7 @@ internal static bool MaybeUri (this string value) { var idx = value.IndexOf (':'); - if (idx == -1) - return false; - - if (idx >= 10) + if (idx < 2 || idx > 9) return false; var schm = value.Substring (0, idx); From 2343ef6427819d1a54ad2cf4595f0689e6e07a79 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 14 Feb 2022 21:32:13 +0900 Subject: [PATCH 4142/6294] [Modify] 2022 --- websocket-sharp/Ext.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index a55151d0a..04026d78a 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -14,7 +14,7 @@ * Copyright (c) 2003 Ben Maurer * Copyright (c) 2003, 2005, 2009 Novell, Inc. (http://www.novell.com) * Copyright (c) 2009 Stephane Delcroix - * Copyright (c) 2010-2016 sta.blockhead + * Copyright (c) 2010-2022 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From 38a306dfc1ea005a0daf36730a7c4d572e978fea Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 15 Feb 2022 21:21:18 +0900 Subject: [PATCH 4143/6294] [Modify] Polish it --- Example/Program.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Example/Program.cs b/Example/Program.cs index d414bb1e5..01cc5ba13 100644 --- a/Example/Program.cs +++ b/Example/Program.cs @@ -112,10 +112,13 @@ public static void Main (string[] args) //ws.ConnectAsync (); Console.WriteLine ("\nType 'exit' to exit.\n"); + while (true) { Thread.Sleep (1000); Console.Write ("> "); + var msg = Console.ReadLine (); + if (msg == "exit") break; From 026ec6ba1e44d367e8512b1a25fcaa293e12d946 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 15 Feb 2022 21:25:53 +0900 Subject: [PATCH 4144/6294] [Modify] Polish it --- Example/Program.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/Example/Program.cs b/Example/Program.cs index 01cc5ba13..c4e5754ba 100644 --- a/Example/Program.cs +++ b/Example/Program.cs @@ -23,8 +23,6 @@ public static void Main (string[] args) //using (var ws = new WebSocket ("wss://echo.websocket.org")) //using (var ws = new WebSocket ("ws://localhost:4649/Echo")) //using (var ws = new WebSocket ("wss://localhost:5963/Echo")) - //using (var ws = new WebSocket ("ws://localhost:4649/Echo?name=nobita")) - //using (var ws = new WebSocket ("wss://localhost:5963/Echo?name=nobita")) //using (var ws = new WebSocket ("ws://localhost:4649/Chat")) //using (var ws = new WebSocket ("wss://localhost:5963/Chat")) //using (var ws = new WebSocket ("ws://localhost:4649/Chat?name=nobita")) From 6511800f42a7b46ac9afa4cae173dcbdf2b49f0c Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 16 Feb 2022 20:54:52 +0900 Subject: [PATCH 4145/6294] [Modify] Polish it --- Example/Notifier.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Example/Notifier.cs b/Example/Notifier.cs index 5371c37a4..1442bb894 100644 --- a/Example/Notifier.cs +++ b/Example/Notifier.cs @@ -26,6 +26,7 @@ public Notifier () state => { while (_enabled || Count > 0) { var msg = dequeue (); + if (msg != null) { #if UBUNTU var nf = new Notification (msg.Summary, msg.Body, msg.Icon); From 23354ad6021c5f98fe2e562e8ad521c19c6937a5 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 16 Feb 2022 20:55:50 +0900 Subject: [PATCH 4146/6294] [Modify] Polish it --- Example/Notifier.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Example/Notifier.cs b/Example/Notifier.cs index 1442bb894..6cc0923c1 100644 --- a/Example/Notifier.cs +++ b/Example/Notifier.cs @@ -62,6 +62,7 @@ private NotificationMessage dequeue () public void Close () { _enabled = false; + _exited.WaitOne (); _exited.Close (); } From df0b5249fafd43e59387943b26ef81a9392c8a79 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 17 Feb 2022 21:45:40 +0900 Subject: [PATCH 4147/6294] [Modify] Remove notify-sharp from Example --- Example/Example.csproj | 8 +--- Example/NotificationMessage.cs | 24 ---------- Example/Notifier.cs | 83 ---------------------------------- Example/Program.cs | 44 ++++++++---------- 4 files changed, 20 insertions(+), 139 deletions(-) delete mode 100644 Example/NotificationMessage.cs delete mode 100644 Example/Notifier.cs diff --git a/Example/Example.csproj b/Example/Example.csproj index 38c5b4200..ee89d9f6e 100644 --- a/Example/Example.csproj +++ b/Example/Example.csproj @@ -34,7 +34,7 @@ full false bin\Debug_Ubuntu - DEBUG,UBUNTU + DEBUG prompt 4 true @@ -43,16 +43,12 @@ none false bin\Release_Ubuntu - UBUNTU prompt 4 true - - notify-sharp - @@ -65,7 +61,5 @@ - - \ No newline at end of file diff --git a/Example/NotificationMessage.cs b/Example/NotificationMessage.cs deleted file mode 100644 index fd1bd3071..000000000 --- a/Example/NotificationMessage.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System; - -namespace Example -{ - internal class NotificationMessage - { - public string Body { - get; set; - } - - public string Icon { - get; set; - } - - public string Summary { - get; set; - } - - public override string ToString () - { - return String.Format ("{0}: {1}", Summary, Body); - } - } -} diff --git a/Example/Notifier.cs b/Example/Notifier.cs deleted file mode 100644 index 6cc0923c1..000000000 --- a/Example/Notifier.cs +++ /dev/null @@ -1,83 +0,0 @@ -#if UBUNTU -using Notifications; -#endif -using System; -using System.Collections; -using System.Collections.Generic; -using System.Threading; - -namespace Example -{ - internal class Notifier : IDisposable - { - private volatile bool _enabled; - private ManualResetEvent _exited; - private Queue _queue; - private object _sync; - - public Notifier () - { - _enabled = true; - _exited = new ManualResetEvent (false); - _queue = new Queue (); - _sync = ((ICollection) _queue).SyncRoot; - - ThreadPool.QueueUserWorkItem ( - state => { - while (_enabled || Count > 0) { - var msg = dequeue (); - - if (msg != null) { -#if UBUNTU - var nf = new Notification (msg.Summary, msg.Body, msg.Icon); - nf.AddHint ("append", "allowed"); - nf.Show (); -#else - Console.WriteLine (msg); -#endif - } - else { - Thread.Sleep (500); - } - } - - _exited.Set (); - } - ); - } - - public int Count { - get { - lock (_sync) - return _queue.Count; - } - } - - private NotificationMessage dequeue () - { - lock (_sync) - return _queue.Count > 0 ? _queue.Dequeue () : null; - } - - public void Close () - { - _enabled = false; - - _exited.WaitOne (); - _exited.Close (); - } - - public void Notify (NotificationMessage message) - { - lock (_sync) { - if (_enabled) - _queue.Enqueue (message); - } - } - - void IDisposable.Dispose () - { - Close (); - } - } -} diff --git a/Example/Program.cs b/Example/Program.cs index c4e5754ba..91104ab65 100644 --- a/Example/Program.cs +++ b/Example/Program.cs @@ -18,7 +18,6 @@ public static void Main (string[] args) // If you would like to connect to the server with the secure connection, // you should create a new instance with a wss scheme WebSocket URL. - using (var nf = new Notifier ()) using (var ws = new WebSocket ("ws://echo.websocket.org")) //using (var ws = new WebSocket ("wss://echo.websocket.org")) //using (var ws = new WebSocket ("ws://localhost:4649/Echo")) @@ -32,32 +31,27 @@ public static void Main (string[] args) ws.OnOpen += (sender, e) => ws.Send ("Hi, there!"); - ws.OnMessage += (sender, e) => - nf.Notify ( - new NotificationMessage { - Summary = "WebSocket Message", - Body = !e.IsPing ? e.Data : "Received a ping.", - Icon = "notification-message-im" - } - ); + ws.OnMessage += (sender, e) => { + var fmt = "WebSocket Message: {0}"; + var body = !e.IsPing ? e.Data : "Received a ping."; + var msg = String.Format (fmt, body); - ws.OnError += (sender, e) => - nf.Notify ( - new NotificationMessage { - Summary = "WebSocket Error", - Body = e.Message, - Icon = "notification-message-im" - } - ); + Console.WriteLine (msg); + }; - ws.OnClose += (sender, e) => - nf.Notify ( - new NotificationMessage { - Summary = String.Format ("WebSocket Close ({0})", e.Code), - Body = e.Reason, - Icon = "notification-message-im" - } - ); + ws.OnError += (sender, e) => { + var fmt = "WebSocket Error: {0}"; + var msg = String.Format (fmt, e.Message); + + Console.WriteLine (msg); + }; + + ws.OnClose += (sender, e) => { + var fmt = "WebSocket Close ({0}): {1}"; + var msg = String.Format (fmt, e.Code, e.Reason); + + Console.WriteLine (msg); + }; #if DEBUG // To change the logging level. ws.Log.Level = LogLevel.Trace; From ba5ccfcd10d99b603e228db8b993fe3744709dad Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 18 Feb 2022 17:37:29 +0900 Subject: [PATCH 4148/6294] [Modify] Remove websocket.org URLs websocket.org no longer available. Many thanks to websocket.org --- Example/Program.cs | 4 +--- README.md | 3 +-- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/Example/Program.cs b/Example/Program.cs index 91104ab65..58df21414 100644 --- a/Example/Program.cs +++ b/Example/Program.cs @@ -18,9 +18,7 @@ public static void Main (string[] args) // If you would like to connect to the server with the secure connection, // you should create a new instance with a wss scheme WebSocket URL. - using (var ws = new WebSocket ("ws://echo.websocket.org")) - //using (var ws = new WebSocket ("wss://echo.websocket.org")) - //using (var ws = new WebSocket ("ws://localhost:4649/Echo")) + using (var ws = new WebSocket ("ws://localhost:4649/Echo")) //using (var ws = new WebSocket ("wss://localhost:5963/Echo")) //using (var ws = new WebSocket ("ws://localhost:4649/Chat")) //using (var ws = new WebSocket ("wss://localhost:5963/Chat")) diff --git a/README.md b/README.md index 8005105ce..7c38bc095 100644 --- a/README.md +++ b/README.md @@ -649,7 +649,7 @@ Examples using websocket-sharp. ### Example ### -[Example] connects to the [Echo server]. +[Example] connects to the server executed by [Example2] or [Example3]. ### Example2 ### @@ -679,7 +679,6 @@ Thanks for translating to japanese. websocket-sharp is provided under [The MIT License]. -[Echo server]: http://www.websocket.org/echo.html [Example]: https://github.com/sta/websocket-sharp/tree/master/Example [Example2]: https://github.com/sta/websocket-sharp/tree/master/Example2 [Example3]: https://github.com/sta/websocket-sharp/tree/master/Example3 From 3a14ed5ec87c70668bd47a1c1c9a5a77e71d61ea Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 19 Feb 2022 17:48:36 +0900 Subject: [PATCH 4149/6294] [Modify] Polish it --- Example/Program.cs | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/Example/Program.cs b/Example/Program.cs index 58df21414..1e80e7a58 100644 --- a/Example/Program.cs +++ b/Example/Program.cs @@ -30,25 +30,22 @@ public static void Main (string[] args) ws.OnOpen += (sender, e) => ws.Send ("Hi, there!"); ws.OnMessage += (sender, e) => { - var fmt = "WebSocket Message: {0}"; + var fmt = "[WebSocket Message] {0}"; var body = !e.IsPing ? e.Data : "Received a ping."; - var msg = String.Format (fmt, body); - Console.WriteLine (msg); + Console.WriteLine (fmt, body); }; ws.OnError += (sender, e) => { - var fmt = "WebSocket Error: {0}"; - var msg = String.Format (fmt, e.Message); + var fmt = "[WebSocket Error] {0}"; - Console.WriteLine (msg); + Console.WriteLine (fmt, e.Message); }; ws.OnClose += (sender, e) => { - var fmt = "WebSocket Close ({0}): {1}"; - var msg = String.Format (fmt, e.Code, e.Reason); + var fmt = "[WebSocket Close ({0})] {1}"; - Console.WriteLine (msg); + Console.WriteLine (fmt, e.Code, e.Reason); }; #if DEBUG // To change the logging level. From 6d0bf7b228c5a31464f2855f85d8d64328853154 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 20 Feb 2022 17:46:00 +0900 Subject: [PATCH 4150/6294] [Modify] Polish it --- Example/Program.cs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/Example/Program.cs b/Example/Program.cs index 1e80e7a58..854f1d20d 100644 --- a/Example/Program.cs +++ b/Example/Program.cs @@ -64,13 +64,12 @@ public static void Main (string[] args) /* ws.SslConfiguration.ServerCertificateValidationCallback = (sender, certificate, chain, sslPolicyErrors) => { - ws.Log.Debug ( - String.Format ( - "Certificate:\n- Issuer: {0}\n- Subject: {1}", - certificate.Issuer, - certificate.Subject - ) - ); + var fmt = "Certificate:\n- Issuer: {0}\n- Subject: {1}"; + var msg = String.Format ( + fmt, certificate.Issuer, certificate.Subject + ); + + ws.Log.Debug (msg); return true; // If the server certificate is valid. }; From cff39a9bb021a88e659bf5340595fb90998d784a Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 20 Feb 2022 17:47:15 +0900 Subject: [PATCH 4151/6294] [Modify] Polish it --- Example/Program.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Example/Program.cs b/Example/Program.cs index 854f1d20d..b7313a9d4 100644 --- a/Example/Program.cs +++ b/Example/Program.cs @@ -31,7 +31,7 @@ public static void Main (string[] args) ws.OnMessage += (sender, e) => { var fmt = "[WebSocket Message] {0}"; - var body = !e.IsPing ? e.Data : "Received a ping."; + var body = !e.IsPing ? e.Data : "A ping was received."; Console.WriteLine (fmt, body); }; From 97c37c85f5ab5e369e9adcd63f5ab12e9107c556 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 21 Feb 2022 17:33:14 +0900 Subject: [PATCH 4152/6294] [Modify] Rename it --- websocket-sharp/Ext.cs | 6 ++---- websocket-sharp/WebSocketFrame.cs | 4 ++-- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 04026d78a..01e66831d 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -196,7 +196,7 @@ private static bool isPredefinedScheme (this string value) internal static byte[] Append (this ushort code, string reason) { - var bytes = code.InternalToByteArray (ByteOrder.Big); + var bytes = code.ToByteArray (ByteOrder.Big); if (reason == null || reason.Length == 0) return bytes; @@ -603,9 +603,7 @@ internal static string GetValue ( return unquote ? val.Unquote () : val; } - internal static byte[] InternalToByteArray ( - this ushort value, ByteOrder order - ) + internal static byte[] ToByteArray (this ushort value, ByteOrder order) { var ret = BitConverter.GetBytes (value); diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index db8a73415..a4ca347a8 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -103,7 +103,7 @@ bool mask } else if (len < 0x010000) { _payloadLength = (byte) 126; - _extPayloadLength = ((ushort) len).InternalToByteArray (ByteOrder.Big); + _extPayloadLength = ((ushort) len).ToByteArray (ByteOrder.Big); } else { _payloadLength = (byte) 127; @@ -880,7 +880,7 @@ public byte[] ToArray () header = (header << 7) + (int) _payloadLength; var headerAsUshort = (ushort) header; - var headerAsBytes = headerAsUshort.InternalToByteArray (ByteOrder.Big); + var headerAsBytes = headerAsUshort.ToByteArray (ByteOrder.Big); buff.Write (headerAsBytes, 0, 2); From d27a9d05ddaaa0ff4d111f245848a24487f1a6d5 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 21 Feb 2022 17:35:33 +0900 Subject: [PATCH 4153/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 01e66831d..dd4f09e43 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -603,16 +603,6 @@ internal static string GetValue ( return unquote ? val.Unquote () : val; } - internal static byte[] ToByteArray (this ushort value, ByteOrder order) - { - var ret = BitConverter.GetBytes (value); - - if (!order.IsHostOrder ()) - Array.Reverse (ret); - - return ret; - } - internal static byte[] InternalToByteArray ( this ulong value, ByteOrder order ) @@ -1033,6 +1023,16 @@ internal static byte[] ToByteArray (this Stream stream) } } + internal static byte[] ToByteArray (this ushort value, ByteOrder order) + { + var ret = BitConverter.GetBytes (value); + + if (!order.IsHostOrder ()) + Array.Reverse (ret); + + return ret; + } + internal static CompressionMethod ToCompressionMethod (this string value) { var methods = Enum.GetValues (typeof (CompressionMethod)); From ec6dbe114f59750338564bc626e85598231c59e3 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 21 Feb 2022 17:37:59 +0900 Subject: [PATCH 4154/6294] [Modify] Rename it --- websocket-sharp/Ext.cs | 4 +--- websocket-sharp/WebSocketFrame.cs | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index dd4f09e43..d73996e73 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -603,9 +603,7 @@ internal static string GetValue ( return unquote ? val.Unquote () : val; } - internal static byte[] InternalToByteArray ( - this ulong value, ByteOrder order - ) + internal static byte[] ToByteArray (this ulong value, ByteOrder order) { var ret = BitConverter.GetBytes (value); diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index a4ca347a8..cbc53f32c 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -107,7 +107,7 @@ bool mask } else { _payloadLength = (byte) 127; - _extPayloadLength = len.InternalToByteArray (ByteOrder.Big); + _extPayloadLength = len.ToByteArray (ByteOrder.Big); } if (mask) { From 0722f653ef73691a3657ab0146c7a4d402486b6b Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 21 Feb 2022 17:39:29 +0900 Subject: [PATCH 4155/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index d73996e73..61cefc93b 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -603,16 +603,6 @@ internal static string GetValue ( return unquote ? val.Unquote () : val; } - internal static byte[] ToByteArray (this ulong value, ByteOrder order) - { - var ret = BitConverter.GetBytes (value); - - if (!order.IsHostOrder ()) - Array.Reverse (ret); - - return ret; - } - internal static bool IsCompressionExtension ( this string value, CompressionMethod method ) @@ -1031,6 +1021,16 @@ internal static byte[] ToByteArray (this ushort value, ByteOrder order) return ret; } + internal static byte[] ToByteArray (this ulong value, ByteOrder order) + { + var ret = BitConverter.GetBytes (value); + + if (!order.IsHostOrder ()) + Array.Reverse (ret); + + return ret; + } + internal static CompressionMethod ToCompressionMethod (this string value) { var methods = Enum.GetValues (typeof (CompressionMethod)); From 90a91451ce35c6debf4de8326df0cb6ab695d616 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 22 Feb 2022 17:41:08 +0900 Subject: [PATCH 4156/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 61cefc93b..993b55623 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -196,13 +196,15 @@ private static bool isPredefinedScheme (this string value) internal static byte[] Append (this ushort code, string reason) { - var bytes = code.ToByteArray (ByteOrder.Big); + var codeAsBytes = code.ToByteArray (ByteOrder.Big); if (reason == null || reason.Length == 0) - return bytes; + return codeAsBytes; - var buff = new List (bytes); - buff.AddRange (Encoding.UTF8.GetBytes (reason)); + var buff = new List (codeAsBytes); + var reasonAsBytes = Encoding.UTF8.GetBytes (reason); + + buff.AddRange (reasonAsBytes); return buff.ToArray (); } From 66bd49c6889a6dcdc763ecf432f3f3fb23df7363 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 23 Feb 2022 17:22:18 +0900 Subject: [PATCH 4157/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 993b55623..cb1614ee5 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1004,12 +1004,13 @@ internal static IEnumerable SplitHeaderValue ( internal static byte[] ToByteArray (this Stream stream) { - using (var output = new MemoryStream ()) { - stream.Position = 0; - stream.CopyTo (output, 1024); - output.Close (); + stream.Position = 0; - return output.ToArray (); + using (var buff = new MemoryStream ()) { + stream.CopyTo (buff, 1024); + buff.Close (); + + return buff.ToArray (); } } From bce03190e8fb4a48322f574560c6091a6698996b Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 23 Feb 2022 17:29:02 +0900 Subject: [PATCH 4158/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index cb1614ee5..603462e9b 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -223,7 +223,9 @@ internal static Stream Compress (this Stream stream, CompressionMethod method) : stream; } - internal static byte[] CompressToArray (this Stream stream, CompressionMethod method) + internal static byte[] CompressToArray ( + this Stream stream, CompressionMethod method + ) { return method == CompressionMethod.Deflate ? stream.compressToArray () From d63b7bfb0f3817599d2ef072413305d7317e3091 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 23 Feb 2022 17:31:59 +0900 Subject: [PATCH 4159/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 603462e9b..89c975ea9 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -400,7 +400,9 @@ internal static Stream Decompress (this Stream stream, CompressionMethod method) : stream; } - internal static byte[] DecompressToArray (this Stream stream, CompressionMethod method) + internal static byte[] DecompressToArray ( + this Stream stream, CompressionMethod method + ) { return method == CompressionMethod.Deflate ? stream.decompressToArray () From b784cc80826b9eb8c1249ab29c12cd6f4344a5a9 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 24 Feb 2022 17:37:28 +0900 Subject: [PATCH 4160/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 89c975ea9..d8129cdc0 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -331,18 +331,19 @@ internal static T[] Copy (this T[] source, long length) } internal static void CopyTo ( - this Stream source, Stream destination, int bufferLength + this Stream sourceStream, Stream destinationStream, int bufferLength ) { var buff = new byte[bufferLength]; var nread = 0; while (true) { - nread = source.Read (buff, 0, bufferLength); + nread = sourceStream.Read (buff, 0, bufferLength); + if (nread <= 0) break; - destination.Write (buff, 0, nread); + destinationStream.Write (buff, 0, nread); } } From 00ec789b7012a3e35934540f14bdf381199cdeb6 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 24 Feb 2022 17:45:02 +0900 Subject: [PATCH 4161/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index d8129cdc0..5be13a723 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -348,8 +348,8 @@ internal static void CopyTo ( } internal static void CopyToAsync ( - this Stream source, - Stream destination, + this Stream sourceStream, + Stream destinationStream, int bufferLength, Action completed, Action error @@ -361,7 +361,8 @@ Action error callback = ar => { try { - var nread = source.EndRead (ar); + var nread = sourceStream.EndRead (ar); + if (nread <= 0) { if (completed != null) completed (); @@ -369,8 +370,9 @@ Action error return; } - destination.Write (buff, 0, nread); - source.BeginRead (buff, 0, bufferLength, callback, null); + destinationStream.Write (buff, 0, nread); + + sourceStream.BeginRead (buff, 0, bufferLength, callback, null); } catch (Exception ex) { if (error != null) @@ -379,7 +381,7 @@ Action error }; try { - source.BeginRead (buff, 0, bufferLength, callback, null); + sourceStream.BeginRead (buff, 0, bufferLength, callback, null); } catch (Exception ex) { if (error != null) From 42693488d89ba51c1e65129dbaca2ddf553409a8 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 25 Feb 2022 21:07:44 +0900 Subject: [PATCH 4162/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 5be13a723..76d0f2ead 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -314,10 +314,11 @@ internal static bool ContainsTwice (this string[] values) return seek (0); } - internal static T[] Copy (this T[] source, int length) + internal static T[] Copy (this T[] sourceArray, int length) { var dest = new T[length]; - Array.Copy (source, 0, dest, 0, length); + + Array.Copy (sourceArray, 0, dest, 0, length); return dest; } From fd088daa77c49cec9f0046d9e0d2914d1586ce52 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 25 Feb 2022 21:09:01 +0900 Subject: [PATCH 4163/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 76d0f2ead..1737232bd 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -323,10 +323,11 @@ internal static T[] Copy (this T[] sourceArray, int length) return dest; } - internal static T[] Copy (this T[] source, long length) + internal static T[] Copy (this T[] sourceArray, long length) { var dest = new T[length]; - Array.Copy (source, 0, dest, 0, length); + + Array.Copy (sourceArray, 0, dest, 0, length); return dest; } From f27f1cf4fd228a48833bc99da3a4b8090b87f379 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 26 Feb 2022 17:18:49 +0900 Subject: [PATCH 4164/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 1737232bd..e02448cec 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -303,6 +303,7 @@ internal static bool ContainsTwice (this string[] values) return false; var val = values[idx]; + for (var i = idx + 1; i < len; i++) { if (values[i] == val) return true; From bbedf0668465e1f64880c5d09479904a4deaaf6f Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 26 Feb 2022 17:23:07 +0900 Subject: [PATCH 4165/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index e02448cec..3a4d504d5 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -269,6 +269,7 @@ StringComparison comparisonTypeForValue ) { var val = collection[name]; + if (val == null) return false; From 89a15fa1be7ca596855abc3f5015c62a2e3653e5 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 27 Feb 2022 21:54:13 +0900 Subject: [PATCH 4166/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 3a4d504d5..aeb7c6d2b 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -216,7 +216,9 @@ internal static byte[] Compress (this byte[] data, CompressionMethod method) : data; } - internal static Stream Compress (this Stream stream, CompressionMethod method) + internal static Stream Compress ( + this Stream stream, CompressionMethod method + ) { return method == CompressionMethod.Deflate ? stream.compress () From d71c568eb0bd5c7cd8633c46fe9fa2f5a449fd61 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 27 Feb 2022 21:56:28 +0900 Subject: [PATCH 4167/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index aeb7c6d2b..e4e82bd4f 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -234,21 +234,6 @@ internal static byte[] CompressToArray ( : stream.ToByteArray (); } - /// - /// Determines whether the specified string contains any of characters in - /// the specified array of . - /// - /// - /// true if contains any of characters in - /// ; otherwise, false. - /// - /// - /// A to test. - /// - /// - /// An array of that contains one or more characters to - /// seek. - /// internal static bool Contains (this string value, params char[] anyOf) { return anyOf != null && anyOf.Length > 0 From 6feda3430948efe4b6928c811af509acc2349768 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 28 Feb 2022 22:22:42 +0900 Subject: [PATCH 4168/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index e4e82bd4f..f9a45852a 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -380,7 +380,9 @@ Action error } } - internal static byte[] Decompress (this byte[] data, CompressionMethod method) + internal static byte[] Decompress ( + this byte[] data, CompressionMethod method + ) { return method == CompressionMethod.Deflate ? data.decompress () From 4a2766b931e8459f4935bf7050f0e9431dbc2896 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 28 Feb 2022 22:23:58 +0900 Subject: [PATCH 4169/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index f9a45852a..c2fe08509 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -389,7 +389,9 @@ internal static byte[] Decompress ( : data; } - internal static Stream Decompress (this Stream stream, CompressionMethod method) + internal static Stream Decompress ( + this Stream stream, CompressionMethod method + ) { return method == CompressionMethod.Deflate ? stream.decompress () From bcd0dc2d79096b303a43d35df86f627ecf818227 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 1 Mar 2022 20:57:41 +0900 Subject: [PATCH 4170/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index c2fe08509..39053279a 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -450,6 +450,7 @@ internal static void Emit ( internal static bool EqualsWith (this int value, char c, Action action) { action (value); + return value == c - 0; } From f3e23f8d3d50d75096334d17cec63bf9c86c28b5 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 2 Mar 2022 20:56:00 +0900 Subject: [PATCH 4171/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 39053279a..1998ab582 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -428,25 +428,6 @@ internal static void Emit ( eventHandler (sender, e); } - /// - /// Determines whether the specified equals the specified , - /// and invokes the specified Action<int> delegate at the same time. - /// - /// - /// true if equals ; - /// otherwise, false. - /// - /// - /// An to compare. - /// - /// - /// A to compare. - /// - /// - /// An Action<int> delegate that references the method(s) called - /// at the same time as comparing. An parameter to pass to - /// the method(s) is . - /// internal static bool EqualsWith (this int value, char c, Action action) { action (value); From 98c4f4b57de30888e1abd26800829e95a9445168 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 2 Mar 2022 21:02:01 +0900 Subject: [PATCH 4172/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 1998ab582..6c481ef05 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -428,9 +428,11 @@ internal static void Emit ( eventHandler (sender, e); } - internal static bool EqualsWith (this int value, char c, Action action) + internal static bool EqualsWith ( + this int value, char c, Action beforeComparing + ) { - action (value); + beforeComparing (value); return value == c - 0; } From 09924ebb1f025fc2d20e04c2564292055c593cac Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 3 Mar 2022 21:35:39 +0900 Subject: [PATCH 4173/6294] [Modify] Rename it --- websocket-sharp/Ext.cs | 2 +- websocket-sharp/HttpBase.cs | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 6c481ef05..66bfab82e 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -428,7 +428,7 @@ internal static void Emit ( eventHandler (sender, e); } - internal static bool EqualsWith ( + internal static bool IsEqualTo ( this int value, char c, Action beforeComparing ) { diff --git a/websocket-sharp/HttpBase.cs b/websocket-sharp/HttpBase.cs index a7dbd4026..dd1e65c94 100644 --- a/websocket-sharp/HttpBase.cs +++ b/websocket-sharp/HttpBase.cs @@ -131,10 +131,10 @@ private static string[] readHeaders (Stream stream, int maxLength) var read = false; while (cnt < maxLength) { - if (stream.ReadByte ().EqualsWith ('\r', add) && - stream.ReadByte ().EqualsWith ('\n', add) && - stream.ReadByte ().EqualsWith ('\r', add) && - stream.ReadByte ().EqualsWith ('\n', add)) { + if (stream.ReadByte ().IsEqualTo ('\r', add) && + stream.ReadByte ().IsEqualTo ('\n', add) && + stream.ReadByte ().IsEqualTo ('\r', add) && + stream.ReadByte ().IsEqualTo ('\n', add)) { read = true; break; } From 69c26440c1e63222511f8fdaf20a33b02677e1c6 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 3 Mar 2022 21:37:16 +0900 Subject: [PATCH 4174/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 66bfab82e..9237aea23 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -428,15 +428,6 @@ internal static void Emit ( eventHandler (sender, e); } - internal static bool IsEqualTo ( - this int value, char c, Action beforeComparing - ) - { - beforeComparing (value); - - return value == c - 0; - } - /// /// Gets the absolute path from the specified . /// @@ -618,6 +609,15 @@ internal static bool IsData (this Opcode opcode) return opcode == Opcode.Text || opcode == Opcode.Binary; } + internal static bool IsEqualTo ( + this int value, char c, Action beforeComparing + ) + { + beforeComparing (value); + + return value == c - 0; + } + internal static bool IsHttpMethod (this string value, Version version) { return version == HttpVersion.Version10 From af4b325f98f90022a4fa892112cf8f4f7dc1e07b Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 4 Mar 2022 21:05:16 +0900 Subject: [PATCH 4175/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 9237aea23..1d863c007 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -444,10 +444,12 @@ internal static string GetAbsolutePath (this Uri uri) return uri.AbsolutePath; var original = uri.OriginalString; + if (original[0] != '/') return null; var idx = original.IndexOfAny (new[] { '?', '#' }); + return idx > 0 ? original.Substring (0, idx) : original; } From ad8ca9c8c80491ac0cda268d680db6d6fdabdb8d Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 4 Mar 2022 21:06:03 +0900 Subject: [PATCH 4176/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 1d863c007..6019a5ef9 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -428,16 +428,6 @@ internal static void Emit ( eventHandler (sender, e); } - /// - /// Gets the absolute path from the specified . - /// - /// - /// A that represents the absolute path if it's successfully found; - /// otherwise, . - /// - /// - /// A that represents the URI to get the absolute path from. - /// internal static string GetAbsolutePath (this Uri uri) { if (uri.IsAbsoluteUri) From 74c714f9fc2070562cde01c642acdc7b72e9451a Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 5 Mar 2022 21:40:50 +0900 Subject: [PATCH 4177/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 6019a5ef9..46e07de23 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -448,6 +448,7 @@ internal static CookieCollection GetCookies ( ) { var val = headers[response ? "Set-Cookie" : "Cookie"]; + return val != null ? CookieCollection.Parse (val, response) : new CookieCollection (); From 352ac36e0eeef371f15959b47619242643d5cd34 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 5 Mar 2022 21:42:42 +0900 Subject: [PATCH 4178/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 46e07de23..2d4b6e4a4 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -505,6 +505,7 @@ internal static string GetMessage (this CloseStatusCode code) internal static string GetName (this string nameAndValue, char separator) { var idx = nameAndValue.IndexOf (separator); + return idx > 0 ? nameAndValue.Substring (0, idx).Trim () : null; } From d95721075cdb262e8c7c674d02fc11f3e038ebbc Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 5 Mar 2022 21:44:48 +0900 Subject: [PATCH 4179/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 2d4b6e4a4..dc62eb5a7 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -484,24 +484,6 @@ internal static string GetMessage (this CloseStatusCode code) : String.Empty; } - /// - /// Gets the name from the specified string that contains a pair of - /// name and value separated by a character. - /// - /// - /// - /// A that represents the name. - /// - /// - /// if the name is not present. - /// - /// - /// - /// A that contains a pair of name and value. - /// - /// - /// A used to separate name and value. - /// internal static string GetName (this string nameAndValue, char separator) { var idx = nameAndValue.IndexOf (separator); From 463a59ae0d78d720efa777a75dbf7f4f122bfaa4 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 6 Mar 2022 00:42:04 +0900 Subject: [PATCH 4180/6294] Support consecutive HTTP/1.1 requests sent on the same connection without waiting for a response This maybe supports issue #685. --- websocket-sharp/Net/ChunkStream.cs | 39 ++++++++- websocket-sharp/Net/ChunkedRequestStream.cs | 42 ++++++++-- websocket-sharp/Net/HttpConnection.cs | 91 ++++++++++++++++----- websocket-sharp/Net/RequestStream.cs | 65 +++++++++++---- 4 files changed, 192 insertions(+), 45 deletions(-) diff --git a/websocket-sharp/Net/ChunkStream.cs b/websocket-sharp/Net/ChunkStream.cs index 6081113b7..bcd87f9bf 100644 --- a/websocket-sharp/Net/ChunkStream.cs +++ b/websocket-sharp/Net/ChunkStream.cs @@ -8,7 +8,7 @@ * The MIT License * * Copyright (c) 2003 Ximian, Inc (http://www.ximian.com) - * Copyright (c) 2012-2021 sta.blockhead + * Copyright (c) 2012-2022 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -53,8 +53,11 @@ internal class ChunkStream private int _chunkRead; private int _chunkSize; private List _chunks; + private int _count; + private byte[] _endBuffer; private bool _gotIt; private WebHeaderCollection _headers; + private int _offset; private StringBuilder _saved; private bool _sawCr; private InputChunkState _state; @@ -75,6 +78,28 @@ public ChunkStream (WebHeaderCollection headers) #endregion + #region Internal Properties + + internal int Count { + get { + return _count; + } + } + + internal byte[] EndBuffer { + get { + return _endBuffer; + } + } + + internal int Offset { + get { + return _offset; + } + } + + #endregion + #region Public Properties public WebHeaderCollection Headers { @@ -209,6 +234,7 @@ private InputChunkState setTrailer ( break; var b = buffer[offset++]; + _saved.Append ((char) b); if (_trailerState == 1 || _trailerState == 3) { // CR or CR LF CR @@ -244,6 +270,7 @@ private InputChunkState setTrailer ( return InputChunkState.End; _saved.Length = len - 2; + var val = _saved.ToString (); var reader = new StringReader (val); @@ -316,6 +343,14 @@ private void write (byte[] buffer, int offset, int length) _saved.Length = 0; } + if (_state == InputChunkState.End) { + _endBuffer = buffer; + _offset = offset; + _count = length - offset; + + return; + } + if (offset >= length) return; @@ -350,7 +385,7 @@ private InputChunkState writeData ( #region Internal Methods - internal void ResetBuffer () + internal void ResetChunkStore () { _chunkRead = 0; _chunkSize = -1; diff --git a/websocket-sharp/Net/ChunkedRequestStream.cs b/websocket-sharp/Net/ChunkedRequestStream.cs index 2db4b0401..d88c47b18 100644 --- a/websocket-sharp/Net/ChunkedRequestStream.cs +++ b/websocket-sharp/Net/ChunkedRequestStream.cs @@ -8,7 +8,7 @@ * The MIT License * * Copyright (c) 2005 Novell, Inc. (http://www.novell.com) - * Copyright (c) 2012-2021 sta.blockhead + * Copyright (c) 2012-2022 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -66,13 +66,13 @@ static ChunkedRequestStream () #region Internal Constructors internal ChunkedRequestStream ( - Stream stream, - byte[] buffer, + Stream innerStream, + byte[] initialBuffer, int offset, int count, HttpListenerContext context ) - : base (stream, buffer, offset, count, -1) + : base (innerStream, initialBuffer, offset, count, -1) { _context = context; @@ -83,6 +83,36 @@ HttpListenerContext context #endregion + #region Internal Properties + + internal bool HasRemainingBuffer { + get { + return _decoder.Count + Count > 0; + } + } + + internal byte[] RemainingBuffer { + get { + using (var buff = new MemoryStream ()) { + var cnt = _decoder.Count; + + if (cnt > 0) + buff.Write (_decoder.EndBuffer, _decoder.Offset, cnt); + + cnt = Count; + + if (cnt > 0) + buff.Write (InitialBuffer, Offset, cnt); + + buff.Close (); + + return buff.ToArray (); + } + } + } + + #endregion + #region Private Methods private void onRead (IAsyncResult asyncResult) @@ -201,9 +231,9 @@ public override void Close () if (_disposed) return; - _disposed = true; - base.Close (); + + _disposed = true; } public override int EndRead (IAsyncResult asyncResult) diff --git a/websocket-sharp/Net/HttpConnection.cs b/websocket-sharp/Net/HttpConnection.cs index 1ae17f381..e14b73d31 100644 --- a/websocket-sharp/Net/HttpConnection.cs +++ b/websocket-sharp/Net/HttpConnection.cs @@ -8,7 +8,7 @@ * The MIT License * * Copyright (c) 2005 Novell, Inc. (http://www.novell.com) - * Copyright (c) 2012-2021 sta.blockhead + * Copyright (c) 2012-2022 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -134,7 +134,8 @@ internal HttpConnection (Socket socket, EndPointListener listener) _timeoutCanceled = new Dictionary (); _timer = new Timer (onTimeout, this, Timeout.Infinite, Timeout.Infinite); - init (90000); // 90k ms for first request, 15k ms from then on. + // 90k ms for first request, 15k ms from then on. + init (new MemoryStream (), 90000); } #endregion @@ -216,6 +217,32 @@ private void closeSocket () _socket = null; } + private static MemoryStream createRequestBuffer ( + RequestStream inputStream + ) + { + var ret = new MemoryStream (); + + if (inputStream is ChunkedRequestStream) { + var crs = (ChunkedRequestStream) inputStream; + + if (crs.HasRemainingBuffer) { + var buff = crs.RemainingBuffer; + + ret.Write (buff, 0, buff.Length); + } + + return ret; + } + + var cnt = inputStream.Count; + + if (cnt > 0) + ret.Write (inputStream.InitialBuffer, inputStream.Offset, cnt); + + return ret; + } + private void disposeRequestBuffer () { if (_requestBuffer == null) @@ -252,8 +279,9 @@ private void disposeTimer () _timer = null; } - private void init (int timeout) + private void init (MemoryStream requestBuffer, int timeout) { + _requestBuffer = requestBuffer; _timeout = timeout; _context = new HttpListenerContext (this); @@ -263,7 +291,6 @@ private void init (int timeout) _lineState = LineState.None; _outputStream = null; _position = 0; - _requestBuffer = new MemoryStream (); } private static void onRead (IAsyncResult asyncResult) @@ -301,9 +328,11 @@ private static void onRead (IAsyncResult asyncResult) } conn._requestBuffer.Write (conn._buffer, 0, nread); + + var data = conn._requestBuffer.GetBuffer (); var len = (int) conn._requestBuffer.Length; - if (conn.processInput (conn._requestBuffer.GetBuffer (), len)) { + if (conn.processInput (data, len)) { if (!conn._context.HasErrorMessage) conn._context.Request.FinishInitialization (); @@ -316,23 +345,23 @@ private static void onRead (IAsyncResult asyncResult) var url = conn._context.Request.Url; HttpListener lsnr; - if (conn._listener.TrySearchHttpListener (url, out lsnr)) { - if (!lsnr.AuthenticateContext (conn._context)) - return; + if (!conn._listener.TrySearchHttpListener (url, out lsnr)) { + conn._context.ErrorStatusCode = 404; + conn._context.SendError (); - if (!lsnr.RegisterContext (conn._context)) { - conn._context.ErrorStatusCode = 503; - conn._context.SendError (); + return; + } - return; - } + if (!lsnr.AuthenticateContext (conn._context)) + return; + + if (!lsnr.RegisterContext (conn._context)) { + conn._context.ErrorStatusCode = 503; + conn._context.SendError (); return; } - conn._context.ErrorStatusCode = 404; - conn._context.SendError (); - return; } @@ -388,6 +417,7 @@ private bool processInput (byte[] data, int length) if (_inputState == InputState.RequestLine) { _context.Request.SetRequestLine (line); + _inputState = InputState.Headers; } else { @@ -450,6 +480,25 @@ private string readLineFrom ( return ret; } + private MemoryStream takeOverRequestBuffer () + { + if (_inputStream != null) + return createRequestBuffer (_inputStream); + + var ret = new MemoryStream (); + + var buff = _requestBuffer.GetBuffer (); + var len = (int) _requestBuffer.Length; + var cnt = len - _position; + + if (cnt > 0) + ret.Write (buff, _position, cnt); + + disposeRequestBuffer (); + + return ret; + } + #endregion #region Internal Methods @@ -503,12 +552,13 @@ internal void Close (bool force) return; } - disposeRequestBuffer (); _context.Unregister (); _reuses++; - init (15000); + var buff = takeOverRequestBuffer (); + init (buff, 15000); + BeginReadRequest (); } } @@ -535,8 +585,6 @@ public RequestStream GetRequestStream (long contentLength, bool chunked) var len = (int) _requestBuffer.Length; var cnt = len - _position; - disposeRequestBuffer (); - _inputStream = chunked ? new ChunkedRequestStream ( _stream, buff, _position, cnt, _context @@ -545,6 +593,8 @@ public RequestStream GetRequestStream (long contentLength, bool chunked) _stream, buff, _position, cnt, contentLength ); + disposeRequestBuffer (); + return _inputStream; } } @@ -560,6 +610,7 @@ public ResponseStream GetResponseStream () var lsnr = _context.Listener; var ignore = lsnr != null ? lsnr.IgnoreWriteExceptions : true; + _outputStream = new ResponseStream (_stream, _context.Response, ignore); return _outputStream; diff --git a/websocket-sharp/Net/RequestStream.cs b/websocket-sharp/Net/RequestStream.cs index a8d9eabae..a10096ee7 100644 --- a/websocket-sharp/Net/RequestStream.cs +++ b/websocket-sharp/Net/RequestStream.cs @@ -8,7 +8,7 @@ * The MIT License * * Copyright (c) 2005 Novell, Inc. (http://www.novell.com) - * Copyright (c) 2012-2021 sta.blockhead + * Copyright (c) 2012-2022 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -47,22 +47,26 @@ internal class RequestStream : Stream #region Private Fields private long _bodyLeft; - private byte[] _buffer; private int _count; private bool _disposed; + private byte[] _initialBuffer; + private Stream _innerStream; private int _offset; - private Stream _stream; #endregion #region Internal Constructors internal RequestStream ( - Stream stream, byte[] buffer, int offset, int count, long contentLength + Stream innerStream, + byte[] initialBuffer, + int offset, + int count, + long contentLength ) { - _stream = stream; - _buffer = buffer; + _innerStream = innerStream; + _initialBuffer = initialBuffer; _offset = offset; _count = count; _bodyLeft = contentLength; @@ -70,6 +74,28 @@ internal RequestStream ( #endregion + #region Internal Properties + + internal int Count { + get { + return _count; + } + } + + internal byte[] InitialBuffer { + get { + return _initialBuffer; + } + } + + internal int Offset { + get { + return _offset; + } + } + + #endregion + #region Public Properties public override bool CanRead { @@ -110,11 +136,11 @@ public override long Position { #region Private Methods - private int fillFromBuffer (byte[] buffer, int offset, int count) + private int fillFromInitialBuffer (byte[] buffer, int offset, int count) { // This method returns a int: - // - > 0 The number of bytes read from the internal buffer - // - 0 No more bytes read from the internal buffer + // - > 0 The number of bytes read from the initial buffer + // - 0 No more bytes read from the initial buffer // - -1 No more content data if (_bodyLeft == 0) @@ -129,7 +155,7 @@ private int fillFromBuffer (byte[] buffer, int offset, int count) if (_bodyLeft > 0 && _bodyLeft < count) count = (int) _bodyLeft; - Buffer.BlockCopy (_buffer, _offset, buffer, offset, count); + Buffer.BlockCopy (_initialBuffer, _offset, buffer, offset, count); _offset += count; _count -= count; @@ -178,25 +204,27 @@ public override IAsyncResult BeginRead ( } if (count == 0) - return _stream.BeginRead (buffer, offset, 0, callback, state); + return _innerStream.BeginRead (buffer, offset, 0, callback, state); - var nread = fillFromBuffer (buffer, offset, count); + var nread = fillFromInitialBuffer (buffer, offset, count); if (nread != 0) { var ares = new HttpStreamAsyncResult (callback, state); + ares.Buffer = buffer; ares.Offset = offset; ares.Count = count; ares.SyncRead = nread > 0 ? nread : 0; + ares.Complete (); return ares; } - if (_bodyLeft >= 0 && _bodyLeft < count) + if (_bodyLeft > 0 && _bodyLeft < count) count = (int) _bodyLeft; - return _stream.BeginRead (buffer, offset, count, callback, state); + return _innerStream.BeginRead (buffer, offset, count, callback, state); } public override IAsyncResult BeginWrite ( @@ -231,7 +259,7 @@ public override int EndRead (IAsyncResult asyncResult) return ares.SyncRead; } - var nread = _stream.EndRead (asyncResult); + var nread = _innerStream.EndRead (asyncResult); if (nread > 0 && _bodyLeft > 0) _bodyLeft -= nread; @@ -282,7 +310,7 @@ public override int Read (byte[] buffer, int offset, int count) if (count == 0) return 0; - var nread = fillFromBuffer (buffer, offset, count); + var nread = fillFromInitialBuffer (buffer, offset, count); if (nread == -1) return 0; @@ -290,7 +318,10 @@ public override int Read (byte[] buffer, int offset, int count) if (nread > 0) return nread; - nread = _stream.Read (buffer, offset, count); + if (_bodyLeft > 0 && _bodyLeft < count) + count = (int) _bodyLeft; + + nread = _innerStream.Read (buffer, offset, count); if (nread > 0 && _bodyLeft > 0) _bodyLeft -= nread; From d64277ba5751d12432505eff3e5530d9f80d45d5 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 6 Mar 2022 15:57:12 +0900 Subject: [PATCH 4181/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index dc62eb5a7..a309f96f4 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -501,24 +501,6 @@ internal static byte[] GetUTF8EncodedBytes (this string s) return Encoding.UTF8.GetBytes (s); } - /// - /// Gets the value from the specified string that contains a pair of - /// name and value separated by a character. - /// - /// - /// - /// A that represents the value. - /// - /// - /// if the value is not present. - /// - /// - /// - /// A that contains a pair of name and value. - /// - /// - /// A used to separate name and value. - /// internal static string GetValue (this string nameAndValue, char separator) { return nameAndValue.GetValue (separator, false); From d1a3734542a504997842387d476db65349553e3f Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 6 Mar 2022 16:01:15 +0900 Subject: [PATCH 4182/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index a309f96f4..6d037b880 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -533,10 +533,12 @@ internal static string GetValue ( ) { var idx = nameAndValue.IndexOf (separator); + if (idx < 0 || idx == nameAndValue.Length - 1) return null; var val = nameAndValue.Substring (idx + 1).Trim (); + return unquote ? val.Unquote () : val; } From 89da42c96bb2eb00bed723c495e8fdee7144c054 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 6 Mar 2022 16:03:16 +0900 Subject: [PATCH 4183/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 6d037b880..cf280ad4c 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -506,28 +506,6 @@ internal static string GetValue (this string nameAndValue, char separator) return nameAndValue.GetValue (separator, false); } - /// - /// Gets the value from the specified string that contains a pair of - /// name and value separated by a character. - /// - /// - /// - /// A that represents the value. - /// - /// - /// if the value is not present. - /// - /// - /// - /// A that contains a pair of name and value. - /// - /// - /// A used to separate name and value. - /// - /// - /// A : true if unquotes the value; otherwise, - /// false. - /// internal static string GetValue ( this string nameAndValue, char separator, bool unquote ) From 14d92c01c45d43c289f0da5f00c093d10be569a5 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 7 Mar 2022 21:34:59 +0900 Subject: [PATCH 4184/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index cf280ad4c..facdb4a62 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -524,7 +524,10 @@ internal static bool IsCompressionExtension ( this string value, CompressionMethod method ) { - return value.StartsWith (method.ToExtensionString ()); + var val = method.ToExtensionString (); + var compType = StringComparison.Ordinal; + + return value.StartsWith (val, compType); } internal static bool IsControl (this byte opcode) From 272d1ad8bf4ce4cabdf229ee2c734a3242ca4ec7 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 7 Mar 2022 21:42:55 +0900 Subject: [PATCH 4185/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index facdb4a62..f0f73af81 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -598,16 +598,19 @@ internal static bool IsText (this string value) for (var i = 0; i < len; i++) { var c = value[i]; + if (c < 0x20) { if ("\r\n\t".IndexOf (c) == -1) return false; if (c == '\n') { i++; + if (i == len) break; c = value[i]; + if (" \t".IndexOf (c) == -1) return false; } From 52a0da9db1243083528d0c10d0688ad76aead001 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 8 Mar 2022 21:01:06 +0900 Subject: [PATCH 4186/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index f0f73af81..a0907e180 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -645,10 +645,11 @@ internal static bool KeepsAlive ( this NameValueCollection headers, Version version ) { - var comparison = StringComparison.OrdinalIgnoreCase; + var compType = StringComparison.OrdinalIgnoreCase; + return version < HttpVersion.Version11 - ? headers.Contains ("Connection", "keep-alive", comparison) - : !headers.Contains ("Connection", "close", comparison); + ? headers.Contains ("Connection", "keep-alive", compType) + : !headers.Contains ("Connection", "close", compType); } internal static bool MaybeUri (this string value) From be45f34eea6b1ce16322a03131125c89b46daebf Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 8 Mar 2022 21:05:55 +0900 Subject: [PATCH 4187/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index a0907e180..77dd051db 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -666,7 +666,10 @@ internal static bool MaybeUri (this string value) internal static string Quote (this string value) { - return String.Format ("\"{0}\"", value.Replace ("\"", "\\\"")); + var fmt = "\"{0}\""; + var val = value.Replace ("\"", "\\\""); + + return String.Format (fmt, val); } internal static byte[] ReadBytes (this Stream stream, int length) From ac4eb656d6a2eabc3b6da6ab5cc8309c58b955d5 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 9 Mar 2022 00:23:56 +0900 Subject: [PATCH 4188/6294] [Modify] Process the request buffer first if it has remaining data --- websocket-sharp/Net/HttpConnection.cs | 86 ++++++++++++++++----------- 1 file changed, 52 insertions(+), 34 deletions(-) diff --git a/websocket-sharp/Net/HttpConnection.cs b/websocket-sharp/Net/HttpConnection.cs index e14b73d31..81dabdaff 100644 --- a/websocket-sharp/Net/HttpConnection.cs +++ b/websocket-sharp/Net/HttpConnection.cs @@ -329,41 +329,8 @@ private static void onRead (IAsyncResult asyncResult) conn._requestBuffer.Write (conn._buffer, 0, nread); - var data = conn._requestBuffer.GetBuffer (); - var len = (int) conn._requestBuffer.Length; - - if (conn.processInput (data, len)) { - if (!conn._context.HasErrorMessage) - conn._context.Request.FinishInitialization (); - - if (conn._context.HasErrorMessage) { - conn._context.SendError (); - - return; - } - - var url = conn._context.Request.Url; - HttpListener lsnr; - - if (!conn._listener.TrySearchHttpListener (url, out lsnr)) { - conn._context.ErrorStatusCode = 404; - conn._context.SendError (); - - return; - } - - if (!lsnr.AuthenticateContext (conn._context)) - return; - - if (!lsnr.RegisterContext (conn._context)) { - conn._context.ErrorStatusCode = 503; - conn._context.SendError (); - - return; - } - + if (conn.processRequestBuffer ()) return; - } conn.BeginReadRequest (); } @@ -443,6 +410,50 @@ private bool processInput (byte[] data, int length) return false; } + private bool processRequestBuffer () + { + // This method returns a bool: + // - true Done processing + // - false Need more write + + var data = _requestBuffer.GetBuffer (); + var len = (int) _requestBuffer.Length; + + if (!processInput (data, len)) + return false; + + if (!_context.HasErrorMessage) + _context.Request.FinishInitialization (); + + if (_context.HasErrorMessage) { + _context.SendError (); + + return true; + } + + var url = _context.Request.Url; + HttpListener lsnr; + + if (!_listener.TrySearchHttpListener (url, out lsnr)) { + _context.ErrorStatusCode = 404; + _context.SendError (); + + return true; + } + + if (!lsnr.AuthenticateContext (_context)) + return true; + + if (!lsnr.RegisterContext (_context)) { + _context.ErrorStatusCode = 503; + _context.SendError (); + + return true; + } + + return true; + } + private string readLineFrom ( byte[] buffer, int offset, int length, out int nread ) @@ -557,8 +568,15 @@ internal void Close (bool force) _reuses++; var buff = takeOverRequestBuffer (); + var len = buff.Length; + init (buff, 15000); + if (len > 0) { + if (processRequestBuffer ()) + return; + } + BeginReadRequest (); } } From eb4130ea4d9cc73cae55e96dd1d42903015d5768 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 9 Mar 2022 17:35:08 +0900 Subject: [PATCH 4189/6294] [Modify] Combine them --- websocket-sharp/Net/HttpConnection.cs | 10 +-- websocket-sharp/Net/HttpListener.cs | 125 ++++++++++++++------------ 2 files changed, 70 insertions(+), 65 deletions(-) diff --git a/websocket-sharp/Net/HttpConnection.cs b/websocket-sharp/Net/HttpConnection.cs index 81dabdaff..d46e80811 100644 --- a/websocket-sharp/Net/HttpConnection.cs +++ b/websocket-sharp/Net/HttpConnection.cs @@ -441,15 +441,7 @@ private bool processRequestBuffer () return true; } - if (!lsnr.AuthenticateContext (_context)) - return true; - - if (!lsnr.RegisterContext (_context)) { - _context.ErrorStatusCode = 503; - _context.SendError (); - - return true; - } + lsnr.RegisterContext (_context); return true; } diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index a1a6a6ab3..b1d154a5b 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -480,6 +480,45 @@ public Func UserCredentialsFinder { #region Private Methods + private bool authenticateContext (HttpListenerContext context) + { + var req = context.Request; + var schm = selectAuthenticationScheme (req); + + if (schm == AuthenticationSchemes.Anonymous) + return true; + + if (schm == AuthenticationSchemes.None) { + context.ErrorStatusCode = 403; + context.ErrorMessage = "Authentication not allowed"; + + context.SendError (); + + return false; + } + + var realm = getRealm (); + var user = HttpUtility.CreateUser ( + req.Headers["Authorization"], + schm, + realm, + req.HttpMethod, + _userCredFinder + ); + + var authenticated = user != null && user.Identity.IsAuthenticated; + + if (!authenticated) { + context.SendAuthenticationChallenge (schm, realm); + + return false; + } + + context.User = user; + + return true; + } + private HttpListenerAsyncResult beginGetContext ( AsyncCallback callback, object state ) @@ -587,6 +626,29 @@ private string getRealm () return realm != null && realm.Length > 0 ? realm : _defaultRealm; } + private bool registerContext (HttpListenerContext context) + { + lock (_contextRegistrySync) { + if (!_listening) + return false; + + context.Listener = this; + + _contextRegistry.AddLast (context); + + if (_waitQueue.Count == 0) { + _contextQueue.Enqueue (context); + + return true; + } + + var ares = _waitQueue.Dequeue (); + ares.Complete (context, false); + + return true; + } + } + private AuthenticationSchemes selectAuthenticationScheme ( HttpListenerRequest request ) @@ -608,45 +670,6 @@ HttpListenerRequest request #region Internal Methods - internal bool AuthenticateContext (HttpListenerContext context) - { - var req = context.Request; - var schm = selectAuthenticationScheme (req); - - if (schm == AuthenticationSchemes.Anonymous) - return true; - - if (schm == AuthenticationSchemes.None) { - context.ErrorStatusCode = 403; - context.ErrorMessage = "Authentication not allowed"; - - context.SendError (); - - return false; - } - - var realm = getRealm (); - var user = HttpUtility.CreateUser ( - req.Headers["Authorization"], - schm, - realm, - req.HttpMethod, - _userCredFinder - ); - - var authenticated = user != null && user.Identity.IsAuthenticated; - - if (!authenticated) { - context.SendAuthenticationChallenge (schm, realm); - - return false; - } - - context.User = user; - - return true; - } - internal void CheckDisposed () { if (_disposed) @@ -655,27 +678,17 @@ internal void CheckDisposed () internal bool RegisterContext (HttpListenerContext context) { - if (!_listening) + if (!authenticateContext (context)) return false; - lock (_contextRegistrySync) { - if (!_listening) - return false; - - context.Listener = this; - - _contextRegistry.AddLast (context); - - if (_waitQueue.Count == 0) { - _contextQueue.Enqueue (context); - } - else { - var ares = _waitQueue.Dequeue (); - ares.Complete (context, false); - } + if (!registerContext (context)) { + context.ErrorStatusCode = 503; + context.SendError (); - return true; + return false; } + + return true; } internal void UnregisterContext (HttpListenerContext context) From e2cabc81cd93a767f65583f7bac74c05b118c6e2 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 9 Mar 2022 17:40:26 +0900 Subject: [PATCH 4190/6294] [Modify] Add it --- websocket-sharp/Net/HttpListenerContext.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/websocket-sharp/Net/HttpListenerContext.cs b/websocket-sharp/Net/HttpListenerContext.cs index 6488a978f..66d660721 100644 --- a/websocket-sharp/Net/HttpListenerContext.cs +++ b/websocket-sharp/Net/HttpListenerContext.cs @@ -244,6 +244,13 @@ internal void SendError () } } + internal void SendError (int statusCode) + { + _errorStatusCode = statusCode; + + SendError (); + } + internal void Unregister () { if (_listener == null) From 5df0a62e03cfb2e57518d891272dec813b6cf6ad Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 9 Mar 2022 17:43:44 +0900 Subject: [PATCH 4191/6294] [Modify] Replace it --- websocket-sharp/Net/HttpListener.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index b1d154a5b..9838c57f2 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -682,8 +682,7 @@ internal bool RegisterContext (HttpListenerContext context) return false; if (!registerContext (context)) { - context.ErrorStatusCode = 503; - context.SendError (); + context.SendError (503); return false; } From c6a1beac8f098ab245562d7a5531054931ee1a06 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 9 Mar 2022 17:46:02 +0900 Subject: [PATCH 4192/6294] [Modify] Replace it --- websocket-sharp/Net/HttpListener.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 9838c57f2..cf1cfbb9b 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -561,10 +561,8 @@ private void cleanupContextQueue (bool force) _contextQueue.Clear (); - foreach (var ctx in ctxs) { - ctx.ErrorStatusCode = 503; - ctx.SendError (); - } + foreach (var ctx in ctxs) + ctx.SendError (503); } private void cleanupContextRegistry () From 309ef04d2720d573b956ccc3d22338068ca079a8 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 9 Mar 2022 17:48:23 +0900 Subject: [PATCH 4193/6294] [Modify] Replace it --- websocket-sharp/Net/HttpConnection.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpConnection.cs b/websocket-sharp/Net/HttpConnection.cs index d46e80811..dd6191d71 100644 --- a/websocket-sharp/Net/HttpConnection.cs +++ b/websocket-sharp/Net/HttpConnection.cs @@ -435,8 +435,7 @@ private bool processRequestBuffer () HttpListener lsnr; if (!_listener.TrySearchHttpListener (url, out lsnr)) { - _context.ErrorStatusCode = 404; - _context.SendError (); + _context.SendError (404); return true; } From a13cb2481b2c039dc44e2cf7eb0f12d5fd2549f5 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 9 Mar 2022 17:50:06 +0900 Subject: [PATCH 4194/6294] [Modify] Replace it --- websocket-sharp/Net/HttpConnection.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpConnection.cs b/websocket-sharp/Net/HttpConnection.cs index dd6191d71..df9e58c0b 100644 --- a/websocket-sharp/Net/HttpConnection.cs +++ b/websocket-sharp/Net/HttpConnection.cs @@ -351,8 +351,7 @@ private static void onTimeout (object state) if (conn._timeoutCanceled[current]) return; - conn._context.ErrorStatusCode = 408; - conn._context.SendError (); + conn._context.SendError (408); } } From feda367c44649141512795084cf62db5fa1d6cbb Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 9 Mar 2022 17:53:56 +0900 Subject: [PATCH 4195/6294] [Modify] Add it --- websocket-sharp/Net/HttpListenerContext.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/websocket-sharp/Net/HttpListenerContext.cs b/websocket-sharp/Net/HttpListenerContext.cs index 66d660721..6671e79b7 100644 --- a/websocket-sharp/Net/HttpListenerContext.cs +++ b/websocket-sharp/Net/HttpListenerContext.cs @@ -251,6 +251,14 @@ internal void SendError (int statusCode) SendError (); } + internal void SendError (int statusCode, string message) + { + _errorStatusCode = statusCode; + _errorMessage = message; + + SendError (); + } + internal void Unregister () { if (_listener == null) From 4e1b866ad8131f72dc5552b76561004c9ccb7fb9 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 9 Mar 2022 17:56:56 +0900 Subject: [PATCH 4196/6294] [Modify] Replace it --- websocket-sharp/Net/HttpListener.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index cf1cfbb9b..95083465f 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -489,10 +489,8 @@ private bool authenticateContext (HttpListenerContext context) return true; if (schm == AuthenticationSchemes.None) { - context.ErrorStatusCode = 403; - context.ErrorMessage = "Authentication not allowed"; - - context.SendError (); + var msg = "Authentication not allowed"; + context.SendError (403, msg); return false; } From c6b8f15fbe883e68d24e4d69bd9ce74b3d900364 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 10 Mar 2022 00:41:27 +0900 Subject: [PATCH 4197/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerContext.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Net/HttpListenerContext.cs b/websocket-sharp/Net/HttpListenerContext.cs index 6671e79b7..961cb6a3f 100644 --- a/websocket-sharp/Net/HttpListenerContext.cs +++ b/websocket-sharp/Net/HttpListenerContext.cs @@ -234,6 +234,7 @@ internal void SendError () var enc = Encoding.UTF8; var entity = enc.GetBytes (content); + _response.ContentEncoding = enc; _response.ContentLength64 = entity.LongLength; From d2c508d600b4a5b13cbdd9ed77290cd4fdb44b98 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 10 Mar 2022 00:43:44 +0900 Subject: [PATCH 4198/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerContext.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerContext.cs b/websocket-sharp/Net/HttpListenerContext.cs index 961cb6a3f..04598e856 100644 --- a/websocket-sharp/Net/HttpListenerContext.cs +++ b/websocket-sharp/Net/HttpListenerContext.cs @@ -212,9 +212,9 @@ internal void SendAuthenticationChallenge ( AuthenticationSchemes scheme, string realm ) { - var chal = new AuthenticationChallenge (scheme, realm).ToString (); - _response.StatusCode = 401; + + var chal = new AuthenticationChallenge (scheme, realm).ToString (); _response.Headers.InternalSet ("WWW-Authenticate", chal, true); _response.Close (); From 30eef970069b92260b17443bee5fc8dab9420b7f Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 10 Mar 2022 00:45:38 +0900 Subject: [PATCH 4199/6294] [Modify] 2022 --- websocket-sharp/Net/HttpListenerContext.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerContext.cs b/websocket-sharp/Net/HttpListenerContext.cs index 04598e856..cbd85631c 100644 --- a/websocket-sharp/Net/HttpListenerContext.cs +++ b/websocket-sharp/Net/HttpListenerContext.cs @@ -8,7 +8,7 @@ * The MIT License * * Copyright (c) 2005 Novell, Inc. (http://www.novell.com) - * Copyright (c) 2012-2020 sta.blockhead + * Copyright (c) 2012-2022 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From 5bf1d35a68bc7245a28ea7a2200b824b5c823355 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 10 Mar 2022 00:53:01 +0900 Subject: [PATCH 4200/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListener.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 95083465f..3b99dd688 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -534,11 +534,12 @@ private HttpListenerAsyncResult beginGetContext ( if (_contextQueue.Count == 0) { _waitQueue.Enqueue (ares); + + return ares; } - else { - var ctx = _contextQueue.Dequeue (); - ares.Complete (ctx, true); - } + + var ctx = _contextQueue.Dequeue (); + ares.Complete (ctx, true); return ares; } From 8543df996256d85b3afad222464dea471cef9981 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 10 Mar 2022 17:42:34 +0900 Subject: [PATCH 4201/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListener.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 3b99dd688..ec5aece89 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -857,8 +857,8 @@ public HttpListenerContext EndGetContext (IAsyncResult asyncResult) /// Gets an incoming request. /// /// - /// This method waits for an incoming request and returns when a request is - /// received. + /// This method waits for an incoming request and returns when + /// a request is received. /// /// /// A that represents a request. From 21952531b99fdeb116980b4818aa14759148d492 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 10 Mar 2022 17:46:20 +0900 Subject: [PATCH 4202/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListener.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index ec5aece89..68fea5cfa 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -885,14 +885,14 @@ public HttpListenerContext GetContext () if (_disposed) throw new ObjectDisposedException (_objectName); - if (_prefixes.Count == 0) { - var msg = "The listener has no URI prefix on which listens."; + if (!_listening) { + var msg = "The listener has not been started."; throw new InvalidOperationException (msg); } - if (!_listening) { - var msg = "The listener has not been started."; + if (_prefixes.Count == 0) { + var msg = "The listener has no URI prefix on which listens."; throw new InvalidOperationException (msg); } From 62a4f861e53fae2698180945861d0977a1705895 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 10 Mar 2022 17:54:06 +0900 Subject: [PATCH 4203/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListener.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 68fea5cfa..cd302efea 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -865,13 +865,13 @@ public HttpListenerContext EndGetContext (IAsyncResult asyncResult) /// /// /// - /// This listener has no URI prefix on which listens. + /// This listener has not been started or is currently stopped. /// /// /// -or- /// /// - /// This listener has not been started or is currently stopped. + /// This listener has no URI prefix on which listens. /// /// /// From ac938f1e70831370c17b5273ac11bba11b652057 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 11 Mar 2022 16:48:40 +0900 Subject: [PATCH 4204/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListener.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index cd302efea..bb79adcab 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -795,8 +795,8 @@ public void Close () /// Ends an asynchronous operation to get an incoming request. /// /// - /// This method completes an asynchronous operation started by calling - /// the BeginGetContext method. + /// This method completes an asynchronous operation started by + /// calling the BeginGetContext method. /// /// /// A that represents a request. From 3fd568343d812f3b21a08927a384e460a1396285 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 11 Mar 2022 16:50:37 +0900 Subject: [PATCH 4205/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListener.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index bb79adcab..101931140 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -760,14 +760,14 @@ public IAsyncResult BeginGetContext (AsyncCallback callback, object state) if (_disposed) throw new ObjectDisposedException (_objectName); - if (_prefixes.Count == 0) { - var msg = "The listener has no URI prefix on which listens."; + if (!_listening) { + var msg = "The listener has not been started."; throw new InvalidOperationException (msg); } - if (!_listening) { - var msg = "The listener has not been started."; + if (_prefixes.Count == 0) { + var msg = "The listener has no URI prefix on which listens."; throw new InvalidOperationException (msg); } From fd9ce22b1ebcbe09ac4f2745566008073a1c1f91 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 11 Mar 2022 16:53:17 +0900 Subject: [PATCH 4206/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListener.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 101931140..b24d44823 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -740,13 +740,13 @@ public void Abort () /// /// /// - /// This listener has no URI prefix on which listens. + /// This listener has not been started or is currently stopped. /// /// /// -or- /// /// - /// This listener has not been started or is currently stopped. + /// This listener has no URI prefix on which listens. /// /// /// From 47402e3978978b77ec99dc54fca87b7f601cf952 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 11 Mar 2022 16:55:17 +0900 Subject: [PATCH 4207/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListener.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index b24d44823..1f432e671 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -731,8 +731,8 @@ public void Abort () /// the asynchronous operation. /// /// - /// An delegate that references the method to - /// invoke when the asynchronous operation completes. + /// An delegate that references the method + /// to invoke when the asynchronous operation completes. /// /// /// An that represents a user defined object to From 341e6d75c9123ca80113a9cce80a4deb1fd56011 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 11 Mar 2022 16:57:28 +0900 Subject: [PATCH 4208/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListener.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 1f432e671..53a47092c 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -735,7 +735,7 @@ public void Abort () /// to invoke when the asynchronous operation completes. /// /// - /// An that represents a user defined object to + /// An that specifies a user defined object to /// pass to . /// /// From 21083fee29434f9273b30afccb4cde990d48a5aa Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 12 Mar 2022 17:33:49 +0900 Subject: [PATCH 4209/6294] [Modify] Add a check if disposed --- websocket-sharp/Net/HttpListener.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 53a47092c..a11ce253a 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -942,6 +942,9 @@ public void Stop () throw new ObjectDisposedException (_objectName); lock (_contextRegistrySync) { + if (_disposed) + throw new ObjectDisposedException (_objectName); + if (!_listening) return; From bf5a217529a970880d65828d88c533cf5de05b30 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 13 Mar 2022 17:45:37 +0900 Subject: [PATCH 4210/6294] [Modify] Add a check if listening --- websocket-sharp/Net/HttpListener.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index a11ce253a..0650c3c57 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -826,6 +826,12 @@ public HttpListenerContext EndGetContext (IAsyncResult asyncResult) if (_disposed) throw new ObjectDisposedException (_objectName); + if (!_listening) { + var msg = "The listener has not been started."; + + throw new InvalidOperationException (msg); + } + if (asyncResult == null) throw new ArgumentNullException ("asyncResult"); From 77f74bd0ddd479ed5666fcdbc1d3bfe4340e4e46 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 14 Mar 2022 21:29:29 +0900 Subject: [PATCH 4211/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListener.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 0650c3c57..95eddb642 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -813,7 +813,15 @@ public void Close () /// the BeginGetContext method. /// /// - /// This method was already called for . + /// + /// This listener has not been started or is currently stopped. + /// + /// + /// -or- + /// + /// + /// This method was already called for . + /// /// /// /// This method is canceled. From d06ac8131a8318c93f7fed342a45255277f35dd1 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 15 Mar 2022 17:10:02 +0900 Subject: [PATCH 4212/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListener.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 95eddb642..6c7588017 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -57,6 +57,17 @@ namespace WebSocketSharp.Net /// /// Provides a simple, programmatically controlled HTTP listener. /// + /// + /// + /// The listener supports HTTP/1.1 version request and response. + /// + /// + /// And the listener allows to accept WebSocket handshake requests. + /// + /// + /// This class cannot be inherited. + /// + /// public sealed class HttpListener : IDisposable { #region Private Fields From 2d25d461c34f29a6adf9a0b1e81f4d6c3f686573 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 16 Mar 2022 22:21:48 +0900 Subject: [PATCH 4213/6294] [Modify] 2022 --- websocket-sharp/Net/HttpListener.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 6c7588017..cfc915297 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -8,7 +8,7 @@ * The MIT License * * Copyright (c) 2005 Novell, Inc. (http://www.novell.com) - * Copyright (c) 2012-2021 sta.blockhead + * Copyright (c) 2012-2022 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From 3f6a785c93be74e0dbd79afb04c91435cba984c7 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 16 Mar 2022 22:29:43 +0900 Subject: [PATCH 4214/6294] [Modify] Polish it --- websocket-sharp/Net/HttpConnection.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/HttpConnection.cs b/websocket-sharp/Net/HttpConnection.cs index df9e58c0b..056aa2d3e 100644 --- a/websocket-sharp/Net/HttpConnection.cs +++ b/websocket-sharp/Net/HttpConnection.cs @@ -421,8 +421,10 @@ private bool processRequestBuffer () if (!processInput (data, len)) return false; + var req = _context.Request; + if (!_context.HasErrorMessage) - _context.Request.FinishInitialization (); + req.FinishInitialization (); if (_context.HasErrorMessage) { _context.SendError (); @@ -430,10 +432,10 @@ private bool processRequestBuffer () return true; } - var url = _context.Request.Url; + var uri = req.Url; HttpListener lsnr; - if (!_listener.TrySearchHttpListener (url, out lsnr)) { + if (!_listener.TrySearchHttpListener (uri, out lsnr)) { _context.SendError (404); return true; From 5413c2b23f55cc5e8d04c3539dde495df3e83351 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 17 Mar 2022 17:37:53 +0900 Subject: [PATCH 4215/6294] [Modify] Rename it --- websocket-sharp/Net/HttpConnection.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/HttpConnection.cs b/websocket-sharp/Net/HttpConnection.cs index 056aa2d3e..4417df9d4 100644 --- a/websocket-sharp/Net/HttpConnection.cs +++ b/websocket-sharp/Net/HttpConnection.cs @@ -68,7 +68,7 @@ internal sealed class HttpConnection private InputState _inputState; private RequestStream _inputStream; private LineState _lineState; - private EndPointListener _listener; + private EndPointListener _endPointListener; private EndPoint _localEndPoint; private static readonly int _maxInputLength; private ResponseStream _outputStream; @@ -101,7 +101,7 @@ static HttpConnection () internal HttpConnection (Socket socket, EndPointListener listener) { _socket = socket; - _listener = listener; + _endPointListener = listener; var netStream = new NetworkStream (socket, false); @@ -201,7 +201,7 @@ private void close () } _context.Unregister (); - _listener.RemoveConnection (this); + _endPointListener.RemoveConnection (this); } private void closeSocket () @@ -435,7 +435,7 @@ private bool processRequestBuffer () var uri = req.Url; HttpListener lsnr; - if (!_listener.TrySearchHttpListener (uri, out lsnr)) { + if (!_endPointListener.TrySearchHttpListener (uri, out lsnr)) { _context.SendError (404); return true; From 8c623eac2485822dce05b6bc38c317080ff6d4f9 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 17 Mar 2022 17:39:47 +0900 Subject: [PATCH 4216/6294] [Modify] Polish it --- websocket-sharp/Net/HttpConnection.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpConnection.cs b/websocket-sharp/Net/HttpConnection.cs index 4417df9d4..1191aea4d 100644 --- a/websocket-sharp/Net/HttpConnection.cs +++ b/websocket-sharp/Net/HttpConnection.cs @@ -65,10 +65,10 @@ internal sealed class HttpConnection private static readonly int _bufferLength; private HttpListenerContext _context; private StringBuilder _currentLine; + private EndPointListener _endPointListener; private InputState _inputState; private RequestStream _inputStream; private LineState _lineState; - private EndPointListener _endPointListener; private EndPoint _localEndPoint; private static readonly int _maxInputLength; private ResponseStream _outputStream; From 1566ba8084edddd1b5d95dbb11f5adb6f4fe5dbf Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 17 Mar 2022 17:47:13 +0900 Subject: [PATCH 4217/6294] [Modify] Polish it --- websocket-sharp/Net/HttpConnection.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/HttpConnection.cs b/websocket-sharp/Net/HttpConnection.cs index 1191aea4d..f174d7ff8 100644 --- a/websocket-sharp/Net/HttpConnection.cs +++ b/websocket-sharp/Net/HttpConnection.cs @@ -433,15 +433,15 @@ private bool processRequestBuffer () } var uri = req.Url; - HttpListener lsnr; + HttpListener httplsnr; - if (!_endPointListener.TrySearchHttpListener (uri, out lsnr)) { + if (!_endPointListener.TrySearchHttpListener (uri, out httplsnr)) { _context.SendError (404); return true; } - lsnr.RegisterContext (_context); + httplsnr.RegisterContext (_context); return true; } From 75a16a8b3e039a71f1784b11131bf9436282fff8 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 18 Mar 2022 20:27:34 +0900 Subject: [PATCH 4218/6294] [Modify] Polish it --- websocket-sharp/Net/HttpConnection.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpConnection.cs b/websocket-sharp/Net/HttpConnection.cs index f174d7ff8..851b914fd 100644 --- a/websocket-sharp/Net/HttpConnection.cs +++ b/websocket-sharp/Net/HttpConnection.cs @@ -394,8 +394,10 @@ private bool processInput (byte[] data, int length) return true; } } - catch (Exception ex) { - _context.ErrorMessage = ex.Message; + catch (Exception) { + // TODO: Logging. + + _context.ErrorMessage = "Processing failure"; return true; } From e124f22a3e208d69999faaf75fb7d1338701c420 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 19 Mar 2022 22:48:08 +0900 Subject: [PATCH 4219/6294] [Modify] Polish it --- websocket-sharp/Net/HttpConnection.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpConnection.cs b/websocket-sharp/Net/HttpConnection.cs index 851b914fd..30ca852ab 100644 --- a/websocket-sharp/Net/HttpConnection.cs +++ b/websocket-sharp/Net/HttpConnection.cs @@ -361,6 +361,8 @@ private bool processInput (byte[] data, int length) // - true Done processing // - false Need more input + var req = _context.Request; + try { while (true) { int nread; @@ -382,12 +384,12 @@ private bool processInput (byte[] data, int length) } if (_inputState == InputState.RequestLine) { - _context.Request.SetRequestLine (line); + req.SetRequestLine (line); _inputState = InputState.Headers; } else { - _context.Request.AddHeader (line); + req.AddHeader (line); } if (_context.HasErrorMessage) From 80f6b2a7926490a7bd9a26f3ed6478b05413b6a8 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 20 Mar 2022 17:11:07 +0900 Subject: [PATCH 4220/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerRequest.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index fec36551a..53a016e92 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -696,9 +696,9 @@ internal void FinishInitialization () var transferEnc = _headers["Transfer-Encoding"]; if (transferEnc != null) { - var comparison = StringComparison.OrdinalIgnoreCase; + var compType = StringComparison.OrdinalIgnoreCase; - if (!transferEnc.Equals ("chunked", comparison)) { + if (!transferEnc.Equals ("chunked", compType)) { _context.ErrorMessage = "Invalid Transfer-Encoding header"; _context.ErrorStatusCode = 501; From c8c9cc1814822da19620ff20cc1e2fcbe65d5807 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 20 Mar 2022 17:13:47 +0900 Subject: [PATCH 4221/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerRequest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index 53a016e92..bbbf29a72 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -699,8 +699,8 @@ internal void FinishInitialization () var compType = StringComparison.OrdinalIgnoreCase; if (!transferEnc.Equals ("chunked", compType)) { - _context.ErrorMessage = "Invalid Transfer-Encoding header"; _context.ErrorStatusCode = 501; + _context.ErrorMessage = "Invalid Transfer-Encoding header"; return; } From 1390477ea3a3af761b2932c6e35b1ef9a50557d7 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 21 Mar 2022 17:34:45 +0900 Subject: [PATCH 4222/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerRequest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index bbbf29a72..fabf76281 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -710,8 +710,8 @@ internal void FinishInitialization () if (_httpMethod == "POST" || _httpMethod == "PUT") { if (_contentLength <= 0 && !_chunked) { - _context.ErrorMessage = String.Empty; _context.ErrorStatusCode = 411; + _context.ErrorMessage = "Valid Content-Length header required"; return; } From dce5db946b20812fdd43cf9d54081bd451424f9c Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 21 Mar 2022 17:37:14 +0900 Subject: [PATCH 4223/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerRequest.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index fabf76281..4c2833c83 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -720,9 +720,9 @@ internal void FinishInitialization () var expect = _headers["Expect"]; if (expect != null) { - var comparison = StringComparison.OrdinalIgnoreCase; + var compType = StringComparison.OrdinalIgnoreCase; - if (!expect.Equals ("100-continue", comparison)) { + if (!expect.Equals ("100-continue", compType)) { _context.ErrorMessage = "Invalid Expect header"; return; From faf2b5224d2e370034551a9ad3e21a4373a5b8be Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 22 Mar 2022 16:45:46 +0900 Subject: [PATCH 4224/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerRequest.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index 4c2833c83..d219cd246 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -729,6 +729,7 @@ internal void FinishInitialization () } var output = _connection.GetResponseStream (); + output.InternalWrite (_100continue, 0, _100continue.Length); } } From 3af4f47658b39b2b2c049662de5b2beb5dea106d Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 22 Mar 2022 16:53:05 +0900 Subject: [PATCH 4225/6294] [Modify] Use status code 417 --- websocket-sharp/Net/HttpListenerRequest.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index d219cd246..753c1a0dc 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -723,6 +723,7 @@ internal void FinishInitialization () var compType = StringComparison.OrdinalIgnoreCase; if (!expect.Equals ("100-continue", compType)) { + _context.ErrorStatusCode = 417; _context.ErrorMessage = "Invalid Expect header"; return; From ffdfd866ff12d4e8b683e3da31c237cc1416ef0b Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 23 Mar 2022 17:51:22 +0900 Subject: [PATCH 4226/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerRequest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index 753c1a0dc..2865abac8 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -823,8 +823,8 @@ internal void SetRequestLine (string requestLine) } if (ver != HttpVersion.Version11) { - _context.ErrorMessage = "Invalid request line (version)"; _context.ErrorStatusCode = 505; + _context.ErrorMessage = "Invalid request line (version)"; return; } From a8283bdc78b222e22f157fa8a079d3b029f0ba4d Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 23 Mar 2022 17:53:18 +0900 Subject: [PATCH 4227/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerRequest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index 2865abac8..40721e4b0 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -830,8 +830,8 @@ internal void SetRequestLine (string requestLine) } if (!method.IsHttpMethod (ver)) { - _context.ErrorMessage = "Invalid request line (method)"; _context.ErrorStatusCode = 501; + _context.ErrorMessage = "Invalid request line (method)"; return; } From 250621f9bc3b484bd1c51fd673051a5cbad4de5c Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 24 Mar 2022 17:25:21 +0900 Subject: [PATCH 4228/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerRequest.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index 40721e4b0..af614b58e 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -916,11 +916,12 @@ public override string ToString () { var buff = new StringBuilder (64); + var fmt = "{0} {1} HTTP/{2}\r\n"; + var headers = _headers.ToString (); + buff - .AppendFormat ( - "{0} {1} HTTP/{2}\r\n", _httpMethod, _rawUrl, _protocolVersion - ) - .Append (_headers.ToString ()); + .AppendFormat (fmt, _httpMethod, _rawUrl, _protocolVersion) + .Append (headers); return buff.ToString (); } From 0ccbc8a6e43699d5975a280b351b627e98861a3f Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 24 Mar 2022 17:31:45 +0900 Subject: [PATCH 4229/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerRequest.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index af614b58e..c92bd69b5 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -849,16 +849,16 @@ internal void SetRequestLine (string requestLine) /// Begins getting the certificate provided by the client asynchronously. /// /// - /// An instance that indicates the status of the - /// operation. + /// An instance that indicates the status of + /// the operation. /// /// /// An delegate that invokes the method called /// when the operation is complete. /// /// - /// An that represents a user defined object to pass to - /// the callback delegate. + /// An that specifies a user defined object to pass + /// to the callback delegate. /// /// /// This method is not supported. From b28c4ba12526ce93a37e01f36e1e04a71a3168ee Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 24 Mar 2022 17:33:25 +0900 Subject: [PATCH 4230/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerRequest.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index c92bd69b5..229cb1856 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -871,8 +871,8 @@ public IAsyncResult BeginGetClientCertificate ( } /// - /// Ends an asynchronous operation to get the certificate provided by the - /// client. + /// Ends an asynchronous operation to get the certificate provided by + /// the client. /// /// /// A that represents an X.509 certificate From 1bb1b9b96689f5a815c99bcbb94d7ce6997671ce Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 25 Mar 2022 17:51:30 +0900 Subject: [PATCH 4231/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerRequest.cs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index 229cb1856..a21d947d0 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -402,12 +402,9 @@ public NameValueCollection QueryString { get { if (_queryString == null) { var url = Url; + var query = url != null ? url.Query : null; - _queryString = QueryStringCollection - .Parse ( - url != null ? url.Query : null, - Encoding.UTF8 - ); + _queryString = QueryStringCollection.Parse (query, Encoding.UTF8); } return _queryString; From fdbd4b05d26a9a1004b54fc9774c285725c6adcd Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 26 Mar 2022 17:31:57 +0900 Subject: [PATCH 4232/6294] [Modify] Add it --- websocket-sharp/Net/HttpListenerRequest.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index a21d947d0..fe5f2dbe8 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -66,6 +66,7 @@ public sealed class HttpListenerRequest private long _contentLength; private HttpListenerContext _context; private CookieCollection _cookies; + private static readonly Encoding _defaultEncoding; private WebHeaderCollection _headers; private string _httpMethod; private Stream _inputStream; @@ -86,6 +87,7 @@ public sealed class HttpListenerRequest static HttpListenerRequest () { _100continue = Encoding.ASCII.GetBytes ("HTTP/1.1 100 Continue\r\n\r\n"); + _defaultEncoding = Encoding.UTF8; } #endregion From 183b5dd5307b167ce60a48a696912215f21d955d Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 26 Mar 2022 17:33:31 +0900 Subject: [PATCH 4233/6294] [Modify] Replace it --- websocket-sharp/Net/HttpListenerRequest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index fe5f2dbe8..4b584732c 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -406,7 +406,7 @@ public NameValueCollection QueryString { var url = Url; var query = url != null ? url.Query : null; - _queryString = QueryStringCollection.Parse (query, Encoding.UTF8); + _queryString = QueryStringCollection.Parse (query, _defaultEncoding); } return _queryString; From 4ec848997b99d540eb6d37e8b8c18312851d9c69 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 26 Mar 2022 17:36:09 +0900 Subject: [PATCH 4234/6294] [Modify] Replace it --- websocket-sharp/Net/HttpListenerRequest.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index 4b584732c..21011651e 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -592,13 +592,13 @@ private Encoding getContentEncoding () var val = _headers["Content-Type"]; if (val == null) - return Encoding.UTF8; + return _defaultEncoding; Encoding ret; return HttpUtility.TryGetEncoding (val, out ret) ? ret - : Encoding.UTF8; + : _defaultEncoding; } #endregion From 4c3783325f896a5e9a237de1e9522392d930a28a Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 27 Mar 2022 17:58:45 +0900 Subject: [PATCH 4235/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerRequest.cs | 40 +++++++++++----------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index 21011651e..f606b28a2 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -58,27 +58,27 @@ public sealed class HttpListenerRequest { #region Private Fields - private static readonly byte[] _100continue; - private string[] _acceptTypes; - private bool _chunked; - private HttpConnection _connection; - private Encoding _contentEncoding; - private long _contentLength; - private HttpListenerContext _context; - private CookieCollection _cookies; + private static readonly byte[] _100continue; + private string[] _acceptTypes; + private bool _chunked; + private HttpConnection _connection; + private Encoding _contentEncoding; + private long _contentLength; + private HttpListenerContext _context; + private CookieCollection _cookies; private static readonly Encoding _defaultEncoding; - private WebHeaderCollection _headers; - private string _httpMethod; - private Stream _inputStream; - private Version _protocolVersion; - private NameValueCollection _queryString; - private string _rawUrl; - private Guid _requestTraceIdentifier; - private Uri _url; - private Uri _urlReferrer; - private bool _urlSet; - private string _userHostName; - private string[] _userLanguages; + private WebHeaderCollection _headers; + private string _httpMethod; + private Stream _inputStream; + private Version _protocolVersion; + private NameValueCollection _queryString; + private string _rawUrl; + private Guid _requestTraceIdentifier; + private Uri _url; + private Uri _urlReferrer; + private bool _urlSet; + private string _userHostName; + private string[] _userLanguages; #endregion From f30aa9d42ece304ddc88c618f1f5372292c73aa0 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 28 Mar 2022 17:31:29 +0900 Subject: [PATCH 4236/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerRequest.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index f606b28a2..d3e3bfdcb 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -561,9 +561,11 @@ public string UserHostName { /// /// /// - /// An array of that contains the names of the - /// natural languages specified in the value of the Accept-Language - /// header. + /// An array of or . + /// + /// + /// The array contains the names of the natural languages specified in + /// the value of the Accept-Language header. /// /// /// if the header is not present. From 798b9d974917d78652bc36c64fd4519e0af2f598 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 28 Mar 2022 17:35:05 +0900 Subject: [PATCH 4237/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerRequest.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index d3e3bfdcb..8bca996c1 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -113,8 +113,11 @@ internal HttpListenerRequest (HttpListenerContext context) /// /// /// - /// An array of that contains the names of the media - /// types specified in the value of the Accept header. + /// An array of or . + /// + /// + /// The array contains the names of the media types specified in + /// the value of the Accept header. /// /// /// if the header is not present. From 13ff1eef943c05b65d0d694bb665bcfc58c23339 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 29 Mar 2022 16:21:36 +0900 Subject: [PATCH 4238/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerRequest.cs | 3 --- 1 file changed, 3 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index 8bca996c1..18e4f31b6 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -549,9 +549,6 @@ public string UserHostAddress { /// /// It includes the port number if provided. /// - /// - /// if the header is not present. - /// /// public string UserHostName { get { From 6800c3567240f5330dfa6bdd1621631032cd023e Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 29 Mar 2022 16:24:25 +0900 Subject: [PATCH 4239/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerRequest.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index 18e4f31b6..bc45eef10 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -530,8 +530,8 @@ public string UserAgent { /// Gets the IP address and port number to which the request is sent. /// /// - /// A that represents the server IP address and port - /// number. + /// A that represents the server IP address and + /// port number. /// public string UserHostAddress { get { From dcb8164acb74161b6ba963d7956622b2d2daf402 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 29 Mar 2022 16:29:48 +0900 Subject: [PATCH 4240/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerRequest.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index bc45eef10..cbea9ddd3 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -433,8 +433,8 @@ public string RawUrl { /// Gets the endpoint from which the request is sent. /// /// - /// A that represents the client IP - /// address and port number. + /// A that represents the client + /// IP address and port number. /// public System.Net.IPEndPoint RemoteEndPoint { get { From e7faae91cd8b74c753cffedc39de8587f931ae8c Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 29 Mar 2022 17:01:34 +0900 Subject: [PATCH 4241/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerRequest.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index cbea9ddd3..822328001 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -400,6 +400,9 @@ public Version ProtocolVersion { /// parameters. /// /// + /// Each query parameter is decoded in UTF-8. + /// + /// /// An empty collection if not included. /// /// From a2f287474df8ae08c3689874eadf134394c77c64 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 29 Mar 2022 17:03:15 +0900 Subject: [PATCH 4242/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerRequest.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index 822328001..ba3ecc3f2 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -369,8 +369,8 @@ public bool KeepAlive { /// Gets the endpoint to which the request is sent. /// /// - /// A that represents the server IP - /// address and port number. + /// A that represents the server + /// IP address and port number. /// public System.Net.IPEndPoint LocalEndPoint { get { From 079af21c8b56e9534ef81acde9075fc4c73abae2 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 29 Mar 2022 17:25:27 +0900 Subject: [PATCH 4243/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerRequest.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index ba3ecc3f2..cb3660b2b 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -312,12 +312,12 @@ public bool IsAuthenticated { } /// - /// Gets a value indicating whether the request is sent from the local - /// computer. + /// Gets a value indicating whether the request is sent from the + /// local computer. /// /// - /// true if the request is sent from the same computer as the server; - /// otherwise, false. + /// true if the request is sent from the same computer as + /// the server; otherwise, false. /// public bool IsLocal { get { From 1de9f65e27d999e7c30fe8f19fdc9b836a1d2a18 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 30 Mar 2022 14:41:46 +0900 Subject: [PATCH 4244/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerRequest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index cb3660b2b..3969759fe 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -474,7 +474,7 @@ public Uri Url { _url = HttpUtility .CreateRequestUrl ( _rawUrl, - _userHostName ?? UserHostAddress, + _userHostName, IsWebSocketRequest, IsSecureConnection ); From 5962b4b55ce47ba4c6214eaf9e30c2250e3d32b0 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 30 Mar 2022 14:51:54 +0900 Subject: [PATCH 4245/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerRequest.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index 3969759fe..762bf73c8 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -203,8 +203,10 @@ public long ContentLength64 { /// /// /// - /// A that represents the value of the Content-Type - /// header. + /// A or . + /// + /// + /// The string represents the value of the Content-Type header. /// /// /// if the header is not present. From 30e9f2b8fb2cb19ca03b51aef053fbdc5467ed65 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 30 Mar 2022 14:56:35 +0900 Subject: [PATCH 4246/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerRequest.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index 762bf73c8..a4fd5395e 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -518,8 +518,10 @@ public Uri UrlReferrer { /// /// /// - /// A that represents the value of the User-Agent - /// header. + /// A or . + /// + /// + /// The string represents the value of the User-Agent header. /// /// /// if the header is not present. From ff6964cb850bd2adc49b3ae5efedb19da1e86de5 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 30 Mar 2022 15:05:03 +0900 Subject: [PATCH 4247/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerRequest.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index a4fd5395e..fac7a6670 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -464,7 +464,10 @@ public Guid RequestTraceIdentifier { ///
/// /// - /// A that represents the URL parsed from the request. + /// A or . + /// + /// + /// The Uri represents the URL parsed from the request. /// /// /// if the URL cannot be parsed. From c1ef2b386be7afb460fbf888095b59da236fc8ff Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 31 Mar 2022 17:05:26 +0900 Subject: [PATCH 4248/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerRequest.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index fac7a6670..1906d4dc1 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -496,7 +496,10 @@ public Uri Url { ///
/// /// - /// A converted from the value of the Referer header. + /// A or . + /// + /// + /// The Uri represents the value of the Referer header. /// /// /// if the header value is not available. From 23aeb06e6df874550b8c1abc2f60d908d69e626d Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 1 Apr 2022 16:56:41 +0900 Subject: [PATCH 4249/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerRequest.cs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index 1906d4dc1..18fcea69a 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -723,9 +723,16 @@ internal void FinishInitialization () } if (_httpMethod == "POST" || _httpMethod == "PUT") { - if (_contentLength <= 0 && !_chunked) { + if (_contentLength == -1 && !_chunked) { _context.ErrorStatusCode = 411; - _context.ErrorMessage = "Valid Content-Length header required"; + _context.ErrorMessage = "Content-Length header required"; + + return; + } + + if (_contentLength == 0 && !_chunked) { + _context.ErrorStatusCode = 411; + _context.ErrorMessage = "Invalid Content-Length header"; return; } From e756c5c2bb4a2c307f092299bfd19713cfab28cb Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 1 Apr 2022 16:59:45 +0900 Subject: [PATCH 4250/6294] [Modify] 2022 --- websocket-sharp/Net/HttpListenerRequest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index 18fcea69a..6070ff89e 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -8,7 +8,7 @@ * The MIT License * * Copyright (c) 2005 Novell, Inc. (http://www.novell.com) - * Copyright (c) 2012-2021 sta.blockhead + * Copyright (c) 2012-2022 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From 0d53fd6fd6efdefac29ebdbdabf2f495fcbcd531 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 2 Apr 2022 17:21:26 +0900 Subject: [PATCH 4251/6294] [Modify] Polish it --- websocket-sharp/Net/QueryStringCollection.cs | 37 +++++++++++--------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/websocket-sharp/Net/QueryStringCollection.cs b/websocket-sharp/Net/QueryStringCollection.cs index 2e925e2d1..e05109bde 100644 --- a/websocket-sharp/Net/QueryStringCollection.cs +++ b/websocket-sharp/Net/QueryStringCollection.cs @@ -84,8 +84,7 @@ public static QueryStringCollection Parse (string query, Encoding encoding) if (query == null) return new QueryStringCollection (1); - var len = query.Length; - if (len == 0) + if (query.Length == 0) return new QueryStringCollection (1); if (query == "?") @@ -100,31 +99,35 @@ public static QueryStringCollection Parse (string query, Encoding encoding) var ret = new QueryStringCollection (); var components = query.Split ('&'); + foreach (var component in components) { - len = component.Length; + var len = component.Length; + if (len == 0) continue; if (component == "=") continue; - var i = component.IndexOf ('='); - if (i < 0) { - ret.Add (null, urlDecode (component, encoding)); - continue; - } + string name = null; + string val = null; - if (i == 0) { - ret.Add (null, urlDecode (component.Substring (1), encoding)); - continue; - } + var idx = component.IndexOf ('='); - var name = urlDecode (component.Substring (0, i), encoding); + if (idx < 0) { + val = urlDecode (component, encoding); + } + else if (idx == 0) { + val = urlDecode (component.Substring (1), encoding); + } + else { + name = urlDecode (component.Substring (0, idx), encoding); - var start = i + 1; - var val = start < len - ? urlDecode (component.Substring (start), encoding) - : String.Empty; + var start = idx + 1; + val = start < len + ? urlDecode (component.Substring (start), encoding) + : String.Empty; + } ret.Add (name, val); } From c05dd145f285c6a0e9f28c41d4e6c34a4343257c Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 3 Apr 2022 16:49:04 +0900 Subject: [PATCH 4252/6294] [Modify] Replace it --- websocket-sharp/Ext.cs | 4 +++- websocket-sharp/Net/QueryStringCollection.cs | 8 ++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 77dd051db..f32dd66b7 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1220,7 +1220,9 @@ internal static bool Upgrades ( internal static string UrlDecode (this string value, Encoding encoding) { - return HttpUtility.UrlDecode (value, encoding); + return value.IndexOfAny (new[] { '%', '+' }) > -1 + ? HttpUtility.UrlDecode (value, encoding) + : value; } internal static string UrlEncode (this string value, Encoding encoding) diff --git a/websocket-sharp/Net/QueryStringCollection.cs b/websocket-sharp/Net/QueryStringCollection.cs index e05109bde..7baeeb270 100644 --- a/websocket-sharp/Net/QueryStringCollection.cs +++ b/websocket-sharp/Net/QueryStringCollection.cs @@ -115,17 +115,17 @@ public static QueryStringCollection Parse (string query, Encoding encoding) var idx = component.IndexOf ('='); if (idx < 0) { - val = urlDecode (component, encoding); + val = component.UrlDecode (encoding); } else if (idx == 0) { - val = urlDecode (component.Substring (1), encoding); + val = component.Substring (1).UrlDecode (encoding); } else { - name = urlDecode (component.Substring (0, idx), encoding); + name = component.Substring (0, idx).UrlDecode (encoding); var start = idx + 1; val = start < len - ? urlDecode (component.Substring (start), encoding) + ? component.Substring (start).UrlDecode (encoding) : String.Empty; } From e503995c7d2e2ccf750ecef4c4f9c3bdb1616dd0 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 3 Apr 2022 16:51:26 +0900 Subject: [PATCH 4253/6294] [Modify] Remove it --- websocket-sharp/Net/QueryStringCollection.cs | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/websocket-sharp/Net/QueryStringCollection.cs b/websocket-sharp/Net/QueryStringCollection.cs index 7baeeb270..9c1b912d3 100644 --- a/websocket-sharp/Net/QueryStringCollection.cs +++ b/websocket-sharp/Net/QueryStringCollection.cs @@ -61,17 +61,6 @@ public QueryStringCollection (int capacity) #endregion - #region Private Methods - - private static string urlDecode (string s, Encoding encoding) - { - return s.IndexOfAny (new[] { '%', '+' }) > -1 - ? HttpUtility.UrlDecode (s, encoding) - : s; - } - - #endregion - #region Public Methods public static QueryStringCollection Parse (string query) From 70b5059122dc925e3d19eb1a58ce42a8668372d9 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 4 Apr 2022 16:38:01 +0900 Subject: [PATCH 4254/6294] [Modify] Polish it --- websocket-sharp/Net/QueryStringCollection.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/websocket-sharp/Net/QueryStringCollection.cs b/websocket-sharp/Net/QueryStringCollection.cs index 9c1b912d3..2c31d0202 100644 --- a/websocket-sharp/Net/QueryStringCollection.cs +++ b/websocket-sharp/Net/QueryStringCollection.cs @@ -87,9 +87,7 @@ public static QueryStringCollection Parse (string query, Encoding encoding) var ret = new QueryStringCollection (); - var components = query.Split ('&'); - - foreach (var component in components) { + foreach (var component in query.Split ('&')) { var len = component.Length; if (len == 0) From 373f3bb4c3662fa439ca699dff94c8b30387fd21 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 4 Apr 2022 16:39:37 +0900 Subject: [PATCH 4255/6294] [Modify] 2022 --- websocket-sharp/Net/QueryStringCollection.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/QueryStringCollection.cs b/websocket-sharp/Net/QueryStringCollection.cs index 2c31d0202..f07f34f40 100644 --- a/websocket-sharp/Net/QueryStringCollection.cs +++ b/websocket-sharp/Net/QueryStringCollection.cs @@ -8,7 +8,7 @@ * The MIT License * * Copyright (c) 2005-2009 Novell, Inc. (http://www.novell.com) - * Copyright (c) 2018 sta.blockhead + * Copyright (c) 2018-2022 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From b8ab1b9da527c03623e5a161f0e05a7e206f7f24 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 4 Apr 2022 23:06:49 +0900 Subject: [PATCH 4256/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index f32dd66b7..6dd0c87b7 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1213,9 +1213,10 @@ internal static bool Upgrades ( this NameValueCollection headers, string protocol ) { - var comparison = StringComparison.OrdinalIgnoreCase; - return headers.Contains ("Upgrade", protocol, comparison) - && headers.Contains ("Connection", "Upgrade", comparison); + var compType = StringComparison.OrdinalIgnoreCase; + + return headers.Contains ("Upgrade", protocol, compType) + && headers.Contains ("Connection", "Upgrade", compType); } internal static string UrlDecode (this string value, Encoding encoding) From 22bbf9fdb1187af2b647985e0066364d207439eb Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 4 Apr 2022 23:16:14 +0900 Subject: [PATCH 4257/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 6dd0c87b7..3bf59ee82 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1195,17 +1195,20 @@ internal static bool TryOpenRead ( internal static string Unquote (this string value) { - var start = value.IndexOf ('"'); - if (start == -1) + var first = value.IndexOf ('"'); + + if (first == -1) return value; - var end = value.LastIndexOf ('"'); - if (end == start) + var last = value.LastIndexOf ('"'); + + if (last == first) return value; - var len = end - start - 1; + var len = last - first - 1; + return len > 0 - ? value.Substring (start + 1, len).Replace ("\\\"", "\"") + ? value.Substring (first + 1, len).Replace ("\\\"", "\"") : String.Empty; } From 8590ec7f8da42e87267380f2f8aef49091af05e5 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 4 Apr 2022 23:22:57 +0900 Subject: [PATCH 4258/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 3bf59ee82..af06086ab 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1163,7 +1163,9 @@ internal static bool TryGetUTF8DecodedString (this byte[] bytes, out string s) return true; } - internal static bool TryGetUTF8EncodedBytes (this string s, out byte[] bytes) + internal static bool TryGetUTF8EncodedBytes ( + this string s, out byte[] bytes + ) { bytes = null; From 61b1701fc15484117565ee24c8dd29221b8a0082 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 4 Apr 2022 23:24:10 +0900 Subject: [PATCH 4259/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index af06086ab..c7dbedff6 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1149,7 +1149,9 @@ internal static bool TryCreateWebSocketUri ( return true; } - internal static bool TryGetUTF8DecodedString (this byte[] bytes, out string s) + internal static bool TryGetUTF8DecodedString ( + this byte[] bytes, out string s + ) { s = null; From fa058fdda16b2874ef93030e3009460cc2250e3e Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 5 Apr 2022 17:12:30 +0900 Subject: [PATCH 4260/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 37 +++++++++++++++++++++++++------------ 1 file changed, 25 insertions(+), 12 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index c7dbedff6..40a6c7357 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1107,44 +1107,57 @@ internal static bool TryCreateWebSocketUri ( message = null; var uri = uriString.ToUri (); + if (uri == null) { message = "An invalid URI string."; + return false; } if (!uri.IsAbsoluteUri) { message = "A relative URI."; + return false; } var schm = uri.Scheme; - if (!(schm == "ws" || schm == "wss")) { + var valid = schm == "ws" || schm == "wss"; + + if (!valid) { message = "The scheme part is not 'ws' or 'wss'."; + return false; } var port = uri.Port; + if (port == 0) { message = "The port part is zero."; + return false; } if (uri.Fragment.Length > 0) { message = "It includes the fragment component."; + return false; } - result = port != -1 - ? uri - : new Uri ( - String.Format ( - "{0}://{1}:{2}{3}", - schm, - uri.Host, - schm == "ws" ? 80 : 443, - uri.PathAndQuery - ) - ); + if (port == -1) { + port = schm == "ws" ? 80 : 443; + uriString = String.Format ( + "{0}://{1}:{2}{3}", + schm, + uri.Host, + port, + uri.PathAndQuery + ); + + result = new Uri (uriString); + } + else { + result = uri; + } return true; } From 3ec1bf5b85743662bfa3c1e5f9cc1e108c22c577 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 5 Apr 2022 17:29:48 +0900 Subject: [PATCH 4261/6294] [Modify] Edit it --- websocket-sharp/Ext.cs | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 40a6c7357..2c2e45e3f 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1078,27 +1078,6 @@ internal static bool TryCreateVersion ( return true; } - /// - /// Tries to create a new for WebSocket with - /// the specified . - /// - /// - /// true if the was successfully created; - /// otherwise, false. - /// - /// - /// A that represents a WebSocket URL to try. - /// - /// - /// When this method returns, a that - /// represents the WebSocket URL or - /// if is invalid. - /// - /// - /// When this method returns, a that - /// represents an error message or - /// if is valid. - /// internal static bool TryCreateWebSocketUri ( this string uriString, out Uri result, out string message ) From 96bb4900a2a9b064dc74593eb4a88fe41e0a5341 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 5 Apr 2022 20:32:14 +0900 Subject: [PATCH 4262/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 2c2e45e3f..06542e5d3 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1026,7 +1026,7 @@ internal static string ToString ( { return bracketIPv6 && address.AddressFamily == AddressFamily.InterNetworkV6 - ? String.Format ("[{0}]", address.ToString ()) + ? String.Format ("[{0}]", address) : address.ToString (); } From 8639e183956813e27c5c72f203672f665b420051 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 5 Apr 2022 20:35:47 +0900 Subject: [PATCH 4263/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 06542e5d3..55da503f6 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1001,11 +1001,13 @@ internal static System.Net.IPAddress ToIPAddress (this string value) return null; System.Net.IPAddress addr; + if (System.Net.IPAddress.TryParse (value, out addr)) return addr; try { var addrs = System.Net.Dns.GetHostAddresses (value); + return addrs[0]; } catch { From 5678e3740f250256dffd4a4b0c55d765503a6c7c Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 5 Apr 2022 20:42:14 +0900 Subject: [PATCH 4264/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 55da503f6..b5c97d06e 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -971,6 +971,7 @@ internal static byte[] ToByteArray (this ulong value, ByteOrder order) internal static CompressionMethod ToCompressionMethod (this string value) { var methods = Enum.GetValues (typeof (CompressionMethod)); + foreach (CompressionMethod method in methods) { if (method.ToExtensionString () == value) return method; From 017b06876bdd53a15e589ffb7a9ddf54c8a6d255 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 6 Apr 2022 17:30:18 +0900 Subject: [PATCH 4265/6294] [Modify] Add it --- websocket-sharp/Ext.cs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index b5c97d06e..b3c62497e 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -443,6 +443,23 @@ internal static string GetAbsolutePath (this Uri uri) return idx > 0 ? original.Substring (0, idx) : original; } + internal static string GetCloseStatusMessage (this ushort code) + { + switch (code) { + case 1002: return "A protocol error has occurred."; + case 1003: return "Unsupported data has been received."; + case 1006: return "An abnormal error has occurred."; + case 1007: return "Invalid data has been received."; + case 1008: return "A policy violation has occurred."; + case 1009: return "A too big message has been received."; + case 1010: return "The client did not receive expected extension(s)."; + case 1011: return "The server got an internal error."; + case 1015: return "An error has occurred during a TLS handshake."; + } + + return String.Empty; + } + internal static CookieCollection GetCookies ( this NameValueCollection headers, bool response ) From 7c8ff45b6aefc707609e84d1a21cbd8c2297b234 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 6 Apr 2022 22:45:55 +0900 Subject: [PATCH 4266/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 41 ++++++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index b3c62497e..fdc87ddfc 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -480,25 +480,28 @@ internal static string GetDnsSafeHost (this Uri uri, bool bracketIPv6) internal static string GetMessage (this CloseStatusCode code) { - return code == CloseStatusCode.ProtocolError - ? "A WebSocket protocol error has occurred." - : code == CloseStatusCode.UnsupportedData - ? "Unsupported data has been received." - : code == CloseStatusCode.Abnormal - ? "An exception has occurred." - : code == CloseStatusCode.InvalidData - ? "Invalid data has been received." - : code == CloseStatusCode.PolicyViolation - ? "A policy violation has occurred." - : code == CloseStatusCode.TooBig - ? "A too big message has been received." - : code == CloseStatusCode.MandatoryExtension - ? "WebSocket client didn't receive expected extension(s)." - : code == CloseStatusCode.ServerError - ? "WebSocket server got an internal error." - : code == CloseStatusCode.TlsHandshakeFailure - ? "An error has occurred during a TLS handshake." - : String.Empty; + switch (code) { + case CloseStatusCode.ProtocolError: + return "A protocol error has occurred."; + case CloseStatusCode.UnsupportedData: + return "Unsupported data has been received."; + case CloseStatusCode.Abnormal: + return "An abnormal error has occurred."; + case CloseStatusCode.InvalidData: + return "Invalid data has been received."; + case CloseStatusCode.PolicyViolation: + return "A policy violation has occurred."; + case CloseStatusCode.TooBig: + return "A too big message has been received."; + case CloseStatusCode.MandatoryExtension: + return "The client did not receive expected extension(s)."; + case CloseStatusCode.ServerError: + return "The server got an internal error."; + case CloseStatusCode.TlsHandshakeFailure: + return "An error has occurred during a TLS handshake."; + default: + return String.Empty; + } } internal static string GetName (this string nameAndValue, char separator) From 63032a3701519041b7034986bd14a3b33e4283a1 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 6 Apr 2022 23:00:01 +0900 Subject: [PATCH 4267/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index fdc87ddfc..a7dc0dd0b 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -695,15 +695,18 @@ internal static string Quote (this string value) internal static byte[] ReadBytes (this Stream stream, int length) { var buff = new byte[length]; + var offset = 0; var retry = 0; var nread = 0; while (length > 0) { nread = stream.Read (buff, offset, length); + if (nread <= 0) { if (retry < _retry) { retry++; + continue; } From e1520f49888431615f786a10526e2ca975cb5f85 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 6 Apr 2022 23:08:42 +0900 Subject: [PATCH 4268/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index a7dc0dd0b..b72a2e2cb 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -736,9 +736,11 @@ internal static byte[] ReadBytes ( bufferLength = (int) length; nread = stream.Read (buff, 0, bufferLength); + if (nread <= 0) { if (retry < _retry) { retry++; + continue; } @@ -748,10 +750,12 @@ internal static byte[] ReadBytes ( retry = 0; dest.Write (buff, 0, nread); + length -= nread; } dest.Close (); + return dest.ToArray (); } } From 2a8cfe0f7ffe4a2d3a5122ed31843c775399e45e Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 6 Apr 2022 23:12:56 +0900 Subject: [PATCH 4269/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index b72a2e2cb..cd8d77fd9 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -694,14 +694,14 @@ internal static string Quote (this string value) internal static byte[] ReadBytes (this Stream stream, int length) { - var buff = new byte[length]; + var ret = new byte[length]; var offset = 0; var retry = 0; var nread = 0; while (length > 0) { - nread = stream.Read (buff, offset, length); + nread = stream.Read (ret, offset, length); if (nread <= 0) { if (retry < _retry) { @@ -710,7 +710,7 @@ internal static byte[] ReadBytes (this Stream stream, int length) continue; } - return buff.SubArray (0, offset); + return ret.SubArray (0, offset); } retry = 0; @@ -719,7 +719,7 @@ internal static byte[] ReadBytes (this Stream stream, int length) length -= nread; } - return buff; + return ret; } internal static byte[] ReadBytes ( From 3e0208b39773565e932f327e4a8e25bba5b34dbe Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 7 Apr 2022 00:08:42 +0900 Subject: [PATCH 4270/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index cd8d77fd9..63399c64e 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -767,7 +767,8 @@ internal static void ReadBytesAsync ( Action error ) { - var buff = new byte[length]; + var ret = new byte[length]; + var offset = 0; var retry = 0; @@ -776,23 +777,25 @@ Action error ar => { try { var nread = stream.EndRead (ar); + if (nread <= 0) { if (retry < _retry) { retry++; - stream.BeginRead (buff, offset, length, callback, null); + + stream.BeginRead (ret, offset, length, callback, null); return; } if (completed != null) - completed (buff.SubArray (0, offset)); + completed (ret.SubArray (0, offset)); return; } if (nread == length) { if (completed != null) - completed (buff); + completed (ret); return; } @@ -802,7 +805,7 @@ Action error offset += nread; length -= nread; - stream.BeginRead (buff, offset, length, callback, null); + stream.BeginRead (ret, offset, length, callback, null); } catch (Exception ex) { if (error != null) @@ -811,7 +814,7 @@ Action error }; try { - stream.BeginRead (buff, offset, length, callback, null); + stream.BeginRead (ret, offset, length, callback, null); } catch (Exception ex) { if (error != null) From ce1b351e2f1a467d5cdc31c38c1b1804772fc5dc Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 7 Apr 2022 17:20:47 +0900 Subject: [PATCH 4271/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 63399c64e..4ea045433 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -831,6 +831,7 @@ Action error ) { var dest = new MemoryStream (); + var buff = new byte[bufferLength]; var retry = 0; @@ -847,9 +848,11 @@ Action error ar => { try { var nread = stream.EndRead (ar); + if (nread <= 0) { if (retry < _retry) { retry++; + read (len); return; @@ -857,10 +860,13 @@ Action error if (completed != null) { dest.Close (); - completed (dest.ToArray ()); + + var ret = dest.ToArray (); + completed (ret); } dest.Dispose (); + return; } @@ -869,10 +875,13 @@ Action error if (nread == len) { if (completed != null) { dest.Close (); - completed (dest.ToArray ()); + + var ret = dest.ToArray (); + completed (ret); } dest.Dispose (); + return; } @@ -882,6 +891,7 @@ Action error } catch (Exception ex) { dest.Dispose (); + if (error != null) error (ex); } @@ -895,6 +905,7 @@ Action error } catch (Exception ex) { dest.Dispose (); + if (error != null) error (ex); } From ac9f3a576857aac4074c618d3bf89b3d86dc881e Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 7 Apr 2022 17:26:20 +0900 Subject: [PATCH 4272/6294] [Modify] Rename it --- websocket-sharp/Ext.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 4ea045433..0c2619085 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -67,7 +67,7 @@ public static class Ext #region Private Fields private static readonly byte[] _last = new byte[] { 0x00 }; - private static readonly int _retry = 5; + private static readonly int _maxRetry = 5; private const string _tspecials = "()<>@,;:\\\"/[]?={} \t"; #endregion @@ -704,7 +704,7 @@ internal static byte[] ReadBytes (this Stream stream, int length) nread = stream.Read (ret, offset, length); if (nread <= 0) { - if (retry < _retry) { + if (retry < _maxRetry) { retry++; continue; @@ -738,7 +738,7 @@ internal static byte[] ReadBytes ( nread = stream.Read (buff, 0, bufferLength); if (nread <= 0) { - if (retry < _retry) { + if (retry < _maxRetry) { retry++; continue; @@ -779,7 +779,7 @@ Action error var nread = stream.EndRead (ar); if (nread <= 0) { - if (retry < _retry) { + if (retry < _maxRetry) { retry++; stream.BeginRead (ret, offset, length, callback, null); @@ -850,7 +850,7 @@ Action error var nread = stream.EndRead (ar); if (nread <= 0) { - if (retry < _retry) { + if (retry < _maxRetry) { retry++; read (len); From c46a1a8b4a137bb51e7c01b484cbfbe5dfe5e0b8 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 7 Apr 2022 17:30:57 +0900 Subject: [PATCH 4273/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 0c2619085..5fadb97fb 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -698,10 +698,9 @@ internal static byte[] ReadBytes (this Stream stream, int length) var offset = 0; var retry = 0; - var nread = 0; while (length > 0) { - nread = stream.Read (ret, offset, length); + var nread = stream.Read (ret, offset, length); if (nread <= 0) { if (retry < _maxRetry) { From b50867ad0d7123d744b7b0c09c8410d75c559d4b Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 7 Apr 2022 17:35:59 +0900 Subject: [PATCH 4274/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 5fadb97fb..3c23f9f0d 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -728,13 +728,12 @@ internal static byte[] ReadBytes ( using (var dest = new MemoryStream ()) { var buff = new byte[bufferLength]; var retry = 0; - var nread = 0; while (length > 0) { if (length < bufferLength) bufferLength = (int) length; - nread = stream.Read (buff, 0, bufferLength); + var nread = stream.Read (buff, 0, bufferLength); if (nread <= 0) { if (retry < _maxRetry) { From 78278c9351452213d56f9653f0be7299829ece77 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 8 Apr 2022 17:28:13 +0900 Subject: [PATCH 4275/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 3c23f9f0d..889a810b5 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -915,6 +915,7 @@ internal static T[] Reverse (this T[] array) var ret = new T[len]; var end = len - 1; + for (var i = 0; i <= end; i++) ret[i] = array[end - i]; From 20a88900047e420a83e757e957bd91ff23ecc798 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 8 Apr 2022 21:28:20 +0900 Subject: [PATCH 4276/6294] [Modify] Use long --- websocket-sharp/Ext.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 889a810b5..23eba14fe 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -911,12 +911,12 @@ Action error internal static T[] Reverse (this T[] array) { - var len = array.Length; + var len = array.LongLength; var ret = new T[len]; var end = len - 1; - for (var i = 0; i <= end; i++) + for (long i = 0; i <= end; i++) ret[i] = array[end - i]; return ret; From 36e4edebf5708b6b902efde3e82922ebb55c3b14 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 8 Apr 2022 21:37:31 +0900 Subject: [PATCH 4277/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 23eba14fe..b8e468557 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1075,7 +1075,9 @@ internal static string ToString ( internal static ushort ToUInt16 (this byte[] source, ByteOrder sourceOrder) { - return BitConverter.ToUInt16 (source.ToHostOrder (sourceOrder), 0); + var val = source.ToHostOrder (sourceOrder); + + return BitConverter.ToUInt16 (val, 0); } internal static ulong ToUInt64 (this byte[] source, ByteOrder sourceOrder) From 38ebcf2fa5744dacd35b57fb3005f9d9272f27ae Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 8 Apr 2022 21:39:46 +0900 Subject: [PATCH 4278/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index b8e468557..2da22cfca 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1082,7 +1082,9 @@ internal static ushort ToUInt16 (this byte[] source, ByteOrder sourceOrder) internal static ulong ToUInt64 (this byte[] source, ByteOrder sourceOrder) { - return BitConverter.ToUInt64 (source.ToHostOrder (sourceOrder), 0); + var val = source.ToHostOrder (sourceOrder); + + return BitConverter.ToUInt64 (val, 0); } internal static IEnumerable TrimEach ( From 84b9851f77ded778309c666ab7d392a243581343 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 8 Apr 2022 22:01:13 +0900 Subject: [PATCH 4279/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 2da22cfca..2124cbccf 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1294,6 +1294,7 @@ Action error ) { var src = new MemoryStream (bytes); + src.CopyToAsync ( stream, bufferLength, @@ -1305,6 +1306,7 @@ Action error }, ex => { src.Dispose (); + if (error != null) error (ex); } From 6fce97c1f91b813964b2ed7f25e1fd8b7fa3cf73 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 9 Apr 2022 22:22:27 +0900 Subject: [PATCH 4280/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 2124cbccf..0ad58a645 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -326,10 +326,9 @@ internal static void CopyTo ( ) { var buff = new byte[bufferLength]; - var nread = 0; while (true) { - nread = sourceStream.Read (buff, 0, bufferLength); + var nread = sourceStream.Read (buff, 0, bufferLength); if (nread <= 0) break; From 1ba97c0ab5af034b6e7c75acd30399bb8e9534c4 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 9 Apr 2022 22:24:01 +0900 Subject: [PATCH 4281/6294] [Modify] Remove it --- websocket-sharp/Ext.cs | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 0ad58a645..28586a13e 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -442,23 +442,6 @@ internal static string GetAbsolutePath (this Uri uri) return idx > 0 ? original.Substring (0, idx) : original; } - internal static string GetCloseStatusMessage (this ushort code) - { - switch (code) { - case 1002: return "A protocol error has occurred."; - case 1003: return "Unsupported data has been received."; - case 1006: return "An abnormal error has occurred."; - case 1007: return "Invalid data has been received."; - case 1008: return "A policy violation has occurred."; - case 1009: return "A too big message has been received."; - case 1010: return "The client did not receive expected extension(s)."; - case 1011: return "The server got an internal error."; - case 1015: return "An error has occurred during a TLS handshake."; - } - - return String.Empty; - } - internal static CookieCollection GetCookies ( this NameValueCollection headers, bool response ) From 325bbc9af836c7b2c27c14497b7f8017cb4ccfd5 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 10 Apr 2022 22:18:43 +0900 Subject: [PATCH 4282/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 28586a13e..28dac2751 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1009,13 +1009,15 @@ internal static string ToExtensionString ( if (method == CompressionMethod.None) return String.Empty; - var name = String.Format ( - "permessage-{0}", method.ToString ().ToLower () - ); + var algo = method.ToString ().ToLower (); + var name = String.Format ("permessage-{0}", algo); - return parameters != null && parameters.Length > 0 - ? String.Format ("{0}; {1}", name, parameters.ToString ("; ")) - : name; + if (parameters == null || parameters.Length == 0) + return name; + + var str = parameters.ToString ("; "); + + return String.Format ("{0}; {1}", name, str); } internal static System.Net.IPAddress ToIPAddress (this string value) From b71835baa6912d4ee7357afb4593249292019b0b Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 11 Apr 2022 15:22:07 +0900 Subject: [PATCH 4283/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 28dac2751..414a2ca13 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1009,15 +1009,15 @@ internal static string ToExtensionString ( if (method == CompressionMethod.None) return String.Empty; - var algo = method.ToString ().ToLower (); - var name = String.Format ("permessage-{0}", algo); + var name = method.ToString ().ToLower (); + var ename = String.Format ("permessage-{0}", name); if (parameters == null || parameters.Length == 0) - return name; + return ename; - var str = parameters.ToString ("; "); + var eparams = parameters.ToString ("; "); - return String.Format ("{0}; {1}", name, str); + return String.Format ("{0}; {1}", ename, eparams); } internal static System.Net.IPAddress ToIPAddress (this string value) From a9ab3ed49c2abd08b1748452cd11a34a51cc46b2 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 11 Apr 2022 15:34:25 +0900 Subject: [PATCH 4284/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 414a2ca13..8a36b8664 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -86,18 +86,21 @@ private static byte[] compress (this byte[] data) private static MemoryStream compress (this Stream stream) { - var output = new MemoryStream (); + var ret = new MemoryStream (); + if (stream.Length == 0) - return output; + return ret; stream.Position = 0; - using (var ds = new DeflateStream (output, CompressionMode.Compress, true)) { + + using (var ds = new DeflateStream (ret, CompressionMode.Compress, true)) { stream.CopyTo (ds, 1024); ds.Close (); // BFINAL set to 1. - output.Write (_last, 0, 1); - output.Position = 0; + ret.Write (_last, 0, 1); - return output; + ret.Position = 0; + + return ret; } } From 185c9be040b67387e58637d93eb2080ec78765f5 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 11 Apr 2022 15:37:03 +0900 Subject: [PATCH 4285/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 8a36b8664..446b7002b 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -108,6 +108,7 @@ private static byte[] compressToArray (this Stream stream) { using (var output = stream.compress ()) { output.Close (); + return output.ToArray (); } } From 02f365c6925d5cb21816c2ff44a80d2786e611ce Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 11 Apr 2022 15:41:33 +0900 Subject: [PATCH 4286/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 446b7002b..75854b56e 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -124,16 +124,19 @@ private static byte[] decompress (this byte[] data) private static MemoryStream decompress (this Stream stream) { - var output = new MemoryStream (); + var ret = new MemoryStream (); + if (stream.Length == 0) - return output; + return ret; stream.Position = 0; + using (var ds = new DeflateStream (stream, CompressionMode.Decompress, true)) { - ds.CopyTo (output, 1024); - output.Position = 0; + ds.CopyTo (ret, 1024); - return output; + ret.Position = 0; + + return ret; } } From 8b407dbe3f6d29894beaa198159157e607d19a4c Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 11 Apr 2022 15:43:21 +0900 Subject: [PATCH 4287/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 75854b56e..5b6a1255a 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -144,6 +144,7 @@ private static byte[] decompressToArray (this Stream stream) { using (var output = stream.decompress ()) { output.Close (); + return output.ToArray (); } } From a91638ce919de1aa76ae404d70b0025230aba52e Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 11 Apr 2022 21:43:13 +0900 Subject: [PATCH 4288/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 5b6a1255a..2b5e3444c 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -93,7 +93,9 @@ private static MemoryStream compress (this Stream stream) stream.Position = 0; - using (var ds = new DeflateStream (ret, CompressionMode.Compress, true)) { + var mode = CompressionMode.Compress; + + using (var ds = new DeflateStream (ret, mode, true)) { stream.CopyTo (ds, 1024); ds.Close (); // BFINAL set to 1. ret.Write (_last, 0, 1); From f2616bdf8cad1404f40acd06ff5e717194452c10 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 11 Apr 2022 21:46:41 +0900 Subject: [PATCH 4289/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 2b5e3444c..96b890b13 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -133,7 +133,9 @@ private static MemoryStream decompress (this Stream stream) stream.Position = 0; - using (var ds = new DeflateStream (stream, CompressionMode.Decompress, true)) { + var mode = CompressionMode.Decompress; + + using (var ds = new DeflateStream (stream, mode, true)) { ds.CopyTo (ret, 1024); ret.Position = 0; From 7b5c73040d4389a75c42c8ee7f690698b04862f1 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 12 Apr 2022 19:59:49 +0900 Subject: [PATCH 4290/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 96b890b13..9e0ef4e51 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -77,7 +77,6 @@ public static class Ext private static byte[] compress (this byte[] data) { if (data.LongLength == 0) - //return new byte[] { 0x00, 0x00, 0x00, 0xff, 0xff }; return data; using (var input = new MemoryStream (data)) From 6baba92560c044dbd12629ac23365e1355458b4e Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 12 Apr 2022 20:03:56 +0900 Subject: [PATCH 4291/6294] [Modify] Add it --- websocket-sharp/Ext.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 9e0ef4e51..96acfeb96 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -572,6 +572,18 @@ internal static bool IsEqualTo ( return value == c - 0; } + internal static bool IsHttpMethod (this string value) + { + return value == "GET" + || value == "HEAD" + || value == "POST" + || value == "PUT" + || value == "DELETE" + || value == "CONNECT" + || value == "OPTIONS" + || value == "TRACE"; + } + internal static bool IsHttpMethod (this string value, Version version) { return version == HttpVersion.Version10 From 8158402ac8b9f91cbfe0d27464fc8d7f61df990c Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 12 Apr 2022 20:11:35 +0900 Subject: [PATCH 4292/6294] [Modify] Replace it --- websocket-sharp/Net/HttpListenerRequest.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index 6070ff89e..f9428d950 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -813,6 +813,13 @@ internal void SetRequestLine (string requestLine) return; } + if (!method.IsHttpMethod ()) { + _context.ErrorStatusCode = 501; + _context.ErrorMessage = "Invalid request line (method)"; + + return; + } + var target = parts[1]; if (target.Length == 0) { @@ -850,13 +857,6 @@ internal void SetRequestLine (string requestLine) return; } - if (!method.IsHttpMethod (ver)) { - _context.ErrorStatusCode = 501; - _context.ErrorMessage = "Invalid request line (method)"; - - return; - } - _httpMethod = method; _rawUrl = target; _protocolVersion = ver; From aa7cce97e59736a11f9490015ecea00a9eafba22 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 12 Apr 2022 20:13:08 +0900 Subject: [PATCH 4293/6294] [Modify] Remove it --- websocket-sharp/Ext.cs | 7 ------- 1 file changed, 7 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 96acfeb96..0ee6cf6b0 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -584,13 +584,6 @@ internal static bool IsHttpMethod (this string value) || value == "TRACE"; } - internal static bool IsHttpMethod (this string value, Version version) - { - return version == HttpVersion.Version10 - ? value.isHttpMethod10 () - : value.isHttpMethod (); - } - internal static bool IsPortNumber (this int value) { return value > 0 && value < 65536; From ded64e845c63af3f48582ac9efa553f638b58321 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 12 Apr 2022 20:14:18 +0900 Subject: [PATCH 4294/6294] [Modify] Remove it --- websocket-sharp/Ext.cs | 7 ------- 1 file changed, 7 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 0ee6cf6b0..fa6419bfc 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -164,13 +164,6 @@ private static bool isHttpMethod (this string value) || value == "TRACE"; } - private static bool isHttpMethod10 (this string value) - { - return value == "GET" - || value == "HEAD" - || value == "POST"; - } - private static bool isPredefinedScheme (this string value) { var c = value[0]; From 0f439875f3996393ae8326ee68a803e96bd874e4 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 12 Apr 2022 20:15:05 +0900 Subject: [PATCH 4295/6294] [Modify] Remove it --- websocket-sharp/Ext.cs | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index fa6419bfc..3bfcc762d 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -152,18 +152,6 @@ private static byte[] decompressToArray (this Stream stream) } } - private static bool isHttpMethod (this string value) - { - return value == "GET" - || value == "HEAD" - || value == "POST" - || value == "PUT" - || value == "DELETE" - || value == "CONNECT" - || value == "OPTIONS" - || value == "TRACE"; - } - private static bool isPredefinedScheme (this string value) { var c = value[0]; From 625b7c678e30d42259fe1878ed8853f0e11ac976 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 13 Apr 2022 17:32:11 +0900 Subject: [PATCH 4296/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 3bfcc762d..bde13880d 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -201,7 +201,9 @@ internal static byte[] Append (this ushort code, string reason) return buff.ToArray (); } - internal static byte[] Compress (this byte[] data, CompressionMethod method) + internal static byte[] Compress ( + this byte[] data, CompressionMethod method + ) { return method == CompressionMethod.Deflate ? data.compress () From a5f1dd2213bd8135fdf27578816ba27a1f111e4d Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 13 Apr 2022 17:35:24 +0900 Subject: [PATCH 4297/6294] [Modify] Remove it --- websocket-sharp/Ext.cs | 9 --------- 1 file changed, 9 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index bde13880d..d5de3f4c2 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -219,15 +219,6 @@ internal static Stream Compress ( : stream; } - internal static byte[] CompressToArray ( - this Stream stream, CompressionMethod method - ) - { - return method == CompressionMethod.Deflate - ? stream.compressToArray () - : stream.ToByteArray (); - } - internal static bool Contains (this string value, params char[] anyOf) { return anyOf != null && anyOf.Length > 0 From 05f10d3d7cec8bb95e1bc947ecea90eaf0c07f8d Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 14 Apr 2022 20:56:14 +0900 Subject: [PATCH 4298/6294] [Modify] Edit it --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 7c38bc095..27fb489d3 100644 --- a/README.md +++ b/README.md @@ -434,7 +434,7 @@ For more information, would you see **[Example3]**? #### Per-message Compression #### -websocket-sharp supports the [Per-message Compression][compression] extension (but does not support it with the [context take over]). +websocket-sharp supports the [Per-message Compression][rfc7692] extension (but does not support it with the [context take over]). As a WebSocket client, if you would like to enable this extension, you should set the `WebSocket.Compression` property to a compression method before calling the connect method. @@ -667,7 +667,7 @@ websocket-sharp supports **RFC 6455**, and it is based on the following referenc - [The WebSocket Protocol][rfc6455] - [The WebSocket API][api] -- [Compression Extensions for WebSocket][compression] +- [Compression Extensions for WebSocket][rfc7692] Thanks for translating to japanese. @@ -696,8 +696,7 @@ websocket-sharp is provided under [The MIT License]. [WebSocket-Sharp for Unity]: http://u3d.as/content/sta-blockhead/websocket-sharp-for-unity [api]: http://www.w3.org/TR/websockets [api_ja]: http://www.hcn.zaq.ne.jp/___/WEB/WebSocket-ja.html -[compression]: http://tools.ietf.org/html/draft-ietf-hybi-permessage-compression-19 -[context take over]: http://tools.ietf.org/html/draft-ietf-hybi-permessage-compression-19#section-8.1.1 +[context take over]: https://datatracker.ietf.org/doc/html/rfc7692#section-7.1.1 [draft-hixie-thewebsocketprotocol-75]: http://tools.ietf.org/html/draft-hixie-thewebsocketprotocol-75 [draft-ietf-hybi-thewebsocketprotocol-00]: http://tools.ietf.org/html/draft-ietf-hybi-thewebsocketprotocol-00 [draft75]: https://github.com/sta/websocket-sharp/tree/draft75 @@ -706,3 +705,4 @@ websocket-sharp is provided under [The MIT License]. [rfc2617]: http://tools.ietf.org/html/rfc2617 [rfc6455]: http://tools.ietf.org/html/rfc6455 [rfc6455_ja]: http://www.hcn.zaq.ne.jp/___/WEB/RFC6455-ja.html +[rfc7692]: https://datatracker.ietf.org/doc/html/rfc7692 From 9a09683ba18dc07afa8733d6d735d58ced1e9363 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 14 Apr 2022 21:12:03 +0900 Subject: [PATCH 4299/6294] [Modify] Polish it --- websocket-sharp/HttpBase.cs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/HttpBase.cs b/websocket-sharp/HttpBase.cs index dd1e65c94..dd350e589 100644 --- a/websocket-sharp/HttpBase.cs +++ b/websocket-sharp/HttpBase.cs @@ -104,11 +104,18 @@ public Version ProtocolVersion { private static byte[] readEntityBody (Stream stream, string length) { long len; - if (!Int64.TryParse (length, out len)) - throw new ArgumentException ("Cannot be parsed.", "length"); - if (len < 0) - throw new ArgumentOutOfRangeException ("length", "Less than zero."); + if (!Int64.TryParse (length, out len)) { + var msg = "It cannot be parsed."; + + throw new ArgumentException (msg, "length"); + } + + if (len < 0) { + var msg = "It is less than zero."; + + throw new ArgumentOutOfRangeException ("length", msg); + } return len > 1024 ? stream.ReadBytes (len, 1024) From 748ee23b081c293a24363613887dfd93bb70b15f Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 15 Apr 2022 20:04:03 +0900 Subject: [PATCH 4300/6294] [Modify] Polish it --- websocket-sharp/HttpBase.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/HttpBase.cs b/websocket-sharp/HttpBase.cs index dd350e589..77d9c0dee 100644 --- a/websocket-sharp/HttpBase.cs +++ b/websocket-sharp/HttpBase.cs @@ -75,13 +75,13 @@ public string EntityBody { if (EntityBodyData == null || EntityBodyData.LongLength == 0) return String.Empty; - Encoding enc = null; - var contentType = _headers["Content-Type"]; - if (contentType != null && contentType.Length > 0) - enc = HttpUtility.GetEncoding (contentType); - return (enc ?? Encoding.UTF8).GetString (EntityBodyData); + var enc = contentType != null && contentType.Length > 0 + ? HttpUtility.GetEncoding (contentType) + : Encoding.UTF8; + + return enc.GetString (EntityBodyData); } } From abfe7400bd438ae97202296493b18633fcd0e537 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 15 Apr 2022 20:16:01 +0900 Subject: [PATCH 4301/6294] [Modify] Replace it --- websocket-sharp/HttpBase.cs | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/websocket-sharp/HttpBase.cs b/websocket-sharp/HttpBase.cs index 77d9c0dee..79f23ac05 100644 --- a/websocket-sharp/HttpBase.cs +++ b/websocket-sharp/HttpBase.cs @@ -40,18 +40,13 @@ internal abstract class HttpBase { #region Private Fields + private byte[] _entityBodyData; private NameValueCollection _headers; private const int _headersMaxLength = 8192; private Version _version; #endregion - #region Internal Fields - - internal byte[] EntityBodyData; - - #endregion - #region Protected Fields protected const string CrLf = "\r\n"; @@ -68,11 +63,21 @@ protected HttpBase (Version version, NameValueCollection headers) #endregion + #region Internal Properties + + internal byte[] EntityBodyData { + get { + return _entityBodyData; + } + } + + #endregion + #region Public Properties public string EntityBody { get { - if (EntityBodyData == null || EntityBodyData.LongLength == 0) + if (_entityBodyData == null || _entityBodyData.LongLength == 0) return String.Empty; var contentType = _headers["Content-Type"]; @@ -81,7 +86,7 @@ public string EntityBody { ? HttpUtility.GetEncoding (contentType) : Encoding.UTF8; - return enc.GetString (EntityBodyData); + return enc.GetString (_entityBodyData); } } @@ -179,7 +184,7 @@ protected static T Read (Stream stream, Func parser, int millise http = parser (readHeaders (stream, _headersMaxLength)); var contentLen = http.Headers["Content-Length"]; if (contentLen != null && contentLen.Length > 0) - http.EntityBodyData = readEntityBody (stream, contentLen); + http._entityBodyData = readEntityBody (stream, contentLen); } catch (Exception ex) { exception = ex; From 7b2d38f9091fb88b0cbd36c301d488f89a7b2e15 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 16 Apr 2022 17:29:20 +0900 Subject: [PATCH 4302/6294] [Modify] Polish it --- websocket-sharp/HttpBase.cs | 47 ++++++++++++++++++++++--------------- 1 file changed, 28 insertions(+), 19 deletions(-) diff --git a/websocket-sharp/HttpBase.cs b/websocket-sharp/HttpBase.cs index 79f23ac05..9f5eb50fc 100644 --- a/websocket-sharp/HttpBase.cs +++ b/websocket-sharp/HttpBase.cs @@ -133,29 +133,38 @@ private static string[] readHeaders (Stream stream, int maxLength) { var buff = new List (); var cnt = 0; - Action add = i => { - if (i == -1) - throw new EndOfStreamException ("The header cannot be read from the data source."); - - buff.Add ((byte) i); - cnt++; - }; - - var read = false; - while (cnt < maxLength) { - if (stream.ReadByte ().IsEqualTo ('\r', add) && - stream.ReadByte ().IsEqualTo ('\n', add) && - stream.ReadByte ().IsEqualTo ('\r', add) && - stream.ReadByte ().IsEqualTo ('\n', add)) { - read = true; - break; + Action add = + i => { + if (i == -1) { + var msg = "The header could not be read from the data source."; + + throw new EndOfStreamException (msg); + } + + buff.Add ((byte) i); + + cnt++; + }; + + while (true) { + var end = stream.ReadByte ().IsEqualTo ('\r', add) + && stream.ReadByte ().IsEqualTo ('\n', add) + && stream.ReadByte ().IsEqualTo ('\r', add) + && stream.ReadByte ().IsEqualTo ('\n', add); + + if (cnt > maxLength) { + var msg = "The length of headers is greater than the max length."; + + throw new WebSocketException (msg); } + + if (end) + break; } - if (!read) - throw new WebSocketException ("The length of header part is greater than the max length."); + var bytes = buff.ToArray (); - return Encoding.UTF8.GetString (buff.ToArray ()) + return Encoding.UTF8.GetString (bytes) .Replace (CrLf + " ", " ") .Replace (CrLf + "\t", " ") .Split (new[] { CrLf }, StringSplitOptions.RemoveEmptyEntries); From e1091b3dd0be33dbff0ac9689f5c28401cba4f89 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 17 Apr 2022 22:23:33 +0900 Subject: [PATCH 4303/6294] [Modify] Polish it --- websocket-sharp/HttpBase.cs | 51 ++++++++++++++++++++++--------------- 1 file changed, 31 insertions(+), 20 deletions(-) diff --git a/websocket-sharp/HttpBase.cs b/websocket-sharp/HttpBase.cs index 9f5eb50fc..73b5835a0 100644 --- a/websocket-sharp/HttpBase.cs +++ b/websocket-sharp/HttpBase.cs @@ -174,26 +174,34 @@ private static string[] readHeaders (Stream stream, int maxLength) #region Protected Methods - protected static T Read (Stream stream, Func parser, int millisecondsTimeout) + protected static T Read ( + Stream stream, Func parser, int millisecondsTimeout + ) where T : HttpBase { + T ret = null; + var timeout = false; var timer = new Timer ( - state => { - timeout = true; - stream.Close (); - }, - null, - millisecondsTimeout, - -1); - - T http = null; + state => { + timeout = true; + stream.Close (); + }, + null, + millisecondsTimeout, + -1 + ); + Exception exception = null; + try { - http = parser (readHeaders (stream, _headersMaxLength)); - var contentLen = http.Headers["Content-Length"]; + var headers = readHeaders (stream, _headersMaxLength); + ret = parser (headers); + + var contentLen = ret.Headers["Content-Length"]; + if (contentLen != null && contentLen.Length > 0) - http._entityBodyData = readEntityBody (stream, contentLen); + ret._entityBodyData = readEntityBody (stream, contentLen); } catch (Exception ex) { exception = ex; @@ -203,16 +211,19 @@ protected static T Read (Stream stream, Func parser, int millise timer.Dispose (); } - var msg = timeout - ? "A timeout has occurred while reading an HTTP request/response." - : exception != null - ? "An exception has occurred while reading an HTTP request/response." - : null; + if (timeout) { + var msg = "A timeout has occurred while reading an HTTP request or response."; + + throw new WebSocketException (msg); + } + + if (exception != null) { + var msg = "An exception has occurred while reading an HTTP request or response."; - if (msg != null) throw new WebSocketException (msg, exception); + } - return http; + return ret; } #endregion From 8d01ac417a85e710574032de083a2e710e6ec343 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 18 Apr 2022 17:34:46 +0900 Subject: [PATCH 4304/6294] [Modify] Polish it --- websocket-sharp/HttpBase.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/HttpBase.cs b/websocket-sharp/HttpBase.cs index 73b5835a0..61d5f4fbf 100644 --- a/websocket-sharp/HttpBase.cs +++ b/websocket-sharp/HttpBase.cs @@ -232,7 +232,9 @@ protected static T Read ( public byte[] ToByteArray () { - return Encoding.UTF8.GetBytes (ToString ()); + var s = ToString (); + + return Encoding.UTF8.GetBytes (s); } #endregion From 22440ce3d5bfd36952b1d991a0f7b418d2bf0a05 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 18 Apr 2022 17:35:58 +0900 Subject: [PATCH 4305/6294] [Modify] Polish it --- websocket-sharp/HttpBase.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/HttpBase.cs b/websocket-sharp/HttpBase.cs index 61d5f4fbf..49a03ab9a 100644 --- a/websocket-sharp/HttpBase.cs +++ b/websocket-sharp/HttpBase.cs @@ -136,7 +136,7 @@ private static string[] readHeaders (Stream stream, int maxLength) Action add = i => { if (i == -1) { - var msg = "The header could not be read from the data source."; + var msg = "The headers could not be read from the data source."; throw new EndOfStreamException (msg); } From 4f5907744e0ef215137584d651f0fe557820f23e Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 18 Apr 2022 17:37:57 +0900 Subject: [PATCH 4306/6294] [Modify] Polish it --- websocket-sharp/HttpBase.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/HttpBase.cs b/websocket-sharp/HttpBase.cs index 49a03ab9a..818e07339 100644 --- a/websocket-sharp/HttpBase.cs +++ b/websocket-sharp/HttpBase.cs @@ -153,7 +153,7 @@ private static string[] readHeaders (Stream stream, int maxLength) && stream.ReadByte ().IsEqualTo ('\n', add); if (cnt > maxLength) { - var msg = "The length of headers is greater than the max length."; + var msg = "The length of the headers is greater than the max length."; throw new WebSocketException (msg); } From 4e1bc0be336b39df19a4c169a309bca39a5fbf6e Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 18 Apr 2022 17:50:14 +0900 Subject: [PATCH 4307/6294] [Modify] Add it --- websocket-sharp/HttpBase.cs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/HttpBase.cs b/websocket-sharp/HttpBase.cs index 818e07339..35900d2a6 100644 --- a/websocket-sharp/HttpBase.cs +++ b/websocket-sharp/HttpBase.cs @@ -42,7 +42,7 @@ internal abstract class HttpBase private byte[] _entityBodyData; private NameValueCollection _headers; - private const int _headersMaxLength = 8192; + private static readonly int _headersMaxLength; private Version _version; #endregion @@ -53,6 +53,15 @@ internal abstract class HttpBase #endregion + #region Static Constructor + + static HttpBase () + { + _headersMaxLength = 8192; + } + + #endregion + #region Protected Constructors protected HttpBase (Version version, NameValueCollection headers) From 76431a3077e1feb0e8a0d0b11a809da5897c0fcf Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 19 Apr 2022 01:12:18 +0900 Subject: [PATCH 4308/6294] [Modify] Replace it --- websocket-sharp/HttpBase.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/HttpBase.cs b/websocket-sharp/HttpBase.cs index 35900d2a6..78582a73f 100644 --- a/websocket-sharp/HttpBase.cs +++ b/websocket-sharp/HttpBase.cs @@ -138,7 +138,7 @@ private static byte[] readEntityBody (Stream stream, string length) : null; } - private static string[] readHeaders (Stream stream, int maxLength) + private static string[] readHeaders (Stream stream) { var buff = new List (); var cnt = 0; @@ -161,7 +161,7 @@ private static string[] readHeaders (Stream stream, int maxLength) && stream.ReadByte ().IsEqualTo ('\r', add) && stream.ReadByte ().IsEqualTo ('\n', add); - if (cnt > maxLength) { + if (cnt > _headersMaxLength) { var msg = "The length of the headers is greater than the max length."; throw new WebSocketException (msg); @@ -204,7 +204,7 @@ protected static T Read ( Exception exception = null; try { - var headers = readHeaders (stream, _headersMaxLength); + var headers = readHeaders (stream); ret = parser (headers); var contentLen = ret.Headers["Content-Length"]; From 93199f480948af5fa05eaeb3dc0e026a064bc24c Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 19 Apr 2022 01:18:54 +0900 Subject: [PATCH 4309/6294] [Modify] Replace it --- websocket-sharp/HttpBase.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/HttpBase.cs b/websocket-sharp/HttpBase.cs index 78582a73f..1576ae1bb 100644 --- a/websocket-sharp/HttpBase.cs +++ b/websocket-sharp/HttpBase.cs @@ -49,7 +49,7 @@ internal abstract class HttpBase #region Protected Fields - protected const string CrLf = "\r\n"; + protected static readonly string CrLf; #endregion @@ -58,6 +58,8 @@ internal abstract class HttpBase static HttpBase () { _headersMaxLength = 8192; + + CrLf = "\r\n"; } #endregion From d70fb318e20c1c62176018c255e6bfead9c47af5 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 19 Apr 2022 01:22:41 +0900 Subject: [PATCH 4310/6294] [Modify] Add it --- websocket-sharp/HttpBase.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/websocket-sharp/HttpBase.cs b/websocket-sharp/HttpBase.cs index 1576ae1bb..157bc55ec 100644 --- a/websocket-sharp/HttpBase.cs +++ b/websocket-sharp/HttpBase.cs @@ -50,6 +50,7 @@ internal abstract class HttpBase #region Protected Fields protected static readonly string CrLf; + protected static readonly string CrLfHt; #endregion @@ -60,6 +61,7 @@ static HttpBase () _headersMaxLength = 8192; CrLf = "\r\n"; + CrLfHt = "\r\n\t"; } #endregion From e30258053f2d7434d457fee991daed11d9b5baad Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 19 Apr 2022 01:24:10 +0900 Subject: [PATCH 4311/6294] [Modify] Replace it --- websocket-sharp/HttpBase.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/HttpBase.cs b/websocket-sharp/HttpBase.cs index 157bc55ec..64965bd59 100644 --- a/websocket-sharp/HttpBase.cs +++ b/websocket-sharp/HttpBase.cs @@ -179,7 +179,7 @@ private static string[] readHeaders (Stream stream) return Encoding.UTF8.GetString (bytes) .Replace (CrLf + " ", " ") - .Replace (CrLf + "\t", " ") + .Replace (CrLfHt, " ") .Split (new[] { CrLf }, StringSplitOptions.RemoveEmptyEntries); } From 9fa5bafc98db7b8b9da996db6b1f94b2cbf2c76c Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 19 Apr 2022 01:27:29 +0900 Subject: [PATCH 4312/6294] [Modify] Add it --- websocket-sharp/HttpBase.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/websocket-sharp/HttpBase.cs b/websocket-sharp/HttpBase.cs index 64965bd59..d2203bd73 100644 --- a/websocket-sharp/HttpBase.cs +++ b/websocket-sharp/HttpBase.cs @@ -51,6 +51,7 @@ internal abstract class HttpBase protected static readonly string CrLf; protected static readonly string CrLfHt; + protected static readonly string CrLfSp; #endregion @@ -62,6 +63,7 @@ static HttpBase () CrLf = "\r\n"; CrLfHt = "\r\n\t"; + CrLfSp = "\r\n "; } #endregion From f76ad2a8454655fe0153f1ac05b8e48d96cd7841 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 19 Apr 2022 01:29:05 +0900 Subject: [PATCH 4313/6294] [Modify] Replace it --- websocket-sharp/HttpBase.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/HttpBase.cs b/websocket-sharp/HttpBase.cs index d2203bd73..2cca30fb1 100644 --- a/websocket-sharp/HttpBase.cs +++ b/websocket-sharp/HttpBase.cs @@ -180,7 +180,7 @@ private static string[] readHeaders (Stream stream) var bytes = buff.ToArray (); return Encoding.UTF8.GetString (bytes) - .Replace (CrLf + " ", " ") + .Replace (CrLfSp, " ") .Replace (CrLfHt, " ") .Split (new[] { CrLf }, StringSplitOptions.RemoveEmptyEntries); } From 6acc620b950ea702b3b95a6a138da73292a9c361 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 19 Apr 2022 17:03:52 +0900 Subject: [PATCH 4314/6294] [Modify] Rename it --- websocket-sharp/HttpBase.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/HttpBase.cs b/websocket-sharp/HttpBase.cs index 2cca30fb1..13202f368 100644 --- a/websocket-sharp/HttpBase.cs +++ b/websocket-sharp/HttpBase.cs @@ -43,7 +43,7 @@ internal abstract class HttpBase private byte[] _entityBodyData; private NameValueCollection _headers; private static readonly int _headersMaxLength; - private Version _version; + private Version _protocolVersion; #endregion @@ -72,7 +72,7 @@ static HttpBase () protected HttpBase (Version version, NameValueCollection headers) { - _version = version; + _protocolVersion = version; _headers = headers; } @@ -113,7 +113,7 @@ public NameValueCollection Headers { public Version ProtocolVersion { get { - return _version; + return _protocolVersion; } } From f82fbed156ac1976f0bbb3722e00a1de4f60bb7e Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 19 Apr 2022 22:09:15 +0900 Subject: [PATCH 4315/6294] [Modify] Replace it --- websocket-sharp/HttpBase.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/HttpBase.cs b/websocket-sharp/HttpBase.cs index 13202f368..7892b7bc9 100644 --- a/websocket-sharp/HttpBase.cs +++ b/websocket-sharp/HttpBase.cs @@ -170,7 +170,7 @@ private static string[] readHeaders (Stream stream) if (cnt > _headersMaxLength) { var msg = "The length of the headers is greater than the max length."; - throw new WebSocketException (msg); + throw new InvalidOperationException (msg); } if (end) From 0358f70643063307863f70dd6848dfd50ae934cc Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 19 Apr 2022 22:11:01 +0900 Subject: [PATCH 4316/6294] [Modify] Polish it --- websocket-sharp/HttpBase.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/HttpBase.cs b/websocket-sharp/HttpBase.cs index 7892b7bc9..add57a697 100644 --- a/websocket-sharp/HttpBase.cs +++ b/websocket-sharp/HttpBase.cs @@ -151,7 +151,7 @@ private static string[] readHeaders (Stream stream) Action add = i => { if (i == -1) { - var msg = "The headers could not be read from the data source."; + var msg = "The headers could not be read from the data stream."; throw new EndOfStreamException (msg); } From 0f2717f9b21dfe2cbc6d9340a2971633ed39fd8a Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 19 Apr 2022 22:21:11 +0900 Subject: [PATCH 4317/6294] [Modify] Add it --- websocket-sharp/HttpBase.cs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/websocket-sharp/HttpBase.cs b/websocket-sharp/HttpBase.cs index add57a697..3abe6230b 100644 --- a/websocket-sharp/HttpBase.cs +++ b/websocket-sharp/HttpBase.cs @@ -121,6 +121,20 @@ public Version ProtocolVersion { #region Private Methods + private string getEntityBody () + { + if (_entityBodyData == null || _entityBodyData.LongLength == 0) + return String.Empty; + + var contentType = _headers["Content-Type"]; + + var enc = contentType != null && contentType.Length > 0 + ? HttpUtility.GetEncoding (contentType) + : Encoding.UTF8; + + return enc.GetString (_entityBodyData); + } + private static byte[] readEntityBody (Stream stream, string length) { long len; From f73b3f0b4265b86c2525f41274c510eda49ac87f Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 19 Apr 2022 22:27:47 +0900 Subject: [PATCH 4318/6294] [Modify] Replace it --- websocket-sharp/HttpBase.cs | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/websocket-sharp/HttpBase.cs b/websocket-sharp/HttpBase.cs index 3abe6230b..073e5c0b9 100644 --- a/websocket-sharp/HttpBase.cs +++ b/websocket-sharp/HttpBase.cs @@ -40,6 +40,7 @@ internal abstract class HttpBase { #region Private Fields + private string _entityBody; private byte[] _entityBodyData; private NameValueCollection _headers; private static readonly int _headersMaxLength; @@ -92,16 +93,10 @@ internal byte[] EntityBodyData { public string EntityBody { get { - if (_entityBodyData == null || _entityBodyData.LongLength == 0) - return String.Empty; + if (_entityBody == null) + _entityBody = getEntityBody (); - var contentType = _headers["Content-Type"]; - - var enc = contentType != null && contentType.Length > 0 - ? HttpUtility.GetEncoding (contentType) - : Encoding.UTF8; - - return enc.GetString (_entityBodyData); + return _entityBody; } } From fef090b4fe073c44873a63f7bdc8192d449b3f42 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 19 Apr 2022 22:31:35 +0900 Subject: [PATCH 4319/6294] [Modify] Rename it --- websocket-sharp/HttpBase.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/HttpBase.cs b/websocket-sharp/HttpBase.cs index 073e5c0b9..c96fc9859 100644 --- a/websocket-sharp/HttpBase.cs +++ b/websocket-sharp/HttpBase.cs @@ -153,7 +153,7 @@ private static byte[] readEntityBody (Stream stream, string length) : null; } - private static string[] readHeaders (Stream stream) + private static string[] readHeadersFrom (Stream stream) { var buff = new List (); var cnt = 0; @@ -219,7 +219,7 @@ protected static T Read ( Exception exception = null; try { - var headers = readHeaders (stream); + var headers = readHeadersFrom (stream); ret = parser (headers); var contentLen = ret.Headers["Content-Length"]; From 3fcf11ebafddc2f9fd81fdfd4332860d31142673 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 19 Apr 2022 22:34:15 +0900 Subject: [PATCH 4320/6294] [Modify] Rename it --- websocket-sharp/HttpBase.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/HttpBase.cs b/websocket-sharp/HttpBase.cs index c96fc9859..ff2b57115 100644 --- a/websocket-sharp/HttpBase.cs +++ b/websocket-sharp/HttpBase.cs @@ -130,7 +130,7 @@ private string getEntityBody () return enc.GetString (_entityBodyData); } - private static byte[] readEntityBody (Stream stream, string length) + private static byte[] readEntityBodyFrom (Stream stream, string length) { long len; @@ -225,7 +225,7 @@ protected static T Read ( var contentLen = ret.Headers["Content-Length"]; if (contentLen != null && contentLen.Length > 0) - ret._entityBodyData = readEntityBody (stream, contentLen); + ret._entityBodyData = readEntityBodyFrom (stream, contentLen); } catch (Exception ex) { exception = ex; From a39572b951a0f947897063ee36ac495e26bf2b3b Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 20 Apr 2022 16:23:44 +0900 Subject: [PATCH 4321/6294] [Modify] Polish it --- websocket-sharp/HttpBase.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/HttpBase.cs b/websocket-sharp/HttpBase.cs index ff2b57115..884fc2f3e 100644 --- a/websocket-sharp/HttpBase.cs +++ b/websocket-sharp/HttpBase.cs @@ -71,9 +71,9 @@ static HttpBase () #region Protected Constructors - protected HttpBase (Version version, NameValueCollection headers) + protected HttpBase (Version protocolVersion, NameValueCollection headers) { - _protocolVersion = version; + _protocolVersion = protocolVersion; _headers = headers; } From 1dd7e95767a40f024eb6e8d2873878bdb3fa4ace Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 20 Apr 2022 16:25:53 +0900 Subject: [PATCH 4322/6294] [Modify] 2022 --- websocket-sharp/HttpBase.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/HttpBase.cs b/websocket-sharp/HttpBase.cs index 884fc2f3e..6e334d51a 100644 --- a/websocket-sharp/HttpBase.cs +++ b/websocket-sharp/HttpBase.cs @@ -4,7 +4,7 @@ * * The MIT License * - * Copyright (c) 2012-2014 sta.blockhead + * Copyright (c) 2012-2022 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From 32cc3081bc754312ba9094bf2a9b73a83ef5a2a7 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 21 Apr 2022 20:01:07 +0900 Subject: [PATCH 4323/6294] [Modify] Polish it --- websocket-sharp/HttpRequest.cs | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/HttpRequest.cs b/websocket-sharp/HttpRequest.cs index fe74d5afb..40e514680 100644 --- a/websocket-sharp/HttpRequest.cs +++ b/websocket-sharp/HttpRequest.cs @@ -156,16 +156,26 @@ internal HttpResponse GetResponse (Stream stream, int millisecondsTimeout) internal static HttpRequest Parse (string[] headerParts) { - var requestLine = headerParts[0].Split (new[] { ' ' }, 3); - if (requestLine.Length != 3) - throw new ArgumentException ("Invalid request line: " + headerParts[0]); + var reqLineParts = headerParts[0].Split (new[] { ' ' }, 3); + + if (reqLineParts.Length != 3) { + var msg = "It includes an invalid request line."; + + throw new ArgumentException (msg); + } + + var method = reqLineParts[0]; + var uri = reqLineParts[1]; + + var num = reqLineParts[2].Substring (5); + var ver = new Version (num); var headers = new WebHeaderCollection (); - for (int i = 1; i < headerParts.Length; i++) + + for (var i = 1; i < headerParts.Length; i++) headers.InternalSet (headerParts[i], false); - return new HttpRequest ( - requestLine[0], requestLine[1], new Version (requestLine[2].Substring (5)), headers); + return new HttpRequest (method, uri, ver, headers); } internal static HttpRequest Read (Stream stream, int millisecondsTimeout) From 5e7bdc743c50b6467ec2e906d116b93d64ed01b2 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 21 Apr 2022 20:26:17 +0900 Subject: [PATCH 4324/6294] [Modify] Add an empty check --- websocket-sharp/HttpRequest.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/websocket-sharp/HttpRequest.cs b/websocket-sharp/HttpRequest.cs index 40e514680..19e41303c 100644 --- a/websocket-sharp/HttpRequest.cs +++ b/websocket-sharp/HttpRequest.cs @@ -156,6 +156,12 @@ internal HttpResponse GetResponse (Stream stream, int millisecondsTimeout) internal static HttpRequest Parse (string[] headerParts) { + if (headerParts.Length == 0) { + var msg = "An empty request has been received."; + + throw new ArgumentException (msg); + } + var reqLineParts = headerParts[0].Split (new[] { ' ' }, 3); if (reqLineParts.Length != 3) { From 69064abd80ea58ae85ab3f04392d6319e1c1feec Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 21 Apr 2022 20:28:23 +0900 Subject: [PATCH 4325/6294] [Modify] Polish it --- websocket-sharp/HttpRequest.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/HttpRequest.cs b/websocket-sharp/HttpRequest.cs index 19e41303c..f2d6417ee 100644 --- a/websocket-sharp/HttpRequest.cs +++ b/websocket-sharp/HttpRequest.cs @@ -171,7 +171,7 @@ internal static HttpRequest Parse (string[] headerParts) } var method = reqLineParts[0]; - var uri = reqLineParts[1]; + var target = reqLineParts[1]; var num = reqLineParts[2].Substring (5); var ver = new Version (num); @@ -181,7 +181,7 @@ internal static HttpRequest Parse (string[] headerParts) for (var i = 1; i < headerParts.Length; i++) headers.InternalSet (headerParts[i], false); - return new HttpRequest (method, uri, ver, headers); + return new HttpRequest (method, target, ver, headers); } internal static HttpRequest Read (Stream stream, int millisecondsTimeout) From eec890bcce7812080be9b5af04012e41cfce2459 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 22 Apr 2022 16:54:34 +0900 Subject: [PATCH 4326/6294] [Modify] Polish it --- websocket-sharp/HttpRequest.cs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/HttpRequest.cs b/websocket-sharp/HttpRequest.cs index f2d6417ee..58d37ac5b 100644 --- a/websocket-sharp/HttpRequest.cs +++ b/websocket-sharp/HttpRequest.cs @@ -212,20 +212,24 @@ public void SetCookies (CookieCollection cookies) public override string ToString () { - var output = new StringBuilder (64); - output.AppendFormat ("{0} {1} HTTP/{2}{3}", _method, _uri, ProtocolVersion, CrLf); + var buff = new StringBuilder (64); + + var fmt = "{0} {1} HTTP/{2}{3}"; + buff.AppendFormat (fmt, _method, _uri, ProtocolVersion, CrLf); var headers = Headers; + foreach (var key in headers.AllKeys) - output.AppendFormat ("{0}: {1}{2}", key, headers[key], CrLf); + buff.AppendFormat ("{0}: {1}{2}", key, headers[key], CrLf); - output.Append (CrLf); + buff.Append (CrLf); var entity = EntityBody; + if (entity.Length > 0) - output.Append (entity); + buff.Append (entity); - return output.ToString (); + return buff.ToString (); } #endregion From 2cb9ba45ffc401a7d1a05555357faa0c0214daeb Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 23 Apr 2022 21:42:04 +0900 Subject: [PATCH 4327/6294] [Modify] Polish it --- websocket-sharp/HttpRequest.cs | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/websocket-sharp/HttpRequest.cs b/websocket-sharp/HttpRequest.cs index 58d37ac5b..69f3d0551 100644 --- a/websocket-sharp/HttpRequest.cs +++ b/websocket-sharp/HttpRequest.cs @@ -199,15 +199,22 @@ public void SetCookies (CookieCollection cookies) return; var buff = new StringBuilder (64); - foreach (var cookie in cookies.Sorted) - if (!cookie.Expired) - buff.AppendFormat ("{0}; ", cookie.ToString ()); - var len = buff.Length; - if (len > 2) { - buff.Length = len - 2; - Headers["Cookie"] = buff.ToString (); + foreach (var cookie in cookies.Sorted) { + if (cookie.Expired) + continue; + + buff.AppendFormat ("{0}; ", cookie); } + + var len = buff.Length; + + if (len <= 2) + return; + + buff.Length = len - 2; + + Headers["Cookie"] = buff.ToString (); } public override string ToString () From f80cd82b623210907db894f486cdaba65d917855 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 23 Apr 2022 21:47:32 +0900 Subject: [PATCH 4328/6294] [Modify] Polish it --- websocket-sharp/HttpRequest.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/HttpRequest.cs b/websocket-sharp/HttpRequest.cs index 69f3d0551..f6269aae7 100644 --- a/websocket-sharp/HttpRequest.cs +++ b/websocket-sharp/HttpRequest.cs @@ -76,9 +76,10 @@ internal HttpRequest (string method, string uri) public AuthenticationResponse AuthenticationResponse { get { - var res = Headers["Authorization"]; - return res != null && res.Length > 0 - ? AuthenticationResponse.Parse (res) + var val = Headers["Authorization"]; + + return val != null && val.Length > 0 + ? AuthenticationResponse.Parse (val) : null; } } From 2df3f216fc470fefe5f9335101c1ea0b670f680c Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 24 Apr 2022 22:06:01 +0900 Subject: [PATCH 4329/6294] [Modify] Polish it --- websocket-sharp/HttpRequest.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/HttpRequest.cs b/websocket-sharp/HttpRequest.cs index f6269aae7..19116b64b 100644 --- a/websocket-sharp/HttpRequest.cs +++ b/websocket-sharp/HttpRequest.cs @@ -53,11 +53,16 @@ internal class HttpRequest : HttpBase #region Private Constructors - private HttpRequest (string method, string uri, Version version, NameValueCollection headers) - : base (version, headers) + private HttpRequest ( + string method, + string target, + Version protocolVersion, + NameValueCollection headers + ) + : base (protocolVersion, headers) { _method = method; - _uri = uri; + _uri = target; } #endregion From fdbfc426ede675c28aff20d149f892d7d2c87ea2 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 24 Apr 2022 22:08:40 +0900 Subject: [PATCH 4330/6294] [Modify] Polish it --- websocket-sharp/HttpRequest.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/HttpRequest.cs b/websocket-sharp/HttpRequest.cs index 19116b64b..9393154a2 100644 --- a/websocket-sharp/HttpRequest.cs +++ b/websocket-sharp/HttpRequest.cs @@ -69,8 +69,8 @@ NameValueCollection headers #region Internal Constructors - internal HttpRequest (string method, string uri) - : this (method, uri, HttpVersion.Version11, new NameValueCollection ()) + internal HttpRequest (string method, string target) + : this (method, target, HttpVersion.Version11, new NameValueCollection ()) { Headers["User-Agent"] = "websocket-sharp/1.0"; } From 3cc52e76247c0259f5b1e5682ed586679f132afe Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 25 Apr 2022 17:21:02 +0900 Subject: [PATCH 4331/6294] [Modify] Rename it --- websocket-sharp/HttpRequest.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/HttpRequest.cs b/websocket-sharp/HttpRequest.cs index 9393154a2..88826b5b5 100644 --- a/websocket-sharp/HttpRequest.cs +++ b/websocket-sharp/HttpRequest.cs @@ -47,7 +47,7 @@ internal class HttpRequest : HttpBase private CookieCollection _cookies; private string _method; - private string _uri; + private string _target; #endregion @@ -62,7 +62,7 @@ NameValueCollection headers : base (protocolVersion, headers) { _method = method; - _uri = target; + _target = target; } #endregion @@ -114,7 +114,7 @@ public bool IsWebSocketRequest { public string RequestUri { get { - return _uri; + return _target; } } @@ -228,7 +228,7 @@ public override string ToString () var buff = new StringBuilder (64); var fmt = "{0} {1} HTTP/{2}{3}"; - buff.AppendFormat (fmt, _method, _uri, ProtocolVersion, CrLf); + buff.AppendFormat (fmt, _method, _target, ProtocolVersion, CrLf); var headers = Headers; From 002e92d75663b51eb0b060560a3cf398990fddca Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 25 Apr 2022 17:23:51 +0900 Subject: [PATCH 4332/6294] [Modify] Rename it --- websocket-sharp/HttpRequest.cs | 2 +- websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/HttpRequest.cs b/websocket-sharp/HttpRequest.cs index 88826b5b5..acec24bd7 100644 --- a/websocket-sharp/HttpRequest.cs +++ b/websocket-sharp/HttpRequest.cs @@ -112,7 +112,7 @@ public bool IsWebSocketRequest { } } - public string RequestUri { + public string RequestTarget { get { return _target; } diff --git a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs index 519da7896..a04455bd3 100644 --- a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs @@ -288,7 +288,7 @@ public override Uri RequestUri { get { if (_requestUri == null) { _requestUri = HttpUtility.CreateRequestUrl ( - _request.RequestUri, + _request.RequestTarget, _request.Headers["Host"], _request.IsWebSocketRequest, _secure From 825e4f98fb5d3f70045b0480dc98012ce1bb3189 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 26 Apr 2022 19:52:18 +0900 Subject: [PATCH 4333/6294] [Modify] Polish it --- websocket-sharp/HttpRequest.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/HttpRequest.cs b/websocket-sharp/HttpRequest.cs index acec24bd7..a629d01a1 100644 --- a/websocket-sharp/HttpRequest.cs +++ b/websocket-sharp/HttpRequest.cs @@ -127,10 +127,12 @@ internal static HttpRequest CreateConnectRequest (Uri uri) var host = uri.DnsSafeHost; var port = uri.Port; var authority = String.Format ("{0}:{1}", host, port); - var req = new HttpRequest ("CONNECT", authority); - req.Headers["Host"] = port == 80 ? host : authority; - return req; + var ret = new HttpRequest ("CONNECT", authority); + + ret.Headers["Host"] = port != 80 ? authority : host; + + return ret; } internal static HttpRequest CreateWebSocketRequest (Uri uri) From f3b6b715f3d0ab3dffb3afb4dc54a2a4231958d6 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 26 Apr 2022 21:26:04 +0900 Subject: [PATCH 4334/6294] [Modify] Polish it --- websocket-sharp/HttpRequest.cs | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/websocket-sharp/HttpRequest.cs b/websocket-sharp/HttpRequest.cs index a629d01a1..ffebe16a0 100644 --- a/websocket-sharp/HttpRequest.cs +++ b/websocket-sharp/HttpRequest.cs @@ -137,21 +137,20 @@ internal static HttpRequest CreateConnectRequest (Uri uri) internal static HttpRequest CreateWebSocketRequest (Uri uri) { - var req = new HttpRequest ("GET", uri.PathAndQuery); - var headers = req.Headers; + var ret = new HttpRequest ("GET", uri.PathAndQuery); - // Only includes a port number in the Host header value if it's non-default. - // See: https://tools.ietf.org/html/rfc6455#page-17 var port = uri.Port; var schm = uri.Scheme; - headers["Host"] = (port == 80 && schm == "ws") || (port == 443 && schm == "wss") - ? uri.DnsSafeHost - : uri.Authority; + var defaultPort = (port == 80 && schm == "ws") + || (port == 443 && schm == "wss"); + var headers = ret.Headers; + + headers["Host"] = !defaultPort ? uri.Authority : uri.DnsSafeHost; headers["Upgrade"] = "websocket"; headers["Connection"] = "Upgrade"; - return req; + return ret; } internal HttpResponse GetResponse (Stream stream, int millisecondsTimeout) From 820032a3feb9a5ad3640ae91b9c6c1cb60ebd441 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 27 Apr 2022 19:57:19 +0900 Subject: [PATCH 4335/6294] [Modify] Polish it --- websocket-sharp/HttpRequest.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/HttpRequest.cs b/websocket-sharp/HttpRequest.cs index ffebe16a0..3db96b686 100644 --- a/websocket-sharp/HttpRequest.cs +++ b/websocket-sharp/HttpRequest.cs @@ -155,10 +155,12 @@ internal static HttpRequest CreateWebSocketRequest (Uri uri) internal HttpResponse GetResponse (Stream stream, int millisecondsTimeout) { - var buff = ToByteArray (); - stream.Write (buff, 0, buff.Length); + var bytes = ToByteArray (); + stream.Write (bytes, 0, bytes.Length); - return Read (stream, HttpResponse.Parse, millisecondsTimeout); + return Read ( + stream, HttpResponse.Parse, millisecondsTimeout + ); } internal static HttpRequest Parse (string[] headerParts) From 2d4202e409b01022c8a3385dfee488ec9819ade9 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 27 Apr 2022 20:01:35 +0900 Subject: [PATCH 4336/6294] [Modify] Rename it --- websocket-sharp/HttpRequest.cs | 4 +++- websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/HttpRequest.cs b/websocket-sharp/HttpRequest.cs index 3db96b686..41b3728f2 100644 --- a/websocket-sharp/HttpRequest.cs +++ b/websocket-sharp/HttpRequest.cs @@ -193,7 +193,9 @@ internal static HttpRequest Parse (string[] headerParts) return new HttpRequest (method, target, ver, headers); } - internal static HttpRequest Read (Stream stream, int millisecondsTimeout) + internal static HttpRequest ReadRequest ( + Stream stream, int millisecondsTimeout + ) { return Read (stream, Parse, millisecondsTimeout); } diff --git a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs index a04455bd3..7878af59c 100644 --- a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs @@ -105,7 +105,7 @@ Logger log _serverEndPoint = sock.LocalEndPoint; _userEndPoint = sock.RemoteEndPoint; - _request = HttpRequest.Read (_stream, 90000); + _request = HttpRequest.ReadRequest (_stream, 90000); _websocket = new WebSocket (this, protocol); } @@ -438,7 +438,7 @@ private HttpRequest sendAuthenticationChallenge (string challenge) var bytes = res.ToByteArray (); _stream.Write (bytes, 0, bytes.Length); - return HttpRequest.Read (_stream, 15000); + return HttpRequest.ReadRequest (_stream, 15000); } #endregion From 30c6b116e02100cb5c22bf50bf02120b9f8db4e6 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 27 Apr 2022 20:04:17 +0900 Subject: [PATCH 4337/6294] [Modify] Polish it --- websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs index 7878af59c..8f70dfcde 100644 --- a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs @@ -436,6 +436,7 @@ private HttpRequest sendAuthenticationChallenge (string challenge) { var res = HttpResponse.CreateUnauthorizedResponse (challenge); var bytes = res.ToByteArray (); + _stream.Write (bytes, 0, bytes.Length); return HttpRequest.ReadRequest (_stream, 15000); From ea02837dd682a8dd914fd5f7ed6c9e70fc3d17b1 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 28 Apr 2022 20:01:09 +0900 Subject: [PATCH 4338/6294] [Modify] Polish it --- websocket-sharp/HttpResponse.cs | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/HttpResponse.cs b/websocket-sharp/HttpResponse.cs index 831b72783..b7795f761 100644 --- a/websocket-sharp/HttpResponse.cs +++ b/websocket-sharp/HttpResponse.cs @@ -155,16 +155,34 @@ internal static HttpResponse CreateWebSocketResponse () internal static HttpResponse Parse (string[] headerParts) { - var statusLine = headerParts[0].Split (new[] { ' ' }, 3); - if (statusLine.Length != 3) - throw new ArgumentException ("Invalid status line: " + headerParts[0]); + var len = headerParts.Length; + + if (len == 0) { + var msg = "An empty response has been received."; + + throw new ArgumentException (msg); + } + + var statusLineParts = headerParts[0].Split (new[] { ' ' }, 3); + + if (statusLineParts.Length != 3) { + var msg = "It includes an invalid status line."; + + throw new ArgumentException (msg); + } + + var code = statusLineParts[1]; + var reason = statusLineParts[2]; + + var num = statusLineParts[0].Substring (5); + var ver = new Version (num); var headers = new WebHeaderCollection (); - for (int i = 1; i < headerParts.Length; i++) + + for (var i = 1; i < len; i++) headers.InternalSet (headerParts[i], true); - return new HttpResponse ( - statusLine[1], statusLine[2], new Version (statusLine[0].Substring (5)), headers); + return new HttpResponse (code, reason, ver, headers); } internal static HttpResponse Read (Stream stream, int millisecondsTimeout) From c56ba1b578ddac969e65a83ef810d1ac7d53908d Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 28 Apr 2022 20:03:01 +0900 Subject: [PATCH 4339/6294] [Modify] Rename it --- websocket-sharp/HttpResponse.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/HttpResponse.cs b/websocket-sharp/HttpResponse.cs index b7795f761..0fa813d98 100644 --- a/websocket-sharp/HttpResponse.cs +++ b/websocket-sharp/HttpResponse.cs @@ -185,7 +185,9 @@ internal static HttpResponse Parse (string[] headerParts) return new HttpResponse (code, reason, ver, headers); } - internal static HttpResponse Read (Stream stream, int millisecondsTimeout) + internal static HttpResponse ReadResponse ( + Stream stream, int millisecondsTimeout + ) { return Read (stream, Parse, millisecondsTimeout); } From 45f629de950114115f02067fc15b48baef1d6eff Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 28 Apr 2022 20:05:39 +0900 Subject: [PATCH 4340/6294] [Modify] Replace it --- websocket-sharp/HttpRequest.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/websocket-sharp/HttpRequest.cs b/websocket-sharp/HttpRequest.cs index 41b3728f2..5a3767577 100644 --- a/websocket-sharp/HttpRequest.cs +++ b/websocket-sharp/HttpRequest.cs @@ -158,9 +158,7 @@ internal HttpResponse GetResponse (Stream stream, int millisecondsTimeout) var bytes = ToByteArray (); stream.Write (bytes, 0, bytes.Length); - return Read ( - stream, HttpResponse.Parse, millisecondsTimeout - ); + return HttpResponse.ReadResponse (stream, millisecondsTimeout); } internal static HttpRequest Parse (string[] headerParts) From 4c4b48ff85e72edfd357f763d9daa6fd8aaac8a9 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 29 Apr 2022 19:34:43 +0900 Subject: [PATCH 4341/6294] [Modify] Polish it --- websocket-sharp/HttpResponse.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/HttpResponse.cs b/websocket-sharp/HttpResponse.cs index 0fa813d98..40ef4badb 100644 --- a/websocket-sharp/HttpResponse.cs +++ b/websocket-sharp/HttpResponse.cs @@ -202,8 +202,12 @@ public void SetCookies (CookieCollection cookies) return; var headers = Headers; - foreach (var cookie in cookies.Sorted) - headers.Add ("Set-Cookie", cookie.ToResponseString ()); + + foreach (var cookie in cookies.Sorted) { + var val = cookie.ToResponseString (); + + headers.Add ("Set-Cookie", val); + } } public override string ToString () From 25b7e2fafbb06c48021a5718650fcd4c435b5a51 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 29 Apr 2022 19:42:28 +0900 Subject: [PATCH 4342/6294] [Modify] Polish it --- websocket-sharp/HttpResponse.cs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/HttpResponse.cs b/websocket-sharp/HttpResponse.cs index 40ef4badb..7e1b2a9ce 100644 --- a/websocket-sharp/HttpResponse.cs +++ b/websocket-sharp/HttpResponse.cs @@ -212,20 +212,24 @@ public void SetCookies (CookieCollection cookies) public override string ToString () { - var output = new StringBuilder (64); - output.AppendFormat ("HTTP/{0} {1} {2}{3}", ProtocolVersion, _code, _reason, CrLf); + var buff = new StringBuilder (64); + + var fmt = "HTTP/{0} {1} {2}{3}"; + buff.AppendFormat (fmt, ProtocolVersion, _code, _reason, CrLf); var headers = Headers; + foreach (var key in headers.AllKeys) - output.AppendFormat ("{0}: {1}{2}", key, headers[key], CrLf); + buff.AppendFormat ("{0}: {1}{2}", key, headers[key], CrLf); - output.Append (CrLf); + buff.Append (CrLf); var entity = EntityBody; + if (entity.Length > 0) - output.Append (entity); + buff.Append (entity); - return output.ToString (); + return buff.ToString (); } #endregion From 55478cfecfa581a6410ce7fb84eac264525cc265 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 30 Apr 2022 21:26:06 +0900 Subject: [PATCH 4343/6294] [Modify] Polish it --- websocket-sharp/HttpResponse.cs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/HttpResponse.cs b/websocket-sharp/HttpResponse.cs index 7e1b2a9ce..16b62e266 100644 --- a/websocket-sharp/HttpResponse.cs +++ b/websocket-sharp/HttpResponse.cs @@ -45,7 +45,9 @@ internal class HttpResponse : HttpBase #region Private Constructors - private HttpResponse (string code, string reason, Version version, NameValueCollection headers) + private HttpResponse ( + string code, string reason, Version version, NameValueCollection headers + ) : base (version, headers) { _code = code; @@ -62,7 +64,12 @@ internal HttpResponse (HttpStatusCode code) } internal HttpResponse (HttpStatusCode code, string reason) - : this (((int) code).ToString (), reason, HttpVersion.Version11, new NameValueCollection ()) + : this ( + ((int) code).ToString (), + reason, + HttpVersion.Version11, + new NameValueCollection () + ) { Headers["Server"] = "websocket-sharp/1.0"; } From cae2f68e755d4f09213c47031b990a550d0e8546 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 30 Apr 2022 21:28:09 +0900 Subject: [PATCH 4344/6294] [Modify] Polish it --- websocket-sharp/HttpResponse.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/HttpResponse.cs b/websocket-sharp/HttpResponse.cs index 16b62e266..b7b282f90 100644 --- a/websocket-sharp/HttpResponse.cs +++ b/websocket-sharp/HttpResponse.cs @@ -86,8 +86,9 @@ public CookieCollection Cookies { public bool HasConnectionClose { get { - var comparison = StringComparison.OrdinalIgnoreCase; - return Headers.Contains ("Connection", "close", comparison); + var compType = StringComparison.OrdinalIgnoreCase; + + return Headers.Contains ("Connection", "close", compType); } } From b81624af9ad000d5ec3dcfc373583124e24b2441 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 30 Apr 2022 21:29:43 +0900 Subject: [PATCH 4345/6294] [Modify] Polish it --- websocket-sharp/HttpResponse.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/HttpResponse.cs b/websocket-sharp/HttpResponse.cs index b7b282f90..72789ec62 100644 --- a/websocket-sharp/HttpResponse.cs +++ b/websocket-sharp/HttpResponse.cs @@ -136,10 +136,11 @@ public string StatusCode { internal static HttpResponse CreateCloseResponse (HttpStatusCode code) { - var res = new HttpResponse (code); - res.Headers["Connection"] = "close"; + var ret = new HttpResponse (code); - return res; + ret.Headers["Connection"] = "close"; + + return ret; } internal static HttpResponse CreateUnauthorizedResponse (string challenge) From 4469163e8d39112f0080cbf1c850607897d45904 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 30 Apr 2022 21:30:51 +0900 Subject: [PATCH 4346/6294] [Modify] Polish it --- websocket-sharp/HttpResponse.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/HttpResponse.cs b/websocket-sharp/HttpResponse.cs index 72789ec62..46223172f 100644 --- a/websocket-sharp/HttpResponse.cs +++ b/websocket-sharp/HttpResponse.cs @@ -145,10 +145,11 @@ internal static HttpResponse CreateCloseResponse (HttpStatusCode code) internal static HttpResponse CreateUnauthorizedResponse (string challenge) { - var res = new HttpResponse (HttpStatusCode.Unauthorized); - res.Headers["WWW-Authenticate"] = challenge; + var ret = new HttpResponse (HttpStatusCode.Unauthorized); - return res; + ret.Headers["WWW-Authenticate"] = challenge; + + return ret; } internal static HttpResponse CreateWebSocketResponse () From 87ec5ac1de0dc894394ff3697e3deebcb59b4bae Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 1 May 2022 17:17:45 +0900 Subject: [PATCH 4347/6294] [Modify] Polish it --- websocket-sharp/HttpResponse.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/HttpResponse.cs b/websocket-sharp/HttpResponse.cs index 46223172f..fc9979058 100644 --- a/websocket-sharp/HttpResponse.cs +++ b/websocket-sharp/HttpResponse.cs @@ -154,13 +154,14 @@ internal static HttpResponse CreateUnauthorizedResponse (string challenge) internal static HttpResponse CreateWebSocketResponse () { - var res = new HttpResponse (HttpStatusCode.SwitchingProtocols); + var ret = new HttpResponse (HttpStatusCode.SwitchingProtocols); + + var headers = ret.Headers; - var headers = res.Headers; headers["Upgrade"] = "websocket"; headers["Connection"] = "Upgrade"; - return res; + return ret; } internal static HttpResponse Parse (string[] headerParts) From 4d475f9a36d41e28408af9a32b12d76380d4cee6 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 2 May 2022 01:41:07 +0900 Subject: [PATCH 4348/6294] [Modify] Use int --- websocket-sharp/HttpResponse.cs | 24 +++++++++++++----------- websocket-sharp/WebSocket.cs | 4 +++- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/websocket-sharp/HttpResponse.cs b/websocket-sharp/HttpResponse.cs index fc9979058..392d04967 100644 --- a/websocket-sharp/HttpResponse.cs +++ b/websocket-sharp/HttpResponse.cs @@ -38,7 +38,7 @@ internal class HttpResponse : HttpBase { #region Private Fields - private string _code; + private int _code; private string _reason; #endregion @@ -46,7 +46,7 @@ internal class HttpResponse : HttpBase #region Private Constructors private HttpResponse ( - string code, string reason, Version version, NameValueCollection headers + int code, string reason, Version version, NameValueCollection headers ) : base (version, headers) { @@ -65,7 +65,7 @@ internal HttpResponse (HttpStatusCode code) internal HttpResponse (HttpStatusCode code, string reason) : this ( - ((int) code).ToString (), + (int) code, reason, HttpVersion.Version11, new NameValueCollection () @@ -94,26 +94,26 @@ public bool HasConnectionClose { public bool IsProxyAuthenticationRequired { get { - return _code == "407"; + return _code == 407; } } public bool IsRedirect { get { - return _code == "301" || _code == "302"; + return _code == 301 || _code == 302; } } public bool IsUnauthorized { get { - return _code == "401"; + return _code == 401; } } public bool IsWebSocketResponse { get { return ProtocolVersion > HttpVersion.Version10 - && _code == "101" + && _code == 101 && Headers.Upgrades ("websocket"); } } @@ -124,7 +124,7 @@ public string Reason { } } - public string StatusCode { + public int StatusCode { get { return _code; } @@ -182,11 +182,13 @@ internal static HttpResponse Parse (string[] headerParts) throw new ArgumentException (msg); } - var code = statusLineParts[1]; + var s = statusLineParts[1]; + var code = Int32.Parse (s); + var reason = statusLineParts[2]; - var num = statusLineParts[0].Substring (5); - var ver = new Version (num); + s = statusLineParts[0].Substring (5); + var ver = new Version (s); var headers = new WebHeaderCollection (); diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 011dee00d..fb4207405 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2105,7 +2105,9 @@ private void sendProxyConnectRequest () throw new WebSocketException ("A proxy authentication is required."); } - if (res.StatusCode[0] != '2') + var code = res.StatusCode; + + if (code < 200 || code > 299) throw new WebSocketException ( "The proxy has failed a connection to the requested host and port."); } From ca8d57b32e7a46e251f85581a67e717fd87d8e28 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 2 May 2022 01:49:40 +0900 Subject: [PATCH 4349/6294] [Modify] Add it --- websocket-sharp/HttpResponse.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/websocket-sharp/HttpResponse.cs b/websocket-sharp/HttpResponse.cs index 392d04967..19e1cc4b9 100644 --- a/websocket-sharp/HttpResponse.cs +++ b/websocket-sharp/HttpResponse.cs @@ -104,6 +104,12 @@ public bool IsRedirect { } } + public bool IsSuccess { + get { + return _code >= 200 && _code <= 299; + } + } + public bool IsUnauthorized { get { return _code == 401; From c5cd1f54e4acf060424ce1b96ff21ed57077aa2d Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 2 May 2022 01:53:20 +0900 Subject: [PATCH 4350/6294] [Modify] Replace it --- websocket-sharp/WebSocket.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index fb4207405..d518a6186 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2105,9 +2105,7 @@ private void sendProxyConnectRequest () throw new WebSocketException ("A proxy authentication is required."); } - var code = res.StatusCode; - - if (code < 200 || code > 299) + if (!res.IsSuccess) throw new WebSocketException ( "The proxy has failed a connection to the requested host and port."); } From 3f536781bdd557b287c47b4dbd91e080a10f8e32 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 2 May 2022 17:39:10 +0900 Subject: [PATCH 4351/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 62 +++++++++++++++++++++++------------- 1 file changed, 40 insertions(+), 22 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index d518a6186..7fa076637 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2077,37 +2077,55 @@ private void sendProxyConnectRequest () { var req = HttpRequest.CreateConnectRequest (_uri); var res = sendHttpRequest (req, 90000); + if (res.IsProxyAuthenticationRequired) { - var chal = res.Headers["Proxy-Authenticate"]; - _logger.Warn ( - String.Format ("Received a proxy authentication requirement for '{0}'.", chal)); + if (_proxyCredentials == null) { + var msg = "No credential for the proxy is specified."; - if (chal.IsNullOrEmpty ()) - throw new WebSocketException ("No proxy authentication challenge is specified."); + throw new WebSocketException (msg); + } - var authChal = AuthenticationChallenge.Parse (chal); - if (authChal == null) - throw new WebSocketException ("An invalid proxy authentication challenge is specified."); + var val = res.Headers["Proxy-Authenticate"]; - if (_proxyCredentials != null) { - if (res.HasConnectionClose) { - releaseClientResources (); - _tcpClient = new TcpClient (_proxyUri.DnsSafeHost, _proxyUri.Port); - _stream = _tcpClient.GetStream (); - } + if (val.IsNullOrEmpty ()) { + var msg = "No proxy authentication challenge is specified."; - var authRes = new AuthenticationResponse (authChal, _proxyCredentials, 0); - req.Headers["Proxy-Authorization"] = authRes.ToString (); - res = sendHttpRequest (req, 15000); + throw new WebSocketException (msg); + } + + var achal = AuthenticationChallenge.Parse (val); + + if (achal == null) { + var msg = "An invalid proxy authentication challenge is specified."; + + throw new WebSocketException (msg); } - if (res.IsProxyAuthenticationRequired) - throw new WebSocketException ("A proxy authentication is required."); + var ares = new AuthenticationResponse (achal, _proxyCredentials, 0); + + req.Headers["Proxy-Authorization"] = ares.ToString (); + + if (res.HasConnectionClose) { + releaseClientResources (); + + _tcpClient = new TcpClient (_proxyUri.DnsSafeHost, _proxyUri.Port); + _stream = _tcpClient.GetStream (); + } + + res = sendHttpRequest (req, 15000); + + if (res.IsProxyAuthenticationRequired) { + var msg = "A proxy authentication is required."; + + throw new WebSocketException (msg); + } } - if (!res.IsSuccess) - throw new WebSocketException ( - "The proxy has failed a connection to the requested host and port."); + if (!res.IsSuccess) { + var msg = "The proxy has failed a connection to the requested URL."; + + throw new WebSocketException (msg); + } } // As client From 9c3523531d69981d1e22db55720a218f8ace52bd Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 3 May 2022 17:43:25 +0900 Subject: [PATCH 4352/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 7fa076637..9ae422246 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2115,7 +2115,7 @@ private void sendProxyConnectRequest () res = sendHttpRequest (req, 15000); if (res.IsProxyAuthenticationRequired) { - var msg = "A proxy authentication is required."; + var msg = "The proxy authentication has failed."; throw new WebSocketException (msg); } From 7466a7786b706d4a6b4cfd950b75df0eefafea58 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 4 May 2022 16:40:19 +0900 Subject: [PATCH 4353/6294] [Modify] Rename it --- websocket-sharp/HttpResponse.cs | 2 +- websocket-sharp/WebSocket.cs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/HttpResponse.cs b/websocket-sharp/HttpResponse.cs index 19e1cc4b9..e712a292f 100644 --- a/websocket-sharp/HttpResponse.cs +++ b/websocket-sharp/HttpResponse.cs @@ -84,7 +84,7 @@ public CookieCollection Cookies { } } - public bool HasConnectionClose { + public bool CloseConnection { get { var compType = StringComparison.OrdinalIgnoreCase; diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 9ae422246..b3369600d 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2009,7 +2009,7 @@ private HttpResponse sendHandshakeRequest () if (_credentials != null && (!_preAuth || _authChallenge.Scheme == AuthenticationSchemes.Digest)) { - if (res.HasConnectionClose) { + if (res.CloseConnection) { releaseClientResources (); setClientStream (); } @@ -2105,7 +2105,7 @@ private void sendProxyConnectRequest () req.Headers["Proxy-Authorization"] = ares.ToString (); - if (res.HasConnectionClose) { + if (res.CloseConnection) { releaseClientResources (); _tcpClient = new TcpClient (_proxyUri.DnsSafeHost, _proxyUri.Port); From 18f1b0194c57f5d9bf13900f561eaa4ae600048c Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 4 May 2022 16:41:45 +0900 Subject: [PATCH 4354/6294] [Modify] Polish it --- websocket-sharp/HttpResponse.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/HttpResponse.cs b/websocket-sharp/HttpResponse.cs index e712a292f..43234a9c1 100644 --- a/websocket-sharp/HttpResponse.cs +++ b/websocket-sharp/HttpResponse.cs @@ -78,12 +78,6 @@ internal HttpResponse (HttpStatusCode code, string reason) #region Public Properties - public CookieCollection Cookies { - get { - return Headers.GetCookies (true); - } - } - public bool CloseConnection { get { var compType = StringComparison.OrdinalIgnoreCase; @@ -92,6 +86,12 @@ public bool CloseConnection { } } + public CookieCollection Cookies { + get { + return Headers.GetCookies (true); + } + } + public bool IsProxyAuthenticationRequired { get { return _code == 407; From fae83e7c51f6df02c5c0038a3dc54e3e9057760e Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 4 May 2022 23:02:26 +0900 Subject: [PATCH 4355/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 94 +++++++++++++++++++++++------------- 1 file changed, 61 insertions(+), 33 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index b3369600d..59789573f 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1993,58 +1993,86 @@ private HttpResponse sendHandshakeRequest () { var req = createHandshakeRequest (); var res = sendHttpRequest (req, 90000); + if (res.IsUnauthorized) { - var chal = res.Headers["WWW-Authenticate"]; - _logger.Warn (String.Format ("Received an authentication requirement for '{0}'.", chal)); - if (chal.IsNullOrEmpty ()) { + if (_credentials == null) { + _logger.Error ("No credential is specified."); + + return res; + } + + var val = res.Headers["WWW-Authenticate"]; + + if (val.IsNullOrEmpty ()) { _logger.Error ("No authentication challenge is specified."); + return res; } - _authChallenge = AuthenticationChallenge.Parse (chal); - if (_authChallenge == null) { + var achal = AuthenticationChallenge.Parse (val); + + if (achal == null) { _logger.Error ("An invalid authentication challenge is specified."); + return res; } - if (_credentials != null && - (!_preAuth || _authChallenge.Scheme == AuthenticationSchemes.Digest)) { - if (res.CloseConnection) { - releaseClientResources (); - setClientStream (); - } + _authChallenge = achal; + + var failed = _preAuth + && _authChallenge.Scheme == AuthenticationSchemes.Basic; - var authRes = new AuthenticationResponse (_authChallenge, _credentials, _nonceCount); - _nonceCount = authRes.NonceCount; - req.Headers["Authorization"] = authRes.ToString (); - res = sendHttpRequest (req, 15000); + if (failed) { + _logger.Error ("The authentication has failed."); + + return res; + } + + var ares = new AuthenticationResponse ( + _authChallenge, _credentials, _nonceCount + ); + + _nonceCount = ares.NonceCount; + + req.Headers["Authorization"] = ares.ToString (); + + if (res.CloseConnection) { + releaseClientResources (); + setClientStream (); } + + res = sendHttpRequest (req, 15000); } if (res.IsRedirect) { - var url = res.Headers["Location"]; - _logger.Warn (String.Format ("Received a redirection to '{0}'.", url)); - if (_enableRedirection) { - if (url.IsNullOrEmpty ()) { - _logger.Error ("No url to redirect is located."); - return res; - } + if (!_enableRedirection) + return res; - Uri uri; - string msg; - if (!url.TryCreateWebSocketUri (out uri, out msg)) { - _logger.Error ("An invalid url to redirect is located: " + msg); - return res; - } + var val = res.Headers["Location"]; - releaseClientResources (); + if (val.IsNullOrEmpty ()) { + _logger.Error ("No url to redirect is located."); + + return res; + } + + Uri uri; + string msg; - _uri = uri; - _secure = uri.Scheme == "wss"; + if (!val.TryCreateWebSocketUri (out uri, out msg)) { + _logger.Error ("An invalid url to redirect is located."); - setClientStream (); - return sendHandshakeRequest (); + return res; } + + releaseClientResources (); + + _uri = uri; + _secure = uri.Scheme == "wss"; + + setClientStream (); + + return sendHandshakeRequest (); } return res; From 3eaf8b403b3c92a6c6acfd113bfdbdcbc4c83db5 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 5 May 2022 17:29:08 +0900 Subject: [PATCH 4356/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 59789573f..68fdd9356 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1321,32 +1321,38 @@ private HttpRequest createHandshakeRequest () var ret = HttpRequest.CreateWebSocketRequest (_uri); var headers = ret.Headers; - if (!_origin.IsNullOrEmpty ()) - headers["Origin"] = _origin; headers["Sec-WebSocket-Key"] = _base64Key; + headers["Sec-WebSocket-Version"] = _version; + + if (!_origin.IsNullOrEmpty ()) + headers["Origin"] = _origin; _protocolsRequested = _protocols != null; + if (_protocolsRequested) headers["Sec-WebSocket-Protocol"] = _protocols.ToString (", "); _extensionsRequested = _compression != CompressionMethod.None; + if (_extensionsRequested) headers["Sec-WebSocket-Extensions"] = createExtensions (); - headers["Sec-WebSocket-Version"] = _version; + AuthenticationResponse ares = null; - AuthenticationResponse authRes = null; if (_authChallenge != null && _credentials != null) { - authRes = new AuthenticationResponse (_authChallenge, _credentials, _nonceCount); - _nonceCount = authRes.NonceCount; + ares = new AuthenticationResponse ( + _authChallenge, _credentials, _nonceCount + ); + + _nonceCount = ares.NonceCount; } else if (_preAuth) { - authRes = new AuthenticationResponse (_credentials); + ares = new AuthenticationResponse (_credentials); } - if (authRes != null) - headers["Authorization"] = authRes.ToString (); + if (ares != null) + headers["Authorization"] = ares.ToString (); if (_cookies.Count > 0) ret.SetCookies (_cookies); From f2bc41321d09bd2fc8574171e105e96197c6713d Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 5 May 2022 17:42:28 +0900 Subject: [PATCH 4357/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 68fdd9356..24458be35 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1292,18 +1292,20 @@ private string createExtensions () if (_compression != CompressionMethod.None) { var str = _compression.ToExtensionString ( - "server_no_context_takeover", "client_no_context_takeover"); + "server_no_context_takeover", "client_no_context_takeover" + ); buff.AppendFormat ("{0}, ", str); } var len = buff.Length; - if (len > 2) { - buff.Length = len - 2; - return buff.ToString (); - } - return null; + if (len <= 2) + return null; + + buff.Length = len - 2; + + return buff.ToString (); } // As server From a3b22069da088cc825ba067aacaeff6285f2a302 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 5 May 2022 22:20:08 +0900 Subject: [PATCH 4358/6294] [Modify] Add it --- websocket-sharp/WebSocket.cs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 24458be35..10f9c264d 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1284,6 +1284,25 @@ private bool connect () return true; } } + + // As client + private AuthenticationResponse createAuthenticationResponse () + { + if (_credentials == null) + return null; + + if (_authChallenge != null) { + var ret = new AuthenticationResponse ( + _authChallenge, _credentials, _nonceCount + ); + + _nonceCount = ret.NonceCount; + + return ret; + } + + return _preAuth ? new AuthenticationResponse (_credentials) : null; + } // As client private string createExtensions () From 7716b2daa07559ceb086cdac8d26b7de7e288ef2 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 5 May 2022 22:27:07 +0900 Subject: [PATCH 4359/6294] [Modify] Replace it --- websocket-sharp/WebSocket.cs | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 10f9c264d..7b23d38c7 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1359,18 +1359,7 @@ private HttpRequest createHandshakeRequest () if (_extensionsRequested) headers["Sec-WebSocket-Extensions"] = createExtensions (); - AuthenticationResponse ares = null; - - if (_authChallenge != null && _credentials != null) { - ares = new AuthenticationResponse ( - _authChallenge, _credentials, _nonceCount - ); - - _nonceCount = ares.NonceCount; - } - else if (_preAuth) { - ares = new AuthenticationResponse (_credentials); - } + var ares = createAuthenticationResponse (); if (ares != null) headers["Authorization"] = ares.ToString (); From 82d077dcd9b9b0cfb17529b3e8386479e50bae45 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 6 May 2022 19:26:58 +0900 Subject: [PATCH 4360/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 7b23d38c7..ee7e6cab5 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1354,10 +1354,13 @@ private HttpRequest createHandshakeRequest () if (_protocolsRequested) headers["Sec-WebSocket-Protocol"] = _protocols.ToString (", "); - _extensionsRequested = _compression != CompressionMethod.None; + var exts = createExtensions (); - if (_extensionsRequested) - headers["Sec-WebSocket-Extensions"] = createExtensions (); + if (exts != null) { + headers["Sec-WebSocket-Extensions"] = exts; + + _extensionsRequested = true; + } var ares = createAuthenticationResponse (); From 0cbcfd93b5a57c1c4941906927a4703adc203caa Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 6 May 2022 19:31:00 +0900 Subject: [PATCH 4361/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index ee7e6cab5..db0ca04f7 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1349,10 +1349,11 @@ private HttpRequest createHandshakeRequest () if (!_origin.IsNullOrEmpty ()) headers["Origin"] = _origin; - _protocolsRequested = _protocols != null; - - if (_protocolsRequested) + if (_protocols != null) { headers["Sec-WebSocket-Protocol"] = _protocols.ToString (", "); + + _protocolsRequested = true; + } var exts = createExtensions (); From d3a69aa2783b69e22de8acf4204c71a602b43f8a Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 7 May 2022 20:38:57 +0900 Subject: [PATCH 4362/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index db0ca04f7..e61e1adfb 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1331,6 +1331,7 @@ private string createExtensions () private HttpResponse createHandshakeFailureResponse (HttpStatusCode code) { var ret = HttpResponse.CreateCloseResponse (code); + ret.Headers["Sec-WebSocket-Version"] = _version; return ret; From f89d5f075e00d9686f7416aea150e6441e11d3c8 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 7 May 2022 20:40:35 +0900 Subject: [PATCH 4363/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index e61e1adfb..8f3cee0e7 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1381,6 +1381,7 @@ private HttpResponse createHandshakeResponse () var ret = HttpResponse.CreateWebSocketResponse (); var headers = ret.Headers; + headers["Sec-WebSocket-Accept"] = CreateResponseKey (_base64Key); if (_protocol != null) From f6f069fd4f956215c09c174eead167b4f3d24075 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 8 May 2022 21:41:12 +0900 Subject: [PATCH 4364/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 8f3cee0e7..7e443102f 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1407,6 +1407,7 @@ private bool customCheckHandshakeRequest ( return true; message = _handshakeRequestChecker (context); + return message == null; } From 71c41a167debf7fa133c38bcbd8ca8210eccbf6e Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 8 May 2022 21:43:14 +0900 Subject: [PATCH 4365/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 7e443102f..c79a409e6 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1413,8 +1413,11 @@ private bool customCheckHandshakeRequest ( private MessageEventArgs dequeueFromMessageEventQueue () { - lock (_forMessageEventQueue) - return _messageEventQueue.Count > 0 ? _messageEventQueue.Dequeue () : null; + lock (_forMessageEventQueue) { + return _messageEventQueue.Count > 0 + ? _messageEventQueue.Dequeue () + : null; + } } // As client From 7598dd5157c3960e3d3d5584a7b4e94a2b90b40e Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 9 May 2022 20:52:26 +0900 Subject: [PATCH 4366/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index c79a409e6..ba506d245 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1424,17 +1424,22 @@ private MessageEventArgs dequeueFromMessageEventQueue () private void doHandshake () { setClientStream (); + var res = sendHandshakeRequest (); string msg; + if (!checkHandshakeResponse (res, out msg)) throw new WebSocketException (CloseStatusCode.ProtocolError, msg); if (_protocolsRequested) _protocol = res.Headers["Sec-WebSocket-Protocol"]; - if (_extensionsRequested) - processSecWebSocketExtensionsServerHeader (res.Headers["Sec-WebSocket-Extensions"]); + if (_extensionsRequested) { + var val = res.Headers["Sec-WebSocket-Extensions"]; + + processSecWebSocketExtensionsServerHeader (val); + } processCookies (res.Cookies); } From b03462a9cf36b84cf3f9c3253738c8a5bd0d831a Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 10 May 2022 14:40:07 +0900 Subject: [PATCH 4367/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 42 +++++++++++++++++++++++++----------- 1 file changed, 30 insertions(+), 12 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index ba506d245..c3c065d1c 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -982,43 +982,61 @@ private bool checkHandshakeRequest ( } // As client - private bool checkHandshakeResponse (HttpResponse response, out string message) + private bool checkHandshakeResponse ( + HttpResponse response, out string message + ) { message = null; if (response.IsRedirect) { - message = "Indicates the redirection."; + message = "The handshake response indicates the redirection."; + return false; } if (response.IsUnauthorized) { - message = "Requires the authentication."; + message = "The handshake response requires the authentication."; + return false; } if (!response.IsWebSocketResponse) { - message = "Not a WebSocket handshake response."; + message = "The handshake response is not a WebSocket handshake response."; + return false; } var headers = response.Headers; - if (!validateSecWebSocketAcceptHeader (headers["Sec-WebSocket-Accept"])) { - message = "Includes no Sec-WebSocket-Accept header, or it has an invalid value."; + + var val = headers["Sec-WebSocket-Accept"]; + + if (!validateSecWebSocketAcceptHeader (val)) { + message = "The Sec-WebSocket-Accept header is non-existent or invalid."; + return false; } - if (!validateSecWebSocketProtocolServerHeader (headers["Sec-WebSocket-Protocol"])) { - message = "Includes no Sec-WebSocket-Protocol header, or it has an invalid value."; + val = headers["Sec-WebSocket-Protocol"]; + + if (!validateSecWebSocketProtocolServerHeader (val)) { + message = "The Sec-WebSocket-Protocol header is non-existent or invalid."; + return false; } - if (!validateSecWebSocketExtensionsServerHeader (headers["Sec-WebSocket-Extensions"])) { - message = "Includes an invalid Sec-WebSocket-Extensions header."; + val = headers["Sec-WebSocket-Extensions"]; + + if (!validateSecWebSocketExtensionsServerHeader (val)) { + message = "The Sec-WebSocket-Extensions header is invalid."; + return false; } - if (!validateSecWebSocketVersionServerHeader (headers["Sec-WebSocket-Version"])) { - message = "Includes an invalid Sec-WebSocket-Version header."; + val = headers["Sec-WebSocket-Version"]; + + if (!validateSecWebSocketVersionServerHeader (val)) { + message = "The Sec-WebSocket-Version header is invalid."; + return false; } From f23296927f082a73dc19f3fc4166bca8ef5dbd2c Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 10 May 2022 15:01:54 +0900 Subject: [PATCH 4368/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index c3c065d1c..881a17509 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -931,49 +931,61 @@ private bool checkHandshakeRequest ( message = null; if (!context.IsWebSocketRequest) { - message = "Not a handshake request."; + message = "Not a WebSocket handshake request."; + return false; } if (context.RequestUri == null) { - message = "It specifies an invalid Request-URI."; + message = "The Request-URI is invalid."; + return false; } var headers = context.Headers; var key = headers["Sec-WebSocket-Key"]; + if (key == null) { - message = "It includes no Sec-WebSocket-Key header."; + message = "The Sec-WebSocket-Key header is non-existent."; + return false; } if (key.Length == 0) { - message = "It includes an invalid Sec-WebSocket-Key header."; + message = "The Sec-WebSocket-Key header is invalid."; + return false; } var version = headers["Sec-WebSocket-Version"]; + if (version == null) { - message = "It includes no Sec-WebSocket-Version header."; + message = "The Sec-WebSocket-Version header is non-existent."; + return false; } if (version != _version) { - message = "It includes an invalid Sec-WebSocket-Version header."; + message = "The Sec-WebSocket-Version header is invalid."; + return false; } var protocol = headers["Sec-WebSocket-Protocol"]; + if (protocol != null && protocol.Length == 0) { - message = "It includes an invalid Sec-WebSocket-Protocol header."; + message = "The Sec-WebSocket-Protocol header is invalid."; + return false; } if (!_ignoreExtensions) { var extensions = headers["Sec-WebSocket-Extensions"]; + if (extensions != null && extensions.Length == 0) { - message = "It includes an invalid Sec-WebSocket-Extensions header."; + message = "The Sec-WebSocket-Extensions header is invalid."; + return false; } } From 633efe6e750b78da8bb06d91a1436cbe9d872fe6 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 10 May 2022 15:07:17 +0900 Subject: [PATCH 4369/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 881a17509..0daec3ce3 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1001,19 +1001,19 @@ private bool checkHandshakeResponse ( message = null; if (response.IsRedirect) { - message = "The handshake response indicates the redirection."; + message = "The redirection is indicated."; return false; } if (response.IsUnauthorized) { - message = "The handshake response requires the authentication."; + message = "The authentication is required."; return false; } if (!response.IsWebSocketResponse) { - message = "The handshake response is not a WebSocket handshake response."; + message = "Not a WebSocket handshake response."; return false; } From a2ebcc5b979221f28fc93cc040052d58863646a0 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 10 May 2022 15:21:01 +0900 Subject: [PATCH 4370/6294] [Modify] Replace it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 0daec3ce3..b85c90c80 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1046,7 +1046,7 @@ private bool checkHandshakeResponse ( val = headers["Sec-WebSocket-Version"]; - if (!validateSecWebSocketVersionServerHeader (val)) { + if (val != null && val != _version) { message = "The Sec-WebSocket-Version header is invalid."; return false; From 6a2ba92c8c4ffa4f76ebf1352275baf5dcd1eb2f Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 10 May 2022 15:22:39 +0900 Subject: [PATCH 4371/6294] [Modify] Remove it --- websocket-sharp/WebSocket.cs | 6 ------ 1 file changed, 6 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index b85c90c80..b96d00f0b 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2362,12 +2362,6 @@ private bool validateSecWebSocketProtocolServerHeader (string value) return _protocolsRequested && _protocols.Contains (p => p == value); } - // As client - private bool validateSecWebSocketVersionServerHeader (string value) - { - return value == null || value == _version; - } - #endregion #region Internal Methods From 9e1582a39e3a447a9583932e26d6c2d7dafb1774 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 10 May 2022 20:08:48 +0900 Subject: [PATCH 4372/6294] [Modify] Replace it --- websocket-sharp/WebSocket.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index b96d00f0b..1dadcf9ae 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1022,8 +1022,14 @@ private bool checkHandshakeResponse ( var val = headers["Sec-WebSocket-Accept"]; - if (!validateSecWebSocketAcceptHeader (val)) { - message = "The Sec-WebSocket-Accept header is non-existent or invalid."; + if (val == null) { + message = "The Sec-WebSocket-Accept header is non-existent."; + + return false; + } + + if (val != CreateResponseKey (_base64Key)) { + message = "The Sec-WebSocket-Accept header is invalid."; return false; } From ce953c89a77b7cf2b5a5fe95b88b7bb4c0f46c0a Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 10 May 2022 20:10:11 +0900 Subject: [PATCH 4373/6294] [Modify] Remove it --- websocket-sharp/WebSocket.cs | 6 ------ 1 file changed, 6 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 1dadcf9ae..fab3af322 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2304,12 +2304,6 @@ private void startReceiving () receive (); } - // As client - private bool validateSecWebSocketAcceptHeader (string value) - { - return value != null && value == CreateResponseKey (_base64Key); - } - // As client private bool validateSecWebSocketExtensionsServerHeader (string value) { From d855fcb11e2831505f18623d57051d4d11f68eee Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 11 May 2022 20:19:17 +0900 Subject: [PATCH 4374/6294] [Modify] Replace it --- websocket-sharp/WebSocket.cs | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index fab3af322..4bd1ef3ba 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1036,10 +1036,23 @@ private bool checkHandshakeResponse ( val = headers["Sec-WebSocket-Protocol"]; - if (!validateSecWebSocketProtocolServerHeader (val)) { - message = "The Sec-WebSocket-Protocol header is non-existent or invalid."; + if (val == null) { + if (_protocolsRequested) { + message = "The Sec-WebSocket-Protocol header is non-existent."; - return false; + return false; + } + } + else { + var valid = val.Length > 0 + && _protocolsRequested + && _protocols.Contains (p => p == val); + + if (!valid) { + message = "The Sec-WebSocket-Protocol header is invalid."; + + return false; + } } val = headers["Sec-WebSocket-Extensions"]; From fc6fba8844492876fdb3c006827793ae89cc947f Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 11 May 2022 20:21:49 +0900 Subject: [PATCH 4375/6294] [Modify] Remove it --- websocket-sharp/WebSocket.cs | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 4bd1ef3ba..31d28e90e 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2363,18 +2363,6 @@ private bool validateSecWebSocketExtensionsServerHeader (string value) return true; } - // As client - private bool validateSecWebSocketProtocolServerHeader (string value) - { - if (value == null) - return !_protocolsRequested; - - if (value.Length == 0) - return false; - - return _protocolsRequested && _protocols.Contains (p => p == value); - } - #endregion #region Internal Methods From 36edc161c7be8a86f4b78d11fcc344d7ca0d8e72 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 12 May 2022 19:50:42 +0900 Subject: [PATCH 4376/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 39 +++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 31d28e90e..754b6b756 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2330,27 +2330,34 @@ private bool validateSecWebSocketExtensionsServerHeader (string value) return false; var comp = _compression != CompressionMethod.None; - foreach (var e in value.SplitHeaderValue (',')) { - var ext = e.Trim (); + + foreach (var elm in value.SplitHeaderValue (',')) { + var ext = elm.Trim (); + if (comp && ext.IsCompressionExtension (_compression)) { if (!ext.Contains ("server_no_context_takeover")) { - _logger.Error ("The server hasn't sent back 'server_no_context_takeover'."); + var msg = "The server has not sent back 'server_no_context_takeover'."; + _logger.Error (msg); + return false; } - if (!ext.Contains ("client_no_context_takeover")) - _logger.Warn ("The server hasn't sent back 'client_no_context_takeover'."); - - var method = _compression.ToExtensionString (); - var invalid = - ext.SplitHeaderValue (';').Contains ( - t => { - t = t.Trim (); - return t != method - && t != "server_no_context_takeover" - && t != "client_no_context_takeover"; - } - ); + if (!ext.Contains ("client_no_context_takeover")) { + var msg = "The server has not sent back 'client_no_context_takeover'."; + + _logger.Warn (msg); + } + + var name = _compression.ToExtensionString (); + var invalid = ext.SplitHeaderValue (';').Contains ( + t => { + t = t.Trim (); + + return t != name + && t != "server_no_context_takeover" + && t != "client_no_context_takeover"; + } + ); if (invalid) return false; From b83a205f776814d35bbff02912158f3f63147787 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 13 May 2022 16:27:44 +0900 Subject: [PATCH 4377/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 754b6b756..44ab62682 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2335,15 +2335,21 @@ private bool validateSecWebSocketExtensionsServerHeader (string value) var ext = elm.Trim (); if (comp && ext.IsCompressionExtension (_compression)) { - if (!ext.Contains ("server_no_context_takeover")) { - var msg = "The server has not sent back 'server_no_context_takeover'."; + var param1 = "server_no_context_takeover"; + var param2 = "client_no_context_takeover"; + + if (!ext.Contains (param1)) { + var fmt = "The server did not send back '{0}'."; + var msg = String.Format (fmt, param1); + _logger.Error (msg); return false; } - if (!ext.Contains ("client_no_context_takeover")) { - var msg = "The server has not sent back 'client_no_context_takeover'."; + if (!ext.Contains (param2)) { + var fmt = "The server did not send back '{0}'."; + var msg = String.Format (fmt, param2); _logger.Warn (msg); } @@ -2354,8 +2360,8 @@ private bool validateSecWebSocketExtensionsServerHeader (string value) t = t.Trim (); return t != name - && t != "server_no_context_takeover" - && t != "client_no_context_takeover"; + && t != param1 + && t != param2; } ); From 6fc39362f6edc3536d2e5655bc51038a811d83e1 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 14 May 2022 16:56:48 +0900 Subject: [PATCH 4378/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 44ab62682..ba1bc20bb 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2359,9 +2359,11 @@ private bool validateSecWebSocketExtensionsServerHeader (string value) t => { t = t.Trim (); - return t != name - && t != param1 - && t != param2; + var valid = t == name + || t == param1 + || t == param2; + + return !valid; } ); From 3d5fc5f9ea2be47a76938b496f107957f9a70435 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 15 May 2022 21:38:13 +0900 Subject: [PATCH 4379/6294] [Modify] No second time --- websocket-sharp/WebSocket.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index ba1bc20bb..a1a3bfcf4 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2369,6 +2369,8 @@ private bool validateSecWebSocketExtensionsServerHeader (string value) if (invalid) return false; + + comp = false; } else { return false; From 697858f7a7c947c14cacc8691f2f23e23402f36d Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 15 May 2022 21:39:16 +0900 Subject: [PATCH 4380/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 7 ------- 1 file changed, 7 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index a1a3bfcf4..ebe494455 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2347,13 +2347,6 @@ private bool validateSecWebSocketExtensionsServerHeader (string value) return false; } - if (!ext.Contains (param2)) { - var fmt = "The server did not send back '{0}'."; - var msg = String.Format (fmt, param2); - - _logger.Warn (msg); - } - var name = _compression.ToExtensionString (); var invalid = ext.SplitHeaderValue (';').Contains ( t => { From dbd4639174d13d546d86283e56bde7ddc4a71806 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 16 May 2022 17:35:26 +0900 Subject: [PATCH 4381/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index ebe494455..751166daa 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1034,6 +1034,14 @@ private bool checkHandshakeResponse ( return false; } + val = headers["Sec-WebSocket-Version"]; + + if (val != null && val != _version) { + message = "The Sec-WebSocket-Version header is invalid."; + + return false; + } + val = headers["Sec-WebSocket-Protocol"]; if (val == null) { @@ -1063,14 +1071,6 @@ private bool checkHandshakeResponse ( return false; } - val = headers["Sec-WebSocket-Version"]; - - if (val != null && val != _version) { - message = "The Sec-WebSocket-Version header is invalid."; - - return false; - } - return true; } From b73cb321e7271b39476828adb70e13bbe13ace96 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 16 May 2022 17:37:13 +0900 Subject: [PATCH 4382/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 751166daa..85950d324 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1063,9 +1063,9 @@ private bool checkHandshakeResponse ( } } - val = headers["Sec-WebSocket-Extensions"]; + var exts = headers["Sec-WebSocket-Extensions"]; - if (!validateSecWebSocketExtensionsServerHeader (val)) { + if (!validateSecWebSocketExtensionsServerHeader (exts)) { message = "The Sec-WebSocket-Extensions header is invalid."; return false; From 4eddfaf81ef2cbb0275b4d3552bec67a36a8edc9 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 16 May 2022 17:40:02 +0900 Subject: [PATCH 4383/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 85950d324..0a6b2d16f 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1042,9 +1042,9 @@ private bool checkHandshakeResponse ( return false; } - val = headers["Sec-WebSocket-Protocol"]; + var subp = headers["Sec-WebSocket-Protocol"]; - if (val == null) { + if (subp == null) { if (_protocolsRequested) { message = "The Sec-WebSocket-Protocol header is non-existent."; @@ -1052,9 +1052,9 @@ private bool checkHandshakeResponse ( } } else { - var valid = val.Length > 0 + var valid = subp.Length > 0 && _protocolsRequested - && _protocols.Contains (p => p == val); + && _protocols.Contains (p => p == subp); if (!valid) { message = "The Sec-WebSocket-Protocol header is invalid."; From 584cdf67c16113134e53b8af5f1a10281db8a97a Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 16 May 2022 17:41:33 +0900 Subject: [PATCH 4384/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 0a6b2d16f..0095945ff 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1034,9 +1034,9 @@ private bool checkHandshakeResponse ( return false; } - val = headers["Sec-WebSocket-Version"]; + var ver = headers["Sec-WebSocket-Version"]; - if (val != null && val != _version) { + if (ver != null && ver != _version) { message = "The Sec-WebSocket-Version header is invalid."; return false; From d03dd55b3e95c4e036ab5b9c6bd9d66adeaec7ec Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 17 May 2022 19:59:04 +0900 Subject: [PATCH 4385/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 0095945ff..d59d5cbf5 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1020,15 +1020,15 @@ private bool checkHandshakeResponse ( var headers = response.Headers; - var val = headers["Sec-WebSocket-Accept"]; + var key = headers["Sec-WebSocket-Accept"]; - if (val == null) { + if (key == null) { message = "The Sec-WebSocket-Accept header is non-existent."; return false; } - if (val != CreateResponseKey (_base64Key)) { + if (key != CreateResponseKey (_base64Key)) { message = "The Sec-WebSocket-Accept header is invalid."; return false; From 74d9ba7a936b0ff1a5872e5f558a4f7dec1e05ec Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 17 May 2022 20:01:47 +0900 Subject: [PATCH 4386/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index d59d5cbf5..4e5b84560 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -958,15 +958,15 @@ private bool checkHandshakeRequest ( return false; } - var version = headers["Sec-WebSocket-Version"]; + var ver = headers["Sec-WebSocket-Version"]; - if (version == null) { + if (ver == null) { message = "The Sec-WebSocket-Version header is non-existent."; return false; } - if (version != _version) { + if (ver != _version) { message = "The Sec-WebSocket-Version header is invalid."; return false; From 2de1d204b2df716d2436f2c3103b40604825bbbb Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 17 May 2022 20:04:37 +0900 Subject: [PATCH 4387/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 4e5b84560..771a4101b 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -972,9 +972,9 @@ private bool checkHandshakeRequest ( return false; } - var protocol = headers["Sec-WebSocket-Protocol"]; + var subps = headers["Sec-WebSocket-Protocol"]; - if (protocol != null && protocol.Length == 0) { + if (subps != null && subps.Length == 0) { message = "The Sec-WebSocket-Protocol header is invalid."; return false; From 08676ff51158a86f0cd5f28896d7764f0922a4bd Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 17 May 2022 20:06:23 +0900 Subject: [PATCH 4388/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 771a4101b..ec87dbad2 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -981,9 +981,9 @@ private bool checkHandshakeRequest ( } if (!_ignoreExtensions) { - var extensions = headers["Sec-WebSocket-Extensions"]; + var exts = headers["Sec-WebSocket-Extensions"]; - if (extensions != null && extensions.Length == 0) { + if (exts != null && exts.Length == 0) { message = "The Sec-WebSocket-Extensions header is invalid."; return false; From 158dd8a6f4bc511160b350ac277f98484d70a136 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 18 May 2022 19:29:45 +0900 Subject: [PATCH 4389/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index ec87dbad2..95344035f 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2242,6 +2242,7 @@ private void setClientStream () if (_proxyUri != null) { _tcpClient = new TcpClient (_proxyUri.DnsSafeHost, _proxyUri.Port); _stream = _tcpClient.GetStream (); + sendProxyConnectRequest (); } else { @@ -2252,27 +2253,36 @@ private void setClientStream () if (_secure) { var conf = getSslConfiguration (); var host = conf.TargetHost; - if (host != _uri.DnsSafeHost) + + if (host != _uri.DnsSafeHost) { + var msg = "An invalid host name is specified."; + throw new WebSocketException ( - CloseStatusCode.TlsHandshakeFailure, "An invalid host name is specified."); + CloseStatusCode.TlsHandshakeFailure, msg + ); + } try { var sslStream = new SslStream ( - _stream, - false, - conf.ServerCertificateValidationCallback, - conf.ClientCertificateSelectionCallback); + _stream, + false, + conf.ServerCertificateValidationCallback, + conf.ClientCertificateSelectionCallback + ); sslStream.AuthenticateAsClient ( host, conf.ClientCertificates, conf.EnabledSslProtocols, - conf.CheckCertificateRevocation); + conf.CheckCertificateRevocation + ); _stream = sslStream; } catch (Exception ex) { - throw new WebSocketException (CloseStatusCode.TlsHandshakeFailure, ex); + throw new WebSocketException ( + CloseStatusCode.TlsHandshakeFailure, ex + ); } } } From f50568fb5263d4629a4932ab806e1df9a7491632 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 19 May 2022 19:59:53 +0900 Subject: [PATCH 4390/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 95344035f..96b375eeb 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2159,11 +2159,19 @@ private HttpResponse sendHandshakeRequest () } // As client - private HttpResponse sendHttpRequest (HttpRequest request, int millisecondsTimeout) + private HttpResponse sendHttpRequest ( + HttpRequest request, int millisecondsTimeout + ) { - _logger.Debug ("A request to the server:\n" + request.ToString ()); + var msg = "An HTTP request to the server:\n" + request.ToString (); + + _logger.Debug (msg); + var res = request.GetResponse (_stream, millisecondsTimeout); - _logger.Debug ("A response to this request:\n" + res.ToString ()); + + msg = "An HTTP response from the server:\n" + res.ToString (); + + _logger.Debug (msg); return res; } From 2ddd277159c2f5110406654e771f35d840ae79a2 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 20 May 2022 19:10:32 +0900 Subject: [PATCH 4391/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 96b375eeb..ef0f43c48 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2179,13 +2179,14 @@ private HttpResponse sendHttpRequest ( // As server private bool sendHttpResponse (HttpResponse response) { - _logger.Debug ( - String.Format ( - "A response to {0}:\n{1}", _context.UserEndPoint, response - ) - ); + var fmt = "An HTTP response to {0}:\n{1}"; + var msg = String.Format (fmt, _context.UserEndPoint, response); + + _logger.Debug (msg); + + var bytes = response.ToByteArray (); - return sendBytes (response.ToByteArray ()); + return sendBytes (bytes); } // As client From aeb4a37797aa579a5962d5e0368eb37b5243d6d2 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 20 May 2022 19:15:29 +0900 Subject: [PATCH 4392/6294] [Modify] Add it --- websocket-sharp/HttpResponse.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/websocket-sharp/HttpResponse.cs b/websocket-sharp/HttpResponse.cs index 43234a9c1..c8ac65f07 100644 --- a/websocket-sharp/HttpResponse.cs +++ b/websocket-sharp/HttpResponse.cs @@ -63,6 +63,17 @@ internal HttpResponse (HttpStatusCode code) { } + internal HttpResponse (int code, string reason) + : this ( + code, + reason, + HttpVersion.Version11, + new NameValueCollection () + ) + { + Headers["Server"] = "websocket-sharp/1.0"; + } + internal HttpResponse (HttpStatusCode code, string reason) : this ( (int) code, From 38bcb48af63e7e40c8c680f570a87ec3ee50c813 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 20 May 2022 19:18:26 +0900 Subject: [PATCH 4393/6294] [Modify] Replace it --- websocket-sharp/HttpResponse.cs | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/websocket-sharp/HttpResponse.cs b/websocket-sharp/HttpResponse.cs index c8ac65f07..c41dbb40a 100644 --- a/websocket-sharp/HttpResponse.cs +++ b/websocket-sharp/HttpResponse.cs @@ -75,14 +75,8 @@ internal HttpResponse (int code, string reason) } internal HttpResponse (HttpStatusCode code, string reason) - : this ( - (int) code, - reason, - HttpVersion.Version11, - new NameValueCollection () - ) + : this ((int) code, reason) { - Headers["Server"] = "websocket-sharp/1.0"; } #endregion From 8d527acba893e94a889a306205157fd9aa3c3d62 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 20 May 2022 19:22:58 +0900 Subject: [PATCH 4394/6294] [Modify] Add it --- websocket-sharp/HttpResponse.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/websocket-sharp/HttpResponse.cs b/websocket-sharp/HttpResponse.cs index c41dbb40a..fde0a46c0 100644 --- a/websocket-sharp/HttpResponse.cs +++ b/websocket-sharp/HttpResponse.cs @@ -58,6 +58,11 @@ private HttpResponse ( #region Internal Constructors + internal HttpResponse (int code) + : this (code, code.GetStatusDescription ()) + { + } + internal HttpResponse (HttpStatusCode code) : this (code, code.GetDescription ()) { From ed7e0498266d26c297f0d706bdcc6d379929b745 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 21 May 2022 16:47:22 +0900 Subject: [PATCH 4395/6294] [Modify] Replace it --- websocket-sharp/HttpResponse.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/HttpResponse.cs b/websocket-sharp/HttpResponse.cs index fde0a46c0..ca1d852e0 100644 --- a/websocket-sharp/HttpResponse.cs +++ b/websocket-sharp/HttpResponse.cs @@ -64,7 +64,7 @@ internal HttpResponse (int code) } internal HttpResponse (HttpStatusCode code) - : this (code, code.GetDescription ()) + : this ((int) code) { } From 3fbbc1207b7698ce8662ca5032d4d3fc4eedfed2 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 22 May 2022 02:26:43 +0900 Subject: [PATCH 4396/6294] [Modify] Rename it --- websocket-sharp/HttpResponse.cs | 2 +- websocket-sharp/WebSocket.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/HttpResponse.cs b/websocket-sharp/HttpResponse.cs index ca1d852e0..2f8011692 100644 --- a/websocket-sharp/HttpResponse.cs +++ b/websocket-sharp/HttpResponse.cs @@ -168,7 +168,7 @@ internal static HttpResponse CreateUnauthorizedResponse (string challenge) return ret; } - internal static HttpResponse CreateWebSocketResponse () + internal static HttpResponse CreateWebSocketHandshakeResponse () { var ret = new HttpResponse (HttpStatusCode.SwitchingProtocols); diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index ef0f43c48..e73095d03 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1427,7 +1427,7 @@ private HttpRequest createHandshakeRequest () // As server private HttpResponse createHandshakeResponse () { - var ret = HttpResponse.CreateWebSocketResponse (); + var ret = HttpResponse.CreateWebSocketHandshakeResponse (); var headers = ret.Headers; From 91eb3d0cdafd88afdc73ecd4cf656c3d9a214cde Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 22 May 2022 21:15:03 +0900 Subject: [PATCH 4397/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index e73095d03..32cde0bc2 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -862,20 +862,16 @@ private bool accept () // As server private bool acceptHandshake () { - _logger.Debug ( - String.Format ( - "A handshake request from {0}:\n{1}", _context.UserEndPoint, _context - ) - ); + var fmt = "A handshake request from {0}:\n{1}"; + var msg = String.Format (fmt, _context.UserEndPoint, _context); + + _logger.Debug (msg); - string msg; if (!checkHandshakeRequest (_context, out msg)) { _logger.Error (msg); - refuseHandshake ( - CloseStatusCode.ProtocolError, - "A handshake error has occurred while attempting to accept." - ); + var reason = "A handshake error has occurred while attempting to accept."; + refuseHandshake (CloseStatusCode.ProtocolError, reason); return false; } @@ -883,10 +879,8 @@ private bool acceptHandshake () if (!customCheckHandshakeRequest (_context, out msg)) { _logger.Error (msg); - refuseHandshake ( - CloseStatusCode.PolicyViolation, - "A handshake error has occurred while attempting to accept." - ); + var reason = "A handshake error has occurred while attempting to accept."; + refuseHandshake (CloseStatusCode.PolicyViolation, reason); return false; } @@ -895,15 +889,19 @@ private bool acceptHandshake () if (_protocol != null) { var vals = _context.SecWebSocketProtocols; + processSecWebSocketProtocolClientHeader (vals); } if (!_ignoreExtensions) { var val = _context.Headers["Sec-WebSocket-Extensions"]; + processSecWebSocketExtensionsClientHeader (val); } - return sendHttpResponse (createHandshakeResponse ()); + var res = createHandshakeResponse (); + + return sendHttpResponse (res); } private bool canSet (out string message) From 72883629f4aaecb830eea481d54ab7d062b00298 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 23 May 2022 16:56:02 +0900 Subject: [PATCH 4398/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 32cde0bc2..f349b2f65 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1793,23 +1793,25 @@ private void processSecWebSocketExtensionsClientHeader (string value) return; var buff = new StringBuilder (80); + var comp = false; foreach (var elm in value.SplitHeaderValue (',')) { - var extension = elm.Trim (); - if (extension.Length == 0) + var ext = elm.Trim (); + + if (ext.Length == 0) continue; if (!comp) { - if (extension.IsCompressionExtension (CompressionMethod.Deflate)) { + if (ext.IsCompressionExtension (CompressionMethod.Deflate)) { _compression = CompressionMethod.Deflate; - buff.AppendFormat ( - "{0}, ", - _compression.ToExtensionString ( - "client_no_context_takeover", "server_no_context_takeover" - ) - ); + var str = _compression.ToExtensionString ( + "client_no_context_takeover", + "server_no_context_takeover" + ); + + buff.AppendFormat ("{0}, ", str); comp = true; } @@ -1817,10 +1819,12 @@ private void processSecWebSocketExtensionsClientHeader (string value) } var len = buff.Length; + if (len <= 2) return; buff.Length = len - 2; + _extensions = buff.ToString (); } From 49627f317dc5bac819156f854bf221f8e2e2561f Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 24 May 2022 20:18:33 +0900 Subject: [PATCH 4399/6294] [Modify] Rename it --- websocket-sharp/HttpRequest.cs | 2 +- websocket-sharp/WebSocket.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/HttpRequest.cs b/websocket-sharp/HttpRequest.cs index 5a3767577..c37afccf8 100644 --- a/websocket-sharp/HttpRequest.cs +++ b/websocket-sharp/HttpRequest.cs @@ -135,7 +135,7 @@ internal static HttpRequest CreateConnectRequest (Uri uri) return ret; } - internal static HttpRequest CreateWebSocketRequest (Uri uri) + internal static HttpRequest CreateWebSocketHandshakeRequest (Uri uri) { var ret = new HttpRequest ("GET", uri.PathAndQuery); diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index f349b2f65..4df913a9e 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1387,7 +1387,7 @@ private HttpResponse createHandshakeFailureResponse (HttpStatusCode code) // As client private HttpRequest createHandshakeRequest () { - var ret = HttpRequest.CreateWebSocketRequest (_uri); + var ret = HttpRequest.CreateWebSocketHandshakeRequest (_uri); var headers = ret.Headers; From 9e000882a70efd36d79f28ab71d0351760c916c0 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 24 May 2022 20:20:11 +0900 Subject: [PATCH 4400/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 4df913a9e..704ef0007 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1399,7 +1399,7 @@ private HttpRequest createHandshakeRequest () if (_protocols != null) { headers["Sec-WebSocket-Protocol"] = _protocols.ToString (", "); - + _protocolsRequested = true; } From 208ce64e6a890a9faf2f14e174946f87b02a067c Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 25 May 2022 19:37:01 +0900 Subject: [PATCH 4401/6294] [Modify] Rename it --- websocket-sharp/HttpRequest.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/HttpRequest.cs b/websocket-sharp/HttpRequest.cs index c37afccf8..9f7e22f59 100644 --- a/websocket-sharp/HttpRequest.cs +++ b/websocket-sharp/HttpRequest.cs @@ -122,10 +122,10 @@ public string RequestTarget { #region Internal Methods - internal static HttpRequest CreateConnectRequest (Uri uri) + internal static HttpRequest CreateConnectRequest (Uri targetUri) { - var host = uri.DnsSafeHost; - var port = uri.Port; + var host = targetUri.DnsSafeHost; + var port = targetUri.Port; var authority = String.Format ("{0}:{1}", host, port); var ret = new HttpRequest ("CONNECT", authority); From 58b8d0e2f5e21d8fab5f64be99e6c117e7a5b462 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 25 May 2022 19:39:25 +0900 Subject: [PATCH 4402/6294] [Modify] Rename it --- websocket-sharp/HttpRequest.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/HttpRequest.cs b/websocket-sharp/HttpRequest.cs index 9f7e22f59..847755047 100644 --- a/websocket-sharp/HttpRequest.cs +++ b/websocket-sharp/HttpRequest.cs @@ -135,18 +135,18 @@ internal static HttpRequest CreateConnectRequest (Uri targetUri) return ret; } - internal static HttpRequest CreateWebSocketHandshakeRequest (Uri uri) + internal static HttpRequest CreateWebSocketHandshakeRequest (Uri targetUri) { - var ret = new HttpRequest ("GET", uri.PathAndQuery); + var ret = new HttpRequest ("GET", targetUri.PathAndQuery); - var port = uri.Port; - var schm = uri.Scheme; + var port = targetUri.Port; + var schm = targetUri.Scheme; var defaultPort = (port == 80 && schm == "ws") || (port == 443 && schm == "wss"); var headers = ret.Headers; - headers["Host"] = !defaultPort ? uri.Authority : uri.DnsSafeHost; + headers["Host"] = !defaultPort ? targetUri.Authority : targetUri.DnsSafeHost; headers["Upgrade"] = "websocket"; headers["Connection"] = "Upgrade"; From f1e6e509a61757566176bf89f70b4ebf44db396f Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 26 May 2022 19:29:54 +0900 Subject: [PATCH 4403/6294] [Modify] Polish it --- websocket-sharp/HttpRequest.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/HttpRequest.cs b/websocket-sharp/HttpRequest.cs index 847755047..9f13ff624 100644 --- a/websocket-sharp/HttpRequest.cs +++ b/websocket-sharp/HttpRequest.cs @@ -139,14 +139,17 @@ internal static HttpRequest CreateWebSocketHandshakeRequest (Uri targetUri) { var ret = new HttpRequest ("GET", targetUri.PathAndQuery); + var headers = ret.Headers; + var port = targetUri.Port; var schm = targetUri.Scheme; var defaultPort = (port == 80 && schm == "ws") || (port == 443 && schm == "wss"); - var headers = ret.Headers; + headers["Host"] = !defaultPort + ? targetUri.Authority + : targetUri.DnsSafeHost; - headers["Host"] = !defaultPort ? targetUri.Authority : targetUri.DnsSafeHost; headers["Upgrade"] = "websocket"; headers["Connection"] = "Upgrade"; From 9d0f0eb259a32fcc17dae084ca30182137bdf0bb Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 26 May 2022 19:39:48 +0900 Subject: [PATCH 4404/6294] [Modify] Rename it --- websocket-sharp/HttpRequest.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/HttpRequest.cs b/websocket-sharp/HttpRequest.cs index 9f13ff624..8abba9a94 100644 --- a/websocket-sharp/HttpRequest.cs +++ b/websocket-sharp/HttpRequest.cs @@ -56,10 +56,10 @@ internal class HttpRequest : HttpBase private HttpRequest ( string method, string target, - Version protocolVersion, + Version version, NameValueCollection headers ) - : base (protocolVersion, headers) + : base (version, headers) { _method = method; _target = target; From 1baa573f22309bcb822ab2656f32641a11a1a06c Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 27 May 2022 19:51:55 +0900 Subject: [PATCH 4405/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 704ef0007..3b6619da8 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1833,6 +1833,7 @@ private void processSecWebSocketExtensionsServerHeader (string value) { if (value == null) { _compression = CompressionMethod.None; + return; } From 5539b38360cb89c822800918c307c31e6013d27f Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 27 May 2022 20:01:06 +0900 Subject: [PATCH 4406/6294] [Modify] Add it --- websocket-sharp/Ext.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index d5de3f4c2..04b0259e5 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1061,6 +1061,11 @@ internal static ulong ToUInt64 (this byte[] source, ByteOrder sourceOrder) return BitConverter.ToUInt64 (val, 0); } + internal static Version ToVersion (this string versionString) + { + return new Version (versionString); + } + internal static IEnumerable TrimEach ( this IEnumerable source ) From cc79345287b55e776c0419f53a7fdfd0441ed908 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 27 May 2022 20:05:16 +0900 Subject: [PATCH 4407/6294] [Modify] Replace it --- websocket-sharp/HttpRequest.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/websocket-sharp/HttpRequest.cs b/websocket-sharp/HttpRequest.cs index 8abba9a94..33d67732e 100644 --- a/websocket-sharp/HttpRequest.cs +++ b/websocket-sharp/HttpRequest.cs @@ -182,9 +182,7 @@ internal static HttpRequest Parse (string[] headerParts) var method = reqLineParts[0]; var target = reqLineParts[1]; - - var num = reqLineParts[2].Substring (5); - var ver = new Version (num); + var ver = reqLineParts[2].Substring (5).ToVersion (); var headers = new WebHeaderCollection (); From 477ad73d478e136b1e153ed5b2ffa88e22776556 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 27 May 2022 20:08:59 +0900 Subject: [PATCH 4408/6294] [Modify] Replace it --- websocket-sharp/HttpResponse.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/websocket-sharp/HttpResponse.cs b/websocket-sharp/HttpResponse.cs index 2f8011692..17b28388a 100644 --- a/websocket-sharp/HttpResponse.cs +++ b/websocket-sharp/HttpResponse.cs @@ -202,9 +202,7 @@ internal static HttpResponse Parse (string[] headerParts) var code = Int32.Parse (s); var reason = statusLineParts[2]; - - s = statusLineParts[0].Substring (5); - var ver = new Version (s); + var ver = statusLineParts[0].Substring (5).ToVersion (); var headers = new WebHeaderCollection (); From 2907a3928253091c43e2f84616bf4c1ade434dae Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 28 May 2022 21:25:37 +0900 Subject: [PATCH 4409/6294] [Modify] Add it --- websocket-sharp/Ext.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 04b0259e5..6d39410a0 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1010,6 +1010,11 @@ internal static string ToExtensionString ( return String.Format ("{0}; {1}", ename, eparams); } + internal static int ToInt32 (this string numericString) + { + return Int32.Parse (numericString); + } + internal static System.Net.IPAddress ToIPAddress (this string value) { if (value == null || value.Length == 0) From 23f187178d497670239fa6464068024b1d066e23 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 29 May 2022 21:11:47 +0900 Subject: [PATCH 4410/6294] [Modify] Replace it --- websocket-sharp/HttpResponse.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/websocket-sharp/HttpResponse.cs b/websocket-sharp/HttpResponse.cs index 17b28388a..99c0e423a 100644 --- a/websocket-sharp/HttpResponse.cs +++ b/websocket-sharp/HttpResponse.cs @@ -198,9 +198,7 @@ internal static HttpResponse Parse (string[] headerParts) throw new ArgumentException (msg); } - var s = statusLineParts[1]; - var code = Int32.Parse (s); - + var code = statusLineParts[1].ToInt32 (); var reason = statusLineParts[2]; var ver = statusLineParts[0].Substring (5).ToVersion (); From 4a231d3bc57b08686848bbce4b6d74ca8157e227 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 29 May 2022 21:16:09 +0900 Subject: [PATCH 4411/6294] [Modify] Rename it --- websocket-sharp/HttpBase.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/HttpBase.cs b/websocket-sharp/HttpBase.cs index 6e334d51a..ddb0070d7 100644 --- a/websocket-sharp/HttpBase.cs +++ b/websocket-sharp/HttpBase.cs @@ -71,9 +71,9 @@ static HttpBase () #region Protected Constructors - protected HttpBase (Version protocolVersion, NameValueCollection headers) + protected HttpBase (Version version, NameValueCollection headers) { - _protocolVersion = protocolVersion; + _protocolVersion = version; _headers = headers; } From 7f7b02dd67b0b9811c417e25664bddc68a17b248 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 30 May 2022 22:08:22 +0900 Subject: [PATCH 4412/6294] [Modify] Add it --- websocket-sharp/HttpBase.cs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/websocket-sharp/HttpBase.cs b/websocket-sharp/HttpBase.cs index ddb0070d7..006b68a13 100644 --- a/websocket-sharp/HttpBase.cs +++ b/websocket-sharp/HttpBase.cs @@ -89,6 +89,23 @@ internal byte[] EntityBodyData { #endregion + #region Protected Properties + + protected string HeaderSection { + get { + var buff = new StringBuilder (64); + + foreach (var key in _headers.AllKeys) + buff.AppendFormat ("{0}: {1}{2}", key, _headers[key], CrLf); + + buff.Append (CrLf); + + return buff.ToString (); + } + } + + #endregion + #region Public Properties public string EntityBody { From cfe83a66d260f1a5e854625e29e90f3d333c7d14 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 31 May 2022 19:55:22 +0900 Subject: [PATCH 4413/6294] [Modify] Add it --- websocket-sharp/HttpRequest.cs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/websocket-sharp/HttpRequest.cs b/websocket-sharp/HttpRequest.cs index 33d67732e..3f1bbb6be 100644 --- a/websocket-sharp/HttpRequest.cs +++ b/websocket-sharp/HttpRequest.cs @@ -77,6 +77,23 @@ internal HttpRequest (string method, string target) #endregion + #region Internal Properties + + internal string MessageHeader { + get { + var buff = new StringBuilder (64); + + var fmt = "{0} {1} HTTP/{2}{3}"; + buff.AppendFormat (fmt, _method, _target, ProtocolVersion, CrLf); + + buff.Append (HeaderSection); + + return buff.ToString (); + } + } + + #endregion + #region Public Properties public AuthenticationResponse AuthenticationResponse { From 49f60b835e18329b3be57aa46d869f17975ee5de Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 31 May 2022 19:59:27 +0900 Subject: [PATCH 4414/6294] [Modify] Add it --- websocket-sharp/HttpRequest.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/websocket-sharp/HttpRequest.cs b/websocket-sharp/HttpRequest.cs index 3f1bbb6be..141f68302 100644 --- a/websocket-sharp/HttpRequest.cs +++ b/websocket-sharp/HttpRequest.cs @@ -79,6 +79,14 @@ internal HttpRequest (string method, string target) #region Internal Properties + internal string RequestLine { + get { + var fmt = "{0} {1} HTTP/{2}{3}"; + + return String.Format (fmt, _method, _target, ProtocolVersion, CrLf); + } + } + internal string MessageHeader { get { var buff = new StringBuilder (64); From 9e6700647ec4e0e4420bcbe668aa6f37a6991dac Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 31 May 2022 20:02:10 +0900 Subject: [PATCH 4415/6294] [Modify] Replace it --- websocket-sharp/HttpRequest.cs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/websocket-sharp/HttpRequest.cs b/websocket-sharp/HttpRequest.cs index 141f68302..f7db9335f 100644 --- a/websocket-sharp/HttpRequest.cs +++ b/websocket-sharp/HttpRequest.cs @@ -91,10 +91,7 @@ internal string MessageHeader { get { var buff = new StringBuilder (64); - var fmt = "{0} {1} HTTP/{2}{3}"; - buff.AppendFormat (fmt, _method, _target, ProtocolVersion, CrLf); - - buff.Append (HeaderSection); + buff.Append (RequestLine).Append (HeaderSection); return buff.ToString (); } From d942dee82384a0787be3dacea3348aba251d4a0f Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 31 May 2022 20:06:38 +0900 Subject: [PATCH 4416/6294] [Modify] Replace it --- websocket-sharp/HttpRequest.cs | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/websocket-sharp/HttpRequest.cs b/websocket-sharp/HttpRequest.cs index f7db9335f..dd6472981 100644 --- a/websocket-sharp/HttpRequest.cs +++ b/websocket-sharp/HttpRequest.cs @@ -253,15 +253,7 @@ public override string ToString () { var buff = new StringBuilder (64); - var fmt = "{0} {1} HTTP/{2}{3}"; - buff.AppendFormat (fmt, _method, _target, ProtocolVersion, CrLf); - - var headers = Headers; - - foreach (var key in headers.AllKeys) - buff.AppendFormat ("{0}: {1}{2}", key, headers[key], CrLf); - - buff.Append (CrLf); + buff.Append (MessageHeader); var entity = EntityBody; From ff16be709cd56bd30a7baa47e7987d909d2a15ac Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 31 May 2022 20:12:30 +0900 Subject: [PATCH 4417/6294] [Modify] Add it --- websocket-sharp/HttpBase.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/websocket-sharp/HttpBase.cs b/websocket-sharp/HttpBase.cs index 006b68a13..b1956e8bb 100644 --- a/websocket-sharp/HttpBase.cs +++ b/websocket-sharp/HttpBase.cs @@ -117,6 +117,12 @@ public string EntityBody { } } + public bool HasEntityBody { + get { + return _entityBodyData != null; + } + } + public NameValueCollection Headers { get { return _headers; From 83fad38aaca76a4c109940c7793876b0ec308ad9 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 1 Jun 2022 19:24:15 +0900 Subject: [PATCH 4418/6294] [Modify] Replace it --- websocket-sharp/HttpRequest.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/HttpRequest.cs b/websocket-sharp/HttpRequest.cs index dd6472981..206d3c2fe 100644 --- a/websocket-sharp/HttpRequest.cs +++ b/websocket-sharp/HttpRequest.cs @@ -255,10 +255,8 @@ public override string ToString () buff.Append (MessageHeader); - var entity = EntityBody; - - if (entity.Length > 0) - buff.Append (entity); + if (HasEntityBody) + buff.Append (EntityBody); return buff.ToString (); } From 2dfe7b69faa3e741e8b07b1d52242857f1b4dc19 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 1 Jun 2022 19:32:16 +0900 Subject: [PATCH 4419/6294] [Modify] Polish it --- websocket-sharp/HttpRequest.cs | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/websocket-sharp/HttpRequest.cs b/websocket-sharp/HttpRequest.cs index 206d3c2fe..86f4ae5cf 100644 --- a/websocket-sharp/HttpRequest.cs +++ b/websocket-sharp/HttpRequest.cs @@ -251,14 +251,7 @@ public void SetCookies (CookieCollection cookies) public override string ToString () { - var buff = new StringBuilder (64); - - buff.Append (MessageHeader); - - if (HasEntityBody) - buff.Append (EntityBody); - - return buff.ToString (); + return HasEntityBody ? MessageHeader + EntityBody : MessageHeader; } #endregion From 8ba2bc277e4d6e18cb7ee5a61debbb8e6a1fda70 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 1 Jun 2022 19:36:19 +0900 Subject: [PATCH 4420/6294] [Modify] Polish it --- websocket-sharp/HttpRequest.cs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/websocket-sharp/HttpRequest.cs b/websocket-sharp/HttpRequest.cs index 86f4ae5cf..6805cf9d1 100644 --- a/websocket-sharp/HttpRequest.cs +++ b/websocket-sharp/HttpRequest.cs @@ -89,11 +89,7 @@ internal string RequestLine { internal string MessageHeader { get { - var buff = new StringBuilder (64); - - buff.Append (RequestLine).Append (HeaderSection); - - return buff.ToString (); + return RequestLine + HeaderSection; } } From af085729f30a4df5d571a5cb81206a45c50d7b90 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 1 Jun 2022 19:44:47 +0900 Subject: [PATCH 4421/6294] [Modify] Add it --- websocket-sharp/HttpResponse.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/websocket-sharp/HttpResponse.cs b/websocket-sharp/HttpResponse.cs index 99c0e423a..b03ac7809 100644 --- a/websocket-sharp/HttpResponse.cs +++ b/websocket-sharp/HttpResponse.cs @@ -86,6 +86,18 @@ internal HttpResponse (HttpStatusCode code, string reason) #endregion + #region Internal Properties + + internal string StatusLine { + get { + var fmt = "HTTP/{0} {1} {2}{3}"; + + return String.Format (fmt, ProtocolVersion, _code, _reason, CrLf); + } + } + + #endregion + #region Public Properties public bool CloseConnection { From 48d493b17f5ef77d05fd4f03b79fbd41e3d89749 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 1 Jun 2022 19:46:33 +0900 Subject: [PATCH 4422/6294] [Modify] Add it --- websocket-sharp/HttpResponse.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/websocket-sharp/HttpResponse.cs b/websocket-sharp/HttpResponse.cs index b03ac7809..ab32ef35c 100644 --- a/websocket-sharp/HttpResponse.cs +++ b/websocket-sharp/HttpResponse.cs @@ -96,6 +96,12 @@ internal string StatusLine { } } + internal string MessageHeader { + get { + return StatusLine + HeaderSection; + } + } + #endregion #region Public Properties From 037e484177d3ef7573f1de91c15338000e055eef Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 2 Jun 2022 20:00:03 +0900 Subject: [PATCH 4423/6294] [Modify] Replace it --- websocket-sharp/HttpResponse.cs | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) diff --git a/websocket-sharp/HttpResponse.cs b/websocket-sharp/HttpResponse.cs index ab32ef35c..3ee8bfd06 100644 --- a/websocket-sharp/HttpResponse.cs +++ b/websocket-sharp/HttpResponse.cs @@ -255,24 +255,7 @@ public void SetCookies (CookieCollection cookies) public override string ToString () { - var buff = new StringBuilder (64); - - var fmt = "HTTP/{0} {1} {2}{3}"; - buff.AppendFormat (fmt, ProtocolVersion, _code, _reason, CrLf); - - var headers = Headers; - - foreach (var key in headers.AllKeys) - buff.AppendFormat ("{0}: {1}{2}", key, headers[key], CrLf); - - buff.Append (CrLf); - - var entity = EntityBody; - - if (entity.Length > 0) - buff.Append (entity); - - return buff.ToString (); + return HasEntityBody ? MessageHeader + EntityBody : MessageHeader; } #endregion From fadbbdd9d513d3b268a0c70b5a6e2e444b2fdd9c Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 2 Jun 2022 20:04:23 +0900 Subject: [PATCH 4424/6294] [Modify] Rename it --- websocket-sharp/HttpBase.cs | 2 +- websocket-sharp/HttpRequest.cs | 2 +- websocket-sharp/HttpResponse.cs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/HttpBase.cs b/websocket-sharp/HttpBase.cs index b1956e8bb..848770175 100644 --- a/websocket-sharp/HttpBase.cs +++ b/websocket-sharp/HttpBase.cs @@ -108,7 +108,7 @@ protected string HeaderSection { #region Public Properties - public string EntityBody { + public string MessageBody { get { if (_entityBody == null) _entityBody = getEntityBody (); diff --git a/websocket-sharp/HttpRequest.cs b/websocket-sharp/HttpRequest.cs index 6805cf9d1..62b35856a 100644 --- a/websocket-sharp/HttpRequest.cs +++ b/websocket-sharp/HttpRequest.cs @@ -247,7 +247,7 @@ public void SetCookies (CookieCollection cookies) public override string ToString () { - return HasEntityBody ? MessageHeader + EntityBody : MessageHeader; + return HasEntityBody ? MessageHeader + MessageBody : MessageHeader; } #endregion diff --git a/websocket-sharp/HttpResponse.cs b/websocket-sharp/HttpResponse.cs index 3ee8bfd06..69e97c608 100644 --- a/websocket-sharp/HttpResponse.cs +++ b/websocket-sharp/HttpResponse.cs @@ -255,7 +255,7 @@ public void SetCookies (CookieCollection cookies) public override string ToString () { - return HasEntityBody ? MessageHeader + EntityBody : MessageHeader; + return HasEntityBody ? MessageHeader + MessageBody : MessageHeader; } #endregion From 08625bc25d2ab3de5ab53393870fd716aea77f5b Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 2 Jun 2022 20:07:29 +0900 Subject: [PATCH 4425/6294] [Modify] Rename it --- websocket-sharp/HttpBase.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/HttpBase.cs b/websocket-sharp/HttpBase.cs index 848770175..64c735ea1 100644 --- a/websocket-sharp/HttpBase.cs +++ b/websocket-sharp/HttpBase.cs @@ -40,7 +40,7 @@ internal abstract class HttpBase { #region Private Fields - private string _entityBody; + private string _messageBody; private byte[] _entityBodyData; private NameValueCollection _headers; private static readonly int _headersMaxLength; @@ -110,10 +110,10 @@ protected string HeaderSection { public string MessageBody { get { - if (_entityBody == null) - _entityBody = getEntityBody (); + if (_messageBody == null) + _messageBody = getEntityBody (); - return _entityBody; + return _messageBody; } } From 37d41c1a1c04779c1d71ea51622ca9307e4cc3af Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 2 Jun 2022 20:08:57 +0900 Subject: [PATCH 4426/6294] [Modify] Polish it --- websocket-sharp/HttpBase.cs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/websocket-sharp/HttpBase.cs b/websocket-sharp/HttpBase.cs index 64c735ea1..a0085e446 100644 --- a/websocket-sharp/HttpBase.cs +++ b/websocket-sharp/HttpBase.cs @@ -108,15 +108,6 @@ protected string HeaderSection { #region Public Properties - public string MessageBody { - get { - if (_messageBody == null) - _messageBody = getEntityBody (); - - return _messageBody; - } - } - public bool HasEntityBody { get { return _entityBodyData != null; @@ -129,6 +120,15 @@ public NameValueCollection Headers { } } + public string MessageBody { + get { + if (_messageBody == null) + _messageBody = getEntityBody (); + + return _messageBody; + } + } + public Version ProtocolVersion { get { return _protocolVersion; From 3f61203d889b3abe0e87d19f0f34213e332e5419 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 2 Jun 2022 20:10:30 +0900 Subject: [PATCH 4427/6294] [Modify] Rename it --- websocket-sharp/HttpBase.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/HttpBase.cs b/websocket-sharp/HttpBase.cs index a0085e446..9208cb626 100644 --- a/websocket-sharp/HttpBase.cs +++ b/websocket-sharp/HttpBase.cs @@ -81,7 +81,7 @@ protected HttpBase (Version version, NameValueCollection headers) #region Internal Properties - internal byte[] EntityBodyData { + internal byte[] MessageBodyData { get { return _entityBodyData; } From 098b18e885d475a75daa6cb9d54d11e89aaaf257 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 2 Jun 2022 20:12:23 +0900 Subject: [PATCH 4428/6294] [Modify] Rename it --- websocket-sharp/HttpBase.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/HttpBase.cs b/websocket-sharp/HttpBase.cs index 9208cb626..0c5c05595 100644 --- a/websocket-sharp/HttpBase.cs +++ b/websocket-sharp/HttpBase.cs @@ -41,7 +41,7 @@ internal abstract class HttpBase #region Private Fields private string _messageBody; - private byte[] _entityBodyData; + private byte[] _messageBodyData; private NameValueCollection _headers; private static readonly int _headersMaxLength; private Version _protocolVersion; @@ -83,7 +83,7 @@ protected HttpBase (Version version, NameValueCollection headers) internal byte[] MessageBodyData { get { - return _entityBodyData; + return _messageBodyData; } } @@ -110,7 +110,7 @@ protected string HeaderSection { public bool HasEntityBody { get { - return _entityBodyData != null; + return _messageBodyData != null; } } @@ -141,7 +141,7 @@ public Version ProtocolVersion { private string getEntityBody () { - if (_entityBodyData == null || _entityBodyData.LongLength == 0) + if (_messageBodyData == null || _messageBodyData.LongLength == 0) return String.Empty; var contentType = _headers["Content-Type"]; @@ -150,7 +150,7 @@ private string getEntityBody () ? HttpUtility.GetEncoding (contentType) : Encoding.UTF8; - return enc.GetString (_entityBodyData); + return enc.GetString (_messageBodyData); } private static byte[] readEntityBodyFrom (Stream stream, string length) @@ -248,7 +248,7 @@ protected static T Read ( var contentLen = ret.Headers["Content-Length"]; if (contentLen != null && contentLen.Length > 0) - ret._entityBodyData = readEntityBodyFrom (stream, contentLen); + ret._messageBodyData = readEntityBodyFrom (stream, contentLen); } catch (Exception ex) { exception = ex; From c6a03b1f12718d997ab46543eb996f06e0054e3f Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 2 Jun 2022 20:13:12 +0900 Subject: [PATCH 4429/6294] [Modify] Polish it --- websocket-sharp/HttpBase.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/HttpBase.cs b/websocket-sharp/HttpBase.cs index 0c5c05595..5cbd22485 100644 --- a/websocket-sharp/HttpBase.cs +++ b/websocket-sharp/HttpBase.cs @@ -40,10 +40,10 @@ internal abstract class HttpBase { #region Private Fields - private string _messageBody; - private byte[] _messageBodyData; private NameValueCollection _headers; private static readonly int _headersMaxLength; + private string _messageBody; + private byte[] _messageBodyData; private Version _protocolVersion; #endregion From 506840d2d6b5d314c89ef7427d7481509932e5f2 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 2 Jun 2022 20:15:20 +0900 Subject: [PATCH 4430/6294] [Modify] Rename it --- websocket-sharp/HttpBase.cs | 2 +- websocket-sharp/HttpRequest.cs | 2 +- websocket-sharp/HttpResponse.cs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/HttpBase.cs b/websocket-sharp/HttpBase.cs index 5cbd22485..90a811f3b 100644 --- a/websocket-sharp/HttpBase.cs +++ b/websocket-sharp/HttpBase.cs @@ -108,7 +108,7 @@ protected string HeaderSection { #region Public Properties - public bool HasEntityBody { + public bool HasMessageBody { get { return _messageBodyData != null; } diff --git a/websocket-sharp/HttpRequest.cs b/websocket-sharp/HttpRequest.cs index 62b35856a..ca0937b19 100644 --- a/websocket-sharp/HttpRequest.cs +++ b/websocket-sharp/HttpRequest.cs @@ -247,7 +247,7 @@ public void SetCookies (CookieCollection cookies) public override string ToString () { - return HasEntityBody ? MessageHeader + MessageBody : MessageHeader; + return HasMessageBody ? MessageHeader + MessageBody : MessageHeader; } #endregion diff --git a/websocket-sharp/HttpResponse.cs b/websocket-sharp/HttpResponse.cs index 69e97c608..d2384f90c 100644 --- a/websocket-sharp/HttpResponse.cs +++ b/websocket-sharp/HttpResponse.cs @@ -255,7 +255,7 @@ public void SetCookies (CookieCollection cookies) public override string ToString () { - return HasEntityBody ? MessageHeader + MessageBody : MessageHeader; + return HasMessageBody ? MessageHeader + MessageBody : MessageHeader; } #endregion From 5284444af197547068a3d9a0e4d280aff99b15dc Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 2 Jun 2022 20:18:42 +0900 Subject: [PATCH 4431/6294] [Modify] Rename it --- websocket-sharp/HttpBase.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/HttpBase.cs b/websocket-sharp/HttpBase.cs index 90a811f3b..355d91802 100644 --- a/websocket-sharp/HttpBase.cs +++ b/websocket-sharp/HttpBase.cs @@ -123,7 +123,7 @@ public NameValueCollection Headers { public string MessageBody { get { if (_messageBody == null) - _messageBody = getEntityBody (); + _messageBody = getMessageBody (); return _messageBody; } @@ -139,7 +139,7 @@ public Version ProtocolVersion { #region Private Methods - private string getEntityBody () + private string getMessageBody () { if (_messageBodyData == null || _messageBodyData.LongLength == 0) return String.Empty; From bf5b7c5344822d4f7ae0096ee9a8880c05241935 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 2 Jun 2022 20:22:43 +0900 Subject: [PATCH 4432/6294] [Modify] Rename it --- websocket-sharp/HttpBase.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/HttpBase.cs b/websocket-sharp/HttpBase.cs index 355d91802..4b44e7060 100644 --- a/websocket-sharp/HttpBase.cs +++ b/websocket-sharp/HttpBase.cs @@ -153,7 +153,7 @@ private string getMessageBody () return enc.GetString (_messageBodyData); } - private static byte[] readEntityBodyFrom (Stream stream, string length) + private static byte[] readMessageBodyFrom (Stream stream, string length) { long len; @@ -248,7 +248,7 @@ protected static T Read ( var contentLen = ret.Headers["Content-Length"]; if (contentLen != null && contentLen.Length > 0) - ret._messageBodyData = readEntityBodyFrom (stream, contentLen); + ret._messageBodyData = readMessageBodyFrom (stream, contentLen); } catch (Exception ex) { exception = ex; From 226fc5f1775480b0a04820d5cc7b4d383dbe449c Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 2 Jun 2022 20:24:38 +0900 Subject: [PATCH 4433/6294] [Modify] Rename it --- websocket-sharp/HttpBase.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/HttpBase.cs b/websocket-sharp/HttpBase.cs index 4b44e7060..9a58710f4 100644 --- a/websocket-sharp/HttpBase.cs +++ b/websocket-sharp/HttpBase.cs @@ -176,7 +176,7 @@ private static byte[] readMessageBodyFrom (Stream stream, string length) : null; } - private static string[] readHeadersFrom (Stream stream) + private static string[] readMessageHeaderFrom (Stream stream) { var buff = new List (); var cnt = 0; @@ -242,7 +242,7 @@ protected static T Read ( Exception exception = null; try { - var headers = readHeadersFrom (stream); + var headers = readMessageHeaderFrom (stream); ret = parser (headers); var contentLen = ret.Headers["Content-Length"]; From e10f8df909ee3668898833f5e6412267d45e6077 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 2 Jun 2022 20:28:12 +0900 Subject: [PATCH 4434/6294] [Modify] Polish it --- websocket-sharp/HttpBase.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/HttpBase.cs b/websocket-sharp/HttpBase.cs index 9a58710f4..4b2df192b 100644 --- a/websocket-sharp/HttpBase.cs +++ b/websocket-sharp/HttpBase.cs @@ -242,8 +242,8 @@ protected static T Read ( Exception exception = null; try { - var headers = readMessageHeaderFrom (stream); - ret = parser (headers); + var header = readMessageHeaderFrom (stream); + ret = parser (header); var contentLen = ret.Headers["Content-Length"]; From d2f5de8cbf19e807127a65e41e89eb2e3c298a69 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 3 Jun 2022 19:35:32 +0900 Subject: [PATCH 4435/6294] [Modify] Rename it --- websocket-sharp/HttpRequest.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/HttpRequest.cs b/websocket-sharp/HttpRequest.cs index ca0937b19..64e37891f 100644 --- a/websocket-sharp/HttpRequest.cs +++ b/websocket-sharp/HttpRequest.cs @@ -182,15 +182,15 @@ internal HttpResponse GetResponse (Stream stream, int millisecondsTimeout) return HttpResponse.ReadResponse (stream, millisecondsTimeout); } - internal static HttpRequest Parse (string[] headerParts) + internal static HttpRequest Parse (string[] messageHeader) { - if (headerParts.Length == 0) { + if (messageHeader.Length == 0) { var msg = "An empty request has been received."; throw new ArgumentException (msg); } - var reqLineParts = headerParts[0].Split (new[] { ' ' }, 3); + var reqLineParts = messageHeader[0].Split (new[] { ' ' }, 3); if (reqLineParts.Length != 3) { var msg = "It includes an invalid request line."; @@ -204,8 +204,8 @@ internal static HttpRequest Parse (string[] headerParts) var headers = new WebHeaderCollection (); - for (var i = 1; i < headerParts.Length; i++) - headers.InternalSet (headerParts[i], false); + for (var i = 1; i < messageHeader.Length; i++) + headers.InternalSet (messageHeader[i], false); return new HttpRequest (method, target, ver, headers); } From bc051f897bd22f97997a04747017b21fa2d63f28 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 3 Jun 2022 19:42:04 +0900 Subject: [PATCH 4436/6294] [Modify] Rename it --- websocket-sharp/HttpResponse.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/HttpResponse.cs b/websocket-sharp/HttpResponse.cs index d2384f90c..3f64c9299 100644 --- a/websocket-sharp/HttpResponse.cs +++ b/websocket-sharp/HttpResponse.cs @@ -198,9 +198,9 @@ internal static HttpResponse CreateWebSocketHandshakeResponse () return ret; } - internal static HttpResponse Parse (string[] headerParts) + internal static HttpResponse Parse (string[] messageHeader) { - var len = headerParts.Length; + var len = messageHeader.Length; if (len == 0) { var msg = "An empty response has been received."; @@ -208,7 +208,7 @@ internal static HttpResponse Parse (string[] headerParts) throw new ArgumentException (msg); } - var statusLineParts = headerParts[0].Split (new[] { ' ' }, 3); + var statusLineParts = messageHeader[0].Split (new[] { ' ' }, 3); if (statusLineParts.Length != 3) { var msg = "It includes an invalid status line."; @@ -223,7 +223,7 @@ internal static HttpResponse Parse (string[] headerParts) var headers = new WebHeaderCollection (); for (var i = 1; i < len; i++) - headers.InternalSet (headerParts[i], true); + headers.InternalSet (messageHeader[i], true); return new HttpResponse (code, reason, ver, headers); } From 6ac9138efe5ec5499c364a641d78ca5c08feeff2 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 4 Jun 2022 21:34:01 +0900 Subject: [PATCH 4437/6294] [Modify] Polish it --- websocket-sharp/HttpRequest.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/HttpRequest.cs b/websocket-sharp/HttpRequest.cs index 64e37891f..730bc9bdc 100644 --- a/websocket-sharp/HttpRequest.cs +++ b/websocket-sharp/HttpRequest.cs @@ -184,7 +184,9 @@ internal HttpResponse GetResponse (Stream stream, int millisecondsTimeout) internal static HttpRequest Parse (string[] messageHeader) { - if (messageHeader.Length == 0) { + var len = messageHeader.Length; + + if (len == 0) { var msg = "An empty request has been received."; throw new ArgumentException (msg); @@ -204,7 +206,7 @@ internal static HttpRequest Parse (string[] messageHeader) var headers = new WebHeaderCollection (); - for (var i = 1; i < messageHeader.Length; i++) + for (var i = 1; i < len; i++) headers.InternalSet (messageHeader[i], false); return new HttpRequest (method, target, ver, headers); From 66323fccc57c88838d50bdda8bb78a5fcece4499 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 5 Jun 2022 22:19:56 +0900 Subject: [PATCH 4438/6294] [Modify] Polish it --- websocket-sharp/HttpRequest.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/HttpRequest.cs b/websocket-sharp/HttpRequest.cs index 730bc9bdc..4b887579e 100644 --- a/websocket-sharp/HttpRequest.cs +++ b/websocket-sharp/HttpRequest.cs @@ -192,17 +192,17 @@ internal static HttpRequest Parse (string[] messageHeader) throw new ArgumentException (msg); } - var reqLineParts = messageHeader[0].Split (new[] { ' ' }, 3); + var rlParts = messageHeader[0].Split (new[] { ' ' }, 3); - if (reqLineParts.Length != 3) { + if (rlParts.Length != 3) { var msg = "It includes an invalid request line."; throw new ArgumentException (msg); } - var method = reqLineParts[0]; - var target = reqLineParts[1]; - var ver = reqLineParts[2].Substring (5).ToVersion (); + var method = rlParts[0]; + var target = rlParts[1]; + var ver = rlParts[2].Substring (5).ToVersion (); var headers = new WebHeaderCollection (); From cf28e113c91150b090b7247bc9cbaafb33260026 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 5 Jun 2022 22:22:11 +0900 Subject: [PATCH 4439/6294] [Modify] Polish it --- websocket-sharp/HttpResponse.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/HttpResponse.cs b/websocket-sharp/HttpResponse.cs index 3f64c9299..c3d68e9e1 100644 --- a/websocket-sharp/HttpResponse.cs +++ b/websocket-sharp/HttpResponse.cs @@ -208,17 +208,17 @@ internal static HttpResponse Parse (string[] messageHeader) throw new ArgumentException (msg); } - var statusLineParts = messageHeader[0].Split (new[] { ' ' }, 3); + var slParts = messageHeader[0].Split (new[] { ' ' }, 3); - if (statusLineParts.Length != 3) { + if (slParts.Length != 3) { var msg = "It includes an invalid status line."; throw new ArgumentException (msg); } - var code = statusLineParts[1].ToInt32 (); - var reason = statusLineParts[2]; - var ver = statusLineParts[0].Substring (5).ToVersion (); + var code = slParts[1].ToInt32 (); + var reason = slParts[2]; + var ver = slParts[0].Substring (5).ToVersion (); var headers = new WebHeaderCollection (); From 580380936654ada34b683c4e293d7988be73630d Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 6 Jun 2022 21:04:18 +0900 Subject: [PATCH 4440/6294] [Modify] For a status line without the reason phrase --- websocket-sharp/HttpResponse.cs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/HttpResponse.cs b/websocket-sharp/HttpResponse.cs index c3d68e9e1..f39af2099 100644 --- a/websocket-sharp/HttpResponse.cs +++ b/websocket-sharp/HttpResponse.cs @@ -90,9 +90,13 @@ internal HttpResponse (HttpStatusCode code, string reason) internal string StatusLine { get { - var fmt = "HTTP/{0} {1} {2}{3}"; - - return String.Format (fmt, ProtocolVersion, _code, _reason, CrLf); + return _reason != null + ? String.Format ( + "HTTP/{0} {1} {2}{3}", ProtocolVersion, _code, _reason, CrLf + ) + : String.Format ( + "HTTP/{0} {1}{2}", ProtocolVersion, _code, CrLf + ); } } @@ -209,15 +213,16 @@ internal static HttpResponse Parse (string[] messageHeader) } var slParts = messageHeader[0].Split (new[] { ' ' }, 3); + var plen = slParts.Length; - if (slParts.Length != 3) { + if (plen < 2) { var msg = "It includes an invalid status line."; throw new ArgumentException (msg); } var code = slParts[1].ToInt32 (); - var reason = slParts[2]; + var reason = plen == 3 ? slParts[2] : null; var ver = slParts[0].Substring (5).ToVersion (); var headers = new WebHeaderCollection (); From 72e801cd7883d567a238cc751dc3983e98b072cd Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 7 Jun 2022 19:50:06 +0900 Subject: [PATCH 4441/6294] [Modify] Polish it --- websocket-sharp/HttpRequest.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/HttpRequest.cs b/websocket-sharp/HttpRequest.cs index 4b887579e..bb46ade97 100644 --- a/websocket-sharp/HttpRequest.cs +++ b/websocket-sharp/HttpRequest.cs @@ -81,9 +81,9 @@ internal HttpRequest (string method, string target) internal string RequestLine { get { - var fmt = "{0} {1} HTTP/{2}{3}"; - - return String.Format (fmt, _method, _target, ProtocolVersion, CrLf); + return String.Format ( + "{0} {1} HTTP/{2}{3}", _method, _target, ProtocolVersion, CrLf + ); } } From 861569087b86d342fb79dbc879ae09225afc0105 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 7 Jun 2022 20:01:27 +0900 Subject: [PATCH 4442/6294] [Modify] Override it --- websocket-sharp/HttpBase.cs | 2 ++ websocket-sharp/HttpRequest.cs | 12 ++++++------ websocket-sharp/HttpResponse.cs | 12 ++++++------ 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/websocket-sharp/HttpBase.cs b/websocket-sharp/HttpBase.cs index 4b2df192b..db8dc245b 100644 --- a/websocket-sharp/HttpBase.cs +++ b/websocket-sharp/HttpBase.cs @@ -129,6 +129,8 @@ public string MessageBody { } } + public abstract string MessageHeader { get; } + public Version ProtocolVersion { get { return _protocolVersion; diff --git a/websocket-sharp/HttpRequest.cs b/websocket-sharp/HttpRequest.cs index bb46ade97..88e9d7399 100644 --- a/websocket-sharp/HttpRequest.cs +++ b/websocket-sharp/HttpRequest.cs @@ -87,12 +87,6 @@ internal string RequestLine { } } - internal string MessageHeader { - get { - return RequestLine + HeaderSection; - } - } - #endregion #region Public Properties @@ -130,6 +124,12 @@ public bool IsWebSocketRequest { } } + public override string MessageHeader { + get { + return RequestLine + HeaderSection; + } + } + public string RequestTarget { get { return _target; diff --git a/websocket-sharp/HttpResponse.cs b/websocket-sharp/HttpResponse.cs index f39af2099..2604bc20b 100644 --- a/websocket-sharp/HttpResponse.cs +++ b/websocket-sharp/HttpResponse.cs @@ -100,12 +100,6 @@ internal string StatusLine { } } - internal string MessageHeader { - get { - return StatusLine + HeaderSection; - } - } - #endregion #region Public Properties @@ -156,6 +150,12 @@ public bool IsWebSocketResponse { } } + public override string MessageHeader { + get { + return StatusLine + HeaderSection; + } + } + public string Reason { get { return _reason; From 9f1fae2df1bd58ce6fd468152977dd8797f2b6f0 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 8 Jun 2022 20:04:41 +0900 Subject: [PATCH 4443/6294] [Modify] Move it --- websocket-sharp/HttpBase.cs | 9 ++++++++- websocket-sharp/HttpRequest.cs | 5 ----- websocket-sharp/HttpResponse.cs | 5 ----- 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/websocket-sharp/HttpBase.cs b/websocket-sharp/HttpBase.cs index db8dc245b..85f7b572a 100644 --- a/websocket-sharp/HttpBase.cs +++ b/websocket-sharp/HttpBase.cs @@ -285,7 +285,14 @@ public byte[] ToByteArray () return Encoding.UTF8.GetBytes (s); } - + + public override string ToString () + { + return _messageBodyData != null + ? MessageHeader + MessageBody + : MessageHeader; + } + #endregion } } diff --git a/websocket-sharp/HttpRequest.cs b/websocket-sharp/HttpRequest.cs index 88e9d7399..664c54972 100644 --- a/websocket-sharp/HttpRequest.cs +++ b/websocket-sharp/HttpRequest.cs @@ -247,11 +247,6 @@ public void SetCookies (CookieCollection cookies) Headers["Cookie"] = buff.ToString (); } - public override string ToString () - { - return HasMessageBody ? MessageHeader + MessageBody : MessageHeader; - } - #endregion } } diff --git a/websocket-sharp/HttpResponse.cs b/websocket-sharp/HttpResponse.cs index 2604bc20b..95daa44f4 100644 --- a/websocket-sharp/HttpResponse.cs +++ b/websocket-sharp/HttpResponse.cs @@ -258,11 +258,6 @@ public void SetCookies (CookieCollection cookies) } } - public override string ToString () - { - return HasMessageBody ? MessageHeader + MessageBody : MessageHeader; - } - #endregion } } From 23db3218e3c94ccbcb2acd2eb7a7235f9774ea05 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 9 Jun 2022 19:53:52 +0900 Subject: [PATCH 4444/6294] [Modify] Replace it --- websocket-sharp/HttpBase.cs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/HttpBase.cs b/websocket-sharp/HttpBase.cs index 85f7b572a..68a0ea0a1 100644 --- a/websocket-sharp/HttpBase.cs +++ b/websocket-sharp/HttpBase.cs @@ -281,9 +281,18 @@ protected static T Read ( public byte[] ToByteArray () { - var s = ToString (); + var headerData = Encoding.UTF8.GetBytes (MessageHeader); - return Encoding.UTF8.GetBytes (s); + if (_messageBodyData == null) + return headerData; + + var buff = new MemoryStream (); + + buff.Write (headerData, 0, headerData.Length); + buff.WriteBytes (_messageBodyData, 1024); + buff.Close (); + + return buff.ToArray (); } public override string ToString () From 16826efbaefbda00965ac1349ce383c6e03447f2 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 10 Jun 2022 19:48:49 +0900 Subject: [PATCH 4445/6294] [Modify] Rename it --- websocket-sharp/HttpBase.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/HttpBase.cs b/websocket-sharp/HttpBase.cs index 68a0ea0a1..435d8cca0 100644 --- a/websocket-sharp/HttpBase.cs +++ b/websocket-sharp/HttpBase.cs @@ -41,7 +41,7 @@ internal abstract class HttpBase #region Private Fields private NameValueCollection _headers; - private static readonly int _headersMaxLength; + private static readonly int _maxMessageHeaderLength; private string _messageBody; private byte[] _messageBodyData; private Version _protocolVersion; @@ -60,7 +60,7 @@ internal abstract class HttpBase static HttpBase () { - _headersMaxLength = 8192; + _maxMessageHeaderLength = 8192; CrLf = "\r\n"; CrLfHt = "\r\n\t"; @@ -201,7 +201,7 @@ private static string[] readMessageHeaderFrom (Stream stream) && stream.ReadByte ().IsEqualTo ('\r', add) && stream.ReadByte ().IsEqualTo ('\n', add); - if (cnt > _headersMaxLength) { + if (cnt > _maxMessageHeaderLength) { var msg = "The length of the headers is greater than the max length."; throw new InvalidOperationException (msg); From 221611975867e9b94ac71c316d7a4957dc9a2cb7 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 11 Jun 2022 21:28:32 +0900 Subject: [PATCH 4446/6294] [Modify] Polish it --- websocket-sharp/HttpBase.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/HttpBase.cs b/websocket-sharp/HttpBase.cs index 435d8cca0..c00c05559 100644 --- a/websocket-sharp/HttpBase.cs +++ b/websocket-sharp/HttpBase.cs @@ -185,7 +185,7 @@ private static string[] readMessageHeaderFrom (Stream stream) Action add = i => { if (i == -1) { - var msg = "The headers could not be read from the data stream."; + var msg = "The header could not be read from the data stream."; throw new EndOfStreamException (msg); } @@ -202,7 +202,7 @@ private static string[] readMessageHeaderFrom (Stream stream) && stream.ReadByte ().IsEqualTo ('\n', add); if (cnt > _maxMessageHeaderLength) { - var msg = "The length of the headers is greater than the max length."; + var msg = "The length of the header is greater than the max length."; throw new InvalidOperationException (msg); } From 25690710272f48a3aa5b9dba2f17e6baf9b81f86 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 12 Jun 2022 21:46:51 +0900 Subject: [PATCH 4447/6294] [Modify] Replace it --- websocket-sharp/HttpBase.cs | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/websocket-sharp/HttpBase.cs b/websocket-sharp/HttpBase.cs index c00c05559..9b52db95a 100644 --- a/websocket-sharp/HttpBase.cs +++ b/websocket-sharp/HttpBase.cs @@ -30,6 +30,7 @@ using System.Collections.Generic; using System.Collections.Specialized; using System.IO; +using System.Linq; using System.Text; using System.Threading; using WebSocketSharp.Net; @@ -283,16 +284,9 @@ public byte[] ToByteArray () { var headerData = Encoding.UTF8.GetBytes (MessageHeader); - if (_messageBodyData == null) - return headerData; - - var buff = new MemoryStream (); - - buff.Write (headerData, 0, headerData.Length); - buff.WriteBytes (_messageBodyData, 1024); - buff.Close (); - - return buff.ToArray (); + return _messageBodyData != null + ? headerData.Concat (_messageBodyData).ToArray () + : headerData; } public override string ToString () From cd081fad77d5162b1a95002a3a5adf9e694d61ee Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 13 Jun 2022 21:28:08 +0900 Subject: [PATCH 4448/6294] [Modify] Polish it --- websocket-sharp/HttpBase.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/HttpBase.cs b/websocket-sharp/HttpBase.cs index 9b52db95a..6ada662cc 100644 --- a/websocket-sharp/HttpBase.cs +++ b/websocket-sharp/HttpBase.cs @@ -262,13 +262,13 @@ protected static T Read ( } if (timeout) { - var msg = "A timeout has occurred while reading an HTTP request or response."; + var msg = "A timeout has occurred."; throw new WebSocketException (msg); } if (exception != null) { - var msg = "An exception has occurred while reading an HTTP request or response."; + var msg = "An exception has occurred."; throw new WebSocketException (msg, exception); } From 6a55028a0bbecebb92164676b9d8665639e1d6e5 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 14 Jun 2022 19:35:50 +0900 Subject: [PATCH 4449/6294] [Modify] Polish it --- websocket-sharp/HttpBase.cs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/websocket-sharp/HttpBase.cs b/websocket-sharp/HttpBase.cs index 6ada662cc..2fd7886e3 100644 --- a/websocket-sharp/HttpBase.cs +++ b/websocket-sharp/HttpBase.cs @@ -196,21 +196,21 @@ private static string[] readMessageHeaderFrom (Stream stream) cnt++; }; - while (true) { - var end = stream.ReadByte ().IsEqualTo ('\r', add) - && stream.ReadByte ().IsEqualTo ('\n', add) - && stream.ReadByte ().IsEqualTo ('\r', add) - && stream.ReadByte ().IsEqualTo ('\n', add); + var end = false; + + do { + end = stream.ReadByte ().IsEqualTo ('\r', add) + && stream.ReadByte ().IsEqualTo ('\n', add) + && stream.ReadByte ().IsEqualTo ('\r', add) + && stream.ReadByte ().IsEqualTo ('\n', add); if (cnt > _maxMessageHeaderLength) { var msg = "The length of the header is greater than the max length."; throw new InvalidOperationException (msg); } - - if (end) - break; } + while (!end); var bytes = buff.ToArray (); From 3f1d9c84246f63e4b65222baed1bc350cbde48fa Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 14 Jun 2022 19:38:45 +0900 Subject: [PATCH 4450/6294] [Modify] Rename it --- websocket-sharp/HttpBase.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/HttpBase.cs b/websocket-sharp/HttpBase.cs index 2fd7886e3..e386ecc84 100644 --- a/websocket-sharp/HttpBase.cs +++ b/websocket-sharp/HttpBase.cs @@ -45,7 +45,7 @@ internal abstract class HttpBase private static readonly int _maxMessageHeaderLength; private string _messageBody; private byte[] _messageBodyData; - private Version _protocolVersion; + private Version _version; #endregion @@ -74,7 +74,7 @@ static HttpBase () protected HttpBase (Version version, NameValueCollection headers) { - _protocolVersion = version; + _version = version; _headers = headers; } @@ -134,7 +134,7 @@ public string MessageBody { public Version ProtocolVersion { get { - return _protocolVersion; + return _version; } } From 036d181db71566ccebdbea6cf8acc3f97d196c81 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 15 Jun 2022 19:09:11 +0900 Subject: [PATCH 4451/6294] [Modify] Polish it --- websocket-sharp/HttpRequest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/HttpRequest.cs b/websocket-sharp/HttpRequest.cs index 664c54972..0a24507f1 100644 --- a/websocket-sharp/HttpRequest.cs +++ b/websocket-sharp/HttpRequest.cs @@ -187,7 +187,7 @@ internal static HttpRequest Parse (string[] messageHeader) var len = messageHeader.Length; if (len == 0) { - var msg = "An empty request has been received."; + var msg = "An empty request header."; throw new ArgumentException (msg); } From 087a1fd082e806d09087cc2475406f4c5ab006c9 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 16 Jun 2022 19:25:47 +0900 Subject: [PATCH 4452/6294] [Modify] 2022 --- websocket-sharp/HttpRequest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/HttpRequest.cs b/websocket-sharp/HttpRequest.cs index 0a24507f1..8e68b144f 100644 --- a/websocket-sharp/HttpRequest.cs +++ b/websocket-sharp/HttpRequest.cs @@ -4,7 +4,7 @@ * * The MIT License * - * Copyright (c) 2012-2015 sta.blockhead + * Copyright (c) 2012-2022 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From fe7c5f9d0169268966284a994827a56f77e36a71 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 16 Jun 2022 19:28:24 +0900 Subject: [PATCH 4453/6294] [Modify] Polish it --- websocket-sharp/HttpResponse.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/HttpResponse.cs b/websocket-sharp/HttpResponse.cs index 95daa44f4..851898ac7 100644 --- a/websocket-sharp/HttpResponse.cs +++ b/websocket-sharp/HttpResponse.cs @@ -207,7 +207,7 @@ internal static HttpResponse Parse (string[] messageHeader) var len = messageHeader.Length; if (len == 0) { - var msg = "An empty response has been received."; + var msg = "An empty response header."; throw new ArgumentException (msg); } From 9f3df4f7501fffbd6525341168cd8efc0249649e Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 17 Jun 2022 19:35:14 +0900 Subject: [PATCH 4454/6294] [Modify] 2022 --- websocket-sharp/HttpResponse.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/HttpResponse.cs b/websocket-sharp/HttpResponse.cs index 851898ac7..00dccf53f 100644 --- a/websocket-sharp/HttpResponse.cs +++ b/websocket-sharp/HttpResponse.cs @@ -4,7 +4,7 @@ * * The MIT License * - * Copyright (c) 2012-2014 sta.blockhead + * Copyright (c) 2012-2022 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From 5e808b06db6a4460c9a8b8633b1a6b78ecee9a6c Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 18 Jun 2022 21:26:00 +0900 Subject: [PATCH 4455/6294] [Modify] Polish it --- websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs index 8f70dfcde..6758cf230 100644 --- a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs @@ -339,11 +339,13 @@ public override string SecWebSocketKey { public override IEnumerable SecWebSocketProtocols { get { var val = _request.Headers["Sec-WebSocket-Protocol"]; + if (val == null || val.Length == 0) yield break; foreach (var elm in val.Split (',')) { var protocol = elm.Trim (); + if (protocol.Length == 0) continue; From fe4c2eaaf87b8a300a31f5b403e9895a8ff1eb07 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 19 Jun 2022 22:01:01 +0900 Subject: [PATCH 4456/6294] [Modify] Polish it --- .../Net/WebSockets/TcpListenerWebSocketContext.cs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs index 6758cf230..9d3ee4667 100644 --- a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs @@ -263,10 +263,9 @@ public override NameValueCollection QueryString { get { if (_queryString == null) { var uri = RequestUri; - _queryString = QueryStringCollection.Parse ( - uri != null ? uri.Query : null, - Encoding.UTF8 - ); + var query = uri != null ? uri.Query : null; + + _queryString = QueryStringCollection.Parse (query, Encoding.UTF8); } return _queryString; From f2831ac89900af217c1de963f4df011a2c2aee56 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 20 Jun 2022 20:53:09 +0900 Subject: [PATCH 4457/6294] [Modify] Polish it --- websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs index 9d3ee4667..5500dfd1b 100644 --- a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs @@ -493,6 +493,7 @@ internal void Close (HttpStatusCode code) { var res = HttpResponse.CreateCloseResponse (code); var bytes = res.ToByteArray (); + _stream.Write (bytes, 0, bytes.Length); _stream.Close (); From 37de8d92e4ebf37c5ff8fbe5037d0ab8422cf7bf Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 21 Jun 2022 20:10:13 +0900 Subject: [PATCH 4458/6294] [Modify] Polish it --- websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs index 5500dfd1b..5799b62b3 100644 --- a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs @@ -460,6 +460,7 @@ Func credentialsFinder auth = () => { retry++; + if (retry > 99) return false; @@ -473,10 +474,12 @@ Func credentialsFinder if (user != null && user.Identity.IsAuthenticated) { _user = user; + return true; } _request = sendAuthenticationChallenge (chal); + return auth (); }; From 517a8f9c831685195a3b2e286d9861e77636c396 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 22 Jun 2022 19:28:58 +0900 Subject: [PATCH 4459/6294] [Modify] Add it --- .../Net/WebSockets/TcpListenerWebSocketContext.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs index 5799b62b3..8b852ff05 100644 --- a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs @@ -503,6 +503,16 @@ internal void Close (HttpStatusCode code) _tcpClient.Close (); } + internal void SendAuthenticationChallenge (string challenge) + { + var res = HttpResponse.CreateUnauthorizedResponse (challenge); + var bytes = res.ToByteArray (); + + _stream.Write (bytes, 0, bytes.Length); + + _request = HttpRequest.ReadRequest (_stream, 15000); + } + #endregion #region Public Methods From 4e26e5b096326b709d5729e74fb56ced9d696a46 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 22 Jun 2022 19:36:56 +0900 Subject: [PATCH 4460/6294] [Modify] Add it --- websocket-sharp/HttpResponse.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/websocket-sharp/HttpResponse.cs b/websocket-sharp/HttpResponse.cs index 00dccf53f..a8ef28839 100644 --- a/websocket-sharp/HttpResponse.cs +++ b/websocket-sharp/HttpResponse.cs @@ -240,6 +240,13 @@ internal static HttpResponse ReadResponse ( return Read (stream, Parse, millisecondsTimeout); } + internal void WriteTo (Stream stream) + { + var bytes = ToByteArray (); + + stream.Write (bytes, 0, bytes.Length); + } + #endregion #region Public Methods From f44ad527a908661d902f36d205d3c1040a9104ef Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 22 Jun 2022 19:42:01 +0900 Subject: [PATCH 4461/6294] [Modify] Replace it --- .../Net/WebSockets/TcpListenerWebSocketContext.cs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs index 8b852ff05..a8b5d4b49 100644 --- a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs @@ -494,10 +494,7 @@ internal void Close () internal void Close (HttpStatusCode code) { - var res = HttpResponse.CreateCloseResponse (code); - var bytes = res.ToByteArray (); - - _stream.Write (bytes, 0, bytes.Length); + HttpResponse.CreateCloseResponse (code).WriteTo (_stream); _stream.Close (); _tcpClient.Close (); From e6ceb3d29287f2119dbb3862ddad791de120bdd3 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 23 Jun 2022 20:05:59 +0900 Subject: [PATCH 4462/6294] [Modify] Replace it --- .../Net/WebSockets/TcpListenerWebSocketContext.cs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs index a8b5d4b49..9d3cef170 100644 --- a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs @@ -502,10 +502,7 @@ internal void Close (HttpStatusCode code) internal void SendAuthenticationChallenge (string challenge) { - var res = HttpResponse.CreateUnauthorizedResponse (challenge); - var bytes = res.ToByteArray (); - - _stream.Write (bytes, 0, bytes.Length); + HttpResponse.CreateUnauthorizedResponse (challenge).WriteTo (_stream); _request = HttpRequest.ReadRequest (_stream, 15000); } From 8250b6ce8811b0f8a2d2bdab335c53c890089d0c Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 24 Jun 2022 19:57:17 +0900 Subject: [PATCH 4463/6294] [Modify] Replace it --- .../WebSockets/TcpListenerWebSocketContext.cs | 11 +++++++ websocket-sharp/Server/WebSocketServer.cs | 33 ++++++++++++++++++- 2 files changed, 43 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs index 9d3cef170..011bb7a31 100644 --- a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs @@ -113,6 +113,12 @@ Logger log #region Internal Properties + internal string HttpMethod { + get { + return _request.HttpMethod; + } + } + internal Logger Log { get { return _log; @@ -507,6 +513,11 @@ internal void SendAuthenticationChallenge (string challenge) _request = HttpRequest.ReadRequest (_stream, 15000); } + internal void SetUser (IPrincipal value) + { + _user = value; + } + #endregion #region Public Methods diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index e1a775afb..eedc427f9 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -707,7 +707,38 @@ private bool authenticateClient (TcpListenerWebSocketContext context) if (_authSchemes == AuthenticationSchemes.None) return false; - return context.Authenticate (_authSchemes, _realmInUse, _userCredFinder); + var chal = new AuthenticationChallenge (_authSchemes, _realmInUse) + .ToString (); + + var retry = -1; + Func auth = null; + auth = + () => { + retry++; + + if (retry > 99) + return false; + + var user = HttpUtility.CreateUser ( + context.Headers["Authorization"], + _authSchemes, + _realmInUse, + context.HttpMethod, + _userCredFinder + ); + + if (user != null && user.Identity.IsAuthenticated) { + context.SetUser (user); + + return true; + } + + context.SendAuthenticationChallenge (chal); + + return auth (); + }; + + return auth (); } private bool canSet () From 64459fc746017d5d7b822e97231a8f7868dc8c6b Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 25 Jun 2022 21:48:23 +0900 Subject: [PATCH 4464/6294] [Modify] Remove it --- .../WebSockets/TcpListenerWebSocketContext.cs | 39 ------------------- 1 file changed, 39 deletions(-) diff --git a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs index 011bb7a31..6f0a39d55 100644 --- a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs @@ -453,45 +453,6 @@ private HttpRequest sendAuthenticationChallenge (string challenge) #region Internal Methods - internal bool Authenticate ( - AuthenticationSchemes scheme, - string realm, - Func credentialsFinder - ) - { - var chal = new AuthenticationChallenge (scheme, realm).ToString (); - - var retry = -1; - Func auth = null; - auth = - () => { - retry++; - - if (retry > 99) - return false; - - var user = HttpUtility.CreateUser ( - _request.Headers["Authorization"], - scheme, - realm, - _request.HttpMethod, - credentialsFinder - ); - - if (user != null && user.Identity.IsAuthenticated) { - _user = user; - - return true; - } - - _request = sendAuthenticationChallenge (chal); - - return auth (); - }; - - return auth (); - } - internal void Close () { _stream.Close (); From 6128e9627ed9d418605e902d015c22373f1ef09b Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 26 Jun 2022 22:49:50 +0900 Subject: [PATCH 4465/6294] [Modify] Remove it --- .../Net/WebSockets/TcpListenerWebSocketContext.cs | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs index 6f0a39d55..71190b767 100644 --- a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs @@ -437,20 +437,6 @@ public override WebSocket WebSocket { #endregion - #region Private Methods - - private HttpRequest sendAuthenticationChallenge (string challenge) - { - var res = HttpResponse.CreateUnauthorizedResponse (challenge); - var bytes = res.ToByteArray (); - - _stream.Write (bytes, 0, bytes.Length); - - return HttpRequest.ReadRequest (_stream, 15000); - } - - #endregion - #region Internal Methods internal void Close () From b2a183d54fe2d53eb972245400e1d3fd8e2d8489 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 27 Jun 2022 20:28:51 +0900 Subject: [PATCH 4466/6294] [Modify] Edit it --- websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs index 71190b767..7d4d89178 100644 --- a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs @@ -413,8 +413,8 @@ public override IPrincipal User { /// Gets the endpoint from which the handshake request is sent. ///
/// - /// A that represents the client IP - /// address and port number. + /// A that represents the client + /// IP address and port number. /// public override System.Net.IPEndPoint UserEndPoint { get { From 14cb051d462e9b900eca3edbd0ddf366de676217 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 27 Jun 2022 20:31:00 +0900 Subject: [PATCH 4467/6294] [Modify] Edit it --- websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs index 7d4d89178..68273cdee 100644 --- a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs @@ -382,8 +382,8 @@ public override string SecWebSocketVersion { /// Gets the endpoint to which the handshake request is sent. ///
/// - /// A that represents the server IP - /// address and port number. + /// A that represents the server + /// IP address and port number. /// public override System.Net.IPEndPoint ServerEndPoint { get { From 74ad49ca72097d95e8e03af70b3e4ae03d88eff6 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 27 Jun 2022 20:33:27 +0900 Subject: [PATCH 4468/6294] [Modify] Edit it --- websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs index 68273cdee..c68eb54f4 100644 --- a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs @@ -369,7 +369,7 @@ public override IEnumerable SecWebSocketProtocols { /// version specified by the client. ///
/// - /// if the header is not present. + /// if not included. /// /// public override string SecWebSocketVersion { From 671f53df69a2e91cf76f8a35e2bc8e36e0fc4d3a Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 27 Jun 2022 20:38:04 +0900 Subject: [PATCH 4469/6294] [Modify] Edit it --- websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs index c68eb54f4..3137a2ed4 100644 --- a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs @@ -318,7 +318,7 @@ public override Uri RequestUri { /// a valid WebSocket handshake request. /// /// - /// if the header is not present. + /// if not included. /// /// public override string SecWebSocketKey { From 0d067f4c58b030a9302c5320309dcfcd612371c9 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 27 Jun 2022 20:40:12 +0900 Subject: [PATCH 4470/6294] [Modify] Edit it --- websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs index 3137a2ed4..67ab1b1a3 100644 --- a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs @@ -244,7 +244,7 @@ public override bool IsWebSocketRequest { /// A that represents the value of the Origin header. /// /// - /// if the header is not present. + /// if not included. /// /// public override string Origin { From 45ae5ac1f9c14b07a758fa09a6754821de581fe4 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 28 Jun 2022 19:30:43 +0900 Subject: [PATCH 4471/6294] [Modify] Polish it --- websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs index 67ab1b1a3..30adcb32b 100644 --- a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs @@ -81,6 +81,7 @@ Logger log _log = log; var netStream = tcpClient.GetStream (); + if (secure) { var sslStream = new SslStream ( netStream, From fb8431efb0aa2e0911718518adbe227390d9c1c3 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 28 Jun 2022 19:33:19 +0900 Subject: [PATCH 4472/6294] [Modify] Edit it --- websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs index 30adcb32b..d020d06d8 100644 --- a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs @@ -45,8 +45,8 @@ namespace WebSocketSharp.Net.WebSockets { /// - /// Provides the access to the information in a WebSocket handshake request to - /// a instance. + /// Provides the access to the information in a WebSocket handshake request + /// to a instance. /// internal class TcpListenerWebSocketContext : WebSocketContext { From e5adffc8a95a253a863ca9f7d0f1053c88a831a4 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 29 Jun 2022 20:04:52 +0900 Subject: [PATCH 4473/6294] [Modify] Add it --- .../WebSockets/TcpListenerWebSocketContext.cs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs index d020d06d8..af78b44d0 100644 --- a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs @@ -466,6 +466,23 @@ internal void SetUser (IPrincipal value) _user = value; } + internal bool SetUser ( + AuthenticationSchemes scheme, + string realm, + Func credentialsFinder + ) + { + _user = HttpUtility.CreateUser ( + _request.Headers["Authorization"], + scheme, + realm, + _request.HttpMethod, + credentialsFinder + ); + + return _user != null; + } + #endregion #region Public Methods From f34cbd5213b2073c6a2a8329a9f61ab0025b4acf Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 30 Jun 2022 20:48:15 +0900 Subject: [PATCH 4474/6294] [Modify] Replace it --- .../WebSockets/TcpListenerWebSocketContext.cs | 26 ++++++++++++------- websocket-sharp/Server/WebSocketServer.cs | 13 +--------- 2 files changed, 18 insertions(+), 21 deletions(-) diff --git a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs index af78b44d0..ff173b679 100644 --- a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs @@ -472,15 +472,23 @@ internal bool SetUser ( Func credentialsFinder ) { - _user = HttpUtility.CreateUser ( - _request.Headers["Authorization"], - scheme, - realm, - _request.HttpMethod, - credentialsFinder - ); - - return _user != null; + var user = HttpUtility.CreateUser ( + _request.Headers["Authorization"], + scheme, + realm, + _request.HttpMethod, + credentialsFinder + ); + + if (user == null) + return false; + + if (!user.Identity.IsAuthenticated) + return false; + + _user = user; + + return true; } #endregion diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index eedc427f9..5fdc0027d 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -719,19 +719,8 @@ private bool authenticateClient (TcpListenerWebSocketContext context) if (retry > 99) return false; - var user = HttpUtility.CreateUser ( - context.Headers["Authorization"], - _authSchemes, - _realmInUse, - context.HttpMethod, - _userCredFinder - ); - - if (user != null && user.Identity.IsAuthenticated) { - context.SetUser (user); - + if (context.SetUser (_authSchemes, _realmInUse, _userCredFinder)) return true; - } context.SendAuthenticationChallenge (chal); From 9f57181f9b388a9357e41ee8d6ef573fe99f62d8 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 30 Jun 2022 20:49:19 +0900 Subject: [PATCH 4475/6294] [Modify] Remove it --- .../Net/WebSockets/TcpListenerWebSocketContext.cs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs index ff173b679..c28bd68ef 100644 --- a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs @@ -461,11 +461,6 @@ internal void SendAuthenticationChallenge (string challenge) _request = HttpRequest.ReadRequest (_stream, 15000); } - internal void SetUser (IPrincipal value) - { - _user = value; - } - internal bool SetUser ( AuthenticationSchemes scheme, string realm, From 146cdb231867a1886ac54cf58e33f515c5082404 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 30 Jun 2022 20:50:12 +0900 Subject: [PATCH 4476/6294] [Modify] Remove it --- .../Net/WebSockets/TcpListenerWebSocketContext.cs | 6 ------ 1 file changed, 6 deletions(-) diff --git a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs index c28bd68ef..2048eba22 100644 --- a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs @@ -114,12 +114,6 @@ Logger log #region Internal Properties - internal string HttpMethod { - get { - return _request.HttpMethod; - } - } - internal Logger Log { get { return _log; From 5ef7ceae7ae0eed836950db1f7cf485386d2143d Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 1 Jul 2022 19:37:59 +0900 Subject: [PATCH 4477/6294] [Modify] 2022 --- websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs index 2048eba22..f3a383f30 100644 --- a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs @@ -4,7 +4,7 @@ * * The MIT License * - * Copyright (c) 2012-2018 sta.blockhead + * Copyright (c) 2012-2022 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From 3e6adc64e244c3a68a4b7111c7df38fd7a071f05 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 2 Jul 2022 21:53:44 +0900 Subject: [PATCH 4478/6294] [Modify] Move it --- websocket-sharp/HttpBase.cs | 11 +++++++++++ websocket-sharp/HttpResponse.cs | 7 ------- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/websocket-sharp/HttpBase.cs b/websocket-sharp/HttpBase.cs index e386ecc84..a6842f929 100644 --- a/websocket-sharp/HttpBase.cs +++ b/websocket-sharp/HttpBase.cs @@ -222,6 +222,17 @@ private static string[] readMessageHeaderFrom (Stream stream) #endregion + #region Internal Methods + + internal void WriteTo (Stream stream) + { + var bytes = ToByteArray (); + + stream.Write (bytes, 0, bytes.Length); + } + + #endregion + #region Protected Methods protected static T Read ( diff --git a/websocket-sharp/HttpResponse.cs b/websocket-sharp/HttpResponse.cs index a8ef28839..00dccf53f 100644 --- a/websocket-sharp/HttpResponse.cs +++ b/websocket-sharp/HttpResponse.cs @@ -240,13 +240,6 @@ internal static HttpResponse ReadResponse ( return Read (stream, Parse, millisecondsTimeout); } - internal void WriteTo (Stream stream) - { - var bytes = ToByteArray (); - - stream.Write (bytes, 0, bytes.Length); - } - #endregion #region Public Methods From 58f30bf71a09bf186bd3429d8efb0e7789beb959 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 3 Jul 2022 22:06:43 +0900 Subject: [PATCH 4479/6294] [Modify] Replace it --- websocket-sharp/HttpRequest.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/websocket-sharp/HttpRequest.cs b/websocket-sharp/HttpRequest.cs index 8e68b144f..3b4e4b323 100644 --- a/websocket-sharp/HttpRequest.cs +++ b/websocket-sharp/HttpRequest.cs @@ -176,8 +176,7 @@ internal static HttpRequest CreateWebSocketHandshakeRequest (Uri targetUri) internal HttpResponse GetResponse (Stream stream, int millisecondsTimeout) { - var bytes = ToByteArray (); - stream.Write (bytes, 0, bytes.Length); + WriteTo (stream); return HttpResponse.ReadResponse (stream, millisecondsTimeout); } From 56ac11125466b4199a443dd478dd0ddf8c0241d4 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 4 Jul 2022 21:10:41 +0900 Subject: [PATCH 4480/6294] [Modify] Edit it --- .../Net/WebSockets/HttpListenerWebSocketContext.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs b/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs index ac963c785..41c5ad199 100644 --- a/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs @@ -337,8 +337,8 @@ public override IPrincipal User { /// Gets the endpoint from which the handshake request is sent. ///
/// - /// A that represents the client IP - /// address and port number. + /// A that represents the client + /// IP address and port number. /// public override System.Net.IPEndPoint UserEndPoint { get { From 8d09089b937f357bd5d93de1db0bfde4a272bab2 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 4 Jul 2022 21:12:18 +0900 Subject: [PATCH 4481/6294] [Modify] Edit it --- .../Net/WebSockets/HttpListenerWebSocketContext.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs b/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs index 41c5ad199..9e53ba2ba 100644 --- a/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs @@ -306,8 +306,8 @@ public override string SecWebSocketVersion { /// Gets the endpoint to which the handshake request is sent. ///
/// - /// A that represents the server IP - /// address and port number. + /// A that represents the server + /// IP address and port number. /// public override System.Net.IPEndPoint ServerEndPoint { get { From 86be17e323c61ed40de1489e78b1f57b3f61f909 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 5 Jul 2022 20:14:03 +0900 Subject: [PATCH 4482/6294] [Modify] Edit it --- websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs b/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs index 9e53ba2ba..823421ff9 100644 --- a/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs @@ -293,7 +293,7 @@ public override IEnumerable SecWebSocketProtocols { /// version specified by the client. /// /// - /// if the header is not present. + /// if not included. /// /// public override string SecWebSocketVersion { From d74ac04403ea0f5d8826abeaa6c38e8cb2f8a29d Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 5 Jul 2022 20:16:37 +0900 Subject: [PATCH 4483/6294] [Modify] Polish it --- websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs b/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs index 823421ff9..573c34fd7 100644 --- a/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs @@ -270,11 +270,13 @@ public override string SecWebSocketKey { public override IEnumerable SecWebSocketProtocols { get { var val = _context.Request.Headers["Sec-WebSocket-Protocol"]; + if (val == null || val.Length == 0) yield break; foreach (var elm in val.Split (',')) { var protocol = elm.Trim (); + if (protocol.Length == 0) continue; From a2f3e63ba14bd4e25b0b3e516e33a1a2060e9ecd Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 5 Jul 2022 20:18:56 +0900 Subject: [PATCH 4484/6294] [Modify] Edit it --- websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs b/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs index 573c34fd7..518e03f8e 100644 --- a/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs @@ -244,7 +244,7 @@ public override Uri RequestUri { /// a valid WebSocket handshake request. /// /// - /// if the header is not present. + /// if not included. /// /// public override string SecWebSocketKey { From 283349185c0e322cf03565cd6fc258cc5c97983d Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 5 Jul 2022 20:21:43 +0900 Subject: [PATCH 4485/6294] [Modify] Edit it --- websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs b/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs index 518e03f8e..4e1d10732 100644 --- a/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs @@ -186,7 +186,7 @@ public override bool IsWebSocketRequest { /// A that represents the value of the Origin header. /// /// - /// if the header is not present. + /// if not included. /// /// public override string Origin { From 7ba60d7c645fbb671fc9b956ef2ea03b5ae818d2 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 6 Jul 2022 19:42:02 +0900 Subject: [PATCH 4486/6294] [Modify] Edit it --- .../Net/WebSockets/HttpListenerWebSocketContext.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs b/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs index 4e1d10732..c1073c0e0 100644 --- a/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs @@ -35,8 +35,8 @@ namespace WebSocketSharp.Net.WebSockets { /// - /// Provides the access to the information in a WebSocket handshake request to - /// a instance. + /// Provides the access to the information in a WebSocket handshake request + /// to a instance. /// public class HttpListenerWebSocketContext : WebSocketContext { From 6ea5ccd5bfe37ab199bf61abf1d6bed819680162 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 7 Jul 2022 20:00:50 +0900 Subject: [PATCH 4487/6294] [Modify] 2022 --- websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs b/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs index c1073c0e0..975582652 100644 --- a/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs @@ -4,7 +4,7 @@ * * The MIT License * - * Copyright (c) 2012-2018 sta.blockhead + * Copyright (c) 2012-2022 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From 87236e709c40ecd7c6352149595110d9bbd41e48 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 7 Jul 2022 20:02:41 +0900 Subject: [PATCH 4488/6294] [Modify] Edit it --- websocket-sharp/Net/WebSockets/WebSocketContext.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/WebSockets/WebSocketContext.cs b/websocket-sharp/Net/WebSockets/WebSocketContext.cs index 6921891f7..11c5cc3f7 100644 --- a/websocket-sharp/Net/WebSockets/WebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/WebSocketContext.cs @@ -205,8 +205,8 @@ protected WebSocketContext () /// Gets the endpoint from which the handshake request is sent. ///
/// - /// A that represents the client IP - /// address and port number. + /// A that represents the client + /// IP address and port number. /// public abstract System.Net.IPEndPoint UserEndPoint { get; } From 97e9b7af29d0910dc535480f07931f1e54ed5289 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 7 Jul 2022 20:03:46 +0900 Subject: [PATCH 4489/6294] [Modify] Edit it --- websocket-sharp/Net/WebSockets/WebSocketContext.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/WebSockets/WebSocketContext.cs b/websocket-sharp/Net/WebSockets/WebSocketContext.cs index 11c5cc3f7..e7dd6e3c5 100644 --- a/websocket-sharp/Net/WebSockets/WebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/WebSocketContext.cs @@ -187,8 +187,8 @@ protected WebSocketContext () /// Gets the endpoint to which the handshake request is sent. ///
/// - /// A that represents the server IP - /// address and port number. + /// A that represents the server + /// IP address and port number. /// public abstract System.Net.IPEndPoint ServerEndPoint { get; } From c134327642ea84b39bab7dbb53eb38b1e07955ed Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 8 Jul 2022 20:33:39 +0900 Subject: [PATCH 4490/6294] [Modify] 2022 --- websocket-sharp/Net/WebSockets/WebSocketContext.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebSockets/WebSocketContext.cs b/websocket-sharp/Net/WebSockets/WebSocketContext.cs index e7dd6e3c5..12f11cf74 100644 --- a/websocket-sharp/Net/WebSockets/WebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/WebSocketContext.cs @@ -4,7 +4,7 @@ * * The MIT License * - * Copyright (c) 2012-2018 sta.blockhead + * Copyright (c) 2012-2022 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From 88ad08b2a88325c81e8d0cef67b5ca198890d0a2 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 9 Jul 2022 21:37:00 +0900 Subject: [PATCH 4491/6294] [Modify] Add it --- websocket-sharp/Net/HttpListenerContext.cs | 25 ++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/websocket-sharp/Net/HttpListenerContext.cs b/websocket-sharp/Net/HttpListenerContext.cs index cbd85631c..292e9f6f5 100644 --- a/websocket-sharp/Net/HttpListenerContext.cs +++ b/websocket-sharp/Net/HttpListenerContext.cs @@ -260,6 +260,31 @@ internal void SendError (int statusCode, string message) SendError (); } + internal bool SetUser ( + AuthenticationSchemes scheme, + string realm, + Func credentialsFinder + ) + { + var user = HttpUtility.CreateUser ( + _request.Headers["Authorization"], + scheme, + realm, + _request.HttpMethod, + credentialsFinder + ); + + if (user == null) + return false; + + if (!user.Identity.IsAuthenticated) + return false; + + _user = user; + + return true; + } + internal void Unregister () { if (_listener == null) From 2e1d4a244f15c5d170e9a71b4cc6f6560fdc9f88 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 10 Jul 2022 21:42:37 +0900 Subject: [PATCH 4492/6294] [Modify] Replace it --- websocket-sharp/Net/HttpListener.cs | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index cfc915297..38c05f63e 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -507,24 +507,13 @@ private bool authenticateContext (HttpListenerContext context) } var realm = getRealm (); - var user = HttpUtility.CreateUser ( - req.Headers["Authorization"], - schm, - realm, - req.HttpMethod, - _userCredFinder - ); - var authenticated = user != null && user.Identity.IsAuthenticated; - - if (!authenticated) { + if (!context.SetUser (schm, realm, _userCredFinder)) { context.SendAuthenticationChallenge (schm, realm); return false; } - context.User = user; - return true; } From 8521abe9bb7aef6eb9b13739b44fe8010af87333 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 11 Jul 2022 20:56:19 +0900 Subject: [PATCH 4493/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListener.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 38c05f63e..3a85eb297 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -493,8 +493,7 @@ public Func UserCredentialsFinder { private bool authenticateContext (HttpListenerContext context) { - var req = context.Request; - var schm = selectAuthenticationScheme (req); + var schm = selectAuthenticationScheme (context.Request); if (schm == AuthenticationSchemes.Anonymous) return true; From 8c331b7ae0b0c89c6e14d904e82834ae1dc226c5 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 11 Jul 2022 21:00:17 +0900 Subject: [PATCH 4494/6294] [Modify] Remove it --- websocket-sharp/Net/HttpListenerContext.cs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerContext.cs b/websocket-sharp/Net/HttpListenerContext.cs index 292e9f6f5..9e3f9607d 100644 --- a/websocket-sharp/Net/HttpListenerContext.cs +++ b/websocket-sharp/Net/HttpListenerContext.cs @@ -169,10 +169,6 @@ public IPrincipal User { get { return _user; } - - internal set { - _user = value; - } } #endregion From 7e1ef73eb08fc870d088ee2c88ef06f29a3b5091 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 12 Jul 2022 19:43:34 +0900 Subject: [PATCH 4495/6294] [Modify] Rename it --- websocket-sharp/Net/HttpListener.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 3a85eb297..0692b49b5 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -491,7 +491,7 @@ public Func UserCredentialsFinder { #region Private Methods - private bool authenticateContext (HttpListenerContext context) + private bool authenticateClient (HttpListenerContext context) { var schm = selectAuthenticationScheme (context.Request); @@ -674,7 +674,7 @@ internal void CheckDisposed () internal bool RegisterContext (HttpListenerContext context) { - if (!authenticateContext (context)) + if (!authenticateClient (context)) return false; if (!registerContext (context)) { From 4d7368ba6075dd2b0d7a67a32e7fb32bb9297c86 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 13 Jul 2022 19:41:02 +0900 Subject: [PATCH 4496/6294] [Modify] Add a check for avoiding a deadlock --- websocket-sharp/Net/HttpListener.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 0692b49b5..92b2680cd 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -624,6 +624,9 @@ private string getRealm () private bool registerContext (HttpListenerContext context) { + if (!_listening) + return false; + lock (_contextRegistrySync) { if (!_listening) return false; From e74133c0af4f3a6f1b1568d54c80263645d7e8ef Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 14 Jul 2022 19:56:42 +0900 Subject: [PATCH 4497/6294] [Modify] Move it out for avoiding a deadlock --- websocket-sharp/Net/HttpListener.cs | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 92b2680cd..64a012457 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -571,9 +571,11 @@ private void cleanupContextRegistry () return; var ctxs = new HttpListenerContext[cnt]; - _contextRegistry.CopyTo (ctxs, 0); - _contextRegistry.Clear (); + lock (_contextRegistrySync) { + _contextRegistry.CopyTo (ctxs, 0); + _contextRegistry.Clear (); + } foreach (var ctx in ctxs) ctx.Connection.Close (true); @@ -958,22 +960,19 @@ public void Stop () throw new ObjectDisposedException (_objectName); lock (_contextRegistrySync) { - if (_disposed) - throw new ObjectDisposedException (_objectName); - if (!_listening) return; _listening = false; + } - cleanupContextQueue (false); - cleanupContextRegistry (); + cleanupContextQueue (false); + cleanupContextRegistry (); - var msg = "The listener is stopped."; - cleanupWaitQueue (msg); + var msg = "The listener is stopped."; + cleanupWaitQueue (msg); - EndPointManager.RemoveListener (this); - } + EndPointManager.RemoveListener (this); } #endregion From 82fd25b94d948596d06d945f0c3abb5c99bc5992 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 14 Jul 2022 19:58:28 +0900 Subject: [PATCH 4498/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListener.cs | 3 --- 1 file changed, 3 deletions(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 64a012457..5afb11fe2 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -936,9 +936,6 @@ public void Start () throw new ObjectDisposedException (_objectName); lock (_contextRegistrySync) { - if (_disposed) - throw new ObjectDisposedException (_objectName); - if (_listening) return; From 0034a28ce6435c46f80022917620bc17dd48251d Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 15 Jul 2022 19:51:15 +0900 Subject: [PATCH 4499/6294] [Modify] Move it out for avoiding a deadlock --- websocket-sharp/Net/HttpListener.cs | 39 ++++++++++++----------------- 1 file changed, 16 insertions(+), 23 deletions(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 5afb11fe2..c7aa58762 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -80,6 +80,7 @@ public sealed class HttpListener : IDisposable private object _contextRegistrySync; private static readonly string _defaultRealm; private bool _disposed; + private bool _disposing; private bool _ignoreWriteExceptions; private volatile bool _listening; private Logger _log; @@ -598,13 +599,20 @@ private void cleanupWaitQueue (string message) private void close (bool force) { - if (!_listening) { - _disposed = true; + lock (_contextRegistrySync) { + if (_disposing) + return; - return; - } + _disposing = true; + + if (!_listening) { + _disposed = true; - _listening = false; + return; + } + + _listening = false; + } cleanupContextQueue (force); cleanupContextRegistry (); @@ -709,12 +717,7 @@ public void Abort () if (_disposed) return; - lock (_contextRegistrySync) { - if (_disposed) - return; - - close (true); - } + close (true); } /// @@ -787,12 +790,7 @@ public void Close () if (_disposed) return; - lock (_contextRegistrySync) { - if (_disposed) - return; - - close (false); - } + close (false); } /// @@ -984,12 +982,7 @@ void IDisposable.Dispose () if (_disposed) return; - lock (_contextRegistrySync) { - if (_disposed) - return; - - close (true); - } + close (true); } #endregion From ee9ec73e6b78163428ffb1aa82e517220ca00d4c Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 16 Jul 2022 22:18:05 +0900 Subject: [PATCH 4500/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListener.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index c7aa58762..dd541fca5 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -522,10 +522,14 @@ private HttpListenerAsyncResult beginGetContext ( ) { lock (_contextRegistrySync) { + if (_disposing) { + var msg = "The listener is closed."; + + throw new HttpListenerException (995, msg); + } + if (!_listening) { - var msg = _disposed - ? "The listener is closed." - : "The listener is stopped."; + var msg = "The listener is stopped."; throw new HttpListenerException (995, msg); } From d0575813ca5d15a2da3717ed7e494f80ff308f02 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 17 Jul 2022 21:53:36 +0900 Subject: [PATCH 4501/6294] [Modify] Add it --- websocket-sharp/Net/HttpListener.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index dd541fca5..9ebe23f40 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -89,6 +89,7 @@ public sealed class HttpListener : IDisposable private string _realm; private bool _reuseAddress; private ServerSslConfiguration _sslConfig; + private object _sync; private Func _userCredFinder; private Queue _waitQueue; @@ -119,6 +120,7 @@ public HttpListener () _log = new Logger (); _objectName = GetType ().ToString (); _prefixes = new HttpListenerPrefixCollection (this); + _sync = new object (); _waitQueue = new Queue (); } From f23e584ca29bc050f623c3cb189325f1c7fd3c93 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 18 Jul 2022 21:30:52 +0900 Subject: [PATCH 4502/6294] [Modify] Lock it --- websocket-sharp/Net/HttpListener.cs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 9ebe23f40..801c97e70 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -939,13 +939,18 @@ public void Start () if (_disposed) throw new ObjectDisposedException (_objectName); - lock (_contextRegistrySync) { - if (_listening) - return; + lock (_sync) { + if (_disposed) + throw new ObjectDisposedException (_objectName); + + lock (_contextRegistrySync) { + if (_listening) + return; - EndPointManager.AddListener (this); + EndPointManager.AddListener (this); - _listening = true; + _listening = true; + } } } From ea5e8bd50abee09a1bc3fee39440bbc9df3f06e3 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 18 Jul 2022 21:33:39 +0900 Subject: [PATCH 4503/6294] [Modify] Lock it --- websocket-sharp/Net/HttpListener.cs | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 801c97e70..82b1f3e59 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -965,20 +965,25 @@ public void Stop () if (_disposed) throw new ObjectDisposedException (_objectName); - lock (_contextRegistrySync) { - if (!_listening) - return; + lock (_sync) { + if (_disposed) + throw new ObjectDisposedException (_objectName); - _listening = false; - } + lock (_contextRegistrySync) { + if (!_listening) + return; - cleanupContextQueue (false); - cleanupContextRegistry (); + _listening = false; + } - var msg = "The listener is stopped."; - cleanupWaitQueue (msg); + cleanupContextQueue (false); + cleanupContextRegistry (); - EndPointManager.RemoveListener (this); + var msg = "The listener is stopped."; + cleanupWaitQueue (msg); + + EndPointManager.RemoveListener (this); + } } #endregion From 6eef0271200207e18fa2e47cb7b74ca83009478c Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 19 Jul 2022 19:41:13 +0900 Subject: [PATCH 4504/6294] [Modify] Lock it --- websocket-sharp/Net/HttpListener.cs | 32 +++++++++++++++-------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 82b1f3e59..79f4c3394 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -605,30 +605,32 @@ private void cleanupWaitQueue (string message) private void close (bool force) { - lock (_contextRegistrySync) { - if (_disposing) + lock (_sync) { + if (_disposed) return; - _disposing = true; + lock (_contextRegistrySync) { + _disposing = true; - if (!_listening) { - _disposed = true; + if (!_listening) { + _disposed = true; - return; - } + return; + } - _listening = false; - } + _listening = false; + } - cleanupContextQueue (force); - cleanupContextRegistry (); + cleanupContextQueue (force); + cleanupContextRegistry (); - var msg = "The listener is closed."; - cleanupWaitQueue (msg); + var msg = "The listener is closed."; + cleanupWaitQueue (msg); - EndPointManager.RemoveListener (this); + EndPointManager.RemoveListener (this); - _disposed = true; + _disposed = true; + } } private string getRealm () From 2486c590642adc8629b9e7b18b61260537cd0060 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 19 Jul 2022 19:46:17 +0900 Subject: [PATCH 4505/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListener.cs | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 79f4c3394..f281856c7 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -524,14 +524,8 @@ private HttpListenerAsyncResult beginGetContext ( ) { lock (_contextRegistrySync) { - if (_disposing) { - var msg = "The listener is closed."; - - throw new HttpListenerException (995, msg); - } - if (!_listening) { - var msg = "The listener is stopped."; + var msg = "The method is canceled."; throw new HttpListenerException (995, msg); } From 35d730975becbb94a535e6509d9a272d2a5c04c3 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 20 Jul 2022 19:45:32 +0900 Subject: [PATCH 4506/6294] [Modify] Remove it --- websocket-sharp/Net/HttpListener.cs | 3 --- 1 file changed, 3 deletions(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index f281856c7..3258e1baf 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -80,7 +80,6 @@ public sealed class HttpListener : IDisposable private object _contextRegistrySync; private static readonly string _defaultRealm; private bool _disposed; - private bool _disposing; private bool _ignoreWriteExceptions; private volatile bool _listening; private Logger _log; @@ -604,8 +603,6 @@ private void close (bool force) return; lock (_contextRegistrySync) { - _disposing = true; - if (!_listening) { _disposed = true; From 0b6ab28cbaf58e0667d2b69b6bc0a45226d592d5 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 21 Jul 2022 20:15:15 +0900 Subject: [PATCH 4507/6294] [Modify] Edit it --- websocket-sharp/Logger.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Logger.cs b/websocket-sharp/Logger.cs index 17850e67e..eafa5c2e5 100644 --- a/websocket-sharp/Logger.cs +++ b/websocket-sharp/Logger.cs @@ -308,14 +308,14 @@ public void Trace (string message) } /// - /// Outputs as a log with . + /// Outputs the specified message as a log with the Warn level. /// /// - /// If the current logging level is higher than , - /// this method doesn't output as a log. + /// If the current logging level is higher than the Warn level, + /// this method does not output the message as a log. /// /// - /// A that represents the message to output as a log. + /// A that specifies the message to output. /// public void Warn (string message) { From 17e5e1085589310c15a96a93d2161c0db70b7b60 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 21 Jul 2022 20:19:32 +0900 Subject: [PATCH 4508/6294] [Modify] Edit it --- websocket-sharp/Logger.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Logger.cs b/websocket-sharp/Logger.cs index eafa5c2e5..656d19ef1 100644 --- a/websocket-sharp/Logger.cs +++ b/websocket-sharp/Logger.cs @@ -290,14 +290,14 @@ public void Info (string message) } /// - /// Outputs as a log with . + /// Outputs the specified message as a log with the Trace level. /// /// - /// If the current logging level is higher than , - /// this method doesn't output as a log. + /// If the current logging level is higher than the Trace level, + /// this method does not output the message as a log. /// /// - /// A that represents the message to output as a log. + /// A that specifies the message to output. /// public void Trace (string message) { From 0acbd582d9f89b03b52467404a5042493349ca63 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 22 Jul 2022 19:39:36 +0900 Subject: [PATCH 4509/6294] [Modify] Edit it --- websocket-sharp/Logger.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Logger.cs b/websocket-sharp/Logger.cs index 656d19ef1..6fbbcb234 100644 --- a/websocket-sharp/Logger.cs +++ b/websocket-sharp/Logger.cs @@ -272,14 +272,14 @@ public void Fatal (string message) } /// - /// Outputs as a log with . + /// Outputs the specified message as a log with the Info level. /// /// - /// If the current logging level is higher than , - /// this method doesn't output as a log. + /// If the current logging level is higher than the Info level, + /// this method does not output the message as a log. /// /// - /// A that represents the message to output as a log. + /// A that specifies the message to output. /// public void Info (string message) { From fef363f9c3b3c682a3516f2a98babf6f63b3a5f5 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 22 Jul 2022 19:42:29 +0900 Subject: [PATCH 4510/6294] [Modify] Edit it --- websocket-sharp/Logger.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Logger.cs b/websocket-sharp/Logger.cs index 6fbbcb234..156a0186b 100644 --- a/websocket-sharp/Logger.cs +++ b/websocket-sharp/Logger.cs @@ -261,10 +261,10 @@ public void Error (string message) } /// - /// Outputs as a log with . + /// Outputs the specified message as a log with the Fatal level. /// /// - /// A that represents the message to output as a log. + /// A that specifies the message to output. /// public void Fatal (string message) { From 463a2ab925334e450e37fab1bab04db290b8ac26 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 22 Jul 2022 19:45:50 +0900 Subject: [PATCH 4511/6294] [Modify] Edit it --- websocket-sharp/Logger.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Logger.cs b/websocket-sharp/Logger.cs index 156a0186b..0ade21553 100644 --- a/websocket-sharp/Logger.cs +++ b/websocket-sharp/Logger.cs @@ -243,14 +243,14 @@ public void Debug (string message) } /// - /// Outputs as a log with . + /// Outputs the specified message as a log with the Error level. /// /// - /// If the current logging level is higher than , - /// this method doesn't output as a log. + /// If the current logging level is higher than the Error level, + /// this method does not output the message as a log. /// /// - /// A that represents the message to output as a log. + /// A that specifies the message to output. /// public void Error (string message) { From e663549f4529f8b18b4703177cf26f96f5148ba3 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 23 Jul 2022 20:55:12 +0900 Subject: [PATCH 4512/6294] [Modify] Edit it --- websocket-sharp/Logger.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Logger.cs b/websocket-sharp/Logger.cs index 0ade21553..f127460b2 100644 --- a/websocket-sharp/Logger.cs +++ b/websocket-sharp/Logger.cs @@ -225,14 +225,14 @@ private static void writeToFile (string value, string path) #region Public Methods /// - /// Outputs as a log with . + /// Outputs the specified message as a log with the Debug level. /// /// - /// If the current logging level is higher than , - /// this method doesn't output as a log. + /// If the current logging level is higher than the Debug level, + /// this method does not output the message as a log. /// /// - /// A that represents the message to output as a log. + /// A that specifies the message to output. /// public void Debug (string message) { From 44393ff2ddaabe0f3a04e63497622ee6d178c200 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 24 Jul 2022 22:42:22 +0900 Subject: [PATCH 4513/6294] [Modify] Polish it --- websocket-sharp/Logger.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Logger.cs b/websocket-sharp/Logger.cs index f127460b2..8c86a039b 100644 --- a/websocket-sharp/Logger.cs +++ b/websocket-sharp/Logger.cs @@ -201,13 +201,16 @@ private void output (string message, LogLevel level) if (_level > level) return; - LogData data = null; try { - data = new LogData (level, new StackFrame (2, true), message); + var data = new LogData (level, new StackFrame (2, true), message); + _output (data, _file); } catch (Exception ex) { - data = new LogData (LogLevel.Fatal, new StackFrame (0, true), ex.Message); + var data = new LogData ( + LogLevel.Fatal, new StackFrame (0, true), ex.Message + ); + Console.WriteLine (data.ToString ()); } } From c6925bc19150b099787fccd21b4d64ec80c76945 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 25 Jul 2022 21:38:47 +0900 Subject: [PATCH 4514/6294] [Modify] Polish it --- websocket-sharp/Logger.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Logger.cs b/websocket-sharp/Logger.cs index 8c86a039b..e9bf65f7f 100644 --- a/websocket-sharp/Logger.cs +++ b/websocket-sharp/Logger.cs @@ -189,10 +189,12 @@ public Action Output { private static void defaultOutput (LogData data, string path) { - var log = data.ToString (); - Console.WriteLine (log); + var val = data.ToString (); + + Console.WriteLine (val); + if (path != null && path.Length > 0) - writeToFile (log, path); + writeToFile (val, path); } private void output (string message, LogLevel level) From 925f2e395ef4d561014b93f4b2561c12f7141574 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 26 Jul 2022 19:39:21 +0900 Subject: [PATCH 4515/6294] [Modify] Polish it --- websocket-sharp/Logger.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Logger.cs b/websocket-sharp/Logger.cs index e9bf65f7f..0a7bf7a9b 100644 --- a/websocket-sharp/Logger.cs +++ b/websocket-sharp/Logger.cs @@ -128,8 +128,11 @@ public string File { set { lock (_sync) { _file = value; - Warn ( - String.Format ("The current path to the log file has been changed to {0}.", _file)); + + var fmt = "The current path to the log file has been changed to {0}."; + var msg = String.Format (fmt , _file); + + Warn (msg); } } } From f1c7e36b29d481efb8dd93b8f38d28c2fc022980 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 26 Jul 2022 19:42:45 +0900 Subject: [PATCH 4516/6294] [Modify] Edit it --- websocket-sharp/Logger.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Logger.cs b/websocket-sharp/Logger.cs index 0a7bf7a9b..2f173be3b 100644 --- a/websocket-sharp/Logger.cs +++ b/websocket-sharp/Logger.cs @@ -115,10 +115,10 @@ public Logger (LogLevel level, string file, Action output) #region Public Properties /// - /// Gets or sets the current path to the log file. + /// Gets or sets the path to the log file. /// /// - /// A that represents the current path to the log file if any. + /// A that represents the path to the log file if any. /// public string File { get { From f20963fd8b44a35e954c52ed80efff7b0d5e222d Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 27 Jul 2022 19:36:06 +0900 Subject: [PATCH 4517/6294] [Modify] Polish it --- websocket-sharp/Logger.cs | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/websocket-sharp/Logger.cs b/websocket-sharp/Logger.cs index 2f173be3b..c728df740 100644 --- a/websocket-sharp/Logger.cs +++ b/websocket-sharp/Logger.cs @@ -126,14 +126,8 @@ public string File { } set { - lock (_sync) { + lock (_sync) _file = value; - - var fmt = "The current path to the log file has been changed to {0}."; - var msg = String.Format (fmt , _file); - - Warn (msg); - } } } From 55d62f36bd7a4796254cea354308088ae155cb81 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 27 Jul 2022 19:37:50 +0900 Subject: [PATCH 4518/6294] [Modify] Polish it --- websocket-sharp/Logger.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/websocket-sharp/Logger.cs b/websocket-sharp/Logger.cs index c728df740..41c97c91f 100644 --- a/websocket-sharp/Logger.cs +++ b/websocket-sharp/Logger.cs @@ -146,10 +146,8 @@ public LogLevel Level { } set { - lock (_sync) { + lock (_sync) _level = value; - Warn (String.Format ("The current logging level has been changed to {0}.", _level)); - } } } From 44ffea01e141d67537f66e84a5813ebc8fe62a9c Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 27 Jul 2022 19:43:44 +0900 Subject: [PATCH 4519/6294] [Modify] Edit it --- websocket-sharp/Logger.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Logger.cs b/websocket-sharp/Logger.cs index 41c97c91f..1858171a6 100644 --- a/websocket-sharp/Logger.cs +++ b/websocket-sharp/Logger.cs @@ -138,7 +138,12 @@ public string File { /// A log with lower than the value of this property cannot be outputted. /// /// - /// One of the enum values, specifies the current logging level. + /// + /// One of the enum values. + /// + /// + /// It represents the current logging level. + /// /// public LogLevel Level { get { From 91020bc645bf0bb596e25db65a71fccff7896efd Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 28 Jul 2022 19:41:18 +0900 Subject: [PATCH 4520/6294] [Modify] Polish it --- websocket-sharp/Logger.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/websocket-sharp/Logger.cs b/websocket-sharp/Logger.cs index 1858171a6..cc35d1f53 100644 --- a/websocket-sharp/Logger.cs +++ b/websocket-sharp/Logger.cs @@ -176,10 +176,8 @@ public Action Output { } set { - lock (_sync) { + lock (_sync) _output = value ?? defaultOutput; - Warn ("The current output action has been changed."); - } } } From a1ac9581ed80063606ef5454529c612324ae29cf Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 29 Jul 2022 20:16:52 +0900 Subject: [PATCH 4521/6294] [Modify] Edit it --- websocket-sharp/Logger.cs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Logger.cs b/websocket-sharp/Logger.cs index cc35d1f53..b38fded90 100644 --- a/websocket-sharp/Logger.cs +++ b/websocket-sharp/Logger.cs @@ -157,17 +157,22 @@ public LogLevel Level { } /// - /// Gets or sets the current output action used to output a log. + /// Gets or sets the delegate used to output a log. /// /// /// - /// An Action<LogData, string> delegate that references the method(s) used to - /// output a log. A parameter passed to this delegate is the value of + /// An Action<LogData, string> delegate. + /// + /// + /// It references the method used to output a log. + /// + /// + /// The string parameter passed to the delegate is the value of /// the property. /// /// - /// If the value to set is , the current output action is changed to - /// the default output action. + /// If the value to set is , the default + /// output method is set. /// /// public Action Output { From 5732b051be4a96512c789d33de79565c5f138492 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 30 Jul 2022 21:31:29 +0900 Subject: [PATCH 4522/6294] [Modify] Edit it --- websocket-sharp/Logger.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Logger.cs b/websocket-sharp/Logger.cs index b38fded90..788b58e77 100644 --- a/websocket-sharp/Logger.cs +++ b/websocket-sharp/Logger.cs @@ -161,7 +161,7 @@ public LogLevel Level { /// /// /// - /// An Action<LogData, string> delegate. + /// An delegate. /// /// /// It references the method used to output a log. From d3f611967feefe848625f2bcd7da9a55dac41f22 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 30 Jul 2022 21:33:59 +0900 Subject: [PATCH 4523/6294] [Modify] Edit it --- websocket-sharp/Logger.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Logger.cs b/websocket-sharp/Logger.cs index 788b58e77..004ff6932 100644 --- a/websocket-sharp/Logger.cs +++ b/websocket-sharp/Logger.cs @@ -67,7 +67,8 @@ public class Logger /// Initializes a new instance of the class. /// /// - /// This constructor initializes the current logging level with . + /// This constructor initializes the current logging level with + /// . /// public Logger () : this (LogLevel.Error, null, null) From 87117527b15645236f02f86cbb92dc50ef621208 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 31 Jul 2022 21:52:50 +0900 Subject: [PATCH 4524/6294] [Modify] Edit it --- websocket-sharp/Logger.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Logger.cs b/websocket-sharp/Logger.cs index 004ff6932..d4c9fc739 100644 --- a/websocket-sharp/Logger.cs +++ b/websocket-sharp/Logger.cs @@ -77,7 +77,7 @@ public Logger () /// /// Initializes a new instance of the class with - /// the specified logging . + /// the specified logging level. /// /// /// One of the enum values. From 9756f0d3f2a9badd3bc6feb7a851e54870836d2f Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 31 Jul 2022 21:54:07 +0900 Subject: [PATCH 4525/6294] [Modify] Polish it --- websocket-sharp/Logger.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Logger.cs b/websocket-sharp/Logger.cs index d4c9fc739..a285a594d 100644 --- a/websocket-sharp/Logger.cs +++ b/websocket-sharp/Logger.cs @@ -108,6 +108,7 @@ public Logger (LogLevel level, string file, Action output) _level = level; _file = file; _output = output ?? defaultOutput; + _sync = new object (); } From 84c293d08feabfd8fcdb2ac3a185dd0545e2168b Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 1 Aug 2022 21:18:40 +0900 Subject: [PATCH 4526/6294] [Modify] Edit it --- websocket-sharp/Logger.cs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Logger.cs b/websocket-sharp/Logger.cs index a285a594d..e813aa65f 100644 --- a/websocket-sharp/Logger.cs +++ b/websocket-sharp/Logger.cs @@ -89,19 +89,22 @@ public Logger (LogLevel level) /// /// Initializes a new instance of the class with - /// the specified logging , path to the log , - /// and action. + /// the specified logging level, path to the log file, and delegate + /// used to output a log. /// /// /// One of the enum values. /// /// - /// A that represents the path to the log file. + /// A that specifies the path to the log file. /// /// - /// An Action<LogData, string> delegate that references the method(s) used to - /// output a log. A parameter passed to this delegate is - /// . + /// + /// An delegate. + /// + /// + /// It is used to output a log. + /// /// public Logger (LogLevel level, string file, Action output) { From dd7211c0a04b183d1bddfd8ac05bfd6608feac98 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 2 Aug 2022 19:40:25 +0900 Subject: [PATCH 4527/6294] [Modify] Edit it --- websocket-sharp/Logger.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Logger.cs b/websocket-sharp/Logger.cs index e813aa65f..1e53976d5 100644 --- a/websocket-sharp/Logger.cs +++ b/websocket-sharp/Logger.cs @@ -93,7 +93,8 @@ public Logger (LogLevel level) /// used to output a log. ///
/// - /// One of the enum values. + /// One of the enum values that specifies + /// the logging level. /// /// /// A that specifies the path to the log file. From f4fa91c55e0082714cb51fc2a4f6cf433b185137 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 3 Aug 2022 19:43:12 +0900 Subject: [PATCH 4528/6294] [Modify] Edit it --- websocket-sharp/Logger.cs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Logger.cs b/websocket-sharp/Logger.cs index 1e53976d5..be1fc1a44 100644 --- a/websocket-sharp/Logger.cs +++ b/websocket-sharp/Logger.cs @@ -100,12 +100,8 @@ public Logger (LogLevel level) /// A that specifies the path to the log file. /// /// - /// - /// An delegate. - /// - /// - /// It is used to output a log. - /// + /// An that specifies + /// the delegate used to output a log. /// public Logger (LogLevel level, string file, Action output) { From 8e6442b27c4b4a5d8d0a09bcda3e95083616e4f0 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 4 Aug 2022 20:31:06 +0900 Subject: [PATCH 4529/6294] [Modify] Edit it --- websocket-sharp/Logger.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Logger.cs b/websocket-sharp/Logger.cs index be1fc1a44..09be9c646 100644 --- a/websocket-sharp/Logger.cs +++ b/websocket-sharp/Logger.cs @@ -37,17 +37,17 @@ namespace WebSocketSharp ///
/// /// - /// If you output a log with lower than the value of the property, + /// If you output a log with lower than the current logging level, /// it cannot be outputted. /// /// - /// The default output action writes a log to the standard output stream and the log file - /// if the property has a valid path to it. + /// The default output method writes a log to the standard output + /// stream and the log file if it has a valid path. /// /// - /// If you would like to use the custom output action, you should set - /// the property to any Action<LogData, string> - /// delegate. + /// If you would like to use the custom output method, you should + /// specify it with the constructor or the + /// property. /// /// public class Logger From ff6c88dc0b5825749c56e556c2294d3d4a0ffb30 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 5 Aug 2022 19:42:27 +0900 Subject: [PATCH 4530/6294] [Modify] Edit it --- websocket-sharp/Logger.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/websocket-sharp/Logger.cs b/websocket-sharp/Logger.cs index 09be9c646..9ec46f9f2 100644 --- a/websocket-sharp/Logger.cs +++ b/websocket-sharp/Logger.cs @@ -67,8 +67,7 @@ public class Logger /// Initializes a new instance of the class. ///
/// - /// This constructor initializes the current logging level with - /// . + /// This constructor initializes the logging level with the Error level. /// public Logger () : this (LogLevel.Error, null, null) From bfe4916a851fefb03f95784fed5c74089d983db4 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 6 Aug 2022 21:41:54 +0900 Subject: [PATCH 4531/6294] [Modify] Edit it --- websocket-sharp/Logger.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Logger.cs b/websocket-sharp/Logger.cs index 9ec46f9f2..704a0ba38 100644 --- a/websocket-sharp/Logger.cs +++ b/websocket-sharp/Logger.cs @@ -79,7 +79,8 @@ public Logger () /// the specified logging level. ///
/// - /// One of the enum values. + /// One of the enum values that specifies + /// the logging level. /// public Logger (LogLevel level) : this (level, null, null) From f428042910c0fd79497d6ce47858b44f4d5e7622 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 7 Aug 2022 21:24:11 +0900 Subject: [PATCH 4532/6294] [Modify] Edit it --- websocket-sharp/Logger.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Logger.cs b/websocket-sharp/Logger.cs index 704a0ba38..024c822d5 100644 --- a/websocket-sharp/Logger.cs +++ b/websocket-sharp/Logger.cs @@ -42,7 +42,7 @@ namespace WebSocketSharp /// /// /// The default output method writes a log to the standard output - /// stream and the log file if it has a valid path. + /// stream and the text file if it has a valid path. /// /// /// If you would like to use the custom output method, you should From e69d0418862371e0115a49d94272f4601b3b6ff9 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 8 Aug 2022 21:17:50 +0900 Subject: [PATCH 4533/6294] [Modify] 2022 --- websocket-sharp/Logger.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Logger.cs b/websocket-sharp/Logger.cs index 024c822d5..7e7ded84c 100644 --- a/websocket-sharp/Logger.cs +++ b/websocket-sharp/Logger.cs @@ -4,7 +4,7 @@ * * The MIT License * - * Copyright (c) 2013-2015 sta.blockhead + * Copyright (c) 2013-2022 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From 4c619fb4687d3b47662171b29e1cb262f37f5d2d Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 8 Aug 2022 21:20:32 +0900 Subject: [PATCH 4534/6294] [Modify] Polish it --- websocket-sharp/LogData.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/LogData.cs b/websocket-sharp/LogData.cs index 9c0843093..9303711c3 100644 --- a/websocket-sharp/LogData.cs +++ b/websocket-sharp/LogData.cs @@ -53,6 +53,7 @@ internal LogData (LogLevel level, StackFrame caller, string message) _level = level; _caller = caller; _message = message ?? String.Empty; + _date = DateTime.Now; } From d5ca15136774eacb15e3af02f04720f8d4a85244 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 9 Aug 2022 19:49:35 +0900 Subject: [PATCH 4535/6294] [Modify] Polish it --- websocket-sharp/LogData.cs | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/LogData.cs b/websocket-sharp/LogData.cs index 9303711c3..d91d0a6e9 100644 --- a/websocket-sharp/LogData.cs +++ b/websocket-sharp/LogData.cs @@ -126,22 +126,34 @@ public override string ToString () var type = method.DeclaringType; #if DEBUG var lineNum = _caller.GetFileLineNumber (); - var headerAndCaller = - String.Format ("{0}{1}.{2}:{3}|", header, type.Name, method.Name, lineNum); + var headerAndCaller = String.Format ( + "{0}{1}.{2}:{3}|", + header, + type.Name, + method.Name, + lineNum + ); #else - var headerAndCaller = String.Format ("{0}{1}.{2}|", header, type.Name, method.Name); + var headerAndCaller = String.Format ( + "{0}{1}.{2}|", header, type.Name, method.Name + ); #endif var msgs = _message.Replace ("\r\n", "\n").TrimEnd ('\n').Split ('\n'); + if (msgs.Length <= 1) return String.Format ("{0}{1}", headerAndCaller, _message); - var buff = new StringBuilder (String.Format ("{0}{1}\n", headerAndCaller, msgs[0]), 64); + var buff = new StringBuilder (64); + + buff.AppendFormat ("{0}{1}\n", headerAndCaller, msgs[0]); var fmt = String.Format ("{{0,{0}}}{{1}}\n", header.Length); + for (var i = 1; i < msgs.Length; i++) buff.AppendFormat (fmt, "", msgs[i]); buff.Length--; + return buff.ToString (); } From 19ad9e018ff74e412aa46290c4e983b9478a5953 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 10 Aug 2022 21:34:04 +0900 Subject: [PATCH 4536/6294] [Modify] Edit it --- websocket-sharp/LogData.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/LogData.cs b/websocket-sharp/LogData.cs index d91d0a6e9..6b0b1a049 100644 --- a/websocket-sharp/LogData.cs +++ b/websocket-sharp/LogData.cs @@ -114,10 +114,10 @@ public string Message { #region Public Methods /// - /// Returns a that represents the current . + /// Returns a string that represents the current instance. /// /// - /// A that represents the current . + /// A that represents the current instance. /// public override string ToString () { From a25d49ae523d4ea0d284e4ab71688f9c0f707e09 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 11 Aug 2022 22:12:56 +0900 Subject: [PATCH 4537/6294] [Modify] Edit it --- websocket-sharp/LogData.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/LogData.cs b/websocket-sharp/LogData.cs index 6b0b1a049..ba24f4deb 100644 --- a/websocket-sharp/LogData.cs +++ b/websocket-sharp/LogData.cs @@ -65,7 +65,8 @@ internal LogData (LogLevel level, StackFrame caller, string message) /// Gets the information of the logging method caller. ///
/// - /// A that provides the information of the logging method caller. + /// A that provides the information of + /// the logging method caller. /// public StackFrame Caller { get { From 971e7fdcb84fa5a6b39530bf69e73c9ac0f35971 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 11 Aug 2022 22:14:17 +0900 Subject: [PATCH 4538/6294] [Modify] Edit it --- websocket-sharp/LogData.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/LogData.cs b/websocket-sharp/LogData.cs index ba24f4deb..13159f247 100644 --- a/websocket-sharp/LogData.cs +++ b/websocket-sharp/LogData.cs @@ -78,7 +78,8 @@ public StackFrame Caller { /// Gets the date and time when the log data was created. ///
/// - /// A that represents the date and time when the log data was created. + /// A that represents the date and time when + /// the log data was created. /// public DateTime Date { get { From 706eb3f8ed7c4fb2048f6409e259541e27b067a9 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 12 Aug 2022 21:42:13 +0900 Subject: [PATCH 4539/6294] [Modify] Edit it --- websocket-sharp/LogData.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/LogData.cs b/websocket-sharp/LogData.cs index 13159f247..0a5e3a3e8 100644 --- a/websocket-sharp/LogData.cs +++ b/websocket-sharp/LogData.cs @@ -91,7 +91,8 @@ public DateTime Date { /// Gets the logging level of the log data. ///
/// - /// One of the enum values, indicates the logging level of the log data. + /// One of the enum values that represents + /// the logging level of the log data. /// public LogLevel Level { get { From 23fd73755ae7fca13f5413801d0a1172e4e52ed7 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 13 Aug 2022 22:02:33 +0900 Subject: [PATCH 4540/6294] [Modify] Polish it --- websocket-sharp/LogData.cs | 30 ++++++++++-------------------- 1 file changed, 10 insertions(+), 20 deletions(-) diff --git a/websocket-sharp/LogData.cs b/websocket-sharp/LogData.cs index 0a5e3a3e8..d62d28b95 100644 --- a/websocket-sharp/LogData.cs +++ b/websocket-sharp/LogData.cs @@ -124,38 +124,28 @@ public string Message { /// public override string ToString () { - var header = String.Format ("{0}|{1,-5}|", _date, _level); + var date = String.Format ("[{0}]", _date); + var level = String.Format ("{0,-5}", _level.ToString ().ToUpper ()); + var method = _caller.GetMethod (); var type = method.DeclaringType; #if DEBUG - var lineNum = _caller.GetFileLineNumber (); - var headerAndCaller = String.Format ( - "{0}{1}.{2}:{3}|", - header, - type.Name, - method.Name, - lineNum - ); + var num = _caller.GetFileLineNumber (); + var caller = String.Format ("{0}.{1}:{2}", type.Name, method.Name, num); #else - var headerAndCaller = String.Format ( - "{0}{1}.{2}|", header, type.Name, method.Name - ); + var caller = String.Format ("{0}.{1}", type.Name, method.Name); #endif var msgs = _message.Replace ("\r\n", "\n").TrimEnd ('\n').Split ('\n'); if (msgs.Length <= 1) - return String.Format ("{0}{1}", headerAndCaller, _message); + return String.Format ("{0} {1} {2} {3}", date, level, caller, _message); var buff = new StringBuilder (64); - buff.AppendFormat ("{0}{1}\n", headerAndCaller, msgs[0]); - - var fmt = String.Format ("{{0,{0}}}{{1}}\n", header.Length); - - for (var i = 1; i < msgs.Length; i++) - buff.AppendFormat (fmt, "", msgs[i]); + buff.AppendFormat ("{0} {1} {2}\n\n", date, level, caller); - buff.Length--; + for (var i = 0; i < msgs.Length; i++) + buff.AppendFormat (" {0}\n", msgs[i]); return buff.ToString (); } From fd92ce34a6c6a00edb4cb9425457558851a83ae5 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 14 Aug 2022 22:17:41 +0900 Subject: [PATCH 4541/6294] [Modify] 2022 --- websocket-sharp/LogData.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/LogData.cs b/websocket-sharp/LogData.cs index d62d28b95..df8c96b89 100644 --- a/websocket-sharp/LogData.cs +++ b/websocket-sharp/LogData.cs @@ -4,7 +4,7 @@ * * The MIT License * - * Copyright (c) 2013-2015 sta.blockhead + * Copyright (c) 2013-2022 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From ebbc55c609d9acd3519685fb1c8875f53b4c2cc5 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 15 Aug 2022 22:07:21 +0900 Subject: [PATCH 4542/6294] [Modify] Specify not to output logs --- websocket-sharp/LogLevel.cs | 6 +++++- websocket-sharp/Logger.cs | 3 +++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/LogLevel.cs b/websocket-sharp/LogLevel.cs index ef9967728..0ebcad01d 100644 --- a/websocket-sharp/LogLevel.cs +++ b/websocket-sharp/LogLevel.cs @@ -58,6 +58,10 @@ public enum LogLevel /// /// Specifies the top logging level. /// - Fatal + Fatal, + /// + /// Specifies not to output logs. + /// + None } } diff --git a/websocket-sharp/Logger.cs b/websocket-sharp/Logger.cs index 7e7ded84c..ad6135803 100644 --- a/websocket-sharp/Logger.cs +++ b/websocket-sharp/Logger.cs @@ -278,6 +278,9 @@ public void Error (string message) /// public void Fatal (string message) { + if (_level > LogLevel.Fatal) + return; + output (message, LogLevel.Fatal); } From bd218901c2fbb5c6dea2744fc7e7395a2075990d Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 16 Aug 2022 20:56:39 +0900 Subject: [PATCH 4543/6294] [Modify] 2022 --- websocket-sharp/LogLevel.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/LogLevel.cs b/websocket-sharp/LogLevel.cs index 0ebcad01d..5ff1d8fed 100644 --- a/websocket-sharp/LogLevel.cs +++ b/websocket-sharp/LogLevel.cs @@ -4,7 +4,7 @@ * * The MIT License * - * Copyright (c) 2013-2015 sta.blockhead + * Copyright (c) 2013-2022 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From 4fb1ab6fe597374a8cbc1a9ab709b5ff24f3f871 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 17 Aug 2022 20:01:48 +0900 Subject: [PATCH 4544/6294] [Modify] Remove it --- websocket-sharp/WebSocket.cs | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 3b6619da8..124c2df73 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1223,25 +1223,6 @@ private void closeAsync ( ); } - private bool closeHandshake (byte[] frameAsBytes, bool receive, bool received) - { - var sent = frameAsBytes != null && sendBytes (frameAsBytes); - - var wait = !received && sent && receive && _receivingExited != null; - if (wait) - received = _receivingExited.WaitOne (_waitTime); - - var ret = sent && received; - - _logger.Debug ( - String.Format ( - "Was clean?: {0}\n sent: {1}\n received: {2}", ret, sent, received - ) - ); - - return ret; - } - private bool closeHandshake ( PayloadData payloadData, bool send, bool receive, bool received ) From 82f7fa2b8c082952e7b4b5da625d1f48b1acd54f Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 18 Aug 2022 19:38:10 +0900 Subject: [PATCH 4545/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 124c2df73..b9d7aeb80 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1228,6 +1228,7 @@ private bool closeHandshake ( ) { var sent = false; + if (send) { var frame = WebSocketFrame.CreateCloseFrame (payloadData, _client); sent = sendBytes (frame.ToArray ()); @@ -1237,16 +1238,20 @@ private bool closeHandshake ( } var wait = !received && sent && receive && _receivingExited != null; + if (wait) received = _receivingExited.WaitOne (_waitTime); var ret = sent && received; - _logger.Debug ( - String.Format ( - "Was clean?: {0}\n sent: {1}\n received: {2}", ret, sent, received - ) - ); + var msg = String.Format ( + "The close was clean? {0} (sent: {1} received: {2})", + ret, + sent, + received + ); + + _logger.Debug (msg); return ret; } From cb9f6a149fcc7290751960fd6387228996dd03d5 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 19 Aug 2022 20:05:55 +0900 Subject: [PATCH 4546/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index b9d7aeb80..d54f3a555 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2407,12 +2407,14 @@ internal void Close (PayloadData payloadData, byte[] frameAsBytes) { lock (_forState) { if (_readyState == WebSocketState.Closing) { - _logger.Info ("The closing is already in progress."); + _logger.Trace ("The closing is already in progress."); + return; } if (_readyState == WebSocketState.Closed) { - _logger.Info ("The connection has already been closed."); + _logger.Trace ("The connection has already been closed."); + return; } @@ -2428,11 +2430,14 @@ internal void Close (PayloadData payloadData, byte[] frameAsBytes) var res = sent && received; - _logger.Debug ( - String.Format ( - "Was clean?: {0}\n sent: {1}\n received: {2}", res, sent, received - ) - ); + var msg = String.Format ( + "The closing was clean? {0} (sent: {1} received: {2})", + res, + sent, + received + ); + + _logger.Debug (msg); releaseServerResources (); releaseCommonResources (); From 1a010ced436db26bf4cfe211b5477fc40b8cb11d Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 20 Aug 2022 21:07:13 +0900 Subject: [PATCH 4547/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index d54f3a555..5dd54d179 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1231,7 +1231,9 @@ private bool closeHandshake ( if (send) { var frame = WebSocketFrame.CreateCloseFrame (payloadData, _client); - sent = sendBytes (frame.ToArray ()); + var bytes = frame.ToArray (); + + sent = sendBytes (bytes); if (_client) frame.Unmask (); @@ -1245,7 +1247,7 @@ private bool closeHandshake ( var ret = sent && received; var msg = String.Format ( - "The close was clean? {0} (sent: {1} received: {2})", + "The closing was clean? {0} (sent: {1} received: {2})", ret, sent, received From d0e74a8e2cd186f3d2e0bd237f540043120b0100 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 21 Aug 2022 20:57:09 +0900 Subject: [PATCH 4548/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 5dd54d179..63abd3e7f 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1157,12 +1157,14 @@ private void close ( { lock (_forState) { if (_readyState == WebSocketState.Closing) { - _logger.Info ("The closing is already in progress."); + _logger.Trace ("The closing is already in progress."); + return; } if (_readyState == WebSocketState.Closed) { - _logger.Info ("The connection has already been closed."); + _logger.Trace ("The connection has already been closed."); + return; } @@ -1175,6 +1177,7 @@ private void close ( _logger.Trace ("Begin closing the connection."); var res = closeHandshake (payloadData, send, receive, received); + releaseResources (); _logger.Trace ("End closing the connection."); From 63906a481b65b695038607ca07139dad2bbc3783 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 22 Aug 2022 21:11:14 +0900 Subject: [PATCH 4549/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 63abd3e7f..d66be8832 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1176,7 +1176,7 @@ private void close ( _logger.Trace ("Begin closing the connection."); - var res = closeHandshake (payloadData, send, receive, received); + var res = closeHandshake (payloadData, send, received); releaseResources (); @@ -1227,7 +1227,7 @@ private void closeAsync ( } private bool closeHandshake ( - PayloadData payloadData, bool send, bool receive, bool received + PayloadData payloadData, bool send, bool received ) { var sent = false; @@ -1242,7 +1242,7 @@ private bool closeHandshake ( frame.Unmask (); } - var wait = !received && sent && receive && _receivingExited != null; + var wait = !received && sent && _receivingExited != null; if (wait) received = _receivingExited.WaitOne (_waitTime); From e4c27c48d81cd73faad95575f24e426f33d1a123 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 23 Aug 2022 19:58:49 +0900 Subject: [PATCH 4550/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index d66be8832..40551ceb2 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1143,17 +1143,17 @@ private void close (ushort code, string reason) } if (code == 1005) { // == no status - close (PayloadData.Empty, true, true, false); + close (PayloadData.Empty, true, false); + return; } var send = !code.IsReserved (); - close (new PayloadData (code, reason), send, send, false); + + close (new PayloadData (code, reason), send, false); } - private void close ( - PayloadData payloadData, bool send, bool receive, bool received - ) + private void close (PayloadData payloadData, bool send, bool received) { lock (_forState) { if (_readyState == WebSocketState.Closing) { @@ -1169,7 +1169,6 @@ private void close ( } send = send && _readyState == WebSocketState.Open; - receive = send && receive; _readyState = WebSocketState.Closing; } @@ -1208,21 +1207,21 @@ private void closeAsync (ushort code, string reason) } if (code == 1005) { // == no status - closeAsync (PayloadData.Empty, true, true, false); + closeAsync (PayloadData.Empty, true, false); return; } var send = !code.IsReserved (); - closeAsync (new PayloadData (code, reason), send, send, false); + + closeAsync (new PayloadData (code, reason), send, false); } - private void closeAsync ( - PayloadData payloadData, bool send, bool receive, bool received - ) + private void closeAsync (PayloadData payloadData, bool send, bool received) { - Action closer = close; + Action closer = close; + closer.BeginInvoke ( - payloadData, send, receive, received, ar => closer.EndInvoke (ar), null + payloadData, send, received, ar => closer.EndInvoke (ar), null ); } @@ -1511,7 +1510,8 @@ private void fatal (string message, Exception exception) private void fatal (string message, ushort code) { var payload = new PayloadData (code, message); - close (payload, !code.IsReserved (), false, false); + + close (payload, !code.IsReserved (), false); } private void fatal (string message, CloseStatusCode code) @@ -1649,7 +1649,7 @@ private bool ping (byte[] data) private bool processCloseFrame (WebSocketFrame frame) { var payload = frame.PayloadData; - close (payload, !payload.HasReservedCode, false, true); + close (payload, !payload.HasReservedCode, true); return false; } From 5219134e6d10f9b739cb4949b86f0c3996da7cf2 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 23 Aug 2022 20:01:59 +0900 Subject: [PATCH 4551/6294] [Modify] Do not send --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 40551ceb2..96f9bc621 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1511,7 +1511,7 @@ private void fatal (string message, ushort code) { var payload = new PayloadData (code, message); - close (payload, !code.IsReserved (), false); + close (payload, false, false); } private void fatal (string message, CloseStatusCode code) From 07f7fc9fbd4ff0d060027e951926287dc2f39c92 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 24 Aug 2022 19:41:17 +0900 Subject: [PATCH 4552/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 96f9bc621..ee1557edf 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1133,24 +1133,27 @@ private bool checkReceivedFrame (WebSocketFrame frame, out string message) private void close (ushort code, string reason) { if (_readyState == WebSocketState.Closing) { - _logger.Info ("The closing is already in progress."); + _logger.Trace ("The closing is already in progress."); + return; } if (_readyState == WebSocketState.Closed) { - _logger.Info ("The connection has already been closed."); + _logger.Trace ("The connection has already been closed."); + return; } - if (code == 1005) { // == no status + if (code == 1005) { close (PayloadData.Empty, true, false); return; } + var data = new PayloadData (code, reason); var send = !code.IsReserved (); - close (new PayloadData (code, reason), send, false); + close (data, send, false); } private void close (PayloadData payloadData, bool send, bool received) From 3bfa7b7df33c18e48e81cae573dcc2131e2b54ba Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 24 Aug 2022 19:44:57 +0900 Subject: [PATCH 4553/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index ee1557edf..8de588487 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1200,23 +1200,27 @@ private void close (PayloadData payloadData, bool send, bool received) private void closeAsync (ushort code, string reason) { if (_readyState == WebSocketState.Closing) { - _logger.Info ("The closing is already in progress."); + _logger.Trace ("The closing is already in progress."); + return; } if (_readyState == WebSocketState.Closed) { - _logger.Info ("The connection has already been closed."); + _logger.Trace ("The connection has already been closed."); + return; } - if (code == 1005) { // == no status + if (code == 1005) { closeAsync (PayloadData.Empty, true, false); + return; } + var data = new PayloadData (code, reason); var send = !code.IsReserved (); - closeAsync (new PayloadData (code, reason), send, false); + closeAsync (data, send, false); } private void closeAsync (PayloadData payloadData, bool send, bool received) From a5238d6b1812633720dcdcc7d5ff1951c4024dbd Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 25 Aug 2022 19:24:19 +0900 Subject: [PATCH 4554/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 8de588487..ba86718a0 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1516,9 +1516,9 @@ private void fatal (string message, Exception exception) private void fatal (string message, ushort code) { - var payload = new PayloadData (code, message); + var data = new PayloadData (code, message); - close (payload, false, false); + close (data, false, false); } private void fatal (string message, CloseStatusCode code) From b227c8396d9722ae6285677bff464bec54645672 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 26 Aug 2022 20:13:32 +0900 Subject: [PATCH 4555/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index ba86718a0..3bccb7aef 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1851,8 +1851,10 @@ IEnumerable values private bool processUnsupportedFrame (WebSocketFrame frame) { - _logger.Fatal ("An unsupported frame:" + frame.PrintToString (false)); - fatal ("There is no way to handle it.", CloseStatusCode.PolicyViolation); + _logger.Fatal ("An unsupported frame was received."); + _logger.Debug ("The frame is" + frame.PrintToString (false)); + + fatal ("There is no way to handle it.", 1008); return false; } From 831c407934bbee35802f386fffdc97b13ba2303d Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 27 Aug 2022 20:31:27 +0900 Subject: [PATCH 4556/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 3bccb7aef..68340e420 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1767,10 +1767,12 @@ private bool processPongFrame (WebSocketFrame frame) private bool processReceivedFrame (WebSocketFrame frame) { string msg; + if (!checkReceivedFrame (frame, out msg)) throw new WebSocketException (CloseStatusCode.ProtocolError, msg); frame.Unmask (); + return frame.IsFragment ? processFragmentFrame (frame) : frame.IsData From 60351ea30d21e1148586ffcd99e53dd44b08b045 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 28 Aug 2022 15:00:23 +0900 Subject: [PATCH 4557/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 68340e420..cc510fc01 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1097,33 +1097,40 @@ private bool checkReceivedFrame (WebSocketFrame frame, out string message) message = null; var masked = frame.IsMasked; + if (_client && masked) { message = "A frame from the server is masked."; + return false; } if (!_client && !masked) { message = "A frame from a client is not masked."; + return false; } if (_inContinuation && frame.IsData) { - message = "A data frame has been received while receiving continuation frames."; + message = "A data frame was received while receiving continuation frames."; + return false; } if (frame.IsCompressed && _compression == CompressionMethod.None) { - message = "A compressed frame has been received without any agreement for it."; + message = "A compressed frame was received without any agreement for it."; + return false; } if (frame.Rsv2 == Rsv.On) { message = "The RSV2 of a frame is non-zero without any negotiation for it."; + return false; } if (frame.Rsv3 == Rsv.On) { message = "The RSV3 of a frame is non-zero without any negotiation for it."; + return false; } From 9bcf2cde98f62ee70e4e73258dc43ba8b898c637 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 29 Aug 2022 20:49:58 +0900 Subject: [PATCH 4558/6294] [Modify] Use close status 1003 --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index cc510fc01..711c50e89 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1863,7 +1863,7 @@ private bool processUnsupportedFrame (WebSocketFrame frame) _logger.Fatal ("An unsupported frame was received."); _logger.Debug ("The frame is" + frame.PrintToString (false)); - fatal ("There is no way to handle it.", 1008); + fatal ("There is no way to handle it.", 1003); return false; } From 0d39e948808d98ab464b1316c4f90d25bd8f864a Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 30 Aug 2022 19:44:56 +0900 Subject: [PATCH 4559/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 711c50e89..7c5993cf6 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1691,7 +1691,6 @@ private bool processDataFrame (WebSocketFrame frame) private bool processFragmentFrame (WebSocketFrame frame) { if (!_inContinuation) { - // Must process first fragment. if (frame.IsContinuation) return true; @@ -1702,13 +1701,16 @@ private bool processFragmentFrame (WebSocketFrame frame) } _fragmentsBuffer.WriteBytes (frame.PayloadData.ApplicationData, 1024); + if (frame.IsFinal) { using (_fragmentsBuffer) { var data = _fragmentsCompressed ? _fragmentsBuffer.DecompressToArray (_compression) : _fragmentsBuffer.ToArray (); - enqueueToMessageEventQueue (new MessageEventArgs (_fragmentsOpcode, data)); + var e = new MessageEventArgs (_fragmentsOpcode, data); + + enqueueToMessageEventQueue (e); } _fragmentsBuffer = null; From eee8589e5c4cdac60141c711526404ffab28c193 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 30 Aug 2022 21:01:42 +0900 Subject: [PATCH 4560/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 7c5993cf6..6fac39622 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1679,11 +1679,14 @@ private void processCookies (CookieCollection cookies) private bool processDataFrame (WebSocketFrame frame) { - enqueueToMessageEventQueue ( - frame.IsCompressed - ? new MessageEventArgs ( - frame.Opcode, frame.PayloadData.ApplicationData.Decompress (_compression)) - : new MessageEventArgs (frame)); + var e = frame.IsCompressed + ? new MessageEventArgs ( + frame.Opcode, + frame.PayloadData.ApplicationData.Decompress (_compression) + ) + : new MessageEventArgs (frame); + + enqueueToMessageEventQueue (e); return true; } From 0d04c7311cc880c24a559a065674bf3c6da16e26 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 31 Aug 2022 20:33:01 +0900 Subject: [PATCH 4561/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 6fac39622..76af71bf6 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1731,11 +1731,14 @@ private bool processPingFrame (WebSocketFrame frame) lock (_forState) { if (_readyState != WebSocketState.Open) { - _logger.Error ("The connection is closing."); + _logger.Trace ("A pong to this ping cannot be sent."); + return true; } - if (!sendBytes (pong.ToArray ())) + var bytes = pong.ToArray (); + + if (!sendBytes (bytes)) return false; } @@ -1745,7 +1748,9 @@ private bool processPingFrame (WebSocketFrame frame) if (_client) pong.Unmask (); - enqueueToMessageEventQueue (new MessageEventArgs (frame)); + var e = new MessageEventArgs (frame); + + enqueueToMessageEventQueue (e); } return true; From 864faa5806970f5da55a9d9a38dcfe5a38170684 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 1 Sep 2022 19:39:02 +0900 Subject: [PATCH 4562/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 76af71bf6..e55b1787a 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1662,8 +1662,10 @@ private bool ping (byte[] data) private bool processCloseFrame (WebSocketFrame frame) { - var payload = frame.PayloadData; - close (payload, !payload.HasReservedCode, true); + var data = frame.PayloadData; + var send = !data.HasReservedCode; + + close (data, send, true); return false; } From 829ade3a00d2736506450b736ff523e402b77c4f Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 2 Sep 2022 19:38:01 +0900 Subject: [PATCH 4563/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index e55b1787a..9593d5c15 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2335,24 +2335,35 @@ private void startReceiving () _stream, false, frame => { - if (!processReceivedFrame (frame) || _readyState == WebSocketState.Closed) { + var exit = !processReceivedFrame (frame) + || _readyState == WebSocketState.Closed; + + if (exit) { var exited = _receivingExited; + if (exited != null) exited.Set (); return; } - // Receive next asap because the Ping or Close needs a response to it. receive (); - if (_inMessage || !HasMessage || _readyState != WebSocketState.Open) + if (_inMessage) + return; + + if (!HasMessage) + return; + + if (_readyState != WebSocketState.Open) return; message (); }, ex => { - _logger.Fatal (ex.ToString ()); + _logger.Fatal (ex.Message); + _logger.Debug (ex.ToString ()); + fatal ("An exception has occurred while receiving.", ex); } ); From 36ac4e03200cb198bdd3e1cba832b73e21d09503 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 2 Sep 2022 19:45:12 +0900 Subject: [PATCH 4564/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 9593d5c15..16579b266 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1556,11 +1556,19 @@ private void init () private void message () { MessageEventArgs e = null; + lock (_forMessageEventQueue) { - if (_inMessage || _messageEventQueue.Count == 0 || _readyState != WebSocketState.Open) + if (_inMessage) + return; + + if (_messageEventQueue.Count == 0) + return; + + if (_readyState != WebSocketState.Open) return; _inMessage = true; + e = _messageEventQueue.Dequeue (); } From 529c72dd137463630ffb776a61b9dc33883766f2 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 3 Sep 2022 16:02:48 +0900 Subject: [PATCH 4565/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 16579b266..37a89ffa7 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1582,13 +1582,22 @@ private void messagec (MessageEventArgs e) OnMessage.Emit (this, e); } catch (Exception ex) { - _logger.Error (ex.ToString ()); - error ("An error has occurred during an OnMessage event.", ex); + _logger.Error (ex.Message); + _logger.Debug (ex.ToString ()); + + error ("An exception has occurred during an OnMessage event.", ex); } lock (_forMessageEventQueue) { - if (_messageEventQueue.Count == 0 || _readyState != WebSocketState.Open) { + if (_messageEventQueue.Count == 0) { + _inMessage = false; + + break; + } + + if (_readyState != WebSocketState.Open) { _inMessage = false; + break; } From 12eaca37238b4739e94fc25985daebae2b909c8f Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 3 Sep 2022 16:06:56 +0900 Subject: [PATCH 4566/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 37a89ffa7..b94025433 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1613,13 +1613,22 @@ private void messages (MessageEventArgs e) OnMessage.Emit (this, e); } catch (Exception ex) { - _logger.Error (ex.ToString ()); - error ("An error has occurred during an OnMessage event.", ex); + _logger.Error (ex.Message); + _logger.Debug (ex.ToString ()); + + error ("An exception has occurred during an OnMessage event.", ex); } lock (_forMessageEventQueue) { - if (_messageEventQueue.Count == 0 || _readyState != WebSocketState.Open) { + if (_messageEventQueue.Count == 0) { + _inMessage = false; + + return; + } + + if (_readyState != WebSocketState.Open) { _inMessage = false; + return; } From d6fb8e4195244eb1aa5de1aaaa1d7b0b5326ae08 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 4 Sep 2022 17:37:34 +0900 Subject: [PATCH 4567/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index b94025433..0d5713325 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1567,9 +1567,9 @@ private void message () if (_readyState != WebSocketState.Open) return; - _inMessage = true; - e = _messageEventQueue.Dequeue (); + + _inMessage = true; } _message (e); From 907b04dff7a7574baa7aeb5b0ed9a81ae2ca9496 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 5 Sep 2022 16:18:48 +0900 Subject: [PATCH 4568/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 6 ------ 1 file changed, 6 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 0d5713325..f127bc135 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2378,12 +2378,6 @@ private void startReceiving () if (_inMessage) return; - if (!HasMessage) - return; - - if (_readyState != WebSocketState.Open) - return; - message (); }, ex => { From 089e46817b5c87bbe63347accff52d59bdc9d0dd Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 6 Sep 2022 17:02:50 +0900 Subject: [PATCH 4569/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index f127bc135..094359151 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2361,10 +2361,10 @@ private void startReceiving () _stream, false, frame => { - var exit = !processReceivedFrame (frame) - || _readyState == WebSocketState.Closed; + var cont = processReceivedFrame (frame) + && _readyState != WebSocketState.Closed; - if (exit) { + if (!cont) { var exited = _receivingExited; if (exited != null) From 7fafe663c3d34208948bdbb6e0e3d5f45bac58dd Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 7 Sep 2022 15:44:03 +0900 Subject: [PATCH 4570/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 094359151..756ac2a53 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1641,19 +1641,31 @@ private void messages (MessageEventArgs e) private void open () { _inMessage = true; + startReceiving (); + try { OnOpen.Emit (this, EventArgs.Empty); } catch (Exception ex) { - _logger.Error (ex.ToString ()); - error ("An error has occurred during the OnOpen event.", ex); + _logger.Error (ex.Message); + _logger.Debug (ex.ToString ()); + + error ("An exception has occurred during the OnOpen event.", ex); } MessageEventArgs e = null; + lock (_forMessageEventQueue) { - if (_messageEventQueue.Count == 0 || _readyState != WebSocketState.Open) { + if (_messageEventQueue.Count == 0) { _inMessage = false; + + return; + } + + if (_readyState != WebSocketState.Open) { + _inMessage = false; + return; } From 8ba876f0d199f179bad8632ed3029dc9da204541 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 8 Sep 2022 19:38:18 +0900 Subject: [PATCH 4571/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 756ac2a53..a48c0382f 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1503,8 +1503,10 @@ private void enqueueToMessageEventQueue (MessageEventArgs e) private void error (string message, Exception exception) { + var e = new ErrorEventArgs (message, exception); + try { - OnError.Emit (this, new ErrorEventArgs (message, exception)); + OnError.Emit (this, e); } catch (Exception ex) { _logger.Error (ex.Message); From dfb39a602ac3aaba2508e609e00aef4eef47fd09 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 9 Sep 2022 19:44:31 +0900 Subject: [PATCH 4572/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index a48c0382f..7c6b56490 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2584,13 +2584,14 @@ internal bool Ping (byte[] frameAsBytes, TimeSpan timeout) if (_readyState != WebSocketState.Open) return false; - var pongReceived = _pongReceived; - if (pongReceived == null) + var received = _pongReceived; + + if (received == null) return false; lock (_forPing) { try { - pongReceived.Reset (); + received.Reset (); lock (_forState) { if (_readyState != WebSocketState.Open) @@ -2600,7 +2601,7 @@ internal bool Ping (byte[] frameAsBytes, TimeSpan timeout) return false; } - return pongReceived.WaitOne (timeout); + return received.WaitOne (timeout); } catch (ObjectDisposedException) { return false; From 878153d15779d4bee337f51d50982e0b463b0028 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 10 Sep 2022 22:03:25 +0900 Subject: [PATCH 4573/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 7c6b56490..4490cfaa5 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1682,17 +1682,21 @@ private bool ping (byte[] data) if (_readyState != WebSocketState.Open) return false; - var pongReceived = _pongReceived; - if (pongReceived == null) + var received = _pongReceived; + + if (received == null) return false; lock (_forPing) { try { - pongReceived.Reset (); - if (!send (Fin.Final, Opcode.Ping, data, false)) + received.Reset (); + + var sent = send (Fin.Final, Opcode.Ping, data, false); + + if (!sent) return false; - return pongReceived.WaitOne (_waitTime); + return received.WaitOne (_waitTime); } catch (ObjectDisposedException) { return false; From 8fc6dc0e2169916666a93b656d50a3a2ddf17878 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 11 Sep 2022 21:58:39 +0900 Subject: [PATCH 4574/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 4490cfaa5..e833fdb32 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2601,7 +2601,9 @@ internal bool Ping (byte[] frameAsBytes, TimeSpan timeout) if (_readyState != WebSocketState.Open) return false; - if (!sendBytes (frameAsBytes)) + var sent = sendBytes (frameAsBytes); + + if (!sent) return false; } From db7f68ae9795c1054869d70c721b59200be32088 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 12 Sep 2022 21:45:33 +0900 Subject: [PATCH 4575/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index e833fdb32..f644768f8 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1809,16 +1809,10 @@ private bool processPongFrame (WebSocketFrame frame) try { _pongReceived.Set (); } - catch (NullReferenceException ex) { - _logger.Error (ex.Message); - _logger.Debug (ex.ToString ()); - + catch (NullReferenceException) { return false; } - catch (ObjectDisposedException ex) { - _logger.Error (ex.Message); - _logger.Debug (ex.ToString ()); - + catch (ObjectDisposedException) { return false; } From b07a88283a5b2fee0e600d40d3eabcd16f463708 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 13 Sep 2022 19:34:27 +0900 Subject: [PATCH 4576/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index f644768f8..3732f2f34 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1783,8 +1783,9 @@ private bool processPingFrame (WebSocketFrame frame) } var bytes = pong.ToArray (); + var sent = sendBytes (bytes); - if (!sendBytes (bytes)) + if (!sent) return false; } From d7075b9fa25b71c03680d6a8f20f2e90f2be8e84 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 14 Sep 2022 19:49:49 +0900 Subject: [PATCH 4577/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 3732f2f34..7229d68d3 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2003,6 +2003,7 @@ private bool send (Opcode opcode, Stream stream) var src = stream; var compressed = false; var sent = false; + try { if (_compression != CompressionMethod.None) { stream = stream.Compress (_compression); @@ -2010,12 +2011,15 @@ private bool send (Opcode opcode, Stream stream) } sent = send (opcode, stream, compressed); + if (!sent) error ("A send has been interrupted.", null); } catch (Exception ex) { - _logger.Error (ex.ToString ()); - error ("An error has occurred during a send.", ex); + _logger.Error (ex.Message); + _logger.Debug (ex.ToString ()); + + error ("An exception has occurred during a send.", ex); } finally { if (compressed) From 87c6698f4974975353a31bdbb54fbb899d357373 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 15 Sep 2022 20:12:05 +0900 Subject: [PATCH 4578/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 7229d68d3..f636c6617 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2087,12 +2087,15 @@ private bool send (Fin fin, Opcode opcode, byte[] data, bool compressed) { lock (_forState) { if (_readyState != WebSocketState.Open) { - _logger.Error ("The connection is closing."); + _logger.Trace ("The connection is closing."); + return false; } var frame = new WebSocketFrame (fin, opcode, data, compressed, _client); - return sendBytes (frame.ToArray ()); + var bytes = frame.ToArray (); + + return sendBytes (bytes); } } From 874b30ea7518298cfcc954b447a5c7772e543622 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 16 Sep 2022 20:20:05 +0900 Subject: [PATCH 4579/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index f636c6617..6b3304480 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2099,22 +2099,28 @@ private bool send (Fin fin, Opcode opcode, byte[] data, bool compressed) } } - private void sendAsync (Opcode opcode, Stream stream, Action completed) + private void sendAsync ( + Opcode opcode, Stream stream, Action completed + ) { Func sender = send; + sender.BeginInvoke ( opcode, stream, ar => { try { var sent = sender.EndInvoke (ar); + if (completed != null) completed (sent); } catch (Exception ex) { - _logger.Error (ex.ToString ()); + _logger.Error (ex.Message); + _logger.Debug (ex.ToString ()); + error ( - "An error has occurred during the callback for an async send.", + "An exception has occurred during the callback for an async send.", ex ); } From 0882def38ea84a85bf10e47292b4e698de70df33 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 17 Sep 2022 21:21:26 +0900 Subject: [PATCH 4580/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 6b3304480..5a7e4baeb 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2035,6 +2035,7 @@ private bool send (Opcode opcode, Stream stream) private bool send (Opcode opcode, Stream stream, bool compressed) { var len = stream.Length; + if (len == 0) return send (Fin.Final, opcode, EmptyBytes, false); @@ -2042,14 +2043,17 @@ private bool send (Opcode opcode, Stream stream, bool compressed) var rem = (int) (len % FragmentLength); byte[] buff = null; + if (quo == 0) { buff = new byte[rem]; + return stream.Read (buff, 0, rem) == rem && send (Fin.Final, opcode, buff, compressed); } if (quo == 1 && rem == 0) { buff = new byte[FragmentLength]; + return stream.Read (buff, 0, FragmentLength) == FragmentLength && send (Fin.Final, opcode, buff, compressed); } @@ -2057,7 +2061,9 @@ private bool send (Opcode opcode, Stream stream, bool compressed) /* Send fragments */ // Begin + buff = new byte[FragmentLength]; + var sent = stream.Read (buff, 0, FragmentLength) == FragmentLength && send (Fin.More, opcode, buff, compressed); @@ -2065,6 +2071,7 @@ private bool send (Opcode opcode, Stream stream, bool compressed) return false; var n = rem == 0 ? quo - 2 : quo - 1; + for (long i = 0; i < n; i++) { sent = stream.Read (buff, 0, FragmentLength) == FragmentLength && send (Fin.More, Opcode.Cont, buff, false); @@ -2074,6 +2081,7 @@ private bool send (Opcode opcode, Stream stream, bool compressed) } // End + if (rem == 0) rem = FragmentLength; else From bf602b284e61b4e950227d90c293f9159ea7e70c Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 18 Sep 2022 22:42:42 +0900 Subject: [PATCH 4581/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 5a7e4baeb..25b842d24 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -841,7 +841,9 @@ private bool accept () } try { - if (!acceptHandshake ()) + var accepted = acceptHandshake (); + + if (!accepted) return false; } catch (Exception ex) { @@ -855,6 +857,7 @@ private bool accept () } _readyState = WebSocketState.Open; + return true; } } From ae0d641ac945b183b51e2a8e81c6f2a147f3fb1e Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 19 Sep 2022 21:10:56 +0900 Subject: [PATCH 4582/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 25b842d24..c9b568557 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -806,8 +806,9 @@ public TimeSpan WaitTime { private bool accept () { if (_readyState == WebSocketState.Open) { - var msg = "The handshake request has already been accepted."; - _logger.Warn (msg); + var msg = "The connection has already been established."; + + _logger.Trace (msg); return false; } From bf59c208304e1e0f6fd2b21f734df236f45d2b6b Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 20 Sep 2022 19:34:37 +0900 Subject: [PATCH 4583/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index c9b568557..ef31fe94c 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -815,8 +815,9 @@ private bool accept () lock (_forState) { if (_readyState == WebSocketState.Open) { - var msg = "The handshake request has already been accepted."; - _logger.Warn (msg); + var msg = "The connection has already been established."; + + _logger.Trace (msg); return false; } From e1ed67d287a84a398a4dbc0161dcc8faf64dcf29 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 21 Sep 2022 19:37:18 +0900 Subject: [PATCH 4584/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index ef31fe94c..e5fd1d577 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -823,10 +823,10 @@ private bool accept () } if (_readyState == WebSocketState.Closing) { - var msg = "The close process has set in."; + var msg = "The connection is closing."; + _logger.Error (msg); - msg = "An interruption has occurred while attempting to accept."; error (msg, null); return false; From 8a4e44a7ca5acb8ca2a873907291bc1765746b1e Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 22 Sep 2022 19:37:52 +0900 Subject: [PATCH 4585/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index e5fd1d577..d46f7ae8b 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -834,9 +834,9 @@ private bool accept () if (_readyState == WebSocketState.Closed) { var msg = "The connection has been closed."; + _logger.Error (msg); - msg = "An interruption has occurred while attempting to accept."; error (msg, null); return false; From b65c7341e5a71d2f7996b3c43c13d0a6a15e2282 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 23 Sep 2022 21:22:59 +0900 Subject: [PATCH 4586/6294] [Modify] Add it --- websocket-sharp/Net/HttpListenerContext.cs | 46 ++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/websocket-sharp/Net/HttpListenerContext.cs b/websocket-sharp/Net/HttpListenerContext.cs index 9e3f9607d..ba214d978 100644 --- a/websocket-sharp/Net/HttpListenerContext.cs +++ b/websocket-sharp/Net/HttpListenerContext.cs @@ -197,6 +197,52 @@ private static string createErrorContent ( #region Internal Methods + internal HttpListenerWebSocketContext AcceptWebSocket ( + string protocol, Action initializer + ) + { + if (_websocketContext != null) { + var msg = "The method has already been done."; + + throw new InvalidOperationException (msg); + } + + if (protocol != null) { + if (protocol.Length == 0) { + var msg = "An empty string."; + + throw new ArgumentException (msg, "protocol"); + } + + if (!protocol.IsToken ()) { + var msg = "It contains an invalid character."; + + throw new ArgumentException (msg, "protocol"); + } + } + + var ctx = GetWebSocketContext (protocol); + var ws = ctx.WebSocket; + + if (initializer != null) { + try { + initializer (ws); + } + catch (Exception ex) { + if (ws.ReadyState == WebSocketState.Connecting) + _websocketContext = null; + + var msg = "It caused an exception."; + + throw new ArgumentException (msg, "initializer", ex); + } + } + + ws.Accept (); + + return ctx; + } + internal HttpListenerWebSocketContext GetWebSocketContext (string protocol) { _websocketContext = new HttpListenerWebSocketContext (this, protocol); From a3a9f67a96f464c17c0d3dbdf43375787c4f2a6a Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 24 Sep 2022 20:46:48 +0900 Subject: [PATCH 4587/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerContext.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerContext.cs b/websocket-sharp/Net/HttpListenerContext.cs index ba214d978..f2da2baa4 100644 --- a/websocket-sharp/Net/HttpListenerContext.cs +++ b/websocket-sharp/Net/HttpListenerContext.cs @@ -221,8 +221,9 @@ internal HttpListenerWebSocketContext AcceptWebSocket ( } } - var ctx = GetWebSocketContext (protocol); - var ws = ctx.WebSocket; + var ret = GetWebSocketContext (protocol); + + var ws = ret.WebSocket; if (initializer != null) { try { @@ -240,7 +241,7 @@ internal HttpListenerWebSocketContext AcceptWebSocket ( ws.Accept (); - return ctx; + return ret; } internal HttpListenerWebSocketContext GetWebSocketContext (string protocol) From c24325ecfd0b95bcafa6bd0b817331d7d90ac5c4 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 25 Sep 2022 22:01:03 +0900 Subject: [PATCH 4588/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 8 -------- 1 file changed, 8 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index d46f7ae8b..057733782 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -805,14 +805,6 @@ public TimeSpan WaitTime { // As server private bool accept () { - if (_readyState == WebSocketState.Open) { - var msg = "The connection has already been established."; - - _logger.Trace (msg); - - return false; - } - lock (_forState) { if (_readyState == WebSocketState.Open) { var msg = "The connection has already been established."; From 7316d3bef05baef2ae68d15f23f28ad7fa4ef9a1 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 26 Sep 2022 21:06:52 +0900 Subject: [PATCH 4589/6294] [Modify] To internal --- websocket-sharp/WebSocket.cs | 56 +++++++----------------------------- 1 file changed, 11 insertions(+), 45 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 057733782..71e263ce2 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2482,6 +2482,17 @@ private bool validateSecWebSocketExtensionsServerHeader (string value) #region Internal Methods + // As server + internal void Accept () + { + var accepted = accept (); + + if (!accepted) + return; + + open (); + } + // As server internal void Close (HttpResponse response) { @@ -2682,51 +2693,6 @@ internal void Send ( #region Public Methods - /// - /// Accepts the handshake request. - /// - /// - /// This method does nothing if the handshake request has already been - /// accepted. - /// - /// - /// - /// This instance is a client. - /// - /// - /// -or- - /// - /// - /// The close process is in progress. - /// - /// - /// -or- - /// - /// - /// The connection has already been closed. - /// - /// - public void Accept () - { - if (_client) { - var msg = "This instance is a client."; - throw new InvalidOperationException (msg); - } - - if (_readyState == WebSocketState.Closing) { - var msg = "The close process is in progress."; - throw new InvalidOperationException (msg); - } - - if (_readyState == WebSocketState.Closed) { - var msg = "The connection has already been closed."; - throw new InvalidOperationException (msg); - } - - if (accept ()) - open (); - } - /// /// Accepts the handshake request asynchronously. /// From 51a7ea5791c5ab6d808eb261c715d6d9d329f873 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 26 Sep 2022 21:15:20 +0900 Subject: [PATCH 4590/6294] [Modify] To internal --- websocket-sharp/WebSocket.cs | 74 +++++++++--------------------------- 1 file changed, 18 insertions(+), 56 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 71e263ce2..35fe6f2fb 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2493,6 +2493,24 @@ internal void Accept () open (); } + // As server + internal void AcceptAsync () + { + Func acceptor = accept; + + acceptor.BeginInvoke ( + ar => { + var accepted = acceptor.EndInvoke (ar); + + if (!accepted) + return; + + open (); + }, + null + ); + } + // As server internal void Close (HttpResponse response) { @@ -2693,62 +2711,6 @@ internal void Send ( #region Public Methods - /// - /// Accepts the handshake request asynchronously. - /// - /// - /// - /// This method does not wait for the accept process to be complete. - /// - /// - /// This method does nothing if the handshake request has already been - /// accepted. - /// - /// - /// - /// - /// This instance is a client. - /// - /// - /// -or- - /// - /// - /// The close process is in progress. - /// - /// - /// -or- - /// - /// - /// The connection has already been closed. - /// - /// - public void AcceptAsync () - { - if (_client) { - var msg = "This instance is a client."; - throw new InvalidOperationException (msg); - } - - if (_readyState == WebSocketState.Closing) { - var msg = "The close process is in progress."; - throw new InvalidOperationException (msg); - } - - if (_readyState == WebSocketState.Closed) { - var msg = "The connection has already been closed."; - throw new InvalidOperationException (msg); - } - - Func acceptor = accept; - acceptor.BeginInvoke ( - ar => { - if (acceptor.EndInvoke (ar)) - open (); - }, - null - ); - } - /// /// Closes the connection. /// From ce0e1437b7dfe5622eb0e423e0a49e547b76319c Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 27 Sep 2022 19:59:07 +0900 Subject: [PATCH 4591/6294] [Modify] Replace it --- websocket-sharp/Net/HttpListenerContext.cs | 22 +--------------------- 1 file changed, 1 insertion(+), 21 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerContext.cs b/websocket-sharp/Net/HttpListenerContext.cs index f2da2baa4..891758b9c 100644 --- a/websocket-sharp/Net/HttpListenerContext.cs +++ b/websocket-sharp/Net/HttpListenerContext.cs @@ -367,27 +367,7 @@ internal void Unregister () ///
public HttpListenerWebSocketContext AcceptWebSocket (string protocol) { - if (_websocketContext != null) { - var msg = "The accepting is already in progress."; - - throw new InvalidOperationException (msg); - } - - if (protocol != null) { - if (protocol.Length == 0) { - var msg = "An empty string."; - - throw new ArgumentException (msg, "protocol"); - } - - if (!protocol.IsToken ()) { - var msg = "It contains an invalid character."; - - throw new ArgumentException (msg, "protocol"); - } - } - - return GetWebSocketContext (protocol); + return AcceptWebSocket (protocol, null); } #endregion From 9ef217517e1a91b7d817702618e41f4f4f6ec275 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 28 Sep 2022 19:36:54 +0900 Subject: [PATCH 4592/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerContext.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerContext.cs b/websocket-sharp/Net/HttpListenerContext.cs index 891758b9c..337b00937 100644 --- a/websocket-sharp/Net/HttpListenerContext.cs +++ b/websocket-sharp/Net/HttpListenerContext.cs @@ -363,7 +363,7 @@ internal void Unregister () /// /// /// - /// This method has already been called. + /// This method has already been done. /// public HttpListenerWebSocketContext AcceptWebSocket (string protocol) { From d1d6e02a49c1cfb291b54811e4f6f183ca7aabb6 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 29 Sep 2022 19:35:23 +0900 Subject: [PATCH 4593/6294] [Modify] To public --- websocket-sharp/Net/HttpListenerContext.cs | 139 ++++++++++++++------- 1 file changed, 92 insertions(+), 47 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerContext.cs b/websocket-sharp/Net/HttpListenerContext.cs index 337b00937..19709b419 100644 --- a/websocket-sharp/Net/HttpListenerContext.cs +++ b/websocket-sharp/Net/HttpListenerContext.cs @@ -197,53 +197,6 @@ private static string createErrorContent ( #region Internal Methods - internal HttpListenerWebSocketContext AcceptWebSocket ( - string protocol, Action initializer - ) - { - if (_websocketContext != null) { - var msg = "The method has already been done."; - - throw new InvalidOperationException (msg); - } - - if (protocol != null) { - if (protocol.Length == 0) { - var msg = "An empty string."; - - throw new ArgumentException (msg, "protocol"); - } - - if (!protocol.IsToken ()) { - var msg = "It contains an invalid character."; - - throw new ArgumentException (msg, "protocol"); - } - } - - var ret = GetWebSocketContext (protocol); - - var ws = ret.WebSocket; - - if (initializer != null) { - try { - initializer (ws); - } - catch (Exception ex) { - if (ws.ReadyState == WebSocketState.Connecting) - _websocketContext = null; - - var msg = "It caused an exception."; - - throw new ArgumentException (msg, "initializer", ex); - } - } - - ws.Accept (); - - return ret; - } - internal HttpListenerWebSocketContext GetWebSocketContext (string protocol) { _websocketContext = new HttpListenerWebSocketContext (this, protocol); @@ -370,6 +323,98 @@ public HttpListenerWebSocketContext AcceptWebSocket (string protocol) return AcceptWebSocket (protocol, null); } + /// + /// Accepts a WebSocket handshake request. + /// + /// + /// A that represents + /// the WebSocket handshake request. + /// + /// + /// + /// A that specifies the subprotocol supported + /// on the WebSocket connection. + /// + /// + /// if not necessary. + /// + /// + /// + /// + /// An delegate. + /// + /// + /// It specifies the delegate that invokes the method called when + /// initializing a new WebSocket instance. + /// + /// + /// + /// + /// is empty. + /// + /// + /// -or- + /// + /// + /// contains an invalid character. + /// + /// + /// -or- + /// + /// + /// caused an exception. + /// + /// + /// + /// This method has already been done. + /// + public HttpListenerWebSocketContext AcceptWebSocket ( + string protocol, Action initializer + ) + { + if (_websocketContext != null) { + var msg = "The method has already been done."; + + throw new InvalidOperationException (msg); + } + + if (protocol != null) { + if (protocol.Length == 0) { + var msg = "An empty string."; + + throw new ArgumentException (msg, "protocol"); + } + + if (!protocol.IsToken ()) { + var msg = "It contains an invalid character."; + + throw new ArgumentException (msg, "protocol"); + } + } + + var ret = GetWebSocketContext (protocol); + + var ws = ret.WebSocket; + + if (initializer != null) { + try { + initializer (ws); + } + catch (Exception ex) { + if (ws.ReadyState == WebSocketState.Connecting) + _websocketContext = null; + + var msg = "It caused an exception."; + + throw new ArgumentException (msg, "initializer", ex); + } + } + + ws.Accept (); + + return ret; + } + #endregion } } From 892c4e312143002c6e223948a760a050aaf7a2d3 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 29 Sep 2022 22:00:45 +0900 Subject: [PATCH 4594/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerContext.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerContext.cs b/websocket-sharp/Net/HttpListenerContext.cs index 19709b419..0ff04f57a 100644 --- a/websocket-sharp/Net/HttpListenerContext.cs +++ b/websocket-sharp/Net/HttpListenerContext.cs @@ -301,8 +301,13 @@ internal void Unregister () /// the WebSocket handshake request. /// /// - /// A that specifies the subprotocol supported on - /// the WebSocket connection. + /// + /// A that specifies the subprotocol supported + /// on the WebSocket connection. + /// + /// + /// if not necessary. + /// /// /// /// From c9603b079620a11fe662eace1e535d6aec6e54e0 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 30 Sep 2022 20:22:16 +0900 Subject: [PATCH 4595/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerContext.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerContext.cs b/websocket-sharp/Net/HttpListenerContext.cs index 0ff04f57a..41bf07124 100644 --- a/websocket-sharp/Net/HttpListenerContext.cs +++ b/websocket-sharp/Net/HttpListenerContext.cs @@ -302,8 +302,8 @@ internal void Unregister () /// /// /// - /// A that specifies the subprotocol supported - /// on the WebSocket connection. + /// A that specifies the name of the subprotocol + /// supported on the WebSocket connection. /// /// /// if not necessary. From 2068af9fcda7dc9d43eaad4e1bdc9caf244b85d9 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 30 Sep 2022 20:24:03 +0900 Subject: [PATCH 4596/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerContext.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerContext.cs b/websocket-sharp/Net/HttpListenerContext.cs index 41bf07124..b0d2cc800 100644 --- a/websocket-sharp/Net/HttpListenerContext.cs +++ b/websocket-sharp/Net/HttpListenerContext.cs @@ -294,7 +294,7 @@ internal void Unregister () #region Public Methods /// - /// Accepts a WebSocket handshake request. + /// Accepts a WebSocket connection. /// /// /// A that represents From 0a95b21da5766708130f44a2795f3b1f3d1484a5 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 1 Oct 2022 16:04:58 +0900 Subject: [PATCH 4597/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerContext.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerContext.cs b/websocket-sharp/Net/HttpListenerContext.cs index b0d2cc800..ba328d4cf 100644 --- a/websocket-sharp/Net/HttpListenerContext.cs +++ b/websocket-sharp/Net/HttpListenerContext.cs @@ -337,8 +337,8 @@ public HttpListenerWebSocketContext AcceptWebSocket (string protocol) /// /// /// - /// A that specifies the subprotocol supported - /// on the WebSocket connection. + /// A that specifies the name of the subprotocol + /// supported on the WebSocket connection. /// /// /// if not necessary. From 5a7a9d6b97e50e0007f7b339e9886ff6f7a87930 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 2 Oct 2022 15:52:32 +0900 Subject: [PATCH 4598/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerContext.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerContext.cs b/websocket-sharp/Net/HttpListenerContext.cs index ba328d4cf..61c0182d7 100644 --- a/websocket-sharp/Net/HttpListenerContext.cs +++ b/websocket-sharp/Net/HttpListenerContext.cs @@ -329,7 +329,8 @@ public HttpListenerWebSocketContext AcceptWebSocket (string protocol) } /// - /// Accepts a WebSocket handshake request. + /// Accepts a WebSocket connection with initializing the WebSocket + /// interface. /// /// /// A that represents From 7130f9305fb265a0ebcc7ab56d652ad1d6c1c628 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 3 Oct 2022 21:05:25 +0900 Subject: [PATCH 4599/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 35fe6f2fb..449c776a7 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -867,7 +867,8 @@ private bool acceptHandshake () if (!checkHandshakeRequest (_context, out msg)) { _logger.Error (msg); - var reason = "A handshake error has occurred while attempting to accept."; + var reason = "A handshake error has occurred."; + refuseHandshake (CloseStatusCode.ProtocolError, reason); return false; From 9de06c718ef7465a3e315f73ab9848271fbbf8e3 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 3 Oct 2022 21:07:12 +0900 Subject: [PATCH 4600/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 449c776a7..63cc534c8 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -877,7 +877,8 @@ private bool acceptHandshake () if (!customCheckHandshakeRequest (_context, out msg)) { _logger.Error (msg); - var reason = "A handshake error has occurred while attempting to accept."; + var reason = "A handshake error has occurred."; + refuseHandshake (CloseStatusCode.PolicyViolation, reason); return false; From a681a7f116f3688d54920926eb72ab3d6cc46038 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 4 Oct 2022 19:45:44 +0900 Subject: [PATCH 4601/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 63cc534c8..b9a64313c 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -859,13 +859,14 @@ private bool accept () // As server private bool acceptHandshake () { - var fmt = "A handshake request from {0}:\n{1}"; - var msg = String.Format (fmt, _context.UserEndPoint, _context); + var fmt = "A handshake request from {0}."; + var msg = String.Format (fmt, _context.UserEndPoint); - _logger.Debug (msg); + _logger.Trace (msg); if (!checkHandshakeRequest (_context, out msg)) { _logger.Error (msg); + _logger.Debug (_context.ToString ()); var reason = "A handshake error has occurred."; @@ -876,6 +877,7 @@ private bool acceptHandshake () if (!customCheckHandshakeRequest (_context, out msg)) { _logger.Error (msg); + _logger.Debug (_context.ToString ()); var reason = "A handshake error has occurred."; From 495e6bb6714bc5153fc63da41ed181ec316443ad Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 5 Oct 2022 19:54:57 +0900 Subject: [PATCH 4602/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index b9a64313c..61b711908 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -859,10 +859,7 @@ private bool accept () // As server private bool acceptHandshake () { - var fmt = "A handshake request from {0}."; - var msg = String.Format (fmt, _context.UserEndPoint); - - _logger.Trace (msg); + string msg; if (!checkHandshakeRequest (_context, out msg)) { _logger.Error (msg); From 1d0731f23f95845bdc001a0493d64f1e787c40c5 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 6 Oct 2022 19:37:08 +0900 Subject: [PATCH 4603/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 61b711908..ba0b2aacb 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1923,8 +1923,8 @@ private void refuseHandshake (CloseStatusCode code, string reason) _readyState = WebSocketState.Closing; var res = createHandshakeFailureResponse (HttpStatusCode.BadRequest); - sendHttpResponse (res); + sendHttpResponse (res); releaseServerResources (); _readyState = WebSocketState.Closed; From 2af12744d1191c4fc10047c8734d2271d26dda06 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 6 Oct 2022 19:40:59 +0900 Subject: [PATCH 4604/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index ba0b2aacb..9dc804a59 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2261,11 +2261,6 @@ private HttpResponse sendHttpRequest ( // As server private bool sendHttpResponse (HttpResponse response) { - var fmt = "An HTTP response to {0}:\n{1}"; - var msg = String.Format (fmt, _context.UserEndPoint, response); - - _logger.Debug (msg); - var bytes = response.ToByteArray (); return sendBytes (bytes); From f98aa2aabf632f4ea841e36bf3855bbd785c8516 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 7 Oct 2022 19:42:55 +0900 Subject: [PATCH 4605/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 9dc804a59..0c12e6cc5 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1986,11 +1986,12 @@ private void releaseResources () // As server private void releaseServerResources () { - if (_closeContext == null) - return; + if (_closeContext != null) { + _closeContext (); + + _closeContext = null; + } - _closeContext (); - _closeContext = null; _stream = null; _context = null; } From 92f8d996d98ae9a755dc8cfcb910438729323f86 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 8 Oct 2022 15:03:04 +0900 Subject: [PATCH 4606/6294] [Modify] Remove it --- websocket-sharp/WebSocket.cs | 6 ------ 1 file changed, 6 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 0c12e6cc5..2cb836d06 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2519,12 +2519,6 @@ internal void Close (HttpResponse response) _readyState = WebSocketState.Closed; } - // As server - internal void Close (HttpStatusCode code) - { - Close (createHandshakeFailureResponse (code)); - } - // As server internal void Close (PayloadData payloadData, byte[] frameAsBytes) { From 8d06f3c54f4d891833d14215f5425a3acbca6e88 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 8 Oct 2022 15:03:37 +0900 Subject: [PATCH 4607/6294] [Modify] Remove it --- websocket-sharp/WebSocket.cs | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 2cb836d06..24ddc0721 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2508,17 +2508,6 @@ internal void AcceptAsync () ); } - // As server - internal void Close (HttpResponse response) - { - _readyState = WebSocketState.Closing; - - sendHttpResponse (response); - releaseServerResources (); - - _readyState = WebSocketState.Closed; - } - // As server internal void Close (PayloadData payloadData, byte[] frameAsBytes) { From bf24f0dfe0777f1e0784e053333e731c962004de Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 9 Oct 2022 17:25:20 +0900 Subject: [PATCH 4608/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 24ddc0721..ceb5a3670 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -834,21 +834,22 @@ private bool accept () return false; } - try { - var accepted = acceptHandshake (); + var accepted = false; - if (!accepted) - return false; + try { + accepted = acceptHandshake (); } catch (Exception ex) { _logger.Fatal (ex.Message); _logger.Debug (ex.ToString ()); var msg = "An exception has occurred while attempting to accept."; + fatal (msg, ex); + } + if (!accepted) return false; - } _readyState = WebSocketState.Open; From 92f47ff9f68ffb8df96ede8cdd2fda73cd7987cd Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 10 Oct 2022 15:32:06 +0900 Subject: [PATCH 4609/6294] [Modify] Replace it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index b2a5dd217..4b0b849e0 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -471,7 +471,7 @@ internal void Start ( _websocket.OnError += onError; _websocket.OnClose += onClose; - _websocket.InternalAccept (); + _websocket.Accept (); } #endregion From 8e175845420d7dd707d7636747a71a0b5037ba91 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 10 Oct 2022 21:22:18 +0900 Subject: [PATCH 4610/6294] [Modify] Remove it --- websocket-sharp/WebSocket.cs | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index ceb5a3670..fa7a9aa1e 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2583,28 +2583,6 @@ internal static string CreateResponseKey (string base64Key) return Convert.ToBase64String (src); } - // As server - internal void InternalAccept () - { - try { - if (!acceptHandshake ()) - return; - } - catch (Exception ex) { - _logger.Fatal (ex.Message); - _logger.Debug (ex.ToString ()); - - var msg = "An exception has occurred while attempting to accept."; - fatal (msg, ex); - - return; - } - - _readyState = WebSocketState.Open; - - open (); - } - // As server internal bool Ping (byte[] frameAsBytes, TimeSpan timeout) { From b3b907de9dc992b8eb403324b3a32338ccc1858a Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 11 Oct 2022 16:11:49 +0900 Subject: [PATCH 4611/6294] [Modify] 2022 --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 4b0b849e0..47eaafc0f 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -4,7 +4,7 @@ * * The MIT License * - * Copyright (c) 2012-2021 sta.blockhead + * Copyright (c) 2012-2022 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From 63b9747240dfc0cc2a00f93db7756585a0d78295 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 11 Oct 2022 16:14:20 +0900 Subject: [PATCH 4612/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index fa7a9aa1e..dabf1133a 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2568,6 +2568,7 @@ internal void Close (PayloadData payloadData, byte[] frameAsBytes) internal static string CreateBase64Key () { var src = new byte[16]; + RandomNumber.GetBytes (src); return Convert.ToBase64String (src); From 41bd09d086fcee8765921e963c1256b25e228cfb Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 11 Oct 2022 17:26:07 +0900 Subject: [PATCH 4613/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index dabf1133a..6b217c87e 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2576,10 +2576,11 @@ internal static string CreateBase64Key () internal static string CreateResponseKey (string base64Key) { - var buff = new StringBuilder (base64Key, 64); - buff.Append (_guid); SHA1 sha1 = new SHA1CryptoServiceProvider (); - var src = sha1.ComputeHash (buff.ToString ().GetUTF8EncodedBytes ()); + + var data = base64Key + _guid; + var bytes = data.GetUTF8EncodedBytes (); + var src = sha1.ComputeHash (bytes); return Convert.ToBase64String (src); } From 2eedf9488cde430af6c85120f5d6e9520e534b63 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 12 Oct 2022 14:59:56 +0900 Subject: [PATCH 4614/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 6b217c87e..4075a6c6d 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3331,22 +3331,23 @@ public void CloseAsync (CloseStatusCode code, string reason) public void Connect () { if (!_client) { - var msg = "This instance is not a client."; - throw new InvalidOperationException (msg); - } + var msg = "The instance is not a client."; - if (_readyState == WebSocketState.Closing) { - var msg = "The close process is in progress."; throw new InvalidOperationException (msg); } if (_retryCountForConnect > _maxRetryCountForConnect) { var msg = "A series of reconnecting has failed."; + throw new InvalidOperationException (msg); } - if (connect ()) - open (); + var connected = connect (); + + if (!connected) + return; + + open (); } /// From 7b4c6776d7a29dfd5154ad6e783b1d9a5dc039b0 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 12 Oct 2022 15:03:00 +0900 Subject: [PATCH 4615/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 4075a6c6d..e63cd98d7 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3309,7 +3309,8 @@ public void CloseAsync (CloseStatusCode code, string reason) /// Establishes a connection. /// /// - /// This method does nothing if the connection has already been established. + /// This method does nothing if the connection has already been + /// established. /// /// /// @@ -3319,12 +3320,6 @@ public void CloseAsync (CloseStatusCode code, string reason) /// -or- /// /// - /// The close process is in progress. - /// - /// - /// -or- - /// - /// /// A series of reconnecting has failed. /// /// From 485026b5c0ef162928471383056942a39d1465fb Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 12 Oct 2022 15:09:15 +0900 Subject: [PATCH 4616/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index e63cd98d7..e1e4d9234 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3377,25 +3377,27 @@ public void Connect () public void ConnectAsync () { if (!_client) { - var msg = "This instance is not a client."; - throw new InvalidOperationException (msg); - } + var msg = "The instance is not a client."; - if (_readyState == WebSocketState.Closing) { - var msg = "The close process is in progress."; throw new InvalidOperationException (msg); } if (_retryCountForConnect > _maxRetryCountForConnect) { var msg = "A series of reconnecting has failed."; + throw new InvalidOperationException (msg); } Func connector = connect; + connector.BeginInvoke ( ar => { - if (connector.EndInvoke (ar)) - open (); + var connected = connector.EndInvoke (ar); + + if (!connected) + return; + + open (); }, null ); From 5ac43b080a1e4942f0d46dabc67bd8b27cad6a62 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 12 Oct 2022 15:11:18 +0900 Subject: [PATCH 4617/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 6 ------ 1 file changed, 6 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index e1e4d9234..b6d347c46 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3365,12 +3365,6 @@ public void Connect () /// -or- /// /// - /// The close process is in progress. - /// - /// - /// -or- - /// - /// /// A series of reconnecting has failed. /// /// From 904861ddd34120e0fc93ad7bb5c28ea180ce0907 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 13 Oct 2022 14:39:37 +0900 Subject: [PATCH 4618/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index b6d347c46..ebd50dea0 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1276,26 +1276,22 @@ private bool closeHandshake ( // As client private bool connect () { - if (_readyState == WebSocketState.Open) { - var msg = "The connection has already been established."; - _logger.Warn (msg); - - return false; - } - lock (_forState) { if (_readyState == WebSocketState.Open) { var msg = "The connection has already been established."; - _logger.Warn (msg); + + _logger.Error (msg); + + error (msg, null); return false; } if (_readyState == WebSocketState.Closing) { - var msg = "The close process has set in."; + var msg = "The connection is closing."; + _logger.Error (msg); - msg = "An interruption has occurred while attempting to connect."; error (msg, null); return false; @@ -1303,9 +1299,9 @@ private bool connect () if (_retryCountForConnect > _maxRetryCountForConnect) { var msg = "An opportunity for reconnecting has been lost."; + _logger.Error (msg); - msg = "An interruption has occurred while attempting to connect."; error (msg, null); return false; @@ -1317,18 +1313,20 @@ private bool connect () doHandshake (); } catch (Exception ex) { - _retryCountForConnect++; - _logger.Fatal (ex.Message); _logger.Debug (ex.ToString ()); + _retryCountForConnect++; + var msg = "An exception has occurred while attempting to connect."; + fatal (msg, ex); return false; } _retryCountForConnect = 1; + _readyState = WebSocketState.Open; return true; From 87ab06c45e858042b253ed946fd7d231aeae1210 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 13 Oct 2022 14:47:33 +0900 Subject: [PATCH 4619/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index ebd50dea0..44b847e77 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2245,17 +2245,7 @@ private HttpResponse sendHttpRequest ( HttpRequest request, int millisecondsTimeout ) { - var msg = "An HTTP request to the server:\n" + request.ToString (); - - _logger.Debug (msg); - - var res = request.GetResponse (_stream, millisecondsTimeout); - - msg = "An HTTP response from the server:\n" + res.ToString (); - - _logger.Debug (msg); - - return res; + return request.GetResponse (_stream, millisecondsTimeout); } // As server From e70cb194f1ac3d7bd4f0491e8a97d2dfd31b39a5 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 13 Oct 2022 16:01:10 +0900 Subject: [PATCH 4620/6294] [Modify] Return a bool --- websocket-sharp/WebSocket.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 44b847e77..ede34d407 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1469,7 +1469,7 @@ private MessageEventArgs dequeueFromMessageEventQueue () } // As client - private void doHandshake () + private bool doHandshake () { setClientStream (); @@ -1490,6 +1490,8 @@ private void doHandshake () } processCookies (res.Cookies); + + return true; } private void enqueueToMessageEventQueue (MessageEventArgs e) From 7013bb317981cb2804db4c3675ab798878089bbb Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 13 Oct 2022 16:08:13 +0900 Subject: [PATCH 4621/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index ede34d407..8aebd5546 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1309,8 +1309,10 @@ private bool connect () _readyState = WebSocketState.Connecting; + var done = false; + try { - doHandshake (); + done = doHandshake (); } catch (Exception ex) { _logger.Fatal (ex.Message); @@ -1321,9 +1323,10 @@ private bool connect () var msg = "An exception has occurred while attempting to connect."; fatal (msg, ex); + } + if (!done) return false; - } _retryCountForConnect = 1; From b4de1b862d57aa389425af8a4fb866bd23a15dbf Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 14 Oct 2022 15:06:27 +0900 Subject: [PATCH 4622/6294] [Modify] Replace it --- websocket-sharp/WebSocket.cs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 8aebd5546..8fa00716c 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1480,8 +1480,18 @@ private bool doHandshake () string msg; - if (!checkHandshakeResponse (res, out msg)) - throw new WebSocketException (CloseStatusCode.ProtocolError, msg); + if (!checkHandshakeResponse (res, out msg)) { + _logger.Error (msg); + _logger.Debug (res.ToString ()); + + _retryCountForConnect++; + + var reason = "A handshake error has occurred."; + + fatal (reason, CloseStatusCode.ProtocolError); + + return false; + } if (_protocolsRequested) _protocol = res.Headers["Sec-WebSocket-Protocol"]; From e8281633c4e6a6a9b7e7ddd49e922152820bcd9f Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 14 Oct 2022 15:11:39 +0900 Subject: [PATCH 4623/6294] [Modify] Add it --- websocket-sharp/WebSocket.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 8fa00716c..d7faa2958 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -802,6 +802,13 @@ public TimeSpan WaitTime { #region Private Methods + private void abort (ushort code, string reason) + { + var data = new PayloadData (code, reason); + + close (data, false, false); + } + // As server private bool accept () { From 32cf2cc7d945857f14215fb5eeb4dd434dbe1d0f Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 14 Oct 2022 15:20:29 +0900 Subject: [PATCH 4624/6294] [Modify] Replace it --- websocket-sharp/WebSocket.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index d7faa2958..35e171c64 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1493,9 +1493,7 @@ private bool doHandshake () _retryCountForConnect++; - var reason = "A handshake error has occurred."; - - fatal (reason, CloseStatusCode.ProtocolError); + abort (1002, "A handshake error has occurred."); return false; } From a292f8170e9fda0a6091b2000cd65b80f3240c04 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 14 Oct 2022 15:26:37 +0900 Subject: [PATCH 4625/6294] [Modify] Replace it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 35e171c64..9268511c2 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1931,7 +1931,7 @@ private bool processUnsupportedFrame (WebSocketFrame frame) _logger.Fatal ("An unsupported frame was received."); _logger.Debug ("The frame is" + frame.PrintToString (false)); - fatal ("There is no way to handle it.", 1003); + abort (1003, "There is no way to handle it."); return false; } From 83f4397c0f090253f34de096dd6e014fee3bdac9 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 14 Oct 2022 15:33:21 +0900 Subject: [PATCH 4626/6294] [Modify] Add it --- websocket-sharp/WebSocket.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 9268511c2..88c4151b3 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -802,6 +802,15 @@ public TimeSpan WaitTime { #region Private Methods + private void abort (string reason, Exception exception) + { + var code = exception is WebSocketException + ? ((WebSocketException) exception).Code + : CloseStatusCode.Abnormal; + + abort ((ushort) code, reason); + } + private void abort (ushort code, string reason) { var data = new PayloadData (code, reason); From c8a9152169658de1f7c8a9ff5ca0f3982549b1d2 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 14 Oct 2022 15:41:43 +0900 Subject: [PATCH 4627/6294] [Modify] Replace it --- websocket-sharp/WebSocket.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 88c4151b3..7897f3238 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1336,9 +1336,7 @@ private bool connect () _retryCountForConnect++; - var msg = "An exception has occurred while attempting to connect."; - - fatal (msg, ex); + abort ("An exception has occurred while connecting.", ex); } if (!done) From e649a0ec67a88213121d864a6f85ddf3b700125a Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 14 Oct 2022 15:43:10 +0900 Subject: [PATCH 4628/6294] [Modify] Replace it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 7897f3238..a19a1b54a 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2428,7 +2428,7 @@ private void startReceiving () _logger.Fatal (ex.Message); _logger.Debug (ex.ToString ()); - fatal ("An exception has occurred while receiving.", ex); + abort ("An exception has occurred while receiving.", ex); } ); From bf6f7ad10ee35618be6db3794206297036085f42 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 14 Oct 2022 15:46:16 +0900 Subject: [PATCH 4629/6294] [Modify] Replace it --- websocket-sharp/WebSocket.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index a19a1b54a..3984972bd 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -859,9 +859,7 @@ private bool accept () _logger.Fatal (ex.Message); _logger.Debug (ex.ToString ()); - var msg = "An exception has occurred while attempting to accept."; - - fatal (msg, ex); + abort ("An exception has occurred while accepting.", ex); } if (!accepted) From 0e52febe15c27f354844c87ef57ced4d6f6b22e9 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 15 Oct 2022 15:14:06 +0900 Subject: [PATCH 4630/6294] [Modify] Remove it --- websocket-sharp/WebSocket.cs | 9 --------- 1 file changed, 9 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 3984972bd..39180707f 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1536,15 +1536,6 @@ private void error (string message, Exception exception) } } - private void fatal (string message, Exception exception) - { - var code = exception is WebSocketException - ? ((WebSocketException) exception).Code - : CloseStatusCode.Abnormal; - - fatal (message, (ushort) code); - } - private void fatal (string message, ushort code) { var data = new PayloadData (code, message); From 647c00dd7341aa1bea7e216bf8a75b5a692f6655 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 15 Oct 2022 15:14:46 +0900 Subject: [PATCH 4631/6294] [Modify] Remove it --- websocket-sharp/WebSocket.cs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 39180707f..8edce95ea 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1543,11 +1543,6 @@ private void fatal (string message, ushort code) close (data, false, false); } - private void fatal (string message, CloseStatusCode code) - { - fatal (message, (ushort) code); - } - private ClientSslConfiguration getSslConfiguration () { if (_sslConfig == null) From 2ed9e7b40f7b2333016dc67f74db1598371aa120 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 15 Oct 2022 15:15:54 +0900 Subject: [PATCH 4632/6294] [Modify] Remove it --- websocket-sharp/WebSocket.cs | 7 ------- 1 file changed, 7 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 8edce95ea..038c17a96 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1536,13 +1536,6 @@ private void error (string message, Exception exception) } } - private void fatal (string message, ushort code) - { - var data = new PayloadData (code, message); - - close (data, false, false); - } - private ClientSslConfiguration getSslConfiguration () { if (_sslConfig == null) From 168973e53c95fc7383ecce6706a80dafa0c6c649 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 15 Oct 2022 15:58:27 +0900 Subject: [PATCH 4633/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 038c17a96..c9477b07d 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1292,11 +1292,9 @@ private bool connect () { lock (_forState) { if (_readyState == WebSocketState.Open) { - var msg = "The connection has already been established."; - - _logger.Error (msg); + _logger.Error ("The connection has already been established."); - error (msg, null); + error ("An error has occurred while connecting.", null); return false; } From 378dfe2db610d6305478759d1f1dbfadf5eb616a Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 15 Oct 2022 16:00:51 +0900 Subject: [PATCH 4634/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index c9477b07d..4abf35876 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1300,11 +1300,9 @@ private bool connect () } if (_readyState == WebSocketState.Closing) { - var msg = "The connection is closing."; - - _logger.Error (msg); + _logger.Error ("The connection is closing."); - error (msg, null); + error ("An error has occurred while connecting.", null); return false; } From 2f50b515ebd861c8d4e436a9cd80105c84aee1ab Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 16 Oct 2022 14:36:51 +0900 Subject: [PATCH 4635/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 4abf35876..795c71c89 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1308,11 +1308,9 @@ private bool connect () } if (_retryCountForConnect > _maxRetryCountForConnect) { - var msg = "An opportunity for reconnecting has been lost."; + _logger.Error ("An opportunity for reconnecting has been lost."); - _logger.Error (msg); - - error (msg, null); + error ("An error has occurred while connecting.", null); return false; } From 5f07f80df33ac2d1a54c232fc0e9c82a8231ad55 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 16 Oct 2022 14:38:11 +0900 Subject: [PATCH 4636/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 795c71c89..7648c54cd 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1292,9 +1292,7 @@ private bool connect () { lock (_forState) { if (_readyState == WebSocketState.Open) { - _logger.Error ("The connection has already been established."); - - error ("An error has occurred while connecting.", null); + _logger.Trace ("The connection has already been established."); return false; } From a381c9234ae651db6f525ee53ca28d7b146969f0 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 17 Oct 2022 14:57:25 +0900 Subject: [PATCH 4637/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 7648c54cd..3672fd5a2 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1298,7 +1298,7 @@ private bool connect () } if (_readyState == WebSocketState.Closing) { - _logger.Error ("The connection is closing."); + _logger.Error ("The closing is in progress."); error ("An error has occurred while connecting.", null); From 1cb97379f8eb2caa51516269115fdf5cddea88e2 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 18 Oct 2022 15:48:02 +0900 Subject: [PATCH 4638/6294] [Modify] Move the place where the retry count is added --- websocket-sharp/WebSocket.cs | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 3672fd5a2..7d43d71d2 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -275,6 +275,7 @@ public WebSocket (string url, params string[] protocols) _client = true; _logger = new Logger (); _message = messagec; + _retryCountForConnect = -1; _secure = _uri.Scheme == "wss"; _waitTime = TimeSpan.FromSeconds (5); @@ -1305,7 +1306,7 @@ private bool connect () return false; } - if (_retryCountForConnect > _maxRetryCountForConnect) { + if (_retryCountForConnect >= _maxRetryCountForConnect) { _logger.Error ("An opportunity for reconnecting has been lost."); error ("An error has occurred while connecting.", null); @@ -1313,6 +1314,8 @@ private bool connect () return false; } + _retryCountForConnect++; + _readyState = WebSocketState.Connecting; var done = false; @@ -1324,15 +1327,13 @@ private bool connect () _logger.Fatal (ex.Message); _logger.Debug (ex.ToString ()); - _retryCountForConnect++; - abort ("An exception has occurred while connecting.", ex); } if (!done) return false; - _retryCountForConnect = 1; + _retryCountForConnect = -1; _readyState = WebSocketState.Open; @@ -1488,8 +1489,6 @@ private bool doHandshake () _logger.Error (msg); _logger.Debug (res.ToString ()); - _retryCountForConnect++; - abort (1002, "A handshake error has occurred."); return false; @@ -3315,7 +3314,7 @@ public void Connect () throw new InvalidOperationException (msg); } - if (_retryCountForConnect > _maxRetryCountForConnect) { + if (_retryCountForConnect >= _maxRetryCountForConnect) { var msg = "A series of reconnecting has failed."; throw new InvalidOperationException (msg); @@ -3360,7 +3359,7 @@ public void ConnectAsync () throw new InvalidOperationException (msg); } - if (_retryCountForConnect > _maxRetryCountForConnect) { + if (_retryCountForConnect >= _maxRetryCountForConnect) { var msg = "A series of reconnecting has failed."; throw new InvalidOperationException (msg); From 51d2b7bb78ce04e22deb55ec8eb225c7dfa9a52e Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 18 Oct 2022 15:49:52 +0900 Subject: [PATCH 4639/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 7d43d71d2..776f5040c 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -824,9 +824,7 @@ private bool accept () { lock (_forState) { if (_readyState == WebSocketState.Open) { - var msg = "The connection has already been established."; - - _logger.Trace (msg); + _logger.Trace ("The connection has already been established."); return false; } From d6ee6c65174b8543ef6dad643fb5e7a5e0fbe525 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 18 Oct 2022 15:52:39 +0900 Subject: [PATCH 4640/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 776f5040c..8046b50e8 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -830,11 +830,9 @@ private bool accept () } if (_readyState == WebSocketState.Closing) { - var msg = "The connection is closing."; + _logger.Error ("The connection is closing."); - _logger.Error (msg); - - error (msg, null); + error ("An error has occurred while accepting.", null); return false; } From ebe43e26cae49c3c3a2259954c6964e30bf1d034 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 19 Oct 2022 14:59:39 +0900 Subject: [PATCH 4641/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 8046b50e8..f53f58775 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -838,11 +838,9 @@ private bool accept () } if (_readyState == WebSocketState.Closed) { - var msg = "The connection has been closed."; + _logger.Error ("The connection has been closed."); - _logger.Error (msg); - - error (msg, null); + error ("An error has occurred while accepting.", null); return false; } From e9a25cf83d4828f87bc0142ed8a377636ddfe8d1 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 19 Oct 2022 15:33:43 +0900 Subject: [PATCH 4642/6294] [Modify] Add it --- websocket-sharp/WebSocket.cs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index f53f58775..dfff0c782 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1905,6 +1905,29 @@ private bool processUnsupportedFrame (WebSocketFrame frame) return false; } + // As server + private void refuseHandshake (ushort code, string reason) + { + _readyState = WebSocketState.Closing; + + var res = createHandshakeFailureResponse (HttpStatusCode.BadRequest); + + sendHttpResponse (res); + releaseServerResources (); + + _readyState = WebSocketState.Closed; + + var e = new CloseEventArgs (code, reason, false); + + try { + OnClose.Emit (this, e); + } + catch (Exception ex) { + _logger.Error (ex.Message); + _logger.Debug (ex.ToString ()); + } + } + // As server private void refuseHandshake (CloseStatusCode code, string reason) { From bc8e202f98eeab0af2be8205fe2561447546e320 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 19 Oct 2022 15:37:13 +0900 Subject: [PATCH 4643/6294] [Modify] Replace it --- websocket-sharp/WebSocket.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index dfff0c782..7ed23b66c 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -875,9 +875,7 @@ private bool acceptHandshake () _logger.Error (msg); _logger.Debug (_context.ToString ()); - var reason = "A handshake error has occurred."; - - refuseHandshake (CloseStatusCode.ProtocolError, reason); + refuseHandshake (1002, "A handshake error has occurred."); return false; } From 6e76987841a7ddc459118f11eeaf8a8e65caca82 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 20 Oct 2022 15:00:44 +0900 Subject: [PATCH 4644/6294] [Modify] Replace it --- websocket-sharp/WebSocket.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 7ed23b66c..e25471c77 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -884,9 +884,7 @@ private bool acceptHandshake () _logger.Error (msg); _logger.Debug (_context.ToString ()); - var reason = "A handshake error has occurred."; - - refuseHandshake (CloseStatusCode.PolicyViolation, reason); + refuseHandshake (1008, "A handshake error has occurred."); return false; } From a59cbe2d2f93db27303147f9f037817622b1cb99 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 20 Oct 2022 15:02:48 +0900 Subject: [PATCH 4645/6294] [Modify] Remove it --- websocket-sharp/WebSocket.cs | 23 ----------------------- 1 file changed, 23 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index e25471c77..dcbae8583 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1924,29 +1924,6 @@ private void refuseHandshake (ushort code, string reason) } } - // As server - private void refuseHandshake (CloseStatusCode code, string reason) - { - _readyState = WebSocketState.Closing; - - var res = createHandshakeFailureResponse (HttpStatusCode.BadRequest); - - sendHttpResponse (res); - releaseServerResources (); - - _readyState = WebSocketState.Closed; - - var e = new CloseEventArgs ((ushort) code, reason, false); - - try { - OnClose.Emit (this, e); - } - catch (Exception ex) { - _logger.Error (ex.Message); - _logger.Debug (ex.ToString ()); - } - } - // As client private void releaseClientResources () { From 59326c03f0fe6714b587d3c98538fb7338de8957 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 20 Oct 2022 15:05:23 +0900 Subject: [PATCH 4646/6294] [Modify] Use 1002 (protocol error) --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index dcbae8583..e890a7b02 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -884,7 +884,7 @@ private bool acceptHandshake () _logger.Error (msg); _logger.Debug (_context.ToString ()); - refuseHandshake (1008, "A handshake error has occurred."); + refuseHandshake (1002, "A handshake error has occurred."); return false; } From 60c9a10a41db43a854f79ea0f86adc8dd49ec5a6 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 20 Oct 2022 17:25:39 +0900 Subject: [PATCH 4647/6294] [Modify] Use 1011 (server error) --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index e890a7b02..0972d442c 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -854,7 +854,7 @@ private bool accept () _logger.Fatal (ex.Message); _logger.Debug (ex.ToString ()); - abort ("An exception has occurred while accepting.", ex); + abort (1011, "An exception has occurred while accepting."); } if (!accepted) From 062bed2890680c57b46ddb75a35b555ebebc485a Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 21 Oct 2022 17:32:33 +0900 Subject: [PATCH 4648/6294] [Modify] Replace it --- websocket-sharp/WebSocket.cs | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 0972d442c..9b8718113 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1904,24 +1904,11 @@ private bool processUnsupportedFrame (WebSocketFrame frame) // As server private void refuseHandshake (ushort code, string reason) { - _readyState = WebSocketState.Closing; - var res = createHandshakeFailureResponse (HttpStatusCode.BadRequest); sendHttpResponse (res); - releaseServerResources (); - - _readyState = WebSocketState.Closed; - - var e = new CloseEventArgs (code, reason, false); - try { - OnClose.Emit (this, e); - } - catch (Exception ex) { - _logger.Error (ex.Message); - _logger.Debug (ex.ToString ()); - } + abort (code, reason); } // As client From 3afe3c444a7c2daff9280d991cc1d986e2b26313 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 21 Oct 2022 17:46:44 +0900 Subject: [PATCH 4649/6294] [Modify] Replace it --- websocket-sharp/WebSocket.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 9b8718113..732bfd4fb 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -905,7 +905,9 @@ private bool acceptHandshake () var res = createHandshakeResponse (); - return sendHttpResponse (res); + sendHttpResponse (res); + + return true; } private bool canSet (out string message) @@ -2221,11 +2223,9 @@ private HttpResponse sendHttpRequest ( } // As server - private bool sendHttpResponse (HttpResponse response) + private void sendHttpResponse (HttpResponse response) { - var bytes = response.ToByteArray (); - - return sendBytes (bytes); + response.WriteTo (_stream); } // As client From 414e6b9db0e810ba13eed223dc3cbd0d4507aecb Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 22 Oct 2022 15:35:03 +0900 Subject: [PATCH 4650/6294] [Modify] Add it --- websocket-sharp/WebSocket.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 732bfd4fb..81ace74c3 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1375,6 +1375,16 @@ private string createExtensions () return buff.ToString (); } + // As server + private HttpResponse createHandshakeFailureResponse () + { + var ret = HttpResponse.CreateCloseResponse (HttpStatusCode.BadRequest); + + ret.Headers["Sec-WebSocket-Version"] = _version; + + return ret; + } + // As server private HttpResponse createHandshakeFailureResponse (HttpStatusCode code) { From 8bb1256232c4b8060669941ba49c4e6b5e94f73b Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 22 Oct 2022 15:37:03 +0900 Subject: [PATCH 4651/6294] [Modify] Replace it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 81ace74c3..d85b8a844 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1916,7 +1916,7 @@ private bool processUnsupportedFrame (WebSocketFrame frame) // As server private void refuseHandshake (ushort code, string reason) { - var res = createHandshakeFailureResponse (HttpStatusCode.BadRequest); + var res = createHandshakeFailureResponse (); sendHttpResponse (res); From a535e7cc46d6b5064e69b135a53b597515d1a089 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 22 Oct 2022 15:38:33 +0900 Subject: [PATCH 4652/6294] [Modify] Remove it --- websocket-sharp/WebSocket.cs | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index d85b8a844..b749afeab 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1385,16 +1385,6 @@ private HttpResponse createHandshakeFailureResponse () return ret; } - // As server - private HttpResponse createHandshakeFailureResponse (HttpStatusCode code) - { - var ret = HttpResponse.CreateCloseResponse (code); - - ret.Headers["Sec-WebSocket-Version"] = _version; - - return ret; - } - // As client private HttpRequest createHandshakeRequest () { From 3b20694c843ec4e7923891d2f58691d504173b67 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 23 Oct 2022 17:01:01 +0900 Subject: [PATCH 4653/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index b749afeab..67c9324b4 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1918,11 +1918,13 @@ private void releaseClientResources () { if (_stream != null) { _stream.Dispose (); + _stream = null; } if (_tcpClient != null) { _tcpClient.Close (); + _tcpClient = null; } } From c2ad943b15dae8f1fef52908e7b4046e43db2b45 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 24 Oct 2022 15:45:26 +0900 Subject: [PATCH 4654/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 67c9324b4..8ed4df9df 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1933,17 +1933,20 @@ private void releaseCommonResources () { if (_fragmentsBuffer != null) { _fragmentsBuffer.Dispose (); + _fragmentsBuffer = null; _inContinuation = false; } if (_pongReceived != null) { _pongReceived.Close (); + _pongReceived = null; } if (_receivingExited != null) { _receivingExited.Close (); + _receivingExited = null; } } From 19ad20dff751231e7f54a0656149592eb4453092 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 25 Oct 2022 13:25:19 +0900 Subject: [PATCH 4655/6294] [Modify] Add it --- websocket-sharp/WebSocket.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 8ed4df9df..cdff725ba 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -910,6 +910,12 @@ private bool acceptHandshake () return true; } + private bool canSet () + { + return _readyState == WebSocketState.Connecting + || _readyState == WebSocketState.Closed; + } + private bool canSet (out string message) { message = null; From ec10bd722063b328e7baee211de7fd71014df043 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 25 Oct 2022 13:29:16 +0900 Subject: [PATCH 4656/6294] [Modify] Replace it --- websocket-sharp/WebSocket.cs | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index cdff725ba..dfbddc5d3 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -365,16 +365,9 @@ public CompressionMethod Compression { throw new InvalidOperationException (msg); } - if (!canSet (out msg)) { - _logger.Warn (msg); - return; - } - lock (_forState) { - if (!canSet (out msg)) { - _logger.Warn (msg); + if (!canSet ()) return; - } _compression = value; } From b5d23b978eafc3936f927aac67fec53f08577f72 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 25 Oct 2022 13:31:33 +0900 Subject: [PATCH 4657/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index dfbddc5d3..60d805563 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -358,10 +358,9 @@ public CompressionMethod Compression { } set { - string msg = null; - if (!_client) { - msg = "This instance is not a client."; + var msg = "The instance is not a client."; + throw new InvalidOperationException (msg); } From 58bcffbfab770e5d13ba614dee11bf816db21cbb Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 25 Oct 2022 13:48:06 +0900 Subject: [PATCH 4658/6294] [Modify] Replace it --- websocket-sharp/WebSocket.cs | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 60d805563..ed69d7662 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -469,16 +469,9 @@ public bool EnableRedirection { throw new InvalidOperationException (msg); } - if (!canSet (out msg)) { - _logger.Warn (msg); - return; - } - lock (_forState) { - if (!canSet (out msg)) { - _logger.Warn (msg); + if (!canSet ()) return; - } _enableRedirection = value; } From 4c6f5775bd6309cf37f215729b8a52106c65bb6c Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 25 Oct 2022 13:49:36 +0900 Subject: [PATCH 4659/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index ed69d7662..3d176f07b 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -462,10 +462,9 @@ public bool EnableRedirection { } set { - string msg = null; - if (!_client) { - msg = "This instance is not a client."; + var msg = "The instance is not a client."; + throw new InvalidOperationException (msg); } From 7ff6ace584c5309d53011a08c0a16dfa5c78df9d Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 25 Oct 2022 14:05:38 +0900 Subject: [PATCH 4660/6294] [Modify] Replace it --- websocket-sharp/WebSocket.cs | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 3d176f07b..4935dbe45 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -609,16 +609,9 @@ public string Origin { } } - if (!canSet (out msg)) { - _logger.Warn (msg); - return; - } - lock (_forState) { - if (!canSet (out msg)) { - _logger.Warn (msg); + if (!canSet ()) return; - } _origin = !value.IsNullOrEmpty () ? value.TrimEnd ('/') : value; } From 5f4c3c910539d0f2a6e95ac4a72c4746013c9918 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 25 Oct 2022 14:46:41 +0900 Subject: [PATCH 4661/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 4935dbe45..0550ef20e 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -589,22 +589,24 @@ public string Origin { } set { - string msg = null; - if (!_client) { - msg = "This instance is not a client."; + var msg = "The instance is not a client."; + throw new InvalidOperationException (msg); } if (!value.IsNullOrEmpty ()) { Uri uri; + if (!Uri.TryCreate (value, UriKind.Absolute, out uri)) { - msg = "Not an absolute URI string."; + var msg = "Not an absolute URI string."; + throw new ArgumentException (msg, "value"); } if (uri.Segments.Length > 1) { - msg = "It includes the path segments."; + var msg = "It includes the path segments."; + throw new ArgumentException (msg, "value"); } } From f9f5e3ec2f71c60f28b6fb110a68e748e6b1258e Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 25 Oct 2022 14:51:44 +0900 Subject: [PATCH 4662/6294] [Modify] Replace it --- websocket-sharp/WebSocket.cs | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 0550ef20e..90610b55a 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -737,17 +737,9 @@ public TimeSpan WaitTime { if (value <= TimeSpan.Zero) throw new ArgumentOutOfRangeException ("value", "Zero or less."); - string msg; - if (!canSet (out msg)) { - _logger.Warn (msg); - return; - } - lock (_forState) { - if (!canSet (out msg)) { - _logger.Warn (msg); + if (!canSet ()) return; - } _waitTime = value; } From 479d9d460ba7625c0b5e5ac69412f68c7ebdfc5b Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 25 Oct 2022 14:55:34 +0900 Subject: [PATCH 4663/6294] [Modify] Replace it --- websocket-sharp/WebSocket.cs | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 90610b55a..1ebbe236a 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3861,16 +3861,9 @@ public void SetCookie (Cookie cookie) if (cookie == null) throw new ArgumentNullException ("cookie"); - if (!canSet (out msg)) { - _logger.Warn (msg); - return; - } - lock (_forState) { - if (!canSet (out msg)) { - _logger.Warn (msg); + if (!canSet ()) return; - } lock (_cookies.SyncRoot) _cookies.SetOrRemove (cookie); From f7610da8db66648ac5fa055fe59fc2d3d72df60c Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 25 Oct 2022 14:56:58 +0900 Subject: [PATCH 4664/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 1ebbe236a..582b6b2af 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3851,10 +3851,9 @@ public void SendAsync (Stream stream, int length, Action completed) /// public void SetCookie (Cookie cookie) { - string msg = null; - if (!_client) { - msg = "This instance is not a client."; + var msg = "The instance is not a client."; + throw new InvalidOperationException (msg); } From 1a23ba31eeab27389f34e67f287ae123d2133e19 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 25 Oct 2022 14:59:44 +0900 Subject: [PATCH 4665/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 582b6b2af..86a38005a 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3841,7 +3841,7 @@ public void SendAsync (Stream stream, int length, Action completed) /// established or it is closing. /// /// - /// A that represents the cookie to send. + /// A that specifies the cookie to send. /// /// /// This instance is not a client. From c20a85a899dd85d83a7591b6b3e3f516ed4916ab Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 25 Oct 2022 15:02:09 +0900 Subject: [PATCH 4666/6294] [Modify] Replace it --- websocket-sharp/WebSocket.cs | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 86a38005a..bdd11facc 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3936,16 +3936,9 @@ public void SetCredentials (string username, string password, bool preAuth) } } - if (!canSet (out msg)) { - _logger.Warn (msg); - return; - } - lock (_forState) { - if (!canSet (out msg)) { - _logger.Warn (msg); + if (!canSet ()) return; - } if (username.IsNullOrEmpty ()) { _credentials = null; From fa2a592d534a05cd3c55fc95a24c71c3882f21a2 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 25 Oct 2022 16:04:57 +0900 Subject: [PATCH 4667/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index bdd11facc..d234bdb95 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3915,23 +3915,24 @@ public void SetCookie (Cookie cookie) /// public void SetCredentials (string username, string password, bool preAuth) { - string msg = null; - if (!_client) { - msg = "This instance is not a client."; + var msg = "The instance is not a client."; + throw new InvalidOperationException (msg); } if (!username.IsNullOrEmpty ()) { if (username.Contains (':') || !username.IsText ()) { - msg = "It contains an invalid character."; + var msg = "It contains an invalid character."; + throw new ArgumentException (msg, "username"); } } if (!password.IsNullOrEmpty ()) { if (!password.IsText ()) { - msg = "It contains an invalid character."; + var msg = "It contains an invalid character."; + throw new ArgumentException (msg, "password"); } } From 19e489bc7c1b99fd5edcc7bbf52f96acc742e530 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 26 Oct 2022 16:07:03 +0900 Subject: [PATCH 4668/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index d234bdb95..8f57e838d 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3878,8 +3878,8 @@ public void SetCookie (Cookie cookie) /// /// /// - /// A that represents the username associated with - /// the credentials. + /// A that specifies the username associated + /// with the credentials. /// /// /// or an empty string if initializes @@ -3888,16 +3888,17 @@ public void SetCookie (Cookie cookie) /// /// /// - /// A that represents the password for the username - /// associated with the credentials. + /// A that specifies the password for the + /// username associated with the credentials. /// /// /// or an empty string if not necessary. /// /// /// - /// true if sends the credentials for the Basic authentication in - /// advance with the first handshake request; otherwise, false. + /// A : true if sends the credentials for + /// the Basic authentication in advance with the first handshake + /// request; otherwise, false. /// /// /// This instance is not a client. From df9a73dcd45b4ec23e1a398a4998a9346f045509 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 26 Oct 2022 16:11:32 +0900 Subject: [PATCH 4669/6294] [Modify] Replace it --- websocket-sharp/WebSocket.cs | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 8f57e838d..b244d7083 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -4071,16 +4071,9 @@ public void SetProxy (string url, string username, string password) } } - if (!canSet (out msg)) { - _logger.Warn (msg); - return; - } - lock (_forState) { - if (!canSet (out msg)) { - _logger.Warn (msg); + if (!canSet ()) return; - } if (url.IsNullOrEmpty ()) { _proxyUri = null; From e9d7c7dbad6a155041a93a46970dd3d804c7b10e Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 27 Oct 2022 20:06:56 +0900 Subject: [PATCH 4670/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index b244d7083..2733509c1 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -4031,10 +4031,9 @@ public void SetCredentials (string username, string password, bool preAuth) /// public void SetProxy (string url, string username, string password) { - string msg = null; - if (!_client) { - msg = "This instance is not a client."; + var msg = "The instance is not a client."; + throw new InvalidOperationException (msg); } @@ -4042,31 +4041,36 @@ public void SetProxy (string url, string username, string password) if (!url.IsNullOrEmpty ()) { if (!Uri.TryCreate (url, UriKind.Absolute, out uri)) { - msg = "Not an absolute URI string."; + var msg = "Not an absolute URI string."; + throw new ArgumentException (msg, "url"); } if (uri.Scheme != "http") { - msg = "The scheme part is not http."; + var msg = "The scheme part is not http."; + throw new ArgumentException (msg, "url"); } if (uri.Segments.Length > 1) { - msg = "It includes the path segments."; + var msg = "It includes the path segments."; + throw new ArgumentException (msg, "url"); } } if (!username.IsNullOrEmpty ()) { if (username.Contains (':') || !username.IsText ()) { - msg = "It contains an invalid character."; + var msg = "It contains an invalid character."; + throw new ArgumentException (msg, "username"); } } if (!password.IsNullOrEmpty ()) { if (!password.IsText ()) { - msg = "It contains an invalid character."; + var msg = "It contains an invalid character."; + throw new ArgumentException (msg, "password"); } } From 030c49b1cd75b6676d84f685ebd1ae3c44458ce5 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 28 Oct 2022 20:54:43 +0900 Subject: [PATCH 4671/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 2733509c1..6452b76a7 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3967,31 +3967,31 @@ public void SetCredentials (string username, string password, bool preAuth) /// /// /// - /// A that represents the URL of the proxy server - /// through which to connect. + /// A that specifies the URL of the proxy + /// server through which to connect. /// /// /// The syntax is http://<host>[:<port>]. /// /// - /// or an empty string if initializes the URL and - /// the credentials. + /// or an empty string if initializes + /// the URL and the credentials. /// /// /// /// - /// A that represents the username associated with - /// the credentials. + /// A that specifies the username associated + /// with the credentials. /// /// - /// or an empty string if the credentials are not - /// necessary. + /// or an empty string if the credentials + /// are not necessary. /// /// /// /// - /// A that represents the password for the username - /// associated with the credentials. + /// A that specifies the password for the + /// username associated with the credentials. /// /// /// or an empty string if not necessary. From 870973f1ab1501b0bc19e4b75549e8770cbe3a3b Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 29 Oct 2022 21:54:49 +0900 Subject: [PATCH 4672/6294] [Modify] Remove it --- websocket-sharp/WebSocket.cs | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 6452b76a7..3be478554 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -887,23 +887,6 @@ private bool canSet () || _readyState == WebSocketState.Closed; } - private bool canSet (out string message) - { - message = null; - - if (_readyState == WebSocketState.Open) { - message = "The connection has already been established."; - return false; - } - - if (_readyState == WebSocketState.Closing) { - message = "The connection is closing."; - return false; - } - - return true; - } - // As server private bool checkHandshakeRequest ( WebSocketContext context, out string message From 0eee1c495888241cd4a89402365cfe3d9375fd99 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 30 Oct 2022 16:29:46 +0900 Subject: [PATCH 4673/6294] [Modify] Remove it --- websocket-sharp/WebSocket.cs | 6 ------ 1 file changed, 6 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 3be478554..65b4653ce 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -321,12 +321,6 @@ internal bool IgnoreExtensions { } } - internal bool IsConnected { - get { - return _readyState == WebSocketState.Open || _readyState == WebSocketState.Closing; - } - } - #endregion #region Public Properties From 32ac2515c0de21cb643270a1d8e1aa22aa51be20 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 31 Oct 2022 21:18:05 +0900 Subject: [PATCH 4674/6294] [Modify] Remove it --- websocket-sharp/WebSocket.cs | 7 ------- 1 file changed, 7 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 65b4653ce..d9d7f6368 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -303,13 +303,6 @@ internal Func CustomHandshakeRequestChecker { } } - internal bool HasMessage { - get { - lock (_forMessageEventQueue) - return _messageEventQueue.Count > 0; - } - } - // As server internal bool IgnoreExtensions { get { From 87be172cdb93dd22a76ac670d5893e27a298bca0 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 1 Nov 2022 19:48:19 +0900 Subject: [PATCH 4675/6294] [Modify] Add New as one of the WebSoketState enum values --- websocket-sharp/Net/HttpListenerContext.cs | 2 +- websocket-sharp/WebSocket.cs | 12 ++++---- websocket-sharp/WebSocketState.cs | 35 +++++++++++----------- 3 files changed, 25 insertions(+), 24 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerContext.cs b/websocket-sharp/Net/HttpListenerContext.cs index 61c0182d7..77fd99553 100644 --- a/websocket-sharp/Net/HttpListenerContext.cs +++ b/websocket-sharp/Net/HttpListenerContext.cs @@ -407,7 +407,7 @@ public HttpListenerWebSocketContext AcceptWebSocket ( initializer (ws); } catch (Exception ex) { - if (ws.ReadyState == WebSocketState.Connecting) + if (ws.ReadyState == WebSocketState.New) _websocketContext = null; var msg = "It caused an exception."; diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index d9d7f6368..f926dc26b 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -630,17 +630,17 @@ internal set { } /// - /// Gets the current state of the connection. + /// Gets the current state of the interface. /// /// /// /// One of the enum values. /// /// - /// It indicates the current state of the connection. + /// It indicates the current state of the interface. /// /// - /// The default value is . + /// The default value is . /// /// public WebSocketState ReadyState { @@ -803,6 +803,8 @@ private bool accept () return false; } + _readyState = WebSocketState.Connecting; + var accepted = false; try { @@ -870,7 +872,7 @@ private bool acceptHandshake () private bool canSet () { - return _readyState == WebSocketState.Connecting + return _readyState == WebSocketState.New || _readyState == WebSocketState.Closed; } @@ -1483,7 +1485,7 @@ private void init () _forState = new object (); _messageEventQueue = new Queue (); _forMessageEventQueue = ((ICollection) _messageEventQueue).SyncRoot; - _readyState = WebSocketState.Connecting; + _readyState = WebSocketState.New; } private void message () diff --git a/websocket-sharp/WebSocketState.cs b/websocket-sharp/WebSocketState.cs index 2cbcd688d..8ba8cb3e0 100644 --- a/websocket-sharp/WebSocketState.cs +++ b/websocket-sharp/WebSocketState.cs @@ -31,35 +31,34 @@ namespace WebSocketSharp { /// - /// Indicates the state of a WebSocket connection. + /// Indicates the state of the WebSocket interface. /// - /// - /// The values of this enumeration are defined in - /// - /// The WebSocket API. - /// public enum WebSocketState : ushort { /// - /// Equivalent to numeric value 0. Indicates that the connection has not - /// yet been established. + /// Equivalent to numeric value 0. Indicates that a new interface has + /// been created. /// - Connecting = 0, + New = 0, /// - /// Equivalent to numeric value 1. Indicates that the connection has - /// been established, and the communication is possible. + /// Equivalent to numeric value 1. Indicates that the connect process is + /// in progress. /// - Open = 1, + Connecting = 1, /// - /// Equivalent to numeric value 2. Indicates that the connection is - /// going through the closing handshake, or the close method has - /// been invoked. + /// Equivalent to numeric value 2. Indicates that the connection has + /// been established and the communication is possible. /// - Closing = 2, + Open = 2, /// - /// Equivalent to numeric value 3. Indicates that the connection has + /// Equivalent to numeric value 3. Indicates that the close process is + /// in progress. + /// + Closing = 3, + /// + /// Equivalent to numeric value 4. Indicates that the connection has /// been closed or could not be established. /// - Closed = 3 + Closed = 4 } } From cc548899465030ac37c19f556a5daa734ca08975 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 1 Nov 2022 19:50:49 +0900 Subject: [PATCH 4676/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index f926dc26b..9bdd40a98 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1240,7 +1240,7 @@ private bool connect () } if (_readyState == WebSocketState.Closing) { - _logger.Error ("The closing is in progress."); + _logger.Error ("The close process is in progress."); error ("An error has occurred while connecting.", null); From 36375523a5c8ecb0edb8b39746700160df871486 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 1 Nov 2022 19:56:03 +0900 Subject: [PATCH 4677/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 9bdd40a98..a7b2aae6e 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -788,7 +788,7 @@ private bool accept () } if (_readyState == WebSocketState.Closing) { - _logger.Error ("The connection is closing."); + _logger.Error ("The close process is in progress."); error ("An error has occurred while accepting.", null); From be29052a52e53857971968999d46869ba8e7ae94 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 1 Nov 2022 19:59:49 +0900 Subject: [PATCH 4678/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index a7b2aae6e..fe5b1c0ad 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1095,7 +1095,7 @@ private bool checkReceivedFrame (WebSocketFrame frame, out string message) private void close (ushort code, string reason) { if (_readyState == WebSocketState.Closing) { - _logger.Trace ("The closing is already in progress."); + _logger.Trace ("The close process is already in progress."); return; } From 90f56d8c8e7b799bd7ae7bf6b13073b46782151f Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 1 Nov 2022 20:01:48 +0900 Subject: [PATCH 4679/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index fe5b1c0ad..f5b32bc23 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1122,7 +1122,7 @@ private void close (PayloadData payloadData, bool send, bool received) { lock (_forState) { if (_readyState == WebSocketState.Closing) { - _logger.Trace ("The closing is already in progress."); + _logger.Trace ("The close process is already in progress."); return; } From fed6714820ea2ce00de8cfefa2b3fce080dd1f9f Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 1 Nov 2022 20:02:54 +0900 Subject: [PATCH 4680/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index f5b32bc23..6bc2b4c9b 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1162,7 +1162,7 @@ private void close (PayloadData payloadData, bool send, bool received) private void closeAsync (ushort code, string reason) { if (_readyState == WebSocketState.Closing) { - _logger.Trace ("The closing is already in progress."); + _logger.Trace ("The close process is already in progress."); return; } From 45e4d574ccbbaa159fa8f61140a62cfb955e3560 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 1 Nov 2022 20:05:35 +0900 Subject: [PATCH 4681/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 6bc2b4c9b..855a8f0a3 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2428,7 +2428,7 @@ internal void Close (PayloadData payloadData, byte[] frameAsBytes) { lock (_forState) { if (_readyState == WebSocketState.Closing) { - _logger.Trace ("The closing is already in progress."); + _logger.Trace ("The close process is already in progress."); return; } From 16389d4deb1edfddbe6e13ae8cf86b1a8c957d58 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 2 Nov 2022 17:41:14 +0900 Subject: [PATCH 4682/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 855a8f0a3..8baf131f9 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -261,6 +261,7 @@ public WebSocket (string url, params string[] protocols) throw new ArgumentException ("An empty string.", "url"); string msg; + if (!url.TryCreateWebSocketUri (out _uri, out msg)) throw new ArgumentException (msg, "url"); From d851abe989df98ea76b7248bc9bf1dc62ead15fd Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 2 Nov 2022 17:52:18 +0900 Subject: [PATCH 4683/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 8baf131f9..228f791aa 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -202,7 +202,7 @@ internal WebSocket (TcpListenerWebSocketContext context, string protocol) /// /// Initializes a new instance of the class with - /// and optionally . + /// the specified URL and optionally subprotocols. /// /// /// From 796b542f5af431d420f8d87f59f8a09ba617d393 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 3 Nov 2022 15:38:44 +0900 Subject: [PATCH 4684/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 228f791aa..7e3d9847a 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -130,15 +130,17 @@ public class WebSocket : IDisposable internal static readonly byte[] EmptyBytes; /// - /// Represents the length used to determine whether the data should be fragmented in sending. + /// Represents the length used to determine whether the data should + /// be fragmented in sending. /// /// /// - /// The data will be fragmented if that length is greater than the value of this field. + /// The data will be fragmented if its length is greater than + /// the value of this field. /// /// - /// If you would like to change the value, you must set it to a value between 125 and - /// Int32.MaxValue - 14 inclusive. + /// If you would like to change the value, you must set it to + /// a value between 125 and Int32.MaxValue - 14 inclusive. /// /// internal static readonly int FragmentLength; From db3ffb917af59c0cdeb669f87f394b39e5e3ab6b Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 3 Nov 2022 15:40:06 +0900 Subject: [PATCH 4685/6294] [Modify] 2022 --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 7e3d9847a..594db8e4f 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -8,7 +8,7 @@ * The MIT License * * Copyright (c) 2009 Adam MacBeth - * Copyright (c) 2010-2016 sta.blockhead + * Copyright (c) 2010-2022 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From 641d0ad88099359760732fdf8741f2ced9061522 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 3 Nov 2022 15:42:02 +0900 Subject: [PATCH 4686/6294] [Modify] 2022 --- websocket-sharp/WebSocketState.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocketState.cs b/websocket-sharp/WebSocketState.cs index 8ba8cb3e0..fa1704970 100644 --- a/websocket-sharp/WebSocketState.cs +++ b/websocket-sharp/WebSocketState.cs @@ -4,7 +4,7 @@ * * The MIT License * - * Copyright (c) 2010-2016 sta.blockhead + * Copyright (c) 2010-2022 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From c1893478cab8c52774eac8c1314e766936899822 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 4 Nov 2022 15:23:48 +0900 Subject: [PATCH 4687/6294] [Modify] Move it --- websocket-sharp/Server/IWebSocketSession.cs | 13 ------- websocket-sharp/Server/WebSocketBehavior.cs | 39 +++++++++---------- .../Server/WebSocketSessionManager.cs | 2 +- 3 files changed, 19 insertions(+), 35 deletions(-) diff --git a/websocket-sharp/Server/IWebSocketSession.cs b/websocket-sharp/Server/IWebSocketSession.cs index 296b5bf5a..b2d55364d 100644 --- a/websocket-sharp/Server/IWebSocketSession.cs +++ b/websocket-sharp/Server/IWebSocketSession.cs @@ -38,19 +38,6 @@ public interface IWebSocketSession { #region Properties - /// - /// Gets the current state of the WebSocket connection for the session. - /// - /// - /// - /// One of the enum values. - /// - /// - /// It indicates the current state of the connection. - /// - /// - WebSocketState ConnectionState { get; } - /// /// Gets the information in the WebSocket handshake request. /// diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 47eaafc0f..5d42ede76 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -112,50 +112,47 @@ protected NameValueCollection QueryString { } /// - /// Gets the management function for the sessions in the service. + /// Gets the current state of the WebSocket interface for a session. /// /// /// - /// A that manages the sessions in - /// the service. + /// One of the enum values. /// /// - /// if the session has not started yet. + /// It indicates the current state of the interface. + /// + /// + /// if the session has not started yet. /// /// - protected WebSocketSessionManager Sessions { + protected WebSocketState ReadyState { get { - return _sessions; + return _websocket != null ? _websocket.ReadyState : WebSocketState.New; } } - #endregion - - #region Public Properties - /// - /// Gets the current state of the WebSocket connection for a session. + /// Gets the management function for the sessions in the service. /// /// /// - /// One of the enum values. - /// - /// - /// It indicates the current state of the connection. + /// A that manages the sessions in + /// the service. /// /// - /// if the session has not - /// started yet. + /// if the session has not started yet. /// /// - public WebSocketState ConnectionState { + protected WebSocketSessionManager Sessions { get { - return _websocket != null - ? _websocket.ReadyState - : WebSocketState.Connecting; + return _sessions; } } + #endregion + + #region Public Properties + /// /// Gets the information in a WebSocket handshake request to the service. /// diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 6229abaff..17252fe22 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -1546,7 +1546,7 @@ public void Sweep () if (!_sessions.TryGetValue (id, out session)) continue; - var state = session.ConnectionState; + var state = session.Context.WebSocket.ReadyState; if (state == WebSocketState.Open) { session.Context.WebSocket.Close (CloseStatusCode.Abnormal); From b76006ee55a4661a9967058cbc26fa4c25463f8d Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 4 Nov 2022 20:53:07 +0900 Subject: [PATCH 4688/6294] [Modify] Throw an exception --- websocket-sharp/Server/WebSocketBehavior.cs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 5d42ede76..2c547421c 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -121,13 +121,19 @@ protected NameValueCollection QueryString { /// /// It indicates the current state of the interface. /// - /// - /// if the session has not started yet. - /// /// + /// + /// The session has not started yet. + /// protected WebSocketState ReadyState { get { - return _websocket != null ? _websocket.ReadyState : WebSocketState.New; + if (_websocket == null) { + var msg = "The session has not started yet."; + + throw new InvalidOperationException (msg); + } + + return _websocket.ReadyState; } } From 8c130ab8a05aafa9120b54cc2f520a7912af9880 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 4 Nov 2022 20:58:19 +0900 Subject: [PATCH 4689/6294] [Modify] Throw an exception --- websocket-sharp/Server/WebSocketBehavior.cs | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 2c547421c..55717627b 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -77,16 +77,20 @@ protected WebSocketBehavior () /// Gets the HTTP headers included in a WebSocket handshake request. ///
/// - /// - /// A that contains the headers. - /// - /// - /// if the session has not started yet. - /// + /// A that contains the headers. /// + /// + /// The session has not started yet. + /// protected NameValueCollection Headers { get { - return _context != null ? _context.Headers : null; + if (_context == null) { + var msg = "The session has not started yet."; + + throw new InvalidOperationException (msg); + } + + return _context.Headers; } } From 68d9ae3fefe185e0844a73a5f3486e58dd2762c5 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 4 Nov 2022 21:03:46 +0900 Subject: [PATCH 4690/6294] [Modify] Throw an exception --- websocket-sharp/Server/WebSocketBehavior.cs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 55717627b..dccd1cc70 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -105,13 +105,19 @@ protected NameValueCollection Headers { /// /// An empty collection if not included. /// - /// - /// if the session has not started yet. - /// /// + /// + /// The session has not started yet. + /// protected NameValueCollection QueryString { get { - return _context != null ? _context.QueryString : null; + if (_context == null) { + var msg = "The session has not started yet."; + + throw new InvalidOperationException (msg); + } + + return _context.QueryString; } } From 77bf4065aaec80684c5427a59f1b5f47c857a8ad Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 5 Nov 2022 21:24:28 +0900 Subject: [PATCH 4691/6294] [Modify] Throw an exception --- websocket-sharp/Server/WebSocketBehavior.cs | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index dccd1cc70..49a79620c 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -151,16 +151,20 @@ protected WebSocketState ReadyState { /// Gets the management function for the sessions in the service. ///
/// - /// - /// A that manages the sessions in - /// the service. - /// - /// - /// if the session has not started yet. - /// + /// A that manages the sessions in + /// the service. /// + /// + /// The session has not started yet. + /// protected WebSocketSessionManager Sessions { get { + if (_sessions == null) { + var msg = "The session has not started yet."; + + throw new InvalidOperationException (msg); + } + return _sessions; } } From 6a2a5815098c3a6cd4bccc277fec7c365b1bd04c Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 5 Nov 2022 21:45:12 +0900 Subject: [PATCH 4692/6294] [Modify] Add it --- websocket-sharp/Server/IWebSocketSession.cs | 8 ++++++++ websocket-sharp/Server/WebSocketBehavior.cs | 22 +++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/websocket-sharp/Server/IWebSocketSession.cs b/websocket-sharp/Server/IWebSocketSession.cs index b2d55364d..23be638e3 100644 --- a/websocket-sharp/Server/IWebSocketSession.cs +++ b/websocket-sharp/Server/IWebSocketSession.cs @@ -73,6 +73,14 @@ public interface IWebSocketSession /// DateTime StartTime { get; } + /// + /// Gets the WebSocket interface for the session. + /// + /// + /// A that represents the interface. + /// + WebSocket WebSocket { get; } + #endregion } } diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 49a79620c..f8755fb8c 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -1249,5 +1249,27 @@ protected void SendAsync (Stream stream, int length, Action completed) } #endregion + + #region Explicit Interface Implementations + + /// + /// Gets the WebSocket interface for a session. + /// + /// + /// + /// A that represents + /// the interface. + /// + /// + /// if the session has not started yet. + /// + /// + WebSocket IWebSocketSession.WebSocket { + get { + return _websocket; + } + } + + #endregion } } From d6446ff1d2576114ee84d510a8fdb84e021df368 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 6 Nov 2022 15:29:13 +0900 Subject: [PATCH 4693/6294] [Modify] Replace it --- .../Server/WebSocketSessionManager.cs | 34 +++++++++---------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 17252fe22..545bdaf2f 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -325,7 +325,7 @@ private void broadcast (Opcode opcode, byte[] data, Action completed) break; } - session.Context.WebSocket.Send (opcode, data, cache); + session.WebSocket.Send (opcode, data, cache); } if (completed != null) @@ -352,7 +352,7 @@ private void broadcast (Opcode opcode, Stream stream, Action completed) break; } - session.Context.WebSocket.Send (opcode, stream, cache); + session.WebSocket.Send (opcode, stream, cache); } if (completed != null) @@ -395,7 +395,7 @@ private Dictionary broadping (byte[] frameAsBytes) break; } - var res = session.Context.WebSocket.Ping (frameAsBytes, _waitTime); + var res = session.WebSocket.Ping (frameAsBytes, _waitTime); ret.Add (session.ID, res); } @@ -432,7 +432,7 @@ private void stop (PayloadData payloadData, bool send) _sweepTimer.Enabled = false; foreach (var session in _sessions.Values.ToList ()) - session.Context.WebSocket.Close (payloadData, bytes); + session.WebSocket.Close (payloadData, bytes); _state = ServerState.Stop; } @@ -870,7 +870,7 @@ public void CloseSession (string id) throw new InvalidOperationException (msg); } - session.Context.WebSocket.Close (); + session.WebSocket.Close (); } /// @@ -948,7 +948,7 @@ public void CloseSession (string id, ushort code, string reason) throw new InvalidOperationException (msg); } - session.Context.WebSocket.Close (code, reason); + session.WebSocket.Close (code, reason); } /// @@ -1017,7 +1017,7 @@ public void CloseSession (string id, CloseStatusCode code, string reason) throw new InvalidOperationException (msg); } - session.Context.WebSocket.Close (code, reason); + session.WebSocket.Close (code, reason); } /// @@ -1049,7 +1049,7 @@ public bool PingTo (string id) throw new InvalidOperationException (msg); } - return session.Context.WebSocket.Ping (); + return session.WebSocket.Ping (); } /// @@ -1101,7 +1101,7 @@ public bool PingTo (string message, string id) throw new InvalidOperationException (msg); } - return session.Context.WebSocket.Ping (message); + return session.WebSocket.Ping (message); } /// @@ -1148,7 +1148,7 @@ public void SendTo (byte[] data, string id) throw new InvalidOperationException (msg); } - session.Context.WebSocket.Send (data); + session.WebSocket.Send (data); } /// @@ -1203,7 +1203,7 @@ public void SendTo (string data, string id) throw new InvalidOperationException (msg); } - session.Context.WebSocket.Send (data); + session.WebSocket.Send (data); } /// @@ -1279,7 +1279,7 @@ public void SendTo (Stream stream, int length, string id) throw new InvalidOperationException (msg); } - session.Context.WebSocket.Send (stream, length); + session.WebSocket.Send (stream, length); } /// @@ -1343,7 +1343,7 @@ public void SendToAsync (byte[] data, string id, Action completed) throw new InvalidOperationException (msg); } - session.Context.WebSocket.SendAsync (data, completed); + session.WebSocket.SendAsync (data, completed); } /// @@ -1415,7 +1415,7 @@ public void SendToAsync (string data, string id, Action completed) throw new InvalidOperationException (msg); } - session.Context.WebSocket.SendAsync (data, completed); + session.WebSocket.SendAsync (data, completed); } /// @@ -1509,7 +1509,7 @@ public void SendToAsync ( throw new InvalidOperationException (msg); } - session.Context.WebSocket.SendAsync (stream, length, completed); + session.WebSocket.SendAsync (stream, length, completed); } /// @@ -1546,10 +1546,10 @@ public void Sweep () if (!_sessions.TryGetValue (id, out session)) continue; - var state = session.Context.WebSocket.ReadyState; + var state = session.WebSocket.ReadyState; if (state == WebSocketState.Open) { - session.Context.WebSocket.Close (CloseStatusCode.Abnormal); + session.WebSocket.Close (CloseStatusCode.Abnormal); continue; } From fc22307b380cbaa80221657bd002aa02f3d5395d Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 6 Nov 2022 15:32:52 +0900 Subject: [PATCH 4694/6294] [Modify] Remove it --- websocket-sharp/Server/IWebSocketSession.cs | 9 --------- websocket-sharp/Server/WebSocketBehavior.cs | 18 ------------------ 2 files changed, 27 deletions(-) diff --git a/websocket-sharp/Server/IWebSocketSession.cs b/websocket-sharp/Server/IWebSocketSession.cs index 23be638e3..9c57855f0 100644 --- a/websocket-sharp/Server/IWebSocketSession.cs +++ b/websocket-sharp/Server/IWebSocketSession.cs @@ -38,15 +38,6 @@ public interface IWebSocketSession { #region Properties - /// - /// Gets the information in the WebSocket handshake request. - /// - /// - /// A instance that provides the access to - /// the information in the handshake request. - /// - WebSocketContext Context { get; } - /// /// Gets the unique ID of the session. /// diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index f8755fb8c..3b25928b5 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -173,24 +173,6 @@ protected WebSocketSessionManager Sessions { #region Public Properties - /// - /// Gets the information in a WebSocket handshake request to the service. - /// - /// - /// - /// A instance that provides the access to - /// the information in the handshake request. - /// - /// - /// if the session has not started yet. - /// - /// - public WebSocketContext Context { - get { - return _context; - } - } - /// /// Gets or sets the delegate used to validate the HTTP cookies included in /// a WebSocket handshake request to the service. From 50ed8d4b6cb0728ee03e858a82f70bdaae68f89e Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 7 Nov 2022 15:50:52 +0900 Subject: [PATCH 4695/6294] [Modify] Remove it --- websocket-sharp/Server/IWebSocketSession.cs | 9 --------- 1 file changed, 9 deletions(-) diff --git a/websocket-sharp/Server/IWebSocketSession.cs b/websocket-sharp/Server/IWebSocketSession.cs index 9c57855f0..4ff828c89 100644 --- a/websocket-sharp/Server/IWebSocketSession.cs +++ b/websocket-sharp/Server/IWebSocketSession.cs @@ -46,15 +46,6 @@ public interface IWebSocketSession /// string ID { get; } - /// - /// Gets the name of the WebSocket subprotocol for the session. - /// - /// - /// A that represents the name of the subprotocol - /// if present. - /// - string Protocol { get; } - /// /// Gets the time that the session has started. /// From b70bc9667586e4cd95e733455b4a813c851653f2 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 7 Nov 2022 15:56:49 +0900 Subject: [PATCH 4696/6294] [Modify] Polish it --- websocket-sharp/Server/IWebSocketSession.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/websocket-sharp/Server/IWebSocketSession.cs b/websocket-sharp/Server/IWebSocketSession.cs index 4ff828c89..7000c5b8c 100644 --- a/websocket-sharp/Server/IWebSocketSession.cs +++ b/websocket-sharp/Server/IWebSocketSession.cs @@ -27,7 +27,6 @@ #endregion using System; -using WebSocketSharp.Net.WebSockets; namespace WebSocketSharp.Server { From bd4dccdd85eaf09b14abfac5fcaa6365269838fc Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 7 Nov 2022 15:58:01 +0900 Subject: [PATCH 4697/6294] [Modify] 2022 --- websocket-sharp/Server/IWebSocketSession.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/IWebSocketSession.cs b/websocket-sharp/Server/IWebSocketSession.cs index 7000c5b8c..4ddc84aca 100644 --- a/websocket-sharp/Server/IWebSocketSession.cs +++ b/websocket-sharp/Server/IWebSocketSession.cs @@ -4,7 +4,7 @@ * * The MIT License * - * Copyright (c) 2013-2018 sta.blockhead + * Copyright (c) 2013-2022 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From 277b3a97c317d09037c26c2a9ac4020e6aa2154e Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 7 Nov 2022 16:00:35 +0900 Subject: [PATCH 4698/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 3b25928b5..295e7ab9e 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -359,7 +359,7 @@ public string Protocol { } if (!value.IsToken ()) { - var msg = "It is not a token."; + var msg = "Not a token."; throw new ArgumentException (msg, "value"); } From 9acce102704920a3e1734a2dbc3e0f87b91bfe68 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 8 Nov 2022 17:02:34 +0900 Subject: [PATCH 4699/6294] [Modify] Add it --- websocket-sharp/Server/WebSocketBehavior.cs | 28 +++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 295e7ab9e..d81087e16 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -29,6 +29,7 @@ using System; using System.Collections.Specialized; using System.IO; +using System.Security.Principal; using WebSocketSharp.Net; using WebSocketSharp.Net.WebSockets; @@ -169,6 +170,33 @@ protected WebSocketSessionManager Sessions { } } + /// + /// Gets the client information for a session. + /// + /// + /// + /// A instance that represents identity, + /// authentication, and security roles for the client. + /// + /// + /// if the client is not authenticated. + /// + /// + /// + /// The session has not started yet. + /// + protected IPrincipal User { + get { + if (_context == null) { + var msg = "The session has not started yet."; + + throw new InvalidOperationException (msg); + } + + return _context.User; + } + } + #endregion #region Public Properties From 767bcb3c778121eed26e09401025fcd62b0d2ffb Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 9 Nov 2022 15:59:44 +0900 Subject: [PATCH 4700/6294] [Modify] Add it --- websocket-sharp/Server/WebSocketBehavior.cs | 22 +++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index d81087e16..052dbc875 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -197,6 +197,28 @@ protected IPrincipal User { } } + /// + /// Gets the client endpoint for a session. + /// + /// + /// A that represents the client + /// IP address and port number. + /// + /// + /// The session has not started yet. + /// + protected System.Net.IPEndPoint UserEndPoint { + get { + if (_context == null) { + var msg = "The session has not started yet."; + + throw new InvalidOperationException (msg); + } + + return _context.UserEndPoint; + } + } + #endregion #region Public Properties From 67d8f5821d3698c122c378fe3f313c3d5944d9ca Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 9 Nov 2022 16:03:39 +0900 Subject: [PATCH 4701/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 052dbc875..481efa5ce 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -75,10 +75,11 @@ protected WebSocketBehavior () #region Protected Properties /// - /// Gets the HTTP headers included in a WebSocket handshake request. + /// Gets the HTTP headers for a session. /// /// - /// A that contains the headers. + /// A that contains the headers + /// included in the WebSocket handshake request. /// /// /// The session has not started yet. From 384e54c80870f3127479bbef32338f0327f9d5dd Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 10 Nov 2022 15:52:19 +0900 Subject: [PATCH 4702/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 481efa5ce..a3ce7fc9e 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -97,12 +97,12 @@ protected NameValueCollection Headers { } /// - /// Gets the query string included in a WebSocket handshake request. + /// Gets the query string for a session. /// /// /// /// A that contains the query - /// parameters. + /// parameters included in the WebSocket handshake request. /// /// /// An empty collection if not included. From be09f8f3a0ee8f6744082f93236392725c62a128 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 10 Nov 2022 16:08:13 +0900 Subject: [PATCH 4703/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index a3ce7fc9e..8d009de66 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -226,20 +226,20 @@ protected System.Net.IPEndPoint UserEndPoint { /// /// Gets or sets the delegate used to validate the HTTP cookies included in - /// a WebSocket handshake request to the service. + /// a WebSocket handshake request. /// /// /// - /// A Func<CookieCollection, CookieCollection, bool> delegate - /// or if not needed. + /// A + /// delegate. /// /// - /// The delegate invokes the method called when the WebSocket instance + /// The delegate invokes the method called when the WebSocket interface /// for a session validates the handshake request. /// /// /// 1st parameter passed to the method - /// contains the cookies to validate if present. + /// contains the cookies to validate. /// /// /// 2nd parameter passed to the method @@ -249,6 +249,9 @@ protected System.Net.IPEndPoint UserEndPoint { /// The method must return true if the cookies are valid. /// /// + /// if not necessary. + /// + /// /// The default value is . /// /// From 604226fc744fd0aaaed979443eff7d4e05c15425 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 11 Nov 2022 15:53:46 +0900 Subject: [PATCH 4704/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 8d009de66..67620d8b1 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -337,15 +337,14 @@ public bool IgnoreExtensions { /// /// Gets or sets the delegate used to validate the Origin header included in - /// a WebSocket handshake request to the service. + /// a WebSocket handshake request. /// /// /// - /// A Func<string, bool> delegate or - /// if not needed. + /// A delegate. /// /// - /// The delegate invokes the method called when the WebSocket instance + /// The delegate invokes the method called when the WebSocket interface /// for a session validates the handshake request. /// /// @@ -357,6 +356,9 @@ public bool IgnoreExtensions { /// The method must return true if the header value is valid. /// /// + /// if not necessary. + /// + /// /// The default value is . /// /// From 8df560643df40b6d7c35f1589a75f87ef55bb9d5 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 11 Nov 2022 15:58:48 +0900 Subject: [PATCH 4705/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 67620d8b1..a028fa56e 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -266,13 +266,13 @@ public Func CookiesValidator { } /// - /// Gets or sets a value indicating whether the WebSocket instance for + /// Gets or sets a value indicating whether the WebSocket interface for /// a session emits the message event when receives a ping. /// /// /// - /// true if the WebSocket instance emits the message event - /// when receives a ping; otherwise, false. + /// true if the interface emits the message event when receives + /// a ping; otherwise, false. /// /// /// The default value is false. From 4683af99132d00dc069e8b425566ee926922a57b Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 11 Nov 2022 17:18:33 +0900 Subject: [PATCH 4706/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index a028fa56e..cdf34dec8 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -312,14 +312,13 @@ public string ID { } /// - /// Gets or sets a value indicating whether the service ignores - /// the Sec-WebSocket-Extensions header included in a WebSocket - /// handshake request. + /// Gets or sets a value indicating whether the WebSocket interface for + /// a session ignores the Sec-WebSocket-Extensions header. /// /// /// - /// true if the service ignores the extensions requested - /// from a client; otherwise, false. + /// true if the interface ignores the extensions requested + /// from the client; otherwise, false. /// /// /// The default value is false. From 546ecc7dea904c2545c296086e2b6d9730fd6dbe Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 11 Nov 2022 17:21:44 +0900 Subject: [PATCH 4707/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index cdf34dec8..5a7f68b72 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -225,8 +225,7 @@ protected System.Net.IPEndPoint UserEndPoint { #region Public Properties /// - /// Gets or sets the delegate used to validate the HTTP cookies included in - /// a WebSocket handshake request. + /// Gets or sets the delegate used to validate the HTTP cookies. /// /// /// From 175c4698bbb26749918e57fcbb4e587ea47e7c2d Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 11 Nov 2022 17:25:10 +0900 Subject: [PATCH 4708/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 5a7f68b72..6a3e245dc 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -334,8 +334,7 @@ public bool IgnoreExtensions { } /// - /// Gets or sets the delegate used to validate the Origin header included in - /// a WebSocket handshake request. + /// Gets or sets the delegate used to validate the Origin header. /// /// /// From 049735ee1ac8b79b17360eff5e45cf60b9555af9 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 12 Nov 2022 16:29:16 +0900 Subject: [PATCH 4709/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 6a3e245dc..b644f1a05 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -370,14 +370,14 @@ public Func OriginValidator { } /// - /// Gets or sets the name of the WebSocket subprotocol for the service. + /// Gets or sets the name of the WebSocket subprotocol for a session. /// /// /// /// A that represents the name of the subprotocol. /// /// - /// The value specified for a set must be a token defined in + /// The value specified for a set operation must be a token defined in /// /// RFC 2616. /// From f4c347c40ed6589b2780be78608463163155db2a Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 13 Nov 2022 16:01:12 +0900 Subject: [PATCH 4710/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketBehavior.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index b644f1a05..452b7d650 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -446,8 +446,11 @@ public DateTime StartTime { private string checkHandshakeRequest (WebSocketContext context) { if (_originValidator != null) { - if (!_originValidator (context.Origin)) - return "It includes no Origin header or an invalid one."; + if (!_originValidator (context.Origin)) { + var msg = "The Origin header is non-existent or invalid."; + + return msg; + } } if (_cookiesValidator != null) { From 1b438e6cd98b9d24d5396b46056f7f1aaf0c02d4 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 14 Nov 2022 15:51:53 +0900 Subject: [PATCH 4711/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketBehavior.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 452b7d650..8089ed45d 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -457,8 +457,11 @@ private string checkHandshakeRequest (WebSocketContext context) var req = context.CookieCollection; var res = context.WebSocket.CookieCollection; - if (!_cookiesValidator (req, res)) - return "It includes no cookie or an invalid one."; + if (!_cookiesValidator (req, res)) { + var msg = "The Cookie header is non-existent or invalid."; + + return msg; + } } return null; From d935f4de75249aeffac42d78cb14aa25e709ab85 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 15 Nov 2022 01:27:48 +0900 Subject: [PATCH 4712/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 8089ed45d..677e83a55 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -540,8 +540,8 @@ internal void Start ( /// Closes the WebSocket connection for a session. /// /// - /// This method does nothing if the current state of the connection is - /// Closing or Closed. + /// This method does nothing if the current state of the WebSocket + /// interface is Closing or Closed. /// /// /// The session has not started yet. From 2019a1c907d68f0091a95e42f286049e1b02d549 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 15 Nov 2022 01:32:25 +0900 Subject: [PATCH 4713/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 677e83a55..bcd80ba7a 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -562,8 +562,8 @@ protected void Close () /// code and reason. /// /// - /// This method does nothing if the current state of the connection is - /// Closing or Closed. + /// This method does nothing if the current state of the WebSocket + /// interface is Closing or Closed. /// /// /// From b1e087bcfd594a55faa38f99b480d11658c4e168 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 15 Nov 2022 01:37:06 +0900 Subject: [PATCH 4714/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index bcd80ba7a..2f06cce8f 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -631,8 +631,8 @@ protected void Close (ushort code, string reason) /// code and reason. /// /// - /// This method does nothing if the current state of the connection is - /// Closing or Closed. + /// This method does nothing if the current state of the WebSocket + /// interface is Closing or Closed. /// /// /// From cec7c7f8714a2d76f88316e7e993a938ddda29f6 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 15 Nov 2022 17:01:55 +0900 Subject: [PATCH 4715/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 2f06cce8f..27d7b8416 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -694,8 +694,8 @@ protected void Close (CloseStatusCode code, string reason) /// This method does not wait for the close to be complete. /// /// - /// This method does nothing if the current state of the connection is - /// Closing or Closed. + /// This method does nothing if the current state of the WebSocket + /// interface is Closing or Closed. /// /// /// From 8c7b05243b092101115e0549c840489da55705ad Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 15 Nov 2022 17:03:42 +0900 Subject: [PATCH 4716/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 27d7b8416..c09d4f70d 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -721,8 +721,8 @@ protected void CloseAsync () /// This method does not wait for the close to be complete. /// /// - /// This method does nothing if the current state of the connection is - /// Closing or Closed. + /// This method does nothing if the current state of the WebSocket + /// interface is Closing or Closed. /// /// /// From e8e58c7901560bfadba31e991ac6c5e2c8e02657 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 15 Nov 2022 17:04:46 +0900 Subject: [PATCH 4717/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index c09d4f70d..061a0ae68 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -795,8 +795,8 @@ protected void CloseAsync (ushort code, string reason) /// This method does not wait for the close to be complete. /// /// - /// This method does nothing if the current state of the connection is - /// Closing or Closed. + /// This method does nothing if the current state of the WebSocket + /// interface is Closing or Closed. /// /// /// From 58dceb210756b2e40fab57bcca783e88d978e86b Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 15 Nov 2022 23:43:06 +0900 Subject: [PATCH 4718/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 061a0ae68..1fda3142d 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -606,7 +606,8 @@ protected void Close () /// -or- /// /// - /// is 1005 (no status) and there is reason. + /// is 1005 (no status) and + /// is specified. /// /// /// -or- From f15fd77a348c60279e11430e0e64b5a25ba9d31e Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 15 Nov 2022 23:47:23 +0900 Subject: [PATCH 4719/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 1fda3142d..7d2a956ec 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -666,8 +666,8 @@ protected void Close (ushort code, string reason) /// -or- /// /// - /// is - /// and there is reason. + /// is + /// and is specified. /// /// /// -or- From 54f9340d2b65ad66aab37320dcd70e9cdb8fa7e3 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 15 Nov 2022 23:50:09 +0900 Subject: [PATCH 4720/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 7d2a956ec..30c3e3a4a 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -767,7 +767,8 @@ protected void CloseAsync () /// -or- /// /// - /// is 1005 (no status) and there is reason. + /// is 1005 (no status) and + /// is specified. /// /// /// -or- From c8512e0eba9fd2ab0ea2496a8d189bc687f5996d Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 15 Nov 2022 23:52:10 +0900 Subject: [PATCH 4721/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 30c3e3a4a..1742afcdc 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -829,8 +829,8 @@ protected void CloseAsync (ushort code, string reason) /// -or- /// /// - /// is - /// and there is reason. + /// is + /// and is specified. /// /// /// -or- From 83e58ede467f64b0a315ced5bfeda2651d852a86 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 15 Nov 2022 23:55:10 +0900 Subject: [PATCH 4722/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 1742afcdc..8b8a6b1af 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -865,7 +865,7 @@ protected virtual void OnClose (CloseEventArgs e) } /// - /// Called when the WebSocket instance for a session gets an error. + /// Called when the WebSocket interface for a session gets an error. /// /// /// A that represents the event data passed From b3067e959b6a8388bc2d7b1afefed53c44cbdaf9 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 15 Nov 2022 23:56:56 +0900 Subject: [PATCH 4723/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 8b8a6b1af..c36a11a81 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -876,7 +876,7 @@ protected virtual void OnError (ErrorEventArgs e) } /// - /// Called when the WebSocket instance for a session receives a message. + /// Called when the WebSocket interface for a session receives a message. /// /// /// A that represents the event data passed From 4746bb4e96171f89b641a714b61e309a16beacb3 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 16 Nov 2022 15:40:58 +0900 Subject: [PATCH 4724/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index c36a11a81..adc0c0492 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -894,10 +894,10 @@ protected virtual void OnOpen () } /// - /// Sends a ping to a client using the WebSocket connection. + /// Sends a ping to the client for a session. /// /// - /// true if the send has done with no error and a pong has been + /// true if the send has successfully done and a pong has been /// received within a time; otherwise, false. /// /// From 27e645cd0d14779c400a304cf0a020bd9c202cbf Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 16 Nov 2022 15:44:37 +0900 Subject: [PATCH 4725/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index adc0c0492..174c27937 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -915,11 +915,10 @@ protected bool Ping () } /// - /// Sends a ping with the specified message to a client using - /// the WebSocket connection. + /// Sends a ping with the specified message to the client for a session. /// /// - /// true if the send has done with no error and a pong has been + /// true if the send has successfully done and a pong has been /// received within a time; otherwise, false. /// /// From 4f9817859c5a8086bc04e9141aca2991c1bcaa20 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 16 Nov 2022 15:47:26 +0900 Subject: [PATCH 4726/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 174c27937..80118afc1 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -964,7 +964,7 @@ protected bool Ping (string message) protected void Send (byte[] data) { if (_websocket == null) { - var msg = "The current state of the connection is not Open."; + var msg = "The session has not started yet."; throw new InvalidOperationException (msg); } From 38d33c7404774473baf3e2bdd3cf13fe7ed2cc8d Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 16 Nov 2022 15:55:38 +0900 Subject: [PATCH 4727/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 80118afc1..f65f65d2f 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -950,13 +950,21 @@ protected bool Ping (string message) } /// - /// Sends the specified data to a client using the WebSocket connection. + /// Sends the specified data to the client for a session. /// /// /// An array of that specifies the binary data to send. /// /// - /// The current state of the connection is not Open. + /// + /// The session has not started yet. + /// + /// + /// -or- + /// + /// + /// The current state of the WebSocket interface is not Open. + /// /// /// /// is . From 4ecf0eefd5be938d0427b97e55a46729402c9c01 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 16 Nov 2022 15:57:44 +0900 Subject: [PATCH 4728/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index f65f65d2f..239313d55 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -1011,7 +1011,7 @@ protected void Send (byte[] data) protected void Send (FileInfo fileInfo) { if (_websocket == null) { - var msg = "The current state of the connection is not Open."; + var msg = "The session has not started yet."; throw new InvalidOperationException (msg); } From 6beb626573b652964fbb4c8d9d080d8732044195 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 16 Nov 2022 16:01:42 +0900 Subject: [PATCH 4729/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 239313d55..49b1d0d41 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -981,7 +981,7 @@ protected void Send (byte[] data) } /// - /// Sends the specified file to a client using the WebSocket connection. + /// Sends the specified file to the client for a session. /// /// /// @@ -992,7 +992,15 @@ protected void Send (byte[] data) /// /// /// - /// The current state of the connection is not Open. + /// + /// The session has not started yet. + /// + /// + /// -or- + /// + /// + /// The current state of the WebSocket interface is not Open. + /// /// /// /// is . From c5ad157f3083efeb324c1db8e7cb66cc707c98a1 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 16 Nov 2022 16:03:36 +0900 Subject: [PATCH 4730/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 49b1d0d41..ab93e9176 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -1045,7 +1045,7 @@ protected void Send (FileInfo fileInfo) protected void Send (string data) { if (_websocket == null) { - var msg = "The current state of the connection is not Open."; + var msg = "The session has not started yet."; throw new InvalidOperationException (msg); } From 290578ea83a30d51cf50bb19acb2aa09a7f6e167 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 16 Nov 2022 16:06:35 +0900 Subject: [PATCH 4731/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index ab93e9176..27797ef45 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -1028,13 +1028,21 @@ protected void Send (FileInfo fileInfo) } /// - /// Sends the specified data to a client using the WebSocket connection. + /// Sends the specified data to the client for a session. /// /// /// A that specifies the text data to send. /// /// - /// The current state of the connection is not Open. + /// + /// The session has not started yet. + /// + /// + /// -or- + /// + /// + /// The current state of the WebSocket interface is not Open. + /// /// /// /// is . From 35c6f7990d75d8f0deadea43e44c0953aa387c88 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 16 Nov 2022 16:08:00 +0900 Subject: [PATCH 4732/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 27797ef45..09aba5b90 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -1102,7 +1102,7 @@ protected void Send (string data) protected void Send (Stream stream, int length) { if (_websocket == null) { - var msg = "The current state of the connection is not Open."; + var msg = "The session has not started yet."; throw new InvalidOperationException (msg); } From 148f51e2ca65656dee56ff2037e74aa38e8017b7 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 16 Nov 2022 21:55:11 +0900 Subject: [PATCH 4733/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 09aba5b90..09236b538 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -1062,8 +1062,8 @@ protected void Send (string data) } /// - /// Sends the data from the specified stream instance to a client using - /// the WebSocket connection. + /// Sends the data from the specified stream instance to the client for + /// a session. /// /// /// @@ -1077,7 +1077,15 @@ protected void Send (string data) /// An that specifies the number of bytes to send. /// /// - /// The current state of the connection is not Open. + /// + /// The session has not started yet. + /// + /// + /// -or- + /// + /// + /// The current state of the WebSocket interface is not Open. + /// /// /// /// is . From fbbb2dbddfa4326f689256a9a9e7bfc1ac8ddf06 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 16 Nov 2022 21:57:11 +0900 Subject: [PATCH 4734/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 09236b538..c35dde946 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -1150,7 +1150,7 @@ protected void Send (Stream stream, int length) protected void SendAsync (byte[] data, Action completed) { if (_websocket == null) { - var msg = "The current state of the connection is not Open."; + var msg = "The session has not started yet."; throw new InvalidOperationException (msg); } From b439b2c926dc0943f67e32e4c59c046bae1a8a7e Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 17 Nov 2022 15:02:33 +0900 Subject: [PATCH 4735/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 23 ++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index c35dde946..7252bdc79 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -1119,8 +1119,7 @@ protected void Send (Stream stream, int length) } /// - /// Sends the specified data to a client asynchronously using - /// the WebSocket connection. + /// Sends the specified data to the client for a session asynchronously. /// /// /// This method does not wait for the send to be complete. @@ -1130,19 +1129,29 @@ protected void Send (Stream stream, int length) /// /// /// - /// An Action<bool> delegate or - /// if not needed. + /// An delegate. /// /// /// The delegate invokes the method called when the send is complete. /// /// - /// true is passed to the method if the send has done with - /// no error; otherwise, false. + /// The parameter passed to the method is true + /// if the send has successfully done; otherwise, false. + /// + /// + /// if not necessary. /// /// /// - /// The current state of the connection is not Open. + /// + /// The session has not started yet. + /// + /// + /// -or- + /// + /// + /// The current state of the WebSocket interface is not Open. + /// /// /// /// is . From 4a521792fe2b8aae778fde745d271151fe7c2e30 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 17 Nov 2022 15:03:34 +0900 Subject: [PATCH 4736/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 7252bdc79..925103343 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -1215,7 +1215,7 @@ protected void SendAsync (byte[] data, Action completed) protected void SendAsync (FileInfo fileInfo, Action completed) { if (_websocket == null) { - var msg = "The current state of the connection is not Open."; + var msg = "The session has not started yet."; throw new InvalidOperationException (msg); } From 20f76ee5c7fc881e9f5035f5a6dff942f8d8cded Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 17 Nov 2022 15:07:29 +0900 Subject: [PATCH 4737/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 23 ++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 925103343..e13e6b15f 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -1168,8 +1168,7 @@ protected void SendAsync (byte[] data, Action completed) } /// - /// Sends the specified file to a client asynchronously using - /// the WebSocket connection. + /// Sends the specified file to the client for a session asynchronously. /// /// /// This method does not wait for the send to be complete. @@ -1184,19 +1183,29 @@ protected void SendAsync (byte[] data, Action completed) /// /// /// - /// An Action<bool> delegate or - /// if not needed. + /// An delegate. /// /// /// The delegate invokes the method called when the send is complete. /// /// - /// true is passed to the method if the send has done with - /// no error; otherwise, false. + /// The parameter passed to the method is true + /// if the send has successfully done; otherwise, false. + /// + /// + /// if not necessary. /// /// /// - /// The current state of the connection is not Open. + /// + /// The session has not started yet. + /// + /// + /// -or- + /// + /// + /// The current state of the WebSocket interface is not Open. + /// /// /// /// is . From d9287ecd8b99fc8d51b5f5c869c3542095f5718e Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 17 Nov 2022 15:08:14 +0900 Subject: [PATCH 4738/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index e13e6b15f..3b87c7afa 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -1267,7 +1267,7 @@ protected void SendAsync (FileInfo fileInfo, Action completed) protected void SendAsync (string data, Action completed) { if (_websocket == null) { - var msg = "The current state of the connection is not Open."; + var msg = "The session has not started yet."; throw new InvalidOperationException (msg); } From ecef7122e8970d961a51f3cb8b04187b86776e47 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 17 Nov 2022 15:11:24 +0900 Subject: [PATCH 4739/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 23 ++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 3b87c7afa..670dfced2 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -1233,8 +1233,7 @@ protected void SendAsync (FileInfo fileInfo, Action completed) } /// - /// Sends the specified data to a client asynchronously using - /// the WebSocket connection. + /// Sends the specified data to the client for a session asynchronously. /// /// /// This method does not wait for the send to be complete. @@ -1244,19 +1243,29 @@ protected void SendAsync (FileInfo fileInfo, Action completed) /// /// /// - /// An Action<bool> delegate or - /// if not needed. + /// An delegate. /// /// /// The delegate invokes the method called when the send is complete. /// /// - /// true is passed to the method if the send has done with - /// no error; otherwise, false. + /// The parameter passed to the method is true + /// if the send has successfully done; otherwise, false. + /// + /// + /// if not necessary. /// /// /// - /// The current state of the connection is not Open. + /// + /// The session has not started yet. + /// + /// + /// -or- + /// + /// + /// The current state of the WebSocket interface is not Open. + /// /// /// /// is . From 924b9d3a4e03de166e21cfd6d3aa0d0722638489 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 17 Nov 2022 15:12:18 +0900 Subject: [PATCH 4740/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 670dfced2..7924fc6d0 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -1341,7 +1341,7 @@ protected void SendAsync (string data, Action completed) protected void SendAsync (Stream stream, int length, Action completed) { if (_websocket == null) { - var msg = "The current state of the connection is not Open."; + var msg = "The session has not started yet."; throw new InvalidOperationException (msg); } From 70c9360f9b2d89f92bcdb0321090df622e1850bb Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 18 Nov 2022 16:03:39 +0900 Subject: [PATCH 4741/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 24 +++++++++++++++------ 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 7924fc6d0..ed840f099 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -1285,8 +1285,8 @@ protected void SendAsync (string data, Action completed) } /// - /// Sends the data from the specified stream instance to a client - /// asynchronously using the WebSocket connection. + /// Sends the data from the specified stream instance to the client for + /// a session asynchronously. /// /// /// This method does not wait for the send to be complete. @@ -1304,19 +1304,29 @@ protected void SendAsync (string data, Action completed) /// /// /// - /// An Action<bool> delegate or - /// if not needed. + /// An delegate. /// /// /// The delegate invokes the method called when the send is complete. /// /// - /// true is passed to the method if the send has done with - /// no error; otherwise, false. + /// The parameter passed to the method is true + /// if the send has successfully done; otherwise, false. + /// + /// + /// if not necessary. /// /// /// - /// The current state of the connection is not Open. + /// + /// The session has not started yet. + /// + /// + /// -or- + /// + /// + /// The current state of the WebSocket interface is not Open. + /// /// /// /// is . From bda3c7bdd5cd959539278615aa24d77b7ff8d108 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 18 Nov 2022 18:05:38 +0900 Subject: [PATCH 4742/6294] [Modify] Edit it --- websocket-sharp/Net/WebSockets/WebSocketContext.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/WebSockets/WebSocketContext.cs b/websocket-sharp/Net/WebSockets/WebSocketContext.cs index 12f11cf74..84841f5bd 100644 --- a/websocket-sharp/Net/WebSockets/WebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/WebSocketContext.cs @@ -211,11 +211,11 @@ protected WebSocketContext () public abstract System.Net.IPEndPoint UserEndPoint { get; } /// - /// Gets the WebSocket instance used for two-way communication between + /// Gets the WebSocket interface used for two-way communication between /// the client and server. /// /// - /// A . + /// A that represents the interface. /// public abstract WebSocket WebSocket { get; } From e799ce38298eee165f6d961595e882948b3f89cf Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 19 Nov 2022 17:45:06 +0900 Subject: [PATCH 4743/6294] [Modify] Edit it --- .../Net/WebSockets/HttpListenerWebSocketContext.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs b/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs index 975582652..7ea153f85 100644 --- a/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs @@ -349,11 +349,11 @@ public override System.Net.IPEndPoint UserEndPoint { } /// - /// Gets the WebSocket instance used for two-way communication between + /// Gets the WebSocket interface used for two-way communication between /// the client and server. /// /// - /// A . + /// A that represents the interface. /// public override WebSocket WebSocket { get { From 22e1045eb766c81515cb135fbb772c34143831f9 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 20 Nov 2022 17:37:06 +0900 Subject: [PATCH 4744/6294] [Modify] Edit it --- websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs index f3a383f30..f95eeb98f 100644 --- a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs @@ -418,11 +418,11 @@ public override System.Net.IPEndPoint UserEndPoint { } /// - /// Gets the WebSocket instance used for two-way communication between + /// Gets the WebSocket interface used for two-way communication between /// the client and server. /// /// - /// A . + /// A that represents the interface. /// public override WebSocket WebSocket { get { From 44e73b04ee4338f2ffa8550624a5181986522ec6 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 21 Nov 2022 21:12:42 +0900 Subject: [PATCH 4745/6294] [Modify] Add a check --- websocket-sharp/Net/HttpListenerContext.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/websocket-sharp/Net/HttpListenerContext.cs b/websocket-sharp/Net/HttpListenerContext.cs index 77fd99553..3c2d5698e 100644 --- a/websocket-sharp/Net/HttpListenerContext.cs +++ b/websocket-sharp/Net/HttpListenerContext.cs @@ -384,6 +384,12 @@ public HttpListenerWebSocketContext AcceptWebSocket ( throw new InvalidOperationException (msg); } + if (!_request.IsWebSocketRequest) { + var msg = "The request is not a WebSocket handshake request."; + + throw new InvalidOperationException (msg); + } + if (protocol != null) { if (protocol.Length == 0) { var msg = "An empty string."; From d0101e6e15c37335f267f0d916cfb1ab74af7d76 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 21 Nov 2022 21:16:19 +0900 Subject: [PATCH 4746/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerContext.cs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerContext.cs b/websocket-sharp/Net/HttpListenerContext.cs index 3c2d5698e..8da1b54d3 100644 --- a/websocket-sharp/Net/HttpListenerContext.cs +++ b/websocket-sharp/Net/HttpListenerContext.cs @@ -354,6 +354,17 @@ public HttpListenerWebSocketContext AcceptWebSocket (string protocol) /// initializing a new WebSocket instance. /// /// + /// + /// + /// This method has already been done. + /// + /// + /// -or- + /// + /// + /// The client request is not a WebSocket handshake request. + /// + /// /// /// /// is empty. @@ -371,9 +382,6 @@ public HttpListenerWebSocketContext AcceptWebSocket (string protocol) /// caused an exception. /// /// - /// - /// This method has already been done. - /// public HttpListenerWebSocketContext AcceptWebSocket ( string protocol, Action initializer ) From 529125cd6e0e6f0176688587d1a6f8f63c5b6187 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 22 Nov 2022 15:46:36 +0900 Subject: [PATCH 4747/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerContext.cs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerContext.cs b/websocket-sharp/Net/HttpListenerContext.cs index 8da1b54d3..abdba157b 100644 --- a/websocket-sharp/Net/HttpListenerContext.cs +++ b/websocket-sharp/Net/HttpListenerContext.cs @@ -309,6 +309,17 @@ internal void Unregister () /// if not necessary. /// /// + /// + /// + /// This method has already been done. + /// + /// + /// -or- + /// + /// + /// The client request is not a WebSocket handshake request. + /// + /// /// /// /// is empty. @@ -320,9 +331,6 @@ internal void Unregister () /// contains an invalid character. /// /// - /// - /// This method has already been done. - /// public HttpListenerWebSocketContext AcceptWebSocket (string protocol) { return AcceptWebSocket (protocol, null); From a0517fe8717e4ea8932fce83e6b5b11c8d7bcacc Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 23 Nov 2022 16:00:34 +0900 Subject: [PATCH 4748/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerContext.cs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerContext.cs b/websocket-sharp/Net/HttpListenerContext.cs index abdba157b..21f345628 100644 --- a/websocket-sharp/Net/HttpListenerContext.cs +++ b/websocket-sharp/Net/HttpListenerContext.cs @@ -153,16 +153,15 @@ public HttpListenerResponse Response { } /// - /// Gets the client information (identity, authentication, and security - /// roles). + /// Gets the client information. /// /// /// - /// A instance or - /// if not authenticated. + /// A instance that represents identity, + /// authentication, and security roles for the client. /// /// - /// The instance describes the client. + /// if the client is not authenticated. /// /// public IPrincipal User { From 4d6ddb4e23b4ff38311d2370ad5deb73623091ea Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 24 Nov 2022 15:45:51 +0900 Subject: [PATCH 4749/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 594db8e4f..f2ff1e70b 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2593,7 +2593,7 @@ internal void Send ( /// Closes the connection. /// /// - /// This method does nothing if the current state of the connection is + /// This method does nothing if the current state of the interface is /// Closing or Closed. /// public void Close () From f7bb4268a36b7bf04fa699fd076e30d47288e411 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 24 Nov 2022 15:50:20 +0900 Subject: [PATCH 4750/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index f2ff1e70b..485839737 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2639,16 +2639,19 @@ public void Close (ushort code) { if (!code.IsCloseStatusCode ()) { var msg = "Less than 1000 or greater than 4999."; + throw new ArgumentOutOfRangeException ("code", msg); } if (_client && code == 1011) { var msg = "1011 cannot be used."; + throw new ArgumentException (msg, "code"); } if (!_client && code == 1010) { var msg = "1010 cannot be used."; + throw new ArgumentException (msg, "code"); } From 9b47453f8d54e9610142136315ac77b5e52090cb Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 24 Nov 2022 17:31:21 +0900 Subject: [PATCH 4751/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 485839737..1827b7eeb 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2605,12 +2605,12 @@ public void Close () /// Closes the connection with the specified code. /// /// - /// This method does nothing if the current state of the connection is + /// This method does nothing if the current state of the interface is /// Closing or Closed. /// /// /// - /// A that represents the status code indicating + /// A that specifies the status code indicating /// the reason for the close. /// /// @@ -2624,15 +2624,15 @@ public void Close () /// /// /// - /// is 1011 (server error). - /// It cannot be used by clients. + /// is 1011 (server error). It cannot be + /// used by a client. /// /// /// -or- /// /// - /// is 1010 (mandatory extension). - /// It cannot be used by servers. + /// is 1010 (mandatory extension). It cannot + /// be used by a server. /// /// public void Close (ushort code) From e90019c52e8e27295b58bded1ffb062494f4daab Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 24 Nov 2022 17:33:56 +0900 Subject: [PATCH 4752/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 1827b7eeb..769327ba9 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2692,11 +2692,13 @@ public void Close (CloseStatusCode code) { if (_client && code == CloseStatusCode.ServerError) { var msg = "ServerError cannot be used."; + throw new ArgumentException (msg, "code"); } if (!_client && code == CloseStatusCode.MandatoryExtension) { var msg = "MandatoryExtension cannot be used."; + throw new ArgumentException (msg, "code"); } From d258010bcf3b697d98e0b569e6d39e3cead5e631 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 24 Nov 2022 23:04:53 +0900 Subject: [PATCH 4753/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 769327ba9..dbe42a6b6 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2662,7 +2662,7 @@ public void Close (ushort code) /// Closes the connection with the specified code. /// /// - /// This method does nothing if the current state of the connection is + /// This method does nothing if the current state of the interface is /// Closing or Closed. /// /// @@ -2670,22 +2670,22 @@ public void Close (ushort code) /// One of the enum values. /// /// - /// It represents the status code indicating the reason for the close. + /// It specifies the status code indicating the reason for the close. /// /// /// /// /// is - /// . - /// It cannot be used by clients. + /// . It cannot be used by + /// a client. /// /// /// -or- /// /// /// is - /// . - /// It cannot be used by servers. + /// . It cannot be + /// used by a server. /// /// public void Close (CloseStatusCode code) From 635943761e07f349bfb9a82c96b3937e281cbc53 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 24 Nov 2022 23:54:38 +0900 Subject: [PATCH 4754/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index dbe42a6b6..3816b7a0d 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2771,37 +2771,45 @@ public void Close (ushort code, string reason) { if (!code.IsCloseStatusCode ()) { var msg = "Less than 1000 or greater than 4999."; + throw new ArgumentOutOfRangeException ("code", msg); } if (_client && code == 1011) { var msg = "1011 cannot be used."; + throw new ArgumentException (msg, "code"); } if (!_client && code == 1010) { var msg = "1010 cannot be used."; + throw new ArgumentException (msg, "code"); } if (reason.IsNullOrEmpty ()) { close (code, String.Empty); + return; } if (code == 1005) { var msg = "1005 cannot be used."; + throw new ArgumentException (msg, "code"); } byte[] bytes; + if (!reason.TryGetUTF8EncodedBytes (out bytes)) { var msg = "It could not be UTF-8-encoded."; + throw new ArgumentException (msg, "reason"); } if (bytes.Length > 123) { var msg = "Its size is greater than 123 bytes."; + throw new ArgumentOutOfRangeException ("reason", msg); } From 9e8fd3176c62f486c73a6bafd559d61b54b048a2 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 25 Nov 2022 00:34:13 +0900 Subject: [PATCH 4755/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 3816b7a0d..ec79517e4 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2709,12 +2709,12 @@ public void Close (CloseStatusCode code) /// Closes the connection with the specified code and reason. /// /// - /// This method does nothing if the current state of the connection is + /// This method does nothing if the current state of the interface is /// Closing or Closed. /// /// /// - /// A that represents the status code indicating + /// A that specifies the status code indicating /// the reason for the close. /// /// @@ -2725,7 +2725,7 @@ public void Close (CloseStatusCode code) /// /// /// - /// A that represents the reason for the close. + /// A that specifies the reason for the close. /// /// /// The size must be 123 bytes or less in UTF-8. @@ -2744,21 +2744,22 @@ public void Close (CloseStatusCode code) /// /// /// - /// is 1011 (server error). - /// It cannot be used by clients. + /// is 1011 (server error). It cannot be used + /// by a client. /// /// /// -or- /// /// - /// is 1010 (mandatory extension). - /// It cannot be used by servers. + /// is 1010 (mandatory extension). It cannot + /// be used by a server. /// /// /// -or- /// /// - /// is 1005 (no status) and there is reason. + /// is 1005 (no status) and + /// is specified. /// /// /// -or- From 7b1ba6c07f7ff3d748c299b2627ae02b3df19e17 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 25 Nov 2022 00:37:44 +0900 Subject: [PATCH 4756/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index ec79517e4..8b6cac3b4 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2875,32 +2875,39 @@ public void Close (CloseStatusCode code, string reason) { if (_client && code == CloseStatusCode.ServerError) { var msg = "ServerError cannot be used."; + throw new ArgumentException (msg, "code"); } if (!_client && code == CloseStatusCode.MandatoryExtension) { var msg = "MandatoryExtension cannot be used."; + throw new ArgumentException (msg, "code"); } if (reason.IsNullOrEmpty ()) { close ((ushort) code, String.Empty); + return; } if (code == CloseStatusCode.NoStatus) { var msg = "NoStatus cannot be used."; + throw new ArgumentException (msg, "code"); } byte[] bytes; + if (!reason.TryGetUTF8EncodedBytes (out bytes)) { var msg = "It could not be UTF-8-encoded."; + throw new ArgumentException (msg, "reason"); } if (bytes.Length > 123) { var msg = "Its size is greater than 123 bytes."; + throw new ArgumentOutOfRangeException ("reason", msg); } From 2cd8dded827ed3dab9d9fd93407e6c5a9d5c20f4 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 25 Nov 2022 16:10:19 +0900 Subject: [PATCH 4757/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 8b6cac3b4..24bc09e64 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2821,7 +2821,7 @@ public void Close (ushort code, string reason) /// Closes the connection with the specified code and reason. /// /// - /// This method does nothing if the current state of the connection is + /// This method does nothing if the current state of the interface is /// Closing or Closed. /// /// @@ -2829,37 +2829,37 @@ public void Close (ushort code, string reason) /// One of the enum values. /// /// - /// It represents the status code indicating the reason for the close. + /// It specifies the status code indicating the reason for the close. /// /// /// /// - /// A that represents the reason for the close. + /// A that specifies the reason for the close. /// /// - /// The size must be 123 bytes or less in UTF-8. + /// Its size must be 123 bytes or less in UTF-8. /// /// /// /// /// is - /// . - /// It cannot be used by clients. + /// . It cannot be used by + /// a client. /// /// /// -or- /// /// /// is - /// . - /// It cannot be used by servers. + /// . It cannot be + /// used by a server. /// /// /// -or- /// /// - /// is - /// and there is reason. + /// is + /// and is specified. /// /// /// -or- From 345c3de97b049a8037018242c21bdf2242606603 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 25 Nov 2022 16:13:10 +0900 Subject: [PATCH 4758/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 24bc09e64..955568c65 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2624,8 +2624,8 @@ public void Close () /// /// /// - /// is 1011 (server error). It cannot be - /// used by a client. + /// is 1011 (server error). It cannot be used + /// by a client. /// /// /// -or- From b55f43b1c44234e65dd5a83d09942a8e30f90da7 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 25 Nov 2022 16:16:06 +0900 Subject: [PATCH 4759/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 955568c65..4702ee863 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2728,7 +2728,7 @@ public void Close (CloseStatusCode code) /// A that specifies the reason for the close. /// /// - /// The size must be 123 bytes or less in UTF-8. + /// Its size must be 123 bytes or less in UTF-8. /// /// /// From 2d24c79cf3a5d64cab01a4320b36c547a4b3f9f2 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 25 Nov 2022 16:18:20 +0900 Subject: [PATCH 4760/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index ed840f099..8ead4d787 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -581,7 +581,7 @@ protected void Close () /// A that specifies the reason for the close. /// /// - /// The size must be 123 bytes or less in UTF-8. + /// Its size must be 123 bytes or less in UTF-8. /// /// /// From 90a0768bd7a7b0bac3e2f650b5d359d8ff14565e Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 25 Nov 2022 16:20:12 +0900 Subject: [PATCH 4761/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 8ead4d787..7700c949a 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -648,7 +648,7 @@ protected void Close (ushort code, string reason) /// A that specifies the reason for the close. /// /// - /// The size must be 123 bytes or less in UTF-8. + /// Its size must be 123 bytes or less in UTF-8. /// /// /// From 4f9b364f5bcc39f2ec8d4fcec94b71f2f99ca357 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 25 Nov 2022 16:22:31 +0900 Subject: [PATCH 4762/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 7700c949a..5b07ae1e0 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -654,9 +654,6 @@ protected void Close (ushort code, string reason) /// /// The session has not started yet. /// - /// - /// The size of is greater than 123 bytes. - /// /// /// /// is @@ -676,6 +673,9 @@ protected void Close (ushort code, string reason) /// could not be UTF-8-encoded. /// /// + /// + /// The size of is greater than 123 bytes. + /// protected void Close (CloseStatusCode code, string reason) { if (_websocket == null) { From f7aa501809b883b13bd4679983ae9d0f0f9ed080 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 26 Nov 2022 15:59:29 +0900 Subject: [PATCH 4763/6294] [Modify] Replace it --- websocket-sharp/WebSocket.cs | 20 +------------------- 1 file changed, 1 insertion(+), 19 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 4702ee863..73b421446 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2637,25 +2637,7 @@ public void Close () /// public void Close (ushort code) { - if (!code.IsCloseStatusCode ()) { - var msg = "Less than 1000 or greater than 4999."; - - throw new ArgumentOutOfRangeException ("code", msg); - } - - if (_client && code == 1011) { - var msg = "1011 cannot be used."; - - throw new ArgumentException (msg, "code"); - } - - if (!_client && code == 1010) { - var msg = "1010 cannot be used."; - - throw new ArgumentException (msg, "code"); - } - - close (code, String.Empty); + Close (code, String.Empty); } /// From 42c6859a164d8ccf766b3bc02b18e57f18a4dde6 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 26 Nov 2022 16:02:55 +0900 Subject: [PATCH 4764/6294] [Modify] Replace it --- websocket-sharp/WebSocket.cs | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 73b421446..01f55849a 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2672,19 +2672,7 @@ public void Close (ushort code) /// public void Close (CloseStatusCode code) { - if (_client && code == CloseStatusCode.ServerError) { - var msg = "ServerError cannot be used."; - - throw new ArgumentException (msg, "code"); - } - - if (!_client && code == CloseStatusCode.MandatoryExtension) { - var msg = "MandatoryExtension cannot be used."; - - throw new ArgumentException (msg, "code"); - } - - close ((ushort) code, String.Empty); + Close (code, String.Empty); } /// From 30ad93a8e49c75b3af65f456f47e67519f4d1917 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 27 Nov 2022 16:16:02 +0900 Subject: [PATCH 4765/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 01f55849a..a8fa0d1ec 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2892,7 +2892,7 @@ public void Close (CloseStatusCode code, string reason) /// This method does not wait for the close to be complete. /// /// - /// This method does nothing if the current state of the connection is + /// This method does nothing if the current state of the interface is /// Closing or Closed. /// /// From c31a358656e2cf3d36f8c1ca69c1a7dea3dcebbb Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 27 Nov 2022 16:22:29 +0900 Subject: [PATCH 4766/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index a8fa0d1ec..962cf73d0 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2909,13 +2909,13 @@ public void CloseAsync () /// This method does not wait for the close to be complete. /// /// - /// This method does nothing if the current state of the connection is + /// This method does nothing if the current state of the interface is /// Closing or Closed. /// /// /// /// - /// A that represents the status code indicating + /// A that specifies the status code indicating /// the reason for the close. /// /// @@ -2929,15 +2929,15 @@ public void CloseAsync () /// /// /// - /// is 1011 (server error). - /// It cannot be used by clients. + /// is 1011 (server error). It cannot be used + /// by a client. /// /// /// -or- /// /// - /// is 1010 (mandatory extension). - /// It cannot be used by servers. + /// is 1010 (mandatory extension). It cannot + /// be used by a server. /// /// public void CloseAsync (ushort code) From 2e1eca3558c7982a76ebc3863c828162d1914ccf Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 27 Nov 2022 17:42:45 +0900 Subject: [PATCH 4767/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 962cf73d0..d0eff7a48 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2968,7 +2968,7 @@ public void CloseAsync (ushort code) /// This method does not wait for the close to be complete. /// /// - /// This method does nothing if the current state of the connection is + /// This method does nothing if the current state of the interface is /// Closing or Closed. /// /// @@ -2977,22 +2977,20 @@ public void CloseAsync (ushort code) /// One of the enum values. /// /// - /// It represents the status code indicating the reason for the close. + /// It specifies the status code indicating the reason for the close. /// /// /// /// - /// is - /// . - /// It cannot be used by clients. + /// is . + /// It cannot be used by a client. /// /// /// -or- /// /// - /// is - /// . - /// It cannot be used by servers. + /// is . + /// It cannot be used by a server. /// /// public void CloseAsync (CloseStatusCode code) From e9d0e79d9cd02be084e9086f9587ff4522f29b84 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 27 Nov 2022 17:46:53 +0900 Subject: [PATCH 4768/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index d0eff7a48..824ecbf6a 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3079,37 +3079,45 @@ public void CloseAsync (ushort code, string reason) { if (!code.IsCloseStatusCode ()) { var msg = "Less than 1000 or greater than 4999."; + throw new ArgumentOutOfRangeException ("code", msg); } if (_client && code == 1011) { var msg = "1011 cannot be used."; + throw new ArgumentException (msg, "code"); } if (!_client && code == 1010) { var msg = "1010 cannot be used."; + throw new ArgumentException (msg, "code"); } if (reason.IsNullOrEmpty ()) { closeAsync (code, String.Empty); + return; } if (code == 1005) { var msg = "1005 cannot be used."; + throw new ArgumentException (msg, "code"); } byte[] bytes; + if (!reason.TryGetUTF8EncodedBytes (out bytes)) { var msg = "It could not be UTF-8-encoded."; + throw new ArgumentException (msg, "reason"); } if (bytes.Length > 123) { var msg = "Its size is greater than 123 bytes."; + throw new ArgumentOutOfRangeException ("reason", msg); } From e64110b86a9b13ce7d7d83772bf7fe806e67bfbc Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 28 Nov 2022 15:53:54 +0900 Subject: [PATCH 4769/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 824ecbf6a..4eeb3aef9 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3016,13 +3016,13 @@ public void CloseAsync (CloseStatusCode code) /// This method does not wait for the close to be complete. /// /// - /// This method does nothing if the current state of the connection is + /// This method does nothing if the current state of the interface is /// Closing or Closed. /// /// /// /// - /// A that represents the status code indicating + /// A that specifies the status code indicating /// the reason for the close. /// /// @@ -3033,10 +3033,10 @@ public void CloseAsync (CloseStatusCode code) /// /// /// - /// A that represents the reason for the close. + /// A that specifies the reason for the close. /// /// - /// The size must be 123 bytes or less in UTF-8. + /// Its size must be 123 bytes or less in UTF-8. /// /// /// @@ -3053,20 +3053,21 @@ public void CloseAsync (CloseStatusCode code) /// /// /// is 1011 (server error). - /// It cannot be used by clients. + /// It cannot be used by a client. /// /// /// -or- /// /// /// is 1010 (mandatory extension). - /// It cannot be used by servers. + /// It cannot be used by a server. /// /// /// -or- /// /// - /// is 1005 (no status) and there is reason. + /// is 1005 (no status) and + /// is specified. /// /// /// -or- From ce826d50ac292207960d944762511f76d89ac458 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 28 Nov 2022 15:56:51 +0900 Subject: [PATCH 4770/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 4eeb3aef9..cfb2aa2d8 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3188,32 +3188,39 @@ public void CloseAsync (CloseStatusCode code, string reason) { if (_client && code == CloseStatusCode.ServerError) { var msg = "ServerError cannot be used."; + throw new ArgumentException (msg, "code"); } if (!_client && code == CloseStatusCode.MandatoryExtension) { var msg = "MandatoryExtension cannot be used."; + throw new ArgumentException (msg, "code"); } if (reason.IsNullOrEmpty ()) { closeAsync ((ushort) code, String.Empty); + return; } if (code == CloseStatusCode.NoStatus) { var msg = "NoStatus cannot be used."; + throw new ArgumentException (msg, "code"); } byte[] bytes; + if (!reason.TryGetUTF8EncodedBytes (out bytes)) { var msg = "It could not be UTF-8-encoded."; + throw new ArgumentException (msg, "reason"); } if (bytes.Length > 123) { var msg = "Its size is greater than 123 bytes."; + throw new ArgumentOutOfRangeException ("reason", msg); } From ff25dfc8f389f34916a606336e66e404e639494b Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 28 Nov 2022 16:07:11 +0900 Subject: [PATCH 4771/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index cfb2aa2d8..62d9a10dc 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3133,7 +3133,7 @@ public void CloseAsync (ushort code, string reason) /// This method does not wait for the close to be complete. /// /// - /// This method does nothing if the current state of the connection is + /// This method does nothing if the current state of the interface is /// Closing or Closed. /// /// @@ -3142,37 +3142,35 @@ public void CloseAsync (ushort code, string reason) /// One of the enum values. /// /// - /// It represents the status code indicating the reason for the close. + /// It specifies the status code indicating the reason for the close. /// /// /// /// - /// A that represents the reason for the close. + /// A that specifies the reason for the close. /// /// - /// The size must be 123 bytes or less in UTF-8. + /// Its size must be 123 bytes or less in UTF-8. /// /// /// /// - /// is - /// . - /// It cannot be used by clients. + /// is . + /// It cannot be used by a client. /// /// /// -or- /// /// - /// is - /// . - /// It cannot be used by servers. + /// is . + /// It cannot be used by a server. /// /// /// -or- /// /// - /// is - /// and there is reason. + /// is and + /// is specified. /// /// /// -or- From c1754af5a7a379a87d1c23c9fb627b688db10c2a Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 28 Nov 2022 16:09:01 +0900 Subject: [PATCH 4772/6294] [Modify] Replace it --- websocket-sharp/WebSocket.cs | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 62d9a10dc..01da914a6 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2942,22 +2942,7 @@ public void CloseAsync () /// public void CloseAsync (ushort code) { - if (!code.IsCloseStatusCode ()) { - var msg = "Less than 1000 or greater than 4999."; - throw new ArgumentOutOfRangeException ("code", msg); - } - - if (_client && code == 1011) { - var msg = "1011 cannot be used."; - throw new ArgumentException (msg, "code"); - } - - if (!_client && code == 1010) { - var msg = "1010 cannot be used."; - throw new ArgumentException (msg, "code"); - } - - closeAsync (code, String.Empty); + CloseAsync (code, String.Empty); } /// From 04d3f2b0a7928f93c9072812b3ea14310f163108 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 28 Nov 2022 16:10:56 +0900 Subject: [PATCH 4773/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 01da914a6..698ff6087 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2929,15 +2929,15 @@ public void CloseAsync () /// /// /// - /// is 1011 (server error). It cannot be used - /// by a client. + /// is 1011 (server error). + /// It cannot be used by a client. /// /// /// -or- /// /// - /// is 1010 (mandatory extension). It cannot - /// be used by a server. + /// is 1010 (mandatory extension). + /// It cannot be used by a server. /// /// public void CloseAsync (ushort code) From c7d32e5495962205aefe9c04434faba7e4562759 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 28 Nov 2022 16:12:31 +0900 Subject: [PATCH 4774/6294] [Modify] Replace it --- websocket-sharp/WebSocket.cs | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 698ff6087..8f555ea44 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2980,17 +2980,7 @@ public void CloseAsync (ushort code) /// public void CloseAsync (CloseStatusCode code) { - if (_client && code == CloseStatusCode.ServerError) { - var msg = "ServerError cannot be used."; - throw new ArgumentException (msg, "code"); - } - - if (!_client && code == CloseStatusCode.MandatoryExtension) { - var msg = "MandatoryExtension cannot be used."; - throw new ArgumentException (msg, "code"); - } - - closeAsync ((ushort) code, String.Empty); + CloseAsync (code, String.Empty); } /// From 5e255c2f9dc40d1f6912f911331c5dbe7299d032 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 28 Nov 2022 16:17:01 +0900 Subject: [PATCH 4775/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 5b07ae1e0..86e10ea50 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -742,7 +742,7 @@ protected void CloseAsync () /// A that specifies the reason for the close. /// /// - /// The size must be 123 bytes or less in UTF-8. + /// Its size must be 123 bytes or less in UTF-8. /// /// /// From 02c5ea98f476709578494ea71ad2f10c45bc3087 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 28 Nov 2022 16:19:38 +0900 Subject: [PATCH 4776/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 86e10ea50..db5387226 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -814,7 +814,7 @@ protected void CloseAsync (ushort code, string reason) /// A that specifies the reason for the close. /// /// - /// The size must be 123 bytes or less in UTF-8. + /// Its size must be 123 bytes or less in UTF-8. /// /// /// @@ -822,15 +822,14 @@ protected void CloseAsync (ushort code, string reason) /// /// /// - /// is - /// . + /// is . /// /// /// -or- /// /// - /// is - /// and is specified. + /// is and + /// is specified. /// /// /// -or- From 2fcb4f993fe6480c5eb14f6906c70dfedeb2e050 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 28 Nov 2022 16:56:15 +0900 Subject: [PATCH 4777/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 8f555ea44..a4e135c85 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2624,15 +2624,15 @@ public void Close () /// /// /// - /// is 1011 (server error). It cannot be used - /// by a client. + /// is 1011 (server error). + /// It cannot be used by a client. /// /// /// -or- /// /// - /// is 1010 (mandatory extension). It cannot - /// be used by a server. + /// is 1010 (mandatory extension). + /// It cannot be used by a server. /// /// public void Close (ushort code) From 29635fc3493711b3ef8fe2b88e1258babf3c38af Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 28 Nov 2022 16:58:35 +0900 Subject: [PATCH 4778/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index a4e135c85..bb638db39 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2657,17 +2657,15 @@ public void Close (ushort code) /// /// /// - /// is - /// . It cannot be used by - /// a client. + /// is . + /// It cannot be used by a client. /// /// /// -or- /// /// - /// is - /// . It cannot be - /// used by a server. + /// is . + /// It cannot be used by a server. /// /// public void Close (CloseStatusCode code) From a26e5626e6f2d5a6b73ee8983b5efc69f1b77002 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 28 Nov 2022 17:39:39 +0900 Subject: [PATCH 4779/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index bb638db39..a65a99aab 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2712,15 +2712,15 @@ public void Close (CloseStatusCode code) /// /// /// - /// is 1011 (server error). It cannot be used - /// by a client. + /// is 1011 (server error). + /// It cannot be used by a client. /// /// /// -or- /// /// - /// is 1010 (mandatory extension). It cannot - /// be used by a server. + /// is 1010 (mandatory extension). + /// It cannot be used by a server. /// /// /// -or- From 25e0a17b0ad74ea1156129e9eebc09cb162b90f9 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 28 Nov 2022 23:09:11 +0900 Subject: [PATCH 4780/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index a65a99aab..3548efd13 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2810,24 +2810,22 @@ public void Close (ushort code, string reason) /// /// /// - /// is - /// . It cannot be used by - /// a client. + /// is . + /// It cannot be used by a client. /// /// /// -or- /// /// - /// is - /// . It cannot be - /// used by a server. + /// is . + /// It cannot be used by a server. /// /// /// -or- /// /// - /// is - /// and is specified. + /// is and + /// is specified. /// /// /// -or- From 5fcfad714500bf5e47558b3d1d7ed3eb7467549b Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 28 Nov 2022 23:14:25 +0900 Subject: [PATCH 4781/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index db5387226..2696e8841 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -656,15 +656,14 @@ protected void Close (ushort code, string reason) /// /// /// - /// is - /// . + /// is . /// /// /// -or- /// /// - /// is - /// and is specified. + /// is and + /// is specified. /// /// /// -or- From 8abff181557a59eeffc3ec98016d072da0849bc7 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 29 Nov 2022 15:40:24 +0900 Subject: [PATCH 4782/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 3548efd13..99840026c 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3289,10 +3289,10 @@ public void ConnectAsync () } /// - /// Sends a ping using the WebSocket connection. + /// Sends a ping to the remote endpoint. /// /// - /// true if the send has done with no error and a pong has been + /// true if the send has successfully done and a pong has been /// received within a time; otherwise, false. /// public bool Ping () From 1b0b11c89b6e3c5eeef908c6d6a2768a58b60127 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 29 Nov 2022 15:42:07 +0900 Subject: [PATCH 4783/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 99840026c..da1257e26 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3328,13 +3328,16 @@ public bool Ping (string message) return ping (EmptyBytes); byte[] bytes; + if (!message.TryGetUTF8EncodedBytes (out bytes)) { var msg = "It could not be UTF-8-encoded."; + throw new ArgumentException (msg, "message"); } if (bytes.Length > 125) { var msg = "Its size is greater than 125 bytes."; + throw new ArgumentOutOfRangeException ("message", msg); } From 5cb7c46914b9d396a837873b9c3d69551aeaa0d5 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 29 Nov 2022 15:47:00 +0900 Subject: [PATCH 4784/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index da1257e26..ff0f463f5 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3301,19 +3301,18 @@ public bool Ping () } /// - /// Sends a ping with using the WebSocket - /// connection. + /// Sends a ping with the specified message to the remote endpoint. /// /// - /// true if the send has done with no error and a pong has been + /// true if the send has successfully done and a pong has been /// received within a time; otherwise, false. /// /// /// - /// A that represents the message to send. + /// A that specifies the message to send. /// /// - /// The size must be 125 bytes or less in UTF-8. + /// Its size must be 125 bytes or less in UTF-8. /// /// /// From eaace6fbbf4a0ce46081db8bfbc93a61dd1a218e Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 29 Nov 2022 15:48:11 +0900 Subject: [PATCH 4785/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 2696e8841..72728af10 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -924,7 +924,7 @@ protected bool Ping () /// A that specifies the message to send. /// /// - /// The size must be 125 bytes or less in UTF-8. + /// Its size must be 125 bytes or less in UTF-8. /// /// /// From de1ff1f100b4d4dec5578b56ee4436ab1b332e33 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 29 Nov 2022 16:24:54 +0900 Subject: [PATCH 4786/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index ff0f463f5..90a0ad376 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -482,14 +482,10 @@ public string Extensions { } /// - /// Gets a value indicating whether the connection is alive. + /// Gets a value indicating whether the communication is possible. /// - /// - /// The get operation returns the value by using a ping/pong - /// if the current state of the connection is Open. - /// /// - /// true if the connection is alive; otherwise, false. + /// true if the communication is possible; otherwise, false. /// public bool IsAlive { get { From 3035bcf6795e1efe1a02301506f62f52a560c9d9 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 29 Nov 2022 17:31:22 +0900 Subject: [PATCH 4787/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 90a0ad376..829f14b01 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -494,11 +494,10 @@ public bool IsAlive { } /// - /// Gets a value indicating whether a secure connection is used. + /// Gets a value indicating whether the connection is secure. /// /// - /// true if this instance uses a secure connection; otherwise, - /// false. + /// true if the connection is secure; otherwise, false. /// public bool IsSecure { get { From 9835288861f0ac236863b95b3f36130135cdcf98 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 29 Nov 2022 17:55:19 +0900 Subject: [PATCH 4788/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 829f14b01..2d16bebb4 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -669,12 +669,14 @@ public WebSocketState ReadyState { public ClientSslConfiguration SslConfiguration { get { if (!_client) { - var msg = "This instance is not a client."; + var msg = "The interface is not for the client."; + throw new InvalidOperationException (msg); } if (!_secure) { - var msg = "This instance does not use a secure connection."; + var msg = "The interface does not use a secure connection."; + throw new InvalidOperationException (msg); } From 48d4f9d61f0344af065d042c7880bd553d3f976d Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 30 Nov 2022 15:52:17 +0900 Subject: [PATCH 4789/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 2d16bebb4..dc25fc078 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -651,19 +651,22 @@ public WebSocketState ReadyState { /// Gets the configuration for secure connection. /// /// - /// This configuration will be referenced when attempts to connect, + /// The configuration is used when the interface attempts to connect, /// so it must be configured before any connect method is called. /// /// - /// A that represents - /// the configuration used to establish a secure connection. + /// A used to establish a secure + /// connection. /// /// /// - /// This instance is not a client. + /// The interface is not for the client. + /// + /// + /// -or- /// /// - /// This instance does not use a secure connection. + /// The interface does not use a secure connection. /// /// public ClientSslConfiguration SslConfiguration { From 26991e69c7a2eced2a8bfdd786b5233ea6d93a55 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 30 Nov 2022 15:53:56 +0900 Subject: [PATCH 4790/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index dc25fc078..63a4a02da 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3217,7 +3217,7 @@ public void CloseAsync (CloseStatusCode code, string reason) public void Connect () { if (!_client) { - var msg = "The instance is not a client."; + var msg = "The interface is not for the client."; throw new InvalidOperationException (msg); } From f0e81246629dc0a5157554db04760c2935a8e6db Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 30 Nov 2022 15:55:44 +0900 Subject: [PATCH 4791/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 63a4a02da..e8f2eda94 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3205,7 +3205,7 @@ public void CloseAsync (CloseStatusCode code, string reason) /// /// /// - /// This instance is not a client. + /// The interface is not for the client. /// /// /// -or- From 4191a3c3634bf4ff1ab78cc584e7b64000aa73d6 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 30 Nov 2022 15:57:10 +0900 Subject: [PATCH 4792/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index e8f2eda94..fcc781a32 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3262,7 +3262,7 @@ public void Connect () public void ConnectAsync () { if (!_client) { - var msg = "The instance is not a client."; + var msg = "The interface is not for the client."; throw new InvalidOperationException (msg); } From 0b136efa7207101d1ba00daa4e99900865f26b22 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 30 Nov 2022 15:58:38 +0900 Subject: [PATCH 4793/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index fcc781a32..c771979e7 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3250,7 +3250,7 @@ public void Connect () /// /// /// - /// This instance is not a client. + /// The interface is not for the client. /// /// /// -or- From 110084fb58640d82f2c39a66327965e6520d32cf Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 30 Nov 2022 16:03:07 +0900 Subject: [PATCH 4794/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index c771979e7..e0ed4a61d 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3803,7 +3803,7 @@ public void SendAsync (Stream stream, int length, Action completed) public void SetCookie (Cookie cookie) { if (!_client) { - var msg = "The instance is not a client."; + var msg = "The interface is not for the client."; throw new InvalidOperationException (msg); } From 109fed67716a7a1896e8871621696338d10e61bf Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 30 Nov 2022 16:04:57 +0900 Subject: [PATCH 4795/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index e0ed4a61d..d94e0edc5 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3795,7 +3795,7 @@ public void SendAsync (Stream stream, int length, Action completed) /// A that specifies the cookie to send. /// /// - /// This instance is not a client. + /// The interface is not for the client. /// /// /// is . From 13564c494a54bbed0daa35515d7014587d9ca993 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 30 Nov 2022 16:06:15 +0900 Subject: [PATCH 4796/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index d94e0edc5..380a368aa 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3868,7 +3868,7 @@ public void SetCookie (Cookie cookie) public void SetCredentials (string username, string password, bool preAuth) { if (!_client) { - var msg = "The instance is not a client."; + var msg = "The interface is not for the client."; throw new InvalidOperationException (msg); } From 1ccd1366dbc6a086c0b06bba0195768139e12d90 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 30 Nov 2022 16:07:46 +0900 Subject: [PATCH 4797/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 380a368aa..cac1220bb 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3852,7 +3852,7 @@ public void SetCookie (Cookie cookie) /// request; otherwise, false. /// /// - /// This instance is not a client. + /// The interface is not for the client. /// /// /// From b63393f1c92357cd0cb07cf3a1e9f44b05c09fbd Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 30 Nov 2022 16:09:09 +0900 Subject: [PATCH 4798/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index cac1220bb..3a8248532 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3983,7 +3983,7 @@ public void SetCredentials (string username, string password, bool preAuth) public void SetProxy (string url, string username, string password) { if (!_client) { - var msg = "The instance is not a client."; + var msg = "The interface is not for the client."; throw new InvalidOperationException (msg); } From 29d08ed0035a9bf0d8059098a04972d3357940b1 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 30 Nov 2022 16:10:58 +0900 Subject: [PATCH 4799/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 3a8248532..608828173 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3949,7 +3949,7 @@ public void SetCredentials (string username, string password, bool preAuth) /// /// /// - /// This instance is not a client. + /// The interface is not for the client. /// /// /// From ba63eebd71b1ff151168f84618494fe50e25a3b8 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 30 Nov 2022 16:13:29 +0900 Subject: [PATCH 4800/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 608828173..345ca41df 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -4062,7 +4062,7 @@ public void SetProxy (string url, string username, string password) /// This method closes the connection with close status 1001 (going away). /// /// - /// And this method does nothing if the current state of the connection is + /// This method does nothing if the current state of the interface is /// Closing or Closed. /// /// From 63a40205a43a88aaa966358126e23830c0fa1b73 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 30 Nov 2022 16:14:53 +0900 Subject: [PATCH 4801/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 345ca41df..0d3321391 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -349,7 +349,7 @@ public CompressionMethod Compression { set { if (!_client) { - var msg = "The instance is not a client."; + var msg = "The interface is not for the client."; throw new InvalidOperationException (msg); } From 163fd12ac0c1bfd3b0b244fd89d297b7969fe60a Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 30 Nov 2022 16:17:50 +0900 Subject: [PATCH 4802/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 0d3321391..5b6f62f44 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -340,7 +340,8 @@ internal bool IgnoreExtensions { /// /// /// - /// The set operation is not available if this instance is not a client. + /// The set operation is not available if the interface is not for + /// the client. /// public CompressionMethod Compression { get { From e921f4435f08365056d72dca21958c86df2a81c0 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 30 Nov 2022 16:55:38 +0900 Subject: [PATCH 4803/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 5b6f62f44..ca94436c6 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -405,13 +405,13 @@ public NetworkCredential Credentials { } /// - /// Gets or sets a value indicating whether a event - /// is emitted when a ping is received. + /// Gets or sets a value indicating whether the interface emits + /// the message event when receives a ping. /// /// /// - /// true if this instance emits a event - /// when receives a ping; otherwise, false. + /// true if the interface emits the message event when + /// receives a ping; otherwise, false. /// /// /// The default value is false. From a62e5abc408c959be3bbf6e11f1a46abe15ccfa7 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 30 Nov 2022 16:57:50 +0900 Subject: [PATCH 4804/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index ca94436c6..11e2a4925 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -454,7 +454,7 @@ public bool EnableRedirection { set { if (!_client) { - var msg = "The instance is not a client."; + var msg = "The interface is not for the client."; throw new InvalidOperationException (msg); } From 9671f75674d0c8733625a74a1fbeaa79e62fa219 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 30 Nov 2022 17:00:28 +0900 Subject: [PATCH 4805/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 11e2a4925..6f46d2918 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -437,7 +437,7 @@ public bool EmitOnPing { /// /// /// - /// true if this instance allows the URL redirection for + /// true if the interface allows the URL redirection for /// the handshake request; otherwise, false. /// /// @@ -445,7 +445,8 @@ public bool EmitOnPing { /// /// /// - /// The set operation is not available if this instance is not a client. + /// The set operation is not available if the interface is not for + /// the client. /// public bool EnableRedirection { get { From 9348225982a6b2d3afee3f0fa49358e4d3b7c559 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 30 Nov 2022 17:02:20 +0900 Subject: [PATCH 4806/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 6f46d2918..573c33aef 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -577,7 +577,7 @@ public string Origin { set { if (!_client) { - var msg = "The instance is not a client."; + var msg = "The interface is not for the client."; throw new InvalidOperationException (msg); } From d416fe1c3d2eb7df61a8b4a2c1fa3adeb3758ec1 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 30 Nov 2022 17:06:37 +0900 Subject: [PATCH 4807/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 573c33aef..56c84c1bc 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -537,7 +537,7 @@ internal set { /// Section 7 of RFC 6454. /// /// - /// This instance sends the Origin header if this property has any. + /// The interface sends the Origin header if this property has any. /// /// /// The set operation does nothing if the connection has already been @@ -557,7 +557,8 @@ internal set { /// /// /// - /// The set operation is not available if this instance is not a client. + /// The set operation is not available if the interface is not for + /// the client. /// /// /// From 1bf805c2d376c8b7b5235e34fe584dab70d5fcfb Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 1 Dec 2022 15:45:04 +0900 Subject: [PATCH 4808/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 56c84c1bc..788e64078 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -714,8 +714,8 @@ public Uri Url { /// A to wait for the response. /// /// - /// The default value is the same as 5 seconds if this instance is - /// a client. + /// The default value is the same as 5 seconds if the interface is + /// for the client. /// /// /// From 85bfa31b4256273489f559e943aa6a8e9fd8ebcb Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 1 Dec 2022 15:59:28 +0900 Subject: [PATCH 4809/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 788e64078..3a59eb388 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -727,8 +727,11 @@ public TimeSpan WaitTime { } set { - if (value <= TimeSpan.Zero) - throw new ArgumentOutOfRangeException ("value", "Zero or less."); + if (value <= TimeSpan.Zero) { + var msg = "Zero or less."; + + throw new ArgumentOutOfRangeException ("value", msg); + } lock (_forState) { if (!canSet ()) From 53fa15e789b0c52911c51718efa7efdf32872508 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 2 Dec 2022 15:43:55 +0900 Subject: [PATCH 4810/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 3a59eb388..85e2135fa 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -706,8 +706,8 @@ public Uri Url { /// Gets or sets the time to wait for the response to the ping or close. /// /// - /// The set operation does nothing if the connection has already been - /// established or it is closing. + /// The set operation works if the current state of the interface is + /// New or Closed. /// /// /// From f6a8ad52f531096d56b391c23a983aafc075b764 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 2 Dec 2022 16:18:21 +0900 Subject: [PATCH 4811/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 85e2135fa..abc81a1ec 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -325,15 +325,15 @@ internal bool IgnoreExtensions { /// Gets or sets the compression method used to compress a message. /// /// - /// The set operation does nothing if the connection has already been - /// established or it is closing. + /// The set operation works if the current state of the interface is + /// New or Closed. /// /// /// /// One of the enum values. /// /// - /// It specifies the compression method used to compress a message. + /// It represents the compression method used to compress a message. /// /// /// The default value is . From bc1f49293f039e0372c998815fa9d0b71371c2d8 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 2 Dec 2022 17:20:58 +0900 Subject: [PATCH 4812/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index abc81a1ec..022829458 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -432,8 +432,8 @@ public bool EmitOnPing { /// the handshake request is allowed. /// /// - /// The set operation does nothing if the connection has already been - /// established or it is closing. + /// The set operation works if the current state of the interface is + /// New or Closed. /// /// /// From 15c6107cbf567fb9da508312c94c4a0fb77e4407 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 2 Dec 2022 17:23:41 +0900 Subject: [PATCH 4813/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 022829458..a2f452aab 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -540,8 +540,8 @@ internal set { /// The interface sends the Origin header if this property has any. /// /// - /// The set operation does nothing if the connection has already been - /// established or it is closing. + /// The set operation works if the current state of the interface is + /// New or Closed. /// /// /// From 093e3c270c6996bb6fc407c3ac99eb901dd5cb45 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 3 Dec 2022 15:56:47 +0900 Subject: [PATCH 4814/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index a2f452aab..dcc8c9675 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -711,7 +711,8 @@ public Uri Url { /// /// /// - /// A to wait for the response. + /// A that represents the time to wait for + /// the response. /// /// /// The default value is the same as 5 seconds if the interface is From 89f0f59f552a118593af6a7dbbdb13107c7f17ff Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 3 Dec 2022 16:11:44 +0900 Subject: [PATCH 4815/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index dcc8c9675..1fa6dd937 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -658,8 +658,8 @@ public WebSocketState ReadyState { /// so it must be configured before any connect method is called. /// /// - /// A used to establish a secure - /// connection. + /// A that represents the + /// configuration used to establish a secure connection. /// /// /// From 61446c6b74d5b1862bf1912fea5beac6d288c039 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 3 Dec 2022 16:19:25 +0900 Subject: [PATCH 4816/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 1fa6dd937..c0671b654 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -470,12 +470,12 @@ public bool EnableRedirection { } /// - /// Gets the extensions selected by server. + /// Gets the extensions selected by the server. /// /// /// A that will be a list of the extensions - /// negotiated between client and server, or an empty string if - /// not specified or selected. + /// negotiated between the client and server, or an empty string + /// if not specified or selected. /// public string Extensions { get { From 0352790a75d406c2d78fd188723d80d2c7409974 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 3 Dec 2022 17:13:07 +0900 Subject: [PATCH 4817/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index c0671b654..896f070f3 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -405,8 +405,8 @@ public NetworkCredential Credentials { } /// - /// Gets or sets a value indicating whether the interface emits - /// the message event when receives a ping. + /// Gets or sets a value indicating whether the message event is + /// emitted when the interface receives a ping. /// /// /// From 4632645e547f86aa9b934317d80d83875a897df4 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 3 Dec 2022 23:02:42 +0900 Subject: [PATCH 4818/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 72728af10..d97be5679 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -265,8 +265,8 @@ public Func CookiesValidator { } /// - /// Gets or sets a value indicating whether the WebSocket interface for - /// a session emits the message event when receives a ping. + /// Gets or sets a value indicating whether the message event is emitted + /// when the WebSocket interface for a session receives a ping. /// /// /// From db16d0c390d6288450e45df64df56bd73d313238 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 3 Dec 2022 23:05:52 +0900 Subject: [PATCH 4819/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 896f070f3..164fa01bc 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -333,7 +333,7 @@ internal bool IgnoreExtensions { /// One of the enum values. /// /// - /// It represents the compression method used to compress a message. + /// It indicates the compression method used to compress a message. /// /// /// The default value is . From 30b60d92b67106ee257c9fbe19624d344825b638 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 3 Dec 2022 23:09:41 +0900 Subject: [PATCH 4820/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 164fa01bc..7c2430052 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -748,7 +748,7 @@ public TimeSpan WaitTime { #region Public Events /// - /// Occurs when the WebSocket connection has been closed. + /// Occurs when the connection has been closed. /// public event EventHandler OnClose; From a37877a0e7f0c72891d032b3f6bf1bb1d91d316e Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 3 Dec 2022 23:11:31 +0900 Subject: [PATCH 4821/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 7c2430052..d066928a0 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -753,7 +753,7 @@ public TimeSpan WaitTime { public event EventHandler OnClose; /// - /// Occurs when the gets an error. + /// Occurs when the interface gets an error. /// public event EventHandler OnError; From e0356b9ef312eb9e32dd65af557210b641a59649 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 3 Dec 2022 23:12:50 +0900 Subject: [PATCH 4822/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index d066928a0..a39ff5401 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -758,7 +758,7 @@ public TimeSpan WaitTime { public event EventHandler OnError; /// - /// Occurs when the receives a message. + /// Occurs when the interface receives a message. /// public event EventHandler OnMessage; From 955ba45c3109cc57dafb47f47e79151304330455 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 3 Dec 2022 23:14:32 +0900 Subject: [PATCH 4823/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index a39ff5401..552faa58f 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -763,7 +763,7 @@ public TimeSpan WaitTime { public event EventHandler OnMessage; /// - /// Occurs when the WebSocket connection has been established. + /// Occurs when the connection has been established. /// public event EventHandler OnOpen; From 13bddc5eeb16d4f223c929f70582177d5b1a99ef Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 4 Dec 2022 16:20:52 +0900 Subject: [PATCH 4824/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 552faa58f..999c442c1 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3795,8 +3795,8 @@ public void SendAsync (Stream stream, int length, Action completed) /// Sets an HTTP cookie to send with the handshake request. /// /// - /// This method does nothing if the connection has already been - /// established or it is closing. + /// This method works if the current state of the interface is + /// New or Closed. /// /// /// A that specifies the cookie to send. From c11dccefbb00db892ca1a847572cb7d35af32f10 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 4 Dec 2022 16:24:36 +0900 Subject: [PATCH 4825/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 999c442c1..f23a7e6a2 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3831,8 +3831,8 @@ public void SetCookie (Cookie cookie) /// Sets the credentials for the HTTP authentication (Basic/Digest). /// /// - /// This method does nothing if the connection has already been - /// established or it is closing. + /// This method works if the current state of the interface is + /// New or Closed. /// /// /// From 485e20524d134534c2715d7c559d05dc25d8a510 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 4 Dec 2022 16:27:49 +0900 Subject: [PATCH 4826/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index f23a7e6a2..23668fe87 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3920,8 +3920,8 @@ public void SetCredentials (string username, string password, bool preAuth) /// the credentials for the HTTP proxy authentication (Basic/Digest). /// /// - /// This method does nothing if the connection has already been - /// established or it is closing. + /// This method works if the current state of the interface is + /// New or Closed. /// /// /// From 7042dcaa49e2cd7699bc4e5e0bc3fa0a82df0a09 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 5 Dec 2022 21:23:24 +0900 Subject: [PATCH 4827/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 23668fe87..e37589895 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -694,7 +694,13 @@ public ClientSslConfiguration SslConfiguration { /// Gets the URL to which to connect. /// /// - /// A that represents the URL to which to connect. + /// + /// A that represents the URL to which to connect. + /// + /// + /// Also it represents the URL requested by the client if the interface + /// is for the server. + /// /// public Uri Url { get { From f1f38b8e187546a4e4e9c8bc94c2099a04f254bc Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 5 Dec 2022 21:26:38 +0900 Subject: [PATCH 4828/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index e37589895..540e5d246 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3371,7 +3371,8 @@ public bool Ping (string message) public void Send (byte[] data) { if (_readyState != WebSocketState.Open) { - var msg = "The current state of the connection is not Open."; + var msg = "The current state of the interface is not Open."; + throw new InvalidOperationException (msg); } From 3ccc8aa466c9ffed6110a19a998c11d02c975f55 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 5 Dec 2022 21:30:18 +0900 Subject: [PATCH 4829/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 540e5d246..d789faf50 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3357,13 +3357,13 @@ public bool Ping (string message) } /// - /// Sends the specified data using the WebSocket connection. + /// Sends the specified data to the remote endpoint. /// /// - /// An array of that represents the binary data to send. + /// An array of that specifies the binary data to send. /// /// - /// The current state of the connection is not Open. + /// The current state of the interface is not Open. /// /// /// is . From 83b8d119abceae4f068dc14d4cdae75e5871c565 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 6 Dec 2022 15:51:26 +0900 Subject: [PATCH 4830/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index d789faf50..1174aa672 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3413,7 +3413,8 @@ public void Send (byte[] data) public void Send (FileInfo fileInfo) { if (_readyState != WebSocketState.Open) { - var msg = "The current state of the connection is not Open."; + var msg = "The current state of the interface is not Open."; + throw new InvalidOperationException (msg); } @@ -3422,12 +3423,15 @@ public void Send (FileInfo fileInfo) if (!fileInfo.Exists) { var msg = "The file does not exist."; + throw new ArgumentException (msg, "fileInfo"); } FileStream stream; + if (!fileInfo.TryOpenRead (out stream)) { var msg = "The file could not be opened."; + throw new ArgumentException (msg, "fileInfo"); } From aaf033fb65322708b93809a914db03263d7230e3 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 6 Dec 2022 15:54:46 +0900 Subject: [PATCH 4831/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 1174aa672..2facf070d 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3383,7 +3383,7 @@ public void Send (byte[] data) } /// - /// Sends the specified file using the WebSocket connection. + /// Sends the specified file to the remote endpoint. /// /// /// @@ -3394,7 +3394,7 @@ public void Send (byte[] data) /// /// /// - /// The current state of the connection is not Open. + /// The current state of the interface is not Open. /// /// /// is . From f50d19aaab698432c434c88869ba132570b858d8 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 6 Dec 2022 15:56:43 +0900 Subject: [PATCH 4832/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 2facf070d..9b7332953 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3456,7 +3456,8 @@ public void Send (FileInfo fileInfo) public void Send (string data) { if (_readyState != WebSocketState.Open) { - var msg = "The current state of the connection is not Open."; + var msg = "The current state of the interface is not Open."; + throw new InvalidOperationException (msg); } @@ -3464,8 +3465,10 @@ public void Send (string data) throw new ArgumentNullException ("data"); byte[] bytes; + if (!data.TryGetUTF8EncodedBytes (out bytes)) { var msg = "It could not be UTF-8-encoded."; + throw new ArgumentException (msg, "data"); } From 0a6a2fe5184c7e96b0b9eab4f6f21b6f19b3aa9e Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 6 Dec 2022 15:59:32 +0900 Subject: [PATCH 4833/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 9b7332953..cb1f7f1c1 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3439,13 +3439,13 @@ public void Send (FileInfo fileInfo) } /// - /// Sends the specified data using the WebSocket connection. + /// Sends the specified data to the remote endpoint. /// /// - /// A that represents the text data to send. + /// A that specifies the text data to send. /// /// - /// The current state of the connection is not Open. + /// The current state of the interface is not Open. /// /// /// is . From f8bfd637f1bd2997e2af9898ec02eacfa17b7642 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 6 Dec 2022 20:51:56 +0900 Subject: [PATCH 4834/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index cb1f7f1c1..404a11ac5 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3515,7 +3515,8 @@ public void Send (string data) public void Send (Stream stream, int length) { if (_readyState != WebSocketState.Open) { - var msg = "The current state of the connection is not Open."; + var msg = "The current state of the interface is not Open."; + throw new InvalidOperationException (msg); } @@ -3524,29 +3525,30 @@ public void Send (Stream stream, int length) if (!stream.CanRead) { var msg = "It cannot be read."; + throw new ArgumentException (msg, "stream"); } if (length < 1) { var msg = "Less than 1."; + throw new ArgumentException (msg, "length"); } var bytes = stream.ReadBytes (length); - var len = bytes.Length; + if (len == 0) { var msg = "No data could be read from it."; + throw new ArgumentException (msg, "stream"); } if (len < length) { - _logger.Warn ( - String.Format ( - "Only {0} byte(s) of data could be read from the stream.", - len - ) - ); + var fmt = "Only {0} byte(s) of data could be read from the stream."; + var msg = String.Format (fmt, len); + + _logger.Warn (msg); } send (Opcode.Binary, new MemoryStream (bytes)); From 2e23d7e4e923c2313b75906b48b12db05d8b2a3a Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 6 Dec 2022 20:59:20 +0900 Subject: [PATCH 4835/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 404a11ac5..cd9c4b45e 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3476,7 +3476,7 @@ public void Send (string data) } /// - /// Sends the data from the specified stream using the WebSocket connection. + /// Sends the data from the specified stream instance to the remote endpoint. /// /// /// @@ -3490,7 +3490,7 @@ public void Send (string data) /// An that specifies the number of bytes to send. /// /// - /// The current state of the connection is not Open. + /// The current state of the interface is not Open. /// /// /// is . From fa6eeae8d8690b623aa69c7b46409888fda73d5c Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 6 Dec 2022 21:01:15 +0900 Subject: [PATCH 4836/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index cd9c4b45e..9b885217d 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3585,7 +3585,8 @@ public void Send (Stream stream, int length) public void SendAsync (byte[] data, Action completed) { if (_readyState != WebSocketState.Open) { - var msg = "The current state of the connection is not Open."; + var msg = "The current state of the interface is not Open."; + throw new InvalidOperationException (msg); } From fe5096de09e4f2bfc109b7833784ae144fdad6ff Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 6 Dec 2022 21:37:10 +0900 Subject: [PATCH 4837/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 9b885217d..c95068632 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3555,29 +3555,31 @@ public void Send (Stream stream, int length) } /// - /// Sends the specified data asynchronously using the WebSocket connection. + /// Sends the specified data to the remote endpoint asynchronously. /// /// /// This method does not wait for the send to be complete. /// /// - /// An array of that represents the binary data to send. + /// An array of that specifies the binary data to send. /// /// /// - /// An Action<bool> delegate or - /// if not needed. + /// An delegate. /// /// /// The delegate invokes the method called when the send is complete. /// /// - /// true is passed to the method if the send has done with - /// no error; otherwise, false. + /// The parameter passed to the method is true + /// if the send has successfully done; otherwise, false. + /// + /// + /// if not necessary. /// /// /// - /// The current state of the connection is not Open. + /// The current state of the interface is not Open. /// /// /// is . From bb62c35c328a8529e64ac07c02bdde700196907f Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 6 Dec 2022 21:39:57 +0900 Subject: [PATCH 4838/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index c95068632..4e6691511 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3645,7 +3645,8 @@ public void SendAsync (byte[] data, Action completed) public void SendAsync (FileInfo fileInfo, Action completed) { if (_readyState != WebSocketState.Open) { - var msg = "The current state of the connection is not Open."; + var msg = "The current state of the interface is not Open."; + throw new InvalidOperationException (msg); } @@ -3654,12 +3655,15 @@ public void SendAsync (FileInfo fileInfo, Action completed) if (!fileInfo.Exists) { var msg = "The file does not exist."; + throw new ArgumentException (msg, "fileInfo"); } FileStream stream; + if (!fileInfo.TryOpenRead (out stream)) { var msg = "The file could not be opened."; + throw new ArgumentException (msg, "fileInfo"); } From f8c4cf0b2b9dcd1dbbfa06cb9cfb4e0a2e5f2d6f Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 6 Dec 2022 21:44:24 +0900 Subject: [PATCH 4839/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 4e6691511..36d9dcba1 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3599,7 +3599,7 @@ public void SendAsync (byte[] data, Action completed) } /// - /// Sends the specified file asynchronously using the WebSocket connection. + /// Sends the specified file to the remote endpoint asynchronously. /// /// /// This method does not wait for the send to be complete. @@ -3614,19 +3614,21 @@ public void SendAsync (byte[] data, Action completed) /// /// /// - /// An Action<bool> delegate or - /// if not needed. + /// An delegate. /// /// /// The delegate invokes the method called when the send is complete. /// /// - /// true is passed to the method if the send has done with - /// no error; otherwise, false. + /// The parameter passed to the method is true + /// if the send has successfully done; otherwise, false. + /// + /// + /// if not necessary. /// /// /// - /// The current state of the connection is not Open. + /// The current state of the interface is not Open. /// /// /// is . From 5d64720aef667b8fb6bfccb1132a908e18d2f728 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 6 Dec 2022 21:46:40 +0900 Subject: [PATCH 4840/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 36d9dcba1..c553db514 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3706,7 +3706,8 @@ public void SendAsync (FileInfo fileInfo, Action completed) public void SendAsync (string data, Action completed) { if (_readyState != WebSocketState.Open) { - var msg = "The current state of the connection is not Open."; + var msg = "The current state of the interface is not Open."; + throw new InvalidOperationException (msg); } @@ -3714,8 +3715,10 @@ public void SendAsync (string data, Action completed) throw new ArgumentNullException ("data"); byte[] bytes; + if (!data.TryGetUTF8EncodedBytes (out bytes)) { var msg = "It could not be UTF-8-encoded."; + throw new ArgumentException (msg, "data"); } From 5544a73c007ea4a66bff4ccc33bcee452b6bd228 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 6 Dec 2022 21:50:29 +0900 Subject: [PATCH 4841/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index c553db514..721707596 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3673,29 +3673,31 @@ public void SendAsync (FileInfo fileInfo, Action completed) } /// - /// Sends the specified data asynchronously using the WebSocket connection. + /// Sends the specified data to the remote endpoint asynchronously. /// /// /// This method does not wait for the send to be complete. /// /// - /// A that represents the text data to send. + /// A that specifies the text data to send. /// /// /// - /// An Action<bool> delegate or - /// if not needed. + /// An delegate. /// /// /// The delegate invokes the method called when the send is complete. /// /// - /// true is passed to the method if the send has done with - /// no error; otherwise, false. + /// The parameter passed to the method is true + /// if the send has successfully done; otherwise, false. + /// + /// + /// if not necessary. /// /// /// - /// The current state of the connection is not Open. + /// The current state of the interface is not Open. /// /// /// is . From ed325af14b1b65e30de94fbd66abdb33bdf54b42 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 7 Dec 2022 16:07:23 +0900 Subject: [PATCH 4842/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 721707596..f7eb8507a 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3784,7 +3784,8 @@ public void SendAsync (string data, Action completed) public void SendAsync (Stream stream, int length, Action completed) { if (_readyState != WebSocketState.Open) { - var msg = "The current state of the connection is not Open."; + var msg = "The current state of the interface is not Open."; + throw new InvalidOperationException (msg); } @@ -3793,29 +3794,30 @@ public void SendAsync (Stream stream, int length, Action completed) if (!stream.CanRead) { var msg = "It cannot be read."; + throw new ArgumentException (msg, "stream"); } if (length < 1) { var msg = "Less than 1."; + throw new ArgumentException (msg, "length"); } var bytes = stream.ReadBytes (length); - var len = bytes.Length; + if (len == 0) { var msg = "No data could be read from it."; + throw new ArgumentException (msg, "stream"); } if (len < length) { - _logger.Warn ( - String.Format ( - "Only {0} byte(s) of data could be read from the stream.", - len - ) - ); + var fmt = "Only {0} byte(s) of data could be read from the stream."; + var msg = String.Format (fmt, len); + + _logger.Warn (msg); } sendAsync (Opcode.Binary, new MemoryStream (bytes), completed); From 484fec9bb05e5381da1d4219c6db3cfef52f9da4 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 7 Dec 2022 16:15:51 +0900 Subject: [PATCH 4843/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index f7eb8507a..2e7a13e60 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3728,8 +3728,8 @@ public void SendAsync (string data, Action completed) } /// - /// Sends the data from the specified stream asynchronously using - /// the WebSocket connection. + /// Sends the data from the specified stream instance to the remote + /// endpoint asynchronously. /// /// /// This method does not wait for the send to be complete. @@ -3747,19 +3747,21 @@ public void SendAsync (string data, Action completed) /// /// /// - /// An Action<bool> delegate or - /// if not needed. + /// An delegate. /// /// /// The delegate invokes the method called when the send is complete. /// /// - /// true is passed to the method if the send has done with - /// no error; otherwise, false. + /// The parameter passed to the method is true + /// if the send has successfully done; otherwise, false. + /// + /// + /// if not necessary. /// /// /// - /// The current state of the connection is not Open. + /// The current state of the interface is not Open. /// /// /// is . From 6b653177217f527da93fff31943060971b1752a1 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 7 Dec 2022 23:19:38 +0900 Subject: [PATCH 4844/6294] [Modify] Replace it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 2e7a13e60..3f24214b7 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2037,7 +2037,7 @@ private bool send (Fin fin, Opcode opcode, byte[] data, bool compressed) { lock (_forState) { if (_readyState != WebSocketState.Open) { - _logger.Trace ("The connection is closing."); + _logger.Error ("The current state of the interface is not Open."); return false; } From b2d673c4e362a14542f5da7660f5f14ecf8dd95b Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 7 Dec 2022 23:21:32 +0900 Subject: [PATCH 4845/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 3f24214b7..de51068ca 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1955,7 +1955,7 @@ private bool send (Opcode opcode, Stream stream) sent = send (opcode, stream, compressed); if (!sent) - error ("A send has been interrupted.", null); + error ("A send has failed.", null); } catch (Exception ex) { _logger.Error (ex.Message); From de12f56e7ed2cc963509dde94cf6afec966a69fe Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 7 Dec 2022 23:32:53 +0900 Subject: [PATCH 4846/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index de51068ca..c702431a1 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2012,6 +2012,8 @@ private bool send (Opcode opcode, Stream stream, bool compressed) if (!sent) return false; + // Continue + var n = rem == 0 ? quo - 2 : quo - 1; for (long i = 0; i < n; i++) { From 12bfe65c9a6d9386b683c32c4caa20cf6f23dd6e Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 7 Dec 2022 23:41:03 +0900 Subject: [PATCH 4847/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index c702431a1..ccc59186f 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2558,11 +2558,13 @@ internal void Send ( lock (_forSend) { lock (_forState) { if (_readyState != WebSocketState.Open) { - _logger.Error ("The connection is closing."); + _logger.Error ("The current state of the interface is not Open."); + return; } byte[] found; + if (!cache.TryGetValue (_compression, out found)) { found = new WebSocketFrame ( Fin.Final, From ad70555ded2df7fe0a197ebf86da558422176a64 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 8 Dec 2022 15:56:49 +0900 Subject: [PATCH 4848/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index ccc59186f..028fc28b1 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2590,8 +2590,10 @@ internal void Send ( { lock (_forSend) { Stream found; + if (!cache.TryGetValue (_compression, out found)) { found = stream.Compress (_compression); + cache.Add (_compression, found); } else { From 8fc2343cbb57c1f4da5f8be7fc29e6b4695d7a41 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 8 Dec 2022 21:47:06 +0900 Subject: [PATCH 4849/6294] [Modify] Rename it --- websocket-sharp/WebSocket.cs | 148 +++++++++++++++++------------------ 1 file changed, 74 insertions(+), 74 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 028fc28b1..4268e403c 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -96,7 +96,7 @@ public class WebSocket : IDisposable private bool _ignoreExtensions; private bool _inContinuation; private volatile bool _inMessage; - private volatile Logger _logger; + private volatile Logger _log; private static readonly int _maxRetryCountForConnect; private Action _message; private Queue _messageEventQueue; @@ -173,7 +173,7 @@ internal WebSocket (HttpListenerWebSocketContext context, string protocol) _protocol = protocol; _closeContext = context.Close; - _logger = context.Log; + _log = context.Log; _message = messages; _secure = context.IsSecureConnection; _stream = context.Stream; @@ -189,7 +189,7 @@ internal WebSocket (TcpListenerWebSocketContext context, string protocol) _protocol = protocol; _closeContext = context.Close; - _logger = context.Log; + _log = context.Log; _message = messages; _secure = context.IsSecureConnection; _stream = context.Stream; @@ -276,7 +276,7 @@ public WebSocket (string url, params string[] protocols) _base64Key = CreateBase64Key (); _client = true; - _logger = new Logger (); + _log = new Logger (); _message = messagec; _retryCountForConnect = -1; _secure = _uri.Scheme == "wss"; @@ -518,11 +518,11 @@ public bool IsSecure { /// public Logger Log { get { - return _logger; + return _log; } internal set { - _logger = value; + _log = value; } } @@ -798,13 +798,13 @@ private bool accept () { lock (_forState) { if (_readyState == WebSocketState.Open) { - _logger.Trace ("The connection has already been established."); + _log.Trace ("The connection has already been established."); return false; } if (_readyState == WebSocketState.Closing) { - _logger.Error ("The close process is in progress."); + _log.Error ("The close process is in progress."); error ("An error has occurred while accepting.", null); @@ -812,7 +812,7 @@ private bool accept () } if (_readyState == WebSocketState.Closed) { - _logger.Error ("The connection has been closed."); + _log.Error ("The connection has been closed."); error ("An error has occurred while accepting.", null); @@ -827,8 +827,8 @@ private bool accept () accepted = acceptHandshake (); } catch (Exception ex) { - _logger.Fatal (ex.Message); - _logger.Debug (ex.ToString ()); + _log.Fatal (ex.Message); + _log.Debug (ex.ToString ()); abort (1011, "An exception has occurred while accepting."); } @@ -848,8 +848,8 @@ private bool acceptHandshake () string msg; if (!checkHandshakeRequest (_context, out msg)) { - _logger.Error (msg); - _logger.Debug (_context.ToString ()); + _log.Error (msg); + _log.Debug (_context.ToString ()); refuseHandshake (1002, "A handshake error has occurred."); @@ -857,8 +857,8 @@ private bool acceptHandshake () } if (!customCheckHandshakeRequest (_context, out msg)) { - _logger.Error (msg); - _logger.Debug (_context.ToString ()); + _log.Error (msg); + _log.Debug (_context.ToString ()); refuseHandshake (1002, "A handshake error has occurred."); @@ -1111,13 +1111,13 @@ private bool checkReceivedFrame (WebSocketFrame frame, out string message) private void close (ushort code, string reason) { if (_readyState == WebSocketState.Closing) { - _logger.Trace ("The close process is already in progress."); + _log.Trace ("The close process is already in progress."); return; } if (_readyState == WebSocketState.Closed) { - _logger.Trace ("The connection has already been closed."); + _log.Trace ("The connection has already been closed."); return; } @@ -1138,13 +1138,13 @@ private void close (PayloadData payloadData, bool send, bool received) { lock (_forState) { if (_readyState == WebSocketState.Closing) { - _logger.Trace ("The close process is already in progress."); + _log.Trace ("The close process is already in progress."); return; } if (_readyState == WebSocketState.Closed) { - _logger.Trace ("The connection has already been closed."); + _log.Trace ("The connection has already been closed."); return; } @@ -1154,13 +1154,13 @@ private void close (PayloadData payloadData, bool send, bool received) _readyState = WebSocketState.Closing; } - _logger.Trace ("Begin closing the connection."); + _log.Trace ("Begin closing the connection."); var res = closeHandshake (payloadData, send, received); releaseResources (); - _logger.Trace ("End closing the connection."); + _log.Trace ("End closing the connection."); _readyState = WebSocketState.Closed; @@ -1170,21 +1170,21 @@ private void close (PayloadData payloadData, bool send, bool received) OnClose.Emit (this, e); } catch (Exception ex) { - _logger.Error (ex.Message); - _logger.Debug (ex.ToString ()); + _log.Error (ex.Message); + _log.Debug (ex.ToString ()); } } private void closeAsync (ushort code, string reason) { if (_readyState == WebSocketState.Closing) { - _logger.Trace ("The close process is already in progress."); + _log.Trace ("The close process is already in progress."); return; } if (_readyState == WebSocketState.Closed) { - _logger.Trace ("The connection has already been closed."); + _log.Trace ("The connection has already been closed."); return; } @@ -1240,7 +1240,7 @@ private bool closeHandshake ( received ); - _logger.Debug (msg); + _log.Debug (msg); return ret; } @@ -1250,13 +1250,13 @@ private bool connect () { lock (_forState) { if (_readyState == WebSocketState.Open) { - _logger.Trace ("The connection has already been established."); + _log.Trace ("The connection has already been established."); return false; } if (_readyState == WebSocketState.Closing) { - _logger.Error ("The close process is in progress."); + _log.Error ("The close process is in progress."); error ("An error has occurred while connecting.", null); @@ -1264,7 +1264,7 @@ private bool connect () } if (_retryCountForConnect >= _maxRetryCountForConnect) { - _logger.Error ("An opportunity for reconnecting has been lost."); + _log.Error ("An opportunity for reconnecting has been lost."); error ("An error has occurred while connecting.", null); @@ -1281,8 +1281,8 @@ private bool connect () done = doHandshake (); } catch (Exception ex) { - _logger.Fatal (ex.Message); - _logger.Debug (ex.ToString ()); + _log.Fatal (ex.Message); + _log.Debug (ex.ToString ()); abort ("An exception has occurred while connecting.", ex); } @@ -1443,8 +1443,8 @@ private bool doHandshake () string msg; if (!checkHandshakeResponse (res, out msg)) { - _logger.Error (msg); - _logger.Debug (res.ToString ()); + _log.Error (msg); + _log.Debug (res.ToString ()); abort (1002, "A handshake error has occurred."); @@ -1479,8 +1479,8 @@ private void error (string message, Exception exception) OnError.Emit (this, e); } catch (Exception ex) { - _logger.Error (ex.Message); - _logger.Debug (ex.ToString ()); + _log.Error (ex.Message); + _log.Debug (ex.ToString ()); } } @@ -1533,8 +1533,8 @@ private void messagec (MessageEventArgs e) OnMessage.Emit (this, e); } catch (Exception ex) { - _logger.Error (ex.Message); - _logger.Debug (ex.ToString ()); + _log.Error (ex.Message); + _log.Debug (ex.ToString ()); error ("An exception has occurred during an OnMessage event.", ex); } @@ -1564,8 +1564,8 @@ private void messages (MessageEventArgs e) OnMessage.Emit (this, e); } catch (Exception ex) { - _logger.Error (ex.Message); - _logger.Debug (ex.ToString ()); + _log.Error (ex.Message); + _log.Debug (ex.ToString ()); error ("An exception has occurred during an OnMessage event.", ex); } @@ -1599,8 +1599,8 @@ private void open () OnOpen.Emit (this, EventArgs.Empty); } catch (Exception ex) { - _logger.Error (ex.Message); - _logger.Debug (ex.ToString ()); + _log.Error (ex.Message); + _log.Debug (ex.ToString ()); error ("An exception has occurred during the OnOpen event.", ex); } @@ -1720,13 +1720,13 @@ private bool processFragmentFrame (WebSocketFrame frame) private bool processPingFrame (WebSocketFrame frame) { - _logger.Trace ("A ping was received."); + _log.Trace ("A ping was received."); var pong = WebSocketFrame.CreatePongFrame (frame.PayloadData, _client); lock (_forState) { if (_readyState != WebSocketState.Open) { - _logger.Trace ("A pong to this ping cannot be sent."); + _log.Trace ("A pong to this ping cannot be sent."); return true; } @@ -1738,7 +1738,7 @@ private bool processPingFrame (WebSocketFrame frame) return false; } - _logger.Trace ("A pong to this ping has been sent."); + _log.Trace ("A pong to this ping has been sent."); if (_emitOnPing) { if (_client) @@ -1754,7 +1754,7 @@ private bool processPingFrame (WebSocketFrame frame) private bool processPongFrame (WebSocketFrame frame) { - _logger.Trace ("A pong was received."); + _log.Trace ("A pong was received."); try { _pongReceived.Set (); @@ -1766,7 +1766,7 @@ private bool processPongFrame (WebSocketFrame frame) return false; } - _logger.Trace ("It has been signaled."); + _log.Trace ("It has been signaled."); return true; } @@ -1860,8 +1860,8 @@ IEnumerable values private bool processUnsupportedFrame (WebSocketFrame frame) { - _logger.Fatal ("An unsupported frame was received."); - _logger.Debug ("The frame is" + frame.PrintToString (false)); + _log.Fatal ("An unsupported frame was received."); + _log.Debug ("The frame is" + frame.PrintToString (false)); abort (1003, "There is no way to handle it."); @@ -1958,8 +1958,8 @@ private bool send (Opcode opcode, Stream stream) error ("A send has failed.", null); } catch (Exception ex) { - _logger.Error (ex.Message); - _logger.Debug (ex.ToString ()); + _log.Error (ex.Message); + _log.Debug (ex.ToString ()); error ("An exception has occurred during a send.", ex); } @@ -2039,7 +2039,7 @@ private bool send (Fin fin, Opcode opcode, byte[] data, bool compressed) { lock (_forState) { if (_readyState != WebSocketState.Open) { - _logger.Error ("The current state of the interface is not Open."); + _log.Error ("The current state of the interface is not Open."); return false; } @@ -2068,8 +2068,8 @@ private void sendAsync ( completed (sent); } catch (Exception ex) { - _logger.Error (ex.Message); - _logger.Debug (ex.ToString ()); + _log.Error (ex.Message); + _log.Debug (ex.ToString ()); error ( "An exception has occurred during the callback for an async send.", @@ -2087,8 +2087,8 @@ private bool sendBytes (byte[] bytes) _stream.Write (bytes, 0, bytes.Length); } catch (Exception ex) { - _logger.Error (ex.Message); - _logger.Debug (ex.ToString ()); + _log.Error (ex.Message); + _log.Debug (ex.ToString ()); return false; } @@ -2104,7 +2104,7 @@ private HttpResponse sendHandshakeRequest () if (res.IsUnauthorized) { if (_credentials == null) { - _logger.Error ("No credential is specified."); + _log.Error ("No credential is specified."); return res; } @@ -2112,7 +2112,7 @@ private HttpResponse sendHandshakeRequest () var val = res.Headers["WWW-Authenticate"]; if (val.IsNullOrEmpty ()) { - _logger.Error ("No authentication challenge is specified."); + _log.Error ("No authentication challenge is specified."); return res; } @@ -2120,7 +2120,7 @@ private HttpResponse sendHandshakeRequest () var achal = AuthenticationChallenge.Parse (val); if (achal == null) { - _logger.Error ("An invalid authentication challenge is specified."); + _log.Error ("An invalid authentication challenge is specified."); return res; } @@ -2131,7 +2131,7 @@ private HttpResponse sendHandshakeRequest () && _authChallenge.Scheme == AuthenticationSchemes.Basic; if (failed) { - _logger.Error ("The authentication has failed."); + _log.Error ("The authentication has failed."); return res; } @@ -2159,7 +2159,7 @@ private HttpResponse sendHandshakeRequest () var val = res.Headers["Location"]; if (val.IsNullOrEmpty ()) { - _logger.Error ("No url to redirect is located."); + _log.Error ("No url to redirect is located."); return res; } @@ -2168,7 +2168,7 @@ private HttpResponse sendHandshakeRequest () string msg; if (!val.TryCreateWebSocketUri (out uri, out msg)) { - _logger.Error ("An invalid url to redirect is located."); + _log.Error ("An invalid url to redirect is located."); return res; } @@ -2342,8 +2342,8 @@ private void startReceiving () message (); }, ex => { - _logger.Fatal (ex.Message); - _logger.Debug (ex.ToString ()); + _log.Fatal (ex.Message); + _log.Debug (ex.ToString ()); abort ("An exception has occurred while receiving.", ex); } @@ -2377,7 +2377,7 @@ private bool validateSecWebSocketExtensionsServerHeader (string value) var fmt = "The server did not send back '{0}'."; var msg = String.Format (fmt, param1); - _logger.Error (msg); + _log.Error (msg); return false; } @@ -2446,13 +2446,13 @@ internal void Close (PayloadData payloadData, byte[] frameAsBytes) { lock (_forState) { if (_readyState == WebSocketState.Closing) { - _logger.Trace ("The close process is already in progress."); + _log.Trace ("The close process is already in progress."); return; } if (_readyState == WebSocketState.Closed) { - _logger.Trace ("The connection has already been closed."); + _log.Trace ("The connection has already been closed."); return; } @@ -2460,7 +2460,7 @@ internal void Close (PayloadData payloadData, byte[] frameAsBytes) _readyState = WebSocketState.Closing; } - _logger.Trace ("Begin closing the connection."); + _log.Trace ("Begin closing the connection."); var sent = frameAsBytes != null && sendBytes (frameAsBytes); var received = sent && _receivingExited != null @@ -2476,12 +2476,12 @@ internal void Close (PayloadData payloadData, byte[] frameAsBytes) received ); - _logger.Debug (msg); + _log.Debug (msg); releaseServerResources (); releaseCommonResources (); - _logger.Trace ("End closing the connection."); + _log.Trace ("End closing the connection."); _readyState = WebSocketState.Closed; @@ -2491,8 +2491,8 @@ internal void Close (PayloadData payloadData, byte[] frameAsBytes) OnClose.Emit (this, e); } catch (Exception ex) { - _logger.Error (ex.Message); - _logger.Debug (ex.ToString ()); + _log.Error (ex.Message); + _log.Debug (ex.ToString ()); } } @@ -2558,7 +2558,7 @@ internal void Send ( lock (_forSend) { lock (_forState) { if (_readyState != WebSocketState.Open) { - _logger.Error ("The current state of the interface is not Open."); + _log.Error ("The current state of the interface is not Open."); return; } @@ -3554,7 +3554,7 @@ public void Send (Stream stream, int length) var fmt = "Only {0} byte(s) of data could be read from the stream."; var msg = String.Format (fmt, len); - _logger.Warn (msg); + _log.Warn (msg); } send (Opcode.Binary, new MemoryStream (bytes)); @@ -3825,7 +3825,7 @@ public void SendAsync (Stream stream, int length, Action completed) var fmt = "Only {0} byte(s) of data could be read from the stream."; var msg = String.Format (fmt, len); - _logger.Warn (msg); + _log.Warn (msg); } sendAsync (Opcode.Binary, new MemoryStream (bytes), completed); From 81ca2cb6743f320ded181a623c0830ee50d25234 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 9 Dec 2022 16:08:49 +0900 Subject: [PATCH 4850/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 4268e403c..4896b594e 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -473,9 +473,13 @@ public bool EnableRedirection { /// Gets the extensions selected by the server. ///
/// - /// A that will be a list of the extensions - /// negotiated between the client and server, or an empty string - /// if not specified or selected. + /// + /// A that represents a list of the extensions + /// negotiated between the client and server. + /// + /// + /// An empty string if not specified or selected. + /// /// public string Extensions { get { From 9c57708697acbba1bdd84e997f943b9e71259a2d Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 9 Dec 2022 16:12:01 +0900 Subject: [PATCH 4851/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 4896b594e..1111fbb29 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -380,7 +380,7 @@ public CompressionMethod Compression { public IEnumerable Cookies { get { lock (_cookies.SyncRoot) { - foreach (Cookie cookie in _cookies) + foreach (var cookie in _cookies) yield return cookie; } } From 8fc5f5595d9d1e7378f4b77211409d196fa19aef Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 9 Dec 2022 16:18:20 +0900 Subject: [PATCH 4852/6294] [Modify] Add it --- websocket-sharp/WebSocket.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 1111fbb29..095b37ab9 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1943,6 +1943,19 @@ private void releaseServerResources () _context = null; } + private bool send (byte[] frameAsBytes) + { + lock (_forState) { + if (_readyState != WebSocketState.Open) { + _log.Error ("The current state of the interface is not Open."); + + return false; + } + + return sendBytes (frameAsBytes); + } + } + private bool send (Opcode opcode, Stream stream) { lock (_forSend) { From 8a2dfc439111fc83a762154c147b8a1ea0a71a51 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 9 Dec 2022 16:23:46 +0900 Subject: [PATCH 4853/6294] [Modify] Replace it --- websocket-sharp/WebSocket.cs | 34 +++++++++++++--------------------- 1 file changed, 13 insertions(+), 21 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 095b37ab9..b2bb1e66f 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2573,30 +2573,22 @@ internal void Send ( ) { lock (_forSend) { - lock (_forState) { - if (_readyState != WebSocketState.Open) { - _log.Error ("The current state of the interface is not Open."); - - return; - } - - byte[] found; + byte[] found; - if (!cache.TryGetValue (_compression, out found)) { - found = new WebSocketFrame ( - Fin.Final, - opcode, - data.Compress (_compression), - _compression != CompressionMethod.None, - false - ) - .ToArray (); - - cache.Add (_compression, found); - } + if (!cache.TryGetValue (_compression, out found)) { + found = new WebSocketFrame ( + Fin.Final, + opcode, + data.Compress (_compression), + _compression != CompressionMethod.None, + false + ) + .ToArray (); - sendBytes (found); + cache.Add (_compression, found); } + + send (found); } } From d1fbeb83c528ce1439760ed2656c521fc427580a Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 10 Dec 2022 15:50:03 +0900 Subject: [PATCH 4854/6294] [Modify] Replace it --- websocket-sharp/WebSocket.cs | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index b2bb1e66f..de03d5930 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2549,15 +2549,10 @@ internal bool Ping (byte[] frameAsBytes, TimeSpan timeout) try { received.Reset (); - lock (_forState) { - if (_readyState != WebSocketState.Open) - return false; + var sent = send (frameAsBytes); - var sent = sendBytes (frameAsBytes); - - if (!sent) - return false; - } + if (!sent) + return false; return received.WaitOne (timeout); } From 9bda4f867e9579220deb93d85fec6844111ebbed Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 10 Dec 2022 15:55:57 +0900 Subject: [PATCH 4855/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketSessionManager.cs | 2 +- websocket-sharp/WebSocket.cs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 545bdaf2f..05b0b3307 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -395,7 +395,7 @@ private Dictionary broadping (byte[] frameAsBytes) break; } - var res = session.WebSocket.Ping (frameAsBytes, _waitTime); + var res = session.WebSocket.Ping (frameAsBytes); ret.Add (session.ID, res); } diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index de03d5930..7255fdd9b 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2535,7 +2535,7 @@ internal static string CreateResponseKey (string base64Key) } // As server - internal bool Ping (byte[] frameAsBytes, TimeSpan timeout) + internal bool Ping (byte[] frameAsBytes) { if (_readyState != WebSocketState.Open) return false; @@ -2554,7 +2554,7 @@ internal bool Ping (byte[] frameAsBytes, TimeSpan timeout) if (!sent) return false; - return received.WaitOne (timeout); + return received.WaitOne (_waitTime); } catch (ObjectDisposedException) { return false; From 1f475d64f9a31586ac5df405230adddbc33a67a8 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 11 Dec 2022 15:58:39 +0900 Subject: [PATCH 4856/6294] [Modify] Replace it --- websocket-sharp/WebSocket.cs | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 7255fdd9b..cdd75dbf5 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2054,18 +2054,10 @@ private bool send (Opcode opcode, Stream stream, bool compressed) private bool send (Fin fin, Opcode opcode, byte[] data, bool compressed) { - lock (_forState) { - if (_readyState != WebSocketState.Open) { - _log.Error ("The current state of the interface is not Open."); + var frame = new WebSocketFrame (fin, opcode, data, compressed, _client); + var bytes = frame.ToArray (); - return false; - } - - var frame = new WebSocketFrame (fin, opcode, data, compressed, _client); - var bytes = frame.ToArray (); - - return sendBytes (bytes); - } + return send (bytes); } private void sendAsync ( From 236572f0efc8663954b3767caf983566990b06ed Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 12 Dec 2022 15:40:32 +0900 Subject: [PATCH 4857/6294] [Modify] Rename it --- websocket-sharp/WebSocket.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index cdd75dbf5..d5567bdbb 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1943,7 +1943,7 @@ private void releaseServerResources () _context = null; } - private bool send (byte[] frameAsBytes) + private bool send (byte[] rawFrame) { lock (_forState) { if (_readyState != WebSocketState.Open) { @@ -1952,7 +1952,7 @@ private bool send (byte[] frameAsBytes) return false; } - return sendBytes (frameAsBytes); + return sendBytes (rawFrame); } } @@ -2451,7 +2451,7 @@ internal void AcceptAsync () } // As server - internal void Close (PayloadData payloadData, byte[] frameAsBytes) + internal void Close (PayloadData payloadData, byte[] rawFrame) { lock (_forState) { if (_readyState == WebSocketState.Closing) { @@ -2471,7 +2471,7 @@ internal void Close (PayloadData payloadData, byte[] frameAsBytes) _log.Trace ("Begin closing the connection."); - var sent = frameAsBytes != null && sendBytes (frameAsBytes); + var sent = rawFrame != null && sendBytes (rawFrame); var received = sent && _receivingExited != null ? _receivingExited.WaitOne (_waitTime) : false; @@ -2527,7 +2527,7 @@ internal static string CreateResponseKey (string base64Key) } // As server - internal bool Ping (byte[] frameAsBytes) + internal bool Ping (byte[] rawFrame) { if (_readyState != WebSocketState.Open) return false; @@ -2541,7 +2541,7 @@ internal bool Ping (byte[] frameAsBytes) try { received.Reset (); - var sent = send (frameAsBytes); + var sent = send (rawFrame); if (!sent) return false; From 5c611a3150b4f99272a26688bbd92ee51dc37aac Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 12 Dec 2022 15:44:03 +0900 Subject: [PATCH 4858/6294] [Modify] Rename it --- websocket-sharp/WebSocket.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index d5567bdbb..5144ea8d8 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2055,9 +2055,9 @@ private bool send (Opcode opcode, Stream stream, bool compressed) private bool send (Fin fin, Opcode opcode, byte[] data, bool compressed) { var frame = new WebSocketFrame (fin, opcode, data, compressed, _client); - var bytes = frame.ToArray (); + var rawFrame = frame.ToArray (); - return send (bytes); + return send (rawFrame); } private void sendAsync ( From 70b1aaccec6ff0ae53a0aaf87bafdb6e98155d67 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 12 Dec 2022 16:55:23 +0900 Subject: [PATCH 4859/6294] [Modify] Rename it --- websocket-sharp/WebSocket.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 5144ea8d8..e0931b9d6 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1991,9 +1991,9 @@ private bool send (Opcode opcode, Stream stream) } } - private bool send (Opcode opcode, Stream stream, bool compressed) + private bool send (Opcode opcode, Stream dataStream, bool compressed) { - var len = stream.Length; + var len = dataStream.Length; if (len == 0) return send (Fin.Final, opcode, EmptyBytes, false); @@ -2006,14 +2006,14 @@ private bool send (Opcode opcode, Stream stream, bool compressed) if (quo == 0) { buff = new byte[rem]; - return stream.Read (buff, 0, rem) == rem + return dataStream.Read (buff, 0, rem) == rem && send (Fin.Final, opcode, buff, compressed); } if (quo == 1 && rem == 0) { buff = new byte[FragmentLength]; - return stream.Read (buff, 0, FragmentLength) == FragmentLength + return dataStream.Read (buff, 0, FragmentLength) == FragmentLength && send (Fin.Final, opcode, buff, compressed); } @@ -2023,7 +2023,7 @@ private bool send (Opcode opcode, Stream stream, bool compressed) buff = new byte[FragmentLength]; - var sent = stream.Read (buff, 0, FragmentLength) == FragmentLength + var sent = dataStream.Read (buff, 0, FragmentLength) == FragmentLength && send (Fin.More, opcode, buff, compressed); if (!sent) @@ -2034,7 +2034,7 @@ private bool send (Opcode opcode, Stream stream, bool compressed) var n = rem == 0 ? quo - 2 : quo - 1; for (long i = 0; i < n; i++) { - sent = stream.Read (buff, 0, FragmentLength) == FragmentLength + sent = dataStream.Read (buff, 0, FragmentLength) == FragmentLength && send (Fin.More, Opcode.Cont, buff, false); if (!sent) @@ -2048,7 +2048,7 @@ private bool send (Opcode opcode, Stream stream, bool compressed) else buff = new byte[rem]; - return stream.Read (buff, 0, rem) == rem + return dataStream.Read (buff, 0, rem) == rem && send (Fin.Final, Opcode.Cont, buff, false); } From 5fb6f7df1b0978fc41851fa44b599a2202e3543d Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 13 Dec 2022 00:35:26 +0900 Subject: [PATCH 4860/6294] [Modify] Rename it --- websocket-sharp/WebSocket.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index e0931b9d6..e199500a7 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1956,20 +1956,20 @@ private bool send (byte[] rawFrame) } } - private bool send (Opcode opcode, Stream stream) + private bool send (Opcode opcode, Stream sourceStream) { lock (_forSend) { - var src = stream; + var dataStream = sourceStream; var compressed = false; var sent = false; try { if (_compression != CompressionMethod.None) { - stream = stream.Compress (_compression); + dataStream = sourceStream.Compress (_compression); compressed = true; } - sent = send (opcode, stream, compressed); + sent = send (opcode, dataStream, compressed); if (!sent) error ("A send has failed.", null); @@ -1982,9 +1982,9 @@ private bool send (Opcode opcode, Stream stream) } finally { if (compressed) - stream.Dispose (); + dataStream.Dispose (); - src.Dispose (); + sourceStream.Dispose (); } return sent; From 782d4ec95767d77b2ef337b39f4571eee79036a1 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 13 Dec 2022 00:41:51 +0900 Subject: [PATCH 4861/6294] [Modify] Rename it --- websocket-sharp/WebSocket.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index e199500a7..066a8b281 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2061,14 +2061,14 @@ private bool send (Fin fin, Opcode opcode, byte[] data, bool compressed) } private void sendAsync ( - Opcode opcode, Stream stream, Action completed + Opcode opcode, Stream sourceStream, Action completed ) { Func sender = send; sender.BeginInvoke ( opcode, - stream, + sourceStream, ar => { try { var sent = sender.EndInvoke (ar); From 864b41ebe6eb7acd0f21002540dc79016f4aee3a Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 13 Dec 2022 15:47:21 +0900 Subject: [PATCH 4862/6294] [Modify] Rename it --- websocket-sharp/WebSocket.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 066a8b281..ca33b2cbe 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2581,14 +2581,16 @@ internal void Send ( // As server internal void Send ( - Opcode opcode, Stream stream, Dictionary cache + Opcode opcode, + Stream sourceStream, + Dictionary cache ) { lock (_forSend) { Stream found; if (!cache.TryGetValue (_compression, out found)) { - found = stream.Compress (_compression); + found = sourceStream.Compress (_compression); cache.Add (_compression, found); } From f05e744b30c42d4d2c893ae791578abb1e024f9b Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 13 Dec 2022 20:49:47 +0900 Subject: [PATCH 4863/6294] [Modify] Add a check --- websocket-sharp/WebSocket.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index ca33b2cbe..944edd230 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1252,6 +1252,12 @@ private bool closeHandshake ( // As client private bool connect () { + if (_readyState == WebSocketState.Connecting) { + _log.Trace ("The connect process is in progress."); + + return false; + } + lock (_forState) { if (_readyState == WebSocketState.Open) { _log.Trace ("The connection has already been established."); From a00ecec87e3d18cb7ba8ba9c6b1402213036d4cc Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 13 Dec 2022 20:56:46 +0900 Subject: [PATCH 4864/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 944edd230..a44c98ed2 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1268,7 +1268,7 @@ private bool connect () if (_readyState == WebSocketState.Closing) { _log.Error ("The close process is in progress."); - error ("An error has occurred while connecting.", null); + error ("An error has occurred before connecting.", null); return false; } @@ -1276,7 +1276,7 @@ private bool connect () if (_retryCountForConnect >= _maxRetryCountForConnect) { _log.Error ("An opportunity for reconnecting has been lost."); - error ("An error has occurred while connecting.", null); + error ("An error has occurred before connecting.", null); return false; } From fe815409ee46f927a91611a01155c435d91427c5 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 13 Dec 2022 21:01:05 +0900 Subject: [PATCH 4865/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index a44c98ed2..8adff2f6e 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3223,8 +3223,8 @@ public void CloseAsync (CloseStatusCode code, string reason) /// Establishes a connection. ///
/// - /// This method does nothing if the connection has already been - /// established. + /// This method does nothing if the current state of the interface is + /// Connecting or Open. /// /// /// From 8b65730c401cf8754bc188e78a5e710cac26f781 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 13 Dec 2022 21:03:11 +0900 Subject: [PATCH 4866/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 8adff2f6e..c531bc6ad 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3267,8 +3267,8 @@ public void Connect () /// This method does not wait for the connect process to be complete. /// /// - /// This method does nothing if the connection has already been - /// established. + /// This method does nothing if the current state of the interface is + /// Connecting or Open. /// /// /// From e6990122b28ee033ae4b327d22b77a65afc6aa9f Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 13 Dec 2022 21:07:37 +0900 Subject: [PATCH 4867/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index c531bc6ad..dd3259d3f 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -810,7 +810,7 @@ private bool accept () if (_readyState == WebSocketState.Closing) { _log.Error ("The close process is in progress."); - error ("An error has occurred while accepting.", null); + error ("An error has occurred before accepting.", null); return false; } @@ -818,7 +818,7 @@ private bool accept () if (_readyState == WebSocketState.Closed) { _log.Error ("The connection has been closed."); - error ("An error has occurred while accepting.", null); + error ("An error has occurred before accepting.", null); return false; } From 7af215957eeb6e06c9c0e2018cd09a847ec95027 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 13 Dec 2022 21:13:40 +0900 Subject: [PATCH 4868/6294] [Modify] Polish it --- websocket-sharp/MessageEventArgs.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/websocket-sharp/MessageEventArgs.cs b/websocket-sharp/MessageEventArgs.cs index 7940f98b7..c6fea904f 100644 --- a/websocket-sharp/MessageEventArgs.cs +++ b/websocket-sharp/MessageEventArgs.cs @@ -168,10 +168,12 @@ private void setData () if (_opcode == Opcode.Binary) { _dataSet = true; + return; } string data; + if (_rawData.TryGetUTF8DecodedString (out data)) _data = data; From f06c1fc0c3e84b9d4cdd345924590a8f76f81a83 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 13 Dec 2022 21:14:53 +0900 Subject: [PATCH 4869/6294] [Modify] Polish it --- websocket-sharp/MessageEventArgs.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/MessageEventArgs.cs b/websocket-sharp/MessageEventArgs.cs index c6fea904f..e4a016a89 100644 --- a/websocket-sharp/MessageEventArgs.cs +++ b/websocket-sharp/MessageEventArgs.cs @@ -104,6 +104,7 @@ internal Opcode Opcode { public string Data { get { setData (); + return _data; } } From 8a5a143ae8e11b91dfde9c33e7533eda11879b8a Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 13 Dec 2022 21:16:25 +0900 Subject: [PATCH 4870/6294] [Modify] Polish it --- websocket-sharp/MessageEventArgs.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/MessageEventArgs.cs b/websocket-sharp/MessageEventArgs.cs index e4a016a89..9cfb44747 100644 --- a/websocket-sharp/MessageEventArgs.cs +++ b/websocket-sharp/MessageEventArgs.cs @@ -154,6 +154,7 @@ public bool IsText { public byte[] RawData { get { setData (); + return _rawData; } } From 66d3eeab3c140696c9b0dc24195c66e97bec99bc Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 14 Dec 2022 00:11:47 +0900 Subject: [PATCH 4871/6294] [Modify] Edit it --- websocket-sharp/MessageEventArgs.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/MessageEventArgs.cs b/websocket-sharp/MessageEventArgs.cs index 9cfb44747..3ed1561ef 100644 --- a/websocket-sharp/MessageEventArgs.cs +++ b/websocket-sharp/MessageEventArgs.cs @@ -97,9 +97,14 @@ internal Opcode Opcode { /// Gets the message data as a . ///
/// - /// A that represents the message data if its type is - /// text or ping and if decoding it to a string has successfully done; - /// otherwise, . + /// + /// A that represents the message data + /// if the message type is text or ping. + /// + /// + /// if the message type is binary or + /// the message data could not be UTF-8-decoded. + /// /// public string Data { get { From ec23db7ec7ea84154d8b3b671f423a536022e550 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 14 Dec 2022 00:39:42 +0900 Subject: [PATCH 4872/6294] [Modify] Edit it --- websocket-sharp/MessageEventArgs.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/MessageEventArgs.cs b/websocket-sharp/MessageEventArgs.cs index 3ed1561ef..79ee824d8 100644 --- a/websocket-sharp/MessageEventArgs.cs +++ b/websocket-sharp/MessageEventArgs.cs @@ -35,8 +35,8 @@ namespace WebSocketSharp /// /// /// - /// That event occurs when the receives - /// a message or a ping if the + /// The message event occurs when the interface + /// receives a message or a ping if the /// property is set to true. /// /// From a7bc94db07ffc1b5fc387dce7b81bd9aefa0c3eb Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 14 Dec 2022 00:41:11 +0900 Subject: [PATCH 4873/6294] [Modify] 2022 --- websocket-sharp/MessageEventArgs.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/MessageEventArgs.cs b/websocket-sharp/MessageEventArgs.cs index 79ee824d8..63add90f7 100644 --- a/websocket-sharp/MessageEventArgs.cs +++ b/websocket-sharp/MessageEventArgs.cs @@ -4,7 +4,7 @@ * * The MIT License * - * Copyright (c) 2012-2016 sta.blockhead + * Copyright (c) 2012-2022 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From ecbd0f1da1df1bc0234847b644766370405304d2 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 14 Dec 2022 00:57:05 +0900 Subject: [PATCH 4874/6294] [Modify] Edit it --- websocket-sharp/ErrorEventArgs.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/ErrorEventArgs.cs b/websocket-sharp/ErrorEventArgs.cs index 41502ab08..afbc9aa15 100644 --- a/websocket-sharp/ErrorEventArgs.cs +++ b/websocket-sharp/ErrorEventArgs.cs @@ -83,8 +83,13 @@ internal ErrorEventArgs (string message, Exception exception) /// Gets the exception that caused the error. /// /// - /// An instance that represents the cause of - /// the error if it is due to an exception; otherwise, . + /// + /// An instance that represents + /// the cause of the error. + /// + /// + /// if not present. + /// /// public Exception Exception { get { From 1022a9316029499449a22ed30b6f91c6f177df52 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 14 Dec 2022 01:12:47 +0900 Subject: [PATCH 4875/6294] [Modify] Edit it --- websocket-sharp/ErrorEventArgs.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/ErrorEventArgs.cs b/websocket-sharp/ErrorEventArgs.cs index afbc9aa15..4b6d96470 100644 --- a/websocket-sharp/ErrorEventArgs.cs +++ b/websocket-sharp/ErrorEventArgs.cs @@ -42,14 +42,15 @@ namespace WebSocketSharp /// /// /// - /// That event occurs when the gets an error. + /// The error event occurs when the interface + /// gets an error. /// /// /// If you would like to get the error message, you should access /// the property. /// /// - /// And if the error is due to an exception, you can get it by accessing + /// If the error is due to an exception, you can get it by accessing /// the property. /// /// From 1be8ec529f74daebd5e262bc8f1c2a108387a066 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 14 Dec 2022 01:14:28 +0900 Subject: [PATCH 4876/6294] [Modify] 2022 --- websocket-sharp/ErrorEventArgs.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/ErrorEventArgs.cs b/websocket-sharp/ErrorEventArgs.cs index 4b6d96470..c02d0e000 100644 --- a/websocket-sharp/ErrorEventArgs.cs +++ b/websocket-sharp/ErrorEventArgs.cs @@ -4,7 +4,7 @@ * * The MIT License * - * Copyright (c) 2012-2016 sta.blockhead + * Copyright (c) 2012-2022 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From 0a41f8c2850f2a1430c8df752a3d297e87d425c1 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 14 Dec 2022 01:32:36 +0900 Subject: [PATCH 4877/6294] [Modify] Remove it --- websocket-sharp/CloseEventArgs.cs | 6 ------ 1 file changed, 6 deletions(-) diff --git a/websocket-sharp/CloseEventArgs.cs b/websocket-sharp/CloseEventArgs.cs index 8127ce418..94f810240 100644 --- a/websocket-sharp/CloseEventArgs.cs +++ b/websocket-sharp/CloseEventArgs.cs @@ -59,12 +59,6 @@ internal CloseEventArgs (PayloadData payloadData, bool clean) _clean = clean; } - internal CloseEventArgs (ushort code, string reason, bool clean) - { - _payloadData = new PayloadData (code, reason); - _clean = clean; - } - #endregion #region Public Properties From de2095177a3700570599996af980175004a9c7f8 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 14 Dec 2022 15:35:58 +0900 Subject: [PATCH 4878/6294] [Modify] Edit it --- websocket-sharp/CloseEventArgs.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/CloseEventArgs.cs b/websocket-sharp/CloseEventArgs.cs index 94f810240..9e7e6f6d9 100644 --- a/websocket-sharp/CloseEventArgs.cs +++ b/websocket-sharp/CloseEventArgs.cs @@ -35,11 +35,12 @@ namespace WebSocketSharp /// /// /// - /// That event occurs when the WebSocket connection has been closed. + /// The close event occurs when the WebSocket connection has been closed. /// /// - /// If you would like to get the reason for the connection close, you should - /// access the or property. + /// If you would like to get the reason for the connection close, + /// you should access the or + /// property. /// /// public class CloseEventArgs : EventArgs From 06866bfd26b8027d394b343f6baf73e63b36371a Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 14 Dec 2022 15:44:06 +0900 Subject: [PATCH 4879/6294] [Modify] Edit it --- websocket-sharp/CloseEventArgs.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/CloseEventArgs.cs b/websocket-sharp/CloseEventArgs.cs index 9e7e6f6d9..1b7a33bec 100644 --- a/websocket-sharp/CloseEventArgs.cs +++ b/websocket-sharp/CloseEventArgs.cs @@ -81,8 +81,13 @@ public ushort Code { /// Gets the reason for the connection close. /// /// - /// A that represents the reason for - /// the connection close if present. + /// + /// A that represents the reason for + /// the connection close. + /// + /// + /// An empty string if not present. + /// /// public string Reason { get { From 69e263386937bf760bf8c9353ab3ed81903690e7 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 14 Dec 2022 15:49:58 +0900 Subject: [PATCH 4880/6294] [Modify] Edit it --- websocket-sharp/CloseEventArgs.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/CloseEventArgs.cs b/websocket-sharp/CloseEventArgs.cs index 1b7a33bec..53d9700a3 100644 --- a/websocket-sharp/CloseEventArgs.cs +++ b/websocket-sharp/CloseEventArgs.cs @@ -68,8 +68,13 @@ internal CloseEventArgs (PayloadData payloadData, bool clean) /// Gets the status code for the connection close. /// /// - /// A that represents the status code for - /// the connection close if present. + /// + /// A that represents the status code for + /// the connection close. + /// + /// + /// 1005 (no status) if not present. + /// /// public ushort Code { get { From ede13801f110522275c75d46388df2239c908e42 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 14 Dec 2022 15:52:40 +0900 Subject: [PATCH 4881/6294] [Modify] 2022 --- websocket-sharp/CloseEventArgs.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/CloseEventArgs.cs b/websocket-sharp/CloseEventArgs.cs index 53d9700a3..50b01ce32 100644 --- a/websocket-sharp/CloseEventArgs.cs +++ b/websocket-sharp/CloseEventArgs.cs @@ -4,7 +4,7 @@ * * The MIT License * - * Copyright (c) 2012-2019 sta.blockhead + * Copyright (c) 2012-2022 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From cac2b751ad890d2becf5185f7462d40f2472feee Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 14 Dec 2022 16:56:59 +0900 Subject: [PATCH 4882/6294] [Modify] Polish it --- websocket-sharp/PayloadData.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/PayloadData.cs b/websocket-sharp/PayloadData.cs index 9e40b9404..9dcb062e8 100644 --- a/websocket-sharp/PayloadData.cs +++ b/websocket-sharp/PayloadData.cs @@ -129,10 +129,11 @@ internal string Reason { if (_length <= 2) return String.Empty; - var raw = _data.SubArray (2, _length - 2); + var bytes = _data.SubArray (2, _length - 2); string reason; - return raw.TryGetUTF8DecodedString (out reason) + + return bytes.TryGetUTF8DecodedString (out reason) ? reason : String.Empty; } From 6bea296e4e1525ee6463203bae0153207b18946f Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 14 Dec 2022 17:03:01 +0900 Subject: [PATCH 4883/6294] [Modify] Edit it --- websocket-sharp/PayloadData.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/PayloadData.cs b/websocket-sharp/PayloadData.cs index 9dcb062e8..639b51e59 100644 --- a/websocket-sharp/PayloadData.cs +++ b/websocket-sharp/PayloadData.cs @@ -54,7 +54,7 @@ internal class PayloadData : IEnumerable /// /// /// - /// A will occur when the length of + /// A is thrown when the length of /// incoming payload data is greater than the value of this field. /// /// From 5e383ccdc350e0f1fedf62ba3988baea8a99a692 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 14 Dec 2022 17:05:21 +0900 Subject: [PATCH 4884/6294] [Modify] 2022 --- websocket-sharp/PayloadData.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/PayloadData.cs b/websocket-sharp/PayloadData.cs index 639b51e59..310b0140c 100644 --- a/websocket-sharp/PayloadData.cs +++ b/websocket-sharp/PayloadData.cs @@ -4,7 +4,7 @@ * * The MIT License * - * Copyright (c) 2012-2019 sta.blockhead + * Copyright (c) 2012-2022 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From 72c60c6d5ff9a11fb4c75673603bafe4b957dc5e Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 15 Dec 2022 15:47:52 +0900 Subject: [PATCH 4885/6294] [Modify] Add it --- websocket-sharp/Ext.cs | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 6d39410a0..44734b37e 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -445,6 +445,32 @@ internal static string GetDnsSafeHost (this Uri uri, bool bracketIPv6) : uri.DnsSafeHost; } + internal static string GetErrorMessage (this ushort code) + { + switch (code) { + case 1002: + return "A protocol error has occurred."; + case 1003: + return "Unsupported data has been received."; + case 1006: + return "An abnormal error has occurred."; + case 1007: + return "Invalid data has been received."; + case 1008: + return "A policy violation has occurred."; + case 1009: + return "A too big message has been received."; + case 1010: + return "The client did not receive expected extension(s)."; + case 1011: + return "The server got an internal error."; + case 1015: + return "An error has occurred during a TLS handshake."; + default: + return String.Empty; + } + } + internal static string GetMessage (this CloseStatusCode code) { switch (code) { From a183b9546e20d31fa9528c74553aeb91efd251ed Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 15 Dec 2022 23:15:28 +0900 Subject: [PATCH 4886/6294] [Modify] Return a ushort --- websocket-sharp/WebSocket.cs | 4 ++-- websocket-sharp/WebSocketException.cs | 28 +++++++++++++++++++++------ 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index dd3259d3f..c04765c61 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -785,9 +785,9 @@ private void abort (string reason, Exception exception) { var code = exception is WebSocketException ? ((WebSocketException) exception).Code - : CloseStatusCode.Abnormal; + : (ushort) 1006; - abort ((ushort) code, reason); + abort (code, reason); } private void abort (ushort code, string reason) diff --git a/websocket-sharp/WebSocketException.cs b/websocket-sharp/WebSocketException.cs index 81d7c8081..f3e4a98b3 100644 --- a/websocket-sharp/WebSocketException.cs +++ b/websocket-sharp/WebSocketException.cs @@ -38,7 +38,19 @@ public class WebSocketException : Exception { #region Private Fields - private CloseStatusCode _code; + private ushort _code; + + #endregion + + #region Private Constructors + + private WebSocketException ( + ushort code, string message, Exception innerException + ) + : base (message ?? code.GetErrorMessage (), innerException) + { + _code = code; + } #endregion @@ -82,9 +94,8 @@ internal WebSocketException (CloseStatusCode code, string message) internal WebSocketException ( CloseStatusCode code, string message, Exception innerException ) - : base (message ?? code.GetMessage (), innerException) + : this ((ushort) code, message, innerException) { - _code = code; } #endregion @@ -95,10 +106,15 @@ internal WebSocketException ( /// Gets the status code indicating the cause of the exception. /// /// - /// One of the enum values that represents - /// the status code indicating the cause of the exception. + /// + /// A that represents the status code indicating + /// the cause of the exception. + /// + /// + /// It is one of the status codes for the WebSocket connection close. + /// /// - public CloseStatusCode Code { + public ushort Code { get { return _code; } From 3fd017fac987da7e299183cef731a5430934cced Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 15 Dec 2022 23:19:17 +0900 Subject: [PATCH 4887/6294] [Modify] Replace it --- websocket-sharp/Ext.cs | 23 +---------------------- 1 file changed, 1 insertion(+), 22 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 44734b37e..cd6f96d2a 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -473,28 +473,7 @@ internal static string GetErrorMessage (this ushort code) internal static string GetMessage (this CloseStatusCode code) { - switch (code) { - case CloseStatusCode.ProtocolError: - return "A protocol error has occurred."; - case CloseStatusCode.UnsupportedData: - return "Unsupported data has been received."; - case CloseStatusCode.Abnormal: - return "An abnormal error has occurred."; - case CloseStatusCode.InvalidData: - return "Invalid data has been received."; - case CloseStatusCode.PolicyViolation: - return "A policy violation has occurred."; - case CloseStatusCode.TooBig: - return "A too big message has been received."; - case CloseStatusCode.MandatoryExtension: - return "The client did not receive expected extension(s)."; - case CloseStatusCode.ServerError: - return "The server got an internal error."; - case CloseStatusCode.TlsHandshakeFailure: - return "An error has occurred during a TLS handshake."; - default: - return String.Empty; - } + return ((ushort) code).GetErrorMessage (); } internal static string GetName (this string nameAndValue, char separator) From a2b5fc2c8d3ed1ca8f45d10b7cc512a9fc76e6a8 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 15 Dec 2022 23:20:48 +0900 Subject: [PATCH 4888/6294] [Modify] Rename it --- websocket-sharp/Ext.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index cd6f96d2a..36f768066 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -471,7 +471,7 @@ internal static string GetErrorMessage (this ushort code) } } - internal static string GetMessage (this CloseStatusCode code) + internal static string GetErrorMessage (this CloseStatusCode code) { return ((ushort) code).GetErrorMessage (); } From 109c3b86deb169b6c57d74c74bb87de36eed4e66 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 16 Dec 2022 16:42:48 +0900 Subject: [PATCH 4889/6294] [Modify] 2022 --- websocket-sharp/WebSocketException.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocketException.cs b/websocket-sharp/WebSocketException.cs index f3e4a98b3..6dfe0b126 100644 --- a/websocket-sharp/WebSocketException.cs +++ b/websocket-sharp/WebSocketException.cs @@ -4,7 +4,7 @@ * * The MIT License * - * Copyright (c) 2012-2016 sta.blockhead + * Copyright (c) 2012-2022 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From efed4aba9fdb5f917e05f48fd9c37cb85f13174b Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 16 Dec 2022 21:21:42 +0900 Subject: [PATCH 4890/6294] [Modify] Replace it --- websocket-sharp/Ext.cs | 7 ++++++- websocket-sharp/WebSocketFrame.cs | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 36f768066..bb91c492c 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -485,7 +485,12 @@ internal static string GetName (this string nameAndValue, char separator) internal static string GetUTF8DecodedString (this byte[] bytes) { - return Encoding.UTF8.GetString (bytes); + try { + return Encoding.UTF8.GetString (bytes); + } + catch { + return null; + } } internal static byte[] GetUTF8EncodedBytes (this string s) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index cbc53f32c..b2739af9b 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -422,7 +422,7 @@ private static string print (WebSocketFrame frame) || frame.IsMasked || frame.IsCompressed ? frame._payloadData.ToString () - : utf8Decode (frame._payloadData.ApplicationData); + : frame._payloadData.ApplicationData.GetUTF8DecodedString (); var fmt = @" FIN: {0} From 9b398238f57f87a72be43bc2021c45829508546c Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 16 Dec 2022 21:23:00 +0900 Subject: [PATCH 4891/6294] [Modify] Remove it --- websocket-sharp/WebSocketFrame.cs | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index b2739af9b..dcd8ff05d 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -738,16 +738,6 @@ Action error stream.ReadBytesAsync (len, 1024, comp, error); } - private static string utf8Decode (byte[] bytes) - { - try { - return Encoding.UTF8.GetString (bytes); - } - catch { - return null; - } - } - #endregion #region Internal Methods From 0b000652a43916294d3250bbb60bf0adc72d8ce1 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 17 Dec 2022 15:59:06 +0900 Subject: [PATCH 4892/6294] [Modify] Polish it --- websocket-sharp/WebSocketFrame.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index dcd8ff05d..f43679678 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -869,10 +869,10 @@ public byte[] ToArray () header = (header << 1) + (int) _mask; header = (header << 7) + (int) _payloadLength; - var headerAsUshort = (ushort) header; - var headerAsBytes = headerAsUshort.ToByteArray (ByteOrder.Big); + var uint16Header = (ushort) header; + var rawHeader = uint16Header.ToByteArray (ByteOrder.Big); - buff.Write (headerAsBytes, 0, 2); + buff.Write (rawHeader, 0, 2); if (_payloadLength > 125) { var cnt = _payloadLength == 126 ? 2 : 8; From 1d1472f74ccadf95770ee904a90dd36a99ee3e80 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 18 Dec 2022 16:12:53 +0900 Subject: [PATCH 4893/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index bb91c492c..620523d5e 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -495,7 +495,12 @@ internal static string GetUTF8DecodedString (this byte[] bytes) internal static byte[] GetUTF8EncodedBytes (this string s) { - return Encoding.UTF8.GetBytes (s); + try { + return Encoding.UTF8.GetBytes (s); + } + catch { + return null; + } } internal static string GetValue (this string nameAndValue, char separator) From 310beb7d943ea491911d46b99c0f85d14653815a Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 18 Dec 2022 16:17:51 +0900 Subject: [PATCH 4894/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index c04765c61..afff72aa0 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2525,11 +2525,11 @@ internal static string CreateResponseKey (string base64Key) { SHA1 sha1 = new SHA1CryptoServiceProvider (); - var data = base64Key + _guid; - var bytes = data.GetUTF8EncodedBytes (); - var src = sha1.ComputeHash (bytes); + var src = base64Key + _guid; + var bytes = src.GetUTF8EncodedBytes (); + var hash = sha1.ComputeHash (bytes); - return Convert.ToBase64String (src); + return Convert.ToBase64String (hash); } // As server From 8ea2a03556c5ad6a9e603dd7b32361c36ab2d434 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 19 Dec 2022 17:28:31 +0900 Subject: [PATCH 4895/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index afff72aa0..943355b97 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2514,11 +2514,11 @@ internal void Close (PayloadData payloadData, byte[] rawFrame) // As client internal static string CreateBase64Key () { - var src = new byte[16]; + var key = new byte[16]; - RandomNumber.GetBytes (src); + RandomNumber.GetBytes (key); - return Convert.ToBase64String (src); + return Convert.ToBase64String (key); } internal static string CreateResponseKey (string base64Key) From 755b91d2f793e7a3e82f363f3643a1236d096497 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 20 Dec 2022 22:30:22 +0900 Subject: [PATCH 4896/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 943355b97..1b1bfecbb 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2527,9 +2527,9 @@ internal static string CreateResponseKey (string base64Key) var src = base64Key + _guid; var bytes = src.GetUTF8EncodedBytes (); - var hash = sha1.ComputeHash (bytes); + var key = sha1.ComputeHash (bytes); - return Convert.ToBase64String (hash); + return Convert.ToBase64String (key); } // As server From a97156ae7f68c1d78955a1917a8b847b64697bbb Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 21 Dec 2022 22:16:57 +0900 Subject: [PATCH 4897/6294] [Modify] Add it --- websocket-sharp/Server/WebSocketBehavior.cs | 22 +++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index d97be5679..1b458271c 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -96,6 +96,28 @@ protected NameValueCollection Headers { } } + /// + /// Gets a value indicating whether the communication is possible for + /// a session. + /// + /// + /// true if the communication is possible; otherwise, false. + /// + /// + /// The session has not started yet. + /// + protected bool IsAlive { + get { + if (_websocket == null) { + var msg = "The session has not started yet."; + + throw new InvalidOperationException (msg); + } + + return _websocket.IsAlive; + } + } + /// /// Gets the query string for a session. /// From 92b9fbfe3f2022530780a76cf9c72b653de1962a Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 22 Dec 2022 16:02:22 +0900 Subject: [PATCH 4898/6294] [Modify] Add it --- websocket-sharp/WebSocketFrame.cs | 42 +++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index f43679678..9e8a3bf84 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -738,6 +738,48 @@ Action error stream.ReadBytesAsync (len, 1024, comp, error); } + private string toString () + { + var extPayloadLen = _payloadLength > 125 + ? ExactPayloadLength.ToString () + : String.Empty; + + var maskingKey = _maskingKey.Length > 0 + ? BitConverter.ToString (_maskingKey) + : String.Empty; + + var payloadData = _payloadLength > 125 + ? "***" + : _payloadLength > 0 + ? _payloadData.ToString () + : String.Empty; + + var fmt = @" FIN: {0} + RSV1: {1} + RSV2: {2} + RSV3: {3} + Opcode: {4} + MASK: {5} + Payload Length: {6} +Extended Payload Length: {7} + Masking Key: {8} + Payload Data: {9}"; + + return String.Format ( + fmt, + _fin, + _rsv1, + _rsv2, + _rsv3, + _opcode, + _mask, + _payloadLength, + extPayloadLen, + maskingKey, + payloadData + ); + } + #endregion #region Internal Methods From 9f96be1a02bd9da40683f914131d6bb8cd8f183c Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 23 Dec 2022 00:48:14 +0900 Subject: [PATCH 4899/6294] [Modify] Add it --- websocket-sharp/WebSocketFrame.cs | 91 +++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index 9e8a3bf84..797460e29 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -738,6 +738,97 @@ Action error stream.ReadBytesAsync (len, 1024, comp, error); } + private string toDumpString () + { + var len = Length; + var cnt = (long) (len / 4); + var rem = (int) (len % 4); + + int cntDigit; + string cntFmt; + + if (cnt < 10000) { + cntDigit = 4; + cntFmt = "{0,4}"; + } + else if (cnt < 0x010000) { + cntDigit = 4; + cntFmt = "{0,4:X}"; + } + else if (cnt < 0x0100000000) { + cntDigit = 8; + cntFmt = "{0,8:X}"; + } + else { + cntDigit = 16; + cntFmt = "{0,16:X}"; + } + + var baseFmt = "{{0,{0}}}"; + var spFmt = String.Format (baseFmt, cntDigit); + + baseFmt = @"{0} 01234567 89ABCDEF 01234567 89ABCDEF +{0}+--------+--------+--------+--------+ +"; + var headerFmt = String.Format (baseFmt, spFmt); + + baseFmt = "{0}|{{1,8}} {{2,8}} {{3,8}} {{4,8}}|\n"; + var lineFmt = String.Format (baseFmt, cntFmt); + + baseFmt = "{0}+--------+--------+--------+--------+"; + var footerFmt = String.Format (baseFmt, spFmt); + + var buff = new StringBuilder (64); + + Func> lineWriter = + () => { + long lineCnt = 0; + + return (arg1, arg2, arg3, arg4) => { + buff.AppendFormat ( + lineFmt, ++lineCnt, arg1, arg2, arg3, arg4 + ); + }; + }; + + var writeLine = lineWriter (); + var bytes = ToArray (); + + buff.AppendFormat (headerFmt, String.Empty); + + for (long i = 0; i <= cnt; i++) { + var j = i * 4; + + if (i < cnt) { + writeLine ( + Convert.ToString (bytes[j], 2).PadLeft (8, '0'), + Convert.ToString (bytes[j + 1], 2).PadLeft (8, '0'), + Convert.ToString (bytes[j + 2], 2).PadLeft (8, '0'), + Convert.ToString (bytes[j + 3], 2).PadLeft (8, '0') + ); + + continue; + } + + if (rem > 0) { + writeLine ( + Convert.ToString (bytes[j], 2).PadLeft (8, '0'), + rem >= 2 + ? Convert.ToString (bytes[j + 1], 2).PadLeft (8, '0') + : String.Empty, + rem == 3 + ? Convert.ToString (bytes[j + 2], 2).PadLeft (8, '0') + : String.Empty, + String.Empty + ); + } + } + + buff.AppendFormat (footerFmt, String.Empty); + + return buff.ToString (); + } + private string toString () { var extPayloadLen = _payloadLength > 125 From 35445672b9d1547a4aa3a9b1ff9548a432235b10 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 23 Dec 2022 00:51:41 +0900 Subject: [PATCH 4900/6294] [Modify] Add it --- websocket-sharp/WebSocketFrame.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index 797460e29..7f2959247 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -958,6 +958,11 @@ Action error ); } + internal string ToString (bool dump) + { + return dump ? toDumpString () : toString (); + } + internal void Unmask () { if (_mask == Mask.Off) From e69aaf94939db944b847627c229813148e9b110e Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 23 Dec 2022 00:54:16 +0900 Subject: [PATCH 4901/6294] [Modify] Replace it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 1b1bfecbb..5d578e4b6 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1871,7 +1871,7 @@ IEnumerable values private bool processUnsupportedFrame (WebSocketFrame frame) { _log.Fatal ("An unsupported frame was received."); - _log.Debug ("The frame is" + frame.PrintToString (false)); + _log.Debug (frame.ToString (false)); abort (1003, "There is no way to handle it."); From d65f8ae24d6a09acb986dfd68390af7f835a363b Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 23 Dec 2022 15:44:01 +0900 Subject: [PATCH 4902/6294] [Modify] Polish it --- websocket-sharp/WebSocketFrame.cs | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index 7f2959247..134e80108 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -744,30 +744,27 @@ private string toDumpString () var cnt = (long) (len / 4); var rem = (int) (len % 4); - int cntDigit; + string spFmt; string cntFmt; if (cnt < 10000) { - cntDigit = 4; + spFmt = "{0,4}"; cntFmt = "{0,4}"; } else if (cnt < 0x010000) { - cntDigit = 4; + spFmt = "{0,4}"; cntFmt = "{0,4:X}"; } else if (cnt < 0x0100000000) { - cntDigit = 8; + spFmt = "{0,8}"; cntFmt = "{0,8:X}"; } else { - cntDigit = 16; + spFmt = "{0,16}"; cntFmt = "{0,16:X}"; } - var baseFmt = "{{0,{0}}}"; - var spFmt = String.Format (baseFmt, cntDigit); - - baseFmt = @"{0} 01234567 89ABCDEF 01234567 89ABCDEF + var baseFmt = @"{0} 01234567 89ABCDEF 01234567 89ABCDEF {0}+--------+--------+--------+--------+ "; var headerFmt = String.Format (baseFmt, spFmt); From 10110d8563ed9a1d848235ef042fe411c002a4be Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 23 Dec 2022 15:52:03 +0900 Subject: [PATCH 4903/6294] [Modify] Replace it --- websocket-sharp/WebSocket.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 5d578e4b6..20419c656 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1785,8 +1785,14 @@ private bool processReceivedFrame (WebSocketFrame frame) { string msg; - if (!checkReceivedFrame (frame, out msg)) - throw new WebSocketException (CloseStatusCode.ProtocolError, msg); + if (!checkReceivedFrame (frame, out msg)) { + _log.Error (msg); + _log.Debug (frame.ToString (false)); + + abort (1002, "An error has occurred while receiving."); + + return false; + } frame.Unmask (); From b87a68feb09b087e9ec66e8ada6a6bfa939dfc7b Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 24 Dec 2022 16:47:40 +0900 Subject: [PATCH 4904/6294] [Modify] Remove it --- websocket-sharp/WebSocketFrame.cs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index 134e80108..9ccff247e 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -988,11 +988,6 @@ public void Print (bool dumped) Console.WriteLine (val); } - public string PrintToString (bool dumped) - { - return dumped ? dump (this) : print (this); - } - public byte[] ToArray () { using (var buff = new MemoryStream ()) { From 67ef8a551107fadade10acb1ed05a5670dacf570 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 24 Dec 2022 16:48:40 +0900 Subject: [PATCH 4905/6294] [Modify] Remove it --- websocket-sharp/WebSocketFrame.cs | 7 ------- 1 file changed, 7 deletions(-) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index 9ccff247e..1538e0b95 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -981,13 +981,6 @@ public IEnumerator GetEnumerator () yield return b; } - public void Print (bool dumped) - { - var val = dumped ? dump (this) : print (this); - - Console.WriteLine (val); - } - public byte[] ToArray () { using (var buff = new MemoryStream ()) { From 198c0881723a28a6221b8cdb75d8f9079f73e901 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 25 Dec 2022 15:43:36 +0900 Subject: [PATCH 4906/6294] [Modify] Remove it --- websocket-sharp/WebSocketFrame.cs | 52 ------------------------------- 1 file changed, 52 deletions(-) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index 1538e0b95..5593a2789 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -399,58 +399,6 @@ private static string dump (WebSocketFrame frame) return buff.ToString (); } - private static string print (WebSocketFrame frame) - { - // Payload Length - var payloadLen = frame._payloadLength; - - // Extended Payload Length - var extPayloadLen = payloadLen > 125 - ? frame.ExactPayloadLength.ToString () - : String.Empty; - - // Masking Key - var maskingKey = BitConverter.ToString (frame._maskingKey); - - // Payload Data - var payload = payloadLen == 0 - ? String.Empty - : payloadLen > 125 - ? "---" - : !frame.IsText - || frame.IsFragment - || frame.IsMasked - || frame.IsCompressed - ? frame._payloadData.ToString () - : frame._payloadData.ApplicationData.GetUTF8DecodedString (); - - var fmt = @" - FIN: {0} - RSV1: {1} - RSV2: {2} - RSV3: {3} - Opcode: {4} - MASK: {5} - Payload Length: {6} -Extended Payload Length: {7} - Masking Key: {8} - Payload Data: {9}"; - - return String.Format ( - fmt, - frame._fin, - frame._rsv1, - frame._rsv2, - frame._rsv3, - frame._opcode, - frame._mask, - payloadLen, - extPayloadLen, - maskingKey, - payload - ); - } - private static WebSocketFrame processHeader (byte[] header) { if (header.Length != 2) { From 015209f25d4887618be8f57021e52dfdb3b8e138 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 25 Dec 2022 15:44:57 +0900 Subject: [PATCH 4907/6294] [Modify] Remove it --- websocket-sharp/WebSocketFrame.cs | 94 ------------------------------- 1 file changed, 94 deletions(-) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index 5593a2789..4aa79d45b 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -305,100 +305,6 @@ private static byte[] createMaskingKey () return key; } - private static string dump (WebSocketFrame frame) - { - var len = frame.Length; - var cnt = (long) (len / 4); - var rem = (int) (len % 4); - - int cntDigit; - string cntFmt; - - if (cnt < 10000) { - cntDigit = 4; - cntFmt = "{0,4}"; - } - else if (cnt < 0x010000) { - cntDigit = 4; - cntFmt = "{0,4:X}"; - } - else if (cnt < 0x0100000000) { - cntDigit = 8; - cntFmt = "{0,8:X}"; - } - else { - cntDigit = 16; - cntFmt = "{0,16:X}"; - } - - var spFmt = String.Format ("{{0,{0}}}", cntDigit); - - var headerFmt = String.Format ( - @" -{0} 01234567 89ABCDEF 01234567 89ABCDEF -{0}+--------+--------+--------+--------+\n", - spFmt - ); - - var lineFmt = String.Format ( - "{0}|{{1,8}} {{2,8}} {{3,8}} {{4,8}}|\n", cntFmt - ); - - var footerFmt = String.Format ( - "{0}+--------+--------+--------+--------+", spFmt - ); - - var buff = new StringBuilder (64); - - Func> linePrinter = - () => { - long lineCnt = 0; - - return (arg1, arg2, arg3, arg4) => { - buff.AppendFormat ( - lineFmt, ++lineCnt, arg1, arg2, arg3, arg4 - ); - }; - }; - - var printLine = linePrinter (); - var bytes = frame.ToArray (); - - buff.AppendFormat (headerFmt, String.Empty); - - for (long i = 0; i <= cnt; i++) { - var j = i * 4; - - if (i < cnt) { - printLine ( - Convert.ToString (bytes[j], 2).PadLeft (8, '0'), - Convert.ToString (bytes[j + 1], 2).PadLeft (8, '0'), - Convert.ToString (bytes[j + 2], 2).PadLeft (8, '0'), - Convert.ToString (bytes[j + 3], 2).PadLeft (8, '0') - ); - - continue; - } - - if (rem > 0) { - printLine ( - Convert.ToString (bytes[j], 2).PadLeft (8, '0'), - rem >= 2 - ? Convert.ToString (bytes[j + 1], 2).PadLeft (8, '0') - : String.Empty, - rem == 3 - ? Convert.ToString (bytes[j + 2], 2).PadLeft (8, '0') - : String.Empty, - String.Empty - ); - } - } - - buff.AppendFormat (footerFmt, String.Empty); - - return buff.ToString (); - } - private static WebSocketFrame processHeader (byte[] header) { if (header.Length != 2) { From 17938c323a04622b7c30beb299720e0feb5e5e12 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 26 Dec 2022 16:08:06 +0900 Subject: [PATCH 4908/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 20419c656..2c518eb97 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1071,30 +1071,35 @@ private bool checkReceivedFrame (WebSocketFrame frame, out string message) { message = null; - var masked = frame.IsMasked; + if (frame.IsMasked) { + if (_client) { + message = "A frame from the server is masked."; - if (_client && masked) { - message = "A frame from the server is masked."; - - return false; + return false; + } } + else { + if (!_client) { + message = "A frame from a client is not masked."; - if (!_client && !masked) { - message = "A frame from a client is not masked."; - - return false; + return false; + } } - if (_inContinuation && frame.IsData) { - message = "A data frame was received while receiving continuation frames."; + if (frame.IsData) { + if (_inContinuation) { + message = "A data frame was received while receiving continuation frames."; - return false; + return false; + } } - if (frame.IsCompressed && _compression == CompressionMethod.None) { - message = "A compressed frame was received without any agreement for it."; + if (frame.IsCompressed) { + if (_compression == CompressionMethod.None) { + message = "A compressed frame was received without any agreement for it."; - return false; + return false; + } } if (frame.Rsv2 == Rsv.On) { From 1e127edd4debcd95f4e28cb2ebcef95ca441c99b Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 27 Dec 2022 01:01:40 +0900 Subject: [PATCH 4909/6294] [Modify] Move it --- websocket-sharp/WebSocket.cs | 6 ++++++ websocket-sharp/WebSocketFrame.cs | 6 ------ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 2c518eb97..29197c37c 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1095,6 +1095,12 @@ private bool checkReceivedFrame (WebSocketFrame frame, out string message) } if (frame.IsCompressed) { + if (!frame.IsData) { + message = "A non data frame is compressed."; + + return false; + } + if (_compression == CompressionMethod.None) { message = "A compressed frame was received without any agreement for it."; diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index 4aa79d45b..084df9670 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -340,12 +340,6 @@ private static WebSocketFrame processHeader (byte[] header) throw new WebSocketException (CloseStatusCode.ProtocolError, msg); } - if (!opcode.IsData () && rsv1 == Rsv.On) { - var msg = "A non data frame is compressed."; - - throw new WebSocketException (CloseStatusCode.ProtocolError, msg); - } - if (opcode.IsControl ()) { if (fin == Fin.More) { var msg = "A control frame is fragmented."; From 05faba279490a79deb995edd64803a0f161f0640 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 27 Dec 2022 15:34:29 +0900 Subject: [PATCH 4910/6294] [Modify] Move it --- websocket-sharp/WebSocket.cs | 14 ++++++++++++++ websocket-sharp/WebSocketFrame.cs | 14 -------------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 29197c37c..a54307c19 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1094,6 +1094,20 @@ private bool checkReceivedFrame (WebSocketFrame frame, out string message) } } + if (frame.IsControl) { + if (frame.Fin == Fin.More) { + message = "A control frame is fragmented."; + + return false; + } + + if (frame.PayloadLength > 125) { + message = "The payload length of a control frame is too long."; + + return false; + } + } + if (frame.IsCompressed) { if (!frame.IsData) { message = "A non data frame is compressed."; diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index 084df9670..f56bd4bf0 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -340,20 +340,6 @@ private static WebSocketFrame processHeader (byte[] header) throw new WebSocketException (CloseStatusCode.ProtocolError, msg); } - if (opcode.IsControl ()) { - if (fin == Fin.More) { - var msg = "A control frame is fragmented."; - - throw new WebSocketException (CloseStatusCode.ProtocolError, msg); - } - - if (payloadLen > 125) { - var msg = "A control frame has too long payload length."; - - throw new WebSocketException (CloseStatusCode.ProtocolError, msg); - } - } - var frame = new WebSocketFrame (); frame._fin = fin; frame._rsv1 = rsv1; From 480123172c0a6c2ea6f775e40cdbc1ce8e0f4da4 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 27 Dec 2022 17:12:22 +0900 Subject: [PATCH 4911/6294] [Modify] Polish it --- websocket-sharp/WebSocketFrame.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index f56bd4bf0..8b94aa06e 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -335,9 +335,9 @@ private static WebSocketFrame processHeader (byte[] header) var payloadLen = (byte) (header[1] & 0x7f); if (!opcode.IsSupported ()) { - var msg = "A frame has an unsupported opcode."; + var msg = "The opcode of a frame is not supported."; - throw new WebSocketException (CloseStatusCode.ProtocolError, msg); + throw new WebSocketException (CloseStatusCode.UnsupportedData, msg); } var frame = new WebSocketFrame (); From e77d54ca354e0016c78252427e020fc7904ec80e Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 27 Dec 2022 17:18:46 +0900 Subject: [PATCH 4912/6294] [Modify] Polish it --- websocket-sharp/WebSocketFrame.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index 8b94aa06e..8b3801678 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -498,7 +498,7 @@ private static WebSocketFrame readPayloadData ( var exactLen = frame.ExactPayloadLength; if (exactLen > PayloadData.MaxLength) { - var msg = "A frame has too long payload length."; + var msg = "The payload data of a frame is too big."; throw new WebSocketException (CloseStatusCode.TooBig, msg); } From c28423ad0cffb233c1cdcb0edd8abb028702c31a Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 28 Dec 2022 16:07:59 +0900 Subject: [PATCH 4913/6294] [Modify] Polish it --- websocket-sharp/WebSocketFrame.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index 8b3801678..5df05708b 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -535,7 +535,7 @@ Action error var exactLen = frame.ExactPayloadLength; if (exactLen > PayloadData.MaxLength) { - var msg = "A frame has too long payload length."; + var msg = "The payload data of a frame is too big."; throw new WebSocketException (CloseStatusCode.TooBig, msg); } From 909842395a3ee37cbdb891a772654f4e8fe9038a Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 28 Dec 2022 16:14:02 +0900 Subject: [PATCH 4914/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index a54307c19..1118c3804 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1102,7 +1102,7 @@ private bool checkReceivedFrame (WebSocketFrame frame, out string message) } if (frame.PayloadLength > 125) { - message = "The payload length of a control frame is too long."; + message = "The payload length of a control frame is greater than 125."; return false; } From 133e432273b8872d3b966f0df72d4d46651404b1 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 29 Dec 2022 00:56:30 +0900 Subject: [PATCH 4915/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 1118c3804..bb678c2d4 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1109,14 +1109,14 @@ private bool checkReceivedFrame (WebSocketFrame frame, out string message) } if (frame.IsCompressed) { - if (!frame.IsData) { - message = "A non data frame is compressed."; + if (_compression == CompressionMethod.None) { + message = "A compressed frame was received without any agreement for it."; return false; } - if (_compression == CompressionMethod.None) { - message = "A compressed frame was received without any agreement for it."; + if (!frame.IsData) { + message = "A non data frame is compressed."; return false; } From cac7831866d1dbe46969cfa0ed6bd876ee466bbe Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 29 Dec 2022 16:14:06 +0900 Subject: [PATCH 4916/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index bb678c2d4..bb6fb69e1 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1110,7 +1110,7 @@ private bool checkReceivedFrame (WebSocketFrame frame, out string message) if (frame.IsCompressed) { if (_compression == CompressionMethod.None) { - message = "A compressed frame was received without any agreement for it."; + message = "A frame is compressed without any agreement for it."; return false; } From c00ba2be8227d12cab8f8be38dddf4a011be9ad4 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 29 Dec 2022 16:54:44 +0900 Subject: [PATCH 4917/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index bb6fb69e1..7ac652450 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1086,37 +1086,37 @@ private bool checkReceivedFrame (WebSocketFrame frame, out string message) } } - if (frame.IsData) { - if (_inContinuation) { - message = "A data frame was received while receiving continuation frames."; + if (frame.IsCompressed) { + if (_compression == CompressionMethod.None) { + message = "A frame is compressed without any agreement for it."; return false; } - } - if (frame.IsControl) { - if (frame.Fin == Fin.More) { - message = "A control frame is fragmented."; + if (!frame.IsData) { + message = "A non data frame is compressed."; return false; } + } - if (frame.PayloadLength > 125) { - message = "The payload length of a control frame is greater than 125."; + if (frame.IsData) { + if (_inContinuation) { + message = "A data frame was received while receiving continuation frames."; return false; } } - if (frame.IsCompressed) { - if (_compression == CompressionMethod.None) { - message = "A frame is compressed without any agreement for it."; + if (frame.IsControl) { + if (frame.Fin == Fin.More) { + message = "A control frame is fragmented."; return false; } - if (!frame.IsData) { - message = "A non data frame is compressed."; + if (frame.PayloadLength > 125) { + message = "The payload length of a control frame is greater than 125."; return false; } From d92064117cc2b53b846742ca2a6a07a58c99c355 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 29 Dec 2022 17:16:32 +0900 Subject: [PATCH 4918/6294] [Modify] Remove it --- websocket-sharp/WebSocketFrame.cs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index 5df05708b..fa88f87bc 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -68,11 +68,6 @@ private WebSocketFrame () #region Internal Constructors - internal WebSocketFrame (Opcode opcode, PayloadData payloadData, bool mask) - : this (Fin.Final, opcode, payloadData, false, mask) - { - } - internal WebSocketFrame ( Fin fin, Opcode opcode, byte[] data, bool compressed, bool mask ) From 57fc611754f5bec374a197eedb959105e00d0b85 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 30 Dec 2022 00:45:32 +0900 Subject: [PATCH 4919/6294] [Modify] Polish it --- websocket-sharp/WebSocketFrame.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index fa88f87bc..62063008f 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -86,7 +86,7 @@ bool mask _fin = fin; _opcode = opcode; - _rsv1 = opcode.IsData () && compressed ? Rsv.On : Rsv.Off; + _rsv1 = compressed ? Rsv.On : Rsv.Off; _rsv2 = Rsv.Off; _rsv3 = Rsv.Off; From 111838b6f84dd6d48815d0eca70182ab5942dcbe Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 30 Dec 2022 17:04:56 +0900 Subject: [PATCH 4920/6294] [Modify] Polish it --- websocket-sharp/WebSocketFrame.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index 62063008f..cf7c4f3ca 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -490,23 +490,23 @@ private static WebSocketFrame readPayloadData ( Stream stream, WebSocketFrame frame ) { - var exactLen = frame.ExactPayloadLength; + var exactPayloadLen = frame.ExactPayloadLength; - if (exactLen > PayloadData.MaxLength) { + if (exactPayloadLen > PayloadData.MaxLength) { var msg = "The payload data of a frame is too big."; throw new WebSocketException (CloseStatusCode.TooBig, msg); } - if (exactLen == 0) { + if (exactPayloadLen == 0) { frame._payloadData = PayloadData.Empty; return frame; } - var len = (long) exactLen; + var len = (long) exactPayloadLen; var bytes = frame._payloadLength < 127 - ? stream.ReadBytes ((int) exactLen) + ? stream.ReadBytes ((int) len) : stream.ReadBytes (len, 1024); if (bytes.LongLength != len) { From 4a6e7249d77366595afdc8554d2d3a2eb0c74257 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 31 Dec 2022 01:22:42 +0900 Subject: [PATCH 4921/6294] [Modify] Polish it --- websocket-sharp/WebSocketFrame.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index cf7c4f3ca..d230a37d3 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -527,15 +527,15 @@ private static void readPayloadDataAsync ( Action error ) { - var exactLen = frame.ExactPayloadLength; + var exactPayloadLen = frame.ExactPayloadLength; - if (exactLen > PayloadData.MaxLength) { + if (exactPayloadLen > PayloadData.MaxLength) { var msg = "The payload data of a frame is too big."; throw new WebSocketException (CloseStatusCode.TooBig, msg); } - if (exactLen == 0) { + if (exactPayloadLen == 0) { frame._payloadData = PayloadData.Empty; completed (frame); @@ -543,7 +543,7 @@ Action error return; } - var len = (long) exactLen; + var len = (long) exactPayloadLen; Action comp = bytes => { @@ -558,13 +558,13 @@ Action error completed (frame); }; - if (frame._payloadLength < 127) { - stream.ReadBytesAsync ((int) exactLen, comp, error); + if (frame._payloadLength > 126) { + stream.ReadBytesAsync (len, 1024, comp, error); return; } - stream.ReadBytesAsync (len, 1024, comp, error); + stream.ReadBytesAsync ((int) len, comp, error); } private string toDumpString () From 97fa5864f93517f6cd2432d696608a1b4424c309 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 31 Dec 2022 02:01:18 +0900 Subject: [PATCH 4922/6294] [Modify] Polish it --- websocket-sharp/WebSocketFrame.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index d230a37d3..3b92980dd 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -505,9 +505,9 @@ private static WebSocketFrame readPayloadData ( } var len = (long) exactPayloadLen; - var bytes = frame._payloadLength < 127 - ? stream.ReadBytes ((int) len) - : stream.ReadBytes (len, 1024); + var bytes = frame._payloadLength > 126 + ? stream.ReadBytes (len, 1024) + : stream.ReadBytes ((int) len); if (bytes.LongLength != len) { var msg = "The payload data of a frame could not be read."; From 9fcdf938cda9be071f9098696f62d74b4c544180 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 31 Dec 2022 15:50:12 +0900 Subject: [PATCH 4923/6294] [Modify] Remove it --- websocket-sharp/Ext.cs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 620523d5e..929c2fcd8 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -532,11 +532,6 @@ internal static bool IsCompressionExtension ( return value.StartsWith (val, compType); } - internal static bool IsControl (this byte opcode) - { - return opcode > 0x7 && opcode < 0x10; - } - internal static bool IsControl (this Opcode opcode) { return opcode >= Opcode.Close; From f0306104ca7167bfddc8b46f02e67f822b525b55 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 31 Dec 2022 15:51:10 +0900 Subject: [PATCH 4924/6294] [Modify] Remove it --- websocket-sharp/Ext.cs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 929c2fcd8..9c490050c 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -532,11 +532,6 @@ internal static bool IsCompressionExtension ( return value.StartsWith (val, compType); } - internal static bool IsControl (this Opcode opcode) - { - return opcode >= Opcode.Close; - } - internal static bool IsData (this byte opcode) { return opcode == 0x1 || opcode == 0x2; From 841a2473a72ffee8068a0046085e1077784bf058 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 1 Jan 2023 17:06:14 +0900 Subject: [PATCH 4925/6294] [Modify] Remove it --- websocket-sharp/Ext.cs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 9c490050c..744ac40a2 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -532,11 +532,6 @@ internal static bool IsCompressionExtension ( return value.StartsWith (val, compType); } - internal static bool IsData (this byte opcode) - { - return opcode == 0x1 || opcode == 0x2; - } - internal static bool IsData (this Opcode opcode) { return opcode == Opcode.Text || opcode == Opcode.Binary; From 8f0ffa4443092a59a051efff9aa3b53a844396e5 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 1 Jan 2023 17:06:55 +0900 Subject: [PATCH 4926/6294] [Modify] Remove it --- websocket-sharp/Ext.cs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 744ac40a2..6e8650206 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -532,11 +532,6 @@ internal static bool IsCompressionExtension ( return value.StartsWith (val, compType); } - internal static bool IsData (this Opcode opcode) - { - return opcode == Opcode.Text || opcode == Opcode.Binary; - } - internal static bool IsEqualTo ( this int value, char c, Action beforeComparing ) From 0c7ff15810b35d9b6e10b1a61a69b8d5a5998c97 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 1 Jan 2023 23:43:35 +0900 Subject: [PATCH 4927/6294] [Modify] 2023 --- LICENSE.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LICENSE.txt b/LICENSE.txt index f7473a9b6..fb0529710 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2010-2022 sta.blockhead +Copyright (c) 2010-2023 sta.blockhead Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal From d0d69483286e6d22b0076165e14a6cc448d96306 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 2 Jan 2023 16:17:55 +0900 Subject: [PATCH 4928/6294] [Modify] Replace it --- websocket-sharp/Ext.cs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 6e8650206..ffcd3906d 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -568,10 +568,7 @@ internal static bool IsReserved (this ushort code) internal static bool IsReserved (this CloseStatusCode code) { - return code == CloseStatusCode.Undefined - || code == CloseStatusCode.NoStatus - || code == CloseStatusCode.Abnormal - || code == CloseStatusCode.TlsHandshakeFailure; + return ((ushort) code).IsReserved (); } internal static bool IsSupported (this byte opcode) From d4f84842129cbb7bae4121a3aba37e9624b251be Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 3 Jan 2023 17:26:37 +0900 Subject: [PATCH 4929/6294] [Modify] Rename it --- websocket-sharp/Ext.cs | 4 ++-- websocket-sharp/PayloadData.cs | 2 +- websocket-sharp/Server/WebSocketSessionManager.cs | 2 +- websocket-sharp/WebSocket.cs | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index ffcd3906d..fd0564b4f 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -558,7 +558,7 @@ internal static bool IsPortNumber (this int value) return value > 0 && value < 65536; } - internal static bool IsReserved (this ushort code) + internal static bool IsReservedStatusCode (this ushort code) { return code == 1004 || code == 1005 @@ -568,7 +568,7 @@ internal static bool IsReserved (this ushort code) internal static bool IsReserved (this CloseStatusCode code) { - return ((ushort) code).IsReserved (); + return ((ushort) code).IsReservedStatusCode (); } internal static bool IsSupported (this byte opcode) diff --git a/websocket-sharp/PayloadData.cs b/websocket-sharp/PayloadData.cs index 310b0140c..6d17bc2a0 100644 --- a/websocket-sharp/PayloadData.cs +++ b/websocket-sharp/PayloadData.cs @@ -120,7 +120,7 @@ internal long ExtensionDataLength { internal bool HasReservedCode { get { - return _length >= 2 && Code.IsReserved (); + return _length >= 2 && Code.IsReservedStatusCode (); } } diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 05b0b3307..7957758a1 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -494,7 +494,7 @@ internal void Stop (ushort code, string reason) } var payloadData = new PayloadData (code, reason); - var send = !code.IsReserved (); + var send = !code.IsReservedStatusCode (); stop (payloadData, send); } diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 7ac652450..2586a7e93 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1158,7 +1158,7 @@ private void close (ushort code, string reason) } var data = new PayloadData (code, reason); - var send = !code.IsReserved (); + var send = !code.IsReservedStatusCode (); close (data, send, false); } @@ -1225,7 +1225,7 @@ private void closeAsync (ushort code, string reason) } var data = new PayloadData (code, reason); - var send = !code.IsReserved (); + var send = !code.IsReservedStatusCode (); closeAsync (data, send, false); } From f2c69b5671ac8817e0b0454af125119a2e82acb2 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 3 Jan 2023 17:28:16 +0900 Subject: [PATCH 4930/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index fd0564b4f..0734bfebe 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -558,6 +558,11 @@ internal static bool IsPortNumber (this int value) return value > 0 && value < 65536; } + internal static bool IsReserved (this CloseStatusCode code) + { + return ((ushort) code).IsReservedStatusCode (); + } + internal static bool IsReservedStatusCode (this ushort code) { return code == 1004 @@ -566,11 +571,6 @@ internal static bool IsReservedStatusCode (this ushort code) || code == 1015; } - internal static bool IsReserved (this CloseStatusCode code) - { - return ((ushort) code).IsReservedStatusCode (); - } - internal static bool IsSupported (this byte opcode) { return Enum.IsDefined (typeof (Opcode), opcode); From 599f8d7133c5798a09134affec6238ea654eeaa8 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 4 Jan 2023 15:41:37 +0900 Subject: [PATCH 4931/6294] [Modify] Rename it --- websocket-sharp/Ext.cs | 2 +- websocket-sharp/WebSocketFrame.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 0734bfebe..7d124e93b 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -571,7 +571,7 @@ internal static bool IsReservedStatusCode (this ushort code) || code == 1015; } - internal static bool IsSupported (this byte opcode) + internal static bool IsSupportedOpcode (this byte opcode) { return Enum.IsDefined (typeof (Opcode), opcode); } diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index 3b92980dd..786adffc0 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -329,7 +329,7 @@ private static WebSocketFrame processHeader (byte[] header) // Payload Length var payloadLen = (byte) (header[1] & 0x7f); - if (!opcode.IsSupported ()) { + if (!opcode.IsSupportedOpcode ()) { var msg = "The opcode of a frame is not supported."; throw new WebSocketException (CloseStatusCode.UnsupportedData, msg); From aaa628791cdc6b09600ba6438314282bf0995d8b Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 4 Jan 2023 15:44:16 +0900 Subject: [PATCH 4932/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 7d124e93b..c5d4ac976 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -526,10 +526,10 @@ internal static bool IsCompressionExtension ( this string value, CompressionMethod method ) { - var val = method.ToExtensionString (); + var extStr = method.ToExtensionString (); var compType = StringComparison.Ordinal; - return value.StartsWith (val, compType); + return value.StartsWith (extStr, compType); } internal static bool IsEqualTo ( From 294a7083a42f7ae69c7fcc1d9b6692680f505bfd Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 5 Jan 2023 15:58:03 +0900 Subject: [PATCH 4933/6294] [Modify] 2023 --- websocket-sharp/Ext.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index c5d4ac976..c25e89dca 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -14,7 +14,7 @@ * Copyright (c) 2003 Ben Maurer * Copyright (c) 2003, 2005, 2009 Novell, Inc. (http://www.novell.com) * Copyright (c) 2009 Stephane Delcroix - * Copyright (c) 2010-2022 sta.blockhead + * Copyright (c) 2010-2023 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From 603ffab1ba51209c4d37a341589e4b1edaf6600a Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 6 Jan 2023 16:08:16 +0900 Subject: [PATCH 4934/6294] [Modify] Polish it --- websocket-sharp/WebSocketFrame.cs | 32 +++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index 786adffc0..fd38f4763 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -626,27 +626,27 @@ private string toDumpString () var j = i * 4; if (i < cnt) { - writeLine ( - Convert.ToString (bytes[j], 2).PadLeft (8, '0'), - Convert.ToString (bytes[j + 1], 2).PadLeft (8, '0'), - Convert.ToString (bytes[j + 2], 2).PadLeft (8, '0'), - Convert.ToString (bytes[j + 3], 2).PadLeft (8, '0') - ); + var arg1 = Convert.ToString (bytes[j], 2).PadLeft (8, '0'); + var arg2 = Convert.ToString (bytes[j + 1], 2).PadLeft (8, '0'); + var arg3 = Convert.ToString (bytes[j + 2], 2).PadLeft (8, '0'); + var arg4 = Convert.ToString (bytes[j + 3], 2).PadLeft (8, '0'); + + writeLine (arg1, arg2, arg3, arg4); continue; } if (rem > 0) { - writeLine ( - Convert.ToString (bytes[j], 2).PadLeft (8, '0'), - rem >= 2 - ? Convert.ToString (bytes[j + 1], 2).PadLeft (8, '0') - : String.Empty, - rem == 3 - ? Convert.ToString (bytes[j + 2], 2).PadLeft (8, '0') - : String.Empty, - String.Empty - ); + var arg1 = Convert.ToString (bytes[j], 2).PadLeft (8, '0'); + var arg2 = rem >= 2 + ? Convert.ToString (bytes[j + 1], 2).PadLeft (8, '0') + : String.Empty; + + var arg3 = rem == 3 + ? Convert.ToString (bytes[j + 2], 2).PadLeft (8, '0') + : String.Empty; + + writeLine (arg1, arg2, arg3, String.Empty); } } From b8c34ac618cd2597f5edaaae56f06fbc12edc1f5 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 7 Jan 2023 15:38:40 +0900 Subject: [PATCH 4935/6294] [Modify] Add it --- websocket-sharp/WebSocketFrame.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index fd38f4763..14b4c53db 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -45,6 +45,7 @@ internal class WebSocketFrame : IEnumerable { #region Private Fields + private static readonly int _defaultMaskingKeyLength; private byte[] _extPayloadLength; private Fin _fin; private Mask _mask; @@ -58,6 +59,15 @@ internal class WebSocketFrame : IEnumerable #endregion + #region Static Constructor + + static WebSocketFrame () + { + _defaultMaskingKeyLength = 4; + } + + #endregion + #region Private Constructors private WebSocketFrame () From 57ef4cb25c30baa53cc0de9b12f95ca547015382 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 7 Jan 2023 15:40:18 +0900 Subject: [PATCH 4936/6294] [Modify] Polish it --- websocket-sharp/WebSocketFrame.cs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index 14b4c53db..c6a2c13aa 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -46,16 +46,16 @@ internal class WebSocketFrame : IEnumerable #region Private Fields private static readonly int _defaultMaskingKeyLength; - private byte[] _extPayloadLength; - private Fin _fin; - private Mask _mask; - private byte[] _maskingKey; - private Opcode _opcode; - private PayloadData _payloadData; - private byte _payloadLength; - private Rsv _rsv1; - private Rsv _rsv2; - private Rsv _rsv3; + private byte[] _extPayloadLength; + private Fin _fin; + private Mask _mask; + private byte[] _maskingKey; + private Opcode _opcode; + private PayloadData _payloadData; + private byte _payloadLength; + private Rsv _rsv1; + private Rsv _rsv2; + private Rsv _rsv3; #endregion From b312309cbc03f9f30f812c43ed77442543746589 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 8 Jan 2023 15:43:30 +0900 Subject: [PATCH 4937/6294] [Modify] Replace it --- websocket-sharp/WebSocketFrame.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index c6a2c13aa..f8ea345a0 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -448,10 +448,9 @@ private static WebSocketFrame readMaskingKey ( return frame; } - var len = 4; - var bytes = stream.ReadBytes (len); + var bytes = stream.ReadBytes (_defaultMaskingKeyLength); - if (bytes.Length != len) { + if (bytes.Length != _defaultMaskingKeyLength) { var msg = "The masking key of a frame could not be read."; throw new WebSocketException (msg); From 8d128b98d04814f4e81fb2ca23926f68aab9850e Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 8 Jan 2023 15:46:13 +0900 Subject: [PATCH 4938/6294] [Modify] Replace it --- websocket-sharp/WebSocketFrame.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index f8ea345a0..7447473ba 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -476,12 +476,10 @@ Action error return; } - var len = 4; - stream.ReadBytesAsync ( - len, + _defaultMaskingKeyLength, bytes => { - if (bytes.Length != len) { + if (bytes.Length != _defaultMaskingKeyLength) { var msg = "The masking key of a frame could not be read."; throw new WebSocketException (msg); From 1f2b07734b0fa83ae4d02821b0c96311f04c3b80 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 9 Jan 2023 16:06:12 +0900 Subject: [PATCH 4939/6294] [Modify] Replace it --- websocket-sharp/WebSocketFrame.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index 7447473ba..2b0d22ebc 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -840,7 +840,7 @@ public byte[] ToArray () } if (_mask == Mask.On) - buff.Write (_maskingKey, 0, 4); + buff.Write (_maskingKey, 0, _defaultMaskingKeyLength); if (_payloadLength > 0) { var bytes = _payloadData.ToArray (); From a67dfd1974f900bd1f0b8f2edb711e661cd7bb27 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 9 Jan 2023 16:16:47 +0900 Subject: [PATCH 4940/6294] [Modify] Polish it --- websocket-sharp/WebSocketFrame.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index 2b0d22ebc..84946380c 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -845,10 +845,10 @@ public byte[] ToArray () if (_payloadLength > 0) { var bytes = _payloadData.ToArray (); - if (_payloadLength < 127) - buff.Write (bytes, 0, bytes.Length); - else + if (_payloadLength > 126) buff.WriteBytes (bytes, 1024); + else + buff.Write (bytes, 0, bytes.Length); } buff.Close (); From 4e72000e188a11b7a7c1ffd57ea7153b98f470a8 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 10 Jan 2023 17:20:59 +0900 Subject: [PATCH 4941/6294] [Modify] Polish it --- websocket-sharp/WebSocketFrame.cs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index 84946380c..2ac2c7cf5 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -833,11 +833,8 @@ public byte[] ToArray () buff.Write (rawHeader, 0, 2); - if (_payloadLength > 125) { - var cnt = _payloadLength == 126 ? 2 : 8; - - buff.Write (_extPayloadLength, 0, cnt); - } + if (_payloadLength >= 126) + buff.Write (_extPayloadLength, 0, _extPayloadLength.Length); if (_mask == Mask.On) buff.Write (_maskingKey, 0, _defaultMaskingKeyLength); From 3b3f9a779089aa3b522af10958e83ceffe44cb99 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 10 Jan 2023 17:22:58 +0900 Subject: [PATCH 4942/6294] [Modify] Replace it --- websocket-sharp/WebSocketFrame.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index 2ac2c7cf5..40e2b6248 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -303,7 +303,7 @@ public Rsv Rsv3 { private static byte[] createMaskingKey () { - var key = new byte[4]; + var key = new byte[_defaultMaskingKeyLength]; WebSocket.RandomNumber.GetBytes (key); From fcd979446f2fdeb48046f2b36e5baf6c6bd0baae Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 11 Jan 2023 01:03:26 +0900 Subject: [PATCH 4943/6294] [Modify] Add it --- websocket-sharp/WebSocketFrame.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index 40e2b6248..f50491fd1 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -45,6 +45,7 @@ internal class WebSocketFrame : IEnumerable { #region Private Fields + private static readonly int _defaultHeaderLength; private static readonly int _defaultMaskingKeyLength; private byte[] _extPayloadLength; private Fin _fin; @@ -63,6 +64,7 @@ internal class WebSocketFrame : IEnumerable static WebSocketFrame () { + _defaultHeaderLength = 2; _defaultMaskingKeyLength = 4; } From 73e79dcb52e35f18b946062d8c7da0472675bd89 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 11 Jan 2023 15:44:54 +0900 Subject: [PATCH 4944/6294] [Modify] Replace it --- websocket-sharp/WebSocketFrame.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index f50491fd1..b9c16b9e9 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -314,7 +314,7 @@ private static byte[] createMaskingKey () private static WebSocketFrame processHeader (byte[] header) { - if (header.Length != 2) { + if (header.Length != _defaultHeaderLength) { var msg = "The header part of a frame could not be read."; throw new WebSocketException (msg); From e3bf430c5253d5585bab48d2ee715972516e5751 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 11 Jan 2023 15:48:19 +0900 Subject: [PATCH 4945/6294] [Modify] Replace it --- websocket-sharp/WebSocketFrame.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index b9c16b9e9..4171d3e1a 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -420,7 +420,7 @@ Action error private static WebSocketFrame readHeader (Stream stream) { - var bytes = stream.ReadBytes (2); + var bytes = stream.ReadBytes (_defaultHeaderLength); return processHeader (bytes); } From a1f3c5af97d193b7ca9027ffdc29d5e7429fb365 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 11 Jan 2023 15:50:03 +0900 Subject: [PATCH 4946/6294] [Modify] Replace it --- websocket-sharp/WebSocketFrame.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index 4171d3e1a..1c24e4637 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -430,7 +430,7 @@ private static void readHeaderAsync ( ) { stream.ReadBytesAsync ( - 2, + _defaultHeaderLength, bytes => { var frame = processHeader (bytes); From 11f1e065679a5de3c9937b83d6ba78058051c129 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 12 Jan 2023 16:18:12 +0900 Subject: [PATCH 4947/6294] [Modify] Replace it --- websocket-sharp/WebSocketFrame.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index 1c24e4637..c94c7a16e 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -245,8 +245,11 @@ public bool IsText { public ulong Length { get { - return 2 - + (ulong) (_extPayloadLength.Length + _maskingKey.Length) + return (ulong) ( + _defaultHeaderLength + + _extPayloadLength.Length + + _maskingKey.Length + ) + _payloadData.Length; } } From 53ba4dbb05bdbe71cbed0d6c4c3b7b5517fcd679 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 13 Jan 2023 17:01:19 +0900 Subject: [PATCH 4948/6294] [Modify] Replace it --- websocket-sharp/WebSocketFrame.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index c94c7a16e..c8c0fc2bf 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -836,7 +836,7 @@ public byte[] ToArray () var uint16Header = (ushort) header; var rawHeader = uint16Header.ToByteArray (ByteOrder.Big); - buff.Write (rawHeader, 0, 2); + buff.Write (rawHeader, 0, _defaultHeaderLength); if (_payloadLength >= 126) buff.Write (_extPayloadLength, 0, _extPayloadLength.Length); From e39327ac2270c6786ee8b02a5b1bd9c217822941 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 14 Jan 2023 15:49:04 +0900 Subject: [PATCH 4949/6294] [Modify] Polish it --- websocket-sharp/WebSocketFrame.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index c8c0fc2bf..84a1aa601 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -669,7 +669,7 @@ private string toDumpString () private string toString () { - var extPayloadLen = _payloadLength > 125 + var extPayloadLen = _payloadLength >= 126 ? ExactPayloadLength.ToString () : String.Empty; @@ -677,7 +677,7 @@ private string toString () ? BitConverter.ToString (_maskingKey) : String.Empty; - var payloadData = _payloadLength > 125 + var payloadData = _payloadLength >= 126 ? "***" : _payloadLength > 0 ? _payloadData.ToString () From f2ddc02fef0954ac53b2817983648ec73d14a5fd Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 15 Jan 2023 16:04:30 +0900 Subject: [PATCH 4950/6294] [Modify] Polish it --- websocket-sharp/WebSocketFrame.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index 84a1aa601..a12ed8610 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -673,7 +673,7 @@ private string toString () ? ExactPayloadLength.ToString () : String.Empty; - var maskingKey = _maskingKey.Length > 0 + var maskingKey = _mask == Mask.On ? BitConverter.ToString (_maskingKey) : String.Empty; From 68c4dd75bd5b4e8a348c46301dd1aa68022a77ce Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 16 Jan 2023 16:13:49 +0900 Subject: [PATCH 4951/6294] [Modify] 2023 --- websocket-sharp/WebSocketFrame.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index a12ed8610..874947e52 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -4,7 +4,7 @@ * * The MIT License * - * Copyright (c) 2012-2021 sta.blockhead + * Copyright (c) 2012-2023 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From dd2acce165367d8894ae8deb74dbbbf3f17a3aaa Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 17 Jan 2023 16:06:31 +0900 Subject: [PATCH 4952/6294] [Modify] Rename it --- websocket-sharp/Server/WebSocketSessionManager.cs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 7957758a1..48b4c0a04 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -48,7 +48,7 @@ public class WebSocketSessionManager { #region Private Fields - private static readonly byte[] _emptyPingFrameAsBytes; + private static readonly byte[] _rawEmptyPingFrame; private object _forSweep; private volatile bool _keepClean; private Logger _log; @@ -65,9 +65,7 @@ public class WebSocketSessionManager static WebSocketSessionManager () { - _emptyPingFrameAsBytes = WebSocketFrame - .CreatePingFrame (false) - .ToArray (); + _rawEmptyPingFrame = WebSocketFrame.CreatePingFrame (false).ToArray (); } #endregion @@ -116,7 +114,7 @@ internal ServerState State { /// public IEnumerable ActiveIDs { get { - foreach (var res in broadping (_emptyPingFrameAsBytes)) { + foreach (var res in broadping (_rawEmptyPingFrame)) { if (res.Value) yield return res.Key; } @@ -176,7 +174,7 @@ public IEnumerable IDs { /// public IEnumerable InactiveIDs { get { - foreach (var res in broadping (_emptyPingFrameAsBytes)) { + foreach (var res in broadping (_rawEmptyPingFrame)) { if (!res.Value) yield return res.Key; } From 68e0b5ffcec58e1261a4521709177174ddffacad Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 17 Jan 2023 23:09:58 +0900 Subject: [PATCH 4953/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketSessionManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 48b4c0a04..f8798376c 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -48,10 +48,10 @@ public class WebSocketSessionManager { #region Private Fields - private static readonly byte[] _rawEmptyPingFrame; private object _forSweep; private volatile bool _keepClean; private Logger _log; + private static readonly byte[] _rawEmptyPingFrame; private Dictionary _sessions; private volatile ServerState _state; private volatile bool _sweeping; From 5b4f40678699621ef63a44201ffc7dc7344b8ab0 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 18 Jan 2023 15:44:10 +0900 Subject: [PATCH 4954/6294] [Modify] Rename it --- websocket-sharp/Server/WebSocketSessionManager.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index f8798376c..41db2d516 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -382,7 +382,7 @@ private void broadcastAsync (Opcode opcode, Stream stream, Action completed) ); } - private Dictionary broadping (byte[] frameAsBytes) + private Dictionary broadping (byte[] rawFrame) { var ret = new Dictionary (); @@ -393,7 +393,7 @@ private Dictionary broadping (byte[] frameAsBytes) break; } - var res = session.WebSocket.Ping (frameAsBytes); + var res = session.WebSocket.Ping (rawFrame); ret.Add (session.ID, res); } From 8de083b58bf93265e254f767ef8e7e2f1a9a0285 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 19 Jan 2023 17:12:30 +0900 Subject: [PATCH 4955/6294] [Modify] Return empty if the state is not Start --- websocket-sharp/Server/WebSocketSessionManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 41db2d516..7561a61a2 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -388,7 +388,7 @@ private Dictionary broadping (byte[] rawFrame) foreach (var session in Sessions) { if (_state != ServerState.Start) { - _log.Error ("The service is shutting down."); + ret.Clear (); break; } From cc78ac091c26f6ea8b0df8d07ae986ad50723023 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 20 Jan 2023 16:09:17 +0900 Subject: [PATCH 4956/6294] [Modify] Replace it --- websocket-sharp/Server/WebSocketSessionManager.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 7561a61a2..7161db9cf 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -1516,14 +1516,14 @@ public void SendToAsync ( public void Sweep () { if (_sweeping) { - _log.Info ("The sweeping is already in progress."); + _log.Trace ("The sweep process is already in progress."); return; } lock (_forSweep) { if (_sweeping) { - _log.Info ("The sweeping is already in progress."); + _log.Trace ("The sweep process is already in progress."); return; } From b6384239f5f6e237494f9308f2b6301b22ccc8c7 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 21 Jan 2023 16:11:56 +0900 Subject: [PATCH 4957/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketSessionManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 7161db9cf..81c0e3e0c 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -1566,7 +1566,7 @@ public void Sweep () /// Tries to get the session instance with the specified ID. /// /// - /// true if the session is successfully found; otherwise, + /// true if the session instance is successfully found; otherwise, /// false. /// /// From dfbe86df3049e7e1831682080722a5e769be969b Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 21 Jan 2023 16:27:10 +0900 Subject: [PATCH 4958/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketSessionManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 81c0e3e0c..fe7826aa7 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -1022,7 +1022,7 @@ public void CloseSession (string id, CloseStatusCode code, string reason) /// Sends a ping to the client using the specified session. /// /// - /// true if the send has done with no error and a pong has been + /// true if the send has successfully done and a pong has been /// received from the client within a time; otherwise, false. /// /// From 5a5361585b0ea4c8e2a0230a9cfc2836d8b7f241 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 22 Jan 2023 16:16:55 +0900 Subject: [PATCH 4959/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketSessionManager.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index fe7826aa7..34d7ad784 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -1055,15 +1055,15 @@ public bool PingTo (string id) /// the specified session. /// /// - /// true if the send has done with no error and a pong has been - /// received from the client within a time; otherwise, false. + /// true if the send has successfully done and a pong has been + /// received within a time; otherwise, false. /// /// /// /// A that specifies the message to send. /// /// - /// The size must be 125 bytes or less in UTF-8. + /// Its size must be 125 bytes or less in UTF-8. /// /// /// From b19dbb7d8a82431709ac9b4d86adf990ed764eb9 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 22 Jan 2023 16:19:03 +0900 Subject: [PATCH 4960/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketSessionManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 34d7ad784..9975058e3 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -1023,7 +1023,7 @@ public void CloseSession (string id, CloseStatusCode code, string reason) /// /// /// true if the send has successfully done and a pong has been - /// received from the client within a time; otherwise, false. + /// received within a time; otherwise, false. /// /// /// A that specifies the ID of the session. From 95331f2d8ea60ccfd8c0a8dbdb71475ba74a2983 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 23 Jan 2023 17:02:33 +0900 Subject: [PATCH 4961/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketSessionManager.cs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 9975058e3..e3a6e04cd 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -968,7 +968,7 @@ public void CloseSession (string id, ushort code, string reason) /// A that specifies the reason for the close. /// /// - /// The size must be 123 bytes or less in UTF-8. + /// Its size must be 123 bytes or less in UTF-8. /// /// /// @@ -982,15 +982,14 @@ public void CloseSession (string id, ushort code, string reason) /// -or- /// /// - /// is - /// . + /// is . /// /// /// -or- /// /// - /// is - /// and there is reason. + /// is and + /// is specified. /// /// /// -or- From 46ebf8911f33c4887c8e1461adf28a031f55c97d Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 23 Jan 2023 17:08:45 +0900 Subject: [PATCH 4962/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketSessionManager.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index e3a6e04cd..6df24cb4f 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -893,7 +893,7 @@ public void CloseSession (string id) /// A that specifies the reason for the close. /// /// - /// The size must be 123 bytes or less in UTF-8. + /// Its size must be 123 bytes or less in UTF-8. /// /// /// @@ -913,7 +913,8 @@ public void CloseSession (string id) /// -or- ///
/// - /// is 1005 (no status) and there is reason. + /// is 1005 (no status) and + /// is specified. /// /// /// -or- From 54579df68607834bd994a8a77ba40a276f917954 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 24 Jan 2023 15:32:00 +0900 Subject: [PATCH 4963/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketSessionManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 6df24cb4f..864162003 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -1133,7 +1133,7 @@ public bool PingTo (string message, string id) /// -or- /// /// - /// The current state of the WebSocket connection is not Open. + /// The current state of the WebSocket interface is not Open. /// ///
public void SendTo (byte[] data, string id) From 070087b53106585015b272998f92d6c32afd2f33 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 24 Jan 2023 15:33:44 +0900 Subject: [PATCH 4964/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketSessionManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 864162003..d84d8eeed 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -1188,7 +1188,7 @@ public void SendTo (byte[] data, string id) /// -or- ///
/// - /// The current state of the WebSocket connection is not Open. + /// The current state of the WebSocket interface is not Open. /// ///
public void SendTo (string data, string id) From b14e6ce0373674267269598cb63a8448ad96d799 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 24 Jan 2023 15:37:53 +0900 Subject: [PATCH 4965/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketSessionManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index d84d8eeed..bb83d8449 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -1264,7 +1264,7 @@ public void SendTo (string data, string id) /// -or- /// /// - /// The current state of the WebSocket connection is not Open. + /// The current state of the WebSocket interface is not Open. /// ///
public void SendTo (Stream stream, int length, string id) From ecc6a3df8ba89814c0fbc52e1e21bee52c8c410c Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 25 Jan 2023 16:14:14 +0900 Subject: [PATCH 4966/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketSessionManager.cs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index bb83d8449..c662d00af 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -1281,7 +1281,7 @@ public void SendTo (Stream stream, int length, string id) } /// - /// Sends the specified data asynchronously to the client using + /// Sends the specified data to the client asynchronously using /// the specified session. /// /// @@ -1295,15 +1295,17 @@ public void SendTo (Stream stream, int length, string id) /// /// /// - /// An Action<bool> delegate or - /// if not needed. + /// An delegate. /// /// /// The delegate invokes the method called when the send is complete. /// /// - /// true is passed to the method if the send has done with - /// no error; otherwise, false. + /// The parameter passed to the method is true + /// if the send has successfully done; otherwise, false. + /// + /// + /// if not necessary. /// /// /// @@ -1328,7 +1330,7 @@ public void SendTo (Stream stream, int length, string id) /// -or- /// /// - /// The current state of the WebSocket connection is not Open. + /// The current state of the WebSocket interface is not Open. /// /// public void SendToAsync (byte[] data, string id, Action completed) From c1295b87f2168964c0015c7097ac6e0ba54fe6a3 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 26 Jan 2023 16:04:38 +0900 Subject: [PATCH 4967/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketSessionManager.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index c662d00af..67799a633 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -1281,8 +1281,8 @@ public void SendTo (Stream stream, int length, string id) } /// - /// Sends the specified data to the client asynchronously using - /// the specified session. + /// Sends the specified data to the client using the specified session + /// asynchronously. /// /// /// This method does not wait for the send to be complete. From cb4ba62337b7baa450e6506b59c18cc9197b7649 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 26 Jan 2023 16:11:04 +0900 Subject: [PATCH 4968/6294] [Modify] Edit it --- .../Server/WebSocketSessionManager.cs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 67799a633..1c3dff4f1 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -1347,8 +1347,8 @@ public void SendToAsync (byte[] data, string id, Action completed) } /// - /// Sends the specified data asynchronously to the client using - /// the specified session. + /// Sends the specified data to the client using the specified session + /// asynchronously. /// /// /// This method does not wait for the send to be complete. @@ -1361,15 +1361,17 @@ public void SendToAsync (byte[] data, string id, Action completed) /// /// /// - /// An Action<bool> delegate or - /// if not needed. + /// An delegate. /// /// /// The delegate invokes the method called when the send is complete. /// /// - /// true is passed to the method if the send has done with - /// no error; otherwise, false. + /// The parameter passed to the method is true + /// if the send has successfully done; otherwise, false. + /// + /// + /// if not necessary. /// /// /// @@ -1402,7 +1404,7 @@ public void SendToAsync (byte[] data, string id, Action completed) /// -or- /// /// - /// The current state of the WebSocket connection is not Open. + /// The current state of the WebSocket interface is not Open. /// /// public void SendToAsync (string data, string id, Action completed) From f51ad6e01983a837347150be048c038af0fede81 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 27 Jan 2023 16:28:17 +0900 Subject: [PATCH 4969/6294] [Modify] Edit it --- .../Server/WebSocketSessionManager.cs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 1c3dff4f1..6b8457d2e 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -1421,8 +1421,8 @@ public void SendToAsync (string data, string id, Action completed) } /// - /// Sends the data from the specified stream instance asynchronously to - /// the client using the specified session. + /// Sends the data from the specified stream instance to the client using + /// the specified session asynchronously. /// /// /// This method does not wait for the send to be complete. @@ -1443,15 +1443,17 @@ public void SendToAsync (string data, string id, Action completed) /// /// /// - /// An Action<bool> delegate or - /// if not needed. + /// An delegate. /// /// /// The delegate invokes the method called when the send is complete. /// /// - /// true is passed to the method if the send has done with - /// no error; otherwise, false. + /// The parameter passed to the method is true + /// if the send has successfully done; otherwise, false. + /// + /// + /// if not necessary. /// /// /// @@ -1496,7 +1498,7 @@ public void SendToAsync (string data, string id, Action completed) /// -or- /// /// - /// The current state of the WebSocket connection is not Open. + /// The current state of the WebSocket interface is not Open. /// /// public void SendToAsync ( From e4d498ca6653011b7cb66dcddbe8dd9d056db7cd Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 27 Jan 2023 23:06:55 +0900 Subject: [PATCH 4970/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketSessionManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 6b8457d2e..b44b3acd0 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -626,7 +626,7 @@ public void Broadcast (Stream stream, int length) } if (length < 1) { - var msg = "It is less than 1."; + var msg = "Less than 1."; throw new ArgumentException (msg, "length"); } From 6b1ae57bd8790f8902a96825e8551166ab4d2d58 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 28 Jan 2023 15:48:46 +0900 Subject: [PATCH 4971/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketSessionManager.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index b44b3acd0..c92c96aa4 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -654,8 +654,8 @@ public void Broadcast (Stream stream, int length) } /// - /// Sends the specified data asynchronously to every client in - /// the WebSocket service. + /// Sends the specified data to every client in the WebSocket service + /// asynchronously. /// /// /// This method does not wait for the send to be complete. @@ -665,12 +665,14 @@ public void Broadcast (Stream stream, int length) /// /// /// - /// An delegate or - /// if not needed. + /// An delegate. /// /// /// The delegate invokes the method called when the send is complete. /// + /// + /// if not necessary. + /// /// /// /// The current state of the service is not Start. From 8a93fa65b2cc93f9e56225172d714486083f71a2 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 28 Jan 2023 15:51:58 +0900 Subject: [PATCH 4972/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketSessionManager.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index c92c96aa4..f149d991f 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -698,8 +698,8 @@ public void BroadcastAsync (byte[] data, Action completed) } /// - /// Sends the specified data asynchronously to every client in - /// the WebSocket service. + /// Sends the specified data to every client in the WebSocket service + /// asynchronously. /// /// /// This method does not wait for the send to be complete. @@ -709,12 +709,14 @@ public void BroadcastAsync (byte[] data, Action completed) /// /// /// - /// An delegate or - /// if not needed. + /// An delegate. /// /// /// The delegate invokes the method called when the send is complete. /// + /// + /// if not necessary. + /// /// /// /// The current state of the service is not Start. From 8f45736fad374c476da77a234ac52b4bb9131b63 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 29 Jan 2023 17:30:04 +0900 Subject: [PATCH 4973/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketSessionManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index f149d991f..709d3ebd4 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -820,7 +820,7 @@ public void BroadcastAsync (Stream stream, int length, Action completed) } if (length < 1) { - var msg = "It is less than 1."; + var msg = "Less than 1."; throw new ArgumentException (msg, "length"); } From 77c3f629780ee905dbb145fa1839da0215faf58b Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 29 Jan 2023 17:36:31 +0900 Subject: [PATCH 4974/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketSessionManager.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 709d3ebd4..ff723143e 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -753,8 +753,8 @@ public void BroadcastAsync (string data, Action completed) } /// - /// Sends the data from the specified stream instance asynchronously to - /// every client in the WebSocket service. + /// Sends the data from the specified stream instance to every client in + /// the WebSocket service asynchronously. /// /// /// This method does not wait for the send to be complete. @@ -772,12 +772,14 @@ public void BroadcastAsync (string data, Action completed) /// /// /// - /// An delegate or - /// if not needed. + /// An delegate. /// /// /// The delegate invokes the method called when the send is complete. /// + /// + /// if not necessary. + /// /// /// /// The current state of the service is not Start. From 10a1a7793d20e3e7e1a992338da64f780dfdde8f Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 30 Jan 2023 16:00:48 +0900 Subject: [PATCH 4975/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketSessionManager.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index ff723143e..9d3df38e0 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -419,18 +419,18 @@ private void setSweepTimer (double interval) private void stop (PayloadData payloadData, bool send) { - var bytes = send - ? WebSocketFrame - .CreateCloseFrame (payloadData, false) - .ToArray () - : null; + var rawFrame = send + ? WebSocketFrame + .CreateCloseFrame (payloadData, false) + .ToArray () + : null; lock (_sync) { _state = ServerState.ShuttingDown; _sweepTimer.Enabled = false; foreach (var session in _sessions.Values.ToList ()) - session.WebSocket.Close (payloadData, bytes); + session.WebSocket.Close (payloadData, rawFrame); _state = ServerState.Stop; } From 62577bdd259637e5453049f558ba333839a450d2 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 31 Jan 2023 16:29:08 +0900 Subject: [PATCH 4976/6294] [Modify] Rename it --- websocket-sharp/Server/WebSocketSessionManager.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 9d3df38e0..c4f4b7bd9 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -338,7 +338,7 @@ private void broadcast (Opcode opcode, byte[] data, Action completed) } } - private void broadcast (Opcode opcode, Stream stream, Action completed) + private void broadcast (Opcode opcode, Stream sourceStream, Action completed) { var cache = new Dictionary (); @@ -350,7 +350,7 @@ private void broadcast (Opcode opcode, Stream stream, Action completed) break; } - session.WebSocket.Send (opcode, stream, cache); + session.WebSocket.Send (opcode, sourceStream, cache); } if (completed != null) From 6fed1b47250d7e92e5665afbc8d2878a7d2263d9 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 31 Jan 2023 16:30:17 +0900 Subject: [PATCH 4977/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketSessionManager.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index c4f4b7bd9..dffc244d7 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -338,7 +338,9 @@ private void broadcast (Opcode opcode, byte[] data, Action completed) } } - private void broadcast (Opcode opcode, Stream sourceStream, Action completed) + private void broadcast ( + Opcode opcode, Stream sourceStream, Action completed + ) { var cache = new Dictionary (); From b231420c37b1f06e10cc27cd570cd1aef1e59ac4 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 1 Feb 2023 17:35:19 +0900 Subject: [PATCH 4978/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketSessionManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index dffc244d7..04c6ee1e9 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -318,7 +318,7 @@ private void broadcast (Opcode opcode, byte[] data, Action completed) try { foreach (var session in Sessions) { if (_state != ServerState.Start) { - _log.Error ("The service is shutting down."); + _log.Error ("The send is cancelled."); break; } From c997cbf519dfccf73955a87554ede880221024e7 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 1 Feb 2023 22:53:28 +0900 Subject: [PATCH 4979/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketSessionManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 04c6ee1e9..5357af740 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -347,7 +347,7 @@ private void broadcast ( try { foreach (var session in Sessions) { if (_state != ServerState.Start) { - _log.Error ("The service is shutting down."); + _log.Error ("The send is cancelled."); break; } From f779a64d6b9f630f7d99fe13f364b1e06b7a2d48 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 2 Feb 2023 15:57:55 +0900 Subject: [PATCH 4980/6294] [Modify] Rename it --- websocket-sharp/Server/WebSocketSessionManager.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 5357af740..a0479ec2c 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -377,10 +377,10 @@ private void broadcastAsync (Opcode opcode, byte[] data, Action completed) ); } - private void broadcastAsync (Opcode opcode, Stream stream, Action completed) + private void broadcastAsync (Opcode opcode, Stream sourceStream, Action completed) { ThreadPool.QueueUserWorkItem ( - state => broadcast (opcode, stream, completed) + state => broadcast (opcode, sourceStream, completed) ); } From 91f57ca7fb72c40e64187390c863551e5546c91f Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 2 Feb 2023 15:59:01 +0900 Subject: [PATCH 4981/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketSessionManager.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index a0479ec2c..b530ead35 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -377,7 +377,9 @@ private void broadcastAsync (Opcode opcode, byte[] data, Action completed) ); } - private void broadcastAsync (Opcode opcode, Stream sourceStream, Action completed) + private void broadcastAsync ( + Opcode opcode, Stream sourceStream, Action completed + ) { ThreadPool.QueueUserWorkItem ( state => broadcast (opcode, sourceStream, completed) From b6f210d844f700e19f87f579e1307b0eeba13958 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 3 Feb 2023 17:59:24 +0900 Subject: [PATCH 4982/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketSessionManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index b530ead35..b5910c738 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -293,7 +293,7 @@ public TimeSpan WaitTime { set { if (value <= TimeSpan.Zero) { - var msg = "It is zero or less."; + var msg = "Zero or less."; throw new ArgumentOutOfRangeException ("value", msg); } From d7eda2b2b6754c72817cf9d4c25cfc3ec43cea6f Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 4 Feb 2023 16:01:56 +0900 Subject: [PATCH 4983/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketSessionManager.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index b5910c738..38facf763 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -281,7 +281,8 @@ public IEnumerable Sessions { /// it is shutting down. /// /// - /// A to wait for the response. + /// A that represents the time to wait for + /// the response. /// /// /// The value specified for a set operation is zero or less. From 60ed11127252d274550e4fb5e51f1f8a00a9d547 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 4 Feb 2023 17:32:40 +0900 Subject: [PATCH 4984/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketSessionManager.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 38facf763..ae802ba46 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -277,8 +277,8 @@ public IEnumerable Sessions { /// or Close. /// /// - /// The set operation does nothing if the service has already started or - /// it is shutting down. + /// The set operation works if the current state of the service is + /// Ready or Stop. /// /// /// A that represents the time to wait for From 655c4780b98d26c0a35c2538ca527c42aff264c1 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 5 Feb 2023 17:38:29 +0900 Subject: [PATCH 4985/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketSessionManager.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index ae802ba46..3d256d176 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -273,8 +273,8 @@ public IEnumerable Sessions { } /// - /// Gets or sets the time to wait for the response to the WebSocket Ping - /// or Close. + /// Gets or sets the time to wait for the response to the WebSocket + /// Ping or Close. /// /// /// The set operation works if the current state of the service is From 08e1d5a84d4b2c86258fa1b7bbe34cca77d7e8a8 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 5 Feb 2023 17:41:34 +0900 Subject: [PATCH 4986/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketSessionManager.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 3d256d176..aea32c268 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -224,8 +224,8 @@ public IWebSocketSession this[string id] { /// the WebSocket service are cleaned up periodically. /// /// - /// The set operation does nothing if the service has already started or - /// it is shutting down. + /// The set operation works if the current state of the service is + /// Ready or Stop. /// /// /// true if the inactive sessions are cleaned up every 60 seconds; From 07f9036f3188e53c315cf5e8e7ae01232daafb16 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 6 Feb 2023 17:35:30 +0900 Subject: [PATCH 4987/6294] [Modify] 2023 --- websocket-sharp/Server/WebSocketSessionManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index aea32c268..dccae2937 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -4,7 +4,7 @@ * * The MIT License * - * Copyright (c) 2012-2021 sta.blockhead + * Copyright (c) 2012-2023 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From 21e0766ba25916bed4ed649a704c41150f30f6dc Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 6 Feb 2023 17:42:59 +0900 Subject: [PATCH 4988/6294] [Modify] Edit it --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 27fb489d3..fc3a5bc83 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ websocket-sharp supports: - [HTTP Authentication](#http-authentication) - [Query string, Origin header, and Cookies](#query-string-origin-header-and-cookies) - [Connecting through the HTTP proxy server](#connecting-through-the-http-proxy-server) -- .NET Framework **3.5** or later (includes compatible environment such as [Mono]) +- .NET Framework **3.5** or later versions of .NET Framework (includes compatible environment such as [Mono]) ## Branches ## From de64a5e68dc72df6f4cec632181cd012ef2ea036 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 6 Feb 2023 22:41:48 +0900 Subject: [PATCH 4989/6294] [Modify] Edit it --- README.md | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/README.md b/README.md index fc3a5bc83..a91468c03 100644 --- a/README.md +++ b/README.md @@ -43,25 +43,6 @@ You can add websocket-sharp to your project with the NuGet Package Manager, by u PM> Install-Package WebSocketSharp -Pre -### Unity Asset Store ### - -websocket-sharp is available on the Unity Asset Store (Sorry, Not available now). - -- [WebSocket-Sharp for Unity] - -It works with **Unity Free**, but there are some limitations: - -- [Security Sandbox of the Webplayer] (The server is not available in Web Player) -- [WebGL Networking] (Not available in WebGL) -- Incompatible platform (Not available for such UWP) -- Lack of dll for the System.IO.Compression (The compression extension is not available on Windows) -- .NET Socket Support for iOS/Android (iOS/Android Pro is required if your Unity is earlier than Unity 5) -- .NET API 2.0 compatibility level for iOS/Android - -.NET API 2.0 compatibility level for iOS/Android may require to fix lack of some features for later than .NET Framework 2.0, such as the `System.Func<...>` delegates (so i have added them in the asset package). - -And it is priced at **US$15**. I believe your $15 makes this project more better, **Thank you!** - ## Usage ## ### WebSocket Client ### @@ -688,12 +669,9 @@ websocket-sharp is provided under [The MIT License]. [NuGet Gallery: websocket-sharp]: http://www.nuget.org/packages/WebSocketSharp [Origin]: http://tools.ietf.org/html/rfc6454#section-7 [Query]: http://tools.ietf.org/html/rfc3986#section-3.4 -[Security Sandbox of the Webplayer]: http://docs.unity3d.com/Manual/SecuritySandbox.html [Squid]: http://www.squid-cache.org [The MIT License]: https://raw.github.com/sta/websocket-sharp/master/LICENSE.txt [Unity]: http://unity3d.com -[WebGL Networking]: http://docs.unity3d.com/Manual/webgl-networking.html -[WebSocket-Sharp for Unity]: http://u3d.as/content/sta-blockhead/websocket-sharp-for-unity [api]: http://www.w3.org/TR/websockets [api_ja]: http://www.hcn.zaq.ne.jp/___/WEB/WebSocket-ja.html [context take over]: https://datatracker.ietf.org/doc/html/rfc7692#section-7.1.1 From ae6af406e5e7a202bf32be5ec4a699a312028c09 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 7 Feb 2023 15:59:36 +0900 Subject: [PATCH 4990/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketServiceManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index 787873d1c..4357a113d 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -590,7 +590,7 @@ public bool TryGetServiceHost (string path, out WebSocketServiceHost host) throw new ArgumentException ("An empty string.", "path"); if (path[0] != '/') { - var msg = "It is not an absolute path."; + var msg = "Not an absolute path."; throw new ArgumentException (msg, "path"); } From c28e976c988f22a6e8f92bce8501be56f81d92b4 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 7 Feb 2023 16:06:00 +0900 Subject: [PATCH 4991/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketServiceManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index 4357a113d..1b9172297 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -158,7 +158,7 @@ public WebSocketServiceHost this[string path] { throw new ArgumentException ("An empty string.", "path"); if (path[0] != '/') { - var msg = "It is not an absolute path."; + var msg = "Not an absolute path."; throw new ArgumentException (msg, "path"); } From e79b303c4ae9687aff8d2ea03dc1dc57b966e3ea Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 8 Feb 2023 16:11:19 +0900 Subject: [PATCH 4992/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketServiceManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index 1b9172297..5ac27e3d5 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -257,7 +257,7 @@ public TimeSpan WaitTime { set { if (value <= TimeSpan.Zero) { - var msg = "It is zero or less."; + var msg = "Zero or less."; throw new ArgumentOutOfRangeException ("value", msg); } From e202c076dda06c8301a12b43f3c1a82a39573663 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 8 Feb 2023 16:17:05 +0900 Subject: [PATCH 4993/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServiceManager.cs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index 5ac27e3d5..0e58efe48 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -232,16 +232,17 @@ public IEnumerable Paths { } /// - /// Gets or sets the time to wait for the response to the WebSocket Ping - /// or Close. + /// Gets or sets the time to wait for the response to the WebSocket + /// Ping or Close. /// /// - /// The set operation does nothing if the server has already started or - /// it is shutting down. + /// The set operation works if the current state of the server is + /// Ready or Stop. /// /// /// - /// A to wait for the response. + /// A that represents the time to wait for + /// the response. /// /// /// The default value is the same as 1 second. From 24bc50068c83f48123df804fa6c2bbff9b5eea5a Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 9 Feb 2023 15:45:28 +0900 Subject: [PATCH 4994/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServiceManager.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index 0e58efe48..3d0ef7a1e 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -182,8 +182,8 @@ public WebSocketServiceHost this[string path] { /// the WebSocket services are cleaned up periodically. /// /// - /// The set operation does nothing if the server has already started or - /// it is shutting down. + /// The set operation works if the current state of the server is + /// Ready or Stop. /// /// /// From 2e556d549223e1ce00cf4737befab633688b39b4 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 10 Feb 2023 16:06:18 +0900 Subject: [PATCH 4995/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketServiceManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index 3d0ef7a1e..c937dbe90 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -397,7 +397,7 @@ public void AddService ( throw new ArgumentException ("An empty string.", "path"); if (path[0] != '/') { - var msg = "It is not an absolute path."; + var msg = "Not an absolute path."; throw new ArgumentException (msg, "path"); } From 398c2233092bd853b58454338f0f07731e9bea54 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 10 Feb 2023 16:19:04 +0900 Subject: [PATCH 4996/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServiceManager.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index c937dbe90..0aadbf5aa 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -339,13 +339,15 @@ internal void Stop (ushort code, string reason) /// /// /// - /// An Action<TBehavior> delegate or - /// if not needed. + /// An delegate. /// /// /// The delegate invokes the method called when initializing /// a new session instance for the service. /// + /// + /// if not necessary. + /// /// /// /// From 01c92193e5a1d1e5877e26acb7bd4854ea3d17a8 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 11 Feb 2023 17:24:04 +0900 Subject: [PATCH 4997/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServiceManager.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index 0aadbf5aa..591769853 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -342,8 +342,8 @@ internal void Stop (ushort code, string reason) /// An delegate. /// /// - /// The delegate invokes the method called when initializing - /// a new session instance for the service. + /// The delegate invokes the method called when the service + /// initializes a new session instance. /// /// /// if not necessary. From 46d9424abfe2e85b1bc760bfa19da0bf51e1fa1e Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 11 Feb 2023 17:25:22 +0900 Subject: [PATCH 4998/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServiceManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index 591769853..2932391c0 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -357,7 +357,7 @@ internal void Stop (ushort code, string reason) /// It must inherit the class. /// /// - /// And also, it must have a public parameterless constructor. + /// Also it must have a public parameterless constructor. /// /// /// From ea1023aee1af3976b02d854847cbee58099a277d Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 12 Feb 2023 16:11:49 +0900 Subject: [PATCH 4999/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServiceManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index 2932391c0..afff30dfa 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -326,7 +326,7 @@ internal void Stop (ushort code, string reason) /// /// Adds a WebSocket service with the specified behavior, path, - /// and delegate. + /// and initializer. /// /// /// From 7f4b494ddc807c1c043badc499caea98720f998e Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 12 Feb 2023 16:17:41 +0900 Subject: [PATCH 5000/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketServiceManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index afff30dfa..7e434bbc4 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -509,7 +509,7 @@ public bool RemoveService (string path) throw new ArgumentException ("An empty string.", "path"); if (path[0] != '/') { - var msg = "It is not an absolute path."; + var msg = "Not an absolute path."; throw new ArgumentException (msg, "path"); } From 6ecca4c6966aab019f0fb1e32f2a9038985dd6d4 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 13 Feb 2023 16:12:20 +0900 Subject: [PATCH 5001/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServiceManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index 7e434bbc4..76311a653 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -464,7 +464,7 @@ public void Clear () /// /// /// The service is stopped with close status 1001 (going away) - /// if it has already started. + /// if the current state of the service is Start. /// /// /// true if the service is successfully found and removed; From a16ab8e8d5dfaa91b0a8c60efd12f9e2fc9faa99 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 14 Feb 2023 16:11:40 +0900 Subject: [PATCH 5002/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServiceManager.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index 76311a653..888e183bf 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -440,8 +440,8 @@ public void AddService ( /// Removes all WebSocket services managed by the manager. /// /// - /// A service is stopped with close status 1001 (going away) - /// if it has already started. + /// Each service is stopped with close status 1001 (going away) + /// if the current state of the service is Start. /// public void Clear () { From 4c0cfb3e7a88361dca349681b1fa9890b3928c89 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 15 Feb 2023 15:58:14 +0900 Subject: [PATCH 5003/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServiceManager.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index 888e183bf..da342df09 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -40,8 +40,8 @@ namespace WebSocketSharp.Server /// Provides the management function for the WebSocket services. /// /// - /// This class manages the WebSocket services provided by - /// the or class. + /// This class manages the WebSocket services provided by the + /// or class. /// public class WebSocketServiceManager { From c02edfb27347f81feaa52c16552763e547006fe4 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 15 Feb 2023 16:07:16 +0900 Subject: [PATCH 5004/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketServiceManager.cs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index da342df09..5702f4c22 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -29,10 +29,6 @@ using System; using System.Collections; using System.Collections.Generic; -using System.IO; -using System.Text; -using System.Threading; -using WebSocketSharp.Net; namespace WebSocketSharp.Server { From fcc0f16ade4a82812a5816bba24a6f9ebe9fa15b Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 15 Feb 2023 16:12:38 +0900 Subject: [PATCH 5005/6294] [Modify] 2023 --- websocket-sharp/Server/WebSocketServiceManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index 5702f4c22..12500592c 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -4,7 +4,7 @@ * * The MIT License * - * Copyright (c) 2012-2021 sta.blockhead + * Copyright (c) 2012-2023 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From 2aa09edc83ad4dbfec6af599c8243983e7a9b2dc Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 16 Feb 2023 15:39:35 +0900 Subject: [PATCH 5006/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServiceHost.cs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceHost.cs b/websocket-sharp/Server/WebSocketServiceHost.cs index dd138bc3f..0fdbe924e 100644 --- a/websocket-sharp/Server/WebSocketServiceHost.cs +++ b/websocket-sharp/Server/WebSocketServiceHost.cs @@ -166,15 +166,16 @@ public WebSocketSessionManager Sessions { public abstract Type BehaviorType { get; } /// - /// Gets or sets the time to wait for the response to the WebSocket Ping - /// or Close. + /// Gets or sets the time to wait for the response to the WebSocket + /// Ping or Close. /// /// - /// The set operation does nothing if the service has already started or - /// it is shutting down. + /// The set operation works if the current state of the service is + /// Ready or Stop. /// /// - /// A to wait for the response. + /// A that represents the time to wait for + /// the response. /// /// /// The value specified for a set operation is zero or less. From ce8a6e78637cf38da90cb57f325ed9f235466d4f Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 16 Feb 2023 15:48:24 +0900 Subject: [PATCH 5007/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServiceHost.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceHost.cs b/websocket-sharp/Server/WebSocketServiceHost.cs index 0fdbe924e..f8f11d1b2 100644 --- a/websocket-sharp/Server/WebSocketServiceHost.cs +++ b/websocket-sharp/Server/WebSocketServiceHost.cs @@ -109,12 +109,12 @@ protected Logger Log { #region Public Properties /// - /// Gets or sets a value indicating whether the service cleans up the - /// inactive sessions periodically. + /// Gets or sets a value indicating whether the service cleans up + /// the inactive sessions periodically. /// /// - /// The set operation does nothing if the service has already started or - /// it is shutting down. + /// The set operation works if the current state of the service is + /// Ready or Stop. /// /// /// true if the service cleans up the inactive sessions every From 5d0c1b3ffc3c705d3ace3c337eb58e204f0cd6e1 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 17 Feb 2023 16:14:11 +0900 Subject: [PATCH 5008/6294] [Modify] 2023 --- websocket-sharp/Server/WebSocketServiceHost.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServiceHost.cs b/websocket-sharp/Server/WebSocketServiceHost.cs index f8f11d1b2..ee20d92a9 100644 --- a/websocket-sharp/Server/WebSocketServiceHost.cs +++ b/websocket-sharp/Server/WebSocketServiceHost.cs @@ -4,7 +4,7 @@ * * The MIT License * - * Copyright (c) 2012-2021 sta.blockhead + * Copyright (c) 2012-2023 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From 47fc11c02b2fb284ea489840a2688ef5a32d70b7 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 17 Feb 2023 16:18:17 +0900 Subject: [PATCH 5009/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 5fdc0027d..88f684929 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -1022,7 +1022,7 @@ private static bool tryCreateUri ( /// It must inherit the class. /// /// - /// And also, it must have a public parameterless constructor. + /// Also it must have a public parameterless constructor. /// /// /// From 37be6e021e39413e319cad2ad90ae9f221afe30c Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 18 Feb 2023 16:19:26 +0900 Subject: [PATCH 5010/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 88f684929..06d0e4ca0 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -1060,7 +1060,7 @@ public void AddWebSocketService (string path) /// /// Adds a WebSocket service with the specified behavior, path, - /// and delegate. + /// and initializer. /// /// /// @@ -1073,12 +1073,14 @@ public void AddWebSocketService (string path) /// /// /// - /// An Action<TBehavior> delegate or - /// if not needed. + /// An delegate. + /// + /// + /// The delegate invokes the method called when the service + /// initializes a new session instance. /// /// - /// The delegate invokes the method called when initializing - /// a new session instance for the service. + /// if not necessary. /// /// /// @@ -1089,7 +1091,7 @@ public void AddWebSocketService (string path) /// It must inherit the class. /// /// - /// And also, it must have a public parameterless constructor. + /// Also it must have a public parameterless constructor. /// /// /// From 94d658eb3b5075d4a6a01901e93cc2c1b1804e48 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 18 Feb 2023 16:58:12 +0900 Subject: [PATCH 5011/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 06d0e4ca0..0423eb9c8 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -1134,7 +1134,7 @@ public void AddWebSocketService ( /// /// /// The service is stopped with close status 1001 (going away) - /// if it has already started. + /// if the current state of the service is Start. /// /// /// true if the service is successfully found and removed; From 8fb7081a30086f7755fcbe0a4f9b1bd7003af958 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 19 Feb 2023 16:12:14 +0900 Subject: [PATCH 5012/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 0423eb9c8..fceef6a35 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -1179,8 +1179,7 @@ public bool RemoveWebSocketService (string path) /// Starts receiving incoming handshake requests. /// /// - /// This method does nothing if the server has already started or - /// it is shutting down. + /// This method works if the current state of the server is Ready or Stop. /// /// /// From a7dcf7ef80ef2e4deb1f2e7ec4ab5512af99d7cc Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 19 Feb 2023 16:15:22 +0900 Subject: [PATCH 5013/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index fceef6a35..30de63e16 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -1204,8 +1204,7 @@ public void Start () /// Stops receiving incoming handshake requests. /// /// - /// This method does nothing if the server is not started, - /// it is shutting down, or it has already stopped. + /// This method works if the current state of the server is Start. /// public void Stop () { From 590213d5087af14b554f390d2131220976d49f65 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 20 Feb 2023 14:52:05 +0900 Subject: [PATCH 5014/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 30de63e16..e84d87f97 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -629,12 +629,13 @@ public Func UserCredentialsFinder { /// Ping or Close. /// /// - /// The set operation does nothing if the server has already started or - /// it is shutting down. + /// The set operation works if the current state of the server is + /// Ready or Stop. /// /// /// - /// A to wait for the response. + /// A that represents the time to wait for + /// the response. /// /// /// The default value is the same as 1 second. From 3886739cbb8b3a0dd4668954abfa87d0eedd0f1b Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 21 Feb 2023 17:03:26 +0900 Subject: [PATCH 5015/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index e84d87f97..950d90917 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -581,31 +581,31 @@ public ServerSslConfiguration SslConfiguration { } /// - /// Gets or sets the delegate used to find the credentials for - /// an identity. + /// Gets or sets the delegate used to find the credentials for an identity. /// /// /// - /// No credentials are found if the method invoked by - /// the delegate returns or - /// the value is . + /// No credentials are found if the method invoked by the delegate + /// returns or the value is . /// /// - /// The set operation does nothing if the server has - /// already started or it is shutting down. + /// The set operation works if the current state of the server is + /// Ready or Stop. /// /// /// /// - /// A Func<, - /// > delegate or - /// if not needed. + /// A + /// delegate. /// /// - /// The delegate invokes the method called for finding + /// The delegate invokes the method called when the server finds /// the credentials used to authenticate a client. /// /// + /// if not necessary. + /// + /// /// The default value is . /// /// From 185764e9de8c000e19ae044c9c5a495aefb48766 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 22 Feb 2023 16:05:35 +0900 Subject: [PATCH 5016/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 950d90917..2e3b8970a 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -584,14 +584,8 @@ public ServerSslConfiguration SslConfiguration { /// Gets or sets the delegate used to find the credentials for an identity. /// /// - /// - /// No credentials are found if the method invoked by the delegate - /// returns or the value is . - /// - /// - /// The set operation works if the current state of the server is - /// Ready or Stop. - /// + /// The set operation works if the current state of the server is + /// Ready or Stop. /// /// /// @@ -603,6 +597,10 @@ public ServerSslConfiguration SslConfiguration { /// the credentials used to authenticate a client. /// /// + /// The method must return if the credentials + /// are not found. + /// + /// /// if not necessary. /// /// From f53bbd76a6c312f92c4de4306e114602622efa3f Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 22 Feb 2023 16:11:42 +0900 Subject: [PATCH 5017/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 2e3b8970a..7a026a667 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -425,12 +425,12 @@ public bool IsSecure { } /// - /// Gets or sets a value indicating whether the server cleans up the - /// inactive sessions periodically. + /// Gets or sets a value indicating whether the server cleans up + /// the inactive sessions periodically. /// /// - /// The set operation does nothing if the server has already started or - /// it is shutting down. + /// The set operation works if the current state of the server is + /// Ready or Stop. /// /// /// From e4148127368ed56448d94fa56889b56767756c18 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 23 Feb 2023 15:42:17 +0900 Subject: [PATCH 5018/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 7a026a667..19b8806fb 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -412,7 +412,7 @@ public bool IsListening { } /// - /// Gets a value indicating whether secure connections are provided. + /// Gets a value indicating whether the server provides secure connections. /// /// /// true if the server provides secure connections; otherwise, From 9ca9df18a59c1ebd118b593463923894811724ef Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 23 Feb 2023 15:45:52 +0900 Subject: [PATCH 5019/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 19b8806fb..62f549602 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -368,8 +368,8 @@ public bool AllowForwardedRequest { /// Gets or sets the scheme used to authenticate the clients. /// /// - /// The set operation does nothing if the server has already started or - /// it is shutting down. + /// The set operation works if the current state of the server is + /// Ready or Stop. /// /// /// From 3c82af1494dee4ec3274a08f67d57c3538921823 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 24 Feb 2023 16:06:20 +0900 Subject: [PATCH 5020/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 62f549602..e1e5996d5 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -337,8 +337,8 @@ public System.Net.IPAddress Address { /// handshake request without checking the request URI. /// /// - /// The set operation does nothing if the server has already started or - /// it is shutting down. + /// The set operation works if the current state of the server is + /// Ready or Stop. /// /// /// From 3d9db64569326add4fc6a969135a4821b011b404 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 24 Feb 2023 16:16:04 +0900 Subject: [PATCH 5021/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketServer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index e1e5996d5..4feb91e03 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -221,7 +221,7 @@ public WebSocketServer (string url) public WebSocketServer (int port, bool secure) { if (!port.IsPortNumber ()) { - var msg = "It is less than 1 or greater than 65535."; + var msg = "Less than 1 or greater than 65535."; throw new ArgumentOutOfRangeException ("port", msg); } From 60326682cfa7f354429fe25bbe6d93e67bcfda0d Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 25 Feb 2023 16:17:16 +0900 Subject: [PATCH 5022/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketServer.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 4feb91e03..a4c94af2e 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -301,13 +301,13 @@ public WebSocketServer (System.Net.IPAddress address, int port, bool secure) throw new ArgumentNullException ("address"); if (!address.IsLocal ()) { - var msg = "It is not a local IP address."; + var msg = "Not a local IP address."; throw new ArgumentException (msg, "address"); } if (!port.IsPortNumber ()) { - var msg = "It is less than 1 or greater than 65535."; + var msg = "Less than 1 or greater than 65535."; throw new ArgumentOutOfRangeException ("port", msg); } From 4418943e93c8722ad07fbcd0c6699c1e9d6e5c15 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 26 Feb 2023 16:23:09 +0900 Subject: [PATCH 5023/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketServer.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index a4c94af2e..14b4e0654 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -956,7 +956,9 @@ private void stop (ushort code, string reason) } try { - stopReceiving (5000); + var timeout = 5000; + + stopReceiving (timeout); } catch (Exception ex) { _log.Fatal (ex.Message); From 3c5657a9299d32f327f98de05934f2c72a46c096 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 27 Feb 2023 22:19:44 +0900 Subject: [PATCH 5024/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketServer.cs | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 14b4e0654..f08ee8a8d 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -846,11 +846,8 @@ private void receiveRequest () ); } catch (SocketException ex) { - if (_state == ServerState.ShuttingDown) { - _log.Info ("The underlying listener is stopped."); - + if (_state == ServerState.ShuttingDown) return; - } _log.Fatal (ex.Message); _log.Debug (ex.ToString ()); @@ -858,11 +855,8 @@ private void receiveRequest () break; } catch (InvalidOperationException ex) { - if (_state == ServerState.ShuttingDown) { - _log.Info ("The underlying listener is stopped."); - + if (_state == ServerState.ShuttingDown) return; - } _log.Fatal (ex.Message); _log.Debug (ex.ToString ()); From 0127cdb492df1eef3a36a4b56f895e9acc865e34 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 28 Feb 2023 16:06:54 +0900 Subject: [PATCH 5025/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index f08ee8a8d..2d3a7b1fd 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -483,19 +483,16 @@ public int Port { /// Gets or sets the name of the realm associated with the server. /// /// - /// - /// "SECRET AREA" is used as the name of the realm if the value is - /// or an empty string. - /// - /// - /// The set operation does nothing if the server has already started - /// or it is shutting down. - /// + /// The set operation works if the current state of the server is + /// Ready or Stop. /// /// /// - /// A that represents the name of the realm or - /// . + /// A that represents the name of the realm. + /// + /// + /// "SECRET AREA" is used as the name of the realm if the value is + /// or an empty string. /// /// /// The default value is . From f9c20ed6fb4c91a37812f92c5c49126c9ce9da33 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 1 Mar 2023 17:27:32 +0900 Subject: [PATCH 5026/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 2d3a7b1fd..4e915c2f1 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -523,8 +523,8 @@ public string Realm { /// resolve to wait for socket in TIME_WAIT state. /// /// - /// The set operation does nothing if the server has already started - /// or it is shutting down. + /// The set operation works if the current state of the server is + /// Ready or Stop. /// /// /// From 14014b73eee85d0bf6943919729535f69afd54c1 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 2 Mar 2023 15:49:05 +0900 Subject: [PATCH 5027/6294] [Modify] 2023 --- websocket-sharp/Server/WebSocketServer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 4e915c2f1..f4b336206 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -4,7 +4,7 @@ * * The MIT License * - * Copyright (c) 2012-2022 sta.blockhead + * Copyright (c) 2012-2023 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From 1ab2d8600638b2da68d2c67667c5aa081e1705dc Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 2 Mar 2023 15:56:42 +0900 Subject: [PATCH 5028/6294] [Modify] Edit it --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a91468c03..d0997ee80 100644 --- a/README.md +++ b/README.md @@ -59,7 +59,7 @@ namespace Example { using (var ws = new WebSocket ("ws://dragonsnest.far/Laputa")) { ws.OnMessage += (sender, e) => - Console.WriteLine ("Laputa says: " + e.Data); + Console.WriteLine ("Laputa says: " + e.Data); ws.Connect (); ws.Send ("BALUS"); From d53aa1fcdf20ea6453a69f5a6d2d1369a949e835 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 2 Mar 2023 16:03:13 +0900 Subject: [PATCH 5029/6294] [Modify] Edit it --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index d0997ee80..4b8ff965d 100644 --- a/README.md +++ b/README.md @@ -108,8 +108,8 @@ This event occurs when the WebSocket connection has been established. ```csharp ws.OnOpen += (sender, e) => { - ... - }; + ... + }; ``` `System.EventArgs.Empty` is passed as `e`, so you do not need to use it. From e60f2babc299c5a1dcafbbca0e127cbf85e38b68 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 3 Mar 2023 16:10:09 +0900 Subject: [PATCH 5030/6294] [Modify] Edit it --- README.md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 4b8ff965d..c82f3237c 100644 --- a/README.md +++ b/README.md @@ -116,12 +116,12 @@ ws.OnOpen += (sender, e) => { ##### WebSocket.OnMessage Event ##### -This event occurs when the `WebSocket` receives a message. +This event occurs when the `WebSocket` instance receives a message. ```csharp ws.OnMessage += (sender, e) => { - ... - }; + ... + }; ``` A `WebSocketSharp.MessageEventArgs` instance is passed as `e`. @@ -153,13 +153,13 @@ And if you would like to notify that a **ping** has been received, via this even ```csharp ws.EmitOnPing = true; ws.OnMessage += (sender, e) => { - if (e.IsPing) { - // Do something to notify that a ping has been received. - ... + if (e.IsPing) { + // Do something to notify that a ping has been received. + ... - return; - } - }; + return; + } + }; ``` ##### WebSocket.OnError Event ##### From 8065141b533eeff2bfc2754372860fca490a4ff0 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 3 Mar 2023 16:15:00 +0900 Subject: [PATCH 5031/6294] [Modify] Edit it --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index c82f3237c..9b1a047d0 100644 --- a/README.md +++ b/README.md @@ -164,12 +164,12 @@ ws.OnMessage += (sender, e) => { ##### WebSocket.OnError Event ##### -This event occurs when the `WebSocket` gets an error. +This event occurs when the `WebSocket` instance gets an error. ```csharp ws.OnError += (sender, e) => { - ... - }; + ... + }; ``` A `WebSocketSharp.ErrorEventArgs` instance is passed as `e`. From 198a6a62216edbf72555d4eb8bd7b9e83bfef553 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 4 Mar 2023 16:15:26 +0900 Subject: [PATCH 5032/6294] [Modify] Edit it --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 9b1a047d0..6271d3b22 100644 --- a/README.md +++ b/README.md @@ -186,8 +186,8 @@ This event occurs when the WebSocket connection has been closed. ```csharp ws.OnClose += (sender, e) => { - ... - }; + ... + }; ``` A `WebSocketSharp.CloseEventArgs` instance is passed as `e`. From 2477b87601ef22b5671e3f861e674c6437e3feeb Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 5 Mar 2023 15:27:30 +0900 Subject: [PATCH 5033/6294] [Modify] Edit it --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 6271d3b22..5c99ed80e 100644 --- a/README.md +++ b/README.md @@ -218,7 +218,7 @@ ws.Send (data); The `WebSocket.Send` method is overloaded. -You can use the `WebSocket.Send (string)`, `WebSocket.Send (byte[])`, or `WebSocket.Send (System.IO.FileInfo)` method to send the data. +You can use the `WebSocket.Send (string)`, `WebSocket.Send (byte[])`, `WebSocket.Send (System.IO.FileInfo)`, or `WebSocket.Send (System.IO.Stream, int)` method to send the data. If you would like to send the data asynchronously, you should use the `WebSocket.SendAsync` method. From 1284df932e955bec938229859c0f81063956b073 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 6 Mar 2023 16:00:20 +0900 Subject: [PATCH 5034/6294] [Modify] Edit it --- websocket-sharp/Server/HttpServer.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 82284f8f3..428f5bde6 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -1318,8 +1318,7 @@ public void Start () /// Stops receiving incoming requests. /// /// - /// This method does nothing if the server is not started, - /// it is shutting down, or it has already stopped. + /// This method works if the current state of the server is Start. /// public void Stop () { From 96399d5680457440108afb5c1ede06c79d83bd0e Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 6 Mar 2023 16:02:41 +0900 Subject: [PATCH 5035/6294] [Modify] Edit it --- websocket-sharp/Server/HttpServer.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 428f5bde6..bcc05d92d 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -1292,8 +1292,7 @@ public bool RemoveWebSocketService (string path) /// Starts receiving incoming requests. /// /// - /// This method does nothing if the server has already started or - /// it is shutting down. + /// This method works if the current state of the server is Ready or Stop. /// /// /// From e49af3e56b323ffd93145e52979922720408bf72 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 7 Mar 2023 15:40:48 +0900 Subject: [PATCH 5036/6294] [Modify] Edit it --- websocket-sharp/Server/HttpServer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index bcc05d92d..5aa874fb6 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -1137,7 +1137,7 @@ private static bool tryCreateUri ( /// It must inherit the class. /// /// - /// And also, it must have a public parameterless constructor. + /// Also it must have a public parameterless constructor. /// /// /// From 9874c3d9ca19a5561e48b6131994bd7fd7d5f8f7 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 7 Mar 2023 15:48:26 +0900 Subject: [PATCH 5037/6294] [Modify] Edit it --- websocket-sharp/Server/HttpServer.cs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 5aa874fb6..df6520ee4 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -1175,7 +1175,7 @@ public void AddWebSocketService (string path) /// /// Adds a WebSocket service with the specified behavior, path, - /// and delegate. + /// and initializer. /// /// /// @@ -1188,12 +1188,14 @@ public void AddWebSocketService (string path) /// /// /// - /// An Action<TBehavior> delegate or - /// if not needed. + /// An delegate. + /// + /// + /// The delegate invokes the method called when the service + /// initializes a new session instance. /// /// - /// The delegate invokes the method called when initializing - /// a new session instance for the service. + /// if not necessary. /// /// /// @@ -1204,7 +1206,7 @@ public void AddWebSocketService (string path) /// It must inherit the class. /// /// - /// And also, it must have a public parameterless constructor. + /// Also it must have a public parameterless constructor. /// /// /// From 2a88f3e919e64ca412e1114057e6b657c1573a80 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 8 Mar 2023 16:10:58 +0900 Subject: [PATCH 5038/6294] [Modify] Edit it --- websocket-sharp/Server/HttpServer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index df6520ee4..8519ca4ef 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -1249,7 +1249,7 @@ public void AddWebSocketService ( /// /// /// The service is stopped with close status 1001 (going away) - /// if it has already started. + /// if the current state of the service is Start. /// /// /// true if the service is successfully found and removed; From f358f84f336e71455f6d36349fc5e4ee3ee68d8b Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 8 Mar 2023 16:23:48 +0900 Subject: [PATCH 5039/6294] [Modify] Polish it --- websocket-sharp/Server/HttpServer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 8519ca4ef..e82a6d655 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -210,7 +210,7 @@ public HttpServer (string url) public HttpServer (int port, bool secure) { if (!port.IsPortNumber ()) { - var msg = "It is less than 1 or greater than 65535."; + var msg = "Less than 1 or greater than 65535."; throw new ArgumentOutOfRangeException ("port", msg); } From e59a5dea08d4ef81ffbff66e1fdb061d44b74df6 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 9 Mar 2023 15:38:16 +0900 Subject: [PATCH 5040/6294] [Modify] Polish it --- websocket-sharp/Server/HttpServer.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index e82a6d655..752fda9fc 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -288,13 +288,13 @@ public HttpServer (System.Net.IPAddress address, int port, bool secure) throw new ArgumentNullException ("address"); if (!address.IsLocal ()) { - var msg = "It is not a local IP address."; + var msg = "Not a local IP address."; throw new ArgumentException (msg, "address"); } if (!port.IsPortNumber ()) { - var msg = "It is less than 1 or greater than 65535."; + var msg = "Less than 1 or greater than 65535."; throw new ArgumentOutOfRangeException ("port", msg); } From a1b87c7dca040852317776b557bbf3afbc911dd3 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 9 Mar 2023 15:43:55 +0900 Subject: [PATCH 5041/6294] [Modify] Edit it --- websocket-sharp/Server/HttpServer.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 752fda9fc..ebd0c1bda 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -674,12 +674,13 @@ public Func UserCredentialsFinder { /// Ping or Close. /// /// - /// The set operation does nothing if the server has already started or - /// it is shutting down. + /// The set operation works if the current state of the server is + /// Ready or Stop. /// /// /// - /// A to wait for the response. + /// A that represents the time to wait for + /// the response. /// /// /// The default value is the same as 1 second. From d8979e9e67a36f95a79dce56cf59e5d3e6408be3 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 10 Mar 2023 16:53:36 +0900 Subject: [PATCH 5042/6294] [Modify] Edit it --- websocket-sharp/Server/HttpServer.cs | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index ebd0c1bda..6671bd7fc 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -626,29 +626,27 @@ public ServerSslConfiguration SslConfiguration { } /// - /// Gets or sets the delegate used to find the credentials for - /// an identity. + /// Gets or sets the delegate used to find the credentials for an identity. /// /// + /// The set operation works if the current state of the server is + /// Ready or Stop. + /// + /// /// - /// No credentials are found if the method invoked by - /// the delegate returns or - /// the value is . + /// A + /// delegate. /// /// - /// The set operation does nothing if the server has - /// already started or it is shutting down. + /// The delegate invokes the method called when the server finds + /// the credentials used to authenticate a client. /// - /// - /// /// - /// A Func<, - /// > delegate or - /// if not needed. + /// The method must return if the credentials + /// are not found. /// /// - /// The delegate invokes the method called for finding - /// the credentials used to authenticate a client. + /// if not necessary. /// /// /// The default value is . From be9f74f1e48e02e655bb8fdc1840efa329232792 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 10 Mar 2023 16:56:32 +0900 Subject: [PATCH 5043/6294] [Modify] Edit it --- websocket-sharp/Server/HttpServer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 6671bd7fc..56aee5ec5 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -611,7 +611,7 @@ public bool ReuseAddress { /// the configuration used to provide secure connections. /// /// - /// This server does not provide secure connections. + /// The server does not provide secure connections. /// public ServerSslConfiguration SslConfiguration { get { From be304898ff78826f856850d2b255073690e11566 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 11 Mar 2023 17:04:06 +0900 Subject: [PATCH 5044/6294] [Modify] Edit it --- websocket-sharp/Server/HttpServer.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 56aee5ec5..cdb558eae 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -571,8 +571,8 @@ public string Realm { /// resolve to wait for socket in TIME_WAIT state. /// /// - /// The set operation does nothing if the server has already started - /// or it is shutting down. + /// The set operation works if the current state of the server is + /// Ready or Stop. /// /// /// From 2ce85212060446b23c6331eb4224f1a04ae763bc Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 11 Mar 2023 17:08:15 +0900 Subject: [PATCH 5045/6294] [Modify] Edit it --- websocket-sharp/Server/HttpServer.cs | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index cdb558eae..e21889295 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -528,19 +528,16 @@ public int Port { /// Gets or sets the name of the realm associated with the server. /// /// - /// - /// "SECRET AREA" is used as the name of the realm if the value is - /// or an empty string. - /// - /// - /// The set operation does nothing if the server has already started - /// or it is shutting down. - /// + /// The set operation works if the current state of the server is + /// Ready or Stop. /// /// /// - /// A that represents the name of the realm or - /// . + /// A that represents the name of the realm. + /// + /// + /// "SECRET AREA" is used as the name of the realm if the value is + /// or an empty string. /// /// /// The default value is . From 97976b027d22787d7659d04e2d767ece3e9e4afe Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 12 Mar 2023 17:05:21 +0900 Subject: [PATCH 5046/6294] [Modify] Edit it --- websocket-sharp/Server/HttpServer.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index e21889295..01746cc25 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -470,17 +470,17 @@ public bool IsSecure { } /// - /// Gets or sets a value indicating whether the server cleans up the - /// inactive sessions periodically. + /// Gets or sets a value indicating whether the server cleans up + /// the inactive sessions periodically. /// /// - /// The set operation does nothing if the server has already started or - /// it is shutting down. + /// The set operation works if the current state of the server is + /// Ready or Stop. /// /// /// - /// true if the server cleans up the inactive sessions every - /// 60 seconds; otherwise, false. + /// true if the server cleans up the inactive sessions + /// every 60 seconds; otherwise, false. /// /// /// The default value is true. From 96255aa313b1b711fa09c5e8087c8a3fc22858b5 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 13 Mar 2023 22:07:56 +0900 Subject: [PATCH 5047/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index f4b336206..0a5254b2d 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -434,8 +434,8 @@ public bool IsSecure { /// /// /// - /// true if the server cleans up the inactive sessions every - /// 60 seconds; otherwise, false. + /// true if the server cleans up the inactive sessions + /// every 60 seconds; otherwise, false. /// /// /// The default value is true. From d4b00378e21ce2b891201cd5c5ae6d2b09699943 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 13 Mar 2023 22:09:55 +0900 Subject: [PATCH 5048/6294] [Modify] Edit it --- websocket-sharp/Server/HttpServer.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 01746cc25..ddfb316fc 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -457,10 +457,10 @@ public bool IsListening { } /// - /// Gets a value indicating whether secure connections are provided. + /// Gets a value indicating whether the server provides secure connections. /// /// - /// true if this instance provides secure connections; otherwise, + /// true if the server provides secure connections; otherwise, /// false. /// public bool IsSecure { From 7743ba24c4af1df903b92e9853d0db4e891de49d Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 14 Mar 2023 16:21:49 +0900 Subject: [PATCH 5049/6294] [Modify] Edit it --- websocket-sharp/Server/HttpServer.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index ddfb316fc..6143d9163 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -359,11 +359,11 @@ public AuthenticationSchemes AuthenticationSchemes { /// /// /// - /// '/' or '\' is trimmed from the end of the value if any. + /// '/' or '\' is trimmed from the end of the value if present. /// /// - /// The set operation does nothing if the server has already - /// started or it is shutting down. + /// The set operation works if the current state of the server is + /// Ready or Stop. /// /// /// From a3d79c0256a38302be6c0b19575360d8d0263053 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 15 Mar 2023 17:01:40 +0900 Subject: [PATCH 5050/6294] [Modify] Edit it --- websocket-sharp/Server/HttpServer.cs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 6143d9163..ddd2cb298 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -358,13 +358,8 @@ public AuthenticationSchemes AuthenticationSchemes { /// Gets or sets the path to the document folder of the server. /// /// - /// - /// '/' or '\' is trimmed from the end of the value if present. - /// - /// - /// The set operation works if the current state of the server is - /// Ready or Stop. - /// + /// The set operation works if the current state of the server is + /// Ready or Stop. /// /// /// @@ -372,6 +367,9 @@ public AuthenticationSchemes AuthenticationSchemes { /// from which to find the requested file. /// /// + /// '/' or '\' is trimmed from the end of the value if present. + /// + /// /// The default value is "./Public". /// /// From c59ff1c450dc26f8544aad3bae831e45f1bae574 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 15 Mar 2023 17:07:41 +0900 Subject: [PATCH 5051/6294] [Modify] Edit it --- websocket-sharp/Server/HttpServer.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index ddd2cb298..7f3d3ff3d 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -323,8 +323,8 @@ public System.Net.IPAddress Address { /// Gets or sets the scheme used to authenticate the clients. /// /// - /// The set operation does nothing if the server has already started or - /// it is shutting down. + /// The set operation works if the current state of the server is + /// Ready or Stop. /// /// /// From 54c6dc8f20bb9bb2c2c53b28cd324c9aab3dd240 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 16 Mar 2023 16:01:09 +0900 Subject: [PATCH 5052/6294] [Modify] Polish it --- websocket-sharp/Server/HttpServer.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 7f3d3ff3d..eef6801d5 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -1038,7 +1038,9 @@ private void stop (ushort code, string reason) } try { - stopReceiving (5000); + var timeout = 5000; + + stopReceiving (timeout); } catch (Exception ex) { _log.Fatal (ex.Message); From 2ab30219acd4e226977a40ebe9f6997c77324c2f Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 16 Mar 2023 16:09:03 +0900 Subject: [PATCH 5053/6294] [Modify] Polish it --- websocket-sharp/Server/HttpServer.cs | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index eef6801d5..d2ffa2a60 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -934,11 +934,8 @@ private void receiveRequest () ); } catch (HttpListenerException ex) { - if (_state == ServerState.ShuttingDown) { - _log.Info ("The underlying listener is stopped."); - + if (_state == ServerState.ShuttingDown) return; - } _log.Fatal (ex.Message); _log.Debug (ex.ToString ()); @@ -946,11 +943,8 @@ private void receiveRequest () break; } catch (InvalidOperationException ex) { - if (_state == ServerState.ShuttingDown) { - _log.Info ("The underlying listener is stopped."); - + if (_state == ServerState.ShuttingDown) return; - } _log.Fatal (ex.Message); _log.Debug (ex.ToString ()); From bf0185a24e9219e1ec99d017517749cc264ad9db Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 17 Mar 2023 16:08:11 +0900 Subject: [PATCH 5054/6294] [Modify] Edit it --- websocket-sharp/Server/HttpServer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index d2ffa2a60..52e2896dc 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -57,7 +57,7 @@ namespace WebSocketSharp.Server /// The server supports HTTP/1.1 version request and response. /// /// - /// And the server allows to accept WebSocket handshake requests. + /// Also the server allows to accept WebSocket handshake requests. /// /// /// This class can provide multiple WebSocket services. From e47048212f4e336d8e712b736562b080666fc54a Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 18 Mar 2023 17:48:42 +0900 Subject: [PATCH 5055/6294] [Modify] 2023 --- websocket-sharp/Server/HttpServer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 52e2896dc..cdd31540e 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -4,7 +4,7 @@ * * The MIT License * - * Copyright (c) 2012-2022 sta.blockhead + * Copyright (c) 2012-2023 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From 0c286021ba5e273f995d49d4e73bb10a12f3818c Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 19 Mar 2023 16:01:48 +0900 Subject: [PATCH 5056/6294] [Modify] Add it --- websocket-sharp/Server/WebSocketBehavior.cs | 44 +++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 1b458271c..1e8860861 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -50,6 +50,7 @@ public abstract class WebSocketBehavior : IWebSocketSession private WebSocketContext _context; private Func _cookiesValidator; private bool _emitOnPing; + private Func _hostValidator; private string _id; private bool _ignoreExtensions; private Func _originValidator; @@ -315,6 +316,41 @@ public bool EmitOnPing { } } + /// + /// Gets or sets the delegate used to validate the Host header. + /// + /// + /// + /// A delegate. + /// + /// + /// The delegate invokes the method called when the WebSocket interface + /// for a session validates the handshake request. + /// + /// + /// The parameter passed to the method is the value + /// of the Host header. + /// + /// + /// The method must return true if the header value is valid. + /// + /// + /// if not necessary. + /// + /// + /// The default value is . + /// + /// + public Func HostValidator { + get { + return _hostValidator; + } + + set { + _hostValidator = value; + } + } + /// /// Gets the unique ID of a session. /// @@ -467,6 +503,14 @@ public DateTime StartTime { private string checkHandshakeRequest (WebSocketContext context) { + if (_hostValidator != null) { + if (!_hostValidator (context.Host)) { + var msg = "The Host header is invalid."; + + return msg; + } + } + if (_originValidator != null) { if (!_originValidator (context.Origin)) { var msg = "The Origin header is non-existent or invalid."; From 1162fe36703dfae658cb242d0f9971fbcc3066ff Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 20 Mar 2023 21:38:35 +0900 Subject: [PATCH 5057/6294] [Modify] Remove the AllowForwardedRequest property --- websocket-sharp/Server/WebSocketServer.cs | 47 ++--------------------- 1 file changed, 3 insertions(+), 44 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 0a5254b2d..4c1bb5423 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -59,7 +59,6 @@ public class WebSocketServer #region Private Fields private System.Net.IPAddress _address; - private bool _allowForwardedRequest; private AuthenticationSchemes _authSchemes; private static readonly string _defaultRealm; private bool _dnsStyle; @@ -332,38 +331,6 @@ public System.Net.IPAddress Address { } } - /// - /// Gets or sets a value indicating whether the server accepts every - /// handshake request without checking the request URI. - /// - /// - /// The set operation works if the current state of the server is - /// Ready or Stop. - /// - /// - /// - /// true if the server accepts every handshake request without - /// checking the request URI; otherwise, false. - /// - /// - /// The default value is false. - /// - /// - public bool AllowForwardedRequest { - get { - return _allowForwardedRequest; - } - - set { - lock (_sync) { - if (!canSet ()) - return; - - _allowForwardedRequest = value; - } - } - } - /// /// Gets or sets the scheme used to authenticate the clients. /// @@ -786,18 +753,10 @@ private void processRequest (TcpListenerWebSocketContext context) return; } - if (!_allowForwardedRequest) { - if (uri.Port != _port) { - context.Close (HttpStatusCode.BadRequest); - - return; - } - - if (!checkHostNameForRequest (uri.DnsSafeHost)) { - context.Close (HttpStatusCode.NotFound); + if (!checkHostNameForRequest (uri.DnsSafeHost)) { + context.Close (HttpStatusCode.NotFound); - return; - } + return; } var path = uri.AbsolutePath; From 963345b1c527f8df62dc4cc0408d88616538d82f Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 21 Mar 2023 16:07:53 +0900 Subject: [PATCH 5058/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketServer.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 4c1bb5423..7e442dd16 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -753,7 +753,9 @@ private void processRequest (TcpListenerWebSocketContext context) return; } - if (!checkHostNameForRequest (uri.DnsSafeHost)) { + var name = uri.DnsSafeHost; + + if (!checkHostNameForRequest (name)) { context.Close (HttpStatusCode.NotFound); return; From 9493b77f8e1ddd90e05925e3bee289a410d37dca Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 22 Mar 2023 15:21:57 +0900 Subject: [PATCH 5059/6294] [Modify] Remove it --- websocket-sharp/WebSocket.cs | 6 ------ 1 file changed, 6 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 2586a7e93..9e45336e3 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -909,12 +909,6 @@ private bool checkHandshakeRequest ( return false; } - if (context.RequestUri == null) { - message = "The Request-URI is invalid."; - - return false; - } - var headers = context.Headers; var key = headers["Sec-WebSocket-Key"]; From c128b2350db8d92252606a0dcd96dc688f68b6a0 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 22 Mar 2023 15:26:22 +0900 Subject: [PATCH 5060/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 9e45336e3..87e636498 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -941,10 +941,12 @@ private bool checkHandshakeRequest ( var subps = headers["Sec-WebSocket-Protocol"]; - if (subps != null && subps.Length == 0) { - message = "The Sec-WebSocket-Protocol header is invalid."; + if (subps != null) { + if (subps.Length == 0) { + message = "The Sec-WebSocket-Protocol header is invalid."; - return false; + return false; + } } if (!_ignoreExtensions) { From 2ff0750fb10d361d30f6ca3eba1fec9706b7bedb Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 23 Mar 2023 15:40:04 +0900 Subject: [PATCH 5061/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 87e636498..d82b33568 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -952,10 +952,12 @@ private bool checkHandshakeRequest ( if (!_ignoreExtensions) { var exts = headers["Sec-WebSocket-Extensions"]; - if (exts != null && exts.Length == 0) { - message = "The Sec-WebSocket-Extensions header is invalid."; + if (exts != null) { + if (exts.Length == 0) { + message = "The Sec-WebSocket-Extensions header is invalid."; - return false; + return false; + } } } From 1df2298fdc4c42ea7957c761327f1ef9d46e93ba Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 23 Mar 2023 17:54:32 +0900 Subject: [PATCH 5062/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index d82b33568..e8b2d0aac 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1891,10 +1891,8 @@ private void processSecWebSocketProtocolClientHeader ( IEnumerable values ) { - if (values.Contains (val => val == _protocol)) - return; - - _protocol = null; + if (!values.Contains (val => val == _protocol)) + _protocol = null; } private bool processUnsupportedFrame (WebSocketFrame frame) From de783a3f10989cd9284508c0992a8c8447a8e24d Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 24 Mar 2023 15:44:46 +0900 Subject: [PATCH 5063/6294] [Modify] Replace it --- websocket-sharp/WebSocket.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index e8b2d0aac..76e13b20d 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -872,9 +872,12 @@ private bool acceptHandshake () _base64Key = _context.Headers["Sec-WebSocket-Key"]; if (_protocol != null) { - var vals = _context.SecWebSocketProtocols; + var matched = _context + .SecWebSocketProtocols + .Contains (p => p == _protocol); - processSecWebSocketProtocolClientHeader (vals); + if (!matched) + _protocol = null; } if (!_ignoreExtensions) { From bdd5ea23de13d068f34c9baaeb4cdc416b977ff3 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 24 Mar 2023 16:51:25 +0900 Subject: [PATCH 5064/6294] [Modify] Remove it --- websocket-sharp/WebSocket.cs | 9 --------- 1 file changed, 9 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 76e13b20d..03c32f4a8 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1889,15 +1889,6 @@ private void processSecWebSocketExtensionsServerHeader (string value) _extensions = value; } - // As server - private void processSecWebSocketProtocolClientHeader ( - IEnumerable values - ) - { - if (!values.Contains (val => val == _protocol)) - _protocol = null; - } - private bool processUnsupportedFrame (WebSocketFrame frame) { _log.Fatal ("An unsupported frame was received."); From 77f7cfa9b2e3bcff269611e2036841fc6b28221f Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 25 Mar 2023 15:28:39 +0900 Subject: [PATCH 5065/6294] [Modify] Replace it --- websocket-sharp/WebSocket.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 03c32f4a8..ecffb3161 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -886,9 +886,7 @@ private bool acceptHandshake () processSecWebSocketExtensionsClientHeader (val); } - var res = createHandshakeResponse (); - - sendHttpResponse (res); + createHandshakeResponse ().WriteTo (_stream); return true; } From fd0f6a847c23f3869e87e6dfab4a24f960366350 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 25 Mar 2023 15:34:31 +0900 Subject: [PATCH 5066/6294] [Modify] Replace it --- websocket-sharp/WebSocket.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index ecffb3161..6f47b5eff 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1900,9 +1900,7 @@ private bool processUnsupportedFrame (WebSocketFrame frame) // As server private void refuseHandshake (ushort code, string reason) { - var res = createHandshakeFailureResponse (); - - sendHttpResponse (res); + createHandshakeFailureResponse ().WriteTo (_stream); abort (code, reason); } From 616674e371a334af546fb4aa184daa747356e337 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 26 Mar 2023 15:40:35 +0900 Subject: [PATCH 5067/6294] [Modify] Remove it --- websocket-sharp/WebSocket.cs | 6 ------ 1 file changed, 6 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 6f47b5eff..62880c15c 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2226,12 +2226,6 @@ private HttpResponse sendHttpRequest ( return request.GetResponse (_stream, millisecondsTimeout); } - // As server - private void sendHttpResponse (HttpResponse response) - { - response.WriteTo (_stream); - } - // As client private void sendProxyConnectRequest () { From 068232e865c024be49f9d3cfef5ebfdecfce44a1 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 27 Mar 2023 21:56:59 +0900 Subject: [PATCH 5068/6294] [Modify] Edit it --- README.md | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 5c99ed80e..268712354 100644 --- a/README.md +++ b/README.md @@ -522,13 +522,13 @@ As a WebSocket client, if you would like to send the query string in the handsha var ws = new WebSocket ("ws://example.com/?name=nobita"); ``` -If you would like to send the Origin header in the handshake request, you should set the `WebSocket.Origin` property to an allowable value as the [Origin] header before calling the connect method. +And if you would like to send the Origin header in the handshake request, you should set the `WebSocket.Origin` property to an allowable value as the [Origin] header before calling the connect method. ```csharp ws.Origin = "http://example.com/"; ``` -And if you would like to send the cookies in the handshake request, you should set any cookie by using the `WebSocket.SetCookie (WebSocketSharp.Net.Cookie)` method before calling the connect method. +And also if you would like to send the cookies in the handshake request, you should set any cookie by using the `WebSocket.SetCookie (WebSocketSharp.Net.Cookie)` method before calling the connect method. ```csharp ws.SetCookie (new Cookie ("name", "nobita")); @@ -551,18 +551,16 @@ public class Chat : WebSocketBehavior } ``` -If you would like to get the value of the Origin header included in a handshake request, you should access the `WebSocketBehavior.Context.Origin` property. - -If you would like to get the cookies included in a handshake request, you should access the `WebSocketBehavior.Context.CookieCollection` property. - And if you would like to validate the Origin header, cookies, or both, you should set each validation for it with your `WebSocketBehavior`, for example, by using the `WebSocketServer.AddWebSocketService (string, Action)` method with initializing, such as the following. ```csharp wssv.AddWebSocketService ( "/Chat", s => { - s.OriginValidator = val => { + s.OriginValidator = + val => { // Check the value of the Origin header, and return true if valid. + Uri origin; return !val.IsNullOrEmpty () @@ -570,11 +568,14 @@ wssv.AddWebSocketService ( && origin.Host == "example.com"; }; - s.CookiesValidator = (req, res) => { - // Check the cookies in 'req', and set the cookies to send to - // the client with 'res' if necessary. + s.CookiesValidator = + (req, res) => { + // Check the cookies in "req", and set the cookies to send to + // the client with "res" if necessary. + foreach (var cookie in req) { cookie.Expired = true; + res.Add (cookie); } From 2680fbe5c1ac5eb20696966f32815500b55a7ffb Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 28 Mar 2023 15:35:45 +0900 Subject: [PATCH 5069/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 62880c15c..cdd8fcb3b 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1008,10 +1008,12 @@ private bool checkHandshakeResponse ( var ver = headers["Sec-WebSocket-Version"]; - if (ver != null && ver != _version) { - message = "The Sec-WebSocket-Version header is invalid."; + if (ver != null) { + if (ver != _version) { + message = "The Sec-WebSocket-Version header is invalid."; - return false; + return false; + } } var subp = headers["Sec-WebSocket-Protocol"]; From 066c19ed39c48a287e7d87b5bf22551815cfa20c Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 28 Mar 2023 15:40:07 +0900 Subject: [PATCH 5070/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index cdd8fcb3b..af2a91c42 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1026,8 +1026,8 @@ private bool checkHandshakeResponse ( } } else { - var valid = subp.Length > 0 - && _protocolsRequested + var valid = _protocolsRequested + && subp.Length > 0 && _protocols.Contains (p => p == subp); if (!valid) { From edcc55348835e897e99d594cb983959ebc60614b Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 29 Mar 2023 15:49:16 +0900 Subject: [PATCH 5071/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index af2a91c42..18d8cbb68 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1039,10 +1039,12 @@ private bool checkHandshakeResponse ( var exts = headers["Sec-WebSocket-Extensions"]; - if (!validateSecWebSocketExtensionsServerHeader (exts)) { - message = "The Sec-WebSocket-Extensions header is invalid."; + if (exts != null) { + if (!validateSecWebSocketExtensionsServerHeader (exts)) { + message = "The Sec-WebSocket-Extensions header is invalid."; - return false; + return false; + } } return true; From ce1b38b3fd4094b48fe2e7123c4685ff24ce7ee9 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 29 Mar 2023 16:55:39 +0900 Subject: [PATCH 5072/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 18d8cbb68..43adc4841 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2385,13 +2385,10 @@ private void startReceiving () // As client private bool validateSecWebSocketExtensionsServerHeader (string value) { - if (value == null) - return true; - - if (value.Length == 0) + if (!_extensionsRequested) return false; - if (!_extensionsRequested) + if (value.Length == 0) return false; var comp = _compression != CompressionMethod.None; From 656e943681e06b5fefd47f35589820c6590a71f6 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 30 Mar 2023 16:04:50 +0900 Subject: [PATCH 5073/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 43adc4841..bdf165f5d 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2401,7 +2401,7 @@ private bool validateSecWebSocketExtensionsServerHeader (string value) var param2 = "client_no_context_takeover"; if (!ext.Contains (param1)) { - var fmt = "The server did not send back '{0}'."; + var fmt = "The server did not send back \"{0}\"."; var msg = String.Format (fmt, param1); _log.Error (msg); From 5bca44c8581f74f3872d976ae8b8186dcbf8df82 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 30 Mar 2023 16:13:45 +0900 Subject: [PATCH 5074/6294] [Modify] Replace it --- websocket-sharp/WebSocket.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index bdf165f5d..1271ca910 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1493,9 +1493,12 @@ private bool doHandshake () _protocol = res.Headers["Sec-WebSocket-Protocol"]; if (_extensionsRequested) { - var val = res.Headers["Sec-WebSocket-Extensions"]; + var exts = res.Headers["Sec-WebSocket-Extensions"]; - processSecWebSocketExtensionsServerHeader (val); + if (exts == null) + _compression = CompressionMethod.None; + else + _extensions = exts; } processCookies (res.Cookies); From 0359fe83095f3d75d83d44d88923751434625fd1 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 30 Mar 2023 16:15:02 +0900 Subject: [PATCH 5075/6294] [Modify] Remove it --- websocket-sharp/WebSocket.cs | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 1271ca910..da2119c85 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1882,18 +1882,6 @@ private void processSecWebSocketExtensionsClientHeader (string value) _extensions = buff.ToString (); } - // As client - private void processSecWebSocketExtensionsServerHeader (string value) - { - if (value == null) { - _compression = CompressionMethod.None; - - return; - } - - _extensions = value; - } - private bool processUnsupportedFrame (WebSocketFrame frame) { _log.Fatal ("An unsupported frame was received."); From 18b227b3501ac96af1650788116d964660ccf05b Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 31 Mar 2023 15:45:52 +0900 Subject: [PATCH 5076/6294] [Modify] Replace it --- websocket-sharp/WebSocket.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index da2119c85..2a3822f11 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1501,7 +1501,10 @@ private bool doHandshake () _extensions = exts; } - processCookies (res.Cookies); + var cookies = res.Cookies; + + if (cookies.Count > 0) + _cookies.SetOrRemove (cookies); return true; } From dfb24332d29238753ac41868959d249686405a34 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 31 Mar 2023 15:46:49 +0900 Subject: [PATCH 5077/6294] [Modify] Remove it --- websocket-sharp/WebSocket.cs | 9 --------- 1 file changed, 9 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 2a3822f11..d4f22dc4a 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1707,15 +1707,6 @@ private bool processCloseFrame (WebSocketFrame frame) return false; } - // As client - private void processCookies (CookieCollection cookies) - { - if (cookies.Count == 0) - return; - - _cookies.SetOrRemove (cookies); - } - private bool processDataFrame (WebSocketFrame frame) { var e = frame.IsCompressed From b098a67b7a059fc90755ea2757e655ac6684c9a2 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 1 Apr 2023 17:16:18 +0900 Subject: [PATCH 5078/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index d4f22dc4a..0ce9e8e1e 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2386,10 +2386,7 @@ private bool validateSecWebSocketExtensionsServerHeader (string value) var param2 = "client_no_context_takeover"; if (!ext.Contains (param1)) { - var fmt = "The server did not send back \"{0}\"."; - var msg = String.Format (fmt, param1); - - _log.Error (msg); + // The server did not send back "server_no_context_takeover". return false; } From fc5503a6b9fc25f42f248e7b9010c07c30abe8b1 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 2 Apr 2023 16:16:50 +0900 Subject: [PATCH 5079/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 0ce9e8e1e..0953d0fe8 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1054,16 +1054,17 @@ private static bool checkProtocols (string[] protocols, out string message) { message = null; - Func cond = protocol => protocol.IsNullOrEmpty () - || !protocol.IsToken (); + Func cond = p => p.IsNullOrEmpty () || !p.IsToken (); if (protocols.Contains (cond)) { message = "It contains a value that is not a token."; + return false; } if (protocols.ContainsTwice ()) { message = "It contains a value twice."; + return false; } From e1afc9f84adf0d6a4157e6ac4f72068da607ecb6 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 3 Apr 2023 15:40:27 +0900 Subject: [PATCH 5080/6294] [Modify] Replace it --- websocket-sharp/WebSocket.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 0953d0fe8..d3c007bb4 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2122,7 +2122,9 @@ private bool sendBytes (byte[] bytes) private HttpResponse sendHandshakeRequest () { var req = createHandshakeRequest (); - var res = sendHttpRequest (req, 90000); + + var timeout = 90000; + var res = req.GetResponse (_stream, timeout); if (res.IsUnauthorized) { if (_credentials == null) { From 004ed2794ee2be5274cb4be54e7dcec74b211ba4 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 3 Apr 2023 15:43:52 +0900 Subject: [PATCH 5081/6294] [Modify] Replace it --- websocket-sharp/WebSocket.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index d3c007bb4..2f157c443 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2173,7 +2173,8 @@ private HttpResponse sendHandshakeRequest () setClientStream (); } - res = sendHttpRequest (req, 15000); + timeout = 15000; + res = req.GetResponse (_stream, timeout); } if (res.IsRedirect) { From e89c019fc08a8bd0168d43641ca304d062fcdc6a Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 4 Apr 2023 15:15:51 +0900 Subject: [PATCH 5082/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 2f157c443..63476ffce 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2127,11 +2127,8 @@ private HttpResponse sendHandshakeRequest () var res = req.GetResponse (_stream, timeout); if (res.IsUnauthorized) { - if (_credentials == null) { - _log.Error ("No credential is specified."); - + if (_credentials == null) return res; - } var val = res.Headers["WWW-Authenticate"]; From d3a640cc0087c726a339c51e30aeb9738b503058 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 5 Apr 2023 16:10:38 +0900 Subject: [PATCH 5083/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 63476ffce..26f553dd0 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2181,7 +2181,7 @@ private HttpResponse sendHandshakeRequest () var val = res.Headers["Location"]; if (val.IsNullOrEmpty ()) { - _log.Error ("No url to redirect is located."); + _log.Error ("No URL to redirect is located."); return res; } @@ -2190,7 +2190,7 @@ private HttpResponse sendHandshakeRequest () string msg; if (!val.TryCreateWebSocketUri (out uri, out msg)) { - _log.Error ("An invalid url to redirect is located."); + _log.Error ("An invalid URL to redirect is located."); return res; } From 51a09ac645fd0e235a0ae8c0626624809097d28b Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 6 Apr 2023 15:38:44 +0900 Subject: [PATCH 5084/6294] [Modify] Replace it --- websocket-sharp/WebSocket.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 26f553dd0..f53e77e9e 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2220,7 +2220,9 @@ private HttpResponse sendHttpRequest ( private void sendProxyConnectRequest () { var req = HttpRequest.CreateConnectRequest (_uri); - var res = sendHttpRequest (req, 90000); + + var timeout = 90000; + var res = req.GetResponse (_stream, timeout); if (res.IsProxyAuthenticationRequired) { if (_proxyCredentials == null) { From 579b0c707695e5c8008a3c739b35be7669d353c2 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 6 Apr 2023 15:46:33 +0900 Subject: [PATCH 5085/6294] [Modify] Replace it --- websocket-sharp/WebSocket.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index f53e77e9e..3c1c0da83 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2258,7 +2258,8 @@ private void sendProxyConnectRequest () _stream = _tcpClient.GetStream (); } - res = sendHttpRequest (req, 15000); + timeout = 15000; + res = req.GetResponse (_stream, timeout); if (res.IsProxyAuthenticationRequired) { var msg = "The proxy authentication has failed."; From 36aeec35dc0dffc0f9007f43d60273a70fae2688 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 7 Apr 2023 15:23:34 +0900 Subject: [PATCH 5086/6294] [Modify] Remove it --- websocket-sharp/WebSocket.cs | 8 -------- 1 file changed, 8 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 3c1c0da83..ad7b1f7b5 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2208,14 +2208,6 @@ private HttpResponse sendHandshakeRequest () return res; } - // As client - private HttpResponse sendHttpRequest ( - HttpRequest request, int millisecondsTimeout - ) - { - return request.GetResponse (_stream, millisecondsTimeout); - } - // As client private void sendProxyConnectRequest () { From 20915a6a63fc57477ec072d996c0a18a214af720 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 8 Apr 2023 16:16:35 +0900 Subject: [PATCH 5087/6294] [Modify] Add it --- websocket-sharp/WebSocket.cs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index ad7b1f7b5..b9d8efdbe 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1071,6 +1071,28 @@ private static bool checkProtocols (string[] protocols, out string message) return true; } + // As client + private bool checkProxyConnectResponse ( + HttpResponse response, out string message + ) + { + message = null; + + if (response.IsProxyAuthenticationRequired) { + message = "The proxy authentication is required."; + + return false; + } + + if (!response.IsSuccess) { + message = "The proxy has failed a connection to the requested URL."; + + return false; + } + + return true; + } + private bool checkReceivedFrame (WebSocketFrame frame, out string message) { message = null; From e9417bfb123a2a1ed571aadff4df39da85b87324 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 9 Apr 2023 17:48:50 +0900 Subject: [PATCH 5088/6294] [Modify] Add it --- websocket-sharp/WebSocket.cs | 46 ++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index b9d8efdbe..3745be5d9 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2289,6 +2289,52 @@ private void sendProxyConnectRequest () } } + // As client + private HttpResponse sendProxyConnectRequest2 () + { + var req = HttpRequest.CreateConnectRequest (_uri); + + var timeout = 90000; + var res = req.GetResponse (_stream, timeout); + + if (res.IsProxyAuthenticationRequired) { + if (_proxyCredentials == null) + return res; + + var val = res.Headers["Proxy-Authenticate"]; + + if (val.IsNullOrEmpty ()) { + _log.Error ("No proxy authentication challenge is specified."); + + return res; + } + + var achal = AuthenticationChallenge.Parse (val); + + if (achal == null) { + _log.Error ("An invalid proxy authentication challenge is specified."); + + return res; + } + + var ares = new AuthenticationResponse (achal, _proxyCredentials, 0); + + req.Headers["Proxy-Authorization"] = ares.ToString (); + + if (res.CloseConnection) { + releaseClientResources (); + + _tcpClient = new TcpClient (_proxyUri.DnsSafeHost, _proxyUri.Port); + _stream = _tcpClient.GetStream (); + } + + timeout = 15000; + res = req.GetResponse (_stream, timeout); + } + + return res; + } + // As client private void setClientStream () { From deba437fe251fbb42f35031611e96717a8457d54 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 10 Apr 2023 14:31:54 +0900 Subject: [PATCH 5089/6294] [Modify] Replace it --- websocket-sharp/WebSocket.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 3745be5d9..8f82a2b74 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2342,7 +2342,12 @@ private void setClientStream () _tcpClient = new TcpClient (_proxyUri.DnsSafeHost, _proxyUri.Port); _stream = _tcpClient.GetStream (); - sendProxyConnectRequest (); + var res = sendProxyConnectRequest2 (); + + string msg; + + if (!checkProxyConnectResponse (res, out msg)) + throw new WebSocketException (msg); } else { _tcpClient = new TcpClient (_uri.DnsSafeHost, _uri.Port); From 900b38abb3d24dbdf2e6669bb281baa521de796d Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 10 Apr 2023 14:35:27 +0900 Subject: [PATCH 5090/6294] [Modify] Remove it --- websocket-sharp/WebSocket.cs | 59 ------------------------------------ 1 file changed, 59 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 8f82a2b74..032b64f7a 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2230,65 +2230,6 @@ private HttpResponse sendHandshakeRequest () return res; } - // As client - private void sendProxyConnectRequest () - { - var req = HttpRequest.CreateConnectRequest (_uri); - - var timeout = 90000; - var res = req.GetResponse (_stream, timeout); - - if (res.IsProxyAuthenticationRequired) { - if (_proxyCredentials == null) { - var msg = "No credential for the proxy is specified."; - - throw new WebSocketException (msg); - } - - var val = res.Headers["Proxy-Authenticate"]; - - if (val.IsNullOrEmpty ()) { - var msg = "No proxy authentication challenge is specified."; - - throw new WebSocketException (msg); - } - - var achal = AuthenticationChallenge.Parse (val); - - if (achal == null) { - var msg = "An invalid proxy authentication challenge is specified."; - - throw new WebSocketException (msg); - } - - var ares = new AuthenticationResponse (achal, _proxyCredentials, 0); - - req.Headers["Proxy-Authorization"] = ares.ToString (); - - if (res.CloseConnection) { - releaseClientResources (); - - _tcpClient = new TcpClient (_proxyUri.DnsSafeHost, _proxyUri.Port); - _stream = _tcpClient.GetStream (); - } - - timeout = 15000; - res = req.GetResponse (_stream, timeout); - - if (res.IsProxyAuthenticationRequired) { - var msg = "The proxy authentication has failed."; - - throw new WebSocketException (msg); - } - } - - if (!res.IsSuccess) { - var msg = "The proxy has failed a connection to the requested URL."; - - throw new WebSocketException (msg); - } - } - // As client private HttpResponse sendProxyConnectRequest2 () { From 9dde3ecf4b66af7ec297ef22164afcbaf752a486 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 11 Apr 2023 15:44:22 +0900 Subject: [PATCH 5091/6294] [Modify] Rename it --- websocket-sharp/WebSocket.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 032b64f7a..41a82d6f6 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2231,7 +2231,7 @@ private HttpResponse sendHandshakeRequest () } // As client - private HttpResponse sendProxyConnectRequest2 () + private HttpResponse sendProxyConnectRequest () { var req = HttpRequest.CreateConnectRequest (_uri); @@ -2283,7 +2283,7 @@ private void setClientStream () _tcpClient = new TcpClient (_proxyUri.DnsSafeHost, _proxyUri.Port); _stream = _tcpClient.GetStream (); - var res = sendProxyConnectRequest2 (); + var res = sendProxyConnectRequest (); string msg; From 05643dfe1132826da715bb4361747c400f14aae7 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 12 Apr 2023 16:58:35 +0900 Subject: [PATCH 5092/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 41a82d6f6..0fd3c4175 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2245,7 +2245,7 @@ private HttpResponse sendProxyConnectRequest () var val = res.Headers["Proxy-Authenticate"]; if (val.IsNullOrEmpty ()) { - _log.Error ("No proxy authentication challenge is specified."); + _log.Debug ("No proxy authentication challenge is specified."); return res; } @@ -2253,7 +2253,7 @@ private HttpResponse sendProxyConnectRequest () var achal = AuthenticationChallenge.Parse (val); if (achal == null) { - _log.Error ("An invalid proxy authentication challenge is specified."); + _log.Debug ("An invalid proxy authentication challenge is specified."); return res; } From 4f24cb29206635b2b596a9e6f634100d2882e4fc Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 13 Apr 2023 15:33:51 +0900 Subject: [PATCH 5093/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 0fd3c4175..5ce3858e2 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2155,7 +2155,7 @@ private HttpResponse sendHandshakeRequest () var val = res.Headers["WWW-Authenticate"]; if (val.IsNullOrEmpty ()) { - _log.Error ("No authentication challenge is specified."); + _log.Debug ("No authentication challenge is specified."); return res; } @@ -2163,7 +2163,7 @@ private HttpResponse sendHandshakeRequest () var achal = AuthenticationChallenge.Parse (val); if (achal == null) { - _log.Error ("An invalid authentication challenge is specified."); + _log.Debug ("An invalid authentication challenge is specified."); return res; } @@ -2174,7 +2174,7 @@ private HttpResponse sendHandshakeRequest () && _authChallenge.Scheme == AuthenticationSchemes.Basic; if (failed) { - _log.Error ("The authentication has failed."); + _log.Debug ("The authentication has failed."); return res; } From 943eee3ee0c16a59bb40b3516cbb0d09958ec7e0 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 13 Apr 2023 15:43:44 +0900 Subject: [PATCH 5094/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 5ce3858e2..498c71774 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2170,13 +2170,9 @@ private HttpResponse sendHandshakeRequest () _authChallenge = achal; - var failed = _preAuth - && _authChallenge.Scheme == AuthenticationSchemes.Basic; - - if (failed) { - _log.Debug ("The authentication has failed."); - - return res; + if (_preAuth) { + if (_authChallenge.Scheme == AuthenticationSchemes.Basic) + return res; } var ares = new AuthenticationResponse ( From 3e178d76280343854ce41e0ede89584dc1ce4e10 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 14 Apr 2023 17:50:41 +0900 Subject: [PATCH 5095/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 498c71774..66541e39e 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2199,7 +2199,7 @@ private HttpResponse sendHandshakeRequest () var val = res.Headers["Location"]; if (val.IsNullOrEmpty ()) { - _log.Error ("No URL to redirect is located."); + _log.Debug ("No URL to redirect is located."); return res; } @@ -2208,7 +2208,7 @@ private HttpResponse sendHandshakeRequest () string msg; if (!val.TryCreateWebSocketUri (out uri, out msg)) { - _log.Error ("An invalid URL to redirect is located."); + _log.Debug ("An invalid URL to redirect is located."); return res; } From 722dfb59376847993cc592d733baa47700d10059 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 15 Apr 2023 17:33:39 +0900 Subject: [PATCH 5096/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 66541e39e..c9c239258 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2170,11 +2170,6 @@ private HttpResponse sendHandshakeRequest () _authChallenge = achal; - if (_preAuth) { - if (_authChallenge.Scheme == AuthenticationSchemes.Basic) - return res; - } - var ares = new AuthenticationResponse ( _authChallenge, _credentials, _nonceCount ); From 572547c3678806add915cbf240bd8c5af9b96fed Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 16 Apr 2023 22:16:56 +0900 Subject: [PATCH 5097/6294] [Modify] Move it --- websocket-sharp/WebSocket.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index c9c239258..a9636e6a2 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2149,9 +2149,6 @@ private HttpResponse sendHandshakeRequest () var res = req.GetResponse (_stream, timeout); if (res.IsUnauthorized) { - if (_credentials == null) - return res; - var val = res.Headers["WWW-Authenticate"]; if (val.IsNullOrEmpty ()) { @@ -2170,6 +2167,9 @@ private HttpResponse sendHandshakeRequest () _authChallenge = achal; + if (_credentials == null) + return res; + var ares = new AuthenticationResponse ( _authChallenge, _credentials, _nonceCount ); From 2f00a699450977f09e4beef45b5aa24e14f59dc6 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 17 Apr 2023 17:48:42 +0900 Subject: [PATCH 5098/6294] [Modify] Edit it --- websocket-sharp/Net/ClientSslConfiguration.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/ClientSslConfiguration.cs b/websocket-sharp/Net/ClientSslConfiguration.cs index 7816e0301..8763c8a42 100644 --- a/websocket-sharp/Net/ClientSslConfiguration.cs +++ b/websocket-sharp/Net/ClientSslConfiguration.cs @@ -223,8 +223,11 @@ public SslProtocols EnabledSslProtocols { /// /// /// - /// A delegate that - /// invokes the method called for validating the certificate. + /// A delegate. + /// + /// + /// The delegate invokes the method called when a client validates + /// the certificate. /// /// /// The default value is a delegate that invokes a method that only From af63644dba4ef209819c43be07adb51cfa3f0a38 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 18 Apr 2023 17:20:00 +0900 Subject: [PATCH 5099/6294] [Modify] Edit it --- websocket-sharp/Net/ClientSslConfiguration.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/ClientSslConfiguration.cs b/websocket-sharp/Net/ClientSslConfiguration.cs index 8763c8a42..de4b35f7f 100644 --- a/websocket-sharp/Net/ClientSslConfiguration.cs +++ b/websocket-sharp/Net/ClientSslConfiguration.cs @@ -169,8 +169,11 @@ public X509CertificateCollection ClientCertificates { /// /// /// - /// A delegate that - /// invokes the method called for selecting the certificate. + /// A delegate. + /// + /// + /// The delegate invokes the method called when a client selects + /// the certificate. /// /// /// The default value is a delegate that invokes a method that only From 1c7c8e4d4e4c99f9c3663ead785a1dc9150e6e88 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 19 Apr 2023 17:41:15 +0900 Subject: [PATCH 5100/6294] [Modify] Edit it --- websocket-sharp/Net/ClientSslConfiguration.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/ClientSslConfiguration.cs b/websocket-sharp/Net/ClientSslConfiguration.cs index de4b35f7f..eb8edfbbf 100644 --- a/websocket-sharp/Net/ClientSslConfiguration.cs +++ b/websocket-sharp/Net/ClientSslConfiguration.cs @@ -136,15 +136,16 @@ public bool CheckCertificateRevocation { } /// - /// Gets or sets the collection of client certificates from which to select + /// Gets or sets the collection of the certificates from which to select /// one to supply to the server. /// /// /// - /// A or . + /// A that contains + /// the certificates from which to select. /// /// - /// The collection contains client certificates from which to select. + /// if not present. /// /// /// The default value is . From b4eef80f996e8f32d8a0dd60b32986c2141e6ca3 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 20 Apr 2023 17:36:13 +0900 Subject: [PATCH 5101/6294] [Modify] Edit it --- websocket-sharp/Net/ClientSslConfiguration.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/ClientSslConfiguration.cs b/websocket-sharp/Net/ClientSslConfiguration.cs index eb8edfbbf..49428be52 100644 --- a/websocket-sharp/Net/ClientSslConfiguration.cs +++ b/websocket-sharp/Net/ClientSslConfiguration.cs @@ -195,14 +195,14 @@ public LocalCertificateSelectionCallback ClientCertificateSelectionCallback { } /// - /// Gets or sets the protocols used for authentication. + /// Gets or sets the enabled versions of the SSL/TLS protocols. /// /// /// /// Any of the enum values. /// /// - /// It represents the protocols used for authentication. + /// It represents the enabled versions of the SSL/TLS protocols. /// /// /// The default value is . From 41c14e2697cf08c60408728b297cf870aa3c554c Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 21 Apr 2023 15:34:03 +0900 Subject: [PATCH 5102/6294] [Modify] Edit it --- websocket-sharp/Net/ClientSslConfiguration.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/ClientSslConfiguration.cs b/websocket-sharp/Net/ClientSslConfiguration.cs index 49428be52..466bf02df 100644 --- a/websocket-sharp/Net/ClientSslConfiguration.cs +++ b/websocket-sharp/Net/ClientSslConfiguration.cs @@ -61,10 +61,11 @@ public class ClientSslConfiguration /// /// Initializes a new instance of the - /// class with the specified target host server name. + /// class with the specified target host name. /// /// - /// A that specifies the target host server name. + /// A that specifies the name of the server that + /// will share a secure connection with a client. /// /// /// is . From 48ba4ec9bb339782714d2e50512142dce5c0369c Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 21 Apr 2023 15:35:17 +0900 Subject: [PATCH 5103/6294] [Modify] Edit it --- websocket-sharp/Net/ClientSslConfiguration.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/ClientSslConfiguration.cs b/websocket-sharp/Net/ClientSslConfiguration.cs index 466bf02df..d310c83bd 100644 --- a/websocket-sharp/Net/ClientSslConfiguration.cs +++ b/websocket-sharp/Net/ClientSslConfiguration.cs @@ -253,7 +253,7 @@ public RemoteCertificateValidationCallback ServerCertificateValidationCallback { } /// - /// Gets or sets the target host server name. + /// Gets or sets the target host name. /// /// /// A that represents the name of the server that From 48a23eb13e97b253f17f90a27c9350a5a94a246d Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 22 Apr 2023 16:55:05 +0900 Subject: [PATCH 5104/6294] [Modify] Edit it --- websocket-sharp/Net/ClientSslConfiguration.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/ClientSslConfiguration.cs b/websocket-sharp/Net/ClientSslConfiguration.cs index d310c83bd..208efbbf3 100644 --- a/websocket-sharp/Net/ClientSslConfiguration.cs +++ b/websocket-sharp/Net/ClientSslConfiguration.cs @@ -88,7 +88,7 @@ public ClientSslConfiguration (string targetHost) /// /// Initializes a new instance of the - /// class that stores the parameters copied from the specified configuration. + /// class copying from the specified configuration. /// /// /// A from which to copy. From 80d0d1b677a34173feae646447f60361a08b86b0 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 23 Apr 2023 15:50:58 +0900 Subject: [PATCH 5105/6294] [Modify] 2023 --- websocket-sharp/Net/ClientSslConfiguration.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/ClientSslConfiguration.cs b/websocket-sharp/Net/ClientSslConfiguration.cs index 208efbbf3..3b9a70dcb 100644 --- a/websocket-sharp/Net/ClientSslConfiguration.cs +++ b/websocket-sharp/Net/ClientSslConfiguration.cs @@ -5,7 +5,7 @@ * The MIT License * * Copyright (c) 2014 liryna - * Copyright (c) 2014-2020 sta.blockhead + * Copyright (c) 2014-2023 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From f394b5f8d7765ed85c13d7cae50f1a06f31fc655 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 24 Apr 2023 16:05:06 +0900 Subject: [PATCH 5106/6294] [Modify] Edit it --- websocket-sharp/Net/ServerSslConfiguration.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/ServerSslConfiguration.cs b/websocket-sharp/Net/ServerSslConfiguration.cs index 47541f435..5f8161cd5 100644 --- a/websocket-sharp/Net/ServerSslConfiguration.cs +++ b/websocket-sharp/Net/ServerSslConfiguration.cs @@ -198,10 +198,10 @@ public SslProtocols EnabledSslProtocols { /// /// /// - /// A or . + /// A that represents an X.509 certificate. /// /// - /// The certificate represents an X.509 certificate. + /// if not present. /// /// /// The default value is . From f8c402bc8aecad28a0192d86723c20c8286999c0 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 25 Apr 2023 15:49:52 +0900 Subject: [PATCH 5107/6294] [Modify] Edit it --- websocket-sharp/Net/ServerSslConfiguration.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/ServerSslConfiguration.cs b/websocket-sharp/Net/ServerSslConfiguration.cs index 5f8161cd5..f5ac9f573 100644 --- a/websocket-sharp/Net/ServerSslConfiguration.cs +++ b/websocket-sharp/Net/ServerSslConfiguration.cs @@ -170,14 +170,14 @@ public RemoteCertificateValidationCallback ClientCertificateValidationCallback { } /// - /// Gets or sets the protocols used for authentication. + /// Gets or sets the enabled versions of the SSL/TLS protocols. /// /// /// /// Any of the enum values. /// /// - /// It represents the protocols used for authentication. + /// It represents the enabled versions of the SSL/TLS protocols. /// /// /// The default value is . From ba3d48fc7c3993f3ffe5e304de3fe69daece6f9f Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 26 Apr 2023 14:22:14 +0900 Subject: [PATCH 5108/6294] [Modify] Edit it --- websocket-sharp/Net/ServerSslConfiguration.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/ServerSslConfiguration.cs b/websocket-sharp/Net/ServerSslConfiguration.cs index f5ac9f573..e811af560 100644 --- a/websocket-sharp/Net/ServerSslConfiguration.cs +++ b/websocket-sharp/Net/ServerSslConfiguration.cs @@ -148,8 +148,11 @@ public bool ClientCertificateRequired { /// /// /// - /// A delegate that - /// invokes the method called for validating the certificate. + /// A delegate. + /// + /// + /// The delegate invokes the method called when the server validates + /// the certificate. /// /// /// The default value is a delegate that invokes a method that only From b658ab386130e02c2a630011e39ffbc1d8c895ad Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 27 Apr 2023 17:46:36 +0900 Subject: [PATCH 5109/6294] [Modify] Edit it --- websocket-sharp/Net/ServerSslConfiguration.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/ServerSslConfiguration.cs b/websocket-sharp/Net/ServerSslConfiguration.cs index e811af560..6771e9e3f 100644 --- a/websocket-sharp/Net/ServerSslConfiguration.cs +++ b/websocket-sharp/Net/ServerSslConfiguration.cs @@ -69,7 +69,7 @@ public ServerSslConfiguration () /// /// Initializes a new instance of the - /// class that stores the parameters copied from the specified configuration. + /// class copying from the specified configuration. /// /// /// A from which to copy. From d059b745b281d61134ed9e847dd68398233109bf Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 28 Apr 2023 17:40:03 +0900 Subject: [PATCH 5110/6294] [Modify] 2023 --- websocket-sharp/Net/ServerSslConfiguration.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/ServerSslConfiguration.cs b/websocket-sharp/Net/ServerSslConfiguration.cs index 6771e9e3f..2bd6f00a8 100644 --- a/websocket-sharp/Net/ServerSslConfiguration.cs +++ b/websocket-sharp/Net/ServerSslConfiguration.cs @@ -5,7 +5,7 @@ * The MIT License * * Copyright (c) 2014 liryna - * Copyright (c) 2014-2020 sta.blockhead + * Copyright (c) 2014-2023 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From 202e70c4ba534ef5a4662c8cb9e3221f7a0f033c Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 29 Apr 2023 15:33:27 +0900 Subject: [PATCH 5111/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 7e442dd16..8b0d74855 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -522,12 +522,12 @@ public bool ReuseAddress { /// Gets the configuration for secure connection. /// /// - /// The configuration will be referenced when attempts to start, + /// The configuration is used when the server attempts to start, /// so it must be configured before the start method is called. /// /// - /// A that represents - /// the configuration used to provide secure connections. + /// A that represents the + /// configuration used to provide secure connections. /// /// /// The server does not provide secure connections. From e61824289d806dd328d2f529d619a2e6f7af2f51 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 30 Apr 2023 16:16:37 +0900 Subject: [PATCH 5112/6294] [Modify] Edit it --- websocket-sharp/Server/HttpServer.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index cdd31540e..789f8182a 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -598,12 +598,12 @@ public bool ReuseAddress { /// Gets the configuration for secure connection. /// /// - /// The configuration will be referenced when attempts to start, + /// The configuration is used when the server attempts to start, /// so it must be configured before the start method is called. /// /// - /// A that represents - /// the configuration used to provide secure connections. + /// A that represents the + /// configuration used to provide secure connections. /// /// /// The server does not provide secure connections. From 167f8aa29e638203e70c148c6348022f5647bb83 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 1 May 2023 16:11:07 +0900 Subject: [PATCH 5113/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListener.cs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 3258e1baf..37bc821d8 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -405,12 +405,11 @@ public string Realm { } /// - /// Gets the SSL configuration used to authenticate the server and - /// optionally the client for secure connection. + /// Gets the configuration for secure connection. /// /// - /// A that represents the SSL - /// configuration for secure connection. + /// A that represents the + /// configuration used to provide secure connections. /// /// /// This listener has been closed. From 66e2460233ef77bd3b466a787a4b1411896a1c9f Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 2 May 2023 16:34:12 +0900 Subject: [PATCH 5114/6294] [Modify] Edit it --- websocket-sharp/Net/AuthenticationResponse.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/AuthenticationResponse.cs b/websocket-sharp/Net/AuthenticationResponse.cs index 0257d85b2..705df1dc5 100644 --- a/websocket-sharp/Net/AuthenticationResponse.cs +++ b/websocket-sharp/Net/AuthenticationResponse.cs @@ -2,8 +2,8 @@ /* * AuthenticationResponse.cs * - * ParseBasicCredentials is derived from System.Net.HttpListenerContext.cs of Mono - * (http://www.mono-project.com). + * ParseBasicCredentials is derived from HttpListenerContext.cs (System.Net) of + * Mono (http://www.mono-project.com). * * The MIT License * From a7767412982c888df8f83250d0f6b7448f3ee42b Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 3 May 2023 15:57:22 +0900 Subject: [PATCH 5115/6294] [Modify] Polish it --- websocket-sharp/Net/AuthenticationResponse.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/AuthenticationResponse.cs b/websocket-sharp/Net/AuthenticationResponse.cs index 705df1dc5..bc1d64a36 100644 --- a/websocket-sharp/Net/AuthenticationResponse.cs +++ b/websocket-sharp/Net/AuthenticationResponse.cs @@ -72,13 +72,15 @@ internal AuthenticationResponse ( AuthenticationSchemes scheme, NameValueCollection parameters, NetworkCredential credentials, - uint nonceCount) + uint nonceCount + ) : base (scheme, parameters) { Parameters["username"] = credentials.Username; Parameters["password"] = credentials.Password; Parameters["uri"] = credentials.Domain; _nonceCount = nonceCount; + if (scheme == AuthenticationSchemes.Digest) initAsDigest (); } From 00ae91eded186d2649d5c1dfe571009bba1faacc Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 4 May 2023 16:35:08 +0900 Subject: [PATCH 5116/6294] [Modify] Polish it --- websocket-sharp/Net/AuthenticationResponse.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/AuthenticationResponse.cs b/websocket-sharp/Net/AuthenticationResponse.cs index bc1d64a36..4bbb5cf00 100644 --- a/websocket-sharp/Net/AuthenticationResponse.cs +++ b/websocket-sharp/Net/AuthenticationResponse.cs @@ -63,7 +63,10 @@ internal AuthenticationResponse (NetworkCredential credentials) } internal AuthenticationResponse ( - AuthenticationChallenge challenge, NetworkCredential credentials, uint nonceCount) + AuthenticationChallenge challenge, + NetworkCredential credentials, + uint nonceCount + ) : this (challenge.Scheme, challenge.Parameters, credentials, nonceCount) { } From b23fedf35d2541688817c625022baec3619b2da2 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 5 May 2023 16:23:41 +0900 Subject: [PATCH 5117/6294] [Modify] Polish it --- websocket-sharp/Net/AuthenticationResponse.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/AuthenticationResponse.cs b/websocket-sharp/Net/AuthenticationResponse.cs index 4bbb5cf00..c54c4e2d6 100644 --- a/websocket-sharp/Net/AuthenticationResponse.cs +++ b/websocket-sharp/Net/AuthenticationResponse.cs @@ -58,7 +58,12 @@ private AuthenticationResponse (AuthenticationSchemes scheme, NameValueCollectio #region Internal Constructors internal AuthenticationResponse (NetworkCredential credentials) - : this (AuthenticationSchemes.Basic, new NameValueCollection (), credentials, 0) + : this ( + AuthenticationSchemes.Basic, + new NameValueCollection (), + credentials, + 0 + ) { } From c24f2042eb2d7eeecec2fa1a5153a76e1adb4b04 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 5 May 2023 16:25:12 +0900 Subject: [PATCH 5118/6294] [Modify] Polish it --- websocket-sharp/Net/AuthenticationResponse.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/AuthenticationResponse.cs b/websocket-sharp/Net/AuthenticationResponse.cs index c54c4e2d6..9aed863a5 100644 --- a/websocket-sharp/Net/AuthenticationResponse.cs +++ b/websocket-sharp/Net/AuthenticationResponse.cs @@ -48,7 +48,9 @@ internal class AuthenticationResponse : AuthenticationBase #region Private Constructors - private AuthenticationResponse (AuthenticationSchemes scheme, NameValueCollection parameters) + private AuthenticationResponse ( + AuthenticationSchemes scheme, NameValueCollection parameters + ) : base (scheme, parameters) { } From dcbc2118b6f455c2916b439ead3561d3fb415a75 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 6 May 2023 17:09:28 +0900 Subject: [PATCH 5119/6294] [Modify] Polish it --- websocket-sharp/Net/AuthenticationResponse.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/AuthenticationResponse.cs b/websocket-sharp/Net/AuthenticationResponse.cs index 9aed863a5..c8e0bfe0c 100644 --- a/websocket-sharp/Net/AuthenticationResponse.cs +++ b/websocket-sharp/Net/AuthenticationResponse.cs @@ -189,8 +189,13 @@ private static string hash (string value) private void initAsDigest () { var qops = Parameters["qop"]; + if (qops != null) { - if (qops.Split (',').Contains (qop => qop.Trim ().ToLower () == "auth")) { + var auth = qops.Split (',').Contains ( + qop => qop.Trim ().ToLower () == "auth" + ); + + if (auth) { Parameters["qop"] = "auth"; Parameters["cnonce"] = CreateNonceValue (); Parameters["nc"] = String.Format ("{0:x8}", ++_nonceCount); From cd3075d52dd8fee33c2b6ca6b193fad5210283fd Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 7 May 2023 16:00:32 +0900 Subject: [PATCH 5120/6294] [Modify] Polish it --- websocket-sharp/Net/AuthenticationResponse.cs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Net/AuthenticationResponse.cs b/websocket-sharp/Net/AuthenticationResponse.cs index c8e0bfe0c..296c910b3 100644 --- a/websocket-sharp/Net/AuthenticationResponse.cs +++ b/websocket-sharp/Net/AuthenticationResponse.cs @@ -175,15 +175,17 @@ private static string createA2 (string method, string uri, string entity) private static string hash (string value) { - var src = Encoding.UTF8.GetBytes (value); var md5 = MD5.Create (); - var hashed = md5.ComputeHash (src); - var res = new StringBuilder (64); - foreach (var b in hashed) - res.Append (b.ToString ("x2")); + var bytes = Encoding.UTF8.GetBytes (value); + var res = md5.ComputeHash (bytes); - return res.ToString (); + var buff = new StringBuilder (64); + + foreach (var b in res) + buff.Append (b.ToString ("x2")); + + return buff.ToString (); } private void initAsDigest () From cfe1ddbdf416b04ad2b046164b6e9c02009a7880 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 7 May 2023 16:02:18 +0900 Subject: [PATCH 5121/6294] [Modify] Polish it --- websocket-sharp/Net/AuthenticationResponse.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/AuthenticationResponse.cs b/websocket-sharp/Net/AuthenticationResponse.cs index 296c910b3..7fe5113df 100644 --- a/websocket-sharp/Net/AuthenticationResponse.cs +++ b/websocket-sharp/Net/AuthenticationResponse.cs @@ -151,7 +151,9 @@ public string UserName { #region Private Methods - private static string createA1 (string username, string password, string realm) + private static string createA1 ( + string username, string password, string realm + ) { return String.Format ("{0}:{1}:{2}", username, realm, password); } From 7ce1074056b59ddf68cafc8fc6b2eab938bb2b6b Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 8 May 2023 16:55:26 +0900 Subject: [PATCH 5122/6294] [Modify] Polish it --- websocket-sharp/Net/AuthenticationResponse.cs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/AuthenticationResponse.cs b/websocket-sharp/Net/AuthenticationResponse.cs index 7fe5113df..0b5b65a27 100644 --- a/websocket-sharp/Net/AuthenticationResponse.cs +++ b/websocket-sharp/Net/AuthenticationResponse.cs @@ -159,10 +159,16 @@ private static string createA1 ( } private static string createA1 ( - string username, string password, string realm, string nonce, string cnonce) + string username, + string password, + string realm, + string nonce, + string cnonce + ) { - return String.Format ( - "{0}:{1}:{2}", hash (createA1 (username, password, realm)), nonce, cnonce); + var a1 = createA1 (username, password, realm); + + return String.Format ("{0}:{1}:{2}", hash (a1), nonce, cnonce); } private static string createA2 (string method, string uri) From e54210a84a3387a7bdc5a89965715a68d03109f8 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 9 May 2023 15:57:38 +0900 Subject: [PATCH 5123/6294] [Modify] Polish it --- websocket-sharp/Net/AuthenticationResponse.cs | 29 +++++++++++++------ 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/websocket-sharp/Net/AuthenticationResponse.cs b/websocket-sharp/Net/AuthenticationResponse.cs index 0b5b65a27..338172496 100644 --- a/websocket-sharp/Net/AuthenticationResponse.cs +++ b/websocket-sharp/Net/AuthenticationResponse.cs @@ -256,22 +256,33 @@ internal static AuthenticationResponse Parse (string value) { try { var cred = value.Split (new[] { ' ' }, 2); + if (cred.Length != 2) return null; var schm = cred[0].ToLower (); - return schm == "basic" - ? new AuthenticationResponse ( - AuthenticationSchemes.Basic, ParseBasicCredentials (cred[1])) - : schm == "digest" - ? new AuthenticationResponse ( - AuthenticationSchemes.Digest, ParseParameters (cred[1])) - : null; + + if (schm == "basic") { + var parameters = ParseBasicCredentials (cred[1]); + + return new AuthenticationResponse ( + AuthenticationSchemes.Basic, parameters + ); + } + else if (schm == "digest") { + var parameters = ParseParameters (cred[1]); + + return new AuthenticationResponse ( + AuthenticationSchemes.Digest, parameters + ); + } + else { + return null; + } } catch { + return null; } - - return null; } internal static NameValueCollection ParseBasicCredentials (string value) From 0c0e57739db17a2145f5fec22d775cb1f3fdf05b Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 10 May 2023 16:10:05 +0900 Subject: [PATCH 5124/6294] [Modify] Polish it --- websocket-sharp/Net/AuthenticationResponse.cs | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/websocket-sharp/Net/AuthenticationResponse.cs b/websocket-sharp/Net/AuthenticationResponse.cs index 338172496..e9398b569 100644 --- a/websocket-sharp/Net/AuthenticationResponse.cs +++ b/websocket-sharp/Net/AuthenticationResponse.cs @@ -287,24 +287,32 @@ internal static AuthenticationResponse Parse (string value) internal static NameValueCollection ParseBasicCredentials (string value) { + var ret = new NameValueCollection (); + // Decode the basic-credentials (a Base64 encoded string). - var userPass = Encoding.Default.GetString (Convert.FromBase64String (value)); + + var bytes = Convert.FromBase64String (value); + var userPass = Encoding.Default.GetString (bytes); // The format is [\]:. + var i = userPass.IndexOf (':'); var user = userPass.Substring (0, i); - var pass = i < userPass.Length - 1 ? userPass.Substring (i + 1) : String.Empty; + var pass = i < userPass.Length - 1 + ? userPass.Substring (i + 1) + : String.Empty; + + // Check if exists. - // Check if 'domain' exists. i = user.IndexOf ('\\'); + if (i > -1) user = user.Substring (i + 1); - var res = new NameValueCollection (); - res["username"] = user; - res["password"] = pass; + ret["username"] = user; + ret["password"] = pass; - return res; + return ret; } internal override string ToBasicString () From 62c0aca97b24d1e969075150ccc5449dd2862ed0 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 10 May 2023 16:38:30 +0900 Subject: [PATCH 5125/6294] [Modify] Polish it --- websocket-sharp/Net/AuthenticationResponse.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/AuthenticationResponse.cs b/websocket-sharp/Net/AuthenticationResponse.cs index e9398b569..78f9f629d 100644 --- a/websocket-sharp/Net/AuthenticationResponse.cs +++ b/websocket-sharp/Net/AuthenticationResponse.cs @@ -317,8 +317,12 @@ internal static NameValueCollection ParseBasicCredentials (string value) internal override string ToBasicString () { - var userPass = String.Format ("{0}:{1}", Parameters["username"], Parameters["password"]); - var cred = Convert.ToBase64String (Encoding.UTF8.GetBytes (userPass)); + var user = Parameters["username"]; + var pass = Parameters["password"]; + var userPass = String.Format ("{0}:{1}", user, pass); + + var bytes = Encoding.UTF8.GetBytes (userPass); + var cred = Convert.ToBase64String (bytes); return "Basic " + cred; } From d62a0a76ecc37e7f4b53b0e367c918a91bfd42ae Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 11 May 2023 16:54:05 +0900 Subject: [PATCH 5126/6294] [Modify] Polish it --- websocket-sharp/Net/AuthenticationResponse.cs | 42 +++++++++++++------ 1 file changed, 29 insertions(+), 13 deletions(-) diff --git a/websocket-sharp/Net/AuthenticationResponse.cs b/websocket-sharp/Net/AuthenticationResponse.cs index 78f9f629d..6618a2296 100644 --- a/websocket-sharp/Net/AuthenticationResponse.cs +++ b/websocket-sharp/Net/AuthenticationResponse.cs @@ -329,29 +329,45 @@ internal override string ToBasicString () internal override string ToDigestString () { - var output = new StringBuilder (256); - output.AppendFormat ( + var buff = new StringBuilder (256); + + var user = Parameters["username"]; + var realm = Parameters["realm"]; + var nonce = Parameters["nonce"]; + var uri = Parameters["uri"]; + var res = Parameters["response"]; + + buff.AppendFormat ( "Digest username=\"{0}\", realm=\"{1}\", nonce=\"{2}\", uri=\"{3}\", response=\"{4}\"", - Parameters["username"], - Parameters["realm"], - Parameters["nonce"], - Parameters["uri"], - Parameters["response"]); + user, + realm, + nonce, + uri, + res + ); var opaque = Parameters["opaque"]; + if (opaque != null) - output.AppendFormat (", opaque=\"{0}\"", opaque); + buff.AppendFormat (", opaque=\"{0}\"", opaque); var algo = Parameters["algorithm"]; + if (algo != null) - output.AppendFormat (", algorithm={0}", algo); + buff.AppendFormat (", algorithm={0}", algo); var qop = Parameters["qop"]; - if (qop != null) - output.AppendFormat ( - ", qop={0}, cnonce=\"{1}\", nc={2}", qop, Parameters["cnonce"], Parameters["nc"]); - return output.ToString (); + if (qop != null) { + var cnonce = Parameters["cnonce"]; + var nc = Parameters["nc"]; + + buff.AppendFormat ( + ", qop={0}, cnonce=\"{1}\", nc={2}", qop, cnonce, nc + ); + } + + return buff.ToString (); } #endregion From 4470b9b2249b2a5e9afaa51be1838d6beece9923 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 12 May 2023 17:52:24 +0900 Subject: [PATCH 5127/6294] [Modify] Polish it --- websocket-sharp/Net/AuthenticationResponse.cs | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Net/AuthenticationResponse.cs b/websocket-sharp/Net/AuthenticationResponse.cs index 6618a2296..1b263593b 100644 --- a/websocket-sharp/Net/AuthenticationResponse.cs +++ b/websocket-sharp/Net/AuthenticationResponse.cs @@ -377,11 +377,19 @@ internal override string ToDigestString () public IIdentity ToIdentity () { var schm = Scheme; - return schm == AuthenticationSchemes.Basic - ? new HttpBasicIdentity (Parameters["username"], Parameters["password"]) as IIdentity - : schm == AuthenticationSchemes.Digest - ? new HttpDigestIdentity (Parameters) - : null; + + if (schm == AuthenticationSchemes.Basic) { + var user = Parameters["username"]; + var pass = Parameters["password"]; + + return new HttpBasicIdentity (user, pass); + } + else if (schm == AuthenticationSchemes.Digest) { + return new HttpDigestIdentity (Parameters); + } + else { + return null; + } } #endregion From 17a92750d417f085a2111d63b720a45ac9334375 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 13 May 2023 15:50:26 +0900 Subject: [PATCH 5128/6294] [Modify] Polish it --- websocket-sharp/Net/AuthenticationResponse.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/AuthenticationResponse.cs b/websocket-sharp/Net/AuthenticationResponse.cs index 1b263593b..c11e50526 100644 --- a/websocket-sharp/Net/AuthenticationResponse.cs +++ b/websocket-sharp/Net/AuthenticationResponse.cs @@ -249,7 +249,9 @@ internal static string CreateRequestDigest (NameValueCollection parameters) ? String.Format ("{0}:{1}:{2}:{3}:{4}", nonce, nc, cnonce, qop, hash (a2)) : String.Format ("{0}:{1}", nonce, hash (a2)); - return hash (String.Format ("{0}:{1}", secret, data)); + var keyed = String.Format ("{0}:{1}", secret, data); + + return hash (keyed); } internal static AuthenticationResponse Parse (string value) From 45e630ddfe25c7a63dff50269d5c38e3645398d0 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 13 May 2023 15:52:56 +0900 Subject: [PATCH 5129/6294] [Modify] Polish it --- websocket-sharp/Net/AuthenticationResponse.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/AuthenticationResponse.cs b/websocket-sharp/Net/AuthenticationResponse.cs index c11e50526..23636c07b 100644 --- a/websocket-sharp/Net/AuthenticationResponse.cs +++ b/websocket-sharp/Net/AuthenticationResponse.cs @@ -246,7 +246,9 @@ internal static string CreateRequestDigest (NameValueCollection parameters) var secret = hash (a1); var data = qop != null - ? String.Format ("{0}:{1}:{2}:{3}:{4}", nonce, nc, cnonce, qop, hash (a2)) + ? String.Format ( + "{0}:{1}:{2}:{3}:{4}", nonce, nc, cnonce, qop, hash (a2) + ) : String.Format ("{0}:{1}", nonce, hash (a2)); var keyed = String.Format ("{0}:{1}", secret, data); From abfa4ebafe7dc1ca5b1c6acddf2128226ad8be83 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 14 May 2023 16:27:06 +0900 Subject: [PATCH 5130/6294] [Modify] Polish it --- websocket-sharp/Net/AuthenticationChallenge.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/AuthenticationChallenge.cs b/websocket-sharp/Net/AuthenticationChallenge.cs index 3472204b9..e4ad787f0 100644 --- a/websocket-sharp/Net/AuthenticationChallenge.cs +++ b/websocket-sharp/Net/AuthenticationChallenge.cs @@ -45,10 +45,13 @@ private AuthenticationChallenge (AuthenticationSchemes scheme, NameValueCollecti #region Internal Constructors - internal AuthenticationChallenge (AuthenticationSchemes scheme, string realm) + internal AuthenticationChallenge ( + AuthenticationSchemes scheme, string realm + ) : base (scheme, new NameValueCollection ()) { Parameters["realm"] = realm; + if (scheme == AuthenticationSchemes.Digest) { Parameters["nonce"] = CreateNonceValue (); Parameters["algorithm"] = "MD5"; From a5978279df10eed6732c62020c31db4aff76f264 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 14 May 2023 16:28:25 +0900 Subject: [PATCH 5131/6294] [Modify] Polish it --- websocket-sharp/Net/AuthenticationChallenge.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/AuthenticationChallenge.cs b/websocket-sharp/Net/AuthenticationChallenge.cs index e4ad787f0..43af81563 100644 --- a/websocket-sharp/Net/AuthenticationChallenge.cs +++ b/websocket-sharp/Net/AuthenticationChallenge.cs @@ -36,7 +36,9 @@ internal class AuthenticationChallenge : AuthenticationBase { #region Private Constructors - private AuthenticationChallenge (AuthenticationSchemes scheme, NameValueCollection parameters) + private AuthenticationChallenge ( + AuthenticationSchemes scheme, NameValueCollection parameters + ) : base (scheme, parameters) { } From 2f48a846ba98cacfe8c5360ecc85fe4717cc9fb9 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 15 May 2023 15:54:40 +0900 Subject: [PATCH 5132/6294] [Modify] Polish it --- .../Net/AuthenticationChallenge.cs | 26 ++++++++++++++----- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/websocket-sharp/Net/AuthenticationChallenge.cs b/websocket-sharp/Net/AuthenticationChallenge.cs index 43af81563..758556de1 100644 --- a/websocket-sharp/Net/AuthenticationChallenge.cs +++ b/websocket-sharp/Net/AuthenticationChallenge.cs @@ -94,17 +94,29 @@ internal static AuthenticationChallenge CreateDigestChallenge (string realm) internal static AuthenticationChallenge Parse (string value) { var chal = value.Split (new[] { ' ' }, 2); + if (chal.Length != 2) return null; var schm = chal[0].ToLower (); - return schm == "basic" - ? new AuthenticationChallenge ( - AuthenticationSchemes.Basic, ParseParameters (chal[1])) - : schm == "digest" - ? new AuthenticationChallenge ( - AuthenticationSchemes.Digest, ParseParameters (chal[1])) - : null; + + if (schm == "basic") { + var parameters = ParseParameters (chal[1]); + + return new AuthenticationChallenge ( + AuthenticationSchemes.Basic, parameters + ); + } + else if (schm == "digest") { + var parameters = ParseParameters (chal[1]); + + return new AuthenticationChallenge ( + AuthenticationSchemes.Digest, parameters + ); + } + else { + return null; + } } internal override string ToBasicString () From 4fa398549398ed1c670ee9225435921dca0a360d Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 16 May 2023 15:37:06 +0900 Subject: [PATCH 5133/6294] [Modify] Polish it --- .../Net/AuthenticationChallenge.cs | 35 ++++++++++++------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/websocket-sharp/Net/AuthenticationChallenge.cs b/websocket-sharp/Net/AuthenticationChallenge.cs index 758556de1..83c775ee4 100644 --- a/websocket-sharp/Net/AuthenticationChallenge.cs +++ b/websocket-sharp/Net/AuthenticationChallenge.cs @@ -126,36 +126,45 @@ internal override string ToBasicString () internal override string ToDigestString () { - var output = new StringBuilder (128); + var buff = new StringBuilder (128); var domain = Parameters["domain"]; - if (domain != null) - output.AppendFormat ( + var realm = Parameters["realm"]; + var nonce = Parameters["nonce"]; + + if (domain != null) { + buff.AppendFormat ( "Digest realm=\"{0}\", domain=\"{1}\", nonce=\"{2}\"", - Parameters["realm"], + realm, domain, - Parameters["nonce"]); - else - output.AppendFormat ( - "Digest realm=\"{0}\", nonce=\"{1}\"", Parameters["realm"], Parameters["nonce"]); + nonce + ); + } + else { + buff.AppendFormat ("Digest realm=\"{0}\", nonce=\"{1}\"", realm, nonce); + } var opaque = Parameters["opaque"]; + if (opaque != null) - output.AppendFormat (", opaque=\"{0}\"", opaque); + buff.AppendFormat (", opaque=\"{0}\"", opaque); var stale = Parameters["stale"]; + if (stale != null) - output.AppendFormat (", stale={0}", stale); + buff.AppendFormat (", stale={0}", stale); var algo = Parameters["algorithm"]; + if (algo != null) - output.AppendFormat (", algorithm={0}", algo); + buff.AppendFormat (", algorithm={0}", algo); var qop = Parameters["qop"]; + if (qop != null) - output.AppendFormat (", qop=\"{0}\"", qop); + buff.AppendFormat (", qop=\"{0}\"", qop); - return output.ToString (); + return buff.ToString (); } #endregion From 732c5068de074bc14df0ba5f85a0be9f7632e403 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 17 May 2023 14:58:41 +0900 Subject: [PATCH 5134/6294] [Modify] Polish it --- websocket-sharp/Net/AuthenticationBase.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/AuthenticationBase.cs b/websocket-sharp/Net/AuthenticationBase.cs index 107750499..a1092ad29 100644 --- a/websocket-sharp/Net/AuthenticationBase.cs +++ b/websocket-sharp/Net/AuthenticationBase.cs @@ -48,7 +48,9 @@ internal abstract class AuthenticationBase #region Protected Constructors - protected AuthenticationBase (AuthenticationSchemes scheme, NameValueCollection parameters) + protected AuthenticationBase ( + AuthenticationSchemes scheme, NameValueCollection parameters + ) { _scheme = scheme; Parameters = parameters; From 116f0ee4072dbab9fad7bb6bb771c1530fb7c225 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 18 May 2023 15:55:48 +0900 Subject: [PATCH 5135/6294] [Modify] Polish it --- websocket-sharp/Net/AuthenticationBase.cs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Net/AuthenticationBase.cs b/websocket-sharp/Net/AuthenticationBase.cs index a1092ad29..a5e31893a 100644 --- a/websocket-sharp/Net/AuthenticationBase.cs +++ b/websocket-sharp/Net/AuthenticationBase.cs @@ -102,15 +102,17 @@ public AuthenticationSchemes Scheme { internal static string CreateNonceValue () { - var src = new byte[16]; var rand = new Random (); - rand.NextBytes (src); + var bytes = new byte[16]; - var res = new StringBuilder (32); - foreach (var b in src) - res.Append (b.ToString ("x2")); + rand.NextBytes (bytes); - return res.ToString (); + var buff = new StringBuilder (32); + + foreach (var b in bytes) + buff.Append (b.ToString ("x2")); + + return buff.ToString (); } internal static NameValueCollection ParseParameters (string value) From 056fcce45f88bbe7be6298c7c4f505c3bdc617fc Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 19 May 2023 17:08:16 +0900 Subject: [PATCH 5136/6294] [Modify] Polish it --- websocket-sharp/Net/AuthenticationBase.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/AuthenticationBase.cs b/websocket-sharp/Net/AuthenticationBase.cs index a5e31893a..52af55128 100644 --- a/websocket-sharp/Net/AuthenticationBase.cs +++ b/websocket-sharp/Net/AuthenticationBase.cs @@ -117,9 +117,11 @@ internal static string CreateNonceValue () internal static NameValueCollection ParseParameters (string value) { - var res = new NameValueCollection (); + var ret = new NameValueCollection (); + foreach (var param in value.SplitHeaderValue (',')) { var i = param.IndexOf ('='); + var name = i > 0 ? param.Substring (0, i).Trim () : null; var val = i < 0 ? param.Trim ().Trim ('"') @@ -127,10 +129,10 @@ internal static NameValueCollection ParseParameters (string value) ? param.Substring (i + 1).Trim ().Trim ('"') : String.Empty; - res.Add (name, val); + ret.Add (name, val); } - return res; + return ret; } internal abstract string ToBasicString (); From 9f373915e1adeae182f6abf4540f2d75d53922e0 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 20 May 2023 16:01:16 +0900 Subject: [PATCH 5137/6294] [Modify] Polish it --- websocket-sharp/Net/AuthenticationBase.cs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Net/AuthenticationBase.cs b/websocket-sharp/Net/AuthenticationBase.cs index 52af55128..ef6a20a48 100644 --- a/websocket-sharp/Net/AuthenticationBase.cs +++ b/websocket-sharp/Net/AuthenticationBase.cs @@ -145,11 +145,15 @@ internal static NameValueCollection ParseParameters (string value) public override string ToString () { - return _scheme == AuthenticationSchemes.Basic - ? ToBasicString () - : _scheme == AuthenticationSchemes.Digest - ? ToDigestString () - : String.Empty; + if (_scheme == AuthenticationSchemes.Basic) { + return ToBasicString (); + } + else if (_scheme == AuthenticationSchemes.Digest) { + return ToDigestString (); + } + else { + return String.Empty; + } } #endregion From e4b83a41b9527611642bb671af235fa479700127 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 21 May 2023 17:56:01 +0900 Subject: [PATCH 5138/6294] [Modify] Polish it --- websocket-sharp/Net/AuthenticationBase.cs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/websocket-sharp/Net/AuthenticationBase.cs b/websocket-sharp/Net/AuthenticationBase.cs index ef6a20a48..775ea0b38 100644 --- a/websocket-sharp/Net/AuthenticationBase.cs +++ b/websocket-sharp/Net/AuthenticationBase.cs @@ -145,15 +145,13 @@ internal static NameValueCollection ParseParameters (string value) public override string ToString () { - if (_scheme == AuthenticationSchemes.Basic) { + if (_scheme == AuthenticationSchemes.Basic) return ToBasicString (); - } - else if (_scheme == AuthenticationSchemes.Digest) { + + if (_scheme == AuthenticationSchemes.Digest) return ToDigestString (); - } - else { - return String.Empty; - } + + return String.Empty; } #endregion From e8b78b8071c7c764c4105c51d75752cd49ce5527 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 22 May 2023 15:33:39 +0900 Subject: [PATCH 5139/6294] [Modify] Polish it --- websocket-sharp/Net/AuthenticationResponse.cs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Net/AuthenticationResponse.cs b/websocket-sharp/Net/AuthenticationResponse.cs index 23636c07b..843a960e0 100644 --- a/websocket-sharp/Net/AuthenticationResponse.cs +++ b/websocket-sharp/Net/AuthenticationResponse.cs @@ -388,12 +388,11 @@ public IIdentity ToIdentity () return new HttpBasicIdentity (user, pass); } - else if (schm == AuthenticationSchemes.Digest) { + + if (schm == AuthenticationSchemes.Digest) return new HttpDigestIdentity (Parameters); - } - else { - return null; - } + + return null; } #endregion From ad6afa3fda071d4c256964184bd61450643aabe4 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 23 May 2023 15:09:17 +0900 Subject: [PATCH 5140/6294] [Modify] Move it --- websocket-sharp/Net/AuthenticationBase.cs | 19 ----------------- .../Net/AuthenticationChallenge.cs | 21 +++++++++++++++++-- websocket-sharp/Net/AuthenticationResponse.cs | 17 +++++++++++++-- 3 files changed, 34 insertions(+), 23 deletions(-) diff --git a/websocket-sharp/Net/AuthenticationBase.cs b/websocket-sharp/Net/AuthenticationBase.cs index 775ea0b38..2c73ae63a 100644 --- a/websocket-sharp/Net/AuthenticationBase.cs +++ b/websocket-sharp/Net/AuthenticationBase.cs @@ -135,25 +135,6 @@ internal static NameValueCollection ParseParameters (string value) return ret; } - internal abstract string ToBasicString (); - - internal abstract string ToDigestString (); - - #endregion - - #region Public Methods - - public override string ToString () - { - if (_scheme == AuthenticationSchemes.Basic) - return ToBasicString (); - - if (_scheme == AuthenticationSchemes.Digest) - return ToDigestString (); - - return String.Empty; - } - #endregion } } diff --git a/websocket-sharp/Net/AuthenticationChallenge.cs b/websocket-sharp/Net/AuthenticationChallenge.cs index 83c775ee4..f45991c00 100644 --- a/websocket-sharp/Net/AuthenticationChallenge.cs +++ b/websocket-sharp/Net/AuthenticationChallenge.cs @@ -119,12 +119,12 @@ internal static AuthenticationChallenge Parse (string value) } } - internal override string ToBasicString () + internal string ToBasicString () { return String.Format ("Basic realm=\"{0}\"", Parameters["realm"]); } - internal override string ToDigestString () + internal string ToDigestString () { var buff = new StringBuilder (128); @@ -168,5 +168,22 @@ internal override string ToDigestString () } #endregion + + #region Public Methods + + public override string ToString () + { + var schm = Scheme; + + if (schm == AuthenticationSchemes.Basic) + return ToBasicString (); + + if (schm == AuthenticationSchemes.Digest) + return ToDigestString (); + + return String.Empty; + } + + #endregion } } diff --git a/websocket-sharp/Net/AuthenticationResponse.cs b/websocket-sharp/Net/AuthenticationResponse.cs index 843a960e0..af8c6d830 100644 --- a/websocket-sharp/Net/AuthenticationResponse.cs +++ b/websocket-sharp/Net/AuthenticationResponse.cs @@ -319,7 +319,7 @@ internal static NameValueCollection ParseBasicCredentials (string value) return ret; } - internal override string ToBasicString () + internal string ToBasicString () { var user = Parameters["username"]; var pass = Parameters["password"]; @@ -331,7 +331,7 @@ internal override string ToBasicString () return "Basic " + cred; } - internal override string ToDigestString () + internal string ToDigestString () { var buff = new StringBuilder (256); @@ -395,6 +395,19 @@ public IIdentity ToIdentity () return null; } + public override string ToString () + { + var schm = Scheme; + + if (schm == AuthenticationSchemes.Basic) + return ToBasicString (); + + if (schm == AuthenticationSchemes.Digest) + return ToDigestString (); + + return String.Empty; + } + #endregion } } From 0c9f187a3e1eadb19b4cec417ae0468de792a04f Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 24 May 2023 16:27:15 +0900 Subject: [PATCH 5141/6294] [Modify] Move it --- websocket-sharp/Net/AuthenticationBase.cs | 15 --------------- websocket-sharp/Net/AuthenticationChallenge.cs | 15 +++++++++++++++ websocket-sharp/Net/AuthenticationResponse.cs | 2 +- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/websocket-sharp/Net/AuthenticationBase.cs b/websocket-sharp/Net/AuthenticationBase.cs index 2c73ae63a..fa71e553c 100644 --- a/websocket-sharp/Net/AuthenticationBase.cs +++ b/websocket-sharp/Net/AuthenticationBase.cs @@ -100,21 +100,6 @@ public AuthenticationSchemes Scheme { #region Internal Methods - internal static string CreateNonceValue () - { - var rand = new Random (); - var bytes = new byte[16]; - - rand.NextBytes (bytes); - - var buff = new StringBuilder (32); - - foreach (var b in bytes) - buff.Append (b.ToString ("x2")); - - return buff.ToString (); - } - internal static NameValueCollection ParseParameters (string value) { var ret = new NameValueCollection (); diff --git a/websocket-sharp/Net/AuthenticationChallenge.cs b/websocket-sharp/Net/AuthenticationChallenge.cs index f45991c00..1e029b123 100644 --- a/websocket-sharp/Net/AuthenticationChallenge.cs +++ b/websocket-sharp/Net/AuthenticationChallenge.cs @@ -91,6 +91,21 @@ internal static AuthenticationChallenge CreateDigestChallenge (string realm) return new AuthenticationChallenge (AuthenticationSchemes.Digest, realm); } + internal static string CreateNonceValue () + { + var rand = new Random (); + var bytes = new byte[16]; + + rand.NextBytes (bytes); + + var buff = new StringBuilder (32); + + foreach (var b in bytes) + buff.Append (b.ToString ("x2")); + + return buff.ToString (); + } + internal static AuthenticationChallenge Parse (string value) { var chal = value.Split (new[] { ' ' }, 2); diff --git a/websocket-sharp/Net/AuthenticationResponse.cs b/websocket-sharp/Net/AuthenticationResponse.cs index af8c6d830..9151fe05f 100644 --- a/websocket-sharp/Net/AuthenticationResponse.cs +++ b/websocket-sharp/Net/AuthenticationResponse.cs @@ -207,7 +207,7 @@ private void initAsDigest () if (auth) { Parameters["qop"] = "auth"; - Parameters["cnonce"] = CreateNonceValue (); + Parameters["cnonce"] = AuthenticationChallenge.CreateNonceValue (); Parameters["nc"] = String.Format ("{0:x8}", ++_nonceCount); } else { From 00b5f900bc37f8ec903378efd43841626d5019df Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 25 May 2023 19:48:22 +0900 Subject: [PATCH 5142/6294] [Modify] Move it --- websocket-sharp/Net/AuthenticationBase.cs | 24 ------------------- .../Net/AuthenticationChallenge.cs | 20 ++++++++++++++++ websocket-sharp/Net/AuthenticationResponse.cs | 2 +- 3 files changed, 21 insertions(+), 25 deletions(-) diff --git a/websocket-sharp/Net/AuthenticationBase.cs b/websocket-sharp/Net/AuthenticationBase.cs index fa71e553c..deb91e5b8 100644 --- a/websocket-sharp/Net/AuthenticationBase.cs +++ b/websocket-sharp/Net/AuthenticationBase.cs @@ -97,29 +97,5 @@ public AuthenticationSchemes Scheme { } #endregion - - #region Internal Methods - - internal static NameValueCollection ParseParameters (string value) - { - var ret = new NameValueCollection (); - - foreach (var param in value.SplitHeaderValue (',')) { - var i = param.IndexOf ('='); - - var name = i > 0 ? param.Substring (0, i).Trim () : null; - var val = i < 0 - ? param.Trim ().Trim ('"') - : i < param.Length - 1 - ? param.Substring (i + 1).Trim ().Trim ('"') - : String.Empty; - - ret.Add (name, val); - } - - return ret; - } - - #endregion } } diff --git a/websocket-sharp/Net/AuthenticationChallenge.cs b/websocket-sharp/Net/AuthenticationChallenge.cs index 1e029b123..2f764e629 100644 --- a/websocket-sharp/Net/AuthenticationChallenge.cs +++ b/websocket-sharp/Net/AuthenticationChallenge.cs @@ -134,6 +134,26 @@ internal static AuthenticationChallenge Parse (string value) } } + internal static NameValueCollection ParseParameters (string value) + { + var ret = new NameValueCollection (); + + foreach (var param in value.SplitHeaderValue (',')) { + var i = param.IndexOf ('='); + + var name = i > 0 ? param.Substring (0, i).Trim () : null; + var val = i < 0 + ? param.Trim ().Trim ('"') + : i < param.Length - 1 + ? param.Substring (i + 1).Trim ().Trim ('"') + : String.Empty; + + ret.Add (name, val); + } + + return ret; + } + internal string ToBasicString () { return String.Format ("Basic realm=\"{0}\"", Parameters["realm"]); diff --git a/websocket-sharp/Net/AuthenticationResponse.cs b/websocket-sharp/Net/AuthenticationResponse.cs index 9151fe05f..ef2c1b5ee 100644 --- a/websocket-sharp/Net/AuthenticationResponse.cs +++ b/websocket-sharp/Net/AuthenticationResponse.cs @@ -274,7 +274,7 @@ internal static AuthenticationResponse Parse (string value) ); } else if (schm == "digest") { - var parameters = ParseParameters (cred[1]); + var parameters = AuthenticationChallenge.ParseParameters (cred[1]); return new AuthenticationResponse ( AuthenticationSchemes.Digest, parameters From 096089a824363ae24c4f2c4e0ea868cc7d66689c Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 26 May 2023 16:45:11 +0900 Subject: [PATCH 5143/6294] [Modify] Polish it --- websocket-sharp/Net/AuthenticationChallenge.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/AuthenticationChallenge.cs b/websocket-sharp/Net/AuthenticationChallenge.cs index 2f764e629..c43fe3899 100644 --- a/websocket-sharp/Net/AuthenticationChallenge.cs +++ b/websocket-sharp/Net/AuthenticationChallenge.cs @@ -122,16 +122,16 @@ internal static AuthenticationChallenge Parse (string value) AuthenticationSchemes.Basic, parameters ); } - else if (schm == "digest") { + + if (schm == "digest") { var parameters = ParseParameters (chal[1]); return new AuthenticationChallenge ( AuthenticationSchemes.Digest, parameters ); } - else { - return null; - } + + return null; } internal static NameValueCollection ParseParameters (string value) From c77a904612f5f818d389557edc0e2077ebb50b8e Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 27 May 2023 16:37:57 +0900 Subject: [PATCH 5144/6294] [Modify] Polish it --- websocket-sharp/Net/AuthenticationResponse.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/AuthenticationResponse.cs b/websocket-sharp/Net/AuthenticationResponse.cs index ef2c1b5ee..a6d73cb2e 100644 --- a/websocket-sharp/Net/AuthenticationResponse.cs +++ b/websocket-sharp/Net/AuthenticationResponse.cs @@ -273,16 +273,16 @@ internal static AuthenticationResponse Parse (string value) AuthenticationSchemes.Basic, parameters ); } - else if (schm == "digest") { + + if (schm == "digest") { var parameters = AuthenticationChallenge.ParseParameters (cred[1]); return new AuthenticationResponse ( AuthenticationSchemes.Digest, parameters ); } - else { - return null; - } + + return null; } catch { return null; From c61073f3d37efcb900ac0d455a24478e204ee63a Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 28 May 2023 17:06:20 +0900 Subject: [PATCH 5145/6294] [Modify] Move it --- websocket-sharp/Net/AuthenticationBase.cs | 6 ------ websocket-sharp/Net/AuthenticationChallenge.cs | 6 ++++++ websocket-sharp/Net/AuthenticationResponse.cs | 6 ++++++ 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Net/AuthenticationBase.cs b/websocket-sharp/Net/AuthenticationBase.cs index deb91e5b8..f903e0f2c 100644 --- a/websocket-sharp/Net/AuthenticationBase.cs +++ b/websocket-sharp/Net/AuthenticationBase.cs @@ -60,12 +60,6 @@ protected AuthenticationBase ( #region Public Properties - public string Algorithm { - get { - return Parameters["algorithm"]; - } - } - public string Nonce { get { return Parameters["nonce"]; diff --git a/websocket-sharp/Net/AuthenticationChallenge.cs b/websocket-sharp/Net/AuthenticationChallenge.cs index c43fe3899..cd34debf5 100644 --- a/websocket-sharp/Net/AuthenticationChallenge.cs +++ b/websocket-sharp/Net/AuthenticationChallenge.cs @@ -65,6 +65,12 @@ internal AuthenticationChallenge ( #region Public Properties + public string Algorithm { + get { + return Parameters["algorithm"]; + } + } + public string Domain { get { return Parameters["domain"]; diff --git a/websocket-sharp/Net/AuthenticationResponse.cs b/websocket-sharp/Net/AuthenticationResponse.cs index a6d73cb2e..50ad78dbe 100644 --- a/websocket-sharp/Net/AuthenticationResponse.cs +++ b/websocket-sharp/Net/AuthenticationResponse.cs @@ -111,6 +111,12 @@ internal uint NonceCount { #region Public Properties + public string Algorithm { + get { + return Parameters["algorithm"]; + } + } + public string Cnonce { get { return Parameters["cnonce"]; From d86be4c7bda6f6d680fe838796bc245860142d4e Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 28 May 2023 17:09:28 +0900 Subject: [PATCH 5146/6294] [Modify] Move it --- websocket-sharp/Net/AuthenticationBase.cs | 6 ------ websocket-sharp/Net/AuthenticationChallenge.cs | 6 ++++++ websocket-sharp/Net/AuthenticationResponse.cs | 6 ++++++ 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Net/AuthenticationBase.cs b/websocket-sharp/Net/AuthenticationBase.cs index f903e0f2c..6e7d3704b 100644 --- a/websocket-sharp/Net/AuthenticationBase.cs +++ b/websocket-sharp/Net/AuthenticationBase.cs @@ -60,12 +60,6 @@ protected AuthenticationBase ( #region Public Properties - public string Nonce { - get { - return Parameters["nonce"]; - } - } - public string Opaque { get { return Parameters["opaque"]; diff --git a/websocket-sharp/Net/AuthenticationChallenge.cs b/websocket-sharp/Net/AuthenticationChallenge.cs index cd34debf5..1ff25783e 100644 --- a/websocket-sharp/Net/AuthenticationChallenge.cs +++ b/websocket-sharp/Net/AuthenticationChallenge.cs @@ -77,6 +77,12 @@ public string Domain { } } + public string Nonce { + get { + return Parameters["nonce"]; + } + } + public string Stale { get { return Parameters["stale"]; diff --git a/websocket-sharp/Net/AuthenticationResponse.cs b/websocket-sharp/Net/AuthenticationResponse.cs index 50ad78dbe..e1a235e48 100644 --- a/websocket-sharp/Net/AuthenticationResponse.cs +++ b/websocket-sharp/Net/AuthenticationResponse.cs @@ -129,6 +129,12 @@ public string Nc { } } + public string Nonce { + get { + return Parameters["nonce"]; + } + } + public string Password { get { return Parameters["password"]; From 3ecef5587d6af545de90788957758c83fdfaeafd Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 29 May 2023 17:48:54 +0900 Subject: [PATCH 5147/6294] [Modify] Move it --- websocket-sharp/Net/AuthenticationBase.cs | 6 ------ websocket-sharp/Net/AuthenticationChallenge.cs | 6 ++++++ websocket-sharp/Net/AuthenticationResponse.cs | 6 ++++++ 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Net/AuthenticationBase.cs b/websocket-sharp/Net/AuthenticationBase.cs index 6e7d3704b..09afcefc1 100644 --- a/websocket-sharp/Net/AuthenticationBase.cs +++ b/websocket-sharp/Net/AuthenticationBase.cs @@ -60,12 +60,6 @@ protected AuthenticationBase ( #region Public Properties - public string Opaque { - get { - return Parameters["opaque"]; - } - } - public string Qop { get { return Parameters["qop"]; diff --git a/websocket-sharp/Net/AuthenticationChallenge.cs b/websocket-sharp/Net/AuthenticationChallenge.cs index 1ff25783e..2f50f7448 100644 --- a/websocket-sharp/Net/AuthenticationChallenge.cs +++ b/websocket-sharp/Net/AuthenticationChallenge.cs @@ -83,6 +83,12 @@ public string Nonce { } } + public string Opaque { + get { + return Parameters["opaque"]; + } + } + public string Stale { get { return Parameters["stale"]; diff --git a/websocket-sharp/Net/AuthenticationResponse.cs b/websocket-sharp/Net/AuthenticationResponse.cs index e1a235e48..853b8627c 100644 --- a/websocket-sharp/Net/AuthenticationResponse.cs +++ b/websocket-sharp/Net/AuthenticationResponse.cs @@ -135,6 +135,12 @@ public string Nonce { } } + public string Opaque { + get { + return Parameters["opaque"]; + } + } + public string Password { get { return Parameters["password"]; From 4e58bf67302e820156d5e84665b1d23d05f398a4 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 29 May 2023 17:52:14 +0900 Subject: [PATCH 5148/6294] [Modify] Move it --- websocket-sharp/Net/AuthenticationBase.cs | 6 ------ websocket-sharp/Net/AuthenticationChallenge.cs | 6 ++++++ websocket-sharp/Net/AuthenticationResponse.cs | 6 ++++++ 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Net/AuthenticationBase.cs b/websocket-sharp/Net/AuthenticationBase.cs index 09afcefc1..a94d5ccc9 100644 --- a/websocket-sharp/Net/AuthenticationBase.cs +++ b/websocket-sharp/Net/AuthenticationBase.cs @@ -60,12 +60,6 @@ protected AuthenticationBase ( #region Public Properties - public string Qop { - get { - return Parameters["qop"]; - } - } - public string Realm { get { return Parameters["realm"]; diff --git a/websocket-sharp/Net/AuthenticationChallenge.cs b/websocket-sharp/Net/AuthenticationChallenge.cs index 2f50f7448..4422281fb 100644 --- a/websocket-sharp/Net/AuthenticationChallenge.cs +++ b/websocket-sharp/Net/AuthenticationChallenge.cs @@ -89,6 +89,12 @@ public string Opaque { } } + public string Qop { + get { + return Parameters["qop"]; + } + } + public string Stale { get { return Parameters["stale"]; diff --git a/websocket-sharp/Net/AuthenticationResponse.cs b/websocket-sharp/Net/AuthenticationResponse.cs index 853b8627c..d10277c1a 100644 --- a/websocket-sharp/Net/AuthenticationResponse.cs +++ b/websocket-sharp/Net/AuthenticationResponse.cs @@ -147,6 +147,12 @@ public string Password { } } + public string Qop { + get { + return Parameters["qop"]; + } + } + public string Response { get { return Parameters["response"]; From 834167e6c71dead07bdfd1770ef370c9804e5e91 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 30 May 2023 15:50:54 +0900 Subject: [PATCH 5149/6294] [Modify] Move it --- websocket-sharp/Net/AuthenticationBase.cs | 6 ------ websocket-sharp/Net/AuthenticationChallenge.cs | 6 ++++++ websocket-sharp/Net/AuthenticationResponse.cs | 6 ++++++ 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Net/AuthenticationBase.cs b/websocket-sharp/Net/AuthenticationBase.cs index a94d5ccc9..6d29658a6 100644 --- a/websocket-sharp/Net/AuthenticationBase.cs +++ b/websocket-sharp/Net/AuthenticationBase.cs @@ -60,12 +60,6 @@ protected AuthenticationBase ( #region Public Properties - public string Realm { - get { - return Parameters["realm"]; - } - } - public AuthenticationSchemes Scheme { get { return _scheme; diff --git a/websocket-sharp/Net/AuthenticationChallenge.cs b/websocket-sharp/Net/AuthenticationChallenge.cs index 4422281fb..d09ae828a 100644 --- a/websocket-sharp/Net/AuthenticationChallenge.cs +++ b/websocket-sharp/Net/AuthenticationChallenge.cs @@ -95,6 +95,12 @@ public string Qop { } } + public string Realm { + get { + return Parameters["realm"]; + } + } + public string Stale { get { return Parameters["stale"]; diff --git a/websocket-sharp/Net/AuthenticationResponse.cs b/websocket-sharp/Net/AuthenticationResponse.cs index d10277c1a..ea0918448 100644 --- a/websocket-sharp/Net/AuthenticationResponse.cs +++ b/websocket-sharp/Net/AuthenticationResponse.cs @@ -153,6 +153,12 @@ public string Qop { } } + public string Realm { + get { + return Parameters["realm"]; + } + } + public string Response { get { return Parameters["response"]; From 0dc175b6ad4109e91885511e0ce163b2452328af Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 31 May 2023 20:17:35 +0900 Subject: [PATCH 5150/6294] [Modify] Do not inherit it --- .../Net/AuthenticationChallenge.cs | 68 ++++++++----- websocket-sharp/Net/AuthenticationResponse.cs | 95 +++++++++++-------- 2 files changed, 101 insertions(+), 62 deletions(-) diff --git a/websocket-sharp/Net/AuthenticationChallenge.cs b/websocket-sharp/Net/AuthenticationChallenge.cs index d09ae828a..5024f79ab 100644 --- a/websocket-sharp/Net/AuthenticationChallenge.cs +++ b/websocket-sharp/Net/AuthenticationChallenge.cs @@ -32,15 +32,23 @@ namespace WebSocketSharp.Net { - internal class AuthenticationChallenge : AuthenticationBase + internal class AuthenticationChallenge { + #region Private Fields + + private NameValueCollection _parameters; + private AuthenticationSchemes _scheme; + + #endregion + #region Private Constructors private AuthenticationChallenge ( AuthenticationSchemes scheme, NameValueCollection parameters ) - : base (scheme, parameters) { + _scheme = scheme; + _parameters = parameters; } #endregion @@ -50,14 +58,24 @@ private AuthenticationChallenge ( internal AuthenticationChallenge ( AuthenticationSchemes scheme, string realm ) - : base (scheme, new NameValueCollection ()) + : this (scheme, new NameValueCollection ()) { - Parameters["realm"] = realm; + _parameters["realm"] = realm; if (scheme == AuthenticationSchemes.Digest) { - Parameters["nonce"] = CreateNonceValue (); - Parameters["algorithm"] = "MD5"; - Parameters["qop"] = "auth"; + _parameters["nonce"] = CreateNonceValue (); + _parameters["algorithm"] = "MD5"; + _parameters["qop"] = "auth"; + } + } + + #endregion + + #region Internal Properties + + internal NameValueCollection Parameters { + get { + return _parameters; } } @@ -67,43 +85,49 @@ internal AuthenticationChallenge ( public string Algorithm { get { - return Parameters["algorithm"]; + return _parameters["algorithm"]; } } public string Domain { get { - return Parameters["domain"]; + return _parameters["domain"]; } } public string Nonce { get { - return Parameters["nonce"]; + return _parameters["nonce"]; } } public string Opaque { get { - return Parameters["opaque"]; + return _parameters["opaque"]; } } public string Qop { get { - return Parameters["qop"]; + return _parameters["qop"]; } } public string Realm { get { - return Parameters["realm"]; + return _parameters["realm"]; + } + } + + public AuthenticationSchemes Scheme { + get { + return _scheme; } } public string Stale { get { - return Parameters["stale"]; + return _parameters["stale"]; } } @@ -186,16 +210,16 @@ internal static NameValueCollection ParseParameters (string value) internal string ToBasicString () { - return String.Format ("Basic realm=\"{0}\"", Parameters["realm"]); + return String.Format ("Basic realm=\"{0}\"", _parameters["realm"]); } internal string ToDigestString () { var buff = new StringBuilder (128); - var domain = Parameters["domain"]; - var realm = Parameters["realm"]; - var nonce = Parameters["nonce"]; + var domain = _parameters["domain"]; + var realm = _parameters["realm"]; + var nonce = _parameters["nonce"]; if (domain != null) { buff.AppendFormat ( @@ -209,22 +233,22 @@ internal string ToDigestString () buff.AppendFormat ("Digest realm=\"{0}\", nonce=\"{1}\"", realm, nonce); } - var opaque = Parameters["opaque"]; + var opaque = _parameters["opaque"]; if (opaque != null) buff.AppendFormat (", opaque=\"{0}\"", opaque); - var stale = Parameters["stale"]; + var stale = _parameters["stale"]; if (stale != null) buff.AppendFormat (", stale={0}", stale); - var algo = Parameters["algorithm"]; + var algo = _parameters["algorithm"]; if (algo != null) buff.AppendFormat (", algorithm={0}", algo); - var qop = Parameters["qop"]; + var qop = _parameters["qop"]; if (qop != null) buff.AppendFormat (", qop=\"{0}\"", qop); diff --git a/websocket-sharp/Net/AuthenticationResponse.cs b/websocket-sharp/Net/AuthenticationResponse.cs index ea0918448..9526a62d6 100644 --- a/websocket-sharp/Net/AuthenticationResponse.cs +++ b/websocket-sharp/Net/AuthenticationResponse.cs @@ -38,11 +38,13 @@ namespace WebSocketSharp.Net { - internal class AuthenticationResponse : AuthenticationBase + internal class AuthenticationResponse { #region Private Fields - private uint _nonceCount; + private uint _nonceCount; + private NameValueCollection _parameters; + private AuthenticationSchemes _scheme; #endregion @@ -51,8 +53,9 @@ internal class AuthenticationResponse : AuthenticationBase private AuthenticationResponse ( AuthenticationSchemes scheme, NameValueCollection parameters ) - : base (scheme, parameters) { + _scheme = scheme; + _parameters = parameters; } #endregion @@ -84,11 +87,11 @@ internal AuthenticationResponse ( NetworkCredential credentials, uint nonceCount ) - : base (scheme, parameters) + : this (scheme, parameters) { - Parameters["username"] = credentials.Username; - Parameters["password"] = credentials.Password; - Parameters["uri"] = credentials.Domain; + _parameters["username"] = credentials.Username; + _parameters["password"] = credentials.Password; + _parameters["uri"] = credentials.Domain; _nonceCount = nonceCount; if (scheme == AuthenticationSchemes.Digest) @@ -107,73 +110,85 @@ internal uint NonceCount { } } + internal NameValueCollection Parameters { + get { + return _parameters; + } + } + #endregion #region Public Properties public string Algorithm { get { - return Parameters["algorithm"]; + return _parameters["algorithm"]; } } public string Cnonce { get { - return Parameters["cnonce"]; + return _parameters["cnonce"]; } } public string Nc { get { - return Parameters["nc"]; + return _parameters["nc"]; } } public string Nonce { get { - return Parameters["nonce"]; + return _parameters["nonce"]; } } public string Opaque { get { - return Parameters["opaque"]; + return _parameters["opaque"]; } } public string Password { get { - return Parameters["password"]; + return _parameters["password"]; } } public string Qop { get { - return Parameters["qop"]; + return _parameters["qop"]; } } public string Realm { get { - return Parameters["realm"]; + return _parameters["realm"]; } } public string Response { get { - return Parameters["response"]; + return _parameters["response"]; + } + } + + public AuthenticationSchemes Scheme { + get { + return _scheme; } } public string Uri { get { - return Parameters["uri"]; + return _parameters["uri"]; } } public string UserName { get { - return Parameters["username"]; + return _parameters["username"]; } } @@ -228,7 +243,7 @@ private static string hash (string value) private void initAsDigest () { - var qops = Parameters["qop"]; + var qops = _parameters["qop"]; if (qops != null) { var auth = qops.Split (',').Contains ( @@ -236,17 +251,17 @@ private void initAsDigest () ); if (auth) { - Parameters["qop"] = "auth"; - Parameters["cnonce"] = AuthenticationChallenge.CreateNonceValue (); - Parameters["nc"] = String.Format ("{0:x8}", ++_nonceCount); + _parameters["qop"] = "auth"; + _parameters["cnonce"] = AuthenticationChallenge.CreateNonceValue (); + _parameters["nc"] = String.Format ("{0:x8}", ++_nonceCount); } else { - Parameters["qop"] = null; + _parameters["qop"] = null; } } - Parameters["method"] = "GET"; - Parameters["response"] = CreateRequestDigest (Parameters); + _parameters["method"] = "GET"; + _parameters["response"] = CreateRequestDigest (_parameters); } #endregion @@ -351,8 +366,8 @@ internal static NameValueCollection ParseBasicCredentials (string value) internal string ToBasicString () { - var user = Parameters["username"]; - var pass = Parameters["password"]; + var user = _parameters["username"]; + var pass = _parameters["password"]; var userPass = String.Format ("{0}:{1}", user, pass); var bytes = Encoding.UTF8.GetBytes (userPass); @@ -365,11 +380,11 @@ internal string ToDigestString () { var buff = new StringBuilder (256); - var user = Parameters["username"]; - var realm = Parameters["realm"]; - var nonce = Parameters["nonce"]; - var uri = Parameters["uri"]; - var res = Parameters["response"]; + var user = _parameters["username"]; + var realm = _parameters["realm"]; + var nonce = _parameters["nonce"]; + var uri = _parameters["uri"]; + var res = _parameters["response"]; buff.AppendFormat ( "Digest username=\"{0}\", realm=\"{1}\", nonce=\"{2}\", uri=\"{3}\", response=\"{4}\"", @@ -380,21 +395,21 @@ internal string ToDigestString () res ); - var opaque = Parameters["opaque"]; + var opaque = _parameters["opaque"]; if (opaque != null) buff.AppendFormat (", opaque=\"{0}\"", opaque); - var algo = Parameters["algorithm"]; + var algo = _parameters["algorithm"]; if (algo != null) buff.AppendFormat (", algorithm={0}", algo); - var qop = Parameters["qop"]; + var qop = _parameters["qop"]; if (qop != null) { - var cnonce = Parameters["cnonce"]; - var nc = Parameters["nc"]; + var cnonce = _parameters["cnonce"]; + var nc = _parameters["nc"]; buff.AppendFormat ( ", qop={0}, cnonce=\"{1}\", nc={2}", qop, cnonce, nc @@ -413,14 +428,14 @@ public IIdentity ToIdentity () var schm = Scheme; if (schm == AuthenticationSchemes.Basic) { - var user = Parameters["username"]; - var pass = Parameters["password"]; + var user = _parameters["username"]; + var pass = _parameters["password"]; return new HttpBasicIdentity (user, pass); } if (schm == AuthenticationSchemes.Digest) - return new HttpDigestIdentity (Parameters); + return new HttpDigestIdentity (_parameters); return null; } From 840486034103e2c9180fdbefa51a589086d66209 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 1 Jun 2023 16:44:31 +0900 Subject: [PATCH 5151/6294] [Delete] AuthenticationBase.cs --- websocket-sharp/Net/AuthenticationBase.cs | 71 ----------------------- websocket-sharp/websocket-sharp.csproj | 3 +- 2 files changed, 1 insertion(+), 73 deletions(-) delete mode 100644 websocket-sharp/Net/AuthenticationBase.cs diff --git a/websocket-sharp/Net/AuthenticationBase.cs b/websocket-sharp/Net/AuthenticationBase.cs deleted file mode 100644 index 6d29658a6..000000000 --- a/websocket-sharp/Net/AuthenticationBase.cs +++ /dev/null @@ -1,71 +0,0 @@ -#region License -/* - * AuthenticationBase.cs - * - * The MIT License - * - * Copyright (c) 2014 sta.blockhead - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, 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 NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -#endregion - -using System; -using System.Collections.Specialized; -using System.Text; - -namespace WebSocketSharp.Net -{ - internal abstract class AuthenticationBase - { - #region Private Fields - - private AuthenticationSchemes _scheme; - - #endregion - - #region Internal Fields - - internal NameValueCollection Parameters; - - #endregion - - #region Protected Constructors - - protected AuthenticationBase ( - AuthenticationSchemes scheme, NameValueCollection parameters - ) - { - _scheme = scheme; - Parameters = parameters; - } - - #endregion - - #region Public Properties - - public AuthenticationSchemes Scheme { - get { - return _scheme; - } - } - - #endregion - } -} diff --git a/websocket-sharp/websocket-sharp.csproj b/websocket-sharp/websocket-sharp.csproj index 0860c0313..9dac290aa 100644 --- a/websocket-sharp/websocket-sharp.csproj +++ b/websocket-sharp/websocket-sharp.csproj @@ -51,7 +51,7 @@ true - + @@ -127,7 +127,6 @@ - From 76272bac91b7efa0dbb79508869b3ccfc56cfcbc Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 2 Jun 2023 15:47:52 +0900 Subject: [PATCH 5152/6294] [Modify] Polish it --- websocket-sharp/Net/AuthenticationChallenge.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/AuthenticationChallenge.cs b/websocket-sharp/Net/AuthenticationChallenge.cs index 5024f79ab..6d577c3e9 100644 --- a/websocket-sharp/Net/AuthenticationChallenge.cs +++ b/websocket-sharp/Net/AuthenticationChallenge.cs @@ -262,12 +262,10 @@ internal string ToDigestString () public override string ToString () { - var schm = Scheme; - - if (schm == AuthenticationSchemes.Basic) + if (_scheme == AuthenticationSchemes.Basic) return ToBasicString (); - if (schm == AuthenticationSchemes.Digest) + if (_scheme == AuthenticationSchemes.Digest) return ToDigestString (); return String.Empty; From 19abed80a202edb7f382c45436509d6e01ea67d1 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 3 Jun 2023 16:50:05 +0900 Subject: [PATCH 5153/6294] [Modify] Polish it --- websocket-sharp/Net/AuthenticationResponse.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/AuthenticationResponse.cs b/websocket-sharp/Net/AuthenticationResponse.cs index 9526a62d6..0ccb3d6f4 100644 --- a/websocket-sharp/Net/AuthenticationResponse.cs +++ b/websocket-sharp/Net/AuthenticationResponse.cs @@ -442,12 +442,10 @@ public IIdentity ToIdentity () public override string ToString () { - var schm = Scheme; - - if (schm == AuthenticationSchemes.Basic) + if (_scheme == AuthenticationSchemes.Basic) return ToBasicString (); - if (schm == AuthenticationSchemes.Digest) + if (_scheme == AuthenticationSchemes.Digest) return ToDigestString (); return String.Empty; From 7a71a4c0124b586b0d150acd3f8748021f87e33d Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 4 Jun 2023 17:49:48 +0900 Subject: [PATCH 5154/6294] [Modify] Polish it --- websocket-sharp/Net/AuthenticationResponse.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/AuthenticationResponse.cs b/websocket-sharp/Net/AuthenticationResponse.cs index 0ccb3d6f4..3b0e43c8c 100644 --- a/websocket-sharp/Net/AuthenticationResponse.cs +++ b/websocket-sharp/Net/AuthenticationResponse.cs @@ -425,16 +425,14 @@ internal string ToDigestString () public IIdentity ToIdentity () { - var schm = Scheme; - - if (schm == AuthenticationSchemes.Basic) { + if (_scheme == AuthenticationSchemes.Basic) { var user = _parameters["username"]; var pass = _parameters["password"]; return new HttpBasicIdentity (user, pass); } - if (schm == AuthenticationSchemes.Digest) + if (_scheme == AuthenticationSchemes.Digest) return new HttpDigestIdentity (_parameters); return null; From 3f22f75ada67b993d50a904b183653ac463141bf Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 5 Jun 2023 21:14:51 +0900 Subject: [PATCH 5155/6294] [Modify] 2023 --- websocket-sharp/Net/AuthenticationChallenge.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/AuthenticationChallenge.cs b/websocket-sharp/Net/AuthenticationChallenge.cs index 6d577c3e9..30a8f9630 100644 --- a/websocket-sharp/Net/AuthenticationChallenge.cs +++ b/websocket-sharp/Net/AuthenticationChallenge.cs @@ -4,7 +4,7 @@ * * The MIT License * - * Copyright (c) 2013-2014 sta.blockhead + * Copyright (c) 2013-2023 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From 27285d327863886833009383e136409f33a89d72 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 6 Jun 2023 21:46:38 +0900 Subject: [PATCH 5156/6294] [Modify] 2023 --- websocket-sharp/Net/AuthenticationResponse.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/AuthenticationResponse.cs b/websocket-sharp/Net/AuthenticationResponse.cs index 3b0e43c8c..8113be6cf 100644 --- a/websocket-sharp/Net/AuthenticationResponse.cs +++ b/websocket-sharp/Net/AuthenticationResponse.cs @@ -8,7 +8,7 @@ * The MIT License * * Copyright (c) 2005 Novell, Inc. (http://www.novell.com) - * Copyright (c) 2013-2014 sta.blockhead + * Copyright (c) 2013-2023 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From 125da455e61e076a0346783744d306226a8f70d7 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 7 Jun 2023 16:48:45 +0900 Subject: [PATCH 5157/6294] [Modify] Polish it --- websocket-sharp/Net/HttpDigestIdentity.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/websocket-sharp/Net/HttpDigestIdentity.cs b/websocket-sharp/Net/HttpDigestIdentity.cs index 68ec86d9f..7bb87a190 100644 --- a/websocket-sharp/Net/HttpDigestIdentity.cs +++ b/websocket-sharp/Net/HttpDigestIdentity.cs @@ -173,12 +173,14 @@ internal bool IsValid ( ) { var copied = new NameValueCollection (_parameters); + copied["password"] = password; copied["realm"] = realm; copied["method"] = method; copied["entity"] = entity; var expected = AuthenticationResponse.CreateRequestDigest (copied); + return _parameters["response"] == expected; } From 34c1ef2e405de969797a759dfacaed3515a18562 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 8 Jun 2023 22:05:28 +0900 Subject: [PATCH 5158/6294] [Modify] Edit it --- websocket-sharp/Net/HttpDigestIdentity.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpDigestIdentity.cs b/websocket-sharp/Net/HttpDigestIdentity.cs index 7bb87a190..27f0addbb 100644 --- a/websocket-sharp/Net/HttpDigestIdentity.cs +++ b/websocket-sharp/Net/HttpDigestIdentity.cs @@ -33,8 +33,8 @@ namespace WebSocketSharp.Net { /// - /// Holds the username and other parameters from - /// an HTTP Digest authentication attempt. + /// Holds the username and other parameters from an HTTP Digest + /// authentication attempt. /// public class HttpDigestIdentity : GenericIdentity { From 98b0b54faa065e47df7e34fc664f02aebe02489c Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 9 Jun 2023 15:15:18 +0900 Subject: [PATCH 5159/6294] [Modify] Polish it --- websocket-sharp/Net/HttpDigestIdentity.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Net/HttpDigestIdentity.cs b/websocket-sharp/Net/HttpDigestIdentity.cs index 27f0addbb..1b2075657 100644 --- a/websocket-sharp/Net/HttpDigestIdentity.cs +++ b/websocket-sharp/Net/HttpDigestIdentity.cs @@ -172,14 +172,14 @@ internal bool IsValid ( string password, string realm, string method, string entity ) { - var copied = new NameValueCollection (_parameters); + var parameters = new NameValueCollection (_parameters); - copied["password"] = password; - copied["realm"] = realm; - copied["method"] = method; - copied["entity"] = entity; + parameters["password"] = password; + parameters["realm"] = realm; + parameters["method"] = method; + parameters["entity"] = entity; - var expected = AuthenticationResponse.CreateRequestDigest (copied); + var expected = AuthenticationResponse.CreateRequestDigest (parameters); return _parameters["response"] == expected; } From a067b0ebe04b36be48ad215c1c7f5b50ca776802 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 10 Jun 2023 15:34:55 +0900 Subject: [PATCH 5160/6294] [Modify] 2023 --- websocket-sharp/Net/HttpDigestIdentity.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpDigestIdentity.cs b/websocket-sharp/Net/HttpDigestIdentity.cs index 1b2075657..de1878e25 100644 --- a/websocket-sharp/Net/HttpDigestIdentity.cs +++ b/websocket-sharp/Net/HttpDigestIdentity.cs @@ -4,7 +4,7 @@ * * The MIT License * - * Copyright (c) 2014-2017 sta.blockhead + * Copyright (c) 2014-2023 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From d98e54e1643aed61a7150ca951ac23532a592fda Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 11 Jun 2023 17:53:51 +0900 Subject: [PATCH 5161/6294] [Modify] Polish it --- websocket-sharp/Net/Cookie.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/websocket-sharp/Net/Cookie.cs b/websocket-sharp/Net/Cookie.cs index 1c5a4bf2d..98047f579 100644 --- a/websocket-sharp/Net/Cookie.cs +++ b/websocket-sharp/Net/Cookie.cs @@ -576,11 +576,13 @@ public string Name { if (value[0] == '$') { var msg = "It starts with a dollar sign."; + throw new ArgumentException (msg, "value"); } if (!value.IsToken ()) { var msg = "It contains an invalid character."; + throw new ArgumentException (msg, "value"); } From 9684c32b69aff2c9b5123a1ca0f668453de034fb Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 12 Jun 2023 17:51:08 +0900 Subject: [PATCH 5162/6294] [Modify] Polish it --- websocket-sharp/Net/Cookie.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Net/Cookie.cs b/websocket-sharp/Net/Cookie.cs index 98047f579..4b5b5a408 100644 --- a/websocket-sharp/Net/Cookie.cs +++ b/websocket-sharp/Net/Cookie.cs @@ -699,6 +699,7 @@ public string Value { if (value.Contains (_reservedCharsForValue)) { if (!value.IsEnclosedIn ('"')) { var msg = "A string not enclosed in double quotes."; + throw new ArgumentException (msg, "value"); } } From 79b7ef802d2a5e01dbff54ad6ce5b8c0fb510497 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 13 Jun 2023 21:53:13 +0900 Subject: [PATCH 5163/6294] [Modify] Edit it --- websocket-sharp/Net/Cookie.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/Cookie.cs b/websocket-sharp/Net/Cookie.cs index 4b5b5a408..bd6e4680c 100644 --- a/websocket-sharp/Net/Cookie.cs +++ b/websocket-sharp/Net/Cookie.cs @@ -685,7 +685,7 @@ public DateTime TimeStamp { /// /// /// The value specified for a set operation is a string not enclosed in - /// double quotes that contains an invalid character. + /// double quotes although it contains a reserved character. /// public string Value { get { From 1c1301cfc26b24613884f20c752b74fba3479523 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 14 Jun 2023 17:36:57 +0900 Subject: [PATCH 5164/6294] [Modify] Polish it --- websocket-sharp/Net/Cookie.cs | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/websocket-sharp/Net/Cookie.cs b/websocket-sharp/Net/Cookie.cs index bd6e4680c..d62e2157f 100644 --- a/websocket-sharp/Net/Cookie.cs +++ b/websocket-sharp/Net/Cookie.cs @@ -917,20 +917,15 @@ internal string ToRequestString (Uri uri) return buff.ToString (); } - /// - /// Returns a string that represents the current cookie instance. - /// - /// - /// A that is suitable for the Set-Cookie response - /// header. - /// internal string ToResponseString () { - return _name.Length == 0 - ? String.Empty - : _version == 0 - ? toResponseStringVersion0 () - : toResponseStringVersion1 (); + if (_name.Length == 0) + return String.Empty; + + if (_version == 0) + return toResponseStringVersion0 (); + + return toResponseStringVersion1 (); } internal static bool TryCreate ( From 10ff438e1b0a91d93aaee075e2eb35ba894eaa37 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 15 Jun 2023 17:27:52 +0900 Subject: [PATCH 5165/6294] [Modify] Polish it --- websocket-sharp/Net/Cookie.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Net/Cookie.cs b/websocket-sharp/Net/Cookie.cs index d62e2157f..a1b464ed7 100644 --- a/websocket-sharp/Net/Cookie.cs +++ b/websocket-sharp/Net/Cookie.cs @@ -968,6 +968,7 @@ internal static bool TryCreate ( public override bool Equals (object comparand) { var cookie = comparand as Cookie; + if (cookie == null) return false; From df1f81e03482d6492592cc14f7046c941d35dcb9 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 16 Jun 2023 17:22:38 +0900 Subject: [PATCH 5166/6294] [Modify] Polish it --- websocket-sharp/Net/Cookie.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/websocket-sharp/Net/Cookie.cs b/websocket-sharp/Net/Cookie.cs index a1b464ed7..8637224a7 100644 --- a/websocket-sharp/Net/Cookie.cs +++ b/websocket-sharp/Net/Cookie.cs @@ -990,13 +990,13 @@ public override bool Equals (object comparand) /// public override int GetHashCode () { - return hash ( - StringComparer.InvariantCultureIgnoreCase.GetHashCode (_name), - _value.GetHashCode (), - _path.GetHashCode (), - StringComparer.InvariantCultureIgnoreCase.GetHashCode (_domain), - _version - ); + var i = StringComparer.InvariantCultureIgnoreCase.GetHashCode (_name); + var j = _value.GetHashCode (); + var k = _path.GetHashCode (); + var l = StringComparer.InvariantCultureIgnoreCase.GetHashCode (_domain); + var m = _version; + + return hash (i, j, k, l, m); } /// From 7d6ebbddaf2a5b6bfb726f8878657f46cdf9648b Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 17 Jun 2023 22:05:44 +0900 Subject: [PATCH 5167/6294] [Modify] Polish it --- websocket-sharp/Net/Cookie.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/websocket-sharp/Net/Cookie.cs b/websocket-sharp/Net/Cookie.cs index 8637224a7..3e4131344 100644 --- a/websocket-sharp/Net/Cookie.cs +++ b/websocket-sharp/Net/Cookie.cs @@ -845,8 +845,10 @@ private static bool tryCreatePorts (string value, out int[] result) for (var i = 0; i < len; i++) { var s = arr[i].Trim (); + if (s.Length == 0) { res[i] = Int32.MinValue; + continue; } @@ -855,6 +857,7 @@ private static bool tryCreatePorts (string value, out int[] result) } result = res; + return true; } From 5c8c4277fea18badbf1d749eaf3e9d734ad27d45 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 18 Jun 2023 17:08:12 +0900 Subject: [PATCH 5168/6294] [Modify] Polish it --- websocket-sharp/Net/Cookie.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Net/Cookie.cs b/websocket-sharp/Net/Cookie.cs index 3e4131344..782fdcf2c 100644 --- a/websocket-sharp/Net/Cookie.cs +++ b/websocket-sharp/Net/Cookie.cs @@ -333,6 +333,7 @@ internal int MaxAge { : _expires; var span = expires - DateTime.Now; + return span > TimeSpan.Zero ? (int) span.TotalSeconds : 0; From b374edd41cef6a920f0ae2b5b676b1803c89122d Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 19 Jun 2023 21:22:22 +0900 Subject: [PATCH 5169/6294] [Modify] Polish it --- websocket-sharp/Net/Cookie.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/websocket-sharp/Net/Cookie.cs b/websocket-sharp/Net/Cookie.cs index 782fdcf2c..d4dfede60 100644 --- a/websocket-sharp/Net/Cookie.cs +++ b/websocket-sharp/Net/Cookie.cs @@ -292,11 +292,13 @@ public Cookie (string name, string value, string path, string domain) if (name[0] == '$') { var msg = "It starts with a dollar sign."; + throw new ArgumentException (msg, "name"); } if (!name.IsToken ()) { var msg = "It contains an invalid character."; + throw new ArgumentException (msg, "name"); } @@ -306,6 +308,7 @@ public Cookie (string name, string value, string path, string domain) if (value.Contains (_reservedCharsForValue)) { if (!value.IsEnclosedIn ('"')) { var msg = "A string not enclosed in double quotes."; + throw new ArgumentException (msg, "value"); } } From d1f7d738deca404725a9c0a4f222887690b26f06 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 20 Jun 2023 16:18:20 +0900 Subject: [PATCH 5170/6294] [Modify] Edit it --- websocket-sharp/Net/Cookie.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/Cookie.cs b/websocket-sharp/Net/Cookie.cs index d4dfede60..dc111b81c 100644 --- a/websocket-sharp/Net/Cookie.cs +++ b/websocket-sharp/Net/Cookie.cs @@ -279,7 +279,7 @@ public Cookie (string name, string value, string path) /// /// /// is a string not enclosed in double quotes - /// that contains an invalid character. + /// although it contains a reserved character. /// /// public Cookie (string name, string value, string path, string domain) From 37941eddd61be12e9c71d6e2b81bf9a311894ad4 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 21 Jun 2023 17:38:00 +0900 Subject: [PATCH 5171/6294] [Modify] Edit it --- websocket-sharp/Net/Cookie.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/Cookie.cs b/websocket-sharp/Net/Cookie.cs index dc111b81c..94c161b97 100644 --- a/websocket-sharp/Net/Cookie.cs +++ b/websocket-sharp/Net/Cookie.cs @@ -222,7 +222,7 @@ public Cookie (string name, string value) /// /// /// is a string not enclosed in double quotes - /// that contains an invalid character. + /// although it contains a reserved character. /// /// public Cookie (string name, string value, string path) From f63d2ad1555423a4577634dedfb1315ccbaf006e Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 21 Jun 2023 17:40:23 +0900 Subject: [PATCH 5172/6294] [Modify] Edit it --- websocket-sharp/Net/Cookie.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/Cookie.cs b/websocket-sharp/Net/Cookie.cs index 94c161b97..50930a2a2 100644 --- a/websocket-sharp/Net/Cookie.cs +++ b/websocket-sharp/Net/Cookie.cs @@ -169,7 +169,7 @@ internal Cookie () /// /// /// is a string not enclosed in double quotes - /// that contains an invalid character. + /// although it contains a reserved character. /// /// public Cookie (string name, string value) From 015f2da3ab1bb6ad8128298fc08f34492cb2a21b Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 22 Jun 2023 17:33:09 +0900 Subject: [PATCH 5173/6294] [Modify] Edit it --- websocket-sharp/Net/Cookie.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/Cookie.cs b/websocket-sharp/Net/Cookie.cs index 50930a2a2..8972b2e36 100644 --- a/websocket-sharp/Net/Cookie.cs +++ b/websocket-sharp/Net/Cookie.cs @@ -56,7 +56,8 @@ namespace WebSocketSharp.Net /// /// /// - /// Netscape specification + /// + /// Netscape specification /// /// /// From ae5a14b3b961b10a7f6383cdcdfecfdeb7b8b2ef Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 23 Jun 2023 17:35:52 +0900 Subject: [PATCH 5174/6294] [Modify] Polish it --- websocket-sharp/Net/Cookie.cs | 3 --- 1 file changed, 3 deletions(-) diff --git a/websocket-sharp/Net/Cookie.cs b/websocket-sharp/Net/Cookie.cs index 8972b2e36..6d3c544d7 100644 --- a/websocket-sharp/Net/Cookie.cs +++ b/websocket-sharp/Net/Cookie.cs @@ -117,9 +117,6 @@ static Cookie () #region Internal Constructors - /// - /// Initializes a new instance of the class. - /// internal Cookie () { init (String.Empty, String.Empty, String.Empty, String.Empty); From 0f1b7dc931ad7b4b916f2951e909cf8922e96a9c Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 23 Jun 2023 17:37:36 +0900 Subject: [PATCH 5175/6294] [Modify] Edit it --- websocket-sharp/Net/Cookie.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/Cookie.cs b/websocket-sharp/Net/Cookie.cs index 6d3c544d7..0837f4a3b 100644 --- a/websocket-sharp/Net/Cookie.cs +++ b/websocket-sharp/Net/Cookie.cs @@ -151,19 +151,19 @@ internal Cookie () /// is an empty string. /// /// - /// - or - + /// -or- /// /// /// starts with a dollar sign. /// /// - /// - or - + /// -or- /// /// /// contains an invalid character. /// /// - /// - or - + /// -or- /// /// /// is a string not enclosed in double quotes From c7b2282ea2bad1f9044f37277d84cd9447c88ece Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 24 Jun 2023 17:01:19 +0900 Subject: [PATCH 5176/6294] [Modify] Edit it --- websocket-sharp/Net/Cookie.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/Cookie.cs b/websocket-sharp/Net/Cookie.cs index 0837f4a3b..6df94b6f7 100644 --- a/websocket-sharp/Net/Cookie.cs +++ b/websocket-sharp/Net/Cookie.cs @@ -204,19 +204,19 @@ public Cookie (string name, string value) /// is an empty string. /// /// - /// - or - + /// -or- /// /// /// starts with a dollar sign. /// /// - /// - or - + /// -or- /// /// /// contains an invalid character. /// /// - /// - or - + /// -or- /// /// /// is a string not enclosed in double quotes From a48c549d332a2afe5cb2114972972c9ef7581c80 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 25 Jun 2023 21:28:48 +0900 Subject: [PATCH 5177/6294] [Modify] Edit it --- websocket-sharp/Net/Cookie.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/Cookie.cs b/websocket-sharp/Net/Cookie.cs index 6df94b6f7..f0ed85668 100644 --- a/websocket-sharp/Net/Cookie.cs +++ b/websocket-sharp/Net/Cookie.cs @@ -261,19 +261,19 @@ public Cookie (string name, string value, string path) /// is an empty string. /// /// - /// - or - + /// -or- /// /// /// starts with a dollar sign. /// /// - /// - or - + /// -or- /// /// /// contains an invalid character. /// /// - /// - or - + /// -or- /// /// /// is a string not enclosed in double quotes From e400cadbb86b170f27db629fe4e79529a162ae0b Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 26 Jun 2023 16:06:27 +0900 Subject: [PATCH 5178/6294] [Modify] Edit it --- websocket-sharp/Net/Cookie.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/Cookie.cs b/websocket-sharp/Net/Cookie.cs index f0ed85668..15472f6a7 100644 --- a/websocket-sharp/Net/Cookie.cs +++ b/websocket-sharp/Net/Cookie.cs @@ -552,13 +552,13 @@ public bool HttpOnly { /// The value specified for a set operation is an empty string. /// /// - /// - or - + /// -or- /// /// /// The value specified for a set operation starts with a dollar sign. /// /// - /// - or - + /// -or- /// /// /// The value specified for a set operation contains an invalid character. From 4e1c67432e36d08a09dd0ce6c3408ef22f497d83 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 27 Jun 2023 15:43:48 +0900 Subject: [PATCH 5179/6294] [Modify] Polish it --- websocket-sharp/Net/Cookie.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Net/Cookie.cs b/websocket-sharp/Net/Cookie.cs index 15472f6a7..62a760324 100644 --- a/websocket-sharp/Net/Cookie.cs +++ b/websocket-sharp/Net/Cookie.cs @@ -823,6 +823,7 @@ private string toResponseStringVersion1 () if (_commentUri != null) { var url = _commentUri.OriginalString; + buff.AppendFormat ( "; CommentURL={0}", !url.IsToken () ? url.Quote () : url ); From 021ce922e547a6bc97c313f105bbdaea0edaf57a Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 28 Jun 2023 15:59:21 +0900 Subject: [PATCH 5180/6294] [Modify] Polish it --- websocket-sharp/Net/Cookie.cs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/websocket-sharp/Net/Cookie.cs b/websocket-sharp/Net/Cookie.cs index 62a760324..6dbcf126b 100644 --- a/websocket-sharp/Net/Cookie.cs +++ b/websocket-sharp/Net/Cookie.cs @@ -769,13 +769,14 @@ private string toResponseStringVersion0 () buff.AppendFormat ("{0}={1}", _name, _value); if (_expires != DateTime.MinValue) { - buff.AppendFormat ( - "; Expires={0}", - _expires.ToUniversalTime ().ToString ( - "ddd, dd'-'MMM'-'yyyy HH':'mm':'ss 'GMT'", - CultureInfo.CreateSpecificCulture ("en-US") - ) - ); + var expires = _expires + .ToUniversalTime () + .ToString ( + "ddd, dd'-'MMM'-'yyyy HH':'mm':'ss 'GMT'", + CultureInfo.CreateSpecificCulture ("en-US") + ); + + buff.AppendFormat ("; Expires={0}", expires); } if (!_path.IsNullOrEmpty ()) From ac2eac971cc8ea00c2e5b698991169998c6ca3ce Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 29 Jun 2023 16:54:29 +0900 Subject: [PATCH 5181/6294] [Modify] Polish it --- websocket-sharp/Net/Cookie.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/Cookie.cs b/websocket-sharp/Net/Cookie.cs index 6dbcf126b..da17d43c0 100644 --- a/websocket-sharp/Net/Cookie.cs +++ b/websocket-sharp/Net/Cookie.cs @@ -819,8 +819,11 @@ private string toResponseStringVersion1 () buff.Append ("; Port"); } - if (_comment != null) - buff.AppendFormat ("; Comment={0}", HttpUtility.UrlEncode (_comment)); + if (_comment != null) { + var comment = HttpUtility.UrlEncode (_comment); + + buff.AppendFormat ("; Comment={0}", comment); + } if (_commentUri != null) { var url = _commentUri.OriginalString; From 949e82dad48f6add33f807bb163f50d01b28255c Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 30 Jun 2023 17:06:50 +0900 Subject: [PATCH 5182/6294] [Modify] Edit it --- websocket-sharp/Net/Cookie.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/Cookie.cs b/websocket-sharp/Net/Cookie.cs index da17d43c0..211a3616b 100644 --- a/websocket-sharp/Net/Cookie.cs +++ b/websocket-sharp/Net/Cookie.cs @@ -719,7 +719,10 @@ public string Value { /// management that the cookie conforms to. /// /// - /// 0 or 1. 0 if not present. + /// 0 or 1. + /// + /// + /// 0 if not present. /// /// /// The default value is 0. From cd4e6c2e939ccedd6ab4689853f215dc1f0e89a8 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 1 Jul 2023 17:09:01 +0900 Subject: [PATCH 5183/6294] [Modify] Polish it --- websocket-sharp/Net/Cookie.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Net/Cookie.cs b/websocket-sharp/Net/Cookie.cs index 211a3616b..b1ea970e1 100644 --- a/websocket-sharp/Net/Cookie.cs +++ b/websocket-sharp/Net/Cookie.cs @@ -631,6 +631,7 @@ public string Port { internal set { int[] ports; + if (!tryCreatePorts (value, out ports)) return; From 2edceb5f95e9749e0b7ad759fb02468b91803eb6 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 1 Jul 2023 17:41:18 +0900 Subject: [PATCH 5184/6294] [Modify] Polish it --- websocket-sharp/Net/Cookie.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/Cookie.cs b/websocket-sharp/Net/Cookie.cs index b1ea970e1..d719ebf69 100644 --- a/websocket-sharp/Net/Cookie.cs +++ b/websocket-sharp/Net/Cookie.cs @@ -635,8 +635,8 @@ internal set { if (!tryCreatePorts (value, out ports)) return; - _port = value; _ports = ports; + _port = value; } } From 1eb8e2cd07afc47e09d8ff77ec4a570713fe27de Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 2 Jul 2023 16:47:26 +0900 Subject: [PATCH 5185/6294] [Modify] Edit it --- websocket-sharp/Net/Cookie.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/Cookie.cs b/websocket-sharp/Net/Cookie.cs index d719ebf69..4371d9dc4 100644 --- a/websocket-sharp/Net/Cookie.cs +++ b/websocket-sharp/Net/Cookie.cs @@ -492,7 +492,7 @@ public bool Expired { /// the cookie expires on. /// /// - /// if this attribute is not needed. + /// if not necessary. /// /// /// The default value is . From f3500d16cd6451409f148e99e5b5f097716a059a Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 3 Jul 2023 15:39:54 +0900 Subject: [PATCH 5186/6294] [Modify] Edit it --- websocket-sharp/Net/Cookie.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/Cookie.cs b/websocket-sharp/Net/Cookie.cs index 4371d9dc4..2933589a5 100644 --- a/websocket-sharp/Net/Cookie.cs +++ b/websocket-sharp/Net/Cookie.cs @@ -449,7 +449,7 @@ internal set { /// the cookie is valid for. /// /// - /// An empty string if this attribute is not needed. + /// An empty string if not necessary. /// /// public string Domain { From 018345b27ced9de4fcdfa0652367fd57c5f4cd5e Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 4 Jul 2023 00:10:50 +0900 Subject: [PATCH 5187/6294] [Modify] 2023 --- websocket-sharp/Net/Cookie.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/Cookie.cs b/websocket-sharp/Net/Cookie.cs index 2933589a5..0f79ddf88 100644 --- a/websocket-sharp/Net/Cookie.cs +++ b/websocket-sharp/Net/Cookie.cs @@ -8,7 +8,7 @@ * The MIT License * * Copyright (c) 2004,2009 Novell, Inc. (http://www.novell.com) - * Copyright (c) 2012-2019 sta.blockhead + * Copyright (c) 2012-2023 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From 9d8bc1d1bf12b16371aeb7b390396b553f1c4777 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 4 Jul 2023 15:42:38 +0900 Subject: [PATCH 5188/6294] [Modify] Polish it --- websocket-sharp/Net/CookieCollection.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/websocket-sharp/Net/CookieCollection.cs b/websocket-sharp/Net/CookieCollection.cs index 8c0322bda..fdd5e399d 100644 --- a/websocket-sharp/Net/CookieCollection.cs +++ b/websocket-sharp/Net/CookieCollection.cs @@ -786,6 +786,7 @@ public bool Remove (Cookie cookie) { if (_readOnly) { var msg = "The collection is read-only."; + throw new InvalidOperationException (msg); } @@ -793,10 +794,12 @@ public bool Remove (Cookie cookie) throw new ArgumentNullException ("cookie"); var idx = search (cookie); + if (idx == -1) return false; _list.RemoveAt (idx); + return true; } From 4a97015d38cdf2813d83302a655f2e1d971abd7c Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 4 Jul 2023 16:18:52 +0900 Subject: [PATCH 5189/6294] [Modify] Polish it --- websocket-sharp/Net/CookieCollection.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Net/CookieCollection.cs b/websocket-sharp/Net/CookieCollection.cs index fdd5e399d..15b3fa7ea 100644 --- a/websocket-sharp/Net/CookieCollection.cs +++ b/websocket-sharp/Net/CookieCollection.cs @@ -743,6 +743,7 @@ public void CopyTo (Cookie[] array, int index) if (array.Length - index < _list.Count) { var msg = "The available space of the array is not enough to copy to."; + throw new ArgumentException (msg); } From 90bc15453ba2222535868a3b1a92edbd723a67be Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 5 Jul 2023 21:04:37 +0900 Subject: [PATCH 5190/6294] [Modify] Polish it --- websocket-sharp/Net/CookieCollection.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/CookieCollection.cs b/websocket-sharp/Net/CookieCollection.cs index 15b3fa7ea..2b0aad787 100644 --- a/websocket-sharp/Net/CookieCollection.cs +++ b/websocket-sharp/Net/CookieCollection.cs @@ -738,8 +738,11 @@ public void CopyTo (Cookie[] array, int index) if (array == null) throw new ArgumentNullException ("array"); - if (index < 0) - throw new ArgumentOutOfRangeException ("index", "Less than zero."); + if (index < 0) { + var msg = "Less than zero."; + + throw new ArgumentOutOfRangeException ("index", msg); + } if (array.Length - index < _list.Count) { var msg = "The available space of the array is not enough to copy to."; From 2d2658a43fdc57f2849ab16564079cb4cf1db2bb Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 5 Jul 2023 21:08:04 +0900 Subject: [PATCH 5191/6294] [Modify] Polish it --- websocket-sharp/Net/CookieCollection.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Net/CookieCollection.cs b/websocket-sharp/Net/CookieCollection.cs index 2b0aad787..2a22cf8cf 100644 --- a/websocket-sharp/Net/CookieCollection.cs +++ b/websocket-sharp/Net/CookieCollection.cs @@ -684,6 +684,7 @@ public void Clear () { if (_readOnly) { var msg = "The collection is read-only."; + throw new InvalidOperationException (msg); } From 56b08a70f329a8caf2255a06955fe430c4253115 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 6 Jul 2023 17:00:38 +0900 Subject: [PATCH 5192/6294] [Modify] Polish it --- websocket-sharp/Net/CookieCollection.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Net/CookieCollection.cs b/websocket-sharp/Net/CookieCollection.cs index 2a22cf8cf..56641870b 100644 --- a/websocket-sharp/Net/CookieCollection.cs +++ b/websocket-sharp/Net/CookieCollection.cs @@ -664,6 +664,7 @@ public void Add (CookieCollection cookies) { if (_readOnly) { var msg = "The collection is read-only."; + throw new InvalidOperationException (msg); } From 5a3eb8d41bbc5dac8b64e2ce1d22e43c49da6533 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 6 Jul 2023 17:02:00 +0900 Subject: [PATCH 5193/6294] [Modify] Polish it --- websocket-sharp/Net/CookieCollection.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Net/CookieCollection.cs b/websocket-sharp/Net/CookieCollection.cs index 56641870b..f57af3361 100644 --- a/websocket-sharp/Net/CookieCollection.cs +++ b/websocket-sharp/Net/CookieCollection.cs @@ -639,6 +639,7 @@ public void Add (Cookie cookie) { if (_readOnly) { var msg = "The collection is read-only."; + throw new InvalidOperationException (msg); } From 68d5303dfb30ea90e284ca8aa60fb8137dec2d0b Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 7 Jul 2023 15:53:03 +0900 Subject: [PATCH 5194/6294] [Modify] Polish it --- websocket-sharp/Net/CookieCollection.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/websocket-sharp/Net/CookieCollection.cs b/websocket-sharp/Net/CookieCollection.cs index f57af3361..42e88e4c5 100644 --- a/websocket-sharp/Net/CookieCollection.cs +++ b/websocket-sharp/Net/CookieCollection.cs @@ -591,16 +591,19 @@ internal static CookieCollection Parse (string value, bool response) internal void SetOrRemove (Cookie cookie) { var idx = search (cookie); + if (idx == -1) { if (cookie.Expired) return; _list.Add (cookie); + return; } if (cookie.Expired) { _list.RemoveAt (idx); + return; } From 3f35b961f4fc5727e61d2a80b19a70891095cb69 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 8 Jul 2023 16:04:05 +0900 Subject: [PATCH 5195/6294] [Modify] Polish it --- websocket-sharp/Net/CookieCollection.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/CookieCollection.cs b/websocket-sharp/Net/CookieCollection.cs index 42e88e4c5..35d00ca39 100644 --- a/websocket-sharp/Net/CookieCollection.cs +++ b/websocket-sharp/Net/CookieCollection.cs @@ -618,8 +618,10 @@ internal void SetOrRemove (CookieCollection cookies) internal void Sort () { - if (_list.Count > 1) - _list.Sort (compareForSort); + if (_list.Count < 2) + return; + + _list.Sort (compareForSort); } #endregion From 6c793c6848f672e1f7d29b9e8611157a14f5c6c4 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 9 Jul 2023 21:33:37 +0900 Subject: [PATCH 5196/6294] [Modify] Polish it --- websocket-sharp/Net/CookieCollection.cs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Net/CookieCollection.cs b/websocket-sharp/Net/CookieCollection.cs index 35d00ca39..50bed1927 100644 --- a/websocket-sharp/Net/CookieCollection.cs +++ b/websocket-sharp/Net/CookieCollection.cs @@ -240,11 +240,16 @@ private static int compareForSort (Cookie x, Cookie y) private static int compareForSorted (Cookie x, Cookie y) { var ret = x.Version - y.Version; - return ret != 0 - ? ret - : (ret = x.Name.CompareTo (y.Name)) != 0 - ? ret - : y.Path.Length - x.Path.Length; + + if (ret != 0) + return ret; + + ret = x.Name.CompareTo (y.Name); + + if (ret != 0) + return ret; + + return y.Path.Length - x.Path.Length; } private static CookieCollection parseRequest (string value) From 7fe0f1ca6bade08de252b47dd549df0ce1f73e4d Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 10 Jul 2023 21:14:56 +0900 Subject: [PATCH 5197/6294] [Modify] Polish it --- websocket-sharp/Net/CookieCollection.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/websocket-sharp/Net/CookieCollection.cs b/websocket-sharp/Net/CookieCollection.cs index 50bed1927..094ad40f4 100644 --- a/websocket-sharp/Net/CookieCollection.cs +++ b/websocket-sharp/Net/CookieCollection.cs @@ -223,8 +223,10 @@ public object SyncRoot { private void add (Cookie cookie) { var idx = search (cookie); + if (idx == -1) { _list.Add (cookie); + return; } From 544d08f567d6d3021ee3091f2296967114d3c8e0 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 11 Jul 2023 17:00:03 +0900 Subject: [PATCH 5198/6294] [Modify] Polish it --- websocket-sharp/Net/CookieCollection.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/websocket-sharp/Net/CookieCollection.cs b/websocket-sharp/Net/CookieCollection.cs index 094ad40f4..2d6622eb6 100644 --- a/websocket-sharp/Net/CookieCollection.cs +++ b/websocket-sharp/Net/CookieCollection.cs @@ -586,9 +586,7 @@ private static string urlDecode (string s, Encoding encoding) internal static CookieCollection Parse (string value, bool response) { try { - return response - ? parseResponse (value) - : parseRequest (value); + return response ? parseResponse (value) : parseRequest (value); } catch (Exception ex) { throw new CookieException ("It could not be parsed.", ex); From 333180f32f036a5d0269b6efcb40dd99458c8402 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 12 Jul 2023 17:16:24 +0900 Subject: [PATCH 5199/6294] [Modify] Polish it --- websocket-sharp/Net/CookieCollection.cs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/CookieCollection.cs b/websocket-sharp/Net/CookieCollection.cs index 2d6622eb6..abd48f738 100644 --- a/websocket-sharp/Net/CookieCollection.cs +++ b/websocket-sharp/Net/CookieCollection.cs @@ -260,22 +260,25 @@ private static CookieCollection parseRequest (string value) Cookie cookie = null; var ver = 0; - var caseInsensitive = StringComparison.InvariantCultureIgnoreCase; + var pairs = value.SplitHeaderValue (',', ';').ToList (); for (var i = 0; i < pairs.Count; i++) { var pair = pairs[i].Trim (); + if (pair.Length == 0) continue; var idx = pair.IndexOf ('='); + if (idx == -1) { if (cookie == null) continue; if (pair.Equals ("$port", caseInsensitive)) { cookie.Port = "\"\""; + continue; } @@ -285,6 +288,7 @@ private static CookieCollection parseRequest (string value) if (idx == 0) { if (cookie != null) { ret.add (cookie); + cookie = null; } @@ -301,10 +305,12 @@ private static CookieCollection parseRequest (string value) continue; int num; + if (!Int32.TryParse (val.Unquote (), out num)) continue; ver = num; + continue; } @@ -316,6 +322,7 @@ private static CookieCollection parseRequest (string value) continue; cookie.Path = val; + continue; } @@ -327,6 +334,7 @@ private static CookieCollection parseRequest (string value) continue; cookie.Domain = val; + continue; } @@ -338,6 +346,7 @@ private static CookieCollection parseRequest (string value) continue; cookie.Port = val; + continue; } From bae84c4e54b886dd45c7915db98cc88a167aad5d Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 13 Jul 2023 16:57:31 +0900 Subject: [PATCH 5200/6294] [Modify] Polish it --- websocket-sharp/Net/CookieCollection.cs | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/CookieCollection.cs b/websocket-sharp/Net/CookieCollection.cs index abd48f738..327be5c2b 100644 --- a/websocket-sharp/Net/CookieCollection.cs +++ b/websocket-sharp/Net/CookieCollection.cs @@ -371,37 +371,43 @@ private static CookieCollection parseResponse (string value) var ret = new CookieCollection (); Cookie cookie = null; - var caseInsensitive = StringComparison.InvariantCultureIgnoreCase; + var pairs = value.SplitHeaderValue (',', ';').ToList (); for (var i = 0; i < pairs.Count; i++) { var pair = pairs[i].Trim (); + if (pair.Length == 0) continue; var idx = pair.IndexOf ('='); + if (idx == -1) { if (cookie == null) continue; if (pair.Equals ("port", caseInsensitive)) { cookie.Port = "\"\""; + continue; } if (pair.Equals ("discard", caseInsensitive)) { cookie.Discard = true; + continue; } if (pair.Equals ("secure", caseInsensitive)) { cookie.Secure = true; + continue; } if (pair.Equals ("httponly", caseInsensitive)) { cookie.HttpOnly = true; + continue; } @@ -411,6 +417,7 @@ private static CookieCollection parseResponse (string value) if (idx == 0) { if (cookie != null) { ret.add (cookie); + cookie = null; } @@ -430,10 +437,12 @@ private static CookieCollection parseResponse (string value) continue; int num; + if (!Int32.TryParse (val.Unquote (), out num)) continue; cookie.Version = num; + continue; } @@ -453,9 +462,11 @@ private static CookieCollection parseResponse (string value) continue; var buff = new StringBuilder (val, 32); + buff.AppendFormat (", {0}", pairs[i].Trim ()); DateTime expires; + if ( !DateTime.TryParseExact ( buff.ToString (), @@ -469,6 +480,7 @@ out expires continue; cookie.Expires = expires.ToLocalTime (); + continue; } @@ -480,10 +492,12 @@ out expires continue; int num; + if (!Int32.TryParse (val.Unquote (), out num)) continue; cookie.MaxAge = num; + continue; } @@ -495,6 +509,7 @@ out expires continue; cookie.Path = val; + continue; } @@ -506,6 +521,7 @@ out expires continue; cookie.Domain = val; + continue; } @@ -517,6 +533,7 @@ out expires continue; cookie.Port = val; + continue; } @@ -528,6 +545,7 @@ out expires continue; cookie.Comment = urlDecode (val, Encoding.UTF8); + continue; } @@ -539,6 +557,7 @@ out expires continue; cookie.CommentUri = val.Unquote ().ToUri (); + continue; } @@ -550,6 +569,7 @@ out expires continue; cookie.SameSite = val.Unquote (); + continue; } From 614fcfd2597e878ce6fbabde23f07426fcbbf06c Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 14 Jul 2023 16:24:12 +0900 Subject: [PATCH 5201/6294] [Modify] Polish it --- websocket-sharp/Net/CookieCollection.cs | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/websocket-sharp/Net/CookieCollection.cs b/websocket-sharp/Net/CookieCollection.cs index 327be5c2b..5bb619266 100644 --- a/websocket-sharp/Net/CookieCollection.cs +++ b/websocket-sharp/Net/CookieCollection.cs @@ -466,17 +466,16 @@ private static CookieCollection parseResponse (string value) buff.AppendFormat (", {0}", pairs[i].Trim ()); DateTime expires; - - if ( - !DateTime.TryParseExact ( - buff.ToString (), - new[] { "ddd, dd'-'MMM'-'yyyy HH':'mm':'ss 'GMT'", "r" }, - CultureInfo.CreateSpecificCulture ("en-US"), - DateTimeStyles.AdjustToUniversal - | DateTimeStyles.AssumeUniversal, - out expires - ) - ) + var done = DateTime.TryParseExact ( + buff.ToString (), + new[] { "ddd, dd'-'MMM'-'yyyy HH':'mm':'ss 'GMT'", "r" }, + CultureInfo.CreateSpecificCulture ("en-US"), + DateTimeStyles.AdjustToUniversal + | DateTimeStyles.AssumeUniversal, + out expires + ); + + if (!done) continue; cookie.Expires = expires.ToLocalTime (); From c92e00ea72c14a0a5a6619cc2cabb202aef3bd16 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 14 Jul 2023 16:29:01 +0900 Subject: [PATCH 5202/6294] [Modify] Polish it --- websocket-sharp/Net/CookieCollection.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/CookieCollection.cs b/websocket-sharp/Net/CookieCollection.cs index 5bb619266..c4558628d 100644 --- a/websocket-sharp/Net/CookieCollection.cs +++ b/websocket-sharp/Net/CookieCollection.cs @@ -465,13 +465,16 @@ private static CookieCollection parseResponse (string value) buff.AppendFormat (", {0}", pairs[i].Trim ()); + var style = DateTimeStyles.AdjustToUniversal + | DateTimeStyles.AssumeUniversal; + DateTime expires; + var done = DateTime.TryParseExact ( buff.ToString (), new[] { "ddd, dd'-'MMM'-'yyyy HH':'mm':'ss 'GMT'", "r" }, CultureInfo.CreateSpecificCulture ("en-US"), - DateTimeStyles.AdjustToUniversal - | DateTimeStyles.AssumeUniversal, + style, out expires ); From 4bd806da6c1dc5f777c2a1b8bb105388526828e6 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 14 Jul 2023 16:35:06 +0900 Subject: [PATCH 5203/6294] [Modify] Polish it --- websocket-sharp/Net/CookieCollection.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/CookieCollection.cs b/websocket-sharp/Net/CookieCollection.cs index c4558628d..3390f8e28 100644 --- a/websocket-sharp/Net/CookieCollection.cs +++ b/websocket-sharp/Net/CookieCollection.cs @@ -465,6 +465,7 @@ private static CookieCollection parseResponse (string value) buff.AppendFormat (", {0}", pairs[i].Trim ()); + var provider = CultureInfo.CreateSpecificCulture ("en-US"); var style = DateTimeStyles.AdjustToUniversal | DateTimeStyles.AssumeUniversal; @@ -473,7 +474,7 @@ private static CookieCollection parseResponse (string value) var done = DateTime.TryParseExact ( buff.ToString (), new[] { "ddd, dd'-'MMM'-'yyyy HH':'mm':'ss 'GMT'", "r" }, - CultureInfo.CreateSpecificCulture ("en-US"), + provider, style, out expires ); From 108a61bc890054526a4bb9b0cd261147a6406a20 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 15 Jul 2023 16:52:04 +0900 Subject: [PATCH 5204/6294] [Modify] Polish it --- websocket-sharp/Net/CookieCollection.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/CookieCollection.cs b/websocket-sharp/Net/CookieCollection.cs index 3390f8e28..ec7e1de19 100644 --- a/websocket-sharp/Net/CookieCollection.cs +++ b/websocket-sharp/Net/CookieCollection.cs @@ -465,6 +465,7 @@ private static CookieCollection parseResponse (string value) buff.AppendFormat (", {0}", pairs[i].Trim ()); + var fmts = new[] { "ddd, dd'-'MMM'-'yyyy HH':'mm':'ss 'GMT'", "r" }; var provider = CultureInfo.CreateSpecificCulture ("en-US"); var style = DateTimeStyles.AdjustToUniversal | DateTimeStyles.AssumeUniversal; @@ -473,7 +474,7 @@ private static CookieCollection parseResponse (string value) var done = DateTime.TryParseExact ( buff.ToString (), - new[] { "ddd, dd'-'MMM'-'yyyy HH':'mm':'ss 'GMT'", "r" }, + fmts, provider, style, out expires From 5ef61308bb78813ca23cb8243a8a39e148af2cf4 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 16 Jul 2023 17:20:49 +0900 Subject: [PATCH 5205/6294] [Modify] Polish it --- websocket-sharp/Net/CookieCollection.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/CookieCollection.cs b/websocket-sharp/Net/CookieCollection.cs index ec7e1de19..e99ded8f9 100644 --- a/websocket-sharp/Net/CookieCollection.cs +++ b/websocket-sharp/Net/CookieCollection.cs @@ -465,6 +465,7 @@ private static CookieCollection parseResponse (string value) buff.AppendFormat (", {0}", pairs[i].Trim ()); + var s = buff.ToString (); var fmts = new[] { "ddd, dd'-'MMM'-'yyyy HH':'mm':'ss 'GMT'", "r" }; var provider = CultureInfo.CreateSpecificCulture ("en-US"); var style = DateTimeStyles.AdjustToUniversal @@ -473,7 +474,7 @@ private static CookieCollection parseResponse (string value) DateTime expires; var done = DateTime.TryParseExact ( - buff.ToString (), + s, fmts, provider, style, From 9fba8b71bcc0a71ba0783a10bf8f61fe110353a2 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 17 Jul 2023 16:56:48 +0900 Subject: [PATCH 5206/6294] [Modify] Polish it --- websocket-sharp/Net/CookieCollection.cs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/websocket-sharp/Net/CookieCollection.cs b/websocket-sharp/Net/CookieCollection.cs index e99ded8f9..ebe8bda1f 100644 --- a/websocket-sharp/Net/CookieCollection.cs +++ b/websocket-sharp/Net/CookieCollection.cs @@ -474,11 +474,7 @@ private static CookieCollection parseResponse (string value) DateTime expires; var done = DateTime.TryParseExact ( - s, - fmts, - provider, - style, - out expires + s, fmts, provider, style, out expires ); if (!done) From f87f14dfada90ba00b9b884e28529c8e9d1c4838 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 18 Jul 2023 21:28:48 +0900 Subject: [PATCH 5207/6294] [Modify] Polish it --- websocket-sharp/Net/CookieCollection.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/CookieCollection.cs b/websocket-sharp/Net/CookieCollection.cs index ebe8bda1f..c457c14d4 100644 --- a/websocket-sharp/Net/CookieCollection.cs +++ b/websocket-sharp/Net/CookieCollection.cs @@ -492,9 +492,11 @@ private static CookieCollection parseResponse (string value) if (val.Length == 0) continue; + var s = val.Unquote (); + int num; - if (!Int32.TryParse (val.Unquote (), out num)) + if (!Int32.TryParse (s, out num)) continue; cookie.MaxAge = num; From f3e97b9586c12d886290fdeef74ede8a5c1d10c7 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 18 Jul 2023 21:30:20 +0900 Subject: [PATCH 5208/6294] [Modify] Polish it --- websocket-sharp/Net/CookieCollection.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/CookieCollection.cs b/websocket-sharp/Net/CookieCollection.cs index c457c14d4..5cbf34c87 100644 --- a/websocket-sharp/Net/CookieCollection.cs +++ b/websocket-sharp/Net/CookieCollection.cs @@ -494,12 +494,12 @@ private static CookieCollection parseResponse (string value) var s = val.Unquote (); - int num; + int maxAge; - if (!Int32.TryParse (s, out num)) + if (!Int32.TryParse (s, out maxAge)) continue; - cookie.MaxAge = num; + cookie.MaxAge = maxAge; continue; } From d0b5c498184df998de39a1579b36b110098f6012 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 19 Jul 2023 16:42:53 +0900 Subject: [PATCH 5209/6294] [Modify] Polish it --- websocket-sharp/Net/CookieCollection.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/CookieCollection.cs b/websocket-sharp/Net/CookieCollection.cs index 5cbf34c87..ddf35d5be 100644 --- a/websocket-sharp/Net/CookieCollection.cs +++ b/websocket-sharp/Net/CookieCollection.cs @@ -304,9 +304,11 @@ private static CookieCollection parseRequest (string value) if (val.Length == 0) continue; + var s = val.Unquote (); + int num; - if (!Int32.TryParse (val.Unquote (), out num)) + if (!Int32.TryParse (s, out num)) continue; ver = num; From 2e97213710cef8e4a020f5c8ae16c155af6d63b1 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 20 Jul 2023 22:28:22 +0900 Subject: [PATCH 5210/6294] [Modify] Polish it --- websocket-sharp/Net/CookieCollection.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/CookieCollection.cs b/websocket-sharp/Net/CookieCollection.cs index ddf35d5be..efd7a57c9 100644 --- a/websocket-sharp/Net/CookieCollection.cs +++ b/websocket-sharp/Net/CookieCollection.cs @@ -438,9 +438,11 @@ private static CookieCollection parseResponse (string value) if (val.Length == 0) continue; + var s = val.Unquote (); + int num; - if (!Int32.TryParse (val.Unquote (), out num)) + if (!Int32.TryParse (s, out num)) continue; cookie.Version = num; From 9d1d18e7518dddef941751a61ca6837ac1b7fc2a Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 21 Jul 2023 17:17:25 +0900 Subject: [PATCH 5211/6294] [Modify] Polish it --- websocket-sharp/Net/CookieCollection.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Net/CookieCollection.cs b/websocket-sharp/Net/CookieCollection.cs index efd7a57c9..459974571 100644 --- a/websocket-sharp/Net/CookieCollection.cs +++ b/websocket-sharp/Net/CookieCollection.cs @@ -85,6 +85,7 @@ internal IList List { internal IEnumerable Sorted { get { var list = new List (_list); + if (list.Count > 1) list.Sort (compareForSorted); From 3822fa15a1b8562e0c76cf271e6a4878ccc7eaa8 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 22 Jul 2023 21:36:58 +0900 Subject: [PATCH 5212/6294] [Modify] 2023 --- websocket-sharp/Net/CookieCollection.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/CookieCollection.cs b/websocket-sharp/Net/CookieCollection.cs index 459974571..df3491b31 100644 --- a/websocket-sharp/Net/CookieCollection.cs +++ b/websocket-sharp/Net/CookieCollection.cs @@ -8,7 +8,7 @@ * The MIT License * * Copyright (c) 2004,2009 Novell, Inc. (http://www.novell.com) - * Copyright (c) 2012-2019 sta.blockhead + * Copyright (c) 2012-2023 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From ecdbaa5b56f4e9e9bf864dcccf16934c9aa9e985 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 23 Jul 2023 22:09:49 +0900 Subject: [PATCH 5213/6294] [Modify] Polish it --- websocket-sharp/Net/HttpUtility.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 90461d073..5ab9c22d7 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -1126,6 +1126,7 @@ public static byte[] UrlEncodeToBytes (byte[] bytes, int offset, int count) throw new ArgumentNullException ("bytes"); var len = bytes.Length; + if (len == 0) { if (offset != 0) throw new ArgumentOutOfRangeException ("offset"); From a98977cd7b60feb41599eb0d9d92afc8f479058b Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 23 Jul 2023 22:12:13 +0900 Subject: [PATCH 5214/6294] [Modify] Polish it --- websocket-sharp/Net/HttpUtility.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 5ab9c22d7..636d1b6dd 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -1117,6 +1117,7 @@ public static byte[] UrlEncodeToBytes (string s, Encoding encoding) return new byte[0]; var bytes = (encoding ?? Encoding.UTF8).GetBytes (s); + return urlEncodeToBytes (bytes, 0, bytes.Length); } From 7eb6ac29631c223b7a8d6da4e7a3e2ab784b1bd1 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 24 Jul 2023 16:35:55 +0900 Subject: [PATCH 5215/6294] [Modify] Polish it --- websocket-sharp/Net/HttpUtility.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 636d1b6dd..995b6f3f2 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -1100,6 +1100,7 @@ public static byte[] UrlEncodeToBytes (byte[] bytes) throw new ArgumentNullException ("bytes"); var len = bytes.Length; + return len > 0 ? urlEncodeToBytes (bytes, 0, len) : bytes; } From 23a45057bec71660d44d324dc4bd0ed17a4f3c02 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 25 Jul 2023 16:36:25 +0900 Subject: [PATCH 5216/6294] [Modify] Polish it --- websocket-sharp/Net/HttpUtility.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 995b6f3f2..6bc9f3310 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -1071,6 +1071,7 @@ public static string UrlEncode (byte[] bytes, int offset, int count) throw new ArgumentNullException ("bytes"); var len = bytes.Length; + if (len == 0) { if (offset != 0) throw new ArgumentOutOfRangeException ("offset"); From 45304b2c4ccc337320136e5e61535625236ec2f9 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 25 Jul 2023 21:59:13 +0900 Subject: [PATCH 5217/6294] [Modify] Polish it --- websocket-sharp/Net/HttpUtility.cs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 6bc9f3310..e68abdebb 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -1088,11 +1088,12 @@ public static string UrlEncode (byte[] bytes, int offset, int count) if (count < 0 || count > len - offset) throw new ArgumentOutOfRangeException ("count"); - return count > 0 - ? Encoding.ASCII.GetString ( - urlEncodeToBytes (bytes, offset, count) - ) - : String.Empty; + if (count == 0) + return String.Empty; + + var encodedBytes = urlEncodeToBytes (bytes, offset, count); + + return Encoding.ASCII.GetString (encodedBytes); } public static byte[] UrlEncodeToBytes (byte[] bytes) From 9408ee678cb90fb223e275ba0191c6cd85e682bc Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 26 Jul 2023 22:03:22 +0900 Subject: [PATCH 5218/6294] [Modify] Polish it --- websocket-sharp/Net/HttpUtility.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index e68abdebb..16a988f7d 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -1053,6 +1053,7 @@ public static string UrlEncode (string s, Encoding encoding) throw new ArgumentNullException ("s"); var len = s.Length; + if (len == 0) return s; From afa2d9be9093637c4bb30843711e3612a1692e4f Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 26 Jul 2023 22:10:39 +0900 Subject: [PATCH 5219/6294] [Modify] Polish it --- websocket-sharp/Net/HttpUtility.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 16a988f7d..c532c76d8 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -1060,10 +1060,12 @@ public static string UrlEncode (string s, Encoding encoding) if (encoding == null) encoding = Encoding.UTF8; - var bytes = new byte[encoding.GetMaxByteCount (len)]; + var maxLen = encoding.GetMaxByteCount (len); + var bytes = new byte[maxLen]; var realLen = encoding.GetBytes (s, 0, len, bytes, 0); + var encodedBytes = urlEncodeToBytes (bytes, 0, realLen); - return Encoding.ASCII.GetString (urlEncodeToBytes (bytes, 0, realLen)); + return Encoding.ASCII.GetString (encodedBytes); } public static string UrlEncode (byte[] bytes, int offset, int count) From 2ae13f996ef4405f88e19e6ce7a2daa8efd27caf Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 27 Jul 2023 13:37:51 +0900 Subject: [PATCH 5220/6294] [Modify] Polish it --- websocket-sharp/Net/HttpUtility.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index c532c76d8..4f3557c62 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -1037,6 +1037,7 @@ public static string UrlEncode (byte[] bytes) throw new ArgumentNullException ("bytes"); var len = bytes.Length; + return len > 0 ? Encoding.ASCII.GetString (urlEncodeToBytes (bytes, 0, len)) : String.Empty; From a14fc7e8ba32a9e28a4474c9e229efc184d451c3 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 27 Jul 2023 13:42:23 +0900 Subject: [PATCH 5221/6294] [Modify] Polish it --- websocket-sharp/Net/HttpUtility.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 4f3557c62..741c294d2 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -1038,9 +1038,12 @@ public static string UrlEncode (byte[] bytes) var len = bytes.Length; - return len > 0 - ? Encoding.ASCII.GetString (urlEncodeToBytes (bytes, 0, len)) - : String.Empty; + if (len == 0) + return String.Empty; + + var encodedBytes = urlEncodeToBytes (bytes, 0, len); + + return Encoding.ASCII.GetString (encodedBytes); } public static string UrlEncode (string s) From 52d5b9dc39019be474cc8a6da46693b75bb27714 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 28 Jul 2023 17:10:54 +0900 Subject: [PATCH 5222/6294] [Modify] Polish it --- websocket-sharp/Net/HttpUtility.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 741c294d2..11c883c7d 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -1064,10 +1064,10 @@ public static string UrlEncode (string s, Encoding encoding) if (encoding == null) encoding = Encoding.UTF8; - var maxLen = encoding.GetMaxByteCount (len); - var bytes = new byte[maxLen]; - var realLen = encoding.GetBytes (s, 0, len, bytes, 0); - var encodedBytes = urlEncodeToBytes (bytes, 0, realLen); + var maxCnt = encoding.GetMaxByteCount (len); + var bytes = new byte[maxCnt]; + var cnt = encoding.GetBytes (s, 0, len, bytes, 0); + var encodedBytes = urlEncodeToBytes (bytes, 0, cnt); return Encoding.ASCII.GetString (encodedBytes); } From 8a8a81304a6cbb62eeba4770802ba70777c2b5c2 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 29 Jul 2023 22:36:09 +0900 Subject: [PATCH 5223/6294] [Modify] Polish it --- websocket-sharp/Net/HttpUtility.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 11c883c7d..c8afcdd86 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -1010,6 +1010,7 @@ public static byte[] UrlDecodeToBytes (byte[] bytes, int offset, int count) throw new ArgumentNullException ("bytes"); var len = bytes.Length; + if (len == 0) { if (offset != 0) throw new ArgumentOutOfRangeException ("offset"); From 94a1160be63ebacfde6ca8e12036e54c4572cf5c Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 29 Jul 2023 22:37:38 +0900 Subject: [PATCH 5224/6294] [Modify] Polish it --- websocket-sharp/Net/HttpUtility.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index c8afcdd86..d0f814433 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -1001,6 +1001,7 @@ public static byte[] UrlDecodeToBytes (string s) return new byte[0]; var bytes = Encoding.ASCII.GetBytes (s); + return urlDecodeToBytes (bytes, 0, bytes.Length); } From a1e6eec1446eec1469122f92e779d9ca7c6ed40c Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 30 Jul 2023 18:01:02 +0900 Subject: [PATCH 5225/6294] [Modify] Polish it --- websocket-sharp/Net/HttpUtility.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index d0f814433..84355e28b 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -987,6 +987,7 @@ public static byte[] UrlDecodeToBytes (byte[] bytes) throw new ArgumentNullException ("bytes"); var len = bytes.Length; + return len > 0 ? urlDecodeToBytes (bytes, 0, len) : bytes; From 752c4614dd5d15544777cf994cdba940635b2033 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 30 Jul 2023 18:02:47 +0900 Subject: [PATCH 5226/6294] [Modify] Polish it --- websocket-sharp/Net/HttpUtility.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 84355e28b..5bfcc01a6 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -958,6 +958,7 @@ public static string UrlDecode ( throw new ArgumentNullException ("bytes"); var len = bytes.Length; + if (len == 0) { if (offset != 0) throw new ArgumentOutOfRangeException ("offset"); From b5bdede1e62a0e5c18b04bdf59eb82b3e724ea27 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 31 Jul 2023 16:18:27 +0900 Subject: [PATCH 5227/6294] [Modify] Polish it --- websocket-sharp/Net/HttpUtility.cs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 5bfcc01a6..8f417790c 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -975,11 +975,12 @@ public static string UrlDecode ( if (count < 0 || count > len - offset) throw new ArgumentOutOfRangeException ("count"); - return count > 0 - ? (encoding ?? Encoding.UTF8).GetString ( - urlDecodeToBytes (bytes, offset, count) - ) - : String.Empty; + if (count == 0) + return String.Empty; + + var decodedBytes = urlDecodeToBytes (bytes, offset, count); + + return (encoding ?? Encoding.UTF8).GetString (decodedBytes); } public static byte[] UrlDecodeToBytes (byte[] bytes) From df131acf114993ab42e106187ff6038d4221ff19 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 31 Jul 2023 16:20:32 +0900 Subject: [PATCH 5228/6294] [Modify] Polish it --- websocket-sharp/Net/HttpUtility.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 8f417790c..e7f07809e 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -945,6 +945,7 @@ public static string UrlDecode (string s, Encoding encoding) return s; var bytes = Encoding.ASCII.GetBytes (s); + return (encoding ?? Encoding.UTF8).GetString ( urlDecodeToBytes (bytes, 0, bytes.Length) ); From 9e04fca93fe91f95d32237b7cfe5130474088462 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 1 Aug 2023 17:26:35 +0900 Subject: [PATCH 5229/6294] [Modify] Polish it --- websocket-sharp/Net/HttpUtility.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index e7f07809e..3f7a4e0da 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -945,10 +945,9 @@ public static string UrlDecode (string s, Encoding encoding) return s; var bytes = Encoding.ASCII.GetBytes (s); + var decodedBytes = urlDecodeToBytes (bytes, 0, bytes.Length); - return (encoding ?? Encoding.UTF8).GetString ( - urlDecodeToBytes (bytes, 0, bytes.Length) - ); + return (encoding ?? Encoding.UTF8).GetString (decodedBytes); } public static string UrlDecode ( From b025efbb4703ae008cc6ee33062ab45813bd03ba Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 2 Aug 2023 17:16:08 +0900 Subject: [PATCH 5230/6294] [Modify] Polish it --- websocket-sharp/Net/HttpUtility.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 3f7a4e0da..c6e5ccf34 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -929,6 +929,7 @@ public static string UrlDecode (byte[] bytes, Encoding encoding) throw new ArgumentNullException ("bytes"); var len = bytes.Length; + return len > 0 ? (encoding ?? Encoding.UTF8).GetString ( urlDecodeToBytes (bytes, 0, len) From 1cae383869f0906696298d584dc0e6c1e46cbbbe Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 2 Aug 2023 17:21:57 +0900 Subject: [PATCH 5231/6294] [Modify] Polish it --- websocket-sharp/Net/HttpUtility.cs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index c6e5ccf34..738d66e60 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -930,11 +930,12 @@ public static string UrlDecode (byte[] bytes, Encoding encoding) var len = bytes.Length; - return len > 0 - ? (encoding ?? Encoding.UTF8).GetString ( - urlDecodeToBytes (bytes, 0, len) - ) - : String.Empty; + if (len == 0) + return String.Empty; + + var decodedBytes = urlDecodeToBytes (bytes, 0, len); + + return (encoding ?? Encoding.UTF8).GetString (decodedBytes); } public static string UrlDecode (string s, Encoding encoding) From 3fbe339c923af944a5578327d98d748750571f8f Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 3 Aug 2023 17:10:20 +0900 Subject: [PATCH 5232/6294] [Modify] Polish it --- websocket-sharp/Net/HttpUtility.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 738d66e60..a13ef9b03 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -915,7 +915,9 @@ public static void HtmlEncode (string s, TextWriter output) if (s.Length == 0) return; - output.Write (htmlEncode (s, false)); + var encodedS = htmlEncode (s, false); + + output.Write (encodedS); } public static string UrlDecode (string s) From e3cf91bb830670be2c1d439e57a9646c9d3d6a36 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 4 Aug 2023 16:13:34 +0900 Subject: [PATCH 5233/6294] [Modify] Polish it --- websocket-sharp/Net/HttpUtility.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index a13ef9b03..148471781 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -893,7 +893,9 @@ public static void HtmlDecode (string s, TextWriter output) if (s.Length == 0) return; - output.Write (htmlDecode (s)); + var decodedS = htmlDecode (s); + + output.Write (decodedS); } public static string HtmlEncode (string s) From 637df91d69c2314c2bbf783e50e8ef362fe27f1e Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 5 Aug 2023 16:45:35 +0900 Subject: [PATCH 5234/6294] [Modify] Polish it --- websocket-sharp/Net/HttpUtility.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 148471781..7a8417f2e 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -871,7 +871,9 @@ public static void HtmlAttributeEncode (string s, TextWriter output) if (s.Length == 0) return; - output.Write (htmlEncode (s, true)); + var encodedS = htmlEncode (s, true); + + output.Write (encodedS); } public static string HtmlDecode (string s) From c79ba838a20cf4543c86f4cc1ebca0cfdb8b2ffa Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 6 Aug 2023 17:01:54 +0900 Subject: [PATCH 5235/6294] [Modify] Polish it --- websocket-sharp/Net/HttpUtility.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 7a8417f2e..6c2db5e7c 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -611,19 +611,22 @@ private static byte[] urlDecodeToBytes (byte[] bytes, int offset, int count) { using (var buff = new MemoryStream ()) { var end = offset + count - 1; + for (var i = offset; i <= end; i++) { var b = bytes[i]; - var c = (char) b; + if (c == '%') { if (i > end - 2) break; var num = getNumber (bytes, i + 1, 2); + if (num == -1) break; buff.WriteByte ((byte) num); + i += 2; continue; @@ -631,6 +634,7 @@ private static byte[] urlDecodeToBytes (byte[] bytes, int offset, int count) if (c == '+') { buff.WriteByte ((byte) ' '); + continue; } @@ -638,6 +642,7 @@ private static byte[] urlDecodeToBytes (byte[] bytes, int offset, int count) } buff.Close (); + return buff.ToArray (); } } From 8e17e72cc11c9a7406e994a87754621f6de4b710 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 7 Aug 2023 11:20:06 +0900 Subject: [PATCH 5236/6294] [Modify] Polish it --- websocket-sharp/Net/HttpUtility.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 6c2db5e7c..f65a10f83 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -651,23 +651,28 @@ private static void urlEncode (byte b, Stream output) { if (b > 31 && b < 127) { var c = (char) b; + if (c == ' ') { output.WriteByte ((byte) '+'); + return; } if (isNumeric (c)) { output.WriteByte (b); + return; } if (isAlphabet (c)) { output.WriteByte (b); + return; } if (isUnreserved (c)) { output.WriteByte (b); + return; } } From 40a67ee342cd3c8eb48fc67d9998c0e4eadca33c Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 7 Aug 2023 11:22:49 +0900 Subject: [PATCH 5237/6294] [Modify] Polish it --- websocket-sharp/Net/HttpUtility.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index f65a10f83..ac8bc7fd7 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -691,10 +691,12 @@ private static byte[] urlEncodeToBytes (byte[] bytes, int offset, int count) { using (var buff = new MemoryStream ()) { var end = offset + count - 1; + for (var i = offset; i <= end; i++) urlEncode (bytes[i], buff); buff.Close (); + return buff.ToArray (); } } From b637a385297f18035ac2db4b3ba95e762d207080 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 8 Aug 2023 22:28:23 +0900 Subject: [PATCH 5238/6294] [Modify] Polish it --- websocket-sharp/Net/HttpUtility.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index ac8bc7fd7..ee51b0e3a 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -99,8 +99,10 @@ private static int getNumber (byte[] bytes, int offset, int count) var ret = 0; var end = offset + count - 1; + for (var i = offset; i <= end; i++) { var num = getNumber ((char) bytes[i]); + if (num == -1) return -1; From c831bed2643c845793ee27cb307446455a9d9770 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 8 Aug 2023 22:29:46 +0900 Subject: [PATCH 5239/6294] [Modify] Polish it --- websocket-sharp/Net/HttpUtility.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index ee51b0e3a..ba62b7a82 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -117,8 +117,10 @@ private static int getNumber (string s, int offset, int count) var ret = 0; var end = offset + count - 1; + for (var i = offset; i <= end; i++) { var num = getNumber (s[i]); + if (num == -1) return -1; From 10f2e8e19aea260784d7ee28d04ec5bce3de50b9 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 9 Aug 2023 16:44:07 +0900 Subject: [PATCH 5240/6294] [Modify] Polish it --- websocket-sharp/Net/HttpUtility.cs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index ba62b7a82..beac444ad 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -85,13 +85,16 @@ private static Dictionary getEntities () private static int getNumber (char c) { - return c >= '0' && c <= '9' - ? c - '0' - : c >= 'A' && c <= 'F' - ? c - 'A' + 10 - : c >= 'a' && c <= 'f' - ? c - 'a' + 10 - : -1; + if (c >= '0' && c <= '9') + return c - '0'; + + if (c >= 'A' && c <= 'F') + return c - 'A' + 10; + + if (c >= 'a' && c <= 'f') + return c - 'a' + 10; + + return -1; } private static int getNumber (byte[] bytes, int offset, int count) From eee3592ec8ca39ec2d3647a24091d3b433d15e23 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 9 Aug 2023 16:46:41 +0900 Subject: [PATCH 5241/6294] [Modify] Polish it --- websocket-sharp/Net/HttpUtility.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index beac444ad..114c25edd 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -104,7 +104,8 @@ private static int getNumber (byte[] bytes, int offset, int count) var end = offset + count - 1; for (var i = offset; i <= end; i++) { - var num = getNumber ((char) bytes[i]); + var c = (char) bytes[i]; + var num = getNumber (c); if (num == -1) return -1; From 8f3b8622dc7f4e061b00bf076a9ec49b424048b4 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 10 Aug 2023 16:21:43 +0900 Subject: [PATCH 5242/6294] [Modify] Polish it --- websocket-sharp/Net/HttpUtility.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 114c25edd..6029e30ab 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -123,7 +123,8 @@ private static int getNumber (string s, int offset, int count) var end = offset + count - 1; for (var i = offset; i <= end; i++) { - var num = getNumber (s[i]); + var c = s[i]; + var num = getNumber (c); if (num == -1) return -1; From 73390fe5d215be8233b1d688f861ce4d689675f4 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 11 Aug 2023 16:52:12 +0900 Subject: [PATCH 5243/6294] [Modify] Polish it --- websocket-sharp/Net/HttpUtility.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 6029e30ab..5c7104941 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -153,12 +153,14 @@ private static string htmlDecode (string s) if (state == 0) { if (c == '&') { reference.Append ('&'); + state = 1; continue; } buff.Append (c); + continue; } @@ -167,6 +169,7 @@ private static string htmlDecode (string s) reference.Length = 0; reference.Append ('&'); + state = 1; continue; @@ -196,6 +199,7 @@ private static string htmlDecode (string s) var name = entity.Substring (1, entity.Length - 2); var entities = getEntities (); + if (entities.ContainsKey (name)) buff.Append (entities[name]); else @@ -225,15 +229,18 @@ private static string htmlDecode (string s) if (c == 'x') { state = reference.Length == 3 ? 4 : 2; + continue; } if (!isNumeric (c)) { state = 2; + continue; } num = num * 10 + (c - '0'); + continue; } @@ -251,8 +258,10 @@ private static string htmlDecode (string s) } var n = getNumber (c); + if (n == -1) { state = 2; + continue; } From 085e15adf6261326e88759c33b82b5f36320d528 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 12 Aug 2023 16:39:01 +0900 Subject: [PATCH 5244/6294] [Modify] Polish it --- websocket-sharp/Net/HttpUtility.cs | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 5c7104941..dfc394a0b 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -302,20 +302,23 @@ private static string htmlEncode (string s, bool minimal) { var buff = new StringBuilder (); + string val = null; + foreach (var c in s) { - buff.Append ( - c == '"' - ? """ - : c == '&' - ? "&" - : c == '<' - ? "<" - : c == '>' - ? ">" - : !minimal && c > 159 - ? String.Format ("&#{0};", (int) c) - : c.ToString () - ); + if (c == '"') + val = """; + else if (c == '&') + val = "&"; + else if (c == '<') + val = "<"; + else if (c == '>') + val = ">"; + else if (!minimal && c > 159) + val = String.Format ("&#{0};", (int) c); + else + val = c.ToString (); + + buff.Append (val); } return buff.ToString (); From f1650721ecad02fa3ac32e33a7ba9064e7e691a3 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 13 Aug 2023 16:39:33 +0900 Subject: [PATCH 5245/6294] [Modify] Polish it --- websocket-sharp/Net/HttpUtility.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index dfc394a0b..81620e6a5 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -313,7 +313,7 @@ private static string htmlEncode (string s, bool minimal) val = "<"; else if (c == '>') val = ">"; - else if (!minimal && c > 159) + else if (c > 159 && !minimal) val = String.Format ("&#{0};", (int) c); else val = c.ToString (); From 84f20c711d2cee64d5a1711089ef1d833165795e Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 13 Aug 2023 16:48:23 +0900 Subject: [PATCH 5246/6294] [Modify] Polish it --- websocket-sharp/Net/HttpUtility.cs | 49 ++++++++++++++++++++---------- 1 file changed, 33 insertions(+), 16 deletions(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 81620e6a5..c7cc1bbd9 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -302,23 +302,40 @@ private static string htmlEncode (string s, bool minimal) { var buff = new StringBuilder (); - string val = null; - foreach (var c in s) { - if (c == '"') - val = """; - else if (c == '&') - val = "&"; - else if (c == '<') - val = "<"; - else if (c == '>') - val = ">"; - else if (c > 159 && !minimal) - val = String.Format ("&#{0};", (int) c); - else - val = c.ToString (); - - buff.Append (val); + if (c == '"') { + buff.Append ("""); + + continue; + } + + if (c == '&') { + buff.Append ("&"); + + continue; + } + + if (c == '<') { + buff.Append ("<"); + + continue; + } + + if (c == '>') { + buff.Append (">"); + + continue; + } + + if (c > 159 && !minimal) { + var val = String.Format ("&#{0};", (int) c); + + buff.Append (val); + + continue; + } + + buff.Append (c); } return buff.ToString (); From 4fa378c2bd322d687616bdd192a7ad52864ce762 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 14 Aug 2023 15:25:03 +0900 Subject: [PATCH 5247/6294] [Modify] Polish it --- websocket-sharp/Net/HttpUtility.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index c7cc1bbd9..8857262a8 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -327,12 +327,14 @@ private static string htmlEncode (string s, bool minimal) continue; } - if (c > 159 && !minimal) { - var val = String.Format ("&#{0};", (int) c); + if (c > 159) { + if (!minimal) { + var val = String.Format ("&#{0};", (int) c); - buff.Append (val); + buff.Append (val); - continue; + continue; + } } buff.Append (c); From 3e7be75c8970362bad0d34dcbb29b0c880a24b63 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 15 Aug 2023 15:54:44 +0900 Subject: [PATCH 5248/6294] [Modify] Polish it --- websocket-sharp/Net/HttpUtility.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 8857262a8..2e1125d48 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -105,12 +105,12 @@ private static int getNumber (byte[] bytes, int offset, int count) for (var i = offset; i <= end; i++) { var c = (char) bytes[i]; - var num = getNumber (c); + var n = getNumber (c); - if (num == -1) + if (n == -1) return -1; - ret = (ret << 4) + num; + ret = (ret << 4) + n; } return ret; From 6ac9f8ca6350a14f78008e6ab1e8036688573155 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 16 Aug 2023 15:47:22 +0900 Subject: [PATCH 5249/6294] [Modify] Polish it --- websocket-sharp/Net/HttpUtility.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 2e1125d48..fea2a6fd0 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -124,12 +124,12 @@ private static int getNumber (string s, int offset, int count) for (var i = offset; i <= end; i++) { var c = s[i]; - var num = getNumber (c); + var n = getNumber (c); - if (num == -1) + if (n == -1) return -1; - ret = (ret << 4) + num; + ret = (ret << 4) + n; } return ret; From f84a99bb6827f1f236c6ef785ab7eedd6fa97fa3 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 17 Aug 2023 22:05:23 +0900 Subject: [PATCH 5250/6294] [Modify] Polish it --- websocket-sharp/Net/HttpUtility.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index fea2a6fd0..ed566bf46 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -353,6 +353,7 @@ private static string htmlEncode (string s, bool minimal) private static void initEntities () { _entities = new Dictionary (); + _entities.Add ("nbsp", '\u00A0'); _entities.Add ("iexcl", '\u00A1'); _entities.Add ("cent", '\u00A2'); From 9883934f8c4b18c12ccf85449aa4888137d807ec Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 18 Aug 2023 22:58:06 +0900 Subject: [PATCH 5251/6294] [Modify] Polish it --- websocket-sharp/Net/HttpUtility.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index ed566bf46..c64a460c6 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -829,18 +829,22 @@ Func credentialsFinder return null; var compType = StringComparison.OrdinalIgnoreCase; + if (response.IndexOf (scheme.ToString (), compType) != 0) return null; var res = AuthenticationResponse.Parse (response); + if (res == null) return null; var id = res.ToIdentity (); + if (id == null) return null; NetworkCredential cred = null; + try { cred = credentialsFinder (id); } @@ -852,12 +856,14 @@ Func credentialsFinder if (scheme == AuthenticationSchemes.Basic) { var basicId = (HttpBasicIdentity) id; + return basicId.Password == cred.Password ? new GenericPrincipal (id, cred.Roles) : null; } var digestId = (HttpDigestIdentity) id; + return digestId.IsValid (cred.Password, realm, method, null) ? new GenericPrincipal (id, cred.Roles) : null; From 579c2e01a31b5d07f6b7c325c49e32d78601aa3b Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 19 Aug 2023 16:17:22 +0900 Subject: [PATCH 5252/6294] [Modify] Polish it --- websocket-sharp/Net/HttpUtility.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index c64a460c6..65472cedd 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -830,7 +830,7 @@ Func credentialsFinder var compType = StringComparison.OrdinalIgnoreCase; - if (response.IndexOf (scheme.ToString (), compType) != 0) + if (!response.StartsWith (scheme.ToString (), compType)) return null; var res = AuthenticationResponse.Parse (response); From 6e827f706f0d42954916ba6ec04019538dd59dee Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 20 Aug 2023 22:18:04 +0900 Subject: [PATCH 5253/6294] [Modify] 2023 --- websocket-sharp/Net/HttpUtility.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 65472cedd..676b0b99f 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -8,7 +8,7 @@ * The MIT License * * Copyright (c) 2005-2009 Novell, Inc. (http://www.novell.com) - * Copyright (c) 2012-2019 sta.blockhead + * Copyright (c) 2012-2023 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From aa8de2bfee46add49dbd9a2f51dfd77a70a8487e Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 21 Aug 2023 16:06:02 +0900 Subject: [PATCH 5254/6294] [Modify] Edit it --- websocket-sharp/Net/NetworkCredential.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/NetworkCredential.cs b/websocket-sharp/Net/NetworkCredential.cs index 3ee52f402..92b2b6a4f 100644 --- a/websocket-sharp/Net/NetworkCredential.cs +++ b/websocket-sharp/Net/NetworkCredential.cs @@ -104,7 +104,7 @@ public NetworkCredential (string username, string password) /// is . /// /// - /// is empty. + /// is an empty string. /// public NetworkCredential ( string username, string password, string domain, params string[] roles From 573070eac590b94e4957897e1caa69fe52f388bb Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 21 Aug 2023 16:08:16 +0900 Subject: [PATCH 5255/6294] [Modify] Edit it --- websocket-sharp/Net/NetworkCredential.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/NetworkCredential.cs b/websocket-sharp/Net/NetworkCredential.cs index 92b2b6a4f..63895167f 100644 --- a/websocket-sharp/Net/NetworkCredential.cs +++ b/websocket-sharp/Net/NetworkCredential.cs @@ -85,7 +85,7 @@ public NetworkCredential (string username, string password) /// and . /// /// - /// A that represents the username associated with + /// A that specifies the username associated with /// the credentials. /// /// From de5ad447969e37f6957eedf54b2b795fc56404d4 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 22 Aug 2023 16:27:47 +0900 Subject: [PATCH 5256/6294] [Modify] Edit it --- websocket-sharp/Net/NetworkCredential.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/NetworkCredential.cs b/websocket-sharp/Net/NetworkCredential.cs index 63895167f..364529b8a 100644 --- a/websocket-sharp/Net/NetworkCredential.cs +++ b/websocket-sharp/Net/NetworkCredential.cs @@ -89,7 +89,7 @@ public NetworkCredential (string username, string password) /// the credentials. /// /// - /// A that represents the password for the username + /// A that specifies the password for the username /// associated with the credentials. /// /// From 90b6a060d2813f6ce75ecca2f84618a887c8f379 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 22 Aug 2023 16:28:40 +0900 Subject: [PATCH 5257/6294] [Modify] Edit it --- websocket-sharp/Net/NetworkCredential.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/NetworkCredential.cs b/websocket-sharp/Net/NetworkCredential.cs index 364529b8a..91ccb18aa 100644 --- a/websocket-sharp/Net/NetworkCredential.cs +++ b/websocket-sharp/Net/NetworkCredential.cs @@ -93,7 +93,7 @@ public NetworkCredential (string username, string password) /// associated with the credentials. /// /// - /// A that represents the domain associated with + /// A that specifies the domain associated with /// the credentials. /// /// From 287ba9be6b748277ea16a727c975c7a5d5b1adb5 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 23 Aug 2023 22:15:15 +0900 Subject: [PATCH 5258/6294] [Modify] Edit it --- websocket-sharp/Net/NetworkCredential.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/NetworkCredential.cs b/websocket-sharp/Net/NetworkCredential.cs index 91ccb18aa..16409e556 100644 --- a/websocket-sharp/Net/NetworkCredential.cs +++ b/websocket-sharp/Net/NetworkCredential.cs @@ -97,8 +97,8 @@ public NetworkCredential (string username, string password) /// the credentials. /// /// - /// An array of that represents the roles - /// associated with the credentials if any. + /// An array of that specifies the roles associated + /// with the credentials if any. /// /// /// is . From c3aa2b9c4703951f2d51e40f02f566062cadc53f Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 23 Aug 2023 22:17:49 +0900 Subject: [PATCH 5259/6294] [Modify] Edit it --- websocket-sharp/Net/NetworkCredential.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/NetworkCredential.cs b/websocket-sharp/Net/NetworkCredential.cs index 16409e556..0b75bff49 100644 --- a/websocket-sharp/Net/NetworkCredential.cs +++ b/websocket-sharp/Net/NetworkCredential.cs @@ -80,9 +80,8 @@ public NetworkCredential (string username, string password) } /// - /// Initializes a new instance of the class with - /// the specified , , - /// and . + /// Initializes a new instance of the class + /// with the specified username, password, domain and roles. /// /// /// A that specifies the username associated with From 6bda7f8ab873f1f0c8a8d1bd51649b8ed877d7dc Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 24 Aug 2023 22:20:57 +0900 Subject: [PATCH 5260/6294] [Modify] Edit it --- websocket-sharp/Net/NetworkCredential.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/NetworkCredential.cs b/websocket-sharp/Net/NetworkCredential.cs index 0b75bff49..e9b7e713c 100644 --- a/websocket-sharp/Net/NetworkCredential.cs +++ b/websocket-sharp/Net/NetworkCredential.cs @@ -72,7 +72,7 @@ static NetworkCredential () /// is . /// /// - /// is empty. + /// is an empty string. /// public NetworkCredential (string username, string password) : this (username, password, null, null) From 6c601e12dadf93621dd9c53d7ab7bde810dbfdc8 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 24 Aug 2023 22:22:20 +0900 Subject: [PATCH 5261/6294] [Modify] Edit it --- websocket-sharp/Net/NetworkCredential.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/NetworkCredential.cs b/websocket-sharp/Net/NetworkCredential.cs index e9b7e713c..99d0d952d 100644 --- a/websocket-sharp/Net/NetworkCredential.cs +++ b/websocket-sharp/Net/NetworkCredential.cs @@ -61,7 +61,7 @@ static NetworkCredential () /// the specified and . /// /// - /// A that represents the username associated with + /// A that specifies the username associated with /// the credentials. /// /// From 634dca592a94f656f94408ae23b1243e251ffb38 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 25 Aug 2023 22:24:27 +0900 Subject: [PATCH 5262/6294] [Modify] Edit it --- websocket-sharp/Net/NetworkCredential.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/NetworkCredential.cs b/websocket-sharp/Net/NetworkCredential.cs index 99d0d952d..3e92fc902 100644 --- a/websocket-sharp/Net/NetworkCredential.cs +++ b/websocket-sharp/Net/NetworkCredential.cs @@ -65,7 +65,7 @@ static NetworkCredential () /// the credentials. /// /// - /// A that represents the password for the username + /// A that specifies the password for the username /// associated with the credentials. /// /// From 7298f6a40e0d81e20f7e719192b4c261aff186b1 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 25 Aug 2023 22:26:21 +0900 Subject: [PATCH 5263/6294] [Modify] Edit it --- websocket-sharp/Net/NetworkCredential.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/NetworkCredential.cs b/websocket-sharp/Net/NetworkCredential.cs index 3e92fc902..1901f4f75 100644 --- a/websocket-sharp/Net/NetworkCredential.cs +++ b/websocket-sharp/Net/NetworkCredential.cs @@ -57,8 +57,8 @@ static NetworkCredential () #region Public Constructors /// - /// Initializes a new instance of the class with - /// the specified and . + /// Initializes a new instance of the class + /// with the specified username and password. /// /// /// A that specifies the username associated with From 4029d1064b10dcd1ba1ec00c81d474eb90eb7318 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 26 Aug 2023 16:48:44 +0900 Subject: [PATCH 5264/6294] [Modify] Edit it --- websocket-sharp/Net/NetworkCredential.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/NetworkCredential.cs b/websocket-sharp/Net/NetworkCredential.cs index 1901f4f75..a3ca6c81f 100644 --- a/websocket-sharp/Net/NetworkCredential.cs +++ b/websocket-sharp/Net/NetworkCredential.cs @@ -170,8 +170,8 @@ internal set { /// Gets the roles associated with the credentials. /// /// - /// This property returns an empty array if the roles were - /// initialized with . + /// This property returns an empty array if the roles were initialized + /// with . /// /// /// An array of that represents the role names From 5e546de6d0e10b296b2a1778829e9cfb39a082f0 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 26 Aug 2023 16:50:49 +0900 Subject: [PATCH 5265/6294] [Modify] Edit it --- websocket-sharp/Net/NetworkCredential.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/NetworkCredential.cs b/websocket-sharp/Net/NetworkCredential.cs index a3ca6c81f..38d07edff 100644 --- a/websocket-sharp/Net/NetworkCredential.cs +++ b/websocket-sharp/Net/NetworkCredential.cs @@ -150,8 +150,8 @@ internal set { /// Gets the password for the username associated with the credentials. /// /// - /// This property returns an empty string if the password was - /// initialized with . + /// This property returns an empty string if the password was initialized + /// with . /// /// /// A that represents the password. From 7f6249dfef58a2d8a7035c88d5da095df5bb7dce Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 27 Aug 2023 16:37:13 +0900 Subject: [PATCH 5266/6294] [Modify] Edit it --- websocket-sharp/Net/NetworkCredential.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/NetworkCredential.cs b/websocket-sharp/Net/NetworkCredential.cs index 38d07edff..570d1cc6f 100644 --- a/websocket-sharp/Net/NetworkCredential.cs +++ b/websocket-sharp/Net/NetworkCredential.cs @@ -129,12 +129,12 @@ public NetworkCredential ( /// Gets the domain associated with the credentials. /// /// - /// This property returns an empty string if the domain was - /// initialized with . + /// This property returns an empty string if the domain was initialized + /// with . /// /// - /// A that represents the domain name - /// to which the username belongs. + /// A that represents the domain name to which + /// the username belongs. /// public string Domain { get { From be37eb6cc7bf24ecd95d64a52fa01677ad6ab923 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 28 Aug 2023 22:15:56 +0900 Subject: [PATCH 5267/6294] [Modify] 2023 --- websocket-sharp/Net/NetworkCredential.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/NetworkCredential.cs b/websocket-sharp/Net/NetworkCredential.cs index 570d1cc6f..fb5ec5c3e 100644 --- a/websocket-sharp/Net/NetworkCredential.cs +++ b/websocket-sharp/Net/NetworkCredential.cs @@ -4,7 +4,7 @@ * * The MIT License * - * Copyright (c) 2014-2017 sta.blockhead + * Copyright (c) 2014-2023 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From 520a843e352ba897b6f30118e3a17d6329874247 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 29 Aug 2023 22:55:36 +0900 Subject: [PATCH 5268/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerResponse.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index 492f51021..d03f81c8b 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -1119,6 +1119,7 @@ public void SetCookie (Cookie cookie) if (!canSetCookie (cookie)) { var msg = "It cannot be updated."; + throw new ArgumentException (msg, "cookie"); } From 5530f1da7068214774c9234e65c3072b4b5d3f21 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 30 Aug 2023 23:00:05 +0900 Subject: [PATCH 5269/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerResponse.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index d03f81c8b..7565005c6 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -1072,11 +1072,13 @@ public void Redirect (string url) { if (_disposed) { var name = GetType ().ToString (); + throw new ObjectDisposedException (name); } if (_headersSent) { var msg = "The response is already being sent."; + throw new InvalidOperationException (msg); } @@ -1085,12 +1087,15 @@ public void Redirect (string url) if (url.Length == 0) { var msg = "An empty string."; + throw new ArgumentException (msg, "url"); } Uri uri; + if (!Uri.TryCreate (url, UriKind.Absolute, out uri)) { var msg = "Not an absolute URL."; + throw new ArgumentException (msg, "url"); } From 8397939b5552372996f1c12b1c4c37e6f12af60a Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 30 Aug 2023 23:03:57 +0900 Subject: [PATCH 5270/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerResponse.cs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index 7565005c6..84e912c5f 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -1085,11 +1085,8 @@ public void Redirect (string url) if (url == null) throw new ArgumentNullException ("url"); - if (url.Length == 0) { - var msg = "An empty string."; - - throw new ArgumentException (msg, "url"); - } + if (url.Length == 0) + throw new ArgumentException ("An empty string.", "url"); Uri uri; From 3aa43f9fddf8e22d11b986e20f3ee9ee9e67f268 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 31 Aug 2023 22:42:39 +0900 Subject: [PATCH 5271/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerResponse.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index 84e912c5f..b0797d6b8 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -967,6 +967,7 @@ public void Close (byte[] responseEntity, bool willBlock) { if (_disposed) { var name = GetType ().ToString (); + throw new ObjectDisposedException (name); } @@ -977,6 +978,7 @@ public void Close (byte[] responseEntity, bool willBlock) if (len > Int32.MaxValue) { close (responseEntity, 1024, willBlock); + return; } From 8ded62ee027eb9c80fe39600501c104e60d24356 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 1 Sep 2023 21:53:37 +0900 Subject: [PATCH 5272/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerResponse.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index b0797d6b8..8a30f0f23 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -774,6 +774,7 @@ private bool canSetCookie (Cookie cookie) private void close (bool force) { _disposed = true; + _context.Connection.Close (force); } From 021170aaf14157930b3074ce8f7921297cbfcbc4 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 2 Sep 2023 11:45:37 +0900 Subject: [PATCH 5273/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerResponse.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index 8a30f0f23..158eb2cb3 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -725,11 +725,13 @@ public string StatusDescription { set { if (_disposed) { var name = GetType ().ToString (); + throw new ObjectDisposedException (name); } if (_headersSent) { var msg = "The response is already being sent."; + throw new InvalidOperationException (msg); } @@ -738,11 +740,13 @@ public string StatusDescription { if (value.Length == 0) { _statusDescription = _statusCode.GetStatusDescription (); + return; } if (!isValidForStatusDescription (value)) { var msg = "It contains an invalid character."; + throw new ArgumentException (msg, "value"); } From b15e89b1b407e6ca5f47036d94ec880c14107629 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 3 Sep 2023 17:53:47 +0900 Subject: [PATCH 5274/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerResponse.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index 158eb2cb3..260f2e771 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -668,16 +668,19 @@ public int StatusCode { set { if (_disposed) { var name = GetType ().ToString (); + throw new ObjectDisposedException (name); } if (_headersSent) { var msg = "The response is already being sent."; + throw new InvalidOperationException (msg); } if (value < 100 || value > 999) { var msg = "A value is not between 100 and 999 inclusive."; + throw new System.Net.ProtocolViolationException (msg); } From 40177ccef72f0d330a6a79d327371f5693f941b5 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 4 Sep 2023 11:09:18 +0900 Subject: [PATCH 5275/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerResponse.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index 260f2e771..5a759558c 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -621,11 +621,13 @@ public bool SendChunked { set { if (_disposed) { var name = GetType ().ToString (); + throw new ObjectDisposedException (name); } if (_headersSent) { var msg = "The response is already being sent."; + throw new InvalidOperationException (msg); } From be3fe293208b2b2aa7199abdc7c1e3f4de5252bd Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 5 Sep 2023 17:21:53 +0900 Subject: [PATCH 5276/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerResponse.cs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index 5a759558c..7eb1c24fa 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -566,27 +566,30 @@ public string RedirectLocation { set { if (_disposed) { var name = GetType ().ToString (); + throw new ObjectDisposedException (name); } if (_headersSent) { var msg = "The response is already being sent."; + throw new InvalidOperationException (msg); } if (value == null) { _redirectLocation = null; + return; } - if (value.Length == 0) { - var msg = "An empty string."; - throw new ArgumentException (msg, "value"); - } + if (value.Length == 0) + throw new ArgumentException ("An empty string.", "value"); Uri uri; + if (!Uri.TryCreate (value, UriKind.Absolute, out uri)) { var msg = "Not an absolute URL."; + throw new ArgumentException (msg, "value"); } From eca6ce7a844bc5e56bcc70069b5c6727f0860ada Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 5 Sep 2023 17:24:47 +0900 Subject: [PATCH 5277/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerResponse.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index 7eb1c24fa..8d9687eee 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -492,6 +492,7 @@ public Stream OutputStream { get { if (_disposed) { var name = GetType ().ToString (); + throw new ObjectDisposedException (name); } From 9c4ae8f74c20d7247aecd9b4ade0cf4181726dd7 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 6 Sep 2023 11:18:48 +0900 Subject: [PATCH 5278/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerResponse.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index 8d9687eee..aeebd5a49 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -466,11 +466,13 @@ public bool KeepAlive { set { if (_disposed) { var name = GetType ().ToString (); + throw new ObjectDisposedException (name); } if (_headersSent) { var msg = "The response is already being sent."; + throw new InvalidOperationException (msg); } From cddd66f09b41ec88cee68d9fda965205f1b263b9 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 6 Sep 2023 11:21:30 +0900 Subject: [PATCH 5279/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerResponse.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index aeebd5a49..f6413b8b3 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -427,11 +427,13 @@ public WebHeaderCollection Headers { set { if (value == null) { _headers = null; + return; } if (value.State != HttpHeaderType.Response) { var msg = "The value is not valid for a response."; + throw new InvalidOperationException (msg); } From e08e710d835473f78768b78da6640f18d3080e39 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 7 Sep 2023 16:15:16 +0900 Subject: [PATCH 5280/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerResponse.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index f6413b8b3..0ebada7c1 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -359,26 +359,28 @@ public string ContentType { set { if (_disposed) { var name = GetType ().ToString (); + throw new ObjectDisposedException (name); } if (_headersSent) { var msg = "The response is already being sent."; + throw new InvalidOperationException (msg); } if (value == null) { _contentType = null; + return; } - if (value.Length == 0) { - var msg = "An empty string."; - throw new ArgumentException (msg, "value"); - } + if (value.Length == 0) + throw new ArgumentException ("An empty string.", "value"); if (!isValidForContentType (value)) { var msg = "It contains an invalid character."; + throw new ArgumentException (msg, "value"); } From 0db20685cd2564ca21e29623fd35024cc25c03eb Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 7 Sep 2023 16:17:51 +0900 Subject: [PATCH 5281/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerResponse.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index 0ebada7c1..42188c29e 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -297,16 +297,19 @@ public long ContentLength64 { set { if (_disposed) { var name = GetType ().ToString (); + throw new ObjectDisposedException (name); } if (_headersSent) { var msg = "The response is already being sent."; + throw new InvalidOperationException (msg); } if (value < 0) { var msg = "Less than zero."; + throw new ArgumentOutOfRangeException (msg, "value"); } From b30d15bfd15fee5605a5e280c35ea711d63a894f Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 8 Sep 2023 10:25:53 +0900 Subject: [PATCH 5282/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerResponse.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index 42188c29e..0abd745ac 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -252,11 +252,13 @@ public Encoding ContentEncoding { set { if (_disposed) { var name = GetType ().ToString (); + throw new ObjectDisposedException (name); } if (_headersSent) { var msg = "The response is already being sent."; + throw new InvalidOperationException (msg); } From dabc130634a02b46a6b94ca9a8bd1ad70e14b135 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 8 Sep 2023 10:30:59 +0900 Subject: [PATCH 5283/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerResponse.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index 0abd745ac..fed20cc01 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -87,6 +87,7 @@ public sealed class HttpListenerResponse : IDisposable internal HttpListenerResponse (HttpListenerContext context) { _context = context; + _keepAlive = true; _statusCode = 200; _statusDescription = "OK"; From 6bc05a347252141c6fa4ac516e8b9615a539f97c Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 9 Sep 2023 16:23:12 +0900 Subject: [PATCH 5284/6294] [Modify] Add it --- websocket-sharp/Net/HttpListenerResponse.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index fed20cc01..37442c748 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -208,6 +208,12 @@ internal bool HeadersSent { } } + internal string ObjectName { + get { + return GetType ().ToString (); + } + } + internal string StatusLine { get { return String.Format ( From e576513f5621771fde97cb1b3dec0f196df3bbc7 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 9 Sep 2023 16:25:27 +0900 Subject: [PATCH 5285/6294] [Modify] Replace it --- websocket-sharp/Net/HttpListenerResponse.cs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index 37442c748..3aa35bdbd 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -257,11 +257,8 @@ public Encoding ContentEncoding { } set { - if (_disposed) { - var name = GetType ().ToString (); - - throw new ObjectDisposedException (name); - } + if (_disposed) + throw new ObjectDisposedException (ObjectName); if (_headersSent) { var msg = "The response is already being sent."; From 6c8c32adf8fb46c925d75168b6f0796389289da1 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 10 Sep 2023 17:00:44 +0900 Subject: [PATCH 5286/6294] [Modify] Replace it --- websocket-sharp/Net/HttpListenerResponse.cs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index 3aa35bdbd..daac8843b 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -301,11 +301,8 @@ public long ContentLength64 { } set { - if (_disposed) { - var name = GetType ().ToString (); - - throw new ObjectDisposedException (name); - } + if (_disposed) + throw new ObjectDisposedException (ObjectName); if (_headersSent) { var msg = "The response is already being sent."; From 8bf7668b8e0401d70510c2569819352c22a02c19 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 10 Sep 2023 17:02:30 +0900 Subject: [PATCH 5287/6294] [Modify] Replace it --- websocket-sharp/Net/HttpListenerResponse.cs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index daac8843b..afa5b9ba8 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -363,11 +363,8 @@ public string ContentType { } set { - if (_disposed) { - var name = GetType ().ToString (); - - throw new ObjectDisposedException (name); - } + if (_disposed) + throw new ObjectDisposedException (ObjectName); if (_headersSent) { var msg = "The response is already being sent."; From 9a559c7cc9df9679f02b26e44b54de778f0ea19e Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 11 Sep 2023 17:05:25 +0900 Subject: [PATCH 5288/6294] [Modify] Replace it --- websocket-sharp/Net/HttpListenerResponse.cs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index afa5b9ba8..410178a4f 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -471,11 +471,8 @@ public bool KeepAlive { } set { - if (_disposed) { - var name = GetType ().ToString (); - - throw new ObjectDisposedException (name); - } + if (_disposed) + throw new ObjectDisposedException (ObjectName); if (_headersSent) { var msg = "The response is already being sent."; From c2c16548f0e8ebde7db586f7a19e56ef30d819ee Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 11 Sep 2023 17:07:21 +0900 Subject: [PATCH 5289/6294] [Modify] Replace it --- websocket-sharp/Net/HttpListenerResponse.cs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index 410178a4f..413880bc7 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -496,11 +496,8 @@ public bool KeepAlive { /// public Stream OutputStream { get { - if (_disposed) { - var name = GetType ().ToString (); - - throw new ObjectDisposedException (name); - } + if (_disposed) + throw new ObjectDisposedException (ObjectName); if (_outputStream == null) _outputStream = _context.Connection.GetResponseStream (); From 68a5f0a49cd0322b0837cc88f1127e48036157ec Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 12 Sep 2023 16:31:13 +0900 Subject: [PATCH 5290/6294] [Modify] Replace it --- websocket-sharp/Net/HttpListenerResponse.cs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index 413880bc7..a82003fa7 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -568,11 +568,8 @@ public string RedirectLocation { } set { - if (_disposed) { - var name = GetType ().ToString (); - - throw new ObjectDisposedException (name); - } + if (_disposed) + throw new ObjectDisposedException (ObjectName); if (_headersSent) { var msg = "The response is already being sent."; From 4a958aae7b22c7b7a5464e65c7a975f71b3e0799 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 12 Sep 2023 16:32:28 +0900 Subject: [PATCH 5291/6294] [Modify] Replace it --- websocket-sharp/Net/HttpListenerResponse.cs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index a82003fa7..7af4406c8 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -623,11 +623,8 @@ public bool SendChunked { } set { - if (_disposed) { - var name = GetType ().ToString (); - - throw new ObjectDisposedException (name); - } + if (_disposed) + throw new ObjectDisposedException (ObjectName); if (_headersSent) { var msg = "The response is already being sent."; From 5b6100af5b83a1a628e2adbea23f7b1c43be72d7 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 13 Sep 2023 11:50:17 +0900 Subject: [PATCH 5292/6294] [Modify] Replace it --- websocket-sharp/Net/HttpListenerResponse.cs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index 7af4406c8..7ec7e28c5 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -669,11 +669,8 @@ public int StatusCode { } set { - if (_disposed) { - var name = GetType ().ToString (); - - throw new ObjectDisposedException (name); - } + if (_disposed) + throw new ObjectDisposedException (ObjectName); if (_headersSent) { var msg = "The response is already being sent."; From 15d855d7447fb6a0ae0bd531e948fd3ce2abe284 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 14 Sep 2023 16:52:16 +0900 Subject: [PATCH 5293/6294] [Modify] Replace it --- websocket-sharp/Net/HttpListenerResponse.cs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index 7ec7e28c5..592c885b9 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -726,11 +726,8 @@ public string StatusDescription { } set { - if (_disposed) { - var name = GetType ().ToString (); - - throw new ObjectDisposedException (name); - } + if (_disposed) + throw new ObjectDisposedException (ObjectName); if (_headersSent) { var msg = "The response is already being sent."; From 12fb5df9ac871f3da41f9c32aa55ab751b7ecfae Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 15 Sep 2023 17:05:32 +0900 Subject: [PATCH 5294/6294] [Modify] Replace it --- websocket-sharp/Net/HttpListenerResponse.cs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index 592c885b9..6eacd5434 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -970,11 +970,8 @@ public void Close () ///
public void Close (byte[] responseEntity, bool willBlock) { - if (_disposed) { - var name = GetType ().ToString (); - - throw new ObjectDisposedException (name); - } + if (_disposed) + throw new ObjectDisposedException (ObjectName); if (responseEntity == null) throw new ArgumentNullException ("responseEntity"); From 907f30cb9aa7f10461208cf676e55dc3c9180768 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 16 Sep 2023 16:28:28 +0900 Subject: [PATCH 5295/6294] [Modify] Replace it --- websocket-sharp/Net/HttpListenerResponse.cs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index 6eacd5434..451fc6f90 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -1074,11 +1074,8 @@ public void CopyFrom (HttpListenerResponse templateResponse) ///
public void Redirect (string url) { - if (_disposed) { - var name = GetType ().ToString (); - - throw new ObjectDisposedException (name); - } + if (_disposed) + throw new ObjectDisposedException (ObjectName); if (_headersSent) { var msg = "The response is already being sent."; From 7b65e0a04dcb9e2160e3e93793d7596bca836a68 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 17 Sep 2023 22:26:16 +0900 Subject: [PATCH 5296/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerResponse.cs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index 451fc6f90..851c1285d 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -216,12 +216,9 @@ internal string ObjectName { internal string StatusLine { get { - return String.Format ( - "HTTP/{0} {1} {2}\r\n", - _version, - _statusCode, - _statusDescription - ); + var fmt = "HTTP/{0} {1} {2}\r\n"; + + return String.Format (fmt, _version, _statusCode, _statusDescription); } } From 97fd8990dc39c752251774917dd32092b9fd562b Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 18 Sep 2023 16:36:40 +0900 Subject: [PATCH 5297/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerResponse.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index 851c1285d..9240ab4c9 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -1100,7 +1100,7 @@ public void Redirect (string url) } /// - /// Adds or updates a cookie in the cookies sent with the response. + /// Adds or updates an HTTP cookie in the cookies sent with the response. /// /// /// A to set. From 398c72c2602fcd3113c2287b8213ca525c5c555b Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 19 Sep 2023 21:28:19 +0900 Subject: [PATCH 5298/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerResponse.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index 9240ab4c9..371079ba3 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -757,14 +757,14 @@ public string StatusDescription { private bool canSetCookie (Cookie cookie) { - var found = findCookie (cookie).ToList (); + var res = findCookie (cookie).ToList (); - if (found.Count == 0) + if (res.Count == 0) return true; var ver = cookie.Version; - foreach (var c in found) { + foreach (var c in res) { if (c.Version == ver) return true; } From 139e3e088b5f801be6052783773986d975037bd7 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 20 Sep 2023 21:16:47 +0900 Subject: [PATCH 5299/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerResponse.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index 371079ba3..8a18e3330 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -867,7 +867,7 @@ public void Abort () } /// - /// Appends the specified cookie to the cookies sent with the response. + /// Appends the specified HTTP cookie to the cookies sent with the response. /// /// /// A to append. From 69ca98a74daa643d631a1c6be8cabcdb1f172b63 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 20 Sep 2023 21:26:22 +0900 Subject: [PATCH 5300/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerResponse.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index 8a18e3330..27678cec1 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -867,7 +867,7 @@ public void Abort () } /// - /// Appends the specified HTTP cookie to the cookies sent with the response. + /// Appends an HTTP cookie to the cookies sent with the response. /// /// /// A to append. From da7875ede7b1cd68d692e0d16d3dbb47d5936c4a Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 21 Sep 2023 21:18:11 +0900 Subject: [PATCH 5301/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerResponse.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index 27678cec1..26ad3d3ef 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -808,7 +808,9 @@ private static string createContentTypeHeaderText ( if (encoding == null) return value; - return String.Format ("{0}; charset={1}", value, encoding.WebName); + var fmt = "{0}; charset={1}"; + + return String.Format (fmt, value, encoding.WebName); } private IEnumerable findCookie (Cookie cookie) From af69bb4d592cf1ae03864dd2f57982b3b9635300 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 22 Sep 2023 17:02:50 +0900 Subject: [PATCH 5302/6294] [Modify] Replace it --- websocket-sharp/Net/HttpListenerResponse.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index 26ad3d3ef..9a4d32c19 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -802,7 +802,7 @@ private static string createContentTypeHeaderText ( string value, Encoding encoding ) { - if (value.IndexOf ("charset=", StringComparison.Ordinal) > -1) + if (value.Contains ("charset=")) return value; if (encoding == null) From 15f12137614a24fd376beabebaf3f86d176e2642 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 23 Sep 2023 21:11:59 +0900 Subject: [PATCH 5303/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerResponse.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index 9a4d32c19..7ca30d12e 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -781,16 +781,14 @@ private void close (bool force) private void close (byte[] responseEntity, int bufferLength, bool willBlock) { - var stream = OutputStream; - if (willBlock) { - stream.WriteBytes (responseEntity, bufferLength); + OutputStream.WriteBytes (responseEntity, bufferLength); close (false); return; } - stream.WriteBytesAsync ( + OutputStream.WriteBytesAsync ( responseEntity, bufferLength, () => close (false), From e6b4caf228a8b2b172f74e1c56372ecb7837c8ab Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 24 Sep 2023 16:45:41 +0900 Subject: [PATCH 5304/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerResponse.cs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index 7ca30d12e..37cbd8003 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -171,11 +171,10 @@ internal WebHeaderCollection FullHeaders { headers.InternalSet ("Connection", "close", true); } else { - headers.InternalSet ( - "Keep-Alive", - String.Format ("timeout=15,max={0}", 100 - reuses), - true - ); + var fmt = "timeout=15,max={0}"; + var val = String.Format (fmt, 100 - reuses); + + headers.InternalSet ("Keep-Alive", val, true); if (_context.Request.ProtocolVersion < HttpVersion.Version11) headers.InternalSet ("Connection", "keep-alive", true); From 9d72ee350493cdf8b07453a4d22e839ab4b47617 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 25 Sep 2023 21:06:19 +0900 Subject: [PATCH 5305/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerResponse.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index 37cbd8003..80ae14f94 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -172,7 +172,8 @@ internal WebHeaderCollection FullHeaders { } else { var fmt = "timeout=15,max={0}"; - var val = String.Format (fmt, 100 - reuses); + var max = 100 - reuses; + var val = String.Format (fmt, max); headers.InternalSet ("Keep-Alive", val, true); From 85723a58aa036e580e48be99a46449cc376c542f Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 26 Sep 2023 16:52:20 +0900 Subject: [PATCH 5306/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerResponse.cs | 3 --- 1 file changed, 3 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index 80ae14f94..6e7c1f136 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -176,9 +176,6 @@ internal WebHeaderCollection FullHeaders { var val = String.Format (fmt, max); headers.InternalSet ("Keep-Alive", val, true); - - if (_context.Request.ProtocolVersion < HttpVersion.Version11) - headers.InternalSet ("Connection", "keep-alive", true); } if (_redirectLocation != null) From ec737d055585c1bb52736e7ad91675171f5bcd33 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 27 Sep 2023 21:32:45 +0900 Subject: [PATCH 5307/6294] [Modify] Move it --- websocket-sharp/Net/HttpListenerResponse.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index 6e7c1f136..edee0df10 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -155,8 +155,11 @@ internal WebHeaderCollection FullHeaders { * - 500 Internal Server Error * - 503 Service Unavailable */ + + var reuses = _context.Connection.Reuses; var closeConn = !_context.Request.KeepAlive || !_keepAlive + || reuses >= 100 || _statusCode == 400 || _statusCode == 408 || _statusCode == 411 @@ -165,9 +168,7 @@ internal WebHeaderCollection FullHeaders { || _statusCode == 500 || _statusCode == 503; - var reuses = _context.Connection.Reuses; - - if (closeConn || reuses >= 100) { + if (closeConn) { headers.InternalSet ("Connection", "close", true); } else { From 5c041d6b824c02a0a3345088a4395b73ca86d5f3 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 28 Sep 2023 22:04:00 +0900 Subject: [PATCH 5308/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerResponse.cs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index edee0df10..1bef3ee1a 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -184,11 +184,9 @@ internal WebHeaderCollection FullHeaders { if (_cookies != null) { foreach (var cookie in _cookies) { - headers.InternalSet ( - "Set-Cookie", - cookie.ToResponseString (), - true - ); + var val = cookie.ToResponseString (); + + headers.InternalSet ("Set-Cookie", val, true); } } From bdc52e8c5704922f4534ec49bc2e4e8668451e95 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 29 Sep 2023 21:14:02 +0900 Subject: [PATCH 5309/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerResponse.cs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index 1bef3ee1a..0e0ed7714 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -116,11 +116,9 @@ internal WebHeaderCollection FullHeaders { headers.Add (_headers); if (_contentType != null) { - headers.InternalSet ( - "Content-Type", - createContentTypeHeaderText (_contentType, _contentEncoding), - true - ); + var val = createContentTypeHeaderText (_contentType, _contentEncoding); + + headers.InternalSet ("Content-Type", val, true); } if (headers["Server"] == null) From cfa20067f66dd9e9c45a7e5d2136b72599af73b2 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 30 Sep 2023 21:33:50 +0900 Subject: [PATCH 5310/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerResponse.cs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index 0e0ed7714..8e9dc2b7a 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -125,11 +125,9 @@ internal WebHeaderCollection FullHeaders { headers.InternalSet ("Server", "websocket-sharp/1.0", true); if (headers["Date"] == null) { - headers.InternalSet ( - "Date", - DateTime.UtcNow.ToString ("r", CultureInfo.InvariantCulture), - true - ); + var val = DateTime.UtcNow.ToString ("r", CultureInfo.InvariantCulture); + + headers.InternalSet ("Date", val, true); } if (_sendChunked) { From 06935e6bd0773fccdda9d474cbfb14922ae5c495 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 1 Oct 2023 17:57:09 +0900 Subject: [PATCH 5311/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerResponse.cs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index 8e9dc2b7a..3e22ff2f1 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -134,11 +134,9 @@ internal WebHeaderCollection FullHeaders { headers.InternalSet ("Transfer-Encoding", "chunked", true); } else { - headers.InternalSet ( - "Content-Length", - _contentLength.ToString (CultureInfo.InvariantCulture), - true - ); + var val = _contentLength.ToString (CultureInfo.InvariantCulture); + + headers.InternalSet ("Content-Length", val, true); } /* From c5be12744391fdca9455c71f7cdd226feefcc095 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 2 Oct 2023 21:28:34 +0900 Subject: [PATCH 5312/6294] [Modify] Add it --- websocket-sharp/Net/HttpListenerResponse.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index 3e22ff2f1..65f3b3c85 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -69,6 +69,7 @@ public sealed class HttpListenerResponse : IDisposable private string _contentType; private HttpListenerContext _context; private CookieCollection _cookies; + private static readonly string _defaultProductName; private bool _disposed; private WebHeaderCollection _headers; private bool _headersSent; @@ -82,6 +83,15 @@ public sealed class HttpListenerResponse : IDisposable #endregion + #region Static Constructor + + static HttpListenerResponse () + { + _defaultProductName = "websocket-sharp/1.0"; + } + + #endregion + #region Internal Constructors internal HttpListenerResponse (HttpListenerContext context) From caae4939c2e5ed03f5737fae5cc0c7dafbe51397 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 2 Oct 2023 21:30:37 +0900 Subject: [PATCH 5313/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerResponse.cs | 32 ++++++++++----------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index 65f3b3c85..56b2d0bf6 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -63,23 +63,23 @@ public sealed class HttpListenerResponse : IDisposable { #region Private Fields - private bool _closeConnection; - private Encoding _contentEncoding; - private long _contentLength; - private string _contentType; - private HttpListenerContext _context; - private CookieCollection _cookies; + private bool _closeConnection; + private Encoding _contentEncoding; + private long _contentLength; + private string _contentType; + private HttpListenerContext _context; + private CookieCollection _cookies; private static readonly string _defaultProductName; - private bool _disposed; - private WebHeaderCollection _headers; - private bool _headersSent; - private bool _keepAlive; - private ResponseStream _outputStream; - private Uri _redirectLocation; - private bool _sendChunked; - private int _statusCode; - private string _statusDescription; - private Version _version; + private bool _disposed; + private WebHeaderCollection _headers; + private bool _headersSent; + private bool _keepAlive; + private ResponseStream _outputStream; + private Uri _redirectLocation; + private bool _sendChunked; + private int _statusCode; + private string _statusDescription; + private Version _version; #endregion From a79e9c79dca1c5c993ea1606399126cffa28c5f3 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 3 Oct 2023 22:16:53 +0900 Subject: [PATCH 5314/6294] [Modify] Replace it --- websocket-sharp/Net/HttpListenerResponse.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index 56b2d0bf6..9445e7d5b 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -132,7 +132,7 @@ internal WebHeaderCollection FullHeaders { } if (headers["Server"] == null) - headers.InternalSet ("Server", "websocket-sharp/1.0", true); + headers.InternalSet ("Server", _defaultProductName, true); if (headers["Date"] == null) { var val = DateTime.UtcNow.ToString ("r", CultureInfo.InvariantCulture); From 1ba5f2ff39ff522759efa8c549be457f9520245e Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 4 Oct 2023 22:04:54 +0900 Subject: [PATCH 5315/6294] [Modify] 2023 --- websocket-sharp/Net/HttpListenerResponse.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index 9445e7d5b..a3a3e48a7 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -8,7 +8,7 @@ * The MIT License * * Copyright (c) 2005 Novell, Inc. (http://www.novell.com) - * Copyright (c) 2012-2021 sta.blockhead + * Copyright (c) 2012-2023 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From 3bbf7fd69ad91adb2dd15a488354a97ce92dc598 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 4 Oct 2023 22:16:00 +0900 Subject: [PATCH 5316/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerRequest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index f9428d950..dcd0b2e92 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -252,7 +252,7 @@ public bool HasEntityBody { } /// - /// Gets the headers included in the request. + /// Gets the HTTP headers included in the request. /// /// /// A that contains the headers. From 8563f216f915973c14f45f54f632c44c81f497fa Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 5 Oct 2023 21:39:30 +0900 Subject: [PATCH 5317/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerRequest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index dcd0b2e92..1ffe3bb58 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -219,7 +219,7 @@ public string ContentType { } /// - /// Gets the cookies included in the request. + /// Gets the HTTP cookies included in the request. /// /// /// From 5edd0d2ba6e9e6997afc010cc587e2e150bfa32d Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 6 Oct 2023 21:29:48 +0900 Subject: [PATCH 5318/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index c25e89dca..c0ef3adc6 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -431,7 +431,8 @@ internal static CookieCollection GetCookies ( this NameValueCollection headers, bool response ) { - var val = headers[response ? "Set-Cookie" : "Cookie"]; + var name = response ? "Set-Cookie" : "Cookie"; + var val = headers[name]; return val != null ? CookieCollection.Parse (val, response) From 44125e270cb7a73b505c0a71bc57c4010ed1227a Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 6 Oct 2023 21:31:19 +0900 Subject: [PATCH 5319/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index c0ef3adc6..8e160f6c0 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -428,7 +428,8 @@ internal static string GetAbsolutePath (this Uri uri) } internal static CookieCollection GetCookies ( - this NameValueCollection headers, bool response + this NameValueCollection headers, + bool response ) { var name = response ? "Set-Cookie" : "Cookie"; From 1466cd31721eea65b8b12597b64b010866354d18 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 7 Oct 2023 17:07:07 +0900 Subject: [PATCH 5320/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerResponse.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index a3a3e48a7..91c68b158 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -389,7 +389,7 @@ public string ContentType { } /// - /// Gets or sets the collection of cookies sent with the response. + /// Gets or sets the collection of the HTTP cookies sent with the response. /// /// /// A that contains the cookies sent with From adaf74971675352ec9bfdf270827df8b7e6e6eeb Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 8 Oct 2023 21:18:34 +0900 Subject: [PATCH 5321/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerRequest.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index 1ffe3bb58..860f479cd 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -885,7 +885,8 @@ internal void SetRequestLine (string requestLine) /// This method is not supported. ///
public IAsyncResult BeginGetClientCertificate ( - AsyncCallback requestCallback, object state + AsyncCallback requestCallback, + object state ) { throw new NotSupportedException (); From 71b96e4efdbfc53e6dc8930299d4bf0791eb82f8 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 8 Oct 2023 21:40:03 +0900 Subject: [PATCH 5322/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerRequest.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index 860f479cd..d6fbfeaf5 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -203,10 +203,8 @@ public long ContentLength64 { /// /// /// - /// A or . - /// - /// - /// The string represents the value of the Content-Type header. + /// A that represents the value of the Content-Type + /// header. /// /// /// if the header is not present. From db3e702b170c85fc17c0218b69acacae4e504d83 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 9 Oct 2023 16:24:41 +0900 Subject: [PATCH 5323/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerRequest.cs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index d6fbfeaf5..a9e11c834 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -113,11 +113,8 @@ internal HttpListenerRequest (HttpListenerContext context) /// /// /// - /// An array of or . - /// - /// - /// The array contains the names of the media types specified in - /// the value of the Accept header. + /// An array of that contains the names of + /// the media types specified in the value of the Accept header. /// /// /// if the header is not present. From 2d9e6e646357b15f78087497547b40c801989a47 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 9 Oct 2023 16:36:06 +0900 Subject: [PATCH 5324/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerRequest.cs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index a9e11c834..96c958653 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -459,10 +459,7 @@ public Guid RequestTraceIdentifier { /// /// /// - /// A or . - /// - /// - /// The Uri represents the URL parsed from the request. + /// A that represents the URL parsed from the request. /// /// /// if the URL cannot be parsed. From f419524e12306f5bed127dad834b98c33c80d5ba Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 10 Oct 2023 22:24:05 +0900 Subject: [PATCH 5325/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerRequest.cs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index 96c958653..7fdc21a69 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -488,10 +488,7 @@ public Uri Url { /// /// /// - /// A or . - /// - /// - /// The Uri represents the value of the Referer header. + /// A that represents the value of the Referer header. /// /// /// if the header value is not available. From 6d1a0caecbecc0ac17abd89c025c5b4d0982a623 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 10 Oct 2023 22:27:32 +0900 Subject: [PATCH 5326/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerRequest.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index 7fdc21a69..8ed526445 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -513,10 +513,8 @@ public Uri UrlReferrer { /// /// /// - /// A or . - /// - /// - /// The string represents the value of the User-Agent header. + /// A that represents the value of the User-Agent + /// header. /// /// /// if the header is not present. From ea7c4a5af79901d7c33558c4af1af502fdefd30b Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 11 Oct 2023 21:20:07 +0900 Subject: [PATCH 5327/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerRequest.cs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index 8ed526445..13dd270df 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -561,11 +561,9 @@ public string UserHostName { /// /// /// - /// An array of or . - /// - /// - /// The array contains the names of the natural languages specified in - /// the value of the Accept-Language header. + /// An array of that contains the names of the + /// natural languages specified in the value of the Accept-Language + /// header. /// /// /// if the header is not present. From f776db58975c34e8aa42983b645197ffb3a1ef21 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 12 Oct 2023 22:02:54 +0900 Subject: [PATCH 5328/6294] [Modify] 2023 --- websocket-sharp/Net/HttpListenerRequest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index 13dd270df..44be56d33 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -8,7 +8,7 @@ * The MIT License * * Copyright (c) 2005 Novell, Inc. (http://www.novell.com) - * Copyright (c) 2012-2022 sta.blockhead + * Copyright (c) 2012-2023 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From 0279fec5843195a1c06c8b1fa6b37cb0f6b86636 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 13 Oct 2023 21:20:18 +0900 Subject: [PATCH 5329/6294] [Modify] Polish it --- websocket-sharp/Net/QueryStringCollection.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/QueryStringCollection.cs b/websocket-sharp/Net/QueryStringCollection.cs index f07f34f40..60ae418c1 100644 --- a/websocket-sharp/Net/QueryStringCollection.cs +++ b/websocket-sharp/Net/QueryStringCollection.cs @@ -126,8 +126,10 @@ public override string ToString () { var buff = new StringBuilder (); + var fmt = "{0}={1}&"; + foreach (var key in AllKeys) - buff.AppendFormat ("{0}={1}&", key, this[key]); + buff.AppendFormat (fmt, key, this[key]); if (buff.Length > 0) buff.Length--; From bf7a130fe3552bcab038209502eb42107671e86f Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 14 Oct 2023 21:14:44 +0900 Subject: [PATCH 5330/6294] [Modify] Polish it --- websocket-sharp/Net/QueryStringCollection.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/websocket-sharp/Net/QueryStringCollection.cs b/websocket-sharp/Net/QueryStringCollection.cs index 60ae418c1..4ef73da62 100644 --- a/websocket-sharp/Net/QueryStringCollection.cs +++ b/websocket-sharp/Net/QueryStringCollection.cs @@ -124,6 +124,9 @@ public static QueryStringCollection Parse (string query, Encoding encoding) public override string ToString () { + if (Count == 0) + return String.Empty; + var buff = new StringBuilder (); var fmt = "{0}={1}&"; From 0d01727067466912573bec15d8b49187fcfe81c3 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 15 Oct 2023 21:10:58 +0900 Subject: [PATCH 5331/6294] [Modify] Polish it --- websocket-sharp/Net/QueryStringCollection.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/websocket-sharp/Net/QueryStringCollection.cs b/websocket-sharp/Net/QueryStringCollection.cs index 4ef73da62..ebbedc088 100644 --- a/websocket-sharp/Net/QueryStringCollection.cs +++ b/websocket-sharp/Net/QueryStringCollection.cs @@ -134,8 +134,7 @@ public override string ToString () foreach (var key in AllKeys) buff.AppendFormat (fmt, key, this[key]); - if (buff.Length > 0) - buff.Length--; + buff.Length--; return buff.ToString (); } From ac79e7b81debacff45ebdfecd0a42aba49262450 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 16 Oct 2023 21:26:46 +0900 Subject: [PATCH 5332/6294] [Modify] 2023 --- websocket-sharp/Net/QueryStringCollection.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/QueryStringCollection.cs b/websocket-sharp/Net/QueryStringCollection.cs index ebbedc088..d5b7a8d9a 100644 --- a/websocket-sharp/Net/QueryStringCollection.cs +++ b/websocket-sharp/Net/QueryStringCollection.cs @@ -8,7 +8,7 @@ * The MIT License * * Copyright (c) 2005-2009 Novell, Inc. (http://www.novell.com) - * Copyright (c) 2018-2022 sta.blockhead + * Copyright (c) 2018-2023 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From b8cda7a7630138fd681ab84b7447d6197badd410 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 17 Oct 2023 21:11:23 +0900 Subject: [PATCH 5333/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerResponse.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index 91c68b158..e90428c88 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -797,7 +797,8 @@ private void close (byte[] responseEntity, int bufferLength, bool willBlock) } private static string createContentTypeHeaderText ( - string value, Encoding encoding + string value, + Encoding encoding ) { if (value.Contains ("charset=")) From 2a66f0142bd277d9ef08b0052b98313b2eea39f0 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 18 Oct 2023 21:08:59 +0900 Subject: [PATCH 5334/6294] [Modify] Polish it --- websocket-sharp/Net/WebHeaderCollection.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index f92fc2915..03ca33796 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1844,8 +1844,10 @@ public override string ToString () var buff = new StringBuilder (); + var fmt = "{0}: {1}\r\n"; + for (var i = 0; i < cnt; i++) - buff.AppendFormat ("{0}: {1}\r\n", GetKey (i), Get (i)); + buff.AppendFormat (fmt, GetKey (i), Get (i)); buff.Append ("\r\n"); From 70e6c592c85dd45c1f6840f51e35ba637d59314e Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 19 Oct 2023 21:21:10 +0900 Subject: [PATCH 5335/6294] [Modify] Polish it --- websocket-sharp/Net/WebHeaderCollection.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 03ca33796..5056790d5 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1880,7 +1880,8 @@ public override string ToString () ) ] void ISerializable.GetObjectData ( - SerializationInfo serializationInfo, StreamingContext streamingContext + SerializationInfo serializationInfo, + StreamingContext streamingContext ) { GetObjectData (serializationInfo, streamingContext); From 8131af9cdfa917e96c58e927312169a1b3ffeef7 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 19 Oct 2023 21:27:20 +0900 Subject: [PATCH 5336/6294] [Modify] Polish it --- websocket-sharp/Net/WebHeaderCollection.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 5056790d5..60ee5ee8a 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1461,7 +1461,8 @@ public override string[] GetValues (string name) ) ] public override void GetObjectData ( - SerializationInfo serializationInfo, StreamingContext streamingContext + SerializationInfo serializationInfo, + StreamingContext streamingContext ) { if (serializationInfo == null) From 65853a3fb7078333ea1440d1d1081553104efa25 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 20 Oct 2023 21:19:11 +0900 Subject: [PATCH 5337/6294] [Modify] Polish it --- websocket-sharp/Net/WebHeaderCollection.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 60ee5ee8a..2255b6301 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1319,6 +1319,7 @@ public override void Add (string name, string value) public override void Clear () { base.Clear (); + _state = HttpHeaderType.Unspecified; } From 97b22f629c2863d9d1f50ec0e8791bb281437fcb Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 21 Oct 2023 21:31:28 +0900 Subject: [PATCH 5338/6294] [Modify] Polish it --- websocket-sharp/Net/WebHeaderCollection.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 2255b6301..0a178fb29 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -580,7 +580,8 @@ internal WebHeaderCollection (HttpHeaderType state, bool internallyUsed) /// . ///
protected WebHeaderCollection ( - SerializationInfo serializationInfo, StreamingContext streamingContext + SerializationInfo serializationInfo, + StreamingContext streamingContext ) { if (serializationInfo == null) From 57e8e5abaa35c5f7f8981231ef79799afba555b4 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 22 Oct 2023 22:04:18 +0900 Subject: [PATCH 5339/6294] [Modify] Polish it --- websocket-sharp/Net/WebHeaderCollection.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 0a178fb29..698df82c0 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -866,10 +866,10 @@ private static string checkValue (string value, string paramName) private static HttpHeaderInfo getHeaderInfo (string name) { - var comparison = StringComparison.InvariantCultureIgnoreCase; + var compType = StringComparison.InvariantCultureIgnoreCase; foreach (var headerInfo in _headers.Values) { - if (headerInfo.HeaderName.Equals (name, comparison)) + if (headerInfo.HeaderName.Equals (name, compType)) return headerInfo; } From 7eed23e61bc074357ba838cd3a5bca401858fb45 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 23 Oct 2023 21:22:37 +0900 Subject: [PATCH 5340/6294] [Modify] Polish it --- websocket-sharp/Net/WebHeaderCollection.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 698df82c0..cffe43809 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -988,17 +988,19 @@ internal string ToStringMultiValue (bool response) var buff = new StringBuilder (); + var fmt = "{0}: {1}\r\n"; + for (var i = 0; i < cnt; i++) { var name = GetKey (i); if (isMultiValue (name, response)) { foreach (var val in GetValues (i)) - buff.AppendFormat ("{0}: {1}\r\n", name, val); + buff.AppendFormat (fmt, name, val); continue; } - buff.AppendFormat ("{0}: {1}\r\n", name, Get (i)); + buff.AppendFormat (fmt, name, Get (i)); } buff.Append ("\r\n"); From cfbb0ed6b6a3675620dc8eb1e461d7e824c02060 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 24 Oct 2023 21:26:38 +0900 Subject: [PATCH 5341/6294] [Modify] Polish it --- websocket-sharp/Net/WebHeaderCollection.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index cffe43809..12a01338e 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1831,7 +1831,9 @@ public override void Set (string name, string value) /// public byte[] ToByteArray () { - return Encoding.UTF8.GetBytes (ToString ()); + var s = ToString (); + + return Encoding.UTF8.GetBytes (s); } /// From 52d160cb68ef131b6e0651b77c5015864b3ed003 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 25 Oct 2023 21:49:09 +0900 Subject: [PATCH 5342/6294] [Modify] 2023 --- websocket-sharp/Net/WebHeaderCollection.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 12a01338e..736d65897 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -9,7 +9,7 @@ * * Copyright (c) 2003 Ximian, Inc. (http://www.ximian.com) * Copyright (c) 2007 Novell, Inc. (http://www.novell.com) - * Copyright (c) 2012-2020 sta.blockhead + * Copyright (c) 2012-2023 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From 8867114699e2d9b0a6f820181826f57746077a53 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 26 Oct 2023 21:33:10 +0900 Subject: [PATCH 5343/6294] [Modify] Polish it --- websocket-sharp/Net/RequestStream.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/RequestStream.cs b/websocket-sharp/Net/RequestStream.cs index a10096ee7..b8f0b3e99 100644 --- a/websocket-sharp/Net/RequestStream.cs +++ b/websocket-sharp/Net/RequestStream.cs @@ -171,7 +171,11 @@ private int fillFromInitialBuffer (byte[] buffer, int offset, int count) #region Public Methods public override IAsyncResult BeginRead ( - byte[] buffer, int offset, int count, AsyncCallback callback, object state + byte[] buffer, + int offset, + int count, + AsyncCallback callback, + object state ) { if (_disposed) { From fcc567b32dd5e62dd30f6db606cf51ae6123d086 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 26 Oct 2023 21:34:37 +0900 Subject: [PATCH 5344/6294] [Modify] Polish it --- websocket-sharp/Net/RequestStream.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/RequestStream.cs b/websocket-sharp/Net/RequestStream.cs index b8f0b3e99..faf83403b 100644 --- a/websocket-sharp/Net/RequestStream.cs +++ b/websocket-sharp/Net/RequestStream.cs @@ -232,7 +232,11 @@ object state } public override IAsyncResult BeginWrite ( - byte[] buffer, int offset, int count, AsyncCallback callback, object state + byte[] buffer, + int offset, + int count, + AsyncCallback callback, + object state ) { throw new NotSupportedException (); From fc6f2cfd8fb2f506fc654a3fcc0b7ddc70e9e83f Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 27 Oct 2023 21:10:07 +0900 Subject: [PATCH 5345/6294] [Modify] Add it --- websocket-sharp/Net/RequestStream.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/websocket-sharp/Net/RequestStream.cs b/websocket-sharp/Net/RequestStream.cs index faf83403b..01daf15c5 100644 --- a/websocket-sharp/Net/RequestStream.cs +++ b/websocket-sharp/Net/RequestStream.cs @@ -88,6 +88,12 @@ internal byte[] InitialBuffer { } } + internal string ObjectName { + get { + return GetType ().ToString (); + } + } + internal int Offset { get { return _offset; From 4129d2d6a7f3a942e1515680c7ffae832d669c63 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 27 Oct 2023 21:12:46 +0900 Subject: [PATCH 5346/6294] [Modify] Replace it --- websocket-sharp/Net/RequestStream.cs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Net/RequestStream.cs b/websocket-sharp/Net/RequestStream.cs index 01daf15c5..b7a9d95ab 100644 --- a/websocket-sharp/Net/RequestStream.cs +++ b/websocket-sharp/Net/RequestStream.cs @@ -184,11 +184,8 @@ public override IAsyncResult BeginRead ( object state ) { - if (_disposed) { - var name = GetType ().ToString (); - - throw new ObjectDisposedException (name); - } + if (_disposed) + throw new ObjectDisposedException (ObjectName); if (buffer == null) throw new ArgumentNullException ("buffer"); From 4e5c53657b85e7b5d731011f88063965197a45c0 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 28 Oct 2023 21:43:11 +0900 Subject: [PATCH 5347/6294] [Modify] Replace it --- websocket-sharp/Net/RequestStream.cs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Net/RequestStream.cs b/websocket-sharp/Net/RequestStream.cs index b7a9d95ab..35d624b36 100644 --- a/websocket-sharp/Net/RequestStream.cs +++ b/websocket-sharp/Net/RequestStream.cs @@ -252,11 +252,8 @@ public override void Close () public override int EndRead (IAsyncResult asyncResult) { - if (_disposed) { - var name = GetType ().ToString (); - - throw new ObjectDisposedException (name); - } + if (_disposed) + throw new ObjectDisposedException (ObjectName); if (asyncResult == null) throw new ArgumentNullException ("asyncResult"); From f5680ec7598e09e2f2ab68cdc48ab3aec9c4da90 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 29 Oct 2023 16:47:43 +0900 Subject: [PATCH 5348/6294] [Modify] Replace it --- websocket-sharp/Net/RequestStream.cs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Net/RequestStream.cs b/websocket-sharp/Net/RequestStream.cs index 35d624b36..3db6ce5a7 100644 --- a/websocket-sharp/Net/RequestStream.cs +++ b/websocket-sharp/Net/RequestStream.cs @@ -286,11 +286,8 @@ public override void Flush () public override int Read (byte[] buffer, int offset, int count) { - if (_disposed) { - var name = GetType ().ToString (); - - throw new ObjectDisposedException (name); - } + if (_disposed) + throw new ObjectDisposedException (ObjectName); if (buffer == null) throw new ArgumentNullException ("buffer"); From be5f35ef53bdb3a2c11704cfc8360eb08fc69da8 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 30 Oct 2023 21:24:48 +0900 Subject: [PATCH 5349/6294] [Modify] Polish it --- websocket-sharp/Net/RequestStream.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/RequestStream.cs b/websocket-sharp/Net/RequestStream.cs index 3db6ce5a7..6e6fb572d 100644 --- a/websocket-sharp/Net/RequestStream.cs +++ b/websocket-sharp/Net/RequestStream.cs @@ -205,7 +205,7 @@ object state var len = buffer.Length; if (offset + count > len) { - var msg = "The sum of 'offset' and 'count' is greater than the length of 'buffer'."; + var msg = "The sum of offset and count is greater than the length of buffer."; throw new ArgumentException (msg); } From 8223899b0f07d65572714c4755f04e4b4f80d9ae Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 31 Oct 2023 22:03:14 +0900 Subject: [PATCH 5350/6294] [Modify] Polish it --- websocket-sharp/Net/RequestStream.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/RequestStream.cs b/websocket-sharp/Net/RequestStream.cs index 6e6fb572d..0d25fe221 100644 --- a/websocket-sharp/Net/RequestStream.cs +++ b/websocket-sharp/Net/RequestStream.cs @@ -307,7 +307,7 @@ public override int Read (byte[] buffer, int offset, int count) var len = buffer.Length; if (offset + count > len) { - var msg = "The sum of 'offset' and 'count' is greater than the length of 'buffer'."; + var msg = "The sum of offset and count is greater than the length of buffer."; throw new ArgumentException (msg); } From 1ecddef6ec1adc595473b64db7ddb8e642433775 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 1 Nov 2023 21:29:12 +0900 Subject: [PATCH 5351/6294] [Modify] 2023 --- websocket-sharp/Net/RequestStream.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/RequestStream.cs b/websocket-sharp/Net/RequestStream.cs index 0d25fe221..dd40f920a 100644 --- a/websocket-sharp/Net/RequestStream.cs +++ b/websocket-sharp/Net/RequestStream.cs @@ -8,7 +8,7 @@ * The MIT License * * Copyright (c) 2005 Novell, Inc. (http://www.novell.com) - * Copyright (c) 2012-2022 sta.blockhead + * Copyright (c) 2012-2023 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From 3474bf0b73cd550ddec8210c6c2f48bad8ca9b1d Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 2 Nov 2023 21:57:37 +0900 Subject: [PATCH 5352/6294] [Modify] Add it --- websocket-sharp/Net/ResponseStream.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/websocket-sharp/Net/ResponseStream.cs b/websocket-sharp/Net/ResponseStream.cs index c91b6e295..6ba049b76 100644 --- a/websocket-sharp/Net/ResponseStream.cs +++ b/websocket-sharp/Net/ResponseStream.cs @@ -97,6 +97,16 @@ bool ignoreWriteExceptions #endregion + #region Internal Properties + + internal string ObjectName { + get { + return GetType ().ToString (); + } + } + + #endregion + #region Public Properties public override bool CanRead { From 69393e1c8554666d24e7241e780be62cc7ceb1a3 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 2 Nov 2023 21:59:42 +0900 Subject: [PATCH 5353/6294] [Modify] Replace it --- websocket-sharp/Net/ResponseStream.cs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Net/ResponseStream.cs b/websocket-sharp/Net/ResponseStream.cs index 6ba049b76..ffef828f2 100644 --- a/websocket-sharp/Net/ResponseStream.cs +++ b/websocket-sharp/Net/ResponseStream.cs @@ -334,11 +334,8 @@ public override IAsyncResult BeginWrite ( object state ) { - if (_disposed) { - var name = GetType ().ToString (); - - throw new ObjectDisposedException (name); - } + if (_disposed) + throw new ObjectDisposedException (ObjectName); return _bodyBuffer.BeginWrite (buffer, offset, count, callback, state); } From 0baccabfa5b490dc553334f06be3ed5fe24e77ea Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 3 Nov 2023 21:32:48 +0900 Subject: [PATCH 5354/6294] [Modify] Replace it --- websocket-sharp/Net/ResponseStream.cs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Net/ResponseStream.cs b/websocket-sharp/Net/ResponseStream.cs index ffef828f2..f289f9ad0 100644 --- a/websocket-sharp/Net/ResponseStream.cs +++ b/websocket-sharp/Net/ResponseStream.cs @@ -357,11 +357,8 @@ public override int EndRead (IAsyncResult asyncResult) public override void EndWrite (IAsyncResult asyncResult) { - if (_disposed) { - var name = GetType ().ToString (); - - throw new ObjectDisposedException (name); - } + if (_disposed) + throw new ObjectDisposedException (ObjectName); _bodyBuffer.EndWrite (asyncResult); } From 25f5e80bcdb94b25fc6b57707f1a20e715874270 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 4 Nov 2023 16:35:16 +0900 Subject: [PATCH 5355/6294] [Modify] Replace it --- websocket-sharp/Net/ResponseStream.cs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Net/ResponseStream.cs b/websocket-sharp/Net/ResponseStream.cs index f289f9ad0..760f25401 100644 --- a/websocket-sharp/Net/ResponseStream.cs +++ b/websocket-sharp/Net/ResponseStream.cs @@ -393,11 +393,8 @@ public override void SetLength (long value) public override void Write (byte[] buffer, int offset, int count) { - if (_disposed) { - var name = GetType ().ToString (); - - throw new ObjectDisposedException (name); - } + if (_disposed) + throw new ObjectDisposedException (ObjectName); _bodyBuffer.Write (buffer, offset, count); } From b04bb7eee97ae2e11e19a69a19371209c757450e Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 4 Nov 2023 16:40:59 +0900 Subject: [PATCH 5356/6294] [Modify] Polish it --- websocket-sharp/Net/ResponseStream.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/ResponseStream.cs b/websocket-sharp/Net/ResponseStream.cs index 760f25401..43ef57bb4 100644 --- a/websocket-sharp/Net/ResponseStream.cs +++ b/websocket-sharp/Net/ResponseStream.cs @@ -261,7 +261,9 @@ private void writeChunkedWithoutThrowingException ( } private void writeWithoutThrowingException ( - byte[] buffer, int offset, int count + byte[] buffer, + int offset, + int count ) { try { From 9bab41fd95532853a1d029f0c0029ad1614d0f3a Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 4 Nov 2023 16:43:11 +0900 Subject: [PATCH 5357/6294] [Modify] Polish it --- websocket-sharp/Net/ResponseStream.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/ResponseStream.cs b/websocket-sharp/Net/ResponseStream.cs index 43ef57bb4..a0a019e14 100644 --- a/websocket-sharp/Net/ResponseStream.cs +++ b/websocket-sharp/Net/ResponseStream.cs @@ -250,7 +250,9 @@ private void writeChunked (byte[] buffer, int offset, int count) } private void writeChunkedWithoutThrowingException ( - byte[] buffer, int offset, int count + byte[] buffer, + int offset, + int count ) { try { From ca27f98132b8cb35cc603760d83d9c5879c5eacf Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 5 Nov 2023 16:35:35 +0900 Subject: [PATCH 5358/6294] [Modify] Polish it --- websocket-sharp/Net/ResponseStream.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/ResponseStream.cs b/websocket-sharp/Net/ResponseStream.cs index a0a019e14..f14129dda 100644 --- a/websocket-sharp/Net/ResponseStream.cs +++ b/websocket-sharp/Net/ResponseStream.cs @@ -235,9 +235,10 @@ private bool flushHeaders () private static byte[] getChunkSizeBytes (int size) { - var chunkSize = String.Format ("{0:x}\r\n", size); + var fmt = "{0:x}\r\n"; + var s = String.Format (fmt, size); - return Encoding.ASCII.GetBytes (chunkSize); + return Encoding.ASCII.GetBytes (s); } private void writeChunked (byte[] buffer, int offset, int count) From dc713cc6b26adb4ad3d1909ef8a288d796124211 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 6 Nov 2023 21:14:18 +0900 Subject: [PATCH 5359/6294] [Modify] Rename it --- websocket-sharp/Net/ResponseStream.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/ResponseStream.cs b/websocket-sharp/Net/ResponseStream.cs index f14129dda..d2b877c03 100644 --- a/websocket-sharp/Net/ResponseStream.cs +++ b/websocket-sharp/Net/ResponseStream.cs @@ -233,7 +233,7 @@ private bool flushHeaders () return true; } - private static byte[] getChunkSizeBytes (int size) + private static byte[] getChunkSizeStringAsBytes (int size) { var fmt = "{0:x}\r\n"; var s = String.Format (fmt, size); @@ -243,7 +243,7 @@ private static byte[] getChunkSizeBytes (int size) private void writeChunked (byte[] buffer, int offset, int count) { - var size = getChunkSizeBytes (count); + var size = getChunkSizeStringAsBytes (count); _innerStream.Write (size, 0, size.Length); _innerStream.Write (buffer, offset, count); From 9eb865d605e55b679c8f9a863d6b22cdd6dc2770 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 7 Nov 2023 20:48:33 +0900 Subject: [PATCH 5360/6294] [Modify] Polish it --- websocket-sharp/Net/ResponseStream.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Net/ResponseStream.cs b/websocket-sharp/Net/ResponseStream.cs index d2b877c03..3a2b683bb 100644 --- a/websocket-sharp/Net/ResponseStream.cs +++ b/websocket-sharp/Net/ResponseStream.cs @@ -192,6 +192,7 @@ private void flushBody (bool closing) if (!closing) { _bodyBuffer = new MemoryStream (); + return; } From 3decc18c438685ade1b74bccf5e08d19b4863c8e Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 8 Nov 2023 21:15:00 +0900 Subject: [PATCH 5361/6294] [Modify] Polish it --- websocket-sharp/Net/ResponseStream.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/ResponseStream.cs b/websocket-sharp/Net/ResponseStream.cs index 3a2b683bb..f622f8ec9 100644 --- a/websocket-sharp/Net/ResponseStream.cs +++ b/websocket-sharp/Net/ResponseStream.cs @@ -186,7 +186,9 @@ private void flushBody (bool closing) } } else if (len > 0) { - _writeBody (_bodyBuffer.GetBuffer (), 0, (int) len); + var buff = _bodyBuffer.GetBuffer (); + + _writeBody (buff, 0, (int) len); } } From eeb0d9dcc768f0465e11ff2d6b7d666220d04c96 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 9 Nov 2023 21:06:28 +0900 Subject: [PATCH 5362/6294] [Modify] Polish it --- websocket-sharp/Net/ResponseStream.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/ResponseStream.cs b/websocket-sharp/Net/ResponseStream.cs index f622f8ec9..a9ca239ab 100644 --- a/websocket-sharp/Net/ResponseStream.cs +++ b/websocket-sharp/Net/ResponseStream.cs @@ -214,21 +214,21 @@ private bool flushHeaders () var statusLine = _response.StatusLine; var headers = _response.FullHeaders; - var buff = new MemoryStream (); + var stream = new MemoryStream (); var enc = Encoding.UTF8; - using (var writer = new StreamWriter (buff, enc, 256)) { + using (var writer = new StreamWriter (stream, enc, 256)) { writer.Write (statusLine); writer.Write (headers.ToStringMultiValue (true)); writer.Flush (); var start = enc.GetPreamble ().Length; - var len = buff.Length - start; + var len = stream.Length - start; if (len > _maxHeadersLength) return false; - _write (buff.GetBuffer (), start, (int) len); + _write (stream.GetBuffer (), start, (int) len); } _response.CloseConnection = headers["Connection"] == "close"; From cda8ead6b0071bafad565f7d547e4b54d5817998 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 10 Nov 2023 21:16:30 +0900 Subject: [PATCH 5363/6294] [Modify] Polish it --- websocket-sharp/Net/ResponseStream.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/ResponseStream.cs b/websocket-sharp/Net/ResponseStream.cs index a9ca239ab..ace941ef0 100644 --- a/websocket-sharp/Net/ResponseStream.cs +++ b/websocket-sharp/Net/ResponseStream.cs @@ -228,7 +228,9 @@ private bool flushHeaders () if (len > _maxHeadersLength) return false; - _write (stream.GetBuffer (), start, (int) len); + var buff = stream.GetBuffer (); + + _write (buff, start, (int) len); } _response.CloseConnection = headers["Connection"] == "close"; From 43238375b0ffe14e17e68f2482dd62be45e00dc0 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 11 Nov 2023 22:03:24 +0900 Subject: [PATCH 5364/6294] [Modify] Polish it --- websocket-sharp/Net/ResponseStream.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/websocket-sharp/Net/ResponseStream.cs b/websocket-sharp/Net/ResponseStream.cs index ace941ef0..ebcc22640 100644 --- a/websocket-sharp/Net/ResponseStream.cs +++ b/websocket-sharp/Net/ResponseStream.cs @@ -211,14 +211,13 @@ private bool flushHeaders () return false; } - var statusLine = _response.StatusLine; var headers = _response.FullHeaders; var stream = new MemoryStream (); var enc = Encoding.UTF8; using (var writer = new StreamWriter (stream, enc, 256)) { - writer.Write (statusLine); + writer.Write (_response.StatusLine); writer.Write (headers.ToStringMultiValue (true)); writer.Flush (); From b68faada474182c38073397b5ecd9938da35f1cf Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 12 Nov 2023 22:04:42 +0900 Subject: [PATCH 5365/6294] [Modify] Polish it --- websocket-sharp/Net/ResponseStream.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/ResponseStream.cs b/websocket-sharp/Net/ResponseStream.cs index ebcc22640..c4045e66b 100644 --- a/websocket-sharp/Net/ResponseStream.cs +++ b/websocket-sharp/Net/ResponseStream.cs @@ -218,7 +218,10 @@ private bool flushHeaders () using (var writer = new StreamWriter (stream, enc, 256)) { writer.Write (_response.StatusLine); - writer.Write (headers.ToStringMultiValue (true)); + + var s = headers.ToStringMultiValue (true); + + writer.Write (s); writer.Flush (); var start = enc.GetPreamble ().Length; From a5bdbc219d8e4dfcfd22a4fc880a423a03abb162 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 13 Nov 2023 20:58:43 +0900 Subject: [PATCH 5366/6294] [Modify] 2023 --- websocket-sharp/Net/ResponseStream.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/ResponseStream.cs b/websocket-sharp/Net/ResponseStream.cs index c4045e66b..456d1e470 100644 --- a/websocket-sharp/Net/ResponseStream.cs +++ b/websocket-sharp/Net/ResponseStream.cs @@ -8,7 +8,7 @@ * The MIT License * * Copyright (c) 2005 Novell, Inc. (http://www.novell.com) - * Copyright (c) 2012-2020 sta.blockhead + * Copyright (c) 2012-2023 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From 08b0d9fcb0bed5acd95f064a8ab69c4431de5b2e Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 14 Nov 2023 20:42:48 +0900 Subject: [PATCH 5367/6294] [Modify] Polish it --- websocket-sharp/Net/EndPointListener.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/EndPointListener.cs b/websocket-sharp/Net/EndPointListener.cs index b372a2524..f46ad9115 100644 --- a/websocket-sharp/Net/EndPointListener.cs +++ b/websocket-sharp/Net/EndPointListener.cs @@ -171,7 +171,8 @@ public ServerSslConfiguration SslConfiguration { #region Private Methods private static void addSpecial ( - List prefixes, HttpListenerPrefix prefix + List prefixes, + HttpListenerPrefix prefix ) { var path = prefix.Path; From 1faf91eaabb5b0b04f462a66a0ac5bf8833ed057 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 15 Nov 2023 21:27:38 +0900 Subject: [PATCH 5368/6294] [Modify] Polish it --- websocket-sharp/Net/EndPointListener.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/websocket-sharp/Net/EndPointListener.cs b/websocket-sharp/Net/EndPointListener.cs index f46ad9115..ea8636fc6 100644 --- a/websocket-sharp/Net/EndPointListener.cs +++ b/websocket-sharp/Net/EndPointListener.cs @@ -200,9 +200,7 @@ private void clearConnections () conns = new HttpConnection[cnt]; - var vals = _connections.Values; - vals.CopyTo (conns, 0); - + _connections.Values.CopyTo (conns, 0); _connections.Clear (); } From fc54d777128ee69b2cd8162cb800b6e7ff03f425 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 15 Nov 2023 21:31:36 +0900 Subject: [PATCH 5369/6294] [Modify] Polish it --- websocket-sharp/Net/EndPointListener.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Net/EndPointListener.cs b/websocket-sharp/Net/EndPointListener.cs index ea8636fc6..df7692f76 100644 --- a/websocket-sharp/Net/EndPointListener.cs +++ b/websocket-sharp/Net/EndPointListener.cs @@ -213,6 +213,7 @@ private static RSACryptoServiceProvider createRSAFromFile (string path) var rsa = new RSACryptoServiceProvider (); var key = File.ReadAllBytes (path); + rsa.ImportCspBlob (key); return rsa; From 59f7d169e9cf71f62260b045ae8c566d20a4bcdb Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 16 Nov 2023 20:30:36 +0900 Subject: [PATCH 5370/6294] [Modify] Polish it --- websocket-sharp/Net/EndPointListener.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/EndPointListener.cs b/websocket-sharp/Net/EndPointListener.cs index df7692f76..9bc6b53c5 100644 --- a/websocket-sharp/Net/EndPointListener.cs +++ b/websocket-sharp/Net/EndPointListener.cs @@ -220,7 +220,9 @@ private static RSACryptoServiceProvider createRSAFromFile (string path) } private static X509Certificate2 getCertificate ( - int port, string folderPath, X509Certificate2 defaultCertificate + int port, + string folderPath, + X509Certificate2 defaultCertificate ) { if (folderPath == null || folderPath.Length == 0) From 27b88926d4c8eb1f152f99141f8a12ff2c920662 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 16 Nov 2023 20:33:10 +0900 Subject: [PATCH 5371/6294] [Modify] Polish it --- websocket-sharp/Net/EndPointListener.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/EndPointListener.cs b/websocket-sharp/Net/EndPointListener.cs index 9bc6b53c5..1e2851bbb 100644 --- a/websocket-sharp/Net/EndPointListener.cs +++ b/websocket-sharp/Net/EndPointListener.cs @@ -232,7 +232,9 @@ X509Certificate2 defaultCertificate var cer = Path.Combine (folderPath, String.Format ("{0}.cer", port)); var key = Path.Combine (folderPath, String.Format ("{0}.key", port)); - if (File.Exists (cer) && File.Exists (key)) { + var exists = File.Exists (cer) && File.Exists (key); + + if (exists) { var cert = new X509Certificate2 (cer); cert.PrivateKey = createRSAFromFile (key); From 9f93b4be4c4161bd261e761608ed8ec32c7713ef Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 17 Nov 2023 20:46:02 +0900 Subject: [PATCH 5372/6294] [Modify] Polish it --- websocket-sharp/Net/EndPointListener.cs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/websocket-sharp/Net/EndPointListener.cs b/websocket-sharp/Net/EndPointListener.cs index 1e2851bbb..4c3d2d841 100644 --- a/websocket-sharp/Net/EndPointListener.cs +++ b/websocket-sharp/Net/EndPointListener.cs @@ -234,17 +234,18 @@ X509Certificate2 defaultCertificate var exists = File.Exists (cer) && File.Exists (key); - if (exists) { - var cert = new X509Certificate2 (cer); - cert.PrivateKey = createRSAFromFile (key); + if (!exists) + return defaultCertificate; - return cert; - } + var cert = new X509Certificate2 (cer); + + cert.PrivateKey = createRSAFromFile (key); + + return cert; } catch { + return defaultCertificate; } - - return defaultCertificate; } private void leaveIfNoPrefix () From 6ca4dcac982da9d899d88240b3ebb903113d9adc Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 18 Nov 2023 21:05:58 +0900 Subject: [PATCH 5373/6294] [Modify] Polish it --- websocket-sharp/Net/EndPointListener.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/EndPointListener.cs b/websocket-sharp/Net/EndPointListener.cs index 4c3d2d841..a7ee4b418 100644 --- a/websocket-sharp/Net/EndPointListener.cs +++ b/websocket-sharp/Net/EndPointListener.cs @@ -301,7 +301,8 @@ private static void onAccept (IAsyncResult asyncResult) } private static void processAccepted ( - Socket socket, EndPointListener listener + Socket socket, + EndPointListener listener ) { HttpConnection conn = null; From ead0280c3c1c9cd355e1e48b8c78265cc92d12df Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 18 Nov 2023 21:07:45 +0900 Subject: [PATCH 5374/6294] [Modify] Polish it --- websocket-sharp/Net/EndPointListener.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/EndPointListener.cs b/websocket-sharp/Net/EndPointListener.cs index a7ee4b418..dad4efbab 100644 --- a/websocket-sharp/Net/EndPointListener.cs +++ b/websocket-sharp/Net/EndPointListener.cs @@ -325,7 +325,8 @@ EndPointListener listener } private static bool removeSpecial ( - List prefixes, HttpListenerPrefix prefix + List prefixes, + HttpListenerPrefix prefix ) { var path = prefix.Path; From fb570ad5c4ec5125c703df0fc1892caa04372033 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 19 Nov 2023 21:06:23 +0900 Subject: [PATCH 5375/6294] [Modify] Polish it --- websocket-sharp/Net/EndPointListener.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/EndPointListener.cs b/websocket-sharp/Net/EndPointListener.cs index dad4efbab..4f9058417 100644 --- a/websocket-sharp/Net/EndPointListener.cs +++ b/websocket-sharp/Net/EndPointListener.cs @@ -344,7 +344,8 @@ HttpListenerPrefix prefix } private static HttpListener searchHttpListenerFromSpecial ( - string path, List prefixes + string path, + List prefixes ) { if (prefixes == null) From f4f8009ced53ce020fc47f9bfde705563eaab0b6 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 20 Nov 2023 21:18:10 +0900 Subject: [PATCH 5376/6294] [Modify] Polish it --- websocket-sharp/Net/EndPointListener.cs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/EndPointListener.cs b/websocket-sharp/Net/EndPointListener.cs index 4f9058417..7c2d188f7 100644 --- a/websocket-sharp/Net/EndPointListener.cs +++ b/websocket-sharp/Net/EndPointListener.cs @@ -362,10 +362,13 @@ List prefixes if (len < bestLen) continue; - if (path.StartsWith (prefPath, StringComparison.Ordinal)) { - bestLen = len; - ret = pref.Listener; - } + var match = path.StartsWith (prefPath, StringComparison.Ordinal); + + if (!match) + continue; + + bestLen = len; + ret = pref.Listener; } return ret; From 0b03b53ffa366da07d39a471c3aa40b99011c098 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 21 Nov 2023 20:54:30 +0900 Subject: [PATCH 5377/6294] [Modify] Polish it --- websocket-sharp/Net/EndPointListener.cs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/EndPointListener.cs b/websocket-sharp/Net/EndPointListener.cs index 7c2d188f7..a04e3bbb7 100644 --- a/websocket-sharp/Net/EndPointListener.cs +++ b/websocket-sharp/Net/EndPointListener.cs @@ -434,10 +434,13 @@ internal bool TrySearchHttpListener (Uri uri, out HttpListener listener) if (len < bestLen) continue; - if (path.StartsWith (prefPath, StringComparison.Ordinal)) { - bestLen = len; - listener = pref.Listener; - } + var match = path.StartsWith (prefPath, StringComparison.Ordinal); + + if (!match) + continue; + + bestLen = len; + listener = pref.Listener; } if (bestLen != -1) From 158ff885f6b784e2afe729e02202c7ebfe81f005 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 22 Nov 2023 20:55:29 +0900 Subject: [PATCH 5378/6294] [Modify] Polish it --- websocket-sharp/Net/EndPointListener.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/EndPointListener.cs b/websocket-sharp/Net/EndPointListener.cs index a04e3bbb7..f1a897135 100644 --- a/websocket-sharp/Net/EndPointListener.cs +++ b/websocket-sharp/Net/EndPointListener.cs @@ -503,9 +503,8 @@ public void AddPrefix (HttpListenerPrefix prefix) if (idx > -1) { if (current[idx].Listener != prefix.Listener) { - var msg = String.Format ( - "There is another listener for {0}.", prefix - ); + var fmt = "There is another listener for {0}."; + var msg = String.Format (fmt, prefix); throw new HttpListenerException (87, msg); } From 8a4925226f98e2fd1d49f1f52866e30f5a44bab4 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 23 Nov 2023 21:19:55 +0900 Subject: [PATCH 5379/6294] [Modify] Polish it --- websocket-sharp/Net/EndPointListener.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Net/EndPointListener.cs b/websocket-sharp/Net/EndPointListener.cs index f1a897135..12b759773 100644 --- a/websocket-sharp/Net/EndPointListener.cs +++ b/websocket-sharp/Net/EndPointListener.cs @@ -581,6 +581,7 @@ public void RemovePrefix (HttpListenerPrefix prefix) break; future = new List (current); + future.Remove (prefix); } while ( From 9e47b71e09eaac0a86e914fb2c15ffcb353329c8 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 24 Nov 2023 21:07:44 +0900 Subject: [PATCH 5380/6294] [Modify] Polish it --- websocket-sharp/Net/EndPointListener.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/EndPointListener.cs b/websocket-sharp/Net/EndPointListener.cs index 12b759773..40b50d005 100644 --- a/websocket-sharp/Net/EndPointListener.cs +++ b/websocket-sharp/Net/EndPointListener.cs @@ -545,7 +545,8 @@ public void RemovePrefix (HttpListenerPrefix prefix) break; } while ( - Interlocked.CompareExchange (ref _unhandled, future, current) != current + Interlocked.CompareExchange (ref _unhandled, future, current) + != current ); leaveIfNoPrefix (); From b700410f6678fec2787b833058efbf963dcd1760 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 24 Nov 2023 21:09:32 +0900 Subject: [PATCH 5381/6294] [Modify] Polish it --- websocket-sharp/Net/EndPointListener.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/EndPointListener.cs b/websocket-sharp/Net/EndPointListener.cs index 40b50d005..70383a7b4 100644 --- a/websocket-sharp/Net/EndPointListener.cs +++ b/websocket-sharp/Net/EndPointListener.cs @@ -567,7 +567,8 @@ public void RemovePrefix (HttpListenerPrefix prefix) break; } while ( - Interlocked.CompareExchange (ref _all, future, current) != current + Interlocked.CompareExchange (ref _all, future, current) + != current ); leaveIfNoPrefix (); From 6d3ee75a4e23ac9079b1d6d411dcfbf9b4fd4bb4 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 24 Nov 2023 21:11:47 +0900 Subject: [PATCH 5382/6294] [Modify] Polish it --- websocket-sharp/Net/EndPointListener.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/EndPointListener.cs b/websocket-sharp/Net/EndPointListener.cs index 70383a7b4..ace5a624a 100644 --- a/websocket-sharp/Net/EndPointListener.cs +++ b/websocket-sharp/Net/EndPointListener.cs @@ -587,7 +587,8 @@ public void RemovePrefix (HttpListenerPrefix prefix) future.Remove (prefix); } while ( - Interlocked.CompareExchange (ref _prefixes, future, current) != current + Interlocked.CompareExchange (ref _prefixes, future, current) + != current ); leaveIfNoPrefix (); From 84f03c63fde75b1a595e6016e4f78c00014b8207 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 25 Nov 2023 21:11:45 +0900 Subject: [PATCH 5383/6294] [Modify] Polish it --- websocket-sharp/Net/EndPointListener.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/EndPointListener.cs b/websocket-sharp/Net/EndPointListener.cs index ace5a624a..e06abf600 100644 --- a/websocket-sharp/Net/EndPointListener.cs +++ b/websocket-sharp/Net/EndPointListener.cs @@ -475,7 +475,8 @@ public void AddPrefix (HttpListenerPrefix prefix) addSpecial (future, prefix); } while ( - Interlocked.CompareExchange (ref _unhandled, future, current) != current + Interlocked.CompareExchange (ref _unhandled, future, current) + != current ); return; From 267fe4dd3a8edc4f77315f32cf44fae68c49b7a2 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 25 Nov 2023 21:12:43 +0900 Subject: [PATCH 5384/6294] [Modify] Polish it --- websocket-sharp/Net/EndPointListener.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/EndPointListener.cs b/websocket-sharp/Net/EndPointListener.cs index e06abf600..bbb956413 100644 --- a/websocket-sharp/Net/EndPointListener.cs +++ b/websocket-sharp/Net/EndPointListener.cs @@ -492,7 +492,8 @@ public void AddPrefix (HttpListenerPrefix prefix) addSpecial (future, prefix); } while ( - Interlocked.CompareExchange (ref _all, future, current) != current + Interlocked.CompareExchange (ref _all, future, current) + != current ); return; From f5672b1764ce9c3c203016b13050f3e196f03861 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 26 Nov 2023 21:08:45 +0900 Subject: [PATCH 5385/6294] [Modify] Polish it --- websocket-sharp/Net/EndPointListener.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Net/EndPointListener.cs b/websocket-sharp/Net/EndPointListener.cs index bbb956413..42d05ed12 100644 --- a/websocket-sharp/Net/EndPointListener.cs +++ b/websocket-sharp/Net/EndPointListener.cs @@ -501,6 +501,7 @@ public void AddPrefix (HttpListenerPrefix prefix) do { current = _prefixes; + var idx = current.IndexOf (prefix); if (idx > -1) { From 6eecf5628e240aef52ed305930cc0b782a5feb6d Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 26 Nov 2023 21:10:04 +0900 Subject: [PATCH 5386/6294] [Modify] Polish it --- websocket-sharp/Net/EndPointListener.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Net/EndPointListener.cs b/websocket-sharp/Net/EndPointListener.cs index 42d05ed12..a557013ac 100644 --- a/websocket-sharp/Net/EndPointListener.cs +++ b/websocket-sharp/Net/EndPointListener.cs @@ -516,6 +516,7 @@ public void AddPrefix (HttpListenerPrefix prefix) } future = new List (current); + future.Add (prefix); } while ( From 356dc2d0ea405524f43b63d4cff6e85e7ac3bdff Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 27 Nov 2023 22:31:40 +0900 Subject: [PATCH 5387/6294] [Modify] Polish it --- websocket-sharp/Net/EndPointListener.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/EndPointListener.cs b/websocket-sharp/Net/EndPointListener.cs index a557013ac..977f97fcb 100644 --- a/websocket-sharp/Net/EndPointListener.cs +++ b/websocket-sharp/Net/EndPointListener.cs @@ -520,7 +520,8 @@ public void AddPrefix (HttpListenerPrefix prefix) future.Add (prefix); } while ( - Interlocked.CompareExchange (ref _prefixes, future, current) != current + Interlocked.CompareExchange (ref _prefixes, future, current) + != current ); } From b7eab685148dc911ab9f7775c39186dab0908d13 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 28 Nov 2023 20:59:47 +0900 Subject: [PATCH 5388/6294] [Modify] 2023 --- websocket-sharp/Net/EndPointListener.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/EndPointListener.cs b/websocket-sharp/Net/EndPointListener.cs index 977f97fcb..3c8b3653a 100644 --- a/websocket-sharp/Net/EndPointListener.cs +++ b/websocket-sharp/Net/EndPointListener.cs @@ -8,7 +8,7 @@ * The MIT License * * Copyright (c) 2005 Novell, Inc. (http://www.novell.com) - * Copyright (c) 2012-2020 sta.blockhead + * Copyright (c) 2012-2023 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From f5e75180a014652ee266f577281e8c8a20a08042 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 29 Nov 2023 21:34:27 +0900 Subject: [PATCH 5389/6294] [Modify] Polish it --- websocket-sharp/Net/HttpConnection.cs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpConnection.cs b/websocket-sharp/Net/HttpConnection.cs index 30ca852ab..ce9fb4eff 100644 --- a/websocket-sharp/Net/HttpConnection.cs +++ b/websocket-sharp/Net/HttpConnection.cs @@ -601,10 +601,18 @@ public RequestStream GetRequestStream (long contentLength, bool chunked) _inputStream = chunked ? new ChunkedRequestStream ( - _stream, buff, _position, cnt, _context + _stream, + buff, + _position, + cnt, + _context ) : new RequestStream ( - _stream, buff, _position, cnt, contentLength + _stream, + buff, + _position, + cnt, + contentLength ); disposeRequestBuffer (); From 5a46e573d1e3ddc64de307620b4997bcd5560cba Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 30 Nov 2023 21:20:41 +0900 Subject: [PATCH 5390/6294] [Modify] Polish it --- websocket-sharp/Net/HttpConnection.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpConnection.cs b/websocket-sharp/Net/HttpConnection.cs index ce9fb4eff..18103196c 100644 --- a/websocket-sharp/Net/HttpConnection.cs +++ b/websocket-sharp/Net/HttpConnection.cs @@ -451,7 +451,10 @@ private bool processRequestBuffer () } private string readLineFrom ( - byte[] buffer, int offset, int length, out int nread + byte[] buffer, + int offset, + int length, + out int nread ) { nread = 0; From 473eb2775de89cc13c7961355aae2528ece3c886 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 1 Dec 2023 21:39:30 +0900 Subject: [PATCH 5391/6294] [Modify] 2023 --- websocket-sharp/Net/HttpConnection.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpConnection.cs b/websocket-sharp/Net/HttpConnection.cs index 18103196c..1f8a497ad 100644 --- a/websocket-sharp/Net/HttpConnection.cs +++ b/websocket-sharp/Net/HttpConnection.cs @@ -8,7 +8,7 @@ * The MIT License * * Copyright (c) 2005 Novell, Inc. (http://www.novell.com) - * Copyright (c) 2012-2022 sta.blockhead + * Copyright (c) 2012-2023 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From 46dd4e5934249208a80bbc710d2912d17e27b3e2 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 2 Dec 2023 21:55:21 +0900 Subject: [PATCH 5392/6294] [Modify] Polish it --- websocket-sharp/Net/ChunkedRequestStream.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/ChunkedRequestStream.cs b/websocket-sharp/Net/ChunkedRequestStream.cs index d88c47b18..e2eb0d5f7 100644 --- a/websocket-sharp/Net/ChunkedRequestStream.cs +++ b/websocket-sharp/Net/ChunkedRequestStream.cs @@ -153,7 +153,11 @@ private void onRead (IAsyncResult asyncResult) #region Public Methods public override IAsyncResult BeginRead ( - byte[] buffer, int offset, int count, AsyncCallback callback, object state + byte[] buffer, + int offset, + int count, + AsyncCallback callback, + object state ) { if (_disposed) { From eb481c52a87348f408f39d33c4c9dd27eefaab8a Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 3 Dec 2023 21:51:43 +0900 Subject: [PATCH 5393/6294] [Modify] Replace it --- websocket-sharp/Net/ChunkedRequestStream.cs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Net/ChunkedRequestStream.cs b/websocket-sharp/Net/ChunkedRequestStream.cs index e2eb0d5f7..797855325 100644 --- a/websocket-sharp/Net/ChunkedRequestStream.cs +++ b/websocket-sharp/Net/ChunkedRequestStream.cs @@ -160,11 +160,8 @@ public override IAsyncResult BeginRead ( object state ) { - if (_disposed) { - var name = GetType ().ToString (); - - throw new ObjectDisposedException (name); - } + if (_disposed) + throw new ObjectDisposedException (ObjectName); if (buffer == null) throw new ArgumentNullException ("buffer"); From 24bfea51b74578a34ce8bfb22b8532028d991354 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 3 Dec 2023 21:55:04 +0900 Subject: [PATCH 5394/6294] [Modify] Polish it --- websocket-sharp/Net/ChunkedRequestStream.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/ChunkedRequestStream.cs b/websocket-sharp/Net/ChunkedRequestStream.cs index 797855325..9141091d5 100644 --- a/websocket-sharp/Net/ChunkedRequestStream.cs +++ b/websocket-sharp/Net/ChunkedRequestStream.cs @@ -181,7 +181,7 @@ object state var len = buffer.Length; if (offset + count > len) { - var msg = "The sum of 'offset' and 'count' is greater than the length of 'buffer'."; + var msg = "The sum of offset and count is greater than the length of buffer."; throw new ArgumentException (msg); } From 60f71e0663915e9eecf1348165e1767b8b99c1f0 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 4 Dec 2023 21:22:11 +0900 Subject: [PATCH 5395/6294] [Modify] Polish it --- websocket-sharp/Net/ChunkedRequestStream.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Net/ChunkedRequestStream.cs b/websocket-sharp/Net/ChunkedRequestStream.cs index 9141091d5..8e3186ab4 100644 --- a/websocket-sharp/Net/ChunkedRequestStream.cs +++ b/websocket-sharp/Net/ChunkedRequestStream.cs @@ -201,6 +201,7 @@ object state if (count == 0) { ares.Count = nread; + ares.Complete (); return ares; From 216b00e393a4d503010e47af55408b6feb7a0ce8 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 4 Dec 2023 21:23:19 +0900 Subject: [PATCH 5396/6294] [Modify] Polish it --- websocket-sharp/Net/ChunkedRequestStream.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Net/ChunkedRequestStream.cs b/websocket-sharp/Net/ChunkedRequestStream.cs index 8e3186ab4..cbf1d8165 100644 --- a/websocket-sharp/Net/ChunkedRequestStream.cs +++ b/websocket-sharp/Net/ChunkedRequestStream.cs @@ -211,6 +211,7 @@ object state _noMoreData = nread == 0; ares.Count = nread; + ares.Complete (); return ares; From 693f9f69e6ae7cd7c7a398b07f814f5ea79b3077 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 5 Dec 2023 21:17:26 +0900 Subject: [PATCH 5397/6294] [Modify] Replace it --- websocket-sharp/Net/ChunkedRequestStream.cs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Net/ChunkedRequestStream.cs b/websocket-sharp/Net/ChunkedRequestStream.cs index cbf1d8165..eb5af7eb1 100644 --- a/websocket-sharp/Net/ChunkedRequestStream.cs +++ b/websocket-sharp/Net/ChunkedRequestStream.cs @@ -241,11 +241,8 @@ public override void Close () public override int EndRead (IAsyncResult asyncResult) { - if (_disposed) { - var name = GetType ().ToString (); - - throw new ObjectDisposedException (name); - } + if (_disposed) + throw new ObjectDisposedException (ObjectName); if (asyncResult == null) throw new ArgumentNullException ("asyncResult"); From a93e40f81d6819ac7df7beda207bc79c1d412c11 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 6 Dec 2023 20:59:55 +0900 Subject: [PATCH 5398/6294] [Modify] Polish it --- websocket-sharp/Net/ChunkedRequestStream.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Net/ChunkedRequestStream.cs b/websocket-sharp/Net/ChunkedRequestStream.cs index eb5af7eb1..d838fbb6f 100644 --- a/websocket-sharp/Net/ChunkedRequestStream.cs +++ b/websocket-sharp/Net/ChunkedRequestStream.cs @@ -222,6 +222,7 @@ object state ares.Count = _bufferLength; var rstate = new ReadBufferState (buffer, offset, count, ares); + rstate.InitialCount += nread; base.BeginRead (ares.Buffer, ares.Offset, ares.Count, onRead, rstate); From 78bea959286bc91cb4def2656038fd4641546515 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 6 Dec 2023 21:02:02 +0900 Subject: [PATCH 5399/6294] [Modify] Polish it --- websocket-sharp/Net/ChunkedRequestStream.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Net/ChunkedRequestStream.cs b/websocket-sharp/Net/ChunkedRequestStream.cs index d838fbb6f..98df64d8e 100644 --- a/websocket-sharp/Net/ChunkedRequestStream.cs +++ b/websocket-sharp/Net/ChunkedRequestStream.cs @@ -124,6 +124,7 @@ private void onRead (IAsyncResult asyncResult) var nread = base.EndRead (asyncResult); _decoder.Write (ares.Buffer, ares.Offset, nread); + nread = _decoder.Read (rstate.Buffer, rstate.Offset, rstate.Count); rstate.Offset += nread; From a984db6c50f334ad7ed05478b5f27d601e3529dc Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 7 Dec 2023 21:39:22 +0900 Subject: [PATCH 5400/6294] [Modify] Polish it --- websocket-sharp/Net/ChunkedRequestStream.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Net/ChunkedRequestStream.cs b/websocket-sharp/Net/ChunkedRequestStream.cs index 98df64d8e..7d8913525 100644 --- a/websocket-sharp/Net/ChunkedRequestStream.cs +++ b/websocket-sharp/Net/ChunkedRequestStream.cs @@ -134,6 +134,7 @@ private void onRead (IAsyncResult asyncResult) _noMoreData = !_decoder.WantsMore && nread == 0; ares.Count = rstate.InitialCount - rstate.Count; + ares.Complete (); return; From ca2ec449a57fa62535374e22733d42104eff261d Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 7 Dec 2023 21:40:38 +0900 Subject: [PATCH 5401/6294] [Modify] Polish it --- websocket-sharp/Net/ChunkedRequestStream.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Net/ChunkedRequestStream.cs b/websocket-sharp/Net/ChunkedRequestStream.cs index 7d8913525..4c6435a23 100644 --- a/websocket-sharp/Net/ChunkedRequestStream.cs +++ b/websocket-sharp/Net/ChunkedRequestStream.cs @@ -144,6 +144,7 @@ private void onRead (IAsyncResult asyncResult) } catch (Exception ex) { _context.ErrorMessage = "I/O operation aborted"; + _context.SendError (); ares.Complete (ex); From cc1f07d2286c87257f4a0f5ea7650d392a041c9e Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 8 Dec 2023 21:24:47 +0900 Subject: [PATCH 5402/6294] [Modify] 2023 --- websocket-sharp/Net/ChunkedRequestStream.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/ChunkedRequestStream.cs b/websocket-sharp/Net/ChunkedRequestStream.cs index 4c6435a23..f4a583925 100644 --- a/websocket-sharp/Net/ChunkedRequestStream.cs +++ b/websocket-sharp/Net/ChunkedRequestStream.cs @@ -8,7 +8,7 @@ * The MIT License * * Copyright (c) 2005 Novell, Inc. (http://www.novell.com) - * Copyright (c) 2012-2022 sta.blockhead + * Copyright (c) 2012-2023 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From 7a4d6d9a0266495eb2e39c3919e616aac1043cba Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 9 Dec 2023 21:32:53 +0900 Subject: [PATCH 5403/6294] [Modify] Polish it --- websocket-sharp/Net/ReadBufferState.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/ReadBufferState.cs b/websocket-sharp/Net/ReadBufferState.cs index 1d8280f00..212f1c1d4 100644 --- a/websocket-sharp/Net/ReadBufferState.cs +++ b/websocket-sharp/Net/ReadBufferState.cs @@ -56,7 +56,10 @@ internal class ReadBufferState #region Public Constructors public ReadBufferState ( - byte[] buffer, int offset, int count, HttpStreamAsyncResult asyncResult + byte[] buffer, + int offset, + int count, + HttpStreamAsyncResult asyncResult ) { _buffer = buffer; From 33071fc058347f0b0b56b4ebe79a49fa9a88b428 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 10 Dec 2023 22:08:00 +0900 Subject: [PATCH 5404/6294] [Modify] 2023 --- websocket-sharp/Net/ReadBufferState.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/ReadBufferState.cs b/websocket-sharp/Net/ReadBufferState.cs index 212f1c1d4..bf0de8848 100644 --- a/websocket-sharp/Net/ReadBufferState.cs +++ b/websocket-sharp/Net/ReadBufferState.cs @@ -8,7 +8,7 @@ * The MIT License * * Copyright (c) 2005 Novell, Inc. (http://www.novell.com) - * Copyright (c) 2014-2021 sta.blockhead + * Copyright (c) 2014-2023 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From 01f41565ed1789bc99730021b3e546ddcaa6e09b Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 11 Dec 2023 21:13:38 +0900 Subject: [PATCH 5405/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerException.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerException.cs b/websocket-sharp/Net/HttpListenerException.cs index 64b7c1d82..406a71d38 100644 --- a/websocket-sharp/Net/HttpListenerException.cs +++ b/websocket-sharp/Net/HttpListenerException.cs @@ -66,7 +66,8 @@ public class HttpListenerException : Win32Exception /// the deserialization. /// protected HttpListenerException ( - SerializationInfo serializationInfo, StreamingContext streamingContext + SerializationInfo serializationInfo, + StreamingContext streamingContext ) : base (serializationInfo, streamingContext) { From 0aee7b66ba44ac935fc0412313c0406aab3c78f2 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 12 Dec 2023 22:09:10 +0900 Subject: [PATCH 5406/6294] [Modify] 2023 --- websocket-sharp/Net/HttpListenerException.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerException.cs b/websocket-sharp/Net/HttpListenerException.cs index 406a71d38..9b7f3011d 100644 --- a/websocket-sharp/Net/HttpListenerException.cs +++ b/websocket-sharp/Net/HttpListenerException.cs @@ -8,7 +8,7 @@ * The MIT License * * Copyright (c) 2005 Novell, Inc. (http://www.novell.com) - * Copyright (c) 2012-2021 sta.blockhead + * Copyright (c) 2012-2023 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From ec95290e88b2445a952849082b103684fe2bd943 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 13 Dec 2023 21:25:50 +0900 Subject: [PATCH 5407/6294] [Modify] Polish it --- websocket-sharp/Net/ChunkStream.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/ChunkStream.cs b/websocket-sharp/Net/ChunkStream.cs index bcd87f9bf..ea4134e05 100644 --- a/websocket-sharp/Net/ChunkStream.cs +++ b/websocket-sharp/Net/ChunkStream.cs @@ -163,7 +163,9 @@ private InputChunkState seekCrLf (byte[] buffer, ref int offset, int length) } private InputChunkState setChunkSize ( - byte[] buffer, ref int offset, int length + byte[] buffer, + ref int offset, + int length ) { byte b = 0; From 5987f584fa602bece8a1a4b682b916de4a9a7460 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 14 Dec 2023 21:32:56 +0900 Subject: [PATCH 5408/6294] [Modify] Polish it --- websocket-sharp/Net/ChunkStream.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/ChunkStream.cs b/websocket-sharp/Net/ChunkStream.cs index ea4134e05..f1d064b9f 100644 --- a/websocket-sharp/Net/ChunkStream.cs +++ b/websocket-sharp/Net/ChunkStream.cs @@ -228,7 +228,9 @@ int length } private InputChunkState setTrailer ( - byte[] buffer, ref int offset, int length + byte[] buffer, + ref int offset, + int length ) { while (offset < length) { From e1174443b60b5f4549305229222f1a8a463a21ba Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 15 Dec 2023 21:44:31 +0900 Subject: [PATCH 5409/6294] [Modify] Polish it --- websocket-sharp/Net/ChunkStream.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/ChunkStream.cs b/websocket-sharp/Net/ChunkStream.cs index f1d064b9f..f55e63352 100644 --- a/websocket-sharp/Net/ChunkStream.cs +++ b/websocket-sharp/Net/ChunkStream.cs @@ -293,7 +293,10 @@ int length private static void throwProtocolViolation (string message) { throw new WebException ( - message, null, WebExceptionStatus.ServerProtocolViolation, null + message, + null, + WebExceptionStatus.ServerProtocolViolation, + null ); } From a54a8ba4dcf442a7e7d6545dcbe3ec40d8304dc1 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 15 Dec 2023 21:45:57 +0900 Subject: [PATCH 5410/6294] [Modify] Polish it --- websocket-sharp/Net/ChunkStream.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/ChunkStream.cs b/websocket-sharp/Net/ChunkStream.cs index f55e63352..4868e2dd9 100644 --- a/websocket-sharp/Net/ChunkStream.cs +++ b/websocket-sharp/Net/ChunkStream.cs @@ -365,7 +365,9 @@ private void write (byte[] buffer, int offset, int length) } private InputChunkState writeData ( - byte[] buffer, ref int offset, int length + byte[] buffer, + ref int offset, + int length ) { var cnt = length - offset; From e4f48ee057a55758fe8737a7823cc9c68fc2f256 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 16 Dec 2023 21:51:24 +0900 Subject: [PATCH 5411/6294] [Modify] Polish it --- websocket-sharp/Net/ChunkStream.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Net/ChunkStream.cs b/websocket-sharp/Net/ChunkStream.cs index 4868e2dd9..3088a4ce5 100644 --- a/websocket-sharp/Net/ChunkStream.cs +++ b/websocket-sharp/Net/ChunkStream.cs @@ -377,6 +377,7 @@ int length cnt = left; var data = new byte[cnt]; + Buffer.BlockCopy (buffer, offset, data, 0, cnt); var chunk = new Chunk (data); From c7c6bf25b882505d8f3d0990a94c2cef7bb78d9e Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 16 Dec 2023 22:00:24 +0900 Subject: [PATCH 5412/6294] [Modify] Polish it --- websocket-sharp/Net/ChunkStream.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Net/ChunkStream.cs b/websocket-sharp/Net/ChunkStream.cs index 3088a4ce5..ad254a0b5 100644 --- a/websocket-sharp/Net/ChunkStream.cs +++ b/websocket-sharp/Net/ChunkStream.cs @@ -381,6 +381,7 @@ int length Buffer.BlockCopy (buffer, offset, data, 0, cnt); var chunk = new Chunk (data); + _chunks.Add (chunk); offset += cnt; From 5e6f1bd0de546f875ae0fffd6da261d274a236d7 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 17 Dec 2023 22:15:22 +0900 Subject: [PATCH 5413/6294] [Modify] 2023 --- websocket-sharp/Net/ChunkStream.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/ChunkStream.cs b/websocket-sharp/Net/ChunkStream.cs index ad254a0b5..3de4374db 100644 --- a/websocket-sharp/Net/ChunkStream.cs +++ b/websocket-sharp/Net/ChunkStream.cs @@ -8,7 +8,7 @@ * The MIT License * * Copyright (c) 2003 Ximian, Inc (http://www.ximian.com) - * Copyright (c) 2012-2022 sta.blockhead + * Copyright (c) 2012-2023 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From 9ef322ad380c6d8b21b4afddee6ef9efa0cbb076 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 18 Dec 2023 23:01:49 +0900 Subject: [PATCH 5414/6294] [Modify] Polish it --- websocket-sharp/Net/HttpDigestIdentity.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpDigestIdentity.cs b/websocket-sharp/Net/HttpDigestIdentity.cs index de1878e25..4c0c886a6 100644 --- a/websocket-sharp/Net/HttpDigestIdentity.cs +++ b/websocket-sharp/Net/HttpDigestIdentity.cs @@ -169,7 +169,10 @@ public string Uri { #region Internal Methods internal bool IsValid ( - string password, string realm, string method, string entity + string password, + string realm, + string method, + string entity ) { var parameters = new NameValueCollection (_parameters); From c1b49134d48dd96e8c71a4469511081ff981d4de Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 19 Dec 2023 22:05:58 +0900 Subject: [PATCH 5415/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerPrefix.cs | 9 --------- 1 file changed, 9 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerPrefix.cs b/websocket-sharp/Net/HttpListenerPrefix.cs index 3c9b0f8ae..33f090038 100644 --- a/websocket-sharp/Net/HttpListenerPrefix.cs +++ b/websocket-sharp/Net/HttpListenerPrefix.cs @@ -249,15 +249,6 @@ public override bool Equals (object obj) return pref != null && _prefix.Equals (pref._prefix); } - /// - /// Gets the hash code for the current instance. - /// - /// - /// This method will be required to detect duplicates in any collection. - /// - /// - /// An that represents the hash code. - /// public override int GetHashCode () { return _prefix.GetHashCode (); From bcad94e8064405f4cad365657eb09c9ba3f2fd1d Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 20 Dec 2023 21:33:06 +0900 Subject: [PATCH 5416/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerPrefix.cs | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerPrefix.cs b/websocket-sharp/Net/HttpListenerPrefix.cs index 33f090038..cabc4aec7 100644 --- a/websocket-sharp/Net/HttpListenerPrefix.cs +++ b/websocket-sharp/Net/HttpListenerPrefix.cs @@ -223,25 +223,6 @@ public static void CheckPrefix (string uriPrefix) } } - /// - /// Determines whether the current instance is equal to the specified - /// instance. - /// - /// - /// This method will be required to detect duplicates in any collection. - /// - /// - /// - /// An instance to compare to the current instance. - /// - /// - /// An reference to a instance. - /// - /// - /// - /// true if the current instance and have - /// the same URI prefix; otherwise, false. - /// public override bool Equals (object obj) { var pref = obj as HttpListenerPrefix; From 28291e8dda7d5dc3a1af598bc1332704d06abb5d Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 21 Dec 2023 21:37:19 +0900 Subject: [PATCH 5417/6294] [Modify] Use Ordinal --- websocket-sharp/Net/HttpListenerPrefix.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerPrefix.cs b/websocket-sharp/Net/HttpListenerPrefix.cs index cabc4aec7..a6b9a382b 100644 --- a/websocket-sharp/Net/HttpListenerPrefix.cs +++ b/websocket-sharp/Net/HttpListenerPrefix.cs @@ -125,7 +125,7 @@ public string Port { private void parse (string uriPrefix) { - if (uriPrefix.StartsWith ("https")) + if (uriPrefix.StartsWith ("https", StringComparison.Ordinal)) _secure = true; var len = uriPrefix.Length; From 663f1f968f35d4a72be68e1cd4ea8ebc38ec4f73 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 22 Dec 2023 21:50:33 +0900 Subject: [PATCH 5418/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerPrefix.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerPrefix.cs b/websocket-sharp/Net/HttpListenerPrefix.cs index a6b9a382b..bc60aabe4 100644 --- a/websocket-sharp/Net/HttpListenerPrefix.cs +++ b/websocket-sharp/Net/HttpListenerPrefix.cs @@ -125,7 +125,10 @@ public string Port { private void parse (string uriPrefix) { - if (uriPrefix.StartsWith ("https", StringComparison.Ordinal)) + var compType = StringComparison.Ordinal; + var secure = uriPrefix.StartsWith ("https", compType); + + if (secure) _secure = true; var len = uriPrefix.Length; From 209918b16ba2e8be8ad9a41eed5325253c465456 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 23 Dec 2023 22:39:34 +0900 Subject: [PATCH 5419/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerPrefix.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerPrefix.cs b/websocket-sharp/Net/HttpListenerPrefix.cs index bc60aabe4..84366e1cd 100644 --- a/websocket-sharp/Net/HttpListenerPrefix.cs +++ b/websocket-sharp/Net/HttpListenerPrefix.cs @@ -126,10 +126,8 @@ public string Port { private void parse (string uriPrefix) { var compType = StringComparison.Ordinal; - var secure = uriPrefix.StartsWith ("https", compType); - if (secure) - _secure = true; + _secure = uriPrefix.StartsWith ("https", compType); var len = uriPrefix.Length; var host = uriPrefix.IndexOf (':') + 3; From 013952575c1db340339dd13eace44d09a57b4460 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 24 Dec 2023 22:19:48 +0900 Subject: [PATCH 5420/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerPrefix.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerPrefix.cs b/websocket-sharp/Net/HttpListenerPrefix.cs index 84366e1cd..f0d91f5c7 100644 --- a/websocket-sharp/Net/HttpListenerPrefix.cs +++ b/websocket-sharp/Net/HttpListenerPrefix.cs @@ -132,7 +132,6 @@ private void parse (string uriPrefix) var len = uriPrefix.Length; var host = uriPrefix.IndexOf (':') + 3; var root = uriPrefix.IndexOf ('/', host + 1, len - host - 1); - var colon = uriPrefix.LastIndexOf (':', root - 1, root - host - 1); if (uriPrefix[root - 1] != ']' && colon > host) { From fc08b3dea13e097313bf2cce09c6b61bf949326d Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 25 Dec 2023 22:05:22 +0900 Subject: [PATCH 5421/6294] [Modify] Replace it --- websocket-sharp/Net/HttpListenerPrefix.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerPrefix.cs b/websocket-sharp/Net/HttpListenerPrefix.cs index f0d91f5c7..35c221f51 100644 --- a/websocket-sharp/Net/HttpListenerPrefix.cs +++ b/websocket-sharp/Net/HttpListenerPrefix.cs @@ -134,7 +134,9 @@ private void parse (string uriPrefix) var root = uriPrefix.IndexOf ('/', host + 1, len - host - 1); var colon = uriPrefix.LastIndexOf (':', root - 1, root - host - 1); - if (uriPrefix[root - 1] != ']' && colon > host) { + var hasPort = uriPrefix[root - 1] != ']' && colon > host; + + if (hasPort) { _host = uriPrefix.Substring (host, colon - host); _port = uriPrefix.Substring (colon + 1, root - colon - 1); } From ab0fd1dd10040bda297186ecd4d07b48b69182eb Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 26 Dec 2023 22:00:33 +0900 Subject: [PATCH 5422/6294] [Modify] Use Ordinal --- websocket-sharp/Net/HttpListenerPrefix.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerPrefix.cs b/websocket-sharp/Net/HttpListenerPrefix.cs index 35c221f51..4d5ee5577 100644 --- a/websocket-sharp/Net/HttpListenerPrefix.cs +++ b/websocket-sharp/Net/HttpListenerPrefix.cs @@ -173,8 +173,9 @@ public static void CheckPrefix (string uriPrefix) throw new ArgumentException (msg, "uriPrefix"); } - var schm = uriPrefix.StartsWith ("http://") - || uriPrefix.StartsWith ("https://"); + var compType = StringComparison.Ordinal; + var schm = uriPrefix.StartsWith ("http://", compType) + || uriPrefix.StartsWith ("https://", compType); if (!schm) { var msg = "The scheme is not 'http' or 'https'."; From 509f18c8947de118b96c837bccccb28ff35ad1b1 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 27 Dec 2023 21:40:26 +0900 Subject: [PATCH 5423/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerPrefix.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerPrefix.cs b/websocket-sharp/Net/HttpListenerPrefix.cs index 4d5ee5577..8feff347b 100644 --- a/websocket-sharp/Net/HttpListenerPrefix.cs +++ b/websocket-sharp/Net/HttpListenerPrefix.cs @@ -178,7 +178,7 @@ public static void CheckPrefix (string uriPrefix) || uriPrefix.StartsWith ("https://", compType); if (!schm) { - var msg = "The scheme is not 'http' or 'https'."; + var msg = "The scheme is not http or https."; throw new ArgumentException (msg, "uriPrefix"); } From e96758ad0d74528c0f7da2b2beb862d0f304b5b2 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 28 Dec 2023 21:54:59 +0900 Subject: [PATCH 5424/6294] [Modify] Replace it --- websocket-sharp/Net/HttpListenerPrefix.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerPrefix.cs b/websocket-sharp/Net/HttpListenerPrefix.cs index 8feff347b..f75b2843d 100644 --- a/websocket-sharp/Net/HttpListenerPrefix.cs +++ b/websocket-sharp/Net/HttpListenerPrefix.cs @@ -174,10 +174,10 @@ public static void CheckPrefix (string uriPrefix) } var compType = StringComparison.Ordinal; - var schm = uriPrefix.StartsWith ("http://", compType) - || uriPrefix.StartsWith ("https://", compType); + var isHttpSchm = uriPrefix.StartsWith ("http://", compType) + || uriPrefix.StartsWith ("https://", compType); - if (!schm) { + if (!isHttpSchm) { var msg = "The scheme is not http or https."; throw new ArgumentException (msg, "uriPrefix"); From 01f9e98e9e062776f210490d3726d8573980c41d Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 29 Dec 2023 21:45:19 +0900 Subject: [PATCH 5425/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerPrefix.cs | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerPrefix.cs b/websocket-sharp/Net/HttpListenerPrefix.cs index f75b2843d..2f6ebc41d 100644 --- a/websocket-sharp/Net/HttpListenerPrefix.cs +++ b/websocket-sharp/Net/HttpListenerPrefix.cs @@ -58,19 +58,6 @@ internal sealed class HttpListenerPrefix #region Internal Constructors - /// - /// Initializes a new instance of the class - /// with the specified URI prefix and HTTP listener. - /// - /// - /// This constructor must be called after calling the CheckPrefix method. - /// - /// - /// A that specifies the URI prefix. - /// - /// - /// A that specifies the HTTP listener. - /// internal HttpListenerPrefix (string uriPrefix, HttpListener listener) { _original = uriPrefix; From ad7634f3e09e67ac7c02d5b058698653f176de3f Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 30 Dec 2023 22:14:46 +0900 Subject: [PATCH 5426/6294] [Modify] Rename it --- websocket-sharp/Net/HttpListenerPrefix.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerPrefix.cs b/websocket-sharp/Net/HttpListenerPrefix.cs index 2f6ebc41d..59fcfb4d0 100644 --- a/websocket-sharp/Net/HttpListenerPrefix.cs +++ b/websocket-sharp/Net/HttpListenerPrefix.cs @@ -52,7 +52,7 @@ internal sealed class HttpListenerPrefix private string _path; private string _port; private string _prefix; - private bool _secure; + private bool _isSecure; #endregion @@ -78,7 +78,7 @@ public string Host { public bool IsSecure { get { - return _secure; + return _isSecure; } } @@ -114,7 +114,7 @@ private void parse (string uriPrefix) { var compType = StringComparison.Ordinal; - _secure = uriPrefix.StartsWith ("https", compType); + _isSecure = uriPrefix.StartsWith ("https", compType); var len = uriPrefix.Length; var host = uriPrefix.IndexOf (':') + 3; @@ -129,14 +129,14 @@ private void parse (string uriPrefix) } else { _host = uriPrefix.Substring (host, root - host); - _port = _secure ? "443" : "80"; + _port = _isSecure ? "443" : "80"; } _path = uriPrefix.Substring (root); _prefix = String.Format ( "{0}://{1}:{2}{3}", - _secure ? "https" : "http", + _isSecure ? "https" : "http", _host, _port, _path From 1373d1c48c6c62f1169e4a278ff13de3e3f94e08 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 31 Dec 2023 21:45:40 +0900 Subject: [PATCH 5427/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerPrefix.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerPrefix.cs b/websocket-sharp/Net/HttpListenerPrefix.cs index 59fcfb4d0..06b568fb2 100644 --- a/websocket-sharp/Net/HttpListenerPrefix.cs +++ b/websocket-sharp/Net/HttpListenerPrefix.cs @@ -47,12 +47,12 @@ internal sealed class HttpListenerPrefix #region Private Fields private string _host; + private bool _isSecure; private HttpListener _listener; private string _original; private string _path; private string _port; private string _prefix; - private bool _isSecure; #endregion From 88193ff3e32bfa09d2ed1f1f3fc8591ecc1d084e Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 1 Jan 2024 21:44:09 +0900 Subject: [PATCH 5428/6294] [Modify] 2024 --- LICENSE.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LICENSE.txt b/LICENSE.txt index fb0529710..6903008b3 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2010-2023 sta.blockhead +Copyright (c) 2010-2024 sta.blockhead Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal From eacf66fa03b467a42de7f578397112134f6d52d5 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 2 Jan 2024 22:11:03 +0900 Subject: [PATCH 5429/6294] [Modify] Rename it --- websocket-sharp/Net/HttpListenerPrefix.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerPrefix.cs b/websocket-sharp/Net/HttpListenerPrefix.cs index 06b568fb2..9f6669aa6 100644 --- a/websocket-sharp/Net/HttpListenerPrefix.cs +++ b/websocket-sharp/Net/HttpListenerPrefix.cs @@ -117,18 +117,18 @@ private void parse (string uriPrefix) _isSecure = uriPrefix.StartsWith ("https", compType); var len = uriPrefix.Length; - var host = uriPrefix.IndexOf (':') + 3; - var root = uriPrefix.IndexOf ('/', host + 1, len - host - 1); - var colon = uriPrefix.LastIndexOf (':', root - 1, root - host - 1); + var hostStartIdx = uriPrefix.IndexOf (':') + 3; + var root = uriPrefix.IndexOf ('/', hostStartIdx + 1, len - hostStartIdx - 1); + var colon = uriPrefix.LastIndexOf (':', root - 1, root - hostStartIdx - 1); - var hasPort = uriPrefix[root - 1] != ']' && colon > host; + var hasPort = uriPrefix[root - 1] != ']' && colon > hostStartIdx; if (hasPort) { - _host = uriPrefix.Substring (host, colon - host); + _host = uriPrefix.Substring (hostStartIdx, colon - hostStartIdx); _port = uriPrefix.Substring (colon + 1, root - colon - 1); } else { - _host = uriPrefix.Substring (host, root - host); + _host = uriPrefix.Substring (hostStartIdx, root - hostStartIdx); _port = _isSecure ? "443" : "80"; } From f21991995edf1a9e16b611c5f7ed4d217744b081 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 3 Jan 2024 21:53:09 +0900 Subject: [PATCH 5430/6294] [Modify] Rename it --- websocket-sharp/Net/HttpListenerPrefix.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerPrefix.cs b/websocket-sharp/Net/HttpListenerPrefix.cs index 9f6669aa6..aa9afc34b 100644 --- a/websocket-sharp/Net/HttpListenerPrefix.cs +++ b/websocket-sharp/Net/HttpListenerPrefix.cs @@ -118,21 +118,21 @@ private void parse (string uriPrefix) var len = uriPrefix.Length; var hostStartIdx = uriPrefix.IndexOf (':') + 3; - var root = uriPrefix.IndexOf ('/', hostStartIdx + 1, len - hostStartIdx - 1); - var colon = uriPrefix.LastIndexOf (':', root - 1, root - hostStartIdx - 1); + var rootIdx = uriPrefix.IndexOf ('/', hostStartIdx + 1, len - hostStartIdx - 1); + var colon = uriPrefix.LastIndexOf (':', rootIdx - 1, rootIdx - hostStartIdx - 1); - var hasPort = uriPrefix[root - 1] != ']' && colon > hostStartIdx; + var hasPort = uriPrefix[rootIdx - 1] != ']' && colon > hostStartIdx; if (hasPort) { _host = uriPrefix.Substring (hostStartIdx, colon - hostStartIdx); - _port = uriPrefix.Substring (colon + 1, root - colon - 1); + _port = uriPrefix.Substring (colon + 1, rootIdx - colon - 1); } else { - _host = uriPrefix.Substring (hostStartIdx, root - hostStartIdx); + _host = uriPrefix.Substring (hostStartIdx, rootIdx - hostStartIdx); _port = _isSecure ? "443" : "80"; } - _path = uriPrefix.Substring (root); + _path = uriPrefix.Substring (rootIdx); _prefix = String.Format ( "{0}://{1}:{2}{3}", From 5927dab0d19597f1fc1cba68013a01cc1dc17e7b Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 4 Jan 2024 21:56:33 +0900 Subject: [PATCH 5431/6294] [Modify] Rename it --- websocket-sharp/Net/HttpListenerPrefix.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerPrefix.cs b/websocket-sharp/Net/HttpListenerPrefix.cs index aa9afc34b..061d234c2 100644 --- a/websocket-sharp/Net/HttpListenerPrefix.cs +++ b/websocket-sharp/Net/HttpListenerPrefix.cs @@ -119,13 +119,13 @@ private void parse (string uriPrefix) var len = uriPrefix.Length; var hostStartIdx = uriPrefix.IndexOf (':') + 3; var rootIdx = uriPrefix.IndexOf ('/', hostStartIdx + 1, len - hostStartIdx - 1); - var colon = uriPrefix.LastIndexOf (':', rootIdx - 1, rootIdx - hostStartIdx - 1); + var colonIdx = uriPrefix.LastIndexOf (':', rootIdx - 1, rootIdx - hostStartIdx - 1); - var hasPort = uriPrefix[rootIdx - 1] != ']' && colon > hostStartIdx; + var hasPort = uriPrefix[rootIdx - 1] != ']' && colonIdx > hostStartIdx; if (hasPort) { - _host = uriPrefix.Substring (hostStartIdx, colon - hostStartIdx); - _port = uriPrefix.Substring (colon + 1, rootIdx - colon - 1); + _host = uriPrefix.Substring (hostStartIdx, colonIdx - hostStartIdx); + _port = uriPrefix.Substring (colonIdx + 1, rootIdx - colonIdx - 1); } else { _host = uriPrefix.Substring (hostStartIdx, rootIdx - hostStartIdx); From 1f8dff586f4b3f3580d558db0fae37a885c94de8 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 5 Jan 2024 21:46:58 +0900 Subject: [PATCH 5432/6294] [Modify] Replace it --- websocket-sharp/Net/HttpListenerPrefix.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerPrefix.cs b/websocket-sharp/Net/HttpListenerPrefix.cs index 061d234c2..d8c1901b6 100644 --- a/websocket-sharp/Net/HttpListenerPrefix.cs +++ b/websocket-sharp/Net/HttpListenerPrefix.cs @@ -134,8 +134,10 @@ private void parse (string uriPrefix) _path = uriPrefix.Substring (rootIdx); + var fmt = "{0}://{1}:{2}{3}"; + _prefix = String.Format ( - "{0}://{1}:{2}{3}", + fmt, _isSecure ? "https" : "http", _host, _port, From ea8b757762a4641ae466e61fc1d4b8027b266f1b Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 6 Jan 2024 16:27:53 +0900 Subject: [PATCH 5433/6294] [Modify] Add it --- websocket-sharp/Net/HttpListenerPrefix.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerPrefix.cs b/websocket-sharp/Net/HttpListenerPrefix.cs index d8c1901b6..b8353b197 100644 --- a/websocket-sharp/Net/HttpListenerPrefix.cs +++ b/websocket-sharp/Net/HttpListenerPrefix.cs @@ -53,6 +53,7 @@ internal sealed class HttpListenerPrefix private string _path; private string _port; private string _prefix; + private string _scheme; #endregion @@ -106,6 +107,12 @@ public string Port { } } + public string Scheme { + get { + return _scheme; + } + } + #endregion #region Private Methods @@ -115,6 +122,7 @@ private void parse (string uriPrefix) var compType = StringComparison.Ordinal; _isSecure = uriPrefix.StartsWith ("https", compType); + _scheme = _isSecure ? "https" : "http"; var len = uriPrefix.Length; var hostStartIdx = uriPrefix.IndexOf (':') + 3; @@ -138,7 +146,7 @@ private void parse (string uriPrefix) _prefix = String.Format ( fmt, - _isSecure ? "https" : "http", + _scheme, _host, _port, _path From 40238d4454900d021801f51698923a44bf35c408 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 7 Jan 2024 21:54:44 +0900 Subject: [PATCH 5434/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerPrefix.cs | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerPrefix.cs b/websocket-sharp/Net/HttpListenerPrefix.cs index b8353b197..a1bc66618 100644 --- a/websocket-sharp/Net/HttpListenerPrefix.cs +++ b/websocket-sharp/Net/HttpListenerPrefix.cs @@ -144,13 +144,7 @@ private void parse (string uriPrefix) var fmt = "{0}://{1}:{2}{3}"; - _prefix = String.Format ( - fmt, - _scheme, - _host, - _port, - _path - ); + _prefix = String.Format (fmt, _scheme, _host, _port, _path); } #endregion From f3829fd15191033f1f37ff661308eb091e7a4931 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 8 Jan 2024 17:25:14 +0900 Subject: [PATCH 5435/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerPrefix.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerPrefix.cs b/websocket-sharp/Net/HttpListenerPrefix.cs index a1bc66618..55d27d97f 100644 --- a/websocket-sharp/Net/HttpListenerPrefix.cs +++ b/websocket-sharp/Net/HttpListenerPrefix.cs @@ -127,7 +127,8 @@ private void parse (string uriPrefix) var len = uriPrefix.Length; var hostStartIdx = uriPrefix.IndexOf (':') + 3; var rootIdx = uriPrefix.IndexOf ('/', hostStartIdx + 1, len - hostStartIdx - 1); - var colonIdx = uriPrefix.LastIndexOf (':', rootIdx - 1, rootIdx - hostStartIdx - 1); + var colonIdx = uriPrefix + .LastIndexOf (':', rootIdx - 1, rootIdx - hostStartIdx - 1); var hasPort = uriPrefix[rootIdx - 1] != ']' && colonIdx > hostStartIdx; From ab6339a4a634edfe0a8e73b358cc0c74700e7d2a Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 9 Jan 2024 21:45:38 +0900 Subject: [PATCH 5436/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerPrefix.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerPrefix.cs b/websocket-sharp/Net/HttpListenerPrefix.cs index 55d27d97f..0b410817b 100644 --- a/websocket-sharp/Net/HttpListenerPrefix.cs +++ b/websocket-sharp/Net/HttpListenerPrefix.cs @@ -126,7 +126,10 @@ private void parse (string uriPrefix) var len = uriPrefix.Length; var hostStartIdx = uriPrefix.IndexOf (':') + 3; - var rootIdx = uriPrefix.IndexOf ('/', hostStartIdx + 1, len - hostStartIdx - 1); + + var rootIdx = uriPrefix + .IndexOf ('/', hostStartIdx + 1, len - hostStartIdx - 1); + var colonIdx = uriPrefix .LastIndexOf (':', rootIdx - 1, rootIdx - hostStartIdx - 1); From 35e255ed8f8a4da06a258ba474ffe4137e4f68fb Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 10 Jan 2024 21:50:28 +0900 Subject: [PATCH 5437/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerPrefix.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerPrefix.cs b/websocket-sharp/Net/HttpListenerPrefix.cs index 0b410817b..4799d3bb6 100644 --- a/websocket-sharp/Net/HttpListenerPrefix.cs +++ b/websocket-sharp/Net/HttpListenerPrefix.cs @@ -124,9 +124,9 @@ private void parse (string uriPrefix) _isSecure = uriPrefix.StartsWith ("https", compType); _scheme = _isSecure ? "https" : "http"; - var len = uriPrefix.Length; var hostStartIdx = uriPrefix.IndexOf (':') + 3; + var len = uriPrefix.Length; var rootIdx = uriPrefix .IndexOf ('/', hostStartIdx + 1, len - hostStartIdx - 1); From 44abf60701e9be9f4edf0ccaef390d7c18a8fbd2 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 11 Jan 2024 21:48:59 +0900 Subject: [PATCH 5438/6294] [Modify] Rename it --- websocket-sharp/Net/HttpListenerPrefix.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerPrefix.cs b/websocket-sharp/Net/HttpListenerPrefix.cs index 4799d3bb6..2b24c1da6 100644 --- a/websocket-sharp/Net/HttpListenerPrefix.cs +++ b/websocket-sharp/Net/HttpListenerPrefix.cs @@ -186,23 +186,23 @@ public static void CheckPrefix (string uriPrefix) throw new ArgumentException (msg, "uriPrefix"); } - var host = uriPrefix.IndexOf (':') + 3; + var hostStartIdx = uriPrefix.IndexOf (':') + 3; - if (host >= end) { + if (hostStartIdx >= end) { var msg = "No host is specified."; throw new ArgumentException (msg, "uriPrefix"); } - if (uriPrefix[host] == ':') { + if (uriPrefix[hostStartIdx] == ':') { var msg = "No host is specified."; throw new ArgumentException (msg, "uriPrefix"); } - var root = uriPrefix.IndexOf ('/', host, len - host); + var root = uriPrefix.IndexOf ('/', hostStartIdx, len - hostStartIdx); - if (root == host) { + if (root == hostStartIdx) { var msg = "No host is specified."; throw new ArgumentException (msg, "uriPrefix"); From 2325401fb34ac41dbf0ea846a437a596ec9b015b Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 12 Jan 2024 22:04:28 +0900 Subject: [PATCH 5439/6294] [Modify] Rename it --- websocket-sharp/Net/HttpListenerPrefix.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerPrefix.cs b/websocket-sharp/Net/HttpListenerPrefix.cs index 2b24c1da6..993a6b5d8 100644 --- a/websocket-sharp/Net/HttpListenerPrefix.cs +++ b/websocket-sharp/Net/HttpListenerPrefix.cs @@ -200,21 +200,21 @@ public static void CheckPrefix (string uriPrefix) throw new ArgumentException (msg, "uriPrefix"); } - var root = uriPrefix.IndexOf ('/', hostStartIdx, len - hostStartIdx); + var rootIdx = uriPrefix.IndexOf ('/', hostStartIdx, len - hostStartIdx); - if (root == hostStartIdx) { + if (rootIdx == hostStartIdx) { var msg = "No host is specified."; throw new ArgumentException (msg, "uriPrefix"); } - if (uriPrefix[root - 1] == ':') { + if (uriPrefix[rootIdx - 1] == ':') { var msg = "No port is specified."; throw new ArgumentException (msg, "uriPrefix"); } - if (root == end - 1) { + if (rootIdx == end - 1) { var msg = "No path is specified."; throw new ArgumentException (msg, "uriPrefix"); From e9cccf5ea9a49c0ad1c3a889d5f83fcd0654ecb0 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 13 Jan 2024 21:50:39 +0900 Subject: [PATCH 5440/6294] [Modify] Rename it --- websocket-sharp/Net/HttpListenerPrefix.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerPrefix.cs b/websocket-sharp/Net/HttpListenerPrefix.cs index 993a6b5d8..9013f4663 100644 --- a/websocket-sharp/Net/HttpListenerPrefix.cs +++ b/websocket-sharp/Net/HttpListenerPrefix.cs @@ -178,9 +178,9 @@ public static void CheckPrefix (string uriPrefix) throw new ArgumentException (msg, "uriPrefix"); } - var end = len - 1; + var endIdx = len - 1; - if (uriPrefix[end] != '/') { + if (uriPrefix[endIdx] != '/') { var msg = "It ends without '/'."; throw new ArgumentException (msg, "uriPrefix"); @@ -188,7 +188,7 @@ public static void CheckPrefix (string uriPrefix) var hostStartIdx = uriPrefix.IndexOf (':') + 3; - if (hostStartIdx >= end) { + if (hostStartIdx >= endIdx) { var msg = "No host is specified."; throw new ArgumentException (msg, "uriPrefix"); @@ -214,7 +214,7 @@ public static void CheckPrefix (string uriPrefix) throw new ArgumentException (msg, "uriPrefix"); } - if (rootIdx == end - 1) { + if (rootIdx == endIdx - 1) { var msg = "No path is specified."; throw new ArgumentException (msg, "uriPrefix"); From dee0d565c96d7ead11219113bd4ad7c9f85e892c Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 14 Jan 2024 22:27:44 +0900 Subject: [PATCH 5441/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerPrefix.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerPrefix.cs b/websocket-sharp/Net/HttpListenerPrefix.cs index 9013f4663..132131ecf 100644 --- a/websocket-sharp/Net/HttpListenerPrefix.cs +++ b/websocket-sharp/Net/HttpListenerPrefix.cs @@ -181,7 +181,7 @@ public static void CheckPrefix (string uriPrefix) var endIdx = len - 1; if (uriPrefix[endIdx] != '/') { - var msg = "It ends without '/'."; + var msg = "It ends without /."; throw new ArgumentException (msg, "uriPrefix"); } From 68985938c96cdb9a06f64d3b9c752838b924fabc Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 15 Jan 2024 21:41:11 +0900 Subject: [PATCH 5442/6294] [Modify] 2024 --- websocket-sharp/Net/HttpListenerPrefix.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerPrefix.cs b/websocket-sharp/Net/HttpListenerPrefix.cs index 132131ecf..7461db8ee 100644 --- a/websocket-sharp/Net/HttpListenerPrefix.cs +++ b/websocket-sharp/Net/HttpListenerPrefix.cs @@ -8,7 +8,7 @@ * The MIT License * * Copyright (c) 2005 Novell, Inc. (http://www.novell.com) - * Copyright (c) 2012-2020 sta.blockhead + * Copyright (c) 2012-2024 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From bd81347b1c015d390f0bc1eae00ac55801ae2bec Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 16 Jan 2024 21:43:55 +0900 Subject: [PATCH 5443/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerPrefixCollection.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Net/HttpListenerPrefixCollection.cs b/websocket-sharp/Net/HttpListenerPrefixCollection.cs index cbe062ee1..fe663f2bd 100644 --- a/websocket-sharp/Net/HttpListenerPrefixCollection.cs +++ b/websocket-sharp/Net/HttpListenerPrefixCollection.cs @@ -65,6 +65,7 @@ public class HttpListenerPrefixCollection : ICollection internal HttpListenerPrefixCollection (HttpListener listener) { _listener = listener; + _prefixes = new List (); } From 996d443360aeb7cb944235091d5354c5089b26eb Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 17 Jan 2024 21:35:12 +0900 Subject: [PATCH 5444/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerPrefixCollection.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerPrefixCollection.cs b/websocket-sharp/Net/HttpListenerPrefixCollection.cs index fe663f2bd..b44a40ac6 100644 --- a/websocket-sharp/Net/HttpListenerPrefixCollection.cs +++ b/websocket-sharp/Net/HttpListenerPrefixCollection.cs @@ -48,8 +48,8 @@ namespace WebSocketSharp.Net /// the class. /// /// - /// The instance responds to the request which has - /// a requested URI that the prefixes most closely match. + /// The instance responds to the request which + /// has a requested URI that the prefixes most closely match. /// public class HttpListenerPrefixCollection : ICollection { From 3b4223ea8df0d54c25f8b3ac87b529988867aa67 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 18 Jan 2024 22:15:06 +0900 Subject: [PATCH 5445/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerPrefixCollection.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerPrefixCollection.cs b/websocket-sharp/Net/HttpListenerPrefixCollection.cs index b44a40ac6..6583baed2 100644 --- a/websocket-sharp/Net/HttpListenerPrefixCollection.cs +++ b/websocket-sharp/Net/HttpListenerPrefixCollection.cs @@ -124,7 +124,7 @@ public bool IsSynchronized { /// /// /// It must be a well-formed URI prefix with http or https scheme, - /// and must end with a '/'. + /// and must end with a forward slash (/). /// /// /// From 990dd1f8777da8833bf6c6926e63ad61861e255e Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 19 Jan 2024 22:02:13 +0900 Subject: [PATCH 5446/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerPrefix.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerPrefix.cs b/websocket-sharp/Net/HttpListenerPrefix.cs index 7461db8ee..aba9d1bfd 100644 --- a/websocket-sharp/Net/HttpListenerPrefix.cs +++ b/websocket-sharp/Net/HttpListenerPrefix.cs @@ -181,7 +181,7 @@ public static void CheckPrefix (string uriPrefix) var endIdx = len - 1; if (uriPrefix[endIdx] != '/') { - var msg = "It ends without /."; + var msg = "It ends without a forward slash."; throw new ArgumentException (msg, "uriPrefix"); } From 9d8361c8bc46806afb670eed6891c83ea9a36806 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 20 Jan 2024 22:03:26 +0900 Subject: [PATCH 5447/6294] [Modify] 2024 --- websocket-sharp/Net/HttpListenerPrefixCollection.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerPrefixCollection.cs b/websocket-sharp/Net/HttpListenerPrefixCollection.cs index 6583baed2..6d3d510fd 100644 --- a/websocket-sharp/Net/HttpListenerPrefixCollection.cs +++ b/websocket-sharp/Net/HttpListenerPrefixCollection.cs @@ -8,7 +8,7 @@ * The MIT License * * Copyright (c) 2005 Novell, Inc. (http://www.novell.com) - * Copyright (c) 2012-2020 sta.blockhead + * Copyright (c) 2012-2024 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From 8073a45ddeeb04b17349cc21dae5f4661e85f892 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 21 Jan 2024 22:08:55 +0900 Subject: [PATCH 5448/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerAsyncResult.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerAsyncResult.cs b/websocket-sharp/Net/HttpListenerAsyncResult.cs index abd9e1aea..bb0e2c87c 100644 --- a/websocket-sharp/Net/HttpListenerAsyncResult.cs +++ b/websocket-sharp/Net/HttpListenerAsyncResult.cs @@ -179,7 +179,8 @@ internal void Complete (Exception exception) } internal void Complete ( - HttpListenerContext context, bool completedSynchronously + HttpListenerContext context, + bool completedSynchronously ) { _context = context; From 997d99d35a7abbba14ca87356e94305e22165c3a Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 22 Jan 2024 21:48:16 +0900 Subject: [PATCH 5449/6294] [Modify] 2024 --- websocket-sharp/Net/HttpListenerAsyncResult.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerAsyncResult.cs b/websocket-sharp/Net/HttpListenerAsyncResult.cs index bb0e2c87c..a9a92bb7e 100644 --- a/websocket-sharp/Net/HttpListenerAsyncResult.cs +++ b/websocket-sharp/Net/HttpListenerAsyncResult.cs @@ -8,7 +8,7 @@ * The MIT License * * Copyright (c) 2005 Ximian, Inc. (http://www.ximian.com) - * Copyright (c) 2012-2021 sta.blockhead + * Copyright (c) 2012-2024 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From cfedb140af755dfde117c54174d3f92f57ebce79 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 23 Jan 2024 21:45:55 +0900 Subject: [PATCH 5450/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerContext.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerContext.cs b/websocket-sharp/Net/HttpListenerContext.cs index 21f345628..a5226fcf0 100644 --- a/websocket-sharp/Net/HttpListenerContext.cs +++ b/websocket-sharp/Net/HttpListenerContext.cs @@ -390,7 +390,8 @@ public HttpListenerWebSocketContext AcceptWebSocket (string protocol) /// /// public HttpListenerWebSocketContext AcceptWebSocket ( - string protocol, Action initializer + string protocol, + Action initializer ) { if (_websocketContext != null) { From 4af6e09f378d2334af0b2559e74fe1c4c250814d Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 24 Jan 2024 21:50:23 +0900 Subject: [PATCH 5451/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerContext.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerContext.cs b/websocket-sharp/Net/HttpListenerContext.cs index a5226fcf0..1a4469295 100644 --- a/websocket-sharp/Net/HttpListenerContext.cs +++ b/websocket-sharp/Net/HttpListenerContext.cs @@ -204,7 +204,8 @@ internal HttpListenerWebSocketContext GetWebSocketContext (string protocol) } internal void SendAuthenticationChallenge ( - AuthenticationSchemes scheme, string realm + AuthenticationSchemes scheme, + string realm ) { _response.StatusCode = 401; From a6c6396483528080b9a3cfe8b559bb72775fda40 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 25 Jan 2024 22:02:52 +0900 Subject: [PATCH 5452/6294] [Modify] Rename it --- websocket-sharp/Net/HttpListenerContext.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerContext.cs b/websocket-sharp/Net/HttpListenerContext.cs index 1a4469295..9aee40a41 100644 --- a/websocket-sharp/Net/HttpListenerContext.cs +++ b/websocket-sharp/Net/HttpListenerContext.cs @@ -210,8 +210,9 @@ string realm { _response.StatusCode = 401; - var chal = new AuthenticationChallenge (scheme, realm).ToString (); - _response.Headers.InternalSet ("WWW-Authenticate", chal, true); + var val = new AuthenticationChallenge (scheme, realm).ToString (); + + _response.Headers.InternalSet ("WWW-Authenticate", val, true); _response.Close (); } From a59b343c751156a51db21f672f4c1c82e2cc46a9 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 26 Jan 2024 22:07:31 +0900 Subject: [PATCH 5453/6294] [Modify] 2024 --- websocket-sharp/Net/HttpListenerContext.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerContext.cs b/websocket-sharp/Net/HttpListenerContext.cs index 9aee40a41..5b9f94b1b 100644 --- a/websocket-sharp/Net/HttpListenerContext.cs +++ b/websocket-sharp/Net/HttpListenerContext.cs @@ -8,7 +8,7 @@ * The MIT License * * Copyright (c) 2005 Novell, Inc. (http://www.novell.com) - * Copyright (c) 2012-2022 sta.blockhead + * Copyright (c) 2012-2024 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From 12bcf26db85f8f962dc7f8d955b5cc9d681354d3 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 27 Jan 2024 22:08:45 +0900 Subject: [PATCH 5454/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListener.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 37bc821d8..a551c1411 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -972,6 +972,7 @@ public void Stop () cleanupContextRegistry (); var msg = "The listener is stopped."; + cleanupWaitQueue (msg); EndPointManager.RemoveListener (this); From a98ec21ab2c8b2eea984f9f5f1f6d8a561d62ca5 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 28 Jan 2024 21:55:32 +0900 Subject: [PATCH 5455/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListener.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index a551c1411..cb37000c6 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -912,6 +912,7 @@ public HttpListenerContext GetContext () } var ares = beginGetContext (null, null); + ares.EndCalled = true; if (!ares.IsCompleted) From 0bf893923edc6e3f8ace38751dddde53418452fc Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 29 Jan 2024 21:52:10 +0900 Subject: [PATCH 5456/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListener.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index cb37000c6..12603a8b1 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -650,6 +650,7 @@ private bool registerContext (HttpListenerContext context) } var ares = _waitQueue.Dequeue (); + ares.Complete (context, false); return true; From 54a6d8f703cb20ec04d24365262034dc84b0ab73 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 30 Jan 2024 21:36:52 +0900 Subject: [PATCH 5457/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListener.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 12603a8b1..22a38b2d8 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -615,6 +615,7 @@ private void close (bool force) cleanupContextRegistry (); var msg = "The listener is closed."; + cleanupWaitQueue (msg); EndPointManager.RemoveListener (this); From f1d583de850db07ee14f9a7ce1245dfaed2a0079 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 31 Jan 2024 21:32:53 +0900 Subject: [PATCH 5458/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListener.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 22a38b2d8..9cf4d8e33 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -591,6 +591,7 @@ private void cleanupWaitQueue (string message) foreach (var ares in aress) { var ex = new HttpListenerException (995, message); + ares.Complete (ex); } } From 54e514454dd612e27b4c98b5917807b1fd844481 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 1 Feb 2024 21:46:15 +0900 Subject: [PATCH 5459/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListener.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 9cf4d8e33..e1308425c 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -518,7 +518,8 @@ private bool authenticateClient (HttpListenerContext context) } private HttpListenerAsyncResult beginGetContext ( - AsyncCallback callback, object state + AsyncCallback callback, + object state ) { lock (_contextRegistrySync) { From 6c010e5c19c3923d886b55519e72f4f6a9a271f7 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 1 Feb 2024 21:50:05 +0900 Subject: [PATCH 5460/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListener.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index e1308425c..834af8aa0 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -538,6 +538,7 @@ object state } var ctx = _contextQueue.Dequeue (); + ares.Complete (ctx, true); return ares; From 709bc76ec214233c2cc904fe531eb6f8d68db1c3 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 2 Feb 2024 21:39:32 +0900 Subject: [PATCH 5461/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListener.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 834af8aa0..eb98d3f51 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -501,6 +501,7 @@ private bool authenticateClient (HttpListenerContext context) if (schm == AuthenticationSchemes.None) { var msg = "Authentication not allowed"; + context.SendError (403, msg); return false; From 976d9abe84445ba56dd80f835f6c61f3760daa2e Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 3 Feb 2024 22:06:56 +0900 Subject: [PATCH 5462/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListener.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index eb98d3f51..301ea8bb0 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -112,10 +112,8 @@ public HttpListener () { _authSchemes = AuthenticationSchemes.Anonymous; _contextQueue = new Queue (); - _contextRegistry = new LinkedList (); _contextRegistrySync = ((ICollection) _contextRegistry).SyncRoot; - _log = new Logger (); _objectName = GetType ().ToString (); _prefixes = new HttpListenerPrefixCollection (this); From 1221291ff939b1822b7929362e68d4418acd5830 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 4 Feb 2024 22:11:38 +0900 Subject: [PATCH 5463/6294] [Modify] Add it --- websocket-sharp/Net/HttpListener.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 301ea8bb0..88dfd2731 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -125,6 +125,12 @@ public HttpListener () #region Internal Properties + internal string ObjectName { + get { + return GetType ().ToString (); + } + } + internal bool ReuseAddress { get { return _reuseAddress; From 48d65f7a09fb044e56f696704b77615b738b27c1 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 4 Feb 2024 22:14:05 +0900 Subject: [PATCH 5464/6294] [Modify] Replace it --- websocket-sharp/Net/HttpListener.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 88dfd2731..2c1985398 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -167,7 +167,7 @@ internal bool ReuseAddress { public AuthenticationSchemes AuthenticationSchemes { get { if (_disposed) - throw new ObjectDisposedException (_objectName); + throw new ObjectDisposedException (ObjectName); return _authSchemes; } From 687c9dd36e8aefcf93b2f33a4da88fb0640c072a Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 4 Feb 2024 22:15:25 +0900 Subject: [PATCH 5465/6294] [Modify] Replace it --- websocket-sharp/Net/HttpListener.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 2c1985398..5e04b5377 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -174,7 +174,7 @@ public AuthenticationSchemes AuthenticationSchemes { set { if (_disposed) - throw new ObjectDisposedException (_objectName); + throw new ObjectDisposedException (ObjectName); _authSchemes = value; } From 786443d11b37da86bf8fcbb612e6fd624f7368a1 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 5 Feb 2024 21:51:25 +0900 Subject: [PATCH 5466/6294] [Modify] Replace it --- websocket-sharp/Net/HttpListener.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 5e04b5377..971abddad 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -215,7 +215,7 @@ public AuthenticationSchemes AuthenticationSchemes { public Func AuthenticationSchemeSelector { get { if (_disposed) - throw new ObjectDisposedException (_objectName); + throw new ObjectDisposedException (ObjectName); return _authSchemeSelector; } From 76c7345aafde219589cc38af83d72bf9ee103b8e Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 5 Feb 2024 21:52:51 +0900 Subject: [PATCH 5467/6294] [Modify] Replace it --- websocket-sharp/Net/HttpListener.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 971abddad..60868f3f7 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -222,7 +222,7 @@ public Func AuthenticationSchemeSele set { if (_disposed) - throw new ObjectDisposedException (_objectName); + throw new ObjectDisposedException (ObjectName); _authSchemeSelector = value; } From 3d6642d60cd25b4ed20087936ad306ea72855b9f Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 6 Feb 2024 21:51:00 +0900 Subject: [PATCH 5468/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListener.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 60868f3f7..294372b95 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -198,14 +198,16 @@ public AuthenticationSchemes AuthenticationSchemes { /// /// /// A Func<, - /// > delegate or - /// if not needed. + /// > delegate. /// /// /// The delegate references the method used to select /// an authentication scheme. /// /// + /// if not needed. + /// + /// /// The default value is . /// /// From 7497a6c10fa7b390b1b0b3eef571fbdc7836dbe6 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 6 Feb 2024 21:57:10 +0900 Subject: [PATCH 5469/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListener.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 294372b95..cfd1fcdd1 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -181,7 +181,7 @@ public AuthenticationSchemes AuthenticationSchemes { } /// - /// Gets or sets the delegate called to select the scheme used to + /// Gets or sets the delegate called to determine the scheme used to /// authenticate the clients. /// /// From 433fc0387f96e596eeb8520c0b76a793520c21a9 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 7 Feb 2024 21:48:44 +0900 Subject: [PATCH 5470/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListener.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index cfd1fcdd1..1c56d0cbf 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -197,8 +197,8 @@ public AuthenticationSchemes AuthenticationSchemes { /// /// /// - /// A Func<, - /// > delegate. + /// A + /// delegate. /// /// /// The delegate references the method used to select From bfef0a6de0baa8891ce32bd03a528cc301a8c207 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 7 Feb 2024 21:51:43 +0900 Subject: [PATCH 5471/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListener.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 1c56d0cbf..1696f9880 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -201,8 +201,8 @@ public AuthenticationSchemes AuthenticationSchemes { /// delegate. /// /// - /// The delegate references the method used to select - /// an authentication scheme. + /// The delegate invokes the method used to select an authentication + /// scheme. /// /// /// if not needed. From 3fc94856b1fa5e32dee0fbf2d0e5cdcbac808c99 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 8 Feb 2024 21:54:47 +0900 Subject: [PATCH 5472/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListener.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 1696f9880..9a12b6436 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -205,7 +205,7 @@ public AuthenticationSchemes AuthenticationSchemes { /// scheme. /// /// - /// if not needed. + /// if not necessary. /// /// /// The default value is . From 54b694f3b11d9848a90d323294d6fad64952370e Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 8 Feb 2024 21:58:28 +0900 Subject: [PATCH 5473/6294] [Modify] Replace it --- websocket-sharp/Net/HttpListener.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 9a12b6436..c08f52aea 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -266,7 +266,7 @@ public Func AuthenticationSchemeSele public string CertificateFolderPath { get { if (_disposed) - throw new ObjectDisposedException (_objectName); + throw new ObjectDisposedException (ObjectName); return _certFolderPath; } From e65e652b768de40a697e47ff33893eb67e80a88c Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 8 Feb 2024 21:59:05 +0900 Subject: [PATCH 5474/6294] [Modify] Replace it --- websocket-sharp/Net/HttpListener.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index c08f52aea..60c3014b3 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -273,7 +273,7 @@ public string CertificateFolderPath { set { if (_disposed) - throw new ObjectDisposedException (_objectName); + throw new ObjectDisposedException (ObjectName); _certFolderPath = value; } From e41bad7ebeb312baeda085319514129c7d7a9aae Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 9 Feb 2024 22:00:16 +0900 Subject: [PATCH 5475/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListener.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 60c3014b3..333149d10 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -246,9 +246,9 @@ public Func AuthenticationSchemeSele /// /// /// If this property is or an empty string, - /// the result of System.Environment.GetFolderPath () - /// is used as the default path. + /// the result of the + /// with the method is used as + /// the default path. /// /// /// From d40f926b1edcbc10d7e002910e7b6db07624b9bf Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 10 Feb 2024 22:03:37 +0900 Subject: [PATCH 5476/6294] [Modify] Replace it --- websocket-sharp/Net/HttpListener.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 333149d10..1b798fe9f 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -298,7 +298,7 @@ public string CertificateFolderPath { public bool IgnoreWriteExceptions { get { if (_disposed) - throw new ObjectDisposedException (_objectName); + throw new ObjectDisposedException (ObjectName); return _ignoreWriteExceptions; } From 544fd4a77ae2fc98cb7a7225e5a2a369b0c06346 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 10 Feb 2024 22:04:32 +0900 Subject: [PATCH 5477/6294] [Modify] Replace it --- websocket-sharp/Net/HttpListener.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 1b798fe9f..58ee4c28e 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -305,7 +305,7 @@ public bool IgnoreWriteExceptions { set { if (_disposed) - throw new ObjectDisposedException (_objectName); + throw new ObjectDisposedException (ObjectName); _ignoreWriteExceptions = value; } From 25b7e0a3c80295b70a2aa382238986dca07ea563 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 11 Feb 2024 21:47:02 +0900 Subject: [PATCH 5478/6294] [Modify] Replace it --- websocket-sharp/Net/HttpListener.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 58ee4c28e..7b0c17e1b 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -370,7 +370,7 @@ public Logger Log { public HttpListenerPrefixCollection Prefixes { get { if (_disposed) - throw new ObjectDisposedException (_objectName); + throw new ObjectDisposedException (ObjectName); return _prefixes; } From e627269c30a283752767e31414ddcffc34ef53d5 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 12 Feb 2024 21:42:01 +0900 Subject: [PATCH 5479/6294] [Modify] Replace it --- websocket-sharp/Net/HttpListener.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 7b0c17e1b..269ce4c59 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -397,7 +397,7 @@ public HttpListenerPrefixCollection Prefixes { public string Realm { get { if (_disposed) - throw new ObjectDisposedException (_objectName); + throw new ObjectDisposedException (ObjectName); return _realm; } From 34b3a13f3d91989b1d35556bcae35f0d50abcd7d Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 12 Feb 2024 21:42:53 +0900 Subject: [PATCH 5480/6294] [Modify] Replace it --- websocket-sharp/Net/HttpListener.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 269ce4c59..7c533447e 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -404,7 +404,7 @@ public string Realm { set { if (_disposed) - throw new ObjectDisposedException (_objectName); + throw new ObjectDisposedException (ObjectName); _realm = value; } From 61656ee565b761b56700b75dc5ab7bb0175852e6 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 13 Feb 2024 21:53:54 +0900 Subject: [PATCH 5481/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListener.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 7c533447e..031936778 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -381,7 +381,7 @@ public HttpListenerPrefixCollection Prefixes { /// /// /// If this property is or an empty string, - /// "SECRET AREA" will be used as the name of the realm. + /// "SECRET AREA" is used as the name of the realm. /// /// /// From f517140a30fa9b5eedcb6541022e6f9ea301e522 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 13 Feb 2024 21:55:34 +0900 Subject: [PATCH 5482/6294] [Modify] Replace it --- websocket-sharp/Net/HttpListener.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 031936778..907ed111a 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -423,7 +423,7 @@ public string Realm { public ServerSslConfiguration SslConfiguration { get { if (_disposed) - throw new ObjectDisposedException (_objectName); + throw new ObjectDisposedException (ObjectName); if (_sslConfig == null) _sslConfig = new ServerSslConfiguration (); From 6f6acb4c837b99dc27c67bdf28837c9ebf77ea3e Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 14 Feb 2024 21:47:13 +0900 Subject: [PATCH 5483/6294] [Modify] Replace it --- websocket-sharp/Net/HttpListener.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 907ed111a..002b9ae31 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -481,7 +481,7 @@ public bool UnsafeConnectionNtlmAuthentication { public Func UserCredentialsFinder { get { if (_disposed) - throw new ObjectDisposedException (_objectName); + throw new ObjectDisposedException (ObjectName); return _userCredFinder; } From 726e7249acf5db9156dc8cf9ad8291a6ff22059b Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 14 Feb 2024 21:48:43 +0900 Subject: [PATCH 5484/6294] [Modify] Replace it --- websocket-sharp/Net/HttpListener.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 002b9ae31..aee9932f0 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -488,7 +488,7 @@ public Func UserCredentialsFinder { set { if (_disposed) - throw new ObjectDisposedException (_objectName); + throw new ObjectDisposedException (ObjectName); _userCredFinder = value; } From 25970456a032f3760de5c8805aebd89903052bc5 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 15 Feb 2024 21:17:54 +0900 Subject: [PATCH 5485/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListener.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index aee9932f0..2285c2d74 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -465,13 +465,15 @@ public bool UnsafeConnectionNtlmAuthentication { /// /// /// A Func<, - /// > delegate or - /// if not needed. + /// > delegate. /// /// /// It references the method used to find the credentials. /// /// + /// if not necessary. + /// + /// /// The default value is . /// /// From 9e96d4adbfa2ac280ee7c128c10f754f8f3b02ed Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 15 Feb 2024 21:22:07 +0900 Subject: [PATCH 5486/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListener.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 2285c2d74..89caed1cc 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -464,8 +464,7 @@ public bool UnsafeConnectionNtlmAuthentication { /// /// /// - /// A Func<, - /// > delegate. + /// A delegate. /// /// /// It references the method used to find the credentials. From 4562b7108722b6d3e4a038bd5995a86ec003e628 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 16 Feb 2024 22:01:53 +0900 Subject: [PATCH 5487/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListener.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 89caed1cc..55c310f2c 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -467,7 +467,7 @@ public bool UnsafeConnectionNtlmAuthentication { /// A delegate. /// /// - /// It references the method used to find the credentials. + /// The delegate invokes the method used to find the credentials. /// /// /// if not necessary. From 1127982f959d1e96e65105ddf5592d11df4b0d95 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 17 Feb 2024 21:46:08 +0900 Subject: [PATCH 5488/6294] [Modify] Replace it --- websocket-sharp/Net/HttpListener.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 55c310f2c..3eedb4039 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -693,7 +693,7 @@ HttpListenerRequest request internal void CheckDisposed () { if (_disposed) - throw new ObjectDisposedException (_objectName); + throw new ObjectDisposedException (ObjectName); } internal bool RegisterContext (HttpListenerContext context) From cf0ef91c37fd1c7001ea5d5f4f8f8eb1af710654 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 17 Feb 2024 21:48:45 +0900 Subject: [PATCH 5489/6294] [Modify] Replace it --- websocket-sharp/Net/HttpListener.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 3eedb4039..1746ae06f 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -776,7 +776,7 @@ public void Abort () public IAsyncResult BeginGetContext (AsyncCallback callback, object state) { if (_disposed) - throw new ObjectDisposedException (_objectName); + throw new ObjectDisposedException (ObjectName); if (!_listening) { var msg = "The listener has not been started."; From ed9c52db99a420cb28d63a50c385b9ce60074f76 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 18 Feb 2024 22:10:11 +0900 Subject: [PATCH 5490/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListener.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 1746ae06f..c6fc0ef25 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -749,8 +749,12 @@ public void Abort () /// the asynchronous operation. /// /// - /// An delegate that references the method - /// to invoke when the asynchronous operation completes. + /// + /// An delegate. + /// + /// + /// The delegate is called when the asynchronous operation completes. + /// /// /// /// An that specifies a user defined object to From 8a9187fc936f1187301d6cf6e17780ca148e7710 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 19 Feb 2024 21:35:42 +0900 Subject: [PATCH 5491/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListener.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index c6fc0ef25..021f9ca6a 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -737,7 +737,7 @@ public void Abort () /// /// /// This asynchronous operation must be completed by calling - /// the EndGetContext method. + /// the method. /// /// /// Typically, the EndGetContext method is called by From 48e9e8d9193ec3600d880a2d3d78ba4d6c9be067 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 19 Feb 2024 21:38:19 +0900 Subject: [PATCH 5492/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListener.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 021f9ca6a..fd3608ada 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -740,7 +740,7 @@ public void Abort () /// the method. /// /// - /// Typically, the EndGetContext method is called by + /// Typically, the method is called by /// . /// /// From 0da9871bd6e23275cae39f83c3d700538567cbb7 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 20 Feb 2024 21:33:36 +0900 Subject: [PATCH 5493/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListener.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index fd3608ada..8e265cc2a 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -736,7 +736,7 @@ public void Abort () /// /// /// - /// This asynchronous operation must be completed by calling + /// This asynchronous operation must be ended by calling /// the method. /// /// From 40c7de8f4858f8bd99b4ec8095e67ae277ef760a Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 20 Feb 2024 21:36:46 +0900 Subject: [PATCH 5494/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListener.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 8e265cc2a..cc55c4379 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -760,6 +760,9 @@ public void Abort () /// An that specifies a user defined object to /// pass to . /// + /// + /// This method is canceled. + /// /// /// /// This listener has not been started or is currently stopped. @@ -771,9 +774,6 @@ public void Abort () /// This listener has no URI prefix on which listens. /// /// - /// - /// This method is canceled. - /// /// /// This listener has been closed. /// From 0dd9e04476e46e53fe1027ef02c0832c757dfa6f Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 21 Feb 2024 21:48:14 +0900 Subject: [PATCH 5495/6294] [Modify] Replace it --- websocket-sharp/Net/HttpListener.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index cc55c4379..a51270444 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -849,7 +849,7 @@ public void Close () public HttpListenerContext EndGetContext (IAsyncResult asyncResult) { if (_disposed) - throw new ObjectDisposedException (_objectName); + throw new ObjectDisposedException (ObjectName); if (!_listening) { var msg = "The listener has not been started."; From 2ba8187f96ccfcb81487c9eaaecad064447e5d91 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 21 Feb 2024 21:53:50 +0900 Subject: [PATCH 5496/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListener.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index a51270444..f3171f357 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -812,8 +812,8 @@ public void Close () /// Ends an asynchronous operation to get an incoming request. /// /// - /// This method completes an asynchronous operation started by - /// calling the BeginGetContext method. + /// This method ends an asynchronous operation started by calling + /// the method. /// /// /// A that represents a request. From 5ee8068a94281cf2b573e19082ba3796d29d75fa Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 21 Feb 2024 21:56:09 +0900 Subject: [PATCH 5497/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListener.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index f3171f357..60f8ebb28 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -820,7 +820,7 @@ public void Close () /// /// /// An instance obtained by calling - /// the BeginGetContext method. + /// the method. /// /// /// is . From 3866ab074d7fbaf32cd64e23972762c30d8d0bac Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 22 Feb 2024 21:54:40 +0900 Subject: [PATCH 5498/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListener.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 60f8ebb28..4ddf39755 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -827,7 +827,7 @@ public void Close () /// /// /// was not obtained by calling - /// the BeginGetContext method. + /// the method. /// /// /// From 3b493eb5096abbe14d3d1d58470bf2d49808a8a2 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 22 Feb 2024 21:57:04 +0900 Subject: [PATCH 5499/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListener.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 4ddf39755..8cef6a997 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -822,13 +822,16 @@ public void Close () /// An instance obtained by calling /// the method. /// - /// - /// is . - /// /// /// was not obtained by calling /// the method. /// + /// + /// is . + /// + /// + /// This method is canceled. + /// /// /// /// This listener has not been started or is currently stopped. @@ -840,9 +843,6 @@ public void Close () /// This method was already called for . /// /// - /// - /// This method is canceled. - /// /// /// This listener has been closed. /// From a6f73204cb8592d6bbf6444188bc75f71c37480f Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 23 Feb 2024 21:46:50 +0900 Subject: [PATCH 5500/6294] [Modify] Replace it --- websocket-sharp/Net/HttpListener.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 8cef6a997..01eac6ca0 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -914,7 +914,7 @@ public HttpListenerContext EndGetContext (IAsyncResult asyncResult) public HttpListenerContext GetContext () { if (_disposed) - throw new ObjectDisposedException (_objectName); + throw new ObjectDisposedException (ObjectName); if (!_listening) { var msg = "The listener has not been started."; From 69e39f7892733171ac0726842463c7a8152ce51c Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 23 Feb 2024 21:48:56 +0900 Subject: [PATCH 5501/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListener.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 01eac6ca0..43e442db8 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -894,6 +894,9 @@ public HttpListenerContext EndGetContext (IAsyncResult asyncResult) /// /// A that represents a request. /// + /// + /// This method is canceled. + /// /// /// /// This listener has not been started or is currently stopped. @@ -905,9 +908,6 @@ public HttpListenerContext EndGetContext (IAsyncResult asyncResult) /// This listener has no URI prefix on which listens. /// /// - /// - /// This method is canceled. - /// /// /// This listener has been closed. /// From 403d6c7f0315fd94d2a9ccc4d49c33f617867f6c Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 24 Feb 2024 21:55:17 +0900 Subject: [PATCH 5502/6294] [Modify] Replace it --- websocket-sharp/Net/HttpListener.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 43e442db8..6949606cb 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -973,11 +973,11 @@ public void Start () public void Stop () { if (_disposed) - throw new ObjectDisposedException (_objectName); + throw new ObjectDisposedException (ObjectName); lock (_sync) { if (_disposed) - throw new ObjectDisposedException (_objectName); + throw new ObjectDisposedException (ObjectName); lock (_contextRegistrySync) { if (!_listening) From b405e34d4bdb438273287dcd28f6cce5d1fb6e4e Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 25 Feb 2024 21:56:27 +0900 Subject: [PATCH 5503/6294] [Modify] Replace it --- websocket-sharp/Net/HttpListener.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 6949606cb..d19c09935 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -947,11 +947,11 @@ public HttpListenerContext GetContext () public void Start () { if (_disposed) - throw new ObjectDisposedException (_objectName); + throw new ObjectDisposedException (ObjectName); lock (_sync) { if (_disposed) - throw new ObjectDisposedException (_objectName); + throw new ObjectDisposedException (ObjectName); lock (_contextRegistrySync) { if (_listening) From a7e9b7f7f1370f247f6f867d81eeab0fa86727e1 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 26 Feb 2024 21:42:25 +0900 Subject: [PATCH 5504/6294] [Modify] Remove it --- websocket-sharp/Net/HttpListener.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index d19c09935..0c68e3635 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -83,7 +83,6 @@ public sealed class HttpListener : IDisposable private bool _ignoreWriteExceptions; private volatile bool _listening; private Logger _log; - private string _objectName; private HttpListenerPrefixCollection _prefixes; private string _realm; private bool _reuseAddress; @@ -115,7 +114,6 @@ public HttpListener () _contextRegistry = new LinkedList (); _contextRegistrySync = ((ICollection) _contextRegistry).SyncRoot; _log = new Logger (); - _objectName = GetType ().ToString (); _prefixes = new HttpListenerPrefixCollection (this); _sync = new object (); _waitQueue = new Queue (); From c2f5ba8a418e0d2094faf569230213f6905190fa Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 27 Feb 2024 22:13:05 +0900 Subject: [PATCH 5505/6294] [Modify] Add a check if it has been closed or not --- websocket-sharp/Net/HttpListener.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 0c68e3635..6c6e75a9e 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -349,8 +349,14 @@ public static bool IsSupported { /// /// A that provides the logging functions. /// + /// + /// This listener has been closed. + /// public Logger Log { get { + if (_disposed) + throw new ObjectDisposedException (ObjectName); + return _log; } } From d7e7917dfbefd23cbf0f10ea4f014190de85b184 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 28 Feb 2024 22:15:00 +0900 Subject: [PATCH 5506/6294] [Modify] 2024 --- websocket-sharp/Net/HttpListener.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 6c6e75a9e..7134e792e 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -8,7 +8,7 @@ * The MIT License * * Copyright (c) 2005 Novell, Inc. (http://www.novell.com) - * Copyright (c) 2012-2022 sta.blockhead + * Copyright (c) 2012-2024 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From 638f7768a32605df82b5168128e7a85ba81e38f0 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 29 Feb 2024 22:06:23 +0900 Subject: [PATCH 5507/6294] [Modify] Polish it --- websocket-sharp/Net/HttpListenerContext.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerContext.cs b/websocket-sharp/Net/HttpListenerContext.cs index 5b9f94b1b..388b204aa 100644 --- a/websocket-sharp/Net/HttpListenerContext.cs +++ b/websocket-sharp/Net/HttpListenerContext.cs @@ -175,7 +175,9 @@ public IPrincipal User { #region Private Methods private static string createErrorContent ( - int statusCode, string statusDescription, string message + int statusCode, + string statusDescription, + string message ) { return message != null && message.Length > 0 From 08d947d53ea1979ac76d8da4bfc4f89c414a74aa Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 1 Mar 2024 21:40:55 +0900 Subject: [PATCH 5508/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerContext.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerContext.cs b/websocket-sharp/Net/HttpListenerContext.cs index 388b204aa..242488929 100644 --- a/websocket-sharp/Net/HttpListenerContext.cs +++ b/websocket-sharp/Net/HttpListenerContext.cs @@ -312,26 +312,26 @@ internal void Unregister () /// if not necessary. /// /// - /// + /// /// - /// This method has already been done. + /// is empty. /// /// /// -or- /// /// - /// The client request is not a WebSocket handshake request. + /// contains an invalid character. /// /// - /// + /// /// - /// is empty. + /// This method has already been done. /// /// /// -or- /// /// - /// contains an invalid character. + /// The client request is not a WebSocket handshake request. /// /// public HttpListenerWebSocketContext AcceptWebSocket (string protocol) From 844c98922c84b8b803729344bffe71990ea99266 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 1 Mar 2024 21:44:01 +0900 Subject: [PATCH 5509/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerContext.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerContext.cs b/websocket-sharp/Net/HttpListenerContext.cs index 242488929..37d133b60 100644 --- a/websocket-sharp/Net/HttpListenerContext.cs +++ b/websocket-sharp/Net/HttpListenerContext.cs @@ -314,7 +314,7 @@ internal void Unregister () /// /// /// - /// is empty. + /// is an empty string. /// /// /// -or- From 25f41b5d8e8941ab1781a95d9aef351328877dcc Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 2 Mar 2024 21:46:06 +0900 Subject: [PATCH 5510/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerContext.cs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerContext.cs b/websocket-sharp/Net/HttpListenerContext.cs index 37d133b60..41027f20d 100644 --- a/websocket-sharp/Net/HttpListenerContext.cs +++ b/websocket-sharp/Net/HttpListenerContext.cs @@ -365,32 +365,32 @@ public HttpListenerWebSocketContext AcceptWebSocket (string protocol) /// initializing a new WebSocket instance. /// /// - /// + /// /// - /// This method has already been done. + /// is empty. /// /// /// -or- /// /// - /// The client request is not a WebSocket handshake request. + /// contains an invalid character. /// - /// - /// /// - /// is empty. + /// -or- /// /// - /// -or- + /// caused an exception. /// + /// + /// /// - /// contains an invalid character. + /// This method has already been done. /// /// /// -or- /// /// - /// caused an exception. + /// The client request is not a WebSocket handshake request. /// /// public HttpListenerWebSocketContext AcceptWebSocket ( From d2892a59d4bdbcc6ec04a86eb5a56692569fb573 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 2 Mar 2024 21:54:35 +0900 Subject: [PATCH 5511/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerContext.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerContext.cs b/websocket-sharp/Net/HttpListenerContext.cs index 41027f20d..605a6ca1b 100644 --- a/websocket-sharp/Net/HttpListenerContext.cs +++ b/websocket-sharp/Net/HttpListenerContext.cs @@ -367,7 +367,7 @@ public HttpListenerWebSocketContext AcceptWebSocket (string protocol) /// /// /// - /// is empty. + /// is an empty string. /// /// /// -or- From f5e202501646da292fad3fb1d6fa312ce9cee137 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 3 Mar 2024 21:56:06 +0900 Subject: [PATCH 5512/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerContext.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerContext.cs b/websocket-sharp/Net/HttpListenerContext.cs index 605a6ca1b..82ea0176c 100644 --- a/websocket-sharp/Net/HttpListenerContext.cs +++ b/websocket-sharp/Net/HttpListenerContext.cs @@ -361,8 +361,8 @@ public HttpListenerWebSocketContext AcceptWebSocket (string protocol) /// An delegate. /// /// - /// It specifies the delegate that invokes the method called when - /// initializing a new WebSocket instance. + /// It specifies the delegate called when a new WebSocket instance is + /// initialized. /// /// /// From c09d646ee7450de748277bbad32fe052d02e9c9c Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 4 Mar 2024 21:41:16 +0900 Subject: [PATCH 5513/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListener.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 7134e792e..e4b549381 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -757,7 +757,8 @@ public void Abort () /// An delegate. /// /// - /// The delegate is called when the asynchronous operation completes. + /// It specifies the delegate called when the asynchronous operation + /// completes. /// /// /// From 54439b91b58cb252330d5252e15dea62a744909a Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 5 Mar 2024 22:18:03 +0900 Subject: [PATCH 5514/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerRequest.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index 44be56d33..d9935ffca 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -859,8 +859,13 @@ internal void SetRequestLine (string requestLine) /// the operation. /// /// - /// An delegate that invokes the method called - /// when the operation is complete. + /// + /// An delegate. + /// + /// + /// It specifies the delegate called when the asynchronous operation is + /// complete. + /// /// /// /// An that specifies a user defined object to pass From c05b91b7758358f547f695f7c4ecee6a74c7cbbb Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 5 Mar 2024 22:22:06 +0900 Subject: [PATCH 5515/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerRequest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index d9935ffca..9d00dccf2 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -869,7 +869,7 @@ internal void SetRequestLine (string requestLine) /// /// /// An that specifies a user defined object to pass - /// to the callback delegate. + /// to . /// /// /// This method is not supported. From 6d5c369208bfd2633e5d70fc624f31b2a8d79e82 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 6 Mar 2024 21:47:18 +0900 Subject: [PATCH 5516/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerRequest.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index 9d00dccf2..fe6617207 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -855,8 +855,8 @@ internal void SetRequestLine (string requestLine) /// Begins getting the certificate provided by the client asynchronously. /// /// - /// An instance that indicates the status of - /// the operation. + /// An instance that represents the status of + /// the asynchronous operation. /// /// /// From 60823b2cb1126f56ff395e01eeb5dca3b25812a7 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 6 Mar 2024 21:49:19 +0900 Subject: [PATCH 5517/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListener.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index e4b549381..0ac73967b 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -757,8 +757,8 @@ public void Abort () /// An delegate. /// /// - /// It specifies the delegate called when the asynchronous operation - /// completes. + /// It specifies the delegate called when the asynchronous operation is + /// complete. /// /// /// From 36cc83270e81f659d07b188eac4a299f7d059b04 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 7 Mar 2024 21:42:39 +0900 Subject: [PATCH 5518/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListener.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 0ac73967b..2e92ff074 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -762,8 +762,8 @@ public void Abort () /// /// /// - /// An that specifies a user defined object to - /// pass to . + /// An that specifies a user defined object to pass to + /// . /// /// /// This method is canceled. From 8e98db17bb65543527cc8bd582bc1b2ecb75b1d2 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 7 Mar 2024 21:44:33 +0900 Subject: [PATCH 5519/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListener.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 2e92ff074..74ba0d421 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -749,7 +749,7 @@ public void Abort () /// /// /// - /// An that represents the status of + /// An instance that represents the status of /// the asynchronous operation. /// /// From 43679aedc0218522cbe9c914eed3122cbc9b06c9 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 8 Mar 2024 21:53:35 +0900 Subject: [PATCH 5520/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerRequest.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index fe6617207..1942ce36d 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -868,8 +868,8 @@ internal void SetRequestLine (string requestLine) /// /// /// - /// An that specifies a user defined object to pass - /// to . + /// An that specifies a user defined object to pass to + /// . /// /// /// This method is not supported. From af6e98f33844de81c71bd69a3abea8f8698ffa41 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 8 Mar 2024 21:58:34 +0900 Subject: [PATCH 5521/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerRequest.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index 1942ce36d..aa3e5418e 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -891,8 +891,8 @@ object state /// provided by the client. /// /// - /// An instance returned when the operation - /// started. + /// An instance obtained by calling + /// the method. /// /// /// This method is not supported. From dc43927532890a891f4ae102760ce8c3b7426ac6 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 9 Mar 2024 21:53:36 +0900 Subject: [PATCH 5522/6294] [Modify] 2024 --- websocket-sharp/Net/HttpListenerRequest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index aa3e5418e..9c7b1a16d 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -8,7 +8,7 @@ * The MIT License * * Copyright (c) 2005 Novell, Inc. (http://www.novell.com) - * Copyright (c) 2012-2023 sta.blockhead + * Copyright (c) 2012-2024 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From 0a29b74890631305df994ab8b85fb71e6ddfa865 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 9 Mar 2024 21:59:37 +0900 Subject: [PATCH 5523/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerResponse.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index e90428c88..4b63ac6ac 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -1137,9 +1137,6 @@ public void SetCookie (Cookie cookie) /// /// A that specifies the value of the header to set. /// - /// - /// is . - /// /// /// /// is an empty string. @@ -1169,6 +1166,9 @@ public void SetCookie (Cookie cookie) /// is a restricted header name. /// /// + /// + /// is . + /// /// /// The length of is greater than 65,535 /// characters. From 09b400ee274da9075ca80387cd68d0f9c8c8e2cf Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 10 Mar 2024 21:58:45 +0900 Subject: [PATCH 5524/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerResponse.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index 4b63ac6ac..ae0e7e23e 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -1106,13 +1106,13 @@ public void Redirect (string url) /// /// A to set. /// - /// - /// is . - /// /// /// already exists in the cookies but /// it cannot be updated. /// + /// + /// is . + /// public void SetCookie (Cookie cookie) { if (cookie == null) From de653e4f7cf1d7588937c41bcfd31fe12342aa68 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 10 Mar 2024 22:01:45 +0900 Subject: [PATCH 5525/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerResponse.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index ae0e7e23e..572b3eb1c 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -1050,9 +1050,6 @@ public void CopyFrom (HttpListenerResponse templateResponse) /// A that specifies the absolute URL to which /// the client is redirected to locate a requested resource. /// - /// - /// is . - /// /// /// /// is an empty string. @@ -1064,6 +1061,9 @@ public void CopyFrom (HttpListenerResponse templateResponse) /// is not an absolute URL. /// /// + /// + /// is . + /// /// /// The response is already being sent. /// From d9934fb67dbb33034fe7f457a9f69e17c2d759c3 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 11 Mar 2024 21:46:34 +0900 Subject: [PATCH 5526/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerResponse.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index 572b3eb1c..529f1e68c 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -893,9 +893,6 @@ public void AppendCookie (Cookie cookie) /// A that specifies the value of the header to /// append. /// - /// - /// is . - /// /// /// /// is an empty string. @@ -925,6 +922,9 @@ public void AppendCookie (Cookie cookie) /// is a restricted header name. /// /// + /// + /// is . + /// /// /// The length of is greater than 65,535 /// characters. From 462bf8ffd31cf3ba303f8f338bb5be7088d2e6b0 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 12 Mar 2024 21:51:56 +0900 Subject: [PATCH 5527/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerResponse.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index 529f1e68c..a356d2f09 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -705,12 +705,12 @@ public int StatusCode { /// An empty string if an RFC 2616 description does not exist. /// /// - /// - /// The value specified for a set operation is . - /// /// /// The value specified for a set operation contains an invalid character. /// + /// + /// The value specified for a set operation is . + /// /// /// The response is already being sent. /// From 74e7d4e2d06bac2a06fe25e24fc13b79038d797f Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 13 Mar 2024 22:16:46 +0900 Subject: [PATCH 5528/6294] [Modify] 2024 --- websocket-sharp/Net/HttpListenerResponse.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerResponse.cs b/websocket-sharp/Net/HttpListenerResponse.cs index a356d2f09..500d42827 100644 --- a/websocket-sharp/Net/HttpListenerResponse.cs +++ b/websocket-sharp/Net/HttpListenerResponse.cs @@ -8,7 +8,7 @@ * The MIT License * * Copyright (c) 2005 Novell, Inc. (http://www.novell.com) - * Copyright (c) 2012-2023 sta.blockhead + * Copyright (c) 2012-2024 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From 9128aad4886ca89755c013e193609601e2ec205d Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 14 Mar 2024 21:58:20 +0900 Subject: [PATCH 5529/6294] [Modify] Edit it --- websocket-sharp/Server/HttpServer.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 789f8182a..3b6a7e0bf 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -1254,9 +1254,6 @@ public void AddWebSocketService ( /// / is trimmed from the end of the string if present. /// /// - /// - /// is . - /// /// /// /// is an empty string. @@ -1275,6 +1272,9 @@ public void AddWebSocketService ( /// query and fragment components. /// /// + /// + /// is . + /// public bool RemoveWebSocketService (string path) { return _services.RemoveService (path); From 4aa4d87dfb7411c8f3e0d5f426d5fb87799db388 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 14 Mar 2024 22:01:48 +0900 Subject: [PATCH 5530/6294] [Modify] Polish it --- websocket-sharp/Server/HttpServer.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 3b6a7e0bf..9827a31f3 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -1227,7 +1227,8 @@ public void AddWebSocketService (string path) /// ///
public void AddWebSocketService ( - string path, Action initializer + string path, + Action initializer ) where TBehavior : WebSocketBehavior, new () { From 2495472474f6443be585f1b7af8ca69576261e2a Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 15 Mar 2024 22:08:53 +0900 Subject: [PATCH 5531/6294] [Modify] Edit it --- websocket-sharp/Server/HttpServer.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 9827a31f3..85dd306f5 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -1199,9 +1199,6 @@ public void AddWebSocketService (string path) /// Also it must have a public parameterless constructor. /// /// - /// - /// is . - /// /// /// /// is an empty string. @@ -1226,6 +1223,9 @@ public void AddWebSocketService (string path) /// is already in use. /// /// + /// + /// is . + /// public void AddWebSocketService ( string path, Action initializer From 9a6c6bed9d824f817dbaadfe5dfcfd31bb8ebaef Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 15 Mar 2024 22:13:31 +0900 Subject: [PATCH 5532/6294] [Modify] Edit it --- websocket-sharp/Server/HttpServer.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 85dd306f5..fdc52bbcc 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -1181,8 +1181,8 @@ public void AddWebSocketService (string path) /// An delegate. /// /// - /// The delegate invokes the method called when the service - /// initializes a new session instance. + /// It specifies the delegate called when the service initializes + /// a new session instance. /// /// /// if not necessary. From 3c49f31aa49804cd879930ae6bb925feca76c113 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 16 Mar 2024 22:17:02 +0900 Subject: [PATCH 5533/6294] [Modify] Edit it --- websocket-sharp/Server/HttpServer.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index fdc52bbcc..ea00cb6b7 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -1130,9 +1130,6 @@ private static bool tryCreateUri ( /// Also it must have a public parameterless constructor. /// /// - /// - /// is . - /// /// /// /// is an empty string. @@ -1157,6 +1154,9 @@ private static bool tryCreateUri ( /// is already in use. /// /// + /// + /// is . + /// public void AddWebSocketService (string path) where TBehavior : WebSocketBehavior, new () { From d8423bca2fdaccbbb249d3a7a4a0f4377e276c26 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 16 Mar 2024 22:20:41 +0900 Subject: [PATCH 5534/6294] [Modify] Edit it --- websocket-sharp/Server/HttpServer.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index ea00cb6b7..638a74f0b 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -142,9 +142,6 @@ public HttpServer (int port) /// /// A that specifies the HTTP URL of the server. /// - /// - /// is . - /// /// /// /// is an empty string. @@ -156,6 +153,9 @@ public HttpServer (int port) /// is invalid. /// /// + /// + /// is . + /// public HttpServer (string url) { if (url == null) From 5568e534162011e286e731303e1cbaeb475f7e99 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 17 Mar 2024 22:00:44 +0900 Subject: [PATCH 5535/6294] [Modify] Edit it --- websocket-sharp/Server/HttpServer.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 638a74f0b..2b20eab54 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -239,12 +239,12 @@ public HttpServer (int port, bool secure) /// An that specifies the number of the port on which /// to listen. /// - /// - /// is . - /// /// /// is not a local IP address. /// + /// + /// is . + /// /// /// is less than 1 or greater than 65535. /// From b4d4aa3c642e1656ddd291095ed1bf908acc7550 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 18 Mar 2024 22:08:50 +0900 Subject: [PATCH 5536/6294] [Modify] Edit it --- websocket-sharp/Server/HttpServer.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 2b20eab54..b89422350 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -273,12 +273,12 @@ public HttpServer (System.Net.IPAddress address, int port) /// A : true if the new instance provides /// secure connections; otherwise, false. /// - /// - /// is . - /// /// /// is not a local IP address. /// + /// + /// is . + /// /// /// is less than 1 or greater than 65535. /// From 50e6556db2c9c3377a7516d03213d632599cda8a Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 18 Mar 2024 22:13:34 +0900 Subject: [PATCH 5537/6294] [Modify] Edit it --- websocket-sharp/Server/HttpServer.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index b89422350..43be717e7 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -373,9 +373,6 @@ public AuthenticationSchemes AuthenticationSchemes { /// The default value is "./Public". /// /// - /// - /// The value specified for a set operation is . - /// /// /// /// The value specified for a set operation is an empty string. @@ -393,6 +390,9 @@ public AuthenticationSchemes AuthenticationSchemes { /// The value specified for a set operation is an invalid path string. /// /// + /// + /// The value specified for a set operation is . + /// public string DocumentRootPath { get { return _docRootPath; From a40d25550bf56879e9d34e9865b263fb79c5f96d Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 19 Mar 2024 21:53:03 +0900 Subject: [PATCH 5538/6294] [Modify] Edit it --- websocket-sharp/Server/HttpServer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 43be717e7..33f8e4acc 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -367,7 +367,7 @@ public AuthenticationSchemes AuthenticationSchemes { /// from which to find the requested file. /// /// - /// '/' or '\' is trimmed from the end of the value if present. + /// / or \ is trimmed from the end of the value if present. /// /// /// The default value is "./Public". From d9e0163a2670b3d3ed36fa5f21e8423ea789f892 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 19 Mar 2024 22:04:07 +0900 Subject: [PATCH 5539/6294] [Modify] Edit it --- websocket-sharp/Server/HttpServer.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 33f8e4acc..2dfab8dbb 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -621,7 +621,8 @@ public ServerSslConfiguration SslConfiguration { } /// - /// Gets or sets the delegate used to find the credentials for an identity. + /// Gets or sets the delegate called to find the credentials for + /// an identity used to authenticate a client. /// /// /// The set operation works if the current state of the server is From 3b41d922cb8631f964588cc89ee8c2af16d247aa Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 20 Mar 2024 22:03:48 +0900 Subject: [PATCH 5540/6294] [Modify] Edit it --- websocket-sharp/Server/HttpServer.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 2dfab8dbb..c2959cc61 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -634,11 +634,11 @@ public ServerSslConfiguration SslConfiguration { /// delegate. /// /// - /// The delegate invokes the method called when the server finds + /// It represents the delegate called when the server finds /// the credentials used to authenticate a client. /// /// - /// The method must return if the credentials + /// It must return if the credentials /// are not found. /// /// From f75659846e93e52daf49bf1fb475e37e213eb505 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 21 Mar 2024 21:55:27 +0900 Subject: [PATCH 5541/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListener.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 74ba0d421..e52025817 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -468,10 +468,12 @@ public bool UnsafeConnectionNtlmAuthentication { /// /// /// - /// A delegate. + /// A + /// delegate. /// /// - /// The delegate invokes the method used to find the credentials. + /// It represents the delegate called when the listener finds + /// the credentials used to authenticate a client. /// /// /// if not necessary. From e98b1175ca6b0ae9e5dfdddea30de5b18b7dcf33 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 22 Mar 2024 21:59:51 +0900 Subject: [PATCH 5542/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListener.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index e52025817..60406d5c1 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -476,6 +476,10 @@ public bool UnsafeConnectionNtlmAuthentication { /// the credentials used to authenticate a client. /// /// + /// It must return if the credentials + /// are not found. + /// + /// /// if not necessary. /// /// From 27d49ff6fe07c21f495b005b3346825606f841bf Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 23 Mar 2024 22:10:24 +0900 Subject: [PATCH 5543/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListener.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 60406d5c1..50f11fa40 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -199,8 +199,8 @@ public AuthenticationSchemes AuthenticationSchemes { /// delegate. /// /// - /// The delegate invokes the method used to select an authentication - /// scheme. + /// It represents the delegate called when the listener selects + /// an authentication scheme. /// /// /// if not necessary. From 9606b09b5f0fba41e0eabca96ac1899180829fde Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 24 Mar 2024 22:31:36 +0900 Subject: [PATCH 5544/6294] [Modify] Polish it --- websocket-sharp/Server/HttpServer.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index c2959cc61..13e1f4223 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -817,7 +817,9 @@ private bool checkCertificate (out string message) } private static HttpListener createListener ( - string hostname, int port, bool secure + string hostname, + int port, + bool secure ) { var lsnr = new HttpListener (); From a166864ab3deb58213bae54cc445a009b84a399d Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 24 Mar 2024 22:33:25 +0900 Subject: [PATCH 5545/6294] [Modify] Polish it --- websocket-sharp/Server/HttpServer.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 13e1f4223..55582b76c 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -822,14 +822,14 @@ private static HttpListener createListener ( bool secure ) { - var lsnr = new HttpListener (); + var ret = new HttpListener (); var schm = secure ? "https" : "http"; var pref = String.Format ("{0}://{1}:{2}/", schm, hostname, port); - lsnr.Prefixes.Add (pref); + ret.Prefixes.Add (pref); - return lsnr; + return ret; } private void init ( From e4893acaeda9af31ea000139ed533ff224d28680 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 25 Mar 2024 21:44:53 +0900 Subject: [PATCH 5546/6294] [Modify] Polish it --- websocket-sharp/Server/HttpServer.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 55582b76c..f61d99d7c 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -824,8 +824,9 @@ bool secure { var ret = new HttpListener (); + var fmt = "{0}://{1}:{2}/"; var schm = secure ? "https" : "http"; - var pref = String.Format ("{0}://{1}:{2}/", schm, hostname, port); + var pref = String.Format (fmt, schm, hostname, port); ret.Prefixes.Add (pref); From fd96ee12ea03487b12849e8127fe7cfae25424ba Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 25 Mar 2024 21:47:59 +0900 Subject: [PATCH 5547/6294] [Modify] Polish it --- websocket-sharp/Server/HttpServer.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index f61d99d7c..28ee7768f 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -834,7 +834,10 @@ bool secure } private void init ( - string hostname, System.Net.IPAddress address, int port, bool secure + string hostname, + System.Net.IPAddress address, + int port, + bool secure ) { _hostname = hostname; From 015ac65cd28d40cb33ac65d76d632fbeecc87369 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 26 Mar 2024 21:56:58 +0900 Subject: [PATCH 5548/6294] [Modify] Polish it --- websocket-sharp/Server/HttpServer.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 28ee7768f..b05bf48d8 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -1058,7 +1058,9 @@ private void stopReceiving (int millisecondsTimeout) } private static bool tryCreateUri ( - string uriString, out Uri result, out string message + string uriString, + out Uri result, + out string message ) { result = null; From 125fff233d8c20fab464f43af8af478814490457 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 27 Mar 2024 21:48:44 +0900 Subject: [PATCH 5549/6294] [Modify] Polish it --- websocket-sharp/Server/HttpServer.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index b05bf48d8..b5956ec3f 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -1081,9 +1081,9 @@ out string message } var schm = uri.Scheme; - var http = schm == "http" || schm == "https"; + var isHttpSchm = schm == "http" || schm == "https"; - if (!http) { + if (!isHttpSchm) { message = "The scheme part is not 'http' or 'https'."; return false; From 9e2f1ebbe85d2ed76de60231452e90e5d8c6ecfc Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 27 Mar 2024 21:53:49 +0900 Subject: [PATCH 5550/6294] [Modify] Polish it --- websocket-sharp/Server/HttpServer.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index b5956ec3f..a3c4f8d89 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -875,6 +875,7 @@ private void processRequest (HttpListenerContext context) if (evt == null) { context.ErrorStatusCode = 501; + context.SendError (); return; From e0a477917b6f6db45b9609844f2f23707ac1ccd4 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 28 Mar 2024 22:02:11 +0900 Subject: [PATCH 5551/6294] [Modify] Polish it --- websocket-sharp/Server/HttpServer.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index a3c4f8d89..e379c56f0 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -882,6 +882,7 @@ private void processRequest (HttpListenerContext context) } var e = new HttpRequestEventArgs (context, _docRootPath); + evt (this, e); context.Response.Close (); From bad91f9e7c5632677b303e592a03f747fac8448f Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 29 Mar 2024 21:03:37 +0900 Subject: [PATCH 5552/6294] [Modify] Rename it --- websocket-sharp/Server/HttpServer.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index e379c56f0..ff788436f 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -74,7 +74,7 @@ public class HttpServer private Logger _log; private int _port; private Thread _receiveThread; - private bool _secure; + private bool _isSecure; private WebSocketServiceManager _services; private volatile ServerState _state; private object _sync; @@ -463,7 +463,7 @@ public bool IsListening { /// public bool IsSecure { get { - return _secure; + return _isSecure; } } @@ -610,7 +610,7 @@ public bool ReuseAddress { ///
public ServerSslConfiguration SslConfiguration { get { - if (!_secure) { + if (!_isSecure) { var msg = "The server does not provide secure connections."; throw new InvalidOperationException (msg); @@ -843,10 +843,10 @@ bool secure _hostname = hostname; _address = address; _port = port; - _secure = secure; + _isSecure = secure; _docRootPath = "./Public"; - _listener = createListener (_hostname, _port, _secure); + _listener = createListener (_hostname, _port, _isSecure); _log = _listener.Log; _services = new WebSocketServiceManager (_log); _sync = new object (); @@ -983,7 +983,7 @@ private void start () if (_state == ServerState.Start || _state == ServerState.ShuttingDown) return; - if (_secure) { + if (_isSecure) { string msg; if (!checkCertificate (out msg)) From f93ef1f2078ab0870f1f8d9b2d2230e18507b1dd Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 29 Mar 2024 21:04:49 +0900 Subject: [PATCH 5553/6294] [Modify] Polish it --- websocket-sharp/Server/HttpServer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index ff788436f..2d2da2323 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -70,11 +70,11 @@ public class HttpServer private System.Net.IPAddress _address; private string _docRootPath; private string _hostname; + private bool _isSecure; private HttpListener _listener; private Logger _log; private int _port; private Thread _receiveThread; - private bool _isSecure; private WebSocketServiceManager _services; private volatile ServerState _state; private object _sync; From c3afa7c23f2f720f39485920f4485ad87c952656 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 30 Mar 2024 22:11:05 +0900 Subject: [PATCH 5554/6294] [Modify] Polish it --- websocket-sharp/Server/HttpServer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 2d2da2323..7daaddeb0 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -846,7 +846,7 @@ bool secure _isSecure = secure; _docRootPath = "./Public"; - _listener = createListener (_hostname, _port, _isSecure); + _listener = createListener (hostname, port, secure); _log = _listener.Log; _services = new WebSocketServiceManager (_log); _sync = new object (); From be6df7bf495643a164bbbf57c9c29a70634aea10 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 31 Mar 2024 21:53:36 +0900 Subject: [PATCH 5555/6294] [Modify] 2024 --- websocket-sharp/Server/HttpServer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 7daaddeb0..6c3f3ca6e 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -4,7 +4,7 @@ * * The MIT License * - * Copyright (c) 2012-2023 sta.blockhead + * Copyright (c) 2012-2024 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From 24d515733a2c4bf0aa36c5479c43bb0454d72fbe Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 1 Apr 2024 21:39:18 +0900 Subject: [PATCH 5556/6294] [Modify] Rename it --- websocket-sharp/Net/HttpListener.cs | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 50f11fa40..3eeb94d7e 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -81,7 +81,7 @@ public sealed class HttpListener : IDisposable private static readonly string _defaultRealm; private bool _disposed; private bool _ignoreWriteExceptions; - private volatile bool _listening; + private volatile bool _isListening; private Logger _log; private HttpListenerPrefixCollection _prefixes; private string _realm; @@ -317,7 +317,7 @@ public bool IgnoreWriteExceptions { /// public bool IsListening { get { - return _listening; + return _isListening; } } @@ -541,7 +541,7 @@ object state ) { lock (_contextRegistrySync) { - if (!_listening) { + if (!_isListening) { var msg = "The method is canceled."; throw new HttpListenerException (995, msg); @@ -623,13 +623,13 @@ private void close (bool force) return; lock (_contextRegistrySync) { - if (!_listening) { + if (!_isListening) { _disposed = true; return; } - _listening = false; + _isListening = false; } cleanupContextQueue (force); @@ -654,11 +654,11 @@ private string getRealm () private bool registerContext (HttpListenerContext context) { - if (!_listening) + if (!_isListening) return false; lock (_contextRegistrySync) { - if (!_listening) + if (!_isListening) return false; context.Listener = this; @@ -793,7 +793,7 @@ public IAsyncResult BeginGetContext (AsyncCallback callback, object state) if (_disposed) throw new ObjectDisposedException (ObjectName); - if (!_listening) { + if (!_isListening) { var msg = "The listener has not been started."; throw new InvalidOperationException (msg); @@ -862,7 +862,7 @@ public HttpListenerContext EndGetContext (IAsyncResult asyncResult) if (_disposed) throw new ObjectDisposedException (ObjectName); - if (!_listening) { + if (!_isListening) { var msg = "The listener has not been started."; throw new InvalidOperationException (msg); @@ -927,7 +927,7 @@ public HttpListenerContext GetContext () if (_disposed) throw new ObjectDisposedException (ObjectName); - if (!_listening) { + if (!_isListening) { var msg = "The listener has not been started."; throw new InvalidOperationException (msg); @@ -965,12 +965,12 @@ public void Start () throw new ObjectDisposedException (ObjectName); lock (_contextRegistrySync) { - if (_listening) + if (_isListening) return; EndPointManager.AddListener (this); - _listening = true; + _isListening = true; } } } @@ -991,10 +991,10 @@ public void Stop () throw new ObjectDisposedException (ObjectName); lock (_contextRegistrySync) { - if (!_listening) + if (!_isListening) return; - _listening = false; + _isListening = false; } cleanupContextQueue (false); From fc404fdd7cc0e7776d9f05a9663c1fa1ff98ae77 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 2 Apr 2024 21:22:00 +0900 Subject: [PATCH 5557/6294] [Modify] Polish it --- websocket-sharp/Server/HttpRequestEventArgs.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Server/HttpRequestEventArgs.cs b/websocket-sharp/Server/HttpRequestEventArgs.cs index 722fe8b93..ee334d3b4 100644 --- a/websocket-sharp/Server/HttpRequestEventArgs.cs +++ b/websocket-sharp/Server/HttpRequestEventArgs.cs @@ -64,7 +64,8 @@ public class HttpRequestEventArgs : EventArgs #region Internal Constructors internal HttpRequestEventArgs ( - HttpListenerContext context, string documentRootPath + HttpListenerContext context, + string documentRootPath ) { _context = context; From 85a9bdb76b5a13750e500aa8fb0c01fe5780b139 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 3 Apr 2024 21:32:45 +0900 Subject: [PATCH 5558/6294] [Modify] Edit it --- websocket-sharp/Server/HttpRequestEventArgs.cs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Server/HttpRequestEventArgs.cs b/websocket-sharp/Server/HttpRequestEventArgs.cs index ee334d3b4..afa9d82ed 100644 --- a/websocket-sharp/Server/HttpRequestEventArgs.cs +++ b/websocket-sharp/Server/HttpRequestEventArgs.cs @@ -107,12 +107,11 @@ public HttpListenerResponse Response { /// /// /// - /// A instance or - /// if not authenticated. + /// A instance that represents identity, + /// authentication scheme, and security roles for the client. /// /// - /// That instance describes the identity, authentication scheme, - /// and security roles for the client. + /// if the client is not authenticated. /// /// public IPrincipal User { From 1d8bb03b20d11dc6096bdcb646c9624cc629b3ca Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 3 Apr 2024 21:34:47 +0900 Subject: [PATCH 5559/6294] [Modify] Edit it --- websocket-sharp/Server/HttpRequestEventArgs.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Server/HttpRequestEventArgs.cs b/websocket-sharp/Server/HttpRequestEventArgs.cs index afa9d82ed..a9dbba213 100644 --- a/websocket-sharp/Server/HttpRequestEventArgs.cs +++ b/websocket-sharp/Server/HttpRequestEventArgs.cs @@ -172,9 +172,6 @@ private static bool tryReadFile (string path, out byte[] contents) /// A that specifies a virtual path to /// find the file from the document folder. /// - /// - /// is . - /// /// /// /// is an empty string. @@ -186,6 +183,9 @@ private static bool tryReadFile (string path, out byte[] contents) /// contains "..". /// /// + /// + /// is . + /// public byte[] ReadFile (string path) { if (path == null) From 7e894d816cf1fe4e2ef5660dd7c4d737ad157540 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 4 Apr 2024 21:18:33 +0900 Subject: [PATCH 5560/6294] [Modify] Polish it --- websocket-sharp/Server/HttpRequestEventArgs.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/HttpRequestEventArgs.cs b/websocket-sharp/Server/HttpRequestEventArgs.cs index a9dbba213..7e5ecbb77 100644 --- a/websocket-sharp/Server/HttpRequestEventArgs.cs +++ b/websocket-sharp/Server/HttpRequestEventArgs.cs @@ -194,8 +194,11 @@ public byte[] ReadFile (string path) if (path.Length == 0) throw new ArgumentException ("An empty string.", "path"); - if (path.IndexOf ("..") > -1) - throw new ArgumentException ("It contains '..'.", "path"); + if (path.IndexOf ("..") > -1) { + var msg = "It contains \"..\"."; + + throw new ArgumentException (msg, "path"); + } path = createFilePath (path); byte[] contents; From 2e0551620f582235ef9c19e70f6ee5d13c3524d9 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 5 Apr 2024 21:54:09 +0900 Subject: [PATCH 5561/6294] [Modify] Replace it --- websocket-sharp/Server/HttpRequestEventArgs.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/HttpRequestEventArgs.cs b/websocket-sharp/Server/HttpRequestEventArgs.cs index 7e5ecbb77..9620b432d 100644 --- a/websocket-sharp/Server/HttpRequestEventArgs.cs +++ b/websocket-sharp/Server/HttpRequestEventArgs.cs @@ -194,7 +194,7 @@ public byte[] ReadFile (string path) if (path.Length == 0) throw new ArgumentException ("An empty string.", "path"); - if (path.IndexOf ("..") > -1) { + if (path.Contains ("..")) { var msg = "It contains \"..\"."; throw new ArgumentException (msg, "path"); From 6ae3b0ee3ab17bbc1e7e3883cad4f3dc1fbc116e Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 6 Apr 2024 21:42:49 +0900 Subject: [PATCH 5562/6294] [Modify] Edit it --- websocket-sharp/Server/HttpRequestEventArgs.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Server/HttpRequestEventArgs.cs b/websocket-sharp/Server/HttpRequestEventArgs.cs index 9620b432d..1633cd359 100644 --- a/websocket-sharp/Server/HttpRequestEventArgs.cs +++ b/websocket-sharp/Server/HttpRequestEventArgs.cs @@ -161,11 +161,11 @@ private static bool tryReadFile (string path, out byte[] contents) /// /// /// - /// An array of or - /// if it fails. + /// An array of that receives the contents of + /// the file. /// /// - /// That array receives the contents of the file. + /// if the read has failed. /// /// /// From dec2ae299e721b88cdd3131717633df6a3601496 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 6 Apr 2024 21:44:35 +0900 Subject: [PATCH 5563/6294] [Modify] Edit it --- websocket-sharp/Server/HttpRequestEventArgs.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/HttpRequestEventArgs.cs b/websocket-sharp/Server/HttpRequestEventArgs.cs index 1633cd359..186127cee 100644 --- a/websocket-sharp/Server/HttpRequestEventArgs.cs +++ b/websocket-sharp/Server/HttpRequestEventArgs.cs @@ -169,8 +169,8 @@ private static bool tryReadFile (string path, out byte[] contents) /// /// /// - /// A that specifies a virtual path to - /// find the file from the document folder. + /// A that specifies a virtual path to find + /// the file from the document folder. /// /// /// From 8a51e6d5c003e3804e955d726342b1f7572c9bf0 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 7 Apr 2024 21:35:01 +0900 Subject: [PATCH 5564/6294] [Modify] Polish it --- websocket-sharp/Server/HttpRequestEventArgs.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/HttpRequestEventArgs.cs b/websocket-sharp/Server/HttpRequestEventArgs.cs index 186127cee..40f815baf 100644 --- a/websocket-sharp/Server/HttpRequestEventArgs.cs +++ b/websocket-sharp/Server/HttpRequestEventArgs.cs @@ -250,8 +250,11 @@ public bool TryReadFile (string path, out byte[] contents) if (path.Length == 0) throw new ArgumentException ("An empty string.", "path"); - if (path.IndexOf ("..") > -1) - throw new ArgumentException ("It contains '..'.", "path"); + if (path.IndexOf ("..") > -1) { + var msg = "It contains \"..\"."; + + throw new ArgumentException (msg, "path"); + } path = createFilePath (path); From 1847954348a41c824cd90dde274967b393ee2b79 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 8 Apr 2024 21:42:31 +0900 Subject: [PATCH 5565/6294] [Modify] Replace it --- websocket-sharp/Server/HttpRequestEventArgs.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/HttpRequestEventArgs.cs b/websocket-sharp/Server/HttpRequestEventArgs.cs index 40f815baf..7d126577a 100644 --- a/websocket-sharp/Server/HttpRequestEventArgs.cs +++ b/websocket-sharp/Server/HttpRequestEventArgs.cs @@ -250,7 +250,7 @@ public bool TryReadFile (string path, out byte[] contents) if (path.Length == 0) throw new ArgumentException ("An empty string.", "path"); - if (path.IndexOf ("..") > -1) { + if (path.Contains ("..")) { var msg = "It contains \"..\"."; throw new ArgumentException (msg, "path"); From 0604f8a100e1dd4de738caeb3e144b1dc39e0abd Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 8 Apr 2024 21:44:06 +0900 Subject: [PATCH 5566/6294] [Modify] Edit it --- websocket-sharp/Server/HttpRequestEventArgs.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Server/HttpRequestEventArgs.cs b/websocket-sharp/Server/HttpRequestEventArgs.cs index 7d126577a..bb31c9cc9 100644 --- a/websocket-sharp/Server/HttpRequestEventArgs.cs +++ b/websocket-sharp/Server/HttpRequestEventArgs.cs @@ -228,9 +228,6 @@ public byte[] ReadFile (string path) /// That array receives the contents of the file. /// /// - /// - /// is . - /// /// /// /// is an empty string. @@ -242,6 +239,9 @@ public byte[] ReadFile (string path) /// contains "..". /// /// + /// + /// is . + /// public bool TryReadFile (string path, out byte[] contents) { if (path == null) From 2c3081d7ff0e48860b327452e5c5ae1e56e354a8 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 9 Apr 2024 21:03:58 +0900 Subject: [PATCH 5567/6294] [Modify] Edit it --- websocket-sharp/Server/HttpRequestEventArgs.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Server/HttpRequestEventArgs.cs b/websocket-sharp/Server/HttpRequestEventArgs.cs index bb31c9cc9..a7e0b3093 100644 --- a/websocket-sharp/Server/HttpRequestEventArgs.cs +++ b/websocket-sharp/Server/HttpRequestEventArgs.cs @@ -221,11 +221,11 @@ public byte[] ReadFile (string path) /// /// /// - /// When this method returns, an array of or - /// if it fails. + /// When this method returns, an array of that + /// receives the contents of the file. /// /// - /// That array receives the contents of the file. + /// if the read has failed. /// /// /// From c76d4f37929adf8aa9abb84856cf4aae9e8ca18d Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 10 Apr 2024 21:45:40 +0900 Subject: [PATCH 5568/6294] [Modify] Edit it --- websocket-sharp/Server/HttpRequestEventArgs.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/HttpRequestEventArgs.cs b/websocket-sharp/Server/HttpRequestEventArgs.cs index a7e0b3093..88c7a5ffc 100644 --- a/websocket-sharp/Server/HttpRequestEventArgs.cs +++ b/websocket-sharp/Server/HttpRequestEventArgs.cs @@ -213,7 +213,7 @@ public byte[] ReadFile (string path) /// the class. /// /// - /// true if it succeeds to read; otherwise, false. + /// true if the try has succeeded; otherwise, false. /// /// /// A that specifies a virtual path to find From 52ba47908436c5783fad3c0c6c09d7634b6c371b Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 11 Apr 2024 21:42:59 +0900 Subject: [PATCH 5569/6294] [Modify] 2024 --- websocket-sharp/Server/HttpRequestEventArgs.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/HttpRequestEventArgs.cs b/websocket-sharp/Server/HttpRequestEventArgs.cs index 88c7a5ffc..45af3c1ee 100644 --- a/websocket-sharp/Server/HttpRequestEventArgs.cs +++ b/websocket-sharp/Server/HttpRequestEventArgs.cs @@ -4,7 +4,7 @@ * * The MIT License * - * Copyright (c) 2012-2021 sta.blockhead + * Copyright (c) 2012-2024 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From f2e0ac1f718e26a83da82a690237c56e2b7f6d04 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 12 Apr 2024 21:38:12 +0900 Subject: [PATCH 5570/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 8b0d74855..a4459c535 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -1102,9 +1102,6 @@ public void AddWebSocketService ( /// / is trimmed from the end of the string if present. /// /// - /// - /// is . - /// /// /// /// is an empty string. @@ -1123,6 +1120,9 @@ public void AddWebSocketService ( /// query and fragment components. /// /// + /// + /// is . + /// public bool RemoveWebSocketService (string path) { return _services.RemoveService (path); From f8949cb53e877057752030740fa28ff894c46305 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 13 Apr 2024 22:22:23 +0900 Subject: [PATCH 5571/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketServer.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index a4459c535..5d741fda7 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -1075,7 +1075,8 @@ public void AddWebSocketService (string path) /// /// public void AddWebSocketService ( - string path, Action initializer + string path, + Action initializer ) where TBehavior : WebSocketBehavior, new () { From 56952a2089e5b892d0f6efd2b172e1bab578fd95 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 14 Apr 2024 21:09:16 +0900 Subject: [PATCH 5572/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 5d741fda7..2b9403c31 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -1047,9 +1047,6 @@ public void AddWebSocketService (string path) /// Also it must have a public parameterless constructor. /// /// - /// - /// is . - /// /// /// /// is an empty string. @@ -1074,6 +1071,9 @@ public void AddWebSocketService (string path) /// is already in use. /// /// + /// + /// is . + /// public void AddWebSocketService ( string path, Action initializer From 2b68a8f7470c5aa585ebe6bb6f311db193029faf Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 14 Apr 2024 21:12:28 +0900 Subject: [PATCH 5573/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 2b9403c31..9b3fee902 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -1029,8 +1029,8 @@ public void AddWebSocketService (string path) /// An delegate. /// /// - /// The delegate invokes the method called when the service - /// initializes a new session instance. + /// It specifies the delegate called when the service initializes + /// a new session instance. /// /// /// if not necessary. From 0f6ac22dede2c376da729444667f7bb2e3544d99 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 15 Apr 2024 22:44:18 +0900 Subject: [PATCH 5574/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 9b3fee902..d96430b36 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -978,9 +978,6 @@ private static bool tryCreateUri ( /// Also it must have a public parameterless constructor. /// /// - /// - /// is . - /// /// /// /// is an empty string. @@ -1005,6 +1002,9 @@ private static bool tryCreateUri ( /// is already in use. /// /// + /// + /// is . + /// public void AddWebSocketService (string path) where TBehavior : WebSocketBehavior, new () { From ea8bb267967fdaa7e892e012e962480fe3232ba2 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 16 Apr 2024 21:17:11 +0900 Subject: [PATCH 5575/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketServer.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index d96430b36..3e1de9786 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -935,7 +935,9 @@ private void stopReceiving (int millisecondsTimeout) } private static bool tryCreateUri ( - string uriString, out Uri result, out string message + string uriString, + out Uri result, + out string message ) { if (!uriString.TryCreateWebSocketUri (out result, out message)) From 6f76e5f0273f1b080555836970d74cee6820f4ee Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 17 Apr 2024 21:39:47 +0900 Subject: [PATCH 5576/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketServer.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 3e1de9786..3f6ec7f42 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -878,7 +878,9 @@ private void startReceiving () { if (_reuseAddress) { _listener.Server.SetSocketOption ( - SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true + SocketOptionLevel.Socket, + SocketOptionName.ReuseAddress, + true ); } From 49c14a50d71aec906ae48654e29a590e9b2f9fc7 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 18 Apr 2024 21:12:42 +0900 Subject: [PATCH 5577/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketServer.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 3f6ec7f42..926017c85 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -789,7 +789,11 @@ private void receiveRequest () state => { try { var ctx = new TcpListenerWebSocketContext ( - cl, null, _secure, _sslConfigInUse, _log + cl, + null, + _secure, + _sslConfigInUse, + _log ); processRequest (ctx); From fbb69b6f63adf889d3dbc10e91bf2372b7a529b3 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 19 Apr 2024 22:06:00 +0900 Subject: [PATCH 5578/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketServer.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 926017c85..787bcb51b 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -721,7 +721,10 @@ private ServerSslConfiguration getSslConfiguration () } private void init ( - string hostname, System.Net.IPAddress address, int port, bool secure + string hostname, + System.Net.IPAddress address, + int port, + bool secure ) { _hostname = hostname; From f9b774fa134ab992d7b1bd1bd45a793cd3913d59 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 20 Apr 2024 21:17:12 +0900 Subject: [PATCH 5579/6294] [Modify] Rename it --- websocket-sharp/Server/WebSocketServer.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 787bcb51b..eb49a0cee 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -70,7 +70,7 @@ public class WebSocketServer private string _realmInUse; private Thread _receiveThread; private bool _reuseAddress; - private bool _secure; + private bool _isSecure; private WebSocketServiceManager _services; private ServerSslConfiguration _sslConfig; private ServerSslConfiguration _sslConfigInUse; @@ -387,7 +387,7 @@ public bool IsListening { /// public bool IsSecure { get { - return _secure; + return _isSecure; } } @@ -534,7 +534,7 @@ public bool ReuseAddress { /// public ServerSslConfiguration SslConfiguration { get { - if (!_secure) { + if (!_isSecure) { var msg = "The server does not provide secure connections."; throw new InvalidOperationException (msg); @@ -730,7 +730,7 @@ bool secure _hostname = hostname; _address = address; _port = port; - _secure = secure; + _isSecure = secure; _authSchemes = AuthenticationSchemes.Anonymous; _dnsStyle = Uri.CheckHostName (hostname) == UriHostNameType.Dns; @@ -794,7 +794,7 @@ private void receiveRequest () var ctx = new TcpListenerWebSocketContext ( cl, null, - _secure, + _isSecure, _sslConfigInUse, _log ); @@ -851,7 +851,7 @@ private void start () if (_state == ServerState.Start || _state == ServerState.ShuttingDown) return; - if (_secure) { + if (_isSecure) { var src = getSslConfiguration (); var conf = new ServerSslConfiguration (src); From b36f62b84bc084bb0f5e9c70bd502b66033e6a8d Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 20 Apr 2024 21:18:26 +0900 Subject: [PATCH 5580/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketServer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index eb49a0cee..abe17e750 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -63,6 +63,7 @@ public class WebSocketServer private static readonly string _defaultRealm; private bool _dnsStyle; private string _hostname; + private bool _isSecure; private TcpListener _listener; private Logger _log; private int _port; @@ -70,7 +71,6 @@ public class WebSocketServer private string _realmInUse; private Thread _receiveThread; private bool _reuseAddress; - private bool _isSecure; private WebSocketServiceManager _services; private ServerSslConfiguration _sslConfig; private ServerSslConfiguration _sslConfigInUse; From e2c623c097fccb170b0cf5181f7889bd163a2948 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 21 Apr 2024 21:43:20 +0900 Subject: [PATCH 5581/6294] [Modify] Rename it --- websocket-sharp/Server/WebSocketServer.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index abe17e750..3474bc986 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -61,7 +61,7 @@ public class WebSocketServer private System.Net.IPAddress _address; private AuthenticationSchemes _authSchemes; private static readonly string _defaultRealm; - private bool _dnsStyle; + private bool _isDnsStyle; private string _hostname; private bool _isSecure; private TcpListener _listener; @@ -700,7 +700,7 @@ private bool canSet () private bool checkHostNameForRequest (string name) { - return !_dnsStyle + return !_isDnsStyle || Uri.CheckHostName (name) != UriHostNameType.Dns || name == _hostname; } @@ -733,7 +733,7 @@ bool secure _isSecure = secure; _authSchemes = AuthenticationSchemes.Anonymous; - _dnsStyle = Uri.CheckHostName (hostname) == UriHostNameType.Dns; + _isDnsStyle = Uri.CheckHostName (hostname) == UriHostNameType.Dns; _listener = new TcpListener (address, port); _log = new Logger (); _services = new WebSocketServiceManager (_log); From f4adbdf97f91cc30a3d75e89785a0e02f175bdc2 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 21 Apr 2024 21:45:56 +0900 Subject: [PATCH 5582/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketServer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 3474bc986..d3acfc3ba 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -61,8 +61,8 @@ public class WebSocketServer private System.Net.IPAddress _address; private AuthenticationSchemes _authSchemes; private static readonly string _defaultRealm; - private bool _isDnsStyle; private string _hostname; + private bool _isDnsStyle; private bool _isSecure; private TcpListener _listener; private Logger _log; From 7f60c36b03e56683b112705e127a5f48c4c43fa4 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 22 Apr 2024 21:47:17 +0900 Subject: [PATCH 5583/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index d3acfc3ba..e92871d9b 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -152,9 +152,6 @@ public WebSocketServer (int port) /// /// A that specifies the WebSocket URL of the server. /// - /// - /// is . - /// /// /// /// is an empty string. @@ -166,6 +163,9 @@ public WebSocketServer (int port) /// is invalid. /// /// + /// + /// is . + /// public WebSocketServer (string url) { if (url == null) From 4240851c357a6ce25cf4b5ccf5b69f82588883b9 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 23 Apr 2024 21:16:23 +0900 Subject: [PATCH 5584/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index e92871d9b..e841042df 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -285,12 +285,12 @@ public WebSocketServer (System.Net.IPAddress address, int port) /// A : true if the new instance provides /// secure connections; otherwise, false. /// - /// - /// is . - /// /// /// is not a local IP address. /// + /// + /// is . + /// /// /// is less than 1 or greater than 65535. /// From b3e1c723ce9a72a955a7d3e07238f549e3338b0a Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 24 Apr 2024 21:28:41 +0900 Subject: [PATCH 5585/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index e841042df..04700b21d 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -251,12 +251,12 @@ public WebSocketServer (int port, bool secure) /// An that specifies the number of the port on which /// to listen. /// - /// - /// is . - /// /// /// is not a local IP address. /// + /// + /// is . + /// /// /// is less than 1 or greater than 65535. /// From 728cad38fb109ace871165b3c7dae7a8d08da052 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 25 Apr 2024 21:15:22 +0900 Subject: [PATCH 5586/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 04700b21d..3171358de 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -557,11 +557,11 @@ public ServerSslConfiguration SslConfiguration { /// delegate. /// /// - /// The delegate invokes the method called when the server finds + /// It represents the delegate called when the server finds /// the credentials used to authenticate a client. /// /// - /// The method must return if the credentials + /// It must return if the credentials /// are not found. /// /// From b21fec6c969214b25371be4db226fd474a42832a Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 26 Apr 2024 22:01:18 +0900 Subject: [PATCH 5587/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServer.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 3171358de..92013b4e8 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -545,7 +545,8 @@ public ServerSslConfiguration SslConfiguration { } /// - /// Gets or sets the delegate used to find the credentials for an identity. + /// Gets or sets the delegate called to find the credentials for + /// an identity used to authenticate a client. /// /// /// The set operation works if the current state of the server is From e300ccd50d4d242d8c6fdeacec2aa8301ce51dd2 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 27 Apr 2024 21:35:25 +0900 Subject: [PATCH 5588/6294] [Modify] 2024 --- websocket-sharp/Server/WebSocketServer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index 92013b4e8..fbf83b3ee 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -4,7 +4,7 @@ * * The MIT License * - * Copyright (c) 2012-2023 sta.blockhead + * Copyright (c) 2012-2024 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From f23c254fdaf9832eb86dee6cf15b58181bf4e521 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 28 Apr 2024 21:14:23 +0900 Subject: [PATCH 5589/6294] [Modify] Remove it --- websocket-sharp/Server/HttpServer.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 6c3f3ca6e..2a27afa86 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -69,7 +69,6 @@ public class HttpServer private System.Net.IPAddress _address; private string _docRootPath; - private string _hostname; private bool _isSecure; private HttpListener _listener; private Logger _log; @@ -840,7 +839,6 @@ private void init ( bool secure ) { - _hostname = hostname; _address = address; _port = port; _isSecure = secure; From 16c199828ef60472dd56c0e5c8e35e1843c77246 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 29 Apr 2024 21:22:58 +0900 Subject: [PATCH 5590/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServiceManager.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index 12500592c..c8d60a9eb 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -559,9 +559,6 @@ public bool RemoveService (string path) /// the information in the service. /// /// - /// - /// is . - /// /// /// /// is an empty string. @@ -580,6 +577,9 @@ public bool RemoveService (string path) /// query and fragment components. /// /// + /// + /// is . + /// public bool TryGetServiceHost (string path, out WebSocketServiceHost host) { if (path == null) From e45e366659e9b3a553122f766b5c4bc9c1c850cf Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 30 Apr 2024 21:41:43 +0900 Subject: [PATCH 5591/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServiceManager.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index c8d60a9eb..41d351a51 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -552,11 +552,13 @@ public bool RemoveService (string path) /// /// /// When this method returns, a - /// instance or if not found. + /// instance that receives the service host instance. /// /// - /// The service host instance provides the function to access - /// the information in the service. + /// It provides the function to access the information in the service. + /// + /// + /// if not found. /// /// /// From d7ecfaba45768ecdf0722b186613797912277670 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 1 May 2024 21:23:51 +0900 Subject: [PATCH 5592/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServiceManager.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index 41d351a51..4176b6573 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -537,8 +537,7 @@ public bool RemoveService (string path) /// the specified path. /// /// - /// true if the service is successfully found; otherwise, - /// false. + /// true if the try has succeeded; otherwise, false. /// /// /// From 83d2ccbb8de9cb4e0d548c1f117a8196db212454 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 1 May 2024 21:25:12 +0900 Subject: [PATCH 5593/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServiceManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index 4176b6573..5ef90eeac 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -542,7 +542,7 @@ public bool RemoveService (string path) /// /// /// A that specifies an absolute path to - /// the service to find. + /// the service to get. /// /// /// / is trimmed from the end of the string if present. From 3897de502c014c02579aca21dbcba51b3a353fb3 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 2 May 2024 21:12:43 +0900 Subject: [PATCH 5594/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServiceManager.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index 5ef90eeac..91cb22612 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -475,9 +475,6 @@ public void Clear () /// / is trimmed from the end of the string if present. /// /// - /// - /// is . - /// /// /// /// is an empty string. @@ -496,6 +493,9 @@ public void Clear () /// query and fragment components. /// /// + /// + /// is . + /// public bool RemoveService (string path) { if (path == null) From 5a3e6a47c05a3b0989240455d56ca14be0a84435 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 3 May 2024 21:27:59 +0900 Subject: [PATCH 5595/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketServiceManager.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index 91cb22612..8cca36ab7 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -384,7 +384,8 @@ internal void Stop (ushort code, string reason) /// /// public void AddService ( - string path, Action initializer + string path, + Action initializer ) where TBehavior : WebSocketBehavior, new () { From 4d5162940e0aa231dc23e31bc6f9209382765883 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 4 May 2024 21:36:34 +0900 Subject: [PATCH 5596/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServiceManager.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index 8cca36ab7..9fce6d80d 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -356,9 +356,6 @@ internal void Stop (ushort code, string reason) /// Also it must have a public parameterless constructor. /// /// - /// - /// is . - /// /// /// /// is an empty string. @@ -383,6 +380,9 @@ internal void Stop (ushort code, string reason) /// is already in use. /// /// + /// + /// is . + /// public void AddService ( string path, Action initializer From ed4e8d1ec157a00c07094373b4897263c42dfe0e Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 5 May 2024 21:04:28 +0900 Subject: [PATCH 5597/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServiceManager.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index 9fce6d80d..6243d28e4 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -338,8 +338,8 @@ internal void Stop (ushort code, string reason) /// An delegate. /// /// - /// The delegate invokes the method called when the service - /// initializes a new session instance. + /// It specifies the delegate called when the service initializes + /// a new session instance. /// /// /// if not necessary. From 676cae28a1fa9e9ed007055ee6c1503d04bae669 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 6 May 2024 21:06:54 +0900 Subject: [PATCH 5598/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServiceManager.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index 6243d28e4..bd7fa25e2 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -124,9 +124,6 @@ public IEnumerable Hosts { /// / is trimmed from the end of the string if present. /// /// - /// - /// is . - /// /// /// /// is an empty string. @@ -145,6 +142,9 @@ public IEnumerable Hosts { /// query and fragment components. /// /// + /// + /// is . + /// public WebSocketServiceHost this[string path] { get { if (path == null) From 574de40522fc51935e99d3a90f9a2ded6c0e9790 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 7 May 2024 21:23:19 +0900 Subject: [PATCH 5599/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServiceManager.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index bd7fa25e2..d727549ac 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -107,12 +107,14 @@ public IEnumerable Hosts { /// /// /// - /// A instance or - /// if not found. + /// A instance that represents + /// the service host instance. /// /// - /// The service host instance provides the function to access - /// the information in the service. + /// It provides the function to access the information in the service. + /// + /// + /// if not found. /// /// /// From e163177a706376c2d3126331d72148a78b377f44 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 7 May 2024 21:24:54 +0900 Subject: [PATCH 5600/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServiceManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index d727549ac..4ef357565 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -120,7 +120,7 @@ public IEnumerable Hosts { /// /// /// A that specifies an absolute path to - /// the service to find. + /// the service to get. /// /// /// / is trimmed from the end of the string if present. From fddedea57378a0d5dfb9863b52899007c3ec6d27 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 8 May 2024 20:59:22 +0900 Subject: [PATCH 5601/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServiceManager.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index 4ef357565..bd22b6a5a 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -215,7 +215,8 @@ public bool KeepClean { /// /// /// - /// An IEnumerable<string> instance. + /// An + /// instance. /// /// /// It provides an enumerator which supports the iteration over From c6ad9a107e4bd4057fbabca1294a309c1d5377c3 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 9 May 2024 22:02:38 +0900 Subject: [PATCH 5602/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketServiceManager.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index bd22b6a5a..2f88298bb 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -288,7 +288,8 @@ private bool canSet () #region Internal Methods internal bool InternalTryGetServiceHost ( - string path, out WebSocketServiceHost host + string path, + out WebSocketServiceHost host ) { path = path.TrimSlashFromEnd (); From 9a576826be9c691121f55a655b907ee14d417360 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 10 May 2024 21:27:09 +0900 Subject: [PATCH 5603/6294] [Modify] 2024 --- websocket-sharp/Server/WebSocketServiceManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index 2f88298bb..bea46f0c4 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -4,7 +4,7 @@ * * The MIT License * - * Copyright (c) 2012-2023 sta.blockhead + * Copyright (c) 2012-2024 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From 7468911ae144fc1491c22261bd8d3166c8383cb5 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 11 May 2024 21:02:32 +0900 Subject: [PATCH 5604/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketServiceHost`1.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServiceHost`1.cs b/websocket-sharp/Server/WebSocketServiceHost`1.cs index f311251c0..02f01839f 100644 --- a/websocket-sharp/Server/WebSocketServiceHost`1.cs +++ b/websocket-sharp/Server/WebSocketServiceHost`1.cs @@ -42,7 +42,9 @@ internal class WebSocketServiceHost : WebSocketServiceHost #region Internal Constructors internal WebSocketServiceHost ( - string path, Action initializer, Logger log + string path, + Action initializer, + Logger log ) : base (path, log) { From c93f355e70d221cbf30f26ef83f03d25c99ea4e4 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 12 May 2024 21:43:57 +0900 Subject: [PATCH 5605/6294] [Modify] 2024 --- websocket-sharp/Server/WebSocketServiceHost`1.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServiceHost`1.cs b/websocket-sharp/Server/WebSocketServiceHost`1.cs index 02f01839f..8aac424e3 100644 --- a/websocket-sharp/Server/WebSocketServiceHost`1.cs +++ b/websocket-sharp/Server/WebSocketServiceHost`1.cs @@ -4,7 +4,7 @@ * * The MIT License * - * Copyright (c) 2015-2021 sta.blockhead + * Copyright (c) 2015-2024 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From a4ae46bb65390a61bc21671965f83f49a00bf153 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 13 May 2024 21:53:07 +0900 Subject: [PATCH 5606/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketSessionManager.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index dccae2937..5e17e23d9 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -1599,12 +1599,12 @@ public void Sweep () /// the information in the session. /// /// - /// - /// is . - /// /// /// is an empty string. /// + /// + /// is . + /// public bool TryGetSession (string id, out IWebSocketSession session) { if (id == null) From 29f19bfb7cd92d322138b1c6cac0af40c06577e2 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 13 May 2024 21:57:04 +0900 Subject: [PATCH 5607/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketSessionManager.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 5e17e23d9..c1eb7e4f1 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -1583,8 +1583,7 @@ public void Sweep () /// Tries to get the session instance with the specified ID. /// /// - /// true if the session instance is successfully found; otherwise, - /// false. + /// true if the try has succeeded; otherwise, false. /// /// /// A that specifies the ID of the session to find. From 4b9ea3afb673eb467acf8d33fe1b48c1f8d8489a Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 14 May 2024 21:20:55 +0900 Subject: [PATCH 5608/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketSessionManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index c1eb7e4f1..ac78312e7 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -1586,7 +1586,7 @@ public void Sweep () /// true if the try has succeeded; otherwise, false. /// /// - /// A that specifies the ID of the session to find. + /// A that specifies the ID of the session to get. /// /// /// From 196aed469196c4e27f76596d6651f4c5affbba37 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 15 May 2024 20:51:37 +0900 Subject: [PATCH 5609/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketSessionManager.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index ac78312e7..5d2d406eb 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -1590,12 +1590,14 @@ public void Sweep () /// /// /// - /// When this method returns, a - /// instance or if not found. + /// When this method returns, a instance + /// that receives the session instance. /// /// - /// The session instance provides the function to access - /// the information in the session. + /// It provides the function to access the information in the session. + /// + /// + /// if not found. /// /// /// From f97579ca901318e036441ea6b3613352e78774b3 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 16 May 2024 21:48:08 +0900 Subject: [PATCH 5610/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketSessionManager.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 5d2d406eb..9d2bfaad5 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -1513,7 +1513,10 @@ public void SendToAsync (string data, string id, Action completed) /// ///
public void SendToAsync ( - Stream stream, int length, string id, Action completed + Stream stream, + int length, + string id, + Action completed ) { IWebSocketSession session; From 4e7cd863f4a1cfdc8711af3ec9cbb85dc95a8845 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 17 May 2024 21:42:46 +0900 Subject: [PATCH 5611/6294] [Modify] Edit it --- .../Server/WebSocketSessionManager.cs | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 9d2bfaad5..6e7fb6e01 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -1467,17 +1467,6 @@ public void SendToAsync (string data, string id, Action completed) /// if not necessary. /// /// - /// - /// - /// is . - /// - /// - /// -or- - /// - /// - /// is . - /// - /// /// /// /// is an empty string. @@ -1501,6 +1490,17 @@ public void SendToAsync (string data, string id, Action completed) /// No data could be read from . /// /// + /// + /// + /// is . + /// + /// + /// -or- + /// + /// + /// is . + /// + /// /// /// /// The session could not be found. From caca4b3944c694bf2c2d6435e1ec86837d1d580c Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 18 May 2024 21:08:32 +0900 Subject: [PATCH 5612/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketSessionManager.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 6e7fb6e01..4043a0b23 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -1457,11 +1457,12 @@ public void SendToAsync (string data, string id, Action completed) /// An delegate. /// /// - /// The delegate invokes the method called when the send is complete. + /// It specifies the delegate called when the send is complete. /// /// - /// The parameter passed to the method is true - /// if the send has successfully done; otherwise, false. + /// The parameter passed to the delegate is + /// true if the send has successfully done; otherwise, + /// false. /// /// /// if not necessary. From 3f2061f5e6792a85168090127c40aa4c8f4bce78 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 19 May 2024 21:36:58 +0900 Subject: [PATCH 5613/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketSessionManager.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 4043a0b23..468ad6a99 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -1385,26 +1385,26 @@ public void SendToAsync (byte[] data, string id, Action completed) /// if not necessary. /// /// - /// + /// /// - /// is . + /// is an empty string. /// /// /// -or- /// /// - /// is . + /// could not be UTF-8-encoded. /// /// - /// + /// /// - /// is an empty string. + /// is . /// /// /// -or- /// /// - /// could not be UTF-8-encoded. + /// is . /// /// /// From 408199b2dfd4291a9aa59f339ca9a517855cbcac Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 20 May 2024 21:25:32 +0900 Subject: [PATCH 5614/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketSessionManager.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 468ad6a99..31ca59446 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -1375,11 +1375,12 @@ public void SendToAsync (byte[] data, string id, Action completed) /// An delegate. /// /// - /// The delegate invokes the method called when the send is complete. + /// It specifies the delegate called when the send is complete. /// /// - /// The parameter passed to the method is true - /// if the send has successfully done; otherwise, false. + /// The parameter passed to the delegate is + /// true if the send has successfully done; otherwise, + /// false. /// /// /// if not necessary. From f101c44dfb69072990352a444a6025881265eec6 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 21 May 2024 21:06:50 +0900 Subject: [PATCH 5615/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketSessionManager.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 31ca59446..0332c5eb4 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -1319,6 +1319,9 @@ public void SendTo (Stream stream, int length, string id) /// if not necessary. /// /// + /// + /// is an empty string. + /// /// /// /// is . @@ -1330,9 +1333,6 @@ public void SendTo (Stream stream, int length, string id) /// is . /// /// - /// - /// is an empty string. - /// /// /// /// The session could not be found. From 0681bc99721e0c480865aadd52e5358d57bcb648 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 21 May 2024 21:11:55 +0900 Subject: [PATCH 5616/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketSessionManager.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 0332c5eb4..befbcd78a 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -1309,11 +1309,12 @@ public void SendTo (Stream stream, int length, string id) /// An delegate. /// /// - /// The delegate invokes the method called when the send is complete. + /// It specifies the delegate called when the send is complete. /// /// - /// The parameter passed to the method is true - /// if the send has successfully done; otherwise, false. + /// The parameter passed to the delegate is + /// true if the send has successfully done; otherwise, + /// false. /// /// /// if not necessary. From b03c5aae9dd0b66162b73ced444e3b712eadb613 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 22 May 2024 21:05:55 +0900 Subject: [PATCH 5617/6294] [Modify] Edit it --- .../Server/WebSocketSessionManager.cs | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index befbcd78a..ef0a26d3f 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -1233,17 +1233,6 @@ public void SendTo (string data, string id) /// /// A that specifies the ID of the session. /// - /// - /// - /// is . - /// - /// - /// -or- - /// - /// - /// is . - /// - /// /// /// /// is an empty string. @@ -1267,6 +1256,17 @@ public void SendTo (string data, string id) /// No data could be read from . /// /// + /// + /// + /// is . + /// + /// + /// -or- + /// + /// + /// is . + /// + /// /// /// /// The session could not be found. From 859e955debd1ba6eb0d1e41226a620a96e45c3df Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 23 May 2024 21:07:28 +0900 Subject: [PATCH 5618/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketSessionManager.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index ef0a26d3f..0ff93aca7 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -1169,26 +1169,26 @@ public void SendTo (byte[] data, string id) /// /// A that specifies the ID of the session. /// - /// + /// /// - /// is . + /// is an empty string. /// /// /// -or- /// /// - /// is . + /// could not be UTF-8-encoded. /// /// - /// + /// /// - /// is an empty string. + /// is . /// /// /// -or- /// /// - /// could not be UTF-8-encoded. + /// is . /// /// /// From de61f947feb8b6f3cc2a5a5496996a2680e77e8a Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 24 May 2024 21:51:40 +0900 Subject: [PATCH 5619/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketSessionManager.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 0ff93aca7..308d55a85 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -1122,6 +1122,9 @@ public bool PingTo (string message, string id) /// /// A that specifies the ID of the session. /// + /// + /// is an empty string. + /// /// /// /// is . @@ -1133,9 +1136,6 @@ public bool PingTo (string message, string id) /// is . /// /// - /// - /// is an empty string. - /// /// /// /// The session could not be found. From f2585dc5c814fab28ddd8a48c973828db2f1e1cf Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 25 May 2024 21:15:10 +0900 Subject: [PATCH 5620/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketSessionManager.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 308d55a85..748448c0c 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -1080,9 +1080,6 @@ public bool PingTo (string id) /// /// A that specifies the ID of the session. /// - /// - /// is . - /// /// /// /// is an empty string. @@ -1094,12 +1091,15 @@ public bool PingTo (string id) /// could not be UTF-8-encoded. /// /// - /// - /// The session could not be found. + /// + /// is . /// /// /// The size of is greater than 125 bytes. /// + /// + /// The session could not be found. + /// public bool PingTo (string message, string id) { IWebSocketSession session; From 50f26c3e4f49de4a2a2f4568040eb37dc5c81fbb Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 26 May 2024 21:11:39 +0900 Subject: [PATCH 5621/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketSessionManager.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 748448c0c..03cd3c00c 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -1039,12 +1039,12 @@ public void CloseSession (string id, CloseStatusCode code, string reason) /// /// A that specifies the ID of the session. /// - /// - /// is . - /// /// /// is an empty string. /// + /// + /// is . + /// /// /// The session could not be found. /// From 80ef95ec5daa9e21cd7efcea4d2960b90d40610c Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 27 May 2024 21:28:56 +0900 Subject: [PATCH 5622/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketSessionManager.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 03cd3c00c..6bdb4e495 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -983,9 +983,6 @@ public void CloseSession (string id, ushort code, string reason) /// Its size must be 123 bytes or less in UTF-8. /// /// - /// - /// is . - /// /// /// /// is an empty string. @@ -1010,12 +1007,15 @@ public void CloseSession (string id, ushort code, string reason) /// could not be UTF-8-encoded. /// /// - /// - /// The session could not be found. + /// + /// is . /// /// /// The size of is greater than 123 bytes. /// + /// + /// The session could not be found. + /// public void CloseSession (string id, CloseStatusCode code, string reason) { IWebSocketSession session; From f894845c44b31a6b489e46f317dd2184570db58f Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 28 May 2024 21:24:09 +0900 Subject: [PATCH 5623/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketSessionManager.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 6bdb4e495..68507fd06 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -907,9 +907,6 @@ public void CloseSession (string id) /// Its size must be 123 bytes or less in UTF-8. /// /// - /// - /// is . - /// /// /// /// is an empty string. @@ -934,8 +931,8 @@ public void CloseSession (string id) /// could not be UTF-8-encoded. /// /// - /// - /// The session could not be found. + /// + /// is . /// /// /// @@ -948,6 +945,9 @@ public void CloseSession (string id) /// The size of is greater than 123 bytes. /// /// + /// + /// The session could not be found. + /// public void CloseSession (string id, ushort code, string reason) { IWebSocketSession session; From b99d4a868717cdf23a5bd107440c3f003553178a Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 29 May 2024 21:01:33 +0900 Subject: [PATCH 5624/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketSessionManager.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 68507fd06..2fa6e46d8 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -860,12 +860,12 @@ public void BroadcastAsync (Stream stream, int length, Action completed) /// /// A that specifies the ID of the session to close. /// - /// - /// is . - /// /// /// is an empty string. /// + /// + /// is . + /// /// /// The session could not be found. /// From bd9af6ea767f58e4834e791dce562347c2360ec1 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 30 May 2024 21:00:31 +0900 Subject: [PATCH 5625/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketSessionManager.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 2fa6e46d8..5a79c1d83 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -786,12 +786,6 @@ public void BroadcastAsync (string data, Action completed) /// if not necessary. /// /// - /// - /// The current state of the service is not Start. - /// - /// - /// is . - /// /// /// /// cannot be read. @@ -809,6 +803,12 @@ public void BroadcastAsync (string data, Action completed) /// No data could be read from . /// /// + /// + /// is . + /// + /// + /// The current state of the service is not Start. + /// public void BroadcastAsync (Stream stream, int length, Action completed) { if (_state != ServerState.Start) { From 303b2c8c7cf29fd97ca3fc2e568f653aa46d41ba Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 30 May 2024 21:07:31 +0900 Subject: [PATCH 5626/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketSessionManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 5a79c1d83..1037ebcaf 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -780,7 +780,7 @@ public void BroadcastAsync (string data, Action completed) /// An delegate. /// /// - /// The delegate invokes the method called when the send is complete. + /// It specifies the delegate called when the send is complete. /// /// /// if not necessary. From 11793b6a63a3fb6ed26f22c458c9cc76b8183b18 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 31 May 2024 21:41:40 +0900 Subject: [PATCH 5627/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketSessionManager.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 1037ebcaf..fcb1e5ee1 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -723,14 +723,14 @@ public void BroadcastAsync (byte[] data, Action completed) /// if not necessary. /// /// - /// - /// The current state of the service is not Start. + /// + /// could not be UTF-8-encoded. /// /// /// is . /// - /// - /// could not be UTF-8-encoded. + /// + /// The current state of the service is not Start. /// public void BroadcastAsync (string data, Action completed) { From e7fdba43445bc14392a043b2d32acfe18a2e7486 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 31 May 2024 21:44:37 +0900 Subject: [PATCH 5628/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketSessionManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index fcb1e5ee1..8e3410834 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -717,7 +717,7 @@ public void BroadcastAsync (byte[] data, Action completed) /// An delegate. /// /// - /// The delegate invokes the method called when the send is complete. + /// It specifies the delegate called when the send is complete. /// /// /// if not necessary. From 5b0b60169637ee1d0dc0d191ee5a6f3eb6ab5605 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 1 Jun 2024 21:24:58 +0900 Subject: [PATCH 5629/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketSessionManager.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 8e3410834..77ec8e8b7 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -679,12 +679,12 @@ public void Broadcast (Stream stream, int length) /// if not necessary. /// /// - /// - /// The current state of the service is not Start. - /// /// /// is . /// + /// + /// The current state of the service is not Start. + /// public void BroadcastAsync (byte[] data, Action completed) { if (_state != ServerState.Start) { From 3552fdf4fc6cfddf992a4b2bf260a7ca0c9d8948 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 1 Jun 2024 21:27:27 +0900 Subject: [PATCH 5630/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketSessionManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 77ec8e8b7..de1f3bf54 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -673,7 +673,7 @@ public void Broadcast (Stream stream, int length) /// An delegate. /// /// - /// The delegate invokes the method called when the send is complete. + /// It specifies the delegate called when the send is complete. /// /// /// if not necessary. From 467983890da9e93279d314a65bcda875124aefe9 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 2 Jun 2024 21:10:59 +0900 Subject: [PATCH 5631/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketSessionManager.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index de1f3bf54..ea21886fc 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -590,12 +590,6 @@ public void Broadcast (string data) /// /// An that specifies the number of bytes to send. /// - /// - /// The current state of the service is not Start. - /// - /// - /// is . - /// /// /// /// cannot be read. @@ -613,6 +607,12 @@ public void Broadcast (string data) /// No data could be read from . /// /// + /// + /// is . + /// + /// + /// The current state of the service is not Start. + /// public void Broadcast (Stream stream, int length) { if (_state != ServerState.Start) { From 3af0a6727ea367800f4d4e45b6d42b5c48e2cf80 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 3 Jun 2024 21:14:49 +0900 Subject: [PATCH 5632/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketSessionManager.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index ea21886fc..c2fd203ee 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -541,14 +541,14 @@ public void Broadcast (byte[] data) /// /// A that specifies the text data to send. /// - /// - /// The current state of the service is not Start. + /// + /// could not be UTF-8-encoded. /// /// /// is . /// - /// - /// could not be UTF-8-encoded. + /// + /// The current state of the service is not Start. /// public void Broadcast (string data) { From 613fea0a9e3b78e17520cc15265c97863f67e788 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 4 Jun 2024 20:45:50 +0900 Subject: [PATCH 5633/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketSessionManager.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index c2fd203ee..bcd118463 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -512,12 +512,12 @@ internal void Stop (ushort code, string reason) /// /// An array of that specifies the binary data to send. /// - /// - /// The current state of the service is not Start. - /// /// /// is . /// + /// + /// The current state of the service is not Start. + /// public void Broadcast (byte[] data) { if (_state != ServerState.Start) { From a22cac530985d24a5d56ca5ec2c47aaf4492c672 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 5 Jun 2024 21:31:59 +0900 Subject: [PATCH 5634/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketSessionManager.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index bcd118463..a22d5aec8 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -379,7 +379,9 @@ private void broadcastAsync (Opcode opcode, byte[] data, Action completed) } private void broadcastAsync ( - Opcode opcode, Stream sourceStream, Action completed + Opcode opcode, + Stream sourceStream, + Action completed ) { ThreadPool.QueueUserWorkItem ( From b832e800f4346aeee779b698b39518ab5c1279f6 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 6 Jun 2024 20:58:29 +0900 Subject: [PATCH 5635/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketSessionManager.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index a22d5aec8..4b0b18b94 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -340,7 +340,9 @@ private void broadcast (Opcode opcode, byte[] data, Action completed) } private void broadcast ( - Opcode opcode, Stream sourceStream, Action completed + Opcode opcode, + Stream sourceStream, + Action completed ) { var cache = new Dictionary (); From d8172ecf39b00670775f4a9933105a97540a866a Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 6 Jun 2024 21:00:03 +0900 Subject: [PATCH 5636/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketSessionManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 4b0b18b94..0ff30f848 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -345,7 +345,7 @@ private void broadcast ( Action completed ) { - var cache = new Dictionary (); + var cache = new Dictionary (); try { foreach (var session in Sessions) { From fef5ee7ebc961d6385d0cbf1390f5a6d45d1a0c1 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 7 Jun 2024 21:36:23 +0900 Subject: [PATCH 5637/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketSessionManager.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 0ff30f848..80301bb89 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -251,7 +251,8 @@ public bool KeepClean { /// /// /// - /// An IEnumerable<IWebSocketSession> instance. + /// An + /// instance. /// /// /// It provides an enumerator which supports the iteration over From 7be6d1981a7926c81dec92ff2e79697f73b7980d Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 8 Jun 2024 21:04:17 +0900 Subject: [PATCH 5638/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketSessionManager.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 80301bb89..e9c1354a6 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -197,12 +197,12 @@ public IEnumerable InactiveIDs { /// /// A that specifies the ID of the session to find. /// - /// - /// is . - /// /// /// is an empty string. /// + /// + /// is . + /// public IWebSocketSession this[string id] { get { if (id == null) From 77036d473263fb497df195a8bc5eb7833b3f2eab Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 9 Jun 2024 20:52:38 +0900 Subject: [PATCH 5639/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketSessionManager.cs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index e9c1354a6..1d169b806 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -186,12 +186,11 @@ public IEnumerable InactiveIDs { /// /// /// - /// A instance or - /// if not found. + /// A instance that provides + /// the function to access the information in the session. /// /// - /// The session instance provides the function to access the information - /// in the session. + /// if not found. /// /// /// From 474ea665945139e84529e801cdeee8eae93f7cfe Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 9 Jun 2024 20:53:45 +0900 Subject: [PATCH 5640/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketSessionManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 1d169b806..e0867ed9f 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -194,7 +194,7 @@ public IEnumerable InactiveIDs { /// /// /// - /// A that specifies the ID of the session to find. + /// A that specifies the ID of the session to get. /// /// /// is an empty string. From a5d70b43ee6801279aeaae9699f3bf5125d5916b Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 10 Jun 2024 21:47:15 +0900 Subject: [PATCH 5641/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketSessionManager.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index e0867ed9f..99a09f83b 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -165,7 +165,8 @@ public IEnumerable IDs { /// /// /// - /// An IEnumerable<string> instance. + /// An + /// instance. /// /// /// It provides an enumerator which supports the iteration over From ec443255658eea916f0eefa5c87dbefe9b83896a Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 11 Jun 2024 22:12:34 +0900 Subject: [PATCH 5642/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketSessionManager.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 99a09f83b..fb91ef4cb 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -139,7 +139,8 @@ public int Count { /// /// /// - /// An IEnumerable<string> instance. + /// An + /// instance. /// /// /// It provides an enumerator which supports the iteration over From b6c4ec0648fe97f5b9d4636e2a18de0fa89134d4 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 12 Jun 2024 21:02:10 +0900 Subject: [PATCH 5643/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketSessionManager.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index fb91ef4cb..83b7a1d29 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -105,7 +105,8 @@ internal ServerState State { /// /// /// - /// An IEnumerable<string> instance. + /// An + /// instance. /// /// /// It provides an enumerator which supports the iteration over From f5c1f20c3f5beaa32e34af65fc7182e1d65323a7 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 13 Jun 2024 21:23:05 +0900 Subject: [PATCH 5644/6294] [Modify] Lock it --- websocket-sharp/Server/WebSocketSessionManager.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 83b7a1d29..01beaf52f 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -1589,7 +1589,8 @@ public void Sweep () } } - _sweeping = false; + lock (_forSweep) + _sweeping = false; } /// From 46b6e15e02e4aa1eec24c2770fbaa47d6c231958 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 14 Jun 2024 21:44:47 +0900 Subject: [PATCH 5645/6294] [Modify] 2024 --- websocket-sharp/Server/WebSocketSessionManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 01beaf52f..5b597b7f3 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -4,7 +4,7 @@ * * The MIT License * - * Copyright (c) 2012-2023 sta.blockhead + * Copyright (c) 2012-2024 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From 11c20ce4344a572d2f11d24b5702dbc6a42b5d5b Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 15 Jun 2024 21:12:25 +0900 Subject: [PATCH 5646/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketServiceManager.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index bea46f0c4..6d71196b4 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -87,7 +87,8 @@ public int Count { /// /// /// - /// An IEnumerable<WebSocketServiceHost> instance. + /// An + /// instance. /// /// /// It provides an enumerator which supports the iteration over From 5c20954b3e6a010ca45558a85231bc960dd474f8 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 16 Jun 2024 21:08:14 +0900 Subject: [PATCH 5647/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 1e8860861..220e7e676 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -1433,7 +1433,7 @@ protected void SendAsync (Stream stream, int length, Action completed) /// /// /// A that represents - /// the interface. + /// the WebSocket interface. /// /// /// if the session has not started yet. From fb415bc504cf62e71eea23b97d023824b0980b26 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 17 Jun 2024 21:47:06 +0900 Subject: [PATCH 5648/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 24 ++++++++++----------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 220e7e676..4ec957fbd 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -1381,35 +1381,35 @@ protected void SendAsync (string data, Action completed) /// if not necessary. /// /// - /// + /// /// - /// The session has not started yet. + /// cannot be read. /// /// /// -or- /// /// - /// The current state of the WebSocket interface is not Open. + /// is less than 1. /// - /// - /// - /// is . - /// - /// /// - /// cannot be read. + /// -or- /// /// - /// -or- + /// No data could be read from . /// + /// + /// + /// is . + /// + /// /// - /// is less than 1. + /// The session has not started yet. /// /// /// -or- /// /// - /// No data could be read from . + /// The current state of the WebSocket interface is not Open. /// /// protected void SendAsync (Stream stream, int length, Action completed) From 9a327a25bb3800210a595cf3fcf27d0dd72dac1d Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 17 Jun 2024 21:54:33 +0900 Subject: [PATCH 5649/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 4ec957fbd..d2e2cc8b4 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -1371,10 +1371,10 @@ protected void SendAsync (string data, Action completed) /// An delegate. /// /// - /// The delegate invokes the method called when the send is complete. + /// It specifies the delegate called when the send is complete. /// /// - /// The parameter passed to the method is true + /// The parameter passed to the delegate is true /// if the send has successfully done; otherwise, false. /// /// From 9c2669c828613a1b81319e6e367f3fa80671e2c7 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 18 Jun 2024 20:33:25 +0900 Subject: [PATCH 5650/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index d2e2cc8b4..4c2f6a68c 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -1320,6 +1320,12 @@ protected void SendAsync (FileInfo fileInfo, Action completed) /// if not necessary. /// /// + /// + /// could not be UTF-8-encoded. + /// + /// + /// is . + /// /// /// /// The session has not started yet. @@ -1331,12 +1337,6 @@ protected void SendAsync (FileInfo fileInfo, Action completed) /// The current state of the WebSocket interface is not Open. /// /// - /// - /// is . - /// - /// - /// could not be UTF-8-encoded. - /// protected void SendAsync (string data, Action completed) { if (_websocket == null) { From fb88f55a04788f347b5178bba332d6fc0c854802 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 18 Jun 2024 20:36:27 +0900 Subject: [PATCH 5651/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 4c2f6a68c..712bf3cea 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -1310,10 +1310,10 @@ protected void SendAsync (FileInfo fileInfo, Action completed) /// An delegate. /// /// - /// The delegate invokes the method called when the send is complete. + /// It specifies the delegate called when the send is complete. /// /// - /// The parameter passed to the method is true + /// The parameter passed to the delegate is true /// if the send has successfully done; otherwise, false. /// /// From a5dbe37d6b0bf20676d519a0c3622fc05a74a5c8 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 19 Jun 2024 20:36:41 +0900 Subject: [PATCH 5652/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 712bf3cea..aad9b925b 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -1260,29 +1260,29 @@ protected void SendAsync (byte[] data, Action completed) /// if not necessary. /// /// - /// + /// /// - /// The session has not started yet. + /// The file does not exist. /// /// /// -or- /// /// - /// The current state of the WebSocket interface is not Open. + /// The file could not be opened. /// /// /// /// is . /// - /// + /// /// - /// The file does not exist. + /// The session has not started yet. /// /// /// -or- /// /// - /// The file could not be opened. + /// The current state of the WebSocket interface is not Open. /// /// protected void SendAsync (FileInfo fileInfo, Action completed) From 7b2b50cd53ed97547ae171fc173ddf74a61800df Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 19 Jun 2024 20:40:47 +0900 Subject: [PATCH 5653/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index aad9b925b..6e0cedc14 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -1250,10 +1250,10 @@ protected void SendAsync (byte[] data, Action completed) /// An delegate. /// /// - /// The delegate invokes the method called when the send is complete. + /// It specifies the delegate called when the send is complete. /// /// - /// The parameter passed to the method is true + /// The parameter passed to the delegate is true /// if the send has successfully done; otherwise, false. /// /// From 44cbd0ca8da8712e3597a50b0d6b27ed00c9a84c Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 20 Jun 2024 20:39:06 +0900 Subject: [PATCH 5654/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 6e0cedc14..54cca9f4c 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -1206,6 +1206,9 @@ protected void Send (Stream stream, int length) /// if not necessary. /// /// + /// + /// is . + /// /// /// /// The session has not started yet. @@ -1217,9 +1220,6 @@ protected void Send (Stream stream, int length) /// The current state of the WebSocket interface is not Open. /// /// - /// - /// is . - /// protected void SendAsync (byte[] data, Action completed) { if (_websocket == null) { From 0ae2713dec5c704dd1b5518f7060a6822202e66a Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 20 Jun 2024 20:42:36 +0900 Subject: [PATCH 5655/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 54cca9f4c..fc4c9aacd 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -1196,10 +1196,10 @@ protected void Send (Stream stream, int length) /// An delegate. /// /// - /// The delegate invokes the method called when the send is complete. + /// It specifies the delegate called when the send is complete. /// /// - /// The parameter passed to the method is true + /// The parameter passed to the delegate is true /// if the send has successfully done; otherwise, false. /// /// From 09dda40217fffe813b8149226306af014ae0f144 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 21 Jun 2024 21:31:50 +0900 Subject: [PATCH 5656/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 24 ++++++++++----------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index fc4c9aacd..520efad89 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -1140,35 +1140,35 @@ protected void Send (string data) /// /// An that specifies the number of bytes to send. /// - /// + /// /// - /// The session has not started yet. + /// cannot be read. /// /// /// -or- /// /// - /// The current state of the WebSocket interface is not Open. + /// is less than 1. /// - /// - /// - /// is . - /// - /// /// - /// cannot be read. + /// -or- /// /// - /// -or- + /// No data could be read from . /// + /// + /// + /// is . + /// + /// /// - /// is less than 1. + /// The session has not started yet. /// /// /// -or- /// /// - /// No data could be read from . + /// The current state of the WebSocket interface is not Open. /// /// protected void Send (Stream stream, int length) From d9b46745fcf0efbeecf2d22004263e47756b2181 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 22 Jun 2024 21:06:03 +0900 Subject: [PATCH 5657/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 520efad89..d3dfd7333 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -1097,6 +1097,12 @@ protected void Send (FileInfo fileInfo) /// /// A that specifies the text data to send. /// + /// + /// could not be UTF-8-encoded. + /// + /// + /// is . + /// /// /// /// The session has not started yet. @@ -1108,12 +1114,6 @@ protected void Send (FileInfo fileInfo) /// The current state of the WebSocket interface is not Open. /// /// - /// - /// is . - /// - /// - /// could not be UTF-8-encoded. - /// protected void Send (string data) { if (_websocket == null) { From b439b42ba050b0392fc4900691f59fbc9f205271 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 23 Jun 2024 21:17:06 +0900 Subject: [PATCH 5658/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index d3dfd7333..ecfd4a790 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -1055,29 +1055,29 @@ protected void Send (byte[] data) /// The file is sent as the binary data. /// /// - /// + /// /// - /// The session has not started yet. + /// The file does not exist. /// /// /// -or- /// /// - /// The current state of the WebSocket interface is not Open. + /// The file could not be opened. /// /// /// /// is . /// - /// + /// /// - /// The file does not exist. + /// The session has not started yet. /// /// /// -or- /// /// - /// The file could not be opened. + /// The current state of the WebSocket interface is not Open. /// /// protected void Send (FileInfo fileInfo) From 2612d51ee781d58f0b778afe5888af2c431ac48a Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 24 Jun 2024 21:26:19 +0900 Subject: [PATCH 5659/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index ecfd4a790..db3add507 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -1019,6 +1019,9 @@ protected bool Ping (string message) /// /// An array of that specifies the binary data to send. /// + /// + /// is . + /// /// /// /// The session has not started yet. @@ -1030,9 +1033,6 @@ protected bool Ping (string message) /// The current state of the WebSocket interface is not Open. /// /// - /// - /// is . - /// protected void Send (byte[] data) { if (_websocket == null) { From 259f70d77dc0603605bfc6214b20ad3d40f2425c Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 25 Jun 2024 21:00:01 +0900 Subject: [PATCH 5660/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index db3add507..c27332f8f 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -993,15 +993,15 @@ protected bool Ping () /// Its size must be 125 bytes or less in UTF-8. /// /// - /// - /// The session has not started yet. - /// /// /// could not be UTF-8-encoded. /// /// /// The size of is greater than 125 bytes. /// + /// + /// The session has not started yet. + /// protected bool Ping (string message) { if (_websocket == null) { From 79e751cb10432ca9100501c0491a6cba361c5037 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 26 Jun 2024 20:41:43 +0900 Subject: [PATCH 5661/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index c27332f8f..005cfba45 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -882,9 +882,6 @@ protected void CloseAsync (ushort code, string reason) /// Its size must be 123 bytes or less in UTF-8. /// /// - /// - /// The session has not started yet. - /// /// /// /// is . @@ -906,6 +903,9 @@ protected void CloseAsync (ushort code, string reason) /// /// The size of is greater than 123 bytes. /// + /// + /// The session has not started yet. + /// protected void CloseAsync (CloseStatusCode code, string reason) { if (_websocket == null) { From 9e0d7807249876b5e37c6d21b3efe5d189dc88c4 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 27 Jun 2024 20:35:43 +0900 Subject: [PATCH 5662/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 26 ++++++++++----------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 005cfba45..8de1b4f06 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -810,38 +810,38 @@ protected void CloseAsync () /// Its size must be 123 bytes or less in UTF-8. /// /// - /// - /// The session has not started yet. - /// - /// + /// /// - /// is less than 1000 or greater than 4999. + /// is 1010 (mandatory extension). /// /// /// -or- /// /// - /// The size of is greater than 123 bytes. + /// is 1005 (no status) and + /// is specified. /// - /// - /// /// - /// is 1010 (mandatory extension). + /// -or- /// /// - /// -or- + /// could not be UTF-8-encoded. /// + /// + /// /// - /// is 1005 (no status) and - /// is specified. + /// is less than 1000 or greater than 4999. /// /// /// -or- /// /// - /// could not be UTF-8-encoded. + /// The size of is greater than 123 bytes. /// /// + /// + /// The session has not started yet. + /// protected void CloseAsync (ushort code, string reason) { if (_websocket == null) { From 1898bef3bcbac63b3497b88ebcad6045998617be Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 28 Jun 2024 21:19:24 +0900 Subject: [PATCH 5663/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 8de1b4f06..895ff037a 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -717,9 +717,6 @@ protected void Close (ushort code, string reason) /// Its size must be 123 bytes or less in UTF-8. /// /// - /// - /// The session has not started yet. - /// /// /// /// is . @@ -741,6 +738,9 @@ protected void Close (ushort code, string reason) /// /// The size of is greater than 123 bytes. /// + /// + /// The session has not started yet. + /// protected void Close (CloseStatusCode code, string reason) { if (_websocket == null) { From 559c4c10168bbe657c9b234e3237dbd701bbf9bc Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 29 Jun 2024 22:04:44 +0900 Subject: [PATCH 5664/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 26 ++++++++++----------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 895ff037a..e9a6d7bee 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -650,38 +650,38 @@ protected void Close () /// Its size must be 123 bytes or less in UTF-8. /// /// - /// - /// The session has not started yet. - /// - /// + /// /// - /// is less than 1000 or greater than 4999. + /// is 1010 (mandatory extension). /// /// /// -or- /// /// - /// The size of is greater than 123 bytes. + /// is 1005 (no status) and + /// is specified. /// - /// - /// /// - /// is 1010 (mandatory extension). + /// -or- /// /// - /// -or- + /// could not be UTF-8-encoded. /// + /// + /// /// - /// is 1005 (no status) and - /// is specified. + /// is less than 1000 or greater than 4999. /// /// /// -or- /// /// - /// could not be UTF-8-encoded. + /// The size of is greater than 123 bytes. /// /// + /// + /// The session has not started yet. + /// protected void Close (ushort code, string reason) { if (_websocket == null) { From 7240536b74bfae4f4d92803c6535a9b37e8efbc2 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 30 Jun 2024 21:01:14 +0900 Subject: [PATCH 5665/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketBehavior.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index e9a6d7bee..d71932859 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -573,7 +573,8 @@ private void onOpen (object sender, EventArgs e) #region Internal Methods internal void Start ( - WebSocketContext context, WebSocketSessionManager sessions + WebSocketContext context, + WebSocketSessionManager sessions ) { _context = context; From 1f627f4f10737d6f63be78b377512996a56762e0 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 1 Jul 2024 21:25:10 +0900 Subject: [PATCH 5666/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index d71932859..005c0f8c9 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -443,12 +443,12 @@ public Func OriginValidator { /// The default value is an empty string. /// /// - /// - /// The set operation is not available if the session has already started. - /// /// /// The value specified for a set operation is not a token. /// + /// + /// The set operation is not available if the session has already started. + /// public string Protocol { get { return _websocket != null From 079c765c055b6a7761cd2d0f6d3f1158e8099243 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 2 Jul 2024 20:48:08 +0900 Subject: [PATCH 5667/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 005c0f8c9..0d9ce88a1 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -399,16 +399,17 @@ public bool IgnoreExtensions { /// A delegate. /// /// - /// The delegate invokes the method called when the WebSocket interface + /// It represents the delegate called when the WebSocket interface /// for a session validates the handshake request. /// /// - /// The parameter passed to the method is the value - /// of the Origin header or if the header is not - /// present. + /// The parameter passed to the delegate is + /// the value of the Origin header or if + /// the header is not present. /// /// - /// The method must return true if the header value is valid. + /// The method invoked by the delegate must return true + /// if the header value is valid. /// /// /// if not necessary. From 2625210941b901924db32071b9bff5d1fa67560a Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 3 Jul 2024 20:39:57 +0900 Subject: [PATCH 5668/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 0d9ce88a1..ab6d71095 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -324,15 +324,16 @@ public bool EmitOnPing { /// A delegate. /// /// - /// The delegate invokes the method called when the WebSocket interface + /// It represents the delegate called when the WebSocket interface /// for a session validates the handshake request. /// /// - /// The parameter passed to the method is the value - /// of the Host header. + /// The parameter passed to the delegate is + /// the value of the Host header. /// /// - /// The method must return true if the header value is valid. + /// The method invoked by the delegate must return true + /// if the header value is valid. /// /// /// if not necessary. From 5f003ebd33afb4b64c45854a87076edd0d2dd93e Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 4 Jul 2024 20:45:42 +0900 Subject: [PATCH 5669/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index ab6d71095..b32a4d01d 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -256,19 +256,20 @@ protected System.Net.IPEndPoint UserEndPoint { /// delegate. /// /// - /// The delegate invokes the method called when the WebSocket interface + /// It represents the delegate called when the WebSocket interface /// for a session validates the handshake request. /// /// - /// 1st parameter passed to the method + /// 1st parameter passed to the delegate /// contains the cookies to validate. /// /// - /// 2nd parameter passed to the method + /// 2nd parameter passed to the delegate /// receives the cookies to send to the client. /// /// - /// The method must return true if the cookies are valid. + /// The method invoked by the delegate must return true + /// if the cookies are valid. /// /// /// if not necessary. From 5717a353771b8c20610b0e0c20fdaf1eb41e2070 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 5 Jul 2024 21:31:32 +0900 Subject: [PATCH 5670/6294] [Modify] 2024 --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index b32a4d01d..8f3e9b68d 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -4,7 +4,7 @@ * * The MIT License * - * Copyright (c) 2012-2022 sta.blockhead + * Copyright (c) 2012-2024 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From eca7bbbfcccce426d9b4fe5572b03d4f6f8e5486 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 6 Jul 2024 20:56:53 +0900 Subject: [PATCH 5671/6294] [Modify] Polish it --- websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs b/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs index 7ea153f85..36b0245e5 100644 --- a/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs @@ -50,7 +50,8 @@ public class HttpListenerWebSocketContext : WebSocketContext #region Internal Constructors internal HttpListenerWebSocketContext ( - HttpListenerContext context, string protocol + HttpListenerContext context, + string protocol ) { _context = context; From db7adaeaf8d39d3d6607517fe739499df28bb5d8 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 7 Jul 2024 21:02:34 +0900 Subject: [PATCH 5672/6294] [Modify] Polish it --- websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs b/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs index 36b0245e5..477a7c2ba 100644 --- a/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs @@ -374,6 +374,7 @@ internal void Close () internal void Close (HttpStatusCode code) { _context.Response.StatusCode = (int) code; + _context.Response.Close (); } From 4cdb5a375a7c5b75576cfd66962ec53a68b83be9 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 8 Jul 2024 21:21:28 +0900 Subject: [PATCH 5673/6294] [Modify] 2024 --- websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs b/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs index 477a7c2ba..3410ff62d 100644 --- a/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs @@ -4,7 +4,7 @@ * * The MIT License * - * Copyright (c) 2012-2022 sta.blockhead + * Copyright (c) 2012-2024 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From 7bd3f824d9f493f8b27bfcbe86a601e3cafefa85 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 9 Jul 2024 20:56:43 +0900 Subject: [PATCH 5674/6294] [Modify] Polish it --- websocket-sharp/HttpRequest.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/HttpRequest.cs b/websocket-sharp/HttpRequest.cs index 3b4e4b323..85fb8c510 100644 --- a/websocket-sharp/HttpRequest.cs +++ b/websocket-sharp/HttpRequest.cs @@ -81,9 +81,9 @@ internal HttpRequest (string method, string target) internal string RequestLine { get { - return String.Format ( - "{0} {1} HTTP/{2}{3}", _method, _target, ProtocolVersion, CrLf - ); + var fmt = "{0} {1} HTTP/{2}{3}"; + + return String.Format (fmt, _method, _target, ProtocolVersion, CrLf); } } From bd665ed75f8a6d782b0f1f0fd538ae38fb90476b Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 10 Jul 2024 20:46:19 +0900 Subject: [PATCH 5675/6294] [Modify] Polish it --- websocket-sharp/HttpRequest.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/HttpRequest.cs b/websocket-sharp/HttpRequest.cs index 85fb8c510..7f306c9cf 100644 --- a/websocket-sharp/HttpRequest.cs +++ b/websocket-sharp/HttpRequest.cs @@ -212,7 +212,8 @@ internal static HttpRequest Parse (string[] messageHeader) } internal static HttpRequest ReadRequest ( - Stream stream, int millisecondsTimeout + Stream stream, + int millisecondsTimeout ) { return Read (stream, Parse, millisecondsTimeout); From 40699a3e73664c29f435863858a63adb4383c88f Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 11 Jul 2024 21:42:51 +0900 Subject: [PATCH 5676/6294] [Modify] Polish it --- websocket-sharp/HttpRequest.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/HttpRequest.cs b/websocket-sharp/HttpRequest.cs index 7f306c9cf..789af1566 100644 --- a/websocket-sharp/HttpRequest.cs +++ b/websocket-sharp/HttpRequest.cs @@ -142,9 +142,10 @@ public string RequestTarget { internal static HttpRequest CreateConnectRequest (Uri targetUri) { + var fmt = "{0}:{1}"; var host = targetUri.DnsSafeHost; var port = targetUri.Port; - var authority = String.Format ("{0}:{1}", host, port); + var authority = String.Format (fmt, host, port); var ret = new HttpRequest ("CONNECT", authority); From 3234f7936c684f73082784e50a86602c660611b7 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 12 Jul 2024 21:27:48 +0900 Subject: [PATCH 5677/6294] [Modify] Polish it --- websocket-sharp/HttpRequest.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/HttpRequest.cs b/websocket-sharp/HttpRequest.cs index 789af1566..630b1ae93 100644 --- a/websocket-sharp/HttpRequest.cs +++ b/websocket-sharp/HttpRequest.cs @@ -162,10 +162,10 @@ internal static HttpRequest CreateWebSocketHandshakeRequest (Uri targetUri) var port = targetUri.Port; var schm = targetUri.Scheme; - var defaultPort = (port == 80 && schm == "ws") - || (port == 443 && schm == "wss"); + var isDefaultPort = (port == 80 && schm == "ws") + || (port == 443 && schm == "wss"); - headers["Host"] = !defaultPort + headers["Host"] = !isDefaultPort ? targetUri.Authority : targetUri.DnsSafeHost; From 2db57ac34d07153df776002d6ad144f9f10397b5 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 13 Jul 2024 21:26:59 +0900 Subject: [PATCH 5678/6294] [Modify] 2024 --- websocket-sharp/HttpRequest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/HttpRequest.cs b/websocket-sharp/HttpRequest.cs index 630b1ae93..dd51d0101 100644 --- a/websocket-sharp/HttpRequest.cs +++ b/websocket-sharp/HttpRequest.cs @@ -4,7 +4,7 @@ * * The MIT License * - * Copyright (c) 2012-2022 sta.blockhead + * Copyright (c) 2012-2024 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From c5941eb602e0afe8ee0d47cf1ac275a921687291 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 14 Jul 2024 20:56:23 +0900 Subject: [PATCH 5679/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 8e160f6c0..cea46324a 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1234,7 +1234,8 @@ internal static string Unquote (this string value) } internal static bool Upgrades ( - this NameValueCollection headers, string protocol + this NameValueCollection headers, + string protocol ) { var compType = StringComparison.OrdinalIgnoreCase; From 78e12e3520a228afdefa89d0b7539a5aa32e6712 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 15 Jul 2024 21:13:47 +0900 Subject: [PATCH 5680/6294] [Modify] Polish it --- websocket-sharp/HttpResponse.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/HttpResponse.cs b/websocket-sharp/HttpResponse.cs index 00dccf53f..dac97f990 100644 --- a/websocket-sharp/HttpResponse.cs +++ b/websocket-sharp/HttpResponse.cs @@ -46,7 +46,10 @@ internal class HttpResponse : HttpBase #region Private Constructors private HttpResponse ( - int code, string reason, Version version, NameValueCollection headers + int code, + string reason, + Version version, + NameValueCollection headers ) : base (version, headers) { From fade916f52d175c9d3d4f6362c97f88ad574f66f Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 16 Jul 2024 20:43:09 +0900 Subject: [PATCH 5681/6294] [Modify] Polish it --- websocket-sharp/HttpResponse.cs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/HttpResponse.cs b/websocket-sharp/HttpResponse.cs index dac97f990..48c19cb51 100644 --- a/websocket-sharp/HttpResponse.cs +++ b/websocket-sharp/HttpResponse.cs @@ -95,10 +95,17 @@ internal string StatusLine { get { return _reason != null ? String.Format ( - "HTTP/{0} {1} {2}{3}", ProtocolVersion, _code, _reason, CrLf + "HTTP/{0} {1} {2}{3}", + ProtocolVersion, + _code, + _reason, + CrLf ) : String.Format ( - "HTTP/{0} {1}{2}", ProtocolVersion, _code, CrLf + "HTTP/{0} {1}{2}", + ProtocolVersion, + _code, + CrLf ); } } From 8cf22d6708613b4a143aa76b00995b12e2a49fc2 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 17 Jul 2024 20:45:08 +0900 Subject: [PATCH 5682/6294] [Modify] Polish it --- websocket-sharp/HttpResponse.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/HttpResponse.cs b/websocket-sharp/HttpResponse.cs index 48c19cb51..1793f0bc6 100644 --- a/websocket-sharp/HttpResponse.cs +++ b/websocket-sharp/HttpResponse.cs @@ -244,7 +244,8 @@ internal static HttpResponse Parse (string[] messageHeader) } internal static HttpResponse ReadResponse ( - Stream stream, int millisecondsTimeout + Stream stream, + int millisecondsTimeout ) { return Read (stream, Parse, millisecondsTimeout); From 92415c9aa9130a9281c236ae0a248d39ec7bebae Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 18 Jul 2024 20:56:29 +0900 Subject: [PATCH 5683/6294] [Modify] 2024 --- websocket-sharp/HttpResponse.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/HttpResponse.cs b/websocket-sharp/HttpResponse.cs index 1793f0bc6..fb2f9d312 100644 --- a/websocket-sharp/HttpResponse.cs +++ b/websocket-sharp/HttpResponse.cs @@ -4,7 +4,7 @@ * * The MIT License * - * Copyright (c) 2012-2022 sta.blockhead + * Copyright (c) 2012-2024 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From 2606dee946e6edf17fb072588a4ee5391125d4f0 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 19 Jul 2024 21:37:02 +0900 Subject: [PATCH 5684/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index cea46324a..cfdc8633f 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -227,7 +227,8 @@ internal static bool Contains (this string value, params char[] anyOf) } internal static bool Contains ( - this NameValueCollection collection, string name + this NameValueCollection collection, + string name ) { return collection[name] != null; From 24ac03047f42a8c755806d8cae0a5ce85321b2eb Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 20 Jul 2024 21:10:01 +0900 Subject: [PATCH 5685/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index cfdc8633f..c54585ae6 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -255,7 +255,8 @@ StringComparison comparisonTypeForValue } internal static bool Contains ( - this IEnumerable source, Func condition + this IEnumerable source, + Func condition ) { foreach (T elm in source) { From f0e417fd14637a332b1be4d22a13161195115876 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 21 Jul 2024 21:33:55 +0900 Subject: [PATCH 5686/6294] [Modify] Polish it --- websocket-sharp/HttpBase.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/HttpBase.cs b/websocket-sharp/HttpBase.cs index a6842f929..b42336121 100644 --- a/websocket-sharp/HttpBase.cs +++ b/websocket-sharp/HttpBase.cs @@ -236,7 +236,10 @@ internal void WriteTo (Stream stream) #region Protected Methods protected static T Read ( - Stream stream, Func parser, int millisecondsTimeout + Stream stream, + Func parser, + int millisecondsTimeout ) where T : HttpBase { From 1e1ac97f723bf1ee65fe38f699a880a8dfe9b06e Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 21 Jul 2024 21:36:17 +0900 Subject: [PATCH 5687/6294] [Modify] Polish it --- websocket-sharp/HttpBase.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/websocket-sharp/HttpBase.cs b/websocket-sharp/HttpBase.cs index b42336121..248b8427e 100644 --- a/websocket-sharp/HttpBase.cs +++ b/websocket-sharp/HttpBase.cs @@ -237,8 +237,7 @@ internal void WriteTo (Stream stream) protected static T Read ( Stream stream, - Func parser, + Func parser, int millisecondsTimeout ) where T : HttpBase From db77353f3d68208114f15a774ce00caaaa396a52 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 22 Jul 2024 21:28:25 +0900 Subject: [PATCH 5688/6294] [Modify] Polish it --- websocket-sharp/HttpBase.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/HttpBase.cs b/websocket-sharp/HttpBase.cs index 248b8427e..056179242 100644 --- a/websocket-sharp/HttpBase.cs +++ b/websocket-sharp/HttpBase.cs @@ -167,7 +167,7 @@ private static byte[] readMessageBodyFrom (Stream stream, string length) } if (len < 0) { - var msg = "It is less than zero."; + var msg = "Less than zero."; throw new ArgumentOutOfRangeException ("length", msg); } From 3fb34be46727400ee9f09bc8ce3229750e3ef160 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 23 Jul 2024 21:30:17 +0900 Subject: [PATCH 5689/6294] [Modify] Polish it --- websocket-sharp/HttpBase.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/HttpBase.cs b/websocket-sharp/HttpBase.cs index 056179242..0dbffe022 100644 --- a/websocket-sharp/HttpBase.cs +++ b/websocket-sharp/HttpBase.cs @@ -161,7 +161,7 @@ private static byte[] readMessageBodyFrom (Stream stream, string length) long len; if (!Int64.TryParse (length, out len)) { - var msg = "It cannot be parsed."; + var msg = "It could not be parsed."; throw new ArgumentException (msg, "length"); } From 1570289ec5789a78a1cfd6217d01babf72e90aed Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 24 Jul 2024 20:59:27 +0900 Subject: [PATCH 5690/6294] [Modify] Polish it --- websocket-sharp/HttpBase.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/HttpBase.cs b/websocket-sharp/HttpBase.cs index 0dbffe022..cd95e10a8 100644 --- a/websocket-sharp/HttpBase.cs +++ b/websocket-sharp/HttpBase.cs @@ -96,8 +96,10 @@ protected string HeaderSection { get { var buff = new StringBuilder (64); + var fmt = "{0}: {1}{2}"; + foreach (var key in _headers.AllKeys) - buff.AppendFormat ("{0}: {1}{2}", key, _headers[key], CrLf); + buff.AppendFormat (fmt, key, _headers[key], CrLf); buff.Append (CrLf); From ae2b4f355d4358ca472bf028e3b58845dedad2df Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 25 Jul 2024 21:27:53 +0900 Subject: [PATCH 5691/6294] [Modify] 2024 --- websocket-sharp/HttpBase.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/HttpBase.cs b/websocket-sharp/HttpBase.cs index cd95e10a8..c53957860 100644 --- a/websocket-sharp/HttpBase.cs +++ b/websocket-sharp/HttpBase.cs @@ -4,7 +4,7 @@ * * The MIT License * - * Copyright (c) 2012-2022 sta.blockhead + * Copyright (c) 2012-2024 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From 38d5285bcbc6a902d8a0a7096e66151de66c55ea Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 26 Jul 2024 21:45:47 +0900 Subject: [PATCH 5692/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index c54585ae6..df99bf49b 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -537,7 +537,9 @@ internal static bool IsCompressionExtension ( } internal static bool IsEqualTo ( - this int value, char c, Action beforeComparing + this int value, + char c, + Action beforeComparing ) { beforeComparing (value); From a0f33804ced85bba28c31537d28be3f6ccedec7d Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 27 Jul 2024 21:29:50 +0900 Subject: [PATCH 5693/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index df99bf49b..03ec2bcaf 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -692,7 +692,9 @@ internal static byte[] ReadBytes (this Stream stream, int length) } internal static byte[] ReadBytes ( - this Stream stream, long length, int bufferLength + this Stream stream, + long length, + int bufferLength ) { using (var dest = new MemoryStream ()) { From 37f3891b985927772af51b198d4f53d3a4e0a49b Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 28 Jul 2024 21:20:32 +0900 Subject: [PATCH 5694/6294] [Modify] Polish it --- websocket-sharp/HttpBase.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/HttpBase.cs b/websocket-sharp/HttpBase.cs index c53957860..c4a244f45 100644 --- a/websocket-sharp/HttpBase.cs +++ b/websocket-sharp/HttpBase.cs @@ -250,6 +250,7 @@ int millisecondsTimeout var timer = new Timer ( state => { timeout = true; + stream.Close (); }, null, From 58ee95085d52bddfc416afaa783e50e767f1034f Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 29 Jul 2024 21:52:23 +0900 Subject: [PATCH 5695/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 03ec2bcaf..ac36994f2 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -832,6 +832,7 @@ Action error dest.Close (); var ret = dest.ToArray (); + completed (ret); } @@ -845,8 +846,9 @@ Action error if (nread == len) { if (completed != null) { dest.Close (); - + var ret = dest.ToArray (); + completed (ret); } From 37a765f45cbf8665f2a56a192a8a39c0c048e795 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 30 Jul 2024 21:44:18 +0900 Subject: [PATCH 5696/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index ac36994f2..44f6cd98d 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -632,7 +632,8 @@ internal static bool IsToken (this string value) } internal static bool KeepsAlive ( - this NameValueCollection headers, Version version + this NameValueCollection headers, + Version version ) { var compType = StringComparison.OrdinalIgnoreCase; From a28b8d15e76b58eb458ef3af595b48c533254db3 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 31 Jul 2024 21:23:57 +0900 Subject: [PATCH 5697/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 44f6cd98d..15b8133fd 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -638,9 +638,9 @@ Version version { var compType = StringComparison.OrdinalIgnoreCase; - return version < HttpVersion.Version11 - ? headers.Contains ("Connection", "keep-alive", compType) - : !headers.Contains ("Connection", "close", compType); + return version > HttpVersion.Version10 + ? !headers.Contains ("Connection", "close", compType) + : headers.Contains ("Connection", "keep-alive", compType); } internal static bool MaybeUri (this string value) From 94c9f7f672fa0d024e56d6bcd7e53ef044775404 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 1 Aug 2024 20:52:03 +0900 Subject: [PATCH 5698/6294] [Modify] Edit it --- websocket-sharp/Net/HttpVersion.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpVersion.cs b/websocket-sharp/Net/HttpVersion.cs index d20061e0b..7127b2dff 100644 --- a/websocket-sharp/Net/HttpVersion.cs +++ b/websocket-sharp/Net/HttpVersion.cs @@ -2,7 +2,7 @@ /* * HttpVersion.cs * - * This code is derived from System.Net.HttpVersion.cs of Mono + * This code is derived from HttpVersion.cs (System.Net) of Mono * (http://www.mono-project.com). * * The MIT License From 46f3429933132f90de09d76e767728c547570f65 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 2 Aug 2024 21:33:53 +0900 Subject: [PATCH 5699/6294] [Modify] 2024 --- websocket-sharp/Net/HttpVersion.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpVersion.cs b/websocket-sharp/Net/HttpVersion.cs index 7127b2dff..95f8f0a38 100644 --- a/websocket-sharp/Net/HttpVersion.cs +++ b/websocket-sharp/Net/HttpVersion.cs @@ -7,7 +7,7 @@ * * The MIT License * - * Copyright (c) 2012-2014 sta.blockhead + * Copyright (c) 2012-2024 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From 6546afdba1ea48d7f6e8b757a4f94d0a07c39db8 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 3 Aug 2024 23:02:43 +0900 Subject: [PATCH 5700/6294] [Modify] Polish it --- websocket-sharp/Net/Cookie.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/Cookie.cs b/websocket-sharp/Net/Cookie.cs index 0f79ddf88..ae13fcb85 100644 --- a/websocket-sharp/Net/Cookie.cs +++ b/websocket-sharp/Net/Cookie.cs @@ -943,7 +943,9 @@ internal string ToResponseString () } internal static bool TryCreate ( - string name, string value, out Cookie result + string name, + string value, + out Cookie result ) { result = null; From 5e68d74fcb445d323f54ea35fb52d0d27bc585b6 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 4 Aug 2024 11:38:48 +0900 Subject: [PATCH 5701/6294] [Modify] Edit it --- websocket-sharp/Net/Cookie.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/Cookie.cs b/websocket-sharp/Net/Cookie.cs index ae13fcb85..b4dcede54 100644 --- a/websocket-sharp/Net/Cookie.cs +++ b/websocket-sharp/Net/Cookie.cs @@ -143,9 +143,6 @@ internal Cookie () /// /// A that specifies the value of the cookie. /// - /// - /// is . - /// /// /// /// is an empty string. @@ -170,6 +167,9 @@ internal Cookie () /// although it contains a reserved character. /// /// + /// + /// is . + /// public Cookie (string name, string value) : this (name, value, String.Empty, String.Empty) { From f2f40ac369fd70145ef042864b0ac4459e207f39 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 5 Aug 2024 21:26:53 +0900 Subject: [PATCH 5702/6294] [Modify] Edit it --- websocket-sharp/Net/Cookie.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/Cookie.cs b/websocket-sharp/Net/Cookie.cs index b4dcede54..c23da7c4f 100644 --- a/websocket-sharp/Net/Cookie.cs +++ b/websocket-sharp/Net/Cookie.cs @@ -196,9 +196,6 @@ public Cookie (string name, string value) /// A that specifies the value of the Path /// attribute of the cookie. /// - /// - /// is . - /// /// /// /// is an empty string. @@ -223,6 +220,9 @@ public Cookie (string name, string value) /// although it contains a reserved character. /// /// + /// + /// is . + /// public Cookie (string name, string value, string path) : this (name, value, path, String.Empty) { From e59973150b83e1471f3dc9718eeae1f8ce2e096a Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 6 Aug 2024 21:21:23 +0900 Subject: [PATCH 5703/6294] [Modify] Edit it --- websocket-sharp/Net/Cookie.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/Cookie.cs b/websocket-sharp/Net/Cookie.cs index c23da7c4f..84e69ea71 100644 --- a/websocket-sharp/Net/Cookie.cs +++ b/websocket-sharp/Net/Cookie.cs @@ -253,9 +253,6 @@ public Cookie (string name, string value, string path) /// A that specifies the value of the Domain /// attribute of the cookie. /// - /// - /// is . - /// /// /// /// is an empty string. @@ -280,6 +277,9 @@ public Cookie (string name, string value, string path) /// although it contains a reserved character. /// /// + /// + /// is . + /// public Cookie (string name, string value, string path, string domain) { if (name == null) From e88b24173f98166937d4db832bbfed332e3d0b79 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 7 Aug 2024 21:43:49 +0900 Subject: [PATCH 5704/6294] [Modify] Edit it --- websocket-sharp/Net/Cookie.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/Cookie.cs b/websocket-sharp/Net/Cookie.cs index 84e69ea71..07c4a8ee4 100644 --- a/websocket-sharp/Net/Cookie.cs +++ b/websocket-sharp/Net/Cookie.cs @@ -544,9 +544,6 @@ public bool HttpOnly { /// RFC 2616. /// /// - /// - /// The value specified for a set operation is . - /// /// /// /// The value specified for a set operation is an empty string. @@ -564,6 +561,9 @@ public bool HttpOnly { /// The value specified for a set operation contains an invalid character. /// /// + /// + /// The value specified for a set operation is . + /// public string Name { get { return _name; From 54dc7ed5fa4d85291d58f728125b4ee52135cccc Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 8 Aug 2024 21:21:20 +0900 Subject: [PATCH 5705/6294] [Modify] Polish it --- websocket-sharp/Net/Cookie.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/Cookie.cs b/websocket-sharp/Net/Cookie.cs index 07c4a8ee4..5ae078a14 100644 --- a/websocket-sharp/Net/Cookie.cs +++ b/websocket-sharp/Net/Cookie.cs @@ -833,7 +833,8 @@ private string toResponseStringVersion1 () var url = _commentUri.OriginalString; buff.AppendFormat ( - "; CommentURL={0}", !url.IsToken () ? url.Quote () : url + "; CommentURL={0}", + !url.IsToken () ? url.Quote () : url ); } From 3424ce46dad3f330801228a8540416a4a4049dd7 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 9 Aug 2024 21:47:58 +0900 Subject: [PATCH 5706/6294] [Modify] 2024 --- websocket-sharp/Net/Cookie.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/Cookie.cs b/websocket-sharp/Net/Cookie.cs index 5ae078a14..149b5041e 100644 --- a/websocket-sharp/Net/Cookie.cs +++ b/websocket-sharp/Net/Cookie.cs @@ -8,7 +8,7 @@ * The MIT License * * Copyright (c) 2004,2009 Novell, Inc. (http://www.novell.com) - * Copyright (c) 2012-2023 sta.blockhead + * Copyright (c) 2012-2024 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From 9fcc41cbd0e9a1437e299a3d65f95a363fba5c5b Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 10 Aug 2024 16:18:56 +0900 Subject: [PATCH 5707/6294] [Modify] Edit it --- websocket-sharp/Net/CookieCollection.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/CookieCollection.cs b/websocket-sharp/Net/CookieCollection.cs index df3491b31..f0b0e2bec 100644 --- a/websocket-sharp/Net/CookieCollection.cs +++ b/websocket-sharp/Net/CookieCollection.cs @@ -676,12 +676,12 @@ internal void Sort () /// /// A to add. /// - /// - /// The collection is read-only. - /// /// /// is . /// + /// + /// The collection is read-only. + /// public void Add (Cookie cookie) { if (_readOnly) { From 0b051f4840cfdc4619abf4d11a9650bf94130109 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 11 Aug 2024 21:35:06 +0900 Subject: [PATCH 5708/6294] [Modify] Edit it --- websocket-sharp/Net/CookieCollection.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/CookieCollection.cs b/websocket-sharp/Net/CookieCollection.cs index f0b0e2bec..1bb409ffe 100644 --- a/websocket-sharp/Net/CookieCollection.cs +++ b/websocket-sharp/Net/CookieCollection.cs @@ -702,12 +702,12 @@ public void Add (Cookie cookie) /// /// A that contains the cookies to add. /// - /// - /// The collection is read-only. - /// /// /// is . /// + /// + /// The collection is read-only. + /// public void Add (CookieCollection cookies) { if (_readOnly) { From 2dad6e6715b4e632fc816bcfa195400f3a10bf5b Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 12 Aug 2024 21:43:53 +0900 Subject: [PATCH 5709/6294] [Modify] Edit it --- websocket-sharp/Net/CookieCollection.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/CookieCollection.cs b/websocket-sharp/Net/CookieCollection.cs index 1bb409ffe..7b92c2059 100644 --- a/websocket-sharp/Net/CookieCollection.cs +++ b/websocket-sharp/Net/CookieCollection.cs @@ -773,16 +773,16 @@ public bool Contains (Cookie cookie) /// An that specifies the zero-based index in /// the array at which copying starts. /// + /// + /// The space from to the end of + /// is not enough to copy to. + /// /// /// is . /// /// /// is less than zero. /// - /// - /// The space from to the end of - /// is not enough to copy to. - /// public void CopyTo (Cookie[] array, int index) { if (array == null) From 16c0224f60e9619e1f17f79349103c6d2bf8a6bd Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 13 Aug 2024 21:35:29 +0900 Subject: [PATCH 5710/6294] [Modify] Edit it --- websocket-sharp/Net/CookieCollection.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/CookieCollection.cs b/websocket-sharp/Net/CookieCollection.cs index 7b92c2059..fd8bc2d14 100644 --- a/websocket-sharp/Net/CookieCollection.cs +++ b/websocket-sharp/Net/CookieCollection.cs @@ -830,12 +830,12 @@ public IEnumerator GetEnumerator () /// /// A to remove. /// - /// - /// The collection is read-only. - /// /// /// is . /// + /// + /// The collection is read-only. + /// public bool Remove (Cookie cookie) { if (_readOnly) { From c61dca5fc3cb53311071690e3d7d8e1ea83965b8 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 14 Aug 2024 20:49:25 +0900 Subject: [PATCH 5711/6294] [Modify] Polish it --- websocket-sharp/Net/CookieCollection.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/CookieCollection.cs b/websocket-sharp/Net/CookieCollection.cs index fd8bc2d14..de2f9c157 100644 --- a/websocket-sharp/Net/CookieCollection.cs +++ b/websocket-sharp/Net/CookieCollection.cs @@ -479,7 +479,11 @@ private static CookieCollection parseResponse (string value) DateTime expires; var done = DateTime.TryParseExact ( - s, fmts, provider, style, out expires + s, + fmts, + provider, + style, + out expires ); if (!done) From e3d7d8f6b80ec50bf03240a5d0bab737986b3179 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 15 Aug 2024 21:47:14 +0900 Subject: [PATCH 5712/6294] [Modify] 2024 --- websocket-sharp/Net/CookieCollection.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/CookieCollection.cs b/websocket-sharp/Net/CookieCollection.cs index de2f9c157..9a8ce641b 100644 --- a/websocket-sharp/Net/CookieCollection.cs +++ b/websocket-sharp/Net/CookieCollection.cs @@ -8,7 +8,7 @@ * The MIT License * * Copyright (c) 2004,2009 Novell, Inc. (http://www.novell.com) - * Copyright (c) 2012-2023 sta.blockhead + * Copyright (c) 2012-2024 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From a5b35b51fe2a3c41765ad8899f65327c32ea0819 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 16 Aug 2024 21:37:45 +0900 Subject: [PATCH 5713/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 15b8133fd..d7605d9a1 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -202,12 +202,11 @@ internal static byte[] Append (this ushort code, string reason) } internal static byte[] Compress ( - this byte[] data, CompressionMethod method + this byte[] data, + CompressionMethod method ) { - return method == CompressionMethod.Deflate - ? data.compress () - : data; + return method == CompressionMethod.Deflate ? data.compress () : data; } internal static Stream Compress ( From 2cf68839e8b64eecbcbb3ec9af8c28e02cf3696f Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 16 Aug 2024 21:40:10 +0900 Subject: [PATCH 5714/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index d7605d9a1..9166f1416 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -210,12 +210,11 @@ CompressionMethod method } internal static Stream Compress ( - this Stream stream, CompressionMethod method + this Stream stream, + CompressionMethod method ) { - return method == CompressionMethod.Deflate - ? stream.compress () - : stream; + return method == CompressionMethod.Deflate ? stream.compress () : stream; } internal static bool Contains (this string value, params char[] anyOf) From 69da4e324ce5871fe24ba0a61f6966b29954fa42 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 17 Aug 2024 21:23:30 +0900 Subject: [PATCH 5715/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 9166f1416..db36f5b34 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -307,7 +307,9 @@ internal static T[] Copy (this T[] sourceArray, long length) } internal static void CopyTo ( - this Stream sourceStream, Stream destinationStream, int bufferLength + this Stream sourceStream, + Stream destinationStream, + int bufferLength ) { var buff = new byte[bufferLength]; From 79db8b5681813d9eab727321b3880159aeb4a61d Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 18 Aug 2024 21:18:40 +0900 Subject: [PATCH 5716/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index db36f5b34..624361232 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -367,12 +367,11 @@ Action error } internal static byte[] Decompress ( - this byte[] data, CompressionMethod method + this byte[] data, + CompressionMethod method ) { - return method == CompressionMethod.Deflate - ? data.decompress () - : data; + return method == CompressionMethod.Deflate ? data.decompress () : data; } internal static Stream Decompress ( From 0e8023ef82f3cfa6e10ad129e007685cbbc784c0 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 18 Aug 2024 21:21:39 +0900 Subject: [PATCH 5717/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 624361232..e9bd302c2 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -375,7 +375,8 @@ CompressionMethod method } internal static Stream Decompress ( - this Stream stream, CompressionMethod method + this Stream stream, + CompressionMethod method ) { return method == CompressionMethod.Deflate From c46b5fe28f4b2cede04453a07d2865c12d638b5d Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 19 Aug 2024 21:36:46 +0900 Subject: [PATCH 5718/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index e9bd302c2..fd55f31ee 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -385,7 +385,8 @@ CompressionMethod method } internal static byte[] DecompressToArray ( - this Stream stream, CompressionMethod method + this Stream stream, + CompressionMethod method ) { return method == CompressionMethod.Deflate From 2b61bd415a3df5013a5a3b5af862ea7a41af95cf Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 20 Aug 2024 21:33:18 +0900 Subject: [PATCH 5719/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index fd55f31ee..edf9086b1 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -395,7 +395,9 @@ CompressionMethod method } internal static void Emit ( - this EventHandler eventHandler, object sender, EventArgs e + this EventHandler eventHandler, + object sender, + EventArgs e ) { if (eventHandler == null) From 2ba866e7fb10cfd536aaaeca1f3b7de2716788df Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 20 Aug 2024 21:34:40 +0900 Subject: [PATCH 5720/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index edf9086b1..b7a526adf 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -407,7 +407,9 @@ EventArgs e } internal static void Emit ( - this EventHandler eventHandler, object sender, TEventArgs e + this EventHandler eventHandler, + object sender, + TEventArgs e ) where TEventArgs : EventArgs { From 3ebcb81214375788f4d56ac17e138046b3ebdd55 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 21 Aug 2024 21:32:01 +0900 Subject: [PATCH 5721/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index b7a526adf..ba4f18823 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -518,7 +518,9 @@ internal static string GetValue (this string nameAndValue, char separator) } internal static string GetValue ( - this string nameAndValue, char separator, bool unquote + this string nameAndValue, + char separator, + bool unquote ) { var idx = nameAndValue.IndexOf (separator); From f00dad7f99830bafd8da6911e89e3c11a9449a45 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 22 Aug 2024 21:32:25 +0900 Subject: [PATCH 5722/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index ba4f18823..c9913ce20 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -534,7 +534,8 @@ bool unquote } internal static bool IsCompressionExtension ( - this string value, CompressionMethod method + this string value, + CompressionMethod method ) { var extStr = method.ToExtensionString (); From 55825badb851bfacc0764c973d2b229e8cd21e11 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 23 Aug 2024 21:39:25 +0900 Subject: [PATCH 5723/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index c9913ce20..bd3219902 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -906,7 +906,8 @@ internal static T[] Reverse (this T[] array) } internal static IEnumerable SplitHeaderValue ( - this string value, params char[] separators + this string value, + params char[] separators ) { var len = value.Length; @@ -918,6 +919,7 @@ internal static IEnumerable SplitHeaderValue ( for (var i = 0; i <= end; i++) { var c = value[i]; + buff.Append (c); if (c == '"') { From dea136f253804d1f816de9001cfd6a017755c354 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 24 Aug 2024 21:28:44 +0900 Subject: [PATCH 5724/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index bd3219902..df30bb1ce 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1006,7 +1006,8 @@ internal static CompressionMethod ToCompressionMethod (this string value) } internal static string ToExtensionString ( - this CompressionMethod method, params string[] parameters + this CompressionMethod method, + params string[] parameters ) { if (method == CompressionMethod.None) From 189962df3c0284f73c9b6030d74d625fc883b460 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 25 Aug 2024 21:06:25 +0900 Subject: [PATCH 5725/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index df30bb1ce..37c0d42ef 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1057,7 +1057,8 @@ this IEnumerable source } internal static string ToString ( - this System.Net.IPAddress address, bool bracketIPv6 + this System.Net.IPAddress address, + bool bracketIPv6 ) { return bracketIPv6 From 83fac76f0fd29bb05f131b6097760ca264bd26e5 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 26 Aug 2024 21:42:44 +0900 Subject: [PATCH 5726/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 37c0d42ef..10f308c5f 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1109,7 +1109,8 @@ internal static string TrimSlashOrBackslashFromEnd (this string value) } internal static bool TryCreateVersion ( - this string versionString, out Version result + this string versionString, + out Version result ) { result = null; From dce6b84e44c054fc539ef0351b4dea31d736976c Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 27 Aug 2024 21:15:51 +0900 Subject: [PATCH 5727/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 10f308c5f..1ea2c50b2 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1126,7 +1126,9 @@ out Version result } internal static bool TryCreateWebSocketUri ( - this string uriString, out Uri result, out string message + this string uriString, + out Uri result, + out string message ) { result = null; From 247bc21ef9eb00b20cb296d91c3e48f1c03bf758 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 27 Aug 2024 21:18:51 +0900 Subject: [PATCH 5728/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 1ea2c50b2..774fc5809 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1152,7 +1152,7 @@ out string message var valid = schm == "ws" || schm == "wss"; if (!valid) { - message = "The scheme part is not 'ws' or 'wss'."; + message = "The scheme part is not \"ws\" or \"wss\"."; return false; } From 75a86a2e0a6cc6566ffe926fa9fe8e2463e9394a Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 28 Aug 2024 21:29:48 +0900 Subject: [PATCH 5729/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 774fc5809..3bbd38a88 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1191,7 +1191,8 @@ out string message } internal static bool TryGetUTF8DecodedString ( - this byte[] bytes, out string s + this byte[] bytes, + out string s ) { s = null; From 1181248e81481a4ba0fb397ae693e0baf6246030 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 28 Aug 2024 21:31:32 +0900 Subject: [PATCH 5730/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 3bbd38a88..b0f0420e8 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1208,7 +1208,8 @@ out string s } internal static bool TryGetUTF8EncodedBytes ( - this string s, out byte[] bytes + this string s, + out byte[] bytes ) { bytes = null; From b08cb45de9df5185a747daf20cfcfda8dbdd7818 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 29 Aug 2024 20:54:20 +0900 Subject: [PATCH 5731/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index b0f0420e8..8ee4cfc8b 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1225,7 +1225,8 @@ out byte[] bytes } internal static bool TryOpenRead ( - this FileInfo fileInfo, out FileStream fileStream + this FileInfo fileInfo, + out FileStream fileStream ) { fileStream = null; From 54dbb39fdaa4bbea47706ecca667739ba789733d Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 30 Aug 2024 22:01:00 +0900 Subject: [PATCH 5732/6294] [Modify] Polish it --- websocket-sharp/Ext.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 8ee4cfc8b..3c67cc207 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -1284,7 +1284,9 @@ internal static string UrlEncode (this string value, Encoding encoding) } internal static void WriteBytes ( - this Stream stream, byte[] bytes, int bufferLength + this Stream stream, + byte[] bytes, + int bufferLength ) { using (var src = new MemoryStream (bytes)) From ca39edc5505cd61b6c6ea431d6bac14d14598440 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 31 Aug 2024 21:33:28 +0900 Subject: [PATCH 5733/6294] [Modify] Polish it --- websocket-sharp/Net/HttpUtility.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 676b0b99f..18c32a142 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -892,7 +892,8 @@ internal static Encoding GetEncoding (string contentType) } internal static bool TryGetEncoding ( - string contentType, out Encoding result + string contentType, + out Encoding result ) { result = null; From 47a781ce63672373f0fc22b37517edf875f623eb Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 1 Sep 2024 10:22:40 +0900 Subject: [PATCH 5734/6294] [Modify] Polish it --- websocket-sharp/Net/HttpUtility.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 18c32a142..5276c986d 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -1019,7 +1019,10 @@ public static string UrlDecode (string s, Encoding encoding) } public static string UrlDecode ( - byte[] bytes, int offset, int count, Encoding encoding + byte[] bytes, + int offset, + int count, + Encoding encoding ) { if (bytes == null) From 3cde288fad830bda6e34fc661b6c1656332e533b Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 2 Sep 2024 21:21:35 +0900 Subject: [PATCH 5735/6294] [Modify] Polish it --- websocket-sharp/Net/HttpUtility.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 5276c986d..fd069536c 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -1061,9 +1061,7 @@ public static byte[] UrlDecodeToBytes (byte[] bytes) var len = bytes.Length; - return len > 0 - ? urlDecodeToBytes (bytes, 0, len) - : bytes; + return len > 0 ? urlDecodeToBytes (bytes, 0, len) : bytes; } public static byte[] UrlDecodeToBytes (string s) From 958fd85be07d04de06b6af130fb281a34ad23895 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 2 Sep 2024 21:24:07 +0900 Subject: [PATCH 5736/6294] [Modify] Polish it --- websocket-sharp/Net/HttpUtility.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index fd069536c..7e5edddfe 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -1100,9 +1100,7 @@ public static byte[] UrlDecodeToBytes (byte[] bytes, int offset, int count) if (count < 0 || count > len - offset) throw new ArgumentOutOfRangeException ("count"); - return count > 0 - ? urlDecodeToBytes (bytes, offset, count) - : new byte[0]; + return count > 0 ? urlDecodeToBytes (bytes, offset, count) : new byte[0]; } public static string UrlEncode (byte[] bytes) From ce63d2227eac346fddbe14368f78d0d047bb87be Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 3 Sep 2024 20:35:38 +0900 Subject: [PATCH 5737/6294] [Modify] Polish it --- websocket-sharp/Net/HttpUtility.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 7e5edddfe..ed525fb34 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -747,7 +747,10 @@ private static byte[] urlEncodeToBytes (byte[] bytes, int offset, int count) #region Internal Methods internal static Uri CreateRequestUrl ( - string requestUri, string host, bool websocketRequest, bool secure + string requestUri, + string host, + bool websocketRequest, + bool secure ) { if (requestUri == null || requestUri.Length == 0) From 2c65155bcae1d0925663c3319204bc5080971134 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 4 Sep 2024 21:03:56 +0900 Subject: [PATCH 5738/6294] [Modify] Polish it --- websocket-sharp/Net/HttpUtility.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index ed525fb34..901bb6aab 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -610,8 +610,7 @@ private static void initEntities () private static bool isAlphabet (char c) { - return (c >= 'A' && c <= 'Z') - || (c >= 'a' && c <= 'z'); + return (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z'); } private static bool isNumeric (char c) From df9d51d30f1e6264938606317d55f878eb9b819a Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 5 Sep 2024 20:54:27 +0900 Subject: [PATCH 5739/6294] [Modify] Polish it --- websocket-sharp/Net/HttpUtility.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index 901bb6aab..add067102 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -168,6 +168,7 @@ private static string htmlDecode (string s) buff.Append (reference.ToString ()); reference.Length = 0; + reference.Append ('&'); state = 1; From d461bf1ed63294938a33fdcba445dad2256f8f1d Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 6 Sep 2024 21:50:33 +0900 Subject: [PATCH 5740/6294] [Modify] 2024 --- websocket-sharp/Net/HttpUtility.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpUtility.cs b/websocket-sharp/Net/HttpUtility.cs index add067102..b7db7b922 100644 --- a/websocket-sharp/Net/HttpUtility.cs +++ b/websocket-sharp/Net/HttpUtility.cs @@ -8,7 +8,7 @@ * The MIT License * * Copyright (c) 2005-2009 Novell, Inc. (http://www.novell.com) - * Copyright (c) 2012-2023 sta.blockhead + * Copyright (c) 2012-2024 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From d9c2d9b185eb01a2653b6d8006f6128f6b8cc66b Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 7 Sep 2024 16:30:56 +0900 Subject: [PATCH 5741/6294] [Modify] Edit it --- websocket-sharp/Net/WebHeaderCollection.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 736d65897..2098dc4ba 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1077,9 +1077,6 @@ protected void AddWithoutValidate (string headerName, string headerValue) /// A that specifies the header to add, /// with the name and value separated by a colon character (':'). /// - /// - /// is . - /// /// /// /// is an empty string. @@ -1123,6 +1120,9 @@ protected void AddWithoutValidate (string headerName, string headerValue) /// is a restricted header. /// /// + /// + /// is . + /// /// /// The length of the value part of is greater /// than 65,535 characters. From 3d3c412a510b4d6a6c64a3af65f08b53e5d3490b Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 8 Sep 2024 16:38:41 +0900 Subject: [PATCH 5742/6294] [Modify] Polish it --- websocket-sharp/Net/WebHeaderCollection.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 2098dc4ba..dc07c8c74 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1152,9 +1152,7 @@ public void Add (string header) } var name = header.Substring (0, idx); - var val = idx < len - 1 - ? header.Substring (idx + 1) - : String.Empty; + var val = idx < len - 1 ? header.Substring (idx + 1) : String.Empty; name = checkName (name, "header"); val = checkValue (val, "header"); From ee3808e0f53e533a345acf1c26cc2ba456ddfc9b Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 9 Sep 2024 21:40:58 +0900 Subject: [PATCH 5743/6294] [Modify] Edit it --- websocket-sharp/Net/WebHeaderCollection.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index dc07c8c74..3d2c0c668 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1263,9 +1263,6 @@ public void Add (HttpResponseHeader header, string value) /// /// A that specifies the value of the header to add. /// - /// - /// is . - /// /// /// /// is an empty string. @@ -1295,6 +1292,9 @@ public void Add (HttpResponseHeader header, string value) /// is a restricted header name. /// /// + /// + /// is . + /// /// /// The length of is greater than 65,535 /// characters. From 14ce024d26628281b67075e72c13c6850434ce99 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 10 Sep 2024 21:31:01 +0900 Subject: [PATCH 5744/6294] [Modify] Edit it --- websocket-sharp/Net/WebHeaderCollection.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 3d2c0c668..be7768d4f 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1022,9 +1022,6 @@ internal string ToStringMultiValue (bool response) /// /// A that specifies the value of the header to add. /// - /// - /// is . - /// /// /// /// is an empty string. @@ -1048,6 +1045,9 @@ internal string ToStringMultiValue (bool response) /// contains an invalid character. /// /// + /// + /// is . + /// /// /// The length of is greater than 65,535 /// characters. From d9653d37583839558159b20cb6a386bf88140e51 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 11 Sep 2024 21:31:35 +0900 Subject: [PATCH 5745/6294] [Modify] Polish it --- websocket-sharp/Net/WebHeaderCollection.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index be7768d4f..eba84bd7e 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1063,6 +1063,7 @@ protected void AddWithoutValidate (string headerName, string headerValue) var headerType = getHeaderType (headerName); checkAllowed (headerType); + add (headerName, headerValue, headerType); } From 2490b034640121285de93f7f31c585d0e92be8cf Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 11 Sep 2024 21:33:02 +0900 Subject: [PATCH 5746/6294] [Modify] Polish it --- websocket-sharp/Net/WebHeaderCollection.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index eba84bd7e..1a39f8a3d 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1162,6 +1162,7 @@ public void Add (string header) checkRestricted (name, headerType); checkAllowed (headerType); + add (name, val, headerType); } From 5d9d1355759e159ac59edf27f8aab5da8a66515f Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 12 Sep 2024 21:12:22 +0900 Subject: [PATCH 5747/6294] [Modify] Polish it --- websocket-sharp/Net/WebHeaderCollection.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 1a39f8a3d..45753273e 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1208,6 +1208,7 @@ public void Add (HttpRequestHeader header, string value) checkRestricted (name, HttpHeaderType.Request); checkAllowed (HttpHeaderType.Request); + add (name, value, HttpHeaderType.Request); } From ff858f1b4b1989ffd144c35718621df3e0a373b9 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 12 Sep 2024 21:13:50 +0900 Subject: [PATCH 5748/6294] [Modify] Polish it --- websocket-sharp/Net/WebHeaderCollection.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 45753273e..87eb143f6 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1254,6 +1254,7 @@ public void Add (HttpResponseHeader header, string value) checkRestricted (name, HttpHeaderType.Response); checkAllowed (HttpHeaderType.Response); + add (name, value, HttpHeaderType.Response); } From e4d24a5cf29fcc78091b15ceac5158b4866c4f70 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 13 Sep 2024 21:49:01 +0900 Subject: [PATCH 5749/6294] [Modify] Polish it --- websocket-sharp/Net/WebHeaderCollection.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 87eb143f6..45e69066d 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1315,6 +1315,7 @@ public override void Add (string name, string value) checkRestricted (name, headerType); checkAllowed (headerType); + add (name, value, headerType); } From 504f651187e6b100466dbb33153e7929df775013 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 14 Sep 2024 16:17:17 +0900 Subject: [PATCH 5750/6294] [Modify] Edit it --- websocket-sharp/Net/WebHeaderCollection.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 45e69066d..ea47173a8 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1497,9 +1497,6 @@ StreamingContext streamingContext /// /// A that specifies the name of the header to test. /// - /// - /// is . - /// /// /// /// is an empty string. @@ -1517,6 +1514,9 @@ StreamingContext streamingContext /// contains an invalid character. /// /// + /// + /// is . + /// public static bool IsRestricted (string headerName) { return IsRestricted (headerName, false); From cf64c2659910659c2049d7912b2afb95fd6898a6 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 15 Sep 2024 21:50:00 +0900 Subject: [PATCH 5751/6294] [Modify] Edit it --- websocket-sharp/Net/WebHeaderCollection.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index ea47173a8..18b20d07c 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1536,9 +1536,6 @@ public static bool IsRestricted (string headerName) /// A : true if the test is for the response; /// otherwise, false. /// - /// - /// is . - /// /// /// /// is an empty string. @@ -1556,6 +1553,9 @@ public static bool IsRestricted (string headerName) /// contains an invalid character. /// /// + /// + /// is . + /// public static bool IsRestricted (string headerName, bool response) { headerName = checkName (headerName, "headerName"); From 451dba7384f99c58358f33f7f18b0167287c0f39 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 16 Sep 2024 16:43:26 +0900 Subject: [PATCH 5752/6294] [Modify] Polish it --- websocket-sharp/Net/WebHeaderCollection.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 18b20d07c..0dc98857f 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1599,6 +1599,7 @@ public void Remove (HttpRequestHeader header) checkRestricted (name, HttpHeaderType.Request); checkAllowed (HttpHeaderType.Request); + base.Remove (name); } From 49826e8104bd3679c5d502bddc04d4083d7a85fa Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 16 Sep 2024 16:45:15 +0900 Subject: [PATCH 5753/6294] [Modify] Polish it --- websocket-sharp/Net/WebHeaderCollection.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 0dc98857f..6754b434d 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1627,6 +1627,7 @@ public void Remove (HttpResponseHeader header) checkRestricted (name, HttpHeaderType.Response); checkAllowed (HttpHeaderType.Response); + base.Remove (name); } From 708431f038218d0df97c17dc7f68ec78ff4f5f4b Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 17 Sep 2024 21:09:57 +0900 Subject: [PATCH 5754/6294] [Modify] Edit it --- websocket-sharp/Net/WebHeaderCollection.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 6754b434d..6180816dc 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1637,9 +1637,6 @@ public void Remove (HttpResponseHeader header) /// /// A that specifies the name of the header to remove. /// - /// - /// is . - /// /// /// /// is an empty string. @@ -1663,6 +1660,9 @@ public void Remove (HttpResponseHeader header) /// is a restricted header name. /// /// + /// + /// is . + /// /// /// This instance does not allow the header. /// From 921a87bc4ac0136e449770fa5a9d574322f80317 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 17 Sep 2024 21:12:00 +0900 Subject: [PATCH 5755/6294] [Modify] Polish it --- websocket-sharp/Net/WebHeaderCollection.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 6180816dc..440a32030 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1674,6 +1674,7 @@ public override void Remove (string name) checkRestricted (name, headerType); checkAllowed (headerType); + base.Remove (name); } From 14c1be1d0029e2a2d4e43d1c6f9931c19eae231f Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 18 Sep 2024 21:03:24 +0900 Subject: [PATCH 5756/6294] [Modify] Polish it --- websocket-sharp/Net/WebHeaderCollection.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 440a32030..583d2c3db 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1720,6 +1720,7 @@ public void Set (HttpRequestHeader header, string value) checkRestricted (name, HttpHeaderType.Request); checkAllowed (HttpHeaderType.Request); + set (name, value, HttpHeaderType.Request); } From b797b8d4c6e8b63159f39db2d2291ee2456b4214 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 18 Sep 2024 21:04:55 +0900 Subject: [PATCH 5757/6294] [Modify] Polish it --- websocket-sharp/Net/WebHeaderCollection.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 583d2c3db..626121f15 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1766,6 +1766,7 @@ public void Set (HttpResponseHeader header, string value) checkRestricted (name, HttpHeaderType.Response); checkAllowed (HttpHeaderType.Response); + set (name, value, HttpHeaderType.Response); } From 011a4c29ce49d0b2ee0287afa9a4b09fef6d0561 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 19 Sep 2024 20:37:46 +0900 Subject: [PATCH 5758/6294] [Modify] Edit it --- websocket-sharp/Net/WebHeaderCollection.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 626121f15..90284619e 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1779,9 +1779,6 @@ public void Set (HttpResponseHeader header, string value) /// /// A that specifies the value of the header to set. /// - /// - /// is . - /// /// /// /// is an empty string. @@ -1811,6 +1808,9 @@ public void Set (HttpResponseHeader header, string value) /// is a restricted header name. /// /// + /// + /// is . + /// /// /// The length of is greater than 65,535 /// characters. From f1a168c31819cb42a5d213ff56dd26c3c7fe3680 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 19 Sep 2024 20:38:45 +0900 Subject: [PATCH 5759/6294] [Modify] Polish it --- websocket-sharp/Net/WebHeaderCollection.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 90284619e..6aeddd9bb 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1827,6 +1827,7 @@ public override void Set (string name, string value) checkRestricted (name, headerType); checkAllowed (headerType); + set (name, value, headerType); } From 3f807c06f7dd1036a2571ae4d7b04031c4d61814 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 20 Sep 2024 21:34:34 +0900 Subject: [PATCH 5760/6294] [Modify] Edit it --- websocket-sharp/Net/WebHeaderCollection.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 6aeddd9bb..5824c8fed 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1337,7 +1337,7 @@ public override void Clear () /// /// /// An that specifies the zero-based index of the header - /// to find. + /// to get. /// /// /// is out of allowable range of indexes for From 764c1007bf6ad97f0521e6c1f4cf5c70896d0fa5 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 20 Sep 2024 21:36:37 +0900 Subject: [PATCH 5761/6294] [Modify] Edit it --- websocket-sharp/Net/WebHeaderCollection.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 5824c8fed..6fbcd8e71 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1360,7 +1360,7 @@ public override string Get (int index) /// /// /// - /// A that specifies the name of the header to find. + /// A that specifies the name of the header to get. /// public override string Get (string name) { From 30489e28776cbf6e6e38f08a12afe59ef59ca3d8 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 21 Sep 2024 20:40:15 +0900 Subject: [PATCH 5762/6294] [Modify] Edit it --- websocket-sharp/Net/WebHeaderCollection.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 6fbcd8e71..dcad6f632 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1387,7 +1387,7 @@ public override IEnumerator GetEnumerator () /// /// /// An that specifies the zero-based index of the header - /// to find. + /// to get. /// /// /// is out of allowable range of indexes for From 1800efdc1b4850271c4f43a9666eb427734f1bc7 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 22 Sep 2024 16:43:33 +0900 Subject: [PATCH 5763/6294] [Modify] Edit it --- websocket-sharp/Net/WebHeaderCollection.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index dcad6f632..d50fac28d 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1412,7 +1412,7 @@ public override string GetKey (int index) /// /// /// An that specifies the zero-based index of the header - /// to find. + /// to get. /// /// /// is out of allowable range of indexes for From 7ded323f33eb33f4dbe66aa7ead4987f8b269c3b Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 23 Sep 2024 20:44:24 +0900 Subject: [PATCH 5764/6294] [Modify] Edit it --- websocket-sharp/Net/WebHeaderCollection.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index d50fac28d..7b9d40ce7 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1438,7 +1438,7 @@ public override string[] GetValues (int index) /// /// /// - /// A that specifies the name of the header to find. + /// A that specifies the name of the header to get. /// public override string[] GetValues (string name) { From 24baeb3b4c8dd8b547a3bc9de030fdc4d8bcab1b Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 24 Sep 2024 20:49:10 +0900 Subject: [PATCH 5765/6294] [Modify] Edit it --- websocket-sharp/Net/WebHeaderCollection.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 7b9d40ce7..db9744c7b 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -572,13 +572,13 @@ internal WebHeaderCollection (HttpHeaderType state, bool internallyUsed) /// A that specifies the source for /// the deserialization. /// - /// - /// is . - /// /// /// An element with the specified name is not found in /// . /// + /// + /// is . + /// protected WebHeaderCollection ( SerializationInfo serializationInfo, StreamingContext streamingContext From f0d2d659455ebaa234818186890c13100595121d Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 25 Sep 2024 21:44:46 +0900 Subject: [PATCH 5766/6294] [Modify] Edit it --- websocket-sharp/Net/WebHeaderCollection.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index db9744c7b..7bf4276b2 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -560,9 +560,9 @@ internal WebHeaderCollection (HttpHeaderType state, bool internallyUsed) #region Protected Constructors /// - /// Initializes a new instance of the class - /// from the specified instances of the and - /// classes. + /// Initializes a new instance of the + /// class from the specified instances of the + /// and classes. /// /// /// A that contains the serialized From 1ca15291adfd63ad55432214220ea3d295829fa7 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 26 Sep 2024 21:22:13 +0900 Subject: [PATCH 5767/6294] [Modify] Edit it --- websocket-sharp/Net/WebHeaderCollection.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 7bf4276b2..892f0bcd0 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1489,7 +1489,7 @@ StreamingContext streamingContext } /// - /// Determines whether the specified HTTP header can be set for the request. + /// Determines whether the specified header can be set for the request. /// /// /// true if the header cannot be set; otherwise, false. From 77cf431022d9ec8753086e62ef7f0594aca914c8 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 26 Sep 2024 21:24:35 +0900 Subject: [PATCH 5768/6294] [Modify] Edit it --- websocket-sharp/Net/WebHeaderCollection.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 892f0bcd0..504c53eb2 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1523,8 +1523,8 @@ public static bool IsRestricted (string headerName) } /// - /// Determines whether the specified HTTP header can be set for the request - /// or the response. + /// Determines whether the specified header can be set for the request or + /// the response. /// /// /// true if the header cannot be set; otherwise, false. From b9d43fab6412335ef49907bce4ef3271d83e476a Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 27 Sep 2024 21:40:39 +0900 Subject: [PATCH 5769/6294] [Modify] 2024 --- websocket-sharp/Net/WebHeaderCollection.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 504c53eb2..577209503 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -9,7 +9,7 @@ * * Copyright (c) 2003 Ximian, Inc. (http://www.ximian.com) * Copyright (c) 2007 Novell, Inc. (http://www.novell.com) - * Copyright (c) 2012-2023 sta.blockhead + * Copyright (c) 2012-2024 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From 6c202e8bb2def64778d9d0c84938998d1c304156 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 28 Sep 2024 21:06:02 +0900 Subject: [PATCH 5770/6294] [Modify] Polish it --- websocket-sharp/Net/AuthenticationChallenge.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/AuthenticationChallenge.cs b/websocket-sharp/Net/AuthenticationChallenge.cs index 30a8f9630..aec4934f5 100644 --- a/websocket-sharp/Net/AuthenticationChallenge.cs +++ b/websocket-sharp/Net/AuthenticationChallenge.cs @@ -44,7 +44,8 @@ internal class AuthenticationChallenge #region Private Constructors private AuthenticationChallenge ( - AuthenticationSchemes scheme, NameValueCollection parameters + AuthenticationSchemes scheme, + NameValueCollection parameters ) { _scheme = scheme; From f3df7a19a37f822f0c130c0d518db6f2f3300195 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 29 Sep 2024 21:06:42 +0900 Subject: [PATCH 5771/6294] [Modify] Polish it --- websocket-sharp/Net/AuthenticationChallenge.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/AuthenticationChallenge.cs b/websocket-sharp/Net/AuthenticationChallenge.cs index aec4934f5..751ed17a2 100644 --- a/websocket-sharp/Net/AuthenticationChallenge.cs +++ b/websocket-sharp/Net/AuthenticationChallenge.cs @@ -57,7 +57,8 @@ NameValueCollection parameters #region Internal Constructors internal AuthenticationChallenge ( - AuthenticationSchemes scheme, string realm + AuthenticationSchemes scheme, + string realm ) : this (scheme, new NameValueCollection ()) { From 96c88b19252b80e26228d5f1920cb0b26533c7c6 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 30 Sep 2024 16:13:26 +0900 Subject: [PATCH 5772/6294] [Modify] Polish it --- websocket-sharp/Net/AuthenticationChallenge.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/AuthenticationChallenge.cs b/websocket-sharp/Net/AuthenticationChallenge.cs index 751ed17a2..a8fbedfcd 100644 --- a/websocket-sharp/Net/AuthenticationChallenge.cs +++ b/websocket-sharp/Net/AuthenticationChallenge.cs @@ -175,7 +175,8 @@ internal static AuthenticationChallenge Parse (string value) var parameters = ParseParameters (chal[1]); return new AuthenticationChallenge ( - AuthenticationSchemes.Basic, parameters + AuthenticationSchemes.Basic, + parameters ); } @@ -183,7 +184,8 @@ internal static AuthenticationChallenge Parse (string value) var parameters = ParseParameters (chal[1]); return new AuthenticationChallenge ( - AuthenticationSchemes.Digest, parameters + AuthenticationSchemes.Digest, + parameters ); } From 9e6b503400c294d564ae978ec4526891974d4f4c Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 1 Oct 2024 20:42:22 +0900 Subject: [PATCH 5773/6294] [Modify] 2024 --- websocket-sharp/Net/AuthenticationChallenge.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/AuthenticationChallenge.cs b/websocket-sharp/Net/AuthenticationChallenge.cs index a8fbedfcd..726740801 100644 --- a/websocket-sharp/Net/AuthenticationChallenge.cs +++ b/websocket-sharp/Net/AuthenticationChallenge.cs @@ -4,7 +4,7 @@ * * The MIT License * - * Copyright (c) 2013-2023 sta.blockhead + * Copyright (c) 2013-2024 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From 428c90f5692a396d1bcbc83037900c003c289168 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 2 Oct 2024 20:34:23 +0900 Subject: [PATCH 5774/6294] [Modify] Polish it --- websocket-sharp/Net/AuthenticationResponse.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/AuthenticationResponse.cs b/websocket-sharp/Net/AuthenticationResponse.cs index 8113be6cf..ab20953e0 100644 --- a/websocket-sharp/Net/AuthenticationResponse.cs +++ b/websocket-sharp/Net/AuthenticationResponse.cs @@ -51,7 +51,8 @@ internal class AuthenticationResponse #region Private Constructors private AuthenticationResponse ( - AuthenticationSchemes scheme, NameValueCollection parameters + AuthenticationSchemes scheme, + NameValueCollection parameters ) { _scheme = scheme; From 16a34b131c48d9576043b2274901341019cf7030 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 3 Oct 2024 21:08:35 +0900 Subject: [PATCH 5775/6294] [Modify] Polish it --- websocket-sharp/Net/AuthenticationResponse.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/websocket-sharp/Net/AuthenticationResponse.cs b/websocket-sharp/Net/AuthenticationResponse.cs index ab20953e0..90d9b83c5 100644 --- a/websocket-sharp/Net/AuthenticationResponse.cs +++ b/websocket-sharp/Net/AuthenticationResponse.cs @@ -105,9 +105,7 @@ uint nonceCount internal uint NonceCount { get { - return _nonceCount < UInt32.MaxValue - ? _nonceCount - : 0; + return _nonceCount < UInt32.MaxValue ? _nonceCount : 0; } } From a2d492f0a332373d634bf6f1986c70738fd4eb44 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 4 Oct 2024 21:29:40 +0900 Subject: [PATCH 5776/6294] [Modify] Polish it --- websocket-sharp/Net/AuthenticationResponse.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/AuthenticationResponse.cs b/websocket-sharp/Net/AuthenticationResponse.cs index 90d9b83c5..1a97f718e 100644 --- a/websocket-sharp/Net/AuthenticationResponse.cs +++ b/websocket-sharp/Net/AuthenticationResponse.cs @@ -196,7 +196,9 @@ public string UserName { #region Private Methods private static string createA1 ( - string username, string password, string realm + string username, + string password, + string realm ) { return String.Format ("{0}:{1}:{2}", username, realm, password); From 86eaab02c7f43b77f38f121a81192b8362bb84de Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 5 Oct 2024 16:22:39 +0900 Subject: [PATCH 5777/6294] [Modify] Polish it --- websocket-sharp/Net/AuthenticationResponse.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/AuthenticationResponse.cs b/websocket-sharp/Net/AuthenticationResponse.cs index 1a97f718e..3b5bd7f73 100644 --- a/websocket-sharp/Net/AuthenticationResponse.cs +++ b/websocket-sharp/Net/AuthenticationResponse.cs @@ -293,7 +293,12 @@ internal static string CreateRequestDigest (NameValueCollection parameters) var secret = hash (a1); var data = qop != null ? String.Format ( - "{0}:{1}:{2}:{3}:{4}", nonce, nc, cnonce, qop, hash (a2) + "{0}:{1}:{2}:{3}:{4}", + nonce, + nc, + cnonce, + qop, + hash (a2) ) : String.Format ("{0}:{1}", nonce, hash (a2)); From 2b48651da4bf4e13b3c751581b62ac7094aec29e Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 6 Oct 2024 12:49:34 +0900 Subject: [PATCH 5778/6294] [Modify] Polish it --- websocket-sharp/Net/AuthenticationResponse.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/AuthenticationResponse.cs b/websocket-sharp/Net/AuthenticationResponse.cs index 3b5bd7f73..0cb02f915 100644 --- a/websocket-sharp/Net/AuthenticationResponse.cs +++ b/websocket-sharp/Net/AuthenticationResponse.cs @@ -321,7 +321,8 @@ internal static AuthenticationResponse Parse (string value) var parameters = ParseBasicCredentials (cred[1]); return new AuthenticationResponse ( - AuthenticationSchemes.Basic, parameters + AuthenticationSchemes.Basic, + parameters ); } @@ -329,7 +330,8 @@ internal static AuthenticationResponse Parse (string value) var parameters = AuthenticationChallenge.ParseParameters (cred[1]); return new AuthenticationResponse ( - AuthenticationSchemes.Digest, parameters + AuthenticationSchemes.Digest, + parameters ); } From 2783f2d1155a5bbb89f10f0e7add2301649ed5ec Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 7 Oct 2024 20:45:37 +0900 Subject: [PATCH 5779/6294] [Modify] Polish it --- websocket-sharp/Net/AuthenticationResponse.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/AuthenticationResponse.cs b/websocket-sharp/Net/AuthenticationResponse.cs index 0cb02f915..23647b047 100644 --- a/websocket-sharp/Net/AuthenticationResponse.cs +++ b/websocket-sharp/Net/AuthenticationResponse.cs @@ -420,7 +420,10 @@ internal string ToDigestString () var nc = _parameters["nc"]; buff.AppendFormat ( - ", qop={0}, cnonce=\"{1}\", nc={2}", qop, cnonce, nc + ", qop={0}, cnonce=\"{1}\", nc={2}", + qop, + cnonce, + nc ); } From 35d3eeb31a485de609b93d6ab9fc40cb6373f135 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 8 Oct 2024 20:44:20 +0900 Subject: [PATCH 5780/6294] [Modify] Polish it --- websocket-sharp/Net/AuthenticationResponse.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/AuthenticationResponse.cs b/websocket-sharp/Net/AuthenticationResponse.cs index 23647b047..c4b5cb988 100644 --- a/websocket-sharp/Net/AuthenticationResponse.cs +++ b/websocket-sharp/Net/AuthenticationResponse.cs @@ -375,10 +375,10 @@ internal static NameValueCollection ParseBasicCredentials (string value) internal string ToBasicString () { var user = _parameters["username"]; - var pass = _parameters["password"]; - var userPass = String.Format ("{0}:{1}", user, pass); + var passwd = _parameters["password"]; + var userPasswd = String.Format ("{0}:{1}", user, passwd); - var bytes = Encoding.UTF8.GetBytes (userPass); + var bytes = Encoding.UTF8.GetBytes (userPasswd); var cred = Convert.ToBase64String (bytes); return "Basic " + cred; From cc95bd213b37d1c31e5f7af2c481ff4c7417b0c3 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 9 Oct 2024 21:07:50 +0900 Subject: [PATCH 5781/6294] [Modify] Polish it --- websocket-sharp/Net/AuthenticationResponse.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/AuthenticationResponse.cs b/websocket-sharp/Net/AuthenticationResponse.cs index c4b5cb988..976308b7f 100644 --- a/websocket-sharp/Net/AuthenticationResponse.cs +++ b/websocket-sharp/Net/AuthenticationResponse.cs @@ -374,9 +374,9 @@ internal static NameValueCollection ParseBasicCredentials (string value) internal string ToBasicString () { - var user = _parameters["username"]; + var uname = _parameters["username"]; var passwd = _parameters["password"]; - var userPasswd = String.Format ("{0}:{1}", user, passwd); + var userPasswd = String.Format ("{0}:{1}", uname, passwd); var bytes = Encoding.UTF8.GetBytes (userPasswd); var cred = Convert.ToBase64String (bytes); From e310fb2831c9c717a1f1ea454f5db903f9440e3e Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 10 Oct 2024 21:30:34 +0900 Subject: [PATCH 5782/6294] [Modify] Polish it --- websocket-sharp/Net/AuthenticationResponse.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/AuthenticationResponse.cs b/websocket-sharp/Net/AuthenticationResponse.cs index 976308b7f..b3675cbf0 100644 --- a/websocket-sharp/Net/AuthenticationResponse.cs +++ b/websocket-sharp/Net/AuthenticationResponse.cs @@ -376,9 +376,9 @@ internal string ToBasicString () { var uname = _parameters["username"]; var passwd = _parameters["password"]; - var userPasswd = String.Format ("{0}:{1}", uname, passwd); + var userPass = String.Format ("{0}:{1}", uname, passwd); - var bytes = Encoding.UTF8.GetBytes (userPasswd); + var bytes = Encoding.UTF8.GetBytes (userPass); var cred = Convert.ToBase64String (bytes); return "Basic " + cred; From fa351f17528a31c5b3aac3b9bbf1244961a78ef9 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 11 Oct 2024 21:41:05 +0900 Subject: [PATCH 5783/6294] [Modify] Polish it --- websocket-sharp/Net/AuthenticationResponse.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/AuthenticationResponse.cs b/websocket-sharp/Net/AuthenticationResponse.cs index b3675cbf0..e3f9ec132 100644 --- a/websocket-sharp/Net/AuthenticationResponse.cs +++ b/websocket-sharp/Net/AuthenticationResponse.cs @@ -388,7 +388,7 @@ internal string ToDigestString () { var buff = new StringBuilder (256); - var user = _parameters["username"]; + var uname = _parameters["username"]; var realm = _parameters["realm"]; var nonce = _parameters["nonce"]; var uri = _parameters["uri"]; @@ -396,7 +396,7 @@ internal string ToDigestString () buff.AppendFormat ( "Digest username=\"{0}\", realm=\"{1}\", nonce=\"{2}\", uri=\"{3}\", response=\"{4}\"", - user, + uname, realm, nonce, uri, From 129c5709b6dad1e75fadf0cf719e6cb02ee2d6fc Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 12 Oct 2024 16:39:57 +0900 Subject: [PATCH 5784/6294] [Modify] Polish it --- websocket-sharp/Net/AuthenticationResponse.cs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/websocket-sharp/Net/AuthenticationResponse.cs b/websocket-sharp/Net/AuthenticationResponse.cs index e3f9ec132..1edf00b3c 100644 --- a/websocket-sharp/Net/AuthenticationResponse.cs +++ b/websocket-sharp/Net/AuthenticationResponse.cs @@ -354,20 +354,20 @@ internal static NameValueCollection ParseBasicCredentials (string value) // The format is [\]:. var i = userPass.IndexOf (':'); - var user = userPass.Substring (0, i); - var pass = i < userPass.Length - 1 - ? userPass.Substring (i + 1) - : String.Empty; + var uname = userPass.Substring (0, i); + var passwd = i < userPass.Length - 1 + ? userPass.Substring (i + 1) + : String.Empty; // Check if exists. - i = user.IndexOf ('\\'); + i = uname.IndexOf ('\\'); if (i > -1) - user = user.Substring (i + 1); + uname = uname.Substring (i + 1); - ret["username"] = user; - ret["password"] = pass; + ret["username"] = uname; + ret["password"] = passwd; return ret; } From 2debbf2f16a4ba94fa135a7fef1262f9524adeb8 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 13 Oct 2024 21:11:53 +0900 Subject: [PATCH 5785/6294] [Modify] Polish it --- websocket-sharp/Net/AuthenticationResponse.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/AuthenticationResponse.cs b/websocket-sharp/Net/AuthenticationResponse.cs index 1edf00b3c..25783cf75 100644 --- a/websocket-sharp/Net/AuthenticationResponse.cs +++ b/websocket-sharp/Net/AuthenticationResponse.cs @@ -271,7 +271,7 @@ private void initAsDigest () internal static string CreateRequestDigest (NameValueCollection parameters) { - var user = parameters["username"]; + var uname = parameters["username"]; var pass = parameters["password"]; var realm = parameters["realm"]; var nonce = parameters["nonce"]; @@ -283,8 +283,8 @@ internal static string CreateRequestDigest (NameValueCollection parameters) var method = parameters["method"]; var a1 = algo != null && algo.ToLower () == "md5-sess" - ? createA1 (user, pass, realm, nonce, cnonce) - : createA1 (user, pass, realm); + ? createA1 (uname, pass, realm, nonce, cnonce) + : createA1 (uname, pass, realm); var a2 = qop != null && qop.ToLower () == "auth-int" ? createA2 (method, uri, parameters["entity"]) From 040e96f54032a831f1d80e08726230a1d5a0bdd9 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 14 Oct 2024 20:56:47 +0900 Subject: [PATCH 5786/6294] [Modify] Polish it --- websocket-sharp/Net/AuthenticationResponse.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/AuthenticationResponse.cs b/websocket-sharp/Net/AuthenticationResponse.cs index 25783cf75..4008d3b4a 100644 --- a/websocket-sharp/Net/AuthenticationResponse.cs +++ b/websocket-sharp/Net/AuthenticationResponse.cs @@ -272,7 +272,7 @@ private void initAsDigest () internal static string CreateRequestDigest (NameValueCollection parameters) { var uname = parameters["username"]; - var pass = parameters["password"]; + var passwd = parameters["password"]; var realm = parameters["realm"]; var nonce = parameters["nonce"]; var uri = parameters["uri"]; @@ -283,8 +283,8 @@ internal static string CreateRequestDigest (NameValueCollection parameters) var method = parameters["method"]; var a1 = algo != null && algo.ToLower () == "md5-sess" - ? createA1 (uname, pass, realm, nonce, cnonce) - : createA1 (uname, pass, realm); + ? createA1 (uname, passwd, realm, nonce, cnonce) + : createA1 (uname, passwd, realm); var a2 = qop != null && qop.ToLower () == "auth-int" ? createA2 (method, uri, parameters["entity"]) From dc190d81951d1b3614a457b4577faeab4155c4de Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 15 Oct 2024 21:40:38 +0900 Subject: [PATCH 5787/6294] [Modify] Polish it --- websocket-sharp/Net/AuthenticationResponse.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/AuthenticationResponse.cs b/websocket-sharp/Net/AuthenticationResponse.cs index 4008d3b4a..83a18ed6a 100644 --- a/websocket-sharp/Net/AuthenticationResponse.cs +++ b/websocket-sharp/Net/AuthenticationResponse.cs @@ -437,10 +437,10 @@ internal string ToDigestString () public IIdentity ToIdentity () { if (_scheme == AuthenticationSchemes.Basic) { - var user = _parameters["username"]; - var pass = _parameters["password"]; + var uname = _parameters["username"]; + var passwd = _parameters["password"]; - return new HttpBasicIdentity (user, pass); + return new HttpBasicIdentity (uname, passwd); } if (_scheme == AuthenticationSchemes.Digest) From b882f81131cc072e2b0ecf2fb40c8254efcca351 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 16 Oct 2024 20:59:46 +0900 Subject: [PATCH 5788/6294] [Modify] Polish it --- websocket-sharp/Net/AuthenticationResponse.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/websocket-sharp/Net/AuthenticationResponse.cs b/websocket-sharp/Net/AuthenticationResponse.cs index 83a18ed6a..b61ebb0a2 100644 --- a/websocket-sharp/Net/AuthenticationResponse.cs +++ b/websocket-sharp/Net/AuthenticationResponse.cs @@ -353,18 +353,18 @@ internal static NameValueCollection ParseBasicCredentials (string value) // The format is [\]:. - var i = userPass.IndexOf (':'); - var uname = userPass.Substring (0, i); - var passwd = i < userPass.Length - 1 - ? userPass.Substring (i + 1) + var idx = userPass.IndexOf (':'); + var uname = userPass.Substring (0, idx); + var passwd = idx < userPass.Length - 1 + ? userPass.Substring (idx + 1) : String.Empty; // Check if exists. - i = uname.IndexOf ('\\'); + idx = uname.IndexOf ('\\'); - if (i > -1) - uname = uname.Substring (i + 1); + if (idx > -1) + uname = uname.Substring (idx + 1); ret["username"] = uname; ret["password"] = passwd; From 558bed2bb8ef549da46bd13d8c23f3821a9fd533 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 17 Oct 2024 21:43:35 +0900 Subject: [PATCH 5789/6294] [Modify] Use UTF-8 --- websocket-sharp/Net/AuthenticationResponse.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/AuthenticationResponse.cs b/websocket-sharp/Net/AuthenticationResponse.cs index b61ebb0a2..50aff8375 100644 --- a/websocket-sharp/Net/AuthenticationResponse.cs +++ b/websocket-sharp/Net/AuthenticationResponse.cs @@ -349,7 +349,7 @@ internal static NameValueCollection ParseBasicCredentials (string value) // Decode the basic-credentials (a Base64 encoded string). var bytes = Convert.FromBase64String (value); - var userPass = Encoding.Default.GetString (bytes); + var userPass = Encoding.UTF8.GetString (bytes); // The format is [\]:. From 60b764537e3d274da90254239fb1ad1fbd6c8b19 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 18 Oct 2024 21:36:49 +0900 Subject: [PATCH 5790/6294] [Modify] Polish it --- websocket-sharp/Net/AuthenticationResponse.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/AuthenticationResponse.cs b/websocket-sharp/Net/AuthenticationResponse.cs index 50aff8375..f29441727 100644 --- a/websocket-sharp/Net/AuthenticationResponse.cs +++ b/websocket-sharp/Net/AuthenticationResponse.cs @@ -229,13 +229,12 @@ private static string createA2 (string method, string uri, string entity) private static string hash (string value) { - var md5 = MD5.Create (); + var buff = new StringBuilder (64); + var md5 = MD5.Create (); var bytes = Encoding.UTF8.GetBytes (value); var res = md5.ComputeHash (bytes); - var buff = new StringBuilder (64); - foreach (var b in res) buff.Append (b.ToString ("x2")); From 44e8b78b7966fcc6791482b36be8eaf570bd71aa Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 19 Oct 2024 21:10:46 +0900 Subject: [PATCH 5791/6294] [Modify] Polish it --- websocket-sharp/Net/AuthenticationResponse.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/AuthenticationResponse.cs b/websocket-sharp/Net/AuthenticationResponse.cs index f29441727..f83c96b52 100644 --- a/websocket-sharp/Net/AuthenticationResponse.cs +++ b/websocket-sharp/Net/AuthenticationResponse.cs @@ -246,11 +246,11 @@ private void initAsDigest () var qops = _parameters["qop"]; if (qops != null) { - var auth = qops.Split (',').Contains ( - qop => qop.Trim ().ToLower () == "auth" - ); + var hasAuth = qops.Split (',').Contains ( + qop => qop.Trim ().ToLower () == "auth" + ); - if (auth) { + if (hasAuth) { _parameters["qop"] = "auth"; _parameters["cnonce"] = AuthenticationChallenge.CreateNonceValue (); _parameters["nc"] = String.Format ("{0:x8}", ++_nonceCount); From 938a121be315c2271e5459b198b029d171143354 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 20 Oct 2024 21:23:21 +0900 Subject: [PATCH 5792/6294] [Modify] Edit it --- websocket-sharp/Net/AuthenticationResponse.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/AuthenticationResponse.cs b/websocket-sharp/Net/AuthenticationResponse.cs index f83c96b52..916265ee2 100644 --- a/websocket-sharp/Net/AuthenticationResponse.cs +++ b/websocket-sharp/Net/AuthenticationResponse.cs @@ -2,8 +2,8 @@ /* * AuthenticationResponse.cs * - * ParseBasicCredentials is derived from HttpListenerContext.cs (System.Net) of - * Mono (http://www.mono-project.com). + * The ParseBasicCredentials method is derived from HttpListenerContext.cs + * (System.Net) of Mono (http://www.mono-project.com). * * The MIT License * From e7514f8fb2c14f55afcd0021540493b211a4cd51 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 21 Oct 2024 20:45:09 +0900 Subject: [PATCH 5793/6294] [Modify] 2024 --- websocket-sharp/Net/AuthenticationResponse.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/AuthenticationResponse.cs b/websocket-sharp/Net/AuthenticationResponse.cs index 916265ee2..28fbd2236 100644 --- a/websocket-sharp/Net/AuthenticationResponse.cs +++ b/websocket-sharp/Net/AuthenticationResponse.cs @@ -8,7 +8,7 @@ * The MIT License * * Copyright (c) 2005 Novell, Inc. (http://www.novell.com) - * Copyright (c) 2013-2023 sta.blockhead + * Copyright (c) 2013-2024 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From 2c74375abe6ae8bdf79c2640b5477eaa9a95417e Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 22 Oct 2024 20:40:10 +0900 Subject: [PATCH 5794/6294] [Modify] Edit it --- websocket-sharp/Ext.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 3c67cc207..0df7f3c25 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -3,9 +3,9 @@ * Ext.cs * * Some parts of this code are derived from Mono (http://www.mono-project.com): - * - GetStatusDescription is derived from HttpListenerResponse.cs (System.Net) - * - MaybeUri is derived from Uri.cs (System) - * - isPredefinedScheme is derived from Uri.cs (System) + * - The GetStatusDescription method is derived from HttpListenerResponse.cs (System.Net) + * - The MaybeUri method is derived from Uri.cs (System) + * - The isPredefinedScheme method is derived from Uri.cs (System) * * The MIT License * From e22e6fecd5a12e46ffe64078e971716856a879f4 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 23 Oct 2024 21:47:08 +0900 Subject: [PATCH 5795/6294] [Modify] Edit it --- websocket-sharp/Net/ClientSslConfiguration.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/ClientSslConfiguration.cs b/websocket-sharp/Net/ClientSslConfiguration.cs index 3b9a70dcb..02bd3a099 100644 --- a/websocket-sharp/Net/ClientSslConfiguration.cs +++ b/websocket-sharp/Net/ClientSslConfiguration.cs @@ -67,12 +67,12 @@ public class ClientSslConfiguration /// A that specifies the name of the server that /// will share a secure connection with a client. /// - /// - /// is . - /// /// /// is an empty string. /// + /// + /// is . + /// public ClientSslConfiguration (string targetHost) { if (targetHost == null) From f1770b9a437ae369a21462ba5af0d587a4d0496b Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 24 Oct 2024 20:53:15 +0900 Subject: [PATCH 5796/6294] [Modify] Edit it --- websocket-sharp/Net/ClientSslConfiguration.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/ClientSslConfiguration.cs b/websocket-sharp/Net/ClientSslConfiguration.cs index 02bd3a099..37aa450ba 100644 --- a/websocket-sharp/Net/ClientSslConfiguration.cs +++ b/websocket-sharp/Net/ClientSslConfiguration.cs @@ -259,12 +259,12 @@ public RemoteCertificateValidationCallback ServerCertificateValidationCallback { /// A that represents the name of the server that /// will share a secure connection with a client. /// - /// - /// The value specified for a set operation is . - /// /// /// The value specified for a set operation is an empty string. /// + /// + /// The value specified for a set operation is . + /// public string TargetHost { get { return _targetHost; From 5d27254f213e3ebe504f8226263179609fbc7ea0 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 25 Oct 2024 21:39:13 +0900 Subject: [PATCH 5797/6294] [Modify] Edit it --- websocket-sharp/Net/ClientSslConfiguration.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/ClientSslConfiguration.cs b/websocket-sharp/Net/ClientSslConfiguration.cs index 37aa450ba..e21d89c36 100644 --- a/websocket-sharp/Net/ClientSslConfiguration.cs +++ b/websocket-sharp/Net/ClientSslConfiguration.cs @@ -231,7 +231,7 @@ public SslProtocols EnabledSslProtocols { /// A delegate. /// /// - /// The delegate invokes the method called when a client validates + /// It represents the delegate called when a client validates /// the certificate. /// /// From 8e1f51174e3c311d4f9f221340c90bb0e18b0a14 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 26 Oct 2024 21:18:10 +0900 Subject: [PATCH 5798/6294] [Modify] Edit it --- websocket-sharp/Net/ClientSslConfiguration.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/websocket-sharp/Net/ClientSslConfiguration.cs b/websocket-sharp/Net/ClientSslConfiguration.cs index e21d89c36..28aba0eff 100644 --- a/websocket-sharp/Net/ClientSslConfiguration.cs +++ b/websocket-sharp/Net/ClientSslConfiguration.cs @@ -235,8 +235,7 @@ public SslProtocols EnabledSslProtocols { /// the certificate. /// /// - /// The default value is a delegate that invokes a method that only - /// returns true. + /// The default value invokes a method that only returns true. /// /// public RemoteCertificateValidationCallback ServerCertificateValidationCallback { From 991bf62cff5044d4d5a1d0bb0d90f8a0d0afa493 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 27 Oct 2024 21:31:16 +0900 Subject: [PATCH 5799/6294] [Modify] Edit it --- websocket-sharp/Net/ClientSslConfiguration.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/ClientSslConfiguration.cs b/websocket-sharp/Net/ClientSslConfiguration.cs index 28aba0eff..d83e7aafb 100644 --- a/websocket-sharp/Net/ClientSslConfiguration.cs +++ b/websocket-sharp/Net/ClientSslConfiguration.cs @@ -174,12 +174,12 @@ public X509CertificateCollection ClientCertificates { /// A delegate. /// /// - /// The delegate invokes the method called when a client selects + /// It represents the delegate called when a client selects /// the certificate. /// /// - /// The default value is a delegate that invokes a method that only - /// returns . + /// The default value invokes a method that only returns + /// . /// /// public LocalCertificateSelectionCallback ClientCertificateSelectionCallback { From e692b81c455c76ae4e4c0597e9f23d31a58dc4ae Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 28 Oct 2024 21:57:02 +0900 Subject: [PATCH 5800/6294] [Modify] Edit it --- websocket-sharp/Net/ClientSslConfiguration.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/ClientSslConfiguration.cs b/websocket-sharp/Net/ClientSslConfiguration.cs index d83e7aafb..c81272f13 100644 --- a/websocket-sharp/Net/ClientSslConfiguration.cs +++ b/websocket-sharp/Net/ClientSslConfiguration.cs @@ -42,7 +42,8 @@ namespace WebSocketSharp.Net { /// - /// Stores the parameters for the used by clients. + /// Stores the parameters for an instance used by + /// a client. /// public class ClientSslConfiguration { From 2ecd70659b1c31b6455859c13c0ffa2f5214bb06 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 29 Oct 2024 21:30:57 +0900 Subject: [PATCH 5801/6294] [Modify] 2024 --- websocket-sharp/Net/ClientSslConfiguration.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/ClientSslConfiguration.cs b/websocket-sharp/Net/ClientSslConfiguration.cs index c81272f13..333571c2f 100644 --- a/websocket-sharp/Net/ClientSslConfiguration.cs +++ b/websocket-sharp/Net/ClientSslConfiguration.cs @@ -5,7 +5,7 @@ * The MIT License * * Copyright (c) 2014 liryna - * Copyright (c) 2014-2023 sta.blockhead + * Copyright (c) 2014-2024 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From dc3c6e48953935110c46d5b01635d99995a419fb Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 30 Oct 2024 21:00:08 +0900 Subject: [PATCH 5802/6294] [Modify] Edit it --- websocket-sharp/Net/ServerSslConfiguration.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/ServerSslConfiguration.cs b/websocket-sharp/Net/ServerSslConfiguration.cs index 2bd6f00a8..98b7ba663 100644 --- a/websocket-sharp/Net/ServerSslConfiguration.cs +++ b/websocket-sharp/Net/ServerSslConfiguration.cs @@ -42,7 +42,8 @@ namespace WebSocketSharp.Net { /// - /// Stores the parameters for the used by servers. + /// Stores the parameters for instances used by + /// a server. /// public class ServerSslConfiguration { From ad087263afbb0c0db306050f077086fde5017c7c Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 31 Oct 2024 20:58:18 +0900 Subject: [PATCH 5803/6294] [Modify] Edit it --- websocket-sharp/Net/ServerSslConfiguration.cs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/ServerSslConfiguration.cs b/websocket-sharp/Net/ServerSslConfiguration.cs index 98b7ba663..849e37d47 100644 --- a/websocket-sharp/Net/ServerSslConfiguration.cs +++ b/websocket-sharp/Net/ServerSslConfiguration.cs @@ -142,7 +142,7 @@ public bool ClientCertificateRequired { /// /// Gets or sets the callback used to validate the certificate supplied by - /// the client. + /// a client. /// /// /// The certificate is valid if the callback returns true. @@ -152,12 +152,11 @@ public bool ClientCertificateRequired { /// A delegate. /// /// - /// The delegate invokes the method called when the server validates + /// It represents the delegate called when a server validates /// the certificate. /// /// - /// The default value is a delegate that invokes a method that only - /// returns true. + /// The default value invokes a method that only returns true. /// /// public RemoteCertificateValidationCallback ClientCertificateValidationCallback { From 0e86839b7aa6a19cc8878b3f02e375bf0af9a32c Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 1 Nov 2024 21:44:11 +0900 Subject: [PATCH 5804/6294] [Modify] Edit it --- websocket-sharp/Net/ServerSslConfiguration.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/ServerSslConfiguration.cs b/websocket-sharp/Net/ServerSslConfiguration.cs index 849e37d47..f430a1acb 100644 --- a/websocket-sharp/Net/ServerSslConfiguration.cs +++ b/websocket-sharp/Net/ServerSslConfiguration.cs @@ -152,7 +152,7 @@ public bool ClientCertificateRequired { /// A delegate. /// /// - /// It represents the delegate called when a server validates + /// It represents the delegate called when the server validates /// the certificate. /// /// From 33ae1f91ac3c5dc99e91f5a4a6d56d277da4e65a Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 2 Nov 2024 16:19:55 +0900 Subject: [PATCH 5805/6294] [Modify] Edit it --- websocket-sharp/Net/ServerSslConfiguration.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/ServerSslConfiguration.cs b/websocket-sharp/Net/ServerSslConfiguration.cs index f430a1acb..517eb561b 100644 --- a/websocket-sharp/Net/ServerSslConfiguration.cs +++ b/websocket-sharp/Net/ServerSslConfiguration.cs @@ -118,12 +118,12 @@ public bool CheckCertificateRevocation { } /// - /// Gets or sets a value indicating whether the client is asked for + /// Gets or sets a value indicating whether each client is asked for /// a certificate for authentication. /// /// /// - /// true if the client is asked for a certificate for + /// true if each client is asked for a certificate for /// authentication; otherwise, false. /// /// From 4b1efa9ca8a30e0006599817b98ad86b95576ef2 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 3 Nov 2024 21:39:32 +0900 Subject: [PATCH 5806/6294] [Modify] Edit it --- websocket-sharp/Net/ServerSslConfiguration.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/ServerSslConfiguration.cs b/websocket-sharp/Net/ServerSslConfiguration.cs index 517eb561b..24eb76a68 100644 --- a/websocket-sharp/Net/ServerSslConfiguration.cs +++ b/websocket-sharp/Net/ServerSslConfiguration.cs @@ -142,7 +142,7 @@ public bool ClientCertificateRequired { /// /// Gets or sets the callback used to validate the certificate supplied by - /// a client. + /// each client. /// /// /// The certificate is valid if the callback returns true. From 78a98084322c405b9a7f2b20e8dac04e9817f00b Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 4 Nov 2024 21:45:56 +0900 Subject: [PATCH 5807/6294] [Modify] 2024 --- websocket-sharp/Net/ServerSslConfiguration.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/ServerSslConfiguration.cs b/websocket-sharp/Net/ServerSslConfiguration.cs index 24eb76a68..b4de5d64c 100644 --- a/websocket-sharp/Net/ServerSslConfiguration.cs +++ b/websocket-sharp/Net/ServerSslConfiguration.cs @@ -5,7 +5,7 @@ * The MIT License * * Copyright (c) 2014 liryna - * Copyright (c) 2014-2023 sta.blockhead + * Copyright (c) 2014-2024 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From 81bc74d3abeb5a649920147d26253a161253dae4 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 4 Nov 2024 21:47:19 +0900 Subject: [PATCH 5808/6294] [Modify] Edit it --- websocket-sharp/Net/ClientSslConfiguration.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/ClientSslConfiguration.cs b/websocket-sharp/Net/ClientSslConfiguration.cs index 333571c2f..b99991e0b 100644 --- a/websocket-sharp/Net/ClientSslConfiguration.cs +++ b/websocket-sharp/Net/ClientSslConfiguration.cs @@ -257,7 +257,7 @@ public RemoteCertificateValidationCallback ServerCertificateValidationCallback { /// /// /// A that represents the name of the server that - /// will share a secure connection with a client. + /// will share a secure connection with the client. /// /// /// The value specified for a set operation is an empty string. From 326f77d0edc5208b45b6815750d620ec1e598d57 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 4 Nov 2024 21:48:55 +0900 Subject: [PATCH 5809/6294] [Modify] Edit it --- websocket-sharp/Net/ClientSslConfiguration.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/ClientSslConfiguration.cs b/websocket-sharp/Net/ClientSslConfiguration.cs index b99991e0b..c193ec470 100644 --- a/websocket-sharp/Net/ClientSslConfiguration.cs +++ b/websocket-sharp/Net/ClientSslConfiguration.cs @@ -232,7 +232,7 @@ public SslProtocols EnabledSslProtocols { /// A delegate. /// /// - /// It represents the delegate called when a client validates + /// It represents the delegate called when the client validates /// the certificate. /// /// From ee42ec0dab86e5d3555b4f662ed16d8027208c5b Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 4 Nov 2024 21:50:21 +0900 Subject: [PATCH 5810/6294] [Modify] Edit it --- websocket-sharp/Net/ClientSslConfiguration.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/ClientSslConfiguration.cs b/websocket-sharp/Net/ClientSslConfiguration.cs index c193ec470..8ff8a9e09 100644 --- a/websocket-sharp/Net/ClientSslConfiguration.cs +++ b/websocket-sharp/Net/ClientSslConfiguration.cs @@ -175,7 +175,7 @@ public X509CertificateCollection ClientCertificates { /// A delegate. /// /// - /// It represents the delegate called when a client selects + /// It represents the delegate called when the client selects /// the certificate. /// /// From 91a38aa12c484bcc01b4d0ca490ec95a371d131c Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 5 Nov 2024 21:23:04 +0900 Subject: [PATCH 5811/6294] [Modify] Edit it --- websocket-sharp/Net/ClientSslConfiguration.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/ClientSslConfiguration.cs b/websocket-sharp/Net/ClientSslConfiguration.cs index 8ff8a9e09..33438a93c 100644 --- a/websocket-sharp/Net/ClientSslConfiguration.cs +++ b/websocket-sharp/Net/ClientSslConfiguration.cs @@ -66,7 +66,7 @@ public class ClientSslConfiguration /// /// /// A that specifies the name of the server that - /// will share a secure connection with a client. + /// will share a secure connection with the client. /// /// /// is an empty string. From 35312025f4d1995b804f0f0b8ac7e26fbc5b601c Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 6 Nov 2024 21:27:38 +0900 Subject: [PATCH 5812/6294] [Modify] Change the default value of the KeepClean property to false To avoid unexpected disconnections. --- Example2/Program.cs | 4 ++-- Example3/Program.cs | 4 ++-- websocket-sharp/Server/HttpServer.cs | 2 +- websocket-sharp/Server/WebSocketServer.cs | 2 +- websocket-sharp/Server/WebSocketServiceManager.cs | 7 +++---- websocket-sharp/Server/WebSocketSessionManager.cs | 1 - 6 files changed, 9 insertions(+), 11 deletions(-) diff --git a/Example2/Program.cs b/Example2/Program.cs index 7b024a0ee..e83c762a4 100644 --- a/Example2/Program.cs +++ b/Example2/Program.cs @@ -53,8 +53,8 @@ public static void Main (string[] args) // To change the wait time for the response to the WebSocket Ping or Close. //wssv.WaitTime = TimeSpan.FromSeconds (2); - // Not to remove the inactive sessions periodically. - //wssv.KeepClean = false; + // To remove the inactive sessions periodically. + //wssv.KeepClean = true; #endif // To provide the secure connection. /* diff --git a/Example3/Program.cs b/Example3/Program.cs index b338e10b3..33744993b 100644 --- a/Example3/Program.cs +++ b/Example3/Program.cs @@ -54,8 +54,8 @@ public static void Main (string[] args) // To change the wait time for the response to the WebSocket Ping or Close. //httpsv.WaitTime = TimeSpan.FromSeconds (2); - // Not to remove the inactive WebSocket sessions periodically. - //httpsv.KeepClean = false; + // To remove the inactive WebSocket sessions periodically. + //httpsv.KeepClean = true; #endif // To provide the secure connection. /* diff --git a/websocket-sharp/Server/HttpServer.cs b/websocket-sharp/Server/HttpServer.cs index 2a27afa86..209109984 100644 --- a/websocket-sharp/Server/HttpServer.cs +++ b/websocket-sharp/Server/HttpServer.cs @@ -480,7 +480,7 @@ public bool IsSecure { /// every 60 seconds; otherwise, false. /// /// - /// The default value is true. + /// The default value is false. /// /// public bool KeepClean { diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index fbf83b3ee..50f03f020 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -405,7 +405,7 @@ public bool IsSecure { /// every 60 seconds; otherwise, false. /// /// - /// The default value is true. + /// The default value is false. /// /// public bool KeepClean { diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index 6d71196b4..29021062a 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -59,7 +59,6 @@ internal WebSocketServiceManager (Logger log) _log = log; _hosts = new Dictionary (); - _keepClean = true; _state = ServerState.Ready; _sync = ((ICollection) _hosts).SyncRoot; _waitTime = TimeSpan.FromSeconds (1); @@ -190,7 +189,7 @@ public WebSocketServiceHost this[string path] { /// seconds; otherwise, false. /// /// - /// The default value is true. + /// The default value is false. /// /// public bool KeepClean { @@ -425,8 +424,8 @@ Action initializer host = new WebSocketServiceHost (path, initializer, _log); - if (!_keepClean) - host.KeepClean = false; + if (_keepClean) + host.KeepClean = true; if (_waitTime != host.WaitTime) host.WaitTime = _waitTime; diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 5b597b7f3..df2a83649 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -77,7 +77,6 @@ internal WebSocketSessionManager (Logger log) _log = log; _forSweep = new object (); - _keepClean = true; _sessions = new Dictionary (); _state = ServerState.Ready; _sync = ((ICollection) _sessions).SyncRoot; From 9fbea8ecff895294b8ff3f0b16cb7b25abb52e50 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 7 Nov 2024 21:33:57 +0900 Subject: [PATCH 5813/6294] [Modify] Polish it --- websocket-sharp/Net/CookieException.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/CookieException.cs b/websocket-sharp/Net/CookieException.cs index 2a5abe98a..97661a07c 100644 --- a/websocket-sharp/Net/CookieException.cs +++ b/websocket-sharp/Net/CookieException.cs @@ -79,7 +79,8 @@ internal CookieException (string message, Exception innerException) /// is . /// protected CookieException ( - SerializationInfo serializationInfo, StreamingContext streamingContext + SerializationInfo serializationInfo, + StreamingContext streamingContext ) : base (serializationInfo, streamingContext) { From 3defaa8c6b8605ce79246e6bb7c91cc7309d933b Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 7 Nov 2024 21:37:47 +0900 Subject: [PATCH 5814/6294] [Modify] Edit it --- websocket-sharp/Net/CookieException.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/CookieException.cs b/websocket-sharp/Net/CookieException.cs index 97661a07c..33bbaf823 100644 --- a/websocket-sharp/Net/CookieException.cs +++ b/websocket-sharp/Net/CookieException.cs @@ -69,7 +69,8 @@ internal CookieException (string message, Exception innerException) /// with the serialized data. /// /// - /// A that holds the serialized object data. + /// A that contains the serialized + /// object data. /// /// /// A that specifies the source for From f43d286757e2d19d2d5995102510e3d466e6e559 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 8 Nov 2024 21:47:57 +0900 Subject: [PATCH 5815/6294] [Modify] Polish it --- websocket-sharp/Net/CookieException.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/CookieException.cs b/websocket-sharp/Net/CookieException.cs index 33bbaf823..9a212f038 100644 --- a/websocket-sharp/Net/CookieException.cs +++ b/websocket-sharp/Net/CookieException.cs @@ -124,7 +124,8 @@ public CookieException () ) ] public override void GetObjectData ( - SerializationInfo serializationInfo, StreamingContext streamingContext + SerializationInfo serializationInfo, + StreamingContext streamingContext ) { base.GetObjectData (serializationInfo, streamingContext); From 5f53b53612d29ccdccd21fc7e9500073ab4460fb Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 9 Nov 2024 22:40:45 +0900 Subject: [PATCH 5816/6294] [Modify] Polish it --- websocket-sharp/Net/CookieException.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/CookieException.cs b/websocket-sharp/Net/CookieException.cs index 9a212f038..829c4ad30 100644 --- a/websocket-sharp/Net/CookieException.cs +++ b/websocket-sharp/Net/CookieException.cs @@ -157,7 +157,8 @@ StreamingContext streamingContext ) ] void ISerializable.GetObjectData ( - SerializationInfo serializationInfo, StreamingContext streamingContext + SerializationInfo serializationInfo, + StreamingContext streamingContext ) { base.GetObjectData (serializationInfo, streamingContext); From 9f84131fc0f2871488f0f922668ea9e95c81c677 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 10 Nov 2024 21:13:43 +0900 Subject: [PATCH 5817/6294] [Modify] 2024 --- websocket-sharp/Net/CookieException.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/CookieException.cs b/websocket-sharp/Net/CookieException.cs index 829c4ad30..e6a735d17 100644 --- a/websocket-sharp/Net/CookieException.cs +++ b/websocket-sharp/Net/CookieException.cs @@ -7,7 +7,7 @@ * * The MIT License * - * Copyright (c) 2012-2019 sta.blockhead + * Copyright (c) 2012-2024 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From 3bb01b7b50e99faf63e56b0cf0b5408bcdd671d6 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 11 Nov 2024 21:18:52 +0900 Subject: [PATCH 5818/6294] [Modify] Edit it --- websocket-sharp/Net/WebHeaderCollection.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 577209503..747e95773 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1448,11 +1448,11 @@ public override string[] GetValues (string name) } /// - /// Populates a instance with the data - /// needed to serialize this instance. + /// Populates the specified instance with + /// the data needed to serialize the current instance. /// /// - /// A to populate with the data. + /// A that holds the serialized object data. /// /// /// A that specifies the destination for From 07a864f2a47c075dcf86c260fde22098d5aac6c9 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 12 Nov 2024 21:20:27 +0900 Subject: [PATCH 5819/6294] [Modify] Edit it --- websocket-sharp/Net/WebHeaderCollection.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 747e95773..27e4bb472 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -1875,11 +1875,11 @@ public override string ToString () #region Explicit Interface Implementations /// - /// Populates a instance with the data - /// needed to serialize this instance. + /// Populates the specified instance with + /// the data needed to serialize the current instance. /// /// - /// A to populate with the data. + /// A that holds the serialized object data. /// /// /// A that specifies the destination for From 03dd86859032369b6ba3081ece2c187ed79ee6a9 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 13 Nov 2024 21:17:53 +0900 Subject: [PATCH 5820/6294] [Modify] Edit it --- websocket-sharp/Net/WebHeaderCollection.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 27e4bb472..e41150811 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -561,8 +561,7 @@ internal WebHeaderCollection (HttpHeaderType state, bool internallyUsed) /// /// Initializes a new instance of the - /// class from the specified instances of the - /// and classes. + /// class with the specified serialized data. /// /// /// A that contains the serialized From 148568438a7b22e4c77ee0c6c5ead36e7e890ffa Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 13 Nov 2024 21:19:41 +0900 Subject: [PATCH 5821/6294] [Modify] Edit it --- websocket-sharp/Net/CookieException.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/CookieException.cs b/websocket-sharp/Net/CookieException.cs index e6a735d17..3c9ab3f9e 100644 --- a/websocket-sharp/Net/CookieException.cs +++ b/websocket-sharp/Net/CookieException.cs @@ -66,7 +66,7 @@ internal CookieException (string message, Exception innerException) /// /// Initializes a new instance of the class - /// with the serialized data. + /// with the specified serialized data. /// /// /// A that contains the serialized From 23c3a4962731af4311d975350c86647d3ab4d867 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 14 Nov 2024 21:33:32 +0900 Subject: [PATCH 5822/6294] [Modify] Polish it --- websocket-sharp/Net/HttpDigestIdentity.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpDigestIdentity.cs b/websocket-sharp/Net/HttpDigestIdentity.cs index 4c0c886a6..8e565e036 100644 --- a/websocket-sharp/Net/HttpDigestIdentity.cs +++ b/websocket-sharp/Net/HttpDigestIdentity.cs @@ -182,9 +182,9 @@ string entity parameters["method"] = method; parameters["entity"] = entity; - var expected = AuthenticationResponse.CreateRequestDigest (parameters); + var expectedDigest = AuthenticationResponse.CreateRequestDigest (parameters); - return _parameters["response"] == expected; + return _parameters["response"] == expectedDigest; } #endregion From b334186bcf8594602ec5d3b71242d7c319680bfe Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 15 Nov 2024 21:55:46 +0900 Subject: [PATCH 5823/6294] [Modify] 2024 --- websocket-sharp/Net/HttpDigestIdentity.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpDigestIdentity.cs b/websocket-sharp/Net/HttpDigestIdentity.cs index 8e565e036..e2863aa9c 100644 --- a/websocket-sharp/Net/HttpDigestIdentity.cs +++ b/websocket-sharp/Net/HttpDigestIdentity.cs @@ -4,7 +4,7 @@ * * The MIT License * - * Copyright (c) 2014-2023 sta.blockhead + * Copyright (c) 2014-2024 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From 638ef4a8be06cd0ac41039a4d5f4ee74326f83ac Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 16 Nov 2024 22:06:15 +0900 Subject: [PATCH 5824/6294] [Modify] Log it --- websocket-sharp/Net/HttpListener.cs | 2 +- websocket-sharp/Net/HttpListenerAsyncResult.cs | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 3eeb94d7e..44b964c0c 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -547,7 +547,7 @@ object state throw new HttpListenerException (995, msg); } - var ares = new HttpListenerAsyncResult (callback, state); + var ares = new HttpListenerAsyncResult (callback, state, _log); if (_contextQueue.Count == 0) { _waitQueue.Enqueue (ares); diff --git a/websocket-sharp/Net/HttpListenerAsyncResult.cs b/websocket-sharp/Net/HttpListenerAsyncResult.cs index a9a92bb7e..e4742d77b 100644 --- a/websocket-sharp/Net/HttpListenerAsyncResult.cs +++ b/websocket-sharp/Net/HttpListenerAsyncResult.cs @@ -59,6 +59,7 @@ internal class HttpListenerAsyncResult : IAsyncResult private HttpListenerContext _context; private bool _endCalled; private Exception _exception; + private Logger _log; private object _state; private object _sync; private ManualResetEvent _waitHandle; @@ -67,10 +68,15 @@ internal class HttpListenerAsyncResult : IAsyncResult #region Internal Constructors - internal HttpListenerAsyncResult (AsyncCallback callback, object state) + internal HttpListenerAsyncResult ( + AsyncCallback callback, + object state, + Logger log + ) { _callback = callback; _state = state; + _log = log; _sync = new object (); } @@ -160,7 +166,9 @@ private void complete () try { _callback (this); } - catch { + catch (Exception ex) { + _log.Error (ex.Message); + _log.Debug (ex.ToString ()); } }, null From 3e8a0b56ebe2555cc55096d6af1a150ea76d5685 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 17 Nov 2024 21:30:41 +0900 Subject: [PATCH 5825/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerException.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerException.cs b/websocket-sharp/Net/HttpListenerException.cs index 9b7f3011d..c087397ae 100644 --- a/websocket-sharp/Net/HttpListenerException.cs +++ b/websocket-sharp/Net/HttpListenerException.cs @@ -54,8 +54,7 @@ public class HttpListenerException : Win32Exception /// /// Initializes a new instance of the - /// class from the specified instances of the - /// and classes. + /// class with the specified serialized data. /// /// /// A that contains the serialized From 6ad5279be27ae799e62815113a8bda3fa38fd61d Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 18 Nov 2024 21:34:29 +0900 Subject: [PATCH 5826/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerException.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/websocket-sharp/Net/HttpListenerException.cs b/websocket-sharp/Net/HttpListenerException.cs index c087397ae..a3fe36c27 100644 --- a/websocket-sharp/Net/HttpListenerException.cs +++ b/websocket-sharp/Net/HttpListenerException.cs @@ -64,6 +64,9 @@ public class HttpListenerException : Win32Exception /// A that specifies the source for /// the deserialization. /// + /// + /// is . + /// protected HttpListenerException ( SerializationInfo serializationInfo, StreamingContext streamingContext From 8b1872d6fc1eeee8ef9fa396bf357614bbd5b01f Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 18 Nov 2024 21:44:42 +0900 Subject: [PATCH 5827/6294] [Modify] 2024 --- websocket-sharp/Net/HttpListenerException.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpListenerException.cs b/websocket-sharp/Net/HttpListenerException.cs index a3fe36c27..dec858d53 100644 --- a/websocket-sharp/Net/HttpListenerException.cs +++ b/websocket-sharp/Net/HttpListenerException.cs @@ -8,7 +8,7 @@ * The MIT License * * Copyright (c) 2005 Novell, Inc. (http://www.novell.com) - * Copyright (c) 2012-2023 sta.blockhead + * Copyright (c) 2012-2024 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From dd17863572cdce94ff362fbacf41629c26a00a31 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 19 Nov 2024 21:56:06 +0900 Subject: [PATCH 5828/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerPrefixCollection.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerPrefixCollection.cs b/websocket-sharp/Net/HttpListenerPrefixCollection.cs index 6d3d510fd..f5716cc83 100644 --- a/websocket-sharp/Net/HttpListenerPrefixCollection.cs +++ b/websocket-sharp/Net/HttpListenerPrefixCollection.cs @@ -127,12 +127,12 @@ public bool IsSynchronized { /// and must end with a forward slash (/). /// /// - /// - /// is . - /// /// /// is invalid. /// + /// + /// is . + /// /// /// The instance associated with this /// collection is closed. From 1f3f297e9af46102723fd22b54075e064e65aa5a Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 20 Nov 2024 21:35:16 +0900 Subject: [PATCH 5829/6294] [Modify] Edit it --- websocket-sharp/Net/HttpListenerPrefixCollection.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/HttpListenerPrefixCollection.cs b/websocket-sharp/Net/HttpListenerPrefixCollection.cs index f5716cc83..3f5c44a2c 100644 --- a/websocket-sharp/Net/HttpListenerPrefixCollection.cs +++ b/websocket-sharp/Net/HttpListenerPrefixCollection.cs @@ -208,16 +208,16 @@ public bool Contains (string uriPrefix) /// An that specifies the zero-based index in /// the array at which copying begins. /// + /// + /// The space from to the end of + /// is not enough to copy to. + /// /// /// is . /// /// /// is less than zero. /// - /// - /// The space from to the end of - /// is not enough to copy to. - /// /// /// The instance associated with this /// collection is closed. From be6ad77cc8162bb31e0c4e2358d37e2e0dc9496d Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 21 Nov 2024 20:53:53 +0900 Subject: [PATCH 5830/6294] [Modify] Edit it --- websocket-sharp/Net/NetworkCredential.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/NetworkCredential.cs b/websocket-sharp/Net/NetworkCredential.cs index fb5ec5c3e..efd412d02 100644 --- a/websocket-sharp/Net/NetworkCredential.cs +++ b/websocket-sharp/Net/NetworkCredential.cs @@ -68,12 +68,12 @@ static NetworkCredential () /// A that specifies the password for the username /// associated with the credentials. /// - /// - /// is . - /// /// /// is an empty string. /// + /// + /// is . + /// public NetworkCredential (string username, string password) : this (username, password, null, null) { From 36c81ab22adfc6cdf3b46ba92e83c83eee0b98a1 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 22 Nov 2024 21:59:37 +0900 Subject: [PATCH 5831/6294] [Modify] Edit it --- websocket-sharp/Net/NetworkCredential.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/NetworkCredential.cs b/websocket-sharp/Net/NetworkCredential.cs index efd412d02..91122f997 100644 --- a/websocket-sharp/Net/NetworkCredential.cs +++ b/websocket-sharp/Net/NetworkCredential.cs @@ -99,12 +99,12 @@ public NetworkCredential (string username, string password) /// An array of that specifies the roles associated /// with the credentials if any. /// - /// - /// is . - /// /// /// is an empty string. /// + /// + /// is . + /// public NetworkCredential ( string username, string password, string domain, params string[] roles ) From d577a25da7ffcce92b18a427b2ea832a14e70f6d Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 23 Nov 2024 21:44:24 +0900 Subject: [PATCH 5832/6294] [Modify] Polish it --- websocket-sharp/Net/NetworkCredential.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/NetworkCredential.cs b/websocket-sharp/Net/NetworkCredential.cs index 91122f997..a89ce9759 100644 --- a/websocket-sharp/Net/NetworkCredential.cs +++ b/websocket-sharp/Net/NetworkCredential.cs @@ -106,7 +106,10 @@ public NetworkCredential (string username, string password) /// is . /// public NetworkCredential ( - string username, string password, string domain, params string[] roles + string username, + string password, + string domain, + params string[] roles ) { if (username == null) From 8b05aa6f17d189c3aa35d71cbe48d361c61a4f82 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 24 Nov 2024 21:20:33 +0900 Subject: [PATCH 5833/6294] [Modify] Edit it --- websocket-sharp/Net/NetworkCredential.cs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Net/NetworkCredential.cs b/websocket-sharp/Net/NetworkCredential.cs index a89ce9759..ca9fbe773 100644 --- a/websocket-sharp/Net/NetworkCredential.cs +++ b/websocket-sharp/Net/NetworkCredential.cs @@ -131,13 +131,15 @@ params string[] roles /// /// Gets the domain associated with the credentials. /// - /// - /// This property returns an empty string if the domain was initialized - /// with . - /// /// - /// A that represents the domain name to which - /// the username belongs. + /// + /// A that represents the domain name to which + /// the username belongs. + /// + /// + /// An empty string if the domain name was initialized with + /// . + /// /// public string Domain { get { From d496b502ac21d76883a3ad2eb82f814cf62259bf Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 25 Nov 2024 21:43:27 +0900 Subject: [PATCH 5834/6294] [Modify] Edit it --- websocket-sharp/Net/NetworkCredential.cs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/Net/NetworkCredential.cs b/websocket-sharp/Net/NetworkCredential.cs index ca9fbe773..87dd4812d 100644 --- a/websocket-sharp/Net/NetworkCredential.cs +++ b/websocket-sharp/Net/NetworkCredential.cs @@ -154,12 +154,14 @@ internal set { /// /// Gets the password for the username associated with the credentials. /// - /// - /// This property returns an empty string if the password was initialized - /// with . - /// /// - /// A that represents the password. + /// + /// A that represents the password. + /// + /// + /// An empty string if the password was initialized with + /// . + /// /// public string Password { get { From 2ac92187c17054bb77311375d498024f8b554868 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 26 Nov 2024 21:27:12 +0900 Subject: [PATCH 5835/6294] [Modify] Edit it --- websocket-sharp/Net/NetworkCredential.cs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Net/NetworkCredential.cs b/websocket-sharp/Net/NetworkCredential.cs index 87dd4812d..33bba0388 100644 --- a/websocket-sharp/Net/NetworkCredential.cs +++ b/websocket-sharp/Net/NetworkCredential.cs @@ -176,13 +176,15 @@ internal set { /// /// Gets the roles associated with the credentials. /// - /// - /// This property returns an empty array if the roles were initialized - /// with . - /// /// - /// An array of that represents the role names - /// to which the username belongs. + /// + /// An array of that represents the role names + /// to which the username belongs. + /// + /// + /// An empty array if the role names were initialized with + /// . + /// /// public string[] Roles { get { From 823836d1aab805d8b262cfb8c285d5d79c6b58a2 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 27 Nov 2024 21:15:31 +0900 Subject: [PATCH 5836/6294] [Modify] Edit it --- websocket-sharp/Net/NetworkCredential.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/NetworkCredential.cs b/websocket-sharp/Net/NetworkCredential.cs index 33bba0388..24af9a403 100644 --- a/websocket-sharp/Net/NetworkCredential.cs +++ b/websocket-sharp/Net/NetworkCredential.cs @@ -133,8 +133,8 @@ params string[] roles /// /// /// - /// A that represents the domain name to which - /// the username belongs. + /// A that represents the domain name + /// to which the username belongs. /// /// /// An empty string if the domain name was initialized with From a4f20a93d40d926e05c6c08fc7463ff1eedfcc27 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 27 Nov 2024 21:17:39 +0900 Subject: [PATCH 5837/6294] [Modify] Edit it --- websocket-sharp/Net/NetworkCredential.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/NetworkCredential.cs b/websocket-sharp/Net/NetworkCredential.cs index 24af9a403..abac8a7f1 100644 --- a/websocket-sharp/Net/NetworkCredential.cs +++ b/websocket-sharp/Net/NetworkCredential.cs @@ -137,7 +137,7 @@ params string[] roles /// to which the username belongs. /// /// - /// An empty string if the domain name was initialized with + /// An empty string if the value was initialized with /// . /// /// From b408e20f0850747a2f6c9ac87841575b22498a53 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 28 Nov 2024 21:34:45 +0900 Subject: [PATCH 5838/6294] [Modify] Edit it --- websocket-sharp/Net/NetworkCredential.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/NetworkCredential.cs b/websocket-sharp/Net/NetworkCredential.cs index abac8a7f1..c8c638390 100644 --- a/websocket-sharp/Net/NetworkCredential.cs +++ b/websocket-sharp/Net/NetworkCredential.cs @@ -159,7 +159,7 @@ internal set { /// A that represents the password. /// /// - /// An empty string if the password was initialized with + /// An empty string if the value was initialized with /// . /// /// From f78f69ea19e45c8d4701ac45d7403fe7a4e2f532 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 29 Nov 2024 21:48:50 +0900 Subject: [PATCH 5839/6294] [Modify] Edit it --- websocket-sharp/Net/NetworkCredential.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/NetworkCredential.cs b/websocket-sharp/Net/NetworkCredential.cs index c8c638390..1892e7e4c 100644 --- a/websocket-sharp/Net/NetworkCredential.cs +++ b/websocket-sharp/Net/NetworkCredential.cs @@ -182,7 +182,7 @@ internal set { /// to which the username belongs. /// /// - /// An empty array if the role names were initialized with + /// An empty array if the value was initialized with /// . /// /// From f0b48c1834aac875291ec17bc6192b668a368c00 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 30 Nov 2024 21:52:25 +0900 Subject: [PATCH 5840/6294] [Modify] 2024 --- websocket-sharp/Net/NetworkCredential.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/NetworkCredential.cs b/websocket-sharp/Net/NetworkCredential.cs index 1892e7e4c..f97df971f 100644 --- a/websocket-sharp/Net/NetworkCredential.cs +++ b/websocket-sharp/Net/NetworkCredential.cs @@ -4,7 +4,7 @@ * * The MIT License * - * Copyright (c) 2014-2023 sta.blockhead + * Copyright (c) 2014-2024 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From beac69d62c6a41d1161ec5f1379014a2f87092e2 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 1 Dec 2024 21:49:37 +0900 Subject: [PATCH 5841/6294] [Modify] Polish it --- websocket-sharp/Logger.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Logger.cs b/websocket-sharp/Logger.cs index ad6135803..f6f1819d0 100644 --- a/websocket-sharp/Logger.cs +++ b/websocket-sharp/Logger.cs @@ -215,7 +215,9 @@ private void output (string message, LogLevel level) } catch (Exception ex) { var data = new LogData ( - LogLevel.Fatal, new StackFrame (0, true), ex.Message + LogLevel.Fatal, + new StackFrame (0, true), + ex.Message ); Console.WriteLine (data.ToString ()); From b27720f3df1a31a6be89ee735e142d6492d657c1 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 2 Dec 2024 22:00:32 +0900 Subject: [PATCH 5842/6294] [Modify] Edit it --- websocket-sharp/Logger.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Logger.cs b/websocket-sharp/Logger.cs index f6f1819d0..6c1b8f700 100644 --- a/websocket-sharp/Logger.cs +++ b/websocket-sharp/Logger.cs @@ -166,7 +166,7 @@ public LogLevel Level { /// An delegate. /// /// - /// It references the method used to output a log. + /// It represents the delegate called when the logger outputs a log. /// /// /// The string parameter passed to the delegate is the value of From d2b0990ef1fc729df4a00d9ffac9e6d1ea1617b7 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 3 Dec 2024 21:43:52 +0900 Subject: [PATCH 5843/6294] [Modify] 2024 --- websocket-sharp/Logger.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Logger.cs b/websocket-sharp/Logger.cs index 6c1b8f700..a280ce43f 100644 --- a/websocket-sharp/Logger.cs +++ b/websocket-sharp/Logger.cs @@ -4,7 +4,7 @@ * * The MIT License * - * Copyright (c) 2013-2022 sta.blockhead + * Copyright (c) 2013-2024 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From 9f81d26810d200d0f45c8423445739152412eb9b Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 4 Dec 2024 21:24:22 +0900 Subject: [PATCH 5844/6294] [Modify] Edit it --- websocket-sharp/LogData.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/LogData.cs b/websocket-sharp/LogData.cs index df8c96b89..af20030d7 100644 --- a/websocket-sharp/LogData.cs +++ b/websocket-sharp/LogData.cs @@ -91,8 +91,12 @@ public DateTime Date { /// Gets the logging level of the log data. /// /// - /// One of the enum values that represents - /// the logging level of the log data. + /// + /// One of the enum values. + /// + /// + /// It represents the logging level of the log data. + /// /// public LogLevel Level { get { From ef6c0c6fb0f7e8800207e3f3651767facc3326c6 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 5 Dec 2024 21:26:53 +0900 Subject: [PATCH 5845/6294] [Modify] Polish it --- websocket-sharp/LogData.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/LogData.cs b/websocket-sharp/LogData.cs index af20030d7..2372f17ae 100644 --- a/websocket-sharp/LogData.cs +++ b/websocket-sharp/LogData.cs @@ -148,8 +148,8 @@ public override string ToString () buff.AppendFormat ("{0} {1} {2}\n\n", date, level, caller); - for (var i = 0; i < msgs.Length; i++) - buff.AppendFormat (" {0}\n", msgs[i]); + foreach (var msg in msgs) + buff.AppendFormat (" {0}\n", msg); return buff.ToString (); } From b79b1b82d5e29beb6edd59889bc13934958955c4 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 6 Dec 2024 22:04:01 +0900 Subject: [PATCH 5846/6294] [Modify] 2024 --- websocket-sharp/LogData.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/LogData.cs b/websocket-sharp/LogData.cs index 2372f17ae..bb3492a9b 100644 --- a/websocket-sharp/LogData.cs +++ b/websocket-sharp/LogData.cs @@ -4,7 +4,7 @@ * * The MIT License * - * Copyright (c) 2013-2022 sta.blockhead + * Copyright (c) 2013-2024 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From 065dc50d9950f4b13450500de9eb5fe192d1b1d7 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 7 Dec 2024 21:40:32 +0900 Subject: [PATCH 5847/6294] [Modify] Rename it --- websocket-sharp/CloseEventArgs.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/CloseEventArgs.cs b/websocket-sharp/CloseEventArgs.cs index 50b01ce32..affb26fdf 100644 --- a/websocket-sharp/CloseEventArgs.cs +++ b/websocket-sharp/CloseEventArgs.cs @@ -47,7 +47,7 @@ public class CloseEventArgs : EventArgs { #region Private Fields - private bool _clean; + private bool _wasClean; private PayloadData _payloadData; #endregion @@ -57,7 +57,7 @@ public class CloseEventArgs : EventArgs internal CloseEventArgs (PayloadData payloadData, bool clean) { _payloadData = payloadData; - _clean = clean; + _wasClean = clean; } #endregion @@ -109,7 +109,7 @@ public string Reason { /// public bool WasClean { get { - return _clean; + return _wasClean; } } From 24ef0601c9ddd8e60c9ee7bb255b78e6338dc19c Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 7 Dec 2024 21:41:30 +0900 Subject: [PATCH 5848/6294] [Modify] Polish it --- websocket-sharp/CloseEventArgs.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/CloseEventArgs.cs b/websocket-sharp/CloseEventArgs.cs index affb26fdf..b7dbe5998 100644 --- a/websocket-sharp/CloseEventArgs.cs +++ b/websocket-sharp/CloseEventArgs.cs @@ -47,8 +47,8 @@ public class CloseEventArgs : EventArgs { #region Private Fields - private bool _wasClean; private PayloadData _payloadData; + private bool _wasClean; #endregion From 78c5a2a441b2f8447976c919b808ea185a75b813 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 8 Dec 2024 21:47:47 +0900 Subject: [PATCH 5849/6294] [Modify] 2024 --- websocket-sharp/CloseEventArgs.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/CloseEventArgs.cs b/websocket-sharp/CloseEventArgs.cs index b7dbe5998..8aa46e2d2 100644 --- a/websocket-sharp/CloseEventArgs.cs +++ b/websocket-sharp/CloseEventArgs.cs @@ -4,7 +4,7 @@ * * The MIT License * - * Copyright (c) 2012-2022 sta.blockhead + * Copyright (c) 2012-2024 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From f6ba776769ccaad6acadbe86d4f0f97450b5c46b Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 9 Dec 2024 21:55:46 +0900 Subject: [PATCH 5850/6294] [Modify] Edit it --- websocket-sharp/Mask.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Mask.cs b/websocket-sharp/Mask.cs index fcafac80c..f37b840ec 100644 --- a/websocket-sharp/Mask.cs +++ b/websocket-sharp/Mask.cs @@ -35,7 +35,8 @@ namespace WebSocketSharp /// /// /// The values of this enumeration are defined in - /// Section 5.2 of RFC 6455. + /// Section 5.2 of + /// RFC 6455. /// internal enum Mask : byte { From 9f7cd2ac8f97bbc01ee649e579f7e900492e4bc2 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 10 Dec 2024 22:06:10 +0900 Subject: [PATCH 5851/6294] [Modify] 2024 --- websocket-sharp/Mask.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Mask.cs b/websocket-sharp/Mask.cs index f37b840ec..18068b521 100644 --- a/websocket-sharp/Mask.cs +++ b/websocket-sharp/Mask.cs @@ -4,7 +4,7 @@ * * The MIT License * - * Copyright (c) 2012-2015 sta.blockhead + * Copyright (c) 2012-2024 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From 3665e5e138e5358eae1de67681cbe0fc192ddee6 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 11 Dec 2024 21:57:18 +0900 Subject: [PATCH 5852/6294] [Modify] Edit it --- websocket-sharp/Mask.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Mask.cs b/websocket-sharp/Mask.cs index 18068b521..68b6171c0 100644 --- a/websocket-sharp/Mask.cs +++ b/websocket-sharp/Mask.cs @@ -35,8 +35,8 @@ namespace WebSocketSharp /// /// /// The values of this enumeration are defined in - /// Section 5.2 of - /// RFC 6455. + /// + /// Section 5.2 of RFC 6455. /// internal enum Mask : byte { From 2fb9da7ce7c1cc8e53f3e0311dd5470ca1314d18 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 12 Dec 2024 21:39:07 +0900 Subject: [PATCH 5853/6294] [Modify] Edit it --- websocket-sharp/Rsv.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Rsv.cs b/websocket-sharp/Rsv.cs index 8a10567c5..1973006a4 100644 --- a/websocket-sharp/Rsv.cs +++ b/websocket-sharp/Rsv.cs @@ -31,11 +31,13 @@ namespace WebSocketSharp { /// - /// Indicates whether each RSV (RSV1, RSV2, and RSV3) of a WebSocket frame is non-zero. + /// Indicates whether each RSV (RSV1, RSV2, and RSV3) of a WebSocket + /// frame is non-zero. /// /// /// The values of this enumeration are defined in - /// Section 5.2 of RFC 6455. + /// + /// Section 5.2 of RFC 6455. /// internal enum Rsv : byte { From 9d95bf807f9f398708ff860c7646f3bde70ee021 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 13 Dec 2024 22:18:51 +0900 Subject: [PATCH 5854/6294] [Modify] 2024 --- websocket-sharp/Rsv.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Rsv.cs b/websocket-sharp/Rsv.cs index 1973006a4..d2a086e56 100644 --- a/websocket-sharp/Rsv.cs +++ b/websocket-sharp/Rsv.cs @@ -4,7 +4,7 @@ * * The MIT License * - * Copyright (c) 2012-2015 sta.blockhead + * Copyright (c) 2012-2024 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From e60f5b9ad4f3803b0552050094a0596296173319 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 14 Dec 2024 21:48:12 +0900 Subject: [PATCH 5855/6294] [Modify] Polish it --- websocket-sharp/WebSocketException.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocketException.cs b/websocket-sharp/WebSocketException.cs index 6dfe0b126..0a607aecb 100644 --- a/websocket-sharp/WebSocketException.cs +++ b/websocket-sharp/WebSocketException.cs @@ -45,7 +45,9 @@ public class WebSocketException : Exception #region Private Constructors private WebSocketException ( - ushort code, string message, Exception innerException + ushort code, + string message, + Exception innerException ) : base (message ?? code.GetErrorMessage (), innerException) { From 3bbc45c324da23ee288e3ef8e9d733d1b3336bc6 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 15 Dec 2024 22:00:04 +0900 Subject: [PATCH 5856/6294] [Modify] Polish it --- websocket-sharp/WebSocketException.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocketException.cs b/websocket-sharp/WebSocketException.cs index 0a607aecb..c2356b444 100644 --- a/websocket-sharp/WebSocketException.cs +++ b/websocket-sharp/WebSocketException.cs @@ -94,7 +94,9 @@ internal WebSocketException (CloseStatusCode code, string message) } internal WebSocketException ( - CloseStatusCode code, string message, Exception innerException + CloseStatusCode code, + string message, + Exception innerException ) : this ((ushort) code, message, innerException) { From 356af902916c1962406c8adccc317e5726cec5ab Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 16 Dec 2024 21:48:06 +0900 Subject: [PATCH 5857/6294] [Modify] 2024 --- websocket-sharp/WebSocketException.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocketException.cs b/websocket-sharp/WebSocketException.cs index c2356b444..12bfc48f8 100644 --- a/websocket-sharp/WebSocketException.cs +++ b/websocket-sharp/WebSocketException.cs @@ -4,7 +4,7 @@ * * The MIT License * - * Copyright (c) 2012-2022 sta.blockhead + * Copyright (c) 2012-2024 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From 1904d7c21c79918ef7ccb5b49f403ce559efc9bb Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 17 Dec 2024 21:37:40 +0900 Subject: [PATCH 5858/6294] [Modify] Polish it --- websocket-sharp/WebSocketFrame.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index 874947e52..95b191d44 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -81,7 +81,11 @@ private WebSocketFrame () #region Internal Constructors internal WebSocketFrame ( - Fin fin, Opcode opcode, byte[] data, bool compressed, bool mask + Fin fin, + Opcode opcode, + byte[] data, + bool compressed, + bool mask ) : this (fin, opcode, new PayloadData (data), compressed, mask) { From 22b40f79c12ab1d8db742e7ca12d7002e0496f71 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 18 Dec 2024 21:45:55 +0900 Subject: [PATCH 5859/6294] [Modify] Polish it --- websocket-sharp/WebSocketFrame.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index 95b191d44..202715c28 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -367,7 +367,8 @@ private static WebSocketFrame processHeader (byte[] header) } private static WebSocketFrame readExtendedPayloadLength ( - Stream stream, WebSocketFrame frame + Stream stream, + WebSocketFrame frame ) { var len = frame.ExtendedPayloadLengthWidth; From 5dc3bfdd99e5b1d93e0d7f0257f9437f26b1a69e Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 19 Dec 2024 21:45:16 +0900 Subject: [PATCH 5860/6294] [Modify] Polish it --- websocket-sharp/WebSocketFrame.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index 202715c28..af18a4ddf 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -434,7 +434,9 @@ private static WebSocketFrame readHeader (Stream stream) } private static void readHeaderAsync ( - Stream stream, Action completed, Action error + Stream stream, + Action completed, + Action error ) { stream.ReadBytesAsync ( From 27ca5e951dab3dde9ec1221ceb58f66ec57c8fdf Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 20 Dec 2024 21:59:28 +0900 Subject: [PATCH 5861/6294] [Modify] Polish it --- websocket-sharp/WebSocketFrame.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index af18a4ddf..722b83265 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -451,7 +451,8 @@ Action error } private static WebSocketFrame readMaskingKey ( - Stream stream, WebSocketFrame frame + Stream stream, + WebSocketFrame frame ) { if (!frame.IsMasked) { From 837197d1bbb3bfc0235370e1027d131ba2250ee7 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 21 Dec 2024 21:59:16 +0900 Subject: [PATCH 5862/6294] [Modify] Polish it --- websocket-sharp/WebSocketFrame.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index 722b83265..952d51631 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -507,7 +507,8 @@ Action error } private static WebSocketFrame readPayloadData ( - Stream stream, WebSocketFrame frame + Stream stream, + WebSocketFrame frame ) { var exactPayloadLen = frame.ExactPayloadLength; From 27b64c46a10a0507c62faedfa5d69e768e66b023 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 22 Dec 2024 21:38:53 +0900 Subject: [PATCH 5863/6294] [Modify] Polish it --- websocket-sharp/WebSocketFrame.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index 952d51631..4fb75ef9c 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -633,7 +633,12 @@ private string toDumpString () return (arg1, arg2, arg3, arg4) => { buff.AppendFormat ( - lineFmt, ++lineCnt, arg1, arg2, arg3, arg4 + lineFmt, + ++lineCnt, + arg1, + arg2, + arg3, + arg4 ); }; }; From 5428cdbc5a00d915db999232f4edb3bd4901064e Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 23 Dec 2024 21:33:19 +0900 Subject: [PATCH 5864/6294] [Modify] Polish it --- websocket-sharp/WebSocketFrame.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index 4fb75ef9c..ea8d6a867 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -728,11 +728,16 @@ private string toString () #region Internal Methods internal static WebSocketFrame CreateCloseFrame ( - PayloadData payloadData, bool mask + PayloadData payloadData, + bool mask ) { return new WebSocketFrame ( - Fin.Final, Opcode.Close, payloadData, false, mask + Fin.Final, + Opcode.Close, + payloadData, + false, + mask ); } From 947f82a4abccfc781f8263425ddab0ff4c8f7088 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 24 Dec 2024 21:39:21 +0900 Subject: [PATCH 5865/6294] [Modify] Polish it --- websocket-sharp/WebSocketFrame.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index ea8d6a867..15d7f8c63 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -744,7 +744,11 @@ bool mask internal static WebSocketFrame CreatePingFrame (bool mask) { return new WebSocketFrame ( - Fin.Final, Opcode.Ping, PayloadData.Empty, false, mask + Fin.Final, + Opcode.Ping, + PayloadData.Empty, + false, + mask ); } From f30193b2ffb40cb14c0154e5d64aceed2ea4ac28 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 25 Dec 2024 21:35:03 +0900 Subject: [PATCH 5866/6294] [Modify] Polish it --- websocket-sharp/WebSocketFrame.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index 15d7f8c63..d18ac89fc 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -755,7 +755,11 @@ internal static WebSocketFrame CreatePingFrame (bool mask) internal static WebSocketFrame CreatePingFrame (byte[] data, bool mask) { return new WebSocketFrame ( - Fin.Final, Opcode.Ping, new PayloadData (data), false, mask + Fin.Final, + Opcode.Ping, + new PayloadData (data), + false, + mask ); } From 3174bccc48eec3f229b37605750c28029d6e7c5a Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 26 Dec 2024 21:41:57 +0900 Subject: [PATCH 5867/6294] [Modify] Polish it --- websocket-sharp/WebSocketFrame.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index d18ac89fc..dd6d8810f 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -764,11 +764,16 @@ internal static WebSocketFrame CreatePingFrame (byte[] data, bool mask) } internal static WebSocketFrame CreatePongFrame ( - PayloadData payloadData, bool mask + PayloadData payloadData, + bool mask ) { return new WebSocketFrame ( - Fin.Final, Opcode.Pong, payloadData, false, mask + Fin.Final, + Opcode.Pong, + payloadData, + false, + mask ); } From 09ebb49493465b7d05fbf5cfb62ce3a51e3e2979 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 27 Dec 2024 21:43:36 +0900 Subject: [PATCH 5868/6294] [Modify] Polish it --- websocket-sharp/WebSocketFrame.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index dd6d8810f..406f88eaa 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -355,6 +355,7 @@ private static WebSocketFrame processHeader (byte[] header) } var frame = new WebSocketFrame (); + frame._fin = fin; frame._rsv1 = rsv1; frame._rsv2 = rsv2; From 79e43e9a6c27f50cb799f821010c176b6ccf21ac Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 28 Dec 2024 21:53:56 +0900 Subject: [PATCH 5869/6294] [Modify] Polish it --- websocket-sharp/WebSocketFrame.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index 406f88eaa..e7fb77e15 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -859,6 +859,7 @@ public byte[] ToArray () { using (var buff = new MemoryStream ()) { var header = (int) _fin; + header = (header << 1) + (int) _rsv1; header = (header << 1) + (int) _rsv2; header = (header << 1) + (int) _rsv3; From 176664396dc52ba83405c71de8579e879d1034a0 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 29 Dec 2024 21:39:00 +0900 Subject: [PATCH 5870/6294] [Modify] Replace it --- websocket-sharp/WebSocketFrame.cs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index e7fb77e15..e66f80b20 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -47,6 +47,7 @@ internal class WebSocketFrame : IEnumerable private static readonly int _defaultHeaderLength; private static readonly int _defaultMaskingKeyLength; + private static readonly byte[] _emptyBytes; private byte[] _extPayloadLength; private Fin _fin; private Mask _mask; @@ -66,6 +67,7 @@ static WebSocketFrame () { _defaultHeaderLength = 2; _defaultMaskingKeyLength = 4; + _emptyBytes = new byte[0]; } #endregion @@ -110,7 +112,7 @@ bool mask if (len < 126) { _payloadLength = (byte) len; - _extPayloadLength = WebSocket.EmptyBytes; + _extPayloadLength = _emptyBytes; } else if (len < 0x010000) { _payloadLength = (byte) 126; @@ -129,7 +131,7 @@ bool mask } else { _mask = Mask.Off; - _maskingKey = WebSocket.EmptyBytes; + _maskingKey = _emptyBytes; } _payloadData = payloadData; @@ -375,7 +377,7 @@ WebSocketFrame frame var len = frame.ExtendedPayloadLengthWidth; if (len == 0) { - frame._extPayloadLength = WebSocket.EmptyBytes; + frame._extPayloadLength = _emptyBytes; return frame; } @@ -403,7 +405,7 @@ Action error var len = frame.ExtendedPayloadLengthWidth; if (len == 0) { - frame._extPayloadLength = WebSocket.EmptyBytes; + frame._extPayloadLength = _emptyBytes; completed (frame); @@ -457,7 +459,7 @@ WebSocketFrame frame ) { if (!frame.IsMasked) { - frame._maskingKey = WebSocket.EmptyBytes; + frame._maskingKey = _emptyBytes; return frame; } @@ -483,7 +485,7 @@ Action error ) { if (!frame.IsMasked) { - frame._maskingKey = WebSocket.EmptyBytes; + frame._maskingKey = _emptyBytes; completed (frame); @@ -841,7 +843,7 @@ internal void Unmask () _payloadData.Mask (_maskingKey); - _maskingKey = WebSocket.EmptyBytes; + _maskingKey = _emptyBytes; _mask = Mask.Off; } From 5554007ed3a6ee6d8955f23cf74c2b205993b842 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 30 Dec 2024 21:47:31 +0900 Subject: [PATCH 5871/6294] [Modify] Polish it --- websocket-sharp/WebSocketFrame.cs | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index e66f80b20..238634a03 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -45,19 +45,19 @@ internal class WebSocketFrame : IEnumerable { #region Private Fields - private static readonly int _defaultHeaderLength; - private static readonly int _defaultMaskingKeyLength; + private static readonly int _defaultHeaderLength; + private static readonly int _defaultMaskingKeyLength; private static readonly byte[] _emptyBytes; - private byte[] _extPayloadLength; - private Fin _fin; - private Mask _mask; - private byte[] _maskingKey; - private Opcode _opcode; - private PayloadData _payloadData; - private byte _payloadLength; - private Rsv _rsv1; - private Rsv _rsv2; - private Rsv _rsv3; + private byte[] _extPayloadLength; + private Fin _fin; + private Mask _mask; + private byte[] _maskingKey; + private Opcode _opcode; + private PayloadData _payloadData; + private byte _payloadLength; + private Rsv _rsv1; + private Rsv _rsv2; + private Rsv _rsv3; #endregion From 1fc1c6e7d16203e536f272dcbeb0dbf2e59337c3 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 31 Dec 2024 16:45:04 +0900 Subject: [PATCH 5872/6294] [Modify] 2024 --- websocket-sharp/WebSocketFrame.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index 238634a03..86ce81b9d 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -4,7 +4,7 @@ * * The MIT License * - * Copyright (c) 2012-2023 sta.blockhead + * Copyright (c) 2012-2024 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From 0cbd542666a64f6925142bec1efbacb50be74e44 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 1 Jan 2025 16:47:54 +0900 Subject: [PATCH 5873/6294] [Modify] 2025! --- LICENSE.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LICENSE.txt b/LICENSE.txt index 6903008b3..b8fa987a2 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2010-2024 sta.blockhead +Copyright (c) 2010-2025 sta.blockhead Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal From 4776fe5a5bf6ecf98429af5e3300d43e4506297f Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 2 Jan 2025 16:16:01 +0900 Subject: [PATCH 5874/6294] [Modify] Replace it --- websocket-sharp/PayloadData.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/PayloadData.cs b/websocket-sharp/PayloadData.cs index 6d17bc2a0..73aa7b45e 100644 --- a/websocket-sharp/PayloadData.cs +++ b/websocket-sharp/PayloadData.cs @@ -37,6 +37,7 @@ internal class PayloadData : IEnumerable #region Private Fields private byte[] _data; + private static readonly byte[] _emptyBytes; private long _extDataLength; private long _length; @@ -71,7 +72,8 @@ internal class PayloadData : IEnumerable static PayloadData () { - Empty = new PayloadData (WebSocket.EmptyBytes, 0); + _emptyBytes = new byte[0]; + Empty = new PayloadData (_emptyBytes, 0); MaxLength = Int64.MaxValue; } @@ -155,7 +157,7 @@ public byte[] ExtensionData { get { return _extDataLength > 0 ? _data.SubArray (0, _extDataLength) - : WebSocket.EmptyBytes; + : _emptyBytes; } } From 34880ff433e4592f8bad9b3a8dc6abb11a77dcad Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 2 Jan 2025 16:17:20 +0900 Subject: [PATCH 5875/6294] [Modify] Polish it --- websocket-sharp/PayloadData.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/PayloadData.cs b/websocket-sharp/PayloadData.cs index 73aa7b45e..30ab94c35 100644 --- a/websocket-sharp/PayloadData.cs +++ b/websocket-sharp/PayloadData.cs @@ -36,10 +36,10 @@ internal class PayloadData : IEnumerable { #region Private Fields - private byte[] _data; + private byte[] _data; private static readonly byte[] _emptyBytes; - private long _extDataLength; - private long _length; + private long _extDataLength; + private long _length; #endregion From f676e24a33ce4a5738cfa6be5f12d1818b3280a4 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 3 Jan 2025 15:55:23 +0900 Subject: [PATCH 5876/6294] [Modify] Polish it --- websocket-sharp/PayloadData.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/PayloadData.cs b/websocket-sharp/PayloadData.cs index 30ab94c35..d6ff2fa42 100644 --- a/websocket-sharp/PayloadData.cs +++ b/websocket-sharp/PayloadData.cs @@ -73,6 +73,7 @@ internal class PayloadData : IEnumerable static PayloadData () { _emptyBytes = new byte[0]; + Empty = new PayloadData (_emptyBytes, 0); MaxLength = Int64.MaxValue; } From d430142e1be269937d453179f26f759681d48628 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 4 Jan 2025 16:06:37 +0900 Subject: [PATCH 5877/6294] [Modify] 2025 --- websocket-sharp/PayloadData.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/PayloadData.cs b/websocket-sharp/PayloadData.cs index d6ff2fa42..e01fcd27e 100644 --- a/websocket-sharp/PayloadData.cs +++ b/websocket-sharp/PayloadData.cs @@ -4,7 +4,7 @@ * * The MIT License * - * Copyright (c) 2012-2022 sta.blockhead + * Copyright (c) 2012-2025 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From fbe8fe78ef131cfaa3ec4a13d128cf12482a33d3 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 5 Jan 2025 15:51:27 +0900 Subject: [PATCH 5878/6294] [Modify] Rename it --- websocket-sharp/Net/HttpConnection.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/HttpConnection.cs b/websocket-sharp/Net/HttpConnection.cs index 1f8a497ad..e55f2ed13 100644 --- a/websocket-sharp/Net/HttpConnection.cs +++ b/websocket-sharp/Net/HttpConnection.cs @@ -76,7 +76,7 @@ internal sealed class HttpConnection private EndPoint _remoteEndPoint; private MemoryStream _requestBuffer; private int _reuses; - private bool _secure; + private bool _isSecure; private Socket _socket; private Stream _stream; private object _sync; @@ -120,7 +120,7 @@ internal HttpConnection (Socket socket, EndPointListener listener) sslConf.CheckCertificateRevocation ); - _secure = true; + _isSecure = true; _stream = sslStream; } else { @@ -156,7 +156,7 @@ public bool IsLocal { public bool IsSecure { get { - return _secure; + return _isSecure; } } From 8ab24d86adec754cd9bebfed171545430c49789c Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 6 Jan 2025 15:46:42 +0900 Subject: [PATCH 5879/6294] [Modify] Polish it --- websocket-sharp/Net/HttpConnection.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpConnection.cs b/websocket-sharp/Net/HttpConnection.cs index e55f2ed13..2eb3f835e 100644 --- a/websocket-sharp/Net/HttpConnection.cs +++ b/websocket-sharp/Net/HttpConnection.cs @@ -68,6 +68,7 @@ internal sealed class HttpConnection private EndPointListener _endPointListener; private InputState _inputState; private RequestStream _inputStream; + private bool _isSecure; private LineState _lineState; private EndPoint _localEndPoint; private static readonly int _maxInputLength; @@ -76,7 +77,6 @@ internal sealed class HttpConnection private EndPoint _remoteEndPoint; private MemoryStream _requestBuffer; private int _reuses; - private bool _isSecure; private Socket _socket; private Stream _stream; private object _sync; From a50134284da4cd992ae8f1ef8915e026252c23a8 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 7 Jan 2025 16:08:46 +0900 Subject: [PATCH 5880/6294] [Modify] 2025 --- websocket-sharp/Net/HttpConnection.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/HttpConnection.cs b/websocket-sharp/Net/HttpConnection.cs index 2eb3f835e..92c2ead58 100644 --- a/websocket-sharp/Net/HttpConnection.cs +++ b/websocket-sharp/Net/HttpConnection.cs @@ -8,7 +8,7 @@ * The MIT License * * Copyright (c) 2005 Novell, Inc. (http://www.novell.com) - * Copyright (c) 2012-2023 sta.blockhead + * Copyright (c) 2012-2025 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From ca5b789052d04cf0f396fcbf5fcbb0c782ee6a22 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 8 Jan 2025 15:46:30 +0900 Subject: [PATCH 5881/6294] [Modify] Edit it --- websocket-sharp/Fin.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Fin.cs b/websocket-sharp/Fin.cs index 8965c378e..8c5c6658f 100644 --- a/websocket-sharp/Fin.cs +++ b/websocket-sharp/Fin.cs @@ -35,7 +35,8 @@ namespace WebSocketSharp /// /// /// The values of this enumeration are defined in - /// Section 5.2 of RFC 6455. + /// + /// Section 5.2 of RFC 6455. /// internal enum Fin : byte { From ff2309d98e76b0742856ab86a329e270e2ea56c7 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 9 Jan 2025 21:47:33 +0900 Subject: [PATCH 5882/6294] [Modify] 2025 --- websocket-sharp/Fin.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Fin.cs b/websocket-sharp/Fin.cs index 8c5c6658f..1c4f29332 100644 --- a/websocket-sharp/Fin.cs +++ b/websocket-sharp/Fin.cs @@ -4,7 +4,7 @@ * * The MIT License * - * Copyright (c) 2012-2015 sta.blockhead + * Copyright (c) 2012-2025 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From 1e46b0da67e310242ef3944b7aa229888902bcaa Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 10 Jan 2025 22:15:05 +0900 Subject: [PATCH 5883/6294] [Modify] Use default type (int) --- websocket-sharp/Ext.cs | 2 +- websocket-sharp/Fin.cs | 2 +- websocket-sharp/Mask.cs | 2 +- websocket-sharp/Opcode.cs | 2 +- websocket-sharp/Rsv.cs | 2 +- websocket-sharp/WebSocketFrame.cs | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 0df7f3c25..e569746c5 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -585,7 +585,7 @@ internal static bool IsReservedStatusCode (this ushort code) || code == 1015; } - internal static bool IsSupportedOpcode (this byte opcode) + internal static bool IsSupportedOpcode (this int opcode) { return Enum.IsDefined (typeof (Opcode), opcode); } diff --git a/websocket-sharp/Fin.cs b/websocket-sharp/Fin.cs index 1c4f29332..36622d7e5 100644 --- a/websocket-sharp/Fin.cs +++ b/websocket-sharp/Fin.cs @@ -38,7 +38,7 @@ namespace WebSocketSharp /// /// Section 5.2 of RFC 6455. /// - internal enum Fin : byte + internal enum Fin { /// /// Equivalent to numeric value 0. Indicates more frames of a message follow. diff --git a/websocket-sharp/Mask.cs b/websocket-sharp/Mask.cs index 68b6171c0..fb0ef1067 100644 --- a/websocket-sharp/Mask.cs +++ b/websocket-sharp/Mask.cs @@ -38,7 +38,7 @@ namespace WebSocketSharp /// /// Section 5.2 of RFC 6455. /// - internal enum Mask : byte + internal enum Mask { /// /// Equivalent to numeric value 0. Indicates not masked. diff --git a/websocket-sharp/Opcode.cs b/websocket-sharp/Opcode.cs index 5a8c632e0..e7bdf6ed5 100644 --- a/websocket-sharp/Opcode.cs +++ b/websocket-sharp/Opcode.cs @@ -38,7 +38,7 @@ namespace WebSocketSharp /// /// Section 5.2 of RFC 6455. /// - internal enum Opcode : byte + internal enum Opcode { /// /// Equivalent to numeric value 0. Indicates continuation frame. diff --git a/websocket-sharp/Rsv.cs b/websocket-sharp/Rsv.cs index d2a086e56..ee245c3f4 100644 --- a/websocket-sharp/Rsv.cs +++ b/websocket-sharp/Rsv.cs @@ -39,7 +39,7 @@ namespace WebSocketSharp /// /// Section 5.2 of RFC 6455. /// - internal enum Rsv : byte + internal enum Rsv { /// /// Equivalent to numeric value 0. Indicates zero. diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index 86ce81b9d..7d4347695 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -342,7 +342,7 @@ private static WebSocketFrame processHeader (byte[] header) var rsv3 = (header[0] & 0x10) == 0x10 ? Rsv.On : Rsv.Off; // Opcode - var opcode = (byte) (header[0] & 0x0f); + var opcode = header[0] & 0x0f; // MASK var mask = (header[1] & 0x80) == 0x80 ? Mask.On : Mask.Off; From cb66fc4ff4603fb784b25577e128f94594586ab4 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 11 Jan 2025 15:51:34 +0900 Subject: [PATCH 5884/6294] [Modify] 2025 --- websocket-sharp/Rsv.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Rsv.cs b/websocket-sharp/Rsv.cs index ee245c3f4..c2a4dea7a 100644 --- a/websocket-sharp/Rsv.cs +++ b/websocket-sharp/Rsv.cs @@ -4,7 +4,7 @@ * * The MIT License * - * Copyright (c) 2012-2024 sta.blockhead + * Copyright (c) 2012-2025 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From 341d307a1d323cd42f5d8bf69eb571e36cec93de Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 12 Jan 2025 22:43:47 +0900 Subject: [PATCH 5885/6294] [Modify] 2025 --- websocket-sharp/Opcode.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Opcode.cs b/websocket-sharp/Opcode.cs index e7bdf6ed5..06da1b5e1 100644 --- a/websocket-sharp/Opcode.cs +++ b/websocket-sharp/Opcode.cs @@ -4,7 +4,7 @@ * * The MIT License * - * Copyright (c) 2012-2016 sta.blockhead + * Copyright (c) 2012-2025 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From 07a7186b1212bee990198c90e3915db9a092cb55 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 13 Jan 2025 16:52:25 +0900 Subject: [PATCH 5886/6294] [Modify] 2025 --- websocket-sharp/Mask.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Mask.cs b/websocket-sharp/Mask.cs index fb0ef1067..2958f5a83 100644 --- a/websocket-sharp/Mask.cs +++ b/websocket-sharp/Mask.cs @@ -4,7 +4,7 @@ * * The MIT License * - * Copyright (c) 2012-2024 sta.blockhead + * Copyright (c) 2012-2025 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From dbe1c136b7e27223d2532b495644a402d6d555d9 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 14 Jan 2025 16:05:00 +0900 Subject: [PATCH 5887/6294] [Modify] Use int --- websocket-sharp/WebSocketFrame.cs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index 7d4347695..bf7d815a5 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -54,7 +54,7 @@ internal class WebSocketFrame : IEnumerable private byte[] _maskingKey; private Opcode _opcode; private PayloadData _payloadData; - private byte _payloadLength; + private int _payloadLength; private Rsv _rsv1; private Rsv _rsv2; private Rsv _rsv3; @@ -111,15 +111,15 @@ bool mask var len = payloadData.Length; if (len < 126) { - _payloadLength = (byte) len; + _payloadLength = (int) len; _extPayloadLength = _emptyBytes; } else if (len < 0x010000) { - _payloadLength = (byte) 126; + _payloadLength = 126; _extPayloadLength = ((ushort) len).ToByteArray (ByteOrder.Big); } else { - _payloadLength = (byte) 127; + _payloadLength = 127; _extPayloadLength = len.ToByteArray (ByteOrder.Big); } @@ -144,7 +144,7 @@ bool mask internal ulong ExactPayloadLength { get { return _payloadLength < 126 - ? _payloadLength + ? (ulong) _payloadLength : _payloadLength == 126 ? _extPayloadLength.ToUInt16 (ByteOrder.Big) : _extPayloadLength.ToUInt64 (ByteOrder.Big); @@ -284,7 +284,7 @@ public PayloadData PayloadData { } } - public byte PayloadLength { + public int PayloadLength { get { return _payloadLength; } @@ -348,7 +348,7 @@ private static WebSocketFrame processHeader (byte[] header) var mask = (header[1] & 0x80) == 0x80 ? Mask.On : Mask.Off; // Payload Length - var payloadLen = (byte) (header[1] & 0x7f); + var payloadLen = header[1] & 0x7f; if (!opcode.IsSupportedOpcode ()) { var msg = "The opcode of a frame is not supported."; @@ -867,7 +867,7 @@ public byte[] ToArray () header = (header << 1) + (int) _rsv3; header = (header << 4) + (int) _opcode; header = (header << 1) + (int) _mask; - header = (header << 7) + (int) _payloadLength; + header = (header << 7) + _payloadLength; var uint16Header = (ushort) header; var rawHeader = uint16Header.ToByteArray (ByteOrder.Big); From 42865f4cd5f0e245b42a237737d1801a00e4071a Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 15 Jan 2025 22:02:24 +0900 Subject: [PATCH 5888/6294] [Modify] Polish it --- websocket-sharp/WebSocketFrame.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index bf7d815a5..8ea484f26 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -869,8 +869,8 @@ public byte[] ToArray () header = (header << 1) + (int) _mask; header = (header << 7) + _payloadLength; - var uint16Header = (ushort) header; - var rawHeader = uint16Header.ToByteArray (ByteOrder.Big); + var headerAsUInt16 = (ushort) header; + var rawHeader = headerAsUInt16.ToByteArray (ByteOrder.Big); buff.Write (rawHeader, 0, _defaultHeaderLength); From 47558510b8c15f2673747396481361860ffba20a Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 16 Jan 2025 22:01:17 +0900 Subject: [PATCH 5889/6294] [Modify] Polish it --- websocket-sharp/WebSocketFrame.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index 8ea484f26..338346ad1 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -870,9 +870,9 @@ public byte[] ToArray () header = (header << 7) + _payloadLength; var headerAsUInt16 = (ushort) header; - var rawHeader = headerAsUInt16.ToByteArray (ByteOrder.Big); + var headerAsBytes = headerAsUInt16.ToByteArray (ByteOrder.Big); - buff.Write (rawHeader, 0, _defaultHeaderLength); + buff.Write (headerAsBytes, 0, _defaultHeaderLength); if (_payloadLength >= 126) buff.Write (_extPayloadLength, 0, _extPayloadLength.Length); From 813ccb15660fbf9f1bcaef84ba941c156ffb040e Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 17 Jan 2025 16:01:48 +0900 Subject: [PATCH 5890/6294] [Modify] 2025 --- websocket-sharp/WebSocketFrame.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index 338346ad1..9ce51b945 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -4,7 +4,7 @@ * * The MIT License * - * Copyright (c) 2012-2024 sta.blockhead + * Copyright (c) 2012-2025 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From cd1061b616dbb5d8d1805e6726c9085e5ade0dd4 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 18 Jan 2025 15:51:36 +0900 Subject: [PATCH 5891/6294] [Modify] Replace it --- websocket-sharp/WebSocket.cs | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index a9636e6a2..a9f357921 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -81,6 +81,7 @@ public class WebSocket : IDisposable private CookieCollection _cookies; private NetworkCredential _credentials; private bool _emitOnPing; + private static readonly byte[] _emptyBytes; private bool _enableRedirection; private string _extensions; private bool _extensionsRequested; @@ -124,11 +125,6 @@ public class WebSocket : IDisposable #region Internal Fields - /// - /// Represents the empty array of used internally. - /// - internal static readonly byte[] EmptyBytes; - /// /// Represents the length used to determine whether the data should /// be fragmented in sending. @@ -157,7 +153,7 @@ public class WebSocket : IDisposable static WebSocket () { _maxRetryCountForConnect = 10; - EmptyBytes = new byte[0]; + _emptyBytes = new byte[0]; FragmentLength = 1016; RandomNumber = new RNGCryptoServiceProvider (); } @@ -495,7 +491,7 @@ public string Extensions { /// public bool IsAlive { get { - return ping (EmptyBytes); + return ping (_emptyBytes); } } @@ -2031,7 +2027,7 @@ private bool send (Opcode opcode, Stream dataStream, bool compressed) var len = dataStream.Length; if (len == 0) - return send (Fin.Final, opcode, EmptyBytes, false); + return send (Fin.Final, opcode, _emptyBytes, false); var quo = len / FragmentLength; var rem = (int) (len % FragmentLength); @@ -3315,7 +3311,7 @@ public void ConnectAsync () /// public bool Ping () { - return ping (EmptyBytes); + return ping (_emptyBytes); } /// @@ -3342,7 +3338,7 @@ public bool Ping () public bool Ping (string message) { if (message.IsNullOrEmpty ()) - return ping (EmptyBytes); + return ping (_emptyBytes); byte[] bytes; From 3e2e502b8983054e4439ba7244a6711a879a609f Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 19 Jan 2025 22:08:43 +0900 Subject: [PATCH 5892/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index a9f357921..9bae559b2 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -152,8 +152,9 @@ public class WebSocket : IDisposable static WebSocket () { - _maxRetryCountForConnect = 10; _emptyBytes = new byte[0]; + _maxRetryCountForConnect = 10; + FragmentLength = 1016; RandomNumber = new RNGCryptoServiceProvider (); } From 7a4ea6d0cd159f790a6cf02dd1e4ac00420da865 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 20 Jan 2025 21:53:31 +0900 Subject: [PATCH 5893/6294] [Modify] 2025 --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 9bae559b2..791960f97 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -8,7 +8,7 @@ * The MIT License * * Copyright (c) 2009 Adam MacBeth - * Copyright (c) 2010-2022 sta.blockhead + * Copyright (c) 2010-2025 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From aa809ed8e0d1c51492098b343606889b3a905966 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 21 Jan 2025 21:54:20 +0900 Subject: [PATCH 5894/6294] [Modify] Add it --- websocket-sharp/Ext.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index e569746c5..2d8dbe46b 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -544,6 +544,11 @@ CompressionMethod method return value.StartsWith (extStr, compType); } + internal static bool IsDefined (this CloseStatusCode code) + { + return Enum.IsDefined (typeof (CloseStatusCode), code); + } + internal static bool IsEqualTo ( this int value, char c, From 9c7abc349f8db56ed144b48fccd3fd6b02bc1d71 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 22 Jan 2025 21:43:50 +0900 Subject: [PATCH 5895/6294] [Modify] 2025 --- websocket-sharp/Ext.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 2d8dbe46b..2540f803e 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -14,7 +14,7 @@ * Copyright (c) 2003 Ben Maurer * Copyright (c) 2003, 2005, 2009 Novell, Inc. (http://www.novell.com) * Copyright (c) 2009 Stephane Delcroix - * Copyright (c) 2010-2023 sta.blockhead + * Copyright (c) 2010-2025 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From 534772763ad42c549dae053dcc05653bb0e05738 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 23 Jan 2025 16:19:37 +0900 Subject: [PATCH 5896/6294] [Modify] Add a check if it is defined --- websocket-sharp/WebSocket.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 791960f97..7202239b9 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2825,6 +2825,12 @@ public void Close (ushort code, string reason) /// /// /// + /// is an undefined enum value. + /// + /// + /// -or- + /// + /// /// is . /// It cannot be used by a client. /// @@ -2854,6 +2860,12 @@ public void Close (ushort code, string reason) /// public void Close (CloseStatusCode code, string reason) { + if (!code.IsDefined ()) { + var msg = "An undefined enum value."; + + throw new ArgumentException (msg, "code"); + } + if (_client && code == CloseStatusCode.ServerError) { var msg = "ServerError cannot be used."; From 24fd07d55059479353b81e672f72cbfc8fa27109 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 24 Jan 2025 15:57:24 +0900 Subject: [PATCH 5897/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 7202239b9..570bbbd82 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2866,10 +2866,12 @@ public void Close (CloseStatusCode code, string reason) throw new ArgumentException (msg, "code"); } - if (_client && code == CloseStatusCode.ServerError) { - var msg = "ServerError cannot be used."; + if (_client) { + if (code == CloseStatusCode.ServerError) { + var msg = "ServerError cannot be used."; - throw new ArgumentException (msg, "code"); + throw new ArgumentException (msg, "code"); + } } if (!_client && code == CloseStatusCode.MandatoryExtension) { From a5e6903252f63aa45a0080fe88e1371d36c6e9a8 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 25 Jan 2025 16:22:58 +0900 Subject: [PATCH 5898/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 570bbbd82..45afe298f 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2873,11 +2873,12 @@ public void Close (CloseStatusCode code, string reason) throw new ArgumentException (msg, "code"); } } + else { + if (code == CloseStatusCode.MandatoryExtension) { + var msg = "MandatoryExtension cannot be used."; - if (!_client && code == CloseStatusCode.MandatoryExtension) { - var msg = "MandatoryExtension cannot be used."; - - throw new ArgumentException (msg, "code"); + throw new ArgumentException (msg, "code"); + } } if (reason.IsNullOrEmpty ()) { From 7f55ed375cd4cef5baf1e5e7481716463b6930fe Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 26 Jan 2025 16:52:11 +0900 Subject: [PATCH 5899/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 45afe298f..5d6533279 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2672,6 +2672,12 @@ public void Close (ushort code) /// /// /// + /// is an undefined enum value. + /// + /// + /// -or- + /// + /// /// is . /// It cannot be used by a client. /// From 3fa0134c7622ab05efe34246f0c5de6416569aa1 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 27 Jan 2025 22:09:19 +0900 Subject: [PATCH 5900/6294] [Modify] Add a check if it is defined --- websocket-sharp/WebSocket.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 5d6533279..707e1a0f6 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3162,6 +3162,12 @@ public void CloseAsync (ushort code, string reason) /// /// /// + /// is an undefined enum value. + /// + /// + /// -or- + /// + /// /// is . /// It cannot be used by a client. /// @@ -3191,6 +3197,12 @@ public void CloseAsync (ushort code, string reason) /// public void CloseAsync (CloseStatusCode code, string reason) { + if (!code.IsDefined ()) { + var msg = "An undefined enum value."; + + throw new ArgumentException (msg, "code"); + } + if (_client && code == CloseStatusCode.ServerError) { var msg = "ServerError cannot be used."; From 485cd3068d330a0e8530f55489ededcbcae31330 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 28 Jan 2025 16:03:55 +0900 Subject: [PATCH 5901/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 707e1a0f6..5a760f0c7 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3203,16 +3203,19 @@ public void CloseAsync (CloseStatusCode code, string reason) throw new ArgumentException (msg, "code"); } - if (_client && code == CloseStatusCode.ServerError) { - var msg = "ServerError cannot be used."; + if (_client) { + if (code == CloseStatusCode.ServerError) { + var msg = "ServerError cannot be used."; - throw new ArgumentException (msg, "code"); + throw new ArgumentException (msg, "code"); + } } + else { + if (code == CloseStatusCode.MandatoryExtension) { + var msg = "MandatoryExtension cannot be used."; - if (!_client && code == CloseStatusCode.MandatoryExtension) { - var msg = "MandatoryExtension cannot be used."; - - throw new ArgumentException (msg, "code"); + throw new ArgumentException (msg, "code"); + } } if (reason.IsNullOrEmpty ()) { From 65cf8ef0812ef10516859eb62d91dfa605a4b5b3 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 29 Jan 2025 16:01:06 +0900 Subject: [PATCH 5902/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 5a760f0c7..e1f585642 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2999,6 +2999,12 @@ public void CloseAsync (ushort code) /// /// /// + /// is an undefined enum value. + /// + /// + /// -or- + /// + /// /// is . /// It cannot be used by a client. /// From 82e831f784aca1758bd819e4d13d4b9de0a22fdc Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 30 Jan 2025 16:25:52 +0900 Subject: [PATCH 5903/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 8f3e9b68d..9b16b043c 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -723,6 +723,12 @@ protected void Close (ushort code, string reason) /// /// /// + /// is an undefined enum value. + /// + /// + /// -or- + /// + /// /// is . /// /// From 57831be4ef6c16ff3fd86064eb97ca55c20e77f9 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 31 Jan 2025 21:58:07 +0900 Subject: [PATCH 5904/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 9b16b043c..5a784fe09 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -894,6 +894,12 @@ protected void CloseAsync (ushort code, string reason) /// /// /// + /// is an undefined enum value. + /// + /// + /// -or- + /// + /// /// is . /// /// From 6fe8e6b51e50496359d63a01d989256e9227d336 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 1 Feb 2025 15:50:20 +0900 Subject: [PATCH 5905/6294] [Modify] 2025 --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 5a784fe09..35b133fd7 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -4,7 +4,7 @@ * * The MIT License * - * Copyright (c) 2012-2024 sta.blockhead + * Copyright (c) 2012-2025 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From 0bb5269cbfb44d5f5953801d8df6322ebebb34e2 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 2 Feb 2025 16:08:23 +0900 Subject: [PATCH 5906/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index e1f585642..8102736fd 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2634,9 +2634,6 @@ public void Close () /// Section 7.4 of RFC 6455. /// /// - /// - /// is less than 1000 or greater than 4999. - /// /// /// /// is 1011 (server error). @@ -2650,6 +2647,9 @@ public void Close () /// It cannot be used by a server. /// /// + /// + /// is less than 1000 or greater than 4999. + /// public void Close (ushort code) { Close (code, String.Empty); From 77e42653af477640fbce21d67272b1c08f787536 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 3 Feb 2025 21:58:55 +0900 Subject: [PATCH 5907/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 8102736fd..e99e94f77 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2617,7 +2617,7 @@ public void Close () } /// - /// Closes the connection with the specified code. + /// Closes the connection with the specified status code. /// /// /// This method does nothing if the current state of the interface is From 64c52db3d2229c4af1510efdee1630f86398a560 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 4 Feb 2025 16:11:03 +0900 Subject: [PATCH 5908/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index e99e94f77..8cdb269dc 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2656,7 +2656,7 @@ public void Close (ushort code) } /// - /// Closes the connection with the specified code. + /// Closes the connection with the specified status code. /// /// /// This method does nothing if the current state of the interface is From e82c025cede8506bc03bdc3e417787062b98af77 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 5 Feb 2025 16:10:13 +0900 Subject: [PATCH 5909/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 8cdb269dc..fb33c3275 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2765,16 +2765,19 @@ public void Close (ushort code, string reason) throw new ArgumentOutOfRangeException ("code", msg); } - if (_client && code == 1011) { - var msg = "1011 cannot be used."; + if (_client) { + if (code == 1011) { + var msg = "1011 cannot be used."; - throw new ArgumentException (msg, "code"); + throw new ArgumentException (msg, "code"); + } } + else { + if (code == 1010) { + var msg = "1010 cannot be used."; - if (!_client && code == 1010) { - var msg = "1010 cannot be used."; - - throw new ArgumentException (msg, "code"); + throw new ArgumentException (msg, "code"); + } } if (reason.IsNullOrEmpty ()) { From c5f637cd4da2125fcb658540452f85e577b029ab Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 6 Feb 2025 21:51:15 +0900 Subject: [PATCH 5910/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index fb33c3275..ca42268f7 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2695,7 +2695,7 @@ public void Close (CloseStatusCode code) } /// - /// Closes the connection with the specified code and reason. + /// Closes the connection with the specified status code and reason. /// /// /// This method does nothing if the current state of the interface is @@ -2720,17 +2720,6 @@ public void Close (CloseStatusCode code) /// Its size must be 123 bytes or less in UTF-8. /// /// - /// - /// - /// is less than 1000 or greater than 4999. - /// - /// - /// -or- - /// - /// - /// The size of is greater than 123 bytes. - /// - /// /// /// /// is 1011 (server error). @@ -2757,6 +2746,17 @@ public void Close (CloseStatusCode code) /// could not be UTF-8-encoded. /// /// + /// + /// + /// is less than 1000 or greater than 4999. + /// + /// + /// -or- + /// + /// + /// The size of is greater than 123 bytes. + /// + /// public void Close (ushort code, string reason) { if (!code.IsCloseStatusCode ()) { From ee958d94958ae6c3a8f50502fcdc3fe324a90981 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 7 Feb 2025 22:17:21 +0900 Subject: [PATCH 5911/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index ca42268f7..fc861e331 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2810,7 +2810,7 @@ public void Close (ushort code, string reason) } /// - /// Closes the connection with the specified code and reason. + /// Closes the connection with the specified status code and reason. /// /// /// This method does nothing if the current state of the interface is From ac87dfbf0fffd26a5f6dbf6ab333d51202bc2fcc Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 8 Feb 2025 22:07:15 +0900 Subject: [PATCH 5912/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index fc861e331..9b6323a9f 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2937,7 +2937,7 @@ public void CloseAsync () } /// - /// Closes the connection asynchronously with the specified code. + /// Closes the connection asynchronously with the specified status code. /// /// /// @@ -2959,9 +2959,6 @@ public void CloseAsync () /// Section 7.4 of RFC 6455. /// /// - /// - /// is less than 1000 or greater than 4999. - /// /// /// /// is 1011 (server error). @@ -2975,6 +2972,9 @@ public void CloseAsync () /// It cannot be used by a server. /// /// + /// + /// is less than 1000 or greater than 4999. + /// public void CloseAsync (ushort code) { CloseAsync (code, String.Empty); From 6f7e1c51e9a3b94235a9dae217e19c7825e3ac5d Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 9 Feb 2025 22:02:42 +0900 Subject: [PATCH 5913/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 9b6323a9f..6f155d22a 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2981,7 +2981,7 @@ public void CloseAsync (ushort code) } /// - /// Closes the connection asynchronously with the specified code. + /// Closes the connection asynchronously with the specified status code. /// /// /// From 38b76cc6172fdcb1f15693f9bc90efa51672ea10 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 10 Feb 2025 22:02:46 +0900 Subject: [PATCH 5914/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 6f155d22a..45cd5d750 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3100,16 +3100,19 @@ public void CloseAsync (ushort code, string reason) throw new ArgumentOutOfRangeException ("code", msg); } - if (_client && code == 1011) { - var msg = "1011 cannot be used."; + if (_client) { + if (code == 1011) { + var msg = "1011 cannot be used."; - throw new ArgumentException (msg, "code"); + throw new ArgumentException (msg, "code"); + } } + else { + if (code == 1010) { + var msg = "1010 cannot be used."; - if (!_client && code == 1010) { - var msg = "1010 cannot be used."; - - throw new ArgumentException (msg, "code"); + throw new ArgumentException (msg, "code"); + } } if (reason.IsNullOrEmpty ()) { From 91019bed66981db227984d4d3e62810c621cc7f9 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 11 Feb 2025 22:06:01 +0900 Subject: [PATCH 5915/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 45cd5d750..ce06971a3 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3025,7 +3025,8 @@ public void CloseAsync (CloseStatusCode code) } /// - /// Closes the connection asynchronously with the specified code and reason. + /// Closes the connection asynchronously with the specified status code and + /// reason. /// /// /// @@ -3055,17 +3056,6 @@ public void CloseAsync (CloseStatusCode code) /// Its size must be 123 bytes or less in UTF-8. /// /// - /// - /// - /// is less than 1000 or greater than 4999. - /// - /// - /// -or- - /// - /// - /// The size of is greater than 123 bytes. - /// - /// /// /// /// is 1011 (server error). @@ -3092,6 +3082,17 @@ public void CloseAsync (CloseStatusCode code) /// could not be UTF-8-encoded. /// /// + /// + /// + /// is less than 1000 or greater than 4999. + /// + /// + /// -or- + /// + /// + /// The size of is greater than 123 bytes. + /// + /// public void CloseAsync (ushort code, string reason) { if (!code.IsCloseStatusCode ()) { From a980b1d9ab87c445a9a1c00a9f29653f074ed31a Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 12 Feb 2025 16:15:50 +0900 Subject: [PATCH 5916/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index ce06971a3..1b46ce4cd 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3146,7 +3146,8 @@ public void CloseAsync (ushort code, string reason) } /// - /// Closes the connection asynchronously with the specified code and reason. + /// Closes the connection asynchronously with the specified status code and + /// reason. /// /// /// From 07a7939db7415b2de042f6ba4bbbc477a191bcdc Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 13 Feb 2025 16:08:54 +0900 Subject: [PATCH 5917/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 35b133fd7..d1c2308de 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -629,7 +629,7 @@ protected void Close () /// /// Closes the WebSocket connection for a session with the specified - /// code and reason. + /// status code and reason. /// /// /// This method does nothing if the current state of the WebSocket From 9b04c89547d761e6a482a8da64c4e7753f97bc49 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 14 Feb 2025 16:13:03 +0900 Subject: [PATCH 5918/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index d1c2308de..f412ae998 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -699,7 +699,7 @@ protected void Close (ushort code, string reason) /// /// Closes the WebSocket connection for a session with the specified - /// code and reason. + /// status code and reason. /// /// /// This method does nothing if the current state of the WebSocket From b34c2d328c96644293273d56511cf30fbba8af49 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 15 Feb 2025 22:14:42 +0900 Subject: [PATCH 5919/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index f412ae998..4daa583c1 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -790,7 +790,7 @@ protected void CloseAsync () /// /// Closes the WebSocket connection for a session asynchronously with - /// the specified code and reason. + /// the specified status code and reason. /// /// /// From 52990ca852e8d1dfbab7ad91c045da61343b2b95 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 16 Feb 2025 22:07:38 +0900 Subject: [PATCH 5920/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 4daa583c1..6641e899e 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -865,7 +865,7 @@ protected void CloseAsync (ushort code, string reason) /// /// Closes the WebSocket connection for a session asynchronously with - /// the specified code and reason. + /// the specified status code and reason. /// /// /// From 5a404b7645ba0a2fd139e0c9138c796fddbb1e1f Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 17 Feb 2025 16:25:08 +0900 Subject: [PATCH 5921/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketSessionManager.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index df2a83649..8d329f286 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -968,7 +968,7 @@ public void CloseSession (string id, ushort code, string reason) } /// - /// Closes the session with the specified ID, code, and reason. + /// Closes the session with the specified ID, status code, and reason. /// /// /// A that specifies the ID of the session to close. @@ -997,6 +997,12 @@ public void CloseSession (string id, ushort code, string reason) /// -or- /// /// + /// is an undefined enum value. + /// + /// + /// -or- + /// + /// /// is . /// /// From 70d1c1dd84b86b5522a3303081248df3ee835984 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 18 Feb 2025 16:20:34 +0900 Subject: [PATCH 5922/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketSessionManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 8d329f286..3fc109e0e 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -889,7 +889,7 @@ public void CloseSession (string id) } /// - /// Closes the session with the specified ID, code, and reason. + /// Closes the session with the specified ID, status code, and reason. /// /// /// A that specifies the ID of the session to close. From da8de182af0f578ca12a9491ed30cd7638449e63 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 19 Feb 2025 16:13:37 +0900 Subject: [PATCH 5923/6294] [Modify] 2025 --- websocket-sharp/Server/WebSocketSessionManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 3fc109e0e..43072fcf4 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -4,7 +4,7 @@ * * The MIT License * - * Copyright (c) 2012-2024 sta.blockhead + * Copyright (c) 2012-2025 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From 0ea5a51faee2b13464117d33730bb2a5584c636d Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 20 Feb 2025 21:44:59 +0900 Subject: [PATCH 5924/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 1b46ce4cd..41fb954d6 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -225,9 +225,6 @@ internal WebSocket (TcpListenerWebSocketContext context, string protocol) /// RFC 2616. /// /// - /// - /// is . - /// /// /// /// is an empty string. @@ -251,6 +248,9 @@ internal WebSocket (TcpListenerWebSocketContext context, string protocol) /// contains a value twice. /// /// + /// + /// is . + /// public WebSocket (string url, params string[] protocols) { if (url == null) From 8809cefb16629b562851a8c28505154b57231446 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 21 Feb 2025 16:02:23 +0900 Subject: [PATCH 5925/6294] [Modify] Rename it --- websocket-sharp/WebSocket.cs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 41fb954d6..b3c33c76e 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -113,7 +113,7 @@ public class WebSocket : IDisposable private volatile WebSocketState _readyState; private ManualResetEvent _receivingExited; private int _retryCountForConnect; - private bool _secure; + private bool _isSecure; private ClientSslConfiguration _sslConfig; private Stream _stream; private TcpClient _tcpClient; @@ -172,7 +172,7 @@ internal WebSocket (HttpListenerWebSocketContext context, string protocol) _closeContext = context.Close; _log = context.Log; _message = messages; - _secure = context.IsSecureConnection; + _isSecure = context.IsSecureConnection; _stream = context.Stream; _waitTime = TimeSpan.FromSeconds (1); @@ -188,7 +188,7 @@ internal WebSocket (TcpListenerWebSocketContext context, string protocol) _closeContext = context.Close; _log = context.Log; _message = messages; - _secure = context.IsSecureConnection; + _isSecure = context.IsSecureConnection; _stream = context.Stream; _waitTime = TimeSpan.FromSeconds (1); @@ -276,7 +276,7 @@ public WebSocket (string url, params string[] protocols) _log = new Logger (); _message = messagec; _retryCountForConnect = -1; - _secure = _uri.Scheme == "wss"; + _isSecure = _uri.Scheme == "wss"; _waitTime = TimeSpan.FromSeconds (5); init (); @@ -504,7 +504,7 @@ public bool IsAlive { /// public bool IsSecure { get { - return _secure; + return _isSecure; } } @@ -681,7 +681,7 @@ public ClientSslConfiguration SslConfiguration { throw new InvalidOperationException (msg); } - if (!_secure) { + if (!_isSecure) { var msg = "The interface does not use a secure connection."; throw new InvalidOperationException (msg); @@ -2208,7 +2208,7 @@ private HttpResponse sendHandshakeRequest () releaseClientResources (); _uri = uri; - _secure = uri.Scheme == "wss"; + _isSecure = uri.Scheme == "wss"; setClientStream (); @@ -2283,7 +2283,7 @@ private void setClientStream () _stream = _tcpClient.GetStream (); } - if (_secure) { + if (_isSecure) { var conf = getSslConfiguration (); var host = conf.TargetHost; From 9534bc0ff5928e1e902340b6f7cf9bc0dbcafadc Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 22 Feb 2025 16:08:52 +0900 Subject: [PATCH 5926/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index b3c33c76e..41e789dbf 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -97,6 +97,7 @@ public class WebSocket : IDisposable private bool _ignoreExtensions; private bool _inContinuation; private volatile bool _inMessage; + private bool _isSecure; private volatile Logger _log; private static readonly int _maxRetryCountForConnect; private Action _message; @@ -113,7 +114,6 @@ public class WebSocket : IDisposable private volatile WebSocketState _readyState; private ManualResetEvent _receivingExited; private int _retryCountForConnect; - private bool _isSecure; private ClientSslConfiguration _sslConfig; private Stream _stream; private TcpClient _tcpClient; From af946b0e0d1ef2399179d0c12bb05019faadb788 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 23 Feb 2025 16:08:12 +0900 Subject: [PATCH 5927/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 41e789dbf..7fe83c26e 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -170,9 +170,9 @@ internal WebSocket (HttpListenerWebSocketContext context, string protocol) _protocol = protocol; _closeContext = context.Close; + _isSecure = context.IsSecureConnection; _log = context.Log; _message = messages; - _isSecure = context.IsSecureConnection; _stream = context.Stream; _waitTime = TimeSpan.FromSeconds (1); From 6ebf58c2d33193186e111ae3d535b2cfcf899e78 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 24 Feb 2025 16:19:10 +0900 Subject: [PATCH 5928/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 7fe83c26e..c86ee9f2f 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -186,9 +186,9 @@ internal WebSocket (TcpListenerWebSocketContext context, string protocol) _protocol = protocol; _closeContext = context.Close; + _isSecure = context.IsSecureConnection; _log = context.Log; _message = messages; - _isSecure = context.IsSecureConnection; _stream = context.Stream; _waitTime = TimeSpan.FromSeconds (1); From fb16d1053420eb16606bb5c17191fd490a3cb923 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 25 Feb 2025 16:18:25 +0900 Subject: [PATCH 5929/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index c86ee9f2f..61854c45b 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -273,10 +273,10 @@ public WebSocket (string url, params string[] protocols) _base64Key = CreateBase64Key (); _client = true; + _isSecure = _uri.Scheme == "wss"; _log = new Logger (); _message = messagec; _retryCountForConnect = -1; - _isSecure = _uri.Scheme == "wss"; _waitTime = TimeSpan.FromSeconds (5); init (); From 762eca4d60301b04e3efa7663ac77a5d90a18e70 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 26 Feb 2025 16:05:43 +0900 Subject: [PATCH 5930/6294] [Modify] Rename it --- websocket-sharp/WebSocket.cs | 48 ++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 61854c45b..90777b842 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -74,7 +74,7 @@ public class WebSocket : IDisposable private AuthenticationChallenge _authChallenge; private string _base64Key; - private bool _client; + private bool _isClient; private Action _closeContext; private CompressionMethod _compression; private WebSocketContext _context; @@ -272,7 +272,7 @@ public WebSocket (string url, params string[] protocols) } _base64Key = CreateBase64Key (); - _client = true; + _isClient = true; _isSecure = _uri.Scheme == "wss"; _log = new Logger (); _message = messagec; @@ -346,7 +346,7 @@ public CompressionMethod Compression { } set { - if (!_client) { + if (!_isClient) { var msg = "The interface is not for the client."; throw new InvalidOperationException (msg); @@ -451,7 +451,7 @@ public bool EnableRedirection { } set { - if (!_client) { + if (!_isClient) { var msg = "The interface is not for the client."; throw new InvalidOperationException (msg); @@ -578,7 +578,7 @@ public string Origin { } set { - if (!_client) { + if (!_isClient) { var msg = "The interface is not for the client."; throw new InvalidOperationException (msg); @@ -675,7 +675,7 @@ public WebSocketState ReadyState { /// public ClientSslConfiguration SslConfiguration { get { - if (!_client) { + if (!_isClient) { var msg = "The interface is not for the client."; throw new InvalidOperationException (msg); @@ -705,7 +705,7 @@ public ClientSslConfiguration SslConfiguration { /// public Uri Url { get { - return _client ? _uri : _context.RequestUri; + return _isClient ? _uri : _context.RequestUri; } } @@ -1095,14 +1095,14 @@ private bool checkReceivedFrame (WebSocketFrame frame, out string message) message = null; if (frame.IsMasked) { - if (_client) { + if (_isClient) { message = "A frame from the server is masked."; return false; } } else { - if (!_client) { + if (!_isClient) { message = "A frame from a client is not masked."; return false; @@ -1269,12 +1269,12 @@ private bool closeHandshake ( var sent = false; if (send) { - var frame = WebSocketFrame.CreateCloseFrame (payloadData, _client); + var frame = WebSocketFrame.CreateCloseFrame (payloadData, _isClient); var bytes = frame.ToArray (); sent = sendBytes (bytes); - if (_client) + if (_isClient) frame.Unmask (); } @@ -1777,7 +1777,7 @@ private bool processPingFrame (WebSocketFrame frame) { _log.Trace ("A ping was received."); - var pong = WebSocketFrame.CreatePongFrame (frame.PayloadData, _client); + var pong = WebSocketFrame.CreatePongFrame (frame.PayloadData, _isClient); lock (_forState) { if (_readyState != WebSocketState.Open) { @@ -1796,7 +1796,7 @@ private bool processPingFrame (WebSocketFrame frame) _log.Trace ("A pong to this ping has been sent."); if (_emitOnPing) { - if (_client) + if (_isClient) pong.Unmask (); var e = new MessageEventArgs (frame); @@ -1954,7 +1954,7 @@ private void releaseCommonResources () private void releaseResources () { - if (_client) + if (_isClient) releaseClientResources (); else releaseServerResources (); @@ -2086,7 +2086,7 @@ private bool send (Opcode opcode, Stream dataStream, bool compressed) private bool send (Fin fin, Opcode opcode, byte[] data, bool compressed) { - var frame = new WebSocketFrame (fin, opcode, data, compressed, _client); + var frame = new WebSocketFrame (fin, opcode, data, compressed, _isClient); var rawFrame = frame.ToArray (); return send (rawFrame); @@ -2765,7 +2765,7 @@ public void Close (ushort code, string reason) throw new ArgumentOutOfRangeException ("code", msg); } - if (_client) { + if (_isClient) { if (code == 1011) { var msg = "1011 cannot be used."; @@ -2875,7 +2875,7 @@ public void Close (CloseStatusCode code, string reason) throw new ArgumentException (msg, "code"); } - if (_client) { + if (_isClient) { if (code == CloseStatusCode.ServerError) { var msg = "ServerError cannot be used."; @@ -3101,7 +3101,7 @@ public void CloseAsync (ushort code, string reason) throw new ArgumentOutOfRangeException ("code", msg); } - if (_client) { + if (_isClient) { if (code == 1011) { var msg = "1011 cannot be used."; @@ -3217,7 +3217,7 @@ public void CloseAsync (CloseStatusCode code, string reason) throw new ArgumentException (msg, "code"); } - if (_client) { + if (_isClient) { if (code == CloseStatusCode.ServerError) { var msg = "ServerError cannot be used."; @@ -3281,7 +3281,7 @@ public void CloseAsync (CloseStatusCode code, string reason) /// public void Connect () { - if (!_client) { + if (!_isClient) { var msg = "The interface is not for the client."; throw new InvalidOperationException (msg); @@ -3326,7 +3326,7 @@ public void Connect () /// public void ConnectAsync () { - if (!_client) { + if (!_isClient) { var msg = "The interface is not for the client."; throw new InvalidOperationException (msg); @@ -3895,7 +3895,7 @@ public void SendAsync (Stream stream, int length, Action completed) /// public void SetCookie (Cookie cookie) { - if (!_client) { + if (!_isClient) { var msg = "The interface is not for the client."; throw new InvalidOperationException (msg); @@ -3960,7 +3960,7 @@ public void SetCookie (Cookie cookie) /// public void SetCredentials (string username, string password, bool preAuth) { - if (!_client) { + if (!_isClient) { var msg = "The interface is not for the client."; throw new InvalidOperationException (msg); @@ -4075,7 +4075,7 @@ public void SetCredentials (string username, string password, bool preAuth) /// public void SetProxy (string url, string username, string password) { - if (!_client) { + if (!_isClient) { var msg = "The interface is not for the client."; throw new InvalidOperationException (msg); From e0642f6a4aafdd32cfc9abb728f192ff391c1e18 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 27 Feb 2025 21:54:47 +0900 Subject: [PATCH 5931/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 90777b842..1f514810b 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -74,7 +74,6 @@ public class WebSocket : IDisposable private AuthenticationChallenge _authChallenge; private string _base64Key; - private bool _isClient; private Action _closeContext; private CompressionMethod _compression; private WebSocketContext _context; @@ -97,6 +96,7 @@ public class WebSocket : IDisposable private bool _ignoreExtensions; private bool _inContinuation; private volatile bool _inMessage; + private bool _isClient; private bool _isSecure; private volatile Logger _log; private static readonly int _maxRetryCountForConnect; From f558f7f8d605938e116aa2c41242efee5a2e9769 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 28 Feb 2025 16:46:39 +0900 Subject: [PATCH 5932/6294] [Modify] Add it To have access to the underlying TCP socket. --- websocket-sharp/Net/HttpConnection.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/websocket-sharp/Net/HttpConnection.cs b/websocket-sharp/Net/HttpConnection.cs index 92c2ead58..e51efb11c 100644 --- a/websocket-sharp/Net/HttpConnection.cs +++ b/websocket-sharp/Net/HttpConnection.cs @@ -178,6 +178,12 @@ public int Reuses { } } + public Socket Socket { + get { + return _socket; + } + } + public Stream Stream { get { return _stream; From 918250e3c16a19c696383f8cfbddc2a6ba7bddd2 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 1 Mar 2025 16:21:58 +0900 Subject: [PATCH 5933/6294] [Modify] Add it To have access to the underlying TCP socket. --- .../Net/WebSockets/HttpListenerWebSocketContext.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs b/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs index 3410ff62d..7b696c015 100644 --- a/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs @@ -30,6 +30,7 @@ using System.Collections.Generic; using System.Collections.Specialized; using System.IO; +using System.Net.Sockets; using System.Security.Principal; namespace WebSocketSharp.Net.WebSockets @@ -68,6 +69,12 @@ internal Logger Log { } } + internal Socket Socket { + get { + return _context.Connection.Socket; + } + } + internal Stream Stream { get { return _context.Connection.Stream; From d9a54e1d1fa8751dbe9df62d7cb1b8ef2ba0e3cf Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 2 Mar 2025 22:25:10 +0900 Subject: [PATCH 5934/6294] [Modify] 2025 --- websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs b/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs index 7b696c015..7e0358d1f 100644 --- a/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/HttpListenerWebSocketContext.cs @@ -4,7 +4,7 @@ * * The MIT License * - * Copyright (c) 2012-2024 sta.blockhead + * Copyright (c) 2012-2025 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From 317bd433f610e2fa4923efe33262134daef9358a Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 3 Mar 2025 22:05:20 +0900 Subject: [PATCH 5935/6294] [Modify] Add it To have access to the underlying TCP socket. --- .../Net/WebSockets/TcpListenerWebSocketContext.cs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs index f95eeb98f..6b08ce281 100644 --- a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs @@ -58,6 +58,7 @@ internal class TcpListenerWebSocketContext : WebSocketContext private Uri _requestUri; private bool _secure; private System.Net.EndPoint _serverEndPoint; + private Socket _socket; private Stream _stream; private TcpClient _tcpClient; private IPrincipal _user; @@ -80,6 +81,8 @@ Logger log _secure = secure; _log = log; + _socket = tcpClient.Client; + var netStream = tcpClient.GetStream (); if (secure) { @@ -102,9 +105,8 @@ Logger log _stream = netStream; } - var sock = tcpClient.Client; - _serverEndPoint = sock.LocalEndPoint; - _userEndPoint = sock.RemoteEndPoint; + _serverEndPoint = _socket.LocalEndPoint; + _userEndPoint = _socket.RemoteEndPoint; _request = HttpRequest.ReadRequest (_stream, 90000); _websocket = new WebSocket (this, protocol); @@ -120,6 +122,12 @@ internal Logger Log { } } + internal Socket Socket { + get { + return _socket; + } + } + internal Stream Stream { get { return _stream; From 1c858cf9434adb4f5ebc8d2c9edccf4c2b435d45 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 4 Mar 2025 16:00:17 +0900 Subject: [PATCH 5936/6294] [Modify] Polish it --- websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs index 6b08ce281..9ca666745 100644 --- a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs @@ -57,7 +57,6 @@ internal class TcpListenerWebSocketContext : WebSocketContext private HttpRequest _request; private Uri _requestUri; private bool _secure; - private System.Net.EndPoint _serverEndPoint; private Socket _socket; private Stream _stream; private TcpClient _tcpClient; @@ -105,7 +104,6 @@ Logger log _stream = netStream; } - _serverEndPoint = _socket.LocalEndPoint; _userEndPoint = _socket.RemoteEndPoint; _request = HttpRequest.ReadRequest (_stream, 90000); @@ -390,7 +388,7 @@ public override string SecWebSocketVersion { /// public override System.Net.IPEndPoint ServerEndPoint { get { - return (System.Net.IPEndPoint) _serverEndPoint; + return (System.Net.IPEndPoint) _socket.LocalEndPoint; } } From a8b1db0184fbe544729600fa8f1503429c3cb4d2 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 5 Mar 2025 16:17:38 +0900 Subject: [PATCH 5937/6294] [Modify] Polish it --- .../Net/WebSockets/TcpListenerWebSocketContext.cs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs index 9ca666745..edd817e6a 100644 --- a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs @@ -61,7 +61,6 @@ internal class TcpListenerWebSocketContext : WebSocketContext private Stream _stream; private TcpClient _tcpClient; private IPrincipal _user; - private System.Net.EndPoint _userEndPoint; private WebSocket _websocket; #endregion @@ -104,8 +103,6 @@ Logger log _stream = netStream; } - _userEndPoint = _socket.RemoteEndPoint; - _request = HttpRequest.ReadRequest (_stream, 90000); _websocket = new WebSocket (this, protocol); } @@ -419,7 +416,7 @@ public override IPrincipal User { /// public override System.Net.IPEndPoint UserEndPoint { get { - return (System.Net.IPEndPoint) _userEndPoint; + return (System.Net.IPEndPoint) _socket.RemoteEndPoint; } } From 555ab680bd29c97045a0e58b15da890db7c3e226 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 6 Mar 2025 16:02:24 +0900 Subject: [PATCH 5938/6294] [Modify] Polish it --- .../Net/WebSockets/TcpListenerWebSocketContext.cs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs index edd817e6a..3ca0d846a 100644 --- a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs @@ -57,7 +57,6 @@ internal class TcpListenerWebSocketContext : WebSocketContext private HttpRequest _request; private Uri _requestUri; private bool _secure; - private Socket _socket; private Stream _stream; private TcpClient _tcpClient; private IPrincipal _user; @@ -79,8 +78,6 @@ Logger log _secure = secure; _log = log; - _socket = tcpClient.Client; - var netStream = tcpClient.GetStream (); if (secure) { @@ -119,7 +116,7 @@ internal Logger Log { internal Socket Socket { get { - return _socket; + return _tcpClient.Client; } } @@ -385,7 +382,7 @@ public override string SecWebSocketVersion { /// public override System.Net.IPEndPoint ServerEndPoint { get { - return (System.Net.IPEndPoint) _socket.LocalEndPoint; + return (System.Net.IPEndPoint) _tcpClient.Client.LocalEndPoint; } } @@ -416,7 +413,7 @@ public override IPrincipal User { /// public override System.Net.IPEndPoint UserEndPoint { get { - return (System.Net.IPEndPoint) _socket.RemoteEndPoint; + return (System.Net.IPEndPoint) _tcpClient.Client.RemoteEndPoint; } } From 2b191f4909075b3ccd13309faf1f386f0e27e25b Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 7 Mar 2025 17:08:40 +0900 Subject: [PATCH 5939/6294] [Modify] Polish it --- websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs index 3ca0d846a..610a2802e 100644 --- a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs @@ -75,7 +75,6 @@ Logger log ) { _tcpClient = tcpClient; - _secure = secure; _log = log; var netStream = tcpClient.GetStream (); @@ -94,6 +93,7 @@ Logger log sslConfig.CheckCertificateRevocation ); + _secure = true; _stream = sslStream; } else { From 383daa6166f5556b2e1c5e5af0185c40c5e7c96f Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 8 Mar 2025 22:02:56 +0900 Subject: [PATCH 5940/6294] [Modify] Rename it --- .../Net/WebSockets/TcpListenerWebSocketContext.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs index 610a2802e..fb7b3fb35 100644 --- a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs @@ -56,7 +56,7 @@ internal class TcpListenerWebSocketContext : WebSocketContext private NameValueCollection _queryString; private HttpRequest _request; private Uri _requestUri; - private bool _secure; + private bool _isSecureConnection; private Stream _stream; private TcpClient _tcpClient; private IPrincipal _user; @@ -93,7 +93,7 @@ Logger log sslConfig.CheckCertificateRevocation ); - _secure = true; + _isSecureConnection = true; _stream = sslStream; } else { @@ -213,7 +213,7 @@ public override bool IsLocal { /// public override bool IsSecureConnection { get { - return _secure; + return _isSecureConnection; } } @@ -291,7 +291,7 @@ public override Uri RequestUri { _request.RequestTarget, _request.Headers["Host"], _request.IsWebSocketRequest, - _secure + _isSecureConnection ); } From 7f6367bdc19847796989b17b4271cb6ba3fff557 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 9 Mar 2025 22:05:08 +0900 Subject: [PATCH 5941/6294] [Modify] Polish it --- websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs index fb7b3fb35..669c548a5 100644 --- a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs @@ -52,11 +52,11 @@ internal class TcpListenerWebSocketContext : WebSocketContext { #region Private Fields + private bool _isSecureConnection; private Logger _log; private NameValueCollection _queryString; private HttpRequest _request; private Uri _requestUri; - private bool _isSecureConnection; private Stream _stream; private TcpClient _tcpClient; private IPrincipal _user; From b9e4f7bb07f767eb395dca2d6a426bf02e6313a1 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 10 Mar 2025 16:39:40 +0900 Subject: [PATCH 5942/6294] [Modify] 2025 --- websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs index 669c548a5..3e8d12777 100644 --- a/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs +++ b/websocket-sharp/Net/WebSockets/TcpListenerWebSocketContext.cs @@ -4,7 +4,7 @@ * * The MIT License * - * Copyright (c) 2012-2022 sta.blockhead + * Copyright (c) 2012-2025 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From 0030e5de38a0981db4f08a7f4815049400c105ee Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 11 Mar 2025 21:38:48 +0900 Subject: [PATCH 5943/6294] [Modify] Add it To have access to the underlying TCP socket. --- websocket-sharp/WebSocket.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 1f514810b..564dd4063 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -114,6 +114,7 @@ public class WebSocket : IDisposable private volatile WebSocketState _readyState; private ManualResetEvent _receivingExited; private int _retryCountForConnect; + private Socket _socket; private ClientSslConfiguration _sslConfig; private Stream _stream; private TcpClient _tcpClient; @@ -173,6 +174,7 @@ internal WebSocket (HttpListenerWebSocketContext context, string protocol) _isSecure = context.IsSecureConnection; _log = context.Log; _message = messages; + _socket = context.Socket; _stream = context.Stream; _waitTime = TimeSpan.FromSeconds (1); @@ -189,6 +191,7 @@ internal WebSocket (TcpListenerWebSocketContext context, string protocol) _isSecure = context.IsSecureConnection; _log = context.Log; _message = messages; + _socket = context.Socket; _stream = context.Stream; _waitTime = TimeSpan.FromSeconds (1); From e7e0f89de88b9911f27b0bc51a8c9dab3ed9a7e1 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 12 Mar 2025 17:00:55 +0900 Subject: [PATCH 5944/6294] [Modify] Add the NoDelay property --- websocket-sharp/WebSocket.cs | 48 ++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 564dd4063..b47dbfa09 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -102,6 +102,7 @@ public class WebSocket : IDisposable private static readonly int _maxRetryCountForConnect; private Action _message; private Queue _messageEventQueue; + private bool _noDelay; private uint _nonceCount; private string _origin; private ManualResetEvent _pongReceived; @@ -530,6 +531,38 @@ internal set { } } + /// + /// Gets or sets a value indicating whether the underlying TCP socket + /// disables a delay when send or receive buffer is not full. + /// + /// + /// The set operation works if the current state of the interface is + /// New or Closed. + /// + /// + /// + /// true if the delay is disabled; otherwise, false. + /// + /// + /// The default value is false. + /// + /// + /// + public bool NoDelay { + get { + return _noDelay; + } + + set { + lock (_forState) { + if (!canSet ()) + return; + + _noDelay = value; + } + } + } + /// /// Gets or sets the value of the HTTP Origin header to send with /// the handshake request. @@ -886,6 +919,9 @@ private bool acceptHandshake () processSecWebSocketExtensionsClientHeader (val); } + if (_noDelay) + _socket.NoDelay = true; + createHandshakeResponse ().WriteTo (_stream); return true; @@ -2257,6 +2293,10 @@ private HttpResponse sendProxyConnectRequest () releaseClientResources (); _tcpClient = new TcpClient (_proxyUri.DnsSafeHost, _proxyUri.Port); + + if (_noDelay) + _tcpClient.NoDelay = true; + _stream = _tcpClient.GetStream (); } @@ -2272,6 +2312,10 @@ private void setClientStream () { if (_proxyUri != null) { _tcpClient = new TcpClient (_proxyUri.DnsSafeHost, _proxyUri.Port); + + if (_noDelay) + _tcpClient.NoDelay = true; + _stream = _tcpClient.GetStream (); var res = sendProxyConnectRequest (); @@ -2283,6 +2327,10 @@ private void setClientStream () } else { _tcpClient = new TcpClient (_uri.DnsSafeHost, _uri.Port); + + if (_noDelay) + _tcpClient.NoDelay = true; + _stream = _tcpClient.GetStream (); } From 196836833c75541d1e50ac80e5327a019359f08b Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 13 Mar 2025 16:55:03 +0900 Subject: [PATCH 5945/6294] [Modify] Add it --- websocket-sharp/WebSocket.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index b47dbfa09..cc2871e3b 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1506,6 +1506,17 @@ private HttpResponse createHandshakeResponse () return ret; } + // As client + private TcpClient createTcpClient (string hostname, int port) + { + var ret = new TcpClient (hostname, port); + + if (_noDelay) + ret.NoDelay = true; + + return ret; + } + // As server private bool customCheckHandshakeRequest ( WebSocketContext context, out string message From 8a547361ec4f7cc3011ddbca5fe132be6dc0c577 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 14 Mar 2025 16:33:06 +0900 Subject: [PATCH 5946/6294] [Modify] Replace it --- websocket-sharp/WebSocket.cs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index cc2871e3b..2c7987d1e 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2303,11 +2303,7 @@ private HttpResponse sendProxyConnectRequest () if (res.CloseConnection) { releaseClientResources (); - _tcpClient = new TcpClient (_proxyUri.DnsSafeHost, _proxyUri.Port); - - if (_noDelay) - _tcpClient.NoDelay = true; - + _tcpClient = createTcpClient (_proxyUri.DnsSafeHost, _proxyUri.Port); _stream = _tcpClient.GetStream (); } From fe316dcb9ca6c274c6250d95b3739523124c0255 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 15 Mar 2025 16:17:57 +0900 Subject: [PATCH 5947/6294] [Modify] Replace it --- websocket-sharp/WebSocket.cs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 2c7987d1e..67e884c45 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2318,11 +2318,7 @@ private HttpResponse sendProxyConnectRequest () private void setClientStream () { if (_proxyUri != null) { - _tcpClient = new TcpClient (_proxyUri.DnsSafeHost, _proxyUri.Port); - - if (_noDelay) - _tcpClient.NoDelay = true; - + _tcpClient = createTcpClient (_proxyUri.DnsSafeHost, _proxyUri.Port); _stream = _tcpClient.GetStream (); var res = sendProxyConnectRequest (); From 132e3781b3402810bb4705e29f25ffc247306220 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 16 Mar 2025 22:07:01 +0900 Subject: [PATCH 5948/6294] [Modify] Replace it --- websocket-sharp/WebSocket.cs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 67e884c45..b1c512273 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2329,11 +2329,7 @@ private void setClientStream () throw new WebSocketException (msg); } else { - _tcpClient = new TcpClient (_uri.DnsSafeHost, _uri.Port); - - if (_noDelay) - _tcpClient.NoDelay = true; - + _tcpClient = createTcpClient (_uri.DnsSafeHost, _uri.Port); _stream = _tcpClient.GetStream (); } From 939faa26a07987f9f0bb91d129f2206645457f4a Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 17 Mar 2025 21:36:22 +0900 Subject: [PATCH 5949/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index b1c512273..de567ae4b 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2341,7 +2341,8 @@ private void setClientStream () var msg = "An invalid host name is specified."; throw new WebSocketException ( - CloseStatusCode.TlsHandshakeFailure, msg + CloseStatusCode.TlsHandshakeFailure, + msg ); } From 0fcb5708718f90120ebe38542c02b921ae24ccf8 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 18 Mar 2025 16:25:43 +0900 Subject: [PATCH 5950/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index de567ae4b..03e6fd8f7 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2365,7 +2365,8 @@ private void setClientStream () } catch (Exception ex) { throw new WebSocketException ( - CloseStatusCode.TlsHandshakeFailure, ex + CloseStatusCode.TlsHandshakeFailure, + ex ); } } From ca6c75ab036f99c06f127c81fa61d4e48d92274d Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 19 Mar 2025 16:38:35 +0900 Subject: [PATCH 5951/6294] [Modify] Add the NoDelay property --- websocket-sharp/Server/WebSocketBehavior.cs | 38 +++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 6641e899e..885d0cc3d 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -53,6 +53,7 @@ public abstract class WebSocketBehavior : IWebSocketSession private Func _hostValidator; private string _id; private bool _ignoreExtensions; + private bool _noDelay; private Func _originValidator; private string _protocol; private WebSocketSessionManager _sessions; @@ -393,6 +394,39 @@ public bool IgnoreExtensions { } } + /// + /// Gets or sets a value indicating whether the underlying TCP socket of + /// the WebSocket interface for a session disables a delay when send or + /// receive buffer is not full. + /// + /// + /// + /// true if the delay is disabled; otherwise, false. + /// + /// + /// The default value is false. + /// + /// + /// + /// + /// The set operation is not available when the session has already started. + /// + public bool NoDelay { + get { + return _noDelay; + } + + set { + if (_websocket != null) { + var msg = "The set operation is not available."; + + throw new InvalidOperationException (msg); + } + + _noDelay = value; + } + } + /// /// Gets or sets the delegate used to validate the Origin header. /// @@ -587,6 +621,10 @@ WebSocketSessionManager sessions _websocket.CustomHandshakeRequestChecker = checkHandshakeRequest; _websocket.EmitOnPing = _emitOnPing; _websocket.IgnoreExtensions = _ignoreExtensions; + + if (_noDelay) + _websocket.NoDelay = true; + _websocket.Protocol = _protocol; var waitTime = sessions.WaitTime; From 8c80be55a832033baacbf044585ad9a51c9bccc5 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 20 Mar 2025 16:24:47 +0900 Subject: [PATCH 5952/6294] [Modify] Add it --- Example/Program.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Example/Program.cs b/Example/Program.cs index b7313a9d4..ff4c3da11 100644 --- a/Example/Program.cs +++ b/Example/Program.cs @@ -56,6 +56,10 @@ public static void Main (string[] args) // To emit a WebSocket.OnMessage event when receives a ping. //ws.EmitOnPing = true; + + // To disable a delay when send or receive buffer of the underlying + // TCP socket is not full. + ws.NoDelay = true; #endif // To enable the Per-message Compression extension. //ws.Compression = CompressionMethod.Deflate; From 1b58fcd641ed92e65b87ca4f1a45eef02b6009be Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 21 Mar 2025 16:22:15 +0900 Subject: [PATCH 5953/6294] [Modify] Add it --- Example2/Program.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Example2/Program.cs b/Example2/Program.cs index e83c762a4..497b8ac96 100644 --- a/Example2/Program.cs +++ b/Example2/Program.cs @@ -100,6 +100,10 @@ public static void Main (string[] args) // To emit a WebSocket.OnMessage event when receives a ping. s.EmitOnPing = true; + // To disable a delay when send or receive buffer of the underlying + // TCP socket is not full. + s.NoDelay = true; + // To validate the Origin header. s.OriginValidator = val => { // Check the value of the Origin header, and return true if valid. From 3e0ddb6b4f2bbf09733b8dafb9b66837f615c785 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 22 Mar 2025 16:17:19 +0900 Subject: [PATCH 5954/6294] [Modify] Add it --- Example3/Program.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Example3/Program.cs b/Example3/Program.cs index 33744993b..2c674378a 100644 --- a/Example3/Program.cs +++ b/Example3/Program.cs @@ -136,6 +136,10 @@ public static void Main (string[] args) // To emit a WebSocket.OnMessage event when receives a ping. s.EmitOnPing = true; + // To disable a delay when send or receive buffer of the underlying + // TCP socket is not full. + s.NoDelay = true; + // To validate the Origin header. s.OriginValidator = val => { // Check the value of the Origin header, and return true if valid. From b4b10997caf3402d62b64db2985c234337ca7a6e Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 23 Mar 2025 22:17:08 +0900 Subject: [PATCH 5955/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 885d0cc3d..4a239ae44 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -495,7 +495,7 @@ public string Protocol { set { if (_websocket != null) { - var msg = "The session has already started."; + var msg = "The set operation is not available."; throw new InvalidOperationException (msg); } From 9b1974e781ac2930caf395626a7fb90ddd94186a Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 23 Mar 2025 22:19:12 +0900 Subject: [PATCH 5956/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 4a239ae44..229cbf859 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -484,7 +484,7 @@ public Func OriginValidator { /// The value specified for a set operation is not a token. /// /// - /// The set operation is not available if the session has already started. + /// The set operation is not available when the session has already started. /// public string Protocol { get { From 607835d05919a671addcdac0d0fb0bebac1daaba Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 24 Mar 2025 21:44:01 +0900 Subject: [PATCH 5957/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketBehavior.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 229cbf859..bb69eabe4 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -620,7 +620,9 @@ WebSocketSessionManager sessions _websocket = context.WebSocket; _websocket.CustomHandshakeRequestChecker = checkHandshakeRequest; _websocket.EmitOnPing = _emitOnPing; - _websocket.IgnoreExtensions = _ignoreExtensions; + + if (_ignoreExtensions) + _websocket.IgnoreExtensions = true; if (_noDelay) _websocket.NoDelay = true; From 34486fa1c6fb6e50a49181fde06ef8c560141333 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 24 Mar 2025 21:52:41 +0900 Subject: [PATCH 5958/6294] [Modify] Throw an exception --- websocket-sharp/Server/WebSocketBehavior.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index bb69eabe4..097ab9d2e 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -384,12 +384,21 @@ public string ID { /// The default value is false. /// /// + /// + /// The set operation is not available when the session has already started. + /// public bool IgnoreExtensions { get { return _ignoreExtensions; } set { + if (_websocket != null) { + var msg = "The set operation is not available."; + + throw new InvalidOperationException (msg); + } + _ignoreExtensions = value; } } From 2d3f5fffd7b9eb400d0b3206d71501ecd2b6a4f7 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 25 Mar 2025 16:18:34 +0900 Subject: [PATCH 5959/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketBehavior.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 097ab9d2e..420af7826 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -628,7 +628,9 @@ WebSocketSessionManager sessions _websocket = context.WebSocket; _websocket.CustomHandshakeRequestChecker = checkHandshakeRequest; - _websocket.EmitOnPing = _emitOnPing; + + if (_emitOnPing) + _websocket.EmitOnPing = true; if (_ignoreExtensions) _websocket.IgnoreExtensions = true; From 689f9b71ff4a90375a97f0987b3bec2258572cb7 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 25 Mar 2025 16:24:32 +0900 Subject: [PATCH 5960/6294] [Modify] Throw an exception --- websocket-sharp/Server/WebSocketBehavior.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 420af7826..015448166 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -302,6 +302,9 @@ public Func CookiesValidator { /// The default value is false. /// /// + /// + /// The set operation is not available when the session has already started. + /// public bool EmitOnPing { get { return _websocket != null ? _websocket.EmitOnPing : _emitOnPing; @@ -309,9 +312,9 @@ public bool EmitOnPing { set { if (_websocket != null) { - _websocket.EmitOnPing = value; + var msg = "The set operation is not available."; - return; + throw new InvalidOperationException (msg); } _emitOnPing = value; From 45458f63b73407f2b7b49d50f13c27c16a7882ed Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 25 Mar 2025 16:27:12 +0900 Subject: [PATCH 5961/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 015448166..f6e323e64 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -307,7 +307,7 @@ public Func CookiesValidator { /// public bool EmitOnPing { get { - return _websocket != null ? _websocket.EmitOnPing : _emitOnPing; + return _emitOnPing; } set { From bf6fa13b8bca8a952ebbf030d2405431f68598fa Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 26 Mar 2025 16:20:08 +0900 Subject: [PATCH 5962/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketBehavior.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index f6e323e64..eb34c6a0f 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -641,7 +641,8 @@ WebSocketSessionManager sessions if (_noDelay) _websocket.NoDelay = true; - _websocket.Protocol = _protocol; + if (_protocol != null) + _websocket.Protocol = _protocol; var waitTime = sessions.WaitTime; From bbc2c72e0c38e69e033bf1d80b1652de7dec461a Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 27 Mar 2025 16:27:11 +0900 Subject: [PATCH 5963/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index eb34c6a0f..666bac2bc 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -489,6 +489,9 @@ public Func OriginValidator { /// RFC 2616. /// /// + /// The value is initialized if not requested. + /// + /// /// The default value is an empty string. /// /// From bd13ca30a75ac5e97eadda1944e9b4a2fe967195 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 27 Mar 2025 16:30:47 +0900 Subject: [PATCH 5964/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 666bac2bc..bc72596cc 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -89,7 +89,7 @@ protected WebSocketBehavior () protected NameValueCollection Headers { get { if (_context == null) { - var msg = "The session has not started yet."; + var msg = "The get operation is not available."; throw new InvalidOperationException (msg); } From 8ee8c19138b4ef549c597c9d280b73166c77c43c Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 27 Mar 2025 16:34:18 +0900 Subject: [PATCH 5965/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index bc72596cc..48ea645b5 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -84,7 +84,7 @@ protected WebSocketBehavior () /// included in the WebSocket handshake request. /// /// - /// The session has not started yet. + /// The get operation is not available when the session has not started yet. /// protected NameValueCollection Headers { get { From 4f5f6fb46674f5fc922df665e96d710e7abdc7e6 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 28 Mar 2025 16:25:51 +0900 Subject: [PATCH 5966/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 48ea645b5..026b60a7b 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -111,7 +111,7 @@ protected NameValueCollection Headers { protected bool IsAlive { get { if (_websocket == null) { - var msg = "The session has not started yet."; + var msg = "The get operation is not available."; throw new InvalidOperationException (msg); } From a807fa655f39fde6a66ecc182547486b90d4e7b9 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 28 Mar 2025 16:27:09 +0900 Subject: [PATCH 5967/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 026b60a7b..1746bbfd1 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -106,7 +106,7 @@ protected NameValueCollection Headers { /// true if the communication is possible; otherwise, false. /// /// - /// The session has not started yet. + /// The get operation is not available when the session has not started yet. /// protected bool IsAlive { get { From 2fe3885bd1058d1991afb430b2e488e02ac21b98 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 29 Mar 2025 16:28:23 +0900 Subject: [PATCH 5968/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 1746bbfd1..4080bc8e6 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -138,7 +138,7 @@ protected bool IsAlive { protected NameValueCollection QueryString { get { if (_context == null) { - var msg = "The session has not started yet."; + var msg = "The get operation is not available."; throw new InvalidOperationException (msg); } From 341c71091b3bac81df6471d04a7394722c1fb2e2 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 29 Mar 2025 16:29:58 +0900 Subject: [PATCH 5969/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 4080bc8e6..bd9c56495 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -133,7 +133,7 @@ protected bool IsAlive { /// /// /// - /// The session has not started yet. + /// The get operation is not available when the session has not started yet. /// protected NameValueCollection QueryString { get { From 556e6dace4b3309cc5f54dc590fe0f50e3b81007 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 30 Mar 2025 16:16:09 +0900 Subject: [PATCH 5970/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketBehavior.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index bd9c56495..f84552f9b 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -133,7 +133,7 @@ protected bool IsAlive { /// /// /// - /// The get operation is not available when the session has not started yet. + /// The session has not started yet. /// protected NameValueCollection QueryString { get { @@ -164,7 +164,7 @@ protected NameValueCollection QueryString { protected WebSocketState ReadyState { get { if (_websocket == null) { - var msg = "The session has not started yet."; + var msg = "The get operation is not available."; throw new InvalidOperationException (msg); } From 563ca020f254438b198884f11064effc172d6ba5 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 30 Mar 2025 16:23:29 +0900 Subject: [PATCH 5971/6294] Revert "[Modify] Polish it" This reverts commit 556e6dace4b3309cc5f54dc590fe0f50e3b81007. --- websocket-sharp/Server/WebSocketBehavior.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index f84552f9b..bd9c56495 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -133,7 +133,7 @@ protected bool IsAlive { /// /// /// - /// The session has not started yet. + /// The get operation is not available when the session has not started yet. /// protected NameValueCollection QueryString { get { @@ -164,7 +164,7 @@ protected NameValueCollection QueryString { protected WebSocketState ReadyState { get { if (_websocket == null) { - var msg = "The get operation is not available."; + var msg = "The session has not started yet."; throw new InvalidOperationException (msg); } From 2dc9317cfc2ded6e7758b14c5d03e17872c2cd35 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 30 Mar 2025 16:29:00 +0900 Subject: [PATCH 5972/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index bd9c56495..175d4c14a 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -164,7 +164,7 @@ protected NameValueCollection QueryString { protected WebSocketState ReadyState { get { if (_websocket == null) { - var msg = "The session has not started yet."; + var msg = "The get operation is not available."; throw new InvalidOperationException (msg); } From 8531404c02f5c6b2bd6213de73350f274e6555b6 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 30 Mar 2025 16:30:35 +0900 Subject: [PATCH 5973/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 175d4c14a..50930033d 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -159,7 +159,7 @@ protected NameValueCollection QueryString { /// /// /// - /// The session has not started yet. + /// The get operation is not available when the session has not started yet. /// protected WebSocketState ReadyState { get { From 9c19583e120feca57ec6c3848420abd008aa3588 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 31 Mar 2025 21:47:56 +0900 Subject: [PATCH 5974/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 50930033d..138cb3fa5 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -186,7 +186,7 @@ protected WebSocketState ReadyState { protected WebSocketSessionManager Sessions { get { if (_sessions == null) { - var msg = "The session has not started yet."; + var msg = "The get operation is not available."; throw new InvalidOperationException (msg); } From 1a668439a9a663b1654ca04324b067eacc13f335 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 31 Mar 2025 21:51:21 +0900 Subject: [PATCH 5975/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 138cb3fa5..1dcc15b7c 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -181,7 +181,7 @@ protected WebSocketState ReadyState { /// the service. /// /// - /// The session has not started yet. + /// The get operation is not available when the session has not started yet. /// protected WebSocketSessionManager Sessions { get { From 9696770b4c3ba1a60e82a8c5dd436950cc811ca9 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 1 Apr 2025 16:14:08 +0900 Subject: [PATCH 5976/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 1dcc15b7c..f366d963a 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -213,7 +213,7 @@ protected WebSocketSessionManager Sessions { protected IPrincipal User { get { if (_context == null) { - var msg = "The session has not started yet."; + var msg = "The get operation is not available."; throw new InvalidOperationException (msg); } From 3953314fde432ba42ff388c1f37dd8f543334fbb Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 1 Apr 2025 16:15:49 +0900 Subject: [PATCH 5977/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index f366d963a..a9fa5873a 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -208,7 +208,7 @@ protected WebSocketSessionManager Sessions { /// /// /// - /// The session has not started yet. + /// The get operation is not available when the session has not started yet. /// protected IPrincipal User { get { From fc11bad9f710f6dfdde73895f46c56aa1281cf20 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 2 Apr 2025 16:15:50 +0900 Subject: [PATCH 5978/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index a9fa5873a..9848af0db 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -235,7 +235,7 @@ protected IPrincipal User { protected System.Net.IPEndPoint UserEndPoint { get { if (_context == null) { - var msg = "The session has not started yet."; + var msg = "The get operation is not available."; throw new InvalidOperationException (msg); } From ee1720719bd0d44e71b2c5e361a22763576ee679 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 2 Apr 2025 16:18:34 +0900 Subject: [PATCH 5979/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 9848af0db..21e2faeff 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -230,7 +230,7 @@ protected IPrincipal User { /// IP address and port number. /// /// - /// The session has not started yet. + /// The get operation is not available when the session has not started yet. /// protected System.Net.IPEndPoint UserEndPoint { get { From 38ffe9bcd3dca1d8173ef53447b428bf32448c78 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 3 Apr 2025 16:32:24 +0900 Subject: [PATCH 5980/6294] [Modify] Throw an exception --- websocket-sharp/Server/WebSocketBehavior.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 21e2faeff..6e4d80e9b 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -279,12 +279,21 @@ protected System.Net.IPEndPoint UserEndPoint { /// The default value is . /// /// + /// + /// The set operation is not available when the session has already started. + /// public Func CookiesValidator { get { return _cookiesValidator; } set { + if (_websocket != null) { + var msg = "The set operation is not available."; + + throw new InvalidOperationException (msg); + } + _cookiesValidator = value; } } From c02875e9f8754eb511bec5314079c45a3cf7373d Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 4 Apr 2025 16:06:45 +0900 Subject: [PATCH 5981/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 6e4d80e9b..fbb37d720 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -266,7 +266,7 @@ protected System.Net.IPEndPoint UserEndPoint { /// /// /// 2nd parameter passed to the delegate - /// receives the cookies to send to the client. + /// holds the cookies to send to the client. /// /// /// The method invoked by the delegate must return true From b972bcb3431a50f8a0a52b10a63b3e2924b8ccc3 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 4 Apr 2025 16:11:25 +0900 Subject: [PATCH 5982/6294] [Modify] Throw an exception --- websocket-sharp/Server/WebSocketBehavior.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index fbb37d720..d4ac13f3e 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -356,12 +356,21 @@ public bool EmitOnPing { /// The default value is . /// /// + /// + /// The set operation is not available when the session has already started. + /// public Func HostValidator { get { return _hostValidator; } set { + if (_websocket != null) { + var msg = "The set operation is not available."; + + throw new InvalidOperationException (msg); + } + _hostValidator = value; } } From 16fc3ec4ba6eae4fe53e5cbc53ef5002851c2343 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 5 Apr 2025 16:21:23 +0900 Subject: [PATCH 5983/6294] [Modify] Throw an exception --- websocket-sharp/Server/WebSocketBehavior.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index d4ac13f3e..9b9488406 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -484,12 +484,21 @@ public bool NoDelay { /// The default value is . /// /// + /// + /// The set operation is not available when the session has already started. + /// public Func OriginValidator { get { return _originValidator; } set { + if (_websocket != null) { + var msg = "The set operation is not available."; + + throw new InvalidOperationException (msg); + } + _originValidator = value; } } From e7a4bbb5a530fb0690fadd0e6602f7ca4de25708 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 6 Apr 2025 16:13:05 +0900 Subject: [PATCH 5984/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 9b9488406..a566f552e 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -704,7 +704,7 @@ WebSocketSessionManager sessions protected void Close () { if (_websocket == null) { - var msg = "The session has not started yet."; + var msg = "The Close method is not available."; throw new InvalidOperationException (msg); } From 2d493f387358d5ae40f95ef1acd2ba4259d0cc0a Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 6 Apr 2025 16:17:24 +0900 Subject: [PATCH 5985/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index a566f552e..a5c0cbdd9 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -699,7 +699,7 @@ WebSocketSessionManager sessions /// interface is Closing or Closed. /// /// - /// The session has not started yet. + /// The Close method is not available when the session has not started yet. /// protected void Close () { From 3b44a32df3ec249e5afb1ea4e58764d7459c3c4f Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 6 Apr 2025 16:19:05 +0900 Subject: [PATCH 5986/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index a5c0cbdd9..d56aeeb12 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -695,7 +695,7 @@ WebSocketSessionManager sessions /// Closes the WebSocket connection for a session. /// /// - /// This method does nothing if the current state of the WebSocket + /// This method does nothing when the current state of the WebSocket /// interface is Closing or Closed. /// /// From b40bad1f98ca17027dc917be4d98a57a8cb5d749 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 7 Apr 2025 21:40:38 +0900 Subject: [PATCH 5987/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index d56aeeb12..816300a93 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -774,7 +774,7 @@ protected void Close () protected void Close (ushort code, string reason) { if (_websocket == null) { - var msg = "The session has not started yet."; + var msg = "The Close method is not available."; throw new InvalidOperationException (msg); } From 9ce8e9b025585d32ba606213ffb62105e2ea537a Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 7 Apr 2025 21:43:01 +0900 Subject: [PATCH 5988/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 816300a93..15cdffc1c 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -717,7 +717,7 @@ protected void Close () /// status code and reason. /// /// - /// This method does nothing if the current state of the WebSocket + /// This method does nothing when the current state of the WebSocket /// interface is Closing or Closed. /// /// @@ -769,7 +769,7 @@ protected void Close () /// /// /// - /// The session has not started yet. + /// The Close method is not available when the session has not started yet. /// protected void Close (ushort code, string reason) { From f9c1d61e6bfebff004fdcb006bf34f96e4f6f5d8 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 8 Apr 2025 16:28:49 +0900 Subject: [PATCH 5989/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 15cdffc1c..ef91e9e66 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -839,7 +839,7 @@ protected void Close (ushort code, string reason) protected void Close (CloseStatusCode code, string reason) { if (_websocket == null) { - var msg = "The session has not started yet."; + var msg = "The Close method is not available."; throw new InvalidOperationException (msg); } From 56fe39061d5388990ff14ac7e885ec4e01f619d7 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 8 Apr 2025 16:31:49 +0900 Subject: [PATCH 5990/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index ef91e9e66..a56e84e7c 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -787,7 +787,7 @@ protected void Close (ushort code, string reason) /// status code and reason. /// /// - /// This method does nothing if the current state of the WebSocket + /// This method does nothing when the current state of the WebSocket /// interface is Closing or Closed. /// /// @@ -834,7 +834,7 @@ protected void Close (ushort code, string reason) /// The size of is greater than 123 bytes. /// /// - /// The session has not started yet. + /// The Close method is not available when the session has not started yet. /// protected void Close (CloseStatusCode code, string reason) { From d11e8a8bf6c4921b8fb82ac4447c6d9d23dc57f2 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 9 Apr 2025 16:23:38 +0900 Subject: [PATCH 5991/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index a56e84e7c..b5d44596c 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -865,7 +865,7 @@ protected void Close (CloseStatusCode code, string reason) protected void CloseAsync () { if (_websocket == null) { - var msg = "The session has not started yet."; + var msg = "The CloseAsync method is not available."; throw new InvalidOperationException (msg); } From 724629c81444e2cd2404b5edd4c91d7aaca9254e Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 9 Apr 2025 16:26:03 +0900 Subject: [PATCH 5992/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index b5d44596c..0a5040d3b 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -855,12 +855,13 @@ protected void Close (CloseStatusCode code, string reason) /// This method does not wait for the close to be complete. /// /// - /// This method does nothing if the current state of the WebSocket + /// This method does nothing when the current state of the WebSocket /// interface is Closing or Closed. /// /// /// - /// The session has not started yet. + /// The CloseAsync method is not available when the session has not + /// started yet. /// protected void CloseAsync () { From d6a463cad493e71d4d241dabc0bc42299eaa5991 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 10 Apr 2025 16:26:20 +0900 Subject: [PATCH 5993/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 0a5040d3b..1f7b6b205 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -941,7 +941,7 @@ protected void CloseAsync () protected void CloseAsync (ushort code, string reason) { if (_websocket == null) { - var msg = "The session has not started yet."; + var msg = "The CloseAsync method is not available."; throw new InvalidOperationException (msg); } From 3d5e5509e814e750d083cf4662a841486ba9f3f6 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 10 Apr 2025 16:28:48 +0900 Subject: [PATCH 5994/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 1f7b6b205..7c36e709b 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -883,7 +883,7 @@ protected void CloseAsync () /// This method does not wait for the close to be complete. /// /// - /// This method does nothing if the current state of the WebSocket + /// This method does nothing when the current state of the WebSocket /// interface is Closing or Closed. /// /// @@ -936,7 +936,8 @@ protected void CloseAsync () /// /// /// - /// The session has not started yet. + /// The CloseAsync method is not available when the session has not + /// started yet. /// protected void CloseAsync (ushort code, string reason) { From 9bf2c896ae9e86f9a1ad8c4b92495189f1a7c41b Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 11 Apr 2025 16:25:21 +0900 Subject: [PATCH 5995/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 7c36e709b..107139ff8 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -1012,7 +1012,7 @@ protected void CloseAsync (ushort code, string reason) protected void CloseAsync (CloseStatusCode code, string reason) { if (_websocket == null) { - var msg = "The session has not started yet."; + var msg = "The CloseAsync method is not available."; throw new InvalidOperationException (msg); } From a4d35990daa8c1689dea1f0782ef07c99f9b7462 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 11 Apr 2025 16:29:10 +0900 Subject: [PATCH 5996/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 107139ff8..79d7c290a 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -959,7 +959,7 @@ protected void CloseAsync (ushort code, string reason) /// This method does not wait for the close to be complete. /// /// - /// This method does nothing if the current state of the WebSocket + /// This method does nothing when the current state of the WebSocket /// interface is Closing or Closed. /// /// @@ -1007,7 +1007,8 @@ protected void CloseAsync (ushort code, string reason) /// The size of is greater than 123 bytes. /// /// - /// The session has not started yet. + /// The CloseAsync method is not available when the session has not + /// started yet. /// protected void CloseAsync (CloseStatusCode code, string reason) { From cb7c23241123ae58600d7f27237e3a1df08d7ec0 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 11 Apr 2025 16:32:49 +0900 Subject: [PATCH 5997/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketBehavior.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 79d7c290a..637b5c133 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -679,10 +679,10 @@ WebSocketSessionManager sessions if (waitTime != _websocket.WaitTime) _websocket.WaitTime = waitTime; - _websocket.OnOpen += onOpen; - _websocket.OnMessage += onMessage; - _websocket.OnError += onError; _websocket.OnClose += onClose; + _websocket.OnError += onError; + _websocket.OnMessage += onMessage; + _websocket.OnOpen += onOpen; _websocket.Accept (); } From 35b7be4d90be62e798c8efb5beb049e9b2c5f93f Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 12 Apr 2025 17:51:36 +0900 Subject: [PATCH 5998/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 637b5c133..73bbd0ee0 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -1074,7 +1074,7 @@ protected virtual void OnOpen () protected bool Ping () { if (_websocket == null) { - var msg = "The session has not started yet."; + var msg = "The Ping method is not available."; throw new InvalidOperationException (msg); } From 5e7f4031d2feae190639c59d73fc531fa0f592e4 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 12 Apr 2025 17:53:45 +0900 Subject: [PATCH 5999/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 73bbd0ee0..464035ebe 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -1069,7 +1069,7 @@ protected virtual void OnOpen () /// received within a time; otherwise, false. /// /// - /// The session has not started yet. + /// The Ping method is not available when the session has not started yet. /// protected bool Ping () { From c38bafc76e51572587a4cbb816d7bf5ec25ad703 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 13 Apr 2025 16:14:03 +0900 Subject: [PATCH 6000/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 464035ebe..7016ae2f9 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -1109,7 +1109,7 @@ protected bool Ping () protected bool Ping (string message) { if (_websocket == null) { - var msg = "The session has not started yet."; + var msg = "The Ping method is not available."; throw new InvalidOperationException (msg); } From 135814465751bdb850e574ba5dd37c2cbd95588e Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 13 Apr 2025 16:16:43 +0900 Subject: [PATCH 6001/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 7016ae2f9..473fbded2 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -1104,7 +1104,7 @@ protected bool Ping () /// The size of is greater than 125 bytes. /// /// - /// The session has not started yet. + /// The Ping method is not available when the session has not started yet. /// protected bool Ping (string message) { From b68723a409bf2c8a052922e26e7399906470db49 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 13 Apr 2025 16:19:22 +0900 Subject: [PATCH 6002/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 473fbded2..55b84c674 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -1140,7 +1140,7 @@ protected bool Ping (string message) protected void Send (byte[] data) { if (_websocket == null) { - var msg = "The session has not started yet."; + var msg = "The Send method is not available."; throw new InvalidOperationException (msg); } From 9b13f730dd6edaa9ec541169ef19d746ea70036b Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 13 Apr 2025 16:21:28 +0900 Subject: [PATCH 6003/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 55b84c674..05a9904dc 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -1128,7 +1128,7 @@ protected bool Ping (string message) /// /// /// - /// The session has not started yet. + /// The Send method is not available when the session has not started yet. /// /// /// -or- From 3c6cff162512d0b87ee378f43d5a677d8c694052 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 14 Apr 2025 16:43:33 +0900 Subject: [PATCH 6004/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 05a9904dc..3c5a2f83e 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -1187,7 +1187,7 @@ protected void Send (byte[] data) protected void Send (FileInfo fileInfo) { if (_websocket == null) { - var msg = "The session has not started yet."; + var msg = "The Send method is not available."; throw new InvalidOperationException (msg); } From f7e4d48b9907dbfba27df635b3944a0936d8bffb Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 14 Apr 2025 16:46:37 +0900 Subject: [PATCH 6005/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 3c5a2f83e..5b7c57727 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -1175,7 +1175,7 @@ protected void Send (byte[] data) /// /// /// - /// The session has not started yet. + /// The Send method is not available when the session has not started yet. /// /// /// -or- From 570bd02e53e588e163cef5ef2efd8568fdb872cf Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 15 Apr 2025 16:38:20 +0900 Subject: [PATCH 6006/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 5b7c57727..20eabd46d 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -1181,7 +1181,8 @@ protected void Send (byte[] data) /// -or- /// /// - /// The current state of the WebSocket interface is not Open. + /// The Send method is not available when the current state of + /// the WebSocket interface is not Open. /// /// protected void Send (FileInfo fileInfo) From 038e52d5bb84932f372b2c01560e186964ebd130 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 15 Apr 2025 16:40:17 +0900 Subject: [PATCH 6007/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 20eabd46d..672b078aa 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -1175,7 +1175,8 @@ protected void Send (byte[] data) /// /// /// - /// The Send method is not available when the session has not started yet. + /// The Send method is not available when the session has not + /// started yet. /// /// /// -or- From 09694d02592ba487cc42e5bc21189f02d36402e2 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 15 Apr 2025 16:42:22 +0900 Subject: [PATCH 6008/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 672b078aa..af113e455 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -1128,13 +1128,15 @@ protected bool Ping (string message) /// /// /// - /// The Send method is not available when the session has not started yet. + /// The Send method is not available when the session has not + /// started yet. /// /// /// -or- /// /// - /// The current state of the WebSocket interface is not Open. + /// The Send method is not available when the current state of + /// the WebSocket interface is not Open. /// /// protected void Send (byte[] data) From a3ca7ebf5686ebf3807f63a348e8576a8533f8c2 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 15 Apr 2025 16:45:40 +0900 Subject: [PATCH 6009/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index af113e455..d054eed31 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -1225,7 +1225,7 @@ protected void Send (FileInfo fileInfo) protected void Send (string data) { if (_websocket == null) { - var msg = "The session has not started yet."; + var msg = "The Send method is not available."; throw new InvalidOperationException (msg); } From 9de8a0453858ed6f3bae0235dcd79259e87b8cf6 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 15 Apr 2025 16:47:45 +0900 Subject: [PATCH 6010/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index d054eed31..5640f9e85 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -1213,13 +1213,15 @@ protected void Send (FileInfo fileInfo) /// /// /// - /// The session has not started yet. + /// The Send method is not available when the session has not + /// started yet. /// /// /// -or- /// /// - /// The current state of the WebSocket interface is not Open. + /// The Send method is not available when the current state of + /// the WebSocket interface is not Open. /// /// protected void Send (string data) From 8f81a4d1b41d5c37265dcaeea0d4cccfe16b0b7d Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 16 Apr 2025 16:41:57 +0900 Subject: [PATCH 6011/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 5640f9e85..24744b0e1 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -1284,7 +1284,7 @@ protected void Send (string data) protected void Send (Stream stream, int length) { if (_websocket == null) { - var msg = "The session has not started yet."; + var msg = "The Send method is not available."; throw new InvalidOperationException (msg); } From 6a02688288f463b5f3c82f093e6b8f94a41f4243 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 16 Apr 2025 16:46:04 +0900 Subject: [PATCH 6012/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 24744b0e1..36fcaadb1 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -1272,13 +1272,15 @@ protected void Send (string data) /// /// /// - /// The session has not started yet. + /// The Send method is not available when the session has not + /// started yet. /// /// /// -or- /// /// - /// The current state of the WebSocket interface is not Open. + /// The Send method is not available when the current state of + /// the WebSocket interface is not Open. /// /// protected void Send (Stream stream, int length) From a4707fd86132a8f65bffe19595e2717c89e44ff2 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 17 Apr 2025 16:20:48 +0900 Subject: [PATCH 6013/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 36fcaadb1..e5e49b9be 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -1335,7 +1335,7 @@ protected void Send (Stream stream, int length) protected void SendAsync (byte[] data, Action completed) { if (_websocket == null) { - var msg = "The session has not started yet."; + var msg = "The SendAsync method is not available."; throw new InvalidOperationException (msg); } From b8c6e48079fb272dcca3bffe4335358df3bfdab6 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 17 Apr 2025 16:23:17 +0900 Subject: [PATCH 6014/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index e5e49b9be..317f6cbf9 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -1323,13 +1323,15 @@ protected void Send (Stream stream, int length) /// /// /// - /// The session has not started yet. + /// The SendAsync method is not available when the session has not + /// started yet. /// /// /// -or- /// /// - /// The current state of the WebSocket interface is not Open. + /// The SendAsync method is not available when the current state of + /// the WebSocket interface is not Open. /// /// protected void SendAsync (byte[] data, Action completed) From 3392adf8e5a9a99bbdf69f6650736e7b66d77fbf Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 18 Apr 2025 16:21:17 +0900 Subject: [PATCH 6015/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 317f6cbf9..3a7466713 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -1402,7 +1402,7 @@ protected void SendAsync (byte[] data, Action completed) protected void SendAsync (FileInfo fileInfo, Action completed) { if (_websocket == null) { - var msg = "The session has not started yet."; + var msg = "The SendAsync method is not available."; throw new InvalidOperationException (msg); } From adb8b452fa9af4b046da00cb7b9f8a2783410969 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 18 Apr 2025 16:23:40 +0900 Subject: [PATCH 6016/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 3a7466713..ae0c8b986 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -1390,13 +1390,15 @@ protected void SendAsync (byte[] data, Action completed) /// /// /// - /// The session has not started yet. + /// The SendAsync method is not available when the session has not + /// started yet. /// /// /// -or- /// /// - /// The current state of the WebSocket interface is not Open. + /// The SendAsync method is not available when the current state of + /// the WebSocket interface is not Open. /// /// protected void SendAsync (FileInfo fileInfo, Action completed) From 46f79cc38a104b09490e509be751461319593550 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 19 Apr 2025 15:56:36 +0900 Subject: [PATCH 6017/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index ae0c8b986..f1b8e2e29 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -1456,7 +1456,7 @@ protected void SendAsync (FileInfo fileInfo, Action completed) protected void SendAsync (string data, Action completed) { if (_websocket == null) { - var msg = "The session has not started yet."; + var msg = "The SendAsync method is not available."; throw new InvalidOperationException (msg); } From d92f66b40067422bd6c032a9d57b7cbfc49c6c38 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 19 Apr 2025 15:58:46 +0900 Subject: [PATCH 6018/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index f1b8e2e29..5b1249d13 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -1444,13 +1444,15 @@ protected void SendAsync (FileInfo fileInfo, Action completed) /// /// /// - /// The session has not started yet. + /// The SendAsync method is not available when the session has not + /// started yet. /// /// /// -or- /// /// - /// The current state of the WebSocket interface is not Open. + /// The SendAsync method is not available when the current state of + /// the WebSocket interface is not Open. /// /// protected void SendAsync (string data, Action completed) From 15f42790c00cec2b88c220d72219c61b507db060 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 20 Apr 2025 16:04:05 +0900 Subject: [PATCH 6019/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 5b1249d13..fe4d6fa75 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -1533,7 +1533,7 @@ protected void SendAsync (string data, Action completed) protected void SendAsync (Stream stream, int length, Action completed) { if (_websocket == null) { - var msg = "The session has not started yet."; + var msg = "The SendAsync method is not available."; throw new InvalidOperationException (msg); } From 47e7293befb478f40e9fb55f26028e28399d332d Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 20 Apr 2025 16:06:10 +0900 Subject: [PATCH 6020/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index fe4d6fa75..248b4fbfc 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -1521,13 +1521,15 @@ protected void SendAsync (string data, Action completed) /// /// /// - /// The session has not started yet. + /// The SendAsync method is not available when the session has not + /// started yet. /// /// /// -or- /// /// - /// The current state of the WebSocket interface is not Open. + /// The SendAsync method is not available when the current state of + /// the WebSocket interface is not Open. /// /// protected void SendAsync (Stream stream, int length, Action completed) From 9a68fddc85866d022a4a46429192d5cf1f65bf49 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 21 Apr 2025 20:49:25 +0900 Subject: [PATCH 6021/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 248b4fbfc..2408a956b 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -1556,7 +1556,7 @@ protected void SendAsync (Stream stream, int length, Action completed) /// the WebSocket interface. /// /// - /// if the session has not started yet. + /// when the session has not started yet. /// /// WebSocket IWebSocketSession.WebSocket { From 46f7edc6d4f773fa013cbce8f6c0cab3b127c015 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 21 Apr 2025 20:51:08 +0900 Subject: [PATCH 6022/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 2408a956b..8cf3ee6fc 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -383,7 +383,7 @@ public Func HostValidator { /// A that represents the unique ID of the session. /// /// - /// if the session has not started yet. + /// when the session has not started yet. /// /// public string ID { From 0ce7189cb1db7f8064681c19a2c41f3bc7094fcc Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 21 Apr 2025 20:53:05 +0900 Subject: [PATCH 6023/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 8cf3ee6fc..ce479bb9b 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -567,7 +567,7 @@ public string Protocol { /// has started. /// /// - /// if the session has not started yet. + /// when the session has not started yet. /// /// public DateTime StartTime { From 7343a620e12e87f2f951d13e7a9724d809dbad87 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 22 Apr 2025 16:47:12 +0900 Subject: [PATCH 6024/6294] [Modify] Polish it --- Example/Program.cs | 84 ++++++++++++++++++++++++---------------------- 1 file changed, 44 insertions(+), 40 deletions(-) diff --git a/Example/Program.cs b/Example/Program.cs index ff4c3da11..c39c4be86 100644 --- a/Example/Program.cs +++ b/Example/Program.cs @@ -25,44 +25,35 @@ public static void Main (string[] args) //using (var ws = new WebSocket ("ws://localhost:4649/Chat?name=nobita")) //using (var ws = new WebSocket ("wss://localhost:5963/Chat?name=nobita")) { - // Set the WebSocket events. - - ws.OnOpen += (sender, e) => ws.Send ("Hi, there!"); - - ws.OnMessage += (sender, e) => { - var fmt = "[WebSocket Message] {0}"; - var body = !e.IsPing ? e.Data : "A ping was received."; - - Console.WriteLine (fmt, body); - }; - - ws.OnError += (sender, e) => { - var fmt = "[WebSocket Error] {0}"; - - Console.WriteLine (fmt, e.Message); - }; - - ws.OnClose += (sender, e) => { - var fmt = "[WebSocket Close ({0})] {1}"; - - Console.WriteLine (fmt, e.Code, e.Reason); - }; -#if DEBUG + #if DEBUG // To change the logging level. ws.Log.Level = LogLevel.Trace; - // To change the wait time for the response to the Ping or Close. - //ws.WaitTime = TimeSpan.FromSeconds (10); + // To enable the Per-message Compression extension. + //ws.Compression = CompressionMethod.Deflate; // To emit a WebSocket.OnMessage event when receives a ping. //ws.EmitOnPing = true; + // To enable the redirection. + //ws.EnableRedirection = true; + // To disable a delay when send or receive buffer of the underlying // TCP socket is not full. ws.NoDelay = true; -#endif - // To enable the Per-message Compression extension. - //ws.Compression = CompressionMethod.Deflate; + + // To send the Origin header. + //ws.Origin = "http://localhost:4649/"; + + // To send the cookies. + //ws.SetCookie (new Cookie ("name", "nobita")); + //ws.SetCookie (new Cookie ("roles", "\"idiot, gunfighter\"")); + + // To send the credentials for the HTTP Authentication (Basic/Digest). + //ws.SetCredentials ("nobita", "password", false); + + // To connect through the HTTP Proxy server. + //ws.SetProxy ("http://localhost:3128/", "nobita", "password"); // To validate the server certificate. /* @@ -70,7 +61,9 @@ public static void Main (string[] args) (sender, certificate, chain, sslPolicyErrors) => { var fmt = "Certificate:\n- Issuer: {0}\n- Subject: {1}"; var msg = String.Format ( - fmt, certificate.Issuer, certificate.Subject + fmt, + certificate.Issuer, + certificate.Subject ); ws.Log.Debug (msg); @@ -79,21 +72,32 @@ public static void Main (string[] args) }; */ - // To send the credentials for the HTTP Authentication (Basic/Digest). - //ws.SetCredentials ("nobita", "password", false); + // To change the wait time for the response to the Ping or Close. + //ws.WaitTime = TimeSpan.FromSeconds (10); + #endif - // To send the Origin header. - //ws.Origin = "http://localhost:4649/"; + // Set the WebSocket events. - // To send the cookies. - //ws.SetCookie (new Cookie ("name", "nobita")); - //ws.SetCookie (new Cookie ("roles", "\"idiot, gunfighter\"")); + ws.OnOpen += (sender, e) => ws.Send ("Hi, there!"); - // To connect through the HTTP Proxy server. - //ws.SetProxy ("http://localhost:3128/", "nobita", "password"); + ws.OnMessage += (sender, e) => { + var fmt = "[WebSocket Message] {0}"; + var body = !e.IsPing ? e.Data : "A ping was received."; - // To enable the redirection. - //ws.EnableRedirection = true; + Console.WriteLine (fmt, body); + }; + + ws.OnError += (sender, e) => { + var fmt = "[WebSocket Error] {0}"; + + Console.WriteLine (fmt, e.Message); + }; + + ws.OnClose += (sender, e) => { + var fmt = "[WebSocket Close ({0})] {1}"; + + Console.WriteLine (fmt, e.Code, e.Reason); + }; // Connect to the server. ws.Connect (); From 122d1a24a56c18fa6102a8be3e70c6e6a2d3f173 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 23 Apr 2025 16:25:52 +0900 Subject: [PATCH 6025/6294] [Modify] Polish it --- Example/Program.cs | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/Example/Program.cs b/Example/Program.cs index c39c4be86..93fc75ca2 100644 --- a/Example/Program.cs +++ b/Example/Program.cs @@ -78,27 +78,30 @@ public static void Main (string[] args) // Set the WebSocket events. - ws.OnOpen += (sender, e) => ws.Send ("Hi, there!"); - - ws.OnMessage += (sender, e) => { - var fmt = "[WebSocket Message] {0}"; - var body = !e.IsPing ? e.Data : "A ping was received."; + ws.OnClose += + (sender, e) => { + var fmt = "[WebSocket Close ({0})] {1}"; - Console.WriteLine (fmt, body); + Console.WriteLine (fmt, e.Code, e.Reason); }; - ws.OnError += (sender, e) => { + ws.OnError += + (sender, e) => { var fmt = "[WebSocket Error] {0}"; Console.WriteLine (fmt, e.Message); }; - ws.OnClose += (sender, e) => { - var fmt = "[WebSocket Close ({0})] {1}"; + ws.OnMessage += + (sender, e) => { + var fmt = "[WebSocket Message] {0}"; + var body = !e.IsPing ? e.Data : "A ping was received."; - Console.WriteLine (fmt, e.Code, e.Reason); + Console.WriteLine (fmt, body); }; + ws.OnOpen += (sender, e) => ws.Send ("Hi, there!"); + // Connect to the server. ws.Connect (); From 4978ebcc06efe963060ef12bd0ed2e49a2702cb3 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 23 Apr 2025 16:34:49 +0900 Subject: [PATCH 6026/6294] [Modify] Polish it --- Example/Program.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Example/Program.cs b/Example/Program.cs index 93fc75ca2..38446eaaa 100644 --- a/Example/Program.cs +++ b/Example/Program.cs @@ -94,10 +94,11 @@ public static void Main (string[] args) ws.OnMessage += (sender, e) => { - var fmt = "[WebSocket Message] {0}"; - var body = !e.IsPing ? e.Data : "A ping was received."; + var fmt = e.IsPing + ? "[WebSocket Ping] {0}" + : "[WebSocket Message] {0}"; - Console.WriteLine (fmt, body); + Console.WriteLine (fmt, e.Data); }; ws.OnOpen += (sender, e) => ws.Send ("Hi, there!"); From eb1ad9ec00e398b63f27c53f6baac16ae313c8bd Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 24 Apr 2025 16:48:33 +0900 Subject: [PATCH 6027/6294] [Modify] Polish it --- Example/Program.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Example/Program.cs b/Example/Program.cs index 38446eaaa..a9173f6f7 100644 --- a/Example/Program.cs +++ b/Example/Program.cs @@ -25,7 +25,7 @@ public static void Main (string[] args) //using (var ws = new WebSocket ("ws://localhost:4649/Chat?name=nobita")) //using (var ws = new WebSocket ("wss://localhost:5963/Chat?name=nobita")) { - #if DEBUG +#if DEBUG // To change the logging level. ws.Log.Level = LogLevel.Trace; @@ -74,7 +74,7 @@ public static void Main (string[] args) // To change the wait time for the response to the Ping or Close. //ws.WaitTime = TimeSpan.FromSeconds (10); - #endif +#endif // Set the WebSocket events. From a2a8d4806a17556d78c9e9284af58530dc3dabc0 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 24 Apr 2025 16:50:38 +0900 Subject: [PATCH 6028/6294] [Modify] Polish it --- Example/Program.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Example/Program.cs b/Example/Program.cs index a9173f6f7..8c57d6fd8 100644 --- a/Example/Program.cs +++ b/Example/Program.cs @@ -113,6 +113,7 @@ public static void Main (string[] args) while (true) { Thread.Sleep (1000); + Console.Write ("> "); var msg = Console.ReadLine (); From eaa3d9a2740a9e098ec7955f14aba6e245a8d65c Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 25 Apr 2025 21:53:37 +0900 Subject: [PATCH 6029/6294] [Modify] Polish it --- Example/Program.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Example/Program.cs b/Example/Program.cs index 8c57d6fd8..439a9918b 100644 --- a/Example/Program.cs +++ b/Example/Program.cs @@ -109,7 +109,7 @@ public static void Main (string[] args) // Connect to the server asynchronously. //ws.ConnectAsync (); - Console.WriteLine ("\nType 'exit' to exit.\n"); + Console.WriteLine ("\nType \"exit\" to exit.\n"); while (true) { Thread.Sleep (1000); From 5bd4191175ec52c38351a415910e8e8ed342005f Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 25 Apr 2025 22:21:09 +0900 Subject: [PATCH 6030/6294] [Modify] Polish it --- Example2/Program.cs | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/Example2/Program.cs b/Example2/Program.cs index 497b8ac96..c586fecdd 100644 --- a/Example2/Program.cs +++ b/Example2/Program.cs @@ -46,28 +46,17 @@ public static void Main (string[] args) //var wssv = new WebSocketServer ("ws://[::1]:4649"); //var wssv = new WebSocketServer ("wss://[::1]:5963"); + #if DEBUG // To change the logging level. wssv.Log.Level = LogLevel.Trace; - // To change the wait time for the response to the WebSocket Ping or Close. - //wssv.WaitTime = TimeSpan.FromSeconds (2); - - // To remove the inactive sessions periodically. - //wssv.KeepClean = true; -#endif - // To provide the secure connection. - /* - var cert = ConfigurationManager.AppSettings["ServerCertFile"]; - var passwd = ConfigurationManager.AppSettings["CertFilePassword"]; - wssv.SslConfiguration.ServerCertificate = new X509Certificate2 (cert, passwd); - */ - // To provide the HTTP Authentication (Basic/Digest). /* wssv.AuthenticationSchemes = AuthenticationSchemes.Basic; wssv.Realm = "WebSocket Test"; - wssv.UserCredentialsFinder = id => { + wssv.UserCredentialsFinder = + id => { var name = id.Name; // Return user name, password, and roles. @@ -77,9 +66,27 @@ public static void Main (string[] args) }; */ + // To remove the inactive sessions periodically. + //wssv.KeepClean = true; + // To resolve to wait for socket in TIME_WAIT state. //wssv.ReuseAddress = true; + // To provide the secure connection. + /* + var cert = ConfigurationManager.AppSettings["ServerCertFile"]; + var passwd = ConfigurationManager.AppSettings["CertFilePassword"]; + + wssv.SslConfiguration.ServerCertificate = new X509Certificate2 ( + cert, + passwd + ); + */ + + // To change the wait time for the response to the WebSocket Ping or Close. + //wssv.WaitTime = TimeSpan.FromSeconds (2); +#endif + // Add the WebSocket services. wssv.AddWebSocketService ("/Echo"); wssv.AddWebSocketService ("/Chat"); From 2962787454ddcfb659d1c1018ca51a4665c22bde Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 26 Apr 2025 16:22:45 +0900 Subject: [PATCH 6031/6294] [Modify] Polish it --- Example2/Program.cs | 51 ++++++++++++++++++++++++++------------------- 1 file changed, 30 insertions(+), 21 deletions(-) diff --git a/Example2/Program.cs b/Example2/Program.cs index c586fecdd..a10b34ded 100644 --- a/Example2/Program.cs +++ b/Example2/Program.cs @@ -88,53 +88,62 @@ public static void Main (string[] args) #endif // Add the WebSocket services. + wssv.AddWebSocketService ("/Echo"); - wssv.AddWebSocketService ("/Chat"); - // Add the WebSocket service with initializing. - /* + // With initializing. wssv.AddWebSocketService ( "/Chat", s => { s.Prefix = "Anon#"; +#if DEBUG + // To validate the cookies. + /* + s.CookiesValidator = + (req, res) => { + // Check the cookies in "req", and set the cookies to send to + // the client with "res" if necessary. - // To send the Sec-WebSocket-Protocol header that has a subprotocol name. - s.Protocol = "chat"; + foreach (var cookie in req) { + cookie.Expired = true; - // To ignore the Sec-WebSocket-Extensions header. - s.IgnoreExtensions = true; + res.Add (cookie); + } + + return true; // If valid. + }; + */ // To emit a WebSocket.OnMessage event when receives a ping. - s.EmitOnPing = true; + //s.EmitOnPing = true; + + // To ignore the Sec-WebSocket-Extensions header. + //s.IgnoreExtensions = true; // To disable a delay when send or receive buffer of the underlying // TCP socket is not full. s.NoDelay = true; // To validate the Origin header. - s.OriginValidator = val => { + /* + s.OriginValidator = + val => { // Check the value of the Origin header, and return true if valid. + Uri origin; return !val.IsNullOrEmpty () && Uri.TryCreate (val, UriKind.Absolute, out origin) && origin.Host == "localhost"; }; + */ - // To validate the cookies. - s.CookiesValidator = (req, res) => { - // Check the cookies in 'req', and set the cookies to send to - // the client with 'res' if necessary. - foreach (var cookie in req) { - cookie.Expired = true; - res.Add (cookie); - } - - return true; // If valid. - }; + // To send the Sec-WebSocket-Protocol header that has a subprotocol + // name. + //s.Protocol = "chat"; +#endif } ); - */ wssv.Start (); From ab59790010dcf477b72c617c42be3141c91122cb Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 27 Apr 2025 16:28:45 +0900 Subject: [PATCH 6032/6294] [Modify] Polish it --- Example2/Program.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Example2/Program.cs b/Example2/Program.cs index a10b34ded..68f23dbb4 100644 --- a/Example2/Program.cs +++ b/Example2/Program.cs @@ -145,18 +145,24 @@ public static void Main (string[] args) } ); + // Start the server. wssv.Start (); if (wssv.IsListening) { - Console.WriteLine ("Listening on port {0}, and providing WebSocket services:", wssv.Port); + Console.WriteLine ( + "Listening on port {0}, and providing WebSocket services:", + wssv.Port + ); foreach (var path in wssv.WebSocketServices.Paths) Console.WriteLine ("- {0}", path); } Console.WriteLine ("\nPress Enter key to stop the server..."); + Console.ReadLine (); + // Stop the server. wssv.Stop (); } } From da2c1aafb904bc57855c0f0942443eee8fcbe4d4 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 27 Apr 2025 16:32:20 +0900 Subject: [PATCH 6033/6294] [Modify] Edit it --- Example2/Program.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Example2/Program.cs b/Example2/Program.cs index 68f23dbb4..5e960de3b 100644 --- a/Example2/Program.cs +++ b/Example2/Program.cs @@ -14,7 +14,7 @@ public static void Main (string[] args) // Create a new instance of the WebSocketServer class. // // If you would like to provide the secure connection, you should - // create a new instance with the 'secure' parameter set to true or + // create a new instance with the "secure" parameter set to true or // with a wss scheme WebSocket URL. var wssv = new WebSocketServer (4649); From 231e9f31022083686674ebc1db1ec7aefc291bd7 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 27 Apr 2025 16:40:49 +0900 Subject: [PATCH 6034/6294] [Modify] Polish it --- Example2/Program.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/Example2/Program.cs b/Example2/Program.cs index 5e960de3b..6f08dddb0 100644 --- a/Example2/Program.cs +++ b/Example2/Program.cs @@ -46,7 +46,6 @@ public static void Main (string[] args) //var wssv = new WebSocketServer ("ws://[::1]:4649"); //var wssv = new WebSocketServer ("wss://[::1]:5963"); - #if DEBUG // To change the logging level. wssv.Log.Level = LogLevel.Trace; @@ -86,7 +85,6 @@ public static void Main (string[] args) // To change the wait time for the response to the WebSocket Ping or Close. //wssv.WaitTime = TimeSpan.FromSeconds (2); #endif - // Add the WebSocket services. wssv.AddWebSocketService ("/Echo"); From 9a1cae93bcc1781c46d399c3ae4ce4cec4b818b0 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 28 Apr 2025 16:22:57 +0900 Subject: [PATCH 6035/6294] [Modify] Polish it --- Example/Program.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/Example/Program.cs b/Example/Program.cs index 439a9918b..ec4302af6 100644 --- a/Example/Program.cs +++ b/Example/Program.cs @@ -75,7 +75,6 @@ public static void Main (string[] args) // To change the wait time for the response to the Ping or Close. //ws.WaitTime = TimeSpan.FromSeconds (10); #endif - // Set the WebSocket events. ws.OnClose += From edaaadc4e8c1fce568509f62ddd44e7455d6e6bf Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 28 Apr 2025 16:35:05 +0900 Subject: [PATCH 6036/6294] [Modify] Polish it --- Example3/Program.cs | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/Example3/Program.cs b/Example3/Program.cs index 2c674378a..24b2047d0 100644 --- a/Example3/Program.cs +++ b/Example3/Program.cs @@ -51,24 +51,12 @@ public static void Main (string[] args) // To change the logging level. httpsv.Log.Level = LogLevel.Trace; - // To change the wait time for the response to the WebSocket Ping or Close. - //httpsv.WaitTime = TimeSpan.FromSeconds (2); - - // To remove the inactive WebSocket sessions periodically. - //httpsv.KeepClean = true; -#endif - // To provide the secure connection. - /* - var cert = ConfigurationManager.AppSettings["ServerCertFile"]; - var passwd = ConfigurationManager.AppSettings["CertFilePassword"]; - httpsv.SslConfiguration.ServerCertificate = new X509Certificate2 (cert, passwd); - */ - // To provide the HTTP Authentication (Basic/Digest). /* httpsv.AuthenticationSchemes = AuthenticationSchemes.Basic; httpsv.Realm = "WebSocket Test"; - httpsv.UserCredentialsFinder = id => { + httpsv.UserCredentialsFinder = + id => { var name = id.Name; // Return user name, password, and roles. @@ -78,9 +66,26 @@ public static void Main (string[] args) }; */ + // To remove the inactive WebSocket sessions periodically. + //httpsv.KeepClean = true; + // To resolve to wait for socket in TIME_WAIT state. //httpsv.ReuseAddress = true; + // To provide the secure connection. + /* + var cert = ConfigurationManager.AppSettings["ServerCertFile"]; + var passwd = ConfigurationManager.AppSettings["CertFilePassword"]; + + httpsv.SslConfiguration.ServerCertificate = new X509Certificate2 ( + cert, + passwd + ); + */ + + // To change the wait time for the response to the WebSocket Ping or Close. + //httpsv.WaitTime = TimeSpan.FromSeconds (2); +#endif // Set the document root path. httpsv.DocumentRootPath = ConfigurationManager.AppSettings["DocumentRootPath"]; From 0a67662e0f1dc9fa49888f8f5a1b3d0e8a5ac08b Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 29 Apr 2025 16:40:46 +0900 Subject: [PATCH 6037/6294] [Modify] Polish it --- Example3/Program.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Example3/Program.cs b/Example3/Program.cs index 24b2047d0..014bf850a 100644 --- a/Example3/Program.cs +++ b/Example3/Program.cs @@ -90,7 +90,8 @@ public static void Main (string[] args) httpsv.DocumentRootPath = ConfigurationManager.AppSettings["DocumentRootPath"]; // Set the HTTP GET request event. - httpsv.OnGet += (sender, e) => { + httpsv.OnGet += + (sender, e) => { var req = e.Request; var res = e.Response; From 69797cb5f6856495a762bfc3afa652b3d740d0ef Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 30 Apr 2025 16:41:59 +0900 Subject: [PATCH 6038/6294] [Modify] Polish it --- Example3/Program.cs | 51 ++++++++++++++++++++++++++------------------- 1 file changed, 30 insertions(+), 21 deletions(-) diff --git a/Example3/Program.cs b/Example3/Program.cs index 014bf850a..321eb14ac 100644 --- a/Example3/Program.cs +++ b/Example3/Program.cs @@ -123,53 +123,62 @@ public static void Main (string[] args) }; // Add the WebSocket services. + httpsv.AddWebSocketService ("/Echo"); - httpsv.AddWebSocketService ("/Chat"); - // Add the WebSocket service with initializing. - /* + // With initializing. httpsv.AddWebSocketService ( "/Chat", s => { s.Prefix = "Anon#"; +#if DEBUG + // To validate the cookies. + /* + s.CookiesValidator = + (req, res) => { + // Check the cookies in "req", and set the cookies to send to + // the client with "res" if necessary. - // To send the Sec-WebSocket-Protocol header that has a subprotocol name. - s.Protocol = "chat"; + foreach (var cookie in req) { + cookie.Expired = true; - // To ignore the Sec-WebSocket-Extensions header. - s.IgnoreExtensions = true; + res.Add (cookie); + } + + return true; // If valid. + }; + */ // To emit a WebSocket.OnMessage event when receives a ping. - s.EmitOnPing = true; + //s.EmitOnPing = true; + + // To ignore the Sec-WebSocket-Extensions header. + //s.IgnoreExtensions = true; // To disable a delay when send or receive buffer of the underlying // TCP socket is not full. s.NoDelay = true; // To validate the Origin header. - s.OriginValidator = val => { + /* + s.OriginValidator = + val => { // Check the value of the Origin header, and return true if valid. + Uri origin; return !val.IsNullOrEmpty () && Uri.TryCreate (val, UriKind.Absolute, out origin) && origin.Host == "localhost"; }; + */ - // To validate the cookies. - s.CookiesValidator = (req, res) => { - // Check the cookies in 'req', and set the cookies to send to - // the client with 'res' if necessary. - foreach (var cookie in req) { - cookie.Expired = true; - res.Add (cookie); - } - - return true; // If valid. - }; + // To send the Sec-WebSocket-Protocol header that has a subprotocol + // name. + //s.Protocol = "chat"; +#endif } ); - */ httpsv.Start (); From b7a1b356d286056ced750886022a3dfa2bbe4350 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 1 May 2025 16:36:03 +0900 Subject: [PATCH 6039/6294] [Modify] Polish it --- Example3/Program.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Example3/Program.cs b/Example3/Program.cs index 321eb14ac..5d592a4af 100644 --- a/Example3/Program.cs +++ b/Example3/Program.cs @@ -180,18 +180,24 @@ public static void Main (string[] args) } ); + // Start the server. httpsv.Start (); if (httpsv.IsListening) { - Console.WriteLine ("Listening on port {0}, and providing WebSocket services:", httpsv.Port); + Console.WriteLine ( + "Listening on port {0}, and providing WebSocket services:", + httpsv.Port + ); foreach (var path in httpsv.WebSocketServices.Paths) Console.WriteLine ("- {0}", path); } Console.WriteLine ("\nPress Enter key to stop the server..."); + Console.ReadLine (); + // Stop the server. httpsv.Stop (); } } From 7c4c2bde3391746a0e50a77a5dfa96381cb3191c Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 2 May 2025 16:37:53 +0900 Subject: [PATCH 6040/6294] [Modify] Edit it --- Example3/Program.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Example3/Program.cs b/Example3/Program.cs index 5d592a4af..216007911 100644 --- a/Example3/Program.cs +++ b/Example3/Program.cs @@ -15,7 +15,7 @@ public static void Main (string[] args) // Create a new instance of the HttpServer class. // // If you would like to provide the secure connection, you should - // create a new instance with the 'secure' parameter set to true or + // create a new instance with the "secure" parameter set to true or // with an https scheme HTTP URL. var httpsv = new HttpServer (4649); From 6203782af2cc90980451f4f638a27aa3f8fc2ab8 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 2 May 2025 16:41:00 +0900 Subject: [PATCH 6041/6294] [Modify] Polish it --- Example3/Program.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Example3/Program.cs b/Example3/Program.cs index 216007911..fc3776ff1 100644 --- a/Example3/Program.cs +++ b/Example3/Program.cs @@ -87,7 +87,8 @@ public static void Main (string[] args) //httpsv.WaitTime = TimeSpan.FromSeconds (2); #endif // Set the document root path. - httpsv.DocumentRootPath = ConfigurationManager.AppSettings["DocumentRootPath"]; + httpsv.DocumentRootPath = ConfigurationManager + .AppSettings["DocumentRootPath"]; // Set the HTTP GET request event. httpsv.OnGet += From 8412a1e364cca5e926ec977022e2943bdfc04c98 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 3 May 2025 17:56:00 +0900 Subject: [PATCH 6042/6294] [Modify] Polish it --- Example3/Program.cs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Example3/Program.cs b/Example3/Program.cs index fc3776ff1..a0649ae38 100644 --- a/Example3/Program.cs +++ b/Example3/Program.cs @@ -185,10 +185,9 @@ public static void Main (string[] args) httpsv.Start (); if (httpsv.IsListening) { - Console.WriteLine ( - "Listening on port {0}, and providing WebSocket services:", - httpsv.Port - ); + var fmt = "Listening on port {0}, and providing WebSocket services:"; + + Console.WriteLine (fmt, httpsv.Port); foreach (var path in httpsv.WebSocketServices.Paths) Console.WriteLine ("- {0}", path); From 2d746ab9d5a1284a63799e8c48c1eedd3723004c Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 4 May 2025 16:16:46 +0900 Subject: [PATCH 6043/6294] [Modify] Polish it --- Example2/Program.cs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Example2/Program.cs b/Example2/Program.cs index 6f08dddb0..b3ccf7ab9 100644 --- a/Example2/Program.cs +++ b/Example2/Program.cs @@ -147,10 +147,9 @@ public static void Main (string[] args) wssv.Start (); if (wssv.IsListening) { - Console.WriteLine ( - "Listening on port {0}, and providing WebSocket services:", - wssv.Port - ); + var fmt = "Listening on port {0}, and providing WebSocket services:"; + + Console.WriteLine (fmt, wssv.Port); foreach (var path in wssv.WebSocketServices.Paths) Console.WriteLine ("- {0}", path); From c204b82ac75255a03088a8c4c0f3a472f561d5aa Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 5 May 2025 18:02:15 +0900 Subject: [PATCH 6044/6294] [Modify] Throw an exception --- websocket-sharp/WebSocket.cs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 03e6fd8f7..3dcfbf620 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -535,10 +535,6 @@ internal set { /// Gets or sets a value indicating whether the underlying TCP socket /// disables a delay when send or receive buffer is not full. /// - /// - /// The set operation works if the current state of the interface is - /// New or Closed. - /// /// /// /// true if the delay is disabled; otherwise, false. @@ -548,6 +544,10 @@ internal set { /// /// /// + /// + /// The set operation is not available when the current state of + /// the interface is neither New nor Closed. + /// public bool NoDelay { get { return _noDelay; @@ -555,8 +555,11 @@ public bool NoDelay { set { lock (_forState) { - if (!canSet ()) - return; + if (!canSet ()) { + var msg = "The set operation is not available."; + + throw new InvalidOperationException (msg); + } _noDelay = value; } From 8469533c26e91abae6e3f44dfa4125a3d150a0ee Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 6 May 2025 11:41:40 +0900 Subject: [PATCH 6045/6294] [Modify] Throw an exception --- websocket-sharp/WebSocket.cs | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 3dcfbf620..26971bbe2 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -341,8 +341,17 @@ internal bool IgnoreExtensions { /// /// /// - /// The set operation is not available if the interface is not for - /// the client. + /// + /// The set operation is not available if the interface is not for + /// the client. + /// + /// + /// -or- + /// + /// + /// The set operation is not available when the current state of + /// the interface is neither New nor Closed. + /// /// public CompressionMethod Compression { get { @@ -357,8 +366,11 @@ public CompressionMethod Compression { } lock (_forState) { - if (!canSet ()) - return; + if (!canSet ()) { + var msg = "The current state of the interface is neither New nor Closed."; + + throw new InvalidOperationException (msg); + } _compression = value; } From 56709183373761920ebd10b4e1d749c20be6252c Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 6 May 2025 11:44:18 +0900 Subject: [PATCH 6046/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 26971bbe2..967389927 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -325,10 +325,6 @@ internal bool IgnoreExtensions { /// /// Gets or sets the compression method used to compress a message. /// - /// - /// The set operation works if the current state of the interface is - /// New or Closed. - /// /// /// /// One of the enum values. From a8faebfc85a85c16ff887a67546cc5bd8d1a18dc Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 7 May 2025 21:02:00 +0900 Subject: [PATCH 6047/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 967389927..cb9043e0f 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -356,14 +356,14 @@ public CompressionMethod Compression { set { if (!_isClient) { - var msg = "The interface is not for the client."; + var msg = "The set operation is not available."; throw new InvalidOperationException (msg); } lock (_forState) { if (!canSet ()) { - var msg = "The current state of the interface is neither New nor Closed."; + var msg = "The set operation is not available."; throw new InvalidOperationException (msg); } From 34199b5c7afdabeedf61482b21ee3f26ba32ef52 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 8 May 2025 16:25:35 +0900 Subject: [PATCH 6048/6294] [Modify] Throw an exception --- websocket-sharp/WebSocket.cs | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index cb9043e0f..fbcd65f5d 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -440,10 +440,6 @@ public bool EmitOnPing { /// Gets or sets a value indicating whether the URL redirection for /// the handshake request is allowed. /// - /// - /// The set operation works if the current state of the interface is - /// New or Closed. - /// /// /// /// true if the interface allows the URL redirection for @@ -454,8 +450,17 @@ public bool EmitOnPing { /// /// /// - /// The set operation is not available if the interface is not for - /// the client. + /// + /// The set operation is not available if the interface is not for + /// the client. + /// + /// + /// -or- + /// + /// + /// The set operation is not available when the current state of + /// the interface is neither New nor Closed. + /// /// public bool EnableRedirection { get { @@ -464,14 +469,17 @@ public bool EnableRedirection { set { if (!_isClient) { - var msg = "The interface is not for the client."; + var msg = "The set operation is not available."; throw new InvalidOperationException (msg); } lock (_forState) { - if (!canSet ()) - return; + if (!canSet ()) { + var msg = "The set operation is not available."; + + throw new InvalidOperationException (msg); + } _enableRedirection = value; } From b85e781b40ef599710a2f2ae7fdfba0a75c330a0 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 9 May 2025 16:29:32 +0900 Subject: [PATCH 6049/6294] [Modify] Throw an exception --- websocket-sharp/WebSocket.cs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index fbcd65f5d..e51b9e186 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -767,10 +767,6 @@ public Uri Url { /// /// Gets or sets the time to wait for the response to the ping or close. /// - /// - /// The set operation works if the current state of the interface is - /// New or Closed. - /// /// /// /// A that represents the time to wait for @@ -784,6 +780,10 @@ public Uri Url { /// /// The value specified for a set operation is zero or less. /// + /// + /// The set operation is not available when the current state of + /// the interface is neither New nor Closed. + /// public TimeSpan WaitTime { get { return _waitTime; @@ -797,8 +797,11 @@ public TimeSpan WaitTime { } lock (_forState) { - if (!canSet ()) - return; + if (!canSet ()) { + var msg = "The set operation is not available."; + + throw new InvalidOperationException (msg); + } _waitTime = value; } From aa0302ce806731cddd96589140b66e3cc69a84f5 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 10 May 2025 16:12:11 +0900 Subject: [PATCH 6050/6294] [Modify] Throw an exception --- websocket-sharp/WebSocket.cs | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index e51b9e186..c3513fdf2 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -595,10 +595,6 @@ public bool NoDelay { /// /// The interface sends the Origin header if this property has any. /// - /// - /// The set operation works if the current state of the interface is - /// New or Closed. - /// /// /// /// @@ -612,10 +608,6 @@ public bool NoDelay { /// The default value is . /// /// - /// - /// The set operation is not available if the interface is not for - /// the client. - /// /// /// /// The value specified for a set operation is not an absolute URI string. @@ -627,6 +619,19 @@ public bool NoDelay { /// The value specified for a set operation includes the path segments. /// /// + /// + /// + /// The set operation is not available if the interface is not for + /// the client. + /// + /// + /// -or- + /// + /// + /// The set operation is not available when the current state of + /// the interface is neither New nor Closed. + /// + /// public string Origin { get { return _origin; @@ -634,7 +639,7 @@ public string Origin { set { if (!_isClient) { - var msg = "The interface is not for the client."; + var msg = "The set operation is not available."; throw new InvalidOperationException (msg); } @@ -656,8 +661,11 @@ public string Origin { } lock (_forState) { - if (!canSet ()) - return; + if (!canSet ()) { + var msg = "The set operation is not available."; + + throw new InvalidOperationException (msg); + } _origin = !value.IsNullOrEmpty () ? value.TrimEnd ('/') : value; } From 6e494c20115376552d2f5ee434ebd89296d3d865 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 11 May 2025 16:43:29 +0900 Subject: [PATCH 6051/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index c3513fdf2..fd3570966 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -727,13 +727,15 @@ public WebSocketState ReadyState { /// /// /// - /// The interface is not for the client. + /// The get operation is not available if the interface is not for + /// the client. /// /// /// -or- /// /// - /// The interface does not use a secure connection. + /// The get operation is not available if the interface does not use + /// a secure connection. /// /// public ClientSslConfiguration SslConfiguration { From 633e6efdf9acf5fec0bb7a9c748ee4a8642b56f6 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 12 May 2025 11:27:01 +0900 Subject: [PATCH 6052/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index fd3570966..7553a841d 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -741,13 +741,13 @@ public WebSocketState ReadyState { public ClientSslConfiguration SslConfiguration { get { if (!_isClient) { - var msg = "The interface is not for the client."; + var msg = "The get operation is not available."; throw new InvalidOperationException (msg); } if (!_isSecure) { - var msg = "The interface does not use a secure connection."; + var msg = "The get operation is not available."; throw new InvalidOperationException (msg); } From 34f9ba17de450f98f333efaf7788f726f1271f4d Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 13 May 2025 10:54:36 +0900 Subject: [PATCH 6053/6294] [Modify] Throw an exception --- websocket-sharp/WebSocket.cs | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 7553a841d..5ce1e6778 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3964,23 +3964,29 @@ public void SendAsync (Stream stream, int length, Action completed) /// /// Sets an HTTP cookie to send with the handshake request. /// - /// - /// This method works if the current state of the interface is - /// New or Closed. - /// /// /// A that specifies the cookie to send. /// - /// - /// The interface is not for the client. - /// /// /// is . /// + /// + /// + /// The SetCookie method is not available if the interface is not for + /// the client. + /// + /// + /// -or- + /// + /// + /// The SetCookie method is not available when the current state of + /// the interface is neither New nor Closed. + /// + /// public void SetCookie (Cookie cookie) { if (!_isClient) { - var msg = "The interface is not for the client."; + var msg = "The SetCookie method is not available."; throw new InvalidOperationException (msg); } @@ -3989,8 +3995,11 @@ public void SetCookie (Cookie cookie) throw new ArgumentNullException ("cookie"); lock (_forState) { - if (!canSet ()) - return; + if (!canSet ()) { + var msg = "The SetCookie method is not available."; + + throw new InvalidOperationException (msg); + } lock (_cookies.SyncRoot) _cookies.SetOrRemove (cookie); From 8f9b5bc07e59d6cb4604b4d0232048b23a610a53 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 14 May 2025 21:17:12 +0900 Subject: [PATCH 6054/6294] [Modify] Do not throw it --- websocket-sharp/WebSocket.cs | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 5ce1e6778..7d643beb5 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3962,7 +3962,7 @@ public void SendAsync (Stream stream, int length, Action completed) } /// - /// Sets an HTTP cookie to send with the handshake request. + /// Sets an HTTP cookie to send with the handshake request or response. /// /// /// A that specifies the cookie to send. @@ -3971,26 +3971,11 @@ public void SendAsync (Stream stream, int length, Action completed) /// is . /// /// - /// - /// The SetCookie method is not available if the interface is not for - /// the client. - /// - /// - /// -or- - /// - /// - /// The SetCookie method is not available when the current state of - /// the interface is neither New nor Closed. - /// + /// The SetCookie method is not available when the current state of + /// the interface is neither New nor Closed. /// public void SetCookie (Cookie cookie) { - if (!_isClient) { - var msg = "The SetCookie method is not available."; - - throw new InvalidOperationException (msg); - } - if (cookie == null) throw new ArgumentNullException ("cookie"); From b54937e2637a626e5324c68c41ac2855ccd73270 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 15 May 2025 16:21:56 +0900 Subject: [PATCH 6055/6294] [Modify] Throw an exception --- websocket-sharp/WebSocket.cs | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 7d643beb5..1440faf2e 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3994,10 +3994,6 @@ public void SetCookie (Cookie cookie) /// /// Sets the credentials for the HTTP authentication (Basic/Digest). /// - /// - /// This method works if the current state of the interface is - /// New or Closed. - /// /// /// /// A that specifies the username associated @@ -4022,9 +4018,6 @@ public void SetCookie (Cookie cookie) /// the Basic authentication in advance with the first handshake /// request; otherwise, false. /// - /// - /// The interface is not for the client. - /// /// /// /// contains an invalid character. @@ -4036,10 +4029,23 @@ public void SetCookie (Cookie cookie) /// contains an invalid character. /// /// + /// + /// + /// The SetCredentials method is not available if the interface is not for + /// the client. + /// + /// + /// -or- + /// + /// + /// The SetCredentials method is not available when the current state of + /// the interface is neither New nor Closed. + /// + /// public void SetCredentials (string username, string password, bool preAuth) { if (!_isClient) { - var msg = "The interface is not for the client."; + var msg = "The SetCredentials method is not available."; throw new InvalidOperationException (msg); } @@ -4061,8 +4067,11 @@ public void SetCredentials (string username, string password, bool preAuth) } lock (_forState) { - if (!canSet ()) - return; + if (!canSet ()) { + var msg = "The SetCredentials method is not available."; + + throw new InvalidOperationException (msg); + } if (username.IsNullOrEmpty ()) { _credentials = null; From b26c4e9f61c5e6c193b07c67388b85d3a6e31a3e Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 16 May 2025 16:34:30 +0900 Subject: [PATCH 6056/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 1440faf2e..616aacf65 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -4081,7 +4081,9 @@ public void SetCredentials (string username, string password, bool preAuth) } _credentials = new NetworkCredential ( - username, password, _uri.PathAndQuery + username, + password, + _uri.PathAndQuery ); _preAuth = preAuth; From a1c685ddfe9d749727c8eac338277a9bb259c27a Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 17 May 2025 16:33:34 +0900 Subject: [PATCH 6057/6294] [Modify] Throw an exception --- websocket-sharp/WebSocket.cs | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 616aacf65..778643f5e 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -4094,10 +4094,6 @@ public void SetCredentials (string username, string password, bool preAuth) /// Sets the URL of the HTTP proxy server through which to connect and /// the credentials for the HTTP proxy authentication (Basic/Digest). /// - /// - /// This method works if the current state of the interface is - /// New or Closed. - /// /// /// /// A that specifies the URL of the proxy @@ -4130,9 +4126,6 @@ public void SetCredentials (string username, string password, bool preAuth) /// or an empty string if not necessary. /// /// - /// - /// The interface is not for the client. - /// /// /// /// is not an absolute URI string. @@ -4162,10 +4155,23 @@ public void SetCredentials (string username, string password, bool preAuth) /// contains an invalid character. /// /// + /// + /// + /// The SetProxy method is not available if the interface is not for + /// the client. + /// + /// + /// -or- + /// + /// + /// The SetProxy method is not available when the current state of + /// the interface is neither New nor Closed. + /// + /// public void SetProxy (string url, string username, string password) { if (!_isClient) { - var msg = "The interface is not for the client."; + var msg = "The SetProxy method is not available."; throw new InvalidOperationException (msg); } @@ -4209,8 +4215,11 @@ public void SetProxy (string url, string username, string password) } lock (_forState) { - if (!canSet ()) - return; + if (!canSet ()) { + var msg = "The SetProxy method is not available."; + + throw new InvalidOperationException (msg); + } if (url.IsNullOrEmpty ()) { _proxyUri = null; From 5bcde410475af5c74bc1359f65a816307bb25054 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 18 May 2025 11:23:10 +0900 Subject: [PATCH 6058/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 778643f5e..cba33b35f 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -4234,7 +4234,9 @@ public void SetProxy (string url, string username, string password) username, password, String.Format ( - "{0}:{1}", _uri.DnsSafeHost, _uri.Port + "{0}:{1}", + _uri.DnsSafeHost, + _uri.Port ) ) : null; From 8ecf25810c45caaf510eb92773777e41b10b335c Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 19 May 2025 16:36:55 +0900 Subject: [PATCH 6059/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index cba33b35f..bb2869b56 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -4229,17 +4229,16 @@ public void SetProxy (string url, string username, string password) } _proxyUri = uri; - _proxyCredentials = !username.IsNullOrEmpty () - ? new NetworkCredential ( - username, - password, - String.Format ( - "{0}:{1}", - _uri.DnsSafeHost, - _uri.Port - ) - ) - : null; + + if (username.IsNullOrEmpty ()) { + _proxyCredentials = null; + + return; + } + + var domain = String.Format ("{0}:{1}", _uri.DnsSafeHost, _uri.Port); + + _proxyCredentials = new NetworkCredential (username, password, domain); } } From 6d90d14db89e40215bd86640db5d9bc4d418cc9f Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 20 May 2025 21:27:56 +0900 Subject: [PATCH 6060/6294] [Modify] Throw an exception --- websocket-sharp/WebSocket.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index bb2869b56..d8e6cb2a9 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -537,8 +537,18 @@ public bool IsSecure { /// /// A that provides the logging function. /// + /// + /// The get operation is not available if the interface is not for + /// the client. + /// public Logger Log { get { + if (!_isClient) { + var msg = "The get operation is not available."; + + throw new InvalidOperationException (msg); + } + return _log; } From 319fe533940c2d59dd171ee07895b1793c5b32e5 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 21 May 2025 17:17:23 +0900 Subject: [PATCH 6061/6294] [Modify] Throw an exception --- websocket-sharp/WebSocket.cs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index d8e6cb2a9..e186a851a 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -426,13 +426,25 @@ public NetworkCredential Credentials { /// The default value is false. /// /// + /// + /// The set operation is not available when the current state of + /// the interface is neither New nor Closed. + /// public bool EmitOnPing { get { return _emitOnPing; } set { - _emitOnPing = value; + lock (_forState) { + if (!canSet ()) { + var msg = "The set operation is not available."; + + throw new InvalidOperationException (msg); + } + + _emitOnPing = value; + } } } From e9e0d15ee2177acfe07905124d3dc3ef1480d7dc Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 22 May 2025 16:29:17 +0900 Subject: [PATCH 6062/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index e186a851a..8d3aede8b 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -414,13 +414,13 @@ public NetworkCredential Credentials { } /// - /// Gets or sets a value indicating whether the message event is - /// emitted when the interface receives a ping. + /// Gets or sets a value indicating whether the interface emits + /// the message event when it receives a ping. /// /// /// /// true if the interface emits the message event when - /// receives a ping; otherwise, false. + /// it receives a ping; otherwise, false. /// /// /// The default value is false. From f7eb33732169e8e79ebbb9736f509508b1208de6 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 23 May 2025 16:20:23 +0900 Subject: [PATCH 6063/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index ce479bb9b..b8375c8bd 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -299,12 +299,12 @@ public Func CookiesValidator { } /// - /// Gets or sets a value indicating whether the message event is emitted - /// when the WebSocket interface for a session receives a ping. + /// Gets or sets a value indicating whether the WebSocket interface for + /// a session emits the message event when it receives a ping. /// /// /// - /// true if the interface emits the message event when receives + /// true if the interface emits the message event when it receives /// a ping; otherwise, false. /// /// From 3daf3f7560d1037fceeaa932a1a6e0ca49fb1092 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 24 May 2025 16:27:09 +0900 Subject: [PATCH 6064/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 8d3aede8b..db6936d98 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3388,7 +3388,7 @@ public void CloseAsync (CloseStatusCode code, string reason) public void Connect () { if (!_isClient) { - var msg = "The interface is not for the client."; + var msg = "The Connect method is not available."; throw new InvalidOperationException (msg); } From 398adfc03bce36b218a7bd115a70c5a47c0c9eb9 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 25 May 2025 11:49:51 +0900 Subject: [PATCH 6065/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index db6936d98..025b73b0b 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3376,7 +3376,8 @@ public void CloseAsync (CloseStatusCode code, string reason) /// /// /// - /// The interface is not for the client. + /// The Connect method is not available if the interface is not for + /// the client. /// /// /// -or- From 3c2058e6a501cc103ea4c3b76e61f07e1a94da9f Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 26 May 2025 16:24:14 +0900 Subject: [PATCH 6066/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 025b73b0b..3e6db1b33 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3395,7 +3395,7 @@ public void Connect () } if (_retryCountForConnect >= _maxRetryCountForConnect) { - var msg = "A series of reconnecting has failed."; + var msg = "The Connect method is not available."; throw new InvalidOperationException (msg); } From b6795cf38e5a873034d3602c0f6cbac3aa0ea1af Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 27 May 2025 16:22:59 +0900 Subject: [PATCH 6067/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 3e6db1b33..81590090a 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3383,7 +3383,8 @@ public void CloseAsync (CloseStatusCode code, string reason) /// -or- /// /// - /// A series of reconnecting has failed. + /// The Connect method is not available if a series of reconnecting + /// has failed. /// /// public void Connect () From ce0f9d39cc1fba5a6234262fbeea917719194423 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 27 May 2025 16:24:05 +0900 Subject: [PATCH 6068/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 81590090a..89a5d8a11 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3371,7 +3371,7 @@ public void CloseAsync (CloseStatusCode code, string reason) /// Establishes a connection. /// /// - /// This method does nothing if the current state of the interface is + /// This method does nothing when the current state of the interface is /// Connecting or Open. /// /// From 4860b987d285b51a3af69de0107863b247f11ff2 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 28 May 2025 16:22:26 +0900 Subject: [PATCH 6069/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 89a5d8a11..a7f72260b 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3435,7 +3435,7 @@ public void Connect () public void ConnectAsync () { if (!_isClient) { - var msg = "The interface is not for the client."; + var msg = "The ConnectAsync method is not available."; throw new InvalidOperationException (msg); } From f1420dd675374266d938dfa8c10f2ca5d980a424 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 28 May 2025 16:24:41 +0900 Subject: [PATCH 6070/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index a7f72260b..34b9c9bd8 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3423,7 +3423,8 @@ public void Connect () /// /// /// - /// The interface is not for the client. + /// The ConnectAsync method is not available if the interface is not + /// for the client. /// /// /// -or- From f40537ab9f713d7d708a8749357196f033d45aa3 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 29 May 2025 16:24:10 +0900 Subject: [PATCH 6071/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 34b9c9bd8..7fc7314b5 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3442,7 +3442,7 @@ public void ConnectAsync () } if (_retryCountForConnect >= _maxRetryCountForConnect) { - var msg = "A series of reconnecting has failed."; + var msg = "The ConnectAsync method is not available."; throw new InvalidOperationException (msg); } From 19ab6b9d404b7605b91937af44cce40e18888c88 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 29 May 2025 16:26:15 +0900 Subject: [PATCH 6072/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 7fc7314b5..c18280262 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3430,7 +3430,8 @@ public void Connect () /// -or- /// /// - /// A series of reconnecting has failed. + /// The ConnectAsync method is not available if a series of reconnecting + /// has failed. /// /// public void ConnectAsync () From 0fd70b96d392fc7f83c15e2b634c499dea01cdd2 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 30 May 2025 16:31:44 +0900 Subject: [PATCH 6073/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index c18280262..f54f54968 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3417,7 +3417,7 @@ public void Connect () /// This method does not wait for the connect process to be complete. /// /// - /// This method does nothing if the current state of the interface is + /// This method does nothing when the current state of the interface is /// Connecting or Open. /// /// From 7f3ac9ea82e5559346bdb67db978cd550d30c289 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 31 May 2025 16:28:28 +0900 Subject: [PATCH 6074/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index f54f54968..88620286f 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3533,7 +3533,7 @@ public bool Ping (string message) public void Send (byte[] data) { if (_readyState != WebSocketState.Open) { - var msg = "The current state of the interface is not Open."; + var msg = "The Send method is not available."; throw new InvalidOperationException (msg); } From aa2da7853e654bac235d9416a6afc624eb63d5a9 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 31 May 2025 16:31:38 +0900 Subject: [PATCH 6075/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 88620286f..b37007ce5 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3525,7 +3525,8 @@ public bool Ping (string message) /// An array of that specifies the binary data to send. /// /// - /// The current state of the interface is not Open. + /// The Send method is not available when the current state of + /// the interface is not Open. /// /// /// is . From 8f3e421ba76c6400a82453ef032d91f363d42cec Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 31 May 2025 16:32:59 +0900 Subject: [PATCH 6076/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index b37007ce5..f27f233bb 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3524,13 +3524,13 @@ public bool Ping (string message) /// /// An array of that specifies the binary data to send. /// + /// + /// is . + /// /// /// The Send method is not available when the current state of /// the interface is not Open. /// - /// - /// is . - /// public void Send (byte[] data) { if (_readyState != WebSocketState.Open) { From 98ce3059b274e998e3abcb03d8dc36d3714ce25b Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 1 Jun 2025 22:02:42 +0900 Subject: [PATCH 6077/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index f27f233bb..791a85650 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3576,7 +3576,7 @@ public void Send (byte[] data) public void Send (FileInfo fileInfo) { if (_readyState != WebSocketState.Open) { - var msg = "The current state of the interface is not Open."; + var msg = "The Send method is not available."; throw new InvalidOperationException (msg); } From 23dae9d60ece13b21496dafdb16d3fa9dc38c3fc Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 1 Jun 2025 22:04:48 +0900 Subject: [PATCH 6078/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 791a85650..dc9ceb7d6 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3557,7 +3557,8 @@ public void Send (byte[] data) /// /// /// - /// The current state of the interface is not Open. + /// The Send method is not available when the current state of + /// the interface is not Open. /// /// /// is . From 6eae78902c23a3fa4c27c538af7a01eb81c7c3f6 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 1 Jun 2025 22:06:43 +0900 Subject: [PATCH 6079/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index dc9ceb7d6..0b0ed2633 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3556,13 +3556,6 @@ public void Send (byte[] data) /// The file is sent as the binary data. /// /// - /// - /// The Send method is not available when the current state of - /// the interface is not Open. - /// - /// - /// is . - /// /// /// /// The file does not exist. @@ -3574,6 +3567,13 @@ public void Send (byte[] data) /// The file could not be opened. /// /// + /// + /// is . + /// + /// + /// The Send method is not available when the current state of + /// the interface is not Open. + /// public void Send (FileInfo fileInfo) { if (_readyState != WebSocketState.Open) { From 78180225627d115f6ae9340d290ea9f60c7da1ec Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 2 Jun 2025 21:06:34 +0900 Subject: [PATCH 6080/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 0b0ed2633..173b6ab2f 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3620,7 +3620,7 @@ public void Send (FileInfo fileInfo) public void Send (string data) { if (_readyState != WebSocketState.Open) { - var msg = "The current state of the interface is not Open."; + var msg = "The Send method is not available."; throw new InvalidOperationException (msg); } From 01de7fc9ead8bce5625a906f655287f550b6fc88 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 2 Jun 2025 21:08:43 +0900 Subject: [PATCH 6081/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 173b6ab2f..a63374e01 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3609,7 +3609,8 @@ public void Send (FileInfo fileInfo) /// A that specifies the text data to send. /// /// - /// The current state of the interface is not Open. + /// The Send method is not available when the current state of + /// the interface is not Open. /// /// /// is . From c55be601784a1b5d9c613988d1ed5e2ec87b93d1 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 2 Jun 2025 21:10:03 +0900 Subject: [PATCH 6082/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index a63374e01..65b61fa53 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3608,15 +3608,15 @@ public void Send (FileInfo fileInfo) /// /// A that specifies the text data to send. /// - /// - /// The Send method is not available when the current state of - /// the interface is not Open. + /// + /// could not be UTF-8-encoded. /// /// /// is . /// - /// - /// could not be UTF-8-encoded. + /// + /// The Send method is not available when the current state of + /// the interface is not Open. /// public void Send (string data) { From 8f637127758ac988dcd354351732de7e1dd1751b Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 3 Jun 2025 16:27:25 +0900 Subject: [PATCH 6083/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 65b61fa53..340538845 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3680,7 +3680,7 @@ public void Send (string data) public void Send (Stream stream, int length) { if (_readyState != WebSocketState.Open) { - var msg = "The current state of the interface is not Open."; + var msg = "The Send method is not available."; throw new InvalidOperationException (msg); } From 0983c0480a467d3a1185d9b54ff4f9c212238ea8 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 3 Jun 2025 16:29:09 +0900 Subject: [PATCH 6084/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 340538845..eca91ced9 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3655,7 +3655,8 @@ public void Send (string data) /// An that specifies the number of bytes to send. /// /// - /// The current state of the interface is not Open. + /// The Send method is not available when the current state of + /// the interface is not Open. /// /// /// is . From da445c8f895723675467bdc18797d14e79d3d4ed Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 3 Jun 2025 16:30:32 +0900 Subject: [PATCH 6085/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index eca91ced9..864ead073 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3654,13 +3654,6 @@ public void Send (string data) /// /// An that specifies the number of bytes to send. /// - /// - /// The Send method is not available when the current state of - /// the interface is not Open. - /// - /// - /// is . - /// /// /// /// cannot be read. @@ -3678,6 +3671,13 @@ public void Send (string data) /// No data could be read from . /// /// + /// + /// is . + /// + /// + /// The Send method is not available when the current state of + /// the interface is not Open. + /// public void Send (Stream stream, int length) { if (_readyState != WebSocketState.Open) { From 8b3115e3adabd3f431a14eae4121d9c60e429c82 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 4 Jun 2025 16:39:28 +0900 Subject: [PATCH 6086/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 864ead073..93200888a 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3753,7 +3753,7 @@ public void Send (Stream stream, int length) public void SendAsync (byte[] data, Action completed) { if (_readyState != WebSocketState.Open) { - var msg = "The current state of the interface is not Open."; + var msg = "The SendAsync method is not available."; throw new InvalidOperationException (msg); } From 9d13553b88d8ef7c22df837d833c273919a12500 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 4 Jun 2025 16:41:10 +0900 Subject: [PATCH 6087/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 93200888a..b147ca2b1 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3745,7 +3745,8 @@ public void Send (Stream stream, int length) /// /// /// - /// The current state of the interface is not Open. + /// The SendAsync method is not available when the current state of + /// the interface is not Open. /// /// /// is . From b68b4b12cdd08b4e4dc9f8521a1b5d98fe4384ff Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 4 Jun 2025 16:42:18 +0900 Subject: [PATCH 6088/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index b147ca2b1..97397be0e 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3744,13 +3744,13 @@ public void Send (Stream stream, int length) /// if not necessary. /// /// + /// + /// is . + /// /// /// The SendAsync method is not available when the current state of /// the interface is not Open. /// - /// - /// is . - /// public void SendAsync (byte[] data, Action completed) { if (_readyState != WebSocketState.Open) { From ebd7a97745d765ccc6f4c0278a7b84e057fc48c2 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 5 Jun 2025 16:15:35 +0900 Subject: [PATCH 6089/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 97397be0e..2f8b44b97 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3734,7 +3734,7 @@ public void Send (Stream stream, int length) /// An delegate. /// /// - /// The delegate invokes the method called when the send is complete. + /// It specifies the delegate called when the send is complete. /// /// /// The parameter passed to the method is true From aaa62939dff5980a7c03c1666c6c1b49e71d1225 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 5 Jun 2025 16:17:28 +0900 Subject: [PATCH 6090/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 2f8b44b97..81735d338 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3737,7 +3737,7 @@ public void Send (Stream stream, int length) /// It specifies the delegate called when the send is complete. /// /// - /// The parameter passed to the method is true + /// The parameter passed to the delegate is true /// if the send has successfully done; otherwise, false. /// /// From 49dda162dfd5f28b119cd6fee88c3a81416e3431 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 6 Jun 2025 16:29:18 +0900 Subject: [PATCH 6091/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 81735d338..2dc2c3192 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3814,7 +3814,7 @@ public void SendAsync (byte[] data, Action completed) public void SendAsync (FileInfo fileInfo, Action completed) { if (_readyState != WebSocketState.Open) { - var msg = "The current state of the interface is not Open."; + var msg = "The SendAsync method is not available."; throw new InvalidOperationException (msg); } From 07dc675e7b8623a255e5235076637fddb28a76ac Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 6 Jun 2025 16:30:48 +0900 Subject: [PATCH 6092/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 2dc2c3192..7bf980690 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3795,7 +3795,8 @@ public void SendAsync (byte[] data, Action completed) /// /// /// - /// The current state of the interface is not Open. + /// The SendAsync method is not available when the current state of + /// the interface is not Open. /// /// /// is . From 90c32775fc5194e55b9e29d7b4f9cd5ab5958f85 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 6 Jun 2025 16:32:12 +0900 Subject: [PATCH 6093/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 7bf980690..14eb555ec 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3794,13 +3794,6 @@ public void SendAsync (byte[] data, Action completed) /// if not necessary. /// /// - /// - /// The SendAsync method is not available when the current state of - /// the interface is not Open. - /// - /// - /// is . - /// /// /// /// The file does not exist. @@ -3812,6 +3805,13 @@ public void SendAsync (byte[] data, Action completed) /// The file could not be opened. /// /// + /// + /// is . + /// + /// + /// The SendAsync method is not available when the current state of + /// the interface is not Open. + /// public void SendAsync (FileInfo fileInfo, Action completed) { if (_readyState != WebSocketState.Open) { From 8043c17b49794fd33648316a574383f3dd18a00e Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 7 Jun 2025 16:22:21 +0900 Subject: [PATCH 6094/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 14eb555ec..80366ec30 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3784,10 +3784,10 @@ public void SendAsync (byte[] data, Action completed) /// An delegate. /// /// - /// The delegate invokes the method called when the send is complete. + /// It specifies the delegate called when the send is complete. /// /// - /// The parameter passed to the method is true + /// The parameter passed to the delegate is true /// if the send has successfully done; otherwise, false. /// /// From 3f44645aa20d061edefb86ac0eda1121f9e27182 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 8 Jun 2025 11:00:07 +0900 Subject: [PATCH 6095/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 80366ec30..149de430c 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3876,7 +3876,7 @@ public void SendAsync (FileInfo fileInfo, Action completed) public void SendAsync (string data, Action completed) { if (_readyState != WebSocketState.Open) { - var msg = "The current state of the interface is not Open."; + var msg = "The SendAsync method is not available."; throw new InvalidOperationException (msg); } From 90dbff92dff6b064c4984fe413ff1982b5da8291 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 8 Jun 2025 11:01:49 +0900 Subject: [PATCH 6096/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 149de430c..fe2537b90 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3865,7 +3865,8 @@ public void SendAsync (FileInfo fileInfo, Action completed) /// /// /// - /// The current state of the interface is not Open. + /// The SendAsync method is not available when the current state of + /// the interface is not Open. /// /// /// is . From dcea4096f5cdda27868e6bac43e31d47abbe44f2 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 8 Jun 2025 11:03:31 +0900 Subject: [PATCH 6097/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index fe2537b90..f800b62b1 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3864,15 +3864,15 @@ public void SendAsync (FileInfo fileInfo, Action completed) /// if not necessary. /// /// - /// - /// The SendAsync method is not available when the current state of - /// the interface is not Open. + /// + /// could not be UTF-8-encoded. /// /// /// is . /// - /// - /// could not be UTF-8-encoded. + /// + /// The SendAsync method is not available when the current state of + /// the interface is not Open. /// public void SendAsync (string data, Action completed) { From bb2741062358967d3c7c920ea8f1ff720f056c1f Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 9 Jun 2025 21:10:53 +0900 Subject: [PATCH 6098/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index f800b62b1..1832d1ffc 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3854,10 +3854,10 @@ public void SendAsync (FileInfo fileInfo, Action completed) /// An delegate. /// /// - /// The delegate invokes the method called when the send is complete. + /// It specifies the delegate called when the send is complete. /// /// - /// The parameter passed to the method is true + /// The parameter passed to the delegate is true /// if the send has successfully done; otherwise, false. /// /// From 1165bf287b1961d5701cc045910f10f90be7256f Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 10 Jun 2025 16:40:20 +0900 Subject: [PATCH 6099/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 1832d1ffc..4cc653da5 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3955,7 +3955,7 @@ public void SendAsync (string data, Action completed) public void SendAsync (Stream stream, int length, Action completed) { if (_readyState != WebSocketState.Open) { - var msg = "The current state of the interface is not Open."; + var msg = "The SendAsync method is not available."; throw new InvalidOperationException (msg); } From 3213df73bed759e2192d04573b03d40cbb384d3e Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 10 Jun 2025 16:42:34 +0900 Subject: [PATCH 6100/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 4cc653da5..bdb27c9c6 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3930,7 +3930,8 @@ public void SendAsync (string data, Action completed) /// /// /// - /// The current state of the interface is not Open. + /// The SendAsync method is not available when the current state of + /// the interface is not Open. /// /// /// is . From 5b577d9daa7f43c56d9d6dc41da7445b2fac5071 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 10 Jun 2025 16:44:30 +0900 Subject: [PATCH 6101/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index bdb27c9c6..617068ccc 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3929,13 +3929,6 @@ public void SendAsync (string data, Action completed) /// if not necessary. /// /// - /// - /// The SendAsync method is not available when the current state of - /// the interface is not Open. - /// - /// - /// is . - /// /// /// /// cannot be read. @@ -3953,6 +3946,13 @@ public void SendAsync (string data, Action completed) /// No data could be read from . /// /// + /// + /// is . + /// + /// + /// The SendAsync method is not available when the current state of + /// the interface is not Open. + /// public void SendAsync (Stream stream, int length, Action completed) { if (_readyState != WebSocketState.Open) { From 0762d05bd982bd4320fe5ec1e9f7393e4d5b2d39 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 11 Jun 2025 16:29:21 +0900 Subject: [PATCH 6102/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 617068ccc..5c79d99b1 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3919,10 +3919,10 @@ public void SendAsync (string data, Action completed) /// An delegate. /// /// - /// The delegate invokes the method called when the send is complete. + /// It specifies the delegate called when the send is complete. /// /// - /// The parameter passed to the method is true + /// The parameter passed to the delegate is true /// if the send has successfully done; otherwise, false. /// /// From 0cbf195800a5c9f3738e15d062250877a569daf5 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 12 Jun 2025 16:38:04 +0900 Subject: [PATCH 6103/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 5c79d99b1..fe07eae1e 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2197,7 +2197,9 @@ private bool send (Fin fin, Opcode opcode, byte[] data, bool compressed) } private void sendAsync ( - Opcode opcode, Stream sourceStream, Action completed + Opcode opcode, + Stream sourceStream, + Action completed ) { Func sender = send; From 5b510522f558d1fc0a43d1d516d70b029b101c73 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 13 Jun 2025 16:21:59 +0900 Subject: [PATCH 6104/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index fe07eae1e..3da498692 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2274,7 +2274,9 @@ private HttpResponse sendHandshakeRequest () return res; var ares = new AuthenticationResponse ( - _authChallenge, _credentials, _nonceCount + _authChallenge, + _credentials, + _nonceCount ); _nonceCount = ares.NonceCount; From 00410703938adf54acd986c7b4ae113488562df5 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 14 Jun 2025 16:15:29 +0900 Subject: [PATCH 6105/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 3da498692..3fd5ba2cf 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2664,7 +2664,9 @@ internal bool Ping (byte[] rawFrame) // As server internal void Send ( - Opcode opcode, byte[] data, Dictionary cache + Opcode opcode, + byte[] data, + Dictionary cache ) { lock (_forSend) { From 1cfead4c0dd05be17203cbc3c192258ee279aef1 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 15 Jun 2025 22:00:11 +0900 Subject: [PATCH 6106/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 3fd5ba2cf..958826e82 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -989,7 +989,8 @@ private bool canSet () // As server private bool checkHandshakeRequest ( - WebSocketContext context, out string message + WebSocketContext context, + out string message ) { message = null; From 6ac1bf3af6157588bdd27ff62248b8b118503d4c Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 16 Jun 2025 15:51:35 +0900 Subject: [PATCH 6107/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 958826e82..44b5a166c 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1058,7 +1058,8 @@ out string message // As client private bool checkHandshakeResponse ( - HttpResponse response, out string message + HttpResponse response, + out string message ) { message = null; From 51ae1bc04ae0f98290e65bf765e2935fddbaec87 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 17 Jun 2025 16:04:55 +0900 Subject: [PATCH 6108/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 44b5a166c..142b9301f 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1165,7 +1165,8 @@ private static bool checkProtocols (string[] protocols, out string message) // As client private bool checkProxyConnectResponse ( - HttpResponse response, out string message + HttpResponse response, + out string message ) { message = null; From b7903b67d1c065852d9506895003c5ac6b90718f Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 18 Jun 2025 15:46:36 +0900 Subject: [PATCH 6109/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 142b9301f..d5ed294bb 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1354,7 +1354,11 @@ private void closeAsync (PayloadData payloadData, bool send, bool received) Action closer = close; closer.BeginInvoke ( - payloadData, send, received, ar => closer.EndInvoke (ar), null + payloadData, + send, + received, + ar => closer.EndInvoke (ar), + null ); } From 28e1d4907207e6291d9967c097ac96fef4e8a212 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 19 Jun 2025 16:12:15 +0900 Subject: [PATCH 6110/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index d5ed294bb..b97313471 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1363,7 +1363,9 @@ private void closeAsync (PayloadData payloadData, bool send, bool received) } private bool closeHandshake ( - PayloadData payloadData, bool send, bool received + PayloadData payloadData, + bool send, + bool received ) { var sent = false; From 79663e3aca23fa49ea2ded08a2153926e523d08b Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 20 Jun 2025 16:03:15 +0900 Subject: [PATCH 6111/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index b97313471..fd22d9c16 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1466,7 +1466,9 @@ private AuthenticationResponse createAuthenticationResponse () if (_authChallenge != null) { var ret = new AuthenticationResponse ( - _authChallenge, _credentials, _nonceCount + _authChallenge, + _credentials, + _nonceCount ); _nonceCount = ret.NonceCount; From a304b6ce5960659b82b1018cf40322bf7a5bc290 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 21 Jun 2025 15:58:21 +0900 Subject: [PATCH 6112/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index fd22d9c16..0a28a14fd 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1464,19 +1464,18 @@ private AuthenticationResponse createAuthenticationResponse () if (_credentials == null) return null; - if (_authChallenge != null) { - var ret = new AuthenticationResponse ( - _authChallenge, - _credentials, - _nonceCount - ); + if (_authChallenge == null) + return _preAuth ? new AuthenticationResponse (_credentials) : null; - _nonceCount = ret.NonceCount; + var ret = new AuthenticationResponse ( + _authChallenge, + _credentials, + _nonceCount + ); - return ret; - } + _nonceCount = ret.NonceCount; - return _preAuth ? new AuthenticationResponse (_credentials) : null; + return ret; } // As client From 0183e05b737ecc20c820080ba2261b6ab50738a7 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 22 Jun 2025 15:37:11 +0900 Subject: [PATCH 6113/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 0a28a14fd..137faaef2 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1485,7 +1485,8 @@ private string createExtensions () if (_compression != CompressionMethod.None) { var str = _compression.ToExtensionString ( - "server_no_context_takeover", "client_no_context_takeover" + "server_no_context_takeover", + "client_no_context_takeover" ); buff.AppendFormat ("{0}, ", str); From 55fdfb8c4fd1026457e774b76c733b2b382409a9 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 23 Jun 2025 15:50:05 +0900 Subject: [PATCH 6114/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 137faaef2..0cb02da14 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1584,7 +1584,8 @@ private TcpClient createTcpClient (string hostname, int port) // As server private bool customCheckHandshakeRequest ( - WebSocketContext context, out string message + WebSocketContext context, + out string message ) { message = null; From 86dee99020354133d02d93eab2e625ce9d0a5ad8 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 24 Jun 2025 16:58:22 +0900 Subject: [PATCH 6115/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 47 ++++++++++++++++++------------------ 1 file changed, 23 insertions(+), 24 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 0cb02da14..078a44c6c 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2452,37 +2452,36 @@ private void startReceiving () Action receive = null; receive = - () => - WebSocketFrame.ReadFrameAsync ( - _stream, - false, - frame => { - var cont = processReceivedFrame (frame) - && _readyState != WebSocketState.Closed; + () => WebSocketFrame.ReadFrameAsync ( + _stream, + false, + frame => { + var cont = processReceivedFrame (frame) + && _readyState != WebSocketState.Closed; - if (!cont) { - var exited = _receivingExited; + if (!cont) { + var exited = _receivingExited; - if (exited != null) - exited.Set (); + if (exited != null) + exited.Set (); - return; - } + return; + } - receive (); + receive (); - if (_inMessage) - return; + if (_inMessage) + return; - message (); - }, - ex => { - _log.Fatal (ex.Message); - _log.Debug (ex.ToString ()); + message (); + }, + ex => { + _log.Fatal (ex.Message); + _log.Debug (ex.ToString ()); - abort ("An exception has occurred while receiving.", ex); - } - ); + abort ("An exception has occurred while receiving.", ex); + } + ); receive (); } From 907af940548a3092b3b81ffc681b929add394e09 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 25 Jun 2025 16:38:58 +0900 Subject: [PATCH 6116/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 078a44c6c..5c7077a29 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2456,10 +2456,10 @@ private void startReceiving () _stream, false, frame => { - var cont = processReceivedFrame (frame) - && _readyState != WebSocketState.Closed; + var doNext = processReceivedFrame (frame) + && _readyState != WebSocketState.Closed; - if (!cont) { + if (!doNext) { var exited = _receivingExited; if (exited != null) From 467a6e1fe26f44ff347c03a3fd564fcb3d7e1d6c Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 26 Jun 2025 21:24:00 +0900 Subject: [PATCH 6117/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 5c7077a29..bb6a90378 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2495,12 +2495,12 @@ private bool validateSecWebSocketExtensionsServerHeader (string value) if (value.Length == 0) return false; - var comp = _compression != CompressionMethod.None; + var compRequested = _compression != CompressionMethod.None; foreach (var elm in value.SplitHeaderValue (',')) { var ext = elm.Trim (); - if (comp && ext.IsCompressionExtension (_compression)) { + if (compRequested && ext.IsCompressionExtension (_compression)) { var param1 = "server_no_context_takeover"; var param2 = "client_no_context_takeover"; @@ -2526,7 +2526,7 @@ private bool validateSecWebSocketExtensionsServerHeader (string value) if (invalid) return false; - comp = false; + compRequested = false; } else { return false; From 231ba907116414740a08b22407f2e9950f592bf0 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 27 Jun 2025 15:44:48 +0900 Subject: [PATCH 6118/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index bb6a90378..6f81e779c 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2515,11 +2515,11 @@ private bool validateSecWebSocketExtensionsServerHeader (string value) t => { t = t.Trim (); - var valid = t == name - || t == param1 - || t == param2; + var isValid = t == name + || t == param1 + || t == param2; - return !valid; + return !isValid; } ); From 855f0288c5b2656c7ea6cdc134b5d5eef8aa5ccd Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 28 Jun 2025 15:34:36 +0900 Subject: [PATCH 6119/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 6f81e779c..7975ff5ef 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2511,19 +2511,20 @@ private bool validateSecWebSocketExtensionsServerHeader (string value) } var name = _compression.ToExtensionString (); - var invalid = ext.SplitHeaderValue (';').Contains ( - t => { - t = t.Trim (); - var isValid = t == name - || t == param1 - || t == param2; + var isInvalid = ext.SplitHeaderValue (';').Contains ( + t => { + t = t.Trim (); - return !isValid; - } - ); + var isValid = t == name + || t == param1 + || t == param2; - if (invalid) + return !isValid; + } + ); + + if (isInvalid) return false; compRequested = false; From 34bcfd7a2686564040d32e4be4dfe0eaa1304537 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 29 Jun 2025 15:52:03 +0900 Subject: [PATCH 6120/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 7975ff5ef..8e44a07c7 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1978,7 +1978,7 @@ private void processSecWebSocketExtensionsClientHeader (string value) var buff = new StringBuilder (80); - var comp = false; + var compRequested = false; foreach (var elm in value.SplitHeaderValue (',')) { var ext = elm.Trim (); @@ -1986,7 +1986,7 @@ private void processSecWebSocketExtensionsClientHeader (string value) if (ext.Length == 0) continue; - if (!comp) { + if (!compRequested) { if (ext.IsCompressionExtension (CompressionMethod.Deflate)) { _compression = CompressionMethod.Deflate; @@ -1997,7 +1997,7 @@ private void processSecWebSocketExtensionsClientHeader (string value) buff.AppendFormat ("{0}, ", str); - comp = true; + compRequested = true; } } } From 2d90062f900b47ee9c91b2a0298dc154a715261a Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 30 Jun 2025 15:18:44 +0900 Subject: [PATCH 6121/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 8e44a07c7..002eb7362 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1118,11 +1118,11 @@ out string message } } else { - var valid = _protocolsRequested - && subp.Length > 0 - && _protocols.Contains (p => p == subp); + var isValid = _protocolsRequested + && subp.Length > 0 + && _protocols.Contains (p => p == subp); - if (!valid) { + if (!isValid) { message = "The Sec-WebSocket-Protocol header is invalid."; return false; From c04c0db32115ae34c589397680b95746720d21fc Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 1 Jul 2025 21:42:56 +0900 Subject: [PATCH 6122/6294] [Modify] Add it To support the user defined header. --- websocket-sharp/WebSocket.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 002eb7362..447d1a8a5 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -120,6 +120,7 @@ public class WebSocket : IDisposable private Stream _stream; private TcpClient _tcpClient; private Uri _uri; + private WebHeaderCollection _userHeaders; private const string _version = "13"; private TimeSpan _waitTime; @@ -318,6 +319,18 @@ internal bool IgnoreExtensions { } } + internal WebHeaderCollection UserHeaders { + get { + if (_userHeaders == null) { + _userHeaders = _isClient + ? new WebHeaderCollection (HttpHeaderType.Request, false) + : new WebHeaderCollection (HttpHeaderType.Response, false); + } + + return _userHeaders; + } + } + #endregion #region Public Properties From 8f39190c3b5ea0fa7dddace476369e07ebaf936e Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 2 Jul 2025 16:10:07 +0900 Subject: [PATCH 6123/6294] [Modify] It is restricted --- websocket-sharp/Net/WebHeaderCollection.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index e41150811..d4f27de86 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -427,6 +427,7 @@ static WebHeaderCollection () "Sec-WebSocket-Protocol", HttpHeaderType.Request | HttpHeaderType.Response + | HttpHeaderType.Restricted | HttpHeaderType.MultiValueInRequest ) }, From e28c6e15feeaa7cf22ce705c69ccdbc46b77633b Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 3 Jul 2025 21:28:30 +0900 Subject: [PATCH 6124/6294] [Modify] It is restricted --- websocket-sharp/Net/WebHeaderCollection.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index d4f27de86..303f8b949 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -499,6 +499,7 @@ static WebHeaderCollection () "Upgrade", HttpHeaderType.Request | HttpHeaderType.Response + | HttpHeaderType.Restricted | HttpHeaderType.MultiValue ) }, From 970544827f0352d30e84cd571f9663d67f346e1e Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 4 Jul 2025 15:59:31 +0900 Subject: [PATCH 6125/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 447d1a8a5..dffc4aa69 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -322,9 +322,11 @@ internal bool IgnoreExtensions { internal WebHeaderCollection UserHeaders { get { if (_userHeaders == null) { - _userHeaders = _isClient - ? new WebHeaderCollection (HttpHeaderType.Request, false) - : new WebHeaderCollection (HttpHeaderType.Response, false); + var state = _isClient + ? HttpHeaderType.Request + : HttpHeaderType.Response; + + _userHeaders = new WebHeaderCollection (state, false); } return _userHeaders; From 3df97bb675b71a9dd9ec5b1bec94ae45a4dcf2a8 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 5 Jul 2025 15:56:56 +0900 Subject: [PATCH 6126/6294] [Modify] It is restricted --- websocket-sharp/Net/WebHeaderCollection.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 303f8b949..f51326bb7 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -133,7 +133,9 @@ static WebHeaderCollection () "Authorization", new HttpHeaderInfo ( "Authorization", - HttpHeaderType.Request | HttpHeaderType.MultiValue + HttpHeaderType.Request + | HttpHeaderType.Restricted + | HttpHeaderType.MultiValue ) }, { From 543a06e5989c18ffd370c0d7be1a72a6a23a893b Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 6 Jul 2025 15:54:53 +0900 Subject: [PATCH 6127/6294] [Modify] It is restricted --- websocket-sharp/Net/WebHeaderCollection.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index f51326bb7..5f7d61cd4 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -357,7 +357,7 @@ static WebHeaderCollection () "ProxyAuthorization", new HttpHeaderInfo ( "Proxy-Authorization", - HttpHeaderType.Request + HttpHeaderType.Request | HttpHeaderType.Restricted ) }, { From 1554ade907238805ec6eb39fc4eacb719f2d1a29 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 7 Jul 2025 15:49:54 +0900 Subject: [PATCH 6128/6294] [Modify] It is restricted --- websocket-sharp/Net/WebHeaderCollection.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 5f7d61cd4..e60e53f01 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -350,7 +350,9 @@ static WebHeaderCollection () "ProxyAuthenticate", new HttpHeaderInfo ( "Proxy-Authenticate", - HttpHeaderType.Response | HttpHeaderType.MultiValue + HttpHeaderType.Response + | HttpHeaderType.Restricted + | HttpHeaderType.MultiValue ) }, { From 73f30a4241c910ea043140bed2fb77b5d958d93d Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 8 Jul 2025 16:32:21 +0900 Subject: [PATCH 6129/6294] [Modify] It is restricted --- websocket-sharp/Net/WebHeaderCollection.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index e60e53f01..cc9830a43 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -329,7 +329,7 @@ static WebHeaderCollection () "Location", new HttpHeaderInfo ( "Location", - HttpHeaderType.Response + HttpHeaderType.Response | HttpHeaderType.Restricted ) }, { From 3cff458c3542751958bd3ee5cb495ce5234b7a5d Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 9 Jul 2025 16:21:57 +0900 Subject: [PATCH 6130/6294] [Modify] It is restricted --- websocket-sharp/Net/WebHeaderCollection.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index cc9830a43..6ca068f1a 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -218,7 +218,7 @@ static WebHeaderCollection () "Cookie", new HttpHeaderInfo ( "Cookie", - HttpHeaderType.Request + HttpHeaderType.Request | HttpHeaderType.Restricted ) }, { From ef6929b3f7ab70a0196410a1a6a5b8ad05e216d0 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 9 Jul 2025 16:23:31 +0900 Subject: [PATCH 6131/6294] [Modify] It is restricted --- websocket-sharp/Net/WebHeaderCollection.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 6ca068f1a..d545f6a25 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -225,7 +225,7 @@ static WebHeaderCollection () "Cookie2", new HttpHeaderInfo ( "Cookie2", - HttpHeaderType.Request + HttpHeaderType.Request | HttpHeaderType.Restricted ) }, { From a4c556616d87f7aecffbedbe56e57d2a65ccc86c Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 10 Jul 2025 15:51:39 +0900 Subject: [PATCH 6132/6294] [Modify] It is restricted --- websocket-sharp/Net/WebHeaderCollection.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index d545f6a25..117b1ce8c 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -456,7 +456,9 @@ static WebHeaderCollection () "SetCookie", new HttpHeaderInfo ( "Set-Cookie", - HttpHeaderType.Response | HttpHeaderType.MultiValue + HttpHeaderType.Response + | HttpHeaderType.Restricted + | HttpHeaderType.MultiValue ) }, { From 941d09beb3389454841ab341727261524e69b7e3 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 11 Jul 2025 16:00:50 +0900 Subject: [PATCH 6133/6294] [Modify] It is restricted --- websocket-sharp/Net/WebHeaderCollection.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/Net/WebHeaderCollection.cs b/websocket-sharp/Net/WebHeaderCollection.cs index 117b1ce8c..da4a79d94 100644 --- a/websocket-sharp/Net/WebHeaderCollection.cs +++ b/websocket-sharp/Net/WebHeaderCollection.cs @@ -465,7 +465,9 @@ static WebHeaderCollection () "SetCookie2", new HttpHeaderInfo ( "Set-Cookie2", - HttpHeaderType.Response | HttpHeaderType.MultiValue + HttpHeaderType.Response + | HttpHeaderType.Restricted + | HttpHeaderType.MultiValue ) }, { From 51fc9fa7fb14b8854b5e63725ae58bed750ec69a Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 12 Jul 2025 16:14:41 +0900 Subject: [PATCH 6134/6294] [Modify] Send it if any --- websocket-sharp/WebSocket.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index dffc4aa69..eea9124a9 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1559,6 +1559,11 @@ private HttpRequest createHandshakeRequest () if (ares != null) headers["Authorization"] = ares.ToString (); + var hasUserHeader = _userHeaders != null && _userHeaders.Count > 0; + + if (hasUserHeader) + headers.Add (_userHeaders); + if (_cookies.Count > 0) ret.SetCookies (_cookies); From 75b2c06bbe6239aa5656aa39579f5a5275bcc76f Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 13 Jul 2025 16:05:28 +0900 Subject: [PATCH 6135/6294] [Modify] Return it if any --- websocket-sharp/WebSocket.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index eea9124a9..2e34e9a14 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1585,6 +1585,11 @@ private HttpResponse createHandshakeResponse () if (_extensions != null) headers["Sec-WebSocket-Extensions"] = _extensions; + var hasUserHeader = _userHeaders != null && _userHeaders.Count > 0; + + if (hasUserHeader) + headers.Add (_userHeaders); + if (_cookies.Count > 0) ret.SetCookies (_cookies); From 09a25e27bba884752078cd86db3d183d21116d2c Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 14 Jul 2025 22:06:24 +0900 Subject: [PATCH 6136/6294] [Modify] Add the SetUserHeader method --- websocket-sharp/WebSocket.cs | 72 ++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 2e34e9a14..284f35aa2 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -4319,6 +4319,78 @@ public void SetProxy (string url, string username, string password) } } + /// + /// Sets a user header to send with the handshake request or response. + /// + /// + /// A that specifies the name of the header to set. + /// + /// + /// A that specifies the value of the header to set. + /// + /// + /// + /// is an empty string. + /// + /// + /// -or- + /// + /// + /// is a string of spaces. + /// + /// + /// -or- + /// + /// + /// contains an invalid character. + /// + /// + /// -or- + /// + /// + /// contains an invalid character. + /// + /// + /// -or- + /// + /// + /// is a restricted header name. + /// + /// + /// + /// is . + /// + /// + /// The length of is greater than 65,535 + /// characters. + /// + /// + /// This instance does not allow the header. + /// + /// The SetUserHeader method is not available when the current state of + /// the interface is neither New nor Closed. + /// + /// + /// -or- + /// + /// + /// The SetUserHeader method is not available if the interface does not + /// allow the header type. + /// + /// + public void SetUserHeader (string name, string value) + { + lock (_forState) { + if (!canSet ()) { + var msg = "The SetUserHeader method is not available."; + + throw new InvalidOperationException (msg); + } + + UserHeaders.Set (name, value); + } + } + #endregion #region Explicit Interface Implementations From 66d9a559e0fdf1799f2d44c8284161f576e9ddac Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 15 Jul 2025 16:33:45 +0900 Subject: [PATCH 6137/6294] [Modify] Log it --- websocket-sharp/WebSocket.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 284f35aa2..089b8e830 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2285,6 +2285,8 @@ private HttpResponse sendHandshakeRequest () { var req = createHandshakeRequest (); + _log.Debug (req.ToString ()); + var timeout = 90000; var res = req.GetResponse (_stream, timeout); @@ -2325,6 +2327,8 @@ private HttpResponse sendHandshakeRequest () setClientStream (); } + _log.Debug (req.ToString ()); + timeout = 15000; res = req.GetResponse (_stream, timeout); } From 71d85bd831ac9d9e8781f72b98e59142e9427d62 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 16 Jul 2025 16:18:45 +0900 Subject: [PATCH 6138/6294] [Modify] Send it --- Example/Program.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Example/Program.cs b/Example/Program.cs index ec4302af6..11ef61ed0 100644 --- a/Example/Program.cs +++ b/Example/Program.cs @@ -55,6 +55,9 @@ public static void Main (string[] args) // To connect through the HTTP Proxy server. //ws.SetProxy ("http://localhost:3128/", "nobita", "password"); + // To send a user header. + ws.SetUserHeader ("HeaderFromHell", "HeaderFromHell2"); + // To validate the server certificate. /* ws.SslConfiguration.ServerCertificateValidationCallback = From 87e788b506ee028f1aa8a5cdc50da511306adc9a Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 17 Jul 2025 16:53:03 +0900 Subject: [PATCH 6139/6294] [Modify] Add the UserHeadersResponder property --- websocket-sharp/Server/WebSocketBehavior.cs | 54 +++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index b8375c8bd..75adca1dd 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -58,6 +58,7 @@ public abstract class WebSocketBehavior : IWebSocketSession private string _protocol; private WebSocketSessionManager _sessions; private DateTime _startTime; + private Action _userHeadersResponder; private WebSocket _websocket; #endregion @@ -576,6 +577,52 @@ public DateTime StartTime { } } + /// + /// Gets or sets the delegate used to respond to the user headers. + /// + /// + /// + /// A + /// delegate. + /// + /// + /// It represents the delegate called when the WebSocket interface + /// for a session validates the handshake request. + /// + /// + /// 1st parameter passed to the delegate + /// contains the HTTP headers included in the handshake request. + /// + /// + /// 2nd parameter passed to the delegate + /// holds the user headers to send to the client. + /// + /// + /// if not necessary. + /// + /// + /// The default value is . + /// + /// + /// + /// The set operation is not available when the session has already started. + /// + public Action UserHeadersResponder { + get { + return _userHeadersResponder; + } + + set { + if (_websocket != null) { + var msg = "The set operation is not available."; + + throw new InvalidOperationException (msg); + } + + _userHeadersResponder = value; + } + } + #endregion #region Private Methods @@ -598,6 +645,13 @@ private string checkHandshakeRequest (WebSocketContext context) } } + if (_userHeadersResponder != null) { + var reqHeaders = context.Headers; + var userHeaders = context.WebSocket.UserHeaders; + + _userHeadersResponder (reqHeaders, userHeaders); + } + if (_cookiesValidator != null) { var req = context.CookieCollection; var res = context.WebSocket.CookieCollection; From 1afb03785daddeadc40d3712d90f1c047f6bb159 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 18 Jul 2025 16:34:02 +0900 Subject: [PATCH 6140/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketBehavior.cs | 24 ++++++++++----------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 75adca1dd..8bbc0917f 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -47,19 +47,19 @@ public abstract class WebSocketBehavior : IWebSocketSession { #region Private Fields - private WebSocketContext _context; - private Func _cookiesValidator; - private bool _emitOnPing; - private Func _hostValidator; - private string _id; - private bool _ignoreExtensions; - private bool _noDelay; - private Func _originValidator; - private string _protocol; - private WebSocketSessionManager _sessions; - private DateTime _startTime; + private WebSocketContext _context; + private Func _cookiesValidator; + private bool _emitOnPing; + private Func _hostValidator; + private string _id; + private bool _ignoreExtensions; + private bool _noDelay; + private Func _originValidator; + private string _protocol; + private WebSocketSessionManager _sessions; + private DateTime _startTime; private Action _userHeadersResponder; - private WebSocket _websocket; + private WebSocket _websocket; #endregion From e6c7064558e531ace6fd638a727f0b4f5b7d4bfb Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 19 Jul 2025 16:25:34 +0900 Subject: [PATCH 6141/6294] [Modify] Return it --- Example2/Program.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Example2/Program.cs b/Example2/Program.cs index b3ccf7ab9..9ef80ae64 100644 --- a/Example2/Program.cs +++ b/Example2/Program.cs @@ -139,6 +139,15 @@ public static void Main (string[] args) // To send the Sec-WebSocket-Protocol header that has a subprotocol // name. //s.Protocol = "chat"; + + // To respond to the user headers. + s.UserHeadersResponder = + (reqHeaders, userHeaders) => { + var val = reqHeaders["HeaderFromHell"]; + + if (!val.IsNullOrEmpty ()) + userHeaders[val] = "Header From Server"; + }; #endif } ); From 5b55d710462c7d84881eb68429f2f90328ee2dc9 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 20 Jul 2025 17:53:22 +0900 Subject: [PATCH 6142/6294] [Modify] Log it --- websocket-sharp/WebSocket.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 089b8e830..e5d476a3f 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1650,6 +1650,8 @@ private bool doHandshake () return false; } + _log.Debug (res.ToString ()); + if (_protocolsRequested) _protocol = res.Headers["Sec-WebSocket-Protocol"]; From 7d19b37fd4e031fa566e2e01279b9fdf63fda274 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 21 Jul 2025 16:38:33 +0900 Subject: [PATCH 6143/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index e5d476a3f..0a1ee5138 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1639,19 +1639,18 @@ private bool doHandshake () var res = sendHandshakeRequest (); + _log.Debug (res.ToString ()); + string msg; if (!checkHandshakeResponse (res, out msg)) { _log.Error (msg); - _log.Debug (res.ToString ()); abort (1002, "A handshake error has occurred."); return false; } - _log.Debug (res.ToString ()); - if (_protocolsRequested) _protocol = res.Headers["Sec-WebSocket-Protocol"]; From 80e78a48152a73792c07325df49a3bed66fde574 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 22 Jul 2025 16:47:29 +0900 Subject: [PATCH 6144/6294] [Modify] Add the HandshakeResponseHeaders property --- websocket-sharp/WebSocket.cs | 45 ++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 0a1ee5138..a3568d304 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -93,6 +93,7 @@ public class WebSocket : IDisposable private Opcode _fragmentsOpcode; private const string _guid = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11"; private Func _handshakeRequestChecker; + private NameValueCollection _handshakeResponseHeaders; private bool _ignoreExtensions; private bool _inContinuation; private volatile bool _inMessage; @@ -531,6 +532,48 @@ public string Extensions { } } + /// + /// Gets the HTTP headers included in the handshake response. + /// + /// + /// A that contains the headers + /// included in the handshake response. + /// + /// + /// + /// The get operation is not available if the interface is not for + /// the client. + /// + /// + /// -or- + /// + /// + /// The get operation is not available when the current state of + /// the interface is New or Connecting. + /// + /// + public NameValueCollection HandshakeResponseHeaders { + get { + if (!_isClient) { + var msg = "The get operation is not available."; + + throw new InvalidOperationException (msg); + } + + lock (_forState) { + var canGet = _readyState > WebSocketState.Connecting; + + if (!canGet) { + var msg = "The get operation is not available."; + + throw new InvalidOperationException (msg); + } + + return _handshakeResponseHeaders; + } + } + } + /// /// Gets a value indicating whether the communication is possible. /// @@ -1641,6 +1684,8 @@ private bool doHandshake () _log.Debug (res.ToString ()); + _handshakeResponseHeaders = res.Headers; + string msg; if (!checkHandshakeResponse (res, out msg)) { From d978b137846760f8b8cf9097cb801ab984e50d47 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 23 Jul 2025 16:50:21 +0900 Subject: [PATCH 6145/6294] [Modify] Receive it --- Example/Program.cs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/Example/Program.cs b/Example/Program.cs index 11ef61ed0..f9872a5d6 100644 --- a/Example/Program.cs +++ b/Example/Program.cs @@ -103,7 +103,19 @@ public static void Main (string[] args) Console.WriteLine (fmt, e.Data); }; - ws.OnOpen += (sender, e) => ws.Send ("Hi, there!"); + ws.OnOpen += + (sender, e) => { +#if DEBUG + var val = ws.HandshakeResponseHeaders["HeaderFromHell2"]; + + if (!val.IsNullOrEmpty ()) { + var fmt = "[WebSocket Open] HeaderFromHell2: {0}"; + + Console.WriteLine (fmt, val); + } +#endif + ws.Send ("Hi, there!"); + }; // Connect to the server. ws.Connect (); From 05d30e3d7648e061ff4ebcfc50dc4e118d8e25bb Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 24 Jul 2025 16:44:16 +0900 Subject: [PATCH 6146/6294] [Modify] Polish it --- Example/Program.cs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/Example/Program.cs b/Example/Program.cs index f9872a5d6..404c3d81c 100644 --- a/Example/Program.cs +++ b/Example/Program.cs @@ -56,7 +56,12 @@ public static void Main (string[] args) //ws.SetProxy ("http://localhost:3128/", "nobita", "password"); // To send a user header. - ws.SetUserHeader ("HeaderFromHell", "HeaderFromHell2"); + + var reqHeader = "HeaderFromClient"; + var resHeader = "HeaderFromServer"; + + ws.SetUserHeader (reqHeader, resHeader); + // To validate the server certificate. /* @@ -106,12 +111,12 @@ public static void Main (string[] args) ws.OnOpen += (sender, e) => { #if DEBUG - var val = ws.HandshakeResponseHeaders["HeaderFromHell2"]; + var val = ws.HandshakeResponseHeaders[resHeader]; if (!val.IsNullOrEmpty ()) { - var fmt = "[WebSocket Open] HeaderFromHell2: {0}"; + var fmt = "[WebSocket Open] {0}: {1}"; - Console.WriteLine (fmt, val); + Console.WriteLine (fmt, resHeader, val); } #endif ws.Send ("Hi, there!"); From 841edd4d049a85c99dbb6f5d84854aa12ad58510 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 24 Jul 2025 16:51:55 +0900 Subject: [PATCH 6147/6294] [Modify] Polish it --- Example2/Program.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Example2/Program.cs b/Example2/Program.cs index 9ef80ae64..0dcf1f839 100644 --- a/Example2/Program.cs +++ b/Example2/Program.cs @@ -143,10 +143,10 @@ public static void Main (string[] args) // To respond to the user headers. s.UserHeadersResponder = (reqHeaders, userHeaders) => { - var val = reqHeaders["HeaderFromHell"]; + var val = reqHeaders["HeaderFromClient"]; if (!val.IsNullOrEmpty ()) - userHeaders[val] = "Header From Server"; + userHeaders[val] = "Hello From Server"; }; #endif } From a222f76406006483ca4d4c7266c9d357fb7fdac5 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 25 Jul 2025 16:43:09 +0900 Subject: [PATCH 6148/6294] [Modify] Test it --- Example/Program.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Example/Program.cs b/Example/Program.cs index 404c3d81c..8bd120515 100644 --- a/Example/Program.cs +++ b/Example/Program.cs @@ -18,9 +18,9 @@ public static void Main (string[] args) // If you would like to connect to the server with the secure connection, // you should create a new instance with a wss scheme WebSocket URL. - using (var ws = new WebSocket ("ws://localhost:4649/Echo")) + //using (var ws = new WebSocket ("ws://localhost:4649/Echo")) //using (var ws = new WebSocket ("wss://localhost:5963/Echo")) - //using (var ws = new WebSocket ("ws://localhost:4649/Chat")) + using (var ws = new WebSocket ("ws://localhost:4649/Chat")) //using (var ws = new WebSocket ("wss://localhost:5963/Chat")) //using (var ws = new WebSocket ("ws://localhost:4649/Chat?name=nobita")) //using (var ws = new WebSocket ("wss://localhost:5963/Chat?name=nobita")) From 3f9d0143a36e53658f2b1e77ed5cdac72fb1f603 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 26 Jul 2025 16:01:44 +0900 Subject: [PATCH 6149/6294] [Modify] Add the CookiesResponder property --- websocket-sharp/Server/WebSocketBehavior.cs | 47 +++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 8bbc0917f..a880b240e 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -48,6 +48,7 @@ public abstract class WebSocketBehavior : IWebSocketSession #region Private Fields private WebSocketContext _context; + private Action _cookiesResponder; private Func _cookiesValidator; private bool _emitOnPing; private Func _hostValidator; @@ -249,6 +250,52 @@ protected System.Net.IPEndPoint UserEndPoint { #region Public Properties + /// + /// Gets or sets the delegate used to respond to the HTTP cookies. + /// + /// + /// + /// A + /// delegate. + /// + /// + /// It represents the delegate called when the WebSocket interface + /// for a session validates the handshake request. + /// + /// + /// 1st parameter passed to the delegate + /// contains the cookies included in the handshake request if any. + /// + /// + /// 2nd parameter passed to the delegate + /// holds the cookies to send to the client. + /// + /// + /// if not necessary. + /// + /// + /// The default value is . + /// + /// + /// + /// The set operation is not available when the session has already started. + /// + public Action CookiesResponder { + get { + return _cookiesResponder; + } + + set { + if (_websocket != null) { + var msg = "The set operation is not available."; + + throw new InvalidOperationException (msg); + } + + _cookiesResponder = value; + } + } + /// /// Gets or sets the delegate used to validate the HTTP cookies. /// From 5e45b9feba62f5acb0c4d4d397a515ffc0325073 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 27 Jul 2025 16:39:15 +0900 Subject: [PATCH 6150/6294] [Modify] Replace it --- websocket-sharp/Server/WebSocketBehavior.cs | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index a880b240e..b38540a34 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -692,6 +692,13 @@ private string checkHandshakeRequest (WebSocketContext context) } } + if (_cookiesResponder != null) { + var reqCookies = context.CookieCollection; + var resCookies = context.WebSocket.CookieCollection; + + _cookiesResponder (reqCookies, resCookies); + } + if (_userHeadersResponder != null) { var reqHeaders = context.Headers; var userHeaders = context.WebSocket.UserHeaders; @@ -699,17 +706,6 @@ private string checkHandshakeRequest (WebSocketContext context) _userHeadersResponder (reqHeaders, userHeaders); } - if (_cookiesValidator != null) { - var req = context.CookieCollection; - var res = context.WebSocket.CookieCollection; - - if (!_cookiesValidator (req, res)) { - var msg = "The Cookie header is non-existent or invalid."; - - return msg; - } - } - return null; } From 20d4dcf3efeee0d5894eef6fafe2e79d8b596ac6 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 27 Jul 2025 16:53:58 +0900 Subject: [PATCH 6151/6294] [Modify] Replace it --- Example2/Program.cs | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/Example2/Program.cs b/Example2/Program.cs index 0dcf1f839..604288a59 100644 --- a/Example2/Program.cs +++ b/Example2/Program.cs @@ -95,20 +95,15 @@ public static void Main (string[] args) s => { s.Prefix = "Anon#"; #if DEBUG - // To validate the cookies. + // To respond to the cookies. /* - s.CookiesValidator = - (req, res) => { - // Check the cookies in "req", and set the cookies to send to - // the client with "res" if necessary. - - foreach (var cookie in req) { + s.CookiesResponder = + (reqCookies, resCookies) => { + foreach (var cookie in reqCookies) { cookie.Expired = true; - res.Add (cookie); + resCookies.Add (cookie); } - - return true; // If valid. }; */ From edba65e7852722c72b79c67be7daf2fa6e540837 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 27 Jul 2025 16:56:05 +0900 Subject: [PATCH 6152/6294] [Modify] Polish it --- Example2/Program.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Example2/Program.cs b/Example2/Program.cs index 604288a59..c38dd38b2 100644 --- a/Example2/Program.cs +++ b/Example2/Program.cs @@ -136,6 +136,7 @@ public static void Main (string[] args) //s.Protocol = "chat"; // To respond to the user headers. + s.UserHeadersResponder = (reqHeaders, userHeaders) => { var val = reqHeaders["HeaderFromClient"]; @@ -143,6 +144,7 @@ public static void Main (string[] args) if (!val.IsNullOrEmpty ()) userHeaders[val] = "Hello From Server"; }; + #endif } ); From a1e5a0336266147572753fa55156c410a533d549 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 28 Jul 2025 16:10:38 +0900 Subject: [PATCH 6153/6294] [Modify] Replace it --- Example3/Program.cs | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/Example3/Program.cs b/Example3/Program.cs index a0649ae38..2338ceec3 100644 --- a/Example3/Program.cs +++ b/Example3/Program.cs @@ -133,21 +133,16 @@ public static void Main (string[] args) s => { s.Prefix = "Anon#"; #if DEBUG - // To validate the cookies. + // To respond to the cookies. /* - s.CookiesValidator = - (req, res) => { - // Check the cookies in "req", and set the cookies to send to - // the client with "res" if necessary. - - foreach (var cookie in req) { - cookie.Expired = true; - - res.Add (cookie); - } - - return true; // If valid. - }; + s.CookiesResponder = + (reqCookies, resCookies) => { + foreach (var cookie in reqCookies) { + cookie.Expired = true; + + resCookies.Add (cookie); + } + }; */ // To emit a WebSocket.OnMessage event when receives a ping. From c454f582b2aee8f61636d4af6c7cef30188074f0 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 29 Jul 2025 16:28:29 +0900 Subject: [PATCH 6154/6294] [Modify] Return it --- Example3/Program.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Example3/Program.cs b/Example3/Program.cs index 2338ceec3..7296d8496 100644 --- a/Example3/Program.cs +++ b/Example3/Program.cs @@ -172,6 +172,17 @@ public static void Main (string[] args) // To send the Sec-WebSocket-Protocol header that has a subprotocol // name. //s.Protocol = "chat"; + + // To respond to the user headers. + + s.UserHeadersResponder = + (reqHeaders, userHeaders) => { + var val = reqHeaders["HeaderFromClient"]; + + if (!val.IsNullOrEmpty ()) + userHeaders[val] = "Hello From Server"; + }; + #endif } ); From 699181a28537c36800c757e3e01fd339f789819c Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 30 Jul 2025 16:43:00 +0900 Subject: [PATCH 6155/6294] [Modify] Edit it --- README.md | 38 ++++++++++++++++++++++++++++---------- 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 268712354..02f745cab 100644 --- a/README.md +++ b/README.md @@ -514,7 +514,7 @@ If you would like to provide the Digest authentication, you should set such as t wssv.AuthenticationSchemes = AuthenticationSchemes.Digest; ``` -### Query string, Origin header, and Cookies ### +### Query string, Origin header, Cookies, and user headers ### As a WebSocket client, if you would like to send the query string in the handshake request, you should create a new instance of the `WebSocket` class with a WebSocket URL that includes the [Query] string parameters. @@ -528,12 +528,18 @@ And if you would like to send the Origin header in the handshake request, you sh ws.Origin = "http://example.com/"; ``` -And also if you would like to send the cookies in the handshake request, you should set any cookie by using the `WebSocket.SetCookie (WebSocketSharp.Net.Cookie)` method before calling the connect method. +And if you would like to send cookies in the handshake request, you should set any cookie by using the `WebSocket.SetCookie (WebSocketSharp.Net.Cookie)` method before calling the connect method. ```csharp ws.SetCookie (new Cookie ("name", "nobita")); ``` +And also if you would like to send user headers in the handshake request, you should set any user defined header by using the `WebSocket.SetUserHeader (string, string)` method before calling the connect method. + +```csharp +ws.SetUserHeader ("HeaderFromClient", "HeaderFromServer"); +``` + As a WebSocket server, if you would like to get the query string included in a handshake request, you should access the `WebSocketBehavior.QueryString` property, such as the following. ```csharp @@ -551,7 +557,7 @@ public class Chat : WebSocketBehavior } ``` -And if you would like to validate the Origin header, cookies, or both, you should set each validation for it with your `WebSocketBehavior`, for example, by using the `WebSocketServer.AddWebSocketService (string, Action)` method with initializing, such as the following. +And if you would like to validate the Origin header, you should set a validation for it with your `WebSocketBehavior`, for example, by using the `WebSocketServer.AddWebSocketService (string, Action)` method with initializing, such as the following. ```csharp wssv.AddWebSocketService ( @@ -567,19 +573,31 @@ wssv.AddWebSocketService ( && Uri.TryCreate (val, UriKind.Absolute, out origin) && origin.Host == "example.com"; }; + } +); +``` - s.CookiesValidator = - (req, res) => { - // Check the cookies in "req", and set the cookies to send to - // the client with "res" if necessary. +And also if you would like to respond to the cookies, user headers, or both, you should set each response action for it with your `WebSocketBehavior`, for example, by using the `WebSocketServer.AddWebSocketService (string, Action)` method with initializing, such as the following. - foreach (var cookie in req) { +```csharp +wssv.AddWebSocketService ( + "/Chat", + s => { + s.CookiesResponder = + (reqCookies, resCookies) => { + foreach (var cookie in reqCookies) { cookie.Expired = true; - res.Add (cookie); + resCookies.Add (cookie); } + }; + + s.UserHeadersResponder = + (reqHeaders, userHeaders) => { + var val = reqHeaders["HeaderFromClient"]; - return true; // If valid. + if (!val.IsNullOrEmpty ()) + userHeaders[val] = "Hello From Server"; }; } ); From 2add469c498742ae1ed82100427835f209847e35 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 31 Jul 2025 16:48:20 +0900 Subject: [PATCH 6156/6294] [Modify] Remove the CookiesValidator property --- websocket-sharp/Server/WebSocketBehavior.cs | 51 --------------------- 1 file changed, 51 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index b38540a34..eace6d10a 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -49,7 +49,6 @@ public abstract class WebSocketBehavior : IWebSocketSession private WebSocketContext _context; private Action _cookiesResponder; - private Func _cookiesValidator; private bool _emitOnPing; private Func _hostValidator; private string _id; @@ -296,56 +295,6 @@ public Action CookiesResponder { } } - /// - /// Gets or sets the delegate used to validate the HTTP cookies. - /// - /// - /// - /// A - /// delegate. - /// - /// - /// It represents the delegate called when the WebSocket interface - /// for a session validates the handshake request. - /// - /// - /// 1st parameter passed to the delegate - /// contains the cookies to validate. - /// - /// - /// 2nd parameter passed to the delegate - /// holds the cookies to send to the client. - /// - /// - /// The method invoked by the delegate must return true - /// if the cookies are valid. - /// - /// - /// if not necessary. - /// - /// - /// The default value is . - /// - /// - /// - /// The set operation is not available when the session has already started. - /// - public Func CookiesValidator { - get { - return _cookiesValidator; - } - - set { - if (_websocket != null) { - var msg = "The set operation is not available."; - - throw new InvalidOperationException (msg); - } - - _cookiesValidator = value; - } - } - /// /// Gets or sets a value indicating whether the WebSocket interface for /// a session emits the message event when it receives a ping. From 9d7637cd80ec96c58ae1a229fabd6a78c8434b8b Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 1 Aug 2025 16:38:31 +0900 Subject: [PATCH 6157/6294] [Modify] Add it --- websocket-sharp/WebSocket.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index a3568d304..3b73599cb 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -93,6 +93,7 @@ public class WebSocket : IDisposable private Opcode _fragmentsOpcode; private const string _guid = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11"; private Func _handshakeRequestChecker; + private Action _handshakeRequestResponder; private NameValueCollection _handshakeResponseHeaders; private bool _ignoreExtensions; private bool _inContinuation; @@ -309,6 +310,17 @@ internal Func CustomHandshakeRequestChecker { } } + // As server + internal Action CustomHandshakeRequestResponder { + get { + return _handshakeRequestResponder; + } + + set { + _handshakeRequestResponder = value; + } + } + // As server internal bool IgnoreExtensions { get { From e12518ef39ed3b33fb625f18d24920a572a90db7 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 1 Aug 2025 16:58:47 +0900 Subject: [PATCH 6158/6294] [Modify] Edit it --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 02f745cab..1f55c1caa 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ websocket-sharp supports: - [Per-message Compression](#per-message-compression) extension - [Secure Connection](#secure-connection) - [HTTP Authentication](#http-authentication) -- [Query string, Origin header, and Cookies](#query-string-origin-header-and-cookies) +- [Query string, Origin header, Cookies, and user headers](#query-string-origin-header-cookies-and-user-headers) - [Connecting through the HTTP proxy server](#connecting-through-the-http-proxy-server) - .NET Framework **3.5** or later versions of .NET Framework (includes compatible environment such as [Mono]) From 78cfefa945db08a5c1983ecab277ac997886c0cd Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 2 Aug 2025 16:37:10 +0900 Subject: [PATCH 6159/6294] [Modify] Add it --- websocket-sharp/WebSocket.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 3b73599cb..18c1964f8 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1678,6 +1678,15 @@ out string message return message == null; } + // As server + private void customRespondToHandshakeRequest (WebSocketContext context) + { + if (_handshakeRequestResponder == null) + return; + + _handshakeRequestResponder (context); + } + private MessageEventArgs dequeueFromMessageEventQueue () { lock (_forMessageEventQueue) { From 5547ad0c74bf743fe8992568b71eec80be421a65 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 2 Aug 2025 16:41:25 +0900 Subject: [PATCH 6160/6294] [Modify] Use it --- websocket-sharp/WebSocket.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 18c1964f8..9f0808b49 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1043,6 +1043,8 @@ private bool acceptHandshake () processSecWebSocketExtensionsClientHeader (val); } + customRespondToHandshakeRequest (_context); + if (_noDelay) _socket.NoDelay = true; From ae1c501b249206281fbbaf838ab0f9161cb8e9f6 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 3 Aug 2025 08:51:51 +0900 Subject: [PATCH 6161/6294] [Modify] Add it --- websocket-sharp/Server/WebSocketBehavior.cs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index eace6d10a..95001df1d 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -693,6 +693,23 @@ private void onOpen (object sender, EventArgs e) OnOpen (); } + private void respondToHandshakeRequest (WebSocketContext context) + { + if (_cookiesResponder != null) { + var reqCookies = context.CookieCollection; + var resCookies = context.WebSocket.CookieCollection; + + _cookiesResponder (reqCookies, resCookies); + } + + if (_userHeadersResponder != null) { + var reqHeaders = context.Headers; + var userHeaders = context.WebSocket.UserHeaders; + + _userHeadersResponder (reqHeaders, userHeaders); + } + } + #endregion #region Internal Methods From 18051fd14a4b16a30e5debe3e95601e4e219c315 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 4 Aug 2025 09:57:00 +0900 Subject: [PATCH 6162/6294] [Modify] Separate it --- websocket-sharp/Server/WebSocketBehavior.cs | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 95001df1d..b8d75207d 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -641,20 +641,6 @@ private string checkHandshakeRequest (WebSocketContext context) } } - if (_cookiesResponder != null) { - var reqCookies = context.CookieCollection; - var resCookies = context.WebSocket.CookieCollection; - - _cookiesResponder (reqCookies, resCookies); - } - - if (_userHeadersResponder != null) { - var reqHeaders = context.Headers; - var userHeaders = context.WebSocket.UserHeaders; - - _userHeadersResponder (reqHeaders, userHeaders); - } - return null; } @@ -724,6 +710,7 @@ WebSocketSessionManager sessions _websocket = context.WebSocket; _websocket.CustomHandshakeRequestChecker = checkHandshakeRequest; + _websocket.CustomHandshakeRequestResponder = respondToHandshakeRequest; if (_emitOnPing) _websocket.EmitOnPing = true; From 09d10588b9b07ae207d4fc387c0dd4884426658d Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 5 Aug 2025 16:15:02 +0900 Subject: [PATCH 6163/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 9f0808b49..bace3119e 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -4438,7 +4438,6 @@ public void SetProxy (string url, string username, string password) /// characters. /// /// - /// This instance does not allow the header. /// /// The SetUserHeader method is not available when the current state of /// the interface is neither New nor Closed. From 6ee668722fc50b01ff0344d7cc6413a10c5f1d8f Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 6 Aug 2025 16:34:17 +0900 Subject: [PATCH 6164/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index b8d75207d..3ded81884 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -259,7 +259,7 @@ protected System.Net.IPEndPoint UserEndPoint { /// /// /// It represents the delegate called when the WebSocket interface - /// for a session validates the handshake request. + /// for a session respond to the handshake request. /// /// /// 1st parameter passed to the delegate From 1020f0e593f5439fdb381f2c55aef2b211e99acc Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 7 Aug 2025 16:22:37 +0900 Subject: [PATCH 6165/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 3ded81884..3a04ad8e9 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -583,7 +583,7 @@ public DateTime StartTime { /// /// /// It represents the delegate called when the WebSocket interface - /// for a session validates the handshake request. + /// for a session respond to the handshake request. /// /// /// 1st parameter passed to the delegate From c6a41cb6301c3917b9b120e0c1f45f7d5c713f8c Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 8 Aug 2025 16:11:40 +0900 Subject: [PATCH 6166/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index bace3119e..e13a8acfb 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1621,7 +1621,9 @@ private HttpRequest createHandshakeRequest () if (hasUserHeader) headers.Add (_userHeaders); - if (_cookies.Count > 0) + var hasCookie = _cookies != null && _cookies.Count > 0; + + if (hasCookie) ret.SetCookies (_cookies); return ret; From 45d0695057e26acc2d9c0baaaa1375e8cea04420 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 9 Aug 2025 15:58:41 +0900 Subject: [PATCH 6167/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index e13a8acfb..8de960877 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1649,7 +1649,9 @@ private HttpResponse createHandshakeResponse () if (hasUserHeader) headers.Add (_userHeaders); - if (_cookies.Count > 0) + var hasCookie = _cookies != null && _cookies.Count > 0; + + if (hasCookie) ret.SetCookies (_cookies); return ret; From 1d51a6784c56fbf4bf4e8fe7f46f30b2fb690823 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 10 Aug 2025 15:29:40 +0900 Subject: [PATCH 6168/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 8de960877..8d1cd3176 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -416,6 +416,11 @@ public CompressionMethod Compression { /// public IEnumerable Cookies { get { + var hasCookie = _cookies != null && _cookies.Count > 0; + + if (!hasCookie) + yield break; + lock (_cookies.SyncRoot) { foreach (var cookie in _cookies) yield return cookie; From 2a719bcc986366f3b098d548da21d93e7d168427 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 11 Aug 2025 16:18:33 +0900 Subject: [PATCH 6169/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 8d1cd3176..7b28c3a24 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -295,6 +295,9 @@ public WebSocket (string url, params string[] protocols) internal CookieCollection CookieCollection { get { + if (_cookies == null) + _cookies = new CookieCollection (); + return _cookies; } } @@ -1778,7 +1781,6 @@ private ClientSslConfiguration getSslConfiguration () private void init () { _compression = CompressionMethod.None; - _cookies = new CookieCollection (); _forPing = new object (); _forSend = new object (); _forState = new object (); @@ -4145,8 +4147,8 @@ public void SetCookie (Cookie cookie) throw new InvalidOperationException (msg); } - lock (_cookies.SyncRoot) - _cookies.SetOrRemove (cookie); + lock (CookieCollection.SyncRoot) + CookieCollection.SetOrRemove (cookie); } } From 4eb052221f8b7edd86c64dc8eaf58565c30fcaad Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 12 Aug 2025 16:10:53 +0900 Subject: [PATCH 6170/6294] [Modify] Add the HandshakeResponseCookies property --- websocket-sharp/WebSocket.cs | 50 +++++++++++++++++++++++++++++++++--- 1 file changed, 46 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 7b28c3a24..d18fc9c60 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -94,6 +94,7 @@ public class WebSocket : IDisposable private const string _guid = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11"; private Func _handshakeRequestChecker; private Action _handshakeRequestResponder; + private CookieCollection _handshakeResponseCookies; private NameValueCollection _handshakeResponseHeaders; private bool _ignoreExtensions; private bool _inContinuation; @@ -552,6 +553,48 @@ public string Extensions { } } + /// + /// Gets the HTTP cookies included in the handshake response. + /// + /// + /// A that contains the cookies included in + /// the handshake response if any. + /// + /// + /// + /// The get operation is not available if the interface is not for + /// the client. + /// + /// + /// -or- + /// + /// + /// The get operation is not available when the current state of + /// the interface is New or Connecting. + /// + /// + public CookieCollection HandshakeResponseCookies { + get { + if (!_isClient) { + var msg = "The get operation is not available."; + + throw new InvalidOperationException (msg); + } + + lock (_forState) { + var canGet = _readyState > WebSocketState.Connecting; + + if (!canGet) { + var msg = "The get operation is not available."; + + throw new InvalidOperationException (msg); + } + + return _handshakeResponseCookies; + } + } + } + /// /// Gets the HTTP headers included in the handshake response. /// @@ -1720,6 +1763,7 @@ private bool doHandshake () _log.Debug (res.ToString ()); _handshakeResponseHeaders = res.Headers; + _handshakeResponseCookies = res.Cookies; string msg; @@ -1743,10 +1787,8 @@ private bool doHandshake () _extensions = exts; } - var cookies = res.Cookies; - - if (cookies.Count > 0) - _cookies.SetOrRemove (cookies); + if (_handshakeResponseCookies.Count > 0) + _cookies.SetOrRemove (_handshakeResponseCookies); return true; } From ebda304c47fc539837a009ef1f11510fe4051933 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 13 Aug 2025 16:01:45 +0900 Subject: [PATCH 6171/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index d18fc9c60..813b45aa3 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1776,10 +1776,10 @@ private bool doHandshake () } if (_protocolsRequested) - _protocol = res.Headers["Sec-WebSocket-Protocol"]; + _protocol = _handshakeResponseHeaders["Sec-WebSocket-Protocol"]; if (_extensionsRequested) { - var exts = res.Headers["Sec-WebSocket-Extensions"]; + var exts = _handshakeResponseHeaders["Sec-WebSocket-Extensions"]; if (exts == null) _compression = CompressionMethod.None; From 35aa70ee68822c8f1b333dd13003fe2e68c74818 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 14 Aug 2025 16:00:44 +0900 Subject: [PATCH 6172/6294] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 813b45aa3..bb5729140 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1781,10 +1781,10 @@ private bool doHandshake () if (_extensionsRequested) { var exts = _handshakeResponseHeaders["Sec-WebSocket-Extensions"]; - if (exts == null) - _compression = CompressionMethod.None; - else + if (exts != null) _extensions = exts; + else + _compression = CompressionMethod.None; } if (_handshakeResponseCookies.Count > 0) From eaaa5521cdae7f1dc34dbb5b7c676e35c257ec72 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 14 Aug 2025 16:04:15 +0900 Subject: [PATCH 6173/6294] [Modify] Replace it --- websocket-sharp/WebSocket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index bb5729140..ff07b4ea1 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1788,7 +1788,7 @@ private bool doHandshake () } if (_handshakeResponseCookies.Count > 0) - _cookies.SetOrRemove (_handshakeResponseCookies); + CookieCollection.SetOrRemove (_handshakeResponseCookies); return true; } From f95ee8e4ed1d7b4f77cc2c660e781f816c3700aa Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 15 Aug 2025 16:30:30 +0900 Subject: [PATCH 6174/6294] [Modify] Remove the Cookies property --- websocket-sharp/WebSocket.cs | 30 +----------------------------- 1 file changed, 1 insertion(+), 29 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index ff07b4ea1..133254a7e 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -405,33 +405,6 @@ public CompressionMethod Compression { } } - /// - /// Gets the HTTP cookies included in the handshake request/response. - /// - /// - /// - /// An - /// instance. - /// - /// - /// It provides an enumerator which supports the iteration over - /// the collection of the cookies. - /// - /// - public IEnumerable Cookies { - get { - var hasCookie = _cookies != null && _cookies.Count > 0; - - if (!hasCookie) - yield break; - - lock (_cookies.SyncRoot) { - foreach (var cookie in _cookies) - yield return cookie; - } - } - } - /// /// Gets the credentials for the HTTP authentication (Basic/Digest). /// @@ -4189,8 +4162,7 @@ public void SetCookie (Cookie cookie) throw new InvalidOperationException (msg); } - lock (CookieCollection.SyncRoot) - CookieCollection.SetOrRemove (cookie); + CookieCollection.SetOrRemove (cookie); } } From bfe019c1ca89b5aaba2a2ccc45aceed6ba7429d1 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 16 Aug 2025 16:13:26 +0900 Subject: [PATCH 6175/6294] [Modify] Rename it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- websocket-sharp/WebSocket.cs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 3a04ad8e9..ad19935f5 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -683,7 +683,7 @@ private void respondToHandshakeRequest (WebSocketContext context) { if (_cookiesResponder != null) { var reqCookies = context.CookieCollection; - var resCookies = context.WebSocket.CookieCollection; + var resCookies = context.WebSocket.Cookies; _cookiesResponder (reqCookies, resCookies); } diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 133254a7e..5bfca517e 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -294,7 +294,7 @@ public WebSocket (string url, params string[] protocols) #region Internal Properties - internal CookieCollection CookieCollection { + internal CookieCollection Cookies { get { if (_cookies == null) _cookies = new CookieCollection (); @@ -1761,7 +1761,7 @@ private bool doHandshake () } if (_handshakeResponseCookies.Count > 0) - CookieCollection.SetOrRemove (_handshakeResponseCookies); + Cookies.SetOrRemove (_handshakeResponseCookies); return true; } @@ -4162,7 +4162,7 @@ public void SetCookie (Cookie cookie) throw new InvalidOperationException (msg); } - CookieCollection.SetOrRemove (cookie); + Cookies.SetOrRemove (cookie); } } From 773cd90dbcffe3f409726ee16d44aed4103cdba8 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 17 Aug 2025 16:31:30 +0900 Subject: [PATCH 6176/6294] [Modify] Initialize it --- websocket-sharp/WebSocket.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 5bfca517e..10b2edfe2 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1729,6 +1729,9 @@ private MessageEventArgs dequeueFromMessageEventQueue () // As client private bool doHandshake () { + _handshakeResponseHeaders = null; + _handshakeResponseCookies = null; + setClientStream (); var res = sendHandshakeRequest (); From 546293aa4ed1858fb8db57a750215b36c6a725c4 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 18 Aug 2025 16:09:08 +0900 Subject: [PATCH 6177/6294] [Modify] Add it --- websocket-sharp/WebSocket.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 10b2edfe2..7a5f4045c 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1807,6 +1807,14 @@ private void init () _readyState = WebSocketState.New; } + // As client + private void initr () + { + _extensionsRequested = false; + _handshakeResponseCookies = null; + _handshakeResponseHeaders = null; + } + private void message () { MessageEventArgs e = null; From 0c1d068ecc0b45e58c0a13ba97435f89d78b17f0 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 19 Aug 2025 16:22:16 +0900 Subject: [PATCH 6178/6294] [Modify] Use it --- websocket-sharp/WebSocket.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 7a5f4045c..ff4bb8425 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1527,6 +1527,9 @@ private bool connect () return false; } + if (_readyState == WebSocketState.Closed) + initr (); + _retryCountForConnect++; _readyState = WebSocketState.Connecting; @@ -1729,9 +1732,6 @@ private MessageEventArgs dequeueFromMessageEventQueue () // As client private bool doHandshake () { - _handshakeResponseHeaders = null; - _handshakeResponseCookies = null; - setClientStream (); var res = sendHandshakeRequest (); From 261536530cf059dc894738ec04635eea360418cb Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 20 Aug 2025 16:20:12 +0900 Subject: [PATCH 6179/6294] [Modify] Add it --- websocket-sharp/WebSocket.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index ff4bb8425..9411b684c 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -96,6 +96,7 @@ public class WebSocket : IDisposable private Action _handshakeRequestResponder; private CookieCollection _handshakeResponseCookies; private NameValueCollection _handshakeResponseHeaders; + private bool _hasProtocol; private bool _ignoreExtensions; private bool _inContinuation; private volatile bool _inMessage; @@ -277,6 +278,7 @@ public WebSocket (string url, params string[] protocols) throw new ArgumentException (msg, "protocols"); _protocols = protocols; + _hasProtocol = true; } _base64Key = CreateBase64Key (); From c56fc90233dbe926323502fad2d6eb00735ed5ec Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 21 Aug 2025 16:21:36 +0900 Subject: [PATCH 6180/6294] [Modify] Replace it --- websocket-sharp/WebSocket.cs | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 9411b684c..b53e4cdec 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -113,7 +113,6 @@ public class WebSocket : IDisposable private bool _preAuth; private string _protocol; private string[] _protocols; - private bool _protocolsRequested; private NetworkCredential _proxyCredentials; private Uri _proxyUri; private volatile WebSocketState _readyState; @@ -1209,14 +1208,14 @@ out string message var subp = headers["Sec-WebSocket-Protocol"]; if (subp == null) { - if (_protocolsRequested) { + if (_hasProtocol) { message = "The Sec-WebSocket-Protocol header is non-existent."; return false; } } else { - var isValid = _protocolsRequested + var isValid = _hasProtocol && subp.Length > 0 && _protocols.Contains (p => p == subp); @@ -1626,12 +1625,9 @@ private HttpRequest createHandshakeRequest () if (!_origin.IsNullOrEmpty ()) headers["Origin"] = _origin; - if (_protocols != null) { + if (_hasProtocol) headers["Sec-WebSocket-Protocol"] = _protocols.ToString (", "); - _protocolsRequested = true; - } - var exts = createExtensions (); if (exts != null) { @@ -1753,7 +1749,7 @@ private bool doHandshake () return false; } - if (_protocolsRequested) + if (_hasProtocol) _protocol = _handshakeResponseHeaders["Sec-WebSocket-Protocol"]; if (_extensionsRequested) { From 2ac4220fddb113521fd803ef9089a377e00afbe9 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 22 Aug 2025 16:34:04 +0900 Subject: [PATCH 6181/6294] [Modify] Replace it --- websocket-sharp/WebSocket.cs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index b53e4cdec..6d05eb049 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -83,7 +83,6 @@ public class WebSocket : IDisposable private static readonly byte[] _emptyBytes; private bool _enableRedirection; private string _extensions; - private bool _extensionsRequested; private object _forMessageEventQueue; private object _forPing; private object _forSend; @@ -96,6 +95,7 @@ public class WebSocket : IDisposable private Action _handshakeRequestResponder; private CookieCollection _handshakeResponseCookies; private NameValueCollection _handshakeResponseHeaders; + private bool _hasExtension; private bool _hasProtocol; private bool _ignoreExtensions; private bool _inContinuation; @@ -1630,11 +1630,10 @@ private HttpRequest createHandshakeRequest () var exts = createExtensions (); - if (exts != null) { - headers["Sec-WebSocket-Extensions"] = exts; + _hasExtension = exts != null; - _extensionsRequested = true; - } + if (_hasExtension) + headers["Sec-WebSocket-Extensions"] = exts; var ares = createAuthenticationResponse (); @@ -1752,7 +1751,7 @@ private bool doHandshake () if (_hasProtocol) _protocol = _handshakeResponseHeaders["Sec-WebSocket-Protocol"]; - if (_extensionsRequested) { + if (_hasExtension) { var exts = _handshakeResponseHeaders["Sec-WebSocket-Extensions"]; if (exts != null) @@ -1808,7 +1807,6 @@ private void init () // As client private void initr () { - _extensionsRequested = false; _handshakeResponseCookies = null; _handshakeResponseHeaders = null; } @@ -2622,7 +2620,7 @@ private void startReceiving () // As client private bool validateSecWebSocketExtensionsServerHeader (string value) { - if (!_extensionsRequested) + if (!_hasExtension) return false; if (value.Length == 0) From 1e6e223002eb4de7df42833ff6fa3733a66b4c6e Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 23 Aug 2025 17:45:46 +0900 Subject: [PATCH 6182/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 6d05eb049..251532d2a 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -531,8 +531,14 @@ public string Extensions { /// Gets the HTTP cookies included in the handshake response. /// /// - /// A that contains the cookies included in - /// the handshake response if any. + /// + /// A that contains the cookies + /// included in the handshake response if any. + /// + /// + /// if the interface could not receive + /// the handshake response. + /// /// /// /// From 01a1a7559f21e38af1045a1ae1e8c123416b6df3 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 24 Aug 2025 16:11:44 +0900 Subject: [PATCH 6183/6294] [Modify] Edit it --- websocket-sharp/WebSocket.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 251532d2a..5d4727f42 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -579,8 +579,14 @@ public CookieCollection HandshakeResponseCookies { /// Gets the HTTP headers included in the handshake response. /// /// - /// A that contains the headers - /// included in the handshake response. + /// + /// A that contains the headers + /// included in the handshake response. + /// + /// + /// if the interface could not receive + /// the handshake response. + /// /// /// /// From b7b87e62ab50c53f3e9a0fb24d3b74cdfc0c8b50 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 25 Aug 2025 16:29:42 +0900 Subject: [PATCH 6184/6294] [Modify] Polish it --- websocket-sharp/Net/CookieCollection.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/CookieCollection.cs b/websocket-sharp/Net/CookieCollection.cs index 9a8ce641b..1e4fb3ff5 100644 --- a/websocket-sharp/Net/CookieCollection.cs +++ b/websocket-sharp/Net/CookieCollection.cs @@ -689,7 +689,7 @@ internal void Sort () public void Add (Cookie cookie) { if (_readOnly) { - var msg = "The collection is read-only."; + var msg = "The Add method is not available."; throw new InvalidOperationException (msg); } From ffb7adac368eedb84e948e40a546f08120a45e51 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 26 Aug 2025 16:51:38 +0900 Subject: [PATCH 6185/6294] [Modify] Edit it --- websocket-sharp/Net/CookieCollection.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/CookieCollection.cs b/websocket-sharp/Net/CookieCollection.cs index 1e4fb3ff5..d9ffd2b62 100644 --- a/websocket-sharp/Net/CookieCollection.cs +++ b/websocket-sharp/Net/CookieCollection.cs @@ -684,7 +684,7 @@ internal void Sort () /// is . /// /// - /// The collection is read-only. + /// This method is not available if the collection is read-only. /// public void Add (Cookie cookie) { From 949df59c6ef625eafc8de9c7ac155e7813e15306 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 27 Aug 2025 16:51:56 +0900 Subject: [PATCH 6186/6294] [Modify] Edit it --- websocket-sharp/Net/CookieCollection.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/CookieCollection.cs b/websocket-sharp/Net/CookieCollection.cs index d9ffd2b62..3dc2a2a56 100644 --- a/websocket-sharp/Net/CookieCollection.cs +++ b/websocket-sharp/Net/CookieCollection.cs @@ -710,7 +710,7 @@ public void Add (Cookie cookie) /// is . /// /// - /// The collection is read-only. + /// This method is not available if the collection is read-only. /// public void Add (CookieCollection cookies) { From 2e3c91af2702fcb0df2ff6d3d0ce7c5a00a92af4 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 28 Aug 2025 22:09:30 +0900 Subject: [PATCH 6187/6294] [Modify] Edit it --- websocket-sharp/Net/CookieCollection.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/CookieCollection.cs b/websocket-sharp/Net/CookieCollection.cs index 3dc2a2a56..791865f14 100644 --- a/websocket-sharp/Net/CookieCollection.cs +++ b/websocket-sharp/Net/CookieCollection.cs @@ -731,7 +731,7 @@ public void Add (CookieCollection cookies) /// Removes all cookies from the collection. /// /// - /// The collection is read-only. + /// This method is not available if the collection is read-only. /// public void Clear () { From 4951838369f6b892ca7d5aecac2c4526eea6094a Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 29 Aug 2025 21:47:41 +0900 Subject: [PATCH 6188/6294] [Modify] Edit it --- websocket-sharp/Net/CookieCollection.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/CookieCollection.cs b/websocket-sharp/Net/CookieCollection.cs index 791865f14..98c841d2a 100644 --- a/websocket-sharp/Net/CookieCollection.cs +++ b/websocket-sharp/Net/CookieCollection.cs @@ -838,7 +838,7 @@ public IEnumerator GetEnumerator () /// is . /// /// - /// The collection is read-only. + /// This method is not available if the collection is read-only. /// public bool Remove (Cookie cookie) { From e789ddcd68be2e055568e7f3eac193167a9117b7 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 30 Aug 2025 22:48:57 +0900 Subject: [PATCH 6189/6294] [Modify] Edit it --- websocket-sharp/Net/CookieCollection.cs | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/websocket-sharp/Net/CookieCollection.cs b/websocket-sharp/Net/CookieCollection.cs index 98c841d2a..3fb5e8e3c 100644 --- a/websocket-sharp/Net/CookieCollection.cs +++ b/websocket-sharp/Net/CookieCollection.cs @@ -823,13 +823,8 @@ public IEnumerator GetEnumerator () /// Removes the specified cookie from the collection. /// /// - /// - /// true if the cookie is successfully removed; otherwise, - /// false. - /// - /// - /// false if the cookie is not found in the collection. - /// + /// true if the cookie is successfully found and removed; + /// otherwise, false. /// /// /// A to remove. From 36ea47efcd8899223daee3b53784d9d50072e936 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 31 Aug 2025 22:22:22 +0900 Subject: [PATCH 6190/6294] [Modify] Polish it --- websocket-sharp/Net/CookieCollection.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/CookieCollection.cs b/websocket-sharp/Net/CookieCollection.cs index 3fb5e8e3c..c8162f019 100644 --- a/websocket-sharp/Net/CookieCollection.cs +++ b/websocket-sharp/Net/CookieCollection.cs @@ -689,7 +689,7 @@ internal void Sort () public void Add (Cookie cookie) { if (_readOnly) { - var msg = "The Add method is not available."; + var msg = "The collection is read-only."; throw new InvalidOperationException (msg); } From e02174bb1f8c69a4e02c73985b8a09c3e6d9900a Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 1 Sep 2025 22:28:29 +0900 Subject: [PATCH 6191/6294] [Modify] Add it --- websocket-sharp/Net/CookieCollection.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/websocket-sharp/Net/CookieCollection.cs b/websocket-sharp/Net/CookieCollection.cs index c8162f019..3963ef2a9 100644 --- a/websocket-sharp/Net/CookieCollection.cs +++ b/websocket-sharp/Net/CookieCollection.cs @@ -82,6 +82,16 @@ internal IList List { } } + internal bool ReadOnly { + get { + return _readOnly; + } + + set { + _readOnly = value; + } + } + internal IEnumerable Sorted { get { var list = new List (_list); From 4a997da841213ecc05fdba4a83bef854dacc4b5c Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 2 Sep 2025 22:14:36 +0900 Subject: [PATCH 6192/6294] [Modify] Polish it --- websocket-sharp/Net/CookieCollection.cs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/websocket-sharp/Net/CookieCollection.cs b/websocket-sharp/Net/CookieCollection.cs index 3963ef2a9..5e82b64c2 100644 --- a/websocket-sharp/Net/CookieCollection.cs +++ b/websocket-sharp/Net/CookieCollection.cs @@ -135,10 +135,6 @@ public bool IsReadOnly { get { return _readOnly; } - - internal set { - _readOnly = value; - } } /// From 21c269cac97afd524aab91fe90b573352fee829a Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 3 Sep 2025 22:24:14 +0900 Subject: [PATCH 6193/6294] [Modify] Rename it --- websocket-sharp/HttpRequest.cs | 2 +- websocket-sharp/HttpResponse.cs | 2 +- websocket-sharp/Net/CookieCollection.cs | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/HttpRequest.cs b/websocket-sharp/HttpRequest.cs index dd51d0101..946024d6a 100644 --- a/websocket-sharp/HttpRequest.cs +++ b/websocket-sharp/HttpRequest.cs @@ -231,7 +231,7 @@ public void SetCookies (CookieCollection cookies) var buff = new StringBuilder (64); - foreach (var cookie in cookies.Sorted) { + foreach (var cookie in cookies.SortedList) { if (cookie.Expired) continue; diff --git a/websocket-sharp/HttpResponse.cs b/websocket-sharp/HttpResponse.cs index fb2f9d312..d511c94fe 100644 --- a/websocket-sharp/HttpResponse.cs +++ b/websocket-sharp/HttpResponse.cs @@ -262,7 +262,7 @@ public void SetCookies (CookieCollection cookies) var headers = Headers; - foreach (var cookie in cookies.Sorted) { + foreach (var cookie in cookies.SortedList) { var val = cookie.ToResponseString (); headers.Add ("Set-Cookie", val); diff --git a/websocket-sharp/Net/CookieCollection.cs b/websocket-sharp/Net/CookieCollection.cs index 5e82b64c2..730d9ce9a 100644 --- a/websocket-sharp/Net/CookieCollection.cs +++ b/websocket-sharp/Net/CookieCollection.cs @@ -92,7 +92,7 @@ internal bool ReadOnly { } } - internal IEnumerable Sorted { + internal IEnumerable SortedList { get { var list = new List (_list); @@ -202,7 +202,7 @@ public Cookie this[string name] { var caseInsensitive = StringComparison.InvariantCultureIgnoreCase; - foreach (var cookie in Sorted) { + foreach (var cookie in SortedList) { if (cookie.Name.Equals (name, caseInsensitive)) return cookie; } From 1eaf1a637810af30ed2c9eb6e5067d1173dfdaec Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 4 Sep 2025 22:11:33 +0900 Subject: [PATCH 6194/6294] [Modify] Rename it --- websocket-sharp/Net/CookieCollection.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Net/CookieCollection.cs b/websocket-sharp/Net/CookieCollection.cs index 730d9ce9a..83982c679 100644 --- a/websocket-sharp/Net/CookieCollection.cs +++ b/websocket-sharp/Net/CookieCollection.cs @@ -97,7 +97,7 @@ internal IEnumerable SortedList { var list = new List (_list); if (list.Count > 1) - list.Sort (compareForSorted); + list.Sort (compareForSortedList); return list; } @@ -246,7 +246,7 @@ private static int compareForSort (Cookie x, Cookie y) - (y.Name.Length + y.Value.Length); } - private static int compareForSorted (Cookie x, Cookie y) + private static int compareForSortedList (Cookie x, Cookie y) { var ret = x.Version - y.Version; From bd8ae8c7927318c43fbba3d8b7f4e2a14f905a20 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 5 Sep 2025 22:25:15 +0900 Subject: [PATCH 6195/6294] [Modify] Polish it --- websocket-sharp/Net/CookieCollection.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/CookieCollection.cs b/websocket-sharp/Net/CookieCollection.cs index 83982c679..a8fe63e61 100644 --- a/websocket-sharp/Net/CookieCollection.cs +++ b/websocket-sharp/Net/CookieCollection.cs @@ -92,7 +92,7 @@ internal bool ReadOnly { } } - internal IEnumerable SortedList { + internal ICollection SortedList { get { var list = new List (_list); From 0244121b0d849b9e1d65b837c4e6eb4c49b8f640 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 6 Sep 2025 16:35:59 +0900 Subject: [PATCH 6196/6294] [Modify] Rename it --- websocket-sharp/Net/CookieCollection.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/CookieCollection.cs b/websocket-sharp/Net/CookieCollection.cs index a8fe63e61..867a16e04 100644 --- a/websocket-sharp/Net/CookieCollection.cs +++ b/websocket-sharp/Net/CookieCollection.cs @@ -57,7 +57,7 @@ public class CookieCollection : ICollection private List _list; private bool _readOnly; - private object _sync; + private object _syncRoot; #endregion @@ -69,7 +69,7 @@ public class CookieCollection : ICollection public CookieCollection () { _list = new List (); - _sync = ((ICollection) _list).SyncRoot; + _syncRoot = ((ICollection) _list).SyncRoot; } #endregion @@ -219,7 +219,7 @@ public Cookie this[string name] { /// public object SyncRoot { get { - return _sync; + return _syncRoot; } } From 3fc3253c4a9452b0e3018dc7f85ac9cafefae0a2 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 7 Sep 2025 22:44:02 +0900 Subject: [PATCH 6197/6294] [Modify] 2025 --- websocket-sharp/Net/CookieCollection.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Net/CookieCollection.cs b/websocket-sharp/Net/CookieCollection.cs index 867a16e04..02e065580 100644 --- a/websocket-sharp/Net/CookieCollection.cs +++ b/websocket-sharp/Net/CookieCollection.cs @@ -8,7 +8,7 @@ * The MIT License * * Copyright (c) 2004,2009 Novell, Inc. (http://www.novell.com) - * Copyright (c) 2012-2024 sta.blockhead + * Copyright (c) 2012-2025 sta.blockhead * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From db1d7e986fd4f33d812e135e2f99086f2e7cf1de Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 8 Sep 2025 22:11:58 +0900 Subject: [PATCH 6198/6294] [Modify] Add it --- websocket-sharp/Server/WebSocketSessionManager.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 43072fcf4..7c77ee1f9 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -480,6 +480,11 @@ internal string Add (IWebSocketSession session) } } + internal static string CreateID () + { + return Guid.NewGuid ().ToString ("N"); + } + internal bool Remove (string id) { lock (_sync) From 3959883c4c6d565531279e7bb006e11a6739c46f Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 9 Sep 2025 22:26:57 +0900 Subject: [PATCH 6199/6294] [Modify] Add it --- websocket-sharp/Server/WebSocketSessionManager.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 7c77ee1f9..25f976698 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -480,6 +480,18 @@ internal string Add (IWebSocketSession session) } } + internal bool Add2 (IWebSocketSession session) + { + lock (_sync) { + if (_state != ServerState.Start) + return false; + + _sessions.Add (session.ID, session); + + return true; + } + } + internal static string CreateID () { return Guid.NewGuid ().ToString ("N"); From f5174e71a3eaae2152c80cae9a6019c9dccfc676 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 10 Sep 2025 22:08:38 +0900 Subject: [PATCH 6200/6294] [Modify] Replace it To enable early access to the ID. --- websocket-sharp/Server/WebSocketBehavior.cs | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index ad19935f5..525f5023a 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -56,6 +56,7 @@ public abstract class WebSocketBehavior : IWebSocketSession private bool _noDelay; private Func _originValidator; private string _protocol; + private bool _registered; private WebSocketSessionManager _sessions; private DateTime _startTime; private Action _userHeadersResponder; @@ -376,15 +377,13 @@ public Func HostValidator { /// Gets the unique ID of a session. /// /// - /// - /// A that represents the unique ID of the session. - /// - /// - /// when the session has not started yet. - /// + /// A that represents the unique ID of the session. /// public string ID { get { + if (_id == null) + _id = WebSocketSessionManager.CreateID (); + return _id; } } @@ -646,7 +645,7 @@ private string checkHandshakeRequest (WebSocketContext context) private void onClose (object sender, CloseEventArgs e) { - if (_id == null) + if (!_registered) return; _sessions.Remove (_id); @@ -666,9 +665,9 @@ private void onMessage (object sender, MessageEventArgs e) private void onOpen (object sender, EventArgs e) { - _id = _sessions.Add (this); + _registered = _sessions.Add2 (this); - if (_id == null) { + if (!_registered) { _websocket.Close (CloseStatusCode.Away); return; From 064d473705b99fd31ae1a09f60ecfb871f8f6b76 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 11 Sep 2025 21:27:18 +0900 Subject: [PATCH 6201/6294] [Modify] Remove it --- websocket-sharp/Server/WebSocketSessionManager.cs | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 25f976698..6861787f1 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -466,20 +466,6 @@ private bool tryGetSession (string id, out IWebSocketSession session) #region Internal Methods - internal string Add (IWebSocketSession session) - { - lock (_sync) { - if (_state != ServerState.Start) - return null; - - var id = createID (); - - _sessions.Add (id, session); - - return id; - } - } - internal bool Add2 (IWebSocketSession session) { lock (_sync) { From be634d01d33d4e005b9dca7a36f2cfd367331ab3 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 12 Sep 2025 22:15:19 +0900 Subject: [PATCH 6202/6294] [Modify] Remove it --- websocket-sharp/Server/WebSocketSessionManager.cs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 6861787f1..eb9229f01 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -417,11 +417,6 @@ private bool canSet () return _state == ServerState.Ready || _state == ServerState.Stop; } - private static string createID () - { - return Guid.NewGuid ().ToString ("N"); - } - private void setSweepTimer (double interval) { _sweepTimer = new System.Timers.Timer (interval); From e3446420d754b28685985212acf5c39575ae4ede Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 13 Sep 2025 16:42:43 +0900 Subject: [PATCH 6203/6294] [Modify] Rename it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- websocket-sharp/Server/WebSocketSessionManager.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 525f5023a..1d567baf5 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -665,7 +665,7 @@ private void onMessage (object sender, MessageEventArgs e) private void onOpen (object sender, EventArgs e) { - _registered = _sessions.Add2 (this); + _registered = _sessions.Add (this); if (!_registered) { _websocket.Close (CloseStatusCode.Away); diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index eb9229f01..e1d1a2001 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -461,7 +461,7 @@ private bool tryGetSession (string id, out IWebSocketSession session) #region Internal Methods - internal bool Add2 (IWebSocketSession session) + internal bool Add (IWebSocketSession session) { lock (_sync) { if (_state != ServerState.Start) From 4219b77077b652c928b4ba0ea7f1d68798c110fe Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 14 Sep 2025 16:35:58 +0900 Subject: [PATCH 6204/6294] [Modify] Test it --- Example/Program.cs | 4 ++-- Example2/Program.cs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Example/Program.cs b/Example/Program.cs index 8bd120515..8d16c0794 100644 --- a/Example/Program.cs +++ b/Example/Program.cs @@ -57,8 +57,8 @@ public static void Main (string[] args) // To send a user header. - var reqHeader = "HeaderFromClient"; - var resHeader = "HeaderFromServer"; + var reqHeader = "RequestForID"; + var resHeader = "ID"; ws.SetUserHeader (reqHeader, resHeader); diff --git a/Example2/Program.cs b/Example2/Program.cs index c38dd38b2..4a2e8c0bf 100644 --- a/Example2/Program.cs +++ b/Example2/Program.cs @@ -139,10 +139,10 @@ public static void Main (string[] args) s.UserHeadersResponder = (reqHeaders, userHeaders) => { - var val = reqHeaders["HeaderFromClient"]; + var val = reqHeaders["RequestForID"]; if (!val.IsNullOrEmpty ()) - userHeaders[val] = "Hello From Server"; + userHeaders[val] = s.ID; }; #endif From 0de65f9cbeb1c4cd1c848578f19f4c9c393787ea Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 15 Sep 2025 22:33:45 +0900 Subject: [PATCH 6205/6294] [Modify] Test it --- Example3/Program.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Example3/Program.cs b/Example3/Program.cs index 7296d8496..259b5164b 100644 --- a/Example3/Program.cs +++ b/Example3/Program.cs @@ -177,10 +177,10 @@ public static void Main (string[] args) s.UserHeadersResponder = (reqHeaders, userHeaders) => { - var val = reqHeaders["HeaderFromClient"]; + var val = reqHeaders["RequestForID"]; if (!val.IsNullOrEmpty ()) - userHeaders[val] = "Hello From Server"; + userHeaders[val] = s.ID; }; #endif From 4c92618b0b6e24628d02db23dbb47f7a2fea08f7 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 16 Sep 2025 22:02:11 +0900 Subject: [PATCH 6206/6294] [Modify] Edit it --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 1f55c1caa..984507ea4 100644 --- a/README.md +++ b/README.md @@ -537,7 +537,7 @@ ws.SetCookie (new Cookie ("name", "nobita")); And also if you would like to send user headers in the handshake request, you should set any user defined header by using the `WebSocket.SetUserHeader (string, string)` method before calling the connect method. ```csharp -ws.SetUserHeader ("HeaderFromClient", "HeaderFromServer"); +ws.SetUserHeader ("RequestForID", "ID"); ``` As a WebSocket server, if you would like to get the query string included in a handshake request, you should access the `WebSocketBehavior.QueryString` property, such as the following. @@ -594,10 +594,10 @@ wssv.AddWebSocketService ( s.UserHeadersResponder = (reqHeaders, userHeaders) => { - var val = reqHeaders["HeaderFromClient"]; + var val = reqHeaders["RequestForID"]; if (!val.IsNullOrEmpty ()) - userHeaders[val] = "Hello From Server"; + userHeaders[val] = s.ID; }; } ); From 41cc7336e75932314bd97359cc747626a7eea6e0 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 17 Sep 2025 22:00:12 +0900 Subject: [PATCH 6207/6294] [Modify] Edit it --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 984507ea4..46d651ce4 100644 --- a/README.md +++ b/README.md @@ -522,19 +522,19 @@ As a WebSocket client, if you would like to send the query string in the handsha var ws = new WebSocket ("ws://example.com/?name=nobita"); ``` -And if you would like to send the Origin header in the handshake request, you should set the `WebSocket.Origin` property to an allowable value as the [Origin] header before calling the connect method. +If you would like to send the Origin header in the handshake request, you should set the `WebSocket.Origin` property to an allowable value as the [Origin] header before calling the connect method. ```csharp ws.Origin = "http://example.com/"; ``` -And if you would like to send cookies in the handshake request, you should set any cookie by using the `WebSocket.SetCookie (WebSocketSharp.Net.Cookie)` method before calling the connect method. +If you would like to send cookies in the handshake request, you should set any cookie by using the `WebSocket.SetCookie (WebSocketSharp.Net.Cookie)` method before calling the connect method. ```csharp ws.SetCookie (new Cookie ("name", "nobita")); ``` -And also if you would like to send user headers in the handshake request, you should set any user defined header by using the `WebSocket.SetUserHeader (string, string)` method before calling the connect method. +And if you would like to send user headers in the handshake request, you should set any user defined header by using the `WebSocket.SetUserHeader (string, string)` method before calling the connect method. ```csharp ws.SetUserHeader ("RequestForID", "ID"); From e87081b73cb919891f34f65642789d85c7e73892 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 18 Sep 2025 22:34:18 +0900 Subject: [PATCH 6208/6294] [Modify] Edit it --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 46d651ce4..b877ca532 100644 --- a/README.md +++ b/README.md @@ -557,7 +557,7 @@ public class Chat : WebSocketBehavior } ``` -And if you would like to validate the Origin header, you should set a validation for it with your `WebSocketBehavior`, for example, by using the `WebSocketServer.AddWebSocketService (string, Action)` method with initializing, such as the following. +If you would like to validate the Origin header, you should set a validation for it with your `WebSocketBehavior`, for example, by using the `WebSocketServer.AddWebSocketService (string, Action)` method with initializing, such as the following. ```csharp wssv.AddWebSocketService ( @@ -577,7 +577,7 @@ wssv.AddWebSocketService ( ); ``` -And also if you would like to respond to the cookies, user headers, or both, you should set each response action for it with your `WebSocketBehavior`, for example, by using the `WebSocketServer.AddWebSocketService (string, Action)` method with initializing, such as the following. +And if you would like to respond to the cookies, user headers, or both, you should set each response action for it with your `WebSocketBehavior`, for example, by using the `WebSocketServer.AddWebSocketService (string, Action)` method with initializing, such as the following. ```csharp wssv.AddWebSocketService ( From f4aacd4a4eeaec4f85c39d353a65402a76a5157a Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 19 Sep 2025 22:31:16 +0900 Subject: [PATCH 6209/6294] [Modify] Edit it --- README.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index b877ca532..676b2b870 100644 --- a/README.md +++ b/README.md @@ -534,12 +534,18 @@ If you would like to send cookies in the handshake request, you should set any c ws.SetCookie (new Cookie ("name", "nobita")); ``` -And if you would like to send user headers in the handshake request, you should set any user defined header by using the `WebSocket.SetUserHeader (string, string)` method before calling the connect method. +If you would like to send user headers in the handshake request, you should set any user defined header by using the `WebSocket.SetUserHeader (string, string)` method before calling the connect method. ```csharp ws.SetUserHeader ("RequestForID", "ID"); ``` +And if you would like to get user headers included in the handshake response, you should access the `WebSocket.HandshakeResponseHeaders` property after the handshake is done. + +```csharp +var id = ws.HandshakeResponseHeaders["ID"]; +``` + As a WebSocket server, if you would like to get the query string included in a handshake request, you should access the `WebSocketBehavior.QueryString` property, such as the following. ```csharp From 438168880a99a3e8fc92bb617129e3eb70bd9381 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 20 Sep 2025 16:45:35 +0900 Subject: [PATCH 6210/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 1d567baf5..74ca65cd5 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -91,7 +91,7 @@ protected WebSocketBehavior () protected NameValueCollection Headers { get { if (_context == null) { - var msg = "The get operation is not available."; + var msg = "The session has not started yet."; throw new InvalidOperationException (msg); } From 01db844c5dec72cb9f5cf0184826ff4445c43939 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 21 Sep 2025 16:51:31 +0900 Subject: [PATCH 6211/6294] [Modify] Replace it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 74ca65cd5..5aacf4468 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -90,7 +90,7 @@ protected WebSocketBehavior () /// protected NameValueCollection Headers { get { - if (_context == null) { + if (!_registered) { var msg = "The session has not started yet."; throw new InvalidOperationException (msg); From 7436c3920d8598d57e311659c3433c4e1d4e918f Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 22 Sep 2025 21:13:03 +0900 Subject: [PATCH 6212/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 5aacf4468..a15c28fcd 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -113,7 +113,7 @@ protected NameValueCollection Headers { protected bool IsAlive { get { if (_websocket == null) { - var msg = "The get operation is not available."; + var msg = "The session has not started yet."; throw new InvalidOperationException (msg); } From 8185e2bace4d317067551610f523731a6139a098 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 22 Sep 2025 21:15:43 +0900 Subject: [PATCH 6213/6294] [Modify] Replace it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index a15c28fcd..233406392 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -112,7 +112,7 @@ protected NameValueCollection Headers { /// protected bool IsAlive { get { - if (_websocket == null) { + if (!_registered) { var msg = "The session has not started yet."; throw new InvalidOperationException (msg); From c54eb1d7e493a595e2e8f85102f041548c9b8487 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 23 Sep 2025 17:03:18 +0900 Subject: [PATCH 6214/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 233406392..fa7ccbed4 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -140,7 +140,7 @@ protected bool IsAlive { protected NameValueCollection QueryString { get { if (_context == null) { - var msg = "The get operation is not available."; + var msg = "The session has not started yet."; throw new InvalidOperationException (msg); } From 7aa9131c9e578a9aa629105bf81c7c107dc0d975 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 23 Sep 2025 17:05:17 +0900 Subject: [PATCH 6215/6294] [Modify] Replace it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index fa7ccbed4..edfe561ab 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -139,7 +139,7 @@ protected bool IsAlive { /// protected NameValueCollection QueryString { get { - if (_context == null) { + if (!_registered) { var msg = "The session has not started yet."; throw new InvalidOperationException (msg); From 7f409245996eced9d11969c1b933b4113ed2e0a7 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 24 Sep 2025 21:56:05 +0900 Subject: [PATCH 6216/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index edfe561ab..3536a1432 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -166,7 +166,7 @@ protected NameValueCollection QueryString { protected WebSocketState ReadyState { get { if (_websocket == null) { - var msg = "The get operation is not available."; + var msg = "The session has not started yet."; throw new InvalidOperationException (msg); } From 246b1500b65aa6363d595e82b45481f37f4f1b13 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 24 Sep 2025 21:58:59 +0900 Subject: [PATCH 6217/6294] [Modify] Replace it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 3536a1432..6e4adf7b1 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -165,7 +165,7 @@ protected NameValueCollection QueryString { /// protected WebSocketState ReadyState { get { - if (_websocket == null) { + if (!_registered) { var msg = "The session has not started yet."; throw new InvalidOperationException (msg); From f02f7195344273ee7db71eff5e1c58d2dbf5c90e Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 25 Sep 2025 16:34:20 +0900 Subject: [PATCH 6218/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 6e4adf7b1..19376656b 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -188,7 +188,7 @@ protected WebSocketState ReadyState { protected WebSocketSessionManager Sessions { get { if (_sessions == null) { - var msg = "The get operation is not available."; + var msg = "The session has not started yet."; throw new InvalidOperationException (msg); } From 50dea0d6d22313b62b12953e35db6f39d5546186 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 25 Sep 2025 16:36:13 +0900 Subject: [PATCH 6219/6294] [Modify] Replace it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 19376656b..99f48cece 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -187,7 +187,7 @@ protected WebSocketState ReadyState { /// protected WebSocketSessionManager Sessions { get { - if (_sessions == null) { + if (!_registered) { var msg = "The session has not started yet."; throw new InvalidOperationException (msg); From 2878f512b0c482c5871edc22869398e756b08c1a Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 26 Sep 2025 16:56:37 +0900 Subject: [PATCH 6220/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 99f48cece..874ae2be9 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -215,7 +215,7 @@ protected WebSocketSessionManager Sessions { protected IPrincipal User { get { if (_context == null) { - var msg = "The get operation is not available."; + var msg = "The session has not started yet."; throw new InvalidOperationException (msg); } From 17821e72461c99f5d44544fe4a6b348020c8c81b Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 26 Sep 2025 16:59:03 +0900 Subject: [PATCH 6221/6294] [Modify] Replace it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 874ae2be9..105ef53be 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -214,7 +214,7 @@ protected WebSocketSessionManager Sessions { /// protected IPrincipal User { get { - if (_context == null) { + if (!_registered) { var msg = "The session has not started yet."; throw new InvalidOperationException (msg); From 3d22a20c8721f40685cf620a7b1dc4c3c3f31e49 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 27 Sep 2025 21:32:55 +0900 Subject: [PATCH 6222/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 105ef53be..b884945ce 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -237,7 +237,7 @@ protected IPrincipal User { protected System.Net.IPEndPoint UserEndPoint { get { if (_context == null) { - var msg = "The get operation is not available."; + var msg = "The session has not started yet."; throw new InvalidOperationException (msg); } From 90a70d4884aaee1eb797a8eba33f84514d4092b7 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 27 Sep 2025 21:34:46 +0900 Subject: [PATCH 6223/6294] [Modify] Replace it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index b884945ce..746a09fbc 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -236,7 +236,7 @@ protected IPrincipal User { /// protected System.Net.IPEndPoint UserEndPoint { get { - if (_context == null) { + if (!_registered) { var msg = "The session has not started yet."; throw new InvalidOperationException (msg); From cd538ef113988d380053f1e93150e792e5581790 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 28 Sep 2025 16:50:29 +0900 Subject: [PATCH 6224/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 746a09fbc..93f945bb4 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -287,7 +287,7 @@ public Action CookiesResponder { set { if (_websocket != null) { - var msg = "The set operation is not available."; + var msg = "The session has already started."; throw new InvalidOperationException (msg); } From e54349ba6ccfaa32fce0c34a4da91b8ceaf9d6fc Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 28 Sep 2025 16:52:29 +0900 Subject: [PATCH 6225/6294] [Modify] Replace it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 93f945bb4..e1710a03f 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -286,7 +286,7 @@ public Action CookiesResponder { } set { - if (_websocket != null) { + if (_registered) { var msg = "The session has already started."; throw new InvalidOperationException (msg); From a8903fa8918dc97fc44816210716c7bfb0b11cd9 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 29 Sep 2025 16:46:59 +0900 Subject: [PATCH 6226/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index e1710a03f..423535d5e 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -319,7 +319,7 @@ public bool EmitOnPing { set { if (_websocket != null) { - var msg = "The set operation is not available."; + var msg = "The session has already started."; throw new InvalidOperationException (msg); } From 1b1b80339b6e6bc6592edaf669063bb1d754a991 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 29 Sep 2025 16:49:25 +0900 Subject: [PATCH 6227/6294] [Modify] Replace it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 423535d5e..990075e40 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -318,7 +318,7 @@ public bool EmitOnPing { } set { - if (_websocket != null) { + if (_registered) { var msg = "The session has already started."; throw new InvalidOperationException (msg); From e50eea470919e1c3aa1d82f342da41fcd725ecac Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 30 Sep 2025 21:26:32 +0900 Subject: [PATCH 6228/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 990075e40..40ac7dc48 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -364,7 +364,7 @@ public Func HostValidator { set { if (_websocket != null) { - var msg = "The set operation is not available."; + var msg = "The session has already started."; throw new InvalidOperationException (msg); } From e075be04f18a4d0c62e4b0c01f58892f00b27345 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 30 Sep 2025 21:31:02 +0900 Subject: [PATCH 6229/6294] [Modify] Replace it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 40ac7dc48..3c4a5a039 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -363,7 +363,7 @@ public Func HostValidator { } set { - if (_websocket != null) { + if (_registered) { var msg = "The session has already started."; throw new InvalidOperationException (msg); From d54d390d5ba517727b7c702c7a05ddba1632fc7f Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 1 Oct 2025 21:38:58 +0900 Subject: [PATCH 6230/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 3c4a5a039..049a8ac76 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -411,7 +411,7 @@ public bool IgnoreExtensions { set { if (_websocket != null) { - var msg = "The set operation is not available."; + var msg = "The session has already started."; throw new InvalidOperationException (msg); } From 39b95664cfca16bd4296bc0f57ea7bcaae196e79 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 1 Oct 2025 21:40:46 +0900 Subject: [PATCH 6231/6294] [Modify] Replace it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 049a8ac76..e5e535e35 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -410,7 +410,7 @@ public bool IgnoreExtensions { } set { - if (_websocket != null) { + if (_registered) { var msg = "The session has already started."; throw new InvalidOperationException (msg); From 36ee982be2abeb7fe73eded572eebafacd624427 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 2 Oct 2025 21:56:20 +0900 Subject: [PATCH 6232/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index e5e535e35..7a6e65d9e 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -444,7 +444,7 @@ public bool NoDelay { set { if (_websocket != null) { - var msg = "The set operation is not available."; + var msg = "The session has already started."; throw new InvalidOperationException (msg); } From 4c8a3130434ec4189003c39b778108d1feb88a79 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 2 Oct 2025 21:57:21 +0900 Subject: [PATCH 6233/6294] [Modify] Replace it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 7a6e65d9e..8ba3bba00 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -443,7 +443,7 @@ public bool NoDelay { } set { - if (_websocket != null) { + if (_registered) { var msg = "The session has already started."; throw new InvalidOperationException (msg); From 4ae8baef9eb3744500363ffbc9f062c5b54d66c2 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 3 Oct 2025 22:17:44 +0900 Subject: [PATCH 6234/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 8ba3bba00..23d8c4691 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -490,7 +490,7 @@ public Func OriginValidator { set { if (_websocket != null) { - var msg = "The set operation is not available."; + var msg = "The session has already started."; throw new InvalidOperationException (msg); } From 908192796a29b70e609277925d7a2fcf79cf15e0 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 3 Oct 2025 22:19:04 +0900 Subject: [PATCH 6235/6294] [Modify] Replace it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 23d8c4691..37f60fe5c 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -489,7 +489,7 @@ public Func OriginValidator { } set { - if (_websocket != null) { + if (_registered) { var msg = "The session has already started."; throw new InvalidOperationException (msg); From a8051a62f5f4ba030e63a3ca25256aca3f556951 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 4 Oct 2025 16:48:55 +0900 Subject: [PATCH 6236/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 37f60fe5c..4c3e2e818 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -533,7 +533,7 @@ public string Protocol { set { if (_websocket != null) { - var msg = "The set operation is not available."; + var msg = "The session has already started."; throw new InvalidOperationException (msg); } From 716d53be40decb0ac78061419bab3eca8c422a79 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 4 Oct 2025 16:51:17 +0900 Subject: [PATCH 6237/6294] [Modify] Replace it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 4c3e2e818..34c397395 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -532,7 +532,7 @@ public string Protocol { } set { - if (_websocket != null) { + if (_registered) { var msg = "The session has already started."; throw new InvalidOperationException (msg); From 333fbcd53a7ac2d1f63e93e6dc50fbd769d8af31 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 5 Oct 2025 15:33:02 +0900 Subject: [PATCH 6238/6294] [Modify] Replace it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 34c397395..8d5edf391 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -538,7 +538,7 @@ public string Protocol { throw new InvalidOperationException (msg); } - if (value == null || value.Length == 0) { + if (value.IsNullOrEmpty ()) { _protocol = null; return; From 0ef3265bb2b85595036e633e757edeae8e2831f5 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 6 Oct 2025 22:14:40 +0900 Subject: [PATCH 6239/6294] [Modify] Replace it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 8d5edf391..0f2475388 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -526,7 +526,7 @@ public Func OriginValidator { /// public string Protocol { get { - return _websocket != null + return _registered ? _websocket.Protocol : (_protocol ?? String.Empty); } From b951cb9f0d17beffd3e7efdba7606f25cd5b9b40 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 7 Oct 2025 22:04:56 +0900 Subject: [PATCH 6240/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 0f2475388..2a82f5ed1 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -609,7 +609,7 @@ public Action UserHeadersResponder { set { if (_websocket != null) { - var msg = "The set operation is not available."; + var msg = "The session has already started."; throw new InvalidOperationException (msg); } From 876cce2edc8cd88be63767934969b2ffd17ac5fc Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 7 Oct 2025 22:06:33 +0900 Subject: [PATCH 6241/6294] [Modify] Replace it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 2a82f5ed1..43c109ce9 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -608,7 +608,7 @@ public Action UserHeadersResponder { } set { - if (_websocket != null) { + if (_registered) { var msg = "The session has already started."; throw new InvalidOperationException (msg); From e377a193737321e80fa72dba2bcad0aedff08723 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 8 Oct 2025 22:00:05 +0900 Subject: [PATCH 6242/6294] [Modify] Edit it --- README.md | 73 ++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 45 insertions(+), 28 deletions(-) diff --git a/README.md b/README.md index 676b2b870..35f94d454 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ websocket-sharp supports: - [Per-message Compression](#per-message-compression) extension - [Secure Connection](#secure-connection) - [HTTP Authentication](#http-authentication) -- [Query string, Origin header, Cookies, and user headers](#query-string-origin-header-cookies-and-user-headers) +- [Query string, Origin header, Cookies, and User headers](#query-string-origin-header-cookies-and-user-headers) - [Connecting through the HTTP proxy server](#connecting-through-the-http-proxy-server) - .NET Framework **3.5** or later versions of .NET Framework (includes compatible environment such as [Mono]) @@ -514,7 +514,9 @@ If you would like to provide the Digest authentication, you should set such as t wssv.AuthenticationSchemes = AuthenticationSchemes.Digest; ``` -### Query string, Origin header, Cookies, and user headers ### +### Query string, Origin header, Cookies, and User headers ### + +#### Query string #### As a WebSocket client, if you would like to send the query string in the handshake request, you should create a new instance of the `WebSocket` class with a WebSocket URL that includes the [Query] string parameters. @@ -522,30 +524,6 @@ As a WebSocket client, if you would like to send the query string in the handsha var ws = new WebSocket ("ws://example.com/?name=nobita"); ``` -If you would like to send the Origin header in the handshake request, you should set the `WebSocket.Origin` property to an allowable value as the [Origin] header before calling the connect method. - -```csharp -ws.Origin = "http://example.com/"; -``` - -If you would like to send cookies in the handshake request, you should set any cookie by using the `WebSocket.SetCookie (WebSocketSharp.Net.Cookie)` method before calling the connect method. - -```csharp -ws.SetCookie (new Cookie ("name", "nobita")); -``` - -If you would like to send user headers in the handshake request, you should set any user defined header by using the `WebSocket.SetUserHeader (string, string)` method before calling the connect method. - -```csharp -ws.SetUserHeader ("RequestForID", "ID"); -``` - -And if you would like to get user headers included in the handshake response, you should access the `WebSocket.HandshakeResponseHeaders` property after the handshake is done. - -```csharp -var id = ws.HandshakeResponseHeaders["ID"]; -``` - As a WebSocket server, if you would like to get the query string included in a handshake request, you should access the `WebSocketBehavior.QueryString` property, such as the following. ```csharp @@ -563,7 +541,15 @@ public class Chat : WebSocketBehavior } ``` -If you would like to validate the Origin header, you should set a validation for it with your `WebSocketBehavior`, for example, by using the `WebSocketServer.AddWebSocketService (string, Action)` method with initializing, such as the following. +#### Origin header #### + +As a WebSocket client, if you would like to send the Origin header in the handshake request, you should set the `WebSocket.Origin` property to an allowable value as the [Origin] header before calling the connect method. + +```csharp +ws.Origin = "http://example.com/"; +``` + +As a WebSocket server, if you would like to validate the Origin header, you should set a validation for it with your `WebSocketBehavior`, for example, by using the `WebSocketServer.AddWebSocketService (string, Action)` method with initializing, such as the following. ```csharp wssv.AddWebSocketService ( @@ -583,7 +569,15 @@ wssv.AddWebSocketService ( ); ``` -And if you would like to respond to the cookies, user headers, or both, you should set each response action for it with your `WebSocketBehavior`, for example, by using the `WebSocketServer.AddWebSocketService (string, Action)` method with initializing, such as the following. +#### Cookies #### + +As a WebSocket client, if you would like to send the cookies in the handshake request, you should set any cookie by using the `WebSocket.SetCookie (WebSocketSharp.Net.Cookie)` method before calling the connect method. + +```csharp +ws.SetCookie (new Cookie ("name", "nobita")); +``` + +As a WebSocket server, if you would like to respond to the cookies, you should set a response action for it with your `WebSocketBehavior`, for example, by using the `WebSocketServer.AddWebSocketService (string, Action)` method with initializing, such as the following. ```csharp wssv.AddWebSocketService ( @@ -597,7 +591,30 @@ wssv.AddWebSocketService ( resCookies.Add (cookie); } }; + } +); +``` + +#### User headers #### + +As a WebSocket client, if you would like to send the user headers in the handshake request, you should set any user defined header by using the `WebSocket.SetUserHeader (string, string)` method before calling the connect method. + +```csharp +ws.SetUserHeader ("RequestForID", "ID"); +``` + +And if you would like to get the user headers included in the handshake response, you should access the `WebSocket.HandshakeResponseHeaders` property after the handshake is done. +```csharp +var id = ws.HandshakeResponseHeaders["ID"]; +``` + +As a WebSocket server, if you would like to respond to the user headers, you should set a response action for it with your `WebSocketBehavior`, for example, by using the `WebSocketServer.AddWebSocketService (string, Action)` method with initializing, such as the following. + +```csharp +wssv.AddWebSocketService ( + "/Chat", + s => { s.UserHeadersResponder = (reqHeaders, userHeaders) => { var val = reqHeaders["RequestForID"]; From f11d22efa2661f5e8ee1330174cfe9c84a39c674 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 9 Oct 2025 16:41:28 +0900 Subject: [PATCH 6243/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 43c109ce9..01d2fae0c 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -753,7 +753,7 @@ WebSocketSessionManager sessions protected void Close () { if (_websocket == null) { - var msg = "The Close method is not available."; + var msg = "The session has not started yet."; throw new InvalidOperationException (msg); } From 8c1c912ee5b69c4031a4e5d43dcf55c7dcb55785 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 9 Oct 2025 16:43:14 +0900 Subject: [PATCH 6244/6294] [Modify] Replace it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 01d2fae0c..b546e04a1 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -752,7 +752,7 @@ WebSocketSessionManager sessions /// protected void Close () { - if (_websocket == null) { + if (!_registered) { var msg = "The session has not started yet."; throw new InvalidOperationException (msg); From 82fff9907362ce1faf31922d2bf1950710d26f5d Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 10 Oct 2025 16:24:04 +0900 Subject: [PATCH 6245/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index b546e04a1..bbac22939 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -748,7 +748,7 @@ WebSocketSessionManager sessions /// interface is Closing or Closed. /// /// - /// The Close method is not available when the session has not started yet. + /// This method is not available when the session has not started yet. /// protected void Close () { From 5cc5d25d80059ab997fa33c211e1449f23053e4f Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 11 Oct 2025 16:36:16 +0900 Subject: [PATCH 6246/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index bbac22939..650732516 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -823,7 +823,7 @@ protected void Close () protected void Close (ushort code, string reason) { if (_websocket == null) { - var msg = "The Close method is not available."; + var msg = "The session has not started yet."; throw new InvalidOperationException (msg); } From c322b9b87fa56a06a2e9064cc2c712b5d85060be Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 11 Oct 2025 16:38:22 +0900 Subject: [PATCH 6247/6294] [Modify] Replace it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 650732516..08ef0a479 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -822,7 +822,7 @@ protected void Close () /// protected void Close (ushort code, string reason) { - if (_websocket == null) { + if (!_registered) { var msg = "The session has not started yet."; throw new InvalidOperationException (msg); From 19665c0d4e8e8cc668ed2ff444e172a41d6e7653 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 12 Oct 2025 21:40:42 +0900 Subject: [PATCH 6248/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 08ef0a479..60f45da98 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -818,7 +818,7 @@ protected void Close () /// /// /// - /// The Close method is not available when the session has not started yet. + /// This method is not available when the session has not started yet. /// protected void Close (ushort code, string reason) { From 76f4888f97c18cfcaf67953fb7c6b3f410b54331 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 13 Oct 2025 16:48:58 +0900 Subject: [PATCH 6249/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 60f45da98..c6a06c246 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -888,7 +888,7 @@ protected void Close (ushort code, string reason) protected void Close (CloseStatusCode code, string reason) { if (_websocket == null) { - var msg = "The Close method is not available."; + var msg = "The session has not started yet."; throw new InvalidOperationException (msg); } From fd9a0f4a3a16fcceaa6109aee3c2a5c99b58b809 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 13 Oct 2025 16:49:59 +0900 Subject: [PATCH 6250/6294] [Modify] Replace it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index c6a06c246..5e47eff84 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -887,7 +887,7 @@ protected void Close (ushort code, string reason) /// protected void Close (CloseStatusCode code, string reason) { - if (_websocket == null) { + if (!_registered) { var msg = "The session has not started yet."; throw new InvalidOperationException (msg); From 60cdb9465a92cc57efd0afad7485e9b3ec07b13c Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 14 Oct 2025 16:53:11 +0900 Subject: [PATCH 6251/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 5e47eff84..5ea5fcb4d 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -883,7 +883,7 @@ protected void Close (ushort code, string reason) /// The size of is greater than 123 bytes. /// /// - /// The Close method is not available when the session has not started yet. + /// This method is not available when the session has not started yet. /// protected void Close (CloseStatusCode code, string reason) { From 0da7d1b5f63ced730177ad37ebe04ddde4572a5c Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 15 Oct 2025 22:32:09 +0900 Subject: [PATCH 6252/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 5ea5fcb4d..8be4f6236 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -915,7 +915,7 @@ protected void Close (CloseStatusCode code, string reason) protected void CloseAsync () { if (_websocket == null) { - var msg = "The CloseAsync method is not available."; + var msg = "The session has not started yet."; throw new InvalidOperationException (msg); } From 55b9e310ff9ef0e9f98036155482ae6965424f5c Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 15 Oct 2025 22:34:28 +0900 Subject: [PATCH 6253/6294] [Modify] Replace it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 8be4f6236..2a4d50963 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -914,7 +914,7 @@ protected void Close (CloseStatusCode code, string reason) /// protected void CloseAsync () { - if (_websocket == null) { + if (!_registered) { var msg = "The session has not started yet."; throw new InvalidOperationException (msg); From ea94741eea6dd9bbf6a5f02c7e00debe0cdbe411 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 16 Oct 2025 21:56:39 +0900 Subject: [PATCH 6254/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 2a4d50963..3a45031fe 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -909,8 +909,7 @@ protected void Close (CloseStatusCode code, string reason) /// /// /// - /// The CloseAsync method is not available when the session has not - /// started yet. + /// This method is not available when the session has not started yet. /// protected void CloseAsync () { From 2f9458c59716232a4e9818fe6737e50849ae2728 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 17 Oct 2025 22:18:59 +0900 Subject: [PATCH 6255/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 3a45031fe..3165b7220 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -990,7 +990,7 @@ protected void CloseAsync () protected void CloseAsync (ushort code, string reason) { if (_websocket == null) { - var msg = "The CloseAsync method is not available."; + var msg = "The session has not started yet."; throw new InvalidOperationException (msg); } From b88614adead8fa6c4476f27b217b7ca1ab350dea Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 17 Oct 2025 22:20:11 +0900 Subject: [PATCH 6256/6294] [Modify] Replace it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 3165b7220..3d62ed5d2 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -989,7 +989,7 @@ protected void CloseAsync () /// protected void CloseAsync (ushort code, string reason) { - if (_websocket == null) { + if (!_registered) { var msg = "The session has not started yet."; throw new InvalidOperationException (msg); From 9630074b355854625dd416692c20346edf5e3b06 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 18 Oct 2025 22:13:26 +0900 Subject: [PATCH 6257/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 3d62ed5d2..540275d48 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -984,8 +984,7 @@ protected void CloseAsync () /// /// /// - /// The CloseAsync method is not available when the session has not - /// started yet. + /// This method is not available when the session has not started yet. /// protected void CloseAsync (ushort code, string reason) { From e93b759a56819f02280ece19a5c285a3b57a83c0 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 19 Oct 2025 16:41:43 +0900 Subject: [PATCH 6258/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 540275d48..c4eb0ab3e 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -1060,7 +1060,7 @@ protected void CloseAsync (ushort code, string reason) protected void CloseAsync (CloseStatusCode code, string reason) { if (_websocket == null) { - var msg = "The CloseAsync method is not available."; + var msg = "The session has not started yet."; throw new InvalidOperationException (msg); } From 845421777b636c8328ba5b9e998c4790e00b2841 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 19 Oct 2025 16:42:59 +0900 Subject: [PATCH 6259/6294] [Modify] Replace it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index c4eb0ab3e..497b6f31f 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -1059,7 +1059,7 @@ protected void CloseAsync (ushort code, string reason) /// protected void CloseAsync (CloseStatusCode code, string reason) { - if (_websocket == null) { + if (!_registered) { var msg = "The session has not started yet."; throw new InvalidOperationException (msg); From 29773b20d3d7f6b52ef27d5c1f83f92c862aa460 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 20 Oct 2025 21:18:41 +0900 Subject: [PATCH 6260/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 497b6f31f..65cc2dff1 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -1054,8 +1054,7 @@ protected void CloseAsync (ushort code, string reason) /// The size of is greater than 123 bytes. /// /// - /// The CloseAsync method is not available when the session has not - /// started yet. + /// This method is not available when the session has not started yet. /// protected void CloseAsync (CloseStatusCode code, string reason) { From b5278d49ebdcb497a4cb2cbfb32b262631f7d68b Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 21 Oct 2025 21:09:10 +0900 Subject: [PATCH 6261/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 65cc2dff1..165b7c230 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -1120,7 +1120,7 @@ protected virtual void OnOpen () protected bool Ping () { if (_websocket == null) { - var msg = "The Ping method is not available."; + var msg = "The session has not started yet."; throw new InvalidOperationException (msg); } From 7b7ba8eef8bc969fb7e590f58db724d965fc3fe8 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 21 Oct 2025 21:10:34 +0900 Subject: [PATCH 6262/6294] [Modify] Replace it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 165b7c230..0d8f1023b 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -1119,7 +1119,7 @@ protected virtual void OnOpen () /// protected bool Ping () { - if (_websocket == null) { + if (!_registered) { var msg = "The session has not started yet."; throw new InvalidOperationException (msg); From 155d2777429785ed4cdc43e17865d122b840dc90 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 22 Oct 2025 16:10:09 +0900 Subject: [PATCH 6263/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 0d8f1023b..fed7d425e 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -1115,7 +1115,7 @@ protected virtual void OnOpen () /// received within a time; otherwise, false. /// /// - /// The Ping method is not available when the session has not started yet. + /// This method is not available when the session has not started yet. /// protected bool Ping () { From 01d4ac8146590569fe2d1341f53a32174bcffe43 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 23 Oct 2025 16:11:17 +0900 Subject: [PATCH 6264/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index fed7d425e..0005df48b 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -1093,8 +1093,8 @@ protected virtual void OnError (ErrorEventArgs e) /// Called when the WebSocket interface for a session receives a message. /// /// - /// A that represents the event data passed - /// from a event. + /// A that represents the message event + /// data passed from the interface. /// protected virtual void OnMessage (MessageEventArgs e) { From dde6beeccfc92bd8df76c1ea8f155732da8ccca9 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 24 Oct 2025 15:42:46 +0900 Subject: [PATCH 6265/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 0005df48b..278020192 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -1082,8 +1082,8 @@ protected virtual void OnClose (CloseEventArgs e) /// Called when the WebSocket interface for a session gets an error. /// /// - /// A that represents the event data passed - /// from a event. + /// A that represents the error event data + /// passed from the interface. /// protected virtual void OnError (ErrorEventArgs e) { From d143f287ff2dad2a162125c7bf379f24fdc0df50 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 25 Oct 2025 17:29:38 +0900 Subject: [PATCH 6266/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 278020192..4f1096732 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -1071,8 +1071,8 @@ protected void CloseAsync (CloseStatusCode code, string reason) /// Called when the WebSocket connection for a session has been closed. /// /// - /// A that represents the event data passed - /// from a event. + /// A that represents the close event data + /// passed from the WebSocket interface. /// protected virtual void OnClose (CloseEventArgs e) { From 820805dce3caf0213b3a9d985ce9f797ac95c2f1 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 25 Oct 2025 17:31:16 +0900 Subject: [PATCH 6267/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 4f1096732..7eeb14e11 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -1093,8 +1093,8 @@ protected virtual void OnError (ErrorEventArgs e) /// Called when the WebSocket interface for a session receives a message. /// /// - /// A that represents the message event - /// data passed from the interface. + /// A that represents the message event data + /// passed from the interface. /// protected virtual void OnMessage (MessageEventArgs e) { From eee95a8f894fa75ae50c56e5ad3babbf0204786c Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 26 Oct 2025 16:21:35 +0900 Subject: [PATCH 6268/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 7eeb14e11..60116f2a8 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -1155,7 +1155,7 @@ protected bool Ping () protected bool Ping (string message) { if (_websocket == null) { - var msg = "The Ping method is not available."; + var msg = "The session has not started yet."; throw new InvalidOperationException (msg); } From 874e86ac436a289ead1b9da2edb7db18057e7835 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 26 Oct 2025 16:22:46 +0900 Subject: [PATCH 6269/6294] [Modify] Replace it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 60116f2a8..08f0905ff 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -1154,7 +1154,7 @@ protected bool Ping () /// protected bool Ping (string message) { - if (_websocket == null) { + if (!_registered) { var msg = "The session has not started yet."; throw new InvalidOperationException (msg); From 8d4cbf41915f4ba78bd6ddf4297a17fb1c743f22 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 27 Oct 2025 16:41:46 +0900 Subject: [PATCH 6270/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 08f0905ff..795731617 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -1150,7 +1150,7 @@ protected bool Ping () /// The size of is greater than 125 bytes. /// /// - /// The Ping method is not available when the session has not started yet. + /// This method is not available when the session has not started yet. /// protected bool Ping (string message) { From 91647a41d1b9ef8ce9b7d0c303a876a8000ccfdd Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 28 Oct 2025 16:32:27 +0900 Subject: [PATCH 6271/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 795731617..1f7c4ab3a 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -1188,7 +1188,7 @@ protected bool Ping (string message) protected void Send (byte[] data) { if (_websocket == null) { - var msg = "The Send method is not available."; + var msg = "The session has not started yet."; throw new InvalidOperationException (msg); } From 3a5b8f05e62c526ed3d39e287f9cbc408e1b7657 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 28 Oct 2025 16:34:28 +0900 Subject: [PATCH 6272/6294] [Modify] Replace it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 1f7c4ab3a..67de0f59c 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -1187,7 +1187,7 @@ protected bool Ping (string message) /// protected void Send (byte[] data) { - if (_websocket == null) { + if (!_registered) { var msg = "The session has not started yet."; throw new InvalidOperationException (msg); From 502be0227f6d0ead8d093ed82baffab9843f2b45 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 29 Oct 2025 16:28:01 +0900 Subject: [PATCH 6273/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 67de0f59c..5f9071698 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -1174,15 +1174,14 @@ protected bool Ping (string message) /// /// /// - /// The Send method is not available when the session has not - /// started yet. + /// This method is not available when the session has not started yet. /// /// /// -or- /// /// - /// The Send method is not available when the current state of - /// the WebSocket interface is not Open. + /// This method is not available when the current state of the WebSocket + /// interface is not Open. /// /// protected void Send (byte[] data) From 5c7af5710904f3b2253f01665933c9eab3ad908a Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 30 Oct 2025 16:39:23 +0900 Subject: [PATCH 6274/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 5f9071698..0eef82ad4 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -1236,7 +1236,7 @@ protected void Send (byte[] data) protected void Send (FileInfo fileInfo) { if (_websocket == null) { - var msg = "The Send method is not available."; + var msg = "The session has not started yet."; throw new InvalidOperationException (msg); } From f911d2a4273eaf43d272c4602a52a315d3a30414 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 30 Oct 2025 16:40:23 +0900 Subject: [PATCH 6275/6294] [Modify] Replace it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 0eef82ad4..85c3b7e45 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -1235,7 +1235,7 @@ protected void Send (byte[] data) /// protected void Send (FileInfo fileInfo) { - if (_websocket == null) { + if (!_registered) { var msg = "The session has not started yet."; throw new InvalidOperationException (msg); From 8e08370cbe8f01bc721c23ec2ca65a3943e49e74 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 31 Oct 2025 16:41:18 +0900 Subject: [PATCH 6276/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 85c3b7e45..b320a8394 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -1222,15 +1222,14 @@ protected void Send (byte[] data) /// /// /// - /// The Send method is not available when the session has not - /// started yet. + /// This method is not available when the session has not started yet. /// /// /// -or- /// /// - /// The Send method is not available when the current state of - /// the WebSocket interface is not Open. + /// This method is not available when the current state of the WebSocket + /// interface is not Open. /// /// protected void Send (FileInfo fileInfo) From 85f2b50c409d8a201bdec2ec34b1523f9018126c Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 1 Nov 2025 22:05:46 +0900 Subject: [PATCH 6277/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index b320a8394..58640199c 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -1271,7 +1271,7 @@ protected void Send (FileInfo fileInfo) protected void Send (string data) { if (_websocket == null) { - var msg = "The Send method is not available."; + var msg = "The session has not started yet."; throw new InvalidOperationException (msg); } From 25bc6182537efd8f52b2c0027de5cf6960343f19 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 1 Nov 2025 22:07:51 +0900 Subject: [PATCH 6278/6294] [Modify] Replace it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 58640199c..924c5ab35 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -1270,7 +1270,7 @@ protected void Send (FileInfo fileInfo) /// protected void Send (string data) { - if (_websocket == null) { + if (!_registered) { var msg = "The session has not started yet."; throw new InvalidOperationException (msg); From b25d4778026289c2bf59ab65429bf84e99f23704 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 2 Nov 2025 16:38:29 +0900 Subject: [PATCH 6279/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 924c5ab35..cdc8d602b 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -1257,15 +1257,14 @@ protected void Send (FileInfo fileInfo) /// /// /// - /// The Send method is not available when the session has not - /// started yet. + /// This method is not available when the session has not started yet. /// /// /// -or- /// /// - /// The Send method is not available when the current state of - /// the WebSocket interface is not Open. + /// This method is not available when the current state of the WebSocket + /// interface is not Open. /// /// protected void Send (string data) From 3a555011aecae04ba689cbc15065cf5932a8e8d5 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 3 Nov 2025 22:10:38 +0900 Subject: [PATCH 6280/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index cdc8d602b..ce51ba799 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -1329,7 +1329,7 @@ protected void Send (string data) protected void Send (Stream stream, int length) { if (_websocket == null) { - var msg = "The Send method is not available."; + var msg = "The session has not started yet."; throw new InvalidOperationException (msg); } From 0d65a3b0e6e612f85256f443d4fbb32ebc39101f Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 3 Nov 2025 22:14:36 +0900 Subject: [PATCH 6281/6294] [Modify] Replace it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index ce51ba799..f558ab4fa 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -1328,7 +1328,7 @@ protected void Send (string data) /// protected void Send (Stream stream, int length) { - if (_websocket == null) { + if (!_registered) { var msg = "The session has not started yet."; throw new InvalidOperationException (msg); From 5008bf3f940652a447a7f122f27c9a8333cd87b6 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 4 Nov 2025 15:58:05 +0900 Subject: [PATCH 6282/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index f558ab4fa..e4990ae3a 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -1315,15 +1315,14 @@ protected void Send (string data) /// /// /// - /// The Send method is not available when the session has not - /// started yet. + /// This method is not available when the session has not started yet. /// /// /// -or- /// /// - /// The Send method is not available when the current state of - /// the WebSocket interface is not Open. + /// This method is not available when the current state of the WebSocket + /// interface is not Open. /// /// protected void Send (Stream stream, int length) From a99d6d2e43a9eeb891f68546e325b53a267d8d13 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 5 Nov 2025 22:50:09 +0900 Subject: [PATCH 6283/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index e4990ae3a..a971f52fc 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -1379,7 +1379,7 @@ protected void Send (Stream stream, int length) protected void SendAsync (byte[] data, Action completed) { if (_websocket == null) { - var msg = "The SendAsync method is not available."; + var msg = "The session has not started yet."; throw new InvalidOperationException (msg); } From ee6fa0db632d0b88ff9be30c30c76202ca40dcb4 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 5 Nov 2025 22:51:20 +0900 Subject: [PATCH 6284/6294] [Modify] Replace it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index a971f52fc..8b07a0fdf 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -1378,7 +1378,7 @@ protected void Send (Stream stream, int length) /// protected void SendAsync (byte[] data, Action completed) { - if (_websocket == null) { + if (!_registered) { var msg = "The session has not started yet."; throw new InvalidOperationException (msg); From 59ff8f51ff3ce17f2c209988c2ba0785ef73fdaf Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 6 Nov 2025 21:39:04 +0900 Subject: [PATCH 6285/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 8b07a0fdf..7d901156f 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -1365,15 +1365,14 @@ protected void Send (Stream stream, int length) ///
/// /// - /// The SendAsync method is not available when the session has not - /// started yet. + /// This method is not available when the session has not started yet. /// /// /// -or- /// /// - /// The SendAsync method is not available when the current state of - /// the WebSocket interface is not Open. + /// This method is not available when the current state of the WebSocket + /// interface is not Open. /// /// protected void SendAsync (byte[] data, Action completed) From a0d86f2adf29726388c37590d911dd66735533a9 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 7 Nov 2025 22:12:12 +0900 Subject: [PATCH 6286/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 7d901156f..d5838e2f6 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -1445,7 +1445,7 @@ protected void SendAsync (byte[] data, Action completed) protected void SendAsync (FileInfo fileInfo, Action completed) { if (_websocket == null) { - var msg = "The SendAsync method is not available."; + var msg = "The session has not started yet."; throw new InvalidOperationException (msg); } From 994c7570c565ae0326ec76d1ea686a59ec88658b Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 7 Nov 2025 22:13:21 +0900 Subject: [PATCH 6287/6294] [Modify] Replace it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index d5838e2f6..7222d0971 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -1444,7 +1444,7 @@ protected void SendAsync (byte[] data, Action completed) ///
protected void SendAsync (FileInfo fileInfo, Action completed) { - if (_websocket == null) { + if (!_registered) { var msg = "The session has not started yet."; throw new InvalidOperationException (msg); From 4925566ee58a9d5ee68ea607c6318a10744d5a40 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 8 Nov 2025 15:53:08 +0900 Subject: [PATCH 6288/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 7222d0971..1b439751e 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -1431,15 +1431,14 @@ protected void SendAsync (byte[] data, Action completed) ///
/// /// - /// The SendAsync method is not available when the session has not - /// started yet. + /// This method is not available when the session has not started yet. /// /// /// -or- /// /// - /// The SendAsync method is not available when the current state of - /// the WebSocket interface is not Open. + /// This method is not available when the current state of the WebSocket + /// interface is not Open. /// /// protected void SendAsync (FileInfo fileInfo, Action completed) From 95ff92f34b77b8eef1a86373822a86cf0cfaef0b Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 9 Nov 2025 15:56:17 +0900 Subject: [PATCH 6289/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 1b439751e..ea83a4610 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -1498,7 +1498,7 @@ protected void SendAsync (FileInfo fileInfo, Action completed) protected void SendAsync (string data, Action completed) { if (_websocket == null) { - var msg = "The SendAsync method is not available."; + var msg = "The session has not started yet."; throw new InvalidOperationException (msg); } From 415008a2a1907139c699a165b228e27084f1df73 Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 9 Nov 2025 15:57:21 +0900 Subject: [PATCH 6290/6294] [Modify] Replace it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index ea83a4610..9cec81097 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -1497,7 +1497,7 @@ protected void SendAsync (FileInfo fileInfo, Action completed) ///
protected void SendAsync (string data, Action completed) { - if (_websocket == null) { + if (!_registered) { var msg = "The session has not started yet."; throw new InvalidOperationException (msg); From 705fbef576a2af389819f9a48d280f99f706fb2d Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 10 Nov 2025 16:50:10 +0900 Subject: [PATCH 6291/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 9cec81097..195c37651 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -1484,15 +1484,14 @@ protected void SendAsync (FileInfo fileInfo, Action completed) ///
/// /// - /// The SendAsync method is not available when the session has not - /// started yet. + /// This method is not available when the session has not started yet. /// /// /// -or- /// /// - /// The SendAsync method is not available when the current state of - /// the WebSocket interface is not Open. + /// This method is not available when the current state of the WebSocket + /// interface is not Open. /// /// protected void SendAsync (string data, Action completed) From 88b0f7afc5aff12deca51507200a914040df98f1 Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 11 Nov 2025 21:45:18 +0900 Subject: [PATCH 6292/6294] [Modify] Polish it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index 195c37651..f5e06ff98 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -1574,7 +1574,7 @@ protected void SendAsync (string data, Action completed) protected void SendAsync (Stream stream, int length, Action completed) { if (_websocket == null) { - var msg = "The SendAsync method is not available."; + var msg = "The session has not started yet."; throw new InvalidOperationException (msg); } From e0282fc7c70a41510d3fd4c6e5ef36431986eefe Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 11 Nov 2025 21:46:42 +0900 Subject: [PATCH 6293/6294] [Modify] Replace it --- websocket-sharp/Server/WebSocketBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index f5e06ff98..f5847415f 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -1573,7 +1573,7 @@ protected void SendAsync (string data, Action completed) ///
protected void SendAsync (Stream stream, int length, Action completed) { - if (_websocket == null) { + if (!_registered) { var msg = "The session has not started yet."; throw new InvalidOperationException (msg); From e7ef819a3d1bb7098ddb3a0440a43f19a9077b67 Mon Sep 17 00:00:00 2001 From: sta Date: Wed, 12 Nov 2025 22:14:03 +0900 Subject: [PATCH 6294/6294] [Modify] Edit it --- websocket-sharp/Server/WebSocketBehavior.cs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/Server/WebSocketBehavior.cs b/websocket-sharp/Server/WebSocketBehavior.cs index f5847415f..a0befe74d 100644 --- a/websocket-sharp/Server/WebSocketBehavior.cs +++ b/websocket-sharp/Server/WebSocketBehavior.cs @@ -1560,15 +1560,14 @@ protected void SendAsync (string data, Action completed) ///
/// /// - /// The SendAsync method is not available when the session has not - /// started yet. + /// This method is not available when the session has not started yet. /// /// /// -or- /// /// - /// The SendAsync method is not available when the current state of - /// the WebSocket interface is not Open. + /// This method is not available when the current state of the WebSocket + /// interface is not Open. /// /// protected void SendAsync (Stream stream, int length, Action completed)