I would like to connect to a site via HTTPS in Python 3.2.
I tried
conn = http.client.HTTPSConnection(urlStr, 8443)
conn.putrequest('GET', '/')
response = conn.getresponse()
print(response.read())
but I get
http.client.ResponseNotReady: Request-started
Anyone know what the problem is?
First of all, if you just want to download something and don’t want any special HTTP requests, you should use
urllib.requestinstead ofhttp.client.If you really want to use http.client, you must call
endheadersafter you send the request headers:As a shortcut to
putrequest/endheaders, you can also use therequestmethod, like this: