mirror of
https://github.com/python/cpython.git
synced 2025-07-24 11:44:31 +00:00
Fix Issue5111 - Wrap the Ipv6 host with [] in the Host header
This commit is contained in:
parent
5ccafbadda
commit
74ebd9e6a3
3 changed files with 28 additions and 0 deletions
|
@ -874,6 +874,13 @@ class HTTPConnection:
|
|||
host_enc = self.host.encode("ascii")
|
||||
except UnicodeEncodeError:
|
||||
host_enc = self.host.encode("idna")
|
||||
|
||||
# As per RFC 273, IPv6 address should be wrapped with []
|
||||
# when used as Host header
|
||||
|
||||
if self.host.find(':') >= 0:
|
||||
host_enc = b'[' + host_enc + b']'
|
||||
|
||||
if self.port == self.default_port:
|
||||
self.putheader('Host', host_enc)
|
||||
else:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue