[Python-bugs-list] [ python-Bugs-579107 ] https broken by recent httplib changes
noreply@sourceforge.net
noreply@sourceforge.net
Tue, 09 Jul 2002 08:48:50 -0700
Bugs item #579107, was opened at 2002-07-09 12:35
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=579107&group_id=5470
Category: Python Library
Group: Python 2.3
Status: Open
Resolution: None
Priority: 5
Submitted By: Kevin Jacobs (jacobs99)
>Assigned to: Jeremy Hylton (jhylton)
Summary: https broken by recent httplib changes
Initial Comment:
Here is code that has worked previously, but does not in
the current CVS:
import urllib
def get(url):
return urllib.urlopen(url).read()
u = get('http://dbserv2.theopalgroup.com/mediumfile')
hlen = len(u)
u = get('https://dbserv2.theopalgroup.com/mediumfile')
slen = len(u)
print "HTTP len = %d, HTTPS len = %d" % (hlen,slen)
Here are the results of running this code for various
python versions:
> python2.0 testhttps.py
HTTP len = 37140, HTTPS len = 37140
> python2.1 testhttps.py
HTTP len = 37140, HTTPS len = 37140
> python2.2 testhttps.py
HTTP len = 37140, HTTPS len = 37140
> python2.3 testhttps.py
HTTP len = 37140, HTTPS len = 0
Clearly, there is something wrong with rhe HTTPS
connection in Python 2.3.
With my proposed patch, the output is now as expected:
> python2.3+patch testhttps.py
HTTP len = 37140, HTTPS len = 37140
However, there are some unresolved issues with
the patch, so I hope that someone more familiar
with httplib will help out. Basically, the problem
stems from non-obvious semantics of
HTTPResponse and HTTPConnection with regard to
closing the active connection.
I've marked several locations in the diff where these
classes close connections and I am not convinced
that it is proper to do so. One of these locations
fixes the problem I demonstrate above. i.e., the
SSL read fails because the socket has already
been closed, and no data is returned.
The exception caused by trying to read from a closed
connection is trapped, so the caller sees no error, and
recieves no bytes (i.e., EOF).
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=579107&group_id=5470