[ python-Bugs-855819 ] urllib does not handle Connection reset
SourceForge.net
noreply at sourceforge.net
Wed Mar 14 09:31:48 CET 2007
Bugs item #855819, was opened at 2003-12-07 16:59
Message generated for change (Comment added) made by gbrandl
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=855819&group_id=5470
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Library
Group: Python 2.3
>Status: Closed
>Resolution: Fixed
Priority: 5
Private: No
Submitted By: Stefan Fleiter (fleiter)
Assigned to: Nobody/Anonymous (nobody)
Summary: urllib does not handle Connection reset
Initial Comment:
Python 2.2.3+ (#1, Nov 18 2003, 01:16:59)
[GCC 3.3.2 (Debian)] on linux2
and
Python 2.3.3c1 (#2, Dec 6 2003, 16:44:56)
[GCC 3.3.3 20031203 (prerelease) (Debian)] on linux2
Server which does reset Connection:
=====================
import SocketServer
class RequestHandler(SocketServer.BaseRequestHandler):
def handle(self):
self.request.send("")
server = SocketServer.TCPServer(("localhost", 2000),
RequestHandler)
server.serve_forever()
urllib-Code:
=======
import urllib
f = urllib.urlopen("http://localhost:2000")
Traceback:
=======
Traceback (most recent call last):
File "url.py", line 4, in ?
f = urllib.urlopen("http://localhost:2000")
File "/usr/lib/python2.2/urllib.py", line 73, in urlopen
return _urlopener.open(url)
File "/usr/lib/python2.2/urllib.py", line 178, in open
return getattr(self, name)(url)
File "/usr/lib/python2.2/urllib.py", line 301, in
open_http
return self.http_error(url, fp, errcode, errmsg,
headers)
File "/usr/lib/python2.2/urllib.py", line 318, in
http_error
return self.http_error_default(url, fp, errcode,
errmsg, headers)
File "/usr/lib/python2.2/urllib.py", line 546, in
http_error_default
return addinfourl(fp, headers, "http:" + url)
File "/usr/lib/python2.2/urllib.py", line 824, in
__init__
addbase.__init__(self, fp)
File "/usr/lib/python2.2/urllib.py", line 778, in
__init__
self.read = self.fp.read
The cause seems to be that urllib.addbase depends on
the fp argument beeing a valid socket while
fp = h.getfile() in open_http sets it to None because
in httplib.HTTP.getreply() the
BadStatusLine-Exception-Handling was triggered.
urllib2 does handle this right.
Thanks for reading all of this. :-)
----------------------------------------------------------------------
>Comment By: Georg Brandl (gbrandl)
Date: 2007-03-14 08:31
Message:
Logged In: YES
user_id=849994
Originator: NO
Finally fixed in rev. 54376, 54377 (2.5). Now raises IOError.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=855819&group_id=5470
More information about the Python-bugs-list
mailing list