[issue19009] Enhance HTTPResponse.readline() performance

Kristján Valur Jónsson report at bugs.python.org
Tue Sep 17 00:29:01 CEST 2013


Kristján Valur Jónsson added the comment:

Ok, I'm adding a more comprehensive patch.  It adds support for
peek, readline, and read1 for both regular and chunked responses.
readline falls back to IOBase.readline for chunked, which again makes use of peek() for performance.
read1() is available for other kinds of client buffering, e.g. when reading the stream incrementally using other delimiters than newline.

The real work is done by the _read1_or_peek_chunked() method.  the code for both cases is almost identical so a dual purpose method is warranted.

Added test cases to test this.  The test cases don't attempt to test that we don't block on partial resopnses, though.  I'm not sure how I would write such a test.  I'd probably have to extend FakeSocket to work on some stream that can be appended to...

----------
Added file: http://bugs.python.org/file31804/httpresponse.patch

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


More information about the Python-bugs-list mailing list