wininet: Fix buffer size query for HttpQueryInfo(HTTP_QUERY_RAW_HEADERS_CRLF).
This commit is contained in:
parent
b11156b84a
commit
694a09284a
|
@ -2197,27 +2197,26 @@ static BOOL WINAPI HTTP_HttpQueryInfoW( LPWININETHTTPREQW lpwhr, DWORD dwInfoLev
|
|||
{
|
||||
LPWSTR headers;
|
||||
DWORD len;
|
||||
BOOL ret;
|
||||
BOOL ret = FALSE;
|
||||
|
||||
if (request_only)
|
||||
headers = HTTP_BuildHeaderRequestString(lpwhr, lpwhr->lpszVerb, lpwhr->lpszPath, lpwhr->lpszVersion);
|
||||
else
|
||||
headers = lpwhr->lpszRawHeaders;
|
||||
|
||||
len = strlenW(headers);
|
||||
if (len + 1 > *lpdwBufferLength/sizeof(WCHAR))
|
||||
len = (strlenW(headers) + 1) * sizeof(WCHAR);
|
||||
if (len > *lpdwBufferLength)
|
||||
{
|
||||
*lpdwBufferLength = (len + 1) * sizeof(WCHAR);
|
||||
INTERNET_SetLastError(ERROR_INSUFFICIENT_BUFFER);
|
||||
ret = FALSE;
|
||||
} else
|
||||
}
|
||||
else if (lpBuffer)
|
||||
{
|
||||
memcpy(lpBuffer, headers, (len+1)*sizeof(WCHAR));
|
||||
*lpdwBufferLength = len * sizeof(WCHAR);
|
||||
|
||||
TRACE("returning data: %s\n", debugstr_wn((WCHAR*)lpBuffer, len));
|
||||
memcpy(lpBuffer, headers, len);
|
||||
TRACE("returning data: %s\n", debugstr_wn(lpBuffer, len / sizeof(WCHAR)));
|
||||
ret = TRUE;
|
||||
}
|
||||
*lpdwBufferLength = len;
|
||||
|
||||
if (request_only)
|
||||
HeapFree(GetProcessHeap(), 0, headers);
|
||||
|
|
|
@ -1848,10 +1848,15 @@ static void test_open_url_async(void)
|
|||
type = 0;
|
||||
size = sizeof(type);
|
||||
ret = InternetQueryOption(ctx.req, INTERNET_OPTION_HANDLE_TYPE, &type, &size);
|
||||
ok(ret, "HttpQueryInfo failed: %u\n", GetLastError());
|
||||
ok(ret, "InternetQueryOption failed: %u\n", GetLastError());
|
||||
ok(type == INTERNET_HANDLE_TYPE_HTTP_REQUEST,
|
||||
"expected INTERNET_HANDLE_TYPE_HTTP_REQUEST, got %u\n", type);
|
||||
|
||||
size = 0;
|
||||
ret = HttpQueryInfo(ctx.req, HTTP_QUERY_RAW_HEADERS_CRLF, NULL, &size, NULL);
|
||||
ok(!ret && GetLastError() == ERROR_INSUFFICIENT_BUFFER, "HttpQueryInfo failed\n");
|
||||
ok(size > 0, "expected size > 0\n");
|
||||
|
||||
CloseHandle(ctx.event);
|
||||
InternetCloseHandle(ctx.req);
|
||||
InternetCloseHandle(ses);
|
||||
|
|
Loading…
Reference in New Issue