Hans Leidekker : winhttp: Set last error for invalid and unimplemented header queries.
Alexandre Julliard
julliard at winehq.org
Fri Aug 2 14:26:31 CDT 2019
Module: wine
Branch: master
Commit: 788f588f0a1194c0334f7fde1dd5ef74791dfbf2
URL: https://source.winehq.org/git/wine.git/?a=commit;h=788f588f0a1194c0334f7fde1dd5ef74791dfbf2
Author: Hans Leidekker <hans at codeweavers.com>
Date: Fri Aug 2 11:01:38 2019 +0200
winhttp: Set last error for invalid and unimplemented header queries.
Signed-off-by: Hans Leidekker <hans at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/winhttp/request.c | 8 +++++++-
dlls/winhttp/tests/winhttp.c | 8 ++++++++
2 files changed, 15 insertions(+), 1 deletion(-)
diff --git a/dlls/winhttp/request.c b/dlls/winhttp/request.c
index 175837d..409ef68 100644
--- a/dlls/winhttp/request.c
+++ b/dlls/winhttp/request.c
@@ -746,9 +746,15 @@ static BOOL query_headers( struct request *request, DWORD level, const WCHAR *na
return ret;
default:
- if (attr >= ARRAY_SIZE(attribute_table) || !attribute_table[attr])
+ if (attr >= ARRAY_SIZE(attribute_table))
+ {
+ SetLastError( ERROR_INVALID_PARAMETER );
+ return FALSE;
+ }
+ if (!attribute_table[attr])
{
FIXME("attribute %u not implemented\n", attr);
+ SetLastError( ERROR_WINHTTP_HEADER_NOT_FOUND );
return FALSE;
}
TRACE("attribute %s\n", debugstr_w(attribute_table[attr]));
diff --git a/dlls/winhttp/tests/winhttp.c b/dlls/winhttp/tests/winhttp.c
index b075638..eb7c7b5 100644
--- a/dlls/winhttp/tests/winhttp.c
+++ b/dlls/winhttp/tests/winhttp.c
@@ -456,6 +456,14 @@ static void test_WinHttpSendRequest (void)
"Expected ERROR_SUCCESS got %u.\n", GetLastError());
ok(ret == TRUE, "WinHttpReceiveResponse failed: %u.\n", GetLastError());
+ SetLastError(0xdeadbeef);
+ ret = WinHttpQueryHeaders(request, WINHTTP_QUERY_ORIG_URI, NULL, NULL, &len, NULL);
+ ok(!ret && GetLastError() == ERROR_WINHTTP_HEADER_NOT_FOUND, "got %u\n", GetLastError());
+
+ SetLastError(0xdeadbeef);
+ ret = WinHttpQueryHeaders(request, WINHTTP_QUERY_MAX + 1, NULL, NULL, &len, NULL);
+ ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, "got %u\n", GetLastError());
+
bytes_rw = -1;
ret = WinHttpReadData(request, buffer, sizeof(buffer) - 1, &bytes_rw);
ok(ret == TRUE, "WinHttpReadData failed: %u.\n", GetLastError());
More information about the wine-cvs
mailing list