socket.io-client-csharp
socket.io-client-csharp copied to clipboard
Extra Headers are not taking JSON payloads
public void Initialize()
{
var client = new SocketIOClient.SocketIO("http://mywebsocket", new SocketIOOptions
{
ExtraHeaders = new Dictionary<string, string>
{
{"Authorization", "{\"id\":123, \"first_name\":\"A\", \"last_name\":\"A\", \"username\":\"A\", \"auth_date\":123, \"hash\":\"gjsdkgbskjdgbkasjdbgjkasbdjgkasdgbjkasbdkagjk\"}"},
{"SessionID", "test" }
}
});
client.ConnectAsync().Wait();
}
Seems like ExtraHeaders are not taking any stringified JSON data. Once you do this it stops sending out any requests.
the reason is that the header "Authorization" is a special header. when you try to add it, .NET will try to validate value first. Sure the value you provided is invalid.
the issue same as https://github.com/doghappy/socket.io-client-csharp/issues/300
so how to solve it?
- try to use another header name
- allow "authorization" header. https://github.com/doghappy/socket.io-client-csharp/blob/956d919dee578ae385597b8427278ae2c454de41/src/SocketIOClient/Transport/Http/DefaultHttpClient.cs#L21-L24
for option2, actually I have implemented but I need to do some research.