Hi Hans,
Sorry for the delay, I wanted to test it a bit more before answering.
On 09/23/13 10:50, Hans Leidekker wrote:
On Thu, 2013-09-19 at 17:38 +0200, Jacek Caban wrote:
I was hoping for a test like the attached one, which shows that there is still more work to do. But it's a step in the right direction, so I'm fine with your patch.
The issue here is that HTTP_ReceiveRequestData calls refill_read_buffer, which calls generic read_http_stream with a read size of 8192 (the read buffer is still empty). In non-chunked mode this should read the minimum of that size and the content length. In chunked mode we don't know the content length, and we should read the minimum of chunk size and read buffer size, as shown by your test. Maybe we should add a refill_read_buffer method to the backends and call that instead of read_http_stream?
We should be able to do that with read semantics that is intended for READMODE_ASYNC: read anything, not more than buf size and, once any data is read, don't block. The attached extended tests show the problem with chunked reads in this case. We'd need to maintain full state of the stream to be able to do non-blocking chunk headers/tails reads.
Jacek