You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To correctly handle WebSockets, HTTP/1 requires the use of the upgrade headers, while HTTP/2 requires the use of :protocol pseudo header.
We don't have any mechanism like we discussed in #1878 for putting these pseudo headers into env.
Therefore, I've been using rack.protocol and mapping it specially.
In HTTP/1, the upgrade header is mapped to rack.protocol, can contain multiple values, and the 101 response should include the specific protocol upgrade. Response should include rack.protocol to indicate an upgrade.
In HTTP/2, the :protocol pseudo header is mapped to rack.protocol, can only contain a single value, and the 200 response indicates that the stream will transport that protocol.
Another option is to map HTTP/2 :protocol header to env["HTTP_UPGRADE"] although this feels a little ugly, and the same with the response header. HTTP/2 RFCs explicitly call out that this is invalid, that the headers are not the same. However, if we consider rack through the lens of a CGI gateway, this is probably acceptable - except that we don't do this strictly for other features.
If we can discuss this and get agreement on a specification, I'll create a PR. This is not urgent, but it would be nice to have, and to be compatible with Falcon's existing behaviour where possible. If not, it's okay to change.
The text was updated successfully, but these errors were encountered:
ioquatix
changed the title
Consider introducing rack.protocol env and response variable.
Consider introducing rack.protocol env variable.
Aug 7, 2022
To correctly handle WebSockets, HTTP/1 requires the use of the upgrade headers, while HTTP/2 requires the use of
:protocol
pseudo header.We don't have any mechanism like we discussed in #1878 for putting these pseudo headers into
env
.Therefore, I've been using
rack.protocol
and mapping it specially.upgrade
header is mapped torack.protocol
, can contain multiple values, and the 101 response should include the specific protocol upgrade. Response should includerack.protocol
to indicate an upgrade.:protocol
pseudo header is mapped torack.protocol
, can only contain a single value, and the 200 response indicates that the stream will transport that protocol.Another option is to map HTTP/2
:protocol
header toenv["HTTP_UPGRADE"]
although this feels a little ugly, and the same with the response header. HTTP/2 RFCs explicitly call out that this is invalid, that the headers are not the same. However, if we consider rack through the lens of a CGI gateway, this is probably acceptable - except that we don't do this strictly for other features.If we can discuss this and get agreement on a specification, I'll create a PR. This is not urgent, but it would be nice to have, and to be compatible with Falcon's existing behaviour where possible. If not, it's okay to change.
The text was updated successfully, but these errors were encountered: