Skip to content

Conversation

@coolreader18
Copy link
Contributor

@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)

@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 Turbo87 and yanns 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.

@yanns
Copy link
Collaborator

yanns commented Jan 30, 2025

Should we add a changelog entry for this?

@jplatte jplatte merged commit 6c9cabf into tokio-rs:main Feb 1, 2025
18 checks passed
@jplatte
Copy link
Member

jplatte commented Feb 1, 2025

We probably should, but I merged because I think asking the original author to update their PR after it previously being stuck for a month is a bit annoying.

Feel free to open a PR; otherwise I'll do it myself at some point.

@coolreader18 coolreader18 deleted the http2-websocket-subprotocol branch March 5, 2025 18:55
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