bpo-33365: print the header values beside the keys (GH-6611) · python/cpython@936f03e · GitHub
Skip to content

Commit 936f03e

Browse files
lethlielserhiy-storchaka
authored andcommitted
bpo-33365: print the header values beside the keys (GH-6611)
with debuglevel=1 only the header keys got printed. With this change the header values get printed as well and the single header entries get '\n' as a separator.
1 parent 1261bfa commit 936f03e

3 files changed

Lines changed: 17 additions & 1 deletion

File tree

Lib/http/client.py

Lines changed: 1 addition & 1 deletion

Lib/test/test_httplib.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,21 @@ def test_invalid_headers(self):
344344
with self.assertRaisesRegex(ValueError, 'Invalid header'):
345345
conn.putheader(name, value)
346346

347+
def test_headers_debuglevel(self):
348+
body = (
349+
b'HTTP/1.1 200 OK\r\n'
350+
b'First: val\r\n'
351+
b'Second: val\r\n'
352+
)
353+
sock = FakeSocket(body)
354+
resp = client.HTTPResponse(sock, debuglevel=1)
355+
with support.captured_stdout() as output:
356+
resp.begin()
357+
lines = output.getvalue().splitlines()
358+
self.assertEqual(lines[0], "reply: 'HTTP/1.1 200 OK\\r\\n'")
359+
self.assertEqual(lines[1], "header: First: val")
360+
self.assertEqual(lines[2], "header: Second: val")
361+
347362

348363
class TransferEncodingTest(TestCase):
349364
expected_body = b"It's just a flesh wound"
Lines changed: 1 addition & 0 deletions

0 commit comments

Comments
 (0)