Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ ParseDeflateOptions()

static WebSocketDeflateOptions System.Net.WebSockets.WebSocketHandle.ParseDeflateOptions ( ReadOnlySpan< char > extension,
WebSocketDeflateOptions original )
inlinestaticprivate

Definition at line 250 of file WebSocketHandle.cs.

251 {
252 WebSocketDeflateOptions webSocketDeflateOptions = new WebSocketDeflateOptions();
253 while (true)
254 {
255 int num = extension.IndexOf(';');
258 if (num < 0)
259 {
260 span = extension;
261 }
262 else
263 {
265 span = readOnlySpan[..num];
266 }
268 if (readOnlySpan2.Length > 0)
269 {
270 if (readOnlySpan2.SequenceEqual("client_no_context_takeover"))
271 {
272 webSocketDeflateOptions.ClientContextTakeover = false;
273 }
274 else if (readOnlySpan2.SequenceEqual("server_no_context_takeover"))
275 {
276 webSocketDeflateOptions.ServerContextTakeover = false;
277 }
278 else if (readOnlySpan2.StartsWith("client_max_window_bits"))
279 {
280 webSocketDeflateOptions.ClientMaxWindowBits = ParseWindowBits(readOnlySpan2);
281 }
282 else if (readOnlySpan2.StartsWith("server_max_window_bits"))
283 {
284 webSocketDeflateOptions.ServerMaxWindowBits = ParseWindowBits(readOnlySpan2);
285 }
286 }
287 if (num < 0)
288 {
289 break;
290 }
292 extension = readOnlySpan[(num + 1)..];
293 }
294 if (webSocketDeflateOptions.ClientMaxWindowBits > original.ClientMaxWindowBits)
295 {
296 throw new WebSocketException(string.Format(System.SR.net_WebSockets_ClientWindowBitsNegotiationFailure, original.ClientMaxWindowBits, webSocketDeflateOptions.ClientMaxWindowBits));
297 }
298 if (webSocketDeflateOptions.ServerMaxWindowBits > original.ServerMaxWindowBits)
299 {
300 throw new WebSocketException(string.Format(System.SR.net_WebSockets_ServerWindowBitsNegotiationFailure, original.ServerMaxWindowBits, webSocketDeflateOptions.ServerMaxWindowBits));
301 }
304 {
305 int num2 = value.IndexOf('=');
306 if (num2 < 0 || !int.TryParse(value.Slice(num2 + 1), NumberStyles.Integer, CultureInfo.InvariantCulture, out var result) || result < 9 || result > 15)
307 {
308 throw new WebSocketException(WebSocketError.HeaderError, System.SR.Format(System.SR.net_WebSockets_InvalidResponseHeader, "permessage-deflate", value.ToString()));
309 }
310 return result;
311 }
312 }
static CultureInfo InvariantCulture
static string net_WebSockets_InvalidResponseHeader
Definition SR.cs:34
static string Format(string resourceFormat, object p1)
Definition SR.cs:118
static string net_WebSockets_ServerWindowBitsNegotiationFailure
Definition SR.cs:40
static string net_WebSockets_ClientWindowBitsNegotiationFailure
Definition SR.cs:42
Definition SR.cs:7

References System.SR.Format(), System.Format, System.Globalization.CultureInfo.InvariantCulture, System.SR.net_WebSockets_ClientWindowBitsNegotiationFailure, System.SR.net_WebSockets_InvalidResponseHeader, System.SR.net_WebSockets_ServerWindowBitsNegotiationFailure, and System.value.

Referenced by System.Net.WebSockets.WebSocketHandle.ConnectAsync().