From a0397a14d391dd8cc67b54b3b32bf3b5611c662e Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 6 Mar 2020 19:37:49 +0900 Subject: [PATCH 0001/2958] [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 0002/2958] [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 0003/2958] [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 0004/2958] [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 0005/2958] [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 0006/2958] [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 0007/2958] [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 0008/2958] [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 0009/2958] [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 0010/2958] [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 0011/2958] [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 0012/2958] [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 0013/2958] [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 0014/2958] [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 0015/2958] [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 0016/2958] [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 0017/2958] [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 0018/2958] [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 0019/2958] [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 0020/2958] [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 0021/2958] [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 0022/2958] [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 0023/2958] [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 0024/2958] [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 0025/2958] [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 0026/2958] [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 0027/2958] [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 0028/2958] [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 0029/2958] [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 0030/2958] [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 0031/2958] [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 0032/2958] [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 0033/2958] [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 0034/2958] [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 0035/2958] [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 0036/2958] [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 0037/2958] [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 0038/2958] [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 0039/2958] [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 0040/2958] [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 0041/2958] [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 0042/2958] [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 0043/2958] [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 0044/2958] [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 0045/2958] [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 0046/2958] [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 0047/2958] [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 0048/2958] [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 0049/2958] [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 0050/2958] [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 0051/2958] [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 0052/2958] [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 0053/2958] [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 0054/2958] [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 0055/2958] [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 0056/2958] [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 0057/2958] [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 0058/2958] [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 0059/2958] [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 0060/2958] [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 0061/2958] [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 0062/2958] [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 0063/2958] [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 0064/2958] [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 0065/2958] [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 0066/2958] [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 0067/2958] [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 0068/2958] [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 0069/2958] [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 0070/2958] [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 0071/2958] [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 0072/2958] [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 0073/2958] [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 0074/2958] [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 0075/2958] [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 0076/2958] [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 0077/2958] [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 0078/2958] [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 0079/2958] [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 0080/2958] [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 0081/2958] [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 0082/2958] [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 0083/2958] [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 0084/2958] [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 0085/2958] [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 0086/2958] [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 0087/2958] [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 0088/2958] [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 0089/2958] [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 0090/2958] [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 0091/2958] [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 0092/2958] [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 0093/2958] [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 0094/2958] [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 0095/2958] [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 0096/2958] [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 0097/2958] [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 0098/2958] [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 0099/2958] [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 0100/2958] [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 0101/2958] [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 0102/2958] [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 0103/2958] [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 0104/2958] [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 0105/2958] [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 0106/2958] [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 0107/2958] [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 0108/2958] [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 0109/2958] [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 0110/2958] [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 0111/2958] [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 0112/2958] [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 0113/2958] [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 0114/2958] [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 0115/2958] [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 0116/2958] [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 0117/2958] [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 0118/2958] [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 0119/2958] [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 0120/2958] [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 0121/2958] [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 0122/2958] [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 0123/2958] [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 0124/2958] [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 0125/2958] [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 0126/2958] [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 0127/2958] [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 0128/2958] [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 0129/2958] [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 0130/2958] [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 0131/2958] [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 0132/2958] [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 0133/2958] [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 0134/2958] [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 0135/2958] [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 0136/2958] [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 0137/2958] [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 0138/2958] [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 0139/2958] [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 0140/2958] [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 0141/2958] [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 0142/2958] [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 0143/2958] [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 0144/2958] [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 0145/2958] [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 0146/2958] [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 0147/2958] [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 0148/2958] [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 0149/2958] [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 0150/2958] [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 0151/2958] [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 0152/2958] [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 0153/2958] [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 0154/2958] [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 0155/2958] [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 0156/2958] [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 0157/2958] [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 0158/2958] [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 0159/2958] [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 0160/2958] [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 0161/2958] [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 0162/2958] [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 0163/2958] [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 0164/2958] [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 0165/2958] [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 0166/2958] [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 0167/2958] [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 0168/2958] [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 0169/2958] [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 0170/2958] [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 0171/2958] [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 0172/2958] [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 0173/2958] [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 0174/2958] [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 0175/2958] [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 0176/2958] [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 0177/2958] [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 0178/2958] [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 0179/2958] [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 0180/2958] [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 0181/2958] [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 0182/2958] [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 0183/2958] [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 0184/2958] [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 0185/2958] [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 0186/2958] [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 0187/2958] [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 0188/2958] [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 0189/2958] [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 0190/2958] [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 0191/2958] [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 0192/2958] [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 0193/2958] [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 0194/2958] [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 0195/2958] [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 0196/2958] [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 0197/2958] [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 0198/2958] [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 0199/2958] [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 0200/2958] [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 0201/2958] [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 0202/2958] [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 0203/2958] [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 0204/2958] [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 0205/2958] [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 0206/2958] [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 0207/2958] [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 0208/2958] [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 0209/2958] [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 0210/2958] [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 0211/2958] [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 0212/2958] [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 0213/2958] [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 0214/2958] [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 0215/2958] [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 0216/2958] [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 0217/2958] [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 0218/2958] [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 0219/2958] [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 0220/2958] [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 0221/2958] [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 0222/2958] [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 0223/2958] [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 0224/2958] [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 0225/2958] [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 0226/2958] [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 0227/2958] [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 0228/2958] [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 0229/2958] [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 0230/2958] [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 0231/2958] [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 0232/2958] [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 0233/2958] [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 0234/2958] [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 0235/2958] [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 0236/2958] [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 0237/2958] [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 0238/2958] [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 0239/2958] [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 0240/2958] [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 0241/2958] [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 0242/2958] [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 0243/2958] [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 0244/2958] [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 0245/2958] [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 0246/2958] [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 0247/2958] [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 0248/2958] [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 0249/2958] [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 0250/2958] [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 0251/2958] [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 0252/2958] [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 0253/2958] [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 0254/2958] [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 0255/2958] [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 0256/2958] [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 0257/2958] [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 0258/2958] [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 0259/2958] [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 0260/2958] [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 0261/2958] [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 0262/2958] [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 0263/2958] [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 0264/2958] [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 0265/2958] [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 0266/2958] [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 0267/2958] [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 0268/2958] [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 0269/2958] [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 0270/2958] [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 0271/2958] [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 0272/2958] [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 0273/2958] [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 0274/2958] [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 0275/2958] [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 0276/2958] [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 0277/2958] [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 0278/2958] [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 0279/2958] [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 0280/2958] [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 0281/2958] [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 0282/2958] [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 0283/2958] [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 0284/2958] [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 0285/2958] [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 0286/2958] [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 0287/2958] [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 0288/2958] [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 0289/2958] [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 0290/2958] [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 0291/2958] [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 0292/2958] [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 0293/2958] [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 0294/2958] [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 0295/2958] [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 0296/2958] [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 0297/2958] [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 0298/2958] [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 0299/2958] [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 0300/2958] [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 0301/2958] [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 0302/2958] [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 0303/2958] [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 0304/2958] [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 0305/2958] [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 0306/2958] [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 0307/2958] [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 0308/2958] [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 0309/2958] [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 0310/2958] [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 0311/2958] [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 0312/2958] [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 0313/2958] [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 0314/2958] [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 0315/2958] [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 0316/2958] [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 0317/2958] [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 0318/2958] [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 0319/2958] [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 0320/2958] [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 0321/2958] [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 0322/2958] [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 0323/2958] [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 0324/2958] [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 0325/2958] [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 0326/2958] [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 0327/2958] [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 0328/2958] [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 0329/2958] [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 0330/2958] [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 0331/2958] [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 0332/2958] [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 0333/2958] [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 0334/2958] [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 0335/2958] [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 0336/2958] [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 0337/2958] [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 0338/2958] [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 0339/2958] [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 0340/2958] [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 0341/2958] [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 0342/2958] [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 0343/2958] [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 0344/2958] [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 0345/2958] [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 0346/2958] [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 0347/2958] [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 0348/2958] [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 0349/2958] [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 0350/2958] [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 0351/2958] [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 0352/2958] [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 0353/2958] [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 0354/2958] [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 0355/2958] [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 0356/2958] [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 0357/2958] [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 0358/2958] [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 0359/2958] [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 0360/2958] [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 0361/2958] [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 0362/2958] [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 0363/2958] [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 0364/2958] [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 0365/2958] [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 0366/2958] [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 0367/2958] [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 0368/2958] [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 0369/2958] [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 0370/2958] [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 0371/2958] [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 0372/2958] [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 0373/2958] [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 0374/2958] [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 0375/2958] [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 0376/2958] [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 0377/2958] [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 0378/2958] [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 0379/2958] [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 0380/2958] [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 0381/2958] [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 0382/2958] [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 0383/2958] [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 0384/2958] [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 0385/2958] [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 0386/2958] [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 0387/2958] [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 0388/2958] [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 0389/2958] [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 0390/2958] [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 0391/2958] [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 0392/2958] [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 0393/2958] [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 0394/2958] [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 0395/2958] [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 0396/2958] [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 0397/2958] [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 0398/2958] [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 0399/2958] [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 0400/2958] [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 0401/2958] [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 0402/2958] [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 0403/2958] [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 0404/2958] [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 0405/2958] [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 0406/2958] [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 0407/2958] [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 0408/2958] [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 0409/2958] [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 0410/2958] [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 0411/2958] [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 0412/2958] [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 0413/2958] [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 0414/2958] [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 0415/2958] [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 0416/2958] [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 0417/2958] [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 0418/2958] [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 0419/2958] [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 0420/2958] [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 0421/2958] [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 0422/2958] [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 0423/2958] [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 0424/2958] [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 0425/2958] [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 0426/2958] [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 0427/2958] [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 0428/2958] [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 0429/2958] [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 0430/2958] [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 0431/2958] [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 0432/2958] [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 0433/2958] [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 0434/2958] [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 0435/2958] [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 0436/2958] [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 0437/2958] [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 0438/2958] [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 0439/2958] [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 0440/2958] [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 0441/2958] [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 0442/2958] [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 0443/2958] [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 0444/2958] [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 0445/2958] [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 0446/2958] [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 0447/2958] [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 0448/2958] [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 0449/2958] [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 0450/2958] [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 0451/2958] [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 0452/2958] [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 0453/2958] [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 0454/2958] [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 0455/2958] [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 0456/2958] [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 0457/2958] [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 0458/2958] [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 0459/2958] [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 0460/2958] [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 0461/2958] [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 0462/2958] [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 0463/2958] [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 0464/2958] [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 0465/2958] [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 0466/2958] [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 0467/2958] [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 0468/2958] [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 0469/2958] [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 0470/2958] [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 0471/2958] [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 0472/2958] [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 0473/2958] [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 0474/2958] [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 0475/2958] [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 0476/2958] [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 0477/2958] [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 0478/2958] [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 0479/2958] [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 0480/2958] [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 0481/2958] [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 0482/2958] [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 0483/2958] [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 0484/2958] [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 0485/2958] [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 0486/2958] [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 0487/2958] [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 0488/2958] [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 0489/2958] [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 0490/2958] [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 0491/2958] [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 0492/2958] [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 0493/2958] [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 0494/2958] [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 0495/2958] [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 0496/2958] [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 0497/2958] [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 0498/2958] [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 0499/2958] [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 0500/2958] [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 0501/2958] [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 0502/2958] [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 0503/2958] [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 0504/2958] [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 0505/2958] [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 0506/2958] [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 0507/2958] [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 0508/2958] [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 0509/2958] [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 0510/2958] [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 0511/2958] [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 0512/2958] [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 0513/2958] [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 0514/2958] [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 0515/2958] [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 0516/2958] [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 0517/2958] [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 0518/2958] [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 0519/2958] [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 0520/2958] [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 0521/2958] [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 0522/2958] [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 0523/2958] [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 0524/2958] [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 0525/2958] [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 0526/2958] [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 0527/2958] [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 0528/2958] [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 0529/2958] [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 0530/2958] [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 0531/2958] [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 0532/2958] [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 0533/2958] [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 0534/2958] [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 0535/2958] [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 0536/2958] [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 0537/2958] [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 0538/2958] [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 0539/2958] [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 0540/2958] [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 0541/2958] [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 0542/2958] [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 0543/2958] [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 0544/2958] [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 0545/2958] [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 0546/2958] [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 0547/2958] [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 0548/2958] [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 0549/2958] [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 0550/2958] [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 0551/2958] [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 0552/2958] [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 0553/2958] [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 0554/2958] [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 0555/2958] [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 0556/2958] [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 0557/2958] [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 0558/2958] [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 0559/2958] [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 0560/2958] [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 0561/2958] [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 0562/2958] [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 0563/2958] [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 0564/2958] [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 0565/2958] [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 0566/2958] [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 0567/2958] [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 0568/2958] [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 0569/2958] [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 0570/2958] [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 0571/2958] [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 0572/2958] [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 0573/2958] [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 0574/2958] [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 0575/2958] [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 0576/2958] [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 0577/2958] [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 0578/2958] [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 0579/2958] [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 0580/2958] [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 0581/2958] [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 0582/2958] [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 0583/2958] [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 0584/2958] [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 0585/2958] [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 0586/2958] [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 0587/2958] [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 0588/2958] [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 0589/2958] [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 0590/2958] [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 0591/2958] [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 0592/2958] [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 0593/2958] [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 0594/2958] [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 0595/2958] [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 0596/2958] [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 0597/2958] [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 0598/2958] [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 0599/2958] [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 0600/2958] [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 0601/2958] [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 0602/2958] [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 0603/2958] [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 0604/2958] [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 0605/2958] [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 0606/2958] [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 0607/2958] [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 0608/2958] [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 0609/2958] [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 0610/2958] [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 0611/2958] [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 0612/2958] [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 0613/2958] [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 0614/2958] [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 0615/2958] [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 0616/2958] [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 0617/2958] [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 0618/2958] [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 0619/2958] [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 0620/2958] [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 0621/2958] [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 0622/2958] [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 0623/2958] [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 0624/2958] [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 0625/2958] [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 0626/2958] [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 0627/2958] [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 0628/2958] [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 0629/2958] [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 0630/2958] [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 0631/2958] [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 0632/2958] [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 0633/2958] [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 0634/2958] [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 0635/2958] [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 0636/2958] [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 0637/2958] [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 0638/2958] [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 0639/2958] [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 0640/2958] [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 0641/2958] [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 0642/2958] [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 0643/2958] [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 0644/2958] [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 0645/2958] [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 0646/2958] [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 0647/2958] [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 0648/2958] [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 0649/2958] [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 0650/2958] [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 0651/2958] [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 0652/2958] [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 0653/2958] [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 0654/2958] [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 0655/2958] [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 0656/2958] [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 0657/2958] [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 0658/2958] [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 0659/2958] [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 0660/2958] [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 0661/2958] [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 0662/2958] [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 0663/2958] [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 0664/2958] [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 0665/2958] [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 0666/2958] [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 0667/2958] [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 0668/2958] [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 0669/2958] [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 0670/2958] [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 0671/2958] [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 0672/2958] [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 0673/2958] [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 0674/2958] [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 0675/2958] [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 0676/2958] [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 0677/2958] [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 0678/2958] [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 0679/2958] [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 0680/2958] [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 0681/2958] [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 0682/2958] [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 0683/2958] [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 0684/2958] [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 0685/2958] [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 0686/2958] [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 0687/2958] [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 0688/2958] [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 0689/2958] [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 0690/2958] [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 0691/2958] [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 0692/2958] [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 0693/2958] [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 0694/2958] [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 0695/2958] [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 0696/2958] [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 0697/2958] [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 0698/2958] [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 0699/2958] [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 0700/2958] [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 0701/2958] [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 0702/2958] [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 0703/2958] [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 0704/2958] [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 0705/2958] [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 0706/2958] [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 0707/2958] [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 0708/2958] [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 0709/2958] [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 0710/2958] [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 0711/2958] [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 0712/2958] [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 0713/2958] [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 0714/2958] [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 0715/2958] [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 0716/2958] [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 0717/2958] [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 0718/2958] [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 0719/2958] [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 0720/2958] [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 0721/2958] [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 0722/2958] [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 0723/2958] [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 0724/2958] [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 0725/2958] [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 0726/2958] [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 0727/2958] [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 0728/2958] [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 0729/2958] [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 0730/2958] [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 0731/2958] [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 0732/2958] [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 0733/2958] [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 0734/2958] [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 0735/2958] [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 0736/2958] [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 0737/2958] [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 0738/2958] [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 0739/2958] [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 0740/2958] [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 0741/2958] [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 0742/2958] [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 0743/2958] [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 0744/2958] [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 0745/2958] [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 0746/2958] [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 0747/2958] [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 0748/2958] [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 0749/2958] [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 0750/2958] [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 0751/2958] [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 0752/2958] [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 0753/2958] [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 0754/2958] [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 0755/2958] [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 0756/2958] [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 0757/2958] [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 0758/2958] [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 0759/2958] [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 0760/2958] [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 0761/2958] [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 0762/2958] [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 0763/2958] [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 0764/2958] [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 0765/2958] [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 0766/2958] [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 0767/2958] [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 0768/2958] [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 0769/2958] [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 0770/2958] [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 0771/2958] [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 0772/2958] [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 0773/2958] [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 0774/2958] [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 0775/2958] [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 0776/2958] [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 0777/2958] [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 0778/2958] [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 0779/2958] [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 0780/2958] [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 0781/2958] [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 0782/2958] [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 0783/2958] [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 0784/2958] [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 0785/2958] [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 0786/2958] [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 0787/2958] [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 0788/2958] [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 0789/2958] [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 0790/2958] [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 0791/2958] [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 0792/2958] [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 0793/2958] [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 0794/2958] [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 0795/2958] [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 0796/2958] [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 0797/2958] [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 0798/2958] [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 0799/2958] [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 0800/2958] [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 0801/2958] [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 0802/2958] [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 0803/2958] [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 0804/2958] [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 0805/2958] [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 0806/2958] [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 0807/2958] [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 0808/2958] [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 0809/2958] [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 0810/2958] [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 0811/2958] [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 0812/2958] [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 0813/2958] [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 0814/2958] [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 0815/2958] [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 0816/2958] [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 0817/2958] [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 0818/2958] [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 0819/2958] [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 0820/2958] [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 0821/2958] [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 0822/2958] [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 0823/2958] [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 0824/2958] [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 0825/2958] [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 0826/2958] [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 0827/2958] [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 0828/2958] [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 0829/2958] [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 0830/2958] [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 0831/2958] [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 0832/2958] [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 0833/2958] [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 0834/2958] [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 0835/2958] [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 0836/2958] [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 0837/2958] [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 0838/2958] [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 0839/2958] [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 0840/2958] [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 0841/2958] [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 0842/2958] [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 0843/2958] [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 0844/2958] [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 0845/2958] [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 0846/2958] [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 0847/2958] [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 0848/2958] [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 0849/2958] [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 0850/2958] [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 0851/2958] [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 0852/2958] [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 0853/2958] [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 0854/2958] [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 0855/2958] [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 0856/2958] [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 0857/2958] [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 0858/2958] [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 0859/2958] [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 0860/2958] [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 0861/2958] [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 0862/2958] [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 0863/2958] [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 0864/2958] [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 0865/2958] [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 0866/2958] [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 0867/2958] [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 0868/2958] [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 0869/2958] [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 0870/2958] [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 0871/2958] [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 0872/2958] [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 0873/2958] [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 0874/2958] [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 0875/2958] [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 0876/2958] [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 0877/2958] [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 0878/2958] [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 0879/2958] [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 0880/2958] [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 0881/2958] [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 0882/2958] [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 0883/2958] [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 0884/2958] [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 0885/2958] [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 0886/2958] [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 0887/2958] [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 0888/2958] [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 0889/2958] [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 0890/2958] [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 0891/2958] [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 0892/2958] [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 0893/2958] [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 0894/2958] [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 0895/2958] [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 0896/2958] [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 0897/2958] [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 0898/2958] [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 0899/2958] [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 0900/2958] [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 0901/2958] [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 0902/2958] [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 0903/2958] [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 0904/2958] [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 0905/2958] [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 0906/2958] [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 0907/2958] [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 0908/2958] [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 0909/2958] [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 0910/2958] [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 0911/2958] [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 0912/2958] [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 0913/2958] [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 0914/2958] [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 0915/2958] [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 0916/2958] [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 0917/2958] [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 0918/2958] [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 0919/2958] [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 0920/2958] [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 0921/2958] [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 0922/2958] [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 0923/2958] [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 0924/2958] [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 0925/2958] [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 0926/2958] [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 0927/2958] [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 0928/2958] [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 0929/2958] [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 0930/2958] [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 0931/2958] [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 0932/2958] [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 0933/2958] [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 0934/2958] [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 0935/2958] [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 0936/2958] [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 0937/2958] [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 0938/2958] [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 0939/2958] [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 0940/2958] [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 0941/2958] [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 0942/2958] [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 0943/2958] [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 0944/2958] [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 0945/2958] [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 0946/2958] [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 0947/2958] [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 0948/2958] [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 0949/2958] [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 0950/2958] [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 0951/2958] [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 0952/2958] [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 0953/2958] [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 0954/2958] [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 0955/2958] [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 0956/2958] [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 0957/2958] [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 0958/2958] [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 0959/2958] [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 0960/2958] [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 0961/2958] [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 0962/2958] [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 0963/2958] [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 0964/2958] [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 0965/2958] [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 0966/2958] [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 0967/2958] [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 0968/2958] [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 0969/2958] [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 0970/2958] [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 0971/2958] [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 0972/2958] [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 0973/2958] [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 0974/2958] [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 0975/2958] [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 0976/2958] [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 0977/2958] [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 0978/2958] [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 0979/2958] [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 0980/2958] [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 0981/2958] [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 0982/2958] [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 0983/2958] [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 0984/2958] [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 0985/2958] [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 0986/2958] [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 0987/2958] [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 0988/2958] [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 0989/2958] [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 0990/2958] [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 0991/2958] [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 0992/2958] [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 0993/2958] [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 0994/2958] [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 0995/2958] [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 0996/2958] [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 0997/2958] [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 0998/2958] [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 0999/2958] [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 1000/2958] [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 1001/2958] [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 1002/2958] [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 1003/2958] [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 1004/2958] [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 1005/2958] [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 1006/2958] [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 1007/2958] [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 1008/2958] [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 1009/2958] [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 1010/2958] [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 1011/2958] [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 1012/2958] [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 1013/2958] [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 1014/2958] [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 1015/2958] [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 1016/2958] [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 1017/2958] [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 1018/2958] [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 1019/2958] [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 1020/2958] [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 1021/2958] [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 1022/2958] [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 1023/2958] [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 1024/2958] [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 1025/2958] [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 1026/2958] [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 1027/2958] [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 1028/2958] [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 1029/2958] [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 1030/2958] [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 1031/2958] [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 1032/2958] [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 1033/2958] [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 1034/2958] [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 1035/2958] [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 1036/2958] [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 1037/2958] [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 1038/2958] [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 1039/2958] [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 1040/2958] [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 1041/2958] [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 1042/2958] [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 1043/2958] [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 1044/2958] [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 1045/2958] [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 1046/2958] [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 1047/2958] [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 1048/2958] [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 1049/2958] [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 1050/2958] [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 1051/2958] [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 1052/2958] [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 1053/2958] [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 1054/2958] [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 1055/2958] [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 1056/2958] [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 1057/2958] [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 1058/2958] [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 1059/2958] [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 1060/2958] [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 1061/2958] [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 1062/2958] [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 1063/2958] [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 1064/2958] [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 1065/2958] [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 1066/2958] [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 1067/2958] [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 1068/2958] [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 1069/2958] [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 1070/2958] [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 1071/2958] [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 1072/2958] [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 1073/2958] [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 1074/2958] [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 1075/2958] [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 1076/2958] [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 1077/2958] [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 1078/2958] [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 1079/2958] [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 1080/2958] [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 1081/2958] [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 1082/2958] [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 1083/2958] [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 1084/2958] [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 1085/2958] [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 1086/2958] [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 1087/2958] [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 1088/2958] [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 1089/2958] [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 1090/2958] [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 1091/2958] [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 1092/2958] [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 1093/2958] [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 1094/2958] [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 1095/2958] [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 1096/2958] [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 1097/2958] [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 1098/2958] [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 1099/2958] [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 1100/2958] [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 1101/2958] [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 1102/2958] [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 1103/2958] [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 1104/2958] [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 1105/2958] [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 1106/2958] [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 1107/2958] [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 1108/2958] [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 1109/2958] [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 1110/2958] [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 1111/2958] [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 1112/2958] [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 1113/2958] [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 1114/2958] [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 1115/2958] [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 1116/2958] [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 1117/2958] [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 1118/2958] [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 1119/2958] [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 1120/2958] [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 1121/2958] [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 1122/2958] [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 1123/2958] [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 1124/2958] [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 1125/2958] [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 1126/2958] [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 1127/2958] [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 1128/2958] [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 1129/2958] [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 1130/2958] [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 1131/2958] [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 1132/2958] [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 1133/2958] [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 1134/2958] [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 1135/2958] [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 1136/2958] [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 1137/2958] [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 1138/2958] [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 1139/2958] [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 1140/2958] [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 1141/2958] [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 1142/2958] [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 1143/2958] [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 1144/2958] [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 1145/2958] [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 1146/2958] [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 1147/2958] [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 1148/2958] [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 1149/2958] [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 1150/2958] [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 1151/2958] [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 1152/2958] [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 1153/2958] [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 1154/2958] [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 1155/2958] [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 1156/2958] [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 1157/2958] [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 1158/2958] [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 1159/2958] [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 1160/2958] [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 1161/2958] [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 1162/2958] [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 1163/2958] [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 1164/2958] [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 1165/2958] [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 1166/2958] [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 1167/2958] [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 1168/2958] [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 1169/2958] [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 1170/2958] [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 1171/2958] [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 1172/2958] [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 1173/2958] [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 1174/2958] [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 1175/2958] [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 1176/2958] [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 1177/2958] [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 1178/2958] [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 1179/2958] [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 1180/2958] [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 1181/2958] [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 1182/2958] [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 1183/2958] [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 1184/2958] [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 1185/2958] [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 1186/2958] [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 1187/2958] [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 1188/2958] [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 1189/2958] [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 1190/2958] [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 1191/2958] [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 1192/2958] [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 1193/2958] [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 1194/2958] [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 1195/2958] [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 1196/2958] [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 1197/2958] [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 1198/2958] [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 1199/2958] [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 1200/2958] [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 1201/2958] [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 1202/2958] [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 1203/2958] [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 1204/2958] [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 1205/2958] [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 1206/2958] [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 1207/2958] [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 1208/2958] [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 1209/2958] [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 1210/2958] [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 1211/2958] [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 1212/2958] [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 1213/2958] [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 1214/2958] [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 1215/2958] [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 1216/2958] [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 1217/2958] [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 1218/2958] [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 1219/2958] [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 1220/2958] [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 1221/2958] [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 1222/2958] [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 1223/2958] [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 1224/2958] [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 1225/2958] [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 1226/2958] [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 1227/2958] [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 1228/2958] [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 1229/2958] [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 1230/2958] [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 1231/2958] [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 1232/2958] [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 1233/2958] [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 1234/2958] [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 1235/2958] [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 1236/2958] [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 1237/2958] [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 1238/2958] [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 1239/2958] [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 1240/2958] [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 1241/2958] [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 1242/2958] [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 1243/2958] [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 1244/2958] [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 1245/2958] [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 1246/2958] [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 1247/2958] [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 1248/2958] [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 1249/2958] [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 1250/2958] [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 1251/2958] [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 1252/2958] [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 1253/2958] [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 1254/2958] [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 1255/2958] [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 1256/2958] [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 1257/2958] [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 1258/2958] [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 1259/2958] [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 1260/2958] [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 1261/2958] [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 1262/2958] [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 1263/2958] [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 1264/2958] [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 1265/2958] [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 1266/2958] [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 1267/2958] [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 1268/2958] [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 1269/2958] [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 1270/2958] [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 1271/2958] [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 1272/2958] [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 1273/2958] [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 1274/2958] [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 1275/2958] [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 1276/2958] [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 1277/2958] [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 1278/2958] [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 1279/2958] [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 1280/2958] [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 1281/2958] [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 1282/2958] [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 1283/2958] [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 1284/2958] [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 1285/2958] [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 1286/2958] [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 1287/2958] [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 1288/2958] [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 1289/2958] [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 1290/2958] [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 1291/2958] [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 1292/2958] [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 1293/2958] [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 1294/2958] [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 1295/2958] [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 1296/2958] [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 1297/2958] [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 1298/2958] 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 1299/2958] [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 1300/2958] [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 1301/2958] [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 1302/2958] [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 1303/2958] [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 1304/2958] [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 1305/2958] [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 1306/2958] [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 1307/2958] [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 1308/2958] [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 1309/2958] [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 1310/2958] [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 1311/2958] [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 1312/2958] [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 1313/2958] [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 1314/2958] [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 1315/2958] [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 1316/2958] [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 1317/2958] [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 1318/2958] [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 1319/2958] [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 1320/2958] [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 1321/2958] [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 1322/2958] [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 1323/2958] [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 1324/2958] [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 1325/2958] [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 1326/2958] [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 1327/2958] [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 1328/2958] [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 1329/2958] [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 1330/2958] [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 1331/2958] [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 1332/2958] [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 1333/2958] [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 1334/2958] [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 1335/2958] [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 1336/2958] [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 1337/2958] [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 1338/2958] [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 1339/2958] [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 1340/2958] [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 1341/2958] [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 1342/2958] [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 1343/2958] [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 1344/2958] [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 1345/2958] [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 1346/2958] [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 1347/2958] [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 1348/2958] [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 1349/2958] [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 1350/2958] [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 1351/2958] [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 1352/2958] [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 1353/2958] [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 1354/2958] [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 1355/2958] [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 1356/2958] [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 1357/2958] [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 1358/2958] [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 1359/2958] [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 1360/2958] [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 1361/2958] [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 1362/2958] [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 1363/2958] [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 1364/2958] [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 1365/2958] [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 1366/2958] [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 1367/2958] [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 1368/2958] [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 1369/2958] [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 1370/2958] [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 1371/2958] [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 1372/2958] [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 1373/2958] [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 1374/2958] [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 1375/2958] [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 1376/2958] [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 1377/2958] [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 1378/2958] [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 1379/2958] [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 1380/2958] [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 1381/2958] [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 1382/2958] [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 1383/2958] [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 1384/2958] [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 1385/2958] [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 1386/2958] [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 1387/2958] [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 1388/2958] [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 1389/2958] [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 1390/2958] [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 1391/2958] [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 1392/2958] [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 1393/2958] [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 1394/2958] [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 1395/2958] [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 1396/2958] [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 1397/2958] [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 1398/2958] [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 1399/2958] [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 1400/2958] [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 1401/2958] [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 1402/2958] [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 1403/2958] [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 1404/2958] [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 1405/2958] [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 1406/2958] [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 1407/2958] [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 1408/2958] [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 1409/2958] [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 1410/2958] [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 1411/2958] [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 1412/2958] [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 1413/2958] [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 1414/2958] [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 1415/2958] [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 1416/2958] [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 1417/2958] [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 1418/2958] [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 1419/2958] [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 1420/2958] [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 1421/2958] [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 1422/2958] [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 1423/2958] [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 1424/2958] [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 1425/2958] [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 1426/2958] [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 1427/2958] [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 1428/2958] [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 1429/2958] [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 1430/2958] [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 1431/2958] [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 1432/2958] [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 1433/2958] [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 1434/2958] [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 1435/2958] [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 1436/2958] [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 1437/2958] [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 1438/2958] [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 1439/2958] [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 1440/2958] [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 1441/2958] [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 1442/2958] [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 1443/2958] [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 1444/2958] [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 1445/2958] [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 1446/2958] [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 1447/2958] [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 1448/2958] [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 1449/2958] [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 1450/2958] [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 1451/2958] [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 1452/2958] [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 1453/2958] [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 1454/2958] [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 1455/2958] [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 1456/2958] [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 1457/2958] [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 1458/2958] [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 1459/2958] [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 1460/2958] [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 1461/2958] [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 1462/2958] [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 1463/2958] [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 1464/2958] [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 1465/2958] [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 1466/2958] [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 1467/2958] [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 1468/2958] [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 1469/2958] [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 1470/2958] [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 1471/2958] [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 1472/2958] [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 1473/2958] [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 1474/2958] [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 1475/2958] [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 1476/2958] [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 1477/2958] [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 1478/2958] [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 1479/2958] [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 1480/2958] [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 1481/2958] [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 1482/2958] [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 1483/2958] [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 1484/2958] [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 1485/2958] [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 1486/2958] [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 1487/2958] [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 1488/2958] [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 1489/2958] [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 1490/2958] [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 1491/2958] [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 1492/2958] [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 1493/2958] [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 1494/2958] [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 1495/2958] [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 1496/2958] [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 1497/2958] [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 1498/2958] [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 1499/2958] [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 1500/2958] [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 1501/2958] [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 1502/2958] [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 1503/2958] [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 1504/2958] [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 1505/2958] [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 1506/2958] [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 1507/2958] [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 1508/2958] [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 1509/2958] [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 1510/2958] [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 1511/2958] [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 1512/2958] [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 1513/2958] [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 1514/2958] [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 1515/2958] [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 1516/2958] [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 1517/2958] [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 1518/2958] [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 1519/2958] [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 1520/2958] [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 1521/2958] [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 1522/2958] [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 1523/2958] [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 1524/2958] [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 1525/2958] [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 1526/2958] [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 1527/2958] [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 1528/2958] [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 1529/2958] [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 1530/2958] [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 1531/2958] [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 1532/2958] [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 1533/2958] [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 1534/2958] [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 1535/2958] [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 1536/2958] [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 1537/2958] [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 1538/2958] [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 1539/2958] [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 1540/2958] [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 1541/2958] [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 1542/2958] [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 1543/2958] [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 1544/2958] [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 1545/2958] [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 1546/2958] [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 1547/2958] [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 1548/2958] [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 1549/2958] [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 1550/2958] [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 1551/2958] [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 1552/2958] [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 1553/2958] [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 1554/2958] [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 1555/2958] [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 1556/2958] [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 1557/2958] [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 1558/2958] [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 1559/2958] [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 1560/2958] [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 1561/2958] [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 1562/2958] [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 1563/2958] [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 1564/2958] [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 1565/2958] [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 1566/2958] [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 1567/2958] [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 1568/2958] [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 1569/2958] [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 1570/2958] [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 1571/2958] [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 1572/2958] [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 1573/2958] [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 1574/2958] [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 1575/2958] [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 1576/2958] [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 1577/2958] [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 1578/2958] [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 1579/2958] [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 1580/2958] [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 1581/2958] [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 1582/2958] [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 1583/2958] [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 1584/2958] [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 1585/2958] [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 1586/2958] [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 1587/2958] [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 1588/2958] [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 1589/2958] [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 1590/2958] [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 1591/2958] [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 1592/2958] [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 1593/2958] [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 1594/2958] [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 1595/2958] [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 1596/2958] [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 1597/2958] [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 1598/2958] [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 1599/2958] [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 1600/2958] [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 1601/2958] [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 1602/2958] [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 1603/2958] [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 1604/2958] [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 1605/2958] [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 1606/2958] [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 1607/2958] [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 1608/2958] [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 1609/2958] [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 1610/2958] [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 1611/2958] [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 1612/2958] [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 1613/2958] [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 1614/2958] [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 1615/2958] [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 1616/2958] [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 1617/2958] [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 1618/2958] [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 1619/2958] [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 1620/2958] [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 1621/2958] [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 1622/2958] [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 1623/2958] [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 1624/2958] [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 1625/2958] [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 1626/2958] [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 1627/2958] [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 1628/2958] [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 1629/2958] [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 1630/2958] [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 1631/2958] [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 1632/2958] [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 1633/2958] [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 1634/2958] [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 1635/2958] [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 1636/2958] [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 1637/2958] [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 1638/2958] [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 1639/2958] [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 1640/2958] [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 1641/2958] [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 1642/2958] [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 1643/2958] [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 1644/2958] [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 1645/2958] [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 1646/2958] [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 1647/2958] [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 1648/2958] [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 1649/2958] [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 1650/2958] [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 1651/2958] [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 1652/2958] [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 1653/2958] [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 1654/2958] [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 1655/2958] [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 1656/2958] [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 1657/2958] [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 1658/2958] [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 1659/2958] [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 1660/2958] [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 1661/2958] [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 1662/2958] [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 1663/2958] [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 1664/2958] [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 1665/2958] [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 1666/2958] [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 1667/2958] [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 1668/2958] [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 1669/2958] [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 1670/2958] [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 1671/2958] [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 1672/2958] [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 1673/2958] [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 1674/2958] [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 1675/2958] [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 1676/2958] [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 1677/2958] [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 1678/2958] [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 1679/2958] [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 1680/2958] [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 1681/2958] [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 1682/2958] [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 1683/2958] [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 1684/2958] [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 1685/2958] [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 1686/2958] [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 1687/2958] [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 1688/2958] [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 1689/2958] [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 1690/2958] [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 1691/2958] [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 1692/2958] [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 1693/2958] [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 1694/2958] [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 1695/2958] [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 1696/2958] [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 1697/2958] [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 1698/2958] [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 1699/2958] [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 1700/2958] [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 1701/2958] [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 1702/2958] [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 1703/2958] [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 1704/2958] [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 1705/2958] [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 1706/2958] [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 1707/2958] [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 1708/2958] [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 1709/2958] [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 1710/2958] [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 1711/2958] [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 1712/2958] [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 1713/2958] [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 1714/2958] [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 1715/2958] [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 1716/2958] [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 1717/2958] [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 1718/2958] [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 1719/2958] [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 1720/2958] [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 1721/2958] [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 1722/2958] [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 1723/2958] [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 1724/2958] [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 1725/2958] [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 1726/2958] [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 1727/2958] [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 1728/2958] [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 1729/2958] [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 1730/2958] [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 1731/2958] [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 1732/2958] [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 1733/2958] [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 1734/2958] [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 1735/2958] [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 1736/2958] [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 1737/2958] [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 1738/2958] [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 1739/2958] [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 1740/2958] [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 1741/2958] [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 1742/2958] [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 1743/2958] [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 1744/2958] [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 1745/2958] [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 1746/2958] [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 1747/2958] [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 1748/2958] [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 1749/2958] [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 1750/2958] [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 1751/2958] [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 1752/2958] [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 1753/2958] [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 1754/2958] [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 1755/2958] [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 1756/2958] [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 1757/2958] [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 1758/2958] [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 1759/2958] [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 1760/2958] [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 1761/2958] [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 1762/2958] [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 1763/2958] [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 1764/2958] [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 1765/2958] [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 1766/2958] [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 1767/2958] [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 1768/2958] [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 1769/2958] [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 1770/2958] [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 1771/2958] [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 1772/2958] [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 1773/2958] [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 1774/2958] [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 1775/2958] [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 1776/2958] [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 1777/2958] [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 1778/2958] [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 1779/2958] [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 1780/2958] [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 1781/2958] [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 1782/2958] [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 1783/2958] [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 1784/2958] [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 1785/2958] [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 1786/2958] [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 1787/2958] [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 1788/2958] [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 1789/2958] [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 1790/2958] [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 1791/2958] [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 1792/2958] [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 1793/2958] [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 1794/2958] [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 1795/2958] [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 1796/2958] [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 1797/2958] [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 1798/2958] [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 1799/2958] [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 1800/2958] [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 1801/2958] [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 1802/2958] [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 1803/2958] [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 1804/2958] [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 1805/2958] [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 1806/2958] [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 1807/2958] [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 1808/2958] [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 1809/2958] [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 1810/2958] [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 1811/2958] [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 1812/2958] [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 1813/2958] [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 1814/2958] [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 1815/2958] [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 1816/2958] [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 1817/2958] [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 1818/2958] [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 1819/2958] [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 1820/2958] [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 1821/2958] [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 1822/2958] [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 1823/2958] [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 1824/2958] [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 1825/2958] [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 1826/2958] [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 1827/2958] [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 1828/2958] [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 1829/2958] [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 1830/2958] [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 1831/2958] [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 1832/2958] [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 1833/2958] [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 1834/2958] [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 1835/2958] [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 1836/2958] [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 1837/2958] [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 1838/2958] [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 1839/2958] [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 1840/2958] [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 1841/2958] [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 1842/2958] [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 1843/2958] [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 1844/2958] [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 1845/2958] [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 1846/2958] [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 1847/2958] [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 1848/2958] [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 1849/2958] [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 1850/2958] [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 1851/2958] [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 1852/2958] [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 1853/2958] [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 1854/2958] [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 1855/2958] [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 1856/2958] [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 1857/2958] [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 1858/2958] [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 1859/2958] [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 1860/2958] [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 1861/2958] [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 1862/2958] [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 1863/2958] [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 1864/2958] [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 1865/2958] [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 1866/2958] [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 1867/2958] [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 1868/2958] [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 1869/2958] [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 1870/2958] [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 1871/2958] [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 1872/2958] [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 1873/2958] [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 1874/2958] [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 1875/2958] [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 1876/2958] [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 1877/2958] [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 1878/2958] [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 1879/2958] [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 1880/2958] [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 1881/2958] [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 1882/2958] [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 1883/2958] [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 1884/2958] [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 1885/2958] [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 1886/2958] [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 1887/2958] [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 1888/2958] [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 1889/2958] [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 1890/2958] [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 1891/2958] [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 1892/2958] [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 1893/2958] [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 1894/2958] [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 1895/2958] [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 1896/2958] [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 1897/2958] [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 1898/2958] [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 1899/2958] [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 1900/2958] [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 1901/2958] [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 1902/2958] [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 1903/2958] [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 1904/2958] [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 1905/2958] [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 1906/2958] [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 1907/2958] [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 1908/2958] [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 1909/2958] [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 1910/2958] [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 1911/2958] [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 1912/2958] [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 1913/2958] [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 1914/2958] [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 1915/2958] [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 1916/2958] [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 1917/2958] [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 1918/2958] [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 1919/2958] [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 1920/2958] [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 1921/2958] [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 1922/2958] [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 1923/2958] [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 1924/2958] [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 1925/2958] [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 1926/2958] [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 1927/2958] [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 1928/2958] [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 1929/2958] [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 1930/2958] [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 1931/2958] [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 1932/2958] [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 1933/2958] [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 1934/2958] [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 1935/2958] [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 1936/2958] [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 1937/2958] [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 1938/2958] [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 1939/2958] [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 1940/2958] [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 1941/2958] [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 1942/2958] [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 1943/2958] [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 1944/2958] [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 1945/2958] [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 1946/2958] [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 1947/2958] [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 1948/2958] [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 1949/2958] [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 1950/2958] [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 1951/2958] [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 1952/2958] [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 1953/2958] [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 1954/2958] [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 1955/2958] [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 1956/2958] [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 1957/2958] [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 1958/2958] [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 1959/2958] [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 1960/2958] [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 1961/2958] [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 1962/2958] [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 1963/2958] [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 1964/2958] [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 1965/2958] [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 1966/2958] [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 1967/2958] [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 1968/2958] [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 1969/2958] [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 1970/2958] [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 1971/2958] [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 1972/2958] [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 1973/2958] [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 1974/2958] [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 1975/2958] [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 1976/2958] [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 1977/2958] [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 1978/2958] [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 1979/2958] [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 1980/2958] [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 1981/2958] [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 1982/2958] [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 1983/2958] [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 1984/2958] [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 1985/2958] [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 1986/2958] [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 1987/2958] [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 1988/2958] [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 1989/2958] [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 1990/2958] [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 1991/2958] [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 1992/2958] [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 1993/2958] [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 1994/2958] [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 1995/2958] [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 1996/2958] [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 1997/2958] [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 1998/2958] [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 1999/2958] [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 2000/2958] [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 2001/2958] [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 2002/2958] [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 2003/2958] [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 2004/2958] [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 2005/2958] [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 2006/2958] [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 2007/2958] [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 2008/2958] [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 2009/2958] [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 2010/2958] [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 2011/2958] [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 2012/2958] [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 2013/2958] [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 2014/2958] [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 2015/2958] [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 2016/2958] [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 2017/2958] [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 2018/2958] [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 2019/2958] [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 2020/2958] [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 2021/2958] [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 2022/2958] [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 2023/2958] [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 2024/2958] [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 2025/2958] [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 2026/2958] [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 2027/2958] [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 2028/2958] [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 2029/2958] [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 2030/2958] [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 2031/2958] [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 2032/2958] [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 2033/2958] [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 2034/2958] [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 2035/2958] [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 2036/2958] [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 2037/2958] [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 2038/2958] [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 2039/2958] [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 2040/2958] [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 2041/2958] [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 2042/2958] [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 2043/2958] [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 2044/2958] [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 2045/2958] [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 2046/2958] [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 2047/2958] [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 2048/2958] [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 2049/2958] [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 2050/2958] [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 2051/2958] [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 2052/2958] [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 2053/2958] [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 2054/2958] [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 2055/2958] [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 2056/2958] [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 2057/2958] [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 2058/2958] [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 2059/2958] [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 2060/2958] [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 2061/2958] [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 2062/2958] [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 2063/2958] [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 2064/2958] [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 2065/2958] [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 2066/2958] [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 2067/2958] [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 2068/2958] [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 2069/2958] [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 2070/2958] [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 2071/2958] [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 2072/2958] [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 2073/2958] [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 2074/2958] [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 2075/2958] [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 2076/2958] [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 2077/2958] [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 2078/2958] [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 2079/2958] [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 2080/2958] [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 2081/2958] [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 2082/2958] [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 2083/2958] [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 2084/2958] [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 2085/2958] [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 2086/2958] [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 2087/2958] [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 2088/2958] [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 2089/2958] [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 2090/2958] [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 2091/2958] [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 2092/2958] [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 2093/2958] [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 2094/2958] [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 2095/2958] [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 2096/2958] [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 2097/2958] [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 2098/2958] [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 2099/2958] [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 2100/2958] [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 2101/2958] [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 2102/2958] [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 2103/2958] [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 2104/2958] [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 2105/2958] [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 2106/2958] [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 2107/2958] [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 2108/2958] [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 2109/2958] [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 2110/2958] [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 2111/2958] [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 2112/2958] [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 2113/2958] [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 2114/2958] [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 2115/2958] [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 2116/2958] [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 2117/2958] [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 2118/2958] [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 2119/2958] [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 2120/2958] [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 2121/2958] [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 2122/2958] [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 2123/2958] [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 2124/2958] [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 2125/2958] [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 2126/2958] [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 2127/2958] [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 2128/2958] [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 2129/2958] [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 2130/2958] [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 2131/2958] [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 2132/2958] [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 2133/2958] [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 2134/2958] [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 2135/2958] [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 2136/2958] [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 2137/2958] [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 2138/2958] [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 2139/2958] [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 2140/2958] [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 2141/2958] [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 2142/2958] [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 2143/2958] [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 2144/2958] [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 2145/2958] [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 2146/2958] [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 2147/2958] [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 2148/2958] [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 2149/2958] [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 2150/2958] [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 2151/2958] [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 2152/2958] [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 2153/2958] [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 2154/2958] [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 2155/2958] [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 2156/2958] [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 2157/2958] [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 2158/2958] [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 2159/2958] [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 2160/2958] [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 2161/2958] [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 2162/2958] [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 2163/2958] [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 2164/2958] [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 2165/2958] [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 2166/2958] [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 2167/2958] [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 2168/2958] [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 2169/2958] [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 2170/2958] [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 2171/2958] [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 2172/2958] [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 2173/2958] [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 2174/2958] [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 2175/2958] [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 2176/2958] [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 2177/2958] [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 2178/2958] [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 2179/2958] [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 2180/2958] [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 2181/2958] [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 2182/2958] [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 2183/2958] [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 2184/2958] [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 2185/2958] [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 2186/2958] [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 2187/2958] [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 2188/2958] [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 2189/2958] [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 2190/2958] [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 2191/2958] [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 2192/2958] [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 2193/2958] [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 2194/2958] [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 2195/2958] [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 2196/2958] [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 2197/2958] [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 2198/2958] [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 2199/2958] [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 2200/2958] [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 2201/2958] [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 2202/2958] [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 2203/2958] [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 2204/2958] [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 2205/2958] [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 2206/2958] [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 2207/2958] [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 2208/2958] [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 2209/2958] [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 2210/2958] [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 2211/2958] [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 2212/2958] [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 2213/2958] [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 2214/2958] [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 2215/2958] [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 2216/2958] [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 2217/2958] [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 2218/2958] [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 2219/2958] [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 2220/2958] [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 2221/2958] [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 2222/2958] [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 2223/2958] [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 2224/2958] [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 2225/2958] [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 2226/2958] [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 2227/2958] [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 2228/2958] [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 2229/2958] [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 2230/2958] [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 2231/2958] [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 2232/2958] [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 2233/2958] [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 2234/2958] [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 2235/2958] [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 2236/2958] [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 2237/2958] [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 2238/2958] [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 2239/2958] [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 2240/2958] [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 2241/2958] [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 2242/2958] [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 2243/2958] [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 2244/2958] [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 2245/2958] [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 2246/2958] [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 2247/2958] [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 2248/2958] [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 2249/2958] [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 2250/2958] [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 2251/2958] [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 2252/2958] [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 2253/2958] [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 2254/2958] [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 2255/2958] [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 2256/2958] [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 2257/2958] [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 2258/2958] [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 2259/2958] [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 2260/2958] [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 2261/2958] [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 2262/2958] [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 2263/2958] [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 2264/2958] [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 2265/2958] [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 2266/2958] [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 2267/2958] [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 2268/2958] [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 2269/2958] [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 2270/2958] [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 2271/2958] [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 2272/2958] [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 2273/2958] [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 2274/2958] [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 2275/2958] [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 2276/2958] [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 2277/2958] [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 2278/2958] [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 2279/2958] [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 2280/2958] [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 2281/2958] [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 2282/2958] [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 2283/2958] [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 2284/2958] [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 2285/2958] [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 2286/2958] [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 2287/2958] [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 2288/2958] [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 2289/2958] [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 2290/2958] [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 2291/2958] [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 2292/2958] [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 2293/2958] [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 2294/2958] [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 2295/2958] [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 2296/2958] [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 2297/2958] [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 2298/2958] [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 2299/2958] [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 2300/2958] [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 2301/2958] [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 2302/2958] [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 2303/2958] [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 2304/2958] [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 2305/2958] [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 2306/2958] [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 2307/2958] [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 2308/2958] [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 2309/2958] [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 2310/2958] [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 2311/2958] [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 2312/2958] [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 2313/2958] [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 2314/2958] [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 2315/2958] [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 2316/2958] [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 2317/2958] [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 2318/2958] [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 2319/2958] [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 2320/2958] [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 2321/2958] [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 2322/2958] [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 2323/2958] [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 2324/2958] [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 2325/2958] [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 2326/2958] [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 2327/2958] [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 2328/2958] [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 2329/2958] [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 2330/2958] [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 2331/2958] [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 2332/2958] [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 2333/2958] [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 2334/2958] [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 2335/2958] [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 2336/2958] [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 2337/2958] [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 2338/2958] [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 2339/2958] [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 2340/2958] [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 2341/2958] [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 2342/2958] [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 2343/2958] [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 2344/2958] [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 2345/2958] [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 2346/2958] [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 2347/2958] [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 2348/2958] [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 2349/2958] [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 2350/2958] [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 2351/2958] [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 2352/2958] [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 2353/2958] [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 2354/2958] [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 2355/2958] [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 2356/2958] [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 2357/2958] [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 2358/2958] [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 2359/2958] [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 2360/2958] [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 2361/2958] [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 2362/2958] [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 2363/2958] [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 2364/2958] [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 2365/2958] [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 2366/2958] [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 2367/2958] [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 2368/2958] [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 2369/2958] [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 2370/2958] [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 2371/2958] [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 2372/2958] [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 2373/2958] [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 2374/2958] [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 2375/2958] [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 2376/2958] [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 2377/2958] [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 2378/2958] [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 2379/2958] [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 2380/2958] [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 2381/2958] [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 2382/2958] [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 2383/2958] [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 2384/2958] [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 2385/2958] [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 2386/2958] [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 2387/2958] [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 2388/2958] [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 2389/2958] [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 2390/2958] [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 2391/2958] [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 2392/2958] [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 2393/2958] [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 2394/2958] [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 2395/2958] [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 2396/2958] [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 2397/2958] [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 2398/2958] [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 2399/2958] [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 2400/2958] [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 2401/2958] [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 2402/2958] [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 2403/2958] [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 2404/2958] [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 2405/2958] [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 2406/2958] [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 2407/2958] [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 2408/2958] [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 2409/2958] [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 2410/2958] [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 2411/2958] [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 2412/2958] [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 2413/2958] [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 2414/2958] [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 2415/2958] [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 2416/2958] [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 2417/2958] [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 2418/2958] [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 2419/2958] [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 2420/2958] [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 2421/2958] [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 2422/2958] [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 2423/2958] [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 2424/2958] [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 2425/2958] [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 2426/2958] [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 2427/2958] [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 2428/2958] [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 2429/2958] [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 2430/2958] [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 2431/2958] [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 2432/2958] [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 2433/2958] [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 2434/2958] [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 2435/2958] [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 2436/2958] [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 2437/2958] [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 2438/2958] [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 2439/2958] [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 2440/2958] [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 2441/2958] [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 2442/2958] [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 2443/2958] [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 2444/2958] [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 2445/2958] [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 2446/2958] [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 2447/2958] [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 2448/2958] [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 2449/2958] [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 2450/2958] [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 2451/2958] [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 2452/2958] [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 2453/2958] [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 2454/2958] [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 2455/2958] [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 2456/2958] [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 2457/2958] [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 2458/2958] [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 2459/2958] [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 2460/2958] [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 2461/2958] [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 2462/2958] [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 2463/2958] [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 2464/2958] [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 2465/2958] [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 2466/2958] [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 2467/2958] [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 2468/2958] [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 2469/2958] [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 2470/2958] [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 2471/2958] [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 2472/2958] [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 2473/2958] [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 2474/2958] [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 2475/2958] [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 2476/2958] [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 2477/2958] [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 2478/2958] [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 2479/2958] [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 2480/2958] [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 2481/2958] [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 2482/2958] [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 2483/2958] [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 2484/2958] [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 2485/2958] [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 2486/2958] [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 2487/2958] [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 2488/2958] [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 2489/2958] [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 2490/2958] [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 2491/2958] [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 2492/2958] [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 2493/2958] [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 2494/2958] [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 2495/2958] [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 2496/2958] [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 2497/2958] [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 2498/2958] [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 2499/2958] [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 2500/2958] [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 2501/2958] [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 2502/2958] [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 2503/2958] [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 2504/2958] [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 2505/2958] [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 2506/2958] [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 2507/2958] [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 2508/2958] [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 2509/2958] [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 2510/2958] [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 2511/2958] [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 2512/2958] [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 2513/2958] [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 2514/2958] [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 2515/2958] [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 2516/2958] [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 2517/2958] [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 2518/2958] [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 2519/2958] [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 2520/2958] [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 2521/2958] [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 2522/2958] [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 2523/2958] [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 2524/2958] [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 2525/2958] [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 2526/2958] [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 2527/2958] [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 2528/2958] [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 2529/2958] [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 2530/2958] [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 2531/2958] [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 2532/2958] [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 2533/2958] [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 2534/2958] [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 2535/2958] [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 2536/2958] [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 2537/2958] [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 2538/2958] [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 2539/2958] [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 2540/2958] [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 2541/2958] [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 2542/2958] [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 2543/2958] [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 2544/2958] [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 2545/2958] [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 2546/2958] [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 2547/2958] [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 2548/2958] [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 2549/2958] [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 2550/2958] [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 2551/2958] [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 2552/2958] [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 2553/2958] [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 2554/2958] [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 2555/2958] [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 2556/2958] [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 2557/2958] [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 2558/2958] [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 2559/2958] [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 2560/2958] [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 2561/2958] [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 2562/2958] [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 2563/2958] [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 2564/2958] [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 2565/2958] [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 2566/2958] [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 2567/2958] [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 2568/2958] [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 2569/2958] [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 2570/2958] [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 2571/2958] [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 2572/2958] [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 2573/2958] [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 2574/2958] [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 2575/2958] [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 2576/2958] [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 2577/2958] [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 2578/2958] [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 2579/2958] [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 2580/2958] [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 2581/2958] [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 2582/2958] [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 2583/2958] [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 2584/2958] [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 2585/2958] [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 2586/2958] [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 2587/2958] [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 2588/2958] [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 2589/2958] [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 2590/2958] [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 2591/2958] [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 2592/2958] [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 2593/2958] [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 2594/2958] [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 2595/2958] [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 2596/2958] [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 2597/2958] [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 2598/2958] [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 2599/2958] [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 2600/2958] [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 2601/2958] [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 2602/2958] [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 2603/2958] [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 2604/2958] [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 2605/2958] [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 2606/2958] [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 2607/2958] [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 2608/2958] [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 2609/2958] [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 2610/2958] [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 2611/2958] [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 2612/2958] [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 2613/2958] [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 2614/2958] [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 2615/2958] [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 2616/2958] [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 2617/2958] [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 2618/2958] [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 2619/2958] [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 2620/2958] [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 2621/2958] [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 2622/2958] [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 2623/2958] [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 2624/2958] [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 2625/2958] [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 2626/2958] [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 2627/2958] [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 2628/2958] [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 2629/2958] [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 2630/2958] [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 2631/2958] [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 2632/2958] [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 2633/2958] [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 2634/2958] [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 2635/2958] [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 2636/2958] [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 2637/2958] [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 2638/2958] [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 2639/2958] [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 2640/2958] [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 2641/2958] [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 2642/2958] [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 2643/2958] [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 2644/2958] [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 2645/2958] [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 2646/2958] [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 2647/2958] [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 2648/2958] [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 2649/2958] [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 2650/2958] [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 2651/2958] [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 2652/2958] [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 2653/2958] [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 2654/2958] [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 2655/2958] [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 2656/2958] [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 2657/2958] [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 2658/2958] [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 2659/2958] [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 2660/2958] [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 2661/2958] [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 2662/2958] [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 2663/2958] [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 2664/2958] [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 2665/2958] [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 2666/2958] [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 2667/2958] [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 2668/2958] [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 2669/2958] [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 2670/2958] [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 2671/2958] [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 2672/2958] [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 2673/2958] [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 2674/2958] [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 2675/2958] [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 2676/2958] [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 2677/2958] [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 2678/2958] [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 2679/2958] [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 2680/2958] [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 2681/2958] [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 2682/2958] [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 2683/2958] [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 2684/2958] [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 2685/2958] [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 2686/2958] [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 2687/2958] [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 2688/2958] [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 2689/2958] [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 2690/2958] [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 2691/2958] [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 2692/2958] [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 2693/2958] [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 2694/2958] [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 2695/2958] [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 2696/2958] [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 2697/2958] [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 2698/2958] [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 2699/2958] [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 2700/2958] [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 2701/2958] [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 2702/2958] [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 2703/2958] [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 2704/2958] [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 2705/2958] [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 2706/2958] [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 2707/2958] [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 2708/2958] [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 2709/2958] [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 2710/2958] [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 2711/2958] [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 2712/2958] [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 2713/2958] [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 2714/2958] [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 2715/2958] [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 2716/2958] [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 2717/2958] [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 2718/2958] [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 2719/2958] [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 2720/2958] [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 2721/2958] [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 2722/2958] [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 2723/2958] [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 2724/2958] [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 2725/2958] [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 2726/2958] [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 2727/2958] [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 2728/2958] [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 2729/2958] [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 2730/2958] [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 2731/2958] [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 2732/2958] [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 2733/2958] [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 2734/2958] [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 2735/2958] [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 2736/2958] [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 2737/2958] [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 2738/2958] [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 2739/2958] [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 2740/2958] [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 2741/2958] [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 2742/2958] [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 2743/2958] [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 2744/2958] [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 2745/2958] [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 2746/2958] [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 2747/2958] [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 2748/2958] [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 2749/2958] [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 2750/2958] [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 2751/2958] [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 2752/2958] [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 2753/2958] [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 2754/2958] [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 2755/2958] [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 2756/2958] [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 2757/2958] [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 2758/2958] [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 2759/2958] [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 2760/2958] [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 2761/2958] [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 2762/2958] [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 2763/2958] [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 2764/2958] [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 2765/2958] [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 2766/2958] [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 2767/2958] [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 2768/2958] [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 2769/2958] [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 2770/2958] [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 2771/2958] [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 2772/2958] [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 2773/2958] [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 2774/2958] [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 2775/2958] [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 2776/2958] [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 2777/2958] [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 2778/2958] [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 2779/2958] [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 2780/2958] [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 2781/2958] [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 2782/2958] [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 2783/2958] [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 2784/2958] [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 2785/2958] [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 2786/2958] [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 2787/2958] [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 2788/2958] [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 2789/2958] [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 2790/2958] [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 2791/2958] [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 2792/2958] [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 2793/2958] [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 2794/2958] [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 2795/2958] [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 2796/2958] [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 2797/2958] [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 2798/2958] [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 2799/2958] [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 2800/2958] [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 2801/2958] [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 2802/2958] [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 2803/2958] [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 2804/2958] [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 2805/2958] [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 2806/2958] [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 2807/2958] [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 2808/2958] [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 2809/2958] [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 2810/2958] [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 2811/2958] [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 2812/2958] [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 2813/2958] [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 2814/2958] [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 2815/2958] [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 2816/2958] [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 2817/2958] [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 2818/2958] [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 2819/2958] [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 2820/2958] [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 2821/2958] [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 2822/2958] [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 2823/2958] [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 2824/2958] [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 2825/2958] [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 2826/2958] [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 2827/2958] [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 2828/2958] [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 2829/2958] [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 2830/2958] [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 2831/2958] [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 2832/2958] [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 2833/2958] [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 2834/2958] [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 2835/2958] [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 2836/2958] [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 2837/2958] [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 2838/2958] [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 2839/2958] [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 2840/2958] [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 2841/2958] [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 2842/2958] [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 2843/2958] [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 2844/2958] [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 2845/2958] [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 2846/2958] [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 2847/2958] [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 2848/2958] [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 2849/2958] [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 2850/2958] [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 2851/2958] [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 2852/2958] [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 2853/2958] [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 2854/2958] [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 2855/2958] [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 2856/2958] [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 2857/2958] [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 2858/2958] [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 2859/2958] [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 2860/2958] [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 2861/2958] [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 2862/2958] [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 2863/2958] [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 2864/2958] [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 2865/2958] [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 2866/2958] [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 2867/2958] [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 2868/2958] [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 2869/2958] [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 2870/2958] [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 2871/2958] [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 2872/2958] [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 2873/2958] [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 2874/2958] [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 2875/2958] [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 2876/2958] [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 2877/2958] [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 2878/2958] [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 2879/2958] [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 2880/2958] [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 2881/2958] [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 2882/2958] [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 2883/2958] [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 2884/2958] [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 2885/2958] [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 2886/2958] [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 2887/2958] [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 2888/2958] [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 2889/2958] [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 2890/2958] [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 2891/2958] [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 2892/2958] [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 2893/2958] [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 2894/2958] [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 2895/2958] [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 2896/2958] [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 2897/2958] [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 2898/2958] [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 2899/2958] [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 2900/2958] [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 2901/2958] [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 2902/2958] [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 2903/2958] [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 2904/2958] [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 2905/2958] [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 2906/2958] [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 2907/2958] [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 2908/2958] [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 2909/2958] [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 2910/2958] [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 2911/2958] [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 2912/2958] [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 2913/2958] [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 2914/2958] [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 2915/2958] [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 2916/2958] [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 2917/2958] [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 2918/2958] [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 2919/2958] [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 2920/2958] [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 2921/2958] [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 2922/2958] [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 2923/2958] [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 2924/2958] [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 2925/2958] [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 2926/2958] [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 2927/2958] [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 2928/2958] [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 2929/2958] [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 2930/2958] [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 2931/2958] [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 2932/2958] [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 2933/2958] [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 2934/2958] [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 2935/2958] [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 2936/2958] [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 2937/2958] [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 2938/2958] [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 2939/2958] [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 2940/2958] [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 2941/2958] [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 2942/2958] [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 2943/2958] [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 2944/2958] [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 2945/2958] [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 2946/2958] [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 2947/2958] [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 2948/2958] [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 2949/2958] [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 2950/2958] [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 2951/2958] [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 2952/2958] [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 2953/2958] [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 2954/2958] [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 2955/2958] [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 2956/2958] [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 2957/2958] [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 2958/2958] [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