When looping through requests to an HTTP server close()
closes out the active connection. An the second loop
through a new HTTP connection is created.
When looping through requests to an HTTPS server
close() does not close the connection. It keeps it
active. On the second pass through the loop
httplib.HTTPS uses the previously initiated connection.
Shouldn't close() close out the connection as it does
for the HTTP connection?
sample code to illustrate:
def getdata():
params = urllib.urlencode({'username': 'test',
'password': 'test'})
h = httplib.HTTPS(host = "test.site.com", port =
443, key_file = "fake.pem", cert_file = "fake.pem")
h.putrequest('POST', '/scripts/cgi.exe?')
h.putheader('Content-length', '%d'%len(params))
h.putheader('Accept', 'text/plain')
h.putheader('Host', 'test.site.com')
h.endheaders()
h.send(params)
reply, msg, hdrs = h.getreply()
data = h.getfile().read()
file('test.file', 'w').write(data)
h.close()
|