ReactOS  0.4.15-dev-507-g90aff8d
winhttp.c File Reference
#include <stdarg.h>
#include <windef.h>
#include <winsock2.h>
#include <ws2tcpip.h>
#include <winhttp.h>
#include <wincrypt.h>
#include <winreg.h>
#include <stdio.h>
#include <initguid.h>
#include <httprequest.h>
#include <httprequestid.h>
#include "wine/test.h"
#include "wine/heap.h"
Include dependency graph for winhttp.c:

Go to the source code of this file.

Classes

struct  server_info
 

Macros

#define COBJMACROS
 
#define X(x)   if (flags & x) trace("%s\n", #x);
 
#define BIG_BUFFER_LEN   0x2250
 

Functions

 DEFINE_GUID (GUID_NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
 
static WCHARa2w (const char *str)
 
static int strcmp_wa (const WCHAR *str1, const char *stra)
 
static BOOL proxy_active (void)
 
static void test_WinHttpQueryOption (void)
 
static void test_WinHttpOpenRequest (void)
 
static void test_empty_headers_param (void)
 
static void test_WinHttpSendRequest (void)
 
static void test_WinHttpTimeFromSystemTime (void)
 
static void test_WinHttpTimeToSystemTime (void)
 
static void test_WinHttpAddHeaders (void)
 
static void CALLBACK cert_error (HINTERNET handle, DWORD_PTR ctx, DWORD status, LPVOID buf, DWORD len)
 
static void test_secure_connection (void)
 
static void test_request_parameter_defaults (void)
 
static DWORD get_default_proxy_reg_value (BYTE *buf, DWORD len, DWORD *type)
 
static void set_proxy (REGSAM access, BYTE *buf, DWORD len, DWORD type)
 
static void set_default_proxy_reg_value (BYTE *buf, DWORD len, DWORD type)
 
static void test_set_default_proxy_config (void)
 
static void test_timeouts (void)
 
static void test_resolve_timeout (void)
 
static DWORD CALLBACK server_thread (LPVOID param)
 
static void test_basic_request (int port, const WCHAR *verb, const WCHAR *path)
 
static void test_basic_authentication (int port)
 
static void test_multi_authentication (int port)
 
static void test_large_data_authentication (int port)
 
static void test_no_headers (int port)
 
static void test_no_content (int port)
 
static void test_head_request (int port)
 
static void test_not_modified (int port)
 
static void test_bad_header (int port)
 
static void test_multiple_reads (int port)
 
static void test_cookies (int port)
 
static void do_request (HINTERNET con, const WCHAR *obj, DWORD flags)
 
static void test_request_path_escapes (int port)
 
static void test_connection_info (int port)
 
static void test_passport_auth (int port)
 
static void test_credentials (void)
 
static void test_IWinHttpRequest (int port)
 
static void request_get_property (IWinHttpRequest *request, int property, VARIANT *ret)
 
static void test_IWinHttpRequest_Invoke (void)
 
static void test_WinHttpDetectAutoProxyConfigUrl (void)
 
static void test_WinHttpGetIEProxyConfigForCurrentUser (void)
 
static void test_WinHttpGetProxyForUrl (void)
 
static void test_chunked_read (void)
 
 START_TEST (winhttp)
 

Variables

static const WCHAR test_useragent []
 
static const WCHAR test_winehq [] = {'t','e','s','t','.','w','i','n','e','h','q','.','o','r','g',0}
 
static const WCHAR test_winehq_https [] = {'h','t','t','p','s',':','/','/','t','e','s','t','.','w','i','n','e','h','q','.','o','r','g',':','4','4','3',0}
 
static const WCHAR localhostW [] = {'l','o','c','a','l','h','o','s','t',0}
 
static const WCHAR Connections []
 
static const WCHAR WinHttpSettings []
 
static const char page1 []
 
static const char okmsg []
 
static const char notokmsg []
 
static const char cookiemsg []
 
static const char cookiemsg2 []
 
static const char nocontentmsg []
 
static const char notmodified []
 
static const char noauthmsg []
 
static const char okauthmsg []
 
static const char headmsg []
 
static const char multiauth []
 
static const char largeauth []
 
static const char passportauth []
 
static const char unauthorized [] = "Unauthorized"
 
static const char hello_world [] = "Hello World"
 
static const char auth_unseen [] = "Auth Unseen"
 

Macro Definition Documentation

◆ BIG_BUFFER_LEN

#define BIG_BUFFER_LEN   0x2250

Definition at line 2269 of file winhttp.c.

◆ COBJMACROS

#define COBJMACROS

Definition at line 22 of file winhttp.c.

◆ X

#define X (   x)    if (flags & x) trace("%s\n", #x);

Function Documentation

◆ a2w()

static WCHAR* a2w ( const char str)
static

Definition at line 46 of file winhttp.c.

47 {
48  int len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
49  WCHAR *ret = heap_alloc(len * sizeof(WCHAR));
51  return ret;
52 }
#define CP_ACP
Definition: compat.h:99
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
const WCHAR * str
smooth NULL
Definition: ftsmooth.c:416
__wchar_t WCHAR
Definition: xmlstorage.h:180
int ret
GLenum GLsizei len
Definition: glext.h:6722
#define MultiByteToWideChar
Definition: compat.h:100

Referenced by strcmp_wa().

◆ cert_error()

static void CALLBACK cert_error ( HINTERNET  handle,
DWORD_PTR  ctx,
DWORD  status,
LPVOID  buf,
DWORD  len 
)
static

Definition at line 1028 of file winhttp.c.

1029 {
1030  DWORD flags = *(DWORD *)buf;
1031 
1032  if (!flags)
1033  {
1034  trace("WINHTTP_CALLBACK_STATUS_FLAG_SECURITY_CHANNEL_ERROR\n");
1035  return;
1036  }
1037 #define X(x) if (flags & x) trace("%s\n", #x);
1045 #undef X
1046 }
#define WINHTTP_CALLBACK_STATUS_FLAG_INVALID_CA
Definition: winhttp.h:437
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define WINHTTP_CALLBACK_STATUS_FLAG_INVALID_CERT
Definition: winhttp.h:435
#define WINHTTP_CALLBACK_STATUS_FLAG_CERT_CN_INVALID
Definition: winhttp.h:438
#define WINHTTP_CALLBACK_STATUS_FLAG_CERT_DATE_INVALID
Definition: winhttp.h:439
#define trace
Definition: atltest.h:70
unsigned long DWORD
Definition: ntddk_ex.h:95
GLbitfield flags
Definition: glext.h:7161
#define WINHTTP_CALLBACK_STATUS_FLAG_CERT_WRONG_USAGE
Definition: winhttp.h:440
#define WINHTTP_CALLBACK_STATUS_FLAG_CERT_REV_FAILED
Definition: winhttp.h:434
#define WINHTTP_CALLBACK_STATUS_FLAG_CERT_REVOKED
Definition: winhttp.h:436
#define X(x)

Referenced by test_secure_connection().

◆ DEFINE_GUID()

DEFINE_GUID ( GUID_NULL  ,
,
,
,
,
,
,
,
,
,
,
 
)

◆ do_request()

static void do_request ( HINTERNET  con,
const WCHAR obj,
DWORD  flags 
)
static

Definition at line 3427 of file winhttp.c.

3428 {
3429  HINTERNET req;
3430  DWORD status, size;
3431  BOOL ret;
3432 
3433  req = WinHttpOpenRequest( con, NULL, obj, NULL, NULL, NULL, flags );
3434  ok( req != NULL, "failed to open a request %u\n", GetLastError() );
3435 
3436  ret = WinHttpSendRequest( req, NULL, 0, NULL, 0, 0, 0 );
3437  ok( ret, "failed to send request %u\n", GetLastError() );
3438 
3439  ret = WinHttpReceiveResponse( req, NULL );
3440  ok( ret, "failed to receive response %u\n", GetLastError() );
3441 
3442  status = 0xdeadbeef;
3443  size = sizeof(status);
3445  ok( ret, "failed to query status code %u\n", GetLastError() );
3446  ok( status == HTTP_STATUS_OK || broken(status == HTTP_STATUS_BAD_REQUEST) /* < win7 */,
3447  "request %s with flags %08x failed %u\n", wine_dbgstr_w(obj), flags, status );
3448  WinHttpCloseHandle( req );
3449 }
BOOL WINAPI WinHttpCloseHandle(HINTERNET handle)
Definition: session.c:1195
char * wine_dbgstr_w(const wchar_t *wstr)
Definition: atltest.h:87
#define WINHTTP_QUERY_STATUS_CODE
Definition: winhttp.h:317
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define HTTP_STATUS_BAD_REQUEST
Definition: winhttp.h:255
BOOL WINAPI WinHttpQueryHeaders(HINTERNET hrequest, DWORD level, LPCWSTR name, LPVOID buffer, LPDWORD buflen, LPDWORD index)
Definition: request.c:856
unsigned int BOOL
Definition: ntddk_ex.h:94
BOOL WINAPI WinHttpReceiveResponse(HINTERNET hrequest, LPVOID reserved)
Definition: request.c:2924
smooth NULL
Definition: ftsmooth.c:416
GLsizeiptr size
Definition: glext.h:5919
#define WINHTTP_QUERY_FLAG_NUMBER
Definition: winhttp.h:377
unsigned long DWORD
Definition: ntddk_ex.h:95
#define HTTP_STATUS_OK
Definition: winhttp.h:240
GLbitfield flags
Definition: glext.h:7161
int ret
#define broken(x)
Definition: _sntprintf.h:21
#define ok(value,...)
Definition: atltest.h:57
HINTERNET WINAPI WinHttpOpenRequest(HINTERNET hconnect, LPCWSTR verb, LPCWSTR object, LPCWSTR version, LPCWSTR referrer, LPCWSTR *types, DWORD flags)
Definition: session.c:1117
static SERVICE_STATUS status
Definition: service.c:31
BOOL WINAPI WinHttpSendRequest(HINTERNET hrequest, LPCWSTR headers, DWORD headers_len, LPVOID optional, DWORD optional_len, DWORD total_len, DWORD_PTR context)
Definition: request.c:2350
Definition: ps.c:97

Referenced by test_request_path_escapes().

◆ get_default_proxy_reg_value()

static DWORD get_default_proxy_reg_value ( BYTE buf,
DWORD  len,
DWORD type 
)
static

Definition at line 1309 of file winhttp.c.

1310 {
1311  LONG l;
1312  HKEY key;
1313  DWORD ret = 0;
1314 
1316  if (!l)
1317  {
1318  DWORD size = 0;
1319 
1321  if (!l)
1322  {
1323  if (size <= len)
1325  &size );
1326  if (!l)
1327  ret = size;
1328  }
1329  RegCloseKey( key );
1330  }
1331  return ret;
1332 }
static const WCHAR WinHttpSettings[]
Definition: winhttp.c:1306
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define KEY_READ
Definition: nt_native.h:1023
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
long LONG
Definition: pedump.c:60
smooth NULL
Definition: ftsmooth.c:416
r l[0]
Definition: byte_order.h:167
GLsizeiptr size
Definition: glext.h:5919
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4116
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
HKEY key
Definition: reg.c:42
GLenum GLsizei len
Definition: glext.h:6722
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3366
static const WCHAR Connections[]
Definition: winhttp.c:1299
Definition: path.c:41
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12

Referenced by test_set_default_proxy_config().

◆ proxy_active()

static BOOL proxy_active ( void  )
static

Definition at line 62 of file winhttp.c.

63 {
64  WINHTTP_PROXY_INFO proxy_info;
65  BOOL active = FALSE;
66 
67  SetLastError(0xdeadbeef);
68  if (WinHttpGetDefaultProxyConfiguration(&proxy_info))
69  {
70  ok(GetLastError() == ERROR_SUCCESS || broken(GetLastError() == 0xdeadbeef) /* < win7 */,
71  "got %u\n", GetLastError());
72  active = (proxy_info.lpszProxy != NULL);
73  if (active)
74  GlobalFree(proxy_info.lpszProxy);
75  if (proxy_info.lpszProxyBypass != NULL)
76  GlobalFree(proxy_info.lpszProxyBypass);
77  }
78  else
79  active = FALSE;
80 
81  return active;
82 }
#define ERROR_SUCCESS
Definition: deptool.c:10
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
LPWSTR lpszProxyBypass
Definition: winhttp.h:506
HGLOBAL NTAPI GlobalFree(HGLOBAL hMem)
Definition: heapmem.c:611
#define SetLastError(x)
Definition: compat.h:418
#define broken(x)
Definition: _sntprintf.h:21
#define ok(value,...)
Definition: atltest.h:57
BOOL WINAPI WinHttpGetDefaultProxyConfiguration(WINHTTP_PROXY_INFO *info)
Definition: session.c:1537
LPWSTR lpszProxy
Definition: winhttp.h:505

Referenced by test_resolve_timeout().

◆ request_get_property()

static void request_get_property ( IWinHttpRequest *  request,
int  property,
VARIANT ret 
)
static

Definition at line 4322 of file winhttp.c.

4323 {
4325  VARIANT arg;
4326  HRESULT hr;
4327 
4328  memset(&params, 0, sizeof(params));
4329  params.cNamedArgs = 0;
4330  params.rgdispidNamedArgs = NULL;
4331  params.cArgs = 1;
4332  params.rgvarg = &arg;
4333  VariantInit(&arg);
4334  V_VT(&arg) = VT_I4;
4335  V_I4(&arg) = property;
4336  VariantInit(ret);
4337  hr = IWinHttpRequest_Invoke(request, DISPID_HTTPREQUEST_OPTION, &IID_NULL, 0,
4339  ok(hr == S_OK, "error %#x\n", hr);
4340 }
Definition: compat.h:1948
#define DISPATCH_PROPERTYGET
Definition: oleauto.h:1007
HRESULT hr
Definition: shlfolder.c:183
void * arg
Definition: msvc.h:10
void WINAPI VariantInit(VARIANTARG *pVarg)
Definition: variant.c:568
#define V_I4(A)
Definition: oleauto.h:247
GLenum const GLfloat * params
Definition: glext.h:5645
smooth NULL
Definition: ftsmooth.c:416
LONG HRESULT
Definition: typedefs.h:78
#define DISPID_HTTPREQUEST_OPTION
Definition: httprequestid.h:28
int ret
#define IID_NULL
Definition: guiddef.h:98
#define V_VT(A)
Definition: oleauto.h:211
#define S_OK
Definition: intsafe.h:59
#define ok(value,...)
Definition: atltest.h:57
Definition: tftpd.h:85
struct stdole::DISPPARAMS DISPPARAMS
#define memset(x, y, z)
Definition: compat.h:39

Referenced by test_IWinHttpRequest_Invoke().

◆ server_thread()

static DWORD CALLBACK server_thread ( LPVOID  param)
static

Definition at line 2271 of file winhttp.c.

2272 {
2273  struct server_info *si = param;
2274  int r, c = -1, i, on;
2275  SOCKET s;
2276  struct sockaddr_in sa;
2277  char buffer[0x100];
2278  WSADATA wsaData;
2279  int last_request = 0;
2280 
2281  WSAStartup(MAKEWORD(1,1), &wsaData);
2282 
2283  s = socket(AF_INET, SOCK_STREAM, 0);
2284  if (s == INVALID_SOCKET)
2285  return 1;
2286 
2287  on = 1;
2288  setsockopt(s, SOL_SOCKET, SO_REUSEADDR, (char*)&on, sizeof on);
2289 
2290  memset(&sa, 0, sizeof sa);
2291  sa.sin_family = AF_INET;
2292  sa.sin_port = htons(si->port);
2293  sa.sin_addr.S_un.S_addr = inet_addr("127.0.0.1");
2294 
2295  r = bind(s, (struct sockaddr *)&sa, sizeof(sa));
2296  if (r < 0)
2297  return 1;
2298 
2299  listen(s, 0);
2300  SetEvent(si->event);
2301  do
2302  {
2303  if (c == -1) c = accept(s, NULL, NULL);
2304 
2305  memset(buffer, 0, sizeof buffer);
2306  for(i = 0; i < sizeof buffer - 1; i++)
2307  {
2308  r = recv(c, &buffer[i], 1, 0);
2309  if (r != 1)
2310  break;
2311  if (i < 4) continue;
2312  if (buffer[i - 2] == '\n' && buffer[i] == '\n' &&
2313  buffer[i - 3] == '\r' && buffer[i - 1] == '\r')
2314  break;
2315  }
2316  if (strstr(buffer, "GET /basic"))
2317  {
2318  send(c, okmsg, sizeof okmsg - 1, 0);
2319  send(c, page1, sizeof page1 - 1, 0);
2320  }
2321  if (strstr(buffer, "/auth_with_creds"))
2322  {
2323  send(c, okauthmsg, sizeof okauthmsg - 1, 0);
2324  if (strstr(buffer, "Authorization: Basic dXNlcjpwd2Q="))
2325  send(c, hello_world, sizeof hello_world - 1, 0);
2326  else
2327  send(c, auth_unseen, sizeof auth_unseen - 1, 0);
2328  continue;
2329  }
2330  if (strstr(buffer, "/auth"))
2331  {
2332  if (strstr(buffer, "Authorization: Basic dXNlcjpwd2Q="))
2333  {
2334  send(c, okauthmsg, sizeof okauthmsg - 1, 0);
2335  send(c, hello_world, sizeof hello_world - 1, 0);
2336  }
2337  else
2338  {
2339  send(c, noauthmsg, sizeof noauthmsg - 1, 0);
2340  send(c, unauthorized, sizeof unauthorized - 1, 0);
2341  }
2342  continue;
2343  }
2344  if (strstr(buffer, "/big"))
2345  {
2346  char msg[BIG_BUFFER_LEN];
2347  memset(msg, 'm', sizeof(msg));
2348  send(c, okmsg, sizeof(okmsg) - 1, 0);
2349  send(c, msg, sizeof(msg), 0);
2350  }
2351  if (strstr(buffer, "/no_headers"))
2352  {
2353  send(c, page1, sizeof page1 - 1, 0);
2354  }
2355  if (strstr(buffer, "GET /no_content"))
2356  {
2357  send(c, nocontentmsg, sizeof nocontentmsg - 1, 0);
2358  continue;
2359  }
2360  if (strstr(buffer, "GET /not_modified"))
2361  {
2362  if (strstr(buffer, "If-Modified-Since:")) send(c, notmodified, sizeof notmodified - 1, 0);
2363  else send(c, notokmsg, sizeof(notokmsg) - 1, 0);
2364  continue;
2365  }
2366  if (strstr(buffer, "HEAD /head"))
2367  {
2368  send(c, headmsg, sizeof headmsg - 1, 0);
2369  continue;
2370  }
2371  if (strstr(buffer, "GET /multiauth"))
2372  {
2373  send(c, multiauth, sizeof multiauth - 1, 0);
2374  }
2375  if (strstr(buffer, "GET /largeauth"))
2376  {
2377  if (strstr(buffer, "Authorization: NTLM"))
2378  send(c, okmsg, sizeof(okmsg) - 1, 0);
2379  else
2380  {
2381  send(c, largeauth, sizeof largeauth - 1, 0);
2382 #ifdef __REACTOS__
2383  memset(buffer, 'A', sizeof(buffer));
2384  for (i = 0; i < (10240 / sizeof(buffer)); i++) send(c, buffer, sizeof(buffer), 0);
2385 #else
2386  for (i = 0; i < 10240; i++) send(c, "A", 1, 0);
2387 #endif
2388  continue;
2389  }
2390  }
2391  if (strstr(buffer, "GET /cookie5"))
2392  {
2393  if (strstr(buffer, "Cookie: name2=value\r\n"))
2394  send(c, okmsg, sizeof(okmsg) - 1, 0);
2395  else
2396  send(c, notokmsg, sizeof(notokmsg) - 1, 0);
2397  }
2398  if (strstr(buffer, "GET /cookie4"))
2399  {
2400  send(c, cookiemsg2, sizeof(cookiemsg2) - 1, 0);
2401  }
2402  if (strstr(buffer, "GET /cookie3"))
2403  {
2404  if (strstr(buffer, "Cookie: name=value2; NAME=value; name=value\r\n") ||
2405  broken(strstr(buffer, "Cookie: name=value2; name=value; NAME=value\r\n") != NULL))
2406  send(c, okmsg, sizeof(okmsg) - 1, 0);
2407  else
2408  send(c, notokmsg, sizeof(notokmsg) - 1, 0);
2409  }
2410  if (strstr(buffer, "GET /cookie2"))
2411  {
2412  if (strstr(buffer, "Cookie: NAME=value; name=value\r\n") ||
2413  broken(strstr(buffer, "Cookie: name=value; NAME=value\r\n") != NULL))
2414  send(c, okmsg, sizeof(okmsg) - 1, 0);
2415  else
2416  send(c, notokmsg, sizeof(notokmsg) - 1, 0);
2417  }
2418  else if (strstr(buffer, "GET /cookie"))
2419  {
2420  if (!strstr(buffer, "Cookie: name=value\r\n")) send(c, cookiemsg, sizeof(cookiemsg) - 1, 0);
2421  else send(c, notokmsg, sizeof(notokmsg) - 1, 0);
2422  }
2423  else if (strstr(buffer, "GET /escape"))
2424  {
2425  static const char res[] = "%0D%0A%1F%7F%3C%20%one?%1F%7F%20!%22%23$%&'()*+,-./:;%3C=%3E?@%5B%5C%5D"
2426  "%5E_%60%7B%7C%7D~%0D%0A ";
2427  static const char res2[] = "%0D%0A%1F%7F%3C%20%25two?%1F%7F%20!%22%23$%25&'()*+,-./:;%3C=%3E?@%5B%5C%5D"
2428  "%5E_%60%7B%7C%7D~%0D%0A ";
2429  static const char res3[] = "\x1f\x7f<%20%three?\x1f\x7f%20!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~ ";
2430  static const char res4[] = "%0D%0A%1F%7F%3C%20%four?\x1f\x7f%20!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~ ";
2431  static const char res5[] = "&text=one%C2%80%7F~";
2432  static const char res6[] = "&text=two%C2%80\x7f~";
2433  static const char res7[] = "&text=%E5%90%9B%E3%81%AE%E5%90%8D%E3%81%AF";
2434 
2435  if (strstr(buffer + 11, res) || strstr(buffer + 11, res2) || strstr(buffer + 11, res3) ||
2436  strstr(buffer + 11, res4) || strstr(buffer + 11, res5) || strstr(buffer + 11, res6) ||
2437  strstr(buffer + 11, res7))
2438  {
2439  send(c, okmsg, sizeof(okmsg) - 1, 0);
2440  }
2441  else send(c, notokmsg, sizeof(notokmsg) - 1, 0);
2442  }
2443  else if (strstr(buffer, "GET /passport"))
2444  {
2445  send(c, passportauth, sizeof(passportauth) - 1, 0);
2446  }
2447  if (strstr(buffer, "GET /quit"))
2448  {
2449  send(c, okmsg, sizeof okmsg - 1, 0);
2450  send(c, page1, sizeof page1 - 1, 0);
2451  last_request = 1;
2452  }
2453  shutdown(c, 2);
2454  closesocket(c);
2455  c = -1;
2456 
2457  } while (!last_request);
2458 
2459  closesocket(s);
2460  return 0;
2461 }
static const char nocontentmsg[]
Definition: winhttp.c:2202
#define BIG_BUFFER_LEN
Definition: winhttp.c:2269
SOCKET WSAAPI socket(IN INT af, IN INT type, IN INT protocol)
Definition: socklife.c:143
#define inet_addr(cp)
Definition: inet.h:98
static const char noauthmsg[]
Definition: winhttp.c:2211
#define MAKEWORD(a, b)
Definition: typedefs.h:247
INT WSAAPI bind(IN SOCKET s, IN CONST struct sockaddr *name, IN INT namelen)
Definition: socklife.c:36
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
char * strstr(char *String1, char *String2)
Definition: utclib.c:653
#define closesocket
Definition: precomp.h:57
static const char notokmsg[]
Definition: winhttp.c:2187
static const char cookiemsg2[]
Definition: winhttp.c:2197
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent(IN HANDLE hEvent)
Definition: synch.c:733
GLuint buffer
Definition: glext.h:5915
#define SOL_SOCKET
Definition: winsock.h:398
static const char multiauth[]
Definition: winhttp.c:2233
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
INT WSAAPI setsockopt(IN SOCKET s, IN INT level, IN INT optname, IN CONST CHAR FAR *optval, IN INT optlen)
Definition: sockctrl.c:421
INT WINAPI WSAStartup(IN WORD wVersionRequested, OUT LPWSADATA lpWSAData)
Definition: startup.c:113
smooth NULL
Definition: ftsmooth.c:416
#define SO_REUSEADDR
Definition: winsock.h:180
static const char page1[]
Definition: winhttp.c:2176
static const char headmsg[]
Definition: winhttp.c:2228
#define INVALID_SOCKET
Definition: winsock.h:332
INT WSAAPI shutdown(IN SOCKET s, IN INT how)
Definition: sockctrl.c:506
INT WSAAPI send(IN SOCKET s, IN CONST CHAR FAR *buf, IN INT len, IN INT flags)
Definition: send.c:23
GLfloat param
Definition: glext.h:5796
const GLubyte * c
Definition: glext.h:8905
static const char largeauth[]
Definition: winhttp.c:2243
static const char cookiemsg[]
Definition: winhttp.c:2191
GLdouble s
Definition: gl.h:2039
SOCKET WSAAPI accept(IN SOCKET s, OUT LPSOCKADDR addr, OUT INT FAR *addrlen)
Definition: socklife.c:23
#define broken(x)
Definition: _sntprintf.h:21
static const char passportauth[]
Definition: winhttp.c:2252
HANDLE event
Definition: notification.c:637
static const char notmodified[]
Definition: winhttp.c:2207
static const char okauthmsg[]
Definition: winhttp.c:2220
static const char unauthorized[]
Definition: winhttp.c:2259
static const char okmsg[]
Definition: winhttp.c:2182
static const char hello_world[]
Definition: winhttp.c:2260
INT WSAAPI listen(IN SOCKET s, IN INT backlog)
Definition: sockctrl.c:123
#define msg(x)
Definition: auth_time.c:54
GLuint res
Definition: glext.h:9613
#define AF_INET
Definition: tcpip.h:117
UINT_PTR SOCKET
Definition: winsock.h:47
#define SOCK_STREAM
Definition: tcpip.h:118
#define htons(x)
Definition: module.h:213
#define memset(x, y, z)
Definition: compat.h:39
INT WSAAPI recv(IN SOCKET s, OUT CHAR FAR *buf, IN INT len, IN INT flags)
Definition: recv.c:23
static struct sockaddr_in sa
Definition: adnsresfilter.c:69
static const char auth_unseen[]
Definition: winhttp.c:2261

Referenced by START_TEST().

◆ set_default_proxy_reg_value()

static void set_default_proxy_reg_value ( BYTE buf,
DWORD  len,
DWORD  type 
)
static

Definition at line 1345 of file winhttp.c.

1346 {
1347  BOOL wow64;
1349  if (sizeof(void *) > sizeof(int) || wow64)
1350  {
1353  }
1354  else
1355  set_proxy( KEY_WRITE, buf, len, type );
1356 }
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
static BOOL wow64
Definition: psapi_main.c:44
unsigned int BOOL
Definition: ntddk_ex.h:94
static void set_proxy(REGSAM access, BYTE *buf, DWORD len, DWORD type)
Definition: winhttp.c:1334
BOOL WINAPI IsWow64Process(IN HANDLE hProcess, OUT PBOOL Wow64Process)
Definition: proc.c:1976
#define KEY_WRITE
Definition: nt_native.h:1031
#define KEY_WOW64_64KEY
Definition: cmtypes.h:46
HANDLE WINAPI GetCurrentProcess(VOID)
Definition: proc.c:1138
GLenum GLsizei len
Definition: glext.h:6722
#define KEY_WOW64_32KEY
Definition: cmtypes.h:45

Referenced by test_set_default_proxy_config().

◆ set_proxy()

static void set_proxy ( REGSAM  access,
BYTE buf,
DWORD  len,
DWORD  type 
)
static

Definition at line 1334 of file winhttp.c.

1335 {
1336  HKEY hkey;
1338  {
1339  if (len) RegSetValueExW( hkey, WinHttpSettings, 0, type, buf, len );
1340  else RegDeleteValueW( hkey, WinHttpSettings );
1341  RegCloseKey( hkey );
1342  }
1343 }
static const WCHAR WinHttpSettings[]
Definition: winhttp.c:1306
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
LONG WINAPI RegCreateKeyExW(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey, _In_ DWORD Reserved, _In_opt_ LPWSTR lpClass, _In_ DWORD dwOptions, _In_ REGSAM samDesired, _In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes, _Out_ PHKEY phkResult, _Out_opt_ LPDWORD lpdwDisposition)
Definition: reg.c:1091
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
smooth NULL
Definition: ftsmooth.c:416
LONG WINAPI RegSetValueExW(_In_ HKEY hKey, _In_ LPCWSTR lpValueName, _In_ DWORD Reserved, _In_ DWORD dwType, _In_ CONST BYTE *lpData, _In_ DWORD cbData)
Definition: reg.c:4895
GLenum GLsizei len
Definition: glext.h:6722
LONG WINAPI RegDeleteValueW(HKEY hKey, LPCWSTR lpValueName)
Definition: reg.c:2355
GLuint GLint GLboolean GLint GLenum access
Definition: glext.h:7866
static const WCHAR Connections[]
Definition: winhttp.c:1299
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12

Referenced by set_default_proxy_reg_value().

◆ START_TEST()

START_TEST ( winhttp  )

Definition at line 4835 of file winhttp.c.

4836 {
4837  static const WCHAR basicW[] = {'/','b','a','s','i','c',0};
4838  static const WCHAR quitW[] = {'/','q','u','i','t',0};
4839  struct server_info si;
4840  HANDLE thread;
4841  DWORD ret;
4842 
4853  test_timeouts();
4855  test_credentials();
4861 
4862  si.event = CreateEventW(NULL, 0, 0, NULL);
4863  si.port = 7532;
4864 
4865  thread = CreateThread(NULL, 0, server_thread, &si, 0, NULL);
4866  ok(thread != NULL, "failed to create thread %u\n", GetLastError());
4867 
4868  ret = WaitForSingleObject(si.event, 10000);
4869  ok(ret == WAIT_OBJECT_0, "failed to start winhttp test server %u\n", GetLastError());
4870  if (ret != WAIT_OBJECT_0)
4871  {
4873  return;
4874  }
4875 
4876  test_IWinHttpRequest(si.port);
4877  test_connection_info(si.port);
4878  test_basic_request(si.port, NULL, basicW);
4879  test_no_headers(si.port);
4880  test_no_content(si.port);
4881  test_head_request(si.port);
4882  test_not_modified(si.port);
4883  test_basic_authentication(si.port);
4884  test_multi_authentication(si.port);
4886  test_bad_header(si.port);
4887 #ifdef __REACTOS__
4888  if (!winetest_interactive)
4889  {
4890  skip("Skipping tests due to hang. See ROSTESTS-350\n");
4891  }
4892  else
4893  {
4894  test_multiple_reads(si.port);
4895  test_cookies(si.port);
4896  test_request_path_escapes(si.port);
4897  test_passport_auth(si.port);
4898 
4899  /* send the basic request again to shutdown the server thread */
4900  test_basic_request(si.port, NULL, quitW);
4901  }
4902 #else
4903  test_multiple_reads(si.port);
4904  test_cookies(si.port);
4905  test_request_path_escapes(si.port);
4906  test_passport_auth(si.port);
4907 
4908  /* send the basic request again to shutdown the server thread */
4909  test_basic_request(si.port, NULL, quitW);
4910 #endif
4911 
4912  WaitForSingleObject(thread, 3000);
4914 }
static const WCHAR basicW[]
static void test_basic_authentication(int port)
Definition: winhttp.c:2555
static void test_request_path_escapes(int port)
Definition: winhttp.c:3451
#define CloseHandle
Definition: compat.h:407
static void test_WinHttpGetIEProxyConfigForCurrentUser(void)
Definition: winhttp.c:4614
static void test_no_headers(int port)
Definition: winhttp.c:2938
static void test_WinHttpTimeToSystemTime(void)
Definition: winhttp.c:514
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
static void test_IWinHttpRequest(int port)
Definition: winhttp.c:3746
static void test_cookies(int port)
Definition: winhttp.c:3266
int winetest_interactive
HANDLE WINAPI DECLSPEC_HOTPATCH CreateEventW(IN LPSECURITY_ATTRIBUTES lpEventAttributes OPTIONAL, IN BOOL bManualReset, IN BOOL bInitialState, IN LPCWSTR lpName OPTIONAL)
Definition: synch.c:651
static void test_basic_request(int port, const WCHAR *verb, const WCHAR *path)
Definition: winhttp.c:2463
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
static void test_resolve_timeout(void)
Definition: winhttp.c:2104
static void test_WinHttpQueryOption(void)
Definition: winhttp.c:84
static void test_multi_authentication(int port)
Definition: winhttp.c:2832
static void test_WinHttpDetectAutoProxyConfigUrl(void)
Definition: winhttp.c:4557
HANDLE WINAPI DECLSPEC_HOTPATCH CreateThread(IN LPSECURITY_ATTRIBUTES lpThreadAttributes, IN DWORD dwStackSize, IN LPTHREAD_START_ROUTINE lpStartAddress, IN LPVOID lpParameter, IN DWORD dwCreationFlags, OUT LPDWORD lpThreadId)
Definition: thread.c:136
static void test_bad_header(int port)
Definition: winhttp.c:3174
smooth NULL
Definition: ftsmooth.c:416
static void test_not_modified(int port)
Definition: winhttp.c:3117
static void test_set_default_proxy_config(void)
Definition: winhttp.c:1358
static DWORD CALLBACK server_thread(LPVOID param)
Definition: winhttp.c:2271
static void test_head_request(int port)
Definition: winhttp.c:3058
#define WAIT_OBJECT_0
Definition: winbase.h:387
static void test_WinHttpOpenRequest(void)
Definition: winhttp.c:270
static void test_no_content(int port)
Definition: winhttp.c:2974
__wchar_t WCHAR
Definition: xmlstorage.h:180
static void test_WinHttpSendRequest(void)
Definition: winhttp.c:365
unsigned long DWORD
Definition: ntddk_ex.h:95
static void test_multiple_reads(int port)
Definition: winhttp.c:3212
static void test_passport_auth(int port)
Definition: winhttp.c:3554
static void test_timeouts(void)
Definition: winhttp.c:1446
static HANDLE thread
Definition: service.c:33
static void test_credentials(void)
Definition: winhttp.c:3625
static void test_empty_headers_param(void)
Definition: winhttp.c:334
int ret
static void test_request_parameter_defaults(void)
Definition: winhttp.c:1222
static void test_IWinHttpRequest_Invoke(void)
Definition: winhttp.c:4342
#define ok(value,...)
Definition: atltest.h:57
static void test_WinHttpGetProxyForUrl(void)
Definition: winhttp.c:4643
static void test_large_data_authentication(int port)
Definition: winhttp.c:2887
static void test_connection_info(int port)
Definition: winhttp.c:3495
#define skip(...)
Definition: atltest.h:64
static void test_chunked_read(void)
Definition: winhttp.c:4750
static void test_secure_connection(void)
Definition: winhttp.c:1048
static void test_WinHttpAddHeaders(void)
Definition: winhttp.c:556
static void test_WinHttpTimeFromSystemTime(void)
Definition: winhttp.c:483

◆ strcmp_wa()

static int strcmp_wa ( const WCHAR str1,
const char stra 
)
static

Definition at line 54 of file winhttp.c.

55 {
56  WCHAR *str2 = a2w(stra);
57  int r = lstrcmpW(str1, str2);
58  heap_free(str2);
59  return r;
60 }
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
int WINAPI lstrcmpW(LPCWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:170
static WCHAR * a2w(const char *str)
Definition: winhttp.c:46
__wchar_t WCHAR
Definition: xmlstorage.h:180
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

Referenced by test_multi_authentication().

◆ test_bad_header()

static void test_bad_header ( int  port)
static

Definition at line 3174 of file winhttp.c.

3175 {
3176  static const WCHAR bad_headerW[] =
3177  {'C','o','n','t','e','n','t','-','T','y','p','e',':',' ',
3178  't','e','x','t','/','h','t','m','l','\n','\r',0};
3179  static const WCHAR text_htmlW[] = {'t','e','x','t','/','h','t','m','l',0};
3180  static const WCHAR content_typeW[] = {'C','o','n','t','e','n','t','-','T','y','p','e',0};
3181  WCHAR buffer[32];
3182  HINTERNET ses, con, req;
3183  DWORD index, len;
3184  BOOL ret;
3185 
3187  ok( ses != NULL, "failed to open session %u\n", GetLastError() );
3188 
3189  con = WinHttpConnect( ses, localhostW, port, 0 );
3190  ok( con != NULL, "failed to open a connection %u\n", GetLastError() );
3191 
3192  req = WinHttpOpenRequest( con, NULL, NULL, NULL, NULL, NULL, 0 );
3193  ok( req != NULL, "failed to open a request %u\n", GetLastError() );
3194 
3195  ret = WinHttpAddRequestHeaders( req, bad_headerW, ~0u, WINHTTP_ADDREQ_FLAG_ADD );
3196  ok( ret, "failed to add header %u\n", GetLastError() );
3197 
3198  index = 0;
3199  buffer[0] = 0;
3200  len = sizeof(buffer);
3202  content_typeW, buffer, &len, &index );
3203  ok( ret, "failed to query headers %u\n", GetLastError() );
3204  ok( !lstrcmpW( buffer, text_htmlW ), "got %s\n", wine_dbgstr_w(buffer) );
3205  ok( index == 1, "index = %u\n", index );
3206 
3207  WinHttpCloseHandle( req );
3208  WinHttpCloseHandle( con );
3209  WinHttpCloseHandle( ses );
3210 }
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble * u
Definition: glfuncs.h:240
HINTERNET WINAPI WinHttpConnect(HINTERNET hsession, LPCWSTR server, INTERNET_PORT port, DWORD reserved)
Definition: session.c:541
BOOL WINAPI WinHttpCloseHandle(HINTERNET handle)
Definition: session.c:1195
#define WINHTTP_ACCESS_TYPE_NO_PROXY
Definition: winhttp.h:63
#define WINHTTP_ADDREQ_FLAG_ADD
Definition: winhttp.h:84
char * wine_dbgstr_w(const wchar_t *wstr)
Definition: atltest.h:87
int WINAPI lstrcmpW(LPCWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:170
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
GLuint buffer
Definition: glext.h:5915
BOOL WINAPI WinHttpQueryHeaders(HINTERNET hrequest, DWORD level, LPCWSTR name, LPVOID buffer, LPDWORD buflen, LPDWORD index)
Definition: request.c:856
unsigned int BOOL
Definition: ntddk_ex.h:94
static const WCHAR test_useragent[]
Definition: winhttp.c:40
#define WINHTTP_QUERY_CUSTOM
Definition: winhttp.h:374
smooth NULL
Definition: ftsmooth.c:416
GLuint index
Definition: glext.h:6031
BOOL WINAPI WinHttpAddRequestHeaders(HINTERNET hrequest, LPCWSTR headers, DWORD len, DWORD flags)
Definition: request.c:542
static const WCHAR text_htmlW[]
Definition: navigate.c:29
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
#define WINHTTP_QUERY_FLAG_REQUEST_HEADERS
Definition: winhttp.h:375
int ret
#define index(s, c)
Definition: various.h:29
GLenum GLsizei len
Definition: glext.h:6722
#define ok(value,...)
Definition: atltest.h:57
static const WCHAR localhostW[]
Definition: winhttp.c:44
HINTERNET WINAPI WinHttpOpen(LPCWSTR agent, DWORD access, LPCWSTR proxy, LPCWSTR bypass, DWORD flags)
Definition: session.c:250
HINTERNET WINAPI WinHttpOpenRequest(HINTERNET hconnect, LPCWSTR verb, LPCWSTR object, LPCWSTR version, LPCWSTR referrer, LPCWSTR *types, DWORD flags)
Definition: session.c:1117
USHORT port
Definition: uri.c:228

Referenced by START_TEST().

◆ test_basic_authentication()

static void test_basic_authentication ( int  port)
static

Definition at line 2555 of file winhttp.c.

2556 {
2557  static const WCHAR authW[] = {'/','a','u','t','h',0};
2558  static const WCHAR auth_with_credsW[] = {'/','a','u','t','h','_','w','i','t','h','_','c','r','e','d','s',0};
2559  static WCHAR userW[] = {'u','s','e','r',0};
2560  static WCHAR passW[] = {'p','w','d',0};
2561  static WCHAR pass2W[] = {'p','w','d','2',0};
2562  HINTERNET ses, con, req;
2563  DWORD status, size, error, supported, first, target;
2564  char buffer[32];
2565  BOOL ret;
2566 
2568  ok(ses != NULL, "failed to open session %u\n", GetLastError());
2569 
2570  con = WinHttpConnect(ses, localhostW, port, 0);
2571  ok(con != NULL, "failed to open a connection %u\n", GetLastError());
2572 
2573  req = WinHttpOpenRequest(con, NULL, authW, NULL, NULL, NULL, 0);
2574  ok(req != NULL, "failed to open a request %u\n", GetLastError());
2575 
2576  SetLastError(0xdeadbeef);
2578  error = GetLastError();
2579  ok(!ret, "expected failure\n");
2580  ok(error == ERROR_INVALID_HANDLE, "expected ERROR_INVALID_HANDLE, got %u\n", error);
2581 
2582  SetLastError(0xdeadbeef);
2584  error = GetLastError();
2585  ok(!ret, "expected failure\n");
2587 
2588  supported = 0xdeadbeef;
2589  SetLastError(0xdeadbeef);
2590  ret = WinHttpQueryAuthSchemes(req, &supported, NULL, NULL);
2591  error = GetLastError();
2592  ok(!ret, "expected failure\n");
2594  ok(supported == 0xdeadbeef, "got %x\n", supported);
2595 
2596  supported = first = 0xdeadbeef;
2597  SetLastError(0xdeadbeef);
2598  ret = WinHttpQueryAuthSchemes(req, &supported, &first, NULL);
2599  error = GetLastError();
2600  ok(!ret, "expected failure\n");
2602  ok(supported == 0xdeadbeef, "got %x\n", supported);
2603  ok(first == 0xdeadbeef, "got %x\n", first);
2604 
2605  supported = first = target = 0xdeadbeef;
2606  SetLastError(0xdeadbeef);
2607  ret = WinHttpQueryAuthSchemes(req, &supported, &first, &target);
2608  error = GetLastError();
2609  ok(!ret, "expected failure\n");
2610  ok(error == ERROR_INVALID_OPERATION, "expected ERROR_INVALID_OPERATION, got %u\n", error);
2611  ok(supported == 0xdeadbeef, "got %x\n", supported);
2612  ok(first == 0xdeadbeef, "got %x\n", first);
2613  ok(target == 0xdeadbeef, "got %x\n", target);
2614 
2615  supported = first = target = 0xdeadbeef;
2616  SetLastError(0xdeadbeef);
2617  ret = WinHttpQueryAuthSchemes(NULL, &supported, &first, &target);
2618  error = GetLastError();
2619  ok(!ret, "expected failure\n");
2620  ok(error == ERROR_INVALID_HANDLE, "expected ERROR_INVALID_HANDLE, got %u\n", error);
2621  ok(supported == 0xdeadbeef, "got %x\n", supported);
2622  ok(first == 0xdeadbeef, "got %x\n", first);
2623  ok(target == 0xdeadbeef, "got %x\n", target);
2624 
2625  ret = WinHttpSendRequest(req, NULL, 0, NULL, 0, 0, 0);
2626  ok(ret, "failed to send request %u\n", GetLastError());
2627 
2629  ok(ret, "failed to receive response %u\n", GetLastError());
2630 
2631  status = 0xdeadbeef;
2632  size = sizeof(status);
2634  ok(ret, "failed to query status code %u\n", GetLastError());
2635  ok(status == HTTP_STATUS_DENIED, "request failed unexpectedly %u\n", status);
2636 
2637  size = 0;
2638  ret = WinHttpReadData(req, buffer, sizeof(buffer), &size);
2639  error = GetLastError();
2640  ok(ret || broken(error == ERROR_WINHTTP_SHUTDOWN || error == ERROR_WINHTTP_TIMEOUT) /* XP */, "failed to read data %u\n", GetLastError());
2641  if (ret)
2642  {
2643  ok(size == 12, "expected 12, got %u\n", size);
2644  ok(!memcmp(buffer, unauthorized, 12), "got %s\n", buffer);
2645  }
2646 
2647  supported = first = target = 0xdeadbeef;
2648  SetLastError(0xdeadbeef);
2649  ret = WinHttpQueryAuthSchemes(req, &supported, &first, &target);
2650  error = GetLastError();
2651  ok(ret, "failed to query authentication schemes %u\n", error);
2652  ok(error == ERROR_SUCCESS || broken(error == 0xdeadbeef) /* < win7 */, "expected ERROR_SUCCESS, got %u\n", error);
2653  ok(supported == WINHTTP_AUTH_SCHEME_BASIC, "got %x\n", supported);
2654  ok(first == WINHTTP_AUTH_SCHEME_BASIC, "got %x\n", first);
2655  ok(target == WINHTTP_AUTH_TARGET_SERVER, "got %x\n", target);
2656 
2657  SetLastError(0xdeadbeef);
2659  error = GetLastError();
2660  ok(ret, "failed to set credentials %u\n", error);
2661  ok(error == ERROR_SUCCESS || broken(error == 0xdeadbeef) /* < win7 */, "expected ERROR_SUCCESS, got %u\n", error);
2662 
2664  ok(ret, "failed to set credentials %u\n", GetLastError());
2665 
2667  ok(ret, "failed to set credentials %u\n", GetLastError());
2668 
2669  SetLastError(0xdeadbeef);
2671  error = GetLastError();
2672  ok(!ret, "expected failure\n");
2673  ok(error == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %u\n", error);
2674 
2675  SetLastError(0xdeadbeef);
2677  error = GetLastError();
2678  ok(!ret, "expected failure\n");
2679  ok(error == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %u\n", error);
2680 
2681  SetLastError(0xdeadbeef);
2683  error = GetLastError();
2684  ok(!ret, "expected failure\n");
2685  ok(error == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %u\n", error);
2686 
2687  SetLastError(0xdeadbeef);
2689  error = GetLastError();
2690  ok(!ret, "expected failure\n");
2691  ok(error == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %u\n", error);
2692 
2694  ok(ret, "failed to set credentials %u\n", GetLastError());
2695 
2696  ret = WinHttpSendRequest(req, NULL, 0, NULL, 0, 0, 0);
2697  ok(ret, "failed to send request %u\n", GetLastError());
2698 
2700  ok(ret, "failed to receive response %u\n", GetLastError());
2701 
2702  status = 0xdeadbeef;
2703  size = sizeof(status);
2705  ok(ret, "failed to query status code %u\n", GetLastError());
2706  ok(status == HTTP_STATUS_OK, "request failed unexpectedly %u\n", status);
2707 
2708  size = 0;
2709  ret = WinHttpReadData(req, buffer, sizeof(buffer), &size);
2710  error = GetLastError();
2711  ok(ret || broken(error == ERROR_WINHTTP_SHUTDOWN || error == ERROR_WINHTTP_TIMEOUT) /* XP */, "failed to read data %u\n", GetLastError());
2712  if (ret)
2713  {
2714  ok(size == 11, "expected 11, got %u\n", size);
2715  ok(!memcmp(buffer, hello_world, 11), "got %s\n", buffer);
2716  }
2717 
2718  WinHttpCloseHandle(req);
2719  WinHttpCloseHandle(con);
2720  WinHttpCloseHandle(ses);
2721 
2722  /* now set the credentials first to show that they get sent with the first request */
2724  ok(ses != NULL, "failed to open session %u\n", GetLastError());
2725 
2726  con = WinHttpConnect(ses, localhostW, port, 0);
2727  ok(con != NULL, "failed to open a connection %u\n", GetLastError());
2728 
2729  req = WinHttpOpenRequest(con, NULL, auth_with_credsW, NULL, NULL, NULL, 0);
2730  ok(req != NULL, "failed to open a request %u\n", GetLastError());
2731 
2733  ok(ret, "failed to set credentials %u\n", GetLastError());
2734 
2735  ret = WinHttpSendRequest(req, NULL, 0, NULL, 0, 0, 0);
2736  ok(ret, "failed to send request %u\n", GetLastError());
2737 
2739  ok(ret, "failed to receive response %u\n", GetLastError());
2740 
2741  status = 0xdeadbeef;
2742  size = sizeof(status);
2744  ok(ret, "failed to query status code %u\n", GetLastError());
2745  ok(status == HTTP_STATUS_OK, "request failed unexpectedly %u\n", status);
2746 
2747  size = 0;
2748  ret = WinHttpReadData(req, buffer, sizeof(buffer), &size);
2749  error = GetLastError();
2750  ok(ret || broken(error == ERROR_WINHTTP_SHUTDOWN || error == ERROR_WINHTTP_TIMEOUT) /* XP */, "failed to read data %u\n", GetLastError());
2751  if (ret)
2752  {
2753  ok(size == 11, "expected 11, got %u\n", size);
2754  ok(!memcmp(buffer, hello_world, 11), "got %s\n", buffer);
2755  }
2756 
2757  WinHttpCloseHandle(req);
2758  WinHttpCloseHandle(con);
2759  WinHttpCloseHandle(ses);
2760 
2761  /* credentials set with WinHttpSetCredentials take precedence over those set through options */
2762 
2764  ok(ses != NULL, "failed to open session %u\n", GetLastError());
2765 
2766  con = WinHttpConnect(ses, localhostW, port, 0);
2767  ok(con != NULL, "failed to open a connection %u\n", GetLastError());
2768 
2769  req = WinHttpOpenRequest(con, NULL, authW, NULL, NULL, NULL, 0);
2770  ok(req != NULL, "failed to open a request %u\n", GetLastError());
2771 
2773  ok(ret, "failed to set credentials %u\n", GetLastError());
2774 
2775  ret = WinHttpSetOption(req, WINHTTP_OPTION_USERNAME, userW, lstrlenW(userW));
2776  ok(ret, "failed to set username %u\n", GetLastError());
2777 
2778  ret = WinHttpSetOption(req, WINHTTP_OPTION_PASSWORD, pass2W, lstrlenW(pass2W));
2779  ok(ret, "failed to set password %u\n", GetLastError());
2780 
2781  ret = WinHttpSendRequest(req, NULL, 0, NULL, 0, 0, 0);
2782  ok(ret, "failed to send request %u\n", GetLastError());
2783 
2785  ok(ret, "failed to receive response %u\n", GetLastError());
2786 
2787  status = 0xdeadbeef;
2788  size = sizeof(status);
2790  ok(ret, "failed to query status code %u\n", GetLastError());
2791  ok(status == HTTP_STATUS_OK, "request failed unexpectedly %u\n", status);
2792 
2793  WinHttpCloseHandle(req);
2794  WinHttpCloseHandle(con);
2795  WinHttpCloseHandle(ses);
2796 
2798  ok(ses != NULL, "failed to open session %u\n", GetLastError());
2799 
2800  con = WinHttpConnect(ses, localhostW, port, 0);
2801  ok(con != NULL, "failed to open a connection %u\n", GetLastError());
2802 
2803  req = WinHttpOpenRequest(con, NULL, authW, NULL, NULL, NULL, 0);
2804  ok(req != NULL, "failed to open a request %u\n", GetLastError());
2805 
2806  ret = WinHttpSetOption(req, WINHTTP_OPTION_USERNAME, userW, lstrlenW(userW));
2807  ok(ret, "failed to set username %u\n", GetLastError());
2808 
2809  ret = WinHttpSetOption(req, WINHTTP_OPTION_PASSWORD, passW, lstrlenW(passW));
2810  ok(ret, "failed to set password %u\n", GetLastError());
2811 
2813  ok(ret, "failed to set credentials %u\n", GetLastError());
2814 
2815  ret = WinHttpSendRequest(req, NULL, 0, NULL, 0, 0, 0);
2816  ok(ret, "failed to send request %u\n", GetLastError());
2817 
2819  ok(ret, "failed to receive response %u\n", GetLastError());
2820 
2821  status = 0xdeadbeef;
2822  size = sizeof(status);
2824  ok(ret, "failed to query status code %u\n", GetLastError());
2825  ok(status == HTTP_STATUS_DENIED, "request failed unexpectedly %u\n", status);
2826 
2827  WinHttpCloseHandle(req);
2828  WinHttpCloseHandle(con);
2829  WinHttpCloseHandle(ses);
2830 }
HINTERNET WINAPI WinHttpConnect(HINTERNET hsession, LPCWSTR server, INTERNET_PORT port, DWORD reserved)
Definition: session.c:541
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
BOOL WINAPI WinHttpCloseHandle(HINTERNET handle)
Definition: session.c:1195
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
#define ERROR_SUCCESS
Definition: deptool.c:10
#define WINHTTP_OPTION_PASSWORD
Definition: winhttp.h:146
#define error(str)
Definition: mkdosfs.c:1605
#define WINHTTP_ACCESS_TYPE_NO_PROXY
Definition: winhttp.h:63
#define ERROR_WINHTTP_TIMEOUT
Definition: winhttp.h:189
const GLint * first
Definition: glext.h:5794
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
BOOL WINAPI WinHttpQueryAuthSchemes(HINTERNET hrequest, LPDWORD supported, LPDWORD first, LPDWORD target)
Definition: request.c:964
#define WINHTTP_QUERY_STATUS_CODE
Definition: winhttp.h:317
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
GLuint buffer
Definition: glext.h:5915
#define WINHTTP_OPTION_USERNAME
Definition: winhttp.h:145
#define lstrlenW
Definition: compat.h:416
#define WINHTTP_AUTH_SCHEME_NTLM
Definition: winhttp.h:453
BOOL WINAPI WinHttpQueryHeaders(HINTERNET hrequest, DWORD level, LPCWSTR name, LPVOID buffer, LPDWORD buflen, LPDWORD index)
Definition: request.c:856
unsigned int BOOL
Definition: ntddk_ex.h:94
static const WCHAR test_useragent[]
Definition: winhttp.c:40
BOOL WINAPI WinHttpReceiveResponse(HINTERNET hrequest, LPVOID reserved)
Definition: request.c:2924
smooth NULL
Definition: ftsmooth.c:416
#define HTTP_STATUS_DENIED
Definition: winhttp.h:256
GLsizeiptr size
Definition: glext.h:5919
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define WINHTTP_AUTH_SCHEME_PASSPORT
Definition: winhttp.h:454
#define WINHTTP_QUERY_FLAG_NUMBER
Definition: winhttp.h:377
unsigned long DWORD
Definition: ntddk_ex.h:95
#define HTTP_STATUS_OK
Definition: winhttp.h:240
#define SetLastError(x)
Definition: compat.h:418
#define ERROR_WINHTTP_SHUTDOWN
Definition: winhttp.h:196
int ret
#define WINHTTP_AUTH_SCHEME_NEGOTIATE
Definition: winhttp.h:456
BOOL WINAPI WinHttpSetCredentials(HINTERNET hrequest, DWORD target, DWORD scheme, LPCWSTR username, LPCWSTR password, LPVOID params)
Definition: request.c:2442
#define WINHTTP_AUTH_SCHEME_BASIC
Definition: winhttp.h:452
BOOL WINAPI WinHttpSetOption(HINTERNET handle, DWORD option, LPVOID buffer, DWORD buflen)
Definition: session.c:1312
#define broken(x)
Definition: _sntprintf.h:21
static const char unauthorized[]
Definition: winhttp.c:2259
#define ok(value,...)
Definition: atltest.h:57
static const char hello_world[]
Definition: winhttp.c:2260
#define ERROR_INVALID_OPERATION
Definition: winerror.h:1261
static const WCHAR localhostW[]
Definition: winhttp.c:44
HINTERNET WINAPI WinHttpOpen(LPCWSTR agent, DWORD access, LPCWSTR proxy, LPCWSTR bypass, DWORD flags)
Definition: session.c:250
GLenum target
Definition: glext.h:7315
HINTERNET WINAPI WinHttpOpenRequest(HINTERNET hconnect, LPCWSTR verb, LPCWSTR object, LPCWSTR version, LPCWSTR referrer, LPCWSTR *types, DWORD flags)
Definition: session.c:1117
USHORT port
Definition: uri.c:228
static SERVICE_STATUS status
Definition: service.c:31
BOOL WINAPI WinHttpSendRequest(HINTERNET hrequest, LPCWSTR headers, DWORD headers_len, LPVOID optional, DWORD optional_len, DWORD total_len, DWORD_PTR context)
Definition: request.c:2350
BOOL WINAPI WinHttpReadData(HINTERNET hrequest, LPVOID buffer, DWORD to_read, LPDWORD read)
Definition: request.c:3053
#define WINHTTP_AUTH_SCHEME_DIGEST
Definition: winhttp.h:455
#define WINHTTP_AUTH_TARGET_SERVER
Definition: winhttp.h:458
Definition: ps.c:97

Referenced by START_TEST().

◆ test_basic_request()

static void test_basic_request ( int  port,
const WCHAR verb,
const WCHAR path 
)
static

Definition at line 2463 of file winhttp.c.

2464 {
2465  static const WCHAR test_header_end_clrf[] = {'\r','\n','\r','\n',0};
2466  static const WCHAR test_header_end_raw[] = {0,0};
2467  HINTERNET ses, con, req;
2468  char buffer[0x100];
2469  WCHAR buffer2[0x100];
2470  DWORD count, status, size, error, supported, first, target;
2471  BOOL ret;
2472 
2474  ok(ses != NULL, "failed to open session %u\n", GetLastError());
2475 
2476  SetLastError(0xdeadbeef);
2477  ret = WinHttpSetOption(ses, 0, buffer, sizeof(buffer));
2478  ok(!ret && GetLastError() == ERROR_WINHTTP_INVALID_OPTION, "got %u\n", GetLastError());
2479 
2480  SetLastError(0xdeadbeef);
2481  ret = WinHttpQueryOption(ses, 0, buffer, &size);
2482  ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, "got %u\n", GetLastError());
2483 
2484  con = WinHttpConnect(ses, localhostW, port, 0);
2485  ok(con != NULL, "failed to open a connection %u\n", GetLastError());
2486 
2487  SetLastError(0xdeadbeef);
2488  ret = WinHttpSetOption(con, 0, buffer, sizeof(buffer));
2490 
2491  SetLastError(0xdeadbeef);
2492  ret = WinHttpQueryOption(con, 0, buffer, &size);
2493  ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, "got %u\n", GetLastError());
2494 
2495  req = WinHttpOpenRequest(con, verb, path, NULL, NULL, NULL, 0);
2496  ok(req != NULL, "failed to open a request %u\n", GetLastError());
2497 
2498  SetLastError(0xdeadbeef);
2499  ret = WinHttpSetOption(req, 0, buffer, sizeof(buffer));
2500  ok(!ret && GetLastError() == ERROR_WINHTTP_INVALID_OPTION, "got %u\n", GetLastError());
2501 
2502  SetLastError(0xdeadbeef);
2503  ret = WinHttpQueryOption(req, 0, buffer, &size);
2504  ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, "got %u\n", GetLastError());
2505 
2506  ret = WinHttpSendRequest(req, NULL, 0, NULL, 0, 0, 0);
2507  ok(ret, "failed to send request %u\n", GetLastError());
2508 
2510  ok(ret, "failed to receive response %u\n", GetLastError());
2511 
2512  status = 0xdeadbeef;
2513  size = sizeof(status);
2515  ok(ret, "failed to query status code %u\n", GetLastError());
2516  ok(status == HTTP_STATUS_OK, "request failed unexpectedly %u\n", status);
2517 
2518  supported = first = target = 0xdeadbeef;
2519  SetLastError(0xdeadbeef);
2520  ret = WinHttpQueryAuthSchemes(req, &supported, &first, &target);
2521  error = GetLastError();
2522  ok(!ret, "unexpected success\n");
2523  ok(error == ERROR_INVALID_OPERATION, "expected ERROR_INVALID_OPERATION, got %u\n", error);
2524  ok(supported == 0xdeadbeef, "got %x\n", supported);
2525  ok(first == 0xdeadbeef, "got %x\n", first);
2526  ok(target == 0xdeadbeef, "got %x\n", target);
2527 
2528  size = sizeof(buffer2);
2529  memset(buffer2, 0, sizeof(buffer2));
2531  ok(ret, "failed to query for raw headers: %u\n", GetLastError());
2532  ok(!memcmp(buffer2 + lstrlenW(buffer2) - 4, test_header_end_clrf, sizeof(test_header_end_clrf)),
2533  "WinHttpQueryHeaders returned invalid end of header string\n");
2534 
2535  size = sizeof(buffer2);
2536  memset(buffer2, 0, sizeof(buffer2));
2538  ok(ret, "failed to query for raw headers: %u\n", GetLastError());
2539  ok(!memcmp(buffer2 + (size / sizeof(WCHAR)) - 1, test_header_end_raw, sizeof(test_header_end_raw)),
2540  "WinHttpQueryHeaders returned invalid end of header string\n");
2541  ok(buffer2[(size / sizeof(WCHAR)) - 2] != 0, "returned string has too many NULL characters\n");
2542 
2543  count = 0;
2544  memset(buffer, 0, sizeof(buffer));
2545  ret = WinHttpReadData(req, buffer, sizeof buffer, &count);
2546  ok(ret, "failed to read data %u\n", GetLastError());
2547  ok(count == sizeof page1 - 1, "count was wrong\n");
2548  ok(!memcmp(buffer, page1, sizeof page1), "http data wrong\n");
2549 
2550  WinHttpCloseHandle(req);
2551  WinHttpCloseHandle(con);
2552  WinHttpCloseHandle(ses);
2553 }
HINTERNET WINAPI WinHttpConnect(HINTERNET hsession, LPCWSTR server, INTERNET_PORT port, DWORD reserved)
Definition: session.c:541
#define WINHTTP_QUERY_RAW_HEADERS
Definition: winhttp.h:319
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
BOOL WINAPI WinHttpQueryOption(HINTERNET handle, DWORD option, LPVOID buffer, LPDWORD buflen)
Definition: session.c:1253
BOOL WINAPI WinHttpCloseHandle(HINTERNET handle)
Definition: session.c:1195
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
#define error(str)
Definition: mkdosfs.c:1605
#define WINHTTP_ACCESS_TYPE_NO_PROXY
Definition: winhttp.h:63
#define WINHTTP_QUERY_RAW_HEADERS_CRLF
Definition: winhttp.h:320
GLuint GLuint GLsizei count
Definition: gl.h:1545
const GLint * first
Definition: glext.h:5794
BOOL WINAPI WinHttpQueryAuthSchemes(HINTERNET hrequest, LPDWORD supported, LPDWORD first, LPDWORD target)
Definition: request.c:964
#define WINHTTP_QUERY_STATUS_CODE
Definition: winhttp.h:317
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
GLuint buffer
Definition: glext.h:5915
#define lstrlenW
Definition: compat.h:416
BOOL WINAPI WinHttpQueryHeaders(HINTERNET hrequest, DWORD level, LPCWSTR name, LPVOID buffer, LPDWORD buflen, LPDWORD index)
Definition: request.c:856
unsigned int BOOL
Definition: ntddk_ex.h:94
static const WCHAR test_useragent[]
Definition: winhttp.c:40
BOOL WINAPI WinHttpReceiveResponse(HINTERNET hrequest, LPVOID reserved)
Definition: request.c:2924
smooth NULL
Definition: ftsmooth.c:416
static const char page1[]
Definition: winhttp.c:2176
GLsizeiptr size
Definition: glext.h:5919
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define WINHTTP_QUERY_FLAG_NUMBER
Definition: winhttp.h:377
unsigned long DWORD
Definition: ntddk_ex.h:95
#define HTTP_STATUS_OK
Definition: winhttp.h:240
#define SetLastError(x)
Definition: compat.h:418
int ret
#define todo_wine
Definition: test.h:162
BOOL WINAPI WinHttpSetOption(HINTERNET handle, DWORD option, LPVOID buffer, DWORD buflen)
Definition: session.c:1312
#define ok(value,...)
Definition: atltest.h:57
#define ERROR_INVALID_OPERATION
Definition: winerror.h:1261
static const WCHAR localhostW[]
Definition: winhttp.c:44
HINTERNET WINAPI WinHttpOpen(LPCWSTR agent, DWORD access, LPCWSTR proxy, LPCWSTR bypass, DWORD flags)
Definition: session.c:250
GLenum target
Definition: glext.h:7315
HINTERNET WINAPI WinHttpOpenRequest(HINTERNET hconnect, LPCWSTR verb, LPCWSTR object, LPCWSTR version, LPCWSTR referrer, LPCWSTR *types, DWORD flags)
Definition: session.c:1117
USHORT port
Definition: uri.c:228
#define memset(x, y, z)
Definition: compat.h:39
static SERVICE_STATUS status
Definition: service.c:31
BOOL WINAPI WinHttpSendRequest(HINTERNET hrequest, LPCWSTR headers, DWORD headers_len, LPVOID optional, DWORD optional_len, DWORD total_len, DWORD_PTR context)
Definition: request.c:2350
#define ERROR_WINHTTP_INVALID_OPTION
Definition: winhttp.h:194
BOOL WINAPI WinHttpReadData(HINTERNET hrequest, LPVOID buffer, DWORD to_read, LPDWORD read)
Definition: request.c:3053
Definition: ps.c:97

Referenced by START_TEST().

◆ test_chunked_read()

static void test_chunked_read ( void  )
static

Definition at line 4750 of file winhttp.c.

4751 {
4752  static const WCHAR verb[] = {'/','t','e','s','t','s','/','c','h','u','n','k','e','d',0};
4753  static const WCHAR chunked[] = {'c','h','u','n','k','e','d',0};
4754  WCHAR header[32];
4755  DWORD len, err;
4756  HINTERNET ses, con = NULL, req = NULL;
4757  BOOL ret;
4758 
4759  trace( "starting chunked read test\n" );
4760 
4761  ses = WinHttpOpen( test_useragent, 0, NULL, NULL, 0 );
4762  ok( ses != NULL, "WinHttpOpen failed with error %u\n", GetLastError() );
4763  if (!ses) goto done;
4764 
4765  con = WinHttpConnect( ses, test_winehq, 0, 0 );
4766  ok( con != NULL, "WinHttpConnect failed with error %u\n", GetLastError() );
4767  if (!con) goto done;
4768 
4769  req = WinHttpOpenRequest( con, NULL, verb, NULL, NULL, NULL, 0 );
4770  ok( req != NULL, "WinHttpOpenRequest failed with error %u\n", GetLastError() );
4771  if (!req) goto done;
4772 
4773  ret = WinHttpSendRequest( req, NULL, 0, NULL, 0, 0, 0 );
4774  err = GetLastError();
4776  {
4777  skip("connection failed, skipping\n");
4778  goto done;
4779  }
4780  ok( ret, "WinHttpSendRequest failed with error %u\n", GetLastError() );
4781  if (!ret) goto done;
4782 
4783  ret = WinHttpReceiveResponse( req, NULL );
4784  ok( ret, "WinHttpReceiveResponse failed with error %u\n", GetLastError() );
4785  if (!ret) goto done;
4786 
4787  header[0] = 0;
4788  len = sizeof(header);
4790  ok( ret, "failed to get TRANSFER_ENCODING header (error %u)\n", GetLastError() );
4791  ok( !lstrcmpW( header, chunked ), "wrong transfer encoding %s\n", wine_dbgstr_w(header) );
4792  trace( "transfer encoding: %s\n", wine_dbgstr_w(header) );
4793 
4794  header[0] = 0;
4795  len = sizeof(header);
4796  SetLastError( 0xdeadbeef );
4798  ok( !ret, "unexpected CONTENT_LENGTH header %s\n", wine_dbgstr_w(header) );
4799  ok( GetLastError() == ERROR_WINHTTP_HEADER_NOT_FOUND, "wrong error %u\n", GetLastError() );
4800 
4801  trace( "entering query loop\n" );
4802  for (;;)
4803  {
4804  len = 0xdeadbeef;
4805  ret = WinHttpQueryDataAvailable( req, &len );
4806  ok( ret, "WinHttpQueryDataAvailable failed with error %u\n", GetLastError() );
4807  if (ret) ok( len != 0xdeadbeef, "WinHttpQueryDataAvailable return wrong length\n" );
4808  trace( "got %u available\n", len );
4809  if (len)
4810  {
4811  DWORD bytes_read;
4812  char *buf = HeapAlloc( GetProcessHeap(), 0, len + 1 );
4813 
4814  ret = WinHttpReadData( req, buf, len, &bytes_read );
4815  ok(ret, "WinHttpReadData failed: %u.\n", GetLastError());
4816 
4817  buf[bytes_read] = 0;
4818  trace( "WinHttpReadData -> %d %u\n", ret, bytes_read );
4819  ok( len == bytes_read, "only got %u of %u available\n", bytes_read, len );
4820  ok( buf[bytes_read - 1] == '\n', "received partial line '%s'\n", buf );
4821 
4822  HeapFree( GetProcessHeap(), 0, buf );
4823  if (!bytes_read) break;
4824  }
4825  if (!len) break;
4826  }
4827  trace( "done\n" );
4828 
4829 done:
4830  if (req) WinHttpCloseHandle( req );
4831  if (con) WinHttpCloseHandle( con );
4832  if (ses) WinHttpCloseHandle( ses );
4833 }
HINTERNET WINAPI WinHttpConnect(HINTERNET hsession, LPCWSTR server, INTERNET_PORT port, DWORD reserved)
Definition: session.c:541
BOOL WINAPI WinHttpCloseHandle(HINTERNET handle)
Definition: session.c:1195
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define ERROR_WINHTTP_TIMEOUT
Definition: winhttp.h:189
#define WINHTTP_QUERY_TRANSFER_ENCODING
Definition: winhttp.h:361
char * wine_dbgstr_w(const wchar_t *wstr)
Definition: atltest.h:87
int WINAPI lstrcmpW(LPCWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:170
#define ERROR_WINHTTP_CANNOT_CONNECT
Definition: winhttp.h:201
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
BOOL WINAPI WinHttpQueryHeaders(HINTERNET hrequest, DWORD level, LPCWSTR name, LPVOID buffer, LPDWORD buflen, LPDWORD index)
Definition: request.c:856
unsigned int BOOL
Definition: ntddk_ex.h:94
static const WCHAR test_useragent[]
Definition: winhttp.c:40
BOOL WINAPI WinHttpReceiveResponse(HINTERNET hrequest, LPVOID reserved)
Definition: request.c:2924
smooth NULL
Definition: ftsmooth.c:416
#define GetProcessHeap()
Definition: compat.h:404
#define trace
Definition: atltest.h:70
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:418
#define WINHTTP_QUERY_CONTENT_LENGTH
Definition: winhttp.h:303
int ret
GLenum GLsizei len
Definition: glext.h:6722
#define err(...)
static const WCHAR test_winehq[]
Definition: winhttp.c:42
#define ok(value,...)
Definition: atltest.h:57
#define skip(...)
Definition: atltest.h:64
HINTERNET WINAPI WinHttpOpen(LPCWSTR agent, DWORD access, LPCWSTR proxy, LPCWSTR bypass, DWORD flags)
Definition: session.c:250
#define ERROR_WINHTTP_HEADER_NOT_FOUND
Definition: winhttp.h:213
HINTERNET WINAPI WinHttpOpenRequest(HINTERNET hconnect, LPCWSTR verb, LPCWSTR object, LPCWSTR version, LPCWSTR referrer, LPCWSTR *types, DWORD flags)
Definition: session.c:1117
BOOL WINAPI WinHttpSendRequest(HINTERNET hrequest, LPCWSTR headers, DWORD headers_len, LPVOID optional, DWORD optional_len, DWORD total_len, DWORD_PTR context)
Definition: request.c:2350
BOOL WINAPI WinHttpQueryDataAvailable(HINTERNET hrequest, LPDWORD available)
Definition: request.c:3005
#define HeapFree(x, y, z)
Definition: compat.h:403
struct CFHEADER header
Definition: fdi.c:101
BOOL WINAPI WinHttpReadData(HINTERNET hrequest, LPVOID buffer, DWORD to_read, LPDWORD read)
Definition: request.c:3053

Referenced by START_TEST().

◆ test_connection_info()

static void test_connection_info ( int  port)
static

Definition at line 3495 of file winhttp.c.

3496 {
3497  static const WCHAR basicW[] = {'/','b','a','s','i','c',0};
3498  HINTERNET ses, con, req;
3499  WINHTTP_CONNECTION_INFO info;
3500  DWORD size, error;
3501  BOOL ret;
3502 
3504  ok( ses != NULL, "failed to open session %u\n", GetLastError() );
3505 
3506  con = WinHttpConnect( ses, localhostW, port, 0 );
3507  ok( con != NULL, "failed to open a connection %u\n", GetLastError() );
3508 
3509  req = WinHttpOpenRequest( con, NULL, basicW, NULL, NULL, NULL, 0 );
3510  ok( req != NULL, "failed to open a request %u\n", GetLastError() );
3511 
3512  size = sizeof(info);
3513  SetLastError( 0xdeadbeef );
3515  error = GetLastError();
3516  if (!ret && error == ERROR_INVALID_PARAMETER)
3517  {
3518  win_skip( "WINHTTP_OPTION_CONNECTION_INFO not supported\n" );
3519  return;
3520  }
3521  ok( !ret, "unexpected success\n" );
3523 
3524  ret = WinHttpSendRequest( req, NULL, 0, NULL, 0, 0, 0 );
3525  ok( ret, "failed to send request %u\n", GetLastError() );
3526 
3527  size = 0;
3528  SetLastError( 0xdeadbeef );
3530  error = GetLastError();
3531  ok( !ret, "unexpected success\n" );
3532  ok( error == ERROR_INSUFFICIENT_BUFFER, "got %u\n", error );
3533 
3534  size = sizeof(info);
3535  memset( &info, 0, sizeof(info) );
3537  ok( ret, "failed to retrieve connection info %u\n", GetLastError() );
3538  ok( info.cbSize == sizeof(info) || info.cbSize == sizeof(info) - sizeof(info.cbSize) /* Win7 */, "wrong size %u\n", info.cbSize );
3539 
3540  ret = WinHttpReceiveResponse( req, NULL );
3541  ok( ret, "failed to receive response %u\n", GetLastError() );
3542 
3543  size = sizeof(info);
3544  memset( &info, 0, sizeof(info) );
3546  ok( ret, "failed to retrieve connection info %u\n", GetLastError() );
3547  ok( info.cbSize == sizeof(info) || info.cbSize == sizeof(info) - sizeof(info.cbSize) /* Win7 */, "wrong size %u\n", info.cbSize );
3548 
3549  WinHttpCloseHandle( req );
3550  WinHttpCloseHandle( con );
3551  WinHttpCloseHandle( ses );
3552 }
HINTERNET WINAPI WinHttpConnect(HINTERNET hsession, LPCWSTR server, INTERNET_PORT port, DWORD reserved)
Definition: session.c:541
static const WCHAR basicW[]
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
BOOL WINAPI WinHttpQueryOption(HINTERNET handle, DWORD option, LPVOID buffer, LPDWORD buflen)
Definition: session.c:1253
BOOL WINAPI WinHttpCloseHandle(HINTERNET handle)
Definition: session.c:1195
#define error(str)
Definition: mkdosfs.c:1605
#define WINHTTP_ACCESS_TYPE_NO_PROXY
Definition: winhttp.h:63
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
struct _test_info info[]
Definition: SetCursorPos.c:19
unsigned int BOOL
Definition: ntddk_ex.h:94
static const WCHAR test_useragent[]
Definition: winhttp.c:40
BOOL WINAPI WinHttpReceiveResponse(HINTERNET hrequest, LPVOID reserved)
Definition: request.c:2924
smooth NULL
Definition: ftsmooth.c:416
GLsizeiptr size
Definition: glext.h:5919
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:418
int ret
#define WINHTTP_OPTION_CONNECTION_INFO
Definition: winhttp.h:136
#define ok(value,...)
Definition: atltest.h:57
static const WCHAR localhostW[]
Definition: winhttp.c:44
HINTERNET WINAPI WinHttpOpen(LPCWSTR agent, DWORD access, LPCWSTR proxy, LPCWSTR bypass, DWORD flags)
Definition: session.c:250
#define ERROR_WINHTTP_INCORRECT_HANDLE_STATE
Definition: winhttp.h:200
HINTERNET WINAPI WinHttpOpenRequest(HINTERNET hconnect, LPCWSTR verb, LPCWSTR object, LPCWSTR version, LPCWSTR referrer, LPCWSTR *types, DWORD flags)
Definition: session.c:1117
USHORT port
Definition: uri.c:228
#define memset(x, y, z)
Definition: compat.h:39
#define win_skip
Definition: test.h:149
BOOL WINAPI WinHttpSendRequest(HINTERNET hrequest, LPCWSTR headers, DWORD headers_len, LPVOID optional, DWORD optional_len, DWORD total_len, DWORD_PTR context)
Definition: request.c:2350
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10

Referenced by START_TEST().

◆ test_cookies()

static void test_cookies ( int  port)
static

Definition at line 3266 of file winhttp.c.

3267 {
3268  static const WCHAR cookieW[] = {'/','c','o','o','k','i','e',0};
3269  static const WCHAR cookie2W[] = {'/','c','o','o','k','i','e','2',0};
3270  static const WCHAR cookie3W[] = {'/','c','o','o','k','i','e','3',0};
3271  static const WCHAR cookie4W[] = {'/','c','o','o','k','i','e','4',0};
3272  static const WCHAR cookie5W[] = {'/','c','o','o','k','i','e','5',0};
3273  static const WCHAR cookieheaderW[] =
3274  {'C','o','o','k','i','e',':',' ','n','a','m','e','=','v','a','l','u','e','2','\r','\n',0};
3275  HINTERNET ses, con, req;
3276  DWORD status, size;
3277  BOOL ret;
3278 
3280  ok( ses != NULL, "failed to open session %u\n", GetLastError() );
3281 
3282  con = WinHttpConnect( ses, localhostW, port, 0 );
3283  ok( con != NULL, "failed to open a connection %u\n", GetLastError() );
3284 
3285  req = WinHttpOpenRequest( con, NULL, cookieW, NULL, NULL, NULL, 0 );
3286  ok( req != NULL, "failed to open a request %u\n", GetLastError() );
3287 
3288  ret = WinHttpSendRequest( req, NULL, 0, NULL, 0, 0, 0 );
3289  ok( ret, "failed to send request %u\n", GetLastError() );
3290 
3291  ret = WinHttpReceiveResponse( req, NULL );
3292  ok( ret, "failed to receive response %u\n", GetLastError() );
3293 
3294  status = 0xdeadbeef;
3295  size = sizeof(status);
3297  ok( ret, "failed to query status code %u\n", GetLastError() );
3298  ok( status == HTTP_STATUS_OK, "request failed unexpectedly %u\n", status );
3299 
3300  WinHttpCloseHandle( req );
3301 
3302  req = WinHttpOpenRequest( con, NULL, cookie2W, NULL, NULL, NULL, 0 );
3303  ok( req != NULL, "failed to open a request %u\n", GetLastError() );
3304 
3305  ret = WinHttpSendRequest( req, NULL, 0, NULL, 0, 0, 0 );
3306  ok( ret, "failed to send request %u\n", GetLastError() );
3307 
3308  ret = WinHttpReceiveResponse( req, NULL );
3309  ok( ret, "failed to receive response %u\n", GetLastError() );
3310 
3311  status = 0xdeadbeef;
3312  size = sizeof(status);
3314  ok( ret, "failed to query status code %u\n", GetLastError() );
3315  ok( status == HTTP_STATUS_OK, "request failed unexpectedly %u\n", status );
3316 
3317  WinHttpCloseHandle( req );
3318  WinHttpCloseHandle( con );
3319 
3320  con = WinHttpConnect( ses, localhostW, port, 0 );
3321  ok( con != NULL, "failed to open a connection %u\n", GetLastError() );
3322 
3323  req = WinHttpOpenRequest( con, NULL, cookie2W, NULL, NULL, NULL, 0 );
3324  ok( req != NULL, "failed to open a request %u\n", GetLastError() );
3325 
3326  ret = WinHttpSendRequest( req, NULL, 0, NULL, 0, 0, 0 );
3327  ok( ret, "failed to send request %u\n", GetLastError() );
3328 
3329  ret = WinHttpReceiveResponse( req, NULL );
3330  ok( ret, "failed to receive response %u\n", GetLastError() );
3331 
3332  status = 0xdeadbeef;
3333  size = sizeof(status);
3335  ok( ret, "failed to query status code %u\n", GetLastError() );
3336  ok( status == HTTP_STATUS_OK, "request failed unexpectedly %u\n", status );
3337 
3338  WinHttpCloseHandle( req );
3339 
3340  req = WinHttpOpenRequest( con, NULL, cookie3W, NULL, NULL, NULL, 0 );
3341  ok( req != NULL, "failed to open a request %u\n", GetLastError() );
3342 
3343  ret = WinHttpSendRequest( req, cookieheaderW, ~0u, NULL, 0, 0, 0 );
3344  ok( ret, "failed to send request %u\n", GetLastError() );
3345 
3346  ret = WinHttpReceiveResponse( req, NULL );
3347  ok( ret, "failed to receive response %u\n", GetLastError() );
3348 
3349  status = 0xdeadbeef;
3350  size = sizeof(status);
3352  ok( ret, "failed to query status code %u\n", GetLastError() );
3353  ok( status == HTTP_STATUS_OK || broken(status == HTTP_STATUS_BAD_REQUEST), "request failed unexpectedly %u\n", status );
3354 
3355  WinHttpCloseHandle( req );
3356  WinHttpCloseHandle( con );
3357  WinHttpCloseHandle( ses );
3358 
3360  ok( ses != NULL, "failed to open session %u\n", GetLastError() );
3361 
3362  con = WinHttpConnect( ses, localhostW, port, 0 );
3363  ok( con != NULL, "failed to open a connection %u\n", GetLastError() );
3364 
3365  req = WinHttpOpenRequest( con, NULL, cookie2W, NULL, NULL, NULL, 0 );
3366  ok( req != NULL, "failed to open a request %u\n", GetLastError() );
3367 
3368  ret = WinHttpSendRequest( req, NULL, 0, NULL, 0, 0, 0 );
3369  ok( ret, "failed to send request %u\n", GetLastError() );
3370 
3371  ret = WinHttpReceiveResponse( req, NULL );
3372  ok( ret, "failed to receive response %u\n", GetLastError() );
3373 
3374  status = 0xdeadbeef;
3375  size = sizeof(status);
3377  ok( ret, "failed to query status code %u\n", GetLastError() );
3378  ok( status == HTTP_STATUS_BAD_REQUEST, "request failed unexpectedly %u\n", status );
3379 
3380  WinHttpCloseHandle( req );
3381  WinHttpCloseHandle( con );
3382  WinHttpCloseHandle( ses );
3383 
3385  ok( ses != NULL, "failed to open session %u\n", GetLastError() );
3386 
3387  con = WinHttpConnect( ses, localhostW, port, 0 );
3388  ok( con != NULL, "failed to open a connection %u\n", GetLastError() );
3389 
3390  req = WinHttpOpenRequest( con, NULL, cookie4W, NULL, NULL, NULL, 0 );
3391  ok( req != NULL, "failed to open a request %u\n", GetLastError() );
3392 
3393  ret = WinHttpSendRequest( req, NULL, 0, NULL, 0, 0, 0 );
3394  ok( ret, "failed to send request %u\n", GetLastError() );
3395 
3396  ret = WinHttpReceiveResponse( req, NULL );
3397  ok( ret, "failed to receive response %u\n", GetLastError() );
3398 
3399  status = 0xdeadbeef;
3400  size = sizeof(status);
3402  ok( ret, "failed to query status code %u\n", GetLastError() );
3403  ok( status == HTTP_STATUS_OK, "request failed unexpectedly %u\n", status );
3404  WinHttpCloseHandle( req );
3405 
3406  req = WinHttpOpenRequest( con, NULL, cookie5W, NULL, NULL, NULL, 0 );
3407  ok( req != NULL, "failed to open a request %u\n", GetLastError() );
3408 
3409  ret = WinHttpSendRequest( req, NULL, 0, NULL, 0, 0, 0 );
3410  ok( ret, "failed to send request %u\n", GetLastError() );
3411 
3412  ret = WinHttpReceiveResponse( req, NULL );
3413  ok( ret, "failed to receive response %u\n", GetLastError() );
3414 
3415  status = 0xdeadbeef;
3416  size = sizeof(status);
3418  ok( ret, "failed to query status code %u\n", GetLastError() );
3419  ok( status == HTTP_STATUS_OK || broken(status == HTTP_STATUS_BAD_REQUEST) /* < win7 */,
3420  "request failed unexpectedly %u\n", status );
3421 
3422  WinHttpCloseHandle( req );
3423  WinHttpCloseHandle( con );
3424  WinHttpCloseHandle( ses );
3425 }
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble * u
Definition: glfuncs.h:240
HINTERNET WINAPI WinHttpConnect(HINTERNET hsession, LPCWSTR server, INTERNET_PORT port, DWORD reserved)
Definition: session.c:541
BOOL WINAPI WinHttpCloseHandle(HINTERNET handle)
Definition: session.c:1195
#define WINHTTP_ACCESS_TYPE_NO_PROXY
Definition: winhttp.h:63
#define WINHTTP_QUERY_STATUS_CODE
Definition: winhttp.h:317
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define HTTP_STATUS_BAD_REQUEST
Definition: winhttp.h:255
BOOL WINAPI WinHttpQueryHeaders(HINTERNET hrequest, DWORD level, LPCWSTR name, LPVOID buffer, LPDWORD buflen, LPDWORD index)
Definition: request.c:856
unsigned int BOOL
Definition: ntddk_ex.h:94
static const WCHAR test_useragent[]
Definition: winhttp.c:40
BOOL WINAPI WinHttpReceiveResponse(HINTERNET hrequest, LPVOID reserved)
Definition: request.c:2924
smooth NULL
Definition: ftsmooth.c:416
GLsizeiptr size
Definition: glext.h:5919
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define WINHTTP_QUERY_FLAG_NUMBER
Definition: winhttp.h:377
unsigned long DWORD
Definition: ntddk_ex.h:95
#define HTTP_STATUS_OK
Definition: winhttp.h:240
int ret
#define broken(x)
Definition: _sntprintf.h:21
#define ok(value,...)
Definition: atltest.h:57
static const WCHAR localhostW[]
Definition: winhttp.c:44
HINTERNET WINAPI WinHttpOpen(LPCWSTR agent, DWORD access, LPCWSTR proxy, LPCWSTR bypass, DWORD flags)
Definition: session.c:250
HINTERNET WINAPI WinHttpOpenRequest(HINTERNET hconnect, LPCWSTR verb, LPCWSTR object, LPCWSTR version, LPCWSTR referrer, LPCWSTR *types, DWORD flags)
Definition: session.c:1117
USHORT port
Definition: uri.c:228
static SERVICE_STATUS status
Definition: service.c:31
BOOL WINAPI WinHttpSendRequest(HINTERNET hrequest, LPCWSTR headers, DWORD headers_len, LPVOID optional, DWORD optional_len, DWORD total_len, DWORD_PTR context)
Definition: request.c:2350
Definition: ps.c:97

Referenced by START_TEST().

◆ test_credentials()

static void test_credentials ( void  )
static

Definition at line 3625 of file winhttp.c.

3626 {
3627  static WCHAR userW[] = {'u','s','e','r',0};
3628  static WCHAR passW[] = {'p','a','s','s',0};
3629  static WCHAR proxy_userW[] = {'p','r','o','x','y','u','s','e','r',0};
3630  static WCHAR proxy_passW[] = {'p','r','o','x','y','p','a','s','s',0};
3631  HINTERNET ses, con, req;
3632  DWORD size, error;
3633  WCHAR buffer[32];
3634  BOOL ret;
3635 
3636  ses = WinHttpOpen(test_useragent, 0, proxy_userW, proxy_passW, 0);
3637  ok(ses != NULL, "failed to open session %u\n", GetLastError());
3638 
3639  con = WinHttpConnect(ses, localhostW, 0, 0);
3640  ok(con != NULL, "failed to open a connection %u\n", GetLastError());
3641 
3642  req = WinHttpOpenRequest(con, NULL, NULL, NULL, NULL, NULL, 0);
3643  ok(req != NULL, "failed to open a request %u\n", GetLastError());
3644 
3645  size = ARRAY_SIZE(buffer);
3647  ok(ret, "failed to query proxy username %u\n", GetLastError());
3648  ok(!buffer[0], "unexpected result %s\n", wine_dbgstr_w(buffer));
3649  ok(!size, "expected 0, got %u\n", size);
3650 
3651  size = ARRAY_SIZE(buffer);
3653  ok(ret, "failed to query proxy password %u\n", GetLastError());
3654  ok(!buffer[0], "unexpected result %s\n", wine_dbgstr_w(buffer));
3655  ok(!size, "expected 0, got %u\n", size);
3656 
3657  ret = WinHttpSetOption(req, WINHTTP_OPTION_PROXY_USERNAME, proxy_userW, lstrlenW(proxy_userW));
3658  ok(ret, "failed to set username %u\n", GetLastError());
3659 
3660  size = ARRAY_SIZE(buffer);
3662  ok(ret, "failed to query proxy username %u\n", GetLastError());
3663  ok(!winetest_strcmpW(buffer, proxy_userW), "unexpected result %s\n", wine_dbgstr_w(buffer));
3664  ok(size == lstrlenW(proxy_userW) * sizeof(WCHAR), "unexpected result %u\n", size);
3665 
3666  size = ARRAY_SIZE(buffer);
3668  ok(ret, "failed to query username %u\n", GetLastError());
3669  ok(!buffer[0], "unexpected result %s\n", wine_dbgstr_w(buffer));
3670  ok(!size, "expected 0, got %u\n", size);
3671 
3672  size = ARRAY_SIZE(buffer);
3674  ok(ret, "failed to query password %u\n", GetLastError());
3675  ok(!buffer[0], "unexpected result %s\n", wine_dbgstr_w(buffer));
3676  ok(!size, "expected 0, got %u\n", size);
3677 
3678  ret = WinHttpSetOption(req, WINHTTP_OPTION_PROXY_PASSWORD, proxy_passW, lstrlenW(proxy_passW));
3679  ok(ret, "failed to set proxy password %u\n", GetLastError());
3680 
3681  size = ARRAY_SIZE(buffer);
3683  ok(ret, "failed to query proxy password %u\n", GetLastError());
3684  ok(!winetest_strcmpW(buffer, proxy_passW), "unexpected result %s\n", wine_dbgstr_w(buffer));
3685  ok(size == lstrlenW(proxy_passW) * sizeof(WCHAR), "unexpected result %u\n", size);
3686 
3687  ret = WinHttpSetOption(req, WINHTTP_OPTION_USERNAME, userW, lstrlenW(userW));
3688  ok(ret, "failed to set username %u\n", GetLastError());
3689 
3690  size = ARRAY_SIZE(buffer);
3692  ok(ret, "failed to query username %u\n", GetLastError());
3693  ok(!winetest_strcmpW(buffer, userW), "unexpected result %s\n", wine_dbgstr_w(buffer));
3694  ok(size == lstrlenW(userW) * sizeof(WCHAR), "unexpected result %u\n", size);
3695 
3696  ret = WinHttpSetOption(req, WINHTTP_OPTION_PASSWORD, passW, lstrlenW(passW));
3697  ok(ret, "failed to set password %u\n", GetLastError());
3698 
3699  size = ARRAY_SIZE(buffer);
3701  ok(ret, "failed to query password %u\n", GetLastError());
3702  ok(!winetest_strcmpW(buffer, passW), "unexpected result %s\n", wine_dbgstr_w(buffer));
3703  ok(size == lstrlenW(passW) * sizeof(WCHAR), "unexpected result %u\n", size);
3704 
3705  WinHttpCloseHandle(req);
3706 
3707  req = WinHttpOpenRequest(con, NULL, NULL, NULL, NULL, NULL, 0);
3708  ok(req != NULL, "failed to open a request %u\n", GetLastError());
3709 
3710  SetLastError(0xdeadbeef);
3712  error = GetLastError();
3713  ok(!ret, "expected failure\n");
3714  ok(error == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %u\n", error);
3715 
3716  SetLastError(0xdeadbeef);
3718  error = GetLastError();
3719  ok(!ret, "expected failure\n");
3720  ok(error == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %u\n", error);
3721 
3723  ok(ret, "failed to set credentials %u\n", GetLastError());
3724 
3725  size = ARRAY_SIZE(buffer);
3727  ok(ret, "failed to query username %u\n", GetLastError());
3728  todo_wine {
3729  ok(!buffer[0], "unexpected result %s\n", wine_dbgstr_w(buffer));
3730  ok(!size, "expected 0, got %u\n", size);
3731  }
3732 
3733  size = ARRAY_SIZE(buffer);
3735  ok(ret, "failed to query password %u\n", GetLastError());
3736  todo_wine {
3737  ok(!buffer[0], "unexpected result %s\n", wine_dbgstr_w(buffer));
3738  ok(!size, "expected 0, got %u\n", size);
3739  }
3740 
3741  WinHttpCloseHandle(req);
3742  WinHttpCloseHandle(con);
3743  WinHttpCloseHandle(ses);
3744 }
HINTERNET WINAPI WinHttpConnect(HINTERNET hsession, LPCWSTR server, INTERNET_PORT port, DWORD reserved)
Definition: session.c:541
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define WINHTTP_OPTION_PROXY_PASSWORD
Definition: winhttp.h:148
BOOL WINAPI WinHttpQueryOption(HINTERNET handle, DWORD option, LPVOID buffer, LPDWORD buflen)
Definition: session.c:1253
BOOL WINAPI WinHttpCloseHandle(HINTERNET handle)
Definition: session.c:1195
#define WINHTTP_OPTION_PASSWORD
Definition: winhttp.h:146
#define error(str)
Definition: mkdosfs.c:1605
char * wine_dbgstr_w(const wchar_t *wstr)
Definition: atltest.h:87
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
GLuint buffer
Definition: glext.h:5915
#define WINHTTP_OPTION_PROXY_USERNAME
Definition: winhttp.h:147
#define WINHTTP_OPTION_USERNAME
Definition: winhttp.h:145
#define lstrlenW
Definition: compat.h:416
unsigned int BOOL
Definition: ntddk_ex.h:94
static const WCHAR test_useragent[]
Definition: winhttp.c:40
smooth NULL
Definition: ftsmooth.c:416
static int winetest_strcmpW(const WCHAR *str1, const WCHAR *str2)
Definition: test.h:89
GLsizeiptr size
Definition: glext.h:5919
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:418
int ret
#define todo_wine
Definition: test.h:162
BOOL WINAPI WinHttpSetCredentials(HINTERNET hrequest, DWORD target, DWORD scheme, LPCWSTR username, LPCWSTR password, LPVOID params)
Definition: request.c:2442
#define WINHTTP_AUTH_SCHEME_BASIC
Definition: winhttp.h:452
BOOL WINAPI WinHttpSetOption(HINTERNET handle, DWORD option, LPVOID buffer, DWORD buflen)
Definition: session.c:1312
#define ARRAY_SIZE(a)
Definition: main.h:24
#define ok(value,...)
Definition: atltest.h:57
static const WCHAR localhostW[]
Definition: winhttp.c:44
HINTERNET WINAPI WinHttpOpen(LPCWSTR agent, DWORD access, LPCWSTR proxy, LPCWSTR bypass, DWORD flags)
Definition: session.c:250
HINTERNET WINAPI WinHttpOpenRequest(HINTERNET hconnect, LPCWSTR verb, LPCWSTR object, LPCWSTR version, LPCWSTR referrer, LPCWSTR *types, DWORD flags)
Definition: session.c:1117
#define WINHTTP_AUTH_TARGET_SERVER
Definition: winhttp.h:458

Referenced by START_TEST().

◆ test_empty_headers_param()

static void test_empty_headers_param ( void  )
static

Definition at line 334 of file winhttp.c.

335 {
336  static const WCHAR empty[] = {0};
337  HINTERNET ses, con, req;
338  DWORD err;
339  BOOL ret;
340 
341  ses = WinHttpOpen(test_useragent, 0, NULL, NULL, 0);
342  ok(ses != NULL, "failed to open session %u\n", GetLastError());
343 
344  con = WinHttpConnect(ses, test_winehq, 80, 0);
345  ok(con != NULL, "failed to open a connection %u\n", GetLastError());
346 
347  req = WinHttpOpenRequest(con, NULL, NULL, NULL, NULL, NULL, 0);
348  ok(req != NULL, "failed to open a request %u\n", GetLastError());
349 
350  ret = WinHttpSendRequest(req, empty, 0, NULL, 0, 0, 0);
351  err = GetLastError();
353  {
354  skip("connection failed, skipping\n");
355  goto done;
356  }
357  ok(ret, "failed to send request %u\n", GetLastError());
358 
359  done:
360  WinHttpCloseHandle(req);
361  WinHttpCloseHandle(con);
362  WinHttpCloseHandle(ses);
363 }
HINTERNET WINAPI WinHttpConnect(HINTERNET hsession, LPCWSTR server, INTERNET_PORT port, DWORD reserved)
Definition: session.c:541
BOOL WINAPI WinHttpCloseHandle(HINTERNET handle)
Definition: session.c:1195
#define ERROR_WINHTTP_TIMEOUT
Definition: winhttp.h:189
#define ERROR_WINHTTP_CANNOT_CONNECT
Definition: winhttp.h:201
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
unsigned int BOOL
Definition: ntddk_ex.h:94
static const WCHAR test_useragent[]
Definition: winhttp.c:40
smooth NULL
Definition: ftsmooth.c:416
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
#define err(...)
static const WCHAR test_winehq[]
Definition: winhttp.c:42
#define ok(value,...)
Definition: atltest.h:57
BOOL empty
Definition: button.c:170
#define skip(...)
Definition: atltest.h:64
HINTERNET WINAPI WinHttpOpen(LPCWSTR agent, DWORD access, LPCWSTR proxy, LPCWSTR bypass, DWORD flags)
Definition: session.c:250
HINTERNET WINAPI WinHttpOpenRequest(HINTERNET hconnect, LPCWSTR verb, LPCWSTR object, LPCWSTR version, LPCWSTR referrer, LPCWSTR *types, DWORD flags)
Definition: session.c:1117
BOOL WINAPI WinHttpSendRequest(HINTERNET hrequest, LPCWSTR headers, DWORD headers_len, LPVOID optional, DWORD optional_len, DWORD total_len, DWORD_PTR context)
Definition: request.c:2350

Referenced by START_TEST().

◆ test_head_request()

static void test_head_request ( int  port)
static

Definition at line 3058 of file winhttp.c.

3059 {
3060  static const WCHAR verbW[] = {'H','E','A','D',0};
3061  static const WCHAR headW[] = {'/','h','e','a','d',0};
3062  HINTERNET ses, con, req;
3063  char buf[128];
3064  DWORD size, len, count, status;
3065  BOOL ret;
3066 
3068  ok(ses != NULL, "failed to open session %u\n", GetLastError());
3069 
3070  con = WinHttpConnect(ses, localhostW, port, 0);
3071  ok(con != NULL, "failed to open a connection %u\n", GetLastError());
3072 
3073  req = WinHttpOpenRequest(con, verbW, headW, NULL, NULL, NULL, 0);
3074  ok(req != NULL, "failed to open a request %u\n", GetLastError());
3075 
3076  ret = WinHttpSendRequest(req, NULL, 0, NULL, 0, 0, 0);
3077  ok(ret, "failed to send request %u\n", GetLastError());
3078 
3080  ok(ret, "failed to receive response %u\n", GetLastError());
3081 
3082  status = 0xdeadbeef;
3083  size = sizeof(status);
3085  NULL, &status, &size, NULL);
3086  ok(ret, "failed to get status code %u\n", GetLastError());
3087  ok(status == HTTP_STATUS_OK, "got %u\n", status);
3088 
3089  len = 0xdeadbeef;
3090  size = sizeof(len);
3092  NULL, &len, &size, 0);
3093  ok(ret, "failed to get content-length header %u\n", GetLastError());
3094  ok(len == HTTP_STATUS_CONTINUE, "got %u\n", len);
3095 
3096  count = 0xdeadbeef;
3098  ok(ret, "failed to query data available %u\n", GetLastError());
3099  ok(!count, "got %u\n", count);
3100 
3101  len = sizeof(buf);
3102  count = 0xdeadbeef;
3103  ret = WinHttpReadData(req, buf, len, &count);
3104  ok(ret, "failed to read data %u\n", GetLastError());
3105  ok(!count, "got %u\n", count);
3106 
3107  count = 0xdeadbeef;
3109  ok(ret, "failed to query data available %u\n", GetLastError());
3110  ok(!count, "got %u\n", count);
3111 
3112  WinHttpCloseHandle(req);
3113  WinHttpCloseHandle(con);
3114  WinHttpCloseHandle(ses);
3115 }
HINTERNET WINAPI WinHttpConnect(HINTERNET hsession, LPCWSTR server, INTERNET_PORT port, DWORD reserved)
Definition: session.c:541
static const WCHAR verbW[]
Definition: main.c:64
BOOL WINAPI WinHttpCloseHandle(HINTERNET handle)
Definition: session.c:1195
#define WINHTTP_ACCESS_TYPE_NO_PROXY
Definition: winhttp.h:63
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define WINHTTP_QUERY_STATUS_CODE
Definition: winhttp.h:317
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
BOOL WINAPI WinHttpQueryHeaders(HINTERNET hrequest, DWORD level, LPCWSTR name, LPVOID buffer, LPDWORD buflen, LPDWORD index)
Definition: request.c:856
unsigned int BOOL
Definition: ntddk_ex.h:94
static const WCHAR test_useragent[]
Definition: winhttp.c:40
BOOL WINAPI WinHttpReceiveResponse(HINTERNET hrequest, LPVOID reserved)
Definition: request.c:2924
smooth NULL
Definition: ftsmooth.c:416
GLsizeiptr size
Definition: glext.h:5919
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define WINHTTP_QUERY_FLAG_NUMBER
Definition: winhttp.h:377
unsigned long DWORD
Definition: ntddk_ex.h:95
#define HTTP_STATUS_OK
Definition: winhttp.h:240
#define WINHTTP_QUERY_CONTENT_LENGTH
Definition: winhttp.h:303
int ret
GLenum GLsizei len
Definition: glext.h:6722
#define ok(value,...)
Definition: atltest.h:57
#define HTTP_STATUS_CONTINUE
Definition: winhttp.h:238
static const WCHAR localhostW[]
Definition: winhttp.c:44
HINTERNET WINAPI WinHttpOpen(LPCWSTR agent, DWORD access, LPCWSTR proxy, LPCWSTR bypass, DWORD flags)
Definition: session.c:250
static const WCHAR headW[]
Definition: htmlelem.c:28
HINTERNET WINAPI WinHttpOpenRequest(HINTERNET hconnect, LPCWSTR verb, LPCWSTR object, LPCWSTR version, LPCWSTR referrer, LPCWSTR *types, DWORD flags)
Definition: session.c:1117
USHORT port
Definition: uri.c:228
static SERVICE_STATUS status
Definition: service.c:31
BOOL WINAPI WinHttpSendRequest(HINTERNET hrequest, LPCWSTR headers, DWORD headers_len, LPVOID optional, DWORD optional_len, DWORD total_len, DWORD_PTR context)
Definition: request.c:2350
BOOL WINAPI WinHttpQueryDataAvailable(HINTERNET hrequest, LPDWORD available)
Definition: request.c:3005
BOOL WINAPI WinHttpReadData(HINTERNET hrequest, LPVOID buffer, DWORD to_read, LPDWORD read)
Definition: request.c:3053
Definition: ps.c:97

Referenced by START_TEST().

◆ test_IWinHttpRequest()

static void test_IWinHttpRequest ( int  port)
static

Definition at line 3746 of file winhttp.c.

3747 {
3748  static const WCHAR data_start[] = {'<','!','D','O','C','T','Y','P','E',' ','h','t','m','l',' ','P','U','B','L','I','C'};
3749  static const WCHAR usernameW[] = {'u','s','e','r','n','a','m','e',0};
3750  static const WCHAR passwordW[] = {'p','a','s','s','w','o','r','d',0};
3751  static const WCHAR url1W[] = {'h','t','t','p',':','/','/','t','e','s','t','.','w','i','n','e','h','q','.','o','r','g',0};
3752  static const WCHAR url2W[] = {'t','e','s','t','.','w','i','n','e','h','q','.','o','r','g',0};
3753  static const WCHAR url3W[] = {'h','t','t','p',':','/','/','t','e','s','t','.','w','i','n','e','h','q','.',
3754  'o','r','g','/','t','e','s','t','s','/','p','o','s','t','.','p','h','p',0};
3755  static const WCHAR method1W[] = {'G','E','T',0};
3756  static const WCHAR method2W[] = {'I','N','V','A','L','I','D',0};
3757  static const WCHAR method3W[] = {'P','O','S','T',0};
3758  static const WCHAR proxy_serverW[] = {'p','r','o','x','y','s','e','r','v','e','r',0};
3759  static const WCHAR bypas_listW[] = {'b','y','p','a','s','s','l','i','s','t',0};
3760  static const WCHAR connectionW[] = {'C','o','n','n','e','c','t','i','o','n',0};
3761  static const WCHAR dateW[] = {'D','a','t','e',0};
3762  static const WCHAR test_dataW[] = {'t','e','s','t','d','a','t','a',128,0};
3763  static const WCHAR utf8W[] = {'u','t','f','-','8',0};
3764  static const WCHAR unauthW[] = {'U','n','a','u','t','h','o','r','i','z','e','d',0};
3765  HRESULT hr;
3766  IWinHttpRequest *req;
3767  BSTR method, url, username, password, response = NULL, status_text = NULL, headers = NULL;
3768  BSTR date, today, connection, value = NULL;
3769  VARIANT async, empty, timeout, body, body2, proxy_server, bypass_list, data, cp;
3770  VARIANT_BOOL succeeded;
3771  LONG status;
3773  SYSTEMTIME st;
3774  IStream *stream, *stream2;
3776  char buf[128];
3777  WCHAR bufW[128];
3778  DWORD count;
3779 
3780  GetSystemTime( &st );
3781  WinHttpTimeFromSystemTime( &st, todayW );
3782 
3783  CoInitialize( NULL );
3784  hr = CoCreateInstance( &CLSID_WinHttpRequest, NULL, CLSCTX_INPROC_SERVER, &IID_IWinHttpRequest, (void **)&req );
3785  ok( hr == S_OK, "got %08x\n", hr );
3786 
3787  V_VT( &empty ) = VT_ERROR;
3788  V_ERROR( &empty ) = 0xdeadbeef;
3789 
3790  V_VT( &async ) = VT_BOOL;
3791  V_BOOL( &async ) = VARIANT_FALSE;
3792 
3793  method = SysAllocString( method3W );
3794  url = SysAllocString( url3W );
3795  hr = IWinHttpRequest_Open( req, method, url, async );
3796  ok( hr == S_OK, "got %08x\n", hr );
3797  SysFreeString( method );
3798  SysFreeString( url );
3799 
3800  V_VT( &data ) = VT_BSTR;
3801  V_BSTR( &data ) = SysAllocString( test_dataW );
3802  hr = IWinHttpRequest_Send( req, data );
3803  ok( hr == S_OK || hr == HRESULT_FROM_WIN32( ERROR_WINHTTP_INVALID_SERVER_RESPONSE ), "got %08x\n", hr );
3804  SysFreeString( V_BSTR( &data ) );
3805  if (hr != S_OK) goto done;
3806 
3807  hr = IWinHttpRequest_Open( req, NULL, NULL, empty );
3808  ok( hr == E_INVALIDARG, "got %08x\n", hr );
3809 
3810  method = SysAllocString( method1W );
3811  hr = IWinHttpRequest_Open( req, method, NULL, empty );
3812  ok( hr == E_INVALIDARG, "got %08x\n", hr );
3813 
3814  hr = IWinHttpRequest_Open( req, method, NULL, async );
3815  ok( hr == E_INVALIDARG, "got %08x\n", hr );
3816 
3817  url = SysAllocString( url1W );
3818  hr = IWinHttpRequest_Open( req, NULL, url, empty );
3819  ok( hr == E_INVALIDARG, "got %08x\n", hr );
3820 
3821  hr = IWinHttpRequest_Abort( req );
3822  ok( hr == S_OK, "got %08x\n", hr );
3823 
3824  hr = IWinHttpRequest_Open( req, method, url, empty );
3825  ok( hr == S_OK, "got %08x\n", hr );
3826 
3827  hr = IWinHttpRequest_Abort( req );
3828  ok( hr == S_OK, "got %08x\n", hr );
3829 
3830  IWinHttpRequest_Release( req );
3831 
3832  hr = CoCreateInstance( &CLSID_WinHttpRequest, NULL, CLSCTX_INPROC_SERVER, &IID_IWinHttpRequest, (void **)&req );
3833  ok( hr == S_OK, "got %08x\n", hr );
3834 
3835  SysFreeString( url );
3836  url = SysAllocString( url2W );
3837  hr = IWinHttpRequest_Open( req, method, url, async );
3839 
3840  SysFreeString( method );
3841  method = SysAllocString( method2W );
3842  hr = IWinHttpRequest_Open( req, method, url, async );
3844 
3845  SysFreeString( method );
3846  method = SysAllocString( method1W );
3847  SysFreeString( url );
3848  url = SysAllocString( url1W );
3849  V_VT( &async ) = VT_ERROR;
3850  V_ERROR( &async ) = DISP_E_PARAMNOTFOUND;
3851  hr = IWinHttpRequest_Open( req, method, url, async );
3852  ok( hr == S_OK, "got %08x\n", hr );
3853 
3854  V_VT( &cp ) = VT_ERROR;
3855  V_ERROR( &cp ) = 0xdeadbeef;
3856  hr = IWinHttpRequest_get_Option( req, WinHttpRequestOption_URLCodePage, &cp );
3857  ok( hr == S_OK, "got %08x\n", hr );
3858  ok( V_VT( &cp ) == VT_I4, "got %08x\n", V_VT( &cp ) );
3859  ok( V_I4( &cp ) == CP_UTF8, "got %u\n", V_I4( &cp ) );
3860 
3861  V_VT( &cp ) = VT_UI4;
3862  V_UI4( &cp ) = CP_ACP;
3863  hr = IWinHttpRequest_put_Option( req, WinHttpRequestOption_URLCodePage, cp );
3864  ok( hr == S_OK, "got %08x\n", hr );
3865 
3866  V_VT( &cp ) = VT_ERROR;
3867  V_ERROR( &cp ) = 0xdeadbeef;
3868  hr = IWinHttpRequest_get_Option( req, WinHttpRequestOption_URLCodePage, &cp );
3869  ok( hr == S_OK, "got %08x\n", hr );
3870  ok( V_VT( &cp ) == VT_I4, "got %08x\n", V_VT( &cp ) );
3871  ok( V_I4( &cp ) == CP_ACP, "got %u\n", V_I4( &cp ) );
3872 
3873  value = SysAllocString( utf8W );
3874  V_VT( &cp ) = VT_BSTR;
3875  V_BSTR( &cp ) = value;
3876  hr = IWinHttpRequest_put_Option( req, WinHttpRequestOption_URLCodePage, cp );
3877  ok( hr == S_OK, "got %08x\n", hr );
3878  SysFreeString( value );
3879 
3880  V_VT( &cp ) = VT_ERROR;
3881  V_ERROR( &cp ) = 0xdeadbeef;
3882  hr = IWinHttpRequest_get_Option( req, WinHttpRequestOption_URLCodePage, &cp );
3883  ok( hr == S_OK, "got %08x\n", hr );
3884  ok( V_VT( &cp ) == VT_I4, "got %08x\n", V_VT( &cp ) );
3885  ok( V_I4( &cp ) == CP_UTF8, "got %u\n", V_I4( &cp ) );
3886 
3887  hr = IWinHttpRequest_Abort( req );
3888  ok( hr == S_OK, "got %08x\n", hr );
3889 
3890  hr = IWinHttpRequest_Send( req, empty );
3892 
3893  hr = IWinHttpRequest_Abort( req );
3894  ok( hr == S_OK, "got %08x\n", hr );
3895 
3896  IWinHttpRequest_Release( req );
3897 
3898  hr = CoCreateInstance( &CLSID_WinHttpRequest, NULL, CLSCTX_INPROC_SERVER, &IID_IWinHttpRequest, (void **)&req );
3899  ok( hr == S_OK, "got %08x\n", hr );
3900 
3901  hr = IWinHttpRequest_get_ResponseText( req, NULL );
3902  ok( hr == E_INVALIDARG, "got %08x\n", hr );
3903 
3904  hr = IWinHttpRequest_get_ResponseText( req, &response );
3906 
3907  hr = IWinHttpRequest_get_Status( req, NULL );
3908  ok( hr == E_INVALIDARG, "got %08x\n", hr );
3909 
3910  hr = IWinHttpRequest_get_Status( req, &status );
3912 
3913  hr = IWinHttpRequest_get_StatusText( req, NULL );
3914  ok( hr == E_INVALIDARG, "got %08x\n", hr );
3915 
3916  hr = IWinHttpRequest_get_StatusText( req, &status_text );
3918 
3919  hr = IWinHttpRequest_get_ResponseBody( req, NULL );
3920  ok( hr == E_INVALIDARG, "got %08x\n", hr );
3921 
3922  hr = IWinHttpRequest_SetTimeouts( req, 10000, 10000, 10000, 10000 );
3923  ok( hr == S_OK, "got %08x\n", hr );
3924 
3925  hr = IWinHttpRequest_SetCredentials( req, NULL, NULL, 0xdeadbeef );
3927 
3929  V_VT( &proxy_server ) = VT_ERROR;
3930  VariantInit( &bypass_list );
3931  V_VT( &bypass_list ) = VT_ERROR;
3932  hr = IWinHttpRequest_SetProxy( req, HTTPREQUEST_PROXYSETTING_DIRECT, proxy_server, bypass_list );
3933  ok( hr == S_OK, "got %08x\n", hr );
3934 
3935  hr = IWinHttpRequest_SetProxy( req, HTTPREQUEST_PROXYSETTING_PROXY, proxy_server, bypass_list );
3936  ok( hr == S_OK, "got %08x\n", hr );
3937 
3938  hr = IWinHttpRequest_SetProxy( req, HTTPREQUEST_PROXYSETTING_DIRECT, proxy_server, bypass_list );
3939  ok( hr == S_OK, "got %08x\n", hr );
3940 
3941  hr = IWinHttpRequest_GetAllResponseHeaders( req, NULL );
3942  ok( hr == E_INVALIDARG, "got %08x\n", hr );
3943 
3944  hr = IWinHttpRequest_GetAllResponseHeaders( req, &headers );
3946 
3947  hr = IWinHttpRequest_GetResponseHeader( req, NULL, NULL );
3949 
3950  connection = SysAllocString( connectionW );
3951  hr = IWinHttpRequest_GetResponseHeader( req, connection, NULL );
3953 
3954  hr = IWinHttpRequest_GetResponseHeader( req, connection, &value );
3956 
3957  hr = IWinHttpRequest_SetRequestHeader( req, NULL, NULL );
3958  ok( hr == E_INVALIDARG, "got %08x\n", hr );
3959 
3960  date = SysAllocString( dateW );
3961  hr = IWinHttpRequest_SetRequestHeader( req, date, NULL );
3963 
3964  today = SysAllocString( todayW );
3965  hr = IWinHttpRequest_SetRequestHeader( req, date, today );
3967 
3968  hr = IWinHttpRequest_SetAutoLogonPolicy( req, 0xdeadbeef );
3969  ok( hr == E_INVALIDARG, "got %08x\n", hr );
3970 
3971  hr = IWinHttpRequest_SetAutoLogonPolicy( req, AutoLogonPolicy_OnlyIfBypassProxy );
3972  ok( hr == S_OK, "got %08x\n", hr );
3973 
3974  SysFreeString( method );
3975  method = SysAllocString( method1W );
3976  SysFreeString( url );
3977  url = SysAllocString( url1W );
3978  hr = IWinHttpRequest_Open( req, method, url, async );
3979  ok( hr == S_OK, "got %08x\n", hr );
3980 
3981  hr = IWinHttpRequest_get_ResponseText( req, NULL );
3982  ok( hr == E_INVALIDARG, "got %08x\n", hr );
3983 
3984  hr = IWinHttpRequest_get_ResponseText( req, &response );
3986 
3987  hr = IWinHttpRequest_get_Status( req, &status );
3989 
3990  hr = IWinHttpRequest_get_StatusText( req, &status_text );
3992 
3993  hr = IWinHttpRequest_get_ResponseBody( req, NULL );
3994  ok( hr == E_INVALIDARG, "got %08x\n", hr );
3995 
3996  hr = IWinHttpRequest_SetTimeouts( req, 10000, 10000, 10000, 10000 );
3997  ok( hr == S_OK, "got %08x\n", hr );
3998 
3999  hr = IWinHttpRequest_SetCredentials( req, NULL, NULL, 0xdeadbeef );
4000  ok( hr == E_INVALIDARG, "got %08x\n", hr );
4001 
4002  username = SysAllocString( usernameW );
4003  hr = IWinHttpRequest_SetCredentials( req, username, NULL, 0xdeadbeef );
4004  ok( hr == E_INVALIDARG, "got %08x\n", hr );
4005 
4006  password = SysAllocString( passwordW );
4007  hr = IWinHttpRequest_SetCredentials( req, NULL, password, 0xdeadbeef );
4008  ok( hr == E_INVALIDARG, "got %08x\n", hr );
4009 
4010  hr = IWinHttpRequest_SetCredentials( req, username, password, 0xdeadbeef );
4011  ok( hr == E_INVALIDARG, "got %08x\n", hr );
4012 
4013  hr = IWinHttpRequest_SetCredentials( req, NULL, password, HTTPREQUEST_SETCREDENTIALS_FOR_SERVER );
4014  ok( hr == E_INVALIDARG, "got %08x\n", hr );
4015 
4016  hr = IWinHttpRequest_SetCredentials( req, username, password, HTTPREQUEST_SETCREDENTIALS_FOR_SERVER );
4017  ok( hr == S_OK, "got %08x\n", hr );
4018 
4019  V_VT( &proxy_server ) = VT_BSTR;
4020  V_BSTR( &proxy_server ) = SysAllocString( proxy_serverW );
4021  V_VT( &bypass_list ) = VT_BSTR;
4022  V_BSTR( &bypass_list ) = SysAllocString( bypas_listW );
4023  hr = IWinHttpRequest_SetProxy( req, HTTPREQUEST_PROXYSETTING_PROXY, proxy_server, bypass_list );
4024  ok( hr == S_OK, "got %08x\n", hr );
4025 
4026  hr = IWinHttpRequest_SetProxy( req, 0xdeadbeef, proxy_server, bypass_list );
4027  ok( hr == E_INVALIDARG, "got %08x\n", hr );
4028 
4029  hr = IWinHttpRequest_SetProxy( req, HTTPREQUEST_PROXYSETTING_DIRECT, proxy_server, bypass_list );
4030  ok( hr == S_OK, "got %08x\n", hr );
4031 
4032  hr = IWinHttpRequest_GetAllResponseHeaders( req, &headers );
4034 
4035  hr = IWinHttpRequest_GetResponseHeader( req, connection, &value );
4037 
4038  hr = IWinHttpRequest_SetRequestHeader( req, date, today );
4039  ok( hr == S_OK, "got %08x\n", hr );
4040 
4041  hr = IWinHttpRequest_SetRequestHeader( req, date, NULL );
4042  ok( hr == S_OK, "got %08x\n", hr );
4043 
4044  hr = IWinHttpRequest_SetAutoLogonPolicy( req, AutoLogonPolicy_OnlyIfBypassProxy );
4045  ok( hr == S_OK, "got %08x\n", hr );
4046 
4047  hr = IWinHttpRequest_Send( req, empty );
4048  ok( hr == S_OK, "got %08x\n", hr );
4049 
4050  hr = IWinHttpRequest_Send( req, empty );
4051  ok( hr == S_OK, "got %08x\n", hr );
4052 
4053  hr = IWinHttpRequest_get_ResponseText( req, NULL );
4054  ok( hr == E_INVALIDARG, "got %08x\n", hr );
4055 
4056  hr = IWinHttpRequest_get_ResponseText( req, &response );
4057  ok( hr == S_OK, "got %08x\n", hr );
4058  ok( !memcmp(response, data_start, sizeof(data_start)), "got %s\n", wine_dbgstr_wn(response, 32) );
4059  SysFreeString( response );
4060 
4061  hr = IWinHttpRequest_get_Status( req, NULL );
4062  ok( hr == E_INVALIDARG, "got %08x\n", hr );
4063 
4064  status = 0;
4065  hr = IWinHttpRequest_get_Status( req, &status );
4066  ok( hr == S_OK, "got %08x\n", hr );
4067  trace("Status=%d\n", status);
4068 
4069  hr = IWinHttpRequest_get_StatusText( req, NULL );
4070  ok( hr == E_INVALIDARG, "got %08x\n", hr );
4071 
4072  hr = IWinHttpRequest_get_StatusText( req, &status_text );
4073  ok( hr == S_OK, "got %08x\n", hr );
4074  trace("StatusText=%s\n", wine_dbgstr_w(status_text));
4075  SysFreeString( status_text );
4076 
4077  hr = IWinHttpRequest_get_ResponseBody( req, NULL );
4078  ok( hr == E_INVALIDARG, "got %08x\n", hr );
4079 
4080  hr = IWinHttpRequest_SetCredentials( req, username, password, HTTPREQUEST_SETCREDENTIALS_FOR_SERVER );
4081  ok( hr == S_OK, "got %08x\n", hr );
4082 
4083  hr = IWinHttpRequest_SetProxy( req, HTTPREQUEST_PROXYSETTING_PROXY, proxy_server, bypass_list );
4084  ok( hr == S_OK, "got %08x\n", hr );
4085 
4086  hr = IWinHttpRequest_SetProxy( req, HTTPREQUEST_PROXYSETTING_DIRECT, proxy_server, bypass_list );
4087  ok( hr == S_OK, "got %08x\n", hr );
4088 
4089  hr = IWinHttpRequest_GetAllResponseHeaders( req, NULL );
4090  ok( hr == E_INVALIDARG, "got %08x\n", hr );
4091 
4092  hr = IWinHttpRequest_GetAllResponseHeaders( req, &headers );
4093  ok( hr == S_OK, "got %08x\n", hr );
4095 
4096  hr = IWinHttpRequest_GetResponseHeader( req, NULL, NULL );
4097  ok( hr == E_INVALIDARG, "got %08x\n", hr );
4098 
4099  hr = IWinHttpRequest_GetResponseHeader( req, connection, NULL );
4100  ok( hr == E_INVALIDARG, "got %08x\n", hr );
4101 
4102  hr = IWinHttpRequest_GetResponseHeader( req, connection, &value );
4103  ok( hr == S_OK, "got %08x\n", hr );
4104  SysFreeString( value );
4105 
4106  hr = IWinHttpRequest_SetRequestHeader( req, date, today );
4108 
4109  hr = IWinHttpRequest_SetAutoLogonPolicy( req, AutoLogonPolicy_OnlyIfBypassProxy );
4110  ok( hr == S_OK, "got %08x\n", hr );
4111 
4112  VariantInit( &timeout );
4113  V_VT( &timeout ) = VT_I4;
4114  V_I4( &timeout ) = 10;
4115  hr = IWinHttpRequest_WaitForResponse( req, timeout, &succeeded );
4116  ok( hr == S_OK, "got %08x\n", hr );
4117 
4118  hr = IWinHttpRequest_get_Status( req, &status );
4119  ok( hr == S_OK, "got %08x\n", hr );
4120 
4121  hr = IWinHttpRequest_get_StatusText( req, &status_text );
4122  ok( hr == S_OK, "got %08x\n", hr );
4123  SysFreeString( status_text );
4124 
4125  hr = IWinHttpRequest_SetCredentials( req, username, password, HTTPREQUEST_SETCREDENTIALS_FOR_SERVER );
4126  ok( hr == S_OK, "got %08x\n", hr );
4127 
4128  hr = IWinHttpRequest_SetProxy( req, HTTPREQUEST_PROXYSETTING_PROXY, proxy_server, bypass_list );
4129  ok( hr == S_OK, "got %08x\n", hr );
4130 
4131  hr = IWinHttpRequest_SetProxy( req, HTTPREQUEST_PROXYSETTING_DIRECT, proxy_server, bypass_list );
4132  ok( hr == S_OK, "got %08x\n", hr );
4133 
4134  hr = IWinHttpRequest_Send( req, empty );
4135  ok( hr == S_OK, "got %08x\n", hr );
4136 
4137  hr = IWinHttpRequest_get_ResponseText( req, NULL );
4138  ok( hr == E_INVALIDARG, "got %08x\n", hr );
4139 
4140  hr = IWinHttpRequest_get_ResponseText( req, &response );
4141  ok( hr == S_OK, "got %08x\n", hr );
4142  SysFreeString( response );
4143 
4144  hr = IWinHttpRequest_get_ResponseBody( req, NULL );
4145  ok( hr == E_INVALIDARG, "got %08x\n", hr );
4146 
4147  VariantInit( &body );
4148  V_VT( &body ) = VT_ERROR;
4149  hr = IWinHttpRequest_get_ResponseBody( req, &body );
4150  ok( hr == S_OK, "got %08x\n", hr );
4151  ok( V_VT( &body ) == (VT_ARRAY|VT_UI1), "got %08x\n", V_VT( &body ) );
4152 
4153  hr = VariantClear( &body );
4154  ok( hr == S_OK, "got %08x\n", hr );
4155 
4156  VariantInit( &body );
4157  V_VT( &body ) = VT_ERROR;
4158  hr = IWinHttpRequest_get_ResponseStream( req, &body );
4159  ok( hr == S_OK, "got %08x\n", hr );
4160  ok( V_VT( &body ) == VT_UNKNOWN, "got %08x\n", V_VT( &body ) );
4161 
4162  hr = IUnknown_QueryInterface( V_UNKNOWN( &body ), &IID_IStream, (void **)&stream );
4163  ok( hr == S_OK, "got %08x\n", hr );
4164  ok( V_UNKNOWN( &body ) == (IUnknown *)stream, "got different interface pointer\n" );
4165 
4166  buf[0] = 0;
4167  count = 0xdeadbeef;
4168  hr = IStream_Read( stream, buf, 128, &count );
4169  ok( hr == S_OK, "got %08x\n", hr );
4170  ok( count != 0xdeadbeef, "count not set\n" );
4171  ok( buf[0], "no data\n" );
4172 
4173  VariantInit( &body2 );
4174  V_VT( &body2 ) = VT_ERROR;
4175  hr = IWinHttpRequest_get_ResponseStream( req, &body2 );
4176  ok( hr == S_OK, "got %08x\n", hr );
4177  ok( V_VT( &body2 ) == VT_UNKNOWN, "got %08x\n", V_VT( &body2 ) );
4178  ok( V_UNKNOWN( &body ) != V_UNKNOWN( &body2 ), "got same interface pointer\n" );
4179 
4180  hr = IUnknown_QueryInterface( V_UNKNOWN( &body2 ), &IID_IStream, (void **)&stream2 );
4181  ok( hr == S_OK, "got %08x\n", hr );
4182  ok( V_UNKNOWN( &body2 ) == (IUnknown *)stream2, "got different interface pointer\n" );
4183  IStream_Release( stream2 );
4184 
4185  hr = VariantClear( &body );
4186  ok( hr == S_OK, "got %08x\n", hr );
4187 
4188  hr = VariantClear( &body2 );
4189  ok( hr == S_OK, "got %08x\n", hr );
4190 
4191  hr = IWinHttpRequest_SetProxy( req, HTTPREQUEST_PROXYSETTING_PROXY, proxy_server, bypass_list );
4192  ok( hr == S_OK, "got %08x\n", hr );
4193 
4194  hr = IWinHttpRequest_SetProxy( req, HTTPREQUEST_PROXYSETTING_DIRECT, proxy_server, bypass_list );
4195  ok( hr == S_OK, "got %08x\n", hr );
4196 
4197  hr = IWinHttpRequest_GetAllResponseHeaders( req, &headers );
4198  ok( hr == S_OK, "got %08x\n", hr );
4200 
4201  hr = IWinHttpRequest_GetResponseHeader( req, connection, &value );
4202  ok( hr == S_OK, "got %08x\n", hr );
4203  SysFreeString( value );
4204 
4205  hr = IWinHttpRequest_SetRequestHeader( req, date, today );
4207 
4208  hr = IWinHttpRequest_SetAutoLogonPolicy( req, AutoLogonPolicy_OnlyIfBypassProxy );
4209  ok( hr == S_OK, "got %08x\n", hr );
4210 
4211  hr = IWinHttpRequest_Send( req, empty );
4212  ok( hr == S_OK, "got %08x\n", hr );
4213 
4214  hr = IWinHttpRequest_Abort( req );
4215  ok( hr == S_OK, "got %08x\n", hr );
4216 
4217  hr = IWinHttpRequest_Abort( req );
4218  ok( hr == S_OK, "got %08x\n", hr );
4219 
4220  IWinHttpRequest_Release( req );
4221 
4222  pos.QuadPart = 0;
4223  hr = IStream_Seek( stream, pos, STREAM_SEEK_SET, NULL );
4224  ok( hr == S_OK, "got %08x\n", hr );
4225 
4226  buf[0] = 0;
4227  count = 0xdeadbeef;
4228  hr = IStream_Read( stream, buf, 128, &count );
4229  ok( hr == S_OK, "got %08x\n", hr );
4230  ok( count != 0xdeadbeef, "count not set\n" );
4231  ok( buf[0], "no data\n" );
4232  IStream_Release( stream );
4233 
4234  hr = CoCreateInstance( &CLSID_WinHttpRequest, NULL, CLSCTX_INPROC_SERVER, &IID_IWinHttpRequest, (void **)&req );
4235  ok( hr == S_OK, "got %08x\n", hr );
4236 
4237  V_VT( &async ) = VT_I4;
4238  V_I4( &async ) = 1;
4239  hr = IWinHttpRequest_Open( req, method, url, async );
4240  ok( hr == S_OK, "got %08x\n", hr );
4241 
4242  hr = IWinHttpRequest_Send( req, empty );
4243  ok( hr == S_OK, "got %08x\n", hr );
4244 
4245  hr = IWinHttpRequest_WaitForResponse( req, timeout, &succeeded );
4246  ok( hr == S_OK, "got %08x\n", hr );
4247 
4248  IWinHttpRequest_Release( req );
4249 
4250  SysFreeString( method );
4251  SysFreeString( url );
4254  SysFreeString( connection );
4255  SysFreeString( date );
4256  SysFreeString( today );
4258  VariantClear( &bypass_list );
4259 
4260  hr = CoCreateInstance( &CLSID_WinHttpRequest, NULL, CLSCTX_INPROC_SERVER, &IID_IWinHttpRequest, (void **)&req );
4261  ok( hr == S_OK, "got %08x\n", hr );
4262 
4264  method = SysAllocString( method3W );
4265  V_VT( &async ) = VT_BOOL;
4266  V_BOOL( &async ) = VARIANT_FALSE;
4267  hr = IWinHttpRequest_Open( req, method, url, async );
4268  ok( hr == S_OK, "got %08x\n", hr );
4269  SysFreeString( method );
4270  SysFreeString( url );
4271 
4272  hr = IWinHttpRequest_Send( req, empty );
4274  hr == SEC_E_ILLEGAL_MESSAGE /* winxp */, "got %08x\n", hr );
4275  if (hr != S_OK) goto done;
4276 
4277  hr = IWinHttpRequest_get_ResponseText( req, &response );
4278  ok( hr == S_OK, "got %08x\n", hr );
4279  ok( !memcmp(response, data_start, sizeof(data_start)), "got %s\n", wine_dbgstr_wn(response, 32) );
4280  SysFreeString( response );
4281 
4282  IWinHttpRequest_Release( req );
4283 
4284  hr = CoCreateInstance( &CLSID_WinHttpRequest, NULL, CLSCTX_INPROC_SERVER, &IID_IWinHttpRequest, (void **)&req );
4285  ok( hr == S_OK, "got %08x\n", hr );
4286 
4287  sprintf( buf, "http://localhost:%d/auth", port );
4288  MultiByteToWideChar( CP_ACP, 0, buf, -1, bufW, ARRAY_SIZE( bufW ));
4289  url = SysAllocString( bufW );
4290  method = SysAllocString( method3W );
4291  V_VT( &async ) = VT_BOOL;
4292  V_BOOL( &async ) = VARIANT_FALSE;
4293  hr = IWinHttpRequest_Open( req, method, url, async );
4294  ok( hr == S_OK, "got %08x\n", hr );
4295  SysFreeString( method );
4296  SysFreeString( url );
4297 
4298  hr = IWinHttpRequest_get_Status( req, &status );
4300 
4301  V_VT( &data ) = VT_BSTR;
4302  V_BSTR( &data ) = SysAllocString( test_dataW );
4303  hr = IWinHttpRequest_Send( req, data );
4304  ok( hr == S_OK, "got %08x\n", hr );
4305  SysFreeString( V_BSTR( &data ) );
4306 
4307  hr = IWinHttpRequest_get_ResponseText( req, &response );
4308  ok( hr == S_OK, "got %08x\n", hr );
4309  ok( !memcmp( response, unauthW, sizeof(unauthW) ), "got %s\n", wine_dbgstr_w(response) );
4310  SysFreeString( response );
4311 
4312  status = 0xdeadbeef;
4313  hr = IWinHttpRequest_get_Status( req, &status );
4314  ok( hr == S_OK, "got %08x\n", hr );
4315  ok( status == HTTP_STATUS_DENIED, "got %d\n", status );
4316 
4317 done:
4318  IWinHttpRequest_Release( req );
4319  CoUninitialize();
4320 }
#define ERROR_WINHTTP_CANNOT_CALL_BEFORE_SEND
Definition: winhttp.h:210
Definition: compat.h:1948
#define HRESULT_FROM_WIN32(x)
Definition: winerror.h:92
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
HRESULT hr
Definition: shlfolder.c:183
const HTTPREQUEST_PROXY_SETTING HTTPREQUEST_PROXYSETTING_DIRECT
Definition: httprequest.idl:41
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
char * wine_dbgstr_w(const wchar_t *wstr)
Definition: atltest.h:87
#define CP_ACP
Definition: compat.h:99
GLuint GLuint GLsizei count
Definition: gl.h:1545
static const WCHAR utf8W[]
Definition: mxwriter.c:86
vector< Header * > headers
Definition: sdkparse.cpp:39
Definition: dhcpd.h:245
OLECHAR * BSTR
Definition: compat.h:1943
void WINAPI VariantInit(VARIANTARG *pVarg)
Definition: variant.c:568
short VARIANT_BOOL
Definition: compat.h:1940
GLbitfield GLuint64 timeout
Definition: glext.h:7164
#define DISP_E_PARAMNOTFOUND
Definition: winerror.h:2513
#define V_I4(A)
Definition: oleauto.h:247
#define sprintf(buf, format,...)
Definition: sprintf.c:55
#define CP_UTF8
Definition: nls.h:20
long LONG
Definition: pedump.c:60
#define E_INVALIDARG
Definition: ddrawi.h:101
smooth NULL
Definition: ftsmooth.c:416
#define SEC_E_ILLEGAL_MESSAGE
Definition: winerror.h:2943
#define ERROR_WINHTTP_CANNOT_CALL_AFTER_SEND
Definition: winhttp.h:211
BSTR WINAPI SysAllocString(LPCOLESTR str)
Definition: oleaut.c:238
#define HTTP_STATUS_DENIED
Definition: winhttp.h:256
#define ERROR_WINHTTP_CANNOT_CALL_BEFORE_OPEN
Definition: winhttp.h:209
static WCHAR username[]
Definition: url.c:32
VOID WINAPI GetSystemTime(OUT LPSYSTEMTIME lpSystemTime)
Definition: time.c:327
#define trace
Definition: atltest.h:70
#define WINHTTP_TIME_FORMAT_BUFSIZE
Definition: winhttp.h:461
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:78
static const WCHAR url[]
Definition: encode.c:1432
#define V_BOOL(A)
Definition: oleauto.h:224
unsigned long DWORD
Definition: ntddk_ex.h:95
static const WCHAR url1W[]
Definition: atl.c:53
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
method
Definition: dragdrop.c:53
#define ERROR_WINHTTP_UNRECOGNIZED_SCHEME
Definition: winhttp.h:192
#define V_UI4(A)
Definition: oleauto.h:270
static const WCHAR test_winehq_https[]
Definition: winhttp.c:43
HRESULT WINAPI DECLSPEC_HOTPATCH VariantClear(VARIANTARG *pVarg)
Definition: variant.c:648
Definition: parse.h:22
T1_FIELD_DICT_PRIVATE password
Definition: t1tokens.h:64
GLuint GLuint stream
Definition: glext.h:7522
#define V_VT(A)
Definition: oleauto.h:211
const char * wine_dbgstr_wn(const WCHAR *str, int n)
Definition: compat.c:342
#define V_UNKNOWN(A)
Definition: oleauto.h:281
const HTTPREQUEST_PROXY_SETTING HTTPREQUEST_PROXYSETTING_PROXY
Definition: httprequest.idl:42
GLsizei const GLfloat * value
Definition: glext.h:6069
#define V_BSTR(A)
Definition: oleauto.h:226
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID iid, LPVOID *ppv)
Definition: compobj.c:3325
#define ERROR_WINHTTP_INVALID_SERVER_RESPONSE
Definition: winhttp.h:214
#define S_OK
Definition: intsafe.h:59
const HTTPREQUEST_SETCREDENTIALS_FLAGS HTTPREQUEST_SETCREDENTIALS_FOR_SERVER
Definition: httprequest.idl:45
BOOL WINAPI WinHttpTimeFromSystemTime(const SYSTEMTIME *time, LPWSTR string)
Definition: session.c:2158
void WINAPI DECLSPEC_HOTPATCH CoUninitialize(void)
Definition: compobj.c:2067
#define ARRAY_SIZE(a)
Definition: main.h:24
__u16 date
Definition: mkdosfs.c:366
#define ok(value,...)
Definition: atltest.h:57
static const void * body(MD5_CTX *ctx, const void *data, unsigned long size)
Definition: md5.c:100
void WINAPI DECLSPEC_HOTPATCH SysFreeString(BSTR str)
Definition: oleaut.c:271
#define V_ERROR(A)
Definition: oleauto.h:241
BOOL empty
Definition: button.c:170
#define MultiByteToWideChar
Definition: compat.h:100
static const WCHAR proxy_server[]
Definition: connections.c:40
HRESULT WINAPI CoInitialize(LPVOID lpReserved)
Definition: compobj.c:1964
POINT cp
Definition: magnifier.c:59
USHORT port
Definition: uri.c:228
static SERVICE_STATUS status
Definition: service.c:31
Definition: ps.c:97

Referenced by START_TEST().

◆ test_IWinHttpRequest_Invoke()

static void test_IWinHttpRequest_Invoke ( void  )
static

Definition at line 4342 of file winhttp.c.

4343 {
4344  static const WCHAR utf8W[] = {'U','T','F','-','8',0};
4345  static const WCHAR regid[] = {'W','i','n','H','t','t','p','.','W','i','n','H','t','t','p','R','e','q','u','e','s','t','.','5','.','1',0};
4346  WCHAR openW[] = {'O','p','e','n',0};
4347  WCHAR optionW[] = {'O','p','t','i','o','n',0};
4348  OLECHAR *open = openW, *option = optionW;
4349  BSTR utf8;
4350  CLSID clsid;
4351  IWinHttpRequest *request;
4353  DISPID id;
4355  VARIANT arg[3], ret;
4356  UINT err;
4357  BOOL bret;
4358  HRESULT hr;
4359 
4360  CoInitialize(NULL);
4361 
4363  ok(hr == S_OK, "CLSIDFromProgID error %#x\n", hr);
4364  bret = IsEqualIID(&clsid, &CLSID_WinHttpRequest);
4365  ok(bret || broken(!bret) /* win2003 */, "not expected %s\n", wine_dbgstr_guid(&clsid));
4366 
4367  hr = CoCreateInstance(&CLSID_WinHttpRequest, 0, CLSCTX_INPROC_SERVER, &IID_IUnknown, (void **)&request);
4368  ok(hr == S_OK, "error %#x\n", hr);
4369 
4370  hr = IWinHttpRequest_QueryInterface(request, &IID_IDispatch, (void **)&dispatch);
4371  ok(hr == S_OK, "error %#x\n", hr);
4372  IDispatch_Release(dispatch);
4373 
4374  hr = IWinHttpRequest_GetIDsOfNames(request, &IID_NULL, &open, 1, 0x0409, &id);
4375  ok(hr == S_OK, "error %#x\n", hr);
4376  ok(id == DISPID_HTTPREQUEST_OPEN, "expected DISPID_HTTPREQUEST_OPEN, got %u\n", id);
4377 
4378  hr = IWinHttpRequest_GetIDsOfNames(request, &IID_NULL, &option, 1, 0x0409, &id);
4379  ok(hr == S_OK, "error %#x\n", hr);
4380  ok(id == DISPID_HTTPREQUEST_OPTION, "expected DISPID_HTTPREQUEST_OPTION, got %u\n", id);
4381 
4383  ok(V_VT(&ret) == VT_I4, "expected VT_I4, got %d\n", V_VT(&ret));
4384  ok(V_I4(&ret) == CP_UTF8, "expected CP_UTF8, got %d\n", V_I4(&ret));
4385 
4386  memset(&params, 0, sizeof(params));
4387  params.cArgs = 2;
4388  params.cNamedArgs = 0;
4389  params.rgvarg = arg;
4390  V_VT(&arg[0]) = VT_I4;
4391  V_I4(&arg[0]) = 1252;
4392  V_VT(&arg[1]) = VT_R8;
4393  V_R8(&arg[1]) = 2.0; /* WinHttpRequestOption_URLCodePage */
4394  VariantInit(&ret);
4395  hr = IWinHttpRequest_Invoke(request, DISPID_HTTPREQUEST_OPTION, &IID_NULL, 0,
4397  ok(hr == S_OK, "error %#x\n", hr);
4398 
4400  ok(V_VT(&ret) == VT_I4, "expected VT_I4, got %d\n", V_VT(&ret));
4401  ok(V_I4(&ret) == CP_UTF8, "expected CP_UTF8, got %d\n", V_I4(&ret));
4402 
4403  memset(&params, 0, sizeof(params));
4404  params.cArgs = 2;
4405  params.cNamedArgs = 0;
4406  params.rgvarg = arg;
4407  V_VT(&arg[0]) = VT_I4;
4408  V_I4(&arg[0]) = 1252;
4409  V_VT(&arg[1]) = VT_R8;
4410  V_R8(&arg[1]) = 2.0; /* WinHttpRequestOption_URLCodePage */
4411  VariantInit(&ret);
4412  hr = IWinHttpRequest_Invoke(request, DISPID_HTTPREQUEST_OPTION, &IID_NULL, 0,
4414  ok(hr == S_OK, "error %#x\n", hr);
4415 
4417  ok(V_VT(&ret) == VT_I4, "expected VT_I4, got %d\n", V_VT(&ret));
4418  ok(V_I4(&ret) == CP_UTF8, "expected CP_UTF8, got %d\n", V_I4(&ret));
4419 
4420  memset(&params, 0, sizeof(params));
4421  params.cArgs = 2;
4422  params.cNamedArgs = 0;
4423  params.rgvarg = arg;
4424  V_VT(&arg[0]) = VT_I4;
4425  V_I4(&arg[0]) = 1252;
4426  V_VT(&arg[1]) = VT_R8;
4427  V_R8(&arg[1]) = 2.0; /* WinHttpRequestOption_URLCodePage */
4428  VariantInit(&ret);
4429  hr = IWinHttpRequest_Invoke(request, DISPID_HTTPREQUEST_OPTION, &IID_NULL, 0,
4431  ok(hr == S_OK, "error %#x\n", hr);
4432 
4434  ok(V_VT(&ret) == VT_I4, "expected VT_I4, got %d\n", V_VT(&ret));
4435  ok(V_I4(&ret) == 1252, "expected 1252, got %d\n", V_I4(&ret));
4436 
4437  memset(&params, 0, sizeof(params));
4438  params.cArgs = 2;
4439  params.cNamedArgs = 0;
4440  params.rgvarg = arg;
4441  V_VT(&arg[0]) = VT_BSTR;
4442  utf8 = SysAllocString(utf8W);
4443  V_BSTR(&arg[0]) = utf8;
4444  V_VT(&arg[1]) = VT_R8;
4445  V_R8(&arg[1]) = 2.0; /* WinHttpRequestOption_URLCodePage */
4446  hr = IWinHttpRequest_Invoke(request, id, &IID_NULL, 0, DISPATCH_METHOD, &params, NULL, NULL, &err);
4447  ok(hr == S_OK, "error %#x\n", hr);
4448 
4450  ok(V_VT(&ret) == VT_I4, "expected VT_I4, got %d\n", V_VT(&ret));
4451  ok(V_I4(&ret) == 1252, "expected 1252, got %d\n", V_I4(&ret));
4452 
4453  VariantInit(&ret);
4454  hr = IWinHttpRequest_Invoke(request, id, &IID_NULL, 0, DISPATCH_METHOD, &params, &ret, NULL, &err);
4455  ok(hr == S_OK, "error %#x\n", hr);
4456 
4458  ok(V_VT(&ret) == VT_I4, "expected VT_I4, got %d\n", V_VT(&ret));
4459  ok(V_I4(&ret) == 1252, "expected 1252, got %d\n", V_I4(&ret));
4460 
4461  VariantInit(&ret);
4462  hr = IWinHttpRequest_Invoke(request, id, &IID_NULL, 0, DISPATCH_PROPERTYPUT, &params, &ret, NULL, &err);
4463  ok(hr == S_OK, "error %#x\n", hr);
4464 
4466  ok(V_VT(&ret) == VT_I4, "expected VT_I4, got %d\n", V_VT(&ret));
4467  ok(V_I4(&ret) == CP_UTF8, "expected CP_UTF8, got %d\n", V_I4(&ret));
4468 
4469  hr = IWinHttpRequest_Invoke(request, DISPID_HTTPREQUEST_OPTION, &IID_NULL, 0, DISPATCH_PROPERTYPUT, &params, NULL, NULL, NULL);
4470  ok(hr == S_OK, "error %#x\n", hr);
4471 
4472  hr = IWinHttpRequest_Invoke(request, 255, &IID_NULL, 0, DISPATCH_PROPERTYPUT, &params, NULL, NULL, NULL);
4473  ok(hr == DISP_E_MEMBERNOTFOUND, "error %#x\n", hr);
4474<