summaryrefslogtreecommitdiffstats
path: root/Lib/http
diff options
context:
space:
mode:
authorSenthil Kumaran <orsenthil@gmail.com>2010-11-14 03:14:52 (GMT)
committerSenthil Kumaran <orsenthil@gmail.com>2010-11-14 03:14:52 (GMT)
commit2e89cf3465763ba9d048e8cac15cae14be201d27 (patch)
tree4890f8db85965f31b698199c672319daac1a4945 /Lib/http
parent650db5bd682eb7bdcaf8e4841999c5573caf3aeb (diff)
downloadcpython-2e89cf3465763ba9d048e8cac15cae14be201d27.zip
cpython-2e89cf3465763ba9d048e8cac15cae14be201d27.tar.gz
cpython-2e89cf3465763ba9d048e8cac15cae14be201d27.tar.bz2
Merged revisions 86450 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k ........ r86450 | senthil.kumaran | 2010-11-13 20:27:49 +0800 (Sat, 13 Nov 2010) | 3 lines Fix Issue5111 - Wrap the Ipv6 host with [] in the Host header ........
Diffstat (limited to 'Lib/http')
-rw-r--r--Lib/http/client.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/Lib/http/client.py b/Lib/http/client.py
index f273b03..bd092c2 100644
--- a/Lib/http/client.py
+++ b/Lib/http/client.py
@@ -873,6 +873,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: