mirror of
https://github.com/python/cpython.git
synced 2025-11-02 14:41:33 +00:00
[Patch #988504] Fix HTTP error handling via a patch from John J. Lee
This commit is contained in:
parent
42851ab490
commit
f9ea7c067a
1 changed files with 6 additions and 10 deletions
|
|
@ -996,16 +996,12 @@ def do_open(self, http_class, req):
|
||||||
except socket.error, err: # XXX what error?
|
except socket.error, err: # XXX what error?
|
||||||
raise URLError(err)
|
raise URLError(err)
|
||||||
|
|
||||||
if r.status in (200, 206):
|
|
||||||
# Pick apart the HTTPResponse object to get the addinfourl
|
# Pick apart the HTTPResponse object to get the addinfourl
|
||||||
# object initialized properly
|
# object initialized properly
|
||||||
resp = addinfourl(r.fp, r.msg, req.get_full_url())
|
resp = addinfourl(r.fp, r.msg, req.get_full_url())
|
||||||
resp.code = r.status
|
resp.code = r.status
|
||||||
resp.msg = r.reason
|
resp.msg = r.reason
|
||||||
return resp
|
return resp
|
||||||
else:
|
|
||||||
return self.parent.error("http", req, r.fp, r.status, r.msg,
|
|
||||||
r.msg.dict)
|
|
||||||
|
|
||||||
|
|
||||||
class HTTPHandler(AbstractHTTPHandler):
|
class HTTPHandler(AbstractHTTPHandler):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue