python/dist/src/Lib urllib2.py,1.62,1.63
Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1119 Modified Files: urllib2.py Log Message: Fix two bugs in the new do_open() implementation for HTTPHandler. Invoke the standard error handlers for non-200 responses. Always supply a "Connection: close" header to prevent the server from leaving the connection open. Downstream users of the socket may attempt recv()/read() with no arguments, which would block if the connection were kept open. Index: urllib2.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/urllib2.py,v retrieving revision 1.62 retrieving revision 1.63 diff -C2 -d -r1.62 -r1.63 *** urllib2.py 15 Feb 2004 21:19:18 -0000 1.62 --- urllib2.py 24 Feb 2004 19:40:33 -0000 1.63 *************** *** 958,961 **** --- 958,968 ---- headers = dict(req.headers) headers.update(req.unredirected_hdrs) + # We want to make an HTTP/1.1 request, but the addinfourl + # class isn't prepared to deal with a persistent connection. + # It will try to read all remaining data from the socket, + # which will block while the server waits for the next request. + # So make sure the connection gets closed after the (only) + # request. + headers["Connection"] = "close" try: h.request(req.get_method(), req.get_selector(), req.data, headers) *************** *** 964,973 **** raise URLError(err) ! # Pick apart the HTTPResponse object to get the various pieces ! # of the ! resp = addinfourl(r.fp, r.msg, req.get_full_url()) ! resp.code = r.status ! resp.msg = r.reason ! return resp --- 971,984 ---- raise URLError(err) ! if r.status == 200: ! # Pick apart the HTTPResponse object to get the addinfourl ! # object initialized properly ! resp = addinfourl(r.fp, r.msg, req.get_full_url()) ! resp.code = r.status ! resp.msg = r.reason ! return resp ! else: ! return self.parent.error("http", req, r.fp, r.status, r.msg, ! r.msg.dict)
participants (1)
-
jhylton@users.sourceforge.net