Commit 846cc2b1 authored by Hans Leidekker's avatar Hans Leidekker Committed by Alexandre Julliard

winhttp: Implement WinHttpQueryHeaders(WINHTTP_QUERY_VERSION).

parent 39b1dbed
...@@ -652,6 +652,24 @@ static BOOL query_headers( request_t *request, DWORD level, LPCWSTR name, LPVOID ...@@ -652,6 +652,24 @@ static BOOL query_headers( request_t *request, DWORD level, LPCWSTR name, LPVOID
if (request_only) heap_free( headers ); if (request_only) heap_free( headers );
return ret; return ret;
} }
case WINHTTP_QUERY_VERSION:
{
DWORD len = (strlenW( request->version ) + 1) * sizeof(WCHAR);
if (len > *buflen)
{
set_last_error( ERROR_INSUFFICIENT_BUFFER );
*buflen = len;
return FALSE;
}
else if (buffer)
{
strcpyW( buffer, request->version );
TRACE("returning string: %s\n", debugstr_w(buffer));
ret = TRUE;
}
*buflen = len - sizeof(WCHAR);
return ret;
}
default: default:
{ {
if (attr >= sizeof(attribute_table)/sizeof(attribute_table[0]) || !attribute_table[attr]) if (attr >= sizeof(attribute_table)/sizeof(attribute_table[0]) || !attribute_table[attr])
......
...@@ -816,7 +816,8 @@ static void test_request_parameter_defaults(void) ...@@ -816,7 +816,8 @@ static void test_request_parameter_defaults(void)
static const WCHAR codeweavers[] = {'c','o','d','e','w','e','a','v','e','r','s','.','c','o','m',0}; static const WCHAR codeweavers[] = {'c','o','d','e','w','e','a','v','e','r','s','.','c','o','m',0};
HANDLE ses, con, req; HANDLE ses, con, req;
DWORD size, status; DWORD size, status, error;
WCHAR *version;
BOOL ret; BOOL ret;
ses = WinHttpOpen(test_useragent, 0, NULL, NULL, 0); ses = WinHttpOpen(test_useragent, 0, NULL, NULL, 0);
...@@ -850,6 +851,19 @@ static void test_request_parameter_defaults(void) ...@@ -850,6 +851,19 @@ static void test_request_parameter_defaults(void)
ret = WinHttpReceiveResponse(req, NULL); ret = WinHttpReceiveResponse(req, NULL);
ok(ret, "failed to receive response %u\n", GetLastError()); ok(ret, "failed to receive response %u\n", GetLastError());
size = 0;
SetLastError(0xdeadbeef);
ret = WinHttpQueryHeaders(req, WINHTTP_QUERY_VERSION, NULL, NULL, &size, NULL);
error = GetLastError();
ok(!ret, "succeeded unexpectedly\n");
ok(error == ERROR_INSUFFICIENT_BUFFER, "expected ERROR_INSUFFICIENT_BUFFER, got %u\n", error);
version = HeapAlloc(GetProcessHeap(), 0, size);
ret = WinHttpQueryHeaders(req, WINHTTP_QUERY_VERSION, NULL, version, &size, NULL);
ok(ret, "failed unexpectedly %u\n", GetLastError());
ok(lstrlenW(version) == size / sizeof(WCHAR), "unexpected size %u\n", size);
HeapFree(GetProcessHeap(), 0, version);
size = sizeof(status); size = sizeof(status);
ret = WinHttpQueryHeaders(req, WINHTTP_QUERY_STATUS_CODE | WINHTTP_QUERY_FLAG_NUMBER, NULL, &status, &size, NULL); ret = WinHttpQueryHeaders(req, WINHTTP_QUERY_STATUS_CODE | WINHTTP_QUERY_FLAG_NUMBER, NULL, &status, &size, NULL);
ok(ret, "failed unexpectedly %u\n", GetLastError()); ok(ret, "failed unexpectedly %u\n", GetLastError());
......
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