@@ -70,11 +70,7 @@ internal static string Unquote(this string str)
7070
7171 return str . Trim ( ) ;
7272 }
73-
74- internal static bool IsData ( this byte opcode ) => opcode == 0x1 || opcode == 0x2 ;
75-
76- internal static bool IsData ( this Opcode opcode ) => opcode == Opcode . Text || opcode == Opcode . Binary ;
77-
73+
7874 internal static byte [ ] InternalToByteArray ( this ushort value , Endianness order )
7975 {
8076 var bytes = BitConverter . GetBytes ( value ) ;
@@ -92,76 +88,22 @@ internal static byte[] InternalToByteArray(this ulong value, Endianness order)
9288
9389 return bytes ;
9490 }
95-
96- internal static bool IsControl ( this byte opcode ) => opcode > 0x7 && opcode < 0x10 ;
97-
98- internal static bool IsReserved ( this CloseStatusCode code )
99- {
100- return code == CloseStatusCode . Undefined ||
101- code == CloseStatusCode . NoStatus ||
102- code == CloseStatusCode . Abnormal ||
103- code == CloseStatusCode . TlsHandshakeFailure ;
104- }
105-
106- /// <summary>
107- /// Converts the order of the specified array of <see cref="byte"/> to the host byte order.
108- /// </summary>
109- /// <returns>
110- /// An array of <see cref="byte"/> converted from <paramref name="source"/>.
111- /// </returns>
112- /// <param name="source">
113- /// An array of <see cref="byte"/> to convert.
114- /// </param>
115- /// <param name="sourceOrder">
116- /// One of the <see cref="Endianness"/> enum values, specifies the byte order of
117- /// <paramref name="source"/>.
118- /// </param>
119- /// <exception cref="ArgumentNullException">
120- /// <paramref name="source"/> is <see langword="null"/>.
121- /// </exception>
91+
12292 internal static byte [ ] ToHostOrder ( this byte [ ] source , Endianness sourceOrder )
12393 {
12494 if ( source == null )
12595 throw new ArgumentNullException ( nameof ( source ) ) ;
12696
12797 return source . Length > 1 && ! sourceOrder . IsHostOrder ( ) ? source . Reverse ( ) . ToArray ( ) : source ;
12898 }
129-
130- /// <summary>
131- /// Determines whether the specified <see cref="Endianness"/> is host (this computer
132- /// architecture) byte order.
133- /// </summary>
134- /// <returns>
135- /// <c>true</c> if <paramref name="order"/> is host byte order; otherwise, <c>false</c>.
136- /// </returns>
137- /// <param name="order">
138- /// One of the <see cref="Endianness"/> enum values, to test.
139- /// </param>
99+
140100 internal static bool IsHostOrder ( this Endianness order )
141101 {
142102 // true: !(true ^ true) or !(false ^ false)
143103 // false: !(true ^ false) or !(false ^ true)
144104 return ! ( BitConverter . IsLittleEndian ^ ( order == Endianness . Little ) ) ;
145105 }
146-
147- /// <summary>
148- /// Tries to create a <see cref="Uri"/> for WebSocket with
149- /// the specified <paramref name="uriString"/>.
150- /// </summary>
151- /// <returns>
152- /// <c>true</c> if a <see cref="Uri"/> is successfully created; otherwise, <c>false</c>.
153- /// </returns>
154- /// <param name="uriString">
155- /// A <see cref="string"/> that represents a WebSocket URL to try.
156- /// </param>
157- /// <param name="result">
158- /// When this method returns, a <see cref="Uri"/> that represents a WebSocket URL,
159- /// or <see langword="null"/> if <paramref name="uriString"/> is invalid.
160- /// </param>
161- /// <param name="message">
162- /// When this method returns, a <see cref="string"/> that represents an error message,
163- /// or <see cref="String.Empty"/> if <paramref name="uriString"/> is valid.
164- /// </param>
106+
165107 internal static bool TryCreateWebSocketUri (
166108 this string uriString , out Uri result , out string message )
167109 {
@@ -211,20 +153,7 @@ internal static bool TryCreateWebSocketUri(
211153
212154 internal static bool IsToken ( this string value ) =>
213155 value . All ( c => c >= 0x20 && c < 0x7f && ! Tspecials . Contains ( c ) ) ;
214-
215- /// <summary>
216- /// Gets the collection of the HTTP cookies from the specified HTTP <paramref name="headers"/>.
217- /// </summary>
218- /// <returns>
219- /// A <see cref="CookieCollection"/> that receives a collection of the HTTP cookies.
220- /// </returns>
221- /// <param name="headers">
222- /// A <see cref="NameValueCollection"/> that contains a collection of the HTTP headers.
223- /// </param>
224- /// <param name="response">
225- /// <c>true</c> if <paramref name="headers"/> is a collection of the response headers;
226- /// otherwise, <c>false</c>.
227- /// </param>
156+
228157 internal static CookieCollection GetCookies ( this NameValueCollection headers , bool response )
229158 {
230159 var name = response ? "Set-Cookie" : Headers . Cookie ;
@@ -242,42 +171,11 @@ internal static string ToExtensionString(this CompressionMethod method, params s
242171
243172 return parameters == null || parameters . Length == 0 ? m : $ "{ m } ; { string . Join ( "; " , parameters ) } ";
244173 }
245-
246- /// <summary>
247- /// Determines whether the specified <see cref="NameValueCollection"/> contains the entry with
248- /// the specified both <paramref name="name"/> and <paramref name="value"/>.
249- /// </summary>
250- /// <returns>
251- /// <c>true</c> if <paramref name="collection"/> contains the entry with both
252- /// <paramref name="name"/> and <paramref name="value"/>; otherwise, <c>false</c>.
253- /// </returns>
254- /// <param name="collection">
255- /// A <see cref="NameValueCollection"/> to test.
256- /// </param>
257- /// <param name="name">
258- /// A <see cref="string"/> that represents the key of the entry to find.
259- /// </param>
260- /// <param name="value">
261- /// A <see cref="string"/> that represents the value of the entry to find.
262- /// </param>
174+
263175 internal static bool Contains ( this NameValueCollection collection , string name , string value )
264176 => collection [ name ] ? . Split ( Strings . CommaSplitChar )
265177 . Any ( val => val . Trim ( ) . Equals ( value , StringComparison . OrdinalIgnoreCase ) ) == true ;
266-
267- /// <summary>
268- /// Determines whether the specified <see cref="string"/> contains any of characters in
269- /// the specified array of <see cref="char"/>.
270- /// </summary>
271- /// <returns>
272- /// <c>true</c> if <paramref name="value"/> contains any of <paramref name="chars"/>;
273- /// otherwise, <c>false</c>.
274- /// </returns>
275- /// <param name="value">
276- /// A <see cref="string"/> to test.
277- /// </param>
278- /// <param name="chars">
279- /// An array of <see cref="char"/> that contains characters to find.
280- /// </param>
178+
281179 internal static bool Contains ( this string value , params char [ ] chars )
282180 => chars ? . Length == 0 || ( ! string . IsNullOrEmpty ( value ) && value . IndexOfAny ( chars ) > - 1 ) ;
283181
0 commit comments