2008-07-18 02:37:23 +02:00
|
|
|
/*
|
|
|
|
* WinHTTP - tests
|
|
|
|
*
|
|
|
|
* Copyright 2008 Google (Zac Brown)
|
2015-09-02 07:44:50 +02:00
|
|
|
* Copyright 2015 Dmitry Timoshkov
|
2008-07-18 02:37:23 +02:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
2008-08-20 11:37:17 +02:00
|
|
|
|
2011-07-21 11:52:44 +02:00
|
|
|
#define COBJMACROS
|
2008-07-18 02:37:23 +02:00
|
|
|
#include <stdarg.h>
|
|
|
|
#include <windef.h>
|
2013-03-15 10:39:00 +01:00
|
|
|
#include <winsock2.h>
|
|
|
|
#include <ws2tcpip.h>
|
2008-07-18 02:37:23 +02:00
|
|
|
#include <winhttp.h>
|
2008-09-08 22:01:39 +02:00
|
|
|
#include <wincrypt.h>
|
2009-07-14 21:36:41 +02:00
|
|
|
#include <winreg.h>
|
2015-08-27 12:28:32 +02:00
|
|
|
#include <initguid.h>
|
2011-07-21 11:52:44 +02:00
|
|
|
#include <httprequest.h>
|
2015-08-27 12:28:32 +02:00
|
|
|
#include <httprequestid.h>
|
2008-07-18 02:37:23 +02:00
|
|
|
|
|
|
|
#include "wine/test.h"
|
2018-09-19 16:17:46 +02:00
|
|
|
#include "wine/heap.h"
|
2008-07-18 02:37:23 +02:00
|
|
|
|
2015-08-27 12:28:32 +02:00
|
|
|
DEFINE_GUID(GUID_NULL,0,0,0,0,0,0,0,0,0,0,0);
|
|
|
|
|
2020-06-24 10:33:10 +02:00
|
|
|
static DWORD (WINAPI *pWinHttpWebSocketClose)(HINTERNET,USHORT,void*,DWORD);
|
2020-06-16 11:45:12 +02:00
|
|
|
static HINTERNET (WINAPI *pWinHttpWebSocketCompleteUpgrade)(HINTERNET,DWORD_PTR);
|
2020-06-24 10:33:10 +02:00
|
|
|
static DWORD (WINAPI *pWinHttpWebSocketQueryCloseStatus)(HINTERNET,USHORT*,void*,DWORD,DWORD*);
|
|
|
|
static DWORD (WINAPI *pWinHttpWebSocketReceive)(HINTERNET,void*,DWORD,DWORD*,WINHTTP_WEB_SOCKET_BUFFER_TYPE*);
|
|
|
|
static DWORD (WINAPI *pWinHttpWebSocketSend)(HINTERNET,WINHTTP_WEB_SOCKET_BUFFER_TYPE,void*,DWORD);
|
|
|
|
static DWORD (WINAPI *pWinHttpWebSocketShutdown)(HINTERNET,USHORT,void*,DWORD);
|
2020-06-16 11:45:12 +02:00
|
|
|
|
2011-01-17 12:37:23 +01:00
|
|
|
static BOOL proxy_active(void)
|
|
|
|
{
|
|
|
|
WINHTTP_PROXY_INFO proxy_info;
|
|
|
|
BOOL active = FALSE;
|
|
|
|
|
2015-08-03 11:27:31 +02:00
|
|
|
SetLastError(0xdeadbeef);
|
2011-01-17 12:37:23 +01:00
|
|
|
if (WinHttpGetDefaultProxyConfiguration(&proxy_info))
|
|
|
|
{
|
2015-08-03 11:27:31 +02:00
|
|
|
ok(GetLastError() == ERROR_SUCCESS || broken(GetLastError() == 0xdeadbeef) /* < win7 */,
|
|
|
|
"got %u\n", GetLastError());
|
2011-01-17 12:37:23 +01:00
|
|
|
active = (proxy_info.lpszProxy != NULL);
|
|
|
|
if (active)
|
2012-07-19 10:22:59 +02:00
|
|
|
GlobalFree(proxy_info.lpszProxy);
|
2011-01-17 12:37:23 +01:00
|
|
|
if (proxy_info.lpszProxyBypass != NULL)
|
2012-07-19 10:22:59 +02:00
|
|
|
GlobalFree(proxy_info.lpszProxyBypass);
|
2011-01-17 12:37:23 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
active = FALSE;
|
|
|
|
|
|
|
|
return active;
|
|
|
|
}
|
|
|
|
|
2019-08-02 11:01:36 +02:00
|
|
|
static void test_WinHttpQueryOption(void)
|
2008-09-16 11:51:58 +02:00
|
|
|
{
|
|
|
|
BOOL ret;
|
|
|
|
HINTERNET session, request, connection;
|
|
|
|
DWORD feature, size;
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
2020-02-14 16:41:38 +01:00
|
|
|
session = WinHttpOpen(L"winetest", 0, 0, 0, 0);
|
2008-09-16 11:51:58 +02:00
|
|
|
ok(session != NULL, "WinHttpOpen failed to open session, error %u\n", GetLastError());
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = WinHttpQueryOption(session, WINHTTP_OPTION_REDIRECT_POLICY, NULL, NULL);
|
|
|
|
ok(!ret, "should fail to set redirect policy %u\n", GetLastError());
|
|
|
|
ok(GetLastError() == ERROR_INVALID_PARAMETER,
|
|
|
|
"expected ERROR_INVALID_PARAMETER, got %u\n", GetLastError());
|
|
|
|
|
|
|
|
size = 0xdeadbeef;
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = WinHttpQueryOption(session, WINHTTP_OPTION_REDIRECT_POLICY, NULL, &size);
|
|
|
|
ok(!ret, "should fail to query option\n");
|
|
|
|
ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER,
|
|
|
|
"expected ERROR_INSUFFICIENT_BUFFER, got %u\n", GetLastError());
|
|
|
|
ok(size == 4, "expected 4, got %u\n", size);
|
|
|
|
|
|
|
|
feature = 0xdeadbeef;
|
|
|
|
size = sizeof(feature) - 1;
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = WinHttpQueryOption(session, WINHTTP_OPTION_REDIRECT_POLICY, &feature, &size);
|
|
|
|
ok(!ret, "should fail to query option\n");
|
|
|
|
ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER,
|
|
|
|
"expected ERROR_INSUFFICIENT_BUFFER, got %u\n", GetLastError());
|
|
|
|
ok(size == 4, "expected 4, got %u\n", size);
|
|
|
|
|
|
|
|
feature = 0xdeadbeef;
|
|
|
|
size = sizeof(feature) + 1;
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = WinHttpQueryOption(session, WINHTTP_OPTION_REDIRECT_POLICY, &feature, &size);
|
|
|
|
ok(ret, "failed to query option %u\n", GetLastError());
|
2015-08-03 11:27:31 +02:00
|
|
|
ok(GetLastError() == ERROR_SUCCESS || broken(GetLastError() == 0xdeadbeef) /* < win7 */,
|
|
|
|
"got %u\n", GetLastError());
|
2008-09-16 11:51:58 +02:00
|
|
|
ok(size == sizeof(feature), "WinHttpQueryOption should set the size: %u\n", size);
|
|
|
|
ok(feature == WINHTTP_OPTION_REDIRECT_POLICY_DISALLOW_HTTPS_TO_HTTP,
|
|
|
|
"expected WINHTTP_OPTION_REDIRECT_POLICY_DISALLOW_HTTPS_TO_HTTP, got %#x\n", feature);
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = WinHttpSetOption(session, WINHTTP_OPTION_REDIRECT_POLICY, NULL, sizeof(feature));
|
|
|
|
ok(!ret, "should fail to set redirect policy %u\n", GetLastError());
|
|
|
|
ok(GetLastError() == ERROR_INVALID_PARAMETER,
|
|
|
|
"expected ERROR_INVALID_PARAMETER, got %u\n", GetLastError());
|
|
|
|
|
|
|
|
feature = WINHTTP_OPTION_REDIRECT_POLICY_ALWAYS;
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = WinHttpSetOption(session, WINHTTP_OPTION_REDIRECT_POLICY, &feature, sizeof(feature) - 1);
|
|
|
|
ok(!ret, "should fail to set redirect policy %u\n", GetLastError());
|
|
|
|
ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER,
|
|
|
|
"expected ERROR_INSUFFICIENT_BUFFER, got %u\n", GetLastError());
|
|
|
|
|
|
|
|
feature = WINHTTP_OPTION_REDIRECT_POLICY_ALWAYS;
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = WinHttpSetOption(session, WINHTTP_OPTION_REDIRECT_POLICY, &feature, sizeof(feature) + 1);
|
|
|
|
ok(!ret, "should fail to set redirect policy %u\n", GetLastError());
|
|
|
|
ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER,
|
|
|
|
"expected ERROR_INSUFFICIENT_BUFFER, got %u\n", GetLastError());
|
|
|
|
|
|
|
|
feature = WINHTTP_OPTION_REDIRECT_POLICY_ALWAYS;
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = WinHttpSetOption(session, WINHTTP_OPTION_REDIRECT_POLICY, &feature, sizeof(feature));
|
|
|
|
ok(ret, "failed to set redirect policy %u\n", GetLastError());
|
|
|
|
|
|
|
|
feature = 0xdeadbeef;
|
|
|
|
size = sizeof(feature);
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = WinHttpQueryOption(session, WINHTTP_OPTION_REDIRECT_POLICY, &feature, &size);
|
|
|
|
ok(ret, "failed to query option %u\n", GetLastError());
|
|
|
|
ok(feature == WINHTTP_OPTION_REDIRECT_POLICY_ALWAYS,
|
|
|
|
"expected WINHTTP_OPTION_REDIRECT_POLICY_ALWAYS, got %#x\n", feature);
|
|
|
|
|
|
|
|
feature = WINHTTP_DISABLE_COOKIES;
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = WinHttpSetOption(session, WINHTTP_OPTION_DISABLE_FEATURE, &feature, sizeof(feature));
|
|
|
|
ok(!ret, "should fail to set disable feature for a session\n");
|
|
|
|
ok(GetLastError() == ERROR_WINHTTP_INCORRECT_HANDLE_TYPE,
|
|
|
|
"expected ERROR_WINHTTP_INCORRECT_HANDLE_TYPE, got %u\n", GetLastError());
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
2020-02-14 16:41:38 +01:00
|
|
|
connection = WinHttpConnect(session, L"test.winehq.org", INTERNET_DEFAULT_HTTP_PORT, 0);
|
2008-09-16 11:51:58 +02:00
|
|
|
ok(connection != NULL, "WinHttpConnect failed to open a connection, error: %u\n", GetLastError());
|
|
|
|
|
|
|
|
feature = WINHTTP_DISABLE_COOKIES;
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = WinHttpSetOption(connection, WINHTTP_OPTION_DISABLE_FEATURE, &feature, sizeof(feature));
|
|
|
|
ok(!ret, "should fail to set disable feature for a connection\n");
|
|
|
|
ok(GetLastError() == ERROR_WINHTTP_INCORRECT_HANDLE_TYPE,
|
|
|
|
"expected ERROR_WINHTTP_INCORRECT_HANDLE_TYPE, got %u\n", GetLastError());
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
request = WinHttpOpenRequest(connection, NULL, NULL, NULL, WINHTTP_NO_REFERER,
|
|
|
|
WINHTTP_DEFAULT_ACCEPT_TYPES, 0);
|
|
|
|
if (request == NULL && GetLastError() == ERROR_WINHTTP_NAME_NOT_RESOLVED)
|
|
|
|
{
|
|
|
|
skip("Network unreachable, skipping the test\n");
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
feature = 0xdeadbeef;
|
|
|
|
size = sizeof(feature);
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = WinHttpQueryOption(request, WINHTTP_OPTION_DISABLE_FEATURE, &feature, &size);
|
|
|
|
ok(!ret, "should fail to query disable feature for a request\n");
|
|
|
|
ok(GetLastError() == ERROR_INVALID_PARAMETER,
|
|
|
|
"expected ERROR_INVALID_PARAMETER, got %u\n", GetLastError());
|
|
|
|
|
|
|
|
feature = 0;
|
|
|
|
size = sizeof(feature);
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = WinHttpSetOption(request, WINHTTP_OPTION_DISABLE_FEATURE, &feature, sizeof(feature));
|
|
|
|
ok(ret, "failed to set feature %u\n", GetLastError());
|
|
|
|
|
|
|
|
feature = 0xffffffff;
|
|
|
|
size = sizeof(feature);
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = WinHttpSetOption(request, WINHTTP_OPTION_DISABLE_FEATURE, &feature, sizeof(feature));
|
|
|
|
ok(ret, "failed to set feature %u\n", GetLastError());
|
|
|
|
|
|
|
|
feature = WINHTTP_DISABLE_COOKIES;
|
|
|
|
size = sizeof(feature);
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = WinHttpSetOption(request, WINHTTP_OPTION_DISABLE_FEATURE, &feature, sizeof(feature));
|
|
|
|
ok(ret, "failed to set feature %u\n", GetLastError());
|
|
|
|
|
|
|
|
size = 0;
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = WinHttpQueryOption(request, WINHTTP_OPTION_DISABLE_FEATURE, NULL, &size);
|
|
|
|
ok(!ret, "should fail to query disable feature for a request\n");
|
|
|
|
ok(GetLastError() == ERROR_INVALID_PARAMETER,
|
|
|
|
"expected ERROR_INVALID_PARAMETER, got %u\n", GetLastError());
|
|
|
|
|
2018-08-24 10:32:49 +02:00
|
|
|
feature = 0xdeadbeef;
|
|
|
|
size = sizeof(feature);
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = WinHttpQueryOption(request, WINHTTP_OPTION_ENABLE_FEATURE, &feature, &size);
|
|
|
|
ok(!ret, "should fail to query enabled features for a request\n");
|
|
|
|
ok(feature == 0xdeadbeef, "expect feature 0xdeadbeef, got %u\n", feature);
|
|
|
|
ok(GetLastError() == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %u\n", GetLastError());
|
|
|
|
|
|
|
|
feature = WINHTTP_ENABLE_SSL_REVOCATION;
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = WinHttpSetOption(request, WINHTTP_OPTION_ENABLE_FEATURE, 0, sizeof(feature));
|
|
|
|
ok(!ret, "should fail to enable WINHTTP_ENABLE_SSL_REVOCATION with invalid parameters\n");
|
|
|
|
ok(GetLastError() == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %u\n", GetLastError());
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = WinHttpSetOption(request, WINHTTP_OPTION_ENABLE_FEATURE, &feature, 0);
|
|
|
|
ok(!ret, "should fail to enable WINHTTP_ENABLE_SSL_REVOCATION with invalid parameters\n");
|
|
|
|
ok(GetLastError() == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %u\n", GetLastError());
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = WinHttpSetOption(request, WINHTTP_OPTION_ENABLE_FEATURE, &feature, sizeof(feature));
|
|
|
|
ok(ret, "failed to set feature\n");
|
|
|
|
ok(GetLastError() == NO_ERROR || broken(GetLastError() == 0xdeadbeef), /* Doesn't set error code on Vista or older */
|
|
|
|
"expected NO_ERROR, got %u\n", GetLastError());
|
|
|
|
|
|
|
|
feature = 0xdeadbeef;
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = WinHttpSetOption(request, WINHTTP_OPTION_ENABLE_FEATURE, &feature, sizeof(feature));
|
|
|
|
ok(!ret, "should fail to enable WINHTTP_ENABLE_SSL_REVOCATION with invalid parameters\n");
|
|
|
|
ok(GetLastError() == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %u\n", GetLastError());
|
|
|
|
|
2018-09-04 15:43:59 +02:00
|
|
|
feature = 6;
|
|
|
|
size = sizeof(feature);
|
|
|
|
ret = WinHttpSetOption(request, WINHTTP_OPTION_CONNECT_RETRIES, &feature, sizeof(feature));
|
|
|
|
ok(ret, "failed to set WINHTTP_OPTION_CONNECT_RETRIES %u\n", GetLastError());
|
|
|
|
|
2008-09-16 11:51:58 +02:00
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = WinHttpCloseHandle(request);
|
|
|
|
ok(ret, "WinHttpCloseHandle failed on closing request: %u\n", GetLastError());
|
|
|
|
|
|
|
|
done:
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = WinHttpCloseHandle(connection);
|
|
|
|
ok(ret, "WinHttpCloseHandle failed on closing connection: %u\n", GetLastError());
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = WinHttpCloseHandle(session);
|
|
|
|
ok(ret, "WinHttpCloseHandle failed on closing session: %u\n", GetLastError());
|
|
|
|
}
|
|
|
|
|
2019-08-02 11:01:36 +02:00
|
|
|
static void test_WinHttpOpenRequest (void)
|
2008-07-18 02:37:23 +02:00
|
|
|
{
|
|
|
|
BOOL ret;
|
|
|
|
HINTERNET session, request, connection;
|
2015-08-03 11:27:31 +02:00
|
|
|
DWORD err;
|
2008-07-18 02:37:23 +02:00
|
|
|
|
2015-08-03 11:27:31 +02:00
|
|
|
SetLastError(0xdeadbeef);
|
2020-02-14 16:41:38 +01:00
|
|
|
session = WinHttpOpen(L"winetest", WINHTTP_ACCESS_TYPE_DEFAULT_PROXY,
|
2008-07-18 02:37:23 +02:00
|
|
|
WINHTTP_NO_PROXY_NAME, WINHTTP_NO_PROXY_BYPASS, 0);
|
2015-08-03 11:27:31 +02:00
|
|
|
err = GetLastError();
|
2008-08-15 14:42:15 +02:00
|
|
|
ok(session != NULL, "WinHttpOpen failed to open session.\n");
|
2015-08-03 11:27:31 +02:00
|
|
|
ok(err == ERROR_SUCCESS, "got %u\n", err);
|
2008-07-18 02:37:23 +02:00
|
|
|
|
|
|
|
/* Test with a bad server name */
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
connection = WinHttpConnect(session, NULL, INTERNET_DEFAULT_HTTP_PORT, 0);
|
2015-08-03 11:27:31 +02:00
|
|
|
err = GetLastError();
|
2008-07-18 02:37:23 +02:00
|
|
|
ok (connection == NULL, "WinHttpConnect succeeded in opening connection to NULL server argument.\n");
|
2015-08-03 11:27:31 +02:00
|
|
|
ok(err == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %u.\n", err);
|
2008-07-18 02:37:23 +02:00
|
|
|
|
|
|
|
/* Test with a valid server name */
|
2015-08-03 11:27:31 +02:00
|
|
|
SetLastError(0xdeadbeef);
|
2020-02-14 16:41:38 +01:00
|
|
|
connection = WinHttpConnect (session, L"test.winehq.org", INTERNET_DEFAULT_HTTP_PORT, 0);
|
2015-08-03 11:27:31 +02:00
|
|
|
err = GetLastError();
|
|
|
|
ok(connection != NULL, "WinHttpConnect failed to open a connection, error: %u.\n", err);
|
|
|
|
ok(err == ERROR_SUCCESS || broken(err == WSAEINVAL) /* < win7 */, "got %u\n", err);
|
2008-07-18 02:37:23 +02:00
|
|
|
|
2015-08-03 11:27:31 +02:00
|
|
|
SetLastError(0xdeadbeef);
|
2008-07-18 02:37:23 +02:00
|
|
|
request = WinHttpOpenRequest(connection, NULL, NULL, NULL, WINHTTP_NO_REFERER,
|
|
|
|
WINHTTP_DEFAULT_ACCEPT_TYPES, 0);
|
2015-08-03 11:27:31 +02:00
|
|
|
err = GetLastError();
|
|
|
|
if (request == NULL && err == ERROR_WINHTTP_NAME_NOT_RESOLVED)
|
2008-07-18 02:37:23 +02:00
|
|
|
{
|
|
|
|
skip("Network unreachable, skipping.\n");
|
|
|
|
goto done;
|
|
|
|
}
|
2015-08-03 11:27:31 +02:00
|
|
|
ok(request != NULL, "WinHttpOpenrequest failed to open a request, error: %u.\n", err);
|
|
|
|
ok(err == ERROR_SUCCESS, "got %u\n", err);
|
2008-07-18 02:37:23 +02:00
|
|
|
|
2015-08-03 11:27:31 +02:00
|
|
|
SetLastError(0xdeadbeef);
|
2008-07-18 02:37:23 +02:00
|
|
|
ret = WinHttpSendRequest(request, WINHTTP_NO_ADDITIONAL_HEADERS, 0, NULL, 0, 0, 0);
|
2015-08-03 11:27:31 +02:00
|
|
|
err = GetLastError();
|
2015-09-22 15:58:33 +02:00
|
|
|
if (!ret && (err == ERROR_WINHTTP_CANNOT_CONNECT || err == ERROR_WINHTTP_TIMEOUT))
|
2010-06-07 22:41:40 +02:00
|
|
|
{
|
|
|
|
skip("Connection failed, skipping.\n");
|
|
|
|
goto done;
|
|
|
|
}
|
2015-08-03 11:27:31 +02:00
|
|
|
ok(ret, "WinHttpSendRequest failed: %u\n", err);
|
|
|
|
ok(err == ERROR_SUCCESS, "got %u\n", err);
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
2008-07-18 02:37:23 +02:00
|
|
|
ret = WinHttpCloseHandle(request);
|
2015-08-03 11:27:31 +02:00
|
|
|
err = GetLastError();
|
|
|
|
ok(ret, "WinHttpCloseHandle failed on closing request, got %u.\n", err);
|
|
|
|
ok(err == ERROR_SUCCESS, "got %u\n", err);
|
2008-07-18 02:37:23 +02:00
|
|
|
|
|
|
|
done:
|
|
|
|
ret = WinHttpCloseHandle(connection);
|
2008-08-15 14:42:28 +02:00
|
|
|
ok(ret == TRUE, "WinHttpCloseHandle failed on closing connection, got %d.\n", ret);
|
2008-07-18 02:37:23 +02:00
|
|
|
ret = WinHttpCloseHandle(session);
|
2008-08-15 14:42:15 +02:00
|
|
|
ok(ret == TRUE, "WinHttpCloseHandle failed on closing session, got %d.\n", ret);
|
2008-07-18 02:37:23 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2009-10-29 11:12:22 +01:00
|
|
|
static void test_empty_headers_param(void)
|
|
|
|
{
|
2010-04-22 16:35:56 +02:00
|
|
|
HINTERNET ses, con, req;
|
2015-09-22 15:58:33 +02:00
|
|
|
DWORD err;
|
2009-10-29 11:12:22 +01:00
|
|
|
BOOL ret;
|
|
|
|
|
2020-02-14 16:41:38 +01:00
|
|
|
ses = WinHttpOpen(L"winetest", 0, NULL, NULL, 0);
|
2009-10-29 11:12:22 +01:00
|
|
|
ok(ses != NULL, "failed to open session %u\n", GetLastError());
|
|
|
|
|
2020-02-14 16:41:38 +01:00
|
|
|
con = WinHttpConnect(ses, L"test.winehq.org", 80, 0);
|
2009-10-29 11:12:22 +01:00
|
|
|
ok(con != NULL, "failed to open a connection %u\n", GetLastError());
|
|
|
|
|
|
|
|
req = WinHttpOpenRequest(con, NULL, NULL, NULL, NULL, NULL, 0);
|
|
|
|
ok(req != NULL, "failed to open a request %u\n", GetLastError());
|
|
|
|
|
2020-02-14 16:41:38 +01:00
|
|
|
ret = WinHttpSendRequest(req, L"", 0, NULL, 0, 0, 0);
|
2015-09-22 15:58:33 +02:00
|
|
|
err = GetLastError();
|
|
|
|
if (!ret && (err == ERROR_WINHTTP_CANNOT_CONNECT || err == ERROR_WINHTTP_TIMEOUT))
|
2014-09-01 14:48:49 +02:00
|
|
|
{
|
|
|
|
skip("connection failed, skipping\n");
|
|
|
|
goto done;
|
|
|
|
}
|
2009-10-29 11:12:22 +01:00
|
|
|
ok(ret, "failed to send request %u\n", GetLastError());
|
|
|
|
|
2014-09-01 14:48:49 +02:00
|
|
|
done:
|
2009-10-29 11:12:22 +01:00
|
|
|
WinHttpCloseHandle(req);
|
|
|
|
WinHttpCloseHandle(con);
|
|
|
|
WinHttpCloseHandle(ses);
|
|
|
|
}
|
|
|
|
|
2019-08-02 11:01:36 +02:00
|
|
|
static void test_WinHttpSendRequest (void)
|
2008-07-30 22:20:40 +02:00
|
|
|
{
|
2020-02-14 16:41:38 +01:00
|
|
|
static const WCHAR content_type[] = L"Content-Type: application/x-www-form-urlencoded";
|
|
|
|
static char post_data[] = "mode=Test";
|
2014-01-28 13:25:23 +01:00
|
|
|
static const char test_post[] = "mode => Test\0\n";
|
2014-02-05 15:31:51 +01:00
|
|
|
HINTERNET session, request, connection;
|
2019-08-02 11:01:36 +02:00
|
|
|
DWORD header_len, optional_len, total_len, bytes_rw, size, err, disable, len;
|
2014-02-05 15:31:51 +01:00
|
|
|
DWORD_PTR context;
|
|
|
|
BOOL ret;
|
|
|
|
CHAR buffer[256];
|
2019-08-02 11:01:36 +02:00
|
|
|
WCHAR method[8];
|
2014-02-05 15:31:51 +01:00
|
|
|
int i;
|
2008-07-30 22:20:40 +02:00
|
|
|
|
|
|
|
header_len = -1L;
|
|
|
|
total_len = optional_len = sizeof(post_data);
|
|
|
|
memset(buffer, 0xff, sizeof(buffer));
|
|
|
|
|
2020-02-14 16:41:38 +01:00
|
|
|
session = WinHttpOpen(L"winetest", WINHTTP_ACCESS_TYPE_DEFAULT_PROXY,
|
2008-07-30 22:20:40 +02:00
|
|
|
WINHTTP_NO_PROXY_NAME, WINHTTP_NO_PROXY_BYPASS, 0);
|
2008-08-15 14:42:15 +02:00
|
|
|
ok(session != NULL, "WinHttpOpen failed to open session.\n");
|
2008-07-30 22:20:40 +02:00
|
|
|
|
2020-02-14 16:41:38 +01:00
|
|
|
connection = WinHttpConnect (session, L"test.winehq.org", INTERNET_DEFAULT_HTTP_PORT, 0);
|
2008-08-15 14:42:28 +02:00
|
|
|
ok(connection != NULL, "WinHttpConnect failed to open a connection, error: %u.\n", GetLastError());
|
2008-07-30 22:20:40 +02:00
|
|
|
|
2020-02-14 16:41:38 +01:00
|
|
|
request = WinHttpOpenRequest(connection, L"POST", L"tests/post.php", NULL, WINHTTP_NO_REFERER,
|
2008-07-30 22:20:40 +02:00
|
|
|
WINHTTP_DEFAULT_ACCEPT_TYPES, WINHTTP_FLAG_BYPASS_PROXY_CACHE);
|
|
|
|
if (request == NULL && GetLastError() == ERROR_WINHTTP_NAME_NOT_RESOLVED)
|
|
|
|
{
|
|
|
|
skip("Network unreachable, skipping.\n");
|
|
|
|
goto done;
|
|
|
|
}
|
2008-08-15 14:42:41 +02:00
|
|
|
ok(request != NULL, "WinHttpOpenrequest failed to open a request, error: %u.\n", GetLastError());
|
2010-01-27 20:59:03 +01:00
|
|
|
if (!request) goto done;
|
2008-07-30 22:20:40 +02:00
|
|
|
|
2019-08-02 11:01:36 +02:00
|
|
|
method[0] = 0;
|
|
|
|
len = sizeof(method);
|
|
|
|
ret = WinHttpQueryHeaders(request, WINHTTP_QUERY_REQUEST_METHOD, NULL, method, &len, NULL);
|
|
|
|
ok(ret, "got %u\n", GetLastError());
|
2020-02-14 16:41:38 +01:00
|
|
|
ok(len == lstrlenW(L"POST") * sizeof(WCHAR), "got %u\n", len);
|
|
|
|
ok(!lstrcmpW(method, L"POST"), "got %s\n", wine_dbgstr_w(method));
|
2019-08-02 11:01:36 +02:00
|
|
|
|
2010-01-25 14:00:08 +01:00
|
|
|
context = 0xdeadbeef;
|
|
|
|
ret = WinHttpSetOption(request, WINHTTP_OPTION_CONTEXT_VALUE, &context, sizeof(context));
|
|
|
|
ok(ret, "WinHttpSetOption failed: %u\n", GetLastError());
|
|
|
|
|
2017-12-22 16:52:51 +01:00
|
|
|
/* writing more data than promised by the content-length header causes an error when the connection
|
2019-12-09 09:46:50 +01:00
|
|
|
is reused, so disable keep-alive */
|
2017-12-22 16:52:51 +01:00
|
|
|
disable = WINHTTP_DISABLE_KEEP_ALIVE;
|
|
|
|
ret = WinHttpSetOption(request, WINHTTP_OPTION_DISABLE_FEATURE, &disable, sizeof(disable));
|
|
|
|
ok(ret, "WinHttpSetOption failed: %u\n", GetLastError());
|
|
|
|
|
2010-01-25 14:00:08 +01:00
|
|
|
context++;
|
|
|
|
ret = WinHttpSendRequest(request, content_type, header_len, post_data, optional_len, total_len, context);
|
2015-09-22 15:58:33 +02:00
|
|
|
err = GetLastError();
|
|
|
|
if (!ret && (err == ERROR_WINHTTP_CANNOT_CONNECT || err == ERROR_WINHTTP_TIMEOUT))
|
2014-09-01 14:48:49 +02:00
|
|
|
{
|
|
|
|
skip("connection failed, skipping\n");
|
|
|
|
goto done;
|
|
|
|
}
|
2008-08-26 11:03:40 +02:00
|
|
|
ok(ret == TRUE, "WinHttpSendRequest failed: %u\n", GetLastError());
|
2008-07-30 22:20:40 +02:00
|
|
|
|
2010-01-25 14:00:08 +01:00
|
|
|
context = 0;
|
|
|
|
size = sizeof(context);
|
|
|
|
ret = WinHttpQueryOption(request, WINHTTP_OPTION_CONTEXT_VALUE, &context, &size);
|
|
|
|
ok(ret, "WinHttpQueryOption failed: %u\n", GetLastError());
|
|
|
|
ok(context == 0xdeadbef0, "expected 0xdeadbef0, got %lx\n", context);
|
|
|
|
|
2008-07-30 22:20:40 +02:00
|
|
|
for (i = 3; post_data[i]; i++)
|
|
|
|
{
|
|
|
|
bytes_rw = -1;
|
2015-08-03 11:27:31 +02:00
|
|
|
SetLastError(0xdeadbeef);
|
2008-07-30 22:20:40 +02:00
|
|
|
ret = WinHttpWriteData(request, &post_data[i], 1, &bytes_rw);
|
2009-09-10 13:48:45 +02:00
|
|
|
if (ret)
|
2015-08-03 11:27:31 +02:00
|
|
|
{
|
|
|
|
ok(GetLastError() == ERROR_SUCCESS, "Expected ERROR_SUCCESS got %u.\n", GetLastError());
|
2009-09-10 13:48:45 +02:00
|
|
|
ok(bytes_rw == 1, "WinHttpWriteData failed, wrote %u bytes instead of 1 byte.\n", bytes_rw);
|
2015-08-03 11:27:31 +02:00
|
|
|
}
|
2009-09-10 13:48:45 +02:00
|
|
|
else /* Since we already passed all optional data in WinHttpSendRequest Win7 fails our WinHttpWriteData call */
|
|
|
|
{
|
|
|
|
ok(GetLastError() == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER got %u.\n", GetLastError());
|
|
|
|
ok(bytes_rw == -1, "Expected bytes_rw to remain unchanged.\n");
|
|
|
|
}
|
2008-07-30 22:20:40 +02:00
|
|
|
}
|
|
|
|
|
2015-08-03 11:27:31 +02:00
|
|
|
SetLastError(0xdeadbeef);
|
2008-07-30 22:20:40 +02:00
|
|
|
ret = WinHttpReceiveResponse(request, NULL);
|
2015-08-03 11:27:31 +02:00
|
|
|
ok(GetLastError() == ERROR_SUCCESS || broken(GetLastError() == ERROR_NO_TOKEN) /* < win7 */,
|
|
|
|
"Expected ERROR_SUCCESS got %u.\n", GetLastError());
|
2008-08-26 11:04:04 +02:00
|
|
|
ok(ret == TRUE, "WinHttpReceiveResponse failed: %u.\n", GetLastError());
|
2008-07-30 22:20:40 +02:00
|
|
|
|
2019-08-02 11:01:38 +02:00
|
|
|
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());
|
|
|
|
|
2008-07-30 22:20:40 +02:00
|
|
|
bytes_rw = -1;
|
|
|
|
ret = WinHttpReadData(request, buffer, sizeof(buffer) - 1, &bytes_rw);
|
2008-08-26 11:04:43 +02:00
|
|
|
ok(ret == TRUE, "WinHttpReadData failed: %u.\n", GetLastError());
|
2008-07-30 22:20:40 +02:00
|
|
|
|
2014-01-28 13:25:23 +01:00
|
|
|
ok(bytes_rw == sizeof(test_post) - 1, "Read %u bytes\n", bytes_rw);
|
|
|
|
ok(!memcmp(buffer, test_post, sizeof(test_post) - 1), "Data read did not match.\n");
|
2008-07-30 22:20:40 +02:00
|
|
|
|
2014-09-01 14:48:49 +02:00
|
|
|
done:
|
2008-07-30 22:20:40 +02:00
|
|
|
ret = WinHttpCloseHandle(request);
|
2008-08-15 14:42:41 +02:00
|
|
|
ok(ret == TRUE, "WinHttpCloseHandle failed on closing request, got %d.\n", ret);
|
2008-07-30 22:20:40 +02:00
|
|
|
ret = WinHttpCloseHandle(connection);
|
2008-08-15 14:42:28 +02:00
|
|
|
ok(ret == TRUE, "WinHttpCloseHandle failed on closing connection, got %d.\n", ret);
|
2008-07-30 22:20:40 +02:00
|
|
|
ret = WinHttpCloseHandle(session);
|
2008-08-15 14:42:15 +02:00
|
|
|
ok(ret == TRUE, "WinHttpCloseHandle failed on closing session, got %d.\n", ret);
|
2008-07-30 22:20:40 +02:00
|
|
|
}
|
|
|
|
|
2008-08-14 23:54:18 +02:00
|
|
|
static void test_WinHttpTimeFromSystemTime(void)
|
|
|
|
{
|
|
|
|
BOOL ret;
|
|
|
|
static const SYSTEMTIME time = {2008, 7, 1, 28, 10, 5, 52, 0};
|
|
|
|
WCHAR time_string[WINHTTP_TIME_FORMAT_BUFSIZE+1];
|
2015-08-03 11:27:31 +02:00
|
|
|
DWORD err;
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = WinHttpTimeFromSystemTime(&time, NULL);
|
|
|
|
err = GetLastError();
|
|
|
|
ok(!ret, "WinHttpTimeFromSystemTime succeeded\n");
|
|
|
|
ok(err == ERROR_INVALID_PARAMETER, "got %u\n", err);
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = WinHttpTimeFromSystemTime(NULL, time_string);
|
|
|
|
err = GetLastError();
|
|
|
|
ok(!ret, "WinHttpTimeFromSystemTime succeeded\n");
|
|
|
|
ok(err == ERROR_INVALID_PARAMETER, "got %u\n", err);
|
2008-08-14 23:54:18 +02:00
|
|
|
|
2015-08-03 11:27:31 +02:00
|
|
|
SetLastError(0xdeadbeef);
|
2008-08-14 23:54:18 +02:00
|
|
|
ret = WinHttpTimeFromSystemTime(&time, time_string);
|
2015-08-03 11:27:31 +02:00
|
|
|
err = GetLastError();
|
|
|
|
ok(ret, "WinHttpTimeFromSystemTime failed: %u\n", err);
|
|
|
|
ok(err == ERROR_SUCCESS || broken(err == 0xdeadbeef) /* < win7 */, "got %u\n", err);
|
2020-02-14 16:41:38 +01:00
|
|
|
ok(!memcmp(time_string, L"Mon, 28 Jul 2008 10:05:52 GMT", sizeof(L"Mon, 28 Jul 2008 10:05:52 GMT")),
|
2008-08-14 23:54:18 +02:00
|
|
|
"Time string returned did not match expected time string.\n");
|
|
|
|
}
|
|
|
|
|
2008-08-14 23:56:07 +02:00
|
|
|
static void test_WinHttpTimeToSystemTime(void)
|
|
|
|
{
|
|
|
|
BOOL ret;
|
|
|
|
SYSTEMTIME time;
|
|
|
|
static const SYSTEMTIME expected_time = {2008, 7, 1, 28, 10, 5, 52, 0};
|
2015-08-03 11:27:31 +02:00
|
|
|
DWORD err;
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
2020-02-14 16:41:38 +01:00
|
|
|
ret = WinHttpTimeToSystemTime(L"Mon, 28 Jul 2008 10:05:52 GMT\n", NULL);
|
2015-08-03 11:27:31 +02:00
|
|
|
err = GetLastError();
|
|
|
|
ok(!ret, "WinHttpTimeToSystemTime succeeded\n");
|
|
|
|
ok(err == ERROR_INVALID_PARAMETER, "got %u\n", err);
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = WinHttpTimeToSystemTime(NULL, &time);
|
|
|
|
err = GetLastError();
|
|
|
|
ok(!ret, "WinHttpTimeToSystemTime succeeded\n");
|
|
|
|
ok(err == ERROR_INVALID_PARAMETER, "got %u\n", err);
|
2008-08-14 23:56:07 +02:00
|
|
|
|
2015-08-03 11:27:31 +02:00
|
|
|
SetLastError(0xdeadbeef);
|
2020-02-14 16:41:38 +01:00
|
|
|
ret = WinHttpTimeToSystemTime(L"Mon, 28 Jul 2008 10:05:52 GMT\n", &time);
|
2015-08-03 11:27:31 +02:00
|
|
|
err = GetLastError();
|
|
|
|
ok(ret, "WinHttpTimeToSystemTime failed: %u\n", err);
|
|
|
|
ok(err == ERROR_SUCCESS || broken(err == 0xdeadbeef) /* < win7 */, "got %u\n", err);
|
2008-08-15 14:44:16 +02:00
|
|
|
ok(memcmp(&time, &expected_time, sizeof(SYSTEMTIME)) == 0,
|
2008-08-14 23:56:07 +02:00
|
|
|
"Returned SYSTEMTIME structure did not match expected SYSTEMTIME structure.\n");
|
|
|
|
|
2015-08-03 11:27:31 +02:00
|
|
|
SetLastError(0xdeadbeef);
|
2020-02-14 16:41:38 +01:00
|
|
|
ret = WinHttpTimeToSystemTime(L" mon 28 jul 2008 10 05 52\n", &time);
|
2015-08-03 11:27:31 +02:00
|
|
|
err = GetLastError();
|
|
|
|
ok(ret, "WinHttpTimeToSystemTime failed: %u\n", err);
|
|
|
|
ok(err == ERROR_SUCCESS || broken(err == 0xdeadbeef) /* < win7 */, "got %u\n", err);
|
2008-08-15 14:44:16 +02:00
|
|
|
ok(memcmp(&time, &expected_time, sizeof(SYSTEMTIME)) == 0,
|
2008-08-14 23:56:07 +02:00
|
|
|
"Returned SYSTEMTIME structure did not match expected SYSTEMTIME structure.\n");
|
|
|
|
}
|
|
|
|
|
2008-08-14 23:50:18 +02:00
|
|
|
static void test_WinHttpAddHeaders(void)
|
|
|
|
{
|
2020-02-14 16:41:38 +01:00
|
|
|
static const WCHAR test_header_begin[] =
|
|
|
|
{'P','O','S','T',' ','/','p','o','s','t','t','e','s','t','.','p','h','p',' ','H','T','T','P','/','1'};
|
2008-08-14 23:50:18 +02:00
|
|
|
HINTERNET session, request, connection;
|
2009-09-10 13:48:45 +02:00
|
|
|
BOOL ret, reverse;
|
2008-08-14 23:50:18 +02:00
|
|
|
WCHAR buffer[MAX_PATH];
|
|
|
|
WCHAR check_buffer[MAX_PATH];
|
2015-06-17 15:11:50 +02:00
|
|
|
DWORD err, index, len, oldlen;
|
2008-08-14 23:50:18 +02:00
|
|
|
|
|
|
|
static const WCHAR test_headers[][14] =
|
2020-02-14 16:41:38 +01:00
|
|
|
{
|
|
|
|
L"Warning:test1",
|
|
|
|
L"Warning:test2",
|
|
|
|
L"Warning:test3",
|
|
|
|
L"Warning:test4",
|
|
|
|
L"Warning:test5",
|
|
|
|
L"Warning:test6",
|
|
|
|
L"Warning:test7",
|
|
|
|
L"",
|
|
|
|
L":",
|
|
|
|
L"a:",
|
|
|
|
L":b",
|
|
|
|
L"cd",
|
|
|
|
L" e :f",
|
|
|
|
L"field: value ",
|
|
|
|
L"name: value",
|
|
|
|
L"name:",
|
|
|
|
};
|
2008-08-14 23:50:18 +02:00
|
|
|
static const WCHAR test_indices[][6] =
|
2020-02-14 16:41:38 +01:00
|
|
|
{
|
|
|
|
L"test1",
|
|
|
|
L"test2",
|
|
|
|
L"test3",
|
|
|
|
L"test4",
|
|
|
|
};
|
2008-08-14 23:50:18 +02:00
|
|
|
|
2020-02-14 16:41:38 +01:00
|
|
|
session = WinHttpOpen(L"winetest", WINHTTP_ACCESS_TYPE_DEFAULT_PROXY,
|
2008-08-14 23:50:18 +02:00
|
|
|
WINHTTP_NO_PROXY_NAME, WINHTTP_NO_PROXY_BYPASS, 0);
|
2008-08-15 14:42:15 +02:00
|
|
|
ok(session != NULL, "WinHttpOpen failed to open session.\n");
|
2008-08-14 23:50:18 +02:00
|
|
|
|
2020-02-14 16:41:38 +01:00
|
|
|
connection = WinHttpConnect (session, L"test.winehq.org", INTERNET_DEFAULT_HTTP_PORT, 0);
|
2008-08-15 14:42:28 +02:00
|
|
|
ok(connection != NULL, "WinHttpConnect failed to open a connection, error: %u.\n", GetLastError());
|
2008-08-14 23:50:18 +02:00
|
|
|
|
2020-02-14 16:41:38 +01:00
|
|
|
request = WinHttpOpenRequest(connection, L"POST", L"/posttest.php", NULL, WINHTTP_NO_REFERER,
|
2008-08-14 23:50:18 +02:00
|
|
|
WINHTTP_DEFAULT_ACCEPT_TYPES, 0);
|
|
|
|
if (request == NULL && GetLastError() == ERROR_WINHTTP_NAME_NOT_RESOLVED)
|
|
|
|
{
|
|
|
|
skip("Network unreachable, skipping.\n");
|
|
|
|
goto done;
|
|
|
|
}
|
2008-08-15 14:42:41 +02:00
|
|
|
ok(request != NULL, "WinHttpOpenRequest failed to open a request, error: %u.\n", GetLastError());
|
2008-08-14 23:50:18 +02:00
|
|
|
|
|
|
|
index = 0;
|
|
|
|
len = sizeof(buffer);
|
|
|
|
ret = WinHttpQueryHeaders(request, WINHTTP_QUERY_CUSTOM | WINHTTP_QUERY_FLAG_REQUEST_HEADERS,
|
2020-02-14 16:41:38 +01:00
|
|
|
L"Warning", buffer, &len, &index);
|
2008-09-01 17:01:59 +02:00
|
|
|
ok(ret == FALSE, "WinHttpQueryHeaders unexpectedly succeeded, found 'Warning' header.\n");
|
2015-08-03 11:27:31 +02:00
|
|
|
SetLastError(0xdeadbeef);
|
2008-08-14 23:50:18 +02:00
|
|
|
ret = WinHttpAddRequestHeaders(request, test_headers[0], -1L, WINHTTP_ADDREQ_FLAG_ADD);
|
2015-08-03 11:27:31 +02:00
|
|
|
err = GetLastError();
|
2017-12-22 16:25:28 +01:00
|
|
|
ok(ret, "WinHttpAddRequestHeaders failed to add new header, got %d with error %u.\n", ret, err);
|
2015-08-03 11:27:31 +02:00
|
|
|
ok(err == ERROR_SUCCESS || broken(err == 0xdeadbeef) /* < win7 */, "got %u\n", err);
|
2008-08-14 23:50:18 +02:00
|
|
|
|
|
|
|
index = 0;
|
|
|
|
len = sizeof(buffer);
|
|
|
|
ret = WinHttpQueryHeaders(request, WINHTTP_QUERY_CUSTOM | WINHTTP_QUERY_FLAG_REQUEST_HEADERS,
|
2020-02-14 16:41:38 +01:00
|
|
|
L"Warning", buffer, &len, &index);
|
2008-08-20 11:36:23 +02:00
|
|
|
ok(ret == TRUE, "WinHttpQueryHeaders failed: %u\n", GetLastError());
|
|
|
|
ok(index == 1, "WinHttpQueryHeaders failed: header index not incremented\n");
|
2020-02-14 16:41:38 +01:00
|
|
|
ok(!memcmp(buffer, test_indices[0], sizeof(test_indices[0])),
|
|
|
|
"WinHttpQueryHeaders failed: incorrect string returned\n");
|
2008-08-20 11:36:23 +02:00
|
|
|
ok(len == 5*sizeof(WCHAR), "WinHttpQueryHeaders failed: invalid length returned, expected 5, got %d\n", len);
|
|
|
|
|
2008-08-14 23:50:18 +02:00
|
|
|
ret = WinHttpQueryHeaders(request, WINHTTP_QUERY_CUSTOM | WINHTTP_QUERY_FLAG_REQUEST_HEADERS,
|
2020-02-14 16:41:38 +01:00
|
|
|
L"Warning", buffer, &len, &index);
|
2008-08-14 23:50:18 +02:00
|
|
|
ok(ret == FALSE, "WinHttpQueryHeaders unexpectedly succeeded, second index should not exist.\n");
|
|
|
|
|
2008-09-01 17:01:17 +02:00
|
|
|
/* Try to fetch the header info with a buffer that's big enough to fit the
|
|
|
|
* string but not the NULL terminator.
|
|
|
|
*/
|
2008-08-14 23:50:18 +02:00
|
|
|
index = 0;
|
|
|
|
len = 5*sizeof(WCHAR);
|
2008-09-16 11:51:58 +02:00
|
|
|
memset(check_buffer, 0xab, sizeof(check_buffer));
|
2008-08-14 23:50:18 +02:00
|
|
|
memcpy(buffer, check_buffer, sizeof(buffer));
|
|
|
|
ret = WinHttpQueryHeaders(request, WINHTTP_QUERY_CUSTOM | WINHTTP_QUERY_FLAG_REQUEST_HEADERS,
|
2020-02-14 16:41:38 +01:00
|
|
|
L"Warning", buffer, &len, &index);
|
2008-09-01 17:01:17 +02:00
|
|
|
ok(ret == FALSE, "WinHttpQueryHeaders unexpectedly succeeded with a buffer that's too small.\n");
|
2008-08-14 23:50:18 +02:00
|
|
|
ok(memcmp(buffer, check_buffer, sizeof(buffer)) == 0,
|
|
|
|
"WinHttpQueryHeaders failed, modified the buffer when it should not have.\n");
|
2008-08-20 11:36:23 +02:00
|
|
|
ok(len == 6*sizeof(WCHAR), "WinHttpQueryHeaders returned invalid length, expected 12, got %d\n", len);
|
2008-08-14 23:50:18 +02:00
|
|
|
|
|
|
|
/* Try with a NULL buffer */
|
|
|
|
index = 0;
|
|
|
|
len = sizeof(buffer);
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = WinHttpQueryHeaders(request, WINHTTP_QUERY_RAW_HEADERS_CRLF | WINHTTP_QUERY_FLAG_REQUEST_HEADERS,
|
2020-02-14 16:41:38 +01:00
|
|
|
L"Warning", NULL, &len, &index);
|
2008-08-14 23:50:18 +02:00
|
|
|
ok(ret == FALSE, "WinHttpQueryHeaders unexpectedly succeeded.\n");
|
2008-09-05 14:11:46 +02:00
|
|
|
ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "Expected ERROR_INSUFFICIENT_BUFFER, got %u\n", GetLastError());
|
2008-08-20 11:37:17 +02:00
|
|
|
ok(len > 40, "WinHttpQueryHeaders returned invalid length: expected greater than 40, got %d\n", len);
|
2008-08-14 23:50:18 +02:00
|
|
|
ok(index == 0, "WinHttpQueryHeaders incorrectly incremented header index.\n");
|
|
|
|
|
2008-09-01 17:01:17 +02:00
|
|
|
/* Try with a NULL buffer and a length that's too small */
|
2008-08-14 23:50:18 +02:00
|
|
|
index = 0;
|
|
|
|
len = 10;
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = WinHttpQueryHeaders(request, WINHTTP_QUERY_RAW_HEADERS_CRLF | WINHTTP_QUERY_FLAG_REQUEST_HEADERS,
|
2020-02-14 16:41:38 +01:00
|
|
|
L"Warning", NULL, &len, &index);
|
2008-08-14 23:50:18 +02:00
|
|
|
ok(ret == FALSE, "WinHttpQueryHeaders unexpectedly succeeded.\n");
|
2008-08-20 11:36:23 +02:00
|
|
|
ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER,
|
2019-12-09 09:46:50 +01:00
|
|
|
"WinHttpQueryHeaders set incorrect error: expected ERROR_INSUFFICIENT_BUFFER, got %u\n", GetLastError());
|
2008-08-20 11:37:17 +02:00
|
|
|
ok(len > 40, "WinHttpQueryHeaders returned invalid length: expected greater than 40, got %d\n", len);
|
2008-08-14 23:50:18 +02:00
|
|
|
ok(index == 0, "WinHttpQueryHeaders incorrectly incremented header index.\n");
|
|
|
|
|
|
|
|
index = 0;
|
|
|
|
len = 0;
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = WinHttpQueryHeaders(request, WINHTTP_QUERY_RAW_HEADERS_CRLF | WINHTTP_QUERY_FLAG_REQUEST_HEADERS,
|
2020-02-14 16:41:38 +01:00
|
|
|
L"Warning", NULL, &len, &index);
|
2008-08-14 23:50:18 +02:00
|
|
|
ok(ret == FALSE, "WinHttpQueryHeaders unexpectedly succeeded.\n");
|
2008-08-20 11:36:23 +02:00
|
|
|
ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER,
|
|
|
|
"WinHttpQueryHeaders set incorrect error: expected ERROR_INSUFFICIENT_BUFFER, got %u\n", GetLastError());
|
2008-08-20 11:37:17 +02:00
|
|
|
ok(len > 40, "WinHttpQueryHeaders returned invalid length: expected greater than 40, got %d\n", len);
|
2008-08-14 23:50:18 +02:00
|
|
|
ok(index == 0, "WinHttpQueryHeaders failed: index was incremented.\n");
|
|
|
|
|
|
|
|
/* valid query */
|
|
|
|
oldlen = len;
|
|
|
|
index = 0;
|
|
|
|
len = sizeof(buffer);
|
|
|
|
memset(buffer, 0xff, sizeof(buffer));
|
|
|
|
ret = WinHttpQueryHeaders(request, WINHTTP_QUERY_RAW_HEADERS_CRLF | WINHTTP_QUERY_FLAG_REQUEST_HEADERS,
|
2020-02-14 16:41:38 +01:00
|
|
|
L"Warning", buffer, &len, &index);
|
2008-08-20 11:36:23 +02:00
|
|
|
ok(ret == TRUE, "WinHttpQueryHeaders failed: got %d\n", ret);
|
|
|
|
ok(len + sizeof(WCHAR) <= oldlen, "WinHttpQueryHeaders resulting length longer than advertized.\n");
|
2020-02-14 16:41:38 +01:00
|
|
|
ok((len < sizeof(buffer) - sizeof(WCHAR)) && !buffer[len / sizeof(WCHAR)],
|
|
|
|
"WinHttpQueryHeaders did not append NULL terminator\n");
|
2008-08-20 11:36:23 +02:00
|
|
|
ok(len == lstrlenW(buffer) * sizeof(WCHAR), "WinHttpQueryHeaders returned incorrect length.\n");
|
2020-02-14 16:41:38 +01:00
|
|
|
ok(!memcmp(buffer, test_header_begin, sizeof(test_header_begin)), "invalid beginning of header string.\n");
|
|
|
|
ok(!memcmp(buffer + lstrlenW(buffer) - 4, L"\r\n\r\n", sizeof(L"\r\n\r\n")),
|
2008-08-20 11:37:17 +02:00
|
|
|
"WinHttpQueryHeaders returned invalid end of header string.\n");
|
2008-08-14 23:50:18 +02:00
|
|
|
ok(index == 0, "WinHttpQueryHeaders incremented header index.\n");
|
|
|
|
|
2008-09-05 14:11:46 +02:00
|
|
|
index = 0;
|
|
|
|
len = 0;
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = WinHttpQueryHeaders(request, WINHTTP_QUERY_RAW_HEADERS | WINHTTP_QUERY_FLAG_REQUEST_HEADERS,
|
2020-02-14 16:41:38 +01:00
|
|
|
L"Warning", NULL, &len, &index);
|
2008-09-05 14:11:46 +02:00
|
|
|
ok(ret == FALSE, "WinHttpQueryHeaders unexpectedly succeeded.\n");
|
|
|
|
ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER,
|
|
|
|
"WinHttpQueryHeaders set incorrect error: expected ERROR_INSUFFICIENT_BUFFER, got %u\n", GetLastError());
|
|
|
|
ok(len > 40, "WinHttpQueryHeaders returned invalid length: expected greater than 40, got %d\n", len);
|
|
|
|
ok(index == 0, "WinHttpQueryHeaders failed: index was incremented.\n");
|
|
|
|
|
|
|
|
oldlen = len;
|
|
|
|
index = 0;
|
|
|
|
len = sizeof(buffer);
|
|
|
|
memset(buffer, 0xff, sizeof(buffer));
|
|
|
|
ret = WinHttpQueryHeaders(request, WINHTTP_QUERY_RAW_HEADERS | WINHTTP_QUERY_FLAG_REQUEST_HEADERS,
|
2020-02-14 16:41:38 +01:00
|
|
|
L"Warning", buffer, &len, &index);
|
2008-09-05 14:11:46 +02:00
|
|
|
ok(ret == TRUE, "WinHttpQueryHeaders failed %u\n", GetLastError());
|
|
|
|
ok(len + sizeof(WCHAR) <= oldlen, "resulting length longer than advertized\n");
|
|
|
|
ok((len < sizeof(buffer) - sizeof(WCHAR)) && !buffer[len / sizeof(WCHAR)] && !buffer[len / sizeof(WCHAR) - 1],
|
|
|
|
"no double NULL terminator\n");
|
2020-02-14 16:41:38 +01:00
|
|
|
ok(!memcmp(buffer, test_header_begin, sizeof(test_header_begin)), "invalid beginning of header string.\n");
|
2008-09-05 14:11:46 +02:00
|
|
|
ok(index == 0, "header index was incremented\n");
|
|
|
|
|
2008-08-14 23:50:18 +02:00
|
|
|
/* tests for more indices */
|
|
|
|
ret = WinHttpAddRequestHeaders(request, test_headers[1], -1L, WINHTTP_ADDREQ_FLAG_ADD);
|
2008-08-20 11:35:39 +02:00
|
|
|
ok(ret == TRUE, "WinHttpAddRequestHeaders failed to add duplicate header: %d\n", ret);
|
2008-08-14 23:50:18 +02:00
|
|
|
|
|
|
|
index = 0;
|
|
|
|
len = sizeof(buffer);
|
|
|
|
ret = WinHttpQueryHeaders(request, WINHTTP_QUERY_CUSTOM | WINHTTP_QUERY_FLAG_REQUEST_HEADERS,
|
2020-02-14 16:41:38 +01:00
|
|
|
L"Warning", buffer, &len, &index);
|
2008-08-20 11:36:23 +02:00
|
|
|
ok(ret == TRUE, "WinHttpQueryHeaders failed: %u\n", GetLastError());
|
|
|
|
ok(index == 1, "WinHttpQueryHeaders failed to increment index.\n");
|
|
|
|
ok(memcmp(buffer, test_indices[0], sizeof(test_indices[0])) == 0, "WinHttpQueryHeaders returned incorrect string.\n");
|
|
|
|
|
2008-08-14 23:50:18 +02:00
|
|
|
len = sizeof(buffer);
|
|
|
|
ret = WinHttpQueryHeaders(request, WINHTTP_QUERY_CUSTOM | WINHTTP_QUERY_FLAG_REQUEST_HEADERS,
|
2020-02-14 16:41:38 +01:00
|
|
|
L"Warning", buffer, &len, &index);
|
2008-08-20 11:36:23 +02:00
|
|
|
ok(ret == TRUE, "WinHttpQueryHeaders failed: %u\n", GetLastError());
|
|
|
|
ok(index == 2, "WinHttpQueryHeaders failed to increment index.\n");
|
|
|
|
ok(memcmp(buffer, test_indices[1], sizeof(test_indices[1])) == 0, "WinHttpQueryHeaders returned incorrect string.\n");
|
2008-08-14 23:50:18 +02:00
|
|
|
|
|
|
|
ret = WinHttpAddRequestHeaders(request, test_headers[2], -1L, WINHTTP_ADDREQ_FLAG_REPLACE);
|
2008-08-20 11:35:39 +02:00
|
|
|
ok(ret == TRUE, "WinHttpAddRequestHeaders failed to add duplicate header.\n");
|
2008-08-14 23:50:18 +02:00
|
|
|
|
|
|
|
index = 0;
|
|
|
|
len = sizeof(buffer);
|
|
|
|
ret = WinHttpQueryHeaders(request, WINHTTP_QUERY_CUSTOM | WINHTTP_QUERY_FLAG_REQUEST_HEADERS,
|
2020-02-14 16:41:38 +01:00
|
|
|
L"Warning", buffer, &len, &index);
|
2008-08-20 11:36:23 +02:00
|
|
|
ok(ret == TRUE, "WinHttpQueryHeaders failed: %u\n", GetLastError());
|
|
|
|
ok(index == 1, "WinHttpQueryHeaders failed to increment index.\n");
|
2009-09-10 13:48:45 +02:00
|
|
|
reverse = (memcmp(buffer, test_indices[1], sizeof(test_indices[1])) != 0); /* Win7 returns values in reverse order of adding */
|
2020-02-14 16:41:38 +01:00
|
|
|
ok(!memcmp(buffer, test_indices[reverse ? 2 : 1], sizeof(test_indices[reverse ? 2 : 1])),
|
|
|
|
"WinHttpQueryHeaders returned incorrect string.\n");
|
2008-08-20 11:36:23 +02:00
|
|
|
|
2008-08-14 23:50:18 +02:00
|
|
|
len = sizeof(buffer);
|
|
|
|
ret = WinHttpQueryHeaders(request, WINHTTP_QUERY_CUSTOM | WINHTTP_QUERY_FLAG_REQUEST_HEADERS,
|
2020-02-14 16:41:38 +01:00
|
|
|
L"Warning", buffer, &len, &index);
|
2008-08-20 11:36:23 +02:00
|
|
|
ok(ret == TRUE, "WinHttpQueryHeaders failed: %u\n", GetLastError());
|
|
|
|
ok(index == 2, "WinHttpQueryHeaders failed to increment index.\n");
|
2020-02-14 16:41:38 +01:00
|
|
|
ok(!memcmp(buffer, test_indices[reverse ? 1 : 2], sizeof(test_indices[reverse ? 1 : 2])),
|
|
|
|
"WinHttpQueryHeaders returned incorrect string.\n");
|
2008-08-14 23:50:18 +02:00
|
|
|
|
|
|
|
/* add if new flag */
|
|
|
|
ret = WinHttpAddRequestHeaders(request, test_headers[3], -1L, WINHTTP_ADDREQ_FLAG_ADD_IF_NEW);
|
|
|
|
ok(ret == FALSE, "WinHttpAddRequestHeaders incorrectly replaced existing header.\n");
|
|
|
|
|
|
|
|
index = 0;
|
|
|
|
len = sizeof(buffer);
|
|
|
|
ret = WinHttpQueryHeaders(request, WINHTTP_QUERY_CUSTOM | WINHTTP_QUERY_FLAG_REQUEST_HEADERS,
|
2020-02-14 16:41:38 +01:00
|
|
|
L"Warning", buffer, &len, &index);
|
2008-08-20 11:36:23 +02:00
|
|
|
ok(ret == TRUE, "WinHttpQueryHeaders failed: %u\n", GetLastError());
|
|
|
|
ok(index == 1, "WinHttpQueryHeaders failed to increment index.\n");
|
2020-02-14 16:41:38 +01:00
|
|
|
ok(!memcmp(buffer, test_indices[reverse ? 2 : 1], sizeof(test_indices[reverse ? 2 : 1])),
|
|
|
|
"WinHttpQueryHeaders returned incorrect string.\n");
|
2008-08-20 11:36:23 +02:00
|
|
|
|
2008-08-14 23:50:18 +02:00
|
|
|
len = sizeof(buffer);
|
|
|
|
ret = WinHttpQueryHeaders(request, WINHTTP_QUERY_CUSTOM | WINHTTP_QUERY_FLAG_REQUEST_HEADERS,
|
2020-02-14 16:41:38 +01:00
|
|
|
L"Warning", buffer, &len, &index);
|
2008-08-20 11:36:23 +02:00
|
|
|
ok(ret == TRUE, "WinHttpQueryHeaders failed: %u\n", GetLastError());
|
|
|
|
ok(index == 2, "WinHttpQueryHeaders failed to increment index.\n");
|
2020-02-14 16:41:38 +01:00
|
|
|
ok(!memcmp(buffer, test_indices[reverse ? 1 : 2], sizeof(test_indices[reverse ? 1 : 2])),
|
|
|
|
"WinHttpQueryHeaders returned incorrect string.\n");
|
2008-08-20 11:36:23 +02:00
|
|
|
|
2008-08-14 23:50:18 +02:00
|
|
|
len = sizeof(buffer);
|
|
|
|
ret = WinHttpQueryHeaders(request, WINHTTP_QUERY_CUSTOM | WINHTTP_QUERY_FLAG_REQUEST_HEADERS,
|
2020-02-14 16:41:38 +01:00
|
|
|
L"Warning", buffer, &len, &index);
|
2008-08-14 23:50:18 +02:00
|
|
|
ok(ret == FALSE, "WinHttpQueryHeaders succeeded unexpectedly, found third header.\n");
|
|
|
|
|
|
|
|
/* coalesce flag */
|
|
|
|
ret = WinHttpAddRequestHeaders(request, test_headers[3], -1L, WINHTTP_ADDREQ_FLAG_COALESCE);
|
2008-08-20 11:35:39 +02:00
|
|
|
ok(ret == TRUE, "WinHttpAddRequestHeaders failed with flag WINHTTP_ADDREQ_FLAG_COALESCE.\n");
|
2008-08-14 23:50:18 +02:00
|
|
|
|
|
|
|
index = 0;
|
|
|
|
len = sizeof(buffer);
|
|
|
|
ret = WinHttpQueryHeaders(request, WINHTTP_QUERY_CUSTOM | WINHTTP_QUERY_FLAG_REQUEST_HEADERS,
|
2020-02-14 16:41:38 +01:00
|
|
|
L"Warning", buffer, &len, &index);
|
2008-08-20 11:36:23 +02:00
|
|
|
ok(ret == TRUE, "WinHttpQueryHeaders failed: %u\n", GetLastError());
|
|
|
|
ok(index == 1, "WinHttpQueryHeaders failed to increment index.\n");
|
2020-02-14 16:41:38 +01:00
|
|
|
ok(!memcmp(buffer, reverse ? L"test3, test4" : L"test2, test4",
|
|
|
|
reverse ? sizeof(L"test3, test4") : sizeof(L"test2, test4")),
|
|
|
|
"WinHttpQueryHeaders returned incorrect string.\n");
|
2008-08-20 11:36:23 +02:00
|
|
|
|
2008-08-14 23:50:18 +02:00
|
|
|
len = sizeof(buffer);
|
|
|
|
ret = WinHttpQueryHeaders(request, WINHTTP_QUERY_CUSTOM | WINHTTP_QUERY_FLAG_REQUEST_HEADERS,
|
2020-02-14 16:41:38 +01:00
|
|
|
L"Warning", buffer, &len, &index);
|
2008-08-20 11:36:23 +02:00
|
|
|
ok(ret == TRUE, "WinHttpQueryHeaders failed: %u\n", GetLastError());
|
|
|
|
ok(index == 2, "WinHttpQueryHeaders failed to increment index.\n");
|
2020-02-14 16:41:38 +01:00
|
|
|
ok(!memcmp(buffer, test_indices[reverse ? 1 : 2], sizeof(test_indices[reverse ? 1 : 2])),
|
|
|
|
"WinHttpQueryHeaders returned incorrect string.\n");
|
2008-08-20 11:36:23 +02:00
|
|
|
|
2008-08-14 23:50:18 +02:00
|
|
|
len = sizeof(buffer);
|
|
|
|
ret = WinHttpQueryHeaders(request, WINHTTP_QUERY_CUSTOM | WINHTTP_QUERY_FLAG_REQUEST_HEADERS,
|
2020-02-14 16:41:38 +01:00
|
|
|
L"Warning", buffer, &len, &index);
|
2008-08-14 23:50:18 +02:00
|
|
|
ok(ret == FALSE, "WinHttpQueryHeaders succeeded unexpectedly, found third header.\n");
|
|
|
|
|
|
|
|
/* coalesce with comma flag */
|
|
|
|
ret = WinHttpAddRequestHeaders(request, test_headers[4], -1L, WINHTTP_ADDREQ_FLAG_COALESCE_WITH_COMMA);
|
2008-08-20 11:35:39 +02:00
|
|
|
ok(ret == TRUE, "WinHttpAddRequestHeaders failed with flag WINHTTP_ADDREQ_FLAG_COALESCE_WITH_COMMA.\n");
|
2008-08-14 23:50:18 +02:00
|
|
|
|
|
|
|
index = 0;
|
|
|
|
len = sizeof(buffer);
|
|
|
|
ret = WinHttpQueryHeaders(request, WINHTTP_QUERY_CUSTOM | WINHTTP_QUERY_FLAG_REQUEST_HEADERS,
|
2020-02-14 16:41:38 +01:00
|
|
|
L"Warning", buffer, &len, &index);
|
2008-08-20 11:36:23 +02:00
|
|
|
ok(ret == TRUE, "WinHttpQueryHeaders failed: %u\n", GetLastError());
|
|
|
|
ok(index == 1, "WinHttpQueryHeaders failed to increment index.\n");
|
2020-02-14 16:41:38 +01:00
|
|
|
|
|
|
|
ok(!memcmp(buffer, reverse ? L"test3, test4, test5" : L"test2, test4, test5",
|
|
|
|
reverse ? sizeof(L"test3, test4, test5") : sizeof(L"test2, test4, test5")),
|
2008-08-20 11:36:23 +02:00
|
|
|
"WinHttpQueryHeaders returned incorrect string.\n");
|
|
|
|
|
2008-08-14 23:50:18 +02:00
|
|
|
len = sizeof(buffer);
|
|
|
|
ret = WinHttpQueryHeaders(request, WINHTTP_QUERY_CUSTOM | WINHTTP_QUERY_FLAG_REQUEST_HEADERS,
|
2020-02-14 16:41:38 +01:00
|
|
|
L"Warning", buffer, &len, &index);
|
2008-08-20 11:36:23 +02:00
|
|
|
ok(ret == TRUE, "WinHttpQueryHeaders failed: %u\n", GetLastError());
|
|
|
|
ok(index == 2, "WinHttpQueryHeaders failed to increment index.\n");
|
2020-02-14 16:41:38 +01:00
|
|
|
ok(!memcmp(buffer, test_indices[reverse ? 1 : 2], sizeof(test_indices[reverse ? 1 : 2])),
|
|
|
|
"WinHttpQueryHeaders returned incorrect string.\n");
|
2008-08-20 11:36:23 +02:00
|
|
|
|
2008-08-14 23:50:18 +02:00
|
|
|
len = sizeof(buffer);
|
|
|
|
ret = WinHttpQueryHeaders(request, WINHTTP_QUERY_CUSTOM | WINHTTP_QUERY_FLAG_REQUEST_HEADERS,
|
2020-02-14 16:41:38 +01:00
|
|
|
L"Warning", buffer, &len, &index);
|
2008-08-14 23:50:18 +02:00
|
|
|
ok(ret == FALSE, "WinHttpQueryHeaders succeeded unexpectedly, found third header.\n");
|
|
|
|
|
|
|
|
|
|
|
|
/* coalesce with semicolon flag */
|
|
|
|
ret = WinHttpAddRequestHeaders(request, test_headers[5], -1L, WINHTTP_ADDREQ_FLAG_COALESCE_WITH_SEMICOLON);
|
2008-08-20 11:35:39 +02:00
|
|
|
ok(ret == TRUE, "WinHttpAddRequestHeaders failed with flag WINHTTP_ADDREQ_FLAG_COALESCE_WITH_SEMICOLON.\n");
|
2008-08-14 23:50:18 +02:00
|
|
|
|
|
|
|
index = 0;
|
|
|
|
len = sizeof(buffer);
|
|
|
|
ret = WinHttpQueryHeaders(request, WINHTTP_QUERY_CUSTOM | WINHTTP_QUERY_FLAG_REQUEST_HEADERS,
|
2020-02-14 16:41:38 +01:00
|
|
|
L"Warning", buffer, &len, &index);
|
2008-08-20 11:36:23 +02:00
|
|
|
ok(ret == TRUE, "WinHttpQueryHeaders failed: %u\n", GetLastError());
|
|
|
|
ok(index == 1, "WinHttpQueryHeaders failed to increment index.\n");
|
2020-02-14 16:41:38 +01:00
|
|
|
|
|
|
|
ok(!memcmp(buffer, reverse ? L"test3, test4, test5; test6" : L"test2, test4, test5; test6",
|
|
|
|
reverse ? sizeof(L"test3, test4, test5; test6") : sizeof(L"test2, test4, test5; test6")),
|
|
|
|
"WinHttpQueryHeaders returned incorrect string.\n");
|
2008-08-20 11:36:23 +02:00
|
|
|
|
2008-08-14 23:50:18 +02:00
|
|
|
len = sizeof(buffer);
|
|
|
|
ret = WinHttpQueryHeaders(request, WINHTTP_QUERY_CUSTOM | WINHTTP_QUERY_FLAG_REQUEST_HEADERS,
|
2020-02-14 16:41:38 +01:00
|
|
|
L"Warning", buffer, &len, &index);
|
2008-08-20 11:36:23 +02:00
|
|
|
ok(ret == TRUE, "WinHttpQueryHeaders failed: %u\n", GetLastError());
|
|
|
|
ok(index == 2, "WinHttpQueryHeaders failed to increment index.\n");
|
2020-02-14 16:41:38 +01:00
|
|
|
ok(!memcmp(buffer, test_indices[reverse ? 1 : 2], sizeof(test_indices[reverse ? 1 : 2])),
|
|
|
|
"WinHttpQueryHeaders returned incorrect string.\n");
|
2008-08-20 11:36:23 +02:00
|
|
|
|
2008-08-14 23:50:18 +02:00
|
|
|
len = sizeof(buffer);
|
|
|
|
ret = WinHttpQueryHeaders(request, WINHTTP_QUERY_CUSTOM | WINHTTP_QUERY_FLAG_REQUEST_HEADERS,
|
2020-02-14 16:41:38 +01:00
|
|
|
L"Warning", buffer, &len, &index);
|
2008-08-14 23:50:18 +02:00
|
|
|
ok(ret == FALSE, "WinHttpQueryHeaders succeeded unexpectedly, found third header.\n");
|
|
|
|
|
|
|
|
/* add and replace flags */
|
|
|
|
ret = WinHttpAddRequestHeaders(request, test_headers[3], -1L, WINHTTP_ADDREQ_FLAG_ADD | WINHTTP_ADDREQ_FLAG_REPLACE);
|
2008-08-20 11:35:39 +02:00
|
|
|
ok(ret == TRUE, "WinHttpAddRequestHeaders failed with flag WINHTTP_ADDREQ_FLAG_ADD | WINHTTP_ADDREQ_FLAG_REPLACE.\n");
|
2008-08-14 23:50:18 +02:00
|
|
|
|
|
|
|
index = 0;
|
|
|
|
len = sizeof(buffer);
|
|
|
|
ret = WinHttpQueryHeaders(request, WINHTTP_QUERY_CUSTOM | WINHTTP_QUERY_FLAG_REQUEST_HEADERS,
|
2020-02-14 16:41:38 +01:00
|
|
|
L"Warning", buffer, &len, &index);
|
2008-08-20 11:36:23 +02:00
|
|
|
ok(ret == TRUE, "WinHttpQueryHeaders failed: %u\n", GetLastError());
|
|
|
|
ok(index == 1, "WinHttpQueryHeaders failed to increment index.\n");
|
2020-02-14 16:41:38 +01:00
|
|
|
ok(!memcmp(buffer, test_indices[reverse ? 3 : 2], sizeof(test_indices[reverse ? 3 : 2])),
|
|
|
|
"WinHttpQueryHeaders returned incorrect string.\n");
|
2008-08-20 11:36:23 +02:00
|
|
|
|
2008-08-14 23:50:18 +02:00
|
|
|
len = sizeof(buffer);
|
|
|
|
ret = WinHttpQueryHeaders(request, WINHTTP_QUERY_CUSTOM | WINHTTP_QUERY_FLAG_REQUEST_HEADERS,
|
2020-02-14 16:41:38 +01:00
|
|
|
L"Warning", buffer, &len, &index);
|
2008-08-20 11:36:23 +02:00
|
|
|
ok(ret == TRUE, "WinHttpQueryHeaders failed: %u\n", GetLastError());
|
|
|
|
ok(index == 2, "WinHttpQueryHeaders failed to increment index.\n");
|
2020-02-14 16:41:38 +01:00
|
|
|
ok(!memcmp(buffer, test_indices[reverse ? 1 : 3], sizeof(test_indices[reverse ? 1 : 3])),
|
|
|
|
"WinHttpQueryHeaders returned incorrect string.\n");
|
2008-08-20 11:36:23 +02:00
|
|
|
|
2008-08-14 23:50:18 +02:00
|
|
|
len = sizeof(buffer);
|
|
|
|
ret = WinHttpQueryHeaders(request, WINHTTP_QUERY_CUSTOM | WINHTTP_QUERY_FLAG_REQUEST_HEADERS,
|
2020-02-14 16:41:38 +01:00
|
|
|
L"Warning", buffer, &len, &index);
|
2008-08-14 23:50:18 +02:00
|
|
|
ok(ret == FALSE, "WinHttpQueryHeaders succeeded unexpectedly, found third header.\n");
|
|
|
|
|
2009-01-03 20:15:00 +01:00
|
|
|
ret = WinHttpAddRequestHeaders(request, test_headers[8], ~0u, WINHTTP_ADDREQ_FLAG_ADD);
|
2008-08-20 11:37:53 +02:00
|
|
|
ok(!ret, "WinHttpAddRequestHeaders failed\n");
|
|
|
|
|
2009-01-03 20:15:00 +01:00
|
|
|
ret = WinHttpAddRequestHeaders(request, test_headers[9], ~0u, WINHTTP_ADDREQ_FLAG_ADD);
|
2008-08-20 11:37:53 +02:00
|
|
|
ok(ret, "WinHttpAddRequestHeaders failed\n");
|
|
|
|
|
2015-06-24 14:16:59 +02:00
|
|
|
index = 0;
|
|
|
|
memset(buffer, 0xff, sizeof(buffer));
|
|
|
|
len = sizeof(buffer);
|
|
|
|
ret = WinHttpQueryHeaders(request, WINHTTP_QUERY_CUSTOM | WINHTTP_QUERY_FLAG_REQUEST_HEADERS,
|
2020-02-14 16:41:38 +01:00
|
|
|
L"a", buffer, &len, &index);
|
2015-06-24 14:16:59 +02:00
|
|
|
ok(ret, "WinHttpQueryHeaders failed: %u\n", GetLastError());
|
2020-02-14 16:41:38 +01:00
|
|
|
ok(!memcmp(buffer, L"", sizeof(L"")), "unexpected result\n");
|
2015-06-24 14:16:59 +02:00
|
|
|
|
2009-01-03 20:15:00 +01:00
|
|
|
ret = WinHttpAddRequestHeaders(request, test_headers[10], ~0u, WINHTTP_ADDREQ_FLAG_ADD);
|
2008-08-20 11:37:53 +02:00
|
|
|
ok(!ret, "WinHttpAddRequestHeaders failed\n");
|
|
|
|
|
2009-01-03 20:15:00 +01:00
|
|
|
ret = WinHttpAddRequestHeaders(request, test_headers[11], ~0u, WINHTTP_ADDREQ_FLAG_ADD);
|
2008-08-20 11:37:53 +02:00
|
|
|
ok(!ret, "WinHttpAddRequestHeaders failed\n");
|
|
|
|
|
2009-01-03 20:15:00 +01:00
|
|
|
ret = WinHttpAddRequestHeaders(request, test_headers[12], ~0u, WINHTTP_ADDREQ_FLAG_ADD);
|
2008-08-20 11:37:53 +02:00
|
|
|
ok(!ret, "WinHttpAddRequestHeaders failed\n");
|
|
|
|
|
2009-01-03 20:15:00 +01:00
|
|
|
ret = WinHttpAddRequestHeaders(request, test_headers[13], ~0u, WINHTTP_ADDREQ_FLAG_ADD);
|
2008-08-20 11:37:53 +02:00
|
|
|
ok(ret, "WinHttpAddRequestHeaders failed\n");
|
|
|
|
|
|
|
|
index = 0;
|
|
|
|
buffer[0] = 0;
|
|
|
|
len = sizeof(buffer);
|
|
|
|
ret = WinHttpQueryHeaders(request, WINHTTP_QUERY_CUSTOM | WINHTTP_QUERY_FLAG_REQUEST_HEADERS,
|
2020-02-14 16:41:38 +01:00
|
|
|
L"field", buffer, &len, &index);
|
2008-08-20 11:37:53 +02:00
|
|
|
ok(ret, "WinHttpQueryHeaders failed: %u\n", GetLastError());
|
2020-02-14 16:41:38 +01:00
|
|
|
ok(!memcmp(buffer, L"value ", sizeof(L"value ")) || !memcmp(buffer, L"value", sizeof(L"value")),
|
|
|
|
"unexpected result\n");
|
2008-08-20 11:37:53 +02:00
|
|
|
|
2015-06-17 15:11:50 +02:00
|
|
|
SetLastError(0xdeadbeef);
|
2020-02-14 16:41:38 +01:00
|
|
|
ret = WinHttpAddRequestHeaders(request, L"Range: bytes=0-773\r\n", 0,
|
2015-06-17 15:11:50 +02:00
|
|
|
WINHTTP_ADDREQ_FLAG_ADD | WINHTTP_ADDREQ_FLAG_REPLACE);
|
|
|
|
err = GetLastError();
|
|
|
|
ok(!ret, "unexpected success\n");
|
|
|
|
ok(err == ERROR_INVALID_PARAMETER, "got %u\n", err);
|
|
|
|
|
2020-02-14 16:41:38 +01:00
|
|
|
ret = WinHttpAddRequestHeaders(request, L"Range: bytes=0-773\r\n", ~0u,
|
2015-06-17 15:11:50 +02:00
|
|
|
WINHTTP_ADDREQ_FLAG_ADD | WINHTTP_ADDREQ_FLAG_REPLACE);
|
|
|
|
ok(ret, "failed to add header: %u\n", GetLastError());
|
|
|
|
|
|
|
|
index = 0;
|
|
|
|
len = sizeof(buffer);
|
|
|
|
ret = WinHttpQueryHeaders(request, WINHTTP_QUERY_CUSTOM | WINHTTP_QUERY_FLAG_REQUEST_HEADERS,
|
2020-02-14 16:41:38 +01:00
|
|
|
L"Range", buffer, &len, &index);
|
2015-06-17 15:11:50 +02:00
|
|
|
ok(ret, "failed to get range header %u\n", GetLastError());
|
2020-02-14 16:41:38 +01:00
|
|
|
ok(!memcmp(buffer, L"bytes=0-773", sizeof(L"bytes=0-773")), "incorrect string returned\n");
|
|
|
|
ok(len == lstrlenW(L"bytes=0-773") * sizeof(WCHAR), "wrong length %u\n", len);
|
2015-06-17 15:11:50 +02:00
|
|
|
ok(index == 1, "wrong index %u\n", index);
|
2015-06-24 14:16:59 +02:00
|
|
|
index = 0;
|
|
|
|
len = sizeof(buffer);
|
|
|
|
ret = WinHttpQueryHeaders(request, WINHTTP_QUERY_CUSTOM | WINHTTP_QUERY_FLAG_REQUEST_HEADERS,
|
2020-02-14 16:41:38 +01:00
|
|
|
L"name", buffer, &len, &index);
|
2015-06-24 14:16:59 +02:00
|
|
|
ok(!ret, "unexpected success\n");
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = WinHttpAddRequestHeaders(request, test_headers[14], ~0u, WINHTTP_ADDREQ_FLAG_REPLACE);
|
|
|
|
err = GetLastError();
|
|
|
|
ok(!ret, "unexpected success\n");
|
|
|
|
ok(err == ERROR_WINHTTP_HEADER_NOT_FOUND, "got %u\n", err);
|
|
|
|
|
|
|
|
ret = WinHttpAddRequestHeaders(request, test_headers[14], ~0u, WINHTTP_ADDREQ_FLAG_ADD);
|
|
|
|
ok(ret, "got %u\n", GetLastError());
|
|
|
|
|
|
|
|
index = 0;
|
|
|
|
len = sizeof(buffer);
|
|
|
|
ret = WinHttpQueryHeaders(request, WINHTTP_QUERY_CUSTOM | WINHTTP_QUERY_FLAG_REQUEST_HEADERS,
|
2020-02-14 16:41:38 +01:00
|
|
|
L"name", buffer, &len, &index);
|
2015-06-24 14:16:59 +02:00
|
|
|
ok(ret, "got %u\n", GetLastError());
|
|
|
|
ok(index == 1, "wrong index %u\n", index);
|
2020-02-14 16:41:38 +01:00
|
|
|
ok(!memcmp(buffer, L"value", sizeof(L"value")), "incorrect string\n");
|
2015-06-24 14:16:59 +02:00
|
|
|
|
|
|
|
ret = WinHttpAddRequestHeaders(request, test_headers[15], ~0u, WINHTTP_ADDREQ_FLAG_REPLACE);
|
|
|
|
ok(ret, "got %u\n", GetLastError());
|
|
|
|
|
|
|
|
index = 0;
|
|
|
|
len = sizeof(buffer);
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = WinHttpQueryHeaders(request, WINHTTP_QUERY_CUSTOM | WINHTTP_QUERY_FLAG_REQUEST_HEADERS,
|
2020-02-14 16:41:38 +01:00
|
|
|
L"name", buffer, &len, &index);
|
2015-06-24 14:16:59 +02:00
|
|
|
err = GetLastError();
|
|
|
|
ok(!ret, "unexpected success\n");
|
|
|
|
ok(err == ERROR_WINHTTP_HEADER_NOT_FOUND, "got %u\n", err);
|
|
|
|
|
|
|
|
ret = WinHttpAddRequestHeaders(request, test_headers[14], -1L, 0);
|
|
|
|
ok(ret, "got %u\n", GetLastError());
|
|
|
|
|
|
|
|
index = 0;
|
|
|
|
len = sizeof(buffer);
|
|
|
|
ret = WinHttpQueryHeaders(request, WINHTTP_QUERY_CUSTOM | WINHTTP_QUERY_FLAG_REQUEST_HEADERS,
|
2020-02-14 16:41:38 +01:00
|
|
|
L"name", buffer, &len, &index);
|
2015-06-24 14:16:59 +02:00
|
|
|
ok(ret, "got %u\n", GetLastError());
|
|
|
|
ok(index == 1, "wrong index %u\n", index);
|
2020-02-14 16:41:38 +01:00
|
|
|
ok(!memcmp(buffer, L"value", sizeof(L"value")), "incorrect string\n");
|
2015-06-24 14:16:59 +02:00
|
|
|
|
2008-08-14 23:50:18 +02:00
|
|
|
ret = WinHttpCloseHandle(request);
|
2008-08-15 14:42:41 +02:00
|
|
|
ok(ret == TRUE, "WinHttpCloseHandle failed on closing request, got %d.\n", ret);
|
2008-08-14 23:50:18 +02:00
|
|
|
done:
|
|
|
|
ret = WinHttpCloseHandle(connection);
|
2008-08-15 14:42:28 +02:00
|
|
|
ok(ret == TRUE, "WinHttpCloseHandle failed on closing connection, got %d.\n", ret);
|
2008-08-14 23:50:18 +02:00
|
|
|
ret = WinHttpCloseHandle(session);
|
2008-08-15 14:42:15 +02:00
|
|
|
ok(ret == TRUE, "WinHttpCloseHandle failed on closing session, got %d.\n", ret);
|
2008-08-14 23:50:18 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2013-06-10 14:24:25 +02:00
|
|
|
static void CALLBACK cert_error(HINTERNET handle, DWORD_PTR ctx, DWORD status, LPVOID buf, DWORD len)
|
|
|
|
{
|
|
|
|
DWORD flags = *(DWORD *)buf;
|
|
|
|
|
|
|
|
if (!flags)
|
|
|
|
{
|
|
|
|
trace("WINHTTP_CALLBACK_STATUS_FLAG_SECURITY_CHANNEL_ERROR\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
#define X(x) if (flags & x) trace("%s\n", #x);
|
|
|
|
X(WINHTTP_CALLBACK_STATUS_FLAG_CERT_REV_FAILED)
|
|
|
|
X(WINHTTP_CALLBACK_STATUS_FLAG_INVALID_CERT)
|
|
|
|
X(WINHTTP_CALLBACK_STATUS_FLAG_CERT_REVOKED)
|
|
|
|
X(WINHTTP_CALLBACK_STATUS_FLAG_INVALID_CA)
|
|
|
|
X(WINHTTP_CALLBACK_STATUS_FLAG_CERT_CN_INVALID)
|
|
|
|
X(WINHTTP_CALLBACK_STATUS_FLAG_CERT_DATE_INVALID)
|
|
|
|
X(WINHTTP_CALLBACK_STATUS_FLAG_CERT_WRONG_USAGE)
|
|
|
|
#undef X
|
|
|
|
}
|
|
|
|
|
2008-08-28 13:50:03 +02:00
|
|
|
static void test_secure_connection(void)
|
|
|
|
{
|
2015-12-04 10:14:38 +01:00
|
|
|
static const char data_start[] = "<!DOCTYPE html PUBLIC";
|
2010-04-22 16:35:56 +02:00
|
|
|
HINTERNET ses, con, req;
|
2018-12-17 12:26:35 +01:00
|
|
|
DWORD size, status, policy, bitness, read_size, err, available_size, protocols, flags;
|
2008-08-28 13:50:03 +02:00
|
|
|
BOOL ret;
|
2008-09-08 22:01:39 +02:00
|
|
|
CERT_CONTEXT *cert;
|
2010-07-20 14:49:52 +02:00
|
|
|
WINHTTP_CERTIFICATE_INFO info;
|
2010-07-20 14:50:19 +02:00
|
|
|
char buffer[32];
|
2008-08-28 13:50:03 +02:00
|
|
|
|
2020-02-14 16:41:38 +01:00
|
|
|
ses = WinHttpOpen(L"winetest", 0, NULL, NULL, 0);
|
2008-08-28 13:50:03 +02:00
|
|
|
ok(ses != NULL, "failed to open session %u\n", GetLastError());
|
|
|
|
|
2008-09-03 16:58:06 +02:00
|
|
|
policy = WINHTTP_OPTION_REDIRECT_POLICY_ALWAYS;
|
|
|
|
ret = WinHttpSetOption(ses, WINHTTP_OPTION_REDIRECT_POLICY, &policy, sizeof(policy));
|
|
|
|
ok(ret, "failed to set redirect policy %u\n", GetLastError());
|
|
|
|
|
2017-09-12 09:59:06 +02:00
|
|
|
protocols = WINHTTP_FLAG_SECURE_PROTOCOL_TLS1_2;
|
|
|
|
ret = WinHttpSetOption(ses, WINHTTP_OPTION_SECURE_PROTOCOLS, &protocols, sizeof(protocols));
|
|
|
|
err = GetLastError();
|
2017-12-26 12:09:42 +01:00
|
|
|
ok(ret || err == ERROR_INVALID_PARAMETER /* < win7 */, "failed to set protocols %u\n", err);
|
2017-09-12 09:59:06 +02:00
|
|
|
|
2020-02-14 16:41:38 +01:00
|
|
|
con = WinHttpConnect(ses, L"test.winehq.org", 443, 0);
|
2008-08-28 13:50:03 +02:00
|
|
|
ok(con != NULL, "failed to open a connection %u\n", GetLastError());
|
|
|
|
|
2019-12-10 12:12:38 +01:00
|
|
|
SetLastError( 0xdeadbeef );
|
|
|
|
protocols = WINHTTP_FLAG_SECURE_PROTOCOL_TLS1_2;
|
|
|
|
ret = WinHttpSetOption(con, WINHTTP_OPTION_SECURE_PROTOCOLS, &protocols, sizeof(protocols));
|
|
|
|
err = GetLastError();
|
|
|
|
ok(!ret, "unexpected success\n");
|
|
|
|
ok(err == ERROR_WINHTTP_INCORRECT_HANDLE_TYPE, "got %u\n", err);
|
|
|
|
|
2008-08-28 13:50:03 +02:00
|
|
|
/* try without setting WINHTTP_FLAG_SECURE */
|
|
|
|
req = WinHttpOpenRequest(con, NULL, NULL, NULL, NULL, NULL, 0);
|
|
|
|
ok(req != NULL, "failed to open a request %u\n", GetLastError());
|
|
|
|
|
2016-10-06 14:05:32 +02:00
|
|
|
ret = WinHttpSetOption(req, WINHTTP_OPTION_CLIENT_CERT_CONTEXT, WINHTTP_NO_CLIENT_CERT_CONTEXT, 0);
|
2016-11-16 23:46:57 +01:00
|
|
|
err = GetLastError();
|
|
|
|
ok(!ret, "unexpected success\n");
|
|
|
|
ok(err == ERROR_WINHTTP_INCORRECT_HANDLE_STATE || broken(err == ERROR_INVALID_PARAMETER) /* winxp */,
|
|
|
|
"setting client cert context returned %u\n", err);
|
2016-10-06 14:05:32 +02:00
|
|
|
|
2008-08-28 13:50:03 +02:00
|
|
|
ret = WinHttpSendRequest(req, NULL, 0, NULL, 0, 0, 0);
|
2015-09-22 15:58:33 +02:00
|
|
|
err = GetLastError();
|
|
|
|
if (!ret && (err == ERROR_WINHTTP_CANNOT_CONNECT || err == ERROR_WINHTTP_TIMEOUT))
|
2010-06-07 22:41:40 +02:00
|
|
|
{
|
|
|
|
skip("Connection failed, skipping.\n");
|
|
|
|
goto cleanup;
|
|
|
|
}
|
2008-08-28 13:50:03 +02:00
|
|
|
ok(ret, "failed to send request %u\n", GetLastError());
|
|
|
|
|
|
|
|
ret = WinHttpReceiveResponse(req, NULL);
|
2016-03-17 10:13:59 +01:00
|
|
|
ok(ret, "failed to receive response %u\n", GetLastError());
|
2008-08-28 13:50:03 +02:00
|
|
|
|
2016-03-17 10:13:59 +01:00
|
|
|
status = 0xdeadbeef;
|
|
|
|
size = sizeof(status);
|
|
|
|
ret = WinHttpQueryHeaders(req, WINHTTP_QUERY_STATUS_CODE|WINHTTP_QUERY_FLAG_NUMBER, NULL, &status, &size, NULL);
|
|
|
|
ok(ret, "header query failed %u\n", GetLastError());
|
|
|
|
ok(status == HTTP_STATUS_BAD_REQUEST, "got %u\n", status);
|
2008-08-28 13:50:03 +02:00
|
|
|
|
|
|
|
WinHttpCloseHandle(req);
|
|
|
|
|
|
|
|
req = WinHttpOpenRequest(con, NULL, NULL, NULL, NULL, NULL, WINHTTP_FLAG_SECURE);
|
|
|
|
ok(req != NULL, "failed to open a request %u\n", GetLastError());
|
2018-12-17 12:26:35 +01:00
|
|
|
|
|
|
|
flags = 0xdeadbeef;
|
|
|
|
size = sizeof(flags);
|
|
|
|
ret = WinHttpQueryOption(req, WINHTTP_OPTION_SECURITY_FLAGS, &flags, &size);
|
|
|
|
ok(ret, "failed to query security flags %u\n", GetLastError());
|
|
|
|
ok(!flags, "got %08x\n", flags);
|
|
|
|
|
|
|
|
flags = SECURITY_FLAG_IGNORE_CERT_WRONG_USAGE;
|
|
|
|
ret = WinHttpSetOption(req, WINHTTP_OPTION_SECURITY_FLAGS, &flags, sizeof(flags));
|
|
|
|
ok(ret, "failed to set security flags %u\n", GetLastError());
|
|
|
|
|
|
|
|
flags = SECURITY_FLAG_SECURE;
|
|
|
|
ret = WinHttpSetOption(req, WINHTTP_OPTION_SECURITY_FLAGS, &flags, sizeof(flags));
|
|
|
|
ok(!ret, "success\n");
|
|
|
|
|
|
|
|
flags = SECURITY_FLAG_STRENGTH_STRONG;
|
|
|
|
ret = WinHttpSetOption(req, WINHTTP_OPTION_SECURITY_FLAGS, &flags, sizeof(flags));
|
|
|
|
ok(!ret, "success\n");
|
|
|
|
|
|
|
|
flags = SECURITY_FLAG_IGNORE_UNKNOWN_CA | SECURITY_FLAG_IGNORE_CERT_DATE_INVALID |
|
|
|
|
SECURITY_FLAG_IGNORE_CERT_CN_INVALID;
|
|
|
|
ret = WinHttpSetOption(req, WINHTTP_OPTION_SECURITY_FLAGS, &flags, sizeof(flags));
|
|
|
|
ok(ret, "failed to set security flags %u\n", GetLastError());
|
|
|
|
|
|
|
|
flags = 0;
|
|
|
|
ret = WinHttpSetOption(req, WINHTTP_OPTION_SECURITY_FLAGS, &flags, sizeof(flags));
|
|
|
|
ok(ret, "failed to set security flags %u\n", GetLastError());
|
2008-08-28 13:50:03 +02:00
|
|
|
|
2016-10-06 14:05:32 +02:00
|
|
|
ret = WinHttpSetOption(req, WINHTTP_OPTION_CLIENT_CERT_CONTEXT, WINHTTP_NO_CLIENT_CERT_CONTEXT, 0);
|
2016-11-16 23:46:57 +01:00
|
|
|
err = GetLastError();
|
|
|
|
ok(ret || broken(!ret && err == ERROR_INVALID_PARAMETER) /* winxp */, "failed to set client cert context %u\n", err);
|
2016-10-06 14:05:32 +02:00
|
|
|
|
2013-06-10 14:24:25 +02:00
|
|
|
WinHttpSetStatusCallback(req, cert_error, WINHTTP_CALLBACK_STATUS_SECURE_FAILURE, 0);
|
|
|
|
|
2008-08-28 13:50:03 +02:00
|
|
|
ret = WinHttpSendRequest(req, NULL, 0, NULL, 0, 0, 0);
|
2015-09-22 15:58:33 +02:00
|
|
|
err = GetLastError();
|
|
|
|
if (!ret && (err == ERROR_WINHTTP_SECURE_FAILURE || err == ERROR_WINHTTP_CANNOT_CONNECT ||
|
2019-10-02 16:43:35 +02:00
|
|
|
err == ERROR_WINHTTP_TIMEOUT || err == SEC_E_ILLEGAL_MESSAGE))
|
2009-12-11 23:10:27 +01:00
|
|
|
{
|
|
|
|
skip("secure connection failed, skipping remaining secure tests\n");
|
|
|
|
goto cleanup;
|
|
|
|
}
|
2014-09-01 14:48:49 +02:00
|
|
|
ok(ret, "failed to send request %u\n", GetLastError());
|
2008-08-28 13:50:03 +02:00
|
|
|
|
2008-09-08 22:01:39 +02:00
|
|
|
size = sizeof(cert);
|
|
|
|
ret = WinHttpQueryOption(req, WINHTTP_OPTION_SERVER_CERT_CONTEXT, &cert, &size );
|
|
|
|
ok(ret, "failed to retrieve certificate context %u\n", GetLastError());
|
2014-09-01 14:48:49 +02:00
|
|
|
if (ret) CertFreeCertificateContext(cert);
|
2008-09-08 22:01:39 +02:00
|
|
|
|
|
|
|
size = sizeof(bitness);
|
|
|
|
ret = WinHttpQueryOption(req, WINHTTP_OPTION_SECURITY_KEY_BITNESS, &bitness, &size );
|
|
|
|
ok(ret, "failed to retrieve key bitness %u\n", GetLastError());
|
|
|
|
|
2010-07-20 14:49:52 +02:00
|
|
|
size = sizeof(info);
|
|
|
|
ret = WinHttpQueryOption(req, WINHTTP_OPTION_SECURITY_CERTIFICATE_STRUCT, &info, &size );
|
|
|
|
ok(ret, "failed to retrieve certificate info %u\n", GetLastError());
|
|
|
|
|
2014-10-14 14:55:05 +02:00
|
|
|
if (ret)
|
2014-10-02 00:33:11 +02:00
|
|
|
{
|
|
|
|
trace("lpszSubjectInfo %s\n", wine_dbgstr_w(info.lpszSubjectInfo));
|
|
|
|
trace("lpszIssuerInfo %s\n", wine_dbgstr_w(info.lpszIssuerInfo));
|
|
|
|
trace("lpszProtocolName %s\n", wine_dbgstr_w(info.lpszProtocolName));
|
|
|
|
trace("lpszSignatureAlgName %s\n", wine_dbgstr_w(info.lpszSignatureAlgName));
|
|
|
|
trace("lpszEncryptionAlgName %s\n", wine_dbgstr_w(info.lpszEncryptionAlgName));
|
|
|
|
trace("dwKeySize %u\n", info.dwKeySize);
|
2017-02-21 09:24:38 +01:00
|
|
|
LocalFree( info.lpszSubjectInfo );
|
|
|
|
LocalFree( info.lpszIssuerInfo );
|
2014-10-02 00:33:11 +02:00
|
|
|
}
|
2010-07-20 14:49:52 +02:00
|
|
|
|
2008-08-28 13:50:03 +02:00
|
|
|
ret = WinHttpReceiveResponse(req, NULL);
|
2019-10-02 16:43:35 +02:00
|
|
|
if (!ret && GetLastError() == ERROR_WINHTTP_CONNECTION_ERROR)
|
|
|
|
{
|
|
|
|
skip("connection error, skipping remaining secure tests\n");
|
|
|
|
goto cleanup;
|
|
|
|
}
|
2008-08-28 13:50:03 +02:00
|
|
|
ok(ret, "failed to receive response %u\n", GetLastError());
|
|
|
|
|
2015-12-04 10:14:38 +01:00
|
|
|
available_size = 0;
|
|
|
|
ret = WinHttpQueryDataAvailable(req, &available_size);
|
|
|
|
ok(ret, "failed to query available data %u\n", GetLastError());
|
|
|
|
ok(available_size > 2014, "available_size = %u\n", available_size);
|
|
|
|
|
2015-04-21 11:21:06 +02:00
|
|
|
status = 0xdeadbeef;
|
2008-09-03 12:31:09 +02:00
|
|
|
size = sizeof(status);
|
|
|
|
ret = WinHttpQueryHeaders(req, WINHTTP_QUERY_STATUS_CODE | WINHTTP_QUERY_FLAG_NUMBER, NULL, &status, &size, NULL);
|
|
|
|
ok(ret, "failed unexpectedly %u\n", GetLastError());
|
2015-12-08 00:01:29 +01:00
|
|
|
ok(status == HTTP_STATUS_OK, "request failed unexpectedly %u\n", status);
|
2008-09-03 12:31:09 +02:00
|
|
|
|
2008-08-28 13:50:03 +02:00
|
|
|
size = 0;
|
|
|
|
ret = WinHttpQueryHeaders(req, WINHTTP_QUERY_RAW_HEADERS_CRLF, NULL, NULL, &size, NULL);
|
|
|
|
ok(!ret, "succeeded unexpectedly\n");
|
|
|
|
|
2013-01-23 15:48:02 +01:00
|
|
|
read_size = 0;
|
2010-07-20 14:50:19 +02:00
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
size = 0;
|
|
|
|
ret = WinHttpReadData(req, buffer, sizeof(buffer), &size);
|
2011-02-09 01:05:28 +01:00
|
|
|
ok(ret == TRUE, "WinHttpReadData failed: %u.\n", GetLastError());
|
2010-07-20 14:50:19 +02:00
|
|
|
if (!size) break;
|
2013-01-23 15:48:02 +01:00
|
|
|
read_size += size;
|
2015-12-04 10:14:38 +01:00
|
|
|
|
|
|
|
if (read_size <= 32)
|
|
|
|
ok(!memcmp(buffer, data_start, sizeof(data_start)-1), "not expected: %.32s\n", buffer);
|
2010-07-20 14:50:19 +02:00
|
|
|
}
|
2015-12-04 10:14:38 +01:00
|
|
|
ok(read_size >= available_size, "read_size = %u, available_size = %u\n", read_size, available_size);
|
2010-07-20 14:50:19 +02:00
|
|
|
|
2018-06-11 09:20:35 +02:00
|
|
|
size = sizeof(cert);
|
|
|
|
ret = WinHttpQueryOption(req, WINHTTP_OPTION_SERVER_CERT_CONTEXT, &cert, &size);
|
|
|
|
ok(ret, "failed to retrieve certificate context %u\n", GetLastError());
|
|
|
|
if (ret) CertFreeCertificateContext(cert);
|
|
|
|
|
2009-12-11 23:10:27 +01:00
|
|
|
cleanup:
|
2008-08-28 13:50:03 +02:00
|
|
|
WinHttpCloseHandle(req);
|
|
|
|
WinHttpCloseHandle(con);
|
|
|
|
WinHttpCloseHandle(ses);
|
|
|
|
}
|
|
|
|
|
2008-08-28 13:51:41 +02:00
|
|
|
static void test_request_parameter_defaults(void)
|
|
|
|
{
|
2010-04-22 16:35:56 +02:00
|
|
|
HINTERNET ses, con, req;
|
2009-10-29 11:12:45 +01:00
|
|
|
DWORD size, status, error;
|
|
|
|
WCHAR *version;
|
2008-08-28 13:51:41 +02:00
|
|
|
BOOL ret;
|
|
|
|
|
2020-02-14 16:41:38 +01:00
|
|
|
ses = WinHttpOpen(L"winetest", 0, NULL, NULL, 0);
|
2008-08-28 13:51:41 +02:00
|
|
|
ok(ses != NULL, "failed to open session %u\n", GetLastError());
|
|
|
|
|
2020-02-14 16:41:38 +01:00
|
|
|
con = WinHttpConnect(ses, L"test.winehq.org", 0, 0);
|
2008-08-28 13:51:41 +02:00
|
|
|
ok(con != NULL, "failed to open a connection %u\n", GetLastError());
|
|
|
|
|
|
|
|
req = WinHttpOpenRequest(con, NULL, NULL, NULL, NULL, NULL, 0);
|
|
|
|
ok(req != NULL, "failed to open a request %u\n", GetLastError());
|
|
|
|
|
|
|
|
ret = WinHttpSendRequest(req, NULL, 0, NULL, 0, 0, 0);
|
2015-09-22 15:58:33 +02:00
|
|
|
error = GetLastError();
|
|
|
|
if (!ret && (error == ERROR_WINHTTP_CANNOT_CONNECT || error == ERROR_WINHTTP_TIMEOUT))
|
2014-09-01 14:48:49 +02:00
|
|
|
{
|
|
|
|
skip("connection failed, skipping\n");
|
|
|
|
goto done;
|
|
|
|
}
|
2008-08-28 13:51:41 +02:00
|
|
|
ok(ret, "failed to send request %u\n", GetLastError());
|
|
|
|
|
|
|
|
ret = WinHttpReceiveResponse(req, NULL);
|
|
|
|
ok(ret, "failed to receive response %u\n", GetLastError());
|
|
|
|
|
2015-04-21 11:21:06 +02:00
|
|
|
status = 0xdeadbeef;
|
2008-09-03 12:31:09 +02:00
|
|
|
size = sizeof(status);
|
|
|
|
ret = WinHttpQueryHeaders(req, WINHTTP_QUERY_STATUS_CODE | WINHTTP_QUERY_FLAG_NUMBER, NULL, &status, &size, NULL);
|
|
|
|
ok(ret, "failed unexpectedly %u\n", GetLastError());
|
2015-12-08 00:01:29 +01:00
|
|
|
ok(status == HTTP_STATUS_OK, "request failed unexpectedly %u\n", status);
|
2008-09-03 12:31:09 +02:00
|
|
|
|
2008-08-28 13:51:41 +02:00
|
|
|
WinHttpCloseHandle(req);
|
|
|
|
|
2020-02-14 16:41:38 +01:00
|
|
|
req = WinHttpOpenRequest(con, L"", L"", L"", NULL, NULL, 0);
|
2008-08-28 13:51:41 +02:00
|
|
|
ok(req != NULL, "failed to open a request %u\n", GetLastError());
|
|
|
|
|
|
|
|
ret = WinHttpSendRequest(req, NULL, 0, NULL, 0, 0, 0);
|
2015-09-22 15:58:33 +02:00
|
|
|
error = GetLastError();
|
|
|
|
if (!ret && (error == ERROR_WINHTTP_CANNOT_CONNECT || error == ERROR_WINHTTP_TIMEOUT))
|
2014-09-01 14:48:49 +02:00
|
|
|
{
|
|
|
|
skip("connection failed, skipping\n");
|
|
|
|
goto done;
|
|
|
|
}
|
2008-08-28 13:51:41 +02:00
|
|
|
ok(ret, "failed to send request %u\n", GetLastError());
|
|
|
|
|
|
|
|
ret = WinHttpReceiveResponse(req, NULL);
|
|
|
|
ok(ret, "failed to receive response %u\n", GetLastError());
|
|
|
|
|
2009-10-29 11:12:45 +01:00
|
|
|
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);
|
|
|
|
|
2015-04-21 11:21:06 +02:00
|
|
|
status = 0xdeadbeef;
|
2008-09-03 12:31:09 +02:00
|
|
|
size = sizeof(status);
|
|
|
|
ret = WinHttpQueryHeaders(req, WINHTTP_QUERY_STATUS_CODE | WINHTTP_QUERY_FLAG_NUMBER, NULL, &status, &size, NULL);
|
|
|
|
ok(ret, "failed unexpectedly %u\n", GetLastError());
|
2015-12-08 00:01:29 +01:00
|
|
|
ok(status == HTTP_STATUS_OK, "request failed unexpectedly %u\n", status);
|
2008-09-03 12:31:09 +02:00
|
|
|
|
2014-09-01 14:48:49 +02:00
|
|
|
done:
|
2008-08-28 13:51:41 +02:00
|
|
|
WinHttpCloseHandle(req);
|
|
|
|
WinHttpCloseHandle(con);
|
|
|
|
WinHttpCloseHandle(ses);
|
|
|
|
}
|
|
|
|
|
2009-07-14 21:36:41 +02:00
|
|
|
static const WCHAR Connections[] = {
|
|
|
|
'S','o','f','t','w','a','r','e','\\',
|
|
|
|
'M','i','c','r','o','s','o','f','t','\\',
|
|
|
|
'W','i','n','d','o','w','s','\\',
|
|
|
|
'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
|
|
|
|
'I','n','t','e','r','n','e','t',' ','S','e','t','t','i','n','g','s','\\',
|
|
|
|
'C','o','n','n','e','c','t','i','o','n','s',0 };
|
|
|
|
static const WCHAR WinHttpSettings[] = {
|
|
|
|
'W','i','n','H','t','t','p','S','e','t','t','i','n','g','s',0 };
|
|
|
|
|
|
|
|
static DWORD get_default_proxy_reg_value( BYTE *buf, DWORD len, DWORD *type )
|
|
|
|
{
|
|
|
|
LONG l;
|
|
|
|
HKEY key;
|
|
|
|
DWORD ret = 0;
|
|
|
|
|
|
|
|
l = RegOpenKeyExW( HKEY_LOCAL_MACHINE, Connections, 0, KEY_READ, &key );
|
|
|
|
if (!l)
|
|
|
|
{
|
|
|
|
DWORD size = 0;
|
|
|
|
|
|
|
|
l = RegQueryValueExW( key, WinHttpSettings, NULL, type, NULL, &size );
|
|
|
|
if (!l)
|
|
|
|
{
|
|
|
|
if (size <= len)
|
|
|
|
l = RegQueryValueExW( key, WinHttpSettings, NULL, type, buf,
|
|
|
|
&size );
|
|
|
|
if (!l)
|
|
|
|
ret = size;
|
|
|
|
}
|
|
|
|
RegCloseKey( key );
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2016-11-30 10:58:57 +01:00
|
|
|
static void set_proxy( REGSAM access, BYTE *buf, DWORD len, DWORD type )
|
2009-07-14 21:36:41 +02:00
|
|
|
{
|
2016-11-30 10:58:57 +01:00
|
|
|
HKEY hkey;
|
|
|
|
if (!RegCreateKeyExW( HKEY_LOCAL_MACHINE, Connections, 0, NULL, 0, access, NULL, &hkey, NULL ))
|
|
|
|
{
|
|
|
|
if (len) RegSetValueExW( hkey, WinHttpSettings, 0, type, buf, len );
|
|
|
|
else RegDeleteValueW( hkey, WinHttpSettings );
|
|
|
|
RegCloseKey( hkey );
|
|
|
|
}
|
|
|
|
}
|
2009-07-14 21:36:41 +02:00
|
|
|
|
2016-11-30 10:58:57 +01:00
|
|
|
static void set_default_proxy_reg_value( BYTE *buf, DWORD len, DWORD type )
|
|
|
|
{
|
|
|
|
BOOL wow64;
|
|
|
|
IsWow64Process( GetCurrentProcess(), &wow64 );
|
|
|
|
if (sizeof(void *) > sizeof(int) || wow64)
|
2009-07-14 21:36:41 +02:00
|
|
|
{
|
2016-11-30 10:58:57 +01:00
|
|
|
set_proxy( KEY_WRITE|KEY_WOW64_64KEY, buf, len, type );
|
|
|
|
set_proxy( KEY_WRITE|KEY_WOW64_32KEY, buf, len, type );
|
2009-07-14 21:36:41 +02:00
|
|
|
}
|
2016-11-30 10:58:57 +01:00
|
|
|
else
|
|
|
|
set_proxy( KEY_WRITE, buf, len, type );
|
2009-07-14 21:36:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void test_set_default_proxy_config(void)
|
|
|
|
{
|
2012-07-19 10:22:59 +02:00
|
|
|
static WCHAR wideString[] = { 0x226f, 0x575b, 0 };
|
|
|
|
static WCHAR normalString[] = { 'f','o','o',0 };
|
2009-07-14 21:36:41 +02:00
|
|
|
DWORD type, len;
|
|
|
|
BYTE *saved_proxy_settings = NULL;
|
|
|
|
WINHTTP_PROXY_INFO info;
|
|
|
|
BOOL ret;
|
|
|
|
|
|
|
|
/* FIXME: it would be simpler to read the current settings using
|
|
|
|
* WinHttpGetDefaultProxyConfiguration and save them using
|
|
|
|
* WinHttpSetDefaultProxyConfiguration, but they appear to have a bug.
|
|
|
|
*
|
|
|
|
* If a proxy is configured in the registry, e.g. via 'proxcfg -p "foo"',
|
|
|
|
* the access type reported by WinHttpGetDefaultProxyConfiguration is 1,
|
|
|
|
* WINHTTP_ACCESS_TYPE_NO_PROXY, whereas it should be
|
|
|
|
* WINHTTP_ACCESS_TYPE_NAMED_PROXY.
|
|
|
|
* If WinHttpSetDefaultProxyConfiguration is called with dwAccessType = 1,
|
|
|
|
* the lpszProxy and lpszProxyBypass values are ignored.
|
|
|
|
* Thus, if a proxy is set with proxycfg, then calling
|
|
|
|
* WinHttpGetDefaultProxyConfiguration followed by
|
|
|
|
* WinHttpSetDefaultProxyConfiguration results in the proxy settings
|
|
|
|
* getting deleted from the registry.
|
|
|
|
*
|
|
|
|
* Instead I read the current registry value and restore it directly.
|
|
|
|
*/
|
|
|
|
len = get_default_proxy_reg_value( NULL, 0, &type );
|
|
|
|
if (len)
|
|
|
|
{
|
|
|
|
saved_proxy_settings = HeapAlloc( GetProcessHeap(), 0, len );
|
|
|
|
len = get_default_proxy_reg_value( saved_proxy_settings, len, &type );
|
|
|
|
}
|
|
|
|
|
2009-07-16 15:47:38 +02:00
|
|
|
if (0)
|
|
|
|
{
|
|
|
|
/* Crashes on Vista and higher */
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = WinHttpSetDefaultProxyConfiguration(NULL);
|
|
|
|
ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER,
|
|
|
|
"expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
|
|
|
|
}
|
2009-07-14 21:36:41 +02:00
|
|
|
|
|
|
|
/* test with invalid access type */
|
|
|
|
info.dwAccessType = 0xdeadbeef;
|
|
|
|
info.lpszProxy = info.lpszProxyBypass = NULL;
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = WinHttpSetDefaultProxyConfiguration(&info);
|
|
|
|
ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER,
|
|
|
|
"expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
|
|
|
|
|
|
|
|
/* at a minimum, the proxy server must be set */
|
|
|
|
info.dwAccessType = WINHTTP_ACCESS_TYPE_NAMED_PROXY;
|
|
|
|
info.lpszProxy = info.lpszProxyBypass = NULL;
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = WinHttpSetDefaultProxyConfiguration(&info);
|
|
|
|
ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER,
|
|
|
|
"expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
|
|
|
|
info.lpszProxyBypass = normalString;
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = WinHttpSetDefaultProxyConfiguration(&info);
|
|
|
|
ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER,
|
|
|
|
"expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
|
|
|
|
|
|
|
|
/* the proxy server can't have wide characters */
|
|
|
|
info.lpszProxy = wideString;
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = WinHttpSetDefaultProxyConfiguration(&info);
|
2012-12-21 13:55:41 +01:00
|
|
|
if (!ret && GetLastError() == ERROR_ACCESS_DENIED)
|
|
|
|
skip("couldn't set default proxy configuration: access denied\n");
|
|
|
|
else
|
|
|
|
ok((!ret && GetLastError() == ERROR_INVALID_PARAMETER) ||
|
|
|
|
broken(ret), /* Earlier winhttp versions on W2K/XP */
|
|
|
|
"expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
|
2009-07-14 21:36:41 +02:00
|
|
|
|
|
|
|
info.lpszProxy = normalString;
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = WinHttpSetDefaultProxyConfiguration(&info);
|
2012-12-21 13:55:41 +01:00
|
|
|
if (!ret && GetLastError() == ERROR_ACCESS_DENIED)
|
2009-12-08 18:47:08 +01:00
|
|
|
skip("couldn't set default proxy configuration: access denied\n");
|
|
|
|
else
|
2015-08-03 11:27:31 +02:00
|
|
|
{
|
|
|
|
ok(ret, "WinHttpSetDefaultProxyConfiguration failed: %u\n", GetLastError());
|
|
|
|
ok(GetLastError() == ERROR_SUCCESS || broken(GetLastError() == 0xdeadbeef) /* < win7 */,
|
|
|
|
"got %u\n", GetLastError());
|
|
|
|
}
|
2012-12-21 13:55:41 +01:00
|
|
|
set_default_proxy_reg_value( saved_proxy_settings, len, type );
|
2009-07-14 21:36:41 +02:00
|
|
|
}
|
|
|
|
|
2018-09-10 13:24:34 +02:00
|
|
|
static void test_timeouts(void)
|
2010-01-27 23:01:29 +01:00
|
|
|
{
|
|
|
|
BOOL ret;
|
2010-01-29 01:40:00 +01:00
|
|
|
DWORD value, size;
|
2010-01-27 23:01:29 +01:00
|
|
|
HINTERNET ses, req, con;
|
|
|
|
|
2020-02-14 16:41:38 +01:00
|
|
|
ses = WinHttpOpen(L"winetest", 0, NULL, NULL, 0);
|
2010-01-27 23:01:29 +01:00
|
|
|
ok(ses != NULL, "failed to open session %u\n", GetLastError());
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = WinHttpSetTimeouts(ses, -2, 0, 0, 0);
|
|
|
|
ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER,
|
|
|
|
"expected ERROR_INVALID_PARAMETER, got %u\n", GetLastError());
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = WinHttpSetTimeouts(ses, 0, -2, 0, 0);
|
|
|
|
ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER,
|
|
|
|
"expected ERROR_INVALID_PARAMETER, got %u\n", GetLastError());
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = WinHttpSetTimeouts(ses, 0, 0, -2, 0);
|
|
|
|
ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER,
|
|
|
|
"expected ERROR_INVALID_PARAMETER, got %u\n", GetLastError());
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = WinHttpSetTimeouts(ses, 0, 0, 0, -2);
|
|
|
|
ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER,
|
|
|
|
"expected ERROR_INVALID_PARAMETER, got %u\n", GetLastError());
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = WinHttpSetTimeouts(ses, -1, -1, -1, -1);
|
2010-01-29 01:45:15 +01:00
|
|
|
ok(ret, "%u\n", GetLastError());
|
2015-08-03 11:27:31 +02:00
|
|
|
ok(GetLastError() == ERROR_SUCCESS || broken(GetLastError() == 0xdeadbeef) /* < win7 */,
|
|
|
|
"expected ERROR_SUCCESS, got %u\n", GetLastError());
|
2010-01-27 23:01:29 +01:00
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = WinHttpSetTimeouts(ses, 0, 0, 0, 0);
|
2010-01-29 01:45:15 +01:00
|
|
|
ok(ret, "%u\n", GetLastError());
|
2010-01-27 23:01:29 +01:00
|
|
|
|
2010-01-29 01:40:00 +01:00
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = WinHttpSetTimeouts(ses, 0x0123, 0x4567, 0x89ab, 0xcdef);
|
2010-01-29 01:45:15 +01:00
|
|
|
ok(ret, "%u\n", GetLastError());
|
2010-01-29 01:40:00 +01:00
|
|
|
|
2010-02-22 12:27:30 +01:00
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
value = 0xdeadbeef;
|
|
|
|
size = sizeof(DWORD);
|
|
|
|
ret = WinHttpQueryOption(ses, WINHTTP_OPTION_RESOLVE_TIMEOUT, &value, &size);
|
|
|
|
ok(ret, "%u\n", GetLastError());
|
|
|
|
ok(value == 0x0123, "Expected 0x0123, got %u\n", value);
|
|
|
|
|
2010-01-29 01:40:00 +01:00
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
value = 0xdeadbeef;
|
|
|
|
size = sizeof(DWORD);
|
|
|
|
ret = WinHttpQueryOption(ses, WINHTTP_OPTION_CONNECT_TIMEOUT, &value, &size);
|
2010-01-29 02:11:57 +01:00
|
|
|
ok(ret, "%u\n", GetLastError());
|
|
|
|
ok(value == 0x4567, "Expected 0x4567, got %u\n", value);
|
2010-01-29 01:40:00 +01:00
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
value = 0xdeadbeef;
|
|
|
|
size = sizeof(DWORD);
|
|
|
|
ret = WinHttpQueryOption(ses, WINHTTP_OPTION_SEND_TIMEOUT, &value, &size);
|
2010-01-29 02:11:57 +01:00
|
|
|
ok(ret, "%u\n", GetLastError());
|
|
|
|
ok(value == 0x89ab, "Expected 0x89ab, got %u\n", value);
|
2010-01-29 01:40:00 +01:00
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
value = 0xdeadbeef;
|
|
|
|
size = sizeof(DWORD);
|
|
|
|
ret = WinHttpQueryOption(ses, WINHTTP_OPTION_RECEIVE_TIMEOUT, &value, &size);
|
2010-01-29 02:11:57 +01:00
|
|
|
ok(ret, "%u\n", GetLastError());
|
|
|
|
ok(value == 0xcdef, "Expected 0xcdef, got %u\n", value);
|
2010-01-29 01:40:00 +01:00
|
|
|
|
2010-02-22 12:27:30 +01:00
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
value = 0;
|
|
|
|
ret = WinHttpSetOption(ses, WINHTTP_OPTION_RESOLVE_TIMEOUT, &value, sizeof(value));
|
|
|
|
ok(ret, "%u\n", GetLastError());
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
value = 0xdeadbeef;
|
|
|
|
size = sizeof(DWORD);
|
|
|
|
ret = WinHttpQueryOption(ses, WINHTTP_OPTION_RESOLVE_TIMEOUT, &value, &size);
|
|
|
|
ok(ret, "%u\n", GetLastError());
|
|
|
|
ok(value == 0, "Expected 0, got %u\n", value);
|
|
|
|
|
2010-01-29 01:40:00 +01:00
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
value = 0;
|
|
|
|
ret = WinHttpSetOption(ses, WINHTTP_OPTION_CONNECT_TIMEOUT, &value, sizeof(value));
|
2010-01-29 02:11:57 +01:00
|
|
|
ok(ret, "%u\n", GetLastError());
|
2010-01-29 01:40:00 +01:00
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
value = 0xdeadbeef;
|
|
|
|
size = sizeof(DWORD);
|
|
|
|
ret = WinHttpQueryOption(ses, WINHTTP_OPTION_CONNECT_TIMEOUT, &value, &size);
|
2010-01-29 02:11:57 +01:00
|
|
|
ok(ret, "%u\n", GetLastError());
|
|
|
|
ok(value == 0, "Expected 0, got %u\n", value);
|
2010-01-29 01:40:00 +01:00
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
value = 0;
|
|
|
|
ret = WinHttpSetOption(ses, WINHTTP_OPTION_SEND_TIMEOUT, &value, sizeof(value));
|
2010-01-29 02:11:57 +01:00
|
|
|
ok(ret, "%u\n", GetLastError());
|
2010-01-29 01:40:00 +01:00
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
value = 0xdeadbeef;
|
|
|
|
size = sizeof(DWORD);
|
|
|
|
ret = WinHttpQueryOption(ses, WINHTTP_OPTION_SEND_TIMEOUT, &value, &size);
|
2010-01-29 02:11:57 +01:00
|
|
|
ok(ret, "%u\n", GetLastError());
|
|
|
|
ok(value == 0, "Expected 0, got %u\n", value);
|
2010-01-29 01:40:00 +01:00
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
value = 0;
|
|
|
|
ret = WinHttpSetOption(ses, WINHTTP_OPTION_RECEIVE_TIMEOUT, &value, sizeof(value));
|
2010-01-29 02:11:57 +01:00
|
|
|
ok(ret, "%u\n", GetLastError());
|
2010-01-29 01:40:00 +01:00
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
value = 0xdeadbeef;
|
|
|
|
size = sizeof(DWORD);
|
|
|
|
ret = WinHttpQueryOption(ses, WINHTTP_OPTION_RECEIVE_TIMEOUT, &value, &size);
|
2010-01-29 02:11:57 +01:00
|
|
|
ok(ret, "%u\n", GetLastError());
|
|
|
|
ok(value == 0, "Expected 0, got %u\n", value);
|
2010-01-29 01:40:00 +01:00
|
|
|
|
2010-02-22 12:27:30 +01:00
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
value = 0xbeefdead;
|
|
|
|
ret = WinHttpSetOption(ses, WINHTTP_OPTION_RESOLVE_TIMEOUT, &value, sizeof(value));
|
|
|
|
ok(ret, "%u\n", GetLastError());
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
value = 0xdeadbeef;
|
|
|
|
size = sizeof(DWORD);
|
|
|
|
ret = WinHttpQueryOption(ses, WINHTTP_OPTION_RESOLVE_TIMEOUT, &value, &size);
|
|
|
|
ok(ret, "%u\n", GetLastError());
|
|
|
|
ok(value == 0xbeefdead, "Expected 0xbeefdead, got %u\n", value);
|
|
|
|
|
2010-01-29 01:40:00 +01:00
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
value = 0xbeefdead;
|
|
|
|
ret = WinHttpSetOption(ses, WINHTTP_OPTION_CONNECT_TIMEOUT, &value, sizeof(value));
|
2010-01-29 02:11:57 +01:00
|
|
|
ok(ret, "%u\n", GetLastError());
|
2010-01-29 01:40:00 +01:00
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
value = 0xdeadbeef;
|
|
|
|
size = sizeof(DWORD);
|
|
|
|
ret = WinHttpQueryOption(ses, WINHTTP_OPTION_CONNECT_TIMEOUT, &value, &size);
|
2010-01-29 02:11:57 +01:00
|
|
|
ok(ret, "%u\n", GetLastError());
|
|
|
|
ok(value == 0xbeefdead, "Expected 0xbeefdead, got %u\n", value);
|
2010-01-29 01:40:00 +01:00
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
value = 0xbeefdead;
|
|
|
|
ret = WinHttpSetOption(ses, WINHTTP_OPTION_SEND_TIMEOUT, &value, sizeof(value));
|
2010-01-29 02:11:57 +01:00
|
|
|
ok(ret, "%u\n", GetLastError());
|
2010-01-29 01:40:00 +01:00
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
value = 0xdeadbeef;
|
|
|
|
size = sizeof(DWORD);
|
|
|
|
ret = WinHttpQueryOption(ses, WINHTTP_OPTION_SEND_TIMEOUT, &value, &size);
|
2010-01-29 02:11:57 +01:00
|
|
|
ok(ret, "%u\n", GetLastError());
|
|
|
|
ok(value == 0xbeefdead, "Expected 0xbeefdead, got %u\n", value);
|
2010-01-29 01:40:00 +01:00
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
value = 0xbeefdead;
|
|
|
|
ret = WinHttpSetOption(ses, WINHTTP_OPTION_RECEIVE_TIMEOUT, &value, sizeof(value));
|
2010-01-29 02:11:57 +01:00
|
|
|
ok(ret, "%u\n", GetLastError());
|
2010-01-29 01:40:00 +01:00
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
value = 0xdeadbeef;
|
|
|
|
size = sizeof(DWORD);
|
|
|
|
ret = WinHttpQueryOption(ses, WINHTTP_OPTION_RECEIVE_TIMEOUT, &value, &size);
|
2010-01-29 02:11:57 +01:00
|
|
|
ok(ret, "%u\n", GetLastError());
|
|
|
|
ok(value == 0xbeefdead, "Expected 0xbeefdead, got %u\n", value);
|
2010-01-29 01:40:00 +01:00
|
|
|
|
2020-02-14 16:41:38 +01:00
|
|
|
con = WinHttpConnect(ses, L"test.winehq.org", 0, 0);
|
2010-01-27 23:01:29 +01:00
|
|
|
ok(con != NULL, "failed to open a connection %u\n", GetLastError());
|
|
|
|
|
2010-01-29 01:40:00 +01:00
|
|
|
/* Timeout values should match the last one set for session */
|
2010-02-22 12:27:30 +01:00
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
value = 0xdeadbeef;
|
|
|
|
size = sizeof(DWORD);
|
|
|
|
ret = WinHttpQueryOption(con, WINHTTP_OPTION_RESOLVE_TIMEOUT, &value, &size);
|
|
|
|
ok(ret, "%u\n", GetLastError());
|
|
|
|
ok(value == 0xbeefdead, "Expected 0xbeefdead, got %u\n", value);
|
|
|
|
|
2010-01-29 01:40:00 +01:00
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
value = 0xdeadbeef;
|
|
|
|
size = sizeof(DWORD);
|
|
|
|
ret = WinHttpQueryOption(con, WINHTTP_OPTION_CONNECT_TIMEOUT, &value, &size);
|
2010-01-29 02:11:57 +01:00
|
|
|
ok(ret, "%u\n", GetLastError());
|
|
|
|
ok(value == 0xbeefdead, "Expected 0xbeefdead, got %u\n", value);
|
2010-01-29 01:40:00 +01:00
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
value = 0xdeadbeef;
|
|
|
|
size = sizeof(DWORD);
|
|
|
|
ret = WinHttpQueryOption(con, WINHTTP_OPTION_SEND_TIMEOUT, &value, &size);
|
2010-01-29 02:11:57 +01:00
|
|
|
ok(ret, "%u\n", GetLastError());
|
|
|
|
ok(value == 0xbeefdead, "Expected 0xbeefdead, got %u\n", value);
|
2010-01-29 01:40:00 +01:00
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
value = 0xdeadbeef;
|
|
|
|
size = sizeof(DWORD);
|
|
|
|
ret = WinHttpQueryOption(con, WINHTTP_OPTION_RECEIVE_TIMEOUT, &value, &size);
|
2010-01-29 02:11:57 +01:00
|
|
|
ok(ret, "%u\n", GetLastError());
|
|
|
|
ok(value == 0xbeefdead, "Expected 0xbeefdead, got %u\n", value);
|
2010-01-29 01:40:00 +01:00
|
|
|
|
2010-01-27 23:01:29 +01:00
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = WinHttpSetTimeouts(con, -2, 0, 0, 0);
|
|
|
|
ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER,
|
|
|
|
"expected ERROR_INVALID_PARAMETER, got %u\n", GetLastError());
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = WinHttpSetTimeouts(con, 0, -2, 0, 0);
|
|
|
|
ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER,
|
|
|
|
"expected ERROR_INVALID_PARAMETER, got %u\n", GetLastError());
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = WinHttpSetTimeouts(con, 0, 0, -2, 0);
|
|
|
|
ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER,
|
|
|
|
"expected ERROR_INVALID_PARAMETER, got %u\n", GetLastError());
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = WinHttpSetTimeouts(con, 0, 0, 0, -2);
|
|
|
|
ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER,
|
|
|
|
"expected ERROR_INVALID_PARAMETER, got %u\n", GetLastError());
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = WinHttpSetTimeouts(con, -1, -1, -1, -1);
|
|
|
|
ok(!ret && GetLastError() == ERROR_WINHTTP_INCORRECT_HANDLE_TYPE,
|
|
|
|
"expected ERROR_WINHTTP_INVALID_TYPE, got %u\n", GetLastError());
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = WinHttpSetTimeouts(con, 0, 0, 0, 0);
|
|
|
|
ok(!ret && GetLastError() == ERROR_WINHTTP_INCORRECT_HANDLE_TYPE,
|
|
|
|
"expected ERROR_WINHTTP_INVALID_TYPE, got %u\n", GetLastError());
|
|
|
|
|
2010-02-22 12:27:30 +01:00
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
value = 0;
|
|
|
|
ret = WinHttpSetOption(con, WINHTTP_OPTION_RESOLVE_TIMEOUT, &value, sizeof(value));
|
|
|
|
ok(!ret && GetLastError() == ERROR_WINHTTP_INCORRECT_HANDLE_TYPE,
|
|
|
|
"expected ERROR_WINHTTP_INVALID_TYPE, got %u\n", GetLastError());
|
|
|
|
|
2010-01-29 01:40:00 +01:00
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
value = 0;
|
|
|
|
ret = WinHttpSetOption(con, WINHTTP_OPTION_CONNECT_TIMEOUT, &value, sizeof(value));
|
|
|
|
ok(!ret && GetLastError() == ERROR_WINHTTP_INCORRECT_HANDLE_TYPE,
|
|
|
|
"expected ERROR_WINHTTP_INVALID_TYPE, got %u\n", GetLastError());
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
value = 0;
|
|
|
|
ret = WinHttpSetOption(con, WINHTTP_OPTION_SEND_TIMEOUT, &value, sizeof(value));
|
|
|
|
ok(!ret && GetLastError() == ERROR_WINHTTP_INCORRECT_HANDLE_TYPE,
|
|
|
|
"expected ERROR_WINHTTP_INVALID_TYPE, got %u\n", GetLastError());
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
value = 0;
|
|
|
|
ret = WinHttpSetOption(con, WINHTTP_OPTION_RECEIVE_TIMEOUT, &value, sizeof(value));
|
|
|
|
ok(!ret && GetLastError() == ERROR_WINHTTP_INCORRECT_HANDLE_TYPE,
|
|
|
|
"expected ERROR_WINHTTP_INVALID_TYPE, got %u\n", GetLastError());
|
|
|
|
|
|
|
|
/* Changing timeout values for session should affect the values for connection */
|
2010-02-22 12:27:30 +01:00
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
value = 0xdead;
|
|
|
|
ret = WinHttpSetOption(ses, WINHTTP_OPTION_RESOLVE_TIMEOUT, &value, sizeof(value));
|
|
|
|
ok(ret, "%u\n", GetLastError());
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
value = 0xdeadbeef;
|
|
|
|
size = sizeof(DWORD);
|
|
|
|
ret = WinHttpQueryOption(con, WINHTTP_OPTION_RESOLVE_TIMEOUT, &value, &size);
|
|
|
|
ok(ret, "%u\n", GetLastError());
|
|
|
|
ok(value == 0xdead, "Expected 0xdead, got %u\n", value);
|
|
|
|
|
2010-01-29 01:40:00 +01:00
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
value = 0xdead;
|
|
|
|
ret = WinHttpSetOption(ses, WINHTTP_OPTION_CONNECT_TIMEOUT, &value, sizeof(value));
|
2010-01-29 02:11:57 +01:00
|
|
|
ok(ret, "%u\n", GetLastError());
|
2010-01-29 01:40:00 +01:00
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
value = 0xdeadbeef;
|
|
|
|
size = sizeof(DWORD);
|
|
|
|
ret = WinHttpQueryOption(con, WINHTTP_OPTION_CONNECT_TIMEOUT, &value, &size);
|
2010-01-29 02:11:57 +01:00
|
|
|
ok(ret, "%u\n", GetLastError());
|
|
|
|
ok(value == 0xdead, "Expected 0xdead, got %u\n", value);
|
2010-01-29 01:40:00 +01:00
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
value = 0xdead;
|
|
|
|
ret = WinHttpSetOption(ses, WINHTTP_OPTION_SEND_TIMEOUT, &value, sizeof(value));
|
2010-01-29 02:11:57 +01:00
|
|
|
ok(ret, "%u\n", GetLastError());
|
2010-01-29 01:40:00 +01:00
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
value = 0xdeadbeef;
|
|
|
|
size = sizeof(DWORD);
|
|
|
|
ret = WinHttpQueryOption(con, WINHTTP_OPTION_SEND_TIMEOUT, &value, &size);
|
2010-01-29 02:11:57 +01:00
|
|
|
ok(ret, "%u\n", GetLastError());
|
|
|
|
ok(value == 0xdead, "Expected 0xdead, got %u\n", value);
|
2010-01-29 01:40:00 +01:00
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
value = 0xdead;
|
|
|
|
ret = WinHttpSetOption(ses, WINHTTP_OPTION_RECEIVE_TIMEOUT, &value, sizeof(value));
|
2010-01-29 02:11:57 +01:00
|
|
|
ok(ret, "%u\n", GetLastError());
|
2010-01-29 01:40:00 +01:00
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
value = 0xdeadbeef;
|
|
|
|
size = sizeof(DWORD);
|
|
|
|
ret = WinHttpQueryOption(con, WINHTTP_OPTION_RECEIVE_TIMEOUT, &value, &size);
|
2010-01-29 02:11:57 +01:00
|
|
|
ok(ret, "%u\n", GetLastError());
|
|
|
|
ok(value == 0xdead, "Expected 0xdead, got %u\n", value);
|
2010-01-29 01:40:00 +01:00
|
|
|
|
2010-01-27 23:01:29 +01:00
|
|
|
req = WinHttpOpenRequest(con, NULL, NULL, NULL, NULL, NULL, 0);
|
|
|
|
ok(req != NULL, "failed to open a request %u\n", GetLastError());
|
|
|
|
|
2010-01-29 01:40:00 +01:00
|
|
|
/* Timeout values should match the last one set for session */
|
2010-02-22 12:27:30 +01:00
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
value = 0xdeadbeef;
|
|
|
|
size = sizeof(DWORD);
|
|
|
|
ret = WinHttpQueryOption(req, WINHTTP_OPTION_RESOLVE_TIMEOUT, &value, &size);
|
|
|
|
ok(ret, "%u\n", GetLastError());
|
|
|
|
ok(value == 0xdead, "Expected 0xdead, got %u\n", value);
|
|
|
|
|
2010-01-29 01:40:00 +01:00
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
value = 0xdeadbeef;
|
|
|
|
size = sizeof(DWORD);
|
|
|
|
ret = WinHttpQueryOption(req, WINHTTP_OPTION_CONNECT_TIMEOUT, &value, &size);
|
2010-01-29 02:11:57 +01:00
|
|
|
ok(ret, "%u\n", GetLastError());
|
|
|
|
ok(value == 0xdead, "Expected 0xdead, got %u\n", value);
|
2010-01-29 01:40:00 +01:00
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
value = 0xdeadbeef;
|
|
|
|
size = sizeof(DWORD);
|
|
|
|
ret = WinHttpQueryOption(req, WINHTTP_OPTION_SEND_TIMEOUT, &value, &size);
|
2010-01-29 02:11:57 +01:00
|
|
|
ok(ret, "%u\n", GetLastError());
|
|
|
|
ok(value == 0xdead, "Expected 0xdead, got %u\n", value);
|
2010-01-29 01:40:00 +01:00
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
value = 0xdeadbeef;
|
|
|
|
size = sizeof(DWORD);
|
|
|
|
ret = WinHttpQueryOption(req, WINHTTP_OPTION_RECEIVE_TIMEOUT, &value, &size);
|
2010-01-29 02:11:57 +01:00
|
|
|
ok(ret, "%u\n", GetLastError());
|
|
|
|
ok(value == 0xdead, "Expected 0xdead, got %u\n", value);
|
2010-01-29 01:40:00 +01:00
|
|
|
|
2010-01-27 23:01:29 +01:00
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = WinHttpSetTimeouts(req, -2, 0, 0, 0);
|
|
|
|
ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER,
|
|
|
|
"expected ERROR_INVALID_PARAMETER, got %u\n", GetLastError());
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = WinHttpSetTimeouts(req, 0, -2, 0, 0);
|
|
|
|
ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER,
|
|
|
|
"expected ERROR_INVALID_PARAMETER, got %u\n", GetLastError());
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = WinHttpSetTimeouts(req, 0, 0, -2, 0);
|
|
|
|
ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER,
|
|
|
|
"expected ERROR_INVALID_PARAMETER, got %u\n", GetLastError());
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = WinHttpSetTimeouts(req, 0, 0, 0, -2);
|
|
|
|
ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER,
|
|
|
|
"expected ERROR_INVALID_PARAMETER, got %u\n", GetLastError());
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = WinHttpSetTimeouts(req, -1, -1, -1, -1);
|
|
|
|
ok(ret, "%u\n", GetLastError());
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = WinHttpSetTimeouts(req, 0, 0, 0, 0);
|
|
|
|
ok(ret, "%u\n", GetLastError());
|
|
|
|
|
2010-01-29 01:40:00 +01:00
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = WinHttpSetTimeouts(req, 0xcdef, 0x89ab, 0x4567, 0x0123);
|
|
|
|
ok(ret, "%u\n", GetLastError());
|
|
|
|
|
2010-02-22 12:27:30 +01:00
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
value = 0xdeadbeef;
|
|
|
|
size = sizeof(DWORD);
|
|
|
|
ret = WinHttpQueryOption(req, WINHTTP_OPTION_RESOLVE_TIMEOUT, &value, &size);
|
|
|
|
ok(ret, "%u\n", GetLastError());
|
|
|
|
ok(value == 0xcdef, "Expected 0xcdef, got %u\n", value);
|
|
|
|
|
2010-01-29 01:40:00 +01:00
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
value = 0xdeadbeef;
|
|
|
|
size = sizeof(DWORD);
|
|
|
|
ret = WinHttpQueryOption(req, WINHTTP_OPTION_CONNECT_TIMEOUT, &value, &size);
|
2010-01-29 02:11:57 +01:00
|
|
|
ok(ret, "%u\n", GetLastError());
|
|
|
|
ok(value == 0x89ab, "Expected 0x89ab, got %u\n", value);
|
2010-01-29 01:40:00 +01:00
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
value = 0xdeadbeef;
|
|
|
|
size = sizeof(DWORD);
|
|
|
|
ret = WinHttpQueryOption(req, WINHTTP_OPTION_SEND_TIMEOUT, &value, &size);
|
2010-01-29 02:11:57 +01:00
|
|
|
ok(ret, "%u\n", GetLastError());
|
|
|
|
ok(value == 0x4567, "Expected 0x4567, got %u\n", value);
|
2010-01-29 01:40:00 +01:00
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
value = 0xdeadbeef;
|
|
|
|
size = sizeof(DWORD);
|
|
|
|
ret = WinHttpQueryOption(req, WINHTTP_OPTION_RECEIVE_TIMEOUT, &value, &size);
|
2010-01-29 02:11:57 +01:00
|
|
|
ok(ret, "%u\n", GetLastError());
|
|
|
|
ok(value == 0x0123, "Expected 0x0123, got %u\n", value);
|
2010-01-29 01:40:00 +01:00
|
|
|
|
2010-02-22 12:27:30 +01:00
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
value = 0;
|
|
|
|
ret = WinHttpSetOption(req, WINHTTP_OPTION_RESOLVE_TIMEOUT, &value, sizeof(value));
|
|
|
|
ok(ret, "%u\n", GetLastError());
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
value = 0xdeadbeef;
|
|
|
|
size = sizeof(DWORD);
|
|
|
|
ret = WinHttpQueryOption(req, WINHTTP_OPTION_RESOLVE_TIMEOUT, &value, &size);
|
|
|
|
ok(ret, "%u\n", GetLastError());
|
|
|
|
ok(value == 0, "Expected 0, got %u\n", value);
|
|
|
|
|
2010-01-29 01:40:00 +01:00
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
value = 0;
|
|
|
|
ret = WinHttpSetOption(req, WINHTTP_OPTION_CONNECT_TIMEOUT, &value, sizeof(value));
|
|
|
|
ok(ret, "%u\n", GetLastError());
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
value = 0xdeadbeef;
|
|
|
|
size = sizeof(DWORD);
|
|
|
|
ret = WinHttpQueryOption(req, WINHTTP_OPTION_CONNECT_TIMEOUT, &value, &size);
|
2010-01-29 02:11:57 +01:00
|
|
|
ok(ret, "%u\n", GetLastError());
|
|
|
|
ok(value == 0, "Expected 0, got %u\n", value);
|
2010-01-29 01:40:00 +01:00
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
value = 0;
|
|
|
|
ret = WinHttpSetOption(req, WINHTTP_OPTION_SEND_TIMEOUT, &value, sizeof(value));
|
|
|
|
ok(ret, "%u\n", GetLastError());
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
value = 0xdeadbeef;
|
|
|
|
size = sizeof(DWORD);
|
|
|
|
ret = WinHttpQueryOption(req, WINHTTP_OPTION_SEND_TIMEOUT, &value, &size);
|
2010-01-29 02:11:57 +01:00
|
|
|
ok(ret, "%u\n", GetLastError());
|
|
|
|
ok(value == 0, "Expected 0, got %u\n", value);
|
2010-01-29 01:40:00 +01:00
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
value = 0;
|
|
|
|
ret = WinHttpSetOption(req, WINHTTP_OPTION_RECEIVE_TIMEOUT, &value, sizeof(value));
|
|
|
|
ok(ret, "%u\n", GetLastError());
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
value = 0xdeadbeef;
|
|
|
|
size = sizeof(DWORD);
|
|
|
|
ret = WinHttpQueryOption(req, WINHTTP_OPTION_RECEIVE_TIMEOUT, &value, &size);
|
2010-01-29 02:11:57 +01:00
|
|
|
ok(ret, "%u\n", GetLastError());
|
|
|
|
ok(value == 0, "Expected 0, got %u\n", value);
|
2010-01-29 01:40:00 +01:00
|
|
|
|
2010-02-22 12:27:30 +01:00
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
value = 0xbeefdead;
|
|
|
|
ret = WinHttpSetOption(req, WINHTTP_OPTION_RESOLVE_TIMEOUT, &value, sizeof(value));
|
|
|
|
ok(ret, "%u\n", GetLastError());
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
value = 0xdeadbeef;
|
|
|
|
size = sizeof(DWORD);
|
|
|
|
ret = WinHttpQueryOption(req, WINHTTP_OPTION_RESOLVE_TIMEOUT, &value, &size);
|
|
|
|
ok(ret, "%u\n", GetLastError());
|
|
|
|
ok(value == 0xbeefdead, "Expected 0xbeefdead, got %u\n", value);
|
|
|
|
|
2010-01-29 01:40:00 +01:00
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
value = 0xbeefdead;
|
|
|
|
ret = WinHttpSetOption(req, WINHTTP_OPTION_CONNECT_TIMEOUT, &value, sizeof(value));
|
|
|
|
ok(ret, "%u\n", GetLastError());
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
value = 0xdeadbeef;
|
|
|
|
size = sizeof(DWORD);
|
|
|
|
ret = WinHttpQueryOption(req, WINHTTP_OPTION_CONNECT_TIMEOUT, &value, &size);
|
2010-01-29 02:11:57 +01:00
|
|
|
ok(ret, "%u\n", GetLastError());
|
|
|
|
ok(value == 0xbeefdead, "Expected 0xbeefdead, got %u\n", value);
|
2010-01-29 01:40:00 +01:00
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
value = 0xbeefdead;
|
|
|
|
ret = WinHttpSetOption(req, WINHTTP_OPTION_SEND_TIMEOUT, &value, sizeof(value));
|
|
|
|
ok(ret, "%u\n", GetLastError());
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
value = 0xdeadbeef;
|
|
|
|
size = sizeof(DWORD);
|
|
|
|
ret = WinHttpQueryOption(req, WINHTTP_OPTION_SEND_TIMEOUT, &value, &size);
|
2010-01-29 02:11:57 +01:00
|
|
|
ok(ret, "%u\n", GetLastError());
|
|
|
|
ok(value == 0xbeefdead, "Expected 0xbeefdead, got %u\n", value);
|
2010-01-29 01:40:00 +01:00
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
value = 0xbeefdead;
|
|
|
|
ret = WinHttpSetOption(req, WINHTTP_OPTION_RECEIVE_TIMEOUT, &value, sizeof(value));
|
|
|
|
ok(ret, "%u\n", GetLastError());
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
value = 0xdeadbeef;
|
|
|
|
size = sizeof(DWORD);
|
|
|
|
ret = WinHttpQueryOption(req, WINHTTP_OPTION_RECEIVE_TIMEOUT, &value, &size);
|
2010-01-29 02:11:57 +01:00
|
|
|
ok(ret, "%u\n", GetLastError());
|
|
|
|
ok(value == 0xbeefdead, "Expected 0xbeefdead, got %u\n", value);
|
2010-01-29 01:40:00 +01:00
|
|
|
|
|
|
|
/* Changing timeout values for session should not affect the values for a request,
|
|
|
|
* neither should the other way around.
|
|
|
|
*/
|
2010-02-22 12:27:30 +01:00
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
value = 0xbeefdead;
|
|
|
|
ret = WinHttpSetOption(req, WINHTTP_OPTION_RESOLVE_TIMEOUT, &value, sizeof(value));
|
|
|
|
ok(ret, "%u\n", GetLastError());
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
value = 0xdeadbeef;
|
|
|
|
size = sizeof(DWORD);
|
|
|
|
ret = WinHttpQueryOption(ses, WINHTTP_OPTION_RESOLVE_TIMEOUT, &value, &size);
|
|
|
|
ok(ret, "%u\n", GetLastError());
|
|
|
|
ok(value == 0xdead, "Expected 0xdead, got %u\n", value);
|
|
|
|
|
2010-01-29 01:40:00 +01:00
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
value = 0xbeefdead;
|
|
|
|
ret = WinHttpSetOption(req, WINHTTP_OPTION_CONNECT_TIMEOUT, &value, sizeof(value));
|
|
|
|
ok(ret, "%u\n", GetLastError());
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
value = 0xdeadbeef;
|
|
|
|
size = sizeof(DWORD);
|
|
|
|
ret = WinHttpQueryOption(ses, WINHTTP_OPTION_CONNECT_TIMEOUT, &value, &size);
|
2010-01-29 02:11:57 +01:00
|
|
|
ok(ret, "%u\n", GetLastError());
|
|
|
|
ok(value == 0xdead, "Expected 0xdead, got %u\n", value);
|
2010-01-29 01:40:00 +01:00
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
value = 0xbeefdead;
|
|
|
|
ret = WinHttpSetOption(req, WINHTTP_OPTION_SEND_TIMEOUT, &value, sizeof(value));
|
|
|
|
ok(ret, "%u\n", GetLastError());
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
value = 0xdeadbeef;
|
|
|
|
size = sizeof(DWORD);
|
|
|
|
ret = WinHttpQueryOption(ses, WINHTTP_OPTION_SEND_TIMEOUT, &value, &size);
|
2010-01-29 02:11:57 +01:00
|
|
|
ok(ret, "%u\n", GetLastError());
|
|
|
|
ok(value == 0xdead, "Expected 0xdead, got %u\n", value);
|
2010-01-29 01:40:00 +01:00
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
value = 0xbeefdead;
|
|
|
|
ret = WinHttpSetOption(req, WINHTTP_OPTION_RECEIVE_TIMEOUT, &value, sizeof(value));
|
|
|
|
ok(ret, "%u\n", GetLastError());
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
value = 0xdeadbeef;
|
|
|
|
size = sizeof(DWORD);
|
|
|
|
ret = WinHttpQueryOption(ses, WINHTTP_OPTION_RECEIVE_TIMEOUT, &value, &size);
|
2010-01-29 02:11:57 +01:00
|
|
|
ok(ret, "%u\n", GetLastError());
|
|
|
|
ok(value == 0xdead, "Expected 0xdead, got %u\n", value);
|
2010-01-29 01:40:00 +01:00
|
|
|
|
2010-02-22 12:27:30 +01:00
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
value = 0xbeef;
|
|
|
|
ret = WinHttpSetOption(ses, WINHTTP_OPTION_RESOLVE_TIMEOUT, &value, sizeof(value));
|
|
|
|
ok(ret, "%u\n", GetLastError());
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
value = 0xdeadbeef;
|
|
|
|
size = sizeof(DWORD);
|
|
|
|
ret = WinHttpQueryOption(req, WINHTTP_OPTION_RESOLVE_TIMEOUT, &value, &size);
|
|
|
|
ok(ret, "%u\n", GetLastError());
|
|
|
|
ok(value == 0xbeefdead, "Expected 0xbeefdead, got %u\n", value);
|
|
|
|
|
2010-01-29 01:40:00 +01:00
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
value = 0xbeef;
|
|
|
|
ret = WinHttpSetOption(ses, WINHTTP_OPTION_CONNECT_TIMEOUT, &value, sizeof(value));
|
2010-01-29 02:11:57 +01:00
|
|
|
ok(ret, "%u\n", GetLastError());
|
2010-01-29 01:40:00 +01:00
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
value = 0xdeadbeef;
|
|
|
|
size = sizeof(DWORD);
|
|
|
|
ret = WinHttpQueryOption(req, WINHTTP_OPTION_CONNECT_TIMEOUT, &value, &size);
|
2010-01-29 02:11:57 +01:00
|
|
|
ok(ret, "%u\n", GetLastError());
|
|
|
|
ok(value == 0xbeefdead, "Expected 0xbeefdead, got %u\n", value);
|
2010-01-29 01:40:00 +01:00
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
value = 0xbeef;
|
|
|
|
ret = WinHttpSetOption(ses, WINHTTP_OPTION_SEND_TIMEOUT, &value, sizeof(value));
|
2010-01-29 02:11:57 +01:00
|
|
|
ok(ret, "%u\n", GetLastError());
|
2010-01-29 01:40:00 +01:00
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
value = 0xdeadbeef;
|
|
|
|
size = sizeof(DWORD);
|
|
|
|
ret = WinHttpQueryOption(req, WINHTTP_OPTION_SEND_TIMEOUT, &value, &size);
|
2010-01-29 02:11:57 +01:00
|
|
|
ok(ret, "%u\n", GetLastError());
|
|
|
|
ok(value == 0xbeefdead, "Expected 0xbeefdead, got %u\n", value);
|
2010-01-29 01:40:00 +01:00
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
value = 0xbeef;
|
|
|
|
ret = WinHttpSetOption(ses, WINHTTP_OPTION_RECEIVE_TIMEOUT, &value, sizeof(value));
|
2010-01-29 02:11:57 +01:00
|
|
|
ok(ret, "%u\n", GetLastError());
|
2010-01-29 01:40:00 +01:00
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
value = 0xdeadbeef;
|
|
|
|
size = sizeof(DWORD);
|
|
|
|
ret = WinHttpQueryOption(req, WINHTTP_OPTION_RECEIVE_TIMEOUT, &value, &size);
|
2010-01-29 02:11:57 +01:00
|
|
|
ok(ret, "%u\n", GetLastError());
|
|
|
|
ok(value == 0xbeefdead, "Expected 0xbeefdead, got %u\n", value);
|
2010-01-29 01:40:00 +01:00
|
|
|
|
2018-09-10 13:24:34 +02:00
|
|
|
/* response timeout */
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
value = 0xdeadbeef;
|
|
|
|
size = sizeof(value);
|
|
|
|
ret = WinHttpQueryOption(req, WINHTTP_OPTION_RECEIVE_RESPONSE_TIMEOUT, &value, &size);
|
|
|
|
ok(ret, "%u\n", GetLastError());
|
|
|
|
ok(value == ~0u, "got %u\n", value);
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
value = 30000;
|
|
|
|
ret = WinHttpSetOption(req, WINHTTP_OPTION_RECEIVE_RESPONSE_TIMEOUT, &value, sizeof(value));
|
|
|
|
ok(ret, "%u\n", GetLastError());
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
value = 0xdeadbeef;
|
|
|
|
size = sizeof(value);
|
|
|
|
ret = WinHttpQueryOption(req, WINHTTP_OPTION_RECEIVE_RESPONSE_TIMEOUT, &value, &size);
|
|
|
|
ok(ret, "%u\n", GetLastError());
|
|
|
|
todo_wine ok(value == 0xbeefdead, "got %u\n", value);
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
value = 0xdeadbeef;
|
|
|
|
size = sizeof(value);
|
|
|
|
ret = WinHttpQueryOption(con, WINHTTP_OPTION_RECEIVE_RESPONSE_TIMEOUT, &value, &size);
|
|
|
|
ok(ret, "%u\n", GetLastError());
|
|
|
|
ok(value == ~0u, "got %u\n", value);
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
value = 30000;
|
|
|
|
ret = WinHttpSetOption(con, WINHTTP_OPTION_RECEIVE_RESPONSE_TIMEOUT, &value, sizeof(value));
|
|
|
|
ok(!ret, "expected failure\n");
|
|
|
|
ok(GetLastError() == ERROR_WINHTTP_INCORRECT_HANDLE_TYPE, "got %u\n", GetLastError());
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
value = 0xdeadbeef;
|
|
|
|
size = sizeof(value);
|
|
|
|
ret = WinHttpQueryOption(ses, WINHTTP_OPTION_RECEIVE_RESPONSE_TIMEOUT, &value, &size);
|
|
|
|
ok(ret, "%u\n", GetLastError());
|
|
|
|
ok(value == ~0u, "got %u\n", value);
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
value = 48878;
|
|
|
|
ret = WinHttpSetOption(ses, WINHTTP_OPTION_RECEIVE_RESPONSE_TIMEOUT, &value, sizeof(value));
|
|
|
|
ok(ret, "%u\n", GetLastError());
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
value = 0xdeadbeef;
|
|
|
|
size = sizeof(value);
|
|
|
|
ret = WinHttpQueryOption(ses, WINHTTP_OPTION_RECEIVE_RESPONSE_TIMEOUT, &value, &size);
|
|
|
|
ok(ret, "%u\n", GetLastError());
|
|
|
|
todo_wine ok(value == 48879, "got %u\n", value);
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
value = 48880;
|
|
|
|
ret = WinHttpSetOption(ses, WINHTTP_OPTION_RECEIVE_RESPONSE_TIMEOUT, &value, sizeof(value));
|
|
|
|
ok(ret, "%u\n", GetLastError());
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
value = 0xdeadbeef;
|
|
|
|
size = sizeof(value);
|
|
|
|
ret = WinHttpQueryOption(ses, WINHTTP_OPTION_RECEIVE_RESPONSE_TIMEOUT, &value, &size);
|
|
|
|
ok(ret, "%u\n", GetLastError());
|
|
|
|
ok(value == 48880, "got %u\n", value);
|
|
|
|
|
2010-01-27 23:01:29 +01:00
|
|
|
WinHttpCloseHandle(req);
|
|
|
|
WinHttpCloseHandle(con);
|
|
|
|
WinHttpCloseHandle(ses);
|
|
|
|
}
|
|
|
|
|
2010-02-22 12:27:30 +01:00
|
|
|
static void test_resolve_timeout(void)
|
|
|
|
{
|
2010-04-22 16:35:56 +02:00
|
|
|
HINTERNET ses, con, req;
|
2010-02-22 12:27:30 +01:00
|
|
|
DWORD timeout;
|
|
|
|
BOOL ret;
|
|
|
|
|
2011-01-17 12:37:23 +01:00
|
|
|
if (! proxy_active())
|
|
|
|
{
|
2020-02-14 16:41:38 +01:00
|
|
|
ses = WinHttpOpen(L"winetest", 0, NULL, NULL, 0);
|
2011-01-17 12:37:23 +01:00
|
|
|
ok(ses != NULL, "failed to open session %u\n", GetLastError());
|
2010-02-22 12:27:30 +01:00
|
|
|
|
2011-01-17 12:37:23 +01:00
|
|
|
timeout = 10000;
|
|
|
|
ret = WinHttpSetOption(ses, WINHTTP_OPTION_RESOLVE_TIMEOUT, &timeout, sizeof(timeout));
|
|
|
|
ok(ret, "failed to set resolve timeout %u\n", GetLastError());
|
2010-02-22 12:27:30 +01:00
|
|
|
|
2020-02-14 16:41:38 +01:00
|
|
|
con = WinHttpConnect(ses, L"nxdomain.winehq.org", 0, 0);
|
2011-01-17 12:37:23 +01:00
|
|
|
ok(con != NULL, "failed to open a connection %u\n", GetLastError());
|
2010-02-22 12:27:30 +01:00
|
|
|
|
2011-01-17 12:37:23 +01:00
|
|
|
req = WinHttpOpenRequest(con, NULL, NULL, NULL, NULL, NULL, 0);
|
|
|
|
ok(req != NULL, "failed to open a request %u\n", GetLastError());
|
2010-02-22 12:27:30 +01:00
|
|
|
|
2011-01-17 12:37:23 +01:00
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = WinHttpSendRequest(req, NULL, 0, NULL, 0, 0, 0);
|
2014-09-01 14:48:49 +02:00
|
|
|
if (ret)
|
2014-03-22 22:34:26 +01:00
|
|
|
{
|
|
|
|
skip("nxdomain returned success. Broken ISP redirects?\n");
|
2014-09-01 14:48:49 +02:00
|
|
|
goto done;
|
2014-03-22 22:34:26 +01:00
|
|
|
}
|
2011-01-17 12:37:23 +01:00
|
|
|
ok(GetLastError() == ERROR_WINHTTP_NAME_NOT_RESOLVED,
|
|
|
|
"expected ERROR_WINHTTP_NAME_NOT_RESOLVED got %u\n", GetLastError());
|
|
|
|
|
2018-11-22 21:15:57 +01:00
|
|
|
ret = WinHttpReceiveResponse( req, NULL );
|
|
|
|
ok( !ret && (GetLastError() == ERROR_WINHTTP_INCORRECT_HANDLE_STATE ||
|
|
|
|
GetLastError() == ERROR_WINHTTP_OPERATION_CANCELLED /* < win7 */),
|
|
|
|
"got %u\n", GetLastError() );
|
|
|
|
|
2011-01-17 12:37:23 +01:00
|
|
|
WinHttpCloseHandle(req);
|
|
|
|
WinHttpCloseHandle(con);
|
|
|
|
WinHttpCloseHandle(ses);
|
|
|
|
}
|
|
|
|
else
|
2019-12-09 09:46:50 +01:00
|
|
|
skip("Skipping host resolution tests, host resolution performed by proxy\n");
|
2010-02-22 12:27:30 +01:00
|
|
|
|
2020-02-14 16:41:38 +01:00
|
|
|
ses = WinHttpOpen(L"winetest", 0, NULL, NULL, 0);
|
2010-02-22 12:27:30 +01:00
|
|
|
ok(ses != NULL, "failed to open session %u\n", GetLastError());
|
|
|
|
|
|
|
|
timeout = 10000;
|
|
|
|
ret = WinHttpSetOption(ses, WINHTTP_OPTION_RESOLVE_TIMEOUT, &timeout, sizeof(timeout));
|
|
|
|
ok(ret, "failed to set resolve timeout %u\n", GetLastError());
|
|
|
|
|
2020-02-14 16:41:38 +01:00
|
|
|
con = WinHttpConnect(ses, L"test.winehq.org", 0, 0);
|
2010-02-22 12:27:30 +01:00
|
|
|
ok(con != NULL, "failed to open a connection %u\n", GetLastError());
|
|
|
|
|
|
|
|
req = WinHttpOpenRequest(con, NULL, NULL, NULL, NULL, NULL, 0);
|
|
|
|
ok(req != NULL, "failed to open a request %u\n", GetLastError());
|
|
|
|
|
|
|
|
ret = WinHttpSendRequest(req, NULL, 0, NULL, 0, 0, 0);
|
2014-09-01 14:48:49 +02:00
|
|
|
if (!ret && GetLastError() == ERROR_WINHTTP_CANNOT_CONNECT)
|
|
|
|
{
|
|
|
|
skip("connection failed, skipping\n");
|
|
|
|
goto done;
|
|
|
|
}
|
2010-02-22 12:27:30 +01:00
|
|
|
ok(ret, "failed to send request\n");
|
|
|
|
|
2014-09-01 14:48:49 +02:00
|
|
|
done:
|
2010-02-22 12:27:30 +01:00
|
|
|
WinHttpCloseHandle(req);
|
|
|
|
WinHttpCloseHandle(con);
|
|
|
|
WinHttpCloseHandle(ses);
|
|
|
|
}
|
|
|
|
|
2010-04-22 16:35:28 +02:00
|
|
|
static const char page1[] =
|
|
|
|
"<HTML>\r\n"
|
|
|
|
"<HEAD><TITLE>winhttp test page</TITLE></HEAD>\r\n"
|
|
|
|
"<BODY>The quick brown fox jumped over the lazy dog<P></BODY>\r\n"
|
|
|
|
"</HTML>\r\n\r\n";
|
|
|
|
|
|
|
|
static const char okmsg[] =
|
|
|
|
"HTTP/1.1 200 OK\r\n"
|
|
|
|
"Server: winetest\r\n"
|
|
|
|
"\r\n";
|
|
|
|
|
2015-06-15 17:32:25 +02:00
|
|
|
static const char notokmsg[] =
|
|
|
|
"HTTP/1.1 400 Bad Request\r\n"
|
|
|
|
"\r\n";
|
|
|
|
|
|
|
|
static const char cookiemsg[] =
|
|
|
|
"HTTP/1.1 200 OK\r\n"
|
|
|
|
"Set-Cookie: name = value \r\n"
|
2015-06-24 14:17:53 +02:00
|
|
|
"Set-Cookie: NAME = value \r\n"
|
2015-06-15 17:32:25 +02:00
|
|
|
"\r\n";
|
|
|
|
|
2017-02-21 09:24:37 +01:00
|
|
|
static const char cookiemsg2[] =
|
|
|
|
"HTTP/1.1 200 OK\r\n"
|
|
|
|
"Set-Cookie: name2=value; Domain = localhost; Path=/cookie5;Expires=Wed, 13 Jan 2021 22:23:01 GMT; HttpOnly; \r\n"
|
|
|
|
"\r\n";
|
|
|
|
|
2014-07-30 18:31:17 +02:00
|
|
|
static const char nocontentmsg[] =
|
|
|
|
"HTTP/1.1 204 No Content\r\n"
|
|
|
|
"Server: winetest\r\n"
|
|
|
|
"\r\n";
|
|
|
|
|
2014-12-09 12:50:07 +01:00
|
|
|
static const char notmodified[] =
|
|
|
|
"HTTP/1.1 304 Not Modified\r\n"
|
|
|
|
"\r\n";
|
|
|
|
|
2010-04-22 16:35:28 +02:00
|
|
|
static const char noauthmsg[] =
|
|
|
|
"HTTP/1.1 401 Unauthorized\r\n"
|
|
|
|
"Server: winetest\r\n"
|
|
|
|
"Connection: close\r\n"
|
|
|
|
"WWW-Authenticate: Basic realm=\"placebo\"\r\n"
|
2015-12-08 00:02:08 +01:00
|
|
|
"Content-Length: 12\r\n"
|
|
|
|
"Content-Type: text/plain\r\n"
|
2010-04-22 16:35:28 +02:00
|
|
|
"\r\n";
|
|
|
|
|
2014-12-09 12:50:41 +01:00
|
|
|
static const char okauthmsg[] =
|
|
|
|
"HTTP/1.1 200 OK\r\n"
|
|
|
|
"Server: winetest\r\n"
|
|
|
|
"Connection: close\r\n"
|
2015-12-08 00:02:08 +01:00
|
|
|
"Content-Length: 11\r\n"
|
|
|
|
"Content-Type: text/plain\r\n"
|
2014-12-09 12:50:41 +01:00
|
|
|
"\r\n";
|
|
|
|
|
2015-01-21 13:25:18 +01:00
|
|
|
static const char headmsg[] =
|
|
|
|
"HTTP/1.1 200 OK\r\n"
|
|
|
|
"Content-Length: 100\r\n"
|
|
|
|
"\r\n";
|
|
|
|
|
2017-04-05 11:20:54 +02:00
|
|
|
static const char multiauth[] =
|
|
|
|
"HTTP/1.1 401 Unauthorized\r\n"
|
|
|
|
"Server: winetest\r\n"
|
|
|
|
"WWW-Authenticate: Bearer\r\n"
|
|
|
|
"WWW-Authenticate: Basic realm=\"placebo\"\r\n"
|
|
|
|
"WWW-Authenticate: NTLM\r\n"
|
|
|
|
"Content-Length: 10\r\n"
|
|
|
|
"Content-Type: text/plain\r\n"
|
|
|
|
"\r\n";
|
|
|
|
|
2017-04-12 10:46:34 +02:00
|
|
|
static const char largeauth[] =
|
|
|
|
"HTTP/1.1 401 Unauthorized\r\n"
|
|
|
|
"Server: winetest\r\n"
|
|
|
|
"WWW-Authenticate: Basic realm=\"placebo\"\r\n"
|
|
|
|
"WWW-Authenticate: NTLM\r\n"
|
|
|
|
"Content-Length: 10240\r\n"
|
|
|
|
"Content-Type: text/plain\r\n"
|
|
|
|
"\r\n";
|
|
|
|
|
2019-08-02 11:01:37 +02:00
|
|
|
static const char passportauth[] =
|
|
|
|
"HTTP/1.1 302 Found\r\n"
|
|
|
|
"Content-Length: 0\r\n"
|
|
|
|
"Location: /\r\n"
|
|
|
|
"WWW-Authenticate: Passport1.4\r\n"
|
|
|
|
"\r\n";
|
|
|
|
|
2020-06-16 11:45:12 +02:00
|
|
|
static const char switchprotocols[] =
|
|
|
|
"HTTP/1.1 101 Switching Protocols\r\n"
|
|
|
|
"Server: winetest\r\n"
|
|
|
|
"Upgrade: websocket\r\n"
|
|
|
|
"Connection: Upgrade\r\n";
|
|
|
|
|
2015-12-08 00:02:08 +01:00
|
|
|
static const char unauthorized[] = "Unauthorized";
|
|
|
|
static const char hello_world[] = "Hello World";
|
2017-10-02 10:47:27 +02:00
|
|
|
static const char auth_unseen[] = "Auth Unseen";
|
2015-12-08 00:02:08 +01:00
|
|
|
|
2010-04-22 16:35:28 +02:00
|
|
|
struct server_info
|
|
|
|
{
|
|
|
|
HANDLE event;
|
|
|
|
int port;
|
|
|
|
};
|
|
|
|
|
2013-10-14 21:36:05 +02:00
|
|
|
#define BIG_BUFFER_LEN 0x2250
|
|
|
|
|
2020-06-16 11:45:12 +02:00
|
|
|
static void create_websocket_accept(const char *key, char *buf, unsigned int buflen)
|
|
|
|
{
|
|
|
|
HCRYPTPROV provider;
|
|
|
|
HCRYPTHASH hash;
|
|
|
|
BYTE sha1[20];
|
|
|
|
char data[128];
|
|
|
|
DWORD len;
|
|
|
|
|
|
|
|
strcpy(data, key);
|
|
|
|
strcat(data, "258EAFA5-E914-47DA-95CA-C5AB0DC85B11");
|
|
|
|
|
|
|
|
CryptAcquireContextW(&provider, NULL, NULL, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT);
|
|
|
|
CryptCreateHash(provider, CALG_SHA1, 0, 0, &hash);
|
|
|
|
CryptHashData(hash, (BYTE *)data, strlen(data), 0);
|
|
|
|
|
|
|
|
len = sizeof(sha1);
|
|
|
|
CryptGetHashParam(hash, HP_HASHVAL, sha1, &len, 0);
|
|
|
|
CryptDestroyHash(hash);
|
|
|
|
CryptReleaseContext(provider, 0);
|
|
|
|
|
|
|
|
buf[0] = 0;
|
|
|
|
len = buflen;
|
|
|
|
CryptBinaryToStringA( (BYTE *)sha1, sizeof(sha1), CRYPT_STRING_BASE64, buf, &len);
|
|
|
|
}
|
|
|
|
|
2010-04-22 16:35:28 +02:00
|
|
|
static DWORD CALLBACK server_thread(LPVOID param)
|
|
|
|
{
|
|
|
|
struct server_info *si = param;
|
2015-01-21 13:24:52 +01:00
|
|
|
int r, c = -1, i, on;
|
2010-04-22 16:35:28 +02:00
|
|
|
SOCKET s;
|
|
|
|
struct sockaddr_in sa;
|
|
|
|
char buffer[0x100];
|
|
|
|
WSADATA wsaData;
|
|
|
|
int last_request = 0;
|
|
|
|
|
|
|
|
WSAStartup(MAKEWORD(1,1), &wsaData);
|
|
|
|
|
|
|
|
s = socket(AF_INET, SOCK_STREAM, 0);
|
|
|
|
if (s == INVALID_SOCKET)
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
on = 1;
|
|
|
|
setsockopt(s, SOL_SOCKET, SO_REUSEADDR, (char*)&on, sizeof on);
|
|
|
|
|
|
|
|
memset(&sa, 0, sizeof sa);
|
|
|
|
sa.sin_family = AF_INET;
|
|
|
|
sa.sin_port = htons(si->port);
|
|
|
|
sa.sin_addr.S_un.S_addr = inet_addr("127.0.0.1");
|
|
|
|
|
|
|
|
r = bind(s, (struct sockaddr *)&sa, sizeof(sa));
|
|
|
|
if (r < 0)
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
listen(s, 0);
|
|
|
|
SetEvent(si->event);
|
|
|
|
do
|
|
|
|
{
|
2015-01-21 13:24:52 +01:00
|
|
|
if (c == -1) c = accept(s, NULL, NULL);
|
2010-04-22 16:35:28 +02:00
|
|
|
|
|
|
|
memset(buffer, 0, sizeof buffer);
|
|
|
|
for(i = 0; i < sizeof buffer - 1; i++)
|
|
|
|
{
|
|
|
|
r = recv(c, &buffer[i], 1, 0);
|
|
|
|
if (r != 1)
|
|
|
|
break;
|
|
|
|
if (i < 4) continue;
|
|
|
|
if (buffer[i - 2] == '\n' && buffer[i] == '\n' &&
|
|
|
|
buffer[i - 3] == '\r' && buffer[i - 1] == '\r')
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (strstr(buffer, "GET /basic"))
|
|
|
|
{
|
|
|
|
send(c, okmsg, sizeof okmsg - 1, 0);
|
|
|
|
send(c, page1, sizeof page1 - 1, 0);
|
|
|
|
}
|
2017-10-02 10:47:27 +02:00
|
|
|
if (strstr(buffer, "/auth_with_creds"))
|
|
|
|
{
|
|
|
|
send(c, okauthmsg, sizeof okauthmsg - 1, 0);
|
|
|
|
if (strstr(buffer, "Authorization: Basic dXNlcjpwd2Q="))
|
|
|
|
send(c, hello_world, sizeof hello_world - 1, 0);
|
|
|
|
else
|
|
|
|
send(c, auth_unseen, sizeof auth_unseen - 1, 0);
|
|
|
|
continue;
|
|
|
|
}
|
2010-04-22 16:35:28 +02:00
|
|
|
if (strstr(buffer, "/auth"))
|
|
|
|
{
|
|
|
|
if (strstr(buffer, "Authorization: Basic dXNlcjpwd2Q="))
|
2015-12-08 00:02:08 +01:00
|
|
|
{
|
2014-12-09 12:50:41 +01:00
|
|
|
send(c, okauthmsg, sizeof okauthmsg - 1, 0);
|
2015-12-08 00:02:08 +01:00
|
|
|
send(c, hello_world, sizeof hello_world - 1, 0);
|
|
|
|
}
|
2010-04-22 16:35:28 +02:00
|
|
|
else
|
2015-12-08 00:02:08 +01:00
|
|
|
{
|
2010-04-22 16:35:28 +02:00
|
|
|
send(c, noauthmsg, sizeof noauthmsg - 1, 0);
|
2015-12-08 00:02:08 +01:00
|
|
|
send(c, unauthorized, sizeof unauthorized - 1, 0);
|
|
|
|
}
|
2015-12-10 14:54:30 +01:00
|
|
|
continue;
|
2010-04-22 16:35:28 +02:00
|
|
|
}
|
2013-10-14 21:36:05 +02:00
|
|
|
if (strstr(buffer, "/big"))
|
|
|
|
{
|
|
|
|
char msg[BIG_BUFFER_LEN];
|
|
|
|
memset(msg, 'm', sizeof(msg));
|
|
|
|
send(c, okmsg, sizeof(okmsg) - 1, 0);
|
|
|
|
send(c, msg, sizeof(msg), 0);
|
|
|
|
}
|
2010-04-22 16:35:28 +02:00
|
|
|
if (strstr(buffer, "/no_headers"))
|
|
|
|
{
|
|
|
|
send(c, page1, sizeof page1 - 1, 0);
|
|
|
|
}
|
2014-07-30 18:31:17 +02:00
|
|
|
if (strstr(buffer, "GET /no_content"))
|
|
|
|
{
|
|
|
|
send(c, nocontentmsg, sizeof nocontentmsg - 1, 0);
|
2015-01-21 13:24:52 +01:00
|
|
|
continue;
|
2014-07-30 18:31:17 +02:00
|
|
|
}
|
2014-12-09 12:50:07 +01:00
|
|
|
if (strstr(buffer, "GET /not_modified"))
|
|
|
|
{
|
2015-06-17 15:11:50 +02:00
|
|
|
if (strstr(buffer, "If-Modified-Since:")) send(c, notmodified, sizeof notmodified - 1, 0);
|
|
|
|
else send(c, notokmsg, sizeof(notokmsg) - 1, 0);
|
2015-01-21 13:24:52 +01:00
|
|
|
continue;
|
2014-12-09 12:50:07 +01:00
|
|
|
}
|
2015-01-21 13:25:18 +01:00
|
|
|
if (strstr(buffer, "HEAD /head"))
|
|
|
|
{
|
|
|
|
send(c, headmsg, sizeof headmsg - 1, 0);
|
|
|
|
continue;
|
|
|
|
}
|
2017-04-12 10:46:34 +02:00
|
|
|
if (strstr(buffer, "GET /multiauth"))
|
|
|
|
{
|
|
|
|
send(c, multiauth, sizeof multiauth - 1, 0);
|
|
|
|
}
|
|
|
|
if (strstr(buffer, "GET /largeauth"))
|
|
|
|
{
|
|
|
|
if (strstr(buffer, "Authorization: NTLM"))
|
|
|
|
send(c, okmsg, sizeof(okmsg) - 1, 0);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
send(c, largeauth, sizeof largeauth - 1, 0);
|
|
|
|
for (i = 0; i < 10240; i++) send(c, "A", 1, 0);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
2017-02-21 09:24:37 +01:00
|
|
|
if (strstr(buffer, "GET /cookie5"))
|
|
|
|
{
|
|
|
|
if (strstr(buffer, "Cookie: name2=value\r\n"))
|
|
|
|
send(c, okmsg, sizeof(okmsg) - 1, 0);
|
|
|
|
else
|
|
|
|
send(c, notokmsg, sizeof(notokmsg) - 1, 0);
|
|
|
|
}
|
|
|
|
if (strstr(buffer, "GET /cookie4"))
|
|
|
|
{
|
|
|
|
send(c, cookiemsg2, sizeof(cookiemsg2) - 1, 0);
|
|
|
|
}
|
2015-06-24 14:17:31 +02:00
|
|
|
if (strstr(buffer, "GET /cookie3"))
|
|
|
|
{
|
2015-06-24 14:17:53 +02:00
|
|
|
if (strstr(buffer, "Cookie: name=value2; NAME=value; name=value\r\n") ||
|
2015-06-24 14:18:27 +02:00
|
|
|
broken(strstr(buffer, "Cookie: name=value2; name=value; NAME=value\r\n") != NULL))
|
|
|
|
send(c, okmsg, sizeof(okmsg) - 1, 0);
|
|
|
|
else
|
|
|
|
send(c, notokmsg, sizeof(notokmsg) - 1, 0);
|
2015-06-24 14:17:31 +02:00
|
|
|
}
|
2015-06-15 17:32:25 +02:00
|
|
|
if (strstr(buffer, "GET /cookie2"))
|
|
|
|
{
|
2015-06-24 14:17:53 +02:00
|
|
|
if (strstr(buffer, "Cookie: NAME=value; name=value\r\n") ||
|
2015-06-24 14:18:27 +02:00
|
|
|
broken(strstr(buffer, "Cookie: name=value; NAME=value\r\n") != NULL))
|
|
|
|
send(c, okmsg, sizeof(okmsg) - 1, 0);
|
|
|
|
else
|
|
|
|
send(c, notokmsg, sizeof(notokmsg) - 1, 0);
|
2015-06-15 17:32:25 +02:00
|
|
|
}
|
|
|
|
else if (strstr(buffer, "GET /cookie"))
|
|
|
|
{
|
|
|
|
if (!strstr(buffer, "Cookie: name=value\r\n")) send(c, cookiemsg, sizeof(cookiemsg) - 1, 0);
|
|
|
|
else send(c, notokmsg, sizeof(notokmsg) - 1, 0);
|
|
|
|
}
|
2018-08-24 13:32:42 +02:00
|
|
|
else if (strstr(buffer, "GET /escape"))
|
|
|
|
{
|
2018-10-04 10:32:01 +02:00
|
|
|
static const char res[] = "%0D%0A%1F%7F%3C%20%one?%1F%7F%20!%22%23$%&'()*+,-./:;%3C=%3E?@%5B%5C%5D"
|
|
|
|
"%5E_%60%7B%7C%7D~%0D%0A ";
|
|
|
|
static const char res2[] = "%0D%0A%1F%7F%3C%20%25two?%1F%7F%20!%22%23$%25&'()*+,-./:;%3C=%3E?@%5B%5C%5D"
|
|
|
|
"%5E_%60%7B%7C%7D~%0D%0A ";
|
|
|
|
static const char res3[] = "\x1f\x7f<%20%three?\x1f\x7f%20!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~ ";
|
|
|
|
static const char res4[] = "%0D%0A%1F%7F%3C%20%four?\x1f\x7f%20!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~ ";
|
2018-11-06 16:09:04 +01:00
|
|
|
static const char res5[] = "&text=one%C2%80%7F~";
|
|
|
|
static const char res6[] = "&text=two%C2%80\x7f~";
|
|
|
|
static const char res7[] = "&text=%E5%90%9B%E3%81%AE%E5%90%8D%E3%81%AF";
|
2018-10-04 10:32:01 +02:00
|
|
|
|
|
|
|
if (strstr(buffer + 11, res) || strstr(buffer + 11, res2) || strstr(buffer + 11, res3) ||
|
2018-11-06 16:09:04 +01:00
|
|
|
strstr(buffer + 11, res4) || strstr(buffer + 11, res5) || strstr(buffer + 11, res6) ||
|
|
|
|
strstr(buffer + 11, res7))
|
|
|
|
{
|
|
|
|
send(c, okmsg, sizeof(okmsg) - 1, 0);
|
|
|
|
}
|
2018-08-24 13:32:42 +02:00
|
|
|
else send(c, notokmsg, sizeof(notokmsg) - 1, 0);
|
|
|
|
}
|
2019-08-02 11:01:37 +02:00
|
|
|
else if (strstr(buffer, "GET /passport"))
|
|
|
|
{
|
|
|
|
send(c, passportauth, sizeof(passportauth) - 1, 0);
|
|
|
|
}
|
2020-06-16 11:45:12 +02:00
|
|
|
else if (strstr(buffer, "GET /websocket"))
|
|
|
|
{
|
|
|
|
char headers[256], key[32], accept[64];
|
|
|
|
const char *pos = strstr(buffer, "Sec-WebSocket-Key: ");
|
|
|
|
if (pos && strstr(buffer, "Connection: Upgrade\r\n") &&
|
|
|
|
(strstr(buffer, "Upgrade: websocket\r\n") || strstr(buffer, "Upgrade: Websocket\r\n")) &&
|
|
|
|
strstr(buffer, "Host: ") && strstr(buffer, "Sec-WebSocket-Version: 13\r\n"))
|
|
|
|
{
|
|
|
|
memcpy(headers, switchprotocols, sizeof(switchprotocols));
|
|
|
|
memcpy(key, pos + 19, 24);
|
|
|
|
key[24] = 0;
|
|
|
|
|
|
|
|
create_websocket_accept(key, accept, sizeof(accept));
|
|
|
|
|
|
|
|
strcat(headers, "Sec-WebSocket-Accept: ");
|
|
|
|
strcat(headers, accept);
|
|
|
|
strcat(headers, "\r\n\r\n");
|
|
|
|
|
|
|
|
send(c, headers, strlen(headers), 0);
|
2020-06-24 10:33:10 +02:00
|
|
|
continue;
|
2020-06-16 11:45:12 +02:00
|
|
|
}
|
|
|
|
else send(c, notokmsg, sizeof(notokmsg) - 1, 0);
|
|
|
|
}
|
2010-04-22 16:35:28 +02:00
|
|
|
if (strstr(buffer, "GET /quit"))
|
|
|
|
{
|
|
|
|
send(c, okmsg, sizeof okmsg - 1, 0);
|
|
|
|
send(c, page1, sizeof page1 - 1, 0);
|
|
|
|
last_request = 1;
|
|
|
|
}
|
|
|
|
shutdown(c, 2);
|
|
|
|
closesocket(c);
|
2015-01-21 13:24:52 +01:00
|
|
|
c = -1;
|
2010-04-22 16:35:28 +02:00
|
|
|
|
|
|
|
} while (!last_request);
|
|
|
|
|
|
|
|
closesocket(s);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_basic_request(int port, const WCHAR *verb, const WCHAR *path)
|
|
|
|
{
|
|
|
|
HINTERNET ses, con, req;
|
|
|
|
char buffer[0x100];
|
2015-08-18 07:56:39 +02:00
|
|
|
WCHAR buffer2[0x100];
|
2013-08-19 15:52:44 +02:00
|
|
|
DWORD count, status, size, error, supported, first, target;
|
2010-04-22 16:35:28 +02:00
|
|
|
BOOL ret;
|
|
|
|
|
2020-02-14 16:41:38 +01:00
|
|
|
ses = WinHttpOpen(L"winetest", WINHTTP_ACCESS_TYPE_NO_PROXY, NULL, NULL, 0);
|
2010-04-22 16:35:28 +02:00
|
|
|
ok(ses != NULL, "failed to open session %u\n", GetLastError());
|
|
|
|
|
2018-05-03 13:30:21 +02:00
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = WinHttpSetOption(ses, 0, buffer, sizeof(buffer));
|
|
|
|
ok(!ret && GetLastError() == ERROR_WINHTTP_INVALID_OPTION, "got %u\n", GetLastError());
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = WinHttpQueryOption(ses, 0, buffer, &size);
|
|
|
|
ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, "got %u\n", GetLastError());
|
|
|
|
|
2020-02-14 16:41:38 +01:00
|
|
|
con = WinHttpConnect(ses, L"localhost", port, 0);
|
2010-04-22 16:35:28 +02:00
|
|
|
ok(con != NULL, "failed to open a connection %u\n", GetLastError());
|
|
|
|
|
2018-05-03 13:30:21 +02:00
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = WinHttpSetOption(con, 0, buffer, sizeof(buffer));
|
|
|
|
todo_wine ok(!ret && GetLastError() == ERROR_WINHTTP_INVALID_OPTION, "got %u\n", GetLastError());
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = WinHttpQueryOption(con, 0, buffer, &size);
|
|
|
|
ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, "got %u\n", GetLastError());
|
|
|
|
|
2010-04-22 16:35:28 +02:00
|
|
|
req = WinHttpOpenRequest(con, verb, path, NULL, NULL, NULL, 0);
|
|
|
|
ok(req != NULL, "failed to open a request %u\n", GetLastError());
|
|
|
|
|
2018-05-03 13:30:21 +02:00
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = WinHttpSetOption(req, 0, buffer, sizeof(buffer));
|
|
|
|
ok(!ret && GetLastError() == ERROR_WINHTTP_INVALID_OPTION, "got %u\n", GetLastError());
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = WinHttpQueryOption(req, 0, buffer, &size);
|
|
|
|
ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, "got %u\n", GetLastError());
|
|
|
|
|
2010-04-22 16:35:28 +02:00
|
|
|
ret = WinHttpSendRequest(req, NULL, 0, NULL, 0, 0, 0);
|
|
|
|
ok(ret, "failed to send request %u\n", GetLastError());
|
|
|
|
|
|
|
|
ret = WinHttpReceiveResponse(req, NULL);
|
|
|
|
ok(ret, "failed to receive response %u\n", GetLastError());
|
|
|
|
|
2015-04-21 11:21:06 +02:00
|
|
|
status = 0xdeadbeef;
|
2010-04-22 16:35:28 +02:00
|
|
|
size = sizeof(status);
|
|
|
|
ret = WinHttpQueryHeaders(req, WINHTTP_QUERY_STATUS_CODE|WINHTTP_QUERY_FLAG_NUMBER, NULL, &status, &size, NULL);
|
|
|
|
ok(ret, "failed to query status code %u\n", GetLastError());
|
2015-12-08 00:01:29 +01:00
|
|
|
ok(status == HTTP_STATUS_OK, "request failed unexpectedly %u\n", status);
|
2010-04-22 16:35:28 +02:00
|
|
|
|
2013-08-19 15:52:44 +02:00
|
|
|
supported = first = target = 0xdeadbeef;
|
|
|
|
SetLastError(0xdeadbeef);
|
2013-06-12 08:02:52 +02:00
|
|
|
ret = WinHttpQueryAuthSchemes(req, &supported, &first, &target);
|
2013-08-19 15:52:44 +02:00
|
|
|
error = GetLastError();
|
2013-06-12 08:02:52 +02:00
|
|
|
ok(!ret, "unexpected success\n");
|
2018-09-19 16:18:22 +02:00
|
|
|
ok(error == ERROR_INVALID_OPERATION, "expected ERROR_INVALID_OPERATION, got %u\n", error);
|
2013-08-19 15:52:44 +02:00
|
|
|
ok(supported == 0xdeadbeef, "got %x\n", supported);
|
|
|
|
ok(first == 0xdeadbeef, "got %x\n", first);
|
|
|
|
ok(target == 0xdeadbeef, "got %x\n", target);
|
2013-06-12 08:02:52 +02:00
|
|
|
|
2015-08-18 07:56:39 +02:00
|
|
|
size = sizeof(buffer2);
|
|
|
|
memset(buffer2, 0, sizeof(buffer2));
|
|
|
|
ret = WinHttpQueryHeaders(req, WINHTTP_QUERY_RAW_HEADERS_CRLF, NULL, buffer2, &size, NULL);
|
|
|
|
ok(ret, "failed to query for raw headers: %u\n", GetLastError());
|
2020-02-14 16:41:38 +01:00
|
|
|
ok(!memcmp(buffer2 + lstrlenW(buffer2) - 4, L"\r\n\r\n", sizeof(L"\r\n\r\n")),
|
2015-08-18 07:56:39 +02:00
|
|
|
"WinHttpQueryHeaders returned invalid end of header string\n");
|
|
|
|
|
|
|
|
size = sizeof(buffer2);
|
|
|
|
memset(buffer2, 0, sizeof(buffer2));
|
|
|
|
ret = WinHttpQueryHeaders(req, WINHTTP_QUERY_RAW_HEADERS, NULL, buffer2, &size, NULL);
|
|
|
|
ok(ret, "failed to query for raw headers: %u\n", GetLastError());
|
2020-02-14 16:41:38 +01:00
|
|
|
ok(!memcmp(buffer2 + (size / sizeof(WCHAR)) - 1, L"", sizeof(L"")),
|
2015-08-18 07:56:39 +02:00
|
|
|
"WinHttpQueryHeaders returned invalid end of header string\n");
|
|
|
|
ok(buffer2[(size / sizeof(WCHAR)) - 2] != 0, "returned string has too many NULL characters\n");
|
|
|
|
|
2010-04-22 16:35:28 +02:00
|
|
|
count = 0;
|
|
|
|
memset(buffer, 0, sizeof(buffer));
|
|
|
|
ret = WinHttpReadData(req, buffer, sizeof buffer, &count);
|
|
|
|
ok(ret, "failed to read data %u\n", GetLastError());
|
|
|
|
ok(count == sizeof page1 - 1, "count was wrong\n");
|
|
|
|
ok(!memcmp(buffer, page1, sizeof page1), "http data wrong\n");
|
|
|
|
|
|
|
|
WinHttpCloseHandle(req);
|
|
|
|
WinHttpCloseHandle(con);
|
|
|
|
WinHttpCloseHandle(ses);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_basic_authentication(int port)
|
|
|
|
{
|
|
|
|
HINTERNET ses, con, req;
|
2013-06-12 08:02:52 +02:00
|
|
|
DWORD status, size, error, supported, first, target;
|
2015-12-08 00:02:08 +01:00
|
|
|
char buffer[32];
|
2010-04-22 16:35:28 +02:00
|
|
|
BOOL ret;
|
|
|
|
|
2020-02-14 16:41:38 +01:00
|
|
|
ses = WinHttpOpen(L"winetest", WINHTTP_ACCESS_TYPE_NO_PROXY, NULL, NULL, 0);
|
2010-04-22 16:35:28 +02:00
|
|
|
ok(ses != NULL, "failed to open session %u\n", GetLastError());
|
|
|
|
|
2020-02-14 16:41:38 +01:00
|
|
|
con = WinHttpConnect(ses, L"localhost", port, 0);
|
2010-04-22 16:35:28 +02:00
|
|
|
ok(con != NULL, "failed to open a connection %u\n", GetLastError());
|
|
|
|
|
2020-02-14 16:41:38 +01:00
|
|
|
req = WinHttpOpenRequest(con, NULL, L"/auth", NULL, NULL, NULL, 0);
|
2010-04-22 16:35:28 +02:00
|
|
|
ok(req != NULL, "failed to open a request %u\n", GetLastError());
|
|
|
|
|
2013-08-19 15:52:44 +02:00
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = WinHttpQueryAuthSchemes(NULL, NULL, NULL, NULL);
|
|
|
|
error = GetLastError();
|
|
|
|
ok(!ret, "expected failure\n");
|
|
|
|
ok(error == ERROR_INVALID_HANDLE, "expected ERROR_INVALID_HANDLE, got %u\n", error);
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = WinHttpQueryAuthSchemes(req, NULL, NULL, NULL);
|
|
|
|
error = GetLastError();
|
|
|
|
ok(!ret, "expected failure\n");
|
|
|
|
ok(error == ERROR_INVALID_PARAMETER || error == ERROR_INVALID_OPERATION, "got %u\n", error);
|
|
|
|
|
|
|
|
supported = 0xdeadbeef;
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = WinHttpQueryAuthSchemes(req, &supported, NULL, NULL);
|
|
|
|
error = GetLastError();
|
|
|
|
ok(!ret, "expected failure\n");
|
|
|
|
ok(error == ERROR_INVALID_PARAMETER || error == ERROR_INVALID_OPERATION, "got %u\n", error);
|
|
|
|
ok(supported == 0xdeadbeef, "got %x\n", supported);
|
|
|
|
|
|
|
|
supported = first = 0xdeadbeef;
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = WinHttpQueryAuthSchemes(req, &supported, &first, NULL);
|
|
|
|
error = GetLastError();
|
|
|
|
ok(!ret, "expected failure\n");
|
|
|
|
ok(error == ERROR_INVALID_PARAMETER || error == ERROR_INVALID_OPERATION, "got %u\n", error);
|
|
|
|
ok(supported == 0xdeadbeef, "got %x\n", supported);
|
|
|
|
ok(first == 0xdeadbeef, "got %x\n", first);
|
|
|
|
|
|
|
|
supported = first = target = 0xdeadbeef;
|
|
|
|
SetLastError(0xdeadbeef);
|
2013-06-12 08:02:52 +02:00
|
|
|
ret = WinHttpQueryAuthSchemes(req, &supported, &first, &target);
|
2013-08-19 15:52:44 +02:00
|
|
|
error = GetLastError();
|
|
|
|
ok(!ret, "expected failure\n");
|
2018-09-19 16:18:22 +02:00
|
|
|
ok(error == ERROR_INVALID_OPERATION, "expected ERROR_INVALID_OPERATION, got %u\n", error);
|
2013-08-19 15:52:44 +02:00
|
|
|
ok(supported == 0xdeadbeef, "got %x\n", supported);
|
|
|
|
ok(first == 0xdeadbeef, "got %x\n", first);
|
|
|
|
ok(target == 0xdeadbeef, "got %x\n", target);
|
|
|
|
|
|
|
|
supported = first = target = 0xdeadbeef;
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = WinHttpQueryAuthSchemes(NULL, &supported, &first, &target);
|
|
|
|
error = GetLastError();
|
|
|
|
ok(!ret, "expected failure\n");
|
|
|
|
ok(error == ERROR_INVALID_HANDLE, "expected ERROR_INVALID_HANDLE, got %u\n", error);
|
|
|
|
ok(supported == 0xdeadbeef, "got %x\n", supported);
|
|
|
|
ok(first == 0xdeadbeef, "got %x\n", first);
|
|
|
|
ok(target == 0xdeadbeef, "got %x\n", target);
|
2013-06-12 08:02:52 +02:00
|
|
|
|
2010-04-22 16:35:28 +02:00
|
|
|
ret = WinHttpSendRequest(req, NULL, 0, NULL, 0, 0, 0);
|
|
|
|
ok(ret, "failed to send request %u\n", GetLastError());
|
|
|
|
|
|
|
|
ret = WinHttpReceiveResponse(req, NULL);
|
|
|
|
ok(ret, "failed to receive response %u\n", GetLastError());
|
|
|
|
|
2015-04-21 11:21:06 +02:00
|
|
|
status = 0xdeadbeef;
|
2010-04-22 16:35:28 +02:00
|
|
|
size = sizeof(status);
|
|
|
|
ret = WinHttpQueryHeaders(req, WINHTTP_QUERY_STATUS_CODE|WINHTTP_QUERY_FLAG_NUMBER, NULL, &status, &size, NULL);
|
|
|
|
ok(ret, "failed to query status code %u\n", GetLastError());
|
2015-12-08 00:01:29 +01:00
|
|
|
ok(status == HTTP_STATUS_DENIED, "request failed unexpectedly %u\n", status);
|
2010-04-22 16:35:28 +02:00
|
|
|
|
2015-12-08 00:02:08 +01:00
|
|
|
size = 0;
|
|
|
|
ret = WinHttpReadData(req, buffer, sizeof(buffer), &size);
|
2015-12-10 14:54:30 +01:00
|
|
|
error = GetLastError();
|
|
|
|
ok(ret || broken(error == ERROR_WINHTTP_SHUTDOWN || error == ERROR_WINHTTP_TIMEOUT) /* XP */, "failed to read data %u\n", GetLastError());
|
|
|
|
if (ret)
|
|
|
|
{
|
|
|
|
ok(size == 12, "expected 12, got %u\n", size);
|
|
|
|
ok(!memcmp(buffer, unauthorized, 12), "got %s\n", buffer);
|
|
|
|
}
|
2015-12-08 00:02:08 +01:00
|
|
|
|
2013-08-19 15:52:44 +02:00
|
|
|
supported = first = target = 0xdeadbeef;
|
2015-08-03 11:27:31 +02:00
|
|
|
SetLastError(0xdeadbeef);
|
2013-08-19 15:52:44 +02:00
|
|
|
ret = WinHttpQueryAuthSchemes(req, &supported, &first, &target);
|
2015-08-03 11:27:31 +02:00
|
|
|
error = GetLastError();
|
|
|
|
ok(ret, "failed to query authentication schemes %u\n", error);
|
|
|
|
ok(error == ERROR_SUCCESS || broken(error == 0xdeadbeef) /* < win7 */, "expected ERROR_SUCCESS, got %u\n", error);
|
2013-08-19 15:52:44 +02:00
|
|
|
ok(supported == WINHTTP_AUTH_SCHEME_BASIC, "got %x\n", supported);
|
|
|
|
ok(first == WINHTTP_AUTH_SCHEME_BASIC, "got %x\n", first);
|
|
|
|
ok(target == WINHTTP_AUTH_TARGET_SERVER, "got %x\n", target);
|
|
|
|
|
2015-08-03 11:27:31 +02:00
|
|
|
SetLastError(0xdeadbeef);
|
2013-08-19 15:52:25 +02:00
|
|
|
ret = WinHttpSetCredentials(req, WINHTTP_AUTH_TARGET_SERVER, WINHTTP_AUTH_SCHEME_NTLM, NULL, NULL, NULL);
|
2015-08-03 11:27:31 +02:00
|
|
|
error = GetLastError();
|
|
|
|
ok(ret, "failed to set credentials %u\n", error);
|
|
|
|
ok(error == ERROR_SUCCESS || broken(error == 0xdeadbeef) /* < win7 */, "expected ERROR_SUCCESS, got %u\n", error);
|
2013-08-19 15:52:25 +02:00
|
|
|
|
|
|
|
ret = WinHttpSetCredentials(req, WINHTTP_AUTH_TARGET_SERVER, WINHTTP_AUTH_SCHEME_PASSPORT, NULL, NULL, NULL);
|
|
|
|
ok(ret, "failed to set credentials %u\n", GetLastError());
|
|
|
|
|
|
|
|
ret = WinHttpSetCredentials(req, WINHTTP_AUTH_TARGET_SERVER, WINHTTP_AUTH_SCHEME_NEGOTIATE, NULL, NULL, NULL);
|
|
|
|
ok(ret, "failed to set credentials %u\n", GetLastError());
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = WinHttpSetCredentials(req, WINHTTP_AUTH_TARGET_SERVER, WINHTTP_AUTH_SCHEME_DIGEST, NULL, NULL, NULL);
|
|
|
|
error = GetLastError();
|
|
|
|
ok(!ret, "expected failure\n");
|
|
|
|
ok(error == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %u\n", error);
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = WinHttpSetCredentials(req, WINHTTP_AUTH_TARGET_SERVER, WINHTTP_AUTH_SCHEME_BASIC, NULL, NULL, NULL);
|
|
|
|
error = GetLastError();
|
|
|
|
ok(!ret, "expected failure\n");
|
|
|
|
ok(error == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %u\n", error);
|
|
|
|
|
2010-04-22 16:35:28 +02:00
|
|
|
SetLastError(0xdeadbeef);
|
2020-02-14 16:41:38 +01:00
|
|
|
ret = WinHttpSetCredentials(req, WINHTTP_AUTH_TARGET_SERVER, WINHTTP_AUTH_SCHEME_BASIC, L"user", NULL, NULL);
|
2010-04-22 16:35:28 +02:00
|
|
|
error = GetLastError();
|
|
|
|
ok(!ret, "expected failure\n");
|
|
|
|
ok(error == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %u\n", error);
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
2020-02-14 16:41:38 +01:00
|
|
|
ret = WinHttpSetCredentials(req, WINHTTP_AUTH_TARGET_SERVER, WINHTTP_AUTH_SCHEME_BASIC, NULL, L"pwd", NULL);
|
2010-04-22 16:35:28 +02:00
|
|
|
error = GetLastError();
|
|
|
|
ok(!ret, "expected failure\n");
|
|
|
|
ok(error == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %u\n", error);
|
|
|
|
|
2020-02-14 16:41:38 +01:00
|
|
|
ret = WinHttpSetCredentials(req, WINHTTP_AUTH_TARGET_SERVER, WINHTTP_AUTH_SCHEME_BASIC, L"user", L"pwd", NULL);
|
2017-10-02 10:47:27 +02:00
|
|
|
ok(ret, "failed to set credentials %u\n", GetLastError());
|
|
|
|
|
|
|
|
ret = WinHttpSendRequest(req, NULL, 0, NULL, 0, 0, 0);
|
|
|
|
ok(ret, "failed to send request %u\n", GetLastError());
|
|
|
|
|
|
|
|
ret = WinHttpReceiveResponse(req, NULL);
|
|
|
|
ok(ret, "failed to receive response %u\n", GetLastError());
|
|
|
|
|
|
|
|
status = 0xdeadbeef;
|
|
|
|
size = sizeof(status);
|
|
|
|
ret = WinHttpQueryHeaders(req, WINHTTP_QUERY_STATUS_CODE|WINHTTP_QUERY_FLAG_NUMBER, NULL, &status, &size, NULL);
|
|
|
|
ok(ret, "failed to query status code %u\n", GetLastError());
|
|
|
|
ok(status == HTTP_STATUS_OK, "request failed unexpectedly %u\n", status);
|
|
|
|
|
|
|
|
size = 0;
|
|
|
|
ret = WinHttpReadData(req, buffer, sizeof(buffer), &size);
|
|
|
|
error = GetLastError();
|
|
|
|
ok(ret || broken(error == ERROR_WINHTTP_SHUTDOWN || error == ERROR_WINHTTP_TIMEOUT) /* XP */, "failed to read data %u\n", GetLastError());
|
|
|
|
if (ret)
|
|
|
|
{
|
|
|
|
ok(size == 11, "expected 11, got %u\n", size);
|
|
|
|
ok(!memcmp(buffer, hello_world, 11), "got %s\n", buffer);
|
|
|
|
}
|
|
|
|
|
|
|
|
WinHttpCloseHandle(req);
|
|
|
|
WinHttpCloseHandle(con);
|
|
|
|
WinHttpCloseHandle(ses);
|
|
|
|
|
|
|
|
/* now set the credentials first to show that they get sent with the first request */
|
2020-02-14 16:41:38 +01:00
|
|
|
ses = WinHttpOpen(L"winetest", WINHTTP_ACCESS_TYPE_NO_PROXY, NULL, NULL, 0);
|
2017-10-02 10:47:27 +02:00
|
|
|
ok(ses != NULL, "failed to open session %u\n", GetLastError());
|
|
|
|
|
2020-02-14 16:41:38 +01:00
|
|
|
con = WinHttpConnect(ses, L"localhost", port, 0);
|
2017-10-02 10:47:27 +02:00
|
|
|
ok(con != NULL, "failed to open a connection %u\n", GetLastError());
|
|
|
|
|
2020-02-14 16:41:38 +01:00
|
|
|
req = WinHttpOpenRequest(con, NULL, L"/auth_with_creds", NULL, NULL, NULL, 0);
|
2017-10-02 10:47:27 +02:00
|
|
|
ok(req != NULL, "failed to open a request %u\n", GetLastError());
|
|
|
|
|
2020-02-14 16:41:38 +01:00
|
|
|
ret = WinHttpSetCredentials(req, WINHTTP_AUTH_TARGET_SERVER, WINHTTP_AUTH_SCHEME_BASIC, L"user", L"pwd", NULL);
|
2010-04-22 16:35:28 +02:00
|
|
|
ok(ret, "failed to set credentials %u\n", GetLastError());
|
|
|
|
|
|
|
|
ret = WinHttpSendRequest(req, NULL, 0, NULL, 0, 0, 0);
|
|
|
|
ok(ret, "failed to send request %u\n", GetLastError());
|
|
|
|
|
|
|
|
ret = WinHttpReceiveResponse(req, NULL);
|
|
|
|
ok(ret, "failed to receive response %u\n", GetLastError());
|
|
|
|
|
2015-04-21 11:21:06 +02:00
|
|
|
status = 0xdeadbeef;
|
2010-04-22 16:35:28 +02:00
|
|
|
size = sizeof(status);
|
|
|
|
ret = WinHttpQueryHeaders(req, WINHTTP_QUERY_STATUS_CODE|WINHTTP_QUERY_FLAG_NUMBER, NULL, &status, &size, NULL);
|
|
|
|
ok(ret, "failed to query status code %u\n", GetLastError());
|
2015-12-08 00:01:29 +01:00
|
|
|
ok(status == HTTP_STATUS_OK, "request failed unexpectedly %u\n", status);
|
2010-04-22 16:35:28 +02:00
|
|
|
|
2015-12-08 00:02:08 +01:00
|
|
|
size = 0;
|
|
|
|
ret = WinHttpReadData(req, buffer, sizeof(buffer), &size);
|
2015-12-10 14:54:30 +01:00
|
|
|
error = GetLastError();
|
|
|
|
ok(ret || broken(error == ERROR_WINHTTP_SHUTDOWN || error == ERROR_WINHTTP_TIMEOUT) /* XP */, "failed to read data %u\n", GetLastError());
|
|
|
|
if (ret)
|
|
|
|
{
|
|
|
|
ok(size == 11, "expected 11, got %u\n", size);
|
|
|
|
ok(!memcmp(buffer, hello_world, 11), "got %s\n", buffer);
|
|
|
|
}
|
2015-12-08 00:02:08 +01:00
|
|
|
|
2010-04-22 16:35:28 +02:00
|
|
|
WinHttpCloseHandle(req);
|
|
|
|
WinHttpCloseHandle(con);
|
|
|
|
WinHttpCloseHandle(ses);
|
2015-06-12 15:08:30 +02:00
|
|
|
|
|
|
|
/* credentials set with WinHttpSetCredentials take precedence over those set through options */
|
|
|
|
|
2020-02-14 16:41:38 +01:00
|
|
|
ses = WinHttpOpen(L"winetest", WINHTTP_ACCESS_TYPE_NO_PROXY, NULL, NULL, 0);
|
2015-06-12 15:08:30 +02:00
|
|
|
ok(ses != NULL, "failed to open session %u\n", GetLastError());
|
|
|
|
|
2020-02-14 16:41:38 +01:00
|
|
|
con = WinHttpConnect(ses, L"localhost", port, 0);
|
2015-06-12 15:08:30 +02:00
|
|
|
ok(con != NULL, "failed to open a connection %u\n", GetLastError());
|
|
|
|
|
2020-02-14 16:41:38 +01:00
|
|
|
req = WinHttpOpenRequest(con, NULL, L"/auth", NULL, NULL, NULL, 0);
|
2015-06-12 15:08:30 +02:00
|
|
|
ok(req != NULL, "failed to open a request %u\n", GetLastError());
|
|
|
|
|
2020-02-14 16:41:38 +01:00
|
|
|
ret = WinHttpSetCredentials(req, WINHTTP_AUTH_TARGET_SERVER, WINHTTP_AUTH_SCHEME_BASIC, L"user", L"pwd", NULL);
|
2015-06-12 15:08:30 +02:00
|
|
|
ok(ret, "failed to set credentials %u\n", GetLastError());
|
|
|
|
|
2020-02-14 16:41:38 +01:00
|
|
|
ret = WinHttpSetOption(req, WINHTTP_OPTION_USERNAME, (void *)L"user", lstrlenW(L"user"));
|
2015-06-12 15:08:30 +02:00
|
|
|
ok(ret, "failed to set username %u\n", GetLastError());
|
|
|
|
|
2020-02-14 16:41:38 +01:00
|
|
|
ret = WinHttpSetOption(req, WINHTTP_OPTION_PASSWORD, (void *)L"pwd2", lstrlenW(L"pwd2"));
|
2015-06-12 15:08:30 +02:00
|
|
|
ok(ret, "failed to set password %u\n", GetLastError());
|
|
|
|
|
|
|
|
ret = WinHttpSendRequest(req, NULL, 0, NULL, 0, 0, 0);
|
|
|
|
ok(ret, "failed to send request %u\n", GetLastError());
|
|
|
|
|
|
|
|
ret = WinHttpReceiveResponse(req, NULL);
|
|
|
|
ok(ret, "failed to receive response %u\n", GetLastError());
|
|
|
|
|
|
|
|
status = 0xdeadbeef;
|
|
|
|
size = sizeof(status);
|
|
|
|
ret = WinHttpQueryHeaders(req, WINHTTP_QUERY_STATUS_CODE|WINHTTP_QUERY_FLAG_NUMBER, NULL, &status, &size, NULL);
|
|
|
|
ok(ret, "failed to query status code %u\n", GetLastError());
|
2015-12-08 00:01:29 +01:00
|
|
|
ok(status == HTTP_STATUS_OK, "request failed unexpectedly %u\n", status);
|
2015-06-12 15:08:30 +02:00
|
|
|
|
|
|
|
WinHttpCloseHandle(req);
|
|
|
|
WinHttpCloseHandle(con);
|
|
|
|
WinHttpCloseHandle(ses);
|
|
|
|
|
2020-02-14 16:41:38 +01:00
|
|
|
ses = WinHttpOpen(L"winetest", WINHTTP_ACCESS_TYPE_NO_PROXY, NULL, NULL, 0);
|
2015-06-12 15:08:30 +02:00
|
|
|
ok(ses != NULL, "failed to open session %u\n", GetLastError());
|
|
|
|
|
2020-02-14 16:41:38 +01:00
|
|
|
con = WinHttpConnect(ses, L"localhost", port, 0);
|
2015-06-12 15:08:30 +02:00
|
|
|
ok(con != NULL, "failed to open a connection %u\n", GetLastError());
|
|
|
|
|
2020-02-14 16:41:38 +01:00
|
|
|
req = WinHttpOpenRequest(con, NULL, L"/auth", NULL, NULL, NULL, 0);
|
2015-06-12 15:08:30 +02:00
|
|
|
ok(req != NULL, "failed to open a request %u\n", GetLastError());
|
|
|
|
|
2020-02-14 16:41:38 +01:00
|
|
|
ret = WinHttpSetOption(req, WINHTTP_OPTION_USERNAME, (void *)L"user", lstrlenW(L"user"));
|
2015-06-12 15:08:30 +02:00
|
|
|
ok(ret, "failed to set username %u\n", GetLastError());
|
|
|
|
|
2020-02-14 16:41:38 +01:00
|
|
|
ret = WinHttpSetOption(req, WINHTTP_OPTION_PASSWORD, (void *)L"pwd", lstrlenW(L"pwd"));
|
2015-06-12 15:08:30 +02:00
|
|
|
ok(ret, "failed to set password %u\n", GetLastError());
|
|
|
|
|
2020-02-14 16:41:38 +01:00
|
|
|
ret = WinHttpSetCredentials(req, WINHTTP_AUTH_TARGET_SERVER, WINHTTP_AUTH_SCHEME_BASIC, L"user", L"pwd2", NULL);
|
2015-06-12 15:08:30 +02:00
|
|
|
ok(ret, "failed to set credentials %u\n", GetLastError());
|
|
|
|
|
|
|
|
ret = WinHttpSendRequest(req, NULL, 0, NULL, 0, 0, 0);
|
|
|
|
ok(ret, "failed to send request %u\n", GetLastError());
|
|
|
|
|
|
|
|
ret = WinHttpReceiveResponse(req, NULL);
|
|
|
|
ok(ret, "failed to receive response %u\n", GetLastError());
|
|
|
|
|
|
|
|
status = 0xdeadbeef;
|
|
|
|
size = sizeof(status);
|
|
|
|
ret = WinHttpQueryHeaders(req, WINHTTP_QUERY_STATUS_CODE|WINHTTP_QUERY_FLAG_NUMBER, NULL, &status, &size, NULL);
|
|
|
|
ok(ret, "failed to query status code %u\n", GetLastError());
|
2015-12-08 00:01:29 +01:00
|
|
|
ok(status == HTTP_STATUS_DENIED, "request failed unexpectedly %u\n", status);
|
2015-06-12 15:08:30 +02:00
|
|
|
|
|
|
|
WinHttpCloseHandle(req);
|
|
|
|
WinHttpCloseHandle(con);
|
|
|
|
WinHttpCloseHandle(ses);
|
2010-04-22 16:35:28 +02:00
|
|
|
}
|
|
|
|
|
2017-04-05 11:20:54 +02:00
|
|
|
static void test_multi_authentication(int port)
|
|
|
|
{
|
|
|
|
HINTERNET ses, con, req;
|
2018-09-19 16:17:46 +02:00
|
|
|
DWORD supported, first, target, size, index;
|
|
|
|
WCHAR buf[512];
|
2017-04-05 11:20:54 +02:00
|
|
|
BOOL ret;
|
|
|
|
|
2020-02-14 16:41:38 +01:00
|
|
|
ses = WinHttpOpen(L"winetest", WINHTTP_ACCESS_TYPE_NO_PROXY, NULL, NULL, 0);
|
2017-04-05 11:20:54 +02:00
|
|
|
ok(ses != NULL, "failed to open session %u\n", GetLastError());
|
|
|
|
|
2020-02-14 16:41:38 +01:00
|
|
|
con = WinHttpConnect(ses, L"localhost", port, 0);
|
2017-04-05 11:20:54 +02:00
|
|
|
ok(con != NULL, "failed to open a connection %u\n", GetLastError());
|
|
|
|
|
2020-02-14 16:41:38 +01:00
|
|
|
req = WinHttpOpenRequest(con, L"GET", L"/multiauth", NULL, NULL, NULL, 0);
|
2017-04-05 11:20:54 +02:00
|
|
|
ok(req != NULL, "failed to open a request %u\n", GetLastError());
|
|
|
|
|
|
|
|
ret = WinHttpSendRequest(req, WINHTTP_NO_ADDITIONAL_HEADERS, 0,
|
|
|
|
WINHTTP_NO_REQUEST_DATA,0, 0, 0 );
|
|
|
|
ok(ret, "expected success\n");
|
|
|
|
|
|
|
|
ret = WinHttpReceiveResponse(req, NULL);
|
|
|
|
ok(ret, "expected success\n");
|
|
|
|
|
2017-04-06 09:38:12 +02:00
|
|
|
supported = first = target = 0xdeadbeef;
|
2017-04-05 11:20:54 +02:00
|
|
|
ret = WinHttpQueryAuthSchemes(req, &supported, &first, &target);
|
2017-04-06 09:38:12 +02:00
|
|
|
ok(ret, "expected success\n");
|
|
|
|
ok(supported == (WINHTTP_AUTH_SCHEME_BASIC | WINHTTP_AUTH_SCHEME_NTLM), "got %x\n", supported);
|
|
|
|
ok(target == WINHTTP_AUTH_TARGET_SERVER, "got %x\n", target);
|
|
|
|
ok(first == WINHTTP_AUTH_SCHEME_BASIC, "got %x\n", first);
|
2017-04-05 11:20:54 +02:00
|
|
|
|
2018-09-19 16:17:46 +02:00
|
|
|
index = 0;
|
|
|
|
size = sizeof(buf);
|
2020-02-14 16:41:38 +01:00
|
|
|
ret = WinHttpQueryHeaders(req, WINHTTP_QUERY_CUSTOM, L"WWW-Authenticate", buf, &size, &index);
|
2018-09-19 16:17:46 +02:00
|
|
|
ok(ret, "expected success\n");
|
2020-02-06 21:41:17 +01:00
|
|
|
ok(!lstrcmpW(buf, L"Bearer"), "buf = %s\n", wine_dbgstr_w(buf));
|
2018-09-19 16:17:46 +02:00
|
|
|
ok(size == lstrlenW(buf) * sizeof(WCHAR), "size = %u\n", size);
|
|
|
|
ok(index == 1, "index = %u\n", index);
|
|
|
|
|
|
|
|
index = 0;
|
|
|
|
size = 0xdeadbeef;
|
2020-02-14 16:41:38 +01:00
|
|
|
ret = WinHttpQueryHeaders(req, WINHTTP_QUERY_CUSTOM, L"WWW-Authenticate", NULL, &size, &index);
|
2018-09-19 16:17:46 +02:00
|
|
|
ok(!ret && GetLastError() == ERROR_INSUFFICIENT_BUFFER,
|
|
|
|
"WinHttpQueryHeaders returned %x(%u)\n", ret, GetLastError());
|
|
|
|
ok(size == (lstrlenW(buf) + 1) * sizeof(WCHAR), "size = %u\n", size);
|
|
|
|
ok(index == 0, "index = %u\n", index);
|
|
|
|
|
2017-04-05 11:20:54 +02:00
|
|
|
WinHttpCloseHandle(req);
|
|
|
|
WinHttpCloseHandle(con);
|
|
|
|
WinHttpCloseHandle(ses);
|
|
|
|
}
|
|
|
|
|
2017-04-12 10:46:34 +02:00
|
|
|
static void test_large_data_authentication(int port)
|
|
|
|
{
|
|
|
|
HINTERNET ses, con, req;
|
|
|
|
DWORD status, size;
|
|
|
|
BOOL ret;
|
|
|
|
|
2020-02-14 16:41:38 +01:00
|
|
|
ses = WinHttpOpen(L"winetest", WINHTTP_ACCESS_TYPE_NO_PROXY, NULL, NULL, 0);
|
2017-04-12 10:46:34 +02:00
|
|
|
ok(ses != NULL, "failed to open session %u\n", GetLastError());
|
|
|
|
|
2020-02-14 16:41:38 +01:00
|
|
|
con = WinHttpConnect(ses, L"localhost", port, 0);
|
2017-04-12 10:46:34 +02:00
|
|
|
ok(con != NULL, "failed to open a connection %u\n", GetLastError());
|
|
|
|
|
2020-02-14 16:41:38 +01:00
|
|
|
req = WinHttpOpenRequest(con, L"GET", L"/largeauth", NULL, NULL, NULL, 0);
|
2017-04-12 10:46:34 +02:00
|
|
|
ok(req != NULL, "failed to open a request %u\n", GetLastError());
|
|
|
|
|
|
|
|
ret = WinHttpSendRequest(req, WINHTTP_NO_ADDITIONAL_HEADERS, 0, WINHTTP_NO_REQUEST_DATA, 0, 0, 0);
|
|
|
|
ok(ret, "expected success\n");
|
|
|
|
|
|
|
|
ret = WinHttpReceiveResponse(req, NULL);
|
|
|
|
ok(ret, "expected success\n");
|
|
|
|
|
|
|
|
size = sizeof(status);
|
|
|
|
ret = WinHttpQueryHeaders(req, WINHTTP_QUERY_STATUS_CODE | WINHTTP_QUERY_FLAG_NUMBER, NULL,
|
|
|
|
&status, &size, NULL);
|
|
|
|
ok(ret, "expected success\n");
|
|
|
|
ok(status == HTTP_STATUS_DENIED, "got %d\n", status);
|
|
|
|
|
2020-02-14 16:41:38 +01:00
|
|
|
ret = WinHttpSetCredentials(req, WINHTTP_AUTH_TARGET_SERVER, WINHTTP_AUTH_SCHEME_NTLM, L"user", L"pwd", NULL);
|
2017-04-12 10:46:34 +02:00
|
|
|
ok(ret, "expected success\n");
|
|
|
|
|
|
|
|
ret = WinHttpSendRequest(req, WINHTTP_NO_ADDITIONAL_HEADERS, 0, WINHTTP_NO_REQUEST_DATA, 0, 0, 0);
|
|
|
|
ok(ret, "expected success %d\n", GetLastError());
|
|
|
|
|
|
|
|
ret = WinHttpReceiveResponse(req, NULL);
|
2017-04-12 10:46:35 +02:00
|
|
|
ok(ret, "expected success\n");
|
2017-04-12 10:46:34 +02:00
|
|
|
|
|
|
|
size = sizeof(status);
|
|
|
|
ret = WinHttpQueryHeaders(req, WINHTTP_QUERY_STATUS_CODE | WINHTTP_QUERY_FLAG_NUMBER, NULL,
|
|
|
|
&status, &size, NULL);
|
2017-04-12 10:46:35 +02:00
|
|
|
ok(ret, "expected success\n");
|
|
|
|
ok(status == HTTP_STATUS_OK, "got %d\n", status);
|
2017-04-12 10:46:34 +02:00
|
|
|
|
|
|
|
WinHttpCloseHandle(req);
|
|
|
|
WinHttpCloseHandle(con);
|
|
|
|
WinHttpCloseHandle(ses);
|
|
|
|
}
|
|
|
|
|
2010-04-22 16:35:28 +02:00
|
|
|
static void test_no_headers(int port)
|
|
|
|
{
|
|
|
|
HINTERNET ses, con, req;
|
2011-07-23 18:15:37 +02:00
|
|
|
DWORD error;
|
2010-04-22 16:35:28 +02:00
|
|
|
BOOL ret;
|
|
|
|
|
2020-02-14 16:41:38 +01:00
|
|
|
ses = WinHttpOpen(L"winetest", WINHTTP_ACCESS_TYPE_NO_PROXY, NULL, NULL, 0);
|
2010-04-22 16:35:28 +02:00
|
|
|
ok(ses != NULL, "failed to open session %u\n", GetLastError());
|
|
|
|
|
2020-02-14 16:41:38 +01:00
|
|
|
con = WinHttpConnect(ses, L"localhost", port, 0);
|
2010-04-22 16:35:28 +02:00
|
|
|
ok(con != NULL, "failed to open a connection %u\n", GetLastError());
|
|
|
|
|
2020-02-14 16:41:38 +01:00
|
|
|
req = WinHttpOpenRequest(con, NULL, L"/no_headers", NULL, NULL, NULL, 0);
|
2010-04-22 16:35:28 +02:00
|
|
|
ok(req != NULL, "failed to open a request %u\n", GetLastError());
|
|
|
|
|
|
|
|
ret = WinHttpSendRequest(req, NULL, 0, NULL, 0, 0, 0);
|
2014-02-11 09:54:22 +01:00
|
|
|
if (!ret)
|
|
|
|
{
|
|
|
|
error = GetLastError();
|
|
|
|
ok(error == ERROR_WINHTTP_INVALID_SERVER_RESPONSE, "got %u\n", error);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = WinHttpReceiveResponse(req, NULL);
|
|
|
|
error = GetLastError();
|
|
|
|
ok(!ret, "expected failure\n");
|
|
|
|
ok(error == ERROR_WINHTTP_INVALID_SERVER_RESPONSE, "got %u\n", error);
|
|
|
|
}
|
2010-04-22 16:35:28 +02:00
|
|
|
|
|
|
|
WinHttpCloseHandle(req);
|
|
|
|
WinHttpCloseHandle(con);
|
|
|
|
WinHttpCloseHandle(ses);
|
|
|
|
}
|
|
|
|
|
2014-07-30 18:31:17 +02:00
|
|
|
static void test_no_content(int port)
|
|
|
|
{
|
|
|
|
HINTERNET ses, con, req;
|
2014-12-09 12:50:07 +01:00
|
|
|
char buf[128];
|
2014-07-30 18:31:17 +02:00
|
|
|
DWORD size, len = sizeof(buf), bytes_read, status;
|
|
|
|
BOOL ret;
|
|
|
|
|
2020-02-14 16:41:38 +01:00
|
|
|
ses = WinHttpOpen(L"winetest", WINHTTP_ACCESS_TYPE_NO_PROXY, NULL, NULL, 0);
|
2014-07-30 18:31:17 +02:00
|
|
|
ok(ses != NULL, "failed to open session %u\n", GetLastError());
|
|
|
|
|
2020-02-14 16:41:38 +01:00
|
|
|
con = WinHttpConnect(ses, L"localhost", port, 0);
|
2014-07-30 18:31:17 +02:00
|
|
|
ok(con != NULL, "failed to open a connection %u\n", GetLastError());
|
|
|
|
|
2020-02-14 16:41:38 +01:00
|
|
|
req = WinHttpOpenRequest(con, NULL, L"/no_content", NULL, NULL, NULL, 0);
|
2014-07-30 18:31:17 +02:00
|
|
|
ok(req != NULL, "failed to open a request %u\n", GetLastError());
|
|
|
|
|
|
|
|
size = 12345;
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = WinHttpQueryDataAvailable(req, &size);
|
|
|
|
todo_wine {
|
|
|
|
ok(!ret, "expected error\n");
|
|
|
|
ok(GetLastError() == ERROR_WINHTTP_INCORRECT_HANDLE_STATE,
|
|
|
|
"expected ERROR_WINHTTP_INCORRECT_HANDLE_STATE, got 0x%08x\n", GetLastError());
|
|
|
|
ok(size == 12345 || broken(size == 0) /* Win <= 2003 */,
|
|
|
|
"expected 12345, got %u\n", size);
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = WinHttpSendRequest(req, NULL, 0, NULL, 0, 0, 0);
|
|
|
|
ok(ret, "expected success\n");
|
|
|
|
|
|
|
|
ret = WinHttpReceiveResponse(req, NULL);
|
|
|
|
ok(ret, "expected success\n");
|
|
|
|
|
2015-04-21 11:21:06 +02:00
|
|
|
status = 0xdeadbeef;
|
2014-07-30 18:31:17 +02:00
|
|
|
size = sizeof(status);
|
|
|
|
ret = WinHttpQueryHeaders(req, WINHTTP_QUERY_STATUS_CODE | WINHTTP_QUERY_FLAG_NUMBER,
|
|
|
|
NULL, &status, &size, NULL);
|
|
|
|
ok(ret, "expected success\n");
|
2015-12-08 00:01:29 +01:00
|
|
|
ok(status == HTTP_STATUS_NO_CONTENT, "expected status 204, got %d\n", status);
|
2014-07-30 18:31:17 +02:00
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
size = sizeof(status);
|
|
|
|
status = 12345;
|
|
|
|
ret = WinHttpQueryHeaders(req, WINHTTP_QUERY_CONTENT_LENGTH | WINHTTP_QUERY_FLAG_NUMBER,
|
|
|
|
NULL, &status, &size, 0);
|
|
|
|
ok(!ret, "expected no content-length header\n");
|
2015-08-03 11:27:31 +02:00
|
|
|
ok(GetLastError() == ERROR_WINHTTP_HEADER_NOT_FOUND, "wrong error %u\n", GetLastError());
|
2014-07-30 18:31:17 +02:00
|
|
|
ok(status == 12345, "expected 0, got %d\n", status);
|
|
|
|
|
2015-08-03 11:27:31 +02:00
|
|
|
SetLastError(0xdeadbeef);
|
2014-07-30 18:31:17 +02:00
|
|
|
size = 12345;
|
|
|
|
ret = WinHttpQueryDataAvailable(req, &size);
|
|
|
|
ok(ret, "expected success\n");
|
2015-08-03 11:27:31 +02:00
|
|
|
ok(GetLastError() == ERROR_SUCCESS || broken(GetLastError() == 0xdeadbeef) /* < win7 */,
|
|
|
|
"wrong error %u\n", GetLastError());
|
|
|
|
ok(!size, "expected 0, got %u\n", size);
|
2014-07-30 18:31:17 +02:00
|
|
|
|
2015-08-03 11:27:31 +02:00
|
|
|
SetLastError(0xdeadbeef);
|
2014-07-30 18:31:17 +02:00
|
|
|
ret = WinHttpReadData(req, buf, len, &bytes_read);
|
2014-12-09 12:50:07 +01:00
|
|
|
ok(ret, "expected success\n");
|
2015-08-03 11:27:31 +02:00
|
|
|
ok(GetLastError() == ERROR_SUCCESS || broken(GetLastError() == 0xdeadbeef) /* < win7 */,
|
|
|
|
"wrong error %u\n", GetLastError());
|
|
|
|
ok(!bytes_read, "expected 0, got %u\n", bytes_read);
|
2014-07-30 18:31:17 +02:00
|
|
|
|
|
|
|
size = 12345;
|
|
|
|
ret = WinHttpQueryDataAvailable(req, &size);
|
|
|
|
ok(ret, "expected success\n");
|
|
|
|
ok(size == 0, "expected 0, got %d\n", size);
|
|
|
|
|
|
|
|
WinHttpCloseHandle(req);
|
|
|
|
|
|
|
|
size = 12345;
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = WinHttpQueryDataAvailable(req, &size);
|
|
|
|
ok(!ret, "expected error\n");
|
|
|
|
ok(GetLastError() == ERROR_INVALID_HANDLE,
|
|
|
|
"expected ERROR_INVALID_HANDLE, got 0x%08x\n", GetLastError());
|
|
|
|
ok(size == 12345, "expected 12345, got %u\n", size);
|
|
|
|
|
|
|
|
WinHttpCloseHandle(con);
|
|
|
|
WinHttpCloseHandle(ses);
|
|
|
|
}
|
|
|
|
|
2015-01-21 13:25:18 +01:00
|
|
|
static void test_head_request(int port)
|
|
|
|
{
|
|
|
|
HINTERNET ses, con, req;
|
|
|
|
char buf[128];
|
|
|
|
DWORD size, len, count, status;
|
|
|
|
BOOL ret;
|
|
|
|
|
2020-02-14 16:41:38 +01:00
|
|
|
ses = WinHttpOpen(L"winetest", WINHTTP_ACCESS_TYPE_NO_PROXY, NULL, NULL, 0);
|
2015-01-21 13:25:18 +01:00
|
|
|
ok(ses != NULL, "failed to open session %u\n", GetLastError());
|
|
|
|
|
2020-02-14 16:41:38 +01:00
|
|
|
con = WinHttpConnect(ses, L"localhost", port, 0);
|
2015-01-21 13:25:18 +01:00
|
|
|
ok(con != NULL, "failed to open a connection %u\n", GetLastError());
|
|
|
|
|
2020-02-14 16:41:38 +01:00
|
|
|
req = WinHttpOpenRequest(con, L"HEAD", L"/head", NULL, NULL, NULL, 0);
|
2015-01-21 13:25:18 +01:00
|
|
|
ok(req != NULL, "failed to open a request %u\n", GetLastError());
|
|
|
|
|
|
|
|
ret = WinHttpSendRequest(req, NULL, 0, NULL, 0, 0, 0);
|
|
|
|
ok(ret, "failed to send request %u\n", GetLastError());
|
|
|
|
|
|
|
|
ret = WinHttpReceiveResponse(req, NULL);
|
|
|
|
ok(ret, "failed to receive response %u\n", GetLastError());
|
|
|
|
|
|
|
|
status = 0xdeadbeef;
|
|
|
|
size = sizeof(status);
|
|
|
|
ret = WinHttpQueryHeaders(req, WINHTTP_QUERY_STATUS_CODE | WINHTTP_QUERY_FLAG_NUMBER,
|
|
|
|
NULL, &status, &size, NULL);
|
|
|
|
ok(ret, "failed to get status code %u\n", GetLastError());
|
2015-12-08 00:01:29 +01:00
|
|
|
ok(status == HTTP_STATUS_OK, "got %u\n", status);
|
2015-01-21 13:25:18 +01:00
|
|
|
|
|
|
|
len = 0xdeadbeef;
|
|
|
|
size = sizeof(len);
|
|
|
|
ret = WinHttpQueryHeaders(req, WINHTTP_QUERY_CONTENT_LENGTH | WINHTTP_QUERY_FLAG_NUMBER,
|
|
|
|
NULL, &len, &size, 0);
|
|
|
|
ok(ret, "failed to get content-length header %u\n", GetLastError());
|
2015-12-08 00:01:29 +01:00
|
|
|
ok(len == HTTP_STATUS_CONTINUE, "got %u\n", len);
|
2015-01-21 13:25:18 +01:00
|
|
|
|
|
|
|
count = 0xdeadbeef;
|
|
|
|
ret = WinHttpQueryDataAvailable(req, &count);
|
|
|
|
ok(ret, "failed to query data available %u\n", GetLastError());
|
|
|
|
ok(!count, "got %u\n", count);
|
|
|
|
|
|
|
|
len = sizeof(buf);
|
|
|
|
count = 0xdeadbeef;
|
|
|
|
ret = WinHttpReadData(req, buf, len, &count);
|
|
|
|
ok(ret, "failed to read data %u\n", GetLastError());
|
|
|
|
ok(!count, "got %u\n", count);
|
|
|
|
|
|
|
|
count = 0xdeadbeef;
|
|
|
|
ret = WinHttpQueryDataAvailable(req, &count);
|
|
|
|
ok(ret, "failed to query data available %u\n", GetLastError());
|
|
|
|
ok(!count, "got %u\n", count);
|
|
|
|
|
|
|
|
WinHttpCloseHandle(req);
|
|
|
|
WinHttpCloseHandle(con);
|
|
|
|
WinHttpCloseHandle(ses);
|
|
|
|
}
|
|
|
|
|
2020-06-16 11:45:12 +02:00
|
|
|
static void test_websocket(int port)
|
|
|
|
{
|
2020-06-24 10:33:10 +02:00
|
|
|
HINTERNET session, connection, request, socket, socket2;
|
2020-06-16 11:45:12 +02:00
|
|
|
DWORD size, len, count, status, index, error;
|
2020-06-22 21:39:20 +02:00
|
|
|
DWORD_PTR ctx;
|
2020-06-24 10:33:10 +02:00
|
|
|
WINHTTP_WEB_SOCKET_BUFFER_TYPE type;
|
2020-06-16 11:45:12 +02:00
|
|
|
WCHAR header[32];
|
2020-06-24 10:33:10 +02:00
|
|
|
char buf[128], *large_buf;
|
|
|
|
USHORT close_status;
|
2020-06-16 11:45:12 +02:00
|
|
|
BOOL ret;
|
|
|
|
|
|
|
|
if (!pWinHttpWebSocketCompleteUpgrade)
|
|
|
|
{
|
|
|
|
win_skip("WinHttpWebSocketCompleteUpgrade not supported\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
session = WinHttpOpen(L"winetest", 0, NULL, NULL, 0);
|
|
|
|
ok(session != NULL, "got %u\n", GetLastError());
|
|
|
|
|
|
|
|
connection = WinHttpConnect(session, L"localhost", port, 0);
|
|
|
|
ok(connection != NULL, "got %u\n", GetLastError());
|
|
|
|
|
|
|
|
request = WinHttpOpenRequest(connection, L"GET", L"/websocket", NULL, NULL, NULL, 0);
|
|
|
|
ok(request != NULL, "got %u\n", GetLastError());
|
|
|
|
|
|
|
|
ret = WinHttpSetOption(request, WINHTTP_OPTION_UPGRADE_TO_WEB_SOCKET, NULL, 0);
|
2020-06-17 11:53:41 +02:00
|
|
|
ok(ret, "got %u\n", GetLastError());
|
2020-06-16 11:45:12 +02:00
|
|
|
|
|
|
|
size = sizeof(header);
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = WinHttpQueryHeaders(request, WINHTTP_QUERY_UPGRADE, NULL, &header, &size, NULL);
|
|
|
|
error = GetLastError();
|
|
|
|
ok(!ret, "success\n");
|
|
|
|
todo_wine ok(error == ERROR_WINHTTP_INCORRECT_HANDLE_STATE, "got %u\n", error);
|
|
|
|
|
|
|
|
size = sizeof(header);
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = WinHttpQueryHeaders(request, WINHTTP_QUERY_CONNECTION, NULL, &header, &size, NULL);
|
|
|
|
error = GetLastError();
|
|
|
|
ok(!ret, "success\n");
|
|
|
|
todo_wine ok(error == ERROR_WINHTTP_INCORRECT_HANDLE_STATE, "got %u\n", error);
|
|
|
|
|
|
|
|
index = 0;
|
|
|
|
size = sizeof(buf);
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = WinHttpQueryHeaders(request, WINHTTP_QUERY_CUSTOM | WINHTTP_QUERY_FLAG_REQUEST_HEADERS,
|
|
|
|
L"Sec-WebSocket-Key", buf, &size, &index);
|
|
|
|
error = GetLastError();
|
|
|
|
ok(!ret, "success\n");
|
|
|
|
ok(error == ERROR_WINHTTP_HEADER_NOT_FOUND, "got %u\n", error);
|
|
|
|
|
|
|
|
index = 0;
|
|
|
|
size = sizeof(buf);
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = WinHttpQueryHeaders(request, WINHTTP_QUERY_CUSTOM | WINHTTP_QUERY_FLAG_REQUEST_HEADERS,
|
|
|
|
L"Sec-WebSocket-Version", buf, &size, &index);
|
|
|
|
error = GetLastError();
|
|
|
|
ok(!ret, "success\n");
|
|
|
|
ok(error == ERROR_WINHTTP_HEADER_NOT_FOUND, "got %u\n", error);
|
|
|
|
|
|
|
|
ret = WinHttpSendRequest(request, NULL, 0, NULL, 0, 0, 0);
|
|
|
|
ok(ret, "got %u\n", GetLastError());
|
|
|
|
|
|
|
|
size = sizeof(header);
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = WinHttpQueryHeaders(request, WINHTTP_QUERY_UPGRADE, NULL, &header, &size, NULL);
|
|
|
|
error = GetLastError();
|
|
|
|
ok(!ret, "success\n");
|
|
|
|
todo_wine ok(error == ERROR_WINHTTP_INCORRECT_HANDLE_STATE, "got %u\n", error);
|
|
|
|
|
|
|
|
size = sizeof(header);
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = WinHttpQueryHeaders(request, WINHTTP_QUERY_CONNECTION, NULL, &header, &size, NULL);
|
|
|
|
error = GetLastError();
|
|
|
|
ok(!ret, "success\n");
|
|
|
|
todo_wine ok(error == ERROR_WINHTTP_INCORRECT_HANDLE_STATE, "got %u\n", error);
|
|
|
|
|
|
|
|
index = 0;
|
|
|
|
buf[0] = 0;
|
|
|
|
size = sizeof(buf);
|
|
|
|
ret = WinHttpQueryHeaders(request, WINHTTP_QUERY_CUSTOM | WINHTTP_QUERY_FLAG_REQUEST_HEADERS,
|
|
|
|
L"Sec-WebSocket-Key", buf, &size, &index);
|
2020-06-17 11:53:41 +02:00
|
|
|
ok(ret, "got %u\n", GetLastError());
|
2020-06-16 11:45:12 +02:00
|
|
|
|
|
|
|
index = 0;
|
|
|
|
buf[0] = 0;
|
|
|
|
size = sizeof(buf);
|
|
|
|
ret = WinHttpQueryHeaders(request, WINHTTP_QUERY_CUSTOM | WINHTTP_QUERY_FLAG_REQUEST_HEADERS,
|
|
|
|
L"Sec-WebSocket-Version", buf, &size, &index);
|
2020-06-17 11:53:41 +02:00
|
|
|
ok(ret, "got %u\n", GetLastError());
|
2020-06-16 11:45:12 +02:00
|
|
|
|
|
|
|
ret = WinHttpReceiveResponse(request, NULL);
|
2020-06-17 11:53:41 +02:00
|
|
|
ok(ret, "got %u\n", GetLastError());
|
2020-06-16 11:45:12 +02:00
|
|
|
|
|
|
|
count = 0xdeadbeef;
|
|
|
|
ret = WinHttpQueryDataAvailable(request, &count);
|
|
|
|
ok(ret, "got %u\n", GetLastError());
|
2020-06-17 11:53:41 +02:00
|
|
|
ok(!count, "got %u\n", count);
|
2020-06-16 11:45:12 +02:00
|
|
|
|
|
|
|
header[0] = 0;
|
|
|
|
size = sizeof(header);
|
|
|
|
ret = WinHttpQueryHeaders(request, WINHTTP_QUERY_UPGRADE, NULL, &header, &size, NULL);
|
2020-06-17 11:53:41 +02:00
|
|
|
ok(ret, "got %u\n", GetLastError());
|
|
|
|
ok(!wcscmp( header, L"websocket" ), "got %s\n", wine_dbgstr_w(header));
|
2020-06-16 11:45:12 +02:00
|
|
|
|
|
|
|
header[0] = 0;
|
|
|
|
size = sizeof(header);
|
|
|
|
ret = WinHttpQueryHeaders(request, WINHTTP_QUERY_CONNECTION, NULL, &header, &size, NULL);
|
2020-06-17 11:53:41 +02:00
|
|
|
ok(ret, "got %u\n", GetLastError());
|
|
|
|
ok(!wcscmp( header, L"Upgrade" ), "got %s\n", wine_dbgstr_w(header));
|
2020-06-16 11:45:12 +02:00
|
|
|
|
|
|
|
status = 0xdeadbeef;
|
|
|
|
size = sizeof(status);
|
|
|
|
ret = WinHttpQueryHeaders(request, WINHTTP_QUERY_STATUS_CODE | WINHTTP_QUERY_FLAG_NUMBER, NULL, &status,
|
|
|
|
&size, NULL);
|
|
|
|
ok(ret, "got %u\n", GetLastError());
|
2020-06-17 11:53:41 +02:00
|
|
|
ok(status == HTTP_STATUS_SWITCH_PROTOCOLS, "got %u\n", status);
|
2020-06-16 11:45:12 +02:00
|
|
|
|
|
|
|
len = 0xdeadbeef;
|
|
|
|
size = sizeof(len);
|
|
|
|
ret = WinHttpQueryHeaders(request, WINHTTP_QUERY_CONTENT_LENGTH | WINHTTP_QUERY_FLAG_NUMBER, NULL, &len,
|
2020-06-24 10:33:10 +02:00
|
|
|
&size, NULL);
|
2020-06-16 11:45:12 +02:00
|
|
|
ok(!ret, "success\n");
|
|
|
|
|
|
|
|
index = 0;
|
|
|
|
size = sizeof(buf);
|
|
|
|
ret = WinHttpQueryHeaders(request, WINHTTP_QUERY_CUSTOM, L"Sec-WebSocket-Accept", buf, &size, &index);
|
2020-06-17 11:53:41 +02:00
|
|
|
ok(ret, "got %u\n", GetLastError());
|
2020-06-16 11:45:12 +02:00
|
|
|
|
|
|
|
socket = pWinHttpWebSocketCompleteUpgrade(request, 0);
|
2020-06-17 11:53:41 +02:00
|
|
|
ok(socket != NULL, "got %u\n", GetLastError());
|
2020-06-16 11:45:12 +02:00
|
|
|
|
2020-06-24 10:33:10 +02:00
|
|
|
size = sizeof(header);
|
|
|
|
ret = WinHttpQueryHeaders(socket, WINHTTP_QUERY_UPGRADE, NULL, &header, &size, NULL);
|
|
|
|
error = GetLastError();
|
|
|
|
ok(!ret, "success\n");
|
|
|
|
ok(error == ERROR_WINHTTP_INCORRECT_HANDLE_TYPE, "got %u\n", error);
|
|
|
|
|
2020-06-16 11:45:12 +02:00
|
|
|
header[0] = 0;
|
|
|
|
size = sizeof(header);
|
|
|
|
ret = WinHttpQueryHeaders(request, WINHTTP_QUERY_UPGRADE, NULL, &header, &size, NULL);
|
2020-06-17 11:53:41 +02:00
|
|
|
ok(ret, "got %u\n", GetLastError());
|
|
|
|
ok(!wcscmp( header, L"websocket" ), "got %s\n", wine_dbgstr_w(header));
|
2020-06-16 11:45:12 +02:00
|
|
|
|
|
|
|
header[0] = 0;
|
|
|
|
size = sizeof(header);
|
|
|
|
ret = WinHttpQueryHeaders(request, WINHTTP_QUERY_CONNECTION, NULL, &header, &size, NULL);
|
2020-06-17 11:53:41 +02:00
|
|
|
ok(ret, "got %u\n", GetLastError());
|
|
|
|
ok(!wcscmp( header, L"Upgrade" ), "got %s\n", wine_dbgstr_w(header));
|
2020-06-16 11:45:12 +02:00
|
|
|
|
|
|
|
index = 0;
|
|
|
|
size = sizeof(buf);
|
|
|
|
ret = WinHttpQueryHeaders(request, WINHTTP_QUERY_CUSTOM, L"Sec-WebSocket-Accept", buf, &size, &index);
|
2020-06-17 11:53:41 +02:00
|
|
|
ok(ret, "got %u\n", GetLastError());
|
2020-06-16 11:45:12 +02:00
|
|
|
|
2020-06-24 10:33:10 +02:00
|
|
|
/* sending request again generates new key */
|
|
|
|
ret = WinHttpSendRequest(request, NULL, 0, NULL, 0, 0, 0);
|
2020-06-22 21:39:20 +02:00
|
|
|
ok(ret, "got %u\n", GetLastError());
|
|
|
|
|
2020-06-24 10:33:10 +02:00
|
|
|
/* and creates a new websocket */
|
|
|
|
socket2 = pWinHttpWebSocketCompleteUpgrade(request, 0);
|
|
|
|
ok(socket2 != NULL, "got %u\n", GetLastError());
|
|
|
|
ok(socket2 != socket, "got same socket\n");
|
|
|
|
|
|
|
|
WinHttpCloseHandle(connection);
|
2020-06-22 21:39:20 +02:00
|
|
|
/* request handle is still valid */
|
|
|
|
size = sizeof(ctx);
|
|
|
|
ret = WinHttpQueryOption(request, WINHTTP_OPTION_CONTEXT_VALUE, &ctx, &size);
|
|
|
|
ok(ret, "got %u\n", GetLastError());
|
|
|
|
|
2020-06-24 10:33:10 +02:00
|
|
|
ret = WinHttpCloseHandle(socket2);
|
|
|
|
ok(ret, "got %u\n", GetLastError());
|
|
|
|
|
2020-06-22 21:39:20 +02:00
|
|
|
ret = WinHttpCloseHandle(socket);
|
|
|
|
ok(ret, "got %u\n", GetLastError());
|
|
|
|
|
|
|
|
ret = WinHttpQueryOption(request, WINHTTP_OPTION_CONTEXT_VALUE, &ctx, &size);
|
|
|
|
ok(ret, "got %u\n", GetLastError());
|
|
|
|
|
|
|
|
ret = WinHttpCloseHandle(session);
|
|
|
|
ok(ret, "got %u\n", GetLastError());
|
|
|
|
|
|
|
|
ret = WinHttpQueryOption(request, WINHTTP_OPTION_CONTEXT_VALUE, &ctx, &size);
|
|
|
|
ok(ret, "got %u\n", GetLastError());
|
|
|
|
|
|
|
|
ret = WinHttpCloseHandle(request);
|
|
|
|
ok(ret, "got %u\n", GetLastError());
|
2020-06-24 10:33:10 +02:00
|
|
|
|
|
|
|
session = WinHttpOpen(L"winetest", 0, NULL, NULL, 0);
|
|
|
|
ok(session != NULL, "got %u\n", GetLastError());
|
|
|
|
|
|
|
|
connection = WinHttpConnect(session, L"echo.websocket.org", 0, 0);
|
|
|
|
ok(connection != NULL, "got %u\n", GetLastError());
|
|
|
|
|
|
|
|
request = WinHttpOpenRequest(connection, L"GET", L"/", NULL, NULL, NULL, 0);
|
|
|
|
ok(request != NULL, "got %u\n", GetLastError());
|
|
|
|
|
|
|
|
ret = WinHttpSetOption(request, WINHTTP_OPTION_UPGRADE_TO_WEB_SOCKET, NULL, 0);
|
|
|
|
ok(ret, "got %u\n", GetLastError());
|
|
|
|
|
|
|
|
ret = WinHttpSendRequest(request, NULL, 0, NULL, 0, 0, 0);
|
|
|
|
ok(ret, "got %u\n", GetLastError());
|
|
|
|
|
|
|
|
ret = WinHttpReceiveResponse(request, NULL);
|
|
|
|
ok(ret, "got %u\n", GetLastError());
|
|
|
|
|
|
|
|
status = 0xdeadbeef;
|
|
|
|
size = sizeof(status);
|
|
|
|
ret = WinHttpQueryHeaders(request, WINHTTP_QUERY_STATUS_CODE | WINHTTP_QUERY_FLAG_NUMBER, NULL, &status,
|
|
|
|
&size, NULL);
|
|
|
|
ok(ret, "got %u\n", GetLastError());
|
|
|
|
ok(status == HTTP_STATUS_SWITCH_PROTOCOLS, "got %u\n", status);
|
|
|
|
|
|
|
|
socket = pWinHttpWebSocketCompleteUpgrade(request, 0);
|
|
|
|
ok(socket != NULL, "got %u\n", GetLastError());
|
|
|
|
|
|
|
|
error = pWinHttpWebSocketSend(socket, WINHTTP_WEB_SOCKET_BINARY_MESSAGE_BUFFER_TYPE, NULL, 1);
|
|
|
|
ok(error == ERROR_INVALID_PARAMETER, "got %u\n", error);
|
|
|
|
|
|
|
|
large_buf = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(buf) * 2);
|
|
|
|
memcpy(large_buf, "hello", sizeof("hello"));
|
|
|
|
memcpy(large_buf + sizeof(buf), "world", sizeof("world"));
|
|
|
|
error = pWinHttpWebSocketSend(socket, WINHTTP_WEB_SOCKET_BINARY_MESSAGE_BUFFER_TYPE, large_buf, sizeof(buf) * 2);
|
|
|
|
ok(!error, "got %u\n", error);
|
|
|
|
HeapFree(GetProcessHeap(), 0, large_buf);
|
|
|
|
|
|
|
|
error = pWinHttpWebSocketReceive(socket, NULL, 0, NULL, NULL);
|
|
|
|
ok(error == ERROR_INVALID_PARAMETER, "got %u\n", error);
|
|
|
|
|
|
|
|
error = pWinHttpWebSocketReceive(socket, buf, 0, NULL, NULL);
|
|
|
|
ok(error == ERROR_INVALID_PARAMETER, "got %u\n", error);
|
|
|
|
|
|
|
|
error = pWinHttpWebSocketReceive(socket, NULL, 1, NULL, NULL);
|
|
|
|
ok(error == ERROR_INVALID_PARAMETER, "got %u\n", error);
|
|
|
|
|
|
|
|
buf[0] = 0;
|
|
|
|
count = 0;
|
|
|
|
type = 0xdeadbeef;
|
|
|
|
error = pWinHttpWebSocketReceive(socket, buf, sizeof(buf), &count, &type);
|
|
|
|
ok(!error, "got %u\n", error);
|
|
|
|
ok(buf[0] == 'h', "got %c\n", buf[0]);
|
|
|
|
ok(count == sizeof(buf), "got %u\n", count);
|
|
|
|
ok(type == WINHTTP_WEB_SOCKET_BINARY_FRAGMENT_BUFFER_TYPE, "got %u\n", type);
|
|
|
|
|
|
|
|
buf[0] = 0;
|
|
|
|
count = 0;
|
|
|
|
type = 0xdeadbeef;
|
|
|
|
error = pWinHttpWebSocketReceive(socket, buf, sizeof(buf), &count, &type);
|
|
|
|
ok(!error, "got %u\n", error);
|
|
|
|
ok(buf[0] == 'w', "got %c\n", buf[0]);
|
|
|
|
ok(count == sizeof(buf), "got %u\n", count);
|
|
|
|
ok(type == WINHTTP_WEB_SOCKET_BINARY_MESSAGE_BUFFER_TYPE, "got %u\n", type);
|
|
|
|
|
|
|
|
error = pWinHttpWebSocketShutdown(socket, WINHTTP_WEB_SOCKET_SUCCESS_CLOSE_STATUS, NULL, 1);
|
|
|
|
ok(error == ERROR_INVALID_PARAMETER, "got %u\n", error);
|
|
|
|
|
2020-06-29 15:46:11 +02:00
|
|
|
error = pWinHttpWebSocketShutdown(socket, WINHTTP_WEB_SOCKET_SUCCESS_CLOSE_STATUS, buf, sizeof(buf));
|
|
|
|
ok(error == ERROR_INVALID_PARAMETER, "got %u\n", error);
|
|
|
|
|
2020-06-24 10:33:10 +02:00
|
|
|
error = pWinHttpWebSocketShutdown(socket, WINHTTP_WEB_SOCKET_SUCCESS_CLOSE_STATUS, (void *)"success",
|
|
|
|
sizeof("success"));
|
|
|
|
ok(!error, "got %u\n", error);
|
|
|
|
|
|
|
|
error = pWinHttpWebSocketClose(socket, WINHTTP_WEB_SOCKET_SUCCESS_CLOSE_STATUS, NULL, 1);
|
|
|
|
ok(error == ERROR_INVALID_PARAMETER, "got %u\n", error);
|
|
|
|
|
2020-06-29 15:46:11 +02:00
|
|
|
error = pWinHttpWebSocketClose(socket, WINHTTP_WEB_SOCKET_SUCCESS_CLOSE_STATUS, buf, sizeof(buf));
|
|
|
|
ok(error == ERROR_INVALID_PARAMETER, "got %u\n", error);
|
|
|
|
|
2020-06-24 10:33:10 +02:00
|
|
|
error = pWinHttpWebSocketClose(socket, WINHTTP_WEB_SOCKET_SUCCESS_CLOSE_STATUS, (void *)"success2",
|
|
|
|
sizeof("success2"));
|
|
|
|
ok(!error, "got %u\n", error);
|
|
|
|
|
|
|
|
error = pWinHttpWebSocketQueryCloseStatus(socket, NULL, NULL, 0, NULL);
|
|
|
|
ok(error == ERROR_INVALID_PARAMETER, "got %u\n", error);
|
|
|
|
|
|
|
|
error = pWinHttpWebSocketQueryCloseStatus(socket, &close_status, NULL, 0, NULL);
|
|
|
|
ok(error == ERROR_INVALID_PARAMETER, "got %u\n", error);
|
|
|
|
|
|
|
|
error = pWinHttpWebSocketQueryCloseStatus(socket, &close_status, buf, 0, NULL);
|
|
|
|
ok(error == ERROR_INVALID_PARAMETER, "got %u\n", error);
|
|
|
|
|
|
|
|
error = pWinHttpWebSocketQueryCloseStatus(socket, &close_status, buf, sizeof(buf), NULL);
|
|
|
|
ok(error == ERROR_INVALID_PARAMETER, "got %u\n", error);
|
|
|
|
|
|
|
|
error = pWinHttpWebSocketQueryCloseStatus(socket, NULL, NULL, 0, &len);
|
|
|
|
ok(error == ERROR_INVALID_PARAMETER, "got %u\n", error);
|
|
|
|
|
|
|
|
len = 0;
|
|
|
|
error = pWinHttpWebSocketQueryCloseStatus(socket, &close_status, NULL, 0, &len);
|
|
|
|
ok(error == ERROR_INSUFFICIENT_BUFFER, "got %u\n", error);
|
|
|
|
ok(len, "len not set\n");
|
|
|
|
|
|
|
|
error = pWinHttpWebSocketQueryCloseStatus(socket, &close_status, NULL, 1, &len);
|
|
|
|
ok(error == ERROR_INVALID_PARAMETER, "got %u\n", error);
|
|
|
|
|
|
|
|
close_status = 0xdead;
|
|
|
|
len = 0xdeadbeef;
|
|
|
|
memset(buf, 0, sizeof(buf));
|
|
|
|
error = pWinHttpWebSocketQueryCloseStatus(socket, &close_status, buf, sizeof(buf), &len);
|
|
|
|
ok(!error, "got %u\n", error);
|
|
|
|
ok(close_status == 1000, "got %08x\n", close_status);
|
|
|
|
ok(len == sizeof("success"), "got %u\n", len);
|
|
|
|
|
|
|
|
WinHttpCloseHandle(socket);
|
|
|
|
WinHttpCloseHandle(request);
|
|
|
|
WinHttpCloseHandle(connection);
|
|
|
|
WinHttpCloseHandle(session);
|
2020-06-16 11:45:12 +02:00
|
|
|
}
|
|
|
|
|
2014-12-09 12:50:07 +01:00
|
|
|
static void test_not_modified(int port)
|
|
|
|
{
|
|
|
|
BOOL ret;
|
|
|
|
HINTERNET session, request, connection;
|
2015-06-17 15:11:50 +02:00
|
|
|
DWORD index, len, status, size, start = GetTickCount();
|
2014-12-09 12:50:07 +01:00
|
|
|
SYSTEMTIME st;
|
2020-02-14 16:41:38 +01:00
|
|
|
WCHAR today[(sizeof(L"If-Modified-Since: ") + WINHTTP_TIME_FORMAT_BUFSIZE)/sizeof(WCHAR) + 3], buffer[32];
|
2014-12-09 12:50:07 +01:00
|
|
|
|
2020-02-14 16:41:38 +01:00
|
|
|
memcpy(today, L"If-Modified-Since: ", sizeof(L"If-Modified-Since: "));
|
2014-12-09 12:50:07 +01:00
|
|
|
GetSystemTime(&st);
|
2020-02-14 16:41:38 +01:00
|
|
|
WinHttpTimeFromSystemTime(&st, &today[ARRAY_SIZE(L"If-Modified-Since: ") - 1]);
|
2014-12-09 12:50:07 +01:00
|
|
|
|
2020-02-14 16:41:38 +01:00
|
|
|
session = WinHttpOpen(L"winetest", WINHTTP_ACCESS_TYPE_NO_PROXY,
|
2014-12-09 12:50:07 +01:00
|
|
|
WINHTTP_NO_PROXY_NAME, WINHTTP_NO_PROXY_BYPASS, 0);
|
|
|
|
ok(session != NULL, "WinHttpOpen failed: %u\n", GetLastError());
|
|
|
|
|
2020-02-14 16:41:38 +01:00
|
|
|
connection = WinHttpConnect(session, L"localhost", port, 0);
|
2014-12-09 12:50:07 +01:00
|
|
|
ok(connection != NULL, "WinHttpConnect failed: %u\n", GetLastError());
|
|
|
|
|
2020-02-14 16:41:38 +01:00
|
|
|
request = WinHttpOpenRequest(connection, NULL, L"/not_modified", NULL, WINHTTP_NO_REFERER,
|
2014-12-09 12:50:07 +01:00
|
|
|
WINHTTP_DEFAULT_ACCEPT_TYPES, WINHTTP_FLAG_BYPASS_PROXY_CACHE);
|
|
|
|
ok(request != NULL, "WinHttpOpenrequest failed: %u\n", GetLastError());
|
|
|
|
|
2015-06-17 15:11:50 +02:00
|
|
|
ret = WinHttpSendRequest(request, today, 0, NULL, 0, 0, 0);
|
2014-12-09 12:50:07 +01:00
|
|
|
ok(ret, "WinHttpSendRequest failed: %u\n", GetLastError());
|
|
|
|
|
|
|
|
ret = WinHttpReceiveResponse(request, NULL);
|
|
|
|
ok(ret, "WinHttpReceiveResponse failed: %u\n", GetLastError());
|
|
|
|
|
2015-06-17 15:11:50 +02:00
|
|
|
index = 0;
|
|
|
|
len = sizeof(buffer);
|
|
|
|
ret = WinHttpQueryHeaders(request, WINHTTP_QUERY_CUSTOM | WINHTTP_QUERY_FLAG_REQUEST_HEADERS,
|
2020-02-14 16:41:38 +01:00
|
|
|
L"If-Modified-Since", buffer, &len, &index);
|
2015-06-17 15:11:50 +02:00
|
|
|
ok(ret, "failed to get header %u\n", GetLastError());
|
|
|
|
|
2015-04-21 11:21:06 +02:00
|
|
|
status = 0xdeadbeef;
|
2014-12-09 12:50:07 +01:00
|
|
|
size = sizeof(status);
|
|
|
|
ret = WinHttpQueryHeaders(request, WINHTTP_QUERY_STATUS_CODE|WINHTTP_QUERY_FLAG_NUMBER,
|
|
|
|
NULL, &status, &size, NULL);
|
|
|
|
ok(ret, "WinHttpQueryHeaders failed: %u\n", GetLastError());
|
|
|
|
ok(status == HTTP_STATUS_NOT_MODIFIED, "got %u\n", status);
|
|
|
|
|
|
|
|
size = 0xdeadbeef;
|
|
|
|
ret = WinHttpQueryDataAvailable(request, &size);
|
|
|
|
ok(ret, "WinHttpQueryDataAvailable failed: %u\n", GetLastError());
|
|
|
|
ok(!size, "got %u\n", size);
|
|
|
|
|
|
|
|
WinHttpCloseHandle(request);
|
|
|
|
WinHttpCloseHandle(connection);
|
|
|
|
WinHttpCloseHandle(session);
|
|
|
|
start = GetTickCount() - start;
|
|
|
|
ok(start <= 2000, "Expected less than 2 seconds for the test, got %u ms\n", start);
|
|
|
|
}
|
|
|
|
|
2012-03-12 12:25:14 +01:00
|
|
|
static void test_bad_header( int port )
|
|
|
|
{
|
|
|
|
WCHAR buffer[32];
|
|
|
|
HINTERNET ses, con, req;
|
|
|
|
DWORD index, len;
|
|
|
|
BOOL ret;
|
|
|
|
|
2020-02-14 16:41:38 +01:00
|
|
|
ses = WinHttpOpen( L"winetest", WINHTTP_ACCESS_TYPE_NO_PROXY, NULL, NULL, 0 );
|
2012-03-12 12:25:14 +01:00
|
|
|
ok( ses != NULL, "failed to open session %u\n", GetLastError() );
|
|
|
|
|
2020-02-14 16:41:38 +01:00
|
|
|
con = WinHttpConnect( ses, L"localhost", port, 0 );
|
2012-03-12 12:25:14 +01:00
|
|
|
ok( con != NULL, "failed to open a connection %u\n", GetLastError() );
|
|
|
|
|
|
|
|
req = WinHttpOpenRequest( con, NULL, NULL, NULL, NULL, NULL, 0 );
|
|
|
|
ok( req != NULL, "failed to open a request %u\n", GetLastError() );
|
|
|
|
|
2020-02-14 16:41:38 +01:00
|
|
|
ret = WinHttpAddRequestHeaders( req, L"Content-Type: text/html\n\r", ~0u, WINHTTP_ADDREQ_FLAG_ADD );
|
2012-03-12 12:25:14 +01:00
|
|
|
ok( ret, "failed to add header %u\n", GetLastError() );
|
|
|
|
|
|
|
|
index = 0;
|
|
|
|
buffer[0] = 0;
|
|
|
|
len = sizeof(buffer);
|
|
|
|
ret = WinHttpQueryHeaders( req, WINHTTP_QUERY_CUSTOM|WINHTTP_QUERY_FLAG_REQUEST_HEADERS,
|
2020-02-14 16:41:38 +01:00
|
|
|
L"Content-Type", buffer, &len, &index );
|
2012-03-12 12:25:14 +01:00
|
|
|
ok( ret, "failed to query headers %u\n", GetLastError() );
|
2020-02-14 16:41:38 +01:00
|
|
|
ok( !lstrcmpW( buffer, L"text/html" ), "got %s\n", wine_dbgstr_w(buffer) );
|
2018-09-19 16:17:46 +02:00
|
|
|
ok( index == 1, "index = %u\n", index );
|
2012-03-12 12:25:14 +01:00
|
|
|
|
|
|
|
WinHttpCloseHandle( req );
|
|
|
|
WinHttpCloseHandle( con );
|
|
|
|
WinHttpCloseHandle( ses );
|
|
|
|
}
|
|
|
|
|
2013-10-14 21:36:05 +02:00
|
|
|
static void test_multiple_reads(int port)
|
|
|
|
{
|
|
|
|
HINTERNET ses, con, req;
|
|
|
|
DWORD total_len = 0;
|
|
|
|
BOOL ret;
|
|
|
|
|
2020-02-14 16:41:38 +01:00
|
|
|
ses = WinHttpOpen(L"winetest", WINHTTP_ACCESS_TYPE_NO_PROXY, NULL, NULL, 0);
|
2013-10-14 21:36:05 +02:00
|
|
|
ok(ses != NULL, "failed to open session %u\n", GetLastError());
|
|
|
|
|
2020-02-14 16:41:38 +01:00
|
|
|
con = WinHttpConnect(ses, L"localhost", port, 0);
|
2013-10-14 21:36:05 +02:00
|
|
|
ok(con != NULL, "failed to open a connection %u\n", GetLastError());
|
|
|
|
|
2020-02-14 16:41:38 +01:00
|
|
|
req = WinHttpOpenRequest(con, NULL, L"big", NULL, NULL, NULL, 0);
|
2013-10-14 21:36:05 +02:00
|
|
|
ok(req != NULL, "failed to open a request %u\n", GetLastError());
|
|
|
|
|
|
|
|
ret = WinHttpSendRequest(req, NULL, 0, NULL, 0, 0, 0);
|
|
|
|
ok(ret, "failed to send request %u\n", GetLastError());
|
|
|
|
|
|
|
|
ret = WinHttpReceiveResponse(req, NULL);
|
|
|
|
ok(ret == TRUE, "expected success\n");
|
|
|
|
|
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
DWORD len = 0xdeadbeef;
|
|
|
|
ret = WinHttpQueryDataAvailable( req, &len );
|
|
|
|
ok( ret, "WinHttpQueryDataAvailable failed with error %u\n", GetLastError() );
|
|
|
|
if (ret) ok( len != 0xdeadbeef, "WinHttpQueryDataAvailable return wrong length\n" );
|
|
|
|
if (len)
|
|
|
|
{
|
|
|
|
DWORD bytes_read;
|
|
|
|
char *buf = HeapAlloc( GetProcessHeap(), 0, len + 1 );
|
|
|
|
|
|
|
|
ret = WinHttpReadData( req, buf, len, &bytes_read );
|
2019-01-31 21:31:46 +01:00
|
|
|
ok(ret, "WinHttpReadData failed: %u.\n", GetLastError());
|
2013-10-14 21:36:05 +02:00
|
|
|
ok( len == bytes_read, "only got %u of %u available\n", bytes_read, len );
|
|
|
|
|
|
|
|
HeapFree( GetProcessHeap(), 0, buf );
|
|
|
|
if (!bytes_read) break;
|
|
|
|
total_len += bytes_read;
|
|
|
|
}
|
|
|
|
if (!len) break;
|
|
|
|
}
|
|
|
|
ok(total_len == BIG_BUFFER_LEN, "got wrong length: 0x%x\n", total_len);
|
|
|
|
|
|
|
|
WinHttpCloseHandle(req);
|
|
|
|
WinHttpCloseHandle(con);
|
|
|
|
WinHttpCloseHandle(ses);
|
|
|
|
}
|
|
|
|
|
2015-06-15 17:32:25 +02:00
|
|
|
static void test_cookies( int port )
|
|
|
|
{
|
|
|
|
HINTERNET ses, con, req;
|
|
|
|
DWORD status, size;
|
|
|
|
BOOL ret;
|
|
|
|
|
2020-02-14 16:41:38 +01:00
|
|
|
ses = WinHttpOpen( L"winetest", WINHTTP_ACCESS_TYPE_NO_PROXY, NULL, NULL, 0 );
|
2015-06-15 17:32:25 +02:00
|
|
|
ok( ses != NULL, "failed to open session %u\n", GetLastError() );
|
|
|
|
|
2020-02-14 16:41:38 +01:00
|
|
|
con = WinHttpConnect( ses, L"localhost", port, 0 );
|
2015-06-15 17:32:25 +02:00
|
|
|
ok( con != NULL, "failed to open a connection %u\n", GetLastError() );
|
|
|
|
|
2020-02-14 16:41:38 +01:00
|
|
|
req = WinHttpOpenRequest( con, NULL, L"/cookie", NULL, NULL, NULL, 0 );
|
2015-06-15 17:32:25 +02:00
|
|
|
ok( req != NULL, "failed to open a request %u\n", GetLastError() );
|
|
|
|
|
|
|
|
ret = WinHttpSendRequest( req, NULL, 0, NULL, 0, 0, 0 );
|
|
|
|
ok( ret, "failed to send request %u\n", GetLastError() );
|
|
|
|
|
|
|
|
ret = WinHttpReceiveResponse( req, NULL );
|
|
|
|
ok( ret, "failed to receive response %u\n", GetLastError() );
|
|
|
|
|
|
|
|
status = 0xdeadbeef;
|
|
|
|
size = sizeof(status);
|
|
|
|
ret = WinHttpQueryHeaders( req, WINHTTP_QUERY_STATUS_CODE|WINHTTP_QUERY_FLAG_NUMBER, NULL, &status, &size, NULL );
|
|
|
|
ok( ret, "failed to query status code %u\n", GetLastError() );
|
2015-12-08 00:01:29 +01:00
|
|
|
ok( status == HTTP_STATUS_OK, "request failed unexpectedly %u\n", status );
|
2015-06-15 17:32:25 +02:00
|
|
|
|
|
|
|
WinHttpCloseHandle( req );
|
|
|
|
|
2020-02-14 16:41:38 +01:00
|
|
|
req = WinHttpOpenRequest( con, NULL, L"/cookie2", NULL, NULL, NULL, 0 );
|
2015-06-15 17:32:25 +02:00
|
|
|
ok( req != NULL, "failed to open a request %u\n", GetLastError() );
|
|
|
|
|
|
|
|
ret = WinHttpSendRequest( req, NULL, 0, NULL, 0, 0, 0 );
|
|
|
|
ok( ret, "failed to send request %u\n", GetLastError() );
|
|
|
|
|
|
|
|
ret = WinHttpReceiveResponse( req, NULL );
|
|
|
|
ok( ret, "failed to receive response %u\n", GetLastError() );
|
|
|
|
|
|
|
|
status = 0xdeadbeef;
|
|
|
|
size = sizeof(status);
|
|
|
|
ret = WinHttpQueryHeaders( req, WINHTTP_QUERY_STATUS_CODE|WINHTTP_QUERY_FLAG_NUMBER, NULL, &status, &size, NULL );
|
|
|
|
ok( ret, "failed to query status code %u\n", GetLastError() );
|
2015-12-08 00:01:29 +01:00
|
|
|
ok( status == HTTP_STATUS_OK, "request failed unexpectedly %u\n", status );
|
2015-06-15 17:32:25 +02:00
|
|
|
|
|
|
|
WinHttpCloseHandle( req );
|
|
|
|
WinHttpCloseHandle( con );
|
|
|
|
|
2020-02-14 16:41:38 +01:00
|
|
|
con = WinHttpConnect( ses, L"localhost", port, 0 );
|
2015-06-15 17:32:25 +02:00
|
|
|
ok( con != NULL, "failed to open a connection %u\n", GetLastError() );
|
|
|
|
|
2020-02-14 16:41:38 +01:00
|
|
|
req = WinHttpOpenRequest( con, NULL, L"/cookie2", NULL, NULL, NULL, 0 );
|
2015-06-15 17:32:25 +02:00
|
|
|
ok( req != NULL, "failed to open a request %u\n", GetLastError() );
|
|
|
|
|
|
|
|
ret = WinHttpSendRequest( req, NULL, 0, NULL, 0, 0, 0 );
|
|
|
|
ok( ret, "failed to send request %u\n", GetLastError() );
|
|
|
|
|
|
|
|
ret = WinHttpReceiveResponse( req, NULL );
|
|
|
|
ok( ret, "failed to receive response %u\n", GetLastError() );
|
|
|
|
|
|
|
|
status = 0xdeadbeef;
|
|
|
|
size = sizeof(status);
|
|
|
|
ret = WinHttpQueryHeaders( req, WINHTTP_QUERY_STATUS_CODE|WINHTTP_QUERY_FLAG_NUMBER, NULL, &status, &size, NULL );
|
|
|
|
ok( ret, "failed to query status code %u\n", GetLastError() );
|
2015-12-08 00:01:29 +01:00
|
|
|
ok( status == HTTP_STATUS_OK, "request failed unexpectedly %u\n", status );
|
2015-06-15 17:32:25 +02:00
|
|
|
|
2015-06-24 14:17:31 +02:00
|
|
|
WinHttpCloseHandle( req );
|
|
|
|
|
2020-02-14 16:41:38 +01:00
|
|
|
req = WinHttpOpenRequest( con, NULL, L"/cookie3", NULL, NULL, NULL, 0 );
|
2015-06-24 14:17:31 +02:00
|
|
|
ok( req != NULL, "failed to open a request %u\n", GetLastError() );
|
2020-02-14 16:41:38 +01:00
|
|
|
ret = WinHttpSendRequest( req, L"Cookie: name=value2\r\n", ~0u, NULL, 0, 0, 0 );
|
2015-06-24 14:17:31 +02:00
|
|
|
ok( ret, "failed to send request %u\n", GetLastError() );
|
|
|
|
|
|
|
|
ret = WinHttpReceiveResponse( req, NULL );
|
|
|
|
ok( ret, "failed to receive response %u\n", GetLastError() );
|
|
|
|
|
|
|
|
status = 0xdeadbeef;
|
|
|
|
size = sizeof(status);
|
|
|
|
ret = WinHttpQueryHeaders( req, WINHTTP_QUERY_STATUS_CODE|WINHTTP_QUERY_FLAG_NUMBER, NULL, &status, &size, NULL );
|
|
|
|
ok( ret, "failed to query status code %u\n", GetLastError() );
|
2015-12-08 00:01:29 +01:00
|
|
|
ok( status == HTTP_STATUS_OK || broken(status == HTTP_STATUS_BAD_REQUEST), "request failed unexpectedly %u\n", status );
|
2015-06-24 14:17:31 +02:00
|
|
|
|
2015-06-15 17:32:25 +02:00
|
|
|
WinHttpCloseHandle( req );
|
|
|
|
WinHttpCloseHandle( con );
|
|
|
|
WinHttpCloseHandle( ses );
|
|
|
|
|
2020-02-14 16:41:38 +01:00
|
|
|
ses = WinHttpOpen( L"winetest", WINHTTP_ACCESS_TYPE_NO_PROXY, NULL, NULL, 0 );
|
2015-06-15 17:32:25 +02:00
|
|
|
ok( ses != NULL, "failed to open session %u\n", GetLastError() );
|
|
|
|
|
2020-02-14 16:41:38 +01:00
|
|
|
con = WinHttpConnect( ses, L"localhost", port, 0 );
|
2015-06-15 17:32:25 +02:00
|
|
|
ok( con != NULL, "failed to open a connection %u\n", GetLastError() );
|
|
|
|
|
2020-02-14 16:41:38 +01:00
|
|
|
req = WinHttpOpenRequest( con, NULL, L"/cookie2", NULL, NULL, NULL, 0 );
|
2015-06-15 17:32:25 +02:00
|
|
|
ok( req != NULL, "failed to open a request %u\n", GetLastError() );
|
|
|
|
|
|
|
|
ret = WinHttpSendRequest( req, NULL, 0, NULL, 0, 0, 0 );
|
|
|
|
ok( ret, "failed to send request %u\n", GetLastError() );
|
|
|
|
|
|
|
|
ret = WinHttpReceiveResponse( req, NULL );
|
|
|
|
ok( ret, "failed to receive response %u\n", GetLastError() );
|
|
|
|
|
|
|
|
status = 0xdeadbeef;
|
|
|
|
size = sizeof(status);
|
|
|
|
ret = WinHttpQueryHeaders( req, WINHTTP_QUERY_STATUS_CODE|WINHTTP_QUERY_FLAG_NUMBER, NULL, &status, &size, NULL );
|
|
|
|
ok( ret, "failed to query status code %u\n", GetLastError() );
|
2015-12-08 00:01:29 +01:00
|
|
|
ok( status == HTTP_STATUS_BAD_REQUEST, "request failed unexpectedly %u\n", status );
|
2015-06-15 17:32:25 +02:00
|
|
|
|
|
|
|
WinHttpCloseHandle( req );
|
|
|
|
WinHttpCloseHandle( con );
|
|
|
|
WinHttpCloseHandle( ses );
|
2017-02-21 09:24:37 +01:00
|
|
|
|
2020-02-14 16:41:38 +01:00
|
|
|
ses = WinHttpOpen( L"winetest", WINHTTP_ACCESS_TYPE_NO_PROXY, NULL, NULL, 0 );
|
2017-02-21 09:24:37 +01:00
|
|
|
ok( ses != NULL, "failed to open session %u\n", GetLastError() );
|
|
|
|
|
2020-02-14 16:41:38 +01:00
|
|
|
con = WinHttpConnect( ses, L"localhost", port, 0 );
|
2017-02-21 09:24:37 +01:00
|
|
|
ok( con != NULL, "failed to open a connection %u\n", GetLastError() );
|
|
|
|
|
2020-02-14 16:41:38 +01:00
|
|
|
req = WinHttpOpenRequest( con, NULL, L"/cookie4", NULL, NULL, NULL, 0 );
|
2017-02-21 09:24:37 +01:00
|
|
|
ok( req != NULL, "failed to open a request %u\n", GetLastError() );
|
|
|
|
|
|
|
|
ret = WinHttpSendRequest( req, NULL, 0, NULL, 0, 0, 0 );
|
|
|
|
ok( ret, "failed to send request %u\n", GetLastError() );
|
|
|
|
|
|
|
|
ret = WinHttpReceiveResponse( req, NULL );
|
|
|
|
ok( ret, "failed to receive response %u\n", GetLastError() );
|
|
|
|
|
|
|
|
status = 0xdeadbeef;
|
|
|
|
size = sizeof(status);
|
|
|
|
ret = WinHttpQueryHeaders( req, WINHTTP_QUERY_STATUS_CODE|WINHTTP_QUERY_FLAG_NUMBER, NULL, &status, &size, NULL );
|
|
|
|
ok( ret, "failed to query status code %u\n", GetLastError() );
|
|
|
|
ok( status == HTTP_STATUS_OK, "request failed unexpectedly %u\n", status );
|
|
|
|
WinHttpCloseHandle( req );
|
|
|
|
|
2020-02-14 16:41:38 +01:00
|
|
|
req = WinHttpOpenRequest( con, NULL, L"/cookie5", NULL, NULL, NULL, 0 );
|
2017-02-21 09:24:37 +01:00
|
|
|
ok( req != NULL, "failed to open a request %u\n", GetLastError() );
|
|
|
|
|
|
|
|
ret = WinHttpSendRequest( req, NULL, 0, NULL, 0, 0, 0 );
|
|
|
|
ok( ret, "failed to send request %u\n", GetLastError() );
|
|
|
|
|
|
|
|
ret = WinHttpReceiveResponse( req, NULL );
|
|
|
|
ok( ret, "failed to receive response %u\n", GetLastError() );
|
|
|
|
|
|
|
|
status = 0xdeadbeef;
|
|
|
|
size = sizeof(status);
|
|
|
|
ret = WinHttpQueryHeaders( req, WINHTTP_QUERY_STATUS_CODE|WINHTTP_QUERY_FLAG_NUMBER, NULL, &status, &size, NULL );
|
|
|
|
ok( ret, "failed to query status code %u\n", GetLastError() );
|
|
|
|
ok( status == HTTP_STATUS_OK || broken(status == HTTP_STATUS_BAD_REQUEST) /* < win7 */,
|
|
|
|
"request failed unexpectedly %u\n", status );
|
|
|
|
|
|
|
|
WinHttpCloseHandle( req );
|
|
|
|
WinHttpCloseHandle( con );
|
|
|
|
WinHttpCloseHandle( ses );
|
2015-06-15 17:32:25 +02:00
|
|
|
}
|
|
|
|
|
2018-10-04 10:32:01 +02:00
|
|
|
static void do_request( HINTERNET con, const WCHAR *obj, DWORD flags )
|
2018-08-24 13:32:42 +02:00
|
|
|
{
|
2018-10-04 10:32:01 +02:00
|
|
|
HINTERNET req;
|
2018-08-24 13:32:42 +02:00
|
|
|
DWORD status, size;
|
|
|
|
BOOL ret;
|
|
|
|
|
2018-10-04 10:32:01 +02:00
|
|
|
req = WinHttpOpenRequest( con, NULL, obj, NULL, NULL, NULL, flags );
|
2018-08-24 13:32:42 +02:00
|
|
|
ok( req != NULL, "failed to open a request %u\n", GetLastError() );
|
|
|
|
|
|
|
|
ret = WinHttpSendRequest( req, NULL, 0, NULL, 0, 0, 0 );
|
|
|
|
ok( ret, "failed to send request %u\n", GetLastError() );
|
|
|
|
|
|
|
|
ret = WinHttpReceiveResponse( req, NULL );
|
|
|
|
ok( ret, "failed to receive response %u\n", GetLastError() );
|
|
|
|
|
|
|
|
status = 0xdeadbeef;
|
|
|
|
size = sizeof(status);
|
|
|
|
ret = WinHttpQueryHeaders( req, WINHTTP_QUERY_STATUS_CODE|WINHTTP_QUERY_FLAG_NUMBER, NULL, &status, &size, NULL );
|
|
|
|
ok( ret, "failed to query status code %u\n", GetLastError() );
|
2018-11-06 16:09:04 +01:00
|
|
|
ok( status == HTTP_STATUS_OK || broken(status == HTTP_STATUS_BAD_REQUEST) /* < win7 */,
|
|
|
|
"request %s with flags %08x failed %u\n", wine_dbgstr_w(obj), flags, status );
|
2018-08-24 13:32:42 +02:00
|
|
|
WinHttpCloseHandle( req );
|
2018-10-04 10:32:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void test_request_path_escapes( int port )
|
|
|
|
{
|
|
|
|
static const WCHAR objW[] =
|
|
|
|
{'/','e','s','c','a','p','e','\r','\n',0x1f,0x7f,'<',' ','%','o','n','e','?',0x1f,0x7f,' ','!','"','#',
|
|
|
|
'$','%','&','\'','(',')','*','+',',','-','.','/',':',';','<','=','>','?','@','[','\\',']','^','_','`',
|
|
|
|
'{','|','}','~','\r','\n',0};
|
|
|
|
static const WCHAR obj2W[] =
|
|
|
|
{'/','e','s','c','a','p','e','\r','\n',0x1f,0x7f,'<',' ','%','t','w','o','?',0x1f,0x7f,' ','!','"','#',
|
|
|
|
'$','%','&','\'','(',')','*','+',',','-','.','/',':',';','<','=','>','?','@','[','\\',']','^','_','`',
|
|
|
|
'{','|','}','~','\r','\n',0};
|
|
|
|
static const WCHAR obj3W[] =
|
|
|
|
{'/','e','s','c','a','p','e','\r','\n',0x1f,0x7f,'<',' ','%','t','h','r','e','e','?',0x1f,0x7f,' ','!',
|
|
|
|
'"','#','$','%','&','\'','(',')','*','+',',','-','.','/',':',';','<','=','>','?','@','[','\\',']','^',
|
|
|
|
'_','`','{','|','}','~','\r','\n',0};
|
|
|
|
static const WCHAR obj4W[] =
|
|
|
|
{'/','e','s','c','a','p','e','\r','\n',0x1f,0x7f,'<',' ','%','f','o','u','r','?',0x1f,0x7f,' ','!','"',
|
|
|
|
'#','$','%','&','\'','(',')','*','+',',','-','.','/',':',';','<','=','>','?','@','[','\\',']','^','_',
|
|
|
|
'`','{','|','}','~','\r','\n',0};
|
2018-11-06 16:09:04 +01:00
|
|
|
static const WCHAR obj5W[] =
|
|
|
|
{'/','e','s','c','a','p','e','&','t','e','x','t','=','o','n','e',0x80,0x7f,0x7e,0};
|
|
|
|
static const WCHAR obj6W[] =
|
|
|
|
{'/','e','s','c','a','p','e','&','t','e','x','t','=','t','w','o',0x80,0x7f,0x7e,0};
|
|
|
|
static const WCHAR obj7W[] =
|
|
|
|
{'/','e','s','c','a','p','e','&','t','e','x','t','=',0x541b,0x306e,0x540d,0x306f,0};
|
2018-10-04 10:32:01 +02:00
|
|
|
HINTERNET ses, con;
|
|
|
|
|
2020-02-14 16:41:38 +01:00
|
|
|
ses = WinHttpOpen( L"winetest", WINHTTP_ACCESS_TYPE_NO_PROXY, NULL, NULL, 0 );
|
2018-10-04 10:32:01 +02:00
|
|
|
ok( ses != NULL, "failed to open session %u\n", GetLastError() );
|
|
|
|
|
2020-02-14 16:41:38 +01:00
|
|
|
con = WinHttpConnect( ses, L"localhost", port, 0 );
|
2018-10-04 10:32:01 +02:00
|
|
|
ok( con != NULL, "failed to open a connection %u\n", GetLastError() );
|
|
|
|
|
|
|
|
do_request( con, objW, 0 );
|
|
|
|
do_request( con, obj2W, WINHTTP_FLAG_ESCAPE_PERCENT );
|
|
|
|
do_request( con, obj3W, WINHTTP_FLAG_ESCAPE_DISABLE );
|
|
|
|
do_request( con, obj4W, WINHTTP_FLAG_ESCAPE_DISABLE_QUERY );
|
2018-11-06 16:09:04 +01:00
|
|
|
do_request( con, obj5W, 0 );
|
|
|
|
do_request( con, obj6W, WINHTTP_FLAG_ESCAPE_DISABLE );
|
|
|
|
do_request( con, obj7W, WINHTTP_FLAG_ESCAPE_DISABLE );
|
2018-10-04 10:32:01 +02:00
|
|
|
|
2018-08-24 13:32:42 +02:00
|
|
|
WinHttpCloseHandle( con );
|
|
|
|
WinHttpCloseHandle( ses );
|
|
|
|
}
|
|
|
|
|
2013-03-15 10:39:00 +01:00
|
|
|
static void test_connection_info( int port )
|
|
|
|
{
|
|
|
|
HINTERNET ses, con, req;
|
|
|
|
WINHTTP_CONNECTION_INFO info;
|
|
|
|
DWORD size, error;
|
|
|
|
BOOL ret;
|
|
|
|
|
2020-02-14 16:41:38 +01:00
|
|
|
ses = WinHttpOpen( L"winetest", WINHTTP_ACCESS_TYPE_NO_PROXY, NULL, NULL, 0 );
|
2013-03-15 10:39:00 +01:00
|
|
|
ok( ses != NULL, "failed to open session %u\n", GetLastError() );
|
|
|
|
|
2020-02-14 16:41:38 +01:00
|
|
|
con = WinHttpConnect( ses, L"localhost", port, 0 );
|
2013-03-15 10:39:00 +01:00
|
|
|
ok( con != NULL, "failed to open a connection %u\n", GetLastError() );
|
|
|
|
|
2020-02-14 16:41:38 +01:00
|
|
|
req = WinHttpOpenRequest( con, NULL, L"/basic", NULL, NULL, NULL, 0 );
|
2013-03-15 10:39:00 +01:00
|
|
|
ok( req != NULL, "failed to open a request %u\n", GetLastError() );
|
|
|
|
|
|
|
|
size = sizeof(info);
|
|
|
|
SetLastError( 0xdeadbeef );
|
|
|
|
ret = WinHttpQueryOption( req, WINHTTP_OPTION_CONNECTION_INFO, &info, &size );
|
|
|
|
error = GetLastError();
|
|
|
|
if (!ret && error == ERROR_INVALID_PARAMETER)
|
|
|
|
{
|
|
|
|
win_skip( "WINHTTP_OPTION_CONNECTION_INFO not supported\n" );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
ok( !ret, "unexpected success\n" );
|
|
|
|
ok( error == ERROR_WINHTTP_INCORRECT_HANDLE_STATE, "got %u\n", error );
|
|
|
|
|
|
|
|
ret = WinHttpSendRequest( req, NULL, 0, NULL, 0, 0, 0 );
|
|
|
|
ok( ret, "failed to send request %u\n", GetLastError() );
|
|
|
|
|
|
|
|
size = 0;
|
|
|
|
SetLastError( 0xdeadbeef );
|
|
|
|
ret = WinHttpQueryOption( req, WINHTTP_OPTION_CONNECTION_INFO, &info, &size );
|
|
|
|
error = GetLastError();
|
|
|
|
ok( !ret, "unexpected success\n" );
|
|
|
|
ok( error == ERROR_INSUFFICIENT_BUFFER, "got %u\n", error );
|
|
|
|
|
|
|
|
size = sizeof(info);
|
|
|
|
memset( &info, 0, sizeof(info) );
|
|
|
|
ret = WinHttpQueryOption( req, WINHTTP_OPTION_CONNECTION_INFO, &info, &size );
|
|
|
|
ok( ret, "failed to retrieve connection info %u\n", GetLastError() );
|
2015-12-04 10:14:05 +01:00
|
|
|
ok( info.cbSize == sizeof(info) || info.cbSize == sizeof(info) - sizeof(info.cbSize) /* Win7 */, "wrong size %u\n", info.cbSize );
|
2013-03-15 10:39:00 +01:00
|
|
|
|
|
|
|
ret = WinHttpReceiveResponse( req, NULL );
|
|
|
|
ok( ret, "failed to receive response %u\n", GetLastError() );
|
|
|
|
|
|
|
|
size = sizeof(info);
|
|
|
|
memset( &info, 0, sizeof(info) );
|
|
|
|
ret = WinHttpQueryOption( req, WINHTTP_OPTION_CONNECTION_INFO, &info, &size );
|
|
|
|
ok( ret, "failed to retrieve connection info %u\n", GetLastError() );
|
2015-12-04 10:14:05 +01:00
|
|
|
ok( info.cbSize == sizeof(info) || info.cbSize == sizeof(info) - sizeof(info.cbSize) /* Win7 */, "wrong size %u\n", info.cbSize );
|
2013-03-15 10:39:00 +01:00
|
|
|
|
|
|
|
WinHttpCloseHandle( req );
|
|
|
|
WinHttpCloseHandle( con );
|
|
|
|
WinHttpCloseHandle( ses );
|
|
|
|
}
|
|
|
|
|
2019-08-02 11:01:37 +02:00
|
|
|
static void test_passport_auth( int port )
|
|
|
|
{
|
|
|
|
static const WCHAR headersW[] =
|
2020-02-14 16:41:38 +01:00
|
|
|
L"HTTP/1.1 401 Found\r\nContent-Length: 0\r\nLocation: /\r\nWWW-Authenticate: Passport1.4\r\n\r\n";
|
2019-08-02 11:01:37 +02:00
|
|
|
HINTERNET ses, con, req;
|
2020-01-09 14:33:06 +01:00
|
|
|
DWORD status, size, option, err;
|
2019-08-02 11:01:37 +02:00
|
|
|
WCHAR buf[128];
|
|
|
|
BOOL ret;
|
|
|
|
|
2020-02-14 16:41:38 +01:00
|
|
|
ses = WinHttpOpen( L"winetest", 0, NULL, NULL, 0 );
|
2019-08-02 11:01:37 +02:00
|
|
|
ok( ses != NULL, "got %u\n", GetLastError() );
|
|
|
|
|
|
|
|
option = WINHTTP_ENABLE_PASSPORT_AUTH;
|
|
|
|
ret = WinHttpSetOption( ses, WINHTTP_OPTION_CONFIGURE_PASSPORT_AUTH, &option, sizeof(option) );
|
|
|
|
ok( ret, "got %u\n", GetLastError() );
|
|
|
|
|
2020-02-14 16:41:38 +01:00
|
|
|
con = WinHttpConnect( ses, L"localhost", port, 0 );
|
2019-08-02 11:01:37 +02:00
|
|
|
ok( con != NULL, "got %u\n", GetLastError() );
|
|
|
|
|
2020-02-14 16:41:38 +01:00
|
|
|
req = WinHttpOpenRequest( con, NULL, L"/passport", NULL, NULL, NULL, 0 );
|
2019-08-02 11:01:37 +02:00
|
|
|
ok( req != NULL, "got %u\n", GetLastError() );
|
|
|
|
|
|
|
|
ret = WinHttpSendRequest( req, NULL, 0, NULL, 0, 0, 0 );
|
|
|
|
ok( ret, "got %u\n", GetLastError() );
|
|
|
|
|
|
|
|
ret = WinHttpReceiveResponse( req, NULL );
|
2020-01-09 14:33:06 +01:00
|
|
|
err = GetLastError();
|
|
|
|
ok( ret || broken(!ret && err == ERROR_WINHTTP_LOGIN_FAILURE) /* winxp */
|
|
|
|
|| broken(!ret && err == ERROR_WINHTTP_INVALID_SERVER_RESPONSE ), "got %u\n", err );
|
|
|
|
if (!ret)
|
2019-10-03 14:56:25 +02:00
|
|
|
{
|
|
|
|
win_skip("no support for Passport redirects\n");
|
|
|
|
goto cleanup;
|
|
|
|
}
|
2019-08-02 11:01:37 +02:00
|
|
|
|
|
|
|
status = 0xdeadbeef;
|
|
|
|
size = sizeof(status);
|
|
|
|
ret = WinHttpQueryHeaders( req, WINHTTP_QUERY_STATUS_CODE|WINHTTP_QUERY_FLAG_NUMBER, NULL, &status, &size, NULL );
|
|
|
|
ok( ret, "got %u\n", GetLastError() );
|
|
|
|
ok( status == HTTP_STATUS_DENIED, "got %u\n", status );
|
|
|
|
|
|
|
|
buf[0] = 0;
|
|
|
|
size = sizeof(buf);
|
|
|
|
ret = WinHttpQueryHeaders( req, WINHTTP_QUERY_STATUS_TEXT, NULL, buf, &size, NULL );
|
|
|
|
ok( ret, "got %u\n", GetLastError() );
|
2020-02-14 16:41:38 +01:00
|
|
|
ok( !lstrcmpW(L"Found", buf) || broken(!lstrcmpW(L"Unauthorized", buf)) /* < win7 */, "got %s\n",
|
|
|
|
wine_dbgstr_w(buf) );
|
2019-08-02 11:01:37 +02:00
|
|
|
|
|
|
|
buf[0] = 0;
|
|
|
|
size = sizeof(buf);
|
|
|
|
ret = WinHttpQueryHeaders( req, WINHTTP_QUERY_RAW_HEADERS_CRLF, NULL, buf, &size, NULL );
|
|
|
|
ok( ret || broken(!ret && GetLastError() == ERROR_INSUFFICIENT_BUFFER) /* < win7 */, "got %u\n", GetLastError() );
|
|
|
|
if (ret)
|
|
|
|
{
|
|
|
|
ok( size == lstrlenW(headersW) * sizeof(WCHAR), "got %u\n", size );
|
|
|
|
ok( !lstrcmpW(headersW, buf), "got %s\n", wine_dbgstr_w(buf) );
|
|
|
|
}
|
|
|
|
|
2019-10-03 14:56:25 +02:00
|
|
|
cleanup:
|
2019-08-02 11:01:37 +02:00
|
|
|
WinHttpCloseHandle( req );
|
|
|
|
WinHttpCloseHandle( con );
|
|
|
|
WinHttpCloseHandle( ses );
|
|
|
|
}
|
|
|
|
|
2010-04-22 16:34:48 +02:00
|
|
|
static void test_credentials(void)
|
|
|
|
{
|
|
|
|
static WCHAR userW[] = {'u','s','e','r',0};
|
|
|
|
static WCHAR passW[] = {'p','a','s','s',0};
|
|
|
|
static WCHAR proxy_userW[] = {'p','r','o','x','y','u','s','e','r',0};
|
|
|
|
static WCHAR proxy_passW[] = {'p','r','o','x','y','p','a','s','s',0};
|
2010-04-22 16:35:56 +02:00
|
|
|
HINTERNET ses, con, req;
|
2010-04-22 16:34:48 +02:00
|
|
|
DWORD size, error;
|
|
|
|
WCHAR buffer[32];
|
|
|
|
BOOL ret;
|
|
|
|
|
2020-02-14 16:41:38 +01:00
|
|
|
ses = WinHttpOpen(L"winetest", 0, proxy_userW, proxy_passW, 0);
|
2010-04-22 16:34:48 +02:00
|
|
|
ok(ses != NULL, "failed to open session %u\n", GetLastError());
|
|
|
|
|
2020-02-14 16:41:38 +01:00
|
|
|
con = WinHttpConnect(ses, L"localhost", 0, 0);
|
2010-04-22 16:34:48 +02:00
|
|
|
ok(con != NULL, "failed to open a connection %u\n", GetLastError());
|
|
|
|
|
|
|
|
req = WinHttpOpenRequest(con, NULL, NULL, NULL, NULL, NULL, 0);
|
|
|
|
ok(req != NULL, "failed to open a request %u\n", GetLastError());
|
|
|
|
|
2018-06-11 23:29:15 +02:00
|
|
|
size = ARRAY_SIZE(buffer);
|
2010-04-22 16:34:48 +02:00
|
|
|
ret = WinHttpQueryOption(req, WINHTTP_OPTION_PROXY_USERNAME, &buffer, &size);
|
|
|
|
ok(ret, "failed to query proxy username %u\n", GetLastError());
|
|
|
|
ok(!buffer[0], "unexpected result %s\n", wine_dbgstr_w(buffer));
|
|
|
|
ok(!size, "expected 0, got %u\n", size);
|
|
|
|
|
2018-06-11 23:29:15 +02:00
|
|
|
size = ARRAY_SIZE(buffer);
|
2010-04-22 16:34:48 +02:00
|
|
|
ret = WinHttpQueryOption(req, WINHTTP_OPTION_PROXY_PASSWORD, &buffer, &size);
|
|
|
|
ok(ret, "failed to query proxy password %u\n", GetLastError());
|
|
|
|
ok(!buffer[0], "unexpected result %s\n", wine_dbgstr_w(buffer));
|
|
|
|
ok(!size, "expected 0, got %u\n", size);
|
|
|
|
|
|
|
|
ret = WinHttpSetOption(req, WINHTTP_OPTION_PROXY_USERNAME, proxy_userW, lstrlenW(proxy_userW));
|
|
|
|
ok(ret, "failed to set username %u\n", GetLastError());
|
|
|
|
|
2018-06-11 23:29:15 +02:00
|
|
|
size = ARRAY_SIZE(buffer);
|
2010-04-22 16:34:48 +02:00
|
|
|
ret = WinHttpQueryOption(req, WINHTTP_OPTION_PROXY_USERNAME, &buffer, &size);
|
|
|
|
ok(ret, "failed to query proxy username %u\n", GetLastError());
|
2019-11-29 13:58:00 +01:00
|
|
|
ok(!wcscmp(buffer, proxy_userW), "unexpected result %s\n", wine_dbgstr_w(buffer));
|
2010-04-22 16:34:48 +02:00
|
|
|
ok(size == lstrlenW(proxy_userW) * sizeof(WCHAR), "unexpected result %u\n", size);
|
|
|
|
|
2018-06-11 23:29:15 +02:00
|
|
|
size = ARRAY_SIZE(buffer);
|
2010-04-22 16:34:48 +02:00
|
|
|
ret = WinHttpQueryOption(req, WINHTTP_OPTION_USERNAME, &buffer, &size);
|
|
|
|
ok(ret, "failed to query username %u\n", GetLastError());
|
|
|
|
ok(!buffer[0], "unexpected result %s\n", wine_dbgstr_w(buffer));
|
|
|
|
ok(!size, "expected 0, got %u\n", size);
|
|
|
|
|
2018-06-11 23:29:15 +02:00
|
|
|
size = ARRAY_SIZE(buffer);
|
2010-04-22 16:34:48 +02:00
|
|
|
ret = WinHttpQueryOption(req, WINHTTP_OPTION_PASSWORD, &buffer, &size);
|
|
|
|
ok(ret, "failed to query password %u\n", GetLastError());
|
|
|
|
ok(!buffer[0], "unexpected result %s\n", wine_dbgstr_w(buffer));
|
|
|
|
ok(!size, "expected 0, got %u\n", size);
|
|
|
|
|
|
|
|
ret = WinHttpSetOption(req, WINHTTP_OPTION_PROXY_PASSWORD, proxy_passW, lstrlenW(proxy_passW));
|
|
|
|
ok(ret, "failed to set proxy password %u\n", GetLastError());
|
|
|
|
|
2018-06-11 23:29:15 +02:00
|
|
|
size = ARRAY_SIZE(buffer);
|
2010-04-22 16:34:48 +02:00
|
|
|
ret = WinHttpQueryOption(req, WINHTTP_OPTION_PROXY_PASSWORD, &buffer, &size);
|
|
|
|
ok(ret, "failed to query proxy password %u\n", GetLastError());
|
2019-11-29 13:58:00 +01:00
|
|
|
ok(!wcscmp(buffer, proxy_passW), "unexpected result %s\n", wine_dbgstr_w(buffer));
|
2010-04-22 16:34:48 +02:00
|
|
|
ok(size == lstrlenW(proxy_passW) * sizeof(WCHAR), "unexpected result %u\n", size);
|
|
|
|
|
|
|
|
ret = WinHttpSetOption(req, WINHTTP_OPTION_USERNAME, userW, lstrlenW(userW));
|
|
|
|
ok(ret, "failed to set username %u\n", GetLastError());
|
|
|
|
|
2018-06-11 23:29:15 +02:00
|
|
|
size = ARRAY_SIZE(buffer);
|
2010-04-22 16:34:48 +02:00
|
|
|
ret = WinHttpQueryOption(req, WINHTTP_OPTION_USERNAME, &buffer, &size);
|
|
|
|
ok(ret, "failed to query username %u\n", GetLastError());
|
2019-11-29 13:58:00 +01:00
|
|
|
ok(!wcscmp(buffer, userW), "unexpected result %s\n", wine_dbgstr_w(buffer));
|
2010-04-22 16:34:48 +02:00
|
|
|
ok(size == lstrlenW(userW) * sizeof(WCHAR), "unexpected result %u\n", size);
|
|
|
|
|
|
|
|
ret = WinHttpSetOption(req, WINHTTP_OPTION_PASSWORD, passW, lstrlenW(passW));
|
|
|
|
ok(ret, "failed to set password %u\n", GetLastError());
|
|
|
|
|
2018-06-11 23:29:15 +02:00
|
|
|
size = ARRAY_SIZE(buffer);
|
2010-04-22 16:34:48 +02:00
|
|
|
ret = WinHttpQueryOption(req, WINHTTP_OPTION_PASSWORD, &buffer, &size);
|
|
|
|
ok(ret, "failed to query password %u\n", GetLastError());
|
2019-11-29 13:58:00 +01:00
|
|
|
ok(!wcscmp(buffer, passW), "unexpected result %s\n", wine_dbgstr_w(buffer));
|
2010-04-22 16:34:48 +02:00
|
|
|
ok(size == lstrlenW(passW) * sizeof(WCHAR), "unexpected result %u\n", size);
|
|
|
|
|
|
|
|
WinHttpCloseHandle(req);
|
|
|
|
|
|
|
|
req = WinHttpOpenRequest(con, NULL, NULL, NULL, NULL, NULL, 0);
|
|
|
|
ok(req != NULL, "failed to open a request %u\n", GetLastError());
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = WinHttpSetCredentials(req, WINHTTP_AUTH_TARGET_SERVER, WINHTTP_AUTH_SCHEME_BASIC, userW, NULL, NULL);
|
|
|
|
error = GetLastError();
|
|
|
|
ok(!ret, "expected failure\n");
|
|
|
|
ok(error == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %u\n", error);
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = WinHttpSetCredentials(req, WINHTTP_AUTH_TARGET_SERVER, WINHTTP_AUTH_SCHEME_BASIC, NULL, passW, NULL);
|
|
|
|
error = GetLastError();
|
|
|
|
ok(!ret, "expected failure\n");
|
|
|
|
ok(error == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %u\n", error);
|
|
|
|
|
|
|
|
ret = WinHttpSetCredentials(req, WINHTTP_AUTH_TARGET_SERVER, WINHTTP_AUTH_SCHEME_BASIC, userW, passW, NULL);
|
|
|
|
ok(ret, "failed to set credentials %u\n", GetLastError());
|
|
|
|
|
2018-06-11 23:29:15 +02:00
|
|
|
size = ARRAY_SIZE(buffer);
|
2010-04-22 16:34:48 +02:00
|
|
|
ret = WinHttpQueryOption(req, WINHTTP_OPTION_USERNAME, &buffer, &size);
|
|
|
|
ok(ret, "failed to query username %u\n", GetLastError());
|
|
|
|
todo_wine {
|
|
|
|
ok(!buffer[0], "unexpected result %s\n", wine_dbgstr_w(buffer));
|
|
|
|
ok(!size, "expected 0, got %u\n", size);
|
|
|
|
}
|
|
|
|
|
2018-06-11 23:29:15 +02:00
|
|
|
size = ARRAY_SIZE(buffer);
|
2010-04-22 16:34:48 +02:00
|
|
|
ret = WinHttpQueryOption(req, WINHTTP_OPTION_PASSWORD, &buffer, &size);
|
|
|
|
ok(ret, "failed to query password %u\n", GetLastError());
|
|
|
|
todo_wine {
|
|
|
|
ok(!buffer[0], "unexpected result %s\n", wine_dbgstr_w(buffer));
|
|
|
|
ok(!size, "expected 0, got %u\n", size);
|
|
|
|
}
|
|
|
|
|
|
|
|
WinHttpCloseHandle(req);
|
|
|
|
WinHttpCloseHandle(con);
|
|
|
|
WinHttpCloseHandle(ses);
|
|
|
|
}
|
|
|
|
|
2015-12-10 14:54:30 +01:00
|
|
|
static void test_IWinHttpRequest(int port)
|
2011-07-21 11:52:44 +02:00
|
|
|
{
|
2015-12-04 10:15:11 +01:00
|
|
|
static const WCHAR data_start[] = {'<','!','D','O','C','T','Y','P','E',' ','h','t','m','l',' ','P','U','B','L','I','C'};
|
2011-07-21 11:52:44 +02:00
|
|
|
HRESULT hr;
|
|
|
|
IWinHttpRequest *req;
|
2011-07-26 09:27:05 +02:00
|
|
|
BSTR method, url, username, password, response = NULL, status_text = NULL, headers = NULL;
|
2011-07-26 09:27:41 +02:00
|
|
|
BSTR date, today, connection, value = NULL;
|
2015-08-26 08:45:07 +02:00
|
|
|
VARIANT async, empty, timeout, body, body2, proxy_server, bypass_list, data, cp;
|
2011-07-21 11:52:44 +02:00
|
|
|
VARIANT_BOOL succeeded;
|
|
|
|
LONG status;
|
2011-07-26 09:27:41 +02:00
|
|
|
WCHAR todayW[WINHTTP_TIME_FORMAT_BUFSIZE];
|
|
|
|
SYSTEMTIME st;
|
2015-02-16 14:41:47 +01:00
|
|
|
IStream *stream, *stream2;
|
|
|
|
LARGE_INTEGER pos;
|
|
|
|
char buf[128];
|
2015-12-10 14:54:30 +01:00
|
|
|
WCHAR bufW[128];
|
2015-02-16 14:41:47 +01:00
|
|
|
DWORD count;
|
2011-07-26 09:27:41 +02:00
|
|
|
|
|
|
|
GetSystemTime( &st );
|
|
|
|
WinHttpTimeFromSystemTime( &st, todayW );
|
2011-07-21 11:52:44 +02:00
|
|
|
|
|
|
|
CoInitialize( NULL );
|
|
|
|
hr = CoCreateInstance( &CLSID_WinHttpRequest, NULL, CLSCTX_INPROC_SERVER, &IID_IWinHttpRequest, (void **)&req );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
|
|
|
|
V_VT( &empty ) = VT_ERROR;
|
2011-09-05 11:46:15 +02:00
|
|
|
V_ERROR( &empty ) = 0xdeadbeef;
|
2011-07-21 11:52:44 +02:00
|
|
|
|
2011-07-26 09:27:05 +02:00
|
|
|
V_VT( &async ) = VT_BOOL;
|
|
|
|
V_BOOL( &async ) = VARIANT_FALSE;
|
|
|
|
|
2020-02-14 16:41:38 +01:00
|
|
|
method = SysAllocString( L"POST" );
|
|
|
|
url = SysAllocString( L"http://test.winehq.org/tests/post.php" );
|
2011-11-10 11:37:31 +01:00
|
|
|
hr = IWinHttpRequest_Open( req, method, url, async );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
SysFreeString( method );
|
|
|
|
SysFreeString( url );
|
|
|
|
|
|
|
|
V_VT( &data ) = VT_BSTR;
|
2020-02-14 16:41:38 +01:00
|
|
|
V_BSTR( &data ) = SysAllocString( L"testdata\x80" );
|
2011-11-10 11:37:31 +01:00
|
|
|
hr = IWinHttpRequest_Send( req, data );
|
2019-10-02 16:43:35 +02:00
|
|
|
ok( hr == S_OK || hr == HRESULT_FROM_WIN32( ERROR_WINHTTP_INVALID_SERVER_RESPONSE ), "got %08x\n", hr );
|
2011-11-10 11:37:31 +01:00
|
|
|
SysFreeString( V_BSTR( &data ) );
|
2019-10-02 16:43:35 +02:00
|
|
|
if (hr != S_OK) goto done;
|
2011-11-10 11:37:31 +01:00
|
|
|
|
2011-07-21 11:52:44 +02:00
|
|
|
hr = IWinHttpRequest_Open( req, NULL, NULL, empty );
|
|
|
|
ok( hr == E_INVALIDARG, "got %08x\n", hr );
|
|
|
|
|
2020-02-14 16:41:38 +01:00
|
|
|
method = SysAllocString( L"GET" );
|
2011-07-21 11:52:44 +02:00
|
|
|
hr = IWinHttpRequest_Open( req, method, NULL, empty );
|
|
|
|
ok( hr == E_INVALIDARG, "got %08x\n", hr );
|
|
|
|
|
2011-07-26 09:27:05 +02:00
|
|
|
hr = IWinHttpRequest_Open( req, method, NULL, async );
|
|
|
|
ok( hr == E_INVALIDARG, "got %08x\n", hr );
|
|
|
|
|
2020-02-14 16:41:38 +01:00
|
|
|
url = SysAllocString( L"http://test.winehq.org" );
|
2011-07-21 11:52:44 +02:00
|
|
|
hr = IWinHttpRequest_Open( req, NULL, url, empty );
|
|
|
|
ok( hr == E_INVALIDARG, "got %08x\n", hr );
|
|
|
|
|
|
|
|
hr = IWinHttpRequest_Abort( req );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
|
|
|
|
hr = IWinHttpRequest_Open( req, method, url, empty );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
|
|
|
|
hr = IWinHttpRequest_Abort( req );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
|
2015-02-16 14:41:47 +01:00
|
|
|
IWinHttpRequest_Release( req );
|
2011-07-21 11:52:44 +02:00
|
|
|
|
|
|
|
hr = CoCreateInstance( &CLSID_WinHttpRequest, NULL, CLSCTX_INPROC_SERVER, &IID_IWinHttpRequest, (void **)&req );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
|
|
|
|
SysFreeString( url );
|
2020-02-14 16:41:38 +01:00
|
|
|
url = SysAllocString( L"test.winehq.org" );
|
2011-07-21 11:52:44 +02:00
|
|
|
hr = IWinHttpRequest_Open( req, method, url, async );
|
|
|
|
ok( hr == HRESULT_FROM_WIN32( ERROR_WINHTTP_UNRECOGNIZED_SCHEME ), "got %08x\n", hr );
|
|
|
|
|
|
|
|
SysFreeString( method );
|
2020-02-14 16:41:38 +01:00
|
|
|
method = SysAllocString( L"INVALID" );
|
2011-07-21 11:52:44 +02:00
|
|
|
hr = IWinHttpRequest_Open( req, method, url, async );
|
|
|
|
ok( hr == HRESULT_FROM_WIN32( ERROR_WINHTTP_UNRECOGNIZED_SCHEME ), "got %08x\n", hr );
|
|
|
|
|
|
|
|
SysFreeString( method );
|
2020-02-14 16:41:38 +01:00
|
|
|
method = SysAllocString( L"GET" );
|
2011-07-21 11:52:44 +02:00
|
|
|
SysFreeString( url );
|
2020-02-14 16:41:38 +01:00
|
|
|
url = SysAllocString( L"http://test.winehq.org" );
|
2014-09-15 16:36:44 +02:00
|
|
|
V_VT( &async ) = VT_ERROR;
|
|
|
|
V_ERROR( &async ) = DISP_E_PARAMNOTFOUND;
|
2011-07-21 11:52:44 +02:00
|
|
|
hr = IWinHttpRequest_Open( req, method, url, async );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
|
2015-08-26 08:45:07 +02:00
|
|
|
V_VT( &cp ) = VT_ERROR;
|
|
|
|
V_ERROR( &cp ) = 0xdeadbeef;
|
|
|
|
hr = IWinHttpRequest_get_Option( req, WinHttpRequestOption_URLCodePage, &cp );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
ok( V_VT( &cp ) == VT_I4, "got %08x\n", V_VT( &cp ) );
|
|
|
|
ok( V_I4( &cp ) == CP_UTF8, "got %u\n", V_I4( &cp ) );
|
|
|
|
|
|
|
|
V_VT( &cp ) = VT_UI4;
|
|
|
|
V_UI4( &cp ) = CP_ACP;
|
|
|
|
hr = IWinHttpRequest_put_Option( req, WinHttpRequestOption_URLCodePage, cp );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
|
|
|
|
V_VT( &cp ) = VT_ERROR;
|
|
|
|
V_ERROR( &cp ) = 0xdeadbeef;
|
|
|
|
hr = IWinHttpRequest_get_Option( req, WinHttpRequestOption_URLCodePage, &cp );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
ok( V_VT( &cp ) == VT_I4, "got %08x\n", V_VT( &cp ) );
|
|
|
|
ok( V_I4( &cp ) == CP_ACP, "got %u\n", V_I4( &cp ) );
|
|
|
|
|
2020-02-14 16:41:38 +01:00
|
|
|
value = SysAllocString( L"utf-8" );
|
2015-08-26 08:45:07 +02:00
|
|
|
V_VT( &cp ) = VT_BSTR;
|
|
|
|
V_BSTR( &cp ) = value;
|
|
|
|
hr = IWinHttpRequest_put_Option( req, WinHttpRequestOption_URLCodePage, cp );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
SysFreeString( value );
|
|
|
|
|
|
|
|
V_VT( &cp ) = VT_ERROR;
|
|
|
|
V_ERROR( &cp ) = 0xdeadbeef;
|
|
|
|
hr = IWinHttpRequest_get_Option( req, WinHttpRequestOption_URLCodePage, &cp );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
ok( V_VT( &cp ) == VT_I4, "got %08x\n", V_VT( &cp ) );
|
|
|
|
ok( V_I4( &cp ) == CP_UTF8, "got %u\n", V_I4( &cp ) );
|
|
|
|
|
2011-07-21 11:52:44 +02:00
|
|
|
hr = IWinHttpRequest_Abort( req );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
|
|
|
|
hr = IWinHttpRequest_Send( req, empty );
|
|
|
|
ok( hr == HRESULT_FROM_WIN32( ERROR_WINHTTP_CANNOT_CALL_BEFORE_OPEN ), "got %08x\n", hr );
|
|
|
|
|
|
|
|
hr = IWinHttpRequest_Abort( req );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
|
2015-02-16 14:41:47 +01:00
|
|
|
IWinHttpRequest_Release( req );
|
2011-07-21 11:52:44 +02:00
|
|
|
|
|
|
|
hr = CoCreateInstance( &CLSID_WinHttpRequest, NULL, CLSCTX_INPROC_SERVER, &IID_IWinHttpRequest, (void **)&req );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
|
2011-07-26 09:27:05 +02:00
|
|
|
hr = IWinHttpRequest_get_ResponseText( req, NULL );
|
|
|
|
ok( hr == E_INVALIDARG, "got %08x\n", hr );
|
|
|
|
|
|
|
|
hr = IWinHttpRequest_get_ResponseText( req, &response );
|
|
|
|
ok( hr == HRESULT_FROM_WIN32( ERROR_WINHTTP_CANNOT_CALL_BEFORE_SEND ), "got %08x\n", hr );
|
|
|
|
|
|
|
|
hr = IWinHttpRequest_get_Status( req, NULL );
|
|
|
|
ok( hr == E_INVALIDARG, "got %08x\n", hr );
|
|
|
|
|
2011-07-21 11:52:44 +02:00
|
|
|
hr = IWinHttpRequest_get_Status( req, &status );
|
|
|
|
ok( hr == HRESULT_FROM_WIN32( ERROR_WINHTTP_CANNOT_CALL_BEFORE_SEND ), "got %08x\n", hr );
|
|
|
|
|
2011-07-26 09:27:05 +02:00
|
|
|
hr = IWinHttpRequest_get_StatusText( req, NULL );
|
|
|
|
ok( hr == E_INVALIDARG, "got %08x\n", hr );
|
|
|
|
|
2011-07-21 11:52:44 +02:00
|
|
|
hr = IWinHttpRequest_get_StatusText( req, &status_text );
|
|
|
|
ok( hr == HRESULT_FROM_WIN32( ERROR_WINHTTP_CANNOT_CALL_BEFORE_SEND ), "got %08x\n", hr );
|
|
|
|
|
2011-07-26 09:27:05 +02:00
|
|
|
hr = IWinHttpRequest_get_ResponseBody( req, NULL );
|
|
|
|
ok( hr == E_INVALIDARG, "got %08x\n", hr );
|
|
|
|
|
2011-07-21 11:52:44 +02:00
|
|
|
hr = IWinHttpRequest_SetTimeouts( req, 10000, 10000, 10000, 10000 );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
|
2011-07-23 18:15:23 +02:00
|
|
|
hr = IWinHttpRequest_SetCredentials( req, NULL, NULL, 0xdeadbeef );
|
|
|
|
ok( hr == HRESULT_FROM_WIN32( ERROR_WINHTTP_CANNOT_CALL_BEFORE_OPEN ), "got %08x\n", hr );
|
|
|
|
|
2011-07-26 09:25:49 +02:00
|
|
|
VariantInit( &proxy_server );
|
|
|
|
V_VT( &proxy_server ) = VT_ERROR;
|
|
|
|
VariantInit( &bypass_list );
|
|
|
|
V_VT( &bypass_list ) = VT_ERROR;
|
|
|
|
hr = IWinHttpRequest_SetProxy( req, HTTPREQUEST_PROXYSETTING_DIRECT, proxy_server, bypass_list );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
|
|
|
|
hr = IWinHttpRequest_SetProxy( req, HTTPREQUEST_PROXYSETTING_PROXY, proxy_server, bypass_list );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
|
|
|
|
hr = IWinHttpRequest_SetProxy( req, HTTPREQUEST_PROXYSETTING_DIRECT, proxy_server, bypass_list );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
|
2011-07-26 09:27:05 +02:00
|
|
|
hr = IWinHttpRequest_GetAllResponseHeaders( req, NULL );
|
|
|
|
ok( hr == E_INVALIDARG, "got %08x\n", hr );
|
|
|
|
|
|
|
|
hr = IWinHttpRequest_GetAllResponseHeaders( req, &headers );
|
|
|
|
ok( hr == HRESULT_FROM_WIN32( ERROR_WINHTTP_CANNOT_CALL_BEFORE_SEND ), "got %08x\n", hr );
|
|
|
|
|
2011-07-26 09:27:23 +02:00
|
|
|
hr = IWinHttpRequest_GetResponseHeader( req, NULL, NULL );
|
|
|
|
ok( hr == HRESULT_FROM_WIN32( ERROR_WINHTTP_CANNOT_CALL_BEFORE_SEND ), "got %08x\n", hr );
|
|
|
|
|
2020-02-14 16:41:38 +01:00
|
|
|
connection = SysAllocString( L"Connection" );
|
2011-07-26 09:27:23 +02:00
|
|
|
hr = IWinHttpRequest_GetResponseHeader( req, connection, NULL );
|
|
|
|
ok( hr == HRESULT_FROM_WIN32( ERROR_WINHTTP_CANNOT_CALL_BEFORE_SEND ), "got %08x\n", hr );
|
|
|
|
|
|
|
|
hr = IWinHttpRequest_GetResponseHeader( req, connection, &value );
|
|
|
|
ok( hr == HRESULT_FROM_WIN32( ERROR_WINHTTP_CANNOT_CALL_BEFORE_SEND ), "got %08x\n", hr );
|
|
|
|
|
2011-07-26 09:27:41 +02:00
|
|
|
hr = IWinHttpRequest_SetRequestHeader( req, NULL, NULL );
|
|
|
|
ok( hr == E_INVALIDARG, "got %08x\n", hr );
|
|
|
|
|
2020-02-14 16:41:38 +01:00
|
|
|
date = SysAllocString( L"Date" );
|
2011-07-26 09:27:41 +02:00
|
|
|
hr = IWinHttpRequest_SetRequestHeader( req, date, NULL );
|
|
|
|
ok( hr == HRESULT_FROM_WIN32( ERROR_WINHTTP_CANNOT_CALL_BEFORE_OPEN ), "got %08x\n", hr );
|
|
|
|
|
|
|
|
today = SysAllocString( todayW );
|
|
|
|
hr = IWinHttpRequest_SetRequestHeader( req, date, today );
|
|
|
|
ok( hr == HRESULT_FROM_WIN32( ERROR_WINHTTP_CANNOT_CALL_BEFORE_OPEN ), "got %08x\n", hr );
|
|
|
|
|
2011-08-02 09:23:35 +02:00
|
|
|
hr = IWinHttpRequest_SetAutoLogonPolicy( req, 0xdeadbeef );
|
|
|
|
ok( hr == E_INVALIDARG, "got %08x\n", hr );
|
|
|
|
|
|
|
|
hr = IWinHttpRequest_SetAutoLogonPolicy( req, AutoLogonPolicy_OnlyIfBypassProxy );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
|
2011-07-21 11:52:44 +02:00
|
|
|
SysFreeString( method );
|
2020-02-14 16:41:38 +01:00
|
|
|
method = SysAllocString( L"GET" );
|
2011-07-21 11:52:44 +02:00
|
|
|
SysFreeString( url );
|
2020-02-14 16:41:38 +01:00
|
|
|
url = SysAllocString( L"http://test.winehq.org" );
|
2011-07-21 11:52:44 +02:00
|
|
|
hr = IWinHttpRequest_Open( req, method, url, async );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
|
2011-07-26 09:27:05 +02:00
|
|
|
hr = IWinHttpRequest_get_ResponseText( req, NULL );
|
|
|
|
ok( hr == E_INVALIDARG, "got %08x\n", hr );
|
|
|
|
|
|
|
|
hr = IWinHttpRequest_get_ResponseText( req, &response );
|
|
|
|
ok( hr == HRESULT_FROM_WIN32( ERROR_WINHTTP_CANNOT_CALL_BEFORE_SEND ), "got %08x\n", hr );
|
|
|
|
|
2011-07-21 11:52:44 +02:00
|
|
|
hr = IWinHttpRequest_get_Status( req, &status );
|
|
|
|
ok( hr == HRESULT_FROM_WIN32( ERROR_WINHTTP_CANNOT_CALL_BEFORE_SEND ), "got %08x\n", hr );
|
|
|
|
|
|
|
|
hr = IWinHttpRequest_get_StatusText( req, &status_text );
|
|
|
|
ok( hr == HRESULT_FROM_WIN32( ERROR_WINHTTP_CANNOT_CALL_BEFORE_SEND ), "got %08x\n", hr );
|
|
|
|
|
2011-07-26 09:27:05 +02:00
|
|
|
hr = IWinHttpRequest_get_ResponseBody( req, NULL );
|
|
|
|
ok( hr == E_INVALIDARG, "got %08x\n", hr );
|
|
|
|
|
2011-07-21 11:52:44 +02:00
|
|
|
hr = IWinHttpRequest_SetTimeouts( req, 10000, 10000, 10000, 10000 );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
|
2011-07-23 18:15:23 +02:00
|
|
|
hr = IWinHttpRequest_SetCredentials( req, NULL, NULL, 0xdeadbeef );
|
|
|
|
ok( hr == E_INVALIDARG, "got %08x\n", hr );
|
|
|
|
|
2020-02-14 16:41:38 +01:00
|
|
|
username = SysAllocString( L"username" );
|
2011-07-23 18:15:23 +02:00
|
|
|
hr = IWinHttpRequest_SetCredentials( req, username, NULL, 0xdeadbeef );
|
|
|
|
ok( hr == E_INVALIDARG, "got %08x\n", hr );
|
|
|
|
|
2020-02-14 16:41:38 +01:00
|
|
|
password = SysAllocString( L"password" );
|
2011-07-26 09:27:05 +02:00
|
|
|
hr = IWinHttpRequest_SetCredentials( req, NULL, password, 0xdeadbeef );
|
|
|
|
ok( hr == E_INVALIDARG, "got %08x\n", hr );
|
|
|
|
|
2011-07-23 18:15:23 +02:00
|
|
|
hr = IWinHttpRequest_SetCredentials( req, username, password, 0xdeadbeef );
|
|
|
|
ok( hr == E_INVALIDARG, "got %08x\n", hr );
|
|
|
|
|
2011-07-26 09:27:05 +02:00
|
|
|
hr = IWinHttpRequest_SetCredentials( req, NULL, password, HTTPREQUEST_SETCREDENTIALS_FOR_SERVER );
|
|
|
|
ok( hr == E_INVALIDARG, "got %08x\n", hr );
|
|
|
|
|
2011-07-23 18:15:23 +02:00
|
|
|
hr = IWinHttpRequest_SetCredentials( req, username, password, HTTPREQUEST_SETCREDENTIALS_FOR_SERVER );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
|
2011-07-26 09:25:49 +02:00
|
|
|
V_VT( &proxy_server ) = VT_BSTR;
|
2020-02-14 16:41:38 +01:00
|
|
|
V_BSTR( &proxy_server ) = SysAllocString( L"proxyserver" );
|
2011-07-26 09:25:49 +02:00
|
|
|
V_VT( &bypass_list ) = VT_BSTR;
|
2020-02-14 16:41:38 +01:00
|
|
|
V_BSTR( &bypass_list ) = SysAllocString( L"bypasslist" );
|
2011-07-26 09:25:49 +02:00
|
|
|
hr = IWinHttpRequest_SetProxy( req, HTTPREQUEST_PROXYSETTING_PROXY, proxy_server, bypass_list );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
|
|
|
|
hr = IWinHttpRequest_SetProxy( req, 0xdeadbeef, proxy_server, bypass_list );
|
|
|
|
ok( hr == E_INVALIDARG, "got %08x\n", hr );
|
|
|
|
|
|
|
|
hr = IWinHttpRequest_SetProxy( req, HTTPREQUEST_PROXYSETTING_DIRECT, proxy_server, bypass_list );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
|
2011-07-26 09:27:05 +02:00
|
|
|
hr = IWinHttpRequest_GetAllResponseHeaders( req, &headers );
|
|
|
|
ok( hr == HRESULT_FROM_WIN32( ERROR_WINHTTP_CANNOT_CALL_BEFORE_SEND ), "got %08x\n", hr );
|
|
|
|
|
2011-07-26 09:27:23 +02:00
|
|
|
hr = IWinHttpRequest_GetResponseHeader( req, connection, &value );
|
|
|
|
ok( hr == HRESULT_FROM_WIN32( ERROR_WINHTTP_CANNOT_CALL_BEFORE_SEND ), "got %08x\n", hr );
|
|
|
|
|
2011-07-26 09:27:41 +02:00
|
|
|
hr = IWinHttpRequest_SetRequestHeader( req, date, today );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
|
|
|
|
hr = IWinHttpRequest_SetRequestHeader( req, date, NULL );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
|
2011-08-02 09:23:35 +02:00
|
|
|
hr = IWinHttpRequest_SetAutoLogonPolicy( req, AutoLogonPolicy_OnlyIfBypassProxy );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
|
2011-07-21 11:52:44 +02:00
|
|
|
hr = IWinHttpRequest_Send( req, empty );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
|
|
|
|
hr = IWinHttpRequest_Send( req, empty );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
|
2011-07-26 09:27:05 +02:00
|
|
|
hr = IWinHttpRequest_get_ResponseText( req, NULL );
|
|
|
|
ok( hr == E_INVALIDARG, "got %08x\n", hr );
|
|
|
|
|
|
|
|
hr = IWinHttpRequest_get_ResponseText( req, &response );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
2015-12-04 10:15:11 +01:00
|
|
|
ok( !memcmp(response, data_start, sizeof(data_start)), "got %s\n", wine_dbgstr_wn(response, 32) );
|
2011-07-26 09:27:05 +02:00
|
|
|
SysFreeString( response );
|
|
|
|
|
|
|
|
hr = IWinHttpRequest_get_Status( req, NULL );
|
|
|
|
ok( hr == E_INVALIDARG, "got %08x\n", hr );
|
|
|
|
|
2011-07-21 11:52:44 +02:00
|
|
|
status = 0;
|
|
|
|
hr = IWinHttpRequest_get_Status( req, &status );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
2012-12-14 11:54:52 +01:00
|
|
|
trace("Status=%d\n", status);
|
2011-07-21 11:52:44 +02:00
|
|
|
|
2011-07-26 09:27:05 +02:00
|
|
|
hr = IWinHttpRequest_get_StatusText( req, NULL );
|
|
|
|
ok( hr == E_INVALIDARG, "got %08x\n", hr );
|
|
|
|
|
2011-07-21 11:52:44 +02:00
|
|
|
hr = IWinHttpRequest_get_StatusText( req, &status_text );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
2012-12-14 11:54:52 +01:00
|
|
|
trace("StatusText=%s\n", wine_dbgstr_w(status_text));
|
2011-07-21 11:52:44 +02:00
|
|
|
SysFreeString( status_text );
|
|
|
|
|
2011-07-26 09:27:05 +02:00
|
|
|
hr = IWinHttpRequest_get_ResponseBody( req, NULL );
|
|
|
|
ok( hr == E_INVALIDARG, "got %08x\n", hr );
|
|
|
|
|
2011-07-23 18:15:23 +02:00
|
|
|
hr = IWinHttpRequest_SetCredentials( req, username, password, HTTPREQUEST_SETCREDENTIALS_FOR_SERVER );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
|
2011-07-26 09:25:49 +02:00
|
|
|
hr = IWinHttpRequest_SetProxy( req, HTTPREQUEST_PROXYSETTING_PROXY, proxy_server, bypass_list );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
|
|
|
|
hr = IWinHttpRequest_SetProxy( req, HTTPREQUEST_PROXYSETTING_DIRECT, proxy_server, bypass_list );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
|
2011-07-26 09:27:05 +02:00
|
|
|
hr = IWinHttpRequest_GetAllResponseHeaders( req, NULL );
|
|
|
|
ok( hr == E_INVALIDARG, "got %08x\n", hr );
|
|
|
|
|
|
|
|
hr = IWinHttpRequest_GetAllResponseHeaders( req, &headers );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
SysFreeString( headers );
|
|
|
|
|
2011-07-26 09:27:23 +02:00
|
|
|
hr = IWinHttpRequest_GetResponseHeader( req, NULL, NULL );
|
|
|
|
ok( hr == E_INVALIDARG, "got %08x\n", hr );
|
|
|
|
|
|
|
|
hr = IWinHttpRequest_GetResponseHeader( req, connection, NULL );
|
|
|
|
ok( hr == E_INVALIDARG, "got %08x\n", hr );
|
|
|
|
|
|
|
|
hr = IWinHttpRequest_GetResponseHeader( req, connection, &value );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
SysFreeString( value );
|
|
|
|
|
2011-07-26 09:27:41 +02:00
|
|
|
hr = IWinHttpRequest_SetRequestHeader( req, date, today );
|
|
|
|
ok( hr == HRESULT_FROM_WIN32( ERROR_WINHTTP_CANNOT_CALL_AFTER_SEND ), "got %08x\n", hr );
|
|
|
|
|
2011-08-02 09:23:35 +02:00
|
|
|
hr = IWinHttpRequest_SetAutoLogonPolicy( req, AutoLogonPolicy_OnlyIfBypassProxy );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
|
2011-07-21 11:52:44 +02:00
|
|
|
VariantInit( &timeout );
|
|
|
|
V_VT( &timeout ) = VT_I4;
|
|
|
|
V_I4( &timeout ) = 10;
|
|
|
|
hr = IWinHttpRequest_WaitForResponse( req, timeout, &succeeded );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
|
|
|
|
hr = IWinHttpRequest_get_Status( req, &status );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
|
|
|
|
hr = IWinHttpRequest_get_StatusText( req, &status_text );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
SysFreeString( status_text );
|
|
|
|
|
2011-07-23 18:15:23 +02:00
|
|
|
hr = IWinHttpRequest_SetCredentials( req, username, password, HTTPREQUEST_SETCREDENTIALS_FOR_SERVER );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
|
2011-07-26 09:25:49 +02:00
|
|
|
hr = IWinHttpRequest_SetProxy( req, HTTPREQUEST_PROXYSETTING_PROXY, proxy_server, bypass_list );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
|
|
|
|
hr = IWinHttpRequest_SetProxy( req, HTTPREQUEST_PROXYSETTING_DIRECT, proxy_server, bypass_list );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
|
2011-07-21 11:52:44 +02:00
|
|
|
hr = IWinHttpRequest_Send( req, empty );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
|
2011-07-26 09:27:05 +02:00
|
|
|
hr = IWinHttpRequest_get_ResponseText( req, NULL );
|
|
|
|
ok( hr == E_INVALIDARG, "got %08x\n", hr );
|
|
|
|
|
2011-07-21 11:52:44 +02:00
|
|
|
hr = IWinHttpRequest_get_ResponseText( req, &response );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
SysFreeString( response );
|
|
|
|
|
2011-07-26 09:27:05 +02:00
|
|
|
hr = IWinHttpRequest_get_ResponseBody( req, NULL );
|
|
|
|
ok( hr == E_INVALIDARG, "got %08x\n", hr );
|
|
|
|
|
2011-07-23 18:15:09 +02:00
|
|
|
VariantInit( &body );
|
|
|
|
V_VT( &body ) = VT_ERROR;
|
|
|
|
hr = IWinHttpRequest_get_ResponseBody( req, &body );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
ok( V_VT( &body ) == (VT_ARRAY|VT_UI1), "got %08x\n", V_VT( &body ) );
|
|
|
|
|
|
|
|
hr = VariantClear( &body );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
|
2015-02-16 14:41:47 +01:00
|
|
|
VariantInit( &body );
|
|
|
|
V_VT( &body ) = VT_ERROR;
|
|
|
|
hr = IWinHttpRequest_get_ResponseStream( req, &body );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
ok( V_VT( &body ) == VT_UNKNOWN, "got %08x\n", V_VT( &body ) );
|
|
|
|
|
|
|
|
hr = IUnknown_QueryInterface( V_UNKNOWN( &body ), &IID_IStream, (void **)&stream );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
ok( V_UNKNOWN( &body ) == (IUnknown *)stream, "got different interface pointer\n" );
|
|
|
|
|
|
|
|
buf[0] = 0;
|
|
|
|
count = 0xdeadbeef;
|
|
|
|
hr = IStream_Read( stream, buf, 128, &count );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
ok( count != 0xdeadbeef, "count not set\n" );
|
|
|
|
ok( buf[0], "no data\n" );
|
|
|
|
|
|
|
|
VariantInit( &body2 );
|
|
|
|
V_VT( &body2 ) = VT_ERROR;
|
|
|
|
hr = IWinHttpRequest_get_ResponseStream( req, &body2 );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
ok( V_VT( &body2 ) == VT_UNKNOWN, "got %08x\n", V_VT( &body2 ) );
|
|
|
|
ok( V_UNKNOWN( &body ) != V_UNKNOWN( &body2 ), "got same interface pointer\n" );
|
|
|
|
|
|
|
|
hr = IUnknown_QueryInterface( V_UNKNOWN( &body2 ), &IID_IStream, (void **)&stream2 );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
ok( V_UNKNOWN( &body2 ) == (IUnknown *)stream2, "got different interface pointer\n" );
|
|
|
|
IStream_Release( stream2 );
|
|
|
|
|
|
|
|
hr = VariantClear( &body );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
|
|
|
|
hr = VariantClear( &body2 );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
|
2011-07-26 09:25:49 +02:00
|
|
|
hr = IWinHttpRequest_SetProxy( req, HTTPREQUEST_PROXYSETTING_PROXY, proxy_server, bypass_list );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
|
|
|
|
hr = IWinHttpRequest_SetProxy( req, HTTPREQUEST_PROXYSETTING_DIRECT, proxy_server, bypass_list );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
|
2011-07-26 09:27:05 +02:00
|
|
|
hr = IWinHttpRequest_GetAllResponseHeaders( req, &headers );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
SysFreeString( headers );
|
|
|
|
|
2011-07-26 09:27:23 +02:00
|
|
|
hr = IWinHttpRequest_GetResponseHeader( req, connection, &value );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
SysFreeString( value );
|
|
|
|
|
2011-07-26 09:27:41 +02:00
|
|
|
hr = IWinHttpRequest_SetRequestHeader( req, date, today );
|
|
|
|
ok( hr == HRESULT_FROM_WIN32( ERROR_WINHTTP_CANNOT_CALL_AFTER_SEND ), "got %08x\n", hr );
|
|
|
|
|
2011-08-02 09:23:35 +02:00
|
|
|
hr = IWinHttpRequest_SetAutoLogonPolicy( req, AutoLogonPolicy_OnlyIfBypassProxy );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
|
2011-07-21 11:52:44 +02:00
|
|
|
hr = IWinHttpRequest_Send( req, empty );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
|
|
|
|
hr = IWinHttpRequest_Abort( req );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
|
|
|
|
hr = IWinHttpRequest_Abort( req );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
|
2015-02-16 14:41:47 +01:00
|
|
|
IWinHttpRequest_Release( req );
|
|
|
|
|
|
|
|
pos.QuadPart = 0;
|
2015-03-30 10:13:44 +02:00
|
|
|
hr = IStream_Seek( stream, pos, STREAM_SEEK_SET, NULL );
|
2015-02-16 14:41:47 +01:00
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
|
|
|
|
buf[0] = 0;
|
|
|
|
count = 0xdeadbeef;
|
|
|
|
hr = IStream_Read( stream, buf, 128, &count );
|
2011-07-21 11:52:44 +02:00
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
2015-02-16 14:41:47 +01:00
|
|
|
ok( count != 0xdeadbeef, "count not set\n" );
|
|
|
|
ok( buf[0], "no data\n" );
|
|
|
|
IStream_Release( stream );
|
2011-07-21 11:52:44 +02:00
|
|
|
|
2014-12-09 12:47:00 +01:00
|
|
|
hr = CoCreateInstance( &CLSID_WinHttpRequest, NULL, CLSCTX_INPROC_SERVER, &IID_IWinHttpRequest, (void **)&req );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
|
|
|
|
V_VT( &async ) = VT_I4;
|
|
|
|
V_I4( &async ) = 1;
|
|
|
|
hr = IWinHttpRequest_Open( req, method, url, async );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
|
|
|
|
hr = IWinHttpRequest_Send( req, empty );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
|
|
|
|
hr = IWinHttpRequest_WaitForResponse( req, timeout, &succeeded );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
|
2015-02-16 14:41:47 +01:00
|
|
|
IWinHttpRequest_Release( req );
|
2014-12-09 12:47:00 +01:00
|
|
|
|
2011-07-21 11:52:44 +02:00
|
|
|
SysFreeString( method );
|
|
|
|
SysFreeString( url );
|
2011-07-23 18:15:23 +02:00
|
|
|
SysFreeString( username );
|
|
|
|
SysFreeString( password );
|
2011-07-29 13:25:04 +02:00
|
|
|
SysFreeString( connection );
|
2011-07-26 09:27:41 +02:00
|
|
|
SysFreeString( date );
|
|
|
|
SysFreeString( today );
|
2011-07-26 09:25:49 +02:00
|
|
|
VariantClear( &proxy_server );
|
|
|
|
VariantClear( &bypass_list );
|
2015-12-04 10:15:46 +01:00
|
|
|
|
|
|
|
hr = CoCreateInstance( &CLSID_WinHttpRequest, NULL, CLSCTX_INPROC_SERVER, &IID_IWinHttpRequest, (void **)&req );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
|
2020-02-14 16:41:38 +01:00
|
|
|
url = SysAllocString( L"https://test.winehq.org:443" );
|
|
|
|
method = SysAllocString( L"POST" );
|
2015-12-04 10:15:46 +01:00
|
|
|
V_VT( &async ) = VT_BOOL;
|
|
|
|
V_BOOL( &async ) = VARIANT_FALSE;
|
|
|
|
hr = IWinHttpRequest_Open( req, method, url, async );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
SysFreeString( method );
|
|
|
|
SysFreeString( url );
|
|
|
|
|
2015-12-07 06:15:53 +01:00
|
|
|
hr = IWinHttpRequest_Send( req, empty );
|
2019-10-02 16:43:35 +02:00
|
|
|
ok( hr == S_OK || hr == HRESULT_FROM_WIN32( ERROR_WINHTTP_INVALID_SERVER_RESPONSE ) ||
|
|
|
|
hr == SEC_E_ILLEGAL_MESSAGE /* winxp */, "got %08x\n", hr );
|
|
|
|
if (hr != S_OK) goto done;
|
|
|
|
|
|
|
|
hr = IWinHttpRequest_get_ResponseText( req, &response );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
ok( !memcmp(response, data_start, sizeof(data_start)), "got %s\n", wine_dbgstr_wn(response, 32) );
|
|
|
|
SysFreeString( response );
|
2015-12-04 10:15:46 +01:00
|
|
|
|
|
|
|
IWinHttpRequest_Release( req );
|
|
|
|
|
2015-12-10 14:54:30 +01:00
|
|
|
hr = CoCreateInstance( &CLSID_WinHttpRequest, NULL, CLSCTX_INPROC_SERVER, &IID_IWinHttpRequest, (void **)&req );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
|
|
|
|
sprintf( buf, "http://localhost:%d/auth", port );
|
2018-06-11 23:29:15 +02:00
|
|
|
MultiByteToWideChar( CP_ACP, 0, buf, -1, bufW, ARRAY_SIZE( bufW ));
|
2015-12-10 14:54:30 +01:00
|
|
|
url = SysAllocString( bufW );
|
2020-02-14 16:41:38 +01:00
|
|
|
method = SysAllocString( L"POST" );
|
2015-12-10 14:54:30 +01:00
|
|
|
V_VT( &async ) = VT_BOOL;
|
|
|
|
V_BOOL( &async ) = VARIANT_FALSE;
|
|
|
|
hr = IWinHttpRequest_Open( req, method, url, async );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
SysFreeString( method );
|
|
|
|
SysFreeString( url );
|
|
|
|
|
|
|
|
hr = IWinHttpRequest_get_Status( req, &status );
|
|
|
|
ok( hr == HRESULT_FROM_WIN32( ERROR_WINHTTP_CANNOT_CALL_BEFORE_SEND ), "got %08x\n", hr );
|
|
|
|
|
|
|
|
V_VT( &data ) = VT_BSTR;
|
2020-02-14 16:41:38 +01:00
|
|
|
V_BSTR( &data ) = SysAllocString( L"testdata\x80" );
|
2015-12-10 14:54:30 +01:00
|
|
|
hr = IWinHttpRequest_Send( req, data );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
SysFreeString( V_BSTR( &data ) );
|
|
|
|
|
|
|
|
hr = IWinHttpRequest_get_ResponseText( req, &response );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
2020-02-14 16:41:38 +01:00
|
|
|
ok( !memcmp( response, L"Unauthorized", sizeof(L"Unauthorized") ), "got %s\n", wine_dbgstr_w(response) );
|
2015-12-10 14:54:30 +01:00
|
|
|
SysFreeString( response );
|
|
|
|
|
|
|
|
status = 0xdeadbeef;
|
|
|
|
hr = IWinHttpRequest_get_Status( req, &status );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
ok( status == HTTP_STATUS_DENIED, "got %d\n", status );
|
|
|
|
|
2019-10-02 16:43:35 +02:00
|
|
|
done:
|
2015-12-10 14:54:30 +01:00
|
|
|
IWinHttpRequest_Release( req );
|
2011-07-21 11:52:44 +02:00
|
|
|
CoUninitialize();
|
|
|
|
}
|
|
|
|
|
2015-09-02 07:44:50 +02:00
|
|
|
static void request_get_property(IWinHttpRequest *request, int property, VARIANT *ret)
|
|
|
|
{
|
|
|
|
DISPPARAMS params;
|
|
|
|
VARIANT arg;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
memset(¶ms, 0, sizeof(params));
|
|
|
|
params.cNamedArgs = 0;
|
|
|
|
params.rgdispidNamedArgs = NULL;
|
|
|
|
params.cArgs = 1;
|
|
|
|
params.rgvarg = &arg;
|
|
|
|
VariantInit(&arg);
|
|
|
|
V_VT(&arg) = VT_I4;
|
|
|
|
V_I4(&arg) = property;
|
|
|
|
VariantInit(ret);
|
|
|
|
hr = IWinHttpRequest_Invoke(request, DISPID_HTTPREQUEST_OPTION, &IID_NULL, 0,
|
|
|
|
DISPATCH_PROPERTYGET, ¶ms, ret, NULL, NULL);
|
|
|
|
ok(hr == S_OK, "error %#x\n", hr);
|
|
|
|
}
|
|
|
|
|
2015-08-27 12:28:32 +02:00
|
|
|
static void test_IWinHttpRequest_Invoke(void)
|
|
|
|
{
|
|
|
|
WCHAR openW[] = {'O','p','e','n',0};
|
|
|
|
WCHAR optionW[] = {'O','p','t','i','o','n',0};
|
|
|
|
OLECHAR *open = openW, *option = optionW;
|
|
|
|
BSTR utf8;
|
|
|
|
CLSID clsid;
|
|
|
|
IWinHttpRequest *request;
|
|
|
|
IDispatch *dispatch;
|
|
|
|
DISPID id;
|
|
|
|
DISPPARAMS params;
|
|
|
|
VARIANT arg[3], ret;
|
|
|
|
UINT err;
|
|
|
|
BOOL bret;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
CoInitialize(NULL);
|
|
|
|
|
2020-02-14 16:41:38 +01:00
|
|
|
hr = CLSIDFromProgID(L"WinHttp.WinHttpRequest.5.1", &clsid);
|
2015-08-27 12:28:32 +02:00
|
|
|
ok(hr == S_OK, "CLSIDFromProgID error %#x\n", hr);
|
|
|
|
bret = IsEqualIID(&clsid, &CLSID_WinHttpRequest);
|
|
|
|
ok(bret || broken(!bret) /* win2003 */, "not expected %s\n", wine_dbgstr_guid(&clsid));
|
|
|
|
|
|
|
|
hr = CoCreateInstance(&CLSID_WinHttpRequest, 0, CLSCTX_INPROC_SERVER, &IID_IUnknown, (void **)&request);
|
|
|
|
ok(hr == S_OK, "error %#x\n", hr);
|
|
|
|
|
|
|
|
hr = IWinHttpRequest_QueryInterface(request, &IID_IDispatch, (void **)&dispatch);
|
|
|
|
ok(hr == S_OK, "error %#x\n", hr);
|
|
|
|
IDispatch_Release(dispatch);
|
|
|
|
|
|
|
|
hr = IWinHttpRequest_GetIDsOfNames(request, &IID_NULL, &open, 1, 0x0409, &id);
|
|
|
|
ok(hr == S_OK, "error %#x\n", hr);
|
|
|
|
ok(id == DISPID_HTTPREQUEST_OPEN, "expected DISPID_HTTPREQUEST_OPEN, got %u\n", id);
|
|
|
|
|
|
|
|
hr = IWinHttpRequest_GetIDsOfNames(request, &IID_NULL, &option, 1, 0x0409, &id);
|
|
|
|
ok(hr == S_OK, "error %#x\n", hr);
|
|
|
|
ok(id == DISPID_HTTPREQUEST_OPTION, "expected DISPID_HTTPREQUEST_OPTION, got %u\n", id);
|
|
|
|
|
2015-09-02 07:44:50 +02:00
|
|
|
request_get_property(request, WinHttpRequestOption_URLCodePage, &ret);
|
|
|
|
ok(V_VT(&ret) == VT_I4, "expected VT_I4, got %d\n", V_VT(&ret));
|
|
|
|
ok(V_I4(&ret) == CP_UTF8, "expected CP_UTF8, got %d\n", V_I4(&ret));
|
|
|
|
|
|
|
|
memset(¶ms, 0, sizeof(params));
|
|
|
|
params.cArgs = 2;
|
|
|
|
params.cNamedArgs = 0;
|
|
|
|
params.rgvarg = arg;
|
|
|
|
V_VT(&arg[0]) = VT_I4;
|
|
|
|
V_I4(&arg[0]) = 1252;
|
|
|
|
V_VT(&arg[1]) = VT_R8;
|
|
|
|
V_R8(&arg[1]) = 2.0; /* WinHttpRequestOption_URLCodePage */
|
|
|
|
VariantInit(&ret);
|
|
|
|
hr = IWinHttpRequest_Invoke(request, DISPID_HTTPREQUEST_OPTION, &IID_NULL, 0,
|
|
|
|
DISPATCH_METHOD, ¶ms, NULL, NULL, &err);
|
|
|
|
ok(hr == S_OK, "error %#x\n", hr);
|
|
|
|
|
|
|
|
request_get_property(request, WinHttpRequestOption_URLCodePage, &ret);
|
|
|
|
ok(V_VT(&ret) == VT_I4, "expected VT_I4, got %d\n", V_VT(&ret));
|
|
|
|
ok(V_I4(&ret) == CP_UTF8, "expected CP_UTF8, got %d\n", V_I4(&ret));
|
|
|
|
|
|
|
|
memset(¶ms, 0, sizeof(params));
|
|
|
|
params.cArgs = 2;
|
|
|
|
params.cNamedArgs = 0;
|
|
|
|
params.rgvarg = arg;
|
|
|
|
V_VT(&arg[0]) = VT_I4;
|
|
|
|
V_I4(&arg[0]) = 1252;
|
|
|
|
V_VT(&arg[1]) = VT_R8;
|
|
|
|
V_R8(&arg[1]) = 2.0; /* WinHttpRequestOption_URLCodePage */
|
|
|
|
VariantInit(&ret);
|
|
|
|
hr = IWinHttpRequest_Invoke(request, DISPID_HTTPREQUEST_OPTION, &IID_NULL, 0,
|
|
|
|
DISPATCH_METHOD | DISPATCH_PROPERTYPUT, ¶ms, NULL, NULL, &err);
|
|
|
|
ok(hr == S_OK, "error %#x\n", hr);
|
|
|
|
|
|
|
|
request_get_property(request, WinHttpRequestOption_URLCodePage, &ret);
|
|
|
|
ok(V_VT(&ret) == VT_I4, "expected VT_I4, got %d\n", V_VT(&ret));
|
|
|
|
ok(V_I4(&ret) == CP_UTF8, "expected CP_UTF8, got %d\n", V_I4(&ret));
|
|
|
|
|
|
|
|
memset(¶ms, 0, sizeof(params));
|
|
|
|
params.cArgs = 2;
|
|
|
|
params.cNamedArgs = 0;
|
|
|
|
params.rgvarg = arg;
|
|
|
|
V_VT(&arg[0]) = VT_I4;
|
|
|
|
V_I4(&arg[0]) = 1252;
|
|
|
|
V_VT(&arg[1]) = VT_R8;
|
|
|
|
V_R8(&arg[1]) = 2.0; /* WinHttpRequestOption_URLCodePage */
|
|
|
|
VariantInit(&ret);
|
|
|
|
hr = IWinHttpRequest_Invoke(request, DISPID_HTTPREQUEST_OPTION, &IID_NULL, 0,
|
|
|
|
DISPATCH_PROPERTYPUT, ¶ms, NULL, NULL, &err);
|
|
|
|
ok(hr == S_OK, "error %#x\n", hr);
|
|
|
|
|
|
|
|
request_get_property(request, WinHttpRequestOption_URLCodePage, &ret);
|
|
|
|
ok(V_VT(&ret) == VT_I4, "expected VT_I4, got %d\n", V_VT(&ret));
|
|
|
|
ok(V_I4(&ret) == 1252, "expected 1252, got %d\n", V_I4(&ret));
|
|
|
|
|
2015-08-27 12:28:32 +02:00
|
|
|
memset(¶ms, 0, sizeof(params));
|
|
|
|
params.cArgs = 2;
|
|
|
|
params.cNamedArgs = 0;
|
|
|
|
params.rgvarg = arg;
|
|
|
|
V_VT(&arg[0]) = VT_BSTR;
|
2020-02-14 16:41:38 +01:00
|
|
|
utf8 = SysAllocString(L"UTF-8");
|
2015-08-27 12:28:32 +02:00
|
|
|
V_BSTR(&arg[0]) = utf8;
|
|
|
|
V_VT(&arg[1]) = VT_R8;
|
2015-09-02 07:44:50 +02:00
|
|
|
V_R8(&arg[1]) = 2.0; /* WinHttpRequestOption_URLCodePage */
|
2015-08-27 12:28:32 +02:00
|
|
|
hr = IWinHttpRequest_Invoke(request, id, &IID_NULL, 0, DISPATCH_METHOD, ¶ms, NULL, NULL, &err);
|
|
|
|
ok(hr == S_OK, "error %#x\n", hr);
|
|
|
|
|
2015-09-02 07:44:50 +02:00
|
|
|
request_get_property(request, WinHttpRequestOption_URLCodePage, &ret);
|
|
|
|
ok(V_VT(&ret) == VT_I4, "expected VT_I4, got %d\n", V_VT(&ret));
|
|
|
|
ok(V_I4(&ret) == 1252, "expected 1252, got %d\n", V_I4(&ret));
|
|
|
|
|
2015-08-27 12:28:32 +02:00
|
|
|
VariantInit(&ret);
|
|
|
|
hr = IWinHttpRequest_Invoke(request, id, &IID_NULL, 0, DISPATCH_METHOD, ¶ms, &ret, NULL, &err);
|
|
|
|
ok(hr == S_OK, "error %#x\n", hr);
|
|
|
|
|
2015-09-02 07:44:50 +02:00
|
|
|
request_get_property(request, WinHttpRequestOption_URLCodePage, &ret);
|
|
|
|
ok(V_VT(&ret) == VT_I4, "expected VT_I4, got %d\n", V_VT(&ret));
|
|
|
|
ok(V_I4(&ret) == 1252, "expected 1252, got %d\n", V_I4(&ret));
|
|
|
|
|
|
|
|
VariantInit(&ret);
|
|
|
|
hr = IWinHttpRequest_Invoke(request, id, &IID_NULL, 0, DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, &err);
|
|
|
|
ok(hr == S_OK, "error %#x\n", hr);
|
|
|
|
|
|
|
|
request_get_property(request, WinHttpRequestOption_URLCodePage, &ret);
|
|
|
|
ok(V_VT(&ret) == VT_I4, "expected VT_I4, got %d\n", V_VT(&ret));
|
|
|
|
ok(V_I4(&ret) == CP_UTF8, "expected CP_UTF8, got %d\n", V_I4(&ret));
|
|
|
|
|
|
|
|
hr = IWinHttpRequest_Invoke(request, DISPID_HTTPREQUEST_OPTION, &IID_NULL, 0, DISPATCH_PROPERTYPUT, ¶ms, NULL, NULL, NULL);
|
|
|
|
ok(hr == S_OK, "error %#x\n", hr);
|
|
|
|
|
|
|
|
hr = IWinHttpRequest_Invoke(request, 255, &IID_NULL, 0, DISPATCH_PROPERTYPUT, ¶ms, NULL, NULL, NULL);
|
|
|
|
ok(hr == DISP_E_MEMBERNOTFOUND, "error %#x\n", hr);
|
|
|
|
|
|
|
|
VariantInit(&ret);
|
|
|
|
hr = IWinHttpRequest_Invoke(request, DISPID_HTTPREQUEST_OPTION, &IID_IUnknown, 0, DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, &err);
|
|
|
|
ok(hr == DISP_E_UNKNOWNINTERFACE, "error %#x\n", hr);
|
|
|
|
|
|
|
|
VariantInit(&ret);
|
2016-08-10 12:19:04 +02:00
|
|
|
if (0) /* crashes */
|
|
|
|
hr = IWinHttpRequest_Invoke(request, DISPID_HTTPREQUEST_OPTION, &IID_NULL, 0, DISPATCH_PROPERTYPUT, NULL, &ret, NULL, &err);
|
2015-09-02 07:44:50 +02:00
|
|
|
|
|
|
|
params.cArgs = 1;
|
|
|
|
hr = IWinHttpRequest_Invoke(request, DISPID_HTTPREQUEST_OPTION, &IID_NULL, 0, DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, &err);
|
|
|
|
ok(hr == DISP_E_TYPEMISMATCH, "error %#x\n", hr);
|
|
|
|
|
|
|
|
VariantInit(&arg[2]);
|
|
|
|
params.cArgs = 3;
|
|
|
|
hr = IWinHttpRequest_Invoke(request, DISPID_HTTPREQUEST_OPTION, &IID_NULL, 0, DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, &err);
|
|
|
|
todo_wine
|
|
|
|
ok(hr == S_OK, "error %#x\n", hr);
|
|
|
|
|
|
|
|
VariantInit(&arg[0]);
|
|
|
|
VariantInit(&arg[1]);
|
|
|
|
VariantInit(&arg[2]);
|
|
|
|
|
|
|
|
params.cArgs = 1;
|
|
|
|
V_VT(&arg[0]) = VT_I4;
|
|
|
|
V_I4(&arg[0]) = WinHttpRequestOption_URLCodePage;
|
|
|
|
hr = IWinHttpRequest_Invoke(request, DISPID_HTTPREQUEST_OPTION, &IID_NULL, 0, DISPATCH_PROPERTYGET, ¶ms, NULL, NULL, NULL);
|
|
|
|
ok(hr == S_OK, "error %#x\n", hr);
|
|
|
|
|
|
|
|
V_VT(&ret) = 0xdead;
|
|
|
|
V_I4(&ret) = 0xbeef;
|
|
|
|
hr = IWinHttpRequest_Invoke(request, DISPID_HTTPREQUEST_OPTION, &IID_NULL, 0, DISPATCH_METHOD|DISPATCH_PROPERTYGET, ¶ms, &ret, NULL, NULL);
|
|
|
|
ok(hr == S_OK, "error %#x\n", hr);
|
|
|
|
ok(V_VT(&ret) == VT_I4, "expected VT_I4, got %d\n", V_VT(&ret));
|
|
|
|
ok(V_I4(&ret) == CP_UTF8, "expected CP_UTF8, got %d\n", V_I4(&ret));
|
|
|
|
|
|
|
|
V_VT(&ret) = 0xdead;
|
|
|
|
V_I4(&ret) = 0xbeef;
|
|
|
|
hr = IWinHttpRequest_Invoke(request, DISPID_HTTPREQUEST_OPTION, &IID_NULL, 0, DISPATCH_METHOD, ¶ms, &ret, NULL, NULL);
|
|
|
|
ok(hr == S_OK, "error %#x\n", hr);
|
|
|
|
ok(V_VT(&ret) == VT_I4, "expected VT_I4, got %d\n", V_VT(&ret));
|
|
|
|
ok(V_I4(&ret) == CP_UTF8, "expected CP_UTF8, got %d\n", V_I4(&ret));
|
|
|
|
|
|
|
|
hr = IWinHttpRequest_Invoke(request, DISPID_HTTPREQUEST_OPTION, &IID_NULL, 0, DISPATCH_METHOD|DISPATCH_PROPERTYGET, ¶ms, NULL, NULL, NULL);
|
|
|
|
ok(hr == S_OK, "error %#x\n", hr);
|
|
|
|
|
|
|
|
V_VT(&ret) = 0xdead;
|
|
|
|
V_I4(&ret) = 0xbeef;
|
|
|
|
hr = IWinHttpRequest_Invoke(request, DISPID_HTTPREQUEST_OPTION, &IID_NULL, 0, 0, ¶ms, &ret, NULL, NULL);
|
|
|
|
ok(hr == S_OK, "error %#x\n", hr);
|
|
|
|
ok(V_VT(&ret) == VT_EMPTY, "expected VT_EMPTY, got %d\n", V_VT(&ret));
|
|
|
|
ok(V_I4(&ret) == 0xbeef || V_I4(&ret) == 0 /* Win8 */, "expected 0xdead, got %d\n", V_I4(&ret));
|
|
|
|
|
|
|
|
hr = IWinHttpRequest_Invoke(request, DISPID_HTTPREQUEST_OPTION, &IID_NULL, 0, 0, ¶ms, NULL, NULL, NULL);
|
|
|
|
ok(hr == S_OK, "error %#x\n", hr);
|
|
|
|
|
|
|
|
hr = IWinHttpRequest_Invoke(request, DISPID_HTTPREQUEST_OPTION, &IID_IUnknown, 0, DISPATCH_PROPERTYGET, ¶ms, NULL, NULL, NULL);
|
|
|
|
ok(hr == DISP_E_UNKNOWNINTERFACE, "error %#x\n", hr);
|
|
|
|
|
|
|
|
params.cArgs = 2;
|
|
|
|
hr = IWinHttpRequest_Invoke(request, DISPID_HTTPREQUEST_OPTION, &IID_NULL, 0, DISPATCH_PROPERTYGET, ¶ms, NULL, NULL, NULL);
|
|
|
|
todo_wine
|
|
|
|
ok(hr == S_OK, "error %#x\n", hr);
|
|
|
|
|
|
|
|
params.cArgs = 0;
|
|
|
|
hr = IWinHttpRequest_Invoke(request, DISPID_HTTPREQUEST_OPTION, &IID_NULL, 0, DISPATCH_PROPERTYGET, ¶ms, NULL, NULL, NULL);
|
|
|
|
ok(hr == DISP_E_PARAMNOTFOUND, "error %#x\n", hr);
|
|
|
|
|
2015-08-27 12:28:32 +02:00
|
|
|
SysFreeString(utf8);
|
2015-10-02 04:24:58 +02:00
|
|
|
|
|
|
|
params.cArgs = 1;
|
|
|
|
V_VT(&arg[0]) = VT_I4;
|
|
|
|
V_I4(&arg[0]) = AutoLogonPolicy_Never;
|
|
|
|
VariantInit(&ret);
|
|
|
|
hr = IWinHttpRequest_Invoke(request, DISPID_HTTPREQUEST_SETAUTOLOGONPOLICY, &IID_NULL, 0,
|
|
|
|
DISPATCH_METHOD, ¶ms, &ret, NULL, NULL);
|
|
|
|
ok(hr == S_OK, "error %#x\n", hr);
|
|
|
|
|
2015-08-27 12:28:32 +02:00
|
|
|
IWinHttpRequest_Release(request);
|
|
|
|
|
|
|
|
CoUninitialize();
|
|
|
|
}
|
|
|
|
|
2011-11-15 09:11:05 +01:00
|
|
|
static void test_WinHttpDetectAutoProxyConfigUrl(void)
|
|
|
|
{
|
|
|
|
BOOL ret;
|
|
|
|
WCHAR *url;
|
|
|
|
DWORD error;
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = WinHttpDetectAutoProxyConfigUrl( 0, NULL );
|
|
|
|
error = GetLastError();
|
|
|
|
ok( !ret, "expected failure\n" );
|
|
|
|
ok( error == ERROR_INVALID_PARAMETER, "got %u\n", error );
|
2018-11-22 21:15:56 +01:00
|
|
|
|
2011-11-15 09:11:05 +01:00
|
|
|
url = NULL;
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = WinHttpDetectAutoProxyConfigUrl( 0, &url );
|
|
|
|
error = GetLastError();
|
|
|
|
ok( !ret, "expected failure\n" );
|
|
|
|
ok( error == ERROR_INVALID_PARAMETER, "got %u\n", error );
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = WinHttpDetectAutoProxyConfigUrl( WINHTTP_AUTO_DETECT_TYPE_DNS_A, NULL );
|
|
|
|
error = GetLastError();
|
|
|
|
ok( !ret, "expected failure\n" );
|
|
|
|
ok( error == ERROR_INVALID_PARAMETER, "got %u\n", error );
|
2018-11-22 21:15:56 +01:00
|
|
|
|
2013-06-25 12:46:55 +02:00
|
|
|
url = (WCHAR *)0xdeadbeef;
|
2011-11-15 09:11:05 +01:00
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = WinHttpDetectAutoProxyConfigUrl( WINHTTP_AUTO_DETECT_TYPE_DNS_A, &url );
|
|
|
|
error = GetLastError();
|
|
|
|
if (!ret)
|
2013-06-25 12:46:55 +02:00
|
|
|
{
|
2011-11-15 09:11:05 +01:00
|
|
|
ok( error == ERROR_WINHTTP_AUTODETECTION_FAILED, "got %u\n", error );
|
2013-10-14 15:57:59 +02:00
|
|
|
ok( !url || broken(url == (WCHAR *)0xdeadbeef), "got %p\n", url );
|
2013-06-25 12:46:55 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
trace("%s\n", wine_dbgstr_w(url));
|
|
|
|
GlobalFree( url );
|
|
|
|
}
|
|
|
|
|
|
|
|
url = (WCHAR *)0xdeadbeef;
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = WinHttpDetectAutoProxyConfigUrl( WINHTTP_AUTO_DETECT_TYPE_DHCP, &url );
|
|
|
|
error = GetLastError();
|
|
|
|
if (!ret)
|
|
|
|
{
|
|
|
|
ok( error == ERROR_WINHTTP_AUTODETECTION_FAILED, "got %u\n", error );
|
2013-10-14 15:57:59 +02:00
|
|
|
ok( !url || broken(url == (WCHAR *)0xdeadbeef), "got %p\n", url );
|
2013-06-25 12:46:55 +02:00
|
|
|
}
|
2011-11-15 09:11:05 +01:00
|
|
|
else
|
|
|
|
{
|
2015-08-03 11:27:31 +02:00
|
|
|
ok( error == ERROR_SUCCESS, "got %u\n", error );
|
2011-11-15 09:11:05 +01:00
|
|
|
trace("%s\n", wine_dbgstr_w(url));
|
|
|
|
GlobalFree( url );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-11-16 09:42:17 +01:00
|
|
|
static void test_WinHttpGetIEProxyConfigForCurrentUser(void)
|
|
|
|
{
|
|
|
|
BOOL ret;
|
|
|
|
DWORD error;
|
|
|
|
WINHTTP_CURRENT_USER_IE_PROXY_CONFIG cfg;
|
|
|
|
|
|
|
|
memset( &cfg, 0, sizeof(cfg) );
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = WinHttpGetIEProxyConfigForCurrentUser( NULL );
|
|
|
|
error = GetLastError();
|
|
|
|
ok( !ret, "expected failure\n" );
|
|
|
|
ok( error == ERROR_INVALID_PARAMETER, "got %u\n", error );
|
|
|
|
|
2015-08-03 11:27:31 +02:00
|
|
|
SetLastError(0xdeadbeef);
|
2011-11-16 09:42:17 +01:00
|
|
|
ret = WinHttpGetIEProxyConfigForCurrentUser( &cfg );
|
2015-08-03 11:27:31 +02:00
|
|
|
error = GetLastError();
|
2011-11-16 09:42:17 +01:00
|
|
|
ok( ret, "expected success\n" );
|
2015-08-03 11:27:31 +02:00
|
|
|
ok( error == ERROR_SUCCESS || broken(error == ERROR_NO_TOKEN) /* < win7 */, "got %u\n", error );
|
|
|
|
|
2012-12-14 11:54:52 +01:00
|
|
|
trace("IEProxy.AutoDetect=%d\n", cfg.fAutoDetect);
|
|
|
|
trace("IEProxy.AutoConfigUrl=%s\n", wine_dbgstr_w(cfg.lpszAutoConfigUrl));
|
|
|
|
trace("IEProxy.Proxy=%s\n", wine_dbgstr_w(cfg.lpszProxy));
|
|
|
|
trace("IEProxy.ProxyBypass=%s\n", wine_dbgstr_w(cfg.lpszProxyBypass));
|
2011-11-16 09:42:17 +01:00
|
|
|
GlobalFree( cfg.lpszAutoConfigUrl );
|
|
|
|
GlobalFree( cfg.lpszProxy );
|
|
|
|
GlobalFree( cfg.lpszProxyBypass );
|
|
|
|
}
|
|
|
|
|
2011-11-18 10:36:04 +01:00
|
|
|
static void test_WinHttpGetProxyForUrl(void)
|
|
|
|
{
|
|
|
|
BOOL ret;
|
|
|
|
DWORD error;
|
|
|
|
HINTERNET session;
|
|
|
|
WINHTTP_AUTOPROXY_OPTIONS options;
|
|
|
|
WINHTTP_PROXY_INFO info;
|
|
|
|
|
|
|
|
memset( &options, 0, sizeof(options) );
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = WinHttpGetProxyForUrl( NULL, NULL, NULL, NULL );
|
|
|
|
error = GetLastError();
|
|
|
|
ok( !ret, "expected failure\n" );
|
|
|
|
ok( error == ERROR_INVALID_HANDLE, "got %u\n", error );
|
|
|
|
|
2020-02-14 16:41:38 +01:00
|
|
|
session = WinHttpOpen( L"winetest", 0, NULL, NULL, 0 );
|
2011-11-18 10:36:04 +01:00
|
|
|
ok( session != NULL, "failed to open session %u\n", GetLastError() );
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = WinHttpGetProxyForUrl( session, NULL, NULL, NULL );
|
|
|
|
error = GetLastError();
|
|
|
|
ok( !ret, "expected failure\n" );
|
|
|
|
ok( error == ERROR_INVALID_PARAMETER, "got %u\n", error );
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
2020-02-14 16:41:38 +01:00
|
|
|
ret = WinHttpGetProxyForUrl( session, L"", NULL, NULL );
|
2011-11-18 10:36:04 +01:00
|
|
|
error = GetLastError();
|
|
|
|
ok( !ret, "expected failure\n" );
|
|
|
|
ok( error == ERROR_INVALID_PARAMETER, "got %u\n", error );
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
2020-02-14 16:41:38 +01:00
|
|
|
ret = WinHttpGetProxyForUrl( session, L"http://winehq.org", NULL, NULL );
|
2011-11-18 10:36:04 +01:00
|
|
|
error = GetLastError();
|
|
|
|
ok( !ret, "expected failure\n" );
|
|
|
|
ok( error == ERROR_INVALID_PARAMETER, "got %u\n", error );
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
2020-02-14 16:41:38 +01:00
|
|
|
ret = WinHttpGetProxyForUrl( session, L"http://winehq.org", &options, &info );
|
2011-11-18 10:36:04 +01:00
|
|
|
error = GetLastError();
|
|
|
|
ok( !ret, "expected failure\n" );
|
|
|
|
ok( error == ERROR_INVALID_PARAMETER, "got %u\n", error );
|
|
|
|
|
|
|
|
options.dwFlags = WINHTTP_AUTOPROXY_AUTO_DETECT;
|
|
|
|
options.dwAutoDetectFlags = WINHTTP_AUTO_DETECT_TYPE_DNS_A;
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
2020-02-14 16:41:38 +01:00
|
|
|
ret = WinHttpGetProxyForUrl( session, L"http://winehq.org", &options, NULL );
|
2011-11-18 10:36:04 +01:00
|
|
|
error = GetLastError();
|
|
|
|
ok( !ret, "expected failure\n" );
|
|
|
|
ok( error == ERROR_INVALID_PARAMETER, "got %u\n", error );
|
|
|
|
|
|
|
|
options.dwFlags = WINHTTP_AUTOPROXY_AUTO_DETECT;
|
|
|
|
options.dwAutoDetectFlags = 0;
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
2020-02-14 16:41:38 +01:00
|
|
|
ret = WinHttpGetProxyForUrl( session, L"http://winehq.org", &options, &info );
|
2011-11-18 10:36:04 +01:00
|
|
|
error = GetLastError();
|
|
|
|
ok( !ret, "expected failure\n" );
|
|
|
|
ok( error == ERROR_INVALID_PARAMETER, "got %u\n", error );
|
|
|
|
|
|
|
|
options.dwFlags = WINHTTP_AUTOPROXY_AUTO_DETECT | WINHTTP_AUTOPROXY_CONFIG_URL;
|
|
|
|
options.dwAutoDetectFlags = WINHTTP_AUTO_DETECT_TYPE_DNS_A;
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
2020-02-14 16:41:38 +01:00
|
|
|
ret = WinHttpGetProxyForUrl( session, L"http://winehq.org", &options, &info );
|
2011-11-18 10:36:04 +01:00
|
|
|
error = GetLastError();
|
|
|
|
ok( !ret, "expected failure\n" );
|
|
|
|
ok( error == ERROR_INVALID_PARAMETER, "got %u\n", error );
|
|
|
|
|
|
|
|
options.dwFlags = WINHTTP_AUTOPROXY_AUTO_DETECT;
|
|
|
|
options.dwAutoDetectFlags = WINHTTP_AUTO_DETECT_TYPE_DNS_A;
|
|
|
|
|
|
|
|
memset( &info, 0, sizeof(info) );
|
2015-08-03 11:27:31 +02:00
|
|
|
SetLastError(0xdeadbeef);
|
2020-02-14 16:41:38 +01:00
|
|
|
ret = WinHttpGetProxyForUrl( session, L"http://winehq.org", &options, &info );
|
2015-08-03 11:27:31 +02:00
|
|
|
error = GetLastError();
|
2014-12-09 12:44:38 +01:00
|
|
|
if (ret)
|
2012-11-01 14:45:59 +01:00
|
|
|
{
|
2015-08-03 11:27:31 +02:00
|
|
|
ok( error == ERROR_SUCCESS, "got %u\n", error );
|
2012-12-14 11:54:52 +01:00
|
|
|
trace("Proxy.AccessType=%u\n", info.dwAccessType);
|
|
|
|
trace("Proxy.Proxy=%s\n", wine_dbgstr_w(info.lpszProxy));
|
|
|
|
trace("Proxy.ProxyBypass=%s\n", wine_dbgstr_w(info.lpszProxyBypass));
|
2012-11-01 14:45:59 +01:00
|
|
|
GlobalFree( info.lpszProxy );
|
|
|
|
GlobalFree( info.lpszProxyBypass );
|
|
|
|
}
|
|
|
|
|
|
|
|
options.dwFlags = WINHTTP_AUTOPROXY_CONFIG_URL;
|
|
|
|
options.dwAutoDetectFlags = 0;
|
2020-02-14 16:41:38 +01:00
|
|
|
options.lpszAutoConfigUrl = L"http://wpad/wpad.dat";
|
2012-11-01 14:45:59 +01:00
|
|
|
|
|
|
|
memset( &info, 0, sizeof(info) );
|
2020-02-14 16:41:38 +01:00
|
|
|
ret = WinHttpGetProxyForUrl( session, L"http://winehq.org", &options, &info );
|
2014-12-09 12:44:38 +01:00
|
|
|
if (ret)
|
2011-11-18 10:36:04 +01:00
|
|
|
{
|
2012-12-14 11:54:52 +01:00
|
|
|
trace("Proxy.AccessType=%u\n", info.dwAccessType);
|
|
|
|
trace("Proxy.Proxy=%s\n", wine_dbgstr_w(info.lpszProxy));
|
|
|
|
trace("Proxy.ProxyBypass=%s\n", wine_dbgstr_w(info.lpszProxyBypass));
|
2012-07-19 10:22:59 +02:00
|
|
|
GlobalFree( info.lpszProxy );
|
|
|
|
GlobalFree( info.lpszProxyBypass );
|
2011-11-18 10:36:04 +01:00
|
|
|
}
|
|
|
|
WinHttpCloseHandle( session );
|
|
|
|
}
|
|
|
|
|
2013-03-25 13:26:37 +01:00
|
|
|
static void test_chunked_read(void)
|
|
|
|
{
|
|
|
|
WCHAR header[32];
|
2015-09-22 15:58:33 +02:00
|
|
|
DWORD len, err;
|
2013-03-25 13:26:37 +01:00
|
|
|
HINTERNET ses, con = NULL, req = NULL;
|
|
|
|
BOOL ret;
|
|
|
|
|
|
|
|
trace( "starting chunked read test\n" );
|
|
|
|
|
2020-02-14 16:41:38 +01:00
|
|
|
ses = WinHttpOpen( L"winetest", 0, NULL, NULL, 0 );
|
2013-03-25 13:26:37 +01:00
|
|
|
ok( ses != NULL, "WinHttpOpen failed with error %u\n", GetLastError() );
|
|
|
|
if (!ses) goto done;
|
|
|
|
|
2020-02-14 16:41:38 +01:00
|
|
|
con = WinHttpConnect( ses, L"test.winehq.org", 0, 0 );
|
2013-03-25 13:26:37 +01:00
|
|
|
ok( con != NULL, "WinHttpConnect failed with error %u\n", GetLastError() );
|
|
|
|
if (!con) goto done;
|
|
|
|
|
2020-02-14 16:41:38 +01:00
|
|
|
req = WinHttpOpenRequest( con, NULL, L"/tests/chunked", NULL, NULL, NULL, 0 );
|
2013-03-25 13:26:37 +01:00
|
|
|
ok( req != NULL, "WinHttpOpenRequest failed with error %u\n", GetLastError() );
|
|
|
|
if (!req) goto done;
|
|
|
|
|
|
|
|
ret = WinHttpSendRequest( req, NULL, 0, NULL, 0, 0, 0 );
|
2015-09-22 15:58:33 +02:00
|
|
|
err = GetLastError();
|
|
|
|
if (!ret && (err == ERROR_WINHTTP_CANNOT_CONNECT || err == ERROR_WINHTTP_TIMEOUT))
|
2014-09-01 14:48:49 +02:00
|
|
|
{
|
|
|
|
skip("connection failed, skipping\n");
|
|
|
|
goto done;
|
|
|
|
}
|
2013-03-25 13:26:37 +01:00
|
|
|
ok( ret, "WinHttpSendRequest failed with error %u\n", GetLastError() );
|
2018-07-12 21:04:24 +02:00
|
|
|
if (!ret) goto done;
|
2013-03-25 13:26:37 +01:00
|
|
|
|
|
|
|
ret = WinHttpReceiveResponse( req, NULL );
|
|
|
|
ok( ret, "WinHttpReceiveResponse failed with error %u\n", GetLastError() );
|
2018-07-12 21:04:24 +02:00
|
|
|
if (!ret) goto done;
|
2013-03-25 13:26:37 +01:00
|
|
|
|
|
|
|
header[0] = 0;
|
|
|
|
len = sizeof(header);
|
|
|
|
ret = WinHttpQueryHeaders( req, WINHTTP_QUERY_TRANSFER_ENCODING, NULL, header, &len, 0 );
|
|
|
|
ok( ret, "failed to get TRANSFER_ENCODING header (error %u)\n", GetLastError() );
|
2020-02-14 16:41:38 +01:00
|
|
|
ok( !lstrcmpW( header, L"chunked" ), "wrong transfer encoding %s\n", wine_dbgstr_w(header) );
|
2013-03-25 13:26:37 +01:00
|
|
|
trace( "transfer encoding: %s\n", wine_dbgstr_w(header) );
|
|
|
|
|
|
|
|
header[0] = 0;
|
|
|
|
len = sizeof(header);
|
|
|
|
SetLastError( 0xdeadbeef );
|
|
|
|
ret = WinHttpQueryHeaders( req, WINHTTP_QUERY_CONTENT_LENGTH, NULL, &header, &len, 0 );
|
|
|
|
ok( !ret, "unexpected CONTENT_LENGTH header %s\n", wine_dbgstr_w(header) );
|
|
|
|
ok( GetLastError() == ERROR_WINHTTP_HEADER_NOT_FOUND, "wrong error %u\n", GetLastError() );
|
|
|
|
|
|
|
|
trace( "entering query loop\n" );
|
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
len = 0xdeadbeef;
|
|
|
|
ret = WinHttpQueryDataAvailable( req, &len );
|
|
|
|
ok( ret, "WinHttpQueryDataAvailable failed with error %u\n", GetLastError() );
|
|
|
|
if (ret) ok( len != 0xdeadbeef, "WinHttpQueryDataAvailable return wrong length\n" );
|
|
|
|
trace( "got %u available\n", len );
|
|
|
|
if (len)
|
|
|
|
{
|
|
|
|
DWORD bytes_read;
|
|
|
|
char *buf = HeapAlloc( GetProcessHeap(), 0, len + 1 );
|
|
|
|
|
|
|
|
ret = WinHttpReadData( req, buf, len, &bytes_read );
|
2019-01-31 21:31:46 +01:00
|
|
|
ok(ret, "WinHttpReadData failed: %u.\n", GetLastError());
|
2013-03-25 13:26:37 +01:00
|
|
|
|
|
|
|
buf[bytes_read] = 0;
|
|
|
|
trace( "WinHttpReadData -> %d %u\n", ret, bytes_read );
|
|
|
|
ok( len == bytes_read, "only got %u of %u available\n", bytes_read, len );
|
|
|
|
ok( buf[bytes_read - 1] == '\n', "received partial line '%s'\n", buf );
|
|
|
|
|
|
|
|
HeapFree( GetProcessHeap(), 0, buf );
|
|
|
|
if (!bytes_read) break;
|
|
|
|
}
|
|
|
|
if (!len) break;
|
|
|
|
}
|
|
|
|
trace( "done\n" );
|
|
|
|
|
|
|
|
done:
|
|
|
|
if (req) WinHttpCloseHandle( req );
|
|
|
|
if (con) WinHttpCloseHandle( con );
|
|
|
|
if (ses) WinHttpCloseHandle( ses );
|
|
|
|
}
|
|
|
|
|
2020-07-03 11:21:37 +02:00
|
|
|
static void test_max_http_automatic_redirects (void)
|
|
|
|
{
|
|
|
|
HINTERNET session, request, connection;
|
|
|
|
DWORD max_redirects, err;
|
|
|
|
BOOL ret;
|
|
|
|
|
|
|
|
session = WinHttpOpen(L"winetest", WINHTTP_ACCESS_TYPE_DEFAULT_PROXY,
|
|
|
|
WINHTTP_NO_PROXY_NAME, WINHTTP_NO_PROXY_BYPASS, 0);
|
|
|
|
ok(session != NULL, "WinHttpOpen failed to open session.\n");
|
|
|
|
|
|
|
|
connection = WinHttpConnect (session, L"test.winehq.org", INTERNET_DEFAULT_HTTP_PORT, 0);
|
|
|
|
ok(connection != NULL, "WinHttpConnect failed to open a connection, error: %u.\n", GetLastError());
|
|
|
|
|
|
|
|
/* Test with 2 redirects (page will try to redirect 3 times) */
|
|
|
|
request = WinHttpOpenRequest(connection, L"GET", L"tests/redirecttest.php?max=3", NULL, WINHTTP_NO_REFERER,
|
|
|
|
WINHTTP_DEFAULT_ACCEPT_TYPES, WINHTTP_FLAG_BYPASS_PROXY_CACHE);
|
|
|
|
if (request == NULL && GetLastError() == ERROR_WINHTTP_NAME_NOT_RESOLVED)
|
|
|
|
{
|
|
|
|
skip("Network unreachable, skipping.\n");
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
ok(request != NULL, "WinHttpOpenRequest failed to open a request, error: %u.\n", GetLastError());
|
|
|
|
if (!request) goto done;
|
|
|
|
|
|
|
|
max_redirects = 2;
|
|
|
|
ret = WinHttpSetOption(request, WINHTTP_OPTION_MAX_HTTP_AUTOMATIC_REDIRECTS, &max_redirects, sizeof(max_redirects));
|
2020-07-03 11:21:40 +02:00
|
|
|
ok(ret, "WinHttpSetOption failed: %u\n", GetLastError());
|
2020-07-03 11:21:37 +02:00
|
|
|
|
|
|
|
ret = WinHttpSendRequest(request, WINHTTP_NO_ADDITIONAL_HEADERS, 0, WINHTTP_NO_REQUEST_DATA, 0, 0, 0);
|
|
|
|
err = GetLastError();
|
|
|
|
if (!ret && (err == ERROR_WINHTTP_CANNOT_CONNECT || err == ERROR_WINHTTP_TIMEOUT))
|
|
|
|
{
|
|
|
|
skip("connection failed, skipping\n");
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
ok(ret == TRUE, "WinHttpSendRequest failed: %u\n", GetLastError());
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = WinHttpReceiveResponse(request, NULL);
|
2020-07-03 11:21:40 +02:00
|
|
|
ok(!ret, "WinHttpReceiveResponse succeeded, expected failure\n");
|
|
|
|
ok(GetLastError() == ERROR_WINHTTP_REDIRECT_FAILED, "Expected ERROR_WINHTTP_REDIRECT_FAILED, got %u.\n", GetLastError());
|
2020-07-03 11:21:37 +02:00
|
|
|
|
|
|
|
done:
|
|
|
|
ret = WinHttpCloseHandle(request);
|
|
|
|
ok(ret == TRUE, "WinHttpCloseHandle failed on closing request, got %d.\n", ret);
|
|
|
|
ret = WinHttpCloseHandle(connection);
|
|
|
|
ok(ret == TRUE, "WinHttpCloseHandle failed on closing connection, got %d.\n", ret);
|
|
|
|
ret = WinHttpCloseHandle(session);
|
|
|
|
ok(ret == TRUE, "WinHttpCloseHandle failed on closing session, got %d.\n", ret);
|
|
|
|
}
|
|
|
|
|
2008-07-18 02:37:23 +02:00
|
|
|
START_TEST (winhttp)
|
|
|
|
{
|
2010-04-22 16:35:28 +02:00
|
|
|
struct server_info si;
|
|
|
|
HANDLE thread;
|
|
|
|
DWORD ret;
|
2020-06-16 11:45:12 +02:00
|
|
|
HMODULE mod = GetModuleHandleA("winhttp.dll");
|
|
|
|
|
2020-06-24 10:33:10 +02:00
|
|
|
pWinHttpWebSocketClose = (void *)GetProcAddress(mod, "WinHttpWebSocketClose");
|
2020-06-16 11:45:12 +02:00
|
|
|
pWinHttpWebSocketCompleteUpgrade = (void *)GetProcAddress(mod, "WinHttpWebSocketCompleteUpgrade");
|
2020-06-24 10:33:10 +02:00
|
|
|
pWinHttpWebSocketQueryCloseStatus = (void *)GetProcAddress(mod, "WinHttpWebSocketQueryCloseStatus");
|
|
|
|
pWinHttpWebSocketSend = (void *)GetProcAddress(mod, "WinHttpWebSocketSend");
|
|
|
|
pWinHttpWebSocketShutdown = (void *)GetProcAddress(mod, "WinHttpWebSocketShutdown");
|
|
|
|
pWinHttpWebSocketReceive = (void *)GetProcAddress(mod, "WinHttpWebSocketReceive");
|
2010-04-22 16:35:28 +02:00
|
|
|
|
2019-08-02 11:01:36 +02:00
|
|
|
test_WinHttpOpenRequest();
|
|
|
|
test_WinHttpSendRequest();
|
2008-08-14 23:54:18 +02:00
|
|
|
test_WinHttpTimeFromSystemTime();
|
2008-08-14 23:56:07 +02:00
|
|
|
test_WinHttpTimeToSystemTime();
|
2008-08-14 23:50:18 +02:00
|
|
|
test_WinHttpAddHeaders();
|
2008-08-28 13:50:03 +02:00
|
|
|
test_secure_connection();
|
2008-08-28 13:51:41 +02:00
|
|
|
test_request_parameter_defaults();
|
2019-08-02 11:01:36 +02:00
|
|
|
test_WinHttpQueryOption();
|
2009-07-14 21:36:41 +02:00
|
|
|
test_set_default_proxy_config();
|
2009-10-29 11:12:22 +01:00
|
|
|
test_empty_headers_param();
|
2018-09-10 13:24:34 +02:00
|
|
|
test_timeouts();
|
2010-02-22 12:27:30 +01:00
|
|
|
test_resolve_timeout();
|
2010-04-22 16:34:48 +02:00
|
|
|
test_credentials();
|
2015-08-27 12:28:32 +02:00
|
|
|
test_IWinHttpRequest_Invoke();
|
2011-11-15 09:11:05 +01:00
|
|
|
test_WinHttpDetectAutoProxyConfigUrl();
|
2011-11-16 09:42:17 +01:00
|
|
|
test_WinHttpGetIEProxyConfigForCurrentUser();
|
2011-11-18 10:36:04 +01:00
|
|
|
test_WinHttpGetProxyForUrl();
|
2013-03-25 13:26:37 +01:00
|
|
|
test_chunked_read();
|
2020-07-03 11:21:37 +02:00
|
|
|
test_max_http_automatic_redirects();
|
2010-04-22 16:35:28 +02:00
|
|
|
|
2013-10-14 15:58:44 +02:00
|
|
|
si.event = CreateEventW(NULL, 0, 0, NULL);
|
2010-04-22 16:35:28 +02:00
|
|
|
si.port = 7532;
|
|
|
|
|
2019-09-02 15:34:53 +02:00
|
|
|
thread = CreateThread(NULL, 0, server_thread, &si, 0, NULL);
|
2010-04-22 16:35:28 +02:00
|
|
|
ok(thread != NULL, "failed to create thread %u\n", GetLastError());
|
|
|
|
|
|
|
|
ret = WaitForSingleObject(si.event, 10000);
|
|
|
|
ok(ret == WAIT_OBJECT_0, "failed to start winhttp test server %u\n", GetLastError());
|
|
|
|
if (ret != WAIT_OBJECT_0)
|
2018-01-05 13:38:11 +01:00
|
|
|
{
|
|
|
|
CloseHandle(thread);
|
2010-04-22 16:35:28 +02:00
|
|
|
return;
|
2018-01-05 13:38:11 +01:00
|
|
|
}
|
2010-04-22 16:35:28 +02:00
|
|
|
|
2015-12-10 14:54:30 +01:00
|
|
|
test_IWinHttpRequest(si.port);
|
2013-03-15 10:39:00 +01:00
|
|
|
test_connection_info(si.port);
|
2020-02-14 16:41:38 +01:00
|
|
|
test_basic_request(si.port, NULL, L"/basic");
|
2010-04-22 16:35:28 +02:00
|
|
|
test_no_headers(si.port);
|
2014-07-30 18:31:17 +02:00
|
|
|
test_no_content(si.port);
|
2015-01-21 13:25:18 +01:00
|
|
|
test_head_request(si.port);
|
2014-12-09 12:50:07 +01:00
|
|
|
test_not_modified(si.port);
|
2010-04-22 16:35:28 +02:00
|
|
|
test_basic_authentication(si.port);
|
2017-04-05 11:20:54 +02:00
|
|
|
test_multi_authentication(si.port);
|
2017-04-12 10:46:34 +02:00
|
|
|
test_large_data_authentication(si.port);
|
2012-03-12 12:25:14 +01:00
|
|
|
test_bad_header(si.port);
|
2013-10-14 21:36:05 +02:00
|
|
|
test_multiple_reads(si.port);
|
2015-06-15 17:32:25 +02:00
|
|
|
test_cookies(si.port);
|
2018-08-24 13:32:42 +02:00
|
|
|
test_request_path_escapes(si.port);
|
2019-08-02 11:01:37 +02:00
|
|
|
test_passport_auth(si.port);
|
2020-06-16 11:45:12 +02:00
|
|
|
test_websocket(si.port);
|
2010-04-22 16:35:28 +02:00
|
|
|
|
|
|
|
/* send the basic request again to shutdown the server thread */
|
2020-02-14 16:41:38 +01:00
|
|
|
test_basic_request(si.port, NULL, L"/quit");
|
2010-04-22 16:35:28 +02:00
|
|
|
|
|
|
|
WaitForSingleObject(thread, 3000);
|
2018-01-05 13:38:11 +01:00
|
|
|
CloseHandle(thread);
|
2008-07-18 02:37:23 +02:00
|
|
|
}
|