wininet: Make HttpQueryInfo[AW] work for lpBuffer == NULL and len > 0.
This commit is contained in:
parent
ab7d17727c
commit
3fa49f0f02
|
@ -1973,6 +1973,8 @@ BOOL WINAPI HttpQueryInfoW(HINTERNET hHttpRequest, DWORD dwInfoLevel,
|
|||
goto lend;
|
||||
}
|
||||
|
||||
if (lpBuffer == NULL)
|
||||
*lpdwBufferLength = 0;
|
||||
bSuccess = HTTP_HttpQueryInfoW( lpwhr, dwInfoLevel,
|
||||
lpBuffer, lpdwBufferLength, lpdwIndex);
|
||||
|
||||
|
@ -2008,11 +2010,19 @@ BOOL WINAPI HttpQueryInfoA(HINTERNET hHttpRequest, DWORD dwInfoLevel,
|
|||
lpdwBufferLength, lpdwIndex );
|
||||
}
|
||||
|
||||
len = (*lpdwBufferLength)*sizeof(WCHAR);
|
||||
bufferW = HeapAlloc( GetProcessHeap(), 0, len );
|
||||
/* buffer is in/out because of HTTP_QUERY_CUSTOM */
|
||||
if ((dwInfoLevel & HTTP_QUERY_HEADER_MASK) == HTTP_QUERY_CUSTOM)
|
||||
MultiByteToWideChar(CP_ACP,0,lpBuffer,-1,bufferW,len);
|
||||
if (lpBuffer)
|
||||
{
|
||||
len = (*lpdwBufferLength)*sizeof(WCHAR);
|
||||
bufferW = HeapAlloc( GetProcessHeap(), 0, len );
|
||||
/* buffer is in/out because of HTTP_QUERY_CUSTOM */
|
||||
if ((dwInfoLevel & HTTP_QUERY_HEADER_MASK) == HTTP_QUERY_CUSTOM)
|
||||
MultiByteToWideChar(CP_ACP,0,lpBuffer,-1,bufferW,len);
|
||||
} else
|
||||
{
|
||||
bufferW = NULL;
|
||||
len = 0;
|
||||
}
|
||||
|
||||
result = HttpQueryInfoW( hHttpRequest, dwInfoLevel, bufferW,
|
||||
&len, lpdwIndex );
|
||||
if( result )
|
||||
|
|
|
@ -990,6 +990,37 @@ static void HttpHeaders_test(void)
|
|||
ok(HttpQueryInfo(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS,
|
||||
buffer,&len,&index)==0,"Second Index Should Not Exist\n");
|
||||
|
||||
|
||||
/* a call with NULL will fail but will return the length */
|
||||
index = 0;
|
||||
len = sizeof(buffer);
|
||||
SetLastError(0xdeadbeef);
|
||||
ok(HttpQueryInfo(hRequest,HTTP_QUERY_RAW_HEADERS_CRLF|HTTP_QUERY_FLAG_REQUEST_HEADERS,
|
||||
NULL,&len,&index) == FALSE,"Query worked\n");
|
||||
ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "Unexpected last error: %d\n", GetLastError());
|
||||
ok(len > 40, "Invalid length (exp. more than 40, got %d)\n", len);
|
||||
ok(index == 0, "Index was incremented\n");
|
||||
|
||||
/* even for a len that is too small */
|
||||
index = 0;
|
||||
len = 15;
|
||||
SetLastError(0xdeadbeef);
|
||||
ok(HttpQueryInfo(hRequest,HTTP_QUERY_RAW_HEADERS_CRLF|HTTP_QUERY_FLAG_REQUEST_HEADERS,
|
||||
NULL,&len,&index) == FALSE,"Query worked\n");
|
||||
ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "Unexpected last error: %d\n", GetLastError());
|
||||
ok(len > 40, "Invalid length (exp. more than 40, got %d)\n", len);
|
||||
ok(index == 0, "Index was incremented\n");
|
||||
|
||||
index = 0;
|
||||
len = 0;
|
||||
SetLastError(0xdeadbeef);
|
||||
ok(HttpQueryInfo(hRequest,HTTP_QUERY_RAW_HEADERS_CRLF|HTTP_QUERY_FLAG_REQUEST_HEADERS,
|
||||
NULL,&len,&index) == FALSE,"Query worked\n");
|
||||
ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "Unexpected last error: %d\n", GetLastError());
|
||||
ok(len > 40, "Invalid length (exp. more than 40, got %d)\n", len);
|
||||
ok(index == 0, "Index was incremented\n");
|
||||
|
||||
|
||||
/* a working query */
|
||||
index = 0;
|
||||
len = sizeof(buffer);
|
||||
|
|
Loading…
Reference in New Issue