Hans Leidekker : winhttp: Implement WINHTTP_QUERY_REQUEST_METHOD.
Alexandre Julliard
julliard at winehq.org
Fri Aug 2 14:26:31 CDT 2019
Module: wine
Branch: master
Commit: e05590f454daf53030e26dd722213a28ef5cee97
URL: https://source.winehq.org/git/wine.git/?a=commit;h=e05590f454daf53030e26dd722213a28ef5cee97
Author: Hans Leidekker <hans at codeweavers.com>
Date: Fri Aug 2 11:01:36 2019 +0200
winhttp: Implement WINHTTP_QUERY_REQUEST_METHOD.
Signed-off-by: Hans Leidekker <hans at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/winhttp/request.c | 16 ++++++++++++++++
dlls/winhttp/tests/winhttp.c | 26 +++++++++++++++++---------
2 files changed, 33 insertions(+), 9 deletions(-)
diff --git a/dlls/winhttp/request.c b/dlls/winhttp/request.c
index 25f7950..0e54168 100644
--- a/dlls/winhttp/request.c
+++ b/dlls/winhttp/request.c
@@ -729,6 +729,22 @@ static BOOL query_headers( struct request *request, DWORD level, const WCHAR *na
*buflen = len;
return ret;
+ case WINHTTP_QUERY_REQUEST_METHOD:
+ len = strlenW( request->verb ) * sizeof(WCHAR);
+ if (!buffer || len + sizeof(WCHAR) > *buflen)
+ {
+ len += sizeof(WCHAR);
+ SetLastError( ERROR_INSUFFICIENT_BUFFER );
+ }
+ else
+ {
+ strcpyW( buffer, request->verb );
+ TRACE("returning string: %s\n", debugstr_w(buffer));
+ ret = TRUE;
+ }
+ *buflen = len;
+ return ret;
+
default:
if (attr >= ARRAY_SIZE(attribute_table) || !attribute_table[attr])
{
diff --git a/dlls/winhttp/tests/winhttp.c b/dlls/winhttp/tests/winhttp.c
index dfd3c4d..5849257 100644
--- a/dlls/winhttp/tests/winhttp.c
+++ b/dlls/winhttp/tests/winhttp.c
@@ -81,7 +81,7 @@ static BOOL proxy_active(void)
return active;
}
-static void test_QueryOption(void)
+static void test_WinHttpQueryOption(void)
{
BOOL ret;
HINTERNET session, request, connection;
@@ -267,7 +267,7 @@ done:
ok(ret, "WinHttpCloseHandle failed on closing session: %u\n", GetLastError());
}
-static void test_OpenRequest (void)
+static void test_WinHttpOpenRequest (void)
{
BOOL ret;
HINTERNET session, request, connection;
@@ -362,20 +362,21 @@ static void test_empty_headers_param(void)
WinHttpCloseHandle(ses);
}
-static void test_SendRequest (void)
+static void test_WinHttpSendRequest (void)
{
static const WCHAR content_type[] =
{'C','o','n','t','e','n','t','-','T','y','p','e',':',' ','a','p','p','l','i','c','a','t','i','o','n',
'/','x','-','w','w','w','-','f','o','r','m','-','u','r','l','e','n','c','o','d','e','d',0};
static const WCHAR test_file[] = {'t','e','s','t','s','/','p','o','s','t','.','p','h','p',0};
- static const WCHAR test_verb[] = {'P','O','S','T',0};
+ static const WCHAR postW[] = {'P','O','S','T',0};
static CHAR post_data[] = "mode=Test";
static const char test_post[] = "mode => Test\0\n";
HINTERNET session, request, connection;
- DWORD header_len, optional_len, total_len, bytes_rw, size, err, disable;
+ DWORD header_len, optional_len, total_len, bytes_rw, size, err, disable, len;
DWORD_PTR context;
BOOL ret;
CHAR buffer[256];
+ WCHAR method[8];
int i;
header_len = -1L;
@@ -389,7 +390,7 @@ static void test_SendRequest (void)
connection = WinHttpConnect (session, test_winehq, INTERNET_DEFAULT_HTTP_PORT, 0);
ok(connection != NULL, "WinHttpConnect failed to open a connection, error: %u.\n", GetLastError());
- request = WinHttpOpenRequest(connection, test_verb, test_file, NULL, WINHTTP_NO_REFERER,
+ request = WinHttpOpenRequest(connection, postW, test_file, NULL, WINHTTP_NO_REFERER,
WINHTTP_DEFAULT_ACCEPT_TYPES, WINHTTP_FLAG_BYPASS_PROXY_CACHE);
if (request == NULL && GetLastError() == ERROR_WINHTTP_NAME_NOT_RESOLVED)
{
@@ -399,6 +400,13 @@ static void test_SendRequest (void)
ok(request != NULL, "WinHttpOpenrequest failed to open a request, error: %u.\n", GetLastError());
if (!request) goto done;
+ method[0] = 0;
+ len = sizeof(method);
+ ret = WinHttpQueryHeaders(request, WINHTTP_QUERY_REQUEST_METHOD, NULL, method, &len, NULL);
+ ok(ret, "got %u\n", GetLastError());
+ ok(len == lstrlenW(postW) * sizeof(WCHAR), "got %u\n", len);
+ ok(!lstrcmpW(method, postW), "got %s\n", wine_dbgstr_w(method));
+
context = 0xdeadbeef;
ret = WinHttpSetOption(request, WINHTTP_OPTION_CONTEXT_VALUE, &context, sizeof(context));
ok(ret, "WinHttpSetOption failed: %u\n", GetLastError());
@@ -4728,14 +4736,14 @@ START_TEST (winhttp)
HANDLE thread;
DWORD ret;
- test_OpenRequest();
- test_SendRequest();
+ test_WinHttpOpenRequest();
+ test_WinHttpSendRequest();
test_WinHttpTimeFromSystemTime();
test_WinHttpTimeToSystemTime();
test_WinHttpAddHeaders();
test_secure_connection();
test_request_parameter_defaults();
- test_QueryOption();
+ test_WinHttpQueryOption();
test_set_default_proxy_config();
test_empty_headers_param();
test_timeouts();
More information about the wine-cvs
mailing list