Commit 851866e2 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

wininet: Set available bytes in InternetQueryDataAvailable even if it ends up in async call.

parent 5f14eb56
......@@ -2763,7 +2763,7 @@ static void send_request_complete(http_request_t *req, DWORD_PTR result, DWORD e
sizeof(INTERNET_ASYNC_RESULT));
}
static void HTTP_ReceiveRequestData(http_request_t *req, BOOL first_notif)
static void HTTP_ReceiveRequestData(http_request_t *req, BOOL first_notif, DWORD *ret_size)
{
DWORD res, read = 0, avail = 0;
read_mode_t mode;
......@@ -2776,6 +2776,8 @@ static void HTTP_ReceiveRequestData(http_request_t *req, BOOL first_notif)
res = refill_read_buffer(req, mode, &read);
if(res == ERROR_SUCCESS && !first_notif)
avail = get_avail_data(req);
if(ret_size)
*ret_size = get_avail_data(req);
LeaveCriticalSection( &req->read_section );
......@@ -2993,11 +2995,16 @@ static DWORD HTTPREQ_WriteFile(object_header_t *hdr, const void *buffer, DWORD s
return res;
}
static void AsyncQueryDataAvailableProc(task_header_t *task)
typedef struct {
task_header_t hdr;
DWORD *ret_size;
} http_data_available_task_t;
static void AsyncQueryDataAvailableProc(task_header_t *hdr)
{
http_request_t *req = (http_request_t*)task->hdr;
http_data_available_task_t *task = (http_data_available_task_t*)hdr;
HTTP_ReceiveRequestData(req, FALSE);
HTTP_ReceiveRequestData((http_request_t*)task->hdr.hdr, FALSE, task->ret_size);
}
static DWORD HTTPREQ_QueryDataAvailable(object_header_t *hdr, DWORD *available, DWORD flags, DWORD_PTR ctx)
......@@ -3008,7 +3015,7 @@ static DWORD HTTPREQ_QueryDataAvailable(object_header_t *hdr, DWORD *available,
if (req->session->appInfo->hdr.dwFlags & INTERNET_FLAG_ASYNC)
{
task_header_t *task;
http_data_available_task_t *task;
/* never wait, if we can't enter the section we queue an async request right away */
if (TryEnterCriticalSection( &req->read_section ))
......@@ -3020,7 +3027,8 @@ static DWORD HTTPREQ_QueryDataAvailable(object_header_t *hdr, DWORD *available,
}
task = alloc_async_task(&req->hdr, AsyncQueryDataAvailableProc, sizeof(*task));
INTERNET_AsyncCall(task);
task->ret_size = available;
INTERNET_AsyncCall(&task->hdr);
return ERROR_IO_PENDING;
}
......@@ -4923,7 +4931,7 @@ lend:
{
if (res == ERROR_SUCCESS) {
if(bEndRequest && request->contentLength && request->bytesWritten == request->bytesToWrite)
HTTP_ReceiveRequestData(request, TRUE);
HTTP_ReceiveRequestData(request, TRUE, NULL);
else
send_request_complete(request,
request->session->hdr.dwInternalFlags & INET_OPENURL ? (DWORD_PTR)request->hdr.hInternet : 1, 0);
......@@ -5034,7 +5042,7 @@ static DWORD HTTP_HttpEndRequestW(http_request_t *request, DWORD dwFlags, DWORD_
create_cache_entry(request);
if (res == ERROR_SUCCESS && request->contentLength)
HTTP_ReceiveRequestData(request, TRUE);
HTTP_ReceiveRequestData(request, TRUE, NULL);
else
send_request_complete(request, res == ERROR_SUCCESS, res);
......
......@@ -448,7 +448,7 @@ static void InternetReadFile_test(int flags, const test_data_t *test)
char *post_data = NULL;
BOOL res, on_async = TRUE;
CHAR buffer[4000];
DWORD length, post_len = 0;
DWORD length, exlen = 0, post_len = 0;
const char *types[2] = { "*", NULL };
HINTERNET hi, hic = 0, hor = 0;
......@@ -649,12 +649,17 @@ static void InternetReadFile_test(int flags, const test_data_t *test)
{
if (flags & INTERNET_FLAG_ASYNC)
SET_EXPECT(INTERNET_STATUS_REQUEST_COMPLETE);
length = 0;
res = InternetQueryDataAvailable(hor,&length,0x0,0x0);
if (flags & INTERNET_FLAG_ASYNC)
{
if (res)
{
CHECK_NOT_NOTIFIED(INTERNET_STATUS_REQUEST_COMPLETE);
if(exlen) {
ok(length >= exlen, "length %u < exlen %u\n", length, exlen);
exlen = 0;
}
}
else if (GetLastError() == ERROR_IO_PENDING)
{
......@@ -663,6 +668,8 @@ static void InternetReadFile_test(int flags, const test_data_t *test)
if(!(test->flags & TESTF_CHUNKED))
ok(!length, "InternetQueryDataAvailable returned ERROR_IO_PENDING and %u length\n", length);
WaitForSingleObject(hCompleteEvent, INFINITE);
exlen = length;
ok(exlen, "length = 0\n");
CHECK_NOTIFIED(INTERNET_STATUS_REQUEST_COMPLETE);
ok(req_error, "req_error = 0\n");
continue;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment