Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add custom headers for handshake. #704

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions websocket-sharp/WebSocket.cs
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,11 @@ public NetworkCredential Credentials {
}
}

/// <summary>
/// Gets or sets the custom headers
/// </summary>
public IEnumerable<KeyValuePair<string, string>> CustomHeaders { get; set; }

/// <summary>
/// Gets or sets a value indicating whether a <see cref="OnMessage"/> event
/// is emitted when a ping is received.
Expand Down Expand Up @@ -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;
}

Expand Down