Skip to content

http client marks valid multipart headers with defects. #74177

Closed

Description

@pareshverma91
BPO 29991
Nosy @vadmium, @pareshverma91
PRs
  • Set headersonly for parsing header data. #996
  • Superseder
  • bpo-29353: Incorrect handling of HTTP response with "Content-Type: message/rfc822" header
  • Files
  • example_bug.py: Example server-client for repro. Use commands from comment section.
  • 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-04-19.05:18:07.809>
    created_at = <Date 2017-04-05.08:04:42.800>
    labels = ['type-bug', 'library']
    title = 'http client marks valid multipart headers with defects.'
    updated_at = <Date 2017-04-19.05:18:07.808>
    user = 'https://github.com/pareshverma91'

    bugs.python.org fields:

    activity = <Date 2017-04-19.05:18:07.808>
    actor = 'berker.peksag'
    assignee = 'none'
    closed = True
    closed_date = <Date 2017-04-19.05:18:07.809>
    closer = 'berker.peksag'
    components = ['Library (Lib)']
    creation = <Date 2017-04-05.08:04:42.800>
    creator = 'pareshverma91'
    dependencies = []
    files = ['46780']
    hgrepos = []
    issue_num = 29991
    keywords = []
    message_count = 2.0
    messages = ['291165', '291168']
    nosy_count = 2.0
    nosy_names = ['martin.panter', 'pareshverma91']
    pr_nums = ['996']
    priority = 'normal'
    resolution = 'duplicate'
    stage = 'resolved'
    status = 'closed'
    superseder = '29353'
    type = 'behavior'
    url = 'https://bugs.python.org/issue29991'
    versions = ['Python 3.5']

    Activity

    1. pareshverma91 commented on Apr 5, 2017

      pareshverma91mannequin
      MannequinAuthor

      When http client parses a multipart response, it always taints the headers with defects. e.g.
      Use the attached file to start a simple http server, using current python exec, with commands:
      python .\example_bug.py server
      and run client with:
      python .\example_bug.py client
      which outputs:
      """[StartBoundaryNotFoundDefect(), MultipartInvariantViolationDefect()]"""

      even though the multipart response is correct.
      This appears to be happening because http.client, when parsing headers of response doesn't specifies the headersonly option, which leads to email.feedparser to parse response body (but http.client only passes header lines for parsing in parse_headers method, and the request body isn't available to email.feedparser).

      The issue has been mentioned at:
      urllib3/urllib3#800
      Azure/azure-storage-python#167

      The submitted PR partially fixes the problem:
      ..\python.bat .\example_bug.py client
      which outputs
      """[MultipartInvariantViolationDefect()]"""

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

      @vadmium
      Member

      Looks like a duplicate of bpo-29353, which has a more complete patch proposed. However, see my comment about a problem with using heartersonly=True.

      My policy-flag.v2.patch for bpo-24363 may help (the details have faded from my mind, but I suspect it will either fix the problem as-is, or could be adapted).

    4. 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