Commit 5d1110a9 authored by Senthil Kumaran's avatar Senthil Kumaran

merge from 3.5

Issue #26892: Honor debuglevel flag in urllib.request.HTTPHandler.

Patch contributed by Chi Hsuan Yen.
parents f94ec1bd 9642eedc
...@@ -480,8 +480,8 @@ class MockHTTPSHandler(urllib.request.AbstractHTTPHandler): ...@@ -480,8 +480,8 @@ class MockHTTPSHandler(urllib.request.AbstractHTTPHandler):
# Useful for testing the Proxy-Authorization request by verifying the # Useful for testing the Proxy-Authorization request by verifying the
# properties of httpcon # properties of httpcon
def __init__(self): def __init__(self, debuglevel=0):
urllib.request.AbstractHTTPHandler.__init__(self) urllib.request.AbstractHTTPHandler.__init__(self, debuglevel=debuglevel)
self.httpconn = MockHTTPClass() self.httpconn = MockHTTPClass()
def https_open(self, req): def https_open(self, req):
...@@ -950,6 +950,13 @@ class HandlerTests(unittest.TestCase): ...@@ -950,6 +950,13 @@ class HandlerTests(unittest.TestCase):
newreq = h.do_request_(req) newreq = h.do_request_(req)
self.assertEqual(int(newreq.get_header('Content-length')),16) self.assertEqual(int(newreq.get_header('Content-length')),16)
def test_http_handler_debuglevel(self):
o = OpenerDirector()
h = MockHTTPSHandler(debuglevel=1)
o.add_handler(h)
o.open("https://www.example.com")
self.assertEqual(h._debuglevel, 1)
def test_http_doubleslash(self): def test_http_doubleslash(self):
# Checks the presence of any unnecessary double slash in url does not # Checks the presence of any unnecessary double slash in url does not
# break anything. Previously, a double slash directly after the host # break anything. Previously, a double slash directly after the host
......
...@@ -1271,6 +1271,7 @@ class AbstractHTTPHandler(BaseHandler): ...@@ -1271,6 +1271,7 @@ class AbstractHTTPHandler(BaseHandler):
# will parse host:port # will parse host:port
h = http_class(host, timeout=req.timeout, **http_conn_args) h = http_class(host, timeout=req.timeout, **http_conn_args)
h.set_debuglevel(self._debuglevel)
headers = dict(req.unredirected_hdrs) headers = dict(req.unredirected_hdrs)
headers.update(dict((k, v) for k, v in req.headers.items() headers.update(dict((k, v) for k, v in req.headers.items()
......
...@@ -277,6 +277,9 @@ Core and Builtins ...@@ -277,6 +277,9 @@ Core and Builtins
Library Library
------- -------
- Issue #26892: Honor debuglevel flag in urllib.request.HTTPHandler. Patch
contributed by Chi Hsuan Yen.
- Issue #22274: In the subprocess module, allow stderr to be redirected to - Issue #22274: In the subprocess module, allow stderr to be redirected to
stdout even when stdout is not redirected. Patch by Akira Li. stdout even when stdout is not redirected. Patch by Akira Li.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment