mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
[3.11] gh-100985: Consistently wrap IPv6 IP address during CONNECT (GH-100986) (GH-115606)
Update _get_hostport to always remove square brackets
from IPv6 addresses. Then add them if needed
in "CONNECT .." and "Host: ".
(cherry picked from commit 465db27cb9
)
Co-authored-by: Derek Higgins <derekh@redhat.com>
This commit is contained in:
parent
a6776cdc53
commit
6fbc61070f
4 changed files with 29 additions and 5 deletions
|
@ -2267,6 +2267,22 @@ class TunnelTests(TestCase):
|
|||
self.assertIn(b'CONNECT destination.com', self.conn.sock.data)
|
||||
self.assertIn(b'Host: destination.com', 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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue