summaryrefslogtreecommitdiff
path: root/Lib/urllib/request.py
diff options
context:
space:
mode:
authorEzio Melotti <ezio.melotti@gmail.com>2012-11-17 12:56:29 +0200
committerEzio Melotti <ezio.melotti@gmail.com>2012-11-17 12:56:29 +0200
commit29b67bd25a1b781749bea5e22e80dcbe41f05dec (patch)
tree6b8cb29b82b6890ac5f98c25fdf45878e9cd86fb /Lib/urllib/request.py
parentb5477a0109194b7c8500037e063bfd29dca03391 (diff)
parent444b8a182b5a690fdb3e4d28ca8a61de27949178 (diff)
downloadcpython-29b67bd25a1b781749bea5e22e80dcbe41f05dec.tar.gz
Merge updates about dir() with 3.3.
Diffstat (limited to 'Lib/urllib/request.py')
-rw-r--r--Lib/urllib/request.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/Lib/urllib/request.py b/Lib/urllib/request.py
index 5ddec5f14e..d389fa9799 100644
--- a/Lib/urllib/request.py
+++ b/Lib/urllib/request.py
@@ -1255,6 +1255,12 @@ class AbstractHTTPHandler(BaseHandler):
raise URLError(err)
else:
r = h.getresponse()
+ # If the server does not send us a 'Connection: close' header,
+ # HTTPConnection assumes the socket should be left open. Manually
+ # mark the socket to be closed when this response object goes away.
+ if h.sock:
+ h.sock.close()
+ h.sock = None
r.url = req.get_full_url()
# This line replaces the .msg attribute of the HTTPResponse
@@ -1658,7 +1664,7 @@ class URLopener:
return getattr(self, name)(url)
else:
return getattr(self, name)(url, data)
- except HTTPError:
+ except (HTTPError, URLError):
raise
except socket.error as msg:
raise IOError('socket error', msg).with_traceback(sys.exc_info()[2])