Mercurial > cpython-lru_cache-weakref
diff Lib/http/client.py @ 66187:c6b2f417830e
Fix Issue5111 - Wrap the Ipv6 host with [] in the Host header
| author | Senthil Kumaran <orsenthil@gmail.com> |
|---|---|
| date | Sat, 13 Nov 2010 12:27:49 +0000 |
| parents | 846c0e1342d0 |
| children | b6d3fe70802f |
line wrap: on
line diff
--- a/Lib/http/client.py Sat Nov 13 10:43:40 2010 +0000 +++ b/Lib/http/client.py Sat Nov 13 12:27:49 2010 +0000 @@ -874,6 +874,13 @@ 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:
