wininet: Make sure that we have data buffered before sending INTERNET_STATUS_REQUEST_COMPLETE notification.

This commit is contained in:
Jacek Caban 2009-01-13 00:28:25 +01:00 committed by Alexandre Julliard
parent 49177a0958
commit 12931062fb
2 changed files with 36 additions and 16 deletions

View File

@ -1636,6 +1636,29 @@ static DWORD HTTPREQ_SetOption(WININETHANDLEHEADER *hdr, DWORD option, void *buf
return ERROR_INTERNET_INVALID_OPTION;
}
static void HTTP_ReceiveRequestData(WININETHTTPREQW *req)
{
INTERNET_ASYNC_RESULT iar;
BYTE buffer[4096];
BOOL res;
TRACE("%p\n", req);
res = NETCON_recv(&req->netConnection, buffer,
min(sizeof(buffer), req->dwContentLength - req->dwContentRead),
MSG_PEEK, (int *)&iar.dwError);
if(res) {
iar.dwResult = (DWORD_PTR)req->hdr.hInternet;
}else {
iar.dwResult = 0;
iar.dwError = INTERNET_GetLastError();
}
INTERNET_SendCallback(&req->hdr, req->hdr.dwContext, INTERNET_STATUS_REQUEST_COMPLETE, &iar,
sizeof(INTERNET_ASYNC_RESULT));
}
static DWORD HTTP_Read(WININETHTTPREQW *req, void *buffer, DWORD size, DWORD *read, BOOL sync)
{
int bytes_read;
@ -1847,17 +1870,8 @@ static BOOL HTTPREQ_WriteFile(WININETHANDLEHEADER *hdr, const void *buffer, DWOR
static void HTTPREQ_AsyncQueryDataAvailableProc(WORKREQUEST *workRequest)
{
WININETHTTPREQW *req = (WININETHTTPREQW*)workRequest->hdr;
INTERNET_ASYNC_RESULT iar;
char buffer[4048];
TRACE("%p\n", workRequest->hdr);
iar.dwResult = NETCON_recv(&req->netConnection, buffer,
min(sizeof(buffer), req->dwContentLength - req->dwContentRead),
MSG_PEEK, (int *)&iar.dwError);
INTERNET_SendCallback(&req->hdr, req->hdr.dwContext, INTERNET_STATUS_REQUEST_COMPLETE, &iar,
sizeof(INTERNET_ASYNC_RESULT));
HTTP_ReceiveRequestData(req);
}
static DWORD HTTPREQ_QueryDataAvailable(WININETHANDLEHEADER *hdr, DWORD *available, DWORD flags, DWORD_PTR ctx)
@ -3465,12 +3479,18 @@ lend:
/* TODO: send notification for P3P header */
if(lpwhr->lpHttpSession->lpAppInfo->hdr.dwFlags & INTERNET_FLAG_ASYNC) {
if(bSuccess) {
HTTP_ReceiveRequestData(lpwhr);
}else {
iar.dwResult = (DWORD_PTR)lpwhr->hdr.hInternet;
iar.dwError = bSuccess ? ERROR_SUCCESS : INTERNET_GetLastError();
iar.dwError = INTERNET_GetLastError();
INTERNET_SendCallback(&lpwhr->hdr, lpwhr->hdr.dwContext,
INTERNET_STATUS_REQUEST_COMPLETE, &iar,
sizeof(INTERNET_ASYNC_RESULT));
}
}
TRACE("<--\n");
if (bSuccess) INTERNET_SetLastError(ERROR_SUCCESS);

View File

@ -367,7 +367,7 @@ static void InternetReadFile_test(int flags)
if (flags & INTERNET_FLAG_ASYNC)
CHECK_NOTIFIED(INTERNET_STATUS_REQUEST_COMPLETE);
else
todo_wine CHECK_NOT_NOTIFIED(INTERNET_STATUS_REQUEST_COMPLETE);
CHECK_NOT_NOTIFIED(INTERNET_STATUS_REQUEST_COMPLETE);
/* Sent on WinXP only if first_connection_to_test_url is TRUE, on Win98 always sent */
CLEAR_NOTIFIED(INTERNET_STATUS_CONNECTING_TO_SERVER);
CLEAR_NOTIFIED(INTERNET_STATUS_CONNECTED_TO_SERVER);