diff options
author | Berker Peksag <berker.peksag@gmail.com> | 2015-02-03 10:22:11 (GMT) |
---|---|---|
committer | Berker Peksag <berker.peksag@gmail.com> | 2015-02-03 10:22:11 (GMT) |
commit | ab53ab0a843757d2a40bde1e00a80ea91bcf8402 (patch) | |
tree | e1d75ac172868df83964bd558cccca4d5ea6e186 /Lib/test/test_httplib.py | |
parent | 50457403f2a86769f378b6a57f6f4ed0c7b9cc39 (diff) | |
download | cpython-ab53ab0a843757d2a40bde1e00a80ea91bcf8402.zip cpython-ab53ab0a843757d2a40bde1e00a80ea91bcf8402.tar.gz cpython-ab53ab0a843757d2a40bde1e00a80ea91bcf8402.tar.bz2 |
Issue #13128: Print response headers for CONNECT requests when debuglevel > 0.
Patch by Demian Brecht.
Diffstat (limited to 'Lib/test/test_httplib.py')
-rw-r--r-- | Lib/test/test_httplib.py | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/Lib/test/test_httplib.py b/Lib/test/test_httplib.py index 31d3184..40ef250 100644 --- a/Lib/test/test_httplib.py +++ b/Lib/test/test_httplib.py @@ -1269,17 +1269,18 @@ class TunnelTests(TestCase): 'HTTP/1.1 200 OK\r\n' # Reply to HEAD 'Content-Length: 42\r\n\r\n' ) - - def create_connection(address, timeout=None, source_address=None): - return FakeSocket(response_text, host=address[0], port=address[1]) - self.host = 'proxy.com' self.conn = client.HTTPConnection(self.host) - self.conn._create_connection = create_connection + self.conn._create_connection = self._create_connection(response_text) def tearDown(self): self.conn.close() + def _create_connection(self, response_text): + def create_connection(address, timeout=None, source_address=None): + return FakeSocket(response_text, host=address[0], port=address[1]) + return create_connection + def test_set_tunnel_host_port_headers(self): tunnel_host = 'destination.com' tunnel_port = 8888 @@ -1320,6 +1321,18 @@ 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_tunnel_debuglog(self): + expected_header = 'X-Dummy: 1' + response_text = 'HTTP/1.0 200 OK\r\n{}\r\n\r\n'.format(expected_header) + + self.conn.set_debuglevel(1) + self.conn._create_connection = self._create_connection(response_text) + self.conn.set_tunnel('destination.com') + + with support.captured_stdout() as output: + self.conn.request('PUT', '/', '') + lines = output.getvalue().splitlines() + self.assertIn('header: {}'.format(expected_header), lines) @support.reap_threads |