From: Hans Leidekker hans@codeweavers.com
--- dlls/winhttp/session.c | 38 ++++++++++++++++++++++++++++++++++++ dlls/winhttp/tests/winhttp.c | 38 ++++++++++++++++++++++++++++++++++-- 2 files changed, 74 insertions(+), 2 deletions(-)
diff --git a/dlls/winhttp/session.c b/dlls/winhttp/session.c index a473451b9a6..d579d72583e 100644 --- a/dlls/winhttp/session.c +++ b/dlls/winhttp/session.c @@ -739,6 +739,33 @@ static BOOL copy_sockaddr( const struct sockaddr *addr, SOCKADDR_STORAGE *addr_s } }
+static WCHAR *build_url( struct request *request ) +{ + URL_COMPONENTS uc; + DWORD len = 0; + WCHAR *ret; + + memset( &uc, 0, sizeof(uc) ); + uc.dwStructSize = sizeof(uc); + uc.nScheme = (request->hdr.flags & WINHTTP_FLAG_SECURE) ? INTERNET_SCHEME_HTTPS : INTERNET_SCHEME_HTTP; + uc.lpszHostName = request->connect->hostname; + uc.dwHostNameLength = wcslen( uc.lpszHostName ); + uc.nPort = request->connect->hostport; + uc.lpszUserName = request->connect->username; + uc.dwUserNameLength = request->connect->username ? wcslen( request->connect->username ) : 0; + uc.lpszPassword = request->connect->password; + uc.dwPasswordLength = request->connect->password ? wcslen( request->connect->password ) : 0; + uc.lpszUrlPath = request->path; + uc.dwUrlPathLength = wcslen( uc.lpszUrlPath ); + + WinHttpCreateUrl( &uc, 0, NULL, &len ); + if (GetLastError() != ERROR_INSUFFICIENT_BUFFER || !(ret = malloc( len * sizeof(WCHAR) ))) return NULL; + + if (WinHttpCreateUrl( &uc, 0, ret, &len )) return ret; + free( ret ); + return NULL; +} + static BOOL request_query_option( struct object_header *hdr, DWORD option, void *buffer, DWORD *buflen ) { struct request *request = (struct request *)hdr; @@ -916,6 +943,17 @@ static BOOL request_query_option( struct object_header *hdr, DWORD option, void *buflen = sizeof(DWORD); return TRUE;
+ case WINHTTP_OPTION_URL: + { + WCHAR *url; + BOOL ret; + + if (!(url = build_url( request ))) return FALSE; + ret = return_string_option( buffer, url, buflen ); + free( url ); + return ret; + } + default: FIXME( "unimplemented option %lu\n", option ); SetLastError( ERROR_INVALID_PARAMETER ); diff --git a/dlls/winhttp/tests/winhttp.c b/dlls/winhttp/tests/winhttp.c index 03b1c067fb5..a1f8c15e356 100644 --- a/dlls/winhttp/tests/winhttp.c +++ b/dlls/winhttp/tests/winhttp.c @@ -3304,6 +3304,7 @@ static void test_redirect(int port) HINTERNET ses, con, req; char buf[128]; DWORD size, len, count, status; + WCHAR url[128], expected[128]; BOOL ret;
ses = WinHttpOpen(L"winetest", WINHTTP_ACCESS_TYPE_NO_PROXY, NULL, NULL, 0); @@ -3315,12 +3316,32 @@ static void test_redirect(int port) req = WinHttpOpenRequest(con, L"POST", L"/redirect", NULL, NULL, NULL, 0); ok(req != NULL, "failed to open a request %lu\n", GetLastError());
+ url[0] = 0; + size = sizeof(url); + ret = WinHttpQueryOption(req, WINHTTP_OPTION_URL, url, &size); + ok(ret, "got %lu\n", GetLastError()); + swprintf(expected, ARRAY_SIZE(expected), L"http://localhost:%u/redirect", port); + ok(!wcscmp(url, expected), "expected %s got %s\n", wine_dbgstr_w(expected), wine_dbgstr_w(url)); + ret = WinHttpSendRequest(req, NULL, 0, (void *)"data", sizeof("data"), sizeof("data"), 0); ok(ret, "failed to send request %lu\n", GetLastError());
+ url[0] = 0; + size = sizeof(url); + ret = WinHttpQueryOption(req, WINHTTP_OPTION_URL, url, &size); + ok(ret, "got %lu\n", GetLastError()); + ok(!wcscmp(url, expected), "expected %s got %s\n", wine_dbgstr_w(expected), wine_dbgstr_w(url)); + ret = WinHttpReceiveResponse(req, NULL); ok(ret, "failed to receive response %lu\n", GetLastError());
+ url[0] = 0; + size = sizeof(url); + ret = WinHttpQueryOption(req, WINHTTP_OPTION_URL, url, &size); + ok(ret, "got %lu\n", GetLastError()); + swprintf(expected, ARRAY_SIZE(expected), L"http://localhost:%u/temporary", port); + ok(!wcscmp(url, expected), "expected %s got %s\n", wine_dbgstr_w(expected), wine_dbgstr_w(url)); + status = 0xdeadbeef; size = sizeof(status); ret = WinHttpQueryHeaders(req, WINHTTP_QUERY_STATUS_CODE | WINHTTP_QUERY_FLAG_NUMBER, @@ -5685,7 +5706,8 @@ done: static void test_max_http_automatic_redirects (void) { HINTERNET session, request, connection; - DWORD max_redirects, err; + DWORD max_redirects, err, size; + WCHAR url[128]; BOOL ret;
session = WinHttpOpen(L"winetest", WINHTTP_ACCESS_TYPE_DEFAULT_PROXY, @@ -5719,11 +5741,23 @@ static void test_max_http_automatic_redirects (void) } ok(ret == TRUE, "WinHttpSendRequest failed: %lu\n", GetLastError());
+ url[0] = 0; + size = sizeof(url); + ret = WinHttpQueryOption(request, WINHTTP_OPTION_URL, url, &size); + ok(ret, "got %lu\n", GetLastError()); + ok(!wcscmp(url, L"http://test.winehq.org/tests/redirecttest.php?max=3"), "got %s\n", wine_dbgstr_w(url)); + SetLastError(0xdeadbeef); ret = WinHttpReceiveResponse(request, NULL); ok(!ret, "WinHttpReceiveResponse succeeded, expected failure\n"); ok(GetLastError() == ERROR_WINHTTP_REDIRECT_FAILED, "Expected ERROR_WINHTTP_REDIRECT_FAILED, got %lu\n", GetLastError());
+ url[0] = 0; + size = sizeof(url); + ret = WinHttpQueryOption(request, WINHTTP_OPTION_URL, url, &size); + ok(ret, "got %lu\n", GetLastError()); + ok(!wcscmp(url, L"http://test.winehq.org/tests/redirecttest.php?id=2&max=3"), "got %s\n", wine_dbgstr_w(url)); + done: ret = WinHttpCloseHandle(request); ok(ret == TRUE, "WinHttpCloseHandle failed on closing request, got %d.\n", ret); @@ -6132,9 +6166,9 @@ START_TEST (winhttp) test_WinHttpGetIEProxyConfigForCurrentUser(); test_chunked_read(); test_max_http_automatic_redirects(); + si.event = CreateEventW(NULL, 0, 0, NULL); si.port = 7532; - thread = CreateThread(NULL, 0, server_thread, &si, 0, NULL); ok(thread != NULL, "failed to create thread %lu\n", GetLastError());
Hi,
It looks like your patch introduced the new failures shown below. Please investigate and fix them before resubmitting your patch. If they are not new, fixing them anyway would help a lot. Otherwise please ask for the known failures list to be updated.
The full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=146948
Your paranoid android.
=== w7u_2qxl (32 bit report) ===
winhttp: winhttp.c:5683: Test failed: got L"http://test.winehq.org/tests/redirecttest.php?id=1&max=3"
=== w7u_adm (32 bit report) ===
winhttp: winhttp.c:5683: Test failed: got L"http://test.winehq.org/tests/redirecttest.php?id=1&max=3"
=== w7u_el (32 bit report) ===
winhttp: winhttp.c:5683: Test failed: got L"http://test.winehq.org/tests/redirecttest.php?id=1&max=3"
=== w8 (32 bit report) ===
winhttp: winhttp.c:5683: Test failed: got L"http://test.winehq.org/tests/redirecttest.php?id=1&max=3"
=== w8adm (32 bit report) ===
winhttp: winhttp.c:5683: Test failed: got L"http://test.winehq.org/tests/redirecttest.php?id=1&max=3"
=== w864 (32 bit report) ===
winhttp: winhttp.c:5683: Test failed: got L"http://test.winehq.org/tests/redirecttest.php?id=1&max=3"
=== w1064v1507 (32 bit report) ===
winhttp: winhttp.c:5683: Test failed: got L"http://test.winehq.org/tests/redirecttest.php?id=1&max=3"
=== w7pro64 (64 bit report) ===
winhttp: winhttp.c:5683: Test failed: got L"http://test.winehq.org/tests/redirecttest.php?id=1&max=3"
=== w864 (64 bit report) ===
winhttp: winhttp.c:5683: Test failed: got L"http://test.winehq.org/tests/redirecttest.php?id=1&max=3"
=== w1064v1507 (64 bit report) ===
winhttp: winhttp.c:5683: Test failed: got L"http://test.winehq.org/tests/redirecttest.php?id=1&max=3"
=== debian11 (build log) ===
/home/winetest/tools/testbot/var/wine-win32/../wine/dlls/winhttp/session.c:948: undefined reference to `return_string_option' collect2: error: ld returned 1 exit status Task: The win32 Wine build failed
=== debian11b (build log) ===
/home/winetest/tools/testbot/var/wine-wow64/../wine/dlls/winhttp/session.c:948: undefined reference to `return_string_option' collect2: error: ld returned 1 exit status Task: The wow64 Wine build failed