From b963fb393d44f084fae53c7e4c4817ce0b3d70f5 Mon Sep 17 00:00:00 2001 From: Wayne Date: Fri, 12 Aug 2022 11:36:50 +1000 Subject: [PATCH] Add custom headers for handshake. --- websocket-sharp/WebSocket.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 3b6619da8..07708bbf7 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -420,6 +420,11 @@ public NetworkCredential Credentials { } } + /// + /// Gets or sets the custom headers + /// + public IEnumerable> CustomHeaders { get; set; } + /// /// Gets or sets a value indicating whether a event /// is emitted when a ping is received. @@ -1419,6 +1424,11 @@ private HttpRequest createHandshakeRequest () if (_cookies.Count > 0) ret.SetCookies (_cookies); + if (CustomHeaders != null) + foreach (var header in CustomHeaders) + if (!headers.Contains(header.Key)) + ret.Headers[header.Key] = header.Value; + return ret; }