Rob Shearman : wininet: Send the correct callbacks during InternetReadFileExA calls.

Alexandre Julliard julliard at wine.codeweavers.com
Wed Jun 6 07:41:54 CDT 2007


Module: wine
Branch: master
Commit: c16bb0718624cecde840f8a36d4681aec96d37e3
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=c16bb0718624cecde840f8a36d4681aec96d37e3

Author: Rob Shearman <rob at codeweavers.com>
Date:   Tue Jun  5 19:45:26 2007 +0100

wininet: Send the correct callbacks during InternetReadFileExA calls.

---

 dlls/wininet/internet.c   |   11 +++++++++++
 dlls/wininet/tests/http.c |   12 ++++++++++++
 2 files changed, 23 insertions(+), 0 deletions(-)

diff --git a/dlls/wininet/internet.c b/dlls/wininet/internet.c
index 305392a..214f8ee 100644
--- a/dlls/wininet/internet.c
+++ b/dlls/wininet/internet.c
@@ -1855,6 +1855,9 @@ BOOL WINAPI InternetReadFileExA(HINTERNET hFile, LPINTERNET_BUFFERSA lpBuffersOu
         return FALSE;
     }
 
+    INTERNET_SendCallback(lpwh, lpwh->dwContext,
+                          INTERNET_STATUS_RECEIVING_RESPONSE, NULL, 0);
+
     /* FIXME: IRF_ASYNC may not be the right thing to test here;
      * hIC->hdr.dwFlags & INTERNET_FLAG_ASYNC is probably better */
     if (dwFlags & IRF_ASYNC)
@@ -1887,6 +1890,14 @@ BOOL WINAPI InternetReadFileExA(HINTERNET hFile, LPINTERNET_BUFFERSA lpBuffersOu
         lpBuffersOut->dwBufferLength, &lpBuffersOut->dwBufferLength,
         !(dwFlags & IRF_NO_WAIT), FALSE);
 
+    if (retval)
+    {
+        DWORD dwBytesReceived = lpBuffersOut->dwBufferLength;
+        INTERNET_SendCallback(lpwh, lpwh->dwContext,
+                              INTERNET_STATUS_RESPONSE_RECEIVED, &dwBytesReceived,
+                              sizeof(dwBytesReceived));
+    }
+
     WININET_Release( lpwh );
 
     TRACE("-- %s (bytes read: %d)\n", retval ? "TRUE": "FALSE", lpBuffersOut->dwBufferLength);
diff --git a/dlls/wininet/tests/http.c b/dlls/wininet/tests/http.c
index 3cf5841..92ef629 100644
--- a/dlls/wininet/tests/http.c
+++ b/dlls/wininet/tests/http.c
@@ -34,6 +34,8 @@
 #define TEST_URL "http://www.winehq.org/site/about"
 
 static HANDLE hCompleteEvent;
+static BOOL bResponseReceived;
+static BOOL bReceivingResponse;
 
 static INTERNET_STATUS_CALLBACK (WINAPI *pInternetSetStatusCallbackA)(HINTERNET ,INTERNET_STATUS_CALLBACK);
 static BOOL (WINAPI *pInternetTimeFromSystemTimeA)(CONST SYSTEMTIME *,DWORD ,LPSTR ,DWORD);
@@ -93,6 +95,7 @@ static VOID WINAPI callback(
             trace("%04x:Callback %p 0x%lx INTERNET_STATUS_RECEIVING_RESPONSE %p %d\n",
                 GetCurrentThreadId(), hInternet, dwContext,
                 lpvStatusInformation,dwStatusInformationLength);
+            bReceivingResponse = TRUE;
             break;
         case INTERNET_STATUS_RESPONSE_RECEIVED:
             ok(dwStatusInformationLength == sizeof(DWORD),
@@ -101,6 +104,7 @@ static VOID WINAPI callback(
             trace("%04x:Callback %p 0x%lx INTERNET_STATUS_RESPONSE_RECEIVED 0x%x %d\n",
                 GetCurrentThreadId(), hInternet, dwContext,
                 *(DWORD *)lpvStatusInformation,dwStatusInformationLength);
+            bResponseReceived = TRUE;
             break;
         case INTERNET_STATUS_CTL_RESPONSE_RECEIVED:
             trace("%04x:Callback %p 0x%lx INTERNET_STATUS_CTL_RESPONSE_RECEIVED %p %d\n",
@@ -413,13 +417,17 @@ static void InternetReadFileExA_test(int flags)
         inetbuffers.dwOffsetHigh = 1234;
         inetbuffers.dwOffsetLow = 5678;
 
+        bReceivingResponse = FALSE;
+        bResponseReceived = FALSE;
         rc = InternetReadFileExA(hor, &inetbuffers, IRF_ASYNC | IRF_USE_CONTEXT, 0xcafebabe);
         if (!rc)
         {
             if (GetLastError() == ERROR_IO_PENDING)
             {
                 trace("InternetReadFileEx -> PENDING\n");
+                ok(bReceivingResponse, "INTERNET_STATUS_RECEIVING_RESPONSE should have been sent to callback function\n");
                 WaitForSingleObject(hCompleteEvent, INFINITE);
+                ok(!bResponseReceived, "INTERNET_STATUS_RESPONSE_RECEIVED should not have been sent to callback function\n");
             }
             else
             {
@@ -428,7 +436,11 @@ static void InternetReadFileExA_test(int flags)
             }
         }
         else
+        {
             trace("InternetReadFileEx -> SUCCEEDED\n");
+            ok(bReceivingResponse, "INTERNET_STATUS_RECEIVING_RESPONSE should have been sent to callback function\n");
+            ok(bResponseReceived, "INTERNET_STATUS_RESPONSE_RECEIVED should have been sent to callback function\n");
+        }
 
         trace("read %i bytes\n", inetbuffers.dwBufferLength);
         ((char *)inetbuffers.lpvBuffer)[inetbuffers.dwBufferLength] = '\0';




More information about the wine-cvs mailing list