diff options
author | Senthil Kumaran <senthil@uthcode.com> | 2011-07-27 00:06:44 (GMT) |
---|---|---|
committer | Senthil Kumaran <senthil@uthcode.com> | 2011-07-27 00:06:44 (GMT) |
commit | 7496fef8ff3ef9c54929a916cd5d42cd6fcdd437 (patch) | |
tree | 7df63b5f2861b48f3549a19bc270fcd1cc18e437 /Lib/urllib | |
parent | d3b2aefbfe69df40dc2f0adf31a188fbbdcc5923 (diff) | |
parent | 1299a8f3b25a543c79f79e6edaebb033018029ca (diff) | |
download | cpython-7496fef8ff3ef9c54929a916cd5d42cd6fcdd437.zip cpython-7496fef8ff3ef9c54929a916cd5d42cd6fcdd437.tar.gz cpython-7496fef8ff3ef9c54929a916cd5d42cd6fcdd437.tar.bz2 |
merge from 3.2 - Fix closes Issue12576 - fix urlopen behavior on sites which do not send (or obsfuscates) Connection: Close header.
Diffstat (limited to 'Lib/urllib')
-rw-r--r-- | Lib/urllib/request.py | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/Lib/urllib/request.py b/Lib/urllib/request.py index 553fe3f..ca643eb 100644 --- a/Lib/urllib/request.py +++ b/Lib/urllib/request.py @@ -1143,11 +1143,14 @@ class AbstractHTTPHandler(BaseHandler): try: h.request(req.get_method(), req.selector, req.data, headers) - r = h.getresponse() # an HTTPResponse instance - except socket.error as err: + except socket.error as err: # timeout error raise URLError(err) finally: - h.close() + try: + r = h.getresponse() # an HTTPResponse instance + except Exception as exp: + h.close() + raise exp r.url = req.get_full_url() # This line replaces the .msg attribute of the HTTPResponse |