Summary:
The API proposal comes after I was required to read response headers after making a WS handshake. Currently there is no way to see what response headers were returned after connecting to a WS server.
Rational & Usage:
For my use case, the current usage would be to figure out if a session was resumed by reading the response headers after re-establishing a WS connection.
Here is where the use case is properly described: https://github.com/Frederikam/Lavalink/blob/master/IMPLEMENTATION.md#resuming-lavalink-sessions
Further more, it can allow people to read any custom headers sent in response.
Proposed API:
Expose a property called Headers in ClientWebSocket/WebSocket class.
public HttpResponseHeaders Headers
{
get
{
if (_headers == null)
throw new NullReferenceException("WebSocket connection hasn't started yet.");
return _headers;
}
}
private HttpResponseHeaders _headers;
And where headers are validated: https://github.com/dotnet/corefx/blob/master/src/System.Net.WebSockets.Client/src/System/Net/WebSockets/WebSocketHandle.Managed.cs#L181-L183
The _headers can be set once the required headers are validated.
ValidateHeader(response.Headers, HttpKnownHeaderNames.Connection, "Upgrade");
ValidateHeader(response.Headers, HttpKnownHeaderNames.Upgrade, "websocket");
ValidateHeader(response.Headers, HttpKnownHeaderNames.SecWebSocketAccept, secKeyAndSecWebSocketAccept.Value);
_headers = response.Headers;
Original Post:
Hi! Pardon me if I opened the issue in the wrong repo.
I was wondering if there was a way to get response headers after ws handshake was completed.
Something like WebSocketReceiveResult.Headers or similar.
Not sure if I'm looking in the right place. Any help will be appreciated.
Cheers!
Summary:The API proposal comes after I was required to read response headers after making a WS handshake. Currently there is no way to see what response headers were returned after connecting to a WS server.
Rational & Usage:For my use case, the current usage would be to figure out if a session was resumed by reading the response headers after re-establishing a WS connection.
Here is where the use case is properly described: https://github.com/Frederikam/Lavalink/blob/master/IMPLEMENTATION.md#resuming-lavalink-sessions
Further more, it can allow people to read any custom headers sent in response.
Proposed API:Expose a property called Headers in ClientWebSocket/WebSocket class.
And where headers are validated: https://github.com/dotnet/corefx/blob/master/src/System.Net.WebSockets.Client/src/System/Net/WebSockets/WebSocketHandle.Managed.cs#L181-L183
The
_headerscan be set once the required headers are validated.Original Post:Hi! Pardon me if I opened the issue in the wrong repo.
I was wondering if there was a way to get response headers after ws handshake was completed.
Something like
WebSocketReceiveResult.Headersor similar.Not sure if I'm looking in the right place. Any help will be appreciated.
Cheers!