Module: wine Branch: master Commit: 12931062fbf5387cfcb0bdb65a110c503728bd6b URL: http://source.winehq.org/git/wine.git/?a=commit;h=12931062fbf5387cfcb0bdb65a...
Author: Jacek Caban jacek@codeweavers.com Date: Tue Jan 13 00:28:25 2009 +0100
wininet: Make sure that we have data buffered before sending INTERNET_STATUS_REQUEST_COMPLETE notification.
---
dlls/wininet/http.c | 50 +++++++++++++++++++++++++++++++------------- dlls/wininet/tests/http.c | 2 +- 2 files changed, 36 insertions(+), 16 deletions(-)
diff --git a/dlls/wininet/http.c b/dlls/wininet/http.c index d4ea219..cdcf8e1 100644 --- a/dlls/wininet/http.c +++ b/dlls/wininet/http.c @@ -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 */
- iar.dwResult = (DWORD_PTR)lpwhr->hdr.hInternet; - iar.dwError = bSuccess ? ERROR_SUCCESS : INTERNET_GetLastError(); + if(lpwhr->lpHttpSession->lpAppInfo->hdr.dwFlags & INTERNET_FLAG_ASYNC) { + if(bSuccess) { + HTTP_ReceiveRequestData(lpwhr); + }else { + iar.dwResult = (DWORD_PTR)lpwhr->hdr.hInternet; + iar.dwError = INTERNET_GetLastError();
- INTERNET_SendCallback(&lpwhr->hdr, lpwhr->hdr.dwContext, - INTERNET_STATUS_REQUEST_COMPLETE, &iar, - sizeof(INTERNET_ASYNC_RESULT)); + INTERNET_SendCallback(&lpwhr->hdr, lpwhr->hdr.dwContext, + INTERNET_STATUS_REQUEST_COMPLETE, &iar, + sizeof(INTERNET_ASYNC_RESULT)); + } + }
TRACE("<--\n"); if (bSuccess) INTERNET_SetLastError(ERROR_SUCCESS); diff --git a/dlls/wininet/tests/http.c b/dlls/wininet/tests/http.c index 89995bf..34f4708 100644 --- a/dlls/wininet/tests/http.c +++ b/dlls/wininet/tests/http.c @@ -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);