-
Notifications
You must be signed in to change notification settings - Fork 111
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
How do I send websocket headers with WebSocketChannel.connect? #237
Comments
i'm was also looking for that possibility and as i see it's impossible because |
You can use
|
Crossplatform solution needed instead of |
@AlexanderShniperson I think that you are correct - there is no way to support this on the web because the WebSocket API does not support setting headers. |
For the initial HTTP handshake, it does not appear Dart sends an 'Origin' header, which sometimes can be optionally sent (thus why OP may have filed the issue). But a larger problem I have is that I have a WebSocket server that is case-sensitive, and by default Dart likes to convert these headers to lowercase. There is a way to preserve the case if you create the connection yourself:
But then there is no way to use this with WebSocketChannel, so I would have to create my own sink handling, which is doable, but this library exists already so if there was a way to either preserve header case directly from the library, that would be cool, but also allowing WebSocketChannel to take in an existing WebSocket could be nice too. Obviously, the correct solution is for the server to be case-insensitive, but in some scenarios you don't have access to the server to correct the behavior. Someone else had this issue a few years ago and tried submitting a PR for the internal WebSocket class to allow preserving the case, but it appears to be stale: dart-lang/sdk#50378. |
@NotTsunami I think that the request here was for the solution to be cross-platform, not require dart:io. |
Sure, I was kind of expanding on why OP might need it and clarifying that there is a valid use for appending additional headers. The rest of it is semi-related but mostly mumbo-jumbo I can extract into another issue. |
No description provided.
The text was updated successfully, but these errors were encountered: