summaryrefslogtreecommitdiff
path: root/Doc/library/http.client.rst
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2014-03-16 15:55:39 -0500
committerBenjamin Peterson <benjamin@python.org>2014-03-16 15:55:39 -0500
commit50d6b5b50b9efd1b06cb9ee21c5f54c69fc47299 (patch)
tree91e4ec720ddea6f49789826efa46b7ad42ee65a7 /Doc/library/http.client.rst
parent5625d33fe9ebc6be5e3ed3b7427c4bab7055cfbb (diff)
downloadcpython-50d6b5b50b9efd1b06cb9ee21c5f54c69fc47299.tar.gz
improve set_tunnel docs (closes #11448)
Patch by Ryan Kelly, karl, and Nikolaus Rath.
Diffstat (limited to 'Doc/library/http.client.rst')
-rw-r--r--Doc/library/http.client.rst22
1 files changed, 18 insertions, 4 deletions
diff --git a/Doc/library/http.client.rst b/Doc/library/http.client.rst
index 783a5963db..bb30f241a3 100644
--- a/Doc/library/http.client.rst
+++ b/Doc/library/http.client.rst
@@ -451,11 +451,25 @@ HTTPConnection Objects
.. 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.
+ Set the host and the port for HTTP Connect Tunnelling. This allows running
+ the connection through a proxy server.
- The headers argument should be a mapping of extra HTTP headers to send
- with the CONNECT request.
+ The host and port arguments specify the endpoint of the tunneled 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, 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