ID EN
HTTP Client

set_tunnel

Python 3.11

Set the host and the port for HTTP Connect Tunnelling. This allows running the connection through a proxy server.

Syntax

PYTHON
HTTPConnection.set_tunnel(host, port=None, headers=None)

Examples

Example 1
PYTHON
>>> import http.client
>>> conn = http.client.HTTPSConnection("localhost", 8080)
>>> conn.set_tunnel("www.python.org")
>>> conn.request("HEAD","/index.html")

See Also

HTTPSConnection set_tunnel()