Kaydet (Commit) 461c416d authored tarafından Matt Houglum's avatar Matt Houglum Kaydeden (comit) Serhiy Storchaka

bpo-36522: Print all values for headers with multiple values. (GH-12681)

üst cb0748d3
......@@ -320,8 +320,8 @@ class HTTPResponse(io.BufferedIOBase):
self.headers = self.msg = parse_headers(self.fp)
if self.debuglevel > 0:
for hdr in self.headers:
print("header:", hdr + ":", self.headers.get(hdr))
for hdr, val in self.headers.items():
print("header:", hdr + ":", val)
# are we using the chunked-style of transfer encoding?
tr_enc = self.headers.get("transfer-encoding")
......
......@@ -348,7 +348,8 @@ class HeaderTests(TestCase):
body = (
b'HTTP/1.1 200 OK\r\n'
b'First: val\r\n'
b'Second: val\r\n'
b'Second: val1\r\n'
b'Second: val2\r\n'
)
sock = FakeSocket(body)
resp = client.HTTPResponse(sock, debuglevel=1)
......@@ -357,7 +358,8 @@ class HeaderTests(TestCase):
lines = output.getvalue().splitlines()
self.assertEqual(lines[0], "reply: 'HTTP/1.1 200 OK\\r\\n'")
self.assertEqual(lines[1], "header: First: val")
self.assertEqual(lines[2], "header: Second: val")
self.assertEqual(lines[2], "header: Second: val1")
self.assertEqual(lines[3], "header: Second: val2")
class TransferEncodingTest(TestCase):
......
If *debuglevel* is set to >0 in :mod:`http.client`, print all values for headers with multiple values for the same header name. Patch by Matt Houglum.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment