Multipart mixed responses generate warnings
See original GitHub issueIf you read a multipart/mixed response, the connectionpool issues a couple of warnings about defects in the message. I’m not sure what the expected, correct behavior is, but these warnings seem spurious.
Stick this perl script somewhere:
#!/usr/bin/perl
print "Server: Some Server Name\r\n";
print "Content-Type: multipart/mixed; boundary=36eeb8c4e26d842a\r\n";
print "Content-Length: 178\r\n";
print "\r\n\r\n";
print "--36eeb8c4e26d842a\r\n";
print "Content-Type: text/plain\r\n";
print "\r\n";
print "7\r\n";
print "--36eeb8c4e26d842a\r\n";
print "Content-Type: text/plain\r\n";
print "\r\n";
print "9\r\n";
print "--36eeb8c4e26d842a\r\n";
print "Content-Type: text/plain\r\n";
print "\r\n";
print "11\r\n";
print "--36eeb8c4e26d842a--\r\n";
Read it with requests (naturally, you’ll have to change the URI to wherever you put the script):
import requests, logging
logging.basicConfig(level=logging.WARNING)
logging.getLogger("requests").setLevel(logging.DEBUG)
headers = {'accept': "multipart/mixed"}
r = requests.get("http://localhost:8124/cgi-bin/mpm.pl", headers=headers)
print(r)
The following errors are displayed:
DEBUG:requests.packages.urllib3.connectionpool:"GET http://localhost:8124/cgi-bin/mpm.pl HTTP/1.1" 200 178
WARNING:requests.packages.urllib3.connectionpool:Failed to parse headers (url=http://localhost:8888/http://localhost:8124/cgi-bin/mpm.pl): [StartBoundaryNotFoundDefect(), MultipartInvariantViolationDefect()], unparsed data: ''
Traceback (most recent call last):
File "/home/ndw/.virtualenvs/pyapi/lib/python3.4/site-packages/requests-2.8.0-py3.4.egg/requests/packages/urllib3/connectionpool.py", line 390, in _make_request
assert_header_parsing(httplib_response.msg)
File "/home/ndw/.virtualenvs/pyapi/lib/python3.4/site-packages/requests-2.8.0-py3.4.egg/requests/packages/urllib3/util/response.py", line 58, in assert_header_parsing
raise HeaderParsingError(defects=defects, unparsed_data=unparsed_data)
requests.packages.urllib3.exceptions.HeaderParsingError: [StartBoundaryNotFoundDefect(), MultipartInvariantViolationDefect()], unparsed data: ''
It took me quite a while to work out that they were spurious (because in real life, the server side that is generating the multipart/mixed is more complicated!)
See also kennethreitz/requests#3001
Issue Analytics
- State:
- Created 8 years ago
- Reactions:15
- Comments:14 (6 by maintainers)
Top Results From Across the Web
Multipart mixed responses generate warnings - - Bountysource
If you read a multipart/mixed response, the connectionpool issues a couple of warnings about defects in the message.
Read more >Browser support of multipart responses - Stack Overflow
I have had HTTP multipart responses working for a stream of JPEG images. ... Just use: Content-type: multipart/x-mixed-replace -- everything ...
Read more >multipart/mixed content type and boundary refused by Amavis
I'm writing a Ruby script that send SMTP email. The email is divided onto 3 parts: headers, body and attachment. Unfortunatly, I'm struggling...
Read more >/Mixed-ing it up: Multipart/Mixed Messages and You ...
Multipart /Mixed, according to RFC 1521, means that the parts are completely independent of each other (not related to each other) but that...
Read more >Parsing multipart/mixed response in Spring Webclient - Medium
Uploading multipart data is very common nowadays. It is a http format which lets you attach multiple files to the request body of...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

As far as I know, yes.
This issue has been solved in master and will be released in v1.26.0