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

Make the value of the upgrade header the same as the RFC. #187

Merged
merged 3 commits into from
Dec 23, 2023

Conversation

palkeo
Copy link
Contributor

@palkeo palkeo commented Dec 11, 2023

As per https://datatracker.ietf.org/doc/html/rfc6455#section-4.2.1 the "Upgrade" header should have the value "websocket", and the server should treat it as case-insensitive.

However, sadly some servers don't respect that case-insentitivity, so better to use exactly the string as specified in the RFC.

That's what the other websocket implementations do. See for example: https://github.com/python-websockets/websockets/blob/94dd203f63bb52b1a30faa228e63ada2f0f2e874/src/websockets/client.py#L119

As per https://datatracker.ietf.org/doc/html/rfc6455#section-4.2.1 the "Upgrade" header should have
the value "websocket", and the server should treat it as case-insensitive.

However, sadly some servers don't respect that case-insentitivity, so better to use exactly the
string as specified in the RFC.

That's what the other websocket implementations do. See for example:
https://github.com/python-websockets/websockets/blob/94dd203f63bb52b1a30faa228e63ada2f0f2e874/src/websockets/client.py#L119
@Kriechi
Copy link
Member

Kriechi commented Dec 12, 2023

Since this value seems to be important to follow the spec, how about pulling it out into a CONSTANT and then re-using it in all the places you now touched, instead of hard-coding it?

We already have this similar one:

WEBSOCKET_VERSION = b"13"

Otherwise, I think I'm 👍 for this change! thanks for catching it!

@palkeo
Copy link
Contributor Author

palkeo commented Dec 17, 2023

Good point, I moved it into a constant.

I kept it hardcoded for tests, I think it makes sense to check the end result there. WEBSOCKET_VERSION is also hardcoded in a test.

@Kriechi
Copy link
Member

Kriechi commented Dec 19, 2023

meta comment: CI lint failed for unrelated reasons.

@Kriechi Kriechi merged commit 9423fc0 into python-hyper:main Dec 23, 2023
6 of 8 checks passed
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.

2 participants