Title: http client marks valid multipart headers with defects.
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.5
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 2017-04-19 05:18 by berker.peksag. This issue is now closed.

File name Uploaded Description Edit 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 .\ server```
and run client with:
```python .\ 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:

The submitted PR partially fixes the problem:
```..\python.bat .\ client```
which outputs
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).
Date User Action Args
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