用法:
HTTPConnection.set_tunnel(host, port=None, headers=None)
設置 HTTP 連接隧道的主機和端口。這允許通過代理服務器運行連接。
主機和端口參數指定隧道連接的端點(即 CONNECT 請求中包含的地址,
not
代理服務器的地址)。headers 參數應該是與 CONNECT 請求一起發送的額外 HTTP 標頭的映射。
例如,要通過在端口 8080 上本地運行的 HTTPS 代理服務器進行隧道傳輸,我們會將代理的地址傳遞給
HTTPSConnection
構造函數,並將我們最終想要到達的主機地址傳遞給set_tunnel()
方法:>>> import http.client >>> conn = http.client.HTTPSConnection("localhost", 8080) >>> conn.set_tunnel("www.python.org") >>> conn.request("HEAD","/index.html")
3.2 版中的新函數。
相關用法
- Python http.client.HTTPConnection用法及代碼示例
- Python http.HTTPStatus用法及代碼示例
- Python html.escape()用法及代碼示例
- Python html.unescape()用法及代碼示例
- Python hashlib.sha3_256()用法及代碼示例
- Python help()用法及代碼示例
- Python hashlib.sha3_512()用法及代碼示例
- Python hashlib.blake2s()用法及代碼示例
- Python hashlib.blake2b()用法及代碼示例
- Python hasattr()用法及代碼示例
- Python statistics harmonic_mean()用法及代碼示例
- Python math hypot()用法及代碼示例
- Python hash()用法及代碼示例
- Python hashlib.sha3_224()用法及代碼示例
- Python hashlib.shake_256()用法及代碼示例
- Python hex()用法及代碼示例
- Python OpenCV haveImageReader()用法及代碼示例
- Python hashlib.pbkdf2_hmac用法及代碼示例
- Python hashlib.shake_128()用法及代碼示例
- Python hex用法及代碼示例
注:本文由純淨天空篩選整理自python.org大神的英文原創作品 http.client.HTTPConnection.set_tunnel。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。