diff options
author | Senthil Kumaran <orsenthil@gmail.com> | 2010-11-13 12:27:49 (GMT) |
---|---|---|
committer | Senthil Kumaran <orsenthil@gmail.com> | 2010-11-13 12:27:49 (GMT) |
commit | 74ebd9e6a3c50b7816e5d11423c298acb5b7af81 (patch) | |
tree | c4219ed199d30167fee966c27b21717cc44f7bfa /Lib/http | |
parent | 5ccafbadda7a56d71389c63aa229623e703f655a (diff) | |
download | cpython-74ebd9e6a3c50b7816e5d11423c298acb5b7af81.zip cpython-74ebd9e6a3c50b7816e5d11423c298acb5b7af81.tar.gz cpython-74ebd9e6a3c50b7816e5d11423c298acb5b7af81.tar.bz2 |
Fix Issue5111 - Wrap the Ipv6 host with [] in the Host header
Diffstat (limited to 'Lib/http')
-rw-r--r-- | Lib/http/client.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/Lib/http/client.py b/Lib/http/client.py index 6c38c4a..0059b51 100644 --- a/Lib/http/client.py +++ b/Lib/http/client.py @@ -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: |