cpython: e0ec68d46464 (original) (raw)
Mercurial > cpython
changeset 101316:e0ec68d46464
merge from 3.5 Issue #26892: Honor debuglevel flag in urllib.request.HTTPHandler. Patch contributed by Chi Hsuan Yen. [#26892]
Senthil Kumaran senthil@uthcode.com | |
---|---|
date | Fri, 13 May 2016 01:35:29 -0700 |
parents | 5979e7aadd59(current diff)63e23b2dedcc(diff) |
children | 175c3f1d0256 |
files | Lib/test/test_urllib2.py Lib/urllib/request.py Misc/NEWS |
diffstat | 3 files changed, 13 insertions(+), 2 deletions(-)[+] [-] Lib/test/test_urllib2.py 11 Lib/urllib/request.py 1 Misc/NEWS 3 |
line wrap: on
line diff
--- a/Lib/test/test_urllib2.py +++ b/Lib/test/test_urllib2.py @@ -480,8 +480,8 @@ class MockHTTPSHandler(urllib.request.Ab # Useful for testing the Proxy-Authorization request by verifying the # properties of httpcon
- def init(self, debuglevel=0):
urllib.request.AbstractHTTPHandler.__init__(self, debuglevel=debuglevel)[](#l1.10) self.httpconn = MockHTTPClass()[](#l1.11)
def https_open(self, req): @@ -950,6 +950,13 @@ class HandlerTests(unittest.TestCase): newreq = h.do_request_(req) self.assertEqual(int(newreq.get_header('Content-length')),16)
- def test_http_handler_debuglevel(self):
o = OpenerDirector()[](#l1.19)
h = MockHTTPSHandler(debuglevel=1)[](#l1.20)
o.add_handler(h)[](#l1.21)
o.open("https://www.example.com")[](#l1.22)
self.assertEqual(h._debuglevel, 1)[](#l1.23)
+ def test_http_doubleslash(self): # Checks the presence of any unnecessary double slash in url does not # break anything. Previously, a double slash directly after the host
--- a/Lib/urllib/request.py +++ b/Lib/urllib/request.py @@ -1271,6 +1271,7 @@ class AbstractHTTPHandler(BaseHandler): # will parse host:port h = http_class(host, timeout=req.timeout, **http_conn_args)
h.set_debuglevel(self._debuglevel)[](#l2.7)
headers = dict(req.unredirected_hdrs) headers.update(dict((k, v) for k, v in req.headers.items()
--- a/Misc/NEWS +++ b/Misc/NEWS @@ -277,6 +277,9 @@ Core and Builtins Library ------- +- Issue #26892: Honor debuglevel flag in urllib.request.HTTPHandler. Patch