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