Returns a dictionary with the headers of the response received from
the proxy server to the CONNECT request.
- If the CONNECT request was not sent, the method returns an empty dictionary.
+ If the CONNECT request was not sent, the method returns ``None``.
.. versionadded:: 3.12
received from the proxy server to the CONNECT request
sent to set the tunnel.
- If the CONNECT request was not sent, the method returns
- an empty dictionary.
+ If the CONNECT request was not sent, the method returns None.
"""
return (
_parse_header_lines(self._raw_proxy_headers)
if self._raw_proxy_headers is not None
- else {}
+ else None
)
def connect(self):
headers = self.conn.get_proxy_response_headers()
self.assertIn(expected_header, headers.items())
+ def test_no_proxy_response_headers(self):
+ expected_header = ('X-Dummy', '1')
+ response_text = (
+ 'HTTP/1.0 200 OK\r\n'
+ '{0}\r\n\r\n'.format(':'.join(expected_header))
+ )
+
+ self.conn._create_connection = self._create_connection(response_text)
+
+ self.conn.request('PUT', '/', '')
+ headers = self.conn.get_proxy_response_headers()
+ self.assertIsNone(headers)
+
def test_tunnel_leak(self):
sock = None