From 16d300cacdeae49c73e334f5b519b112e019751f Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Tue, 2 Aug 2016 15:33:40 +0200 Subject: [PATCH] wininet: Return data available in current chunk in chunked_get_avail_data. Based on a patch by Hans Leidekker. Signed-off-by: Jacek Caban Signed-off-by: Alexandre Julliard --- dlls/wininet/http.c | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/dlls/wininet/http.c b/dlls/wininet/http.c index 47700c93804..ac794048ff1 100644 --- a/dlls/wininet/http.c +++ b/dlls/wininet/http.c @@ -2711,12 +2711,6 @@ static char next_chunked_data_char(chunked_stream_t *stream) return stream->buf[stream->buf_pos++]; } -static DWORD chunked_get_avail_data(data_stream_t *stream, http_request_t *req) -{ - /* Allow reading only from read buffer */ - return 0; -} - static BOOL chunked_end_of_data(data_stream_t *stream, http_request_t *req) { chunked_stream_t *chunked_stream = (chunked_stream_t*)stream; @@ -2858,6 +2852,26 @@ static DWORD chunked_read(data_stream_t *stream, http_request_t *req, BYTE *buf, return ERROR_SUCCESS; } +static DWORD chunked_get_avail_data(data_stream_t *stream, http_request_t *req) +{ + chunked_stream_t *chunked_stream = (chunked_stream_t*)stream; + DWORD avail = 0; + + if(chunked_stream->state != CHUNKED_STREAM_STATE_READING_CHUNK) { + DWORD res, read; + + /* try to process to the next chunk */ + res = chunked_read(stream, req, NULL, 0, &read, BLOCKING_DISALLOW); + if(res != ERROR_SUCCESS || chunked_stream->state != CHUNKED_STREAM_STATE_READING_CHUNK) + return 0; + } + + if(is_valid_netconn(req->netconn) && chunked_stream->buf_size < chunked_stream->chunk_size) + NETCON_query_data_available(req->netconn, &avail); + + return min(avail + chunked_stream->buf_size, chunked_stream->chunk_size); +} + static BOOL chunked_drain_content(data_stream_t *stream, http_request_t *req) { chunked_stream_t *chunked_stream = (chunked_stream_t*)stream;