Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

http/client.py does not print correct headers in debug #77546

Closed
lethliel mannequin opened this issue Apr 26, 2018 · 5 comments
Closed

http/client.py does not print correct headers in debug #77546

lethliel mannequin opened this issue Apr 26, 2018 · 5 comments
Labels
3.7 (EOL) end of life 3.8 (EOL) end of life stdlib Python modules in the Lib dir

Comments

@lethliel
Copy link
Mannequin

lethliel mannequin commented Apr 26, 2018

BPO 33365
Nosy @warsaw, @bitdancer, @serhiy-storchaka, @miss-islington, @lethliel
PRs
  • bpo-33365: print the header values besides the keys #6611
  • [3.7] bpo-33365: print the header values beside the keys (GH-6611) #7792
  • [3.6] bpo-33365: print the header values beside the keys (GH-6611) #7793
  • Files
  • complete_pretty_headers.patch
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2018-06-19.13:54:02.844>
    created_at = <Date 2018-04-26.12:12:56.787>
    labels = ['3.8', '3.7', 'library']
    title = 'http/client.py does not print correct headers in debug'
    updated_at = <Date 2018-06-19.13:54:02.843>
    user = 'https://github.com/lethliel'

    bugs.python.org fields:

    activity = <Date 2018-06-19.13:54:02.843>
    actor = 'serhiy.storchaka'
    assignee = 'none'
    closed = True
    closed_date = <Date 2018-06-19.13:54:02.844>
    closer = 'serhiy.storchaka'
    components = ['Library (Lib)']
    creation = <Date 2018-04-26.12:12:56.787>
    creator = 'mstrigl'
    dependencies = []
    files = ['47550']
    hgrepos = []
    issue_num = 33365
    keywords = ['patch']
    message_count = 5.0
    messages = ['315787', '319961', '319967', '319968', '319969']
    nosy_count = 5.0
    nosy_names = ['barry', 'r.david.murray', 'serhiy.storchaka', 'miss-islington', 'mstrigl']
    pr_nums = ['6611', '7792', '7793']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue33365'
    versions = ['Python 3.6', 'Python 3.7', 'Python 3.8']

    @lethliel
    Copy link
    Mannequin Author

    lethliel mannequin commented Apr 26, 2018

    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.

    @lethliel lethliel mannequin added 3.7 (EOL) end of life 3.8 (EOL) end of life stdlib Python modules in the Lib dir labels Apr 26, 2018
    @serhiy-storchaka
    Copy link
    Member

    New changeset 936f03e by Serhiy Storchaka (Marco Strigl) in branch 'master':
    bpo-33365: print the header values beside the keys (GH-6611)
    936f03e

    @miss-islington
    Copy link
    Contributor

    New changeset 2edcf0a by Miss Islington (bot) in branch '3.7':
    bpo-33365: print the header values beside the keys (GH-6611)
    2edcf0a

    @miss-islington
    Copy link
    Contributor

    New changeset 34cd482 by Miss Islington (bot) in branch '3.6':
    bpo-33365: print the header values beside the keys (GH-6611)
    34cd482

    @serhiy-storchaka
    Copy link
    Member

    Thank you for your contribution Marco!

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.7 (EOL) end of life 3.8 (EOL) end of life stdlib Python modules in the Lib dir
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants