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 Origin Header in native app #27

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

Its-Just-Nans
Copy link

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 :

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

Thanks

log = "0.4"

# native:
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
tungstenite = { version = ">=0.17, <=0.20" }
tungstenite = { version = ">=0.17, <=0.21" }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this needs to be set to the version number of the first tungstenite release with the with_header function

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes you're right !
I'm waiting for the new version. I'm tagging the PR as DRAFT to wait for it

@Its-Just-Nans
Copy link
Author

When tungstenite 0.22.0 will be out, this PR should fix

Now waiting for the version bump

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants