falcon: request.headers['Host'] is missing
The “Host” header is missing from the request headers when the application is served by Falcon.
This is likely due to async-http
stripping it away in https://github.com/socketry/async-http/blob/f8ead57a4b545aea69df312124b682f7762b7ee4/lib/async/http/protocol/http11.rb#L217
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 16 (12 by maintainers)
The latest release of falcon now uses
http-protocol
which doesn’t delete the host header.https://github.com/socketry/http-protocol/blob/42d6bcb1d68e4e725048f6503a96b52403ed50fe/lib/http/protocol/http11/connection.rb#L128
That being said, the situation with HTTP/2 is far from clear: https://http2.github.io/http2-spec/#rfc.section.8.1.2.3
I think that
#authority
is a good baseline for HTTP/2 and I think that while it’s optional, it was very close to being mandatory. Some more details here:https://www.ietf.org/mail-archive/web/httpbisa/current/msg28630.html
I will leave this issue until we have actually confirmed that this is fixed and then I believe we should figure out ultimately what the behaviour should be like going forward:
falcon serve
add ahost
header so that rack apps that expect it continue to work? (alternatively document the current behaviour).async-http
allow:authority
to be optional (e.g. nil)?I think the best option is indeed the second one: not deleting the
Host
header, but still extracting it for authority. I don’t think that adding it for HTTP/2 makes a lot of sense, although I guess it can be useful for compatibility.