Commit a48d9eaa authored by Benjamin Peterson's avatar Benjamin Peterson

improve set_tunnel docs (closes #11448)

Patch by Ryan Kelly, karl, and Nikolaus Rath.
parent fda33559
...@@ -451,11 +451,25 @@ HTTPConnection Objects ...@@ -451,11 +451,25 @@ HTTPConnection Objects
.. method:: HTTPConnection.set_tunnel(host, port=None, headers=None) .. method:: HTTPConnection.set_tunnel(host, port=None, headers=None)
Set the host and the port for HTTP Connect Tunnelling. Normally used when it Set the host and the port for HTTP Connect Tunnelling. This allows running
is required to a HTTPS Connection through a proxy server. the connection through a proxy server.
The headers argument should be a mapping of extra HTTP headers to send The host and port arguments specify the endpoint of the tunneled connection
with the CONNECT request. (i.e. the address included in the CONNECT request, *not* the address of the
proxy server).
The headers argument should be a mapping of extra HTTP headers to send with
the CONNECT request.
For example, to tunnel through a HTTPS proxy server running locally on port
8080, we would pass the address of the proxy to the :class:`HTTPSConnection`
constructor, and the address of the host that we eventually want to reach to
the :meth:`~HTTPConnection.set_tunnel` method::
>>> import http.client
>>> conn = http.client.HTTPSConnection("localhost", 8080)
>>> conn.set_tunnel("www.python.org")
>>> conn.request("HEAD","/index.html")
.. versionadded:: 3.2 .. versionadded:: 3.2
......
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