[issue29353] Incorrect handling of HTTP response with "Content-Type: message/rfc822" header

R. David Murray report at bugs.python.org
Wed Apr 5 07:36:15 EDT 2017


R. David Murray added the comment:

I'm not surprised that trying to render a message parsed with 'headersonly' fails.  headersonly treats the entire message body as a single string payload.  I'm not sure what the correct behavior should be for the email package, but the fact that this doesn't work currently shouldn't matter to the http package.  Given the error involves policy, it is quite possible as_string used to work in this context and I broke it when introducing policy because there is no test that covers this case.  I'm guessing there is no test because turning a message parsed with headersonly back into a string wasn't considered to be useful.

As for the multipart thing, that is actually consistent with the docs.  get_content_type gives you the value of the header, is_multipart effectively reports whether or not the payload is a list, and when parsed with headersonly, the body is a string not a list, which is documented.  Granted, you have to connect those dots yourself, so a sentence about that *could* be added to the headersonly docs.

All of which should be in a separate issue from this one.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue29353>
_______________________________________


More information about the Python-bugs-list mailing list