wininet: Send the correct callbacks during InternetReadFileExA calls.

This commit is contained in:
Rob Shearman 2007-06-05 19:45:26 +01:00 committed by Alexandre Julliard
parent 785771272a
commit c16bb07186
2 changed files with 23 additions and 0 deletions

View File

@ -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);

View File

@ -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';