在 Twisted 中发出 HTTPS 请求
我正在尝试编写一个客户端,它可以根据其配置方式发出 HTTP 和 HTTPS 请求。对于普通的HTTP,我一直在使用twisted.web.client.Agent并使用agent.request(METHOD, HOST, HEADERS, CONTENT)来发出请求。我关心的是主机字段,当我执行 HTTP 时,它可以执行类似“http://localhost:8000 的操作”,但如果我切换到 HTTPS,则会收到错误:
Failure: twins.web.error.SchemeNotSupported: Unsupported schema: 'https'
我知道 client.getPage 方法的存在,但我想知道是否有任何类似的很棒的高级方法可以像 agent.request 一样发出请求,但使用 HTTPS?
I am trying to write a client that can make both HTTP and HTTPS requests depending on how it is configured. For normal HTTP, I have been using twisted.web.client.Agent and using agent.request(METHOD, HOST, HEADERS, CONTENT) to make the requests. What I care about is that host field, when I do HTTP it works doing something like "http://localhost:8000", but if I switch to HTTPS, I get an error:
Failure: twisted.web.error.SchemeNotSupported: Unsupported scheme: 'https'
I am aware of the existence of the client.getPage method, but I was wondering if there was any similarly awesome and high level methods that I can make requests with just like agent.request, but using HTTPS?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
twisted.web.client.Agent
最近才添加了 HTTPS 支持。如果您可以使用最近发布的 Twisted 10.1,则Agent
将接受您的 HTTPS URL。HTTPS support was only recently added to
twisted.web.client.Agent
. If you can use Twisted 10.1, very recently released, thenAgent
will accept your HTTPS URLs.