classification
Title: httplib: wrong Host header when connecting to IPv6 link-local address
Type: behavior Stage: needs patch
Components: Library (Lib) Versions: Python 3.7, Python 3.6, Python 3.5, Python 2.7
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: JonathanGuthrie, gregory.p.smith, martin.panter
Priority: normal Keywords:

Created on 2017-01-25 20:14 by JonathanGuthrie, last changed 2017-01-26 21:13 by JonathanGuthrie.

Messages (3)
msg286276 - (view) Author: Jonathan Guthrie (JonathanGuthrie) Date: 2017-01-25 20:14
This is related to issue 5111.

An IPv6 link-local address must include a scope specifier as part of the address passed to the HTTPConnection or HTTPSConnection constructor, that scope specifier is not being stripped from the address passed in the HTTP 1.1 Host: header line.

So, suppose I was attempting to connect to an HTTP server on fe80::8aae:1dff:fea4:29c8.  That's a link-local address, so I must give the scope specifier, which is the interface I can use to connect to that address.  So, the address I would pass to the HTTPConnection constructor might look like "fe80::8aae:1dff:fea4:29c8%eth0".  The appropriate Host line in the HTTP request would be "Host: [fe80::8aae:1dff:fea4:29c8]" but it is actually "Host: [fe80::8aae:1dff:fea4:29c8%eth0]"

Compliant HTTP servers reject requests including this line as malformed.
msg286286 - (view) Author: Martin Panter (martin.panter) * (Python committer) Date: 2017-01-25 23:18
More closely related: Issue 23448, about the same thing with urllib, which adds the Host value itself. Any solution should be shared between both modules.
msg286333 - (view) Author: Jonathan Guthrie (JonathanGuthrie) Date: 2017-01-26 21:13
Yes, it is more closely related to Issue 23448.  My search for related issues apparently wasn't exhaustive enough.
History
Date User Action Args
2017-01-26 21:13:35JonathanGuthriesetmessages: + msg286333
2017-01-25 23:18:40martin.pantersetnosy: + martin.panter
messages: + msg286286
2017-01-25 22:19:32gregory.p.smithsetnosy: + gregory.p.smith
2017-01-25 21:22:30martin.pantersetstage: needs patch
components: + Library (Lib)
versions: + Python 3.6, Python 3.7
2017-01-25 20:14:44JonathanGuthriecreate