File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -451,11 +451,25 @@ HTTPConnection Objects
451451
452452.. method :: HTTPConnection.set_tunnel(host, port=None, headers=None)
453453
454- Set the host and the port for HTTP Connect Tunnelling. Normally used when it
455- is required to a HTTPS Connection through a proxy server.
454+ Set the host and the port for HTTP Connect Tunnelling. This allows running
455+ the connection through a proxy server.
456456
457- The headers argument should be a mapping of extra HTTP headers to send
458- with the CONNECT request.
457+ The host and port arguments specify the endpoint of the tunneled connection
458+ (i.e. the address included in the CONNECT request, *not * the address of the
459+ proxy server).
460+
461+ The headers argument should be a mapping of extra HTTP headers to send with
462+ the CONNECT request.
463+
464+ For example, to tunnel through a HTTPS proxy server running locally on port
465+ 8080, we would pass the address of the proxy to the :class: `HTTPSConnection `
466+ constructor, and the address of the host that we eventually want to reach to
467+ the :meth: `~HTTPConnection.set_tunnel ` method::
468+
469+ >>> import http.client
470+ >>> conn = http.client.HTTPSConnection("localhost", 8080)
471+ >>> conn.set_tunnel("www.python.org")
472+ >>> conn.request("HEAD","/index.html")
459473
460474 .. versionadded :: 3.2
461475
You can’t perform that action at this time.
0 commit comments