[ python-Bugs-855819 ] urllib does not handle Connection reset

SourceForge.net noreply at sourceforge.net
Sun Dec 7 11:59:11 EST 2003


Bugs item #855819, was opened at 2003-12-07 16:59
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=855819&group_id=5470

Category: Python Library
Group: Python 2.3
Status: Open
Resolution: None
Priority: 5
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. :-)

----------------------------------------------------------------------

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