问题描述
将请求与不需要身份验证的代理一起使用时,请求请求的function A () {
const randomNumber = Math.floor(Math.random() * 100);
A.prototype.id = randomNumber;
console.log("creating instance with id: " + randomNumber);
}
const a1 = new A()
const a2 = new A()
console.log("Current ID of a1: " + a1.id);
console.log("Current ID of a2: " + a2.id);
console.log(a1.__proto__ === a2.__proto__); // Will return "true" because it's the same object
参数似乎是request.put-将身份验证转发到代理而不是Web服务器。
即对于某些请求,例如:
auth
尝试使用后者会给出以下信息:
url = 'https://some.open-websever.com/landing'
url_with_authentication = 'https://auth-required.some-webserver.com/landing'
# Works
with open('file','rb') as f:
requests.put(url,data=f)
# Does not work
with open('file','rb') as f:
requests.put(url_with_authentication,data=f,auth=(username,password))
另一方面,大致等效的卷曲效果很好:
Traceback (most recent call last):
File "/home/grep_username/venv/requests_test/lib64/python3.6/site-packages/requests/adapters.py",line 449,in send
timeout=timeout
File "/home/grep_username/venv/requests_test/lib64/python3.6/site-packages/urllib3/connectionpool.py",line 725,in urlopen
method,url,error=e,_pool=self,_stacktrace=sys.exc_info()[2]
File "/home/grep_username/venv/requests_test/lib64/python3.6/site-packages/urllib3/util/retry.py",line 439,in increment
raise MaxRetryError(_pool,error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='https://auth-required.some-webserver.com',port=443): Max retries exceeded with url: /landing/ (Caused by ProxyError('Cannot connect to proxy.',BrokenPipeError(32,'Broken pipe'))
在所有情况下,无论代理是由HTTP_PROXY作为环境变量提供还是通过proxies = {“ http”:“ http://proxy.server.com:8080”,“ https”:“ http://proxy.server.com:8080“}(用于请求)或--proxy参数用于curl。
编辑:这是我的用户错误:requests.put应该使用files参数而不是data参数来传输大文件,否则请求太大,一切都会爆炸。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)