static DWORD chunked_get_avail_data(data_stream_t *stream, http_request_t *req) { - /* Allow reading only from read buffer */ + chunked_stream_t *chunked_stream = (chunked_stream_t*)stream; + DWORD res; + + if(!chunked_stream->chunk_size || chunked_stream->chunk_size == ~0u) { + res = start_next_chunk(chunked_stream, req); + if(res != ERROR_SUCCESS) + return 0; + }