WebSockets over HTTP/2 are currently not supported. It is defined in RFC 8441 (websockets over HTTP/3 are defined in RFC 9220 and it is exactly the same as HTTP/2).
Solution
Implement the changes necessary to support them, which just requires looking at the :protocol pseudo-header in the websocket extractor and advertising our support by enabling SETTINGS_ENABLE_CONNECT_PROTOCOL in HTTP/2.
Additionally, I needed to fix the handling of responses to CONNECT requests: Axum was incorrectly adding the Content-Length header to them (see also https://github.com/hyperium/hyper/pull/3748), which was causing things to break.
Motivation
WebSockets over HTTP/2 are currently not supported. It is defined in RFC 8441 (websockets over HTTP/3 are defined in RFC 9220 and it is exactly the same as HTTP/2).
Solution
Implement the changes necessary to support them, which just requires looking at the
:protocol
pseudo-header in the websocket extractor and advertising our support by enablingSETTINGS_ENABLE_CONNECT_PROTOCOL
in HTTP/2.Additionally, I needed to fix the handling of responses to CONNECT requests: Axum was incorrectly adding the
Content-Length
header to them (see also https://github.com/hyperium/hyper/pull/3748), which was causing things to break.