diff --git a/Doc/library/http.client.rst b/Doc/library/http.client.rst --- a/Doc/library/http.client.rst +++ b/Doc/library/http.client.rst @@ -452,11 +452,24 @@ .. method:: HTTPConnection.set_tunnel(host, port=None, headers=None) Set the host and the port for HTTP Connect Tunnelling. Normally used when it - is required to a HTTPS Connection through a proxy server. + is required to access a HTTPS Connection through a proxy server. + + The host and port arguments specify the endpoint of the tunnelled connection + (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, if we set up a HTTPS proxy server locally on port 8080. We first + set the tunnel host in `HTTPSConnection` and then the host we want to reach + into set_tunnel`:: + + >>> import http.client + >>> conn = http.client.HTTPSConnection("localhost",8080) + >>> conn.set_tunnel("www.python.org") + >>> conn.request("HEAD","/index.html") + .. versionadded:: 3.2