cURL:通过代理进行 https
我需要向 https URL 发出 cURL 请求,但我还必须通过代理。这样做有什么问题吗?我在使用curl和php执行此操作时遇到了很多麻烦,因此我尝试在Python中使用urllib2执行此操作,结果发现urllib2在通过代理时无法POST到https。我无法找到与 cURL 相关的任何文档,但我想知道是否有人知道这是否是一个问题?
I need to make a cURL request to a https URL, but I have to go through a proxy as well. Is there some problem with doing this? I have been having so much trouble doing this with curl and php, that I tried doing it with urllib2 in Python, only to find that urllib2 cannot POST to https when going through a proxy. I haven't been able to find any documentation to this effect with cURL, but I was wondering if anyone knew if this was an issue?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我发现在转向 PHP/cURL 之前使用命令行curl 进行测试有很大帮助。
例如,使用命令行,除非您配置了证书,否则您将需要
-k
开关。要通过代理,需要使用-x
开关。我相信
-k
等效项是我相信
-x
等效项是I find testing with command-line curl a big help before moving to PHP/cURL.
For example, w/ command-line, unless you've configured certificates, you'll need
-k
switch. And to go through a proxy, it's the-x <proxyhost[:port]>
switch.I believe the
-k
equivalent isI believe the
-x
equivalent is没问题,因为代理服务器支持 CONNECT 方法。
No problem since the proxy server supports the CONNECT method.