Message197574
| 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:30 | kristjan.jonsson | set | recipients:
+ kristjan.jonsson |
| 2013年09月13日 13:39:30 | kristjan.jonsson | set | messageid: <1379079570.46.0.352920817481.issue19009@psf.upfronthosting.co.za> |
| 2013年09月13日 13:39:30 | kristjan.jonsson | link | issue19009 messages |
| 2013年09月13日 13:39:30 | kristjan.jonsson | create |
|