summaryrefslogtreecommitdiffstats
path: root/Lib/urllib
diff options
context:
space:
mode:
authorSenthil Kumaran <senthil@uthcode.com>2011-07-27 00:05:58 (GMT)
committerSenthil Kumaran <senthil@uthcode.com>2011-07-27 00:05:58 (GMT)
commit1299a8f3b25a543c79f79e6edaebb033018029ca (patch)
treed6654f73c078b2f969892dc917d2dc755e203848 /Lib/urllib
parent5cd3e305e3ef19f6009f3097a7b2ff98b2234bec (diff)
downloadcpython-1299a8f3b25a543c79f79e6edaebb033018029ca.zip
cpython-1299a8f3b25a543c79f79e6edaebb033018029ca.tar.gz
cpython-1299a8f3b25a543c79f79e6edaebb033018029ca.tar.bz2
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.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/Lib/urllib/request.py b/Lib/urllib/request.py
index a09a353..534408d 100644
--- a/Lib/urllib/request.py
+++ b/Lib/urllib/request.py
@@ -1134,11 +1134,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