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

Consider introducing rack.protocol env variable. #1946

Open
ioquatix opened this issue Aug 7, 2022 · 1 comment
Open

Consider introducing rack.protocol env variable. #1946

ioquatix opened this issue Aug 7, 2022 · 1 comment

Comments

@ioquatix
Copy link
Member

ioquatix commented 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.

  • 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.

@ioquatix
Copy link
Member Author

Another example of this problem: socketry/falcon#202

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

No branches or pull requests

1 participant