This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author kristjan.jonsson
Recipients kristjan.jonsson
Date 2013-09-13.13:39:29
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1379079570.46.0.352920817481.issue19009@psf.upfronthosting.co.za>
In-reply-to
Content
Some applications require reading http response data in "long" polls as it becomes available.  This is used, e.g. to receive "notifications" over a HTTP stream.
Using response.read(large_buffer) is not possible because this will attempt to fullfill the entire request (using multiple underlying recv() calls), negating the attempt to get data as it becomes available.
Using "readline", and using \n boundaries in the data, this problem can be overcome.
Currently, readline is slow because it will attempt to read one byte at a time.  Even if it is doing so from a buffered stream, it is still doing it one character at a time.
This patch adds a "peek" method to HttpResponse, which works both for chunked and non-chunked transfer encoding, thus improving the performance of readline.  IOBase.readline will use peek() to determine the readahead it can use, instead of one byte which it must use by default.
History
Date User Action Args
2013-09-13 13:39:30kristjan.jonssonsetrecipients: + kristjan.jonsson
2013-09-13 13:39:30kristjan.jonssonsetmessageid: <1379079570.46.0.352920817481.issue19009@psf.upfronthosting.co.za>
2013-09-13 13:39:30kristjan.jonssonlinkissue19009 messages
2013-09-13 13:39:30kristjan.jonssoncreate