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
My problem with this is that Host is always set, so it will always override the hostname. I don't know if that is intended.
Do you mean that HTTPX always passes a Host header, and so with the changes from #241 we will actually end up always using that instead of the URL hostname? I think that's actually beneficial, since I see Host and :authority as closer in goal than the URL hostname and :authority. But reviewing the definition of :authority might help…
The "Host" header field in a request provides the host and port
information from the target URI, enabling the origin server to
distinguish among resources while servicing requests for multiple
host names on a single IP address.
The ":authority" pseudo-header field includes the authority portion of the target URI ([RFC3986], Section 3.2).
…So, it looks to me like the way you got it in #241 is correct: if Host is present we can use it as :authority, based on the assumption that it's meant to represent the same information than hostname+port. In practice for HTTPX we'll always go this route, but if you were to use HTTPcore itself then you probably wouldn't, so that's not a problem imo.
Activity
lovelydinosaur commentedon Nov 25, 2020
Right, yup. We drop the host header, because HTTP/2 doesn't use it. Instead it has the
:authoritypseudo header...https://tools.ietf.org/html/rfc7540
However, we probably ought to give precedence to the value of
headers["Host"]when setting the:authoritypseudo header. Eg...httpcore/httpcore/_sync/http2.py
Lines 317 to 320 in 84c7738
Should instead perhaps be, this?...
chripede commentedon Nov 25, 2020
That would be great. That would make it possible to always use Host and not worry about 1.1 or 2.
Btw I tried setting the ":authority" header as well, but ended up with two of them.
Do you need me to submit a pull request?
lovelydinosaur commentedon Nov 25, 2020
It'd be great if you could, yup.
chripede commentedon Nov 25, 2020
I submitted a pull request, but wanted some input before fixing for async as well.
My problem with this is that Host is always set, so it will always override the hostname. I don't know if that is intended.
florimondmanca commentedon Nov 26, 2020
@chripede I just saw your comment here:
Do you mean that HTTPX always passes a
Hostheader, and so with the changes from #241 we will actually end up always using that instead of the URLhostname? I think that's actually beneficial, since I seeHostand:authorityas closer in goal than the URLhostnameand:authority. But reviewing the definition of:authoritymight help…florimondmanca commentedon Nov 26, 2020
Well, it seems
Host,:authorityandhostname+portall basically contain the same information:Host: https://tools.ietf.org/html/rfc7230#section-5.4:authority: https://tools.ietf.org/html/rfc7540#section-8.1.2.3…So, it looks to me like the way you got it in #241 is correct: if
Hostis present we can use it as:authority, based on the assumption that it's meant to represent the same information thanhostname+port. In practice for HTTPX we'll always go this route, but if you were to use HTTPcore itself then you probably wouldn't, so that's not a problem imo.chripede commentedon Nov 26, 2020
@florimondmanca Yes maybe I should have mentioned that this was via HTTPX.
I've updated my pull request but are facing some linting problems. Moving the conversation to the pull request
cdeler commentedon Nov 27, 2020
I've merged the PR (#241 (comment)).
But it's reasonable to add new tests to check newly added functionality
florimondmanca commentedon Dec 7, 2020
Closing this since a fix was merged, but I filed #250 to track adding a test case. :-)
Allow Host to override :authority in HTTP2 (encode#241)