diff options
| author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2024-02-17 13:01:48 (GMT) |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-02-17 13:01:48 (GMT) |
| commit | 23aef575c7629abcd4aaf028ebd226fb41a4b3c8 (patch) | |
| tree | b1e7973211aaa17b8f6ac1a262f330da3b6b93f7 /Lib/test/test_httplib.py | |
| parent | 9148b77e0af91cdacaa7fe3dfac09635c3fe9a74 (diff) | |
| download | cpython-23aef575c7629abcd4aaf028ebd226fb41a4b3c8.zip cpython-23aef575c7629abcd4aaf028ebd226fb41a4b3c8.tar.gz cpython-23aef575c7629abcd4aaf028ebd226fb41a4b3c8.tar.bz2 | |
[3.12] gh-100985: Consistently wrap IPv6 IP address during CONNECT (GH-100986) (GH-115591)
Update _get_hostport to always remove square brackets
from IPv6 addresses. Then add them if needed
in "CONNECT .." and "Host: ".
(cherry picked from commit 465db27cb983084e718a1fd9519b2726c96935cb)
Co-authored-by: Derek Higgins <derekh@redhat.com>
Diffstat (limited to 'Lib/test/test_httplib.py')
| -rw-r--r-- | Lib/test/test_httplib.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/Lib/test/test_httplib.py b/Lib/test/test_httplib.py index 089bf5b..6e63a88 100644 --- a/Lib/test/test_httplib.py +++ b/Lib/test/test_httplib.py @@ -2408,6 +2408,22 @@ class TunnelTests(TestCase): self.assertIn(b'PUT / HTTP/1.1\r\nHost: %(host)s\r\n' % d, self.conn.sock.data) + def test_connect_put_request_ipv6(self): + self.conn.set_tunnel('[1:2:3::4]', 1234) + self.conn.request('PUT', '/', '') + self.assertEqual(self.conn.sock.host, self.host) + self.assertEqual(self.conn.sock.port, client.HTTP_PORT) + self.assertIn(b'CONNECT [1:2:3::4]:1234', self.conn.sock.data) + self.assertIn(b'Host: [1:2:3::4]:1234', self.conn.sock.data) + + def test_connect_put_request_ipv6_port(self): + self.conn.set_tunnel('[1:2:3::4]:1234') + self.conn.request('PUT', '/', '') + self.assertEqual(self.conn.sock.host, self.host) + self.assertEqual(self.conn.sock.port, client.HTTP_PORT) + self.assertIn(b'CONNECT [1:2:3::4]:1234', self.conn.sock.data) + self.assertIn(b'Host: [1:2:3::4]:1234', self.conn.sock.data) + def test_tunnel_debuglog(self): expected_header = 'X-Dummy: 1' response_text = 'HTTP/1.0 200 OK\r\n{}\r\n\r\n'.format(expected_header) |
