-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
enforce rfc6455 section 4.2.1 requirement to refuse malformed Websocket handshake #10729
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
base: master
Are you sure you want to change the base?
Conversation
CodSpeed Performance ReportMerging #10729 will not alter performanceComparing Summary
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #10729 +/- ##
=======================================
Coverage 98.72% 98.72%
=======================================
Files 125 125
Lines 37722 37755 +33
Branches 2082 2083 +1
=======================================
+ Hits 37240 37273 +33
Misses 334 334
Partials 148 148
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Responding "HTTP/1.1 101 Switching Protocols" to a HEAD or POST request is unlikely intended. Spec says **"MUST stop"** for non-GET requests: https://datatracker.ietf.org/doc/html/rfc6455#section-4.2.1 There is precedent for being strict about 1xx informational responses that might confuse a proxy, see expect-100 processing.
The release notes that added the client-side functionality says:
I don't know if that's still true, but if so, it may be desirable to be able to imitate the same behaviour. (We've seen this also in aiohttp-sse, where several users need to be compatible with some client that does POST requests for SSE connection). |
For aiohttp-sse, we ended up removing the check with a flag, so people couldn't use a non-GET endpoint without explicitly opting into it (this helped avoid the situation of a backend developer creating POST endpoints, and then the frontend developers telling them after it's deployed that they can't connect to it, because browsers only allow GET requests). |
This probably needs to be controlled by a flag so that users can opt out if needed. I don’t think #3980 would’ve been merged unless it was addressing a real issue, so we should be cautious about changing the behavior outright. If the flag is unset, we should default to the current 3.x behavior for now. In 4.x, we can flip the default so that only To help with the transition, 3.x should log a deprecation warning whenever a non- |
What do these changes do?
I only noticed this was previously in place and had been removed in #3980 after writing this. I do not believe it should have been, given that proxies may depend on the clear language in the spec.
Are there changes in behavior for the user?
Is it a substantial burden for the maintainers to support this?
References
https://websockets.spec.whatwg.org/
https://datatracker.ietf.org/doc/html/rfc9110#field.upgrade
https://docs.aiohttp.org/en/stable/web_quickstart.html#websockets
I have failed to identify which client issue motivated supporting non-rfc6455 websocket handshake, but recent docker versions are clearly expecting GET for the relevant API endpoint.
Related issue number
Checklist
CHANGES/
folder