This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: httplib: HTTPS does not close() connection properly
Type: Stage:
Components: Library (Lib) Versions: Python 2.3
process
Status: closed Resolution: wont fix
Dependencies: Superseder:
Assigned To: akuchling Nosy List: akuchling, insomnike, paul.moore, sf_rick
Priority: normal Keywords:

Created on 2004-03-10 17:00 by sf_rick, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (4)
msg20193 - (view) Author: rick (sf_rick) Date: 2004-03-10 17:00
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()
    
msg20194 - (view) Author: Aaron Brady (insomnike) Date: 2004-06-05 17:17
Logged In: YES 
user_id=1057404

I've attempted to duplicate this with HEAD (05/Jun/04), and
I can't. 

HTTPSConnection uses a FakeSocket class which does reference
counting, meaning that the amount of sock.makefile() must
match sock.close() - this should be documented.
msg20195 - (view) Author: Paul Moore (paul.moore) * (Python committer) Date: 2004-06-05 17:39
Logged In: YES 
user_id=113328

I'm not sure there's a need to document the makefile/close
thing in the Python manual, as the sock attribute isn't
publicly documented.

Internally, the constraint must be adhered to, but I can't
see evidence of where it isn't.

Unless the OP can provide a reproducible test case, I think
this can be closed with no change.
msg20196 - (view) Author: A.M. Kuchling (akuchling) * (Python committer) Date: 2004-07-07 13:54
Logged In: YES 
user_id=11375

Closing as suggested.
History
Date User Action Args
2022-04-11 14:56:03adminsetgithub: 40021
2004-03-10 17:00:16sf_rickcreate