我正在使用https://github.com/abhinavsingh/proxy.py,使用基本身份驗證進行設定,如下所示:
proxy --basic-auth "user:pass"
當我將它與 curl 一起使用時,它需要代理身份驗證:
curl -I -x localhost:8899 http://example.com => 407
curl -I -x user:pass@localhost:8899 http://example.com => 200
但是當我從 Python 中使用它時,我可以在不提供任何身份驗證的情況下訪問它:
import requests
proxies = {
"http": "http://127.0.0.1:8899",
"https": "http://127.0.0.1:8899"
}
response = requests.get("https://www.example.com", proxies=proxies)
print(response.status_code)
我得到了 200。我錯過了什么嗎?
uj5u.com熱心網友回復:
這看起來像proxy.py. 它似乎是由發出沒有請求標頭requests的請求的事實觸發的。HTTP/1.0您可以自己觸發相同的問題:
$ telnet localhost 8899
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
CONNECT www.example.com:80 HTTP/1.0
HTTP/1.1 200 Connection established
與 不同requests,curl即使在使用時,也總是發送請求標頭,--proxy1.0因此不可能觸發相同的行為。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/505182.html
上一篇:在GAS中運行cURL
