-
Notifications
You must be signed in to change notification settings - Fork 226
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 builder for additional header values #400
Add builder for additional header values #400
Conversation
This would be great to simulate a connection from a browser !
@ManevilleF I've made a PR on your repo ManevilleF#1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NB: These changes might indeed be useful, but the CI pipeline fails. I also think writing a couple of tests for the subprotocol functionality would be useful.
Doc correct to pass the CI
@ManevilleF I'v made PR once again on your repo to correct doc (once again 😅) and add a test Link to the PR: ManevilleF#2 Maybe after you merged it @daniel-abramov could merge this one! |
Corrections and add test
Nice. Btw, one of the CI steps fails. I did not check it in a detail, but my first guess is that the new example might require enabling some features. |
Thanks for the tip ! @ManevilleF If you add
at the top of the test file I guess it should work ? |
Hello, In the native app, the Websocket protocol can lead to error because it doesn't act like the web interface. When we are using the WebSocket API (in the browser), it add automatically some headers - like the `Origin` header. In fact this header is mandatory, as explained in the RFC : - <https://datatracker.ietf.org/doc/html/rfc6455> ```text 8. The request MUST include a header field with the name |Origin| [[RFC6454](https://datatracker.ietf.org/doc/html/rfc6454)] if the request is coming from a browser client. If the connection is from a non-browser client, the request MAY include this header field if the semantics of that client match the use-case described here for browser clients. The value of this header field is the ASCII serialization of origin of the context in which the code establishing the connection is running. See [[RFC6454](https://datatracker.ietf.org/doc/html/rfc6454)] for the details of how this header field value is constructed. ``` However, if we don't set the `Origin` header in the native app, the app "could" not act the same as in the browser In this PR, I had the Origin header to the client. Note that - the PR to add a header in tungstenite is quite new : snapview/tungstenite-rs#400 - a new version of tungstenite has not been released yet (so this PR is kind of a draft) Thanks --------- Co-authored-by: Emil Ernerfeldt <[email protected]>
Work done
Added a
ClientRequestBuilder
type inspired by websockets to allow for additional header values in the request, like authorization or subprotocols.The way I implemented this is not the cleanest but I wanted to avoid any breaking change.
This is merely a proposal, so feedback welcome !