summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorSenthil Kumaran <orsenthil@gmail.com>2010-11-13 12:27:49 (GMT)
committerSenthil Kumaran <orsenthil@gmail.com>2010-11-13 12:27:49 (GMT)
commit74ebd9e6a3c50b7816e5d11423c298acb5b7af81 (patch)
treec4219ed199d30167fee966c27b21717cc44f7bfa /Lib/test
parent5ccafbadda7a56d71389c63aa229623e703f655a (diff)
downloadcpython-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/test')
-rw-r--r--Lib/test/test_httplib.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/Lib/test/test_httplib.py b/Lib/test/test_httplib.py
index c3bafea..c5c0f7a 100644
--- a/Lib/test/test_httplib.py
+++ b/Lib/test/test_httplib.py
@@ -106,6 +106,25 @@ class HeaderTests(TestCase):
conn.putheader('Content-length', 42)
self.assertTrue(b'Content-length: 42' in conn._buffer)
+ def test_ipv6host_header(self):
+ # Default host header on IPv6 transaction should wrapped by [] if
+ # its actual IPv6 address
+ expected = b'GET /foo HTTP/1.1\r\nHost: [2001::]:81\r\n' \
+ b'Accept-Encoding: identity\r\n\r\n'
+ conn = client.HTTPConnection('[2001::]:81')
+ sock = FakeSocket('')
+ conn.sock = sock
+ conn.request('GET', '/foo')
+ self.assertTrue(sock.data.startswith(expected))
+
+ expected = b'GET /foo HTTP/1.1\r\nHost: [2001:102A::]\r\n' \
+ b'Accept-Encoding: identity\r\n\r\n'
+ conn = client.HTTPConnection('[2001:102A::]')
+ sock = FakeSocket('')
+ conn.sock = sock
+ conn.request('GET', '/foo')
+ self.assertTrue(sock.data.startswith(expected))
+
class BasicTest(TestCase):
def test_status_lines(self):