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

◆ AddWebSocketHeaders()

static void System.Net.WebSockets.WebSocketHandle.AddWebSocketHeaders ( HttpRequestMessage request,
string secKey,
ClientWebSocketOptions options )
inlinestaticprivate

Definition at line 314 of file WebSocketHandle.cs.

315 {
316 request.Headers.TryAddWithoutValidation("Connection", "Upgrade");
317 request.Headers.TryAddWithoutValidation("Upgrade", "websocket");
318 request.Headers.TryAddWithoutValidation("Sec-WebSocket-Version", "13");
319 request.Headers.TryAddWithoutValidation("Sec-WebSocket-Key", secKey);
320 List<string> requestedSubProtocols = options._requestedSubProtocols;
322 {
323 request.Headers.TryAddWithoutValidation("Sec-WebSocket-Protocol", string.Join(", ", options.RequestedSubProtocols));
324 }
325 if (options.DangerousDeflateOptions != null)
326 {
327 request.Headers.TryAddWithoutValidation("Sec-WebSocket-Extensions", GetDeflateOptions(options.DangerousDeflateOptions));
328 }
329 static string GetDeflateOptions(WebSocketDeflateOptions options)
330 {
332 stringBuilder.Append("permessage-deflate").Append("; ");
333 if (options.ClientMaxWindowBits != 15)
334 {
338 IFormatProvider provider = invariantCulture;
340 handler.AppendFormatted("client_max_window_bits");
341 handler.AppendLiteral("=");
342 handler.AppendFormatted(options.ClientMaxWindowBits);
343 stringBuilder3.Append(provider, ref handler);
344 }
345 else
346 {
347 stringBuilder.Append("client_max_window_bits");
348 }
349 if (!options.ClientContextTakeover)
350 {
351 stringBuilder.Append("; ").Append("client_no_context_takeover");
352 }
353 if (options.ServerMaxWindowBits != 15)
354 {
358 IFormatProvider provider2 = invariantCulture;
360 handler2.AppendLiteral("; ");
361 handler2.AppendFormatted("server_max_window_bits");
362 handler2.AppendLiteral("=");
363 handler2.AppendFormatted(options.ServerMaxWindowBits);
365 }
366 if (!options.ServerContextTakeover)
367 {
368 stringBuilder.Append("; ").Append("server_no_context_takeover");
369 }
370 return stringBuilder.ToString();
371 }
372 }
static CultureInfo InvariantCulture

References System.Text.StringBuilder.AppendInterpolatedStringHandler.AppendFormatted(), System.Text.StringBuilder.AppendInterpolatedStringHandler.AppendLiteral(), System.Collections.Generic.Dictionary< TKey, TValue >.Count, System.Globalization.CultureInfo.InvariantCulture, System.Threading.Tasks.Join, and System.options.

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