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. :-)
|