mirror of https://github.com/python/cpython
merge from 3.2 - fix urlopen behavior on sites which do not send (or obsfuscates) Connection: Close header.
This commit is contained in:
parent
d8b1723965
commit
7d7702b581
|
@ -186,6 +186,14 @@ class OtherNetworkTests(unittest.TestCase):
|
|||
opener.open(request)
|
||||
self.assertEqual(request.get_header('User-agent'),'Test-Agent')
|
||||
|
||||
def test_sites_no_connection_close(self):
|
||||
# Some sites do not send Connection: close header.
|
||||
# Verify that those work properly. (#issue12576)
|
||||
|
||||
req = urllib2.urlopen('http://www.imdb.com')
|
||||
res = req.read()
|
||||
self.assertTrue(res)
|
||||
|
||||
def _test_urls(self, urls, handlers, retry=True):
|
||||
import time
|
||||
import logging
|
||||
|
|
|
@ -1166,14 +1166,14 @@ class AbstractHTTPHandler(BaseHandler):
|
|||
|
||||
try:
|
||||
h.request(req.get_method(), req.get_selector(), req.data, headers)
|
||||
except socket.error, err: # XXX what error?
|
||||
h.close()
|
||||
raise URLError(err)
|
||||
else:
|
||||
try:
|
||||
r = h.getresponse(buffering=True)
|
||||
except TypeError: #buffering kw not supported
|
||||
except TypeError: # buffering kw not supported
|
||||
r = h.getresponse()
|
||||
except socket.error, err: # XXX what error?
|
||||
raise URLError(err)
|
||||
finally:
|
||||
h.close()
|
||||
|
||||
# Pick apart the HTTPResponse object to get the addinfourl
|
||||
# object initialized properly.
|
||||
|
|
Loading…
Reference in New Issue