Commit ab7d1772 authored by Mikołaj Zalewski's avatar Mikołaj Zalewski Committed by Alexandre Julliard

wininet: Support HTTP_QUERY_RAW_HEADER_CRLF|HTTP_QUERY_FLAG_REQUEST_HEADERS.

parent cf353535
......@@ -1664,19 +1664,33 @@ static BOOL WINAPI HTTP_HttpQueryInfoW( LPWININETHTTPREQW lpwhr, DWORD dwInfoLev
case HTTP_QUERY_RAW_HEADERS_CRLF:
{
DWORD len = strlenW(lpwhr->lpszRawHeaders);
LPWSTR headers;
DWORD len;
BOOL ret;
if (request_only)
headers = HTTP_BuildHeaderRequestString(lpwhr, lpwhr->lpszVerb, lpwhr->lpszPath, FALSE);
else
headers = lpwhr->lpszRawHeaders;
len = strlenW(headers);
if (len + 1 > *lpdwBufferLength/sizeof(WCHAR))
{
*lpdwBufferLength = (len + 1) * sizeof(WCHAR);
INTERNET_SetLastError(ERROR_INSUFFICIENT_BUFFER);
return FALSE;
}
memcpy(lpBuffer, lpwhr->lpszRawHeaders, (len+1)*sizeof(WCHAR));
*lpdwBufferLength = len * sizeof(WCHAR);
ret = FALSE;
} else
{
memcpy(lpBuffer, headers, (len+1)*sizeof(WCHAR));
*lpdwBufferLength = len * sizeof(WCHAR);
TRACE("returning data: %s\n", debugstr_wn((WCHAR*)lpBuffer, len));
TRACE("returning data: %s\n", debugstr_wn((WCHAR*)lpBuffer, len));
ret = TRUE;
}
return TRUE;
if (request_only)
HeapFree(GetProcessHeap(), 0, headers);
return ret;
}
case HTTP_QUERY_RAW_HEADERS:
{
......
......@@ -983,11 +983,25 @@ static void HttpHeaders_test(void)
buffer,&len,&index),"Unable to query header\n");
ok(index == 1, "Index was not incremented\n");
ok(strcmp(buffer,"test1")==0, "incorrect string was returned(%s)\n",buffer);
ok(len == 5, "Invalid length (exp. 5, got %d)\n", len);
ok(buffer[len] == 0, "Buffer not NULL-terminated\n"); /* len show only 5 characters but the buffer is NULL-terminated*/
len = sizeof(buffer);
strcpy(buffer,"Warning");
ok(HttpQueryInfo(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS,
buffer,&len,&index)==0,"Second Index Should Not Exist\n");
/* a working query */
index = 0;
len = sizeof(buffer);
ok(HttpQueryInfo(hRequest,HTTP_QUERY_RAW_HEADERS_CRLF|HTTP_QUERY_FLAG_REQUEST_HEADERS,
buffer,&len,&index),"Unable to query header\n");
/* what's in the middle differs between Wine and Windows so currently we check only the beginning and the end */
ok(strncmp(buffer, "POST /posttest.php HTTP/1", 25)==0, "Invalid beginning of headers string\n");
ok(strcmp(buffer + strlen(buffer) - 4, "\r\n\r\n")==0, "Invalid end of headers string\n");
ok(index == 0, "Index was incremented\n");
ok(HttpAddRequestHeaders(hRequest,"Warning:test2",-1,HTTP_ADDREQ_FLAG_ADD),
"Failed to add duplicate header using HTTP_ADDREQ_FLAG_ADD\n");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment