[issue22233] http.client splits headers on non-\r\n characters

Martin Panter report at bugs.python.org
Fri Nov 27 20:34:32 EST 2015


Martin Panter added the comment:

David: what is the email issue you mentioned? In the mean time, I am uploading a patch to this issue.

It seems using StringIO is a bit slower than str.splitlines(). I found a way to optimize building long lines, which compensated a lot of the loss, but this optimization would apply even without using StringIO. My patch makes test.test_email 0.3% slower (the optimization alone would make it 4.4% faster), and test_email.TestFeedParsers.test_long_lines() is 3% slower (optimization 12% faster).

I also tried two other alternatives to str.splitlines(), but they were both slower than the StringIO technique:
* _partial is a list of UTF-8 bytes; join and use bytes.splitlines()
* _partial is a UTF-8 bytearray; use bytearray.splitlines()

----------
keywords: +patch
stage: needs patch -> patch review
versions: +Python 3.6
Added file: http://bugs.python.org/file41177/crlf-headers.patch

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


More information about the Python-bugs-list mailing list