summaryrefslogtreecommitdiffstats
path: root/Lib/urllib/request.py
diff options
context:
space:
mode:
authorSenthil Kumaran <senthil@uthcode.com>2013-12-29 01:36:18 (GMT)
committerSenthil Kumaran <senthil@uthcode.com>2013-12-29 01:36:18 (GMT)
commitb6fac245b5aaaf0b465c2f7f346c7f0ad82143f2 (patch)
tree8bae383d75406ec6ba918d6be961c6ff13b5e329 /Lib/urllib/request.py
parent3e86ba4e321d20931648d110e1be12643cb8ff04 (diff)
downloadcpython-b6fac245b5aaaf0b465c2f7f346c7f0ad82143f2.zip
cpython-b6fac245b5aaaf0b465c2f7f346c7f0ad82143f2.tar.gz
cpython-b6fac245b5aaaf0b465c2f7f346c7f0ad82143f2.tar.bz2
Backporing the fix from Issue #12692
Diffstat (limited to 'Lib/urllib/request.py')
-rw-r--r--Lib/urllib/request.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/Lib/urllib/request.py b/Lib/urllib/request.py
index a7445d1..ef62acc 100644
--- a/Lib/urllib/request.py
+++ b/Lib/urllib/request.py
@@ -1251,6 +1251,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