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

Properly respond with sec-websocket-protocol under http/2 #3141

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

coolreader18
Copy link

@coolreader18 coolreader18 commented Jan 3, 2025

Motivation

Was looking at the ws code and noticed that the subprotocol never gets properly communicated to the client if the connection is HTTP/2.

Solution

Add the sec-websocket-protocol header irrespective of HTTP version. A response with that header is still a valid HTTP/2 websocket handshake, as per RFC8441.

@jplatte
Copy link
Member

jplatte commented Jan 3, 2025

cc @SabrinaJewson

@SabrinaJewson
Copy link
Contributor

Ah, looks good! Can you modify the http2 test to check for this as well? (Or write a new test)

axum/src/extract/ws.rs Outdated Show resolved Hide resolved
@coolreader18 coolreader18 force-pushed the http2-websocket-subprotocol branch from 9a4f267 to 95f2535 Compare January 6, 2025 16:01
finnbear added a commit to finnbear/axum-tws that referenced this pull request Jan 15, 2025
finnbear added a commit to finnbear/axum-tws that referenced this pull request Jan 15, 2025
robertwayne pushed a commit to robertwayne/axum-tws that referenced this pull request Jan 16, 2025
* Port HTTP/2 support.

* Port tokio-rs/axum#3141
@jplatte jplatte requested review from yanns and Turbo87 January 28, 2025 23:52
Copy link
Collaborator

@Turbo87 Turbo87 left a comment

Choose a reason for hiding this comment

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

I could click on "Approve" but I have very little knowledge about WebSocket internals, so I'd rather have those with more experience in this area chime in 😅

@yanns
Copy link
Collaborator

yanns commented Jan 29, 2025

Same here, no knowledge in WS in HTTP2.
@SabrinaJewson would be more knowledgeable?

@Turbo87 You haven't approved AFAIS:
Screenshot 2025-01-29 at 11 28 06

@Turbo87
Copy link
Collaborator

Turbo87 commented Jan 29, 2025

You haven't approved AFAIS

yeah, that was intentional. I didn't want to approve anything I don't have a clue about :D

Copy link
Contributor

@SabrinaJewson SabrinaJewson left a comment

Choose a reason for hiding this comment

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

Yeah, sorry I didn’t say before but this looks good.

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.

5 participants