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?
HTTPS support was only recently added to
twisted.web.client.Agent. If you can use Twisted 10.1, very recently released, thenAgentwill accept your HTTPS URLs.