Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
mib1185 committed Sep 18, 2022
1 parent db69e4f commit 937cb17
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Lib/http/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1198,7 +1198,7 @@ def putrequest(self, method, url, skip_host=False,
# remove interface scope from IPv6 address
# when used as Host header
if host.find('%') >= 0:
host_enc = host_enc[:host.find('%')] + b']'
host_enc = host_enc[:host.find('%')]
host_enc = b'[' + host_enc + b']'

if port == self.default_port:
Expand Down
8 changes: 8 additions & 0 deletions Lib/test/test_httplib.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,14 @@ def test_ipv6host_header(self):
conn.request('GET', '/foo')
self.assertTrue(sock.data.startswith(expected))

expected = b'GET /foo HTTP/1.1\r\nHost: [fe80::]:81\r\n' \
b'Accept-Encoding: identity\r\n\r\n'
conn = client.HTTPConnection('[fe80::%2]:81')
sock = FakeSocket('')
conn.sock = sock
conn.request('GET', '/foo')
self.assertTrue(sock.data.startswith(expected))

def test_malformed_headers_coped_with(self):
# Issue 19996
body = "HTTP/1.1 200 OK\r\nFirst: val\r\n: nval\r\nSecond: val\r\n\r\n"
Expand Down

0 comments on commit 937cb17

Please sign in to comment.