classification
Title: http/client.py does not print correct headers in debug
Type: Stage: resolved
Components: Library (Lib) Versions: Python 3.8, Python 3.7, Python 3.6
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: barry, miss-islington, mstrigl, r.david.murray, serhiy.storchaka
Priority: normal Keywords: patch

Created on 2018-04-26 12:12 by mstrigl, last changed 2018-06-19 13:54 by serhiy.storchaka. This issue is now closed.

Files
File name Uploaded Description Edit
complete_pretty_headers.patch mstrigl, 2018-04-26 12:12 review
Pull Requests
URL Status Linked Edit
PR 6611 merged mstrigl, 2018-04-26 12:33
PR 7792 merged miss-islington, 2018-06-19 13:23
PR 7793 merged miss-islington, 2018-06-19 13:24
Messages (5)
msg315787 - (view) Author: Marco Strigl (mstrigl) * Date: 2018-04-26 12:12
Consider the following script: 

try:
    from urllib import request
except ImportError:
    import urllib2 as request

handler = request.HTTPSHandler(debuglevel=1)
opener = request.build_opener(handler)
f = opener.open('https://httpbin.org/user-agent')


In python2.x this works: 

$ python2 http_client_bug.py
send: 'GET /user-agent HTTP/1.1\r\nAccept-Encoding: identity\r\nHost:
httpbin.org\r\nConnection: close\r\nUser-Agent: Python-urllib/2.7\r\n\r\n'
reply: 'HTTP/1.1 200 OK\r\n'
header: Connection: close
header: Server: gunicorn/19.7.1
header: Date: Thu, 26 Apr 2018 12:01:35 GMT
header: Content-Type: application/json
header: Access-Control-Allow-Origin: *
header: Access-Control-Allow-Credentials: true
header: X-Powered-By: Flask
header: X-Processed-Time: 0
header: Content-Length: 40
header: Via: 1.1 vegur


But in python3.x only the header keys are printed. Not the values (also a newline after each header will be nice):

$ python3 http_client_bug.py
send: b'GET /user-agent HTTP/1.1\r\nAccept-Encoding: identity\r\nHost:
httpbin.org\r\nUser-Agent: Python-urllib/3.6\r\nConnection: close\r\n\r\n'
reply: 'HTTP/1.1 200 OK\r\n'
header: Connection header: Server header: Date header: Content-Type
header: Access-Control-Allow-Origin header:
Access-Control-Allow-Credentials header: X-Powered-By header:
X-Processed-Time header: Content-Length header:

Patch for this is attached.
msg319961 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-06-19 13:21
New changeset 936f03e7fafc28fd6fdfba11d162c776b89c0167 by Serhiy Storchaka (Marco Strigl) in branch 'master':
bpo-33365: print the header values beside the keys (GH-6611)
https://github.com/python/cpython/commit/936f03e7fafc28fd6fdfba11d162c776b89c0167
msg319967 - (view) Author: miss-islington (miss-islington) Date: 2018-06-19 13:52
New changeset 2edcf0a3db608457f42f4e4b74aff28237b4c91b by Miss Islington (bot) in branch '3.7':
bpo-33365: print the header values beside the keys (GH-6611)
https://github.com/python/cpython/commit/2edcf0a3db608457f42f4e4b74aff28237b4c91b
msg319968 - (view) Author: miss-islington (miss-islington) Date: 2018-06-19 13:52
New changeset 34cd4821ed97639896f85bdf0c0d5c75b23f8a76 by Miss Islington (bot) in branch '3.6':
bpo-33365: print the header values beside the keys (GH-6611)
https://github.com/python/cpython/commit/34cd4821ed97639896f85bdf0c0d5c75b23f8a76
msg319969 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-06-19 13:54
Thank you for your contribution Marco!
History
Date User Action Args
2018-06-19 13:54:02serhiy.storchakasetstatus: open -> closed
resolution: fixed
messages: + msg319969

stage: patch review -> resolved
2018-06-19 13:52:47miss-islingtonsetmessages: + msg319968
2018-06-19 13:52:40miss-islingtonsetnosy: + miss-islington
messages: + msg319967
2018-06-19 13:24:45miss-islingtonsetpull_requests: + pull_request7398
2018-06-19 13:23:47miss-islingtonsetpull_requests: + pull_request7397
2018-06-19 13:21:01serhiy.storchakasetnosy: + serhiy.storchaka
messages: + msg319961
2018-05-08 12:42:38serhiy.storchakasetnosy: + barry, r.david.murray

versions: - Python 3.4, Python 3.5
2018-04-26 12:33:00mstriglsetstage: patch review
pull_requests: + pull_request6307
2018-04-26 12:12:56mstriglcreate