wininet: Support HTTP_QUERY_RAW_HEADER_CRLF|HTTP_QUERY_FLAG_REQUEST_HEADERS.
This commit is contained in:
parent
cf3535351a
commit
ab7d17727c
|
@ -1664,19 +1664,33 @@ static BOOL WINAPI HTTP_HttpQueryInfoW( LPWININETHTTPREQW lpwhr, DWORD dwInfoLev
|
||||||
|
|
||||||
case HTTP_QUERY_RAW_HEADERS_CRLF:
|
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))
|
if (len + 1 > *lpdwBufferLength/sizeof(WCHAR))
|
||||||
{
|
{
|
||||||
*lpdwBufferLength = (len + 1) * sizeof(WCHAR);
|
*lpdwBufferLength = (len + 1) * sizeof(WCHAR);
|
||||||
INTERNET_SetLastError(ERROR_INSUFFICIENT_BUFFER);
|
INTERNET_SetLastError(ERROR_INSUFFICIENT_BUFFER);
|
||||||
return FALSE;
|
ret = FALSE;
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
memcpy(lpBuffer, headers, (len+1)*sizeof(WCHAR));
|
||||||
|
*lpdwBufferLength = len * sizeof(WCHAR);
|
||||||
|
|
||||||
|
TRACE("returning data: %s\n", debugstr_wn((WCHAR*)lpBuffer, len));
|
||||||
|
ret = TRUE;
|
||||||
}
|
}
|
||||||
memcpy(lpBuffer, lpwhr->lpszRawHeaders, (len+1)*sizeof(WCHAR));
|
|
||||||
*lpdwBufferLength = len * sizeof(WCHAR);
|
|
||||||
|
|
||||||
TRACE("returning data: %s\n", debugstr_wn((WCHAR*)lpBuffer, len));
|
if (request_only)
|
||||||
|
HeapFree(GetProcessHeap(), 0, headers);
|
||||||
return TRUE;
|
return ret;
|
||||||
}
|
}
|
||||||
case HTTP_QUERY_RAW_HEADERS:
|
case HTTP_QUERY_RAW_HEADERS:
|
||||||
{
|
{
|
||||||
|
|
|
@ -983,11 +983,25 @@ static void HttpHeaders_test(void)
|
||||||
buffer,&len,&index),"Unable to query header\n");
|
buffer,&len,&index),"Unable to query header\n");
|
||||||
ok(index == 1, "Index was not incremented\n");
|
ok(index == 1, "Index was not incremented\n");
|
||||||
ok(strcmp(buffer,"test1")==0, "incorrect string was returned(%s)\n",buffer);
|
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);
|
len = sizeof(buffer);
|
||||||
strcpy(buffer,"Warning");
|
strcpy(buffer,"Warning");
|
||||||
ok(HttpQueryInfo(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS,
|
ok(HttpQueryInfo(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS,
|
||||||
buffer,&len,&index)==0,"Second Index Should Not Exist\n");
|
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),
|
ok(HttpAddRequestHeaders(hRequest,"Warning:test2",-1,HTTP_ADDREQ_FLAG_ADD),
|
||||||
"Failed to add duplicate header using HTTP_ADDREQ_FLAG_ADD\n");
|
"Failed to add duplicate header using HTTP_ADDREQ_FLAG_ADD\n");
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue