This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: http client marks valid multipart headers with defects.
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.5
process
Status: closed Resolution: duplicate
Dependencies: Superseder: Incorrect handling of HTTP response with "Content-Type: message/rfc822" header
View: 29353
Assigned To: Nosy List: martin.panter, pareshverma91
Priority: normal Keywords:

Created on 2017-04-05 08:04 by pareshverma91, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
example_bug.py pareshverma91, 2017-04-05 08:04 Example server-client for repro. Use commands from comment section.
Pull Requests
URL Status Linked Edit
PR 996 pareshverma91, 2017-04-05 08:04
Messages (2)
msg291165 - (view) Author: Paresh Verma (pareshverma91) * Date: 2017-04-05 08:04
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:
https://github.com/shazow/urllib3/issues/800
https://github.com/Azure/azure-storage-python/issues/167

The submitted PR partially fixes the problem:
```..\python.bat .\example_bug.py client```
which outputs
"""[MultipartInvariantViolationDefect()]"""
msg291168 - (view) Author: Martin Panter (martin.panter) * (Python committer) Date: 2017-04-05 08:24
Looks like a duplicate of Issue 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 Issue 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).
History
Date User Action Args
2022-04-11 14:58:44adminsetgithub: 74177
2017-04-19 05:18:07berker.peksagsetstatus: open -> closed
stage: resolved
2017-04-05 08:24:53martin.pantersetnosy: + martin.panter
messages: + msg291168
resolution: duplicate

superseder: Incorrect handling of HTTP response with "Content-Type: message/rfc822" header
2017-04-05 08:04:42pareshverma91create