diff options
author | Senthil Kumaran <orsenthil@gmail.com> | 2010-11-14 03:31:52 +0000 |
---|---|---|
committer | Senthil Kumaran <orsenthil@gmail.com> | 2010-11-14 03:31:52 +0000 |
commit | 501bfd8f5c29cddc8f74c67e862f582929c16ed1 (patch) | |
tree | 441e5dab435fa45f58d599ffdcdede8175e5b2cf /Lib/test/test_httplib.py | |
parent | db4c334e0dfe62d4fbf189d53c95c1e90ef1a1ca (diff) | |
download | cpython-git-501bfd8f5c29cddc8f74c67e862f582929c16ed1.tar.gz |
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/test/test_httplib.py')
-rw-r--r-- | Lib/test/test_httplib.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/Lib/test/test_httplib.py b/Lib/test/test_httplib.py index 74301ff39a..d7b73e131e 100644 --- a/Lib/test/test_httplib.py +++ b/Lib/test/test_httplib.py @@ -97,6 +97,26 @@ class HeaderTests(TestCase): conn.putheader('Content-length',42) self.assertTrue('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 = 'GET /foo HTTP/1.1\r\nHost: [2001::]:81\r\n' \ + 'Accept-Encoding: identity\r\n\r\n' + conn = httplib.HTTPConnection('[2001::]:81') + sock = FakeSocket('') + conn.sock = sock + conn.request('GET', '/foo') + self.assertTrue(sock.data.startswith(expected)) + + expected = 'GET /foo HTTP/1.1\r\nHost: [2001:102A::]\r\n' \ + 'Accept-Encoding: identity\r\n\r\n' + conn = httplib.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): # Test HTTP status lines |