Skip to content

Commit 5a495f8

Browse files
committed
fix
1 parent 56058ab commit 5a495f8

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

Lib/http/client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1222,7 +1222,7 @@ def putrequest(self, method, url, skip_host=False,
12221222
# remove interface scope from IPv6 address
12231223
# when used as Host header
12241224
if host.find('%') >= 0:
1225-
host_enc = host_enc[:host.find('%')] + b']'
1225+
host_enc = host_enc[:host.find('%')]
12261226
host_enc = b'[' + host_enc + b']'
12271227

12281228
if port == self.default_port:

Lib/test/test_httplib.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,14 @@ def test_ipv6host_header(self):
289289
conn.request('GET', '/foo')
290290
self.assertTrue(sock.data.startswith(expected))
291291

292+
expected = b'GET /foo HTTP/1.1\r\nHost: [fe80::]:81\r\n' \
293+
b'Accept-Encoding: identity\r\n\r\n'
294+
conn = client.HTTPConnection('[fe80::%2]:81')
295+
sock = FakeSocket('')
296+
conn.sock = sock
297+
conn.request('GET', '/foo')
298+
self.assertTrue(sock.data.startswith(expected))
299+
292300
def test_malformed_headers_coped_with(self):
293301
# Issue 19996
294302
body = "HTTP/1.1 200 OK\r\nFirst: val\r\n: nval\r\nSecond: val\r\n\r\n"

0 commit comments

Comments
 (0)