Skip to content

http.client: missing response headers when malformed header is part of the response #73631

Closed

Description

@gboudreau
mannequin
BPO 29445
Nosy @bitdancer, @gboudreau
Superseder
  • bpo-24363: httplib fails to handle semivalid HTTP headers
  • 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 2017-02-04.20:58:55.818>
    created_at = <Date 2017-02-04.20:29:53.415>
    labels = ['type-bug', 'library']
    title = 'http.client: missing response headers when malformed header is part of the response'
    updated_at = <Date 2017-02-05.00:10:37.824>
    user = 'https://github.com/gboudreau'

    bugs.python.org fields:

    activity = <Date 2017-02-05.00:10:37.824>
    actor = 'gboudreau'
    assignee = 'none'
    closed = True
    closed_date = <Date 2017-02-04.20:58:55.818>
    closer = 'r.david.murray'
    components = ['Library (Lib)']
    creation = <Date 2017-02-04.20:29:53.415>
    creator = 'gboudreau'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 29445
    keywords = []
    message_count = 3.0
    messages = ['286987', '286990', '287023']
    nosy_count = 2.0
    nosy_names = ['r.david.murray', 'gboudreau']
    pr_nums = []
    priority = 'normal'
    resolution = 'duplicate'
    stage = 'resolved'
    status = 'closed'
    superseder = '24363'
    type = 'behavior'
    url = 'https://bugs.python.org/issue29445'
    versions = ['Python 3.5']

    Activity

    1. gboudreau commented on Feb 4, 2017

      gboudreaumannequin
      MannequinAuthor

      Tested using urllib3 1.20

      >>> import urllib3
      >>> http = urllib3.PoolManager()
      >>> r = http.request('GET', 'https://online.chasecanada.ca/ChaseCanada_Consumer/Login.do')
      >>> r.status
      200
      >>> r.headers
      HTTPHeaderDict({'Date': 'Sat, 04 Feb 2017 20:09:21 GMT'})
      >>>
      

      I'm pretty sure the problem is caused by an invalid HTTP header returned by the server:

      HTTP/1.1 200 OK
      Date: Sat, 04 Feb 2017 19:16:34 GMT
      My Param: None
      [...]
      

      It directly follows the Date response header, which is returned fine, but since no other response headers is returned, I think this broken header is breaking the HTTP response headers parser.

      Of note: the http.client.HTTPresponse.headers object (HTTPMessage) shows all headers in _payload, but only the Date header in _headers.
      Thus why I think this is a http.client issue, and not a urllib3 issue.

    2. added
      stdlibStandard Library Python modules in the Lib/ directory
      type-bugAn unexpected behavior, bug, or error
      on Feb 4, 2017
    3. bitdancer commented on Feb 4, 2017

      @bitdancer
      Member

      This appears to be a duplicate of bpo-24363. Does the patch there fix the problem for you?

    4. gboudreau commented on Feb 5, 2017

      gboudreaumannequin
      MannequinAuthor

      Yes, indeed. The latest patch in 24363 resolves this issue.
      Sorry for the duplicate.

    5. transferred this issue fromon Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    No one assigned

      Labels

      stdlibStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or error

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions