ReactOS  0.4.14-dev-77-gd9e7c48
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 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 BOOL proxy_active (void)
 
static void test_QueryOption (void)
 
static void test_OpenRequest (void)
 
static void test_empty_headers_param (void)
 
static void test_SendRequest (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 test_connection_info (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 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 2092 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

◆ cert_error()

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

Definition at line 959 of file winhttp.c.

960 {
961  DWORD flags = *(DWORD *)buf;
962 
963  if (!flags)
964  {
965  trace("WINHTTP_CALLBACK_STATUS_FLAG_SECURITY_CHANNEL_ERROR\n");
966  return;
967  }
968 #define X(x) if (flags & x) trace("%s\n", #x);
976 #undef X
977 }
#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  ,
,
,
,
,
,
,
,
,
,
,
 
)

◆ get_default_proxy_reg_value()

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

Definition at line 1208 of file winhttp.c.

1209 {
1210  LONG l;
1211  HKEY key;
1212  DWORD ret = 0;
1213 
1215  if (!l)
1216  {
1217  DWORD size = 0;
1218 
1220  if (!l)
1221  {
1222  if (size <= len)
1224  &size );
1225  if (!l)
1226  ret = size;
1227  }
1228  RegCloseKey( key );
1229  }
1230  return ret;
1231 }
static const WCHAR WinHttpSettings[]
Definition: winhttp.c:1205
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:1198
Definition: path.c:42
#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 45 of file winhttp.c.

46 {
47  WINHTTP_PROXY_INFO proxy_info;
48  BOOL active = FALSE;
49 
50  SetLastError(0xdeadbeef);
51  if (WinHttpGetDefaultProxyConfiguration(&proxy_info))
52  {
53  ok(GetLastError() == ERROR_SUCCESS || broken(GetLastError() == 0xdeadbeef) /* < win7 */,
54  "got %u\n", GetLastError());
55  active = (proxy_info.lpszProxy != NULL);
56  if (active)
57  GlobalFree(proxy_info.lpszProxy);
58  if (proxy_info.lpszProxyBypass != NULL)
59  GlobalFree(proxy_info.lpszProxyBypass);
60  }
61  else
62  active = FALSE;
63 
64  return active;
65 }
#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:409
#define broken(x)
Definition: _sntprintf.h:21
#define ok(value,...)
Definition: atltest.h:57
BOOL WINAPI WinHttpGetDefaultProxyConfiguration(WINHTTP_PROXY_INFO *info)
Definition: session.c:1503
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 3957 of file winhttp.c.

3958 {
3960  VARIANT arg;
3961  HRESULT hr;
3962 
3963  memset(&params, 0, sizeof(params));
3964  params.cNamedArgs = 0;
3965  params.rgdispidNamedArgs = NULL;
3966  params.cArgs = 1;
3967  params.rgvarg = &arg;
3968  VariantInit(&arg);
3969  V_VT(&arg) = VT_I4;
3970  V_I4(&arg) = property;
3971  VariantInit(ret);
3972  hr = IWinHttpRequest_Invoke(request, DISPID_HTTPREQUEST_OPTION, &IID_NULL, 0,
3974  ok(hr == S_OK, "error %#x\n", hr);
3975 }
Definition: compat.h:1939
#define DISPATCH_PROPERTYGET
Definition: oleauto.h:1007
HRESULT hr
Definition: shlfolder.c:183
void * arg
Definition: msvc.h:12
void WINAPI VariantInit(VARIANTARG *pVarg)
Definition: variant.c:571
#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:77
#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 2094 of file winhttp.c.

2095 {
2096  struct server_info *si = param;
2097  int r, c = -1, i, on;
2098  SOCKET s;
2099  struct sockaddr_in sa;
2100  char buffer[0x100];
2101  WSADATA wsaData;
2102  int last_request = 0;
2103 
2104  WSAStartup(MAKEWORD(1,1), &wsaData);
2105 
2106  s = socket(AF_INET, SOCK_STREAM, 0);
2107  if (s == INVALID_SOCKET)
2108  return 1;
2109 
2110  on = 1;
2111  setsockopt(s, SOL_SOCKET, SO_REUSEADDR, (char*)&on, sizeof on);
2112 
2113  memset(&sa, 0, sizeof sa);
2114  sa.sin_family = AF_INET;
2115  sa.sin_port = htons(si->port);
2116  sa.sin_addr.S_un.S_addr = inet_addr("127.0.0.1");
2117 
2118  r = bind(s, (struct sockaddr *)&sa, sizeof(sa));
2119  if (r < 0)
2120  return 1;
2121 
2122  listen(s, 0);
2123  SetEvent(si->event);
2124  do
2125  {
2126  if (c == -1) c = accept(s, NULL, NULL);
2127 
2128  memset(buffer, 0, sizeof buffer);
2129  for(i = 0; i < sizeof buffer - 1; i++)
2130  {
2131  r = recv(c, &buffer[i], 1, 0);
2132  if (r != 1)
2133  break;
2134  if (i < 4) continue;
2135  if (buffer[i - 2] == '\n' && buffer[i] == '\n' &&
2136  buffer[i - 3] == '\r' && buffer[i - 1] == '\r')
2137  break;
2138  }
2139  if (strstr(buffer, "GET /basic"))
2140  {
2141  send(c, okmsg, sizeof okmsg - 1, 0);
2142  send(c, page1, sizeof page1 - 1, 0);
2143  }
2144  if (strstr(buffer, "/auth_with_creds"))
2145  {
2146  send(c, okauthmsg, sizeof okauthmsg - 1, 0);
2147  if (strstr(buffer, "Authorization: Basic dXNlcjpwd2Q="))
2148  send(c, hello_world, sizeof hello_world - 1, 0);
2149  else
2150  send(c, auth_unseen, sizeof auth_unseen - 1, 0);
2151  continue;
2152  }
2153  if (strstr(buffer, "/auth"))
2154  {
2155  if (strstr(buffer, "Authorization: Basic dXNlcjpwd2Q="))
2156  {
2157  send(c, okauthmsg, sizeof okauthmsg - 1, 0);
2158  send(c, hello_world, sizeof hello_world - 1, 0);
2159  }
2160  else
2161  {
2162  send(c, noauthmsg, sizeof noauthmsg - 1, 0);
2163  send(c, unauthorized, sizeof unauthorized - 1, 0);
2164  }
2165  continue;
2166  }
2167  if (strstr(buffer, "/big"))
2168  {
2169  char msg[BIG_BUFFER_LEN];
2170  memset(msg, 'm', sizeof(msg));
2171  send(c, okmsg, sizeof(okmsg) - 1, 0);
2172  send(c, msg, sizeof(msg), 0);
2173  }
2174  if (strstr(buffer, "/no_headers"))
2175  {
2176  send(c, page1, sizeof page1 - 1, 0);
2177  }
2178  if (strstr(buffer, "GET /no_content"))
2179  {
2180  send(c, nocontentmsg, sizeof nocontentmsg - 1, 0);
2181  continue;
2182  }
2183  if (strstr(buffer, "GET /not_modified"))
2184  {
2185  if (strstr(buffer, "If-Modified-Since:")) send(c, notmodified, sizeof notmodified - 1, 0);
2186  else send(c, notokmsg, sizeof(notokmsg) - 1, 0);
2187  continue;
2188  }
2189  if (strstr(buffer, "HEAD /head"))
2190  {
2191  send(c, headmsg, sizeof headmsg - 1, 0);
2192  continue;
2193  }
2194  if (strstr(buffer, "GET /multiauth"))
2195  {
2196  send(c, multiauth, sizeof multiauth - 1, 0);
2197  }
2198  if (strstr(buffer, "GET /largeauth"))
2199  {
2200  if (strstr(buffer, "Authorization: NTLM"))
2201  send(c, okmsg, sizeof(okmsg) - 1, 0);
2202  else
2203  {
2204  send(c, largeauth, sizeof largeauth - 1, 0);
2205 #ifdef __REACTOS__
2206  memset(buffer, 'A', sizeof(buffer));
2207  for (i = 0; i < (10240 / sizeof(buffer)); i++) send(c, buffer, sizeof(buffer), 0);
2208 #else
2209  for (i = 0; i < 10240; i++) send(c, "A", 1, 0);
2210 #endif
2211  continue;
2212  }
2213  }
2214  if (strstr(buffer, "GET /cookie5"))
2215  {
2216  if (strstr(buffer, "Cookie: name2=value\r\n"))
2217  send(c, okmsg, sizeof(okmsg) - 1, 0);
2218  else
2219  send(c, notokmsg, sizeof(notokmsg) - 1, 0);
2220  }
2221  if (strstr(buffer, "GET /cookie4"))
2222  {
2223  send(c, cookiemsg2, sizeof(cookiemsg2) - 1, 0);
2224  }
2225  if (strstr(buffer, "GET /cookie3"))
2226  {
2227  if (strstr(buffer, "Cookie: name=value2; NAME=value; name=value\r\n") ||
2228  broken(strstr(buffer, "Cookie: name=value2; name=value; NAME=value\r\n") != NULL))
2229  send(c, okmsg, sizeof(okmsg) - 1, 0);
2230  else
2231  send(c, notokmsg, sizeof(notokmsg) - 1, 0);
2232  }
2233  if (strstr(buffer, "GET /cookie2"))
2234  {
2235  if (strstr(buffer, "Cookie: NAME=value; name=value\r\n") ||
2236  broken(strstr(buffer, "Cookie: name=value; NAME=value\r\n") != NULL))
2237  send(c, okmsg, sizeof(okmsg) - 1, 0);
2238  else
2239  send(c, notokmsg, sizeof(notokmsg) - 1, 0);
2240  }
2241  else if (strstr(buffer, "GET /cookie"))
2242  {
2243  if (!strstr(buffer, "Cookie: name=value\r\n")) send(c, cookiemsg, sizeof(cookiemsg) - 1, 0);
2244  else send(c, notokmsg, sizeof(notokmsg) - 1, 0);
2245  }
2246  if (strstr(buffer, "GET /quit"))
2247  {
2248  send(c, okmsg, sizeof okmsg - 1, 0);
2249  send(c, page1, sizeof page1 - 1, 0);
2250  last_request = 1;
2251  }
2252  shutdown(c, 2);
2253  closesocket(c);
2254  c = -1;
2255 
2256  } while (!last_request);
2257 
2258  closesocket(s);
2259  return 0;
2260 }
static const char nocontentmsg[]
Definition: winhttp.c:2032
#define BIG_BUFFER_LEN
Definition: winhttp.c:2092
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:2041
#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
static const char notokmsg[]
Definition: winhttp.c:2017
static const char cookiemsg2[]
Definition: winhttp.c:2027
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:2063
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
#define closesocket
Definition: main.c:39
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:2006
static const char headmsg[]
Definition: winhttp.c:2058
#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:2073
static const char cookiemsg[]
Definition: winhttp.c:2021
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
HANDLE event
Definition: notification.c:637
static const char notmodified[]
Definition: winhttp.c:2037
static const char okauthmsg[]
Definition: winhttp.c:2050
static const char unauthorized[]
Definition: winhttp.c:2082
static const char okmsg[]
Definition: winhttp.c:2012
static const char hello_world[]
Definition: winhttp.c:2083
INT WSAAPI listen(IN SOCKET s, IN INT backlog)
Definition: sockctrl.c:123
#define msg(x)
Definition: auth_time.c:54
#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:2084

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 1244 of file winhttp.c.

1245 {
1246  BOOL wow64;
1248  if (sizeof(void *) > sizeof(int) || wow64)
1249  {
1252  }
1253  else
1254  set_proxy( KEY_WRITE, buf, len, type );
1255 }
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:49
unsigned int BOOL
Definition: ntddk_ex.h:94
static void set_proxy(REGSAM access, BYTE *buf, DWORD len, DWORD type)
Definition: winhttp.c:1233
BOOL WINAPI IsWow64Process(IN HANDLE hProcess, OUT PBOOL Wow64Process)
Definition: proc.c:1974
#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 1233 of file winhttp.c.

1234 {
1235  HKEY hkey;
1237  {
1238  if (len) RegSetValueExW( hkey, WinHttpSettings, 0, type, buf, len );
1239  else RegDeleteValueW( hkey, WinHttpSettings );
1240  RegCloseKey( hkey );
1241  }
1242 }
static const WCHAR WinHttpSettings[]
Definition: winhttp.c:1205
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:1198
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12

Referenced by set_default_proxy_reg_value().

◆ START_TEST()

START_TEST ( winhttp  )

Definition at line 4471 of file winhttp.c.

4472 {
4473  static const WCHAR basicW[] = {'/','b','a','s','i','c',0};
4474  static const WCHAR quitW[] = {'/','q','u','i','t',0};
4475  struct server_info si;
4476  HANDLE thread;
4477  DWORD ret;
4478 
4479  test_OpenRequest();
4480  test_SendRequest();
4486  test_QueryOption();
4489  test_Timeouts();
4491  test_credentials();
4497 
4498  si.event = CreateEventW(NULL, 0, 0, NULL);
4499  si.port = 7532;
4500 
4501  thread = CreateThread(NULL, 0, server_thread, (LPVOID)&si, 0, NULL);
4502  ok(thread != NULL, "failed to create thread %u\n", GetLastError());
4503 
4504  ret = WaitForSingleObject(si.event, 10000);
4505  ok(ret == WAIT_OBJECT_0, "failed to start winhttp test server %u\n", GetLastError());
4506  if (ret != WAIT_OBJECT_0)
4507  {
4509  return;
4510  }
4511 
4512  test_IWinHttpRequest(si.port);
4513  test_connection_info(si.port);
4514  test_basic_request(si.port, NULL, basicW);
4515  test_no_headers(si.port);
4516  test_no_content(si.port);
4517  test_head_request(si.port);
4518  test_not_modified(si.port);
4519  test_basic_authentication(si.port);
4520  test_multi_authentication(si.port);
4522  test_bad_header(si.port);
4523  test_multiple_reads(si.port);
4524  test_cookies(si.port);
4525 
4526  /* send the basic request again to shutdown the server thread */
4527  test_basic_request(si.port, NULL, quitW);
4528 
4529  WaitForSingleObject(thread, 3000);
4531 }
static const WCHAR basicW[]
static void test_basic_authentication(int port)
Definition: winhttp.c:2354
#define CloseHandle
Definition: compat.h:398
static void test_WinHttpGetIEProxyConfigForCurrentUser(void)
Definition: winhttp.c:4253
static void test_QueryOption(void)
Definition: winhttp.c:67
static void test_no_headers(int port)
Definition: winhttp.c:2718
static void test_WinHttpTimeToSystemTime(void)
Definition: winhttp.c:445
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
static void test_IWinHttpRequest(int port)
Definition: winhttp.c:3381
static void test_cookies(int port)
Definition: winhttp.c:3040
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:2262
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
static void test_resolve_timeout(void)
Definition: winhttp.c:1939
static void test_multi_authentication(int port)
Definition: winhttp.c:2631
static void test_WinHttpDetectAutoProxyConfigUrl(void)
Definition: winhttp.c:4192
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:2954
smooth NULL
Definition: ftsmooth.c:416
static void test_not_modified(int port)
Definition: winhttp.c:2897
static void test_set_default_proxy_config(void)
Definition: winhttp.c:1257
static DWORD CALLBACK server_thread(LPVOID param)
Definition: winhttp.c:2094
static void test_head_request(int port)
Definition: winhttp.c:2838
#define WAIT_OBJECT_0
Definition: winbase.h:387
static void test_no_content(int port)
Definition: winhttp.c:2754
__wchar_t WCHAR
Definition: xmlstorage.h:180
static void test_Timeouts(void)
Definition: winhttp.c:1345
unsigned long DWORD
Definition: ntddk_ex.h:95
static void test_multiple_reads(int port)
Definition: winhttp.c:2991
static void test_OpenRequest(void)
Definition: winhttp.c:217
static HANDLE thread
Definition: service.c:33
static void test_credentials(void)
Definition: winhttp.c:3260
static void test_empty_headers_param(void)
Definition: winhttp.c:281
int ret
static void test_request_parameter_defaults(void)
Definition: winhttp.c:1116
static void test_IWinHttpRequest_Invoke(void)
Definition: winhttp.c:3977
#define ok(value,...)
Definition: atltest.h:57
static void test_WinHttpGetProxyForUrl(void)
Definition: winhttp.c:4282
static void test_large_data_authentication(int port)
Definition: winhttp.c:2667
static void test_SendRequest(void)
Definition: winhttp.c:312
static void test_connection_info(int port)
Definition: winhttp.c:3201
static void test_chunked_read(void)
Definition: winhttp.c:4389
static void test_secure_connection(void)
Definition: winhttp.c:979
static void test_WinHttpAddHeaders(void)
Definition: winhttp.c:487
static void test_WinHttpTimeFromSystemTime(void)
Definition: winhttp.c:414

◆ test_bad_header()

static void test_bad_header ( int  port)
static

Definition at line 2954 of file winhttp.c.

2955 {
2956  static const WCHAR bad_headerW[] =
2957  {'C','o','n','t','e','n','t','-','T','y','p','e',':',' ',
2958  't','e','x','t','/','h','t','m','l','\n','\r',0};
2959  static const WCHAR text_htmlW[] = {'t','e','x','t','/','h','t','m','l',0};
2960  static const WCHAR content_typeW[] = {'C','o','n','t','e','n','t','-','T','y','p','e',0};
2961  WCHAR buffer[32];
2962  HINTERNET ses, con, req;
2963  DWORD index, len;
2964  BOOL ret;
2965 
2967  ok( ses != NULL, "failed to open session %u\n", GetLastError() );
2968 
2969  con = WinHttpConnect( ses, localhostW, port, 0 );
2970  ok( con != NULL, "failed to open a connection %u\n", GetLastError() );
2971 
2972  req = WinHttpOpenRequest( con, NULL, NULL, NULL, NULL, NULL, 0 );
2973  ok( req != NULL, "failed to open a request %u\n", GetLastError() );
2974 
2975  ret = WinHttpAddRequestHeaders( req, bad_headerW, ~0u, WINHTTP_ADDREQ_FLAG_ADD );
2976  ok( ret, "failed to add header %u\n", GetLastError() );
2977 
2978  index = 0;
2979  buffer[0] = 0;
2980  len = sizeof(buffer);
2982  content_typeW, buffer, &len, &index );
2983  ok( ret, "failed to query headers %u\n", GetLastError() );
2984  ok( !lstrcmpW( buffer, text_htmlW ), "got %s\n", wine_dbgstr_w(buffer) );
2985 
2986  WinHttpCloseHandle( req );
2987  WinHttpCloseHandle( con );
2988  WinHttpCloseHandle( ses );
2989 }
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:524
BOOL WINAPI WinHttpCloseHandle(HINTERNET handle)
Definition: session.c:1153
#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:831
unsigned int BOOL
Definition: ntddk_ex.h:94
static const WCHAR test_useragent[]
Definition: winhttp.c:39
#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:521
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:43
HINTERNET WINAPI WinHttpOpen(LPCWSTR agent, DWORD access, LPCWSTR proxy, LPCWSTR bypass, DWORD flags)
Definition: session.c:246
HINTERNET WINAPI WinHttpOpenRequest(HINTERNET hconnect, LPCWSTR verb, LPCWSTR object, LPCWSTR version, LPCWSTR referrer, LPCWSTR *types, DWORD flags)
Definition: session.c:1061
USHORT port
Definition: uri.c:227

Referenced by START_TEST().

◆ test_basic_authentication()

static void test_basic_authentication ( int  port)
static

Definition at line 2354 of file winhttp.c.

2355 {
2356  static const WCHAR authW[] = {'/','a','u','t','h',0};
2357  static const WCHAR auth_with_credsW[] = {'/','a','u','t','h','_','w','i','t','h','_','c','r','e','d','s',0};
2358  static WCHAR userW[] = {'u','s','e','r',0};
2359  static WCHAR passW[] = {'p','w','d',0};
2360  static WCHAR pass2W[] = {'p','w','d','2',0};
2361  HINTERNET ses, con, req;
2362  DWORD status, size, error, supported, first, target;
2363  char buffer[32];
2364  BOOL ret;
2365 
2367  ok(ses != NULL, "failed to open session %u\n", GetLastError());
2368 
2369  con = WinHttpConnect(ses, localhostW, port, 0);
2370  ok(con != NULL, "failed to open a connection %u\n", GetLastError());
2371 
2372  req = WinHttpOpenRequest(con, NULL, authW, NULL, NULL, NULL, 0);
2373  ok(req != NULL, "failed to open a request %u\n", GetLastError());
2374 
2375  SetLastError(0xdeadbeef);
2377  error = GetLastError();
2378  ok(!ret, "expected failure\n");
2379  ok(error == ERROR_INVALID_HANDLE, "expected ERROR_INVALID_HANDLE, got %u\n", error);
2380 
2381  SetLastError(0xdeadbeef);
2383  error = GetLastError();
2384  ok(!ret, "expected failure\n");
2386 
2387  supported = 0xdeadbeef;
2388  SetLastError(0xdeadbeef);
2389  ret = WinHttpQueryAuthSchemes(req, &supported, NULL, NULL);
2390  error = GetLastError();
2391  ok(!ret, "expected failure\n");
2393  ok(supported == 0xdeadbeef, "got %x\n", supported);
2394 
2395  supported = first = 0xdeadbeef;
2396  SetLastError(0xdeadbeef);
2397  ret = WinHttpQueryAuthSchemes(req, &supported, &first, NULL);
2398  error = GetLastError();
2399  ok(!ret, "expected failure\n");
2401  ok(supported == 0xdeadbeef, "got %x\n", supported);
2402  ok(first == 0xdeadbeef, "got %x\n", first);
2403 
2404  supported = first = target = 0xdeadbeef;
2405  SetLastError(0xdeadbeef);
2406  ret = WinHttpQueryAuthSchemes(req, &supported, &first, &target);
2407  error = GetLastError();
2408  ok(!ret, "expected failure\n");
2409  todo_wine ok(error == ERROR_INVALID_OPERATION, "expected ERROR_INVALID_OPERATION, got %u\n", error);
2410  ok(supported == 0xdeadbeef, "got %x\n", supported);
2411  ok(first == 0xdeadbeef, "got %x\n", first);
2412  ok(target == 0xdeadbeef, "got %x\n", target);
2413 
2414  supported = first = target = 0xdeadbeef;
2415  SetLastError(0xdeadbeef);
2416  ret = WinHttpQueryAuthSchemes(NULL, &supported, &first, &target);
2417  error = GetLastError();
2418  ok(!ret, "expected failure\n");
2419  ok(error == ERROR_INVALID_HANDLE, "expected ERROR_INVALID_HANDLE, got %u\n", error);
2420  ok(supported == 0xdeadbeef, "got %x\n", supported);
2421  ok(first == 0xdeadbeef, "got %x\n", first);
2422  ok(target == 0xdeadbeef, "got %x\n", target);
2423 
2424  ret = WinHttpSendRequest(req, NULL, 0, NULL, 0, 0, 0);
2425  ok(ret, "failed to send request %u\n", GetLastError());
2426 
2428  ok(ret, "failed to receive response %u\n", GetLastError());
2429 
2430  status = 0xdeadbeef;
2431  size = sizeof(status);
2433  ok(ret, "failed to query status code %u\n", GetLastError());
2434  ok(status == HTTP_STATUS_DENIED, "request failed unexpectedly %u\n", status);
2435 
2436  size = 0;
2437  ret = WinHttpReadData(req, buffer, sizeof(buffer), &size);
2438  error = GetLastError();
2439  ok(ret || broken(error == ERROR_WINHTTP_SHUTDOWN || error == ERROR_WINHTTP_TIMEOUT) /* XP */, "failed to read data %u\n", GetLastError());
2440  if (ret)
2441  {
2442  ok(size == 12, "expected 12, got %u\n", size);
2443  ok(!memcmp(buffer, unauthorized, 12), "got %s\n", buffer);
2444  }
2445 
2446  supported = first = target = 0xdeadbeef;
2447  SetLastError(0xdeadbeef);
2448  ret = WinHttpQueryAuthSchemes(req, &supported, &first, &target);
2449  error = GetLastError();
2450  ok(ret, "failed to query authentication schemes %u\n", error);
2451  ok(error == ERROR_SUCCESS || broken(error == 0xdeadbeef) /* < win7 */, "expected ERROR_SUCCESS, got %u\n", error);
2452  ok(supported == WINHTTP_AUTH_SCHEME_BASIC, "got %x\n", supported);
2453  ok(first == WINHTTP_AUTH_SCHEME_BASIC, "got %x\n", first);
2454  ok(target == WINHTTP_AUTH_TARGET_SERVER, "got %x\n", target);
2455 
2456  SetLastError(0xdeadbeef);
2458  error = GetLastError();
2459  ok(ret, "failed to set credentials %u\n", error);
2460  ok(error == ERROR_SUCCESS || broken(error == 0xdeadbeef) /* < win7 */, "expected ERROR_SUCCESS, got %u\n", error);
2461 
2463  ok(ret, "failed to set credentials %u\n", GetLastError());
2464 
2466  ok(ret, "failed to set credentials %u\n", GetLastError());
2467 
2468  SetLastError(0xdeadbeef);
2470  error = GetLastError();
2471  ok(!ret, "expected failure\n");
2472  ok(error == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %u\n", error);
2473 
2474  SetLastError(0xdeadbeef);
2476  error = GetLastError();
2477  ok(!ret, "expected failure\n");
2478  ok(error == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %u\n", error);
2479 
2480  SetLastError(0xdeadbeef);
2482  error = GetLastError();
2483  ok(!ret, "expected failure\n");
2484  ok(error == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %u\n", error);
2485 
2486  SetLastError(0xdeadbeef);
2488  error = GetLastError();
2489  ok(!ret, "expected failure\n");
2490  ok(error == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %u\n", error);
2491 
2493  ok(ret, "failed to set credentials %u\n", GetLastError());
2494 
2495  ret = WinHttpSendRequest(req, NULL, 0, NULL, 0, 0, 0);
2496  ok(ret, "failed to send request %u\n", GetLastError());
2497 
2499  ok(ret, "failed to receive response %u\n", GetLastError());
2500 
2501  status = 0xdeadbeef;
2502  size = sizeof(status);
2504  ok(ret, "failed to query status code %u\n", GetLastError());
2505  ok(status == HTTP_STATUS_OK, "request failed unexpectedly %u\n", status);
2506 
2507  size = 0;
2508  ret = WinHttpReadData(req, buffer, sizeof(buffer), &size);
2509  error = GetLastError();
2510  ok(ret || broken(error == ERROR_WINHTTP_SHUTDOWN || error == ERROR_WINHTTP_TIMEOUT) /* XP */, "failed to read data %u\n", GetLastError());
2511  if (ret)
2512  {
2513  ok(size == 11, "expected 11, got %u\n", size);
2514  ok(!memcmp(buffer, hello_world, 11), "got %s\n", buffer);
2515  }
2516 
2517  WinHttpCloseHandle(req);
2518  WinHttpCloseHandle(con);
2519  WinHttpCloseHandle(ses);
2520 
2521  /* now set the credentials first to show that they get sent with the first request */
2523  ok(ses != NULL, "failed to open session %u\n", GetLastError());
2524 
2525  con = WinHttpConnect(ses, localhostW, port, 0);
2526  ok(con != NULL, "failed to open a connection %u\n", GetLastError());
2527 
2528  req = WinHttpOpenRequest(con, NULL, auth_with_credsW, NULL, NULL, NULL, 0);
2529  ok(req != NULL, "failed to open a request %u\n", GetLastError());
2530 
2532  ok(ret, "failed to set credentials %u\n", GetLastError());
2533 
2534  ret = WinHttpSendRequest(req, NULL, 0, NULL, 0, 0, 0);
2535  ok(ret, "failed to send request %u\n", GetLastError());
2536 
2538  ok(ret, "failed to receive response %u\n", GetLastError());
2539 
2540  status = 0xdeadbeef;
2541  size = sizeof(status);
2543  ok(ret, "failed to query status code %u\n", GetLastError());
2544  ok(status == HTTP_STATUS_OK, "request failed unexpectedly %u\n", status);
2545 
2546  size = 0;
2547  ret = WinHttpReadData(req, buffer, sizeof(buffer), &size);
2548  error = GetLastError();
2549  ok(ret || broken(error == ERROR_WINHTTP_SHUTDOWN || error == ERROR_WINHTTP_TIMEOUT) /* XP */, "failed to read data %u\n", GetLastError());
2550  if (ret)
2551  {
2552  ok(size == 11, "expected 11, got %u\n", size);
2553  ok(!memcmp(buffer, hello_world, 11), "got %s\n", buffer);
2554  }
2555 
2556  WinHttpCloseHandle(req);
2557  WinHttpCloseHandle(con);
2558  WinHttpCloseHandle(ses);
2559 
2560  /* credentials set with WinHttpSetCredentials take precedence over those set through options */
2561 
2563  ok(ses != NULL, "failed to open session %u\n", GetLastError());
2564 
2565  con = WinHttpConnect(ses, localhostW, port, 0);
2566  ok(con != NULL, "failed to open a connection %u\n", GetLastError());
2567 
2568  req = WinHttpOpenRequest(con, NULL, authW, NULL, NULL, NULL, 0);
2569  ok(req != NULL, "failed to open a request %u\n", GetLastError());
2570 
2572  ok(ret, "failed to set credentials %u\n", GetLastError());
2573 
2574  ret = WinHttpSetOption(req, WINHTTP_OPTION_USERNAME, userW, lstrlenW(userW));
2575  ok(ret, "failed to set username %u\n", GetLastError());
2576 
2577  ret = WinHttpSetOption(req, WINHTTP_OPTION_PASSWORD, pass2W, lstrlenW(pass2W));
2578  ok(ret, "failed to set password %u\n", GetLastError());
2579 
2580  ret = WinHttpSendRequest(req, NULL, 0, NULL, 0, 0, 0);
2581  ok(ret, "failed to send request %u\n", GetLastError());
2582 
2584  ok(ret, "failed to receive response %u\n", GetLastError());
2585 
2586  status = 0xdeadbeef;
2587  size = sizeof(status);
2589  ok(ret, "failed to query status code %u\n", GetLastError());
2590  ok(status == HTTP_STATUS_OK, "request failed unexpectedly %u\n", status);
2591 
2592  WinHttpCloseHandle(req);
2593  WinHttpCloseHandle(con);
2594  WinHttpCloseHandle(ses);
2595 
2597  ok(ses != NULL, "failed to open session %u\n", GetLastError());
2598 
2599  con = WinHttpConnect(ses, localhostW, port, 0);
2600  ok(con != NULL, "failed to open a connection %u\n", GetLastError());
2601 
2602  req = WinHttpOpenRequest(con, NULL, authW, NULL, NULL, NULL, 0);
2603  ok(req != NULL, "failed to open a request %u\n", GetLastError());
2604 
2605  ret = WinHttpSetOption(req, WINHTTP_OPTION_USERNAME, userW, lstrlenW(userW));
2606  ok(ret, "failed to set username %u\n", GetLastError());
2607 
2608  ret = WinHttpSetOption(req, WINHTTP_OPTION_PASSWORD, passW, lstrlenW(passW));
2609  ok(ret, "failed to set password %u\n", GetLastError());
2610 
2612  ok(ret, "failed to set credentials %u\n", GetLastError());
2613 
2614  ret = WinHttpSendRequest(req, NULL, 0, NULL, 0, 0, 0);
2615  ok(ret, "failed to send request %u\n", GetLastError());
2616 
2618  ok(ret, "failed to receive response %u\n", GetLastError());
2619 
2620  status = 0xdeadbeef;
2621  size = sizeof(status);
2623  ok(ret, "failed to query status code %u\n", GetLastError());
2624  ok(status == HTTP_STATUS_DENIED, "request failed unexpectedly %u\n", status);
2625 
2626  WinHttpCloseHandle(req);
2627  WinHttpCloseHandle(con);
2628  WinHttpCloseHandle(ses);
2629 }
HINTERNET WINAPI WinHttpConnect(HINTERNET hsession, LPCWSTR server, INTERNET_PORT port, DWORD reserved)
Definition: session.c:524
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
BOOL WINAPI WinHttpCloseHandle(HINTERNET handle)
Definition: session.c:1153
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:944
#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:407
#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:831
unsigned int BOOL
Definition: ntddk_ex.h:94
static const WCHAR test_useragent[]
Definition: winhttp.c:39
BOOL WINAPI WinHttpReceiveResponse(HINTERNET hrequest, LPVOID reserved)
Definition: request.c:2692
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:409
#define ERROR_WINHTTP_SHUTDOWN
Definition: winhttp.h:196
int ret
#define WINHTTP_AUTH_SCHEME_NEGOTIATE
Definition: winhttp.h:456
#define todo_wine
Definition: test.h:154
BOOL WINAPI WinHttpSetCredentials(HINTERNET hrequest, DWORD target, DWORD scheme, LPCWSTR username, LPCWSTR password, LPVOID params)
Definition: request.c:2260
#define WINHTTP_AUTH_SCHEME_BASIC
Definition: winhttp.h:452
BOOL WINAPI WinHttpSetOption(HINTERNET handle, DWORD option, LPVOID buffer, DWORD buflen)
Definition: session.c:1270
#define broken(x)
Definition: _sntprintf.h:21
static const char unauthorized[]
Definition: winhttp.c:2082
#define ok(value,...)
Definition: atltest.h:57
static const char hello_world[]
Definition: winhttp.c:2083
#define ERROR_INVALID_OPERATION
Definition: winerror.h:1261
static const WCHAR localhostW[]
Definition: winhttp.c:43
HINTERNET WINAPI WinHttpOpen(LPCWSTR agent, DWORD access, LPCWSTR proxy, LPCWSTR bypass, DWORD flags)
Definition: session.c:246
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:1061
USHORT port
Definition: uri.c:227
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:2168
BOOL WINAPI WinHttpReadData(HINTERNET hrequest, LPVOID buffer, DWORD to_read, LPDWORD read)
Definition: request.c:2811
#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 2262 of file winhttp.c.

2263 {
2264  static const WCHAR test_header_end_clrf[] = {'\r','\n','\r','\n',0};
2265  static const WCHAR test_header_end_raw[] = {0,0};
2266  HINTERNET ses, con, req;
2267  char buffer[0x100];
2268  WCHAR buffer2[0x100];
2269  DWORD count, status, size, error, supported, first, target;
2270  BOOL ret;
2271 
2273  ok(ses != NULL, "failed to open session %u\n", GetLastError());
2274 
2275  SetLastError(0xdeadbeef);
2276  ret = WinHttpSetOption(ses, 0, buffer, sizeof(buffer));
2277  ok(!ret && GetLastError() == ERROR_WINHTTP_INVALID_OPTION, "got %u\n", GetLastError());
2278 
2279  SetLastError(0xdeadbeef);
2280  ret = WinHttpQueryOption(ses, 0, buffer, &size);
2281  ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, "got %u\n", GetLastError());
2282 
2283  con = WinHttpConnect(ses, localhostW, port, 0);
2284  ok(con != NULL, "failed to open a connection %u\n", GetLastError());
2285 
2286  SetLastError(0xdeadbeef);
2287  ret = WinHttpSetOption(con, 0, buffer, sizeof(buffer));
2289 
2290  SetLastError(0xdeadbeef);
2291  ret = WinHttpQueryOption(con, 0, buffer, &size);
2292  ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, "got %u\n", GetLastError());
2293 
2294  req = WinHttpOpenRequest(con, verb, path, NULL, NULL, NULL, 0);
2295  ok(req != NULL, "failed to open a request %u\n", GetLastError());
2296 
2297  SetLastError(0xdeadbeef);
2298  ret = WinHttpSetOption(req, 0, buffer, sizeof(buffer));
2299  ok(!ret && GetLastError() == ERROR_WINHTTP_INVALID_OPTION, "got %u\n", GetLastError());
2300 
2301  SetLastError(0xdeadbeef);
2302  ret = WinHttpQueryOption(req, 0, buffer, &size);
2303  ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, "got %u\n", GetLastError());
2304 
2305  ret = WinHttpSendRequest(req, NULL, 0, NULL, 0, 0, 0);
2306  ok(ret, "failed to send request %u\n", GetLastError());
2307 
2309  ok(ret, "failed to receive response %u\n", GetLastError());
2310 
2311  status = 0xdeadbeef;
2312  size = sizeof(status);
2314  ok(ret, "failed to query status code %u\n", GetLastError());
2315  ok(status == HTTP_STATUS_OK, "request failed unexpectedly %u\n", status);
2316 
2317  supported = first = target = 0xdeadbeef;
2318  SetLastError(0xdeadbeef);
2319  ret = WinHttpQueryAuthSchemes(req, &supported, &first, &target);
2320  error = GetLastError();
2321  ok(!ret, "unexpected success\n");
2322  todo_wine ok(error == ERROR_INVALID_OPERATION, "expected ERROR_INVALID_OPERATION, got %u\n", error);
2323  ok(supported == 0xdeadbeef, "got %x\n", supported);
2324  ok(first == 0xdeadbeef, "got %x\n", first);
2325  ok(target == 0xdeadbeef, "got %x\n", target);
2326 
2327  size = sizeof(buffer2);
2328  memset(buffer2, 0, sizeof(buffer2));
2330  ok(ret, "failed to query for raw headers: %u\n", GetLastError());
2331  ok(!memcmp(buffer2 + lstrlenW(buffer2) - 4, test_header_end_clrf, sizeof(test_header_end_clrf)),
2332  "WinHttpQueryHeaders returned invalid end of header string\n");
2333 
2334  size = sizeof(buffer2);
2335  memset(buffer2, 0, sizeof(buffer2));
2337  ok(ret, "failed to query for raw headers: %u\n", GetLastError());
2338  ok(!memcmp(buffer2 + (size / sizeof(WCHAR)) - 1, test_header_end_raw, sizeof(test_header_end_raw)),
2339  "WinHttpQueryHeaders returned invalid end of header string\n");
2340  ok(buffer2[(size / sizeof(WCHAR)) - 2] != 0, "returned string has too many NULL characters\n");
2341 
2342  count = 0;
2343  memset(buffer, 0, sizeof(buffer));
2344  ret = WinHttpReadData(req, buffer, sizeof buffer, &count);
2345  ok(ret, "failed to read data %u\n", GetLastError());
2346  ok(count == sizeof page1 - 1, "count was wrong\n");
2347  ok(!memcmp(buffer, page1, sizeof page1), "http data wrong\n");
2348 
2349  WinHttpCloseHandle(req);
2350  WinHttpCloseHandle(con);
2351  WinHttpCloseHandle(ses);
2352 }
HINTERNET WINAPI WinHttpConnect(HINTERNET hsession, LPCWSTR server, INTERNET_PORT port, DWORD reserved)
Definition: session.c:524
#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:1211
BOOL WINAPI WinHttpCloseHandle(HINTERNET handle)
Definition: session.c:1153
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:944
#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:407
BOOL WINAPI WinHttpQueryHeaders(HINTERNET hrequest, DWORD level, LPCWSTR name, LPVOID buffer, LPDWORD buflen, LPDWORD index)
Definition: request.c:831
unsigned int BOOL
Definition: ntddk_ex.h:94
static const WCHAR test_useragent[]
Definition: winhttp.c:39
BOOL WINAPI WinHttpReceiveResponse(HINTERNET hrequest, LPVOID reserved)
Definition: request.c:2692
smooth NULL
Definition: ftsmooth.c:416
static const char page1[]
Definition: winhttp.c:2006
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:409
int ret
#define todo_wine
Definition: test.h:154
BOOL WINAPI WinHttpSetOption(HINTERNET handle, DWORD option, LPVOID buffer, DWORD buflen)
Definition: session.c:1270
#define ok(value,...)
Definition: atltest.h:57
Definition: services.c:325
#define ERROR_INVALID_OPERATION
Definition: winerror.h:1261
static const WCHAR localhostW[]
Definition: winhttp.c:43
HINTERNET WINAPI WinHttpOpen(LPCWSTR agent, DWORD access, LPCWSTR proxy, LPCWSTR bypass, DWORD flags)
Definition: session.c:246
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:1061
USHORT port
Definition: uri.c:227
#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:2168
#define ERROR_WINHTTP_INVALID_OPTION
Definition: winhttp.h:194
BOOL WINAPI WinHttpReadData(HINTERNET hrequest, LPVOID buffer, DWORD to_read, LPDWORD read)
Definition: request.c:2811
Definition: ps.c:97

Referenced by START_TEST().

◆ test_chunked_read()

static void test_chunked_read ( void  )
static

Definition at line 4389 of file winhttp.c.

4390 {
4391  static const WCHAR verb[] = {'/','t','e','s','t','c','h','u','n','k','e','d',0};
4392  static const WCHAR chunked[] = {'c','h','u','n','k','e','d',0};
4393  WCHAR header[32];
4394  DWORD len, err;
4395  HINTERNET ses, con = NULL, req = NULL;
4396  BOOL ret;
4397 
4398  trace( "starting chunked read test\n" );
4399 
4400  ses = WinHttpOpen( test_useragent, 0, NULL, NULL, 0 );
4401  ok( ses != NULL, "WinHttpOpen failed with error %u\n", GetLastError() );
4402  if (!ses) goto done;
4403 
4404  con = WinHttpConnect( ses, test_winehq, 0, 0 );
4405  ok( con != NULL, "WinHttpConnect failed with error %u\n", GetLastError() );
4406  if (!con) goto done;
4407 
4408  req = WinHttpOpenRequest( con, NULL, verb, NULL, NULL, NULL, 0 );
4409  ok( req != NULL, "WinHttpOpenRequest failed with error %u\n", GetLastError() );
4410  if (!req) goto done;
4411 
4412  ret = WinHttpSendRequest( req, NULL, 0, NULL, 0, 0, 0 );
4413  err = GetLastError();
4415  {
4416  skip("connection failed, skipping\n");
4417  goto done;
4418  }
4419  ok( ret, "WinHttpSendRequest failed with error %u\n", GetLastError() );
4420 
4421  ret = WinHttpReceiveResponse( req, NULL );
4422  ok( ret, "WinHttpReceiveResponse failed with error %u\n", GetLastError() );
4423 
4424  header[0] = 0;
4425  len = sizeof(header);
4427  ok( ret, "failed to get TRANSFER_ENCODING header (error %u)\n", GetLastError() );
4428  ok( !lstrcmpW( header, chunked ), "wrong transfer encoding %s\n", wine_dbgstr_w(header) );
4429  trace( "transfer encoding: %s\n", wine_dbgstr_w(header) );
4430 
4431  header[0] = 0;
4432  len = sizeof(header);
4433  SetLastError( 0xdeadbeef );
4435  ok( !ret, "unexpected CONTENT_LENGTH header %s\n", wine_dbgstr_w(header) );
4436  ok( GetLastError() == ERROR_WINHTTP_HEADER_NOT_FOUND, "wrong error %u\n", GetLastError() );
4437 
4438  trace( "entering query loop\n" );
4439  for (;;)
4440  {
4441  len = 0xdeadbeef;
4442  ret = WinHttpQueryDataAvailable( req, &len );
4443  ok( ret, "WinHttpQueryDataAvailable failed with error %u\n", GetLastError() );
4444  if (ret) ok( len != 0xdeadbeef, "WinHttpQueryDataAvailable return wrong length\n" );
4445  trace( "got %u available\n", len );
4446  if (len)
4447  {
4448  DWORD bytes_read;
4449  char *buf = HeapAlloc( GetProcessHeap(), 0, len + 1 );
4450 
4451  ret = WinHttpReadData( req, buf, len, &bytes_read );
4452 
4453  buf[bytes_read] = 0;
4454  trace( "WinHttpReadData -> %d %u\n", ret, bytes_read );
4455  ok( len == bytes_read, "only got %u of %u available\n", bytes_read, len );
4456  ok( buf[bytes_read - 1] == '\n', "received partial line '%s'\n", buf );
4457 
4458  HeapFree( GetProcessHeap(), 0, buf );
4459  if (!bytes_read) break;
4460  }
4461  if (!len) break;
4462  }
4463  trace( "done\n" );
4464 
4465 done:
4466  if (req) WinHttpCloseHandle( req );
4467  if (con) WinHttpCloseHandle( con );
4468  if (ses) WinHttpCloseHandle( ses );
4469 }
HINTERNET WINAPI WinHttpConnect(HINTERNET hsession, LPCWSTR server, INTERNET_PORT port, DWORD reserved)
Definition: session.c:524
BOOL WINAPI WinHttpCloseHandle(HINTERNET handle)
Definition: session.c:1153
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:831
unsigned int BOOL
Definition: ntddk_ex.h:94
static const WCHAR test_useragent[]
Definition: winhttp.c:39
BOOL WINAPI WinHttpReceiveResponse(HINTERNET hrequest, LPVOID reserved)
Definition: request.c:2692
smooth NULL
Definition: ftsmooth.c:416
#define GetProcessHeap()
Definition: compat.h:395
#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:409
#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:41
#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:246
#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:1061
BOOL WINAPI WinHttpSendRequest(HINTERNET hrequest, LPCWSTR headers, DWORD headers_len, LPVOID optional, DWORD optional_len, DWORD total_len, DWORD_PTR context)
Definition: request.c:2168
BOOL WINAPI WinHttpQueryDataAvailable(HINTERNET hrequest, LPDWORD available)
Definition: request.c:2763
#define HeapFree(x, y, z)
Definition: compat.h:394
struct CFHEADER header
Definition: fdi.c:109
BOOL WINAPI WinHttpReadData(HINTERNET hrequest, LPVOID buffer, DWORD to_read, LPDWORD read)
Definition: request.c:2811

Referenced by START_TEST().

◆ test_connection_info()

static void test_connection_info ( int  port)
static

Definition at line 3201 of file winhttp.c.

3202 {
3203  static const WCHAR basicW[] = {'/','b','a','s','i','c',0};
3204  HINTERNET ses, con, req;
3205  WINHTTP_CONNECTION_INFO info;
3206  DWORD size, error;
3207  BOOL ret;
3208 
3210  ok( ses != NULL, "failed to open session %u\n", GetLastError() );
3211 
3212  con = WinHttpConnect( ses, localhostW, port, 0 );
3213  ok( con != NULL, "failed to open a connection %u\n", GetLastError() );
3214 
3215  req = WinHttpOpenRequest( con, NULL, basicW, NULL, NULL, NULL, 0 );
3216  ok( req != NULL, "failed to open a request %u\n", GetLastError() );
3217 
3218  size = sizeof(info);
3219  SetLastError( 0xdeadbeef );
3221  error = GetLastError();
3222  if (!ret && error == ERROR_INVALID_PARAMETER)
3223  {
3224  win_skip( "WINHTTP_OPTION_CONNECTION_INFO not supported\n" );
3225  return;
3226  }
3227  ok( !ret, "unexpected success\n" );
3229 
3230  ret = WinHttpSendRequest( req, NULL, 0, NULL, 0, 0, 0 );
3231  ok( ret, "failed to send request %u\n", GetLastError() );
3232 
3233  size = 0;
3234  SetLastError( 0xdeadbeef );
3236  error = GetLastError();
3237  ok( !ret, "unexpected success\n" );
3238  ok( error == ERROR_INSUFFICIENT_BUFFER, "got %u\n", error );
3239 
3240  size = sizeof(info);
3241  memset( &info, 0, sizeof(info) );
3243  ok( ret, "failed to retrieve connection info %u\n", GetLastError() );
3244  ok( info.cbSize == sizeof(info) || info.cbSize == sizeof(info) - sizeof(info.cbSize) /* Win7 */, "wrong size %u\n", info.cbSize );
3245 
3246  ret = WinHttpReceiveResponse( req, NULL );
3247  ok( ret, "failed to receive response %u\n", GetLastError() );
3248 
3249  size = sizeof(info);
3250  memset( &info, 0, sizeof(info) );
3252  ok( ret, "failed to retrieve connection info %u\n", GetLastError() );
3253  ok( info.cbSize == sizeof(info) || info.cbSize == sizeof(info) - sizeof(info.cbSize) /* Win7 */, "wrong size %u\n", info.cbSize );
3254 
3255  WinHttpCloseHandle( req );
3256  WinHttpCloseHandle( con );
3257  WinHttpCloseHandle( ses );
3258 }
HINTERNET WINAPI WinHttpConnect(HINTERNET hsession, LPCWSTR server, INTERNET_PORT port, DWORD reserved)
Definition: session.c:524
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:1211
BOOL WINAPI WinHttpCloseHandle(HINTERNET handle)
Definition: session.c:1153
#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:39
BOOL WINAPI WinHttpReceiveResponse(HINTERNET hrequest, LPVOID reserved)
Definition: request.c:2692
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:409
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:43
HINTERNET WINAPI WinHttpOpen(LPCWSTR agent, DWORD access, LPCWSTR proxy, LPCWSTR bypass, DWORD flags)
Definition: session.c:246
#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:1061
USHORT port
Definition: uri.c:227
#define memset(x, y, z)
Definition: compat.h:39
#define win_skip
Definition: test.h:141
BOOL WINAPI WinHttpSendRequest(HINTERNET hrequest, LPCWSTR headers, DWORD headers_len, LPVOID optional, DWORD optional_len, DWORD total_len, DWORD_PTR context)
Definition: request.c:2168
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10

Referenced by START_TEST().

◆ test_cookies()

static void test_cookies ( int  port)
static

Definition at line 3040 of file winhttp.c.

3041 {
3042  static const WCHAR cookieW[] = {'/','c','o','o','k','i','e',0};
3043  static const WCHAR cookie2W[] = {'/','c','o','o','k','i','e','2',0};
3044  static const WCHAR cookie3W[] = {'/','c','o','o','k','i','e','3',0};
3045  static const WCHAR cookie4W[] = {'/','c','o','o','k','i','e','4',0};
3046  static const WCHAR cookie5W[] = {'/','c','o','o','k','i','e','5',0};
3047  static const WCHAR cookieheaderW[] =
3048  {'C','o','o','k','i','e',':',' ','n','a','m','e','=','v','a','l','u','e','2','\r','\n',0};
3049  HINTERNET ses, con, req;
3050  DWORD status, size;
3051  BOOL ret;
3052 
3054  ok( ses != NULL, "failed to open session %u\n", GetLastError() );
3055 
3056  con = WinHttpConnect( ses, localhostW, port, 0 );
3057  ok( con != NULL, "failed to open a connection %u\n", GetLastError() );
3058 
3059  req = WinHttpOpenRequest( con, NULL, cookieW, NULL, NULL, NULL, 0 );
3060  ok( req != NULL, "failed to open a request %u\n", GetLastError() );
3061 
3062  ret = WinHttpSendRequest( req, NULL, 0, NULL, 0, 0, 0 );
3063  ok( ret, "failed to send request %u\n", GetLastError() );
3064 
3065  ret = WinHttpReceiveResponse( req, NULL );
3066  ok( ret, "failed to receive response %u\n", GetLastError() );
3067 
3068  status = 0xdeadbeef;
3069  size = sizeof(status);
3071  ok( ret, "failed to query status code %u\n", GetLastError() );
3072  ok( status == HTTP_STATUS_OK, "request failed unexpectedly %u\n", status );
3073 
3074  WinHttpCloseHandle( req );
3075 
3076  req = WinHttpOpenRequest( con, NULL, cookie2W, NULL, NULL, NULL, 0 );
3077  ok( req != NULL, "failed to open a request %u\n", GetLastError() );
3078 
3079  ret = WinHttpSendRequest( req, NULL, 0, NULL, 0, 0, 0 );
3080  ok( ret, "failed to send request %u\n", GetLastError() );
3081 
3082  ret = WinHttpReceiveResponse( req, NULL );
3083  ok( ret, "failed to receive response %u\n", GetLastError() );
3084 
3085  status = 0xdeadbeef;
3086  size = sizeof(status);
3088  ok( ret, "failed to query status code %u\n", GetLastError() );
3089  ok( status == HTTP_STATUS_OK, "request failed unexpectedly %u\n", status );
3090 
3091  WinHttpCloseHandle( req );
3092  WinHttpCloseHandle( con );
3093 
3094  con = WinHttpConnect( ses, localhostW, port, 0 );
3095  ok( con != NULL, "failed to open a connection %u\n", GetLastError() );
3096 
3097  req = WinHttpOpenRequest( con, NULL, cookie2W, NULL, NULL, NULL, 0 );
3098  ok( req != NULL, "failed to open a request %u\n", GetLastError() );
3099 
3100  ret = WinHttpSendRequest( req, NULL, 0, NULL, 0, 0, 0 );
3101  ok( ret, "failed to send request %u\n", GetLastError() );
3102 
3103  ret = WinHttpReceiveResponse( req, NULL );
3104  ok( ret, "failed to receive response %u\n", GetLastError() );
3105 
3106  status = 0xdeadbeef;
3107  size = sizeof(status);
3109  ok( ret, "failed to query status code %u\n", GetLastError() );
3110  ok( status == HTTP_STATUS_OK, "request failed unexpectedly %u\n", status );
3111 
3112  WinHttpCloseHandle( req );
3113 
3114  req = WinHttpOpenRequest( con, NULL, cookie3W, NULL, NULL, NULL, 0 );
3115  ok( req != NULL, "failed to open a request %u\n", GetLastError() );
3116 
3117  ret = WinHttpSendRequest( req, cookieheaderW, ~0u, NULL, 0, 0, 0 );
3118  ok( ret, "failed to send request %u\n", GetLastError() );
3119 
3120  ret = WinHttpReceiveResponse( req, NULL );
3121  ok( ret, "failed to receive response %u\n", GetLastError() );
3122 
3123  status = 0xdeadbeef;
3124  size = sizeof(status);
3126  ok( ret, "failed to query status code %u\n", GetLastError() );
3127  ok( status == HTTP_STATUS_OK || broken(status == HTTP_STATUS_BAD_REQUEST), "request failed unexpectedly %u\n", status );
3128 
3129  WinHttpCloseHandle( req );
3130  WinHttpCloseHandle( con );
3131  WinHttpCloseHandle( ses );
3132 
3134  ok( ses != NULL, "failed to open session %u\n", GetLastError() );
3135 
3136  con = WinHttpConnect( ses, localhostW, port, 0 );
3137  ok( con != NULL, "failed to open a connection %u\n", GetLastError() );
3138 
3139  req = WinHttpOpenRequest( con, NULL, cookie2W, NULL, NULL, NULL, 0 );
3140  ok( req != NULL, "failed to open a request %u\n", GetLastError() );
3141 
3142  ret = WinHttpSendRequest( req, NULL, 0, NULL, 0, 0, 0 );
3143  ok( ret, "failed to send request %u\n", GetLastError() );
3144 
3145  ret = WinHttpReceiveResponse( req, NULL );
3146  ok( ret, "failed to receive response %u\n", GetLastError() );
3147 
3148  status = 0xdeadbeef;
3149  size = sizeof(status);
3151  ok( ret, "failed to query status code %u\n", GetLastError() );
3152  ok( status == HTTP_STATUS_BAD_REQUEST, "request failed unexpectedly %u\n", status );
3153 
3154  WinHttpCloseHandle( req );
3155  WinHttpCloseHandle( con );
3156  WinHttpCloseHandle( ses );
3157 
3159  ok( ses != NULL, "failed to open session %u\n", GetLastError() );
3160 
3161  con = WinHttpConnect( ses, localhostW, port, 0 );
3162  ok( con != NULL, "failed to open a connection %u\n", GetLastError() );
3163 
3164  req = WinHttpOpenRequest( con, NULL, cookie4W, NULL, NULL, NULL, 0 );
3165  ok( req != NULL, "failed to open a request %u\n", GetLastError() );
3166 
3167  ret = WinHttpSendRequest( req, NULL, 0, NULL, 0, 0, 0 );
3168  ok( ret, "failed to send request %u\n", GetLastError() );
3169 
3170  ret = WinHttpReceiveResponse( req, NULL );
3171  ok( ret, "failed to receive response %u\n", GetLastError() );
3172 
3173  status = 0xdeadbeef;
3174  size = sizeof(status);
3176  ok( ret, "failed to query status code %u\n", GetLastError() );
3177  ok( status == HTTP_STATUS_OK, "request failed unexpectedly %u\n", status );
3178  WinHttpCloseHandle( req );
3179 
3180  req = WinHttpOpenRequest( con, NULL, cookie5W, NULL, NULL, NULL, 0 );
3181  ok( req != NULL, "failed to open a request %u\n", GetLastError() );
3182 
3183  ret = WinHttpSendRequest( req, NULL, 0, NULL, 0, 0, 0 );
3184  ok( ret, "failed to send request %u\n", GetLastError() );
3185 
3186  ret = WinHttpReceiveResponse( req, NULL );
3187  ok( ret, "failed to receive response %u\n", GetLastError() );
3188 
3189  status = 0xdeadbeef;
3190  size = sizeof(status);
3192  ok( ret, "failed to query status code %u\n", GetLastError() );
3193  ok( status == HTTP_STATUS_OK || broken(status == HTTP_STATUS_BAD_REQUEST) /* < win7 */,
3194  "request failed unexpectedly %u\n", status );
3195 
3196  WinHttpCloseHandle( req );
3197  WinHttpCloseHandle( con );
3198  WinHttpCloseHandle( ses );
3199 }
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:524
BOOL WINAPI WinHttpCloseHandle(HINTERNET handle)
Definition: session.c:1153
#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:831
unsigned int BOOL
Definition: ntddk_ex.h:94
static const WCHAR test_useragent[]
Definition: winhttp.c:39
BOOL WINAPI WinHttpReceiveResponse(HINTERNET hrequest, LPVOID reserved)
Definition: request.c:2692
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:43
HINTERNET WINAPI WinHttpOpen(LPCWSTR agent, DWORD access, LPCWSTR proxy, LPCWSTR bypass, DWORD flags)
Definition: session.c:246
HINTERNET WINAPI WinHttpOpenRequest(HINTERNET hconnect, LPCWSTR verb, LPCWSTR object, LPCWSTR version, LPCWSTR referrer, LPCWSTR *types, DWORD flags)
Definition: session.c:1061
USHORT port
Definition: uri.c:227
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:2168
Definition: ps.c:97

Referenced by START_TEST().

◆ test_credentials()

static void test_credentials ( void  )
static

Definition at line 3260 of file winhttp.c.

3261 {
3262  static WCHAR userW[] = {'u','s','e','r',0};
3263  static WCHAR passW[] = {'p','a','s','s',0};
3264  static WCHAR proxy_userW[] = {'p','r','o','x','y','u','s','e','r',0};
3265  static WCHAR proxy_passW[] = {'p','r','o','x','y','p','a','s','s',0};
3266  HINTERNET ses, con, req;
3267  DWORD size, error;
3268  WCHAR buffer[32];
3269  BOOL ret;
3270 
3271  ses = WinHttpOpen(test_useragent, 0, proxy_userW, proxy_passW, 0);
3272  ok(ses != NULL, "failed to open session %u\n", GetLastError());
3273 
3274  con = WinHttpConnect(ses, localhostW, 0, 0);
3275  ok(con != NULL, "failed to open a connection %u\n", GetLastError());
3276 
3277  req = WinHttpOpenRequest(con, NULL, NULL, NULL, NULL, NULL, 0);
3278  ok(req != NULL, "failed to open a request %u\n", GetLastError());
3279 
3280  size = sizeof(buffer)/sizeof(WCHAR);
3282  ok(ret, "failed to query proxy username %u\n", GetLastError());
3283  ok(!buffer[0], "unexpected result %s\n", wine_dbgstr_w(buffer));
3284  ok(!size, "expected 0, got %u\n", size);
3285 
3286  size = sizeof(buffer)/sizeof(WCHAR);
3288  ok(ret, "failed to query proxy password %u\n", GetLastError());
3289  ok(!buffer[0], "unexpected result %s\n", wine_dbgstr_w(buffer));
3290  ok(!size, "expected 0, got %u\n", size);
3291 
3292  ret = WinHttpSetOption(req, WINHTTP_OPTION_PROXY_USERNAME, proxy_userW, lstrlenW(proxy_userW));
3293  ok(ret, "failed to set username %u\n", GetLastError());
3294 
3295  size = sizeof(buffer)/sizeof(WCHAR);
3297  ok(ret, "failed to query proxy username %u\n", GetLastError());
3298  ok(!winetest_strcmpW(buffer, proxy_userW), "unexpected result %s\n", wine_dbgstr_w(buffer));
3299  ok(size == lstrlenW(proxy_userW) * sizeof(WCHAR), "unexpected result %u\n", size);
3300 
3301  size = sizeof(buffer)/sizeof(WCHAR);
3303  ok(ret, "failed to query username %u\n", GetLastError());
3304  ok(!buffer[0], "unexpected result %s\n", wine_dbgstr_w(buffer));
3305  ok(!size, "expected 0, got %u\n", size);
3306 
3307  size = sizeof(buffer)/sizeof(WCHAR);
3309  ok(ret, "failed to query password %u\n", GetLastError());
3310  ok(!buffer[0], "unexpected result %s\n", wine_dbgstr_w(buffer));
3311  ok(!size, "expected 0, got %u\n", size);
3312 
3313  ret = WinHttpSetOption(req, WINHTTP_OPTION_PROXY_PASSWORD, proxy_passW, lstrlenW(proxy_passW));
3314  ok(ret, "failed to set proxy password %u\n", GetLastError());
3315 
3316  size = sizeof(buffer)/sizeof(WCHAR);
3318  ok(ret, "failed to query proxy password %u\n", GetLastError());
3319  ok(!winetest_strcmpW(buffer, proxy_passW), "unexpected result %s\n", wine_dbgstr_w(buffer));
3320  ok(size == lstrlenW(proxy_passW) * sizeof(WCHAR), "unexpected result %u\n", size);
3321 
3322  ret = WinHttpSetOption(req, WINHTTP_OPTION_USERNAME, userW, lstrlenW(userW));
3323  ok(ret, "failed to set username %u\n", GetLastError());
3324 
3325  size = sizeof(buffer)/sizeof(WCHAR);
3327  ok(ret, "failed to query username %u\n", GetLastError());
3328  ok(!winetest_strcmpW(buffer, userW), "unexpected result %s\n", wine_dbgstr_w(buffer));
3329  ok(size == lstrlenW(userW) * sizeof(WCHAR), "unexpected result %u\n", size);
3330 
3331  ret = WinHttpSetOption(req, WINHTTP_OPTION_PASSWORD, passW, lstrlenW(passW));
3332  ok(ret, "failed to set password %u\n", GetLastError());
3333 
3334  size = sizeof(buffer)/sizeof(WCHAR);
3336  ok(ret, "failed to query password %u\n", GetLastError());
3337  ok(!winetest_strcmpW(buffer, passW), "unexpected result %s\n", wine_dbgstr_w(buffer));
3338  ok(size == lstrlenW(passW) * sizeof(WCHAR), "unexpected result %u\n", size);
3339 
3340  WinHttpCloseHandle(req);
3341 
3342  req = WinHttpOpenRequest(con, NULL, NULL, NULL, NULL, NULL, 0);
3343  ok(req != NULL, "failed to open a request %u\n", GetLastError());
3344 
3345  SetLastError(0xdeadbeef);
3347  error = GetLastError();
3348  ok(!ret, "expected failure\n");
3349  ok(error == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %u\n", error);
3350 
3351  SetLastError(0xdeadbeef);
3353  error = GetLastError();
3354  ok(!ret, "expected failure\n");
3355  ok(error == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %u\n", error);
3356 
3358  ok(ret, "failed to set credentials %u\n", GetLastError());
3359 
3360  size = sizeof(buffer)/sizeof(WCHAR);
3362  ok(ret, "failed to query username %u\n", GetLastError());
3363  todo_wine {
3364  ok(!buffer[0], "unexpected result %s\n", wine_dbgstr_w(buffer));
3365  ok(!size, "expected 0, got %u\n", size);
3366  }
3367 
3368  size = sizeof(buffer)/sizeof(WCHAR);
3370  ok(ret, "failed to query password %u\n", GetLastError());
3371  todo_wine {
3372  ok(!buffer[0], "unexpected result %s\n", wine_dbgstr_w(buffer));
3373  ok(!size, "expected 0, got %u\n", size);
3374  }
3375 
3376  WinHttpCloseHandle(req);
3377  WinHttpCloseHandle(con);
3378  WinHttpCloseHandle(ses);
3379 }
HINTERNET WINAPI WinHttpConnect(HINTERNET hsession, LPCWSTR server, INTERNET_PORT port, DWORD reserved)
Definition: session.c:524
#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:1211
BOOL WINAPI WinHttpCloseHandle(HINTERNET handle)
Definition: session.c:1153
#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:407
unsigned int BOOL
Definition: ntddk_ex.h:94
static const WCHAR test_useragent[]
Definition: winhttp.c:39
smooth NULL
Definition: ftsmooth.c:416
static int winetest_strcmpW(const WCHAR *str1, const WCHAR *str2)
Definition: test.h:83
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:409
int ret
#define todo_wine
Definition: test.h:154
BOOL WINAPI WinHttpSetCredentials(HINTERNET hrequest, DWORD target, DWORD scheme, LPCWSTR username, LPCWSTR password, LPVOID params)
Definition: request.c:2260
#define WINHTTP_AUTH_SCHEME_BASIC
Definition: winhttp.h:452
BOOL WINAPI WinHttpSetOption(HINTERNET handle, DWORD option, LPVOID buffer, DWORD buflen)
Definition: session.c:1270
#define ok(value,...)
Definition: atltest.h:57
static const WCHAR localhostW[]
Definition: winhttp.c:43
HINTERNET WINAPI WinHttpOpen(LPCWSTR agent, DWORD access, LPCWSTR proxy, LPCWSTR bypass, DWORD flags)
Definition: session.c:246
HINTERNET WINAPI WinHttpOpenRequest(HINTERNET hconnect, LPCWSTR verb, LPCWSTR object, LPCWSTR version, LPCWSTR referrer, LPCWSTR *types, DWORD flags)
Definition: session.c:1061
#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 281 of file winhttp.c.

282 {
283  static const WCHAR empty[] = {0};
284  HINTERNET ses, con, req;
285  DWORD err;
286  BOOL ret;
287 
288  ses = WinHttpOpen(test_useragent, 0, NULL, NULL, 0);
289  ok(ses != NULL, "failed to open session %u\n", GetLastError());
290 
291  con = WinHttpConnect(ses, test_winehq, 80, 0);
292  ok(con != NULL, "failed to open a connection %u\n", GetLastError());
293 
294  req = WinHttpOpenRequest(con, NULL, NULL, NULL, NULL, NULL, 0);
295  ok(req != NULL, "failed to open a request %u\n", GetLastError());
296 
297  ret = WinHttpSendRequest(req, empty, 0, NULL, 0, 0, 0);
298  err = GetLastError();
300  {
301  skip("connection failed, skipping\n");
302  goto done;
303  }
304  ok(ret, "failed to send request %u\n", GetLastError());
305 
306  done:
307  WinHttpCloseHandle(req);
308  WinHttpCloseHandle(con);
309  WinHttpCloseHandle(ses);
310 }
HINTERNET WINAPI WinHttpConnect(HINTERNET hsession, LPCWSTR server, INTERNET_PORT port, DWORD reserved)
Definition: session.c:524
BOOL WINAPI WinHttpCloseHandle(HINTERNET handle)
Definition: session.c:1153
#define ERROR_WINHTTP_TIMEOUT
Definition: winhttp.h:189
static const WCHAR empty[]
Definition: main.c:49
#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:39
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:41
#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:246
HINTERNET WINAPI WinHttpOpenRequest(HINTERNET hconnect, LPCWSTR verb, LPCWSTR object, LPCWSTR version, LPCWSTR referrer, LPCWSTR *types, DWORD flags)
Definition: session.c:1061
BOOL WINAPI WinHttpSendRequest(HINTERNET hrequest, LPCWSTR headers, DWORD headers_len, LPVOID optional, DWORD optional_len, DWORD total_len, DWORD_PTR context)
Definition: request.c:2168

Referenced by START_TEST().

◆ test_head_request()

static void test_head_request ( int  port)
static

Definition at line 2838 of file winhttp.c.

2839 {
2840  static const WCHAR verbW[] = {'H','E','A','D',0};
2841  static const WCHAR headW[] = {'/','h','e','a','d',0};
2842  HINTERNET ses, con, req;
2843  char buf[128];
2844  DWORD size, len, count, status;
2845  BOOL ret;
2846 
2848  ok(ses != NULL, "failed to open session %u\n", GetLastError());
2849 
2850  con = WinHttpConnect(ses, localhostW, port, 0);
2851  ok(con != NULL, "failed to open a connection %u\n", GetLastError());
2852 
2853  req = WinHttpOpenRequest(con, verbW, headW, NULL, NULL, NULL, 0);
2854  ok(req != NULL, "failed to open a request %u\n", GetLastError());
2855 
2856  ret = WinHttpSendRequest(req, NULL, 0, NULL, 0, 0, 0);
2857  ok(ret, "failed to send request %u\n", GetLastError());
2858 
2860  ok(ret, "failed to receive response %u\n", GetLastError());
2861 
2862  status = 0xdeadbeef;
2863  size = sizeof(status);
2865  NULL, &status, &size, NULL);
2866  ok(ret, "failed to get status code %u\n", GetLastError());
2867  ok(status == HTTP_STATUS_OK, "got %u\n", status);
2868 
2869  len = 0xdeadbeef;
2870  size = sizeof(len);
2872  NULL, &len, &size, 0);
2873  ok(ret, "failed to get content-length header %u\n", GetLastError());
2874  ok(len == HTTP_STATUS_CONTINUE, "got %u\n", len);
2875 
2876  count = 0xdeadbeef;
2878  ok(ret, "failed to query data available %u\n", GetLastError());
2879  ok(!count, "got %u\n", count);
2880 
2881  len = sizeof(buf);
2882  count = 0xdeadbeef;
2883  ret = WinHttpReadData(req, buf, len, &count);
2884  ok(ret, "failed to read data %u\n", GetLastError());
2885  ok(!count, "got %u\n", count);
2886 
2887  count = 0xdeadbeef;
2889  ok(ret, "failed to query data available %u\n", GetLastError());
2890  ok(!count, "got %u\n", count);
2891 
2892  WinHttpCloseHandle(req);
2893  WinHttpCloseHandle(con);
2894  WinHttpCloseHandle(ses);
2895 }
HINTERNET WINAPI WinHttpConnect(HINTERNET hsession, LPCWSTR server, INTERNET_PORT port, DWORD reserved)
Definition: session.c:524
static const WCHAR verbW[]
Definition: main.c:64
BOOL WINAPI WinHttpCloseHandle(HINTERNET handle)
Definition: session.c:1153
#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:831
unsigned int BOOL
Definition: ntddk_ex.h:94
static const WCHAR test_useragent[]
Definition: winhttp.c:39
BOOL WINAPI WinHttpReceiveResponse(HINTERNET hrequest, LPVOID reserved)
Definition: request.c:2692
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:43
HINTERNET WINAPI WinHttpOpen(LPCWSTR agent, DWORD access, LPCWSTR proxy, LPCWSTR bypass, DWORD flags)
Definition: session.c:246
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:1061
USHORT port
Definition: uri.c:227
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:2168
BOOL WINAPI WinHttpQueryDataAvailable(HINTERNET hrequest, LPDWORD available)
Definition: request.c:2763
BOOL WINAPI WinHttpReadData(HINTERNET hrequest, LPVOID buffer, DWORD to_read, LPDWORD read)
Definition: request.c:2811
Definition: ps.c:97

Referenced by START_TEST().

◆ test_IWinHttpRequest()

static void test_IWinHttpRequest ( int  port)
static

Definition at line 3381 of file winhttp.c.

3382 {
3383  static const WCHAR data_start[] = {'<','!','D','O','C','T','Y','P','E',' ','h','t','m','l',' ','P','U','B','L','I','C'};
3384  static const WCHAR usernameW[] = {'u','s','e','r','n','a','m','e',0};
3385  static const WCHAR passwordW[] = {'p','a','s','s','w','o','r','d',0};
3386  static const WCHAR url1W[] = {'h','t','t','p',':','/','/','t','e','s','t','.','w','i','n','e','h','q','.','o','r','g',0};
3387  static const WCHAR url2W[] = {'t','e','s','t','.','w','i','n','e','h','q','.','o','r','g',0};
3388  static const WCHAR url3W[] = {'h','t','t','p',':','/','/','t','e','s','t','.','w','i','n','e','h','q','.',
3389  'o','r','g','/','t','e','s','t','s','/','p','o','s','t','.','p','h','p',0};
3390  static const WCHAR method1W[] = {'G','E','T',0};
3391  static const WCHAR method2W[] = {'I','N','V','A','L','I','D',0};
3392  static const WCHAR method3W[] = {'P','O','S','T',0};
3393  static const WCHAR proxy_serverW[] = {'p','r','o','x','y','s','e','r','v','e','r',0};
3394  static const WCHAR bypas_listW[] = {'b','y','p','a','s','s','l','i','s','t',0};
3395  static const WCHAR connectionW[] = {'C','o','n','n','e','c','t','i','o','n',0};
3396  static const WCHAR dateW[] = {'D','a','t','e',0};
3397  static const WCHAR test_dataW[] = {'t','e','s','t','d','a','t','a',128,0};
3398  static const WCHAR utf8W[] = {'u','t','f','-','8',0};
3399  static const WCHAR unauthW[] = {'U','n','a','u','t','h','o','r','i','z','e','d',0};
3400  HRESULT hr;
3401  IWinHttpRequest *req;
3402  BSTR method, url, username, password, response = NULL, status_text = NULL, headers = NULL;
3403  BSTR date, today, connection, value = NULL;
3404  VARIANT async, empty, timeout, body, body2, proxy_server, bypass_list, data, cp;
3405  VARIANT_BOOL succeeded;
3406  LONG status;
3408  SYSTEMTIME st;
3409  IStream *stream, *stream2;
3411  char buf[128];
3412  WCHAR bufW[128];
3413  DWORD count;
3414 
3415  GetSystemTime( &st );
3416  WinHttpTimeFromSystemTime( &st, todayW );
3417 
3418  CoInitialize( NULL );
3419  hr = CoCreateInstance( &CLSID_WinHttpRequest, NULL, CLSCTX_INPROC_SERVER, &IID_IWinHttpRequest, (void **)&req );
3420  ok( hr == S_OK, "got %08x\n", hr );
3421 
3422  V_VT( &empty ) = VT_ERROR;
3423  V_ERROR( &empty ) = 0xdeadbeef;
3424 
3425  V_VT( &async ) = VT_BOOL;
3426  V_BOOL( &async ) = VARIANT_FALSE;
3427 
3428  method = SysAllocString( method3W );
3429  url = SysAllocString( url3W );
3430  hr = IWinHttpRequest_Open( req, method, url, async );
3431  ok( hr == S_OK, "got %08x\n", hr );
3432  SysFreeString( method );
3433  SysFreeString( url );
3434 
3435  V_VT( &data ) = VT_BSTR;
3436  V_BSTR( &data ) = SysAllocString( test_dataW );
3437  hr = IWinHttpRequest_Send( req, data );
3439  "got %08x\n", hr );
3440  SysFreeString( V_BSTR( &data ) );
3441 
3442  hr = IWinHttpRequest_Open( req, NULL, NULL, empty );
3443  ok( hr == E_INVALIDARG, "got %08x\n", hr );
3444 
3445  method = SysAllocString( method1W );
3446  hr = IWinHttpRequest_Open( req, method, NULL, empty );
3447  ok( hr == E_INVALIDARG, "got %08x\n", hr );
3448 
3449  hr = IWinHttpRequest_Open( req, method, NULL, async );
3450  ok( hr == E_INVALIDARG, "got %08x\n", hr );
3451 
3452  url = SysAllocString( url1W );
3453  hr = IWinHttpRequest_Open( req, NULL, url, empty );
3454  ok( hr == E_INVALIDARG, "got %08x\n", hr );
3455 
3456  hr = IWinHttpRequest_Abort( req );
3457  ok( hr == S_OK, "got %08x\n", hr );
3458 
3459  hr = IWinHttpRequest_Open( req, method, url, empty );
3460  ok( hr == S_OK, "got %08x\n", hr );
3461 
3462  hr = IWinHttpRequest_Abort( req );
3463  ok( hr == S_OK, "got %08x\n", hr );
3464 
3465  IWinHttpRequest_Release( req );
3466 
3467  hr = CoCreateInstance( &CLSID_WinHttpRequest, NULL, CLSCTX_INPROC_SERVER, &IID_IWinHttpRequest, (void **)&req );
3468  ok( hr == S_OK, "got %08x\n", hr );
3469 
3470  SysFreeString( url );
3471  url = SysAllocString( url2W );
3472  hr = IWinHttpRequest_Open( req, method, url, async );
3474 
3475  SysFreeString( method );
3476  method = SysAllocString( method2W );
3477  hr = IWinHttpRequest_Open( req, method, url, async );
3479 
3480  SysFreeString( method );
3481  method = SysAllocString( method1W );
3482  SysFreeString( url );
3483  url = SysAllocString( url1W );
3484  V_VT( &async ) = VT_ERROR;
3485  V_ERROR( &async ) = DISP_E_PARAMNOTFOUND;
3486  hr = IWinHttpRequest_Open( req, method, url, async );
3487  ok( hr == S_OK, "got %08x\n", hr );
3488 
3489  V_VT( &cp ) = VT_ERROR;
3490  V_ERROR( &cp ) = 0xdeadbeef;
3491  hr = IWinHttpRequest_get_Option( req, WinHttpRequestOption_URLCodePage, &cp );
3492  ok( hr == S_OK, "got %08x\n", hr );
3493  ok( V_VT( &cp ) == VT_I4, "got %08x\n", V_VT( &cp ) );
3494  ok( V_I4( &cp ) == CP_UTF8, "got %u\n", V_I4( &cp ) );
3495 
3496  V_VT( &cp ) = VT_UI4;
3497  V_UI4( &cp ) = CP_ACP;
3498  hr = IWinHttpRequest_put_Option( req, WinHttpRequestOption_URLCodePage, cp );
3499  ok( hr == S_OK, "got %08x\n", hr );
3500 
3501  V_VT( &cp ) = VT_ERROR;
3502  V_ERROR( &cp ) = 0xdeadbeef;
3503  hr = IWinHttpRequest_get_Option( req, WinHttpRequestOption_URLCodePage, &cp );
3504  ok( hr == S_OK, "got %08x\n", hr );
3505  ok( V_VT( &cp ) == VT_I4, "got %08x\n", V_VT( &cp ) );
3506  ok( V_I4( &cp ) == CP_ACP, "got %u\n", V_I4( &cp ) );
3507 
3508  value = SysAllocString( utf8W );
3509  V_VT( &cp ) = VT_BSTR;
3510  V_BSTR( &cp ) = value;
3511  hr = IWinHttpRequest_put_Option( req, WinHttpRequestOption_URLCodePage, cp );
3512  ok( hr == S_OK, "got %08x\n", hr );
3513  SysFreeString( value );
3514 
3515  V_VT( &cp ) = VT_ERROR;
3516  V_ERROR( &cp ) = 0xdeadbeef;
3517  hr = IWinHttpRequest_get_Option( req, WinHttpRequestOption_URLCodePage, &cp );
3518  ok( hr == S_OK, "got %08x\n", hr );
3519  ok( V_VT( &cp ) == VT_I4, "got %08x\n", V_VT( &cp ) );
3520  ok( V_I4( &cp ) == CP_UTF8, "got %u\n", V_I4( &cp ) );
3521 
3522  hr = IWinHttpRequest_Abort( req );
3523  ok( hr == S_OK, "got %08x\n", hr );
3524 
3525  hr = IWinHttpRequest_Send( req, empty );
3527 
3528  hr = IWinHttpRequest_Abort( req );
3529  ok( hr == S_OK, "got %08x\n", hr );
3530 
3531  IWinHttpRequest_Release( req );
3532 
3533  hr = CoCreateInstance( &CLSID_WinHttpRequest, NULL, CLSCTX_INPROC_SERVER, &IID_IWinHttpRequest, (void **)&req );
3534  ok( hr == S_OK, "got %08x\n", hr );
3535 
3536  hr = IWinHttpRequest_get_ResponseText( req, NULL );
3537  ok( hr == E_INVALIDARG, "got %08x\n", hr );
3538 
3539  hr = IWinHttpRequest_get_ResponseText( req, &response );
3541 
3542  hr = IWinHttpRequest_get_Status( req, NULL );
3543  ok( hr == E_INVALIDARG, "got %08x\n", hr );
3544 
3545  hr = IWinHttpRequest_get_Status( req, &status );
3547 
3548  hr = IWinHttpRequest_get_StatusText( req, NULL );
3549  ok( hr == E_INVALIDARG, "got %08x\n", hr );
3550 
3551  hr = IWinHttpRequest_get_StatusText( req, &status_text );
3553 
3554  hr = IWinHttpRequest_get_ResponseBody( req, NULL );
3555  ok( hr == E_INVALIDARG, "got %08x\n", hr );
3556 
3557  hr = IWinHttpRequest_SetTimeouts( req, 10000, 10000, 10000, 10000 );
3558  ok( hr == S_OK, "got %08x\n", hr );
3559 
3560  hr = IWinHttpRequest_SetCredentials( req, NULL, NULL, 0xdeadbeef );
3562 
3564  V_VT( &proxy_server ) = VT_ERROR;
3565  VariantInit( &bypass_list );
3566  V_VT( &bypass_list ) = VT_ERROR;
3567  hr = IWinHttpRequest_SetProxy( req, HTTPREQUEST_PROXYSETTING_DIRECT, proxy_server, bypass_list );
3568  ok( hr == S_OK, "got %08x\n", hr );
3569 
3570  hr = IWinHttpRequest_SetProxy( req, HTTPREQUEST_PROXYSETTING_PROXY, proxy_server, bypass_list );
3571  ok( hr == S_OK, "got %08x\n", hr );
3572 
3573  hr = IWinHttpRequest_SetProxy( req, HTTPREQUEST_PROXYSETTING_DIRECT, proxy_server, bypass_list );
3574  ok( hr == S_OK, "got %08x\n", hr );
3575 
3576  hr = IWinHttpRequest_GetAllResponseHeaders( req, NULL );
3577  ok( hr == E_INVALIDARG, "got %08x\n", hr );
3578 
3579  hr = IWinHttpRequest_GetAllResponseHeaders( req, &headers );
3581 
3582  hr = IWinHttpRequest_GetResponseHeader( req, NULL, NULL );
3584 
3585  connection = SysAllocString( connectionW );
3586  hr = IWinHttpRequest_GetResponseHeader( req, connection, NULL );
3588 
3589  hr = IWinHttpRequest_GetResponseHeader( req, connection, &value );
3591 
3592  hr = IWinHttpRequest_SetRequestHeader( req, NULL, NULL );
3593  ok( hr == E_INVALIDARG, "got %08x\n", hr );
3594 
3595  date = SysAllocString( dateW );
3596  hr = IWinHttpRequest_SetRequestHeader( req, date, NULL );
3598 
3599  today = SysAllocString( todayW );
3600  hr = IWinHttpRequest_SetRequestHeader( req, date, today );
3602 
3603  hr = IWinHttpRequest_SetAutoLogonPolicy( req, 0xdeadbeef );
3604  ok( hr == E_INVALIDARG, "got %08x\n", hr );
3605 
3606  hr = IWinHttpRequest_SetAutoLogonPolicy( req, AutoLogonPolicy_OnlyIfBypassProxy );
3607  ok( hr == S_OK, "got %08x\n", hr );
3608 
3609  SysFreeString( method );
3610  method = SysAllocString( method1W );
3611  SysFreeString( url );
3612  url = SysAllocString( url1W );
3613  hr = IWinHttpRequest_Open( req, method, url, async );
3614  ok( hr == S_OK, "got %08x\n", hr );
3615 
3616  hr = IWinHttpRequest_get_ResponseText( req, NULL );
3617  ok( hr == E_INVALIDARG, "got %08x\n", hr );
3618 
3619  hr = IWinHttpRequest_get_ResponseText( req, &response );
3621 
3622  hr = IWinHttpRequest_get_Status( req, &status );
3624 
3625  hr = IWinHttpRequest_get_StatusText( req, &status_text );
3627 
3628  hr = IWinHttpRequest_get_ResponseBody( req, NULL );
3629  ok( hr == E_INVALIDARG, "got %08x\n", hr );
3630 
3631  hr = IWinHttpRequest_SetTimeouts( req, 10000, 10000, 10000, 10000 );
3632  ok( hr == S_OK, "got %08x\n", hr );
3633 
3634  hr = IWinHttpRequest_SetCredentials( req, NULL, NULL, 0xdeadbeef );
3635  ok( hr == E_INVALIDARG, "got %08x\n", hr );
3636 
3637  username = SysAllocString( usernameW );
3638  hr = IWinHttpRequest_SetCredentials( req, username, NULL, 0xdeadbeef );
3639  ok( hr == E_INVALIDARG, "got %08x\n", hr );
3640 
3641  password = SysAllocString( passwordW );
3642  hr = IWinHttpRequest_SetCredentials( req, NULL, password, 0xdeadbeef );
3643  ok( hr == E_INVALIDARG, "got %08x\n", hr );
3644 
3645  hr = IWinHttpRequest_SetCredentials( req, username, password, 0xdeadbeef );
3646  ok( hr == E_INVALIDARG, "got %08x\n", hr );
3647 
3648  hr = IWinHttpRequest_SetCredentials( req, NULL, password, HTTPREQUEST_SETCREDENTIALS_FOR_SERVER );
3649  ok( hr == E_INVALIDARG, "got %08x\n", hr );
3650 
3651  hr = IWinHttpRequest_SetCredentials( req, username, password, HTTPREQUEST_SETCREDENTIALS_FOR_SERVER );
3652  ok( hr == S_OK, "got %08x\n", hr );
3653 
3654  V_VT( &proxy_server ) = VT_BSTR;
3655  V_BSTR( &proxy_server ) = SysAllocString( proxy_serverW );
3656  V_VT( &bypass_list ) = VT_BSTR;
3657  V_BSTR( &bypass_list ) = SysAllocString( bypas_listW );
3658  hr = IWinHttpRequest_SetProxy( req, HTTPREQUEST_PROXYSETTING_PROXY, proxy_server, bypass_list );
3659  ok( hr == S_OK, "got %08x\n", hr );
3660 
3661  hr = IWinHttpRequest_SetProxy( req, 0xdeadbeef, proxy_server, bypass_list );
3662  ok( hr == E_INVALIDARG, "got %08x\n", hr );
3663 
3664  hr = IWinHttpRequest_SetProxy( req, HTTPREQUEST_PROXYSETTING_DIRECT, proxy_server, bypass_list );
3665  ok( hr == S_OK, "got %08x\n", hr );
3666 
3667  hr = IWinHttpRequest_GetAllResponseHeaders( req, &headers );
3669 
3670  hr = IWinHttpRequest_GetResponseHeader( req, connection, &value );
3672 
3673  hr = IWinHttpRequest_SetRequestHeader( req, date, today );
3674  ok( hr == S_OK, "got %08x\n", hr );
3675 
3676  hr = IWinHttpRequest_SetRequestHeader( req, date, NULL );
3677  ok( hr == S_OK, "got %08x\n", hr );
3678 
3679  hr = IWinHttpRequest_SetAutoLogonPolicy( req, AutoLogonPolicy_OnlyIfBypassProxy );
3680  ok( hr == S_OK, "got %08x\n", hr );
3681 
3682  hr = IWinHttpRequest_Send( req, empty );
3683  ok( hr == S_OK, "got %08x\n", hr );
3684 
3685  hr = IWinHttpRequest_Send( req, empty );
3686  ok( hr == S_OK, "got %08x\n", hr );
3687 
3688  hr = IWinHttpRequest_get_ResponseText( req, NULL );
3689  ok( hr == E_INVALIDARG, "got %08x\n", hr );
3690 
3691  hr = IWinHttpRequest_get_ResponseText( req, &response );
3692  ok( hr == S_OK, "got %08x\n", hr );
3693  ok( !memcmp(response, data_start, sizeof(data_start)), "got %s\n", wine_dbgstr_wn(response, 32) );
3694  SysFreeString( response );
3695 
3696  hr = IWinHttpRequest_get_Status( req, NULL );
3697  ok( hr == E_INVALIDARG, "got %08x\n", hr );
3698 
3699  status = 0;
3700  hr = IWinHttpRequest_get_Status( req, &status );
3701  ok( hr == S_OK, "got %08x\n", hr );
3702  trace("Status=%d\n", status);
3703 
3704  hr = IWinHttpRequest_get_StatusText( req, NULL );
3705  ok( hr == E_INVALIDARG, "got %08x\n", hr );
3706 
3707  hr = IWinHttpRequest_get_StatusText( req, &status_text );
3708  ok( hr == S_OK, "got %08x\n", hr );
3709  trace("StatusText=%s\n", wine_dbgstr_w(status_text));
3710  SysFreeString( status_text );
3711 
3712  hr = IWinHttpRequest_get_ResponseBody( req, NULL );
3713  ok( hr == E_INVALIDARG, "got %08x\n", hr );
3714 
3715  hr = IWinHttpRequest_SetCredentials( req, username, password, HTTPREQUEST_SETCREDENTIALS_FOR_SERVER );
3716  ok( hr == S_OK, "got %08x\n", hr );
3717 
3718  hr = IWinHttpRequest_SetProxy( req, HTTPREQUEST_PROXYSETTING_PROXY, proxy_server, bypass_list );
3719  ok( hr == S_OK, "got %08x\n", hr );
3720 
3721  hr = IWinHttpRequest_SetProxy( req, HTTPREQUEST_PROXYSETTING_DIRECT, proxy_server, bypass_list );
3722  ok( hr == S_OK, "got %08x\n", hr );
3723 
3724  hr = IWinHttpRequest_GetAllResponseHeaders( req, NULL );
3725  ok( hr == E_INVALIDARG, "got %08x\n", hr );
3726 
3727  hr = IWinHttpRequest_GetAllResponseHeaders( req, &headers );
3728  ok( hr == S_OK, "got %08x\n", hr );
3730 
3731  hr = IWinHttpRequest_GetResponseHeader( req, NULL, NULL );
3732  ok( hr == E_INVALIDARG, "got %08x\n", hr );
3733 
3734  hr = IWinHttpRequest_GetResponseHeader( req, connection, NULL );
3735  ok( hr == E_INVALIDARG, "got %08x\n", hr );
3736 
3737  hr = IWinHttpRequest_GetResponseHeader( req, connection, &value );
3738  ok( hr == S_OK, "got %08x\n", hr );
3739  SysFreeString( value );
3740 
3741  hr = IWinHttpRequest_SetRequestHeader( req, date, today );
3743 
3744  hr = IWinHttpRequest_SetAutoLogonPolicy( req, AutoLogonPolicy_OnlyIfBypassProxy );
3745  ok( hr == S_OK, "got %08x\n", hr );
3746 
3747  VariantInit( &timeout );
3748  V_VT( &timeout ) = VT_I4;
3749  V_I4( &timeout ) = 10;
3750  hr = IWinHttpRequest_WaitForResponse( req, timeout, &succeeded );
3751  ok( hr == S_OK, "got %08x\n", hr );
3752 
3753  hr = IWinHttpRequest_get_Status( req, &status );
3754  ok( hr == S_OK, "got %08x\n", hr );
3755 
3756  hr = IWinHttpRequest_get_StatusText( req, &status_text );
3757  ok( hr == S_OK, "got %08x\n", hr );
3758  SysFreeString( status_text );
3759 
3760  hr = IWinHttpRequest_SetCredentials( req, username, password, HTTPREQUEST_SETCREDENTIALS_FOR_SERVER );
3761  ok( hr == S_OK, "got %08x\n", hr );
3762 
3763  hr = IWinHttpRequest_SetProxy( req, HTTPREQUEST_PROXYSETTING_PROXY, proxy_server, bypass_list );
3764  ok( hr == S_OK, "got %08x\n", hr );
3765 
3766  hr = IWinHttpRequest_SetProxy( req, HTTPREQUEST_PROXYSETTING_DIRECT, proxy_server, bypass_list );
3767  ok( hr == S_OK, "got %08x\n", hr );
3768 
3769  hr = IWinHttpRequest_Send( req, empty );
3770  ok( hr == S_OK, "got %08x\n", hr );
3771 
3772  hr = IWinHttpRequest_get_ResponseText( req, NULL );
3773  ok( hr == E_INVALIDARG, "got %08x\n", hr );
3774 
3775  hr = IWinHttpRequest_get_ResponseText( req, &response );
3776  ok( hr == S_OK, "got %08x\n", hr );
3777  SysFreeString( response );
3778 
3779  hr = IWinHttpRequest_get_ResponseBody( req, NULL );
3780  ok( hr == E_INVALIDARG, "got %08x\n", hr );
3781 
3782  VariantInit( &body );
3783  V_VT( &body ) = VT_ERROR;
3784  hr = IWinHttpRequest_get_ResponseBody( req, &body );
3785  ok( hr == S_OK, "got %08x\n", hr );
3786  ok( V_VT( &body ) == (VT_ARRAY|VT_UI1), "got %08x\n", V_VT( &body ) );
3787 
3788  hr = VariantClear( &body );
3789  ok( hr == S_OK, "got %08x\n", hr );
3790 
3791  VariantInit( &body );
3792  V_VT( &body ) = VT_ERROR;
3793  hr = IWinHttpRequest_get_ResponseStream( req, &body );
3794  ok( hr == S_OK, "got %08x\n", hr );
3795  ok( V_VT( &body ) == VT_UNKNOWN, "got %08x\n", V_VT( &body ) );
3796 
3797  hr = IUnknown_QueryInterface( V_UNKNOWN( &body ), &IID_IStream, (void **)&stream );
3798  ok( hr == S_OK, "got %08x\n", hr );
3799  ok( V_UNKNOWN( &body ) == (IUnknown *)stream, "got different interface pointer\n" );
3800 
3801  buf[0] = 0;
3802  count = 0xdeadbeef;
3803  hr = IStream_Read( stream, buf, 128, &count );
3804  ok( hr == S_OK, "got %08x\n", hr );
3805  ok( count != 0xdeadbeef, "count not set\n" );
3806  ok( buf[0], "no data\n" );
3807 
3808  VariantInit( &body2 );
3809  V_VT( &body2 ) = VT_ERROR;
3810  hr = IWinHttpRequest_get_ResponseStream( req, &body2 );
3811  ok( hr == S_OK, "got %08x\n", hr );
3812  ok( V_VT( &body2 ) == VT_UNKNOWN, "got %08x\n", V_VT( &body2 ) );
3813  ok( V_UNKNOWN( &body ) != V_UNKNOWN( &body2 ), "got same interface pointer\n" );
3814 
3815  hr = IUnknown_QueryInterface( V_UNKNOWN( &body2 ), &IID_IStream, (void **)&stream2 );
3816  ok( hr == S_OK, "got %08x\n", hr );
3817  ok( V_UNKNOWN( &body2 ) == (IUnknown *)stream2, "got different interface pointer\n" );
3818  IStream_Release( stream2 );
3819 
3820  hr = VariantClear( &body );
3821  ok( hr == S_OK, "got %08x\n", hr );
3822 
3823  hr = VariantClear( &body2 );
3824  ok( hr == S_OK, "got %08x\n", hr );
3825 
3826  hr = IWinHttpRequest_SetProxy( req, HTTPREQUEST_PROXYSETTING_PROXY, proxy_server, bypass_list );
3827  ok( hr == S_OK, "got %08x\n", hr );
3828 
3829  hr = IWinHttpRequest_SetProxy( req, HTTPREQUEST_PROXYSETTING_DIRECT, proxy_server, bypass_list );
3830  ok( hr == S_OK, "got %08x\n", hr );
3831 
3832  hr = IWinHttpRequest_GetAllResponseHeaders( req, &headers );
3833  ok( hr == S_OK, "got %08x\n", hr );
3835 
3836  hr = IWinHttpRequest_GetResponseHeader( req, connection, &value );
3837  ok( hr == S_OK, "got %08x\n", hr );
3838  SysFreeString( value );
3839 
3840  hr = IWinHttpRequest_SetRequestHeader( req, date, today );
3842 
3843  hr = IWinHttpRequest_SetAutoLogonPolicy( req, AutoLogonPolicy_OnlyIfBypassProxy );
3844  ok( hr == S_OK, "got %08x\n", hr );
3845 
3846  hr = IWinHttpRequest_Send( req, empty );
3847  ok( hr == S_OK, "got %08x\n", hr );
3848 
3849  hr = IWinHttpRequest_Abort( req );
3850  ok( hr == S_OK, "got %08x\n", hr );
3851 
3852  hr = IWinHttpRequest_Abort( req );
3853  ok( hr == S_OK, "got %08x\n", hr );
3854 
3855  IWinHttpRequest_Release( req );
3856 
3857  pos.QuadPart = 0;
3858  hr = IStream_Seek( stream, pos, STREAM_SEEK_SET, NULL );
3859  ok( hr == S_OK, "got %08x\n", hr );
3860 
3861  buf[0] = 0;
3862  count = 0xdeadbeef;
3863  hr = IStream_Read( stream, buf, 128, &count );
3864  ok( hr == S_OK, "got %08x\n", hr );
3865  ok( count != 0xdeadbeef, "count not set\n" );
3866  ok( buf[0], "no data\n" );
3867  IStream_Release( stream );
3868 
3869  hr = CoCreateInstance( &CLSID_WinHttpRequest, NULL, CLSCTX_INPROC_SERVER, &IID_IWinHttpRequest, (void **)&req );
3870  ok( hr == S_OK, "got %08x\n", hr );
3871 
3872  V_VT( &async ) = VT_I4;
3873  V_I4( &async ) = 1;
3874  hr = IWinHttpRequest_Open( req, method, url, async );
3875  ok( hr == S_OK, "got %08x\n", hr );
3876 
3877  hr = IWinHttpRequest_Send( req, empty );
3878  ok( hr == S_OK, "got %08x\n", hr );
3879 
3880  hr = IWinHttpRequest_WaitForResponse( req, timeout, &succeeded );
3881  ok( hr == S_OK, "got %08x\n", hr );
3882 
3883  IWinHttpRequest_Release( req );
3884 
3885  SysFreeString( method );
3886  SysFreeString( url );
3889  SysFreeString( connection );
3890  SysFreeString( date );
3891  SysFreeString( today );
3893  VariantClear( &bypass_list );
3894 
3895  hr = CoCreateInstance( &CLSID_WinHttpRequest, NULL, CLSCTX_INPROC_SERVER, &IID_IWinHttpRequest, (void **)&req );
3896  ok( hr == S_OK, "got %08x\n", hr );
3897 
3899  method = SysAllocString( method3W );
3900  V_VT( &async ) = VT_BOOL;
3901  V_BOOL( &async ) = VARIANT_FALSE;
3902  hr = IWinHttpRequest_Open( req, method, url, async );
3903  ok( hr == S_OK, "got %08x\n", hr );
3904  SysFreeString( method );
3905  SysFreeString( url );
3906 
3907  hr = IWinHttpRequest_Send( req, empty );
3909  if (hr == S_OK)
3910  {
3911  hr = IWinHttpRequest_get_ResponseText( req, &response );
3912  ok( hr == S_OK, "got %08x\n", hr );
3913  ok( !memcmp(response, data_start, sizeof(data_start)), "got %s\n", wine_dbgstr_wn(response, 32) );
3914  SysFreeString( response );
3915  }
3916 
3917  IWinHttpRequest_Release( req );
3918 
3919  hr = CoCreateInstance( &CLSID_WinHttpRequest, NULL, CLSCTX_INPROC_SERVER, &IID_IWinHttpRequest, (void **)&req );
3920  ok( hr == S_OK, "got %08x\n", hr );
3921 
3922  sprintf( buf, "http://localhost:%d/auth", port );
3923  MultiByteToWideChar( CP_ACP, 0, buf, -1, bufW, sizeof(bufW)/sizeof(bufW[0]) );
3924  url = SysAllocString( bufW );
3925  method = SysAllocString( method3W );
3926  V_VT( &async ) = VT_BOOL;
3927  V_BOOL( &async ) = VARIANT_FALSE;
3928  hr = IWinHttpRequest_Open( req, method, url, async );
3929  ok( hr == S_OK, "got %08x\n", hr );
3930  SysFreeString( method );
3931  SysFreeString( url );
3932 
3933  hr = IWinHttpRequest_get_Status( req, &status );
3935 
3936  V_VT( &data ) = VT_BSTR;
3937  V_BSTR( &data ) = SysAllocString( test_dataW );
3938  hr = IWinHttpRequest_Send( req, data );
3939  ok( hr == S_OK, "got %08x\n", hr );
3940  SysFreeString( V_BSTR( &data ) );
3941 
3942  hr = IWinHttpRequest_get_ResponseText( req, &response );
3943  ok( hr == S_OK, "got %08x\n", hr );
3944  ok( !memcmp( response, unauthW, sizeof(unauthW) ), "got %s\n", wine_dbgstr_w(response) );
3945  SysFreeString( response );
3946 
3947  status = 0xdeadbeef;
3948  hr = IWinHttpRequest_get_Status( req, &status );
3949  ok( hr == S_OK, "got %08x\n", hr );
3950  ok( status == HTTP_STATUS_DENIED, "got %d\n", status );
3951 
3952  IWinHttpRequest_Release( req );
3953 
3954  CoUninitialize();
3955 }
#define ERROR_WINHTTP_CANNOT_CALL_BEFORE_SEND
Definition: winhttp.h:210
Definition: compat.h:1939
#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
static const WCHAR empty[]
Definition: main.c:49
#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:1934
void WINAPI VariantInit(VARIANTARG *pVarg)
Definition: variant.c:571
short VARIANT_BOOL
Definition: compat.h:1931
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 ERROR_WINHTTP_CANNOT_CALL_AFTER_SEND
Definition: winhttp.h:211
BSTR WINAPI SysAllocString(LPCOLESTR str)
Definition: oleaut.c:241
#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:317
#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:77
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:42
HRESULT WINAPI DECLSPEC_HOTPATCH VariantClear(VARIANTARG *pVarg)
Definition: variant.c:651
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
#define broken(x)
Definition: _sntprintf.h:21
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID iid, LPVOID *ppv)
Definition: compobj.c:3234
#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:2124
void WINAPI DECLSPEC_HOTPATCH CoUninitialize(void)
Definition: compobj.c:1991
__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:274
#define V_ERROR(A)
Definition: oleauto.h:241
#define MultiByteToWideChar
Definition: compat.h:100
static const WCHAR proxy_server[]
Definition: connections.c:40
HRESULT WINAPI CoInitialize(LPVOID lpReserved)
Definition: compobj.c:1897
POINT cp
Definition: magnifier.c:59
USHORT port
Definition: uri.c:227
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 3977 of file winhttp.c.

3978 {
3979  static const WCHAR utf8W[] = {'U','T','F','-','8',0};
3980  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};
3981  WCHAR openW[] = {'O','p','e','n',0};
3982  WCHAR optionW[] = {'O','p','t','i','o','n',0};
3983  OLECHAR *open = openW, *option = optionW;
3984  BSTR utf8;
3985  CLSID clsid;
3986  IWinHttpRequest *request;
3988  DISPID id;
3990  VARIANT arg[3], ret;
3991  UINT err;
3992  BOOL bret;
3993  HRESULT hr;
3994 
3995  CoInitialize(NULL);
3996 
3998  ok(hr == S_OK, "CLSIDFromProgID error %#x\n", hr);
3999  bret = IsEqualIID(&clsid, &CLSID_WinHttpRequest);
4000  ok(bret || broken(!bret) /* win2003 */, "not expected %s\n", wine_dbgstr_guid(&clsid));
4001 
4002  hr = CoCreateInstance(&CLSID_WinHttpRequest, 0, CLSCTX_INPROC_SERVER, &IID_IUnknown, (void **)&request);
4003  ok(hr == S_OK, "error %#x\n", hr);
4004 
4005  hr = IWinHttpRequest_QueryInterface(request, &IID_IDispatch, (void **)&dispatch);
4006  ok(hr == S_OK, "error %#x\n", hr);
4007  IDispatch_Release(dispatch);
4008 
4009  hr = IWinHttpRequest_GetIDsOfNames(request, &IID_NULL, &open, 1, 0x0409, &id);
4010  ok(hr == S_OK, "error %#x\n", hr);
4011  ok(id == DISPID_HTTPREQUEST_OPEN, "expected DISPID_HTTPREQUEST_OPEN, got %u\n", id);
4012 
4013  hr = IWinHttpRequest_GetIDsOfNames(request, &IID_NULL, &option, 1, 0x0409, &id);
4014  ok(hr == S_OK, "error %#x\n", hr);
4015  ok(id == DISPID_HTTPREQUEST_OPTION, "expected DISPID_HTTPREQUEST_OPTION, got %u\n", id);
4016 
4018  ok(V_VT(&ret) == VT_I4, "expected VT_I4, got %d\n", V_VT(&ret));
4019  ok(V_I4(&ret) == CP_UTF8, "expected CP_UTF8, got %d\n", V_I4(&ret));
4020 
4021  memset(&params, 0, sizeof(params));
4022  params.cArgs = 2;
4023  params.cNamedArgs = 0;
4024  params.rgvarg = arg;
4025  V_VT(&arg[0]) = VT_I4;
4026  V_I4(&arg[0]) = 1252;
4027  V_VT(&arg[1]) = VT_R8;
4028  V_R8(&arg[1]) = 2.0; /* WinHttpRequestOption_URLCodePage */
4029  VariantInit(&ret);
4030  hr = IWinHttpRequest_Invoke(request, DISPID_HTTPREQUEST_OPTION, &IID_NULL, 0,
4032  ok(hr == S_OK, "error %#x\n", hr);
4033 
4035  ok(V_VT(&ret) == VT_I4, "expected VT_I4, got %d\n", V_VT(&ret));
4036  ok(V_I4(&ret) == CP_UTF8, "expected CP_UTF8, got %d\n", V_I4(&ret));
4037 
4038  memset(&params, 0, sizeof(params));
4039  params.cArgs = 2;
4040  params.cNamedArgs = 0;
4041  params.rgvarg = arg;
4042  V_VT(&arg[0]) = VT_I4;
4043  V_I4(&arg[0]) = 1252;
4044  V_VT(&arg[1]) = VT_R8;
4045  V_R8(&arg[1]) = 2.0; /* WinHttpRequestOption_URLCodePage */
4046  VariantInit(&ret);
4047  hr = IWinHttpRequest_Invoke(request, DISPID_HTTPREQUEST_OPTION, &IID_NULL, 0,
4049  ok(hr == S_OK, "error %#x\n", hr);
4050 
4052  ok(V_VT(&ret) == VT_I4, "expected VT_I4, got %d\n", V_VT(&ret));
4053  ok(V_I4(&ret) == CP_UTF8, "expected CP_UTF8, got %d\n", V_I4(&ret));
4054 
4055  memset(&params, 0, sizeof(params));
4056  params.cArgs = 2;
4057  params.cNamedArgs = 0;
4058  params.rgvarg = arg;
4059  V_VT(&arg[0]) = VT_I4;
4060  V_I4(&arg[0]) = 1252;
4061  V_VT(&arg[1]) = VT_R8;
4062  V_R8(&arg[1]) = 2.0; /* WinHttpRequestOption_URLCodePage */
4063  VariantInit(&ret);
4064  hr = IWinHttpRequest_Invoke(request, DISPID_HTTPREQUEST_OPTION, &IID_NULL, 0,
4066  ok(hr == S_OK, "error %#x\n", hr);
4067 
4069  ok(V_VT(&ret) == VT_I4, "expected VT_I4, got %d\n", V_VT(&ret));
4070  ok(V_I4(&ret) == 1252, "expected 1252, got %d\n", V_I4(&ret));
4071 
4072  memset(&params, 0, sizeof(params));
4073  params.cArgs = 2;
4074  params.cNamedArgs = 0;
4075  params.rgvarg = arg;
4076  V_VT(&arg[0]) = VT_BSTR;
4077  utf8 = SysAllocString(utf8W);
4078  V_BSTR(&arg[0]) = utf8;
4079  V_VT(&arg[1]) = VT_R8;
4080  V_R8(&arg[1]) = 2.0; /* WinHttpRequestOption_URLCodePage */
4081  hr = IWinHttpRequest_Invoke(request, id, &IID_NULL, 0, DISPATCH_METHOD, &params, NULL, NULL, &err);
4082  ok(hr == S_OK, "error %#x\n", hr);
4083 
4085  ok(V_VT(&ret) == VT_I4, "expected VT_I4, got %d\n", V_VT(&ret));
4086  ok(V_I4(&ret) == 1252, "expected 1252, got %d\n", V_I4(&ret));
4087 
4088  VariantInit(&ret);
4089  hr = IWinHttpRequest_Invoke(request, id, &IID_NULL, 0, DISPATCH_METHOD, &params, &ret, NULL, &err);
4090  ok(hr == S_OK, "error %#x\n", hr);
4091 
4093  ok(V_VT(&ret) == VT_I4, "expected VT_I4, got %d\n", V_VT(&ret));
4094  ok(V_I4(&ret) == 1252, "expected 1252, got %d\n", V_I4(&ret));
4095 
4096  VariantInit(&ret);
4097  hr = IWinHttpRequest_Invoke(request, id, &IID_NULL, 0, DISPATCH_PROPERTYPUT, &params, &ret, NULL, &err);
4098  ok(hr == S_OK, "error %#x\n", hr);
4099 
4101  ok(V_VT(&ret) == VT_I4, "expected VT_I4, got %d\n", V_VT(&ret));
4102  ok(V_I4(&ret) == CP_UTF8, "expected CP_UTF8, got %d\n", V_I4(&ret));
4103 
4104  hr = IWinHttpRequest_Invoke(request, DISPID_HTTPREQUEST_OPTION, &IID_NULL, 0, DISPATCH_PROPERTYPUT, &params, NULL, NULL, NULL);
4105  ok(hr == S_OK, "error %#x\n", hr);
4106 
4107  hr = IWinHttpRequest_Invoke(request, 255, &IID_NULL, 0, DISPATCH_PROPERTYPUT, &params, NULL, NULL, NULL);
4108  ok(hr == DISP_E_MEMBERNOTFOUND, "error %#x\n", hr);
4109 
4110  VariantInit(&ret);
4111  hr = IWinHttpRequest_Invoke(request, DISPID_HTTPREQUEST_OPTION, &IID_IUnknown, 0, DISPATCH_PROPERTYPUT, &params, &ret, NULL, &err);
4112  ok(hr == DISP_E_UNKNOWNINTERFACE, "error %#x\n", hr);
4113 
4114  VariantInit(&ret);
4115  if (0) /* crashes */
4116  hr = IWinHttpRequest_Invoke(request, DISPID_HTTPREQUEST_OPTION, &IID_NULL, 0, DISPATCH_PROPERTYPUT, NULL, &ret, NULL, &err);
4117 
4118  params.cArgs = 1;
4119  hr = IWinHttpRequest_Invoke(request, DISPID_HTTPREQUEST_OPTION, &IID_NULL, 0, DISPATCH_PROPERTYPUT, &params, &ret, NULL, &err);
4120  ok(hr == DISP_E_TYPEMISMATCH, "error %#x\n", hr);
4121 
4122  VariantInit(&arg[2]);
4123  params.cArgs = 3;
4124  hr = IWinHttpRequest_Invoke(request, DISPID_HTTPREQUEST_OPTION, &IID_NULL, 0, DISPATCH_PROPERTYPUT, &params, &ret, NULL, &err);
4125 todo_wine
4126  ok(hr == S_OK, "error %#x\n", hr);
4127 
4128  VariantInit(&arg[0]);
4129  VariantInit(&arg[1]);
4130  VariantInit(&arg[2]);
4131 
4132  params.cArgs = 1;
4133  V_VT(&arg[0]) = VT_I4;
4135  hr = IWinHttpRequest_Invoke(request, DISPID_HTTPREQUEST_OPTION, &IID_NULL, 0, DISPATCH_PROPERTYGET, &params, NULL, NULL, NULL);
4136  ok(hr == S_OK, "error %#x\n", hr);
4137 
4138  V_VT(&ret) = 0xdead;
4139  V_I4(&ret) = 0xbeef;
4141  ok(hr == S_OK, "error %#x\n", hr);
4142  ok(V_VT(&ret) == VT_I4, "expected VT_I4, got %d\n", V_VT(&ret));
4143  ok(V_I4(&ret) == CP_UTF8, "expected CP_UTF8, got %d\n", V_I4(&ret));
4144 
4145  V_VT(&ret) = 0xdead;
4146  V_I4(&ret) = 0xbeef;
4147  hr = IWinHttpRequest_Invoke(request, DISPID_HTTPREQUEST_OPTION, &IID_NULL, 0, DISPATCH_METHOD, &params, &ret, NULL, NULL);
4148  ok(hr == S_OK, "error %#x\n", hr);
4149  ok(V_VT(&ret) == VT_I4, "expected VT_I4, got %d\n", V_VT(&ret));
4150  ok(V_I4(&ret) == CP_UTF8, "expected CP_UTF8, got %d\n", V_I4(&ret));
4151 
4153  ok(hr == S_OK, "error %#x\n", hr);
4154 
4155  V_VT(&ret) = 0xdead;
4156  V_I4(&ret) = 0xbeef;
4157  hr = IWinHttpRequest_Invoke(request, DISPID_HTTPREQUEST_OPTION, &IID_NULL, 0, 0, &params, &ret, NULL, NULL);
4158  ok(hr == S_OK, "error %#x\n", hr);
4159  ok(V_VT(&ret) == VT_EMPTY, "expected VT_EMPTY, got %d\n", V_VT(&ret));
4160  ok(V_I4(&ret) == 0xbeef || V_I4(&ret) == 0 /* Win8 */, "expected 0xdead, got %d\n", V_I4(&ret));
4161 
4162  hr = IWinHttpRequest_Invoke(request, DISPID_HTTPREQUEST_OPTION, &IID_NULL, 0, 0, &params, NULL, NULL, NULL);
4163  ok(hr == S_OK, "error %#x\n", hr);
4164 
4166  ok(hr == DISP_E_UNKNOWNINTERFACE, "error %#x\n", hr);
4167 
4168  params.cArgs = 2;
4169  hr = IWinHttpRequest_Invoke(request, DISPID_HTTPREQUEST_OPTION, &IID_NULL, 0, DISPATCH_PROPERTYGET, &params, NULL, NULL, NULL);
4170 todo_wine
4171  ok(hr == S_OK, "error %#x\n", hr);
4172 
4173  params.cArgs = 0;
4174  hr = IWinHttpRequest_Invoke(request, DISPID_HTTPREQUEST_OPTION, &IID_NULL, 0, DISPATCH_PROPERTYGET, &params, NULL, NULL, NULL);
4175  ok(hr == DISP_E_PARAMNOTFOUND, "error %#x\n", hr);
4176 
4177  SysFreeString(utf8);
4178 
4179  params.cArgs = 1;
4180  V_VT(&arg[0]) = VT_I4;
4182  VariantInit(&ret);
4183  hr = IWinHttpRequest_Invoke(request, DISPID_HTTPREQUEST_SETAUTOLOGONPOLICY, &IID_NULL, 0,
4185  ok(hr == S_OK, "error %#x\n", hr);
4186 
4187  IWinHttpRequest_Release(request);
4188 
4189  CoUninitialize();
4190 }
WCHAR OLECHAR
Definition: compat.h:1933
Definition: compat.h:1939
#define DISPATCH_PROPERTYGET
Definition: oleauto.h:1007
HRESULT hr
Definition: shlfolder.c:183
#define open
Definition: acwin.h:95
#define V_R8(A)
Definition: oleauto.h:262
static const WCHAR utf8W[]
Definition: mxwriter.c:86
static void request_get_property(IWinHttpRequest *request, int property, VARIANT *ret)
Definition: winhttp.c:3957
#define DISP_E_MEMBERNOTFOUND
Definition: winerror.h:2512
const char * wine_dbgstr_guid(const GUID *guid)
void * arg
Definition: msvc.h:12
OLECHAR * BSTR
Definition: compat.h:1934
void WINAPI VariantInit(VARIANTARG *pVarg)
Definition: variant.c:571
HRESULT WINAPI DECLSPEC_HOTPATCH CLSIDFromProgID(LPCOLESTR progid, LPCLSID clsid)
Definition: compobj.c:2511
#define DISP_E_PARAMNOTFOUND
Definition: winerror.h:2513
#define V_I4(A)
Definition: oleauto.h:247
#define DISPATCH_METHOD
Definition: oleauto.h:1006
#define regid
Definition: ecma_167.h:64
#define CP_UTF8
Definition: nls.h:20
GLenum const GLfloat * params
Definition: glext.h:5645
unsigned int BOOL
Definition: ntddk_ex.h:94
static const WCHAR optionW[]
Definition: htmlelem.c:36
smooth NULL
Definition: ftsmooth.c:416
Definition: getopt.h:108
BSTR WINAPI SysAllocString(LPCOLESTR str)
Definition: oleaut.c:241
#define DISPATCH_PROPERTYPUT
Definition: oleauto.h:1008
#define DISP_E_TYPEMISMATCH
Definition: winerror.h:2514
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:77
const GUID IID_IUnknown
#define DISP_E_UNKNOWNINTERFACE
Definition: winerror.h:2511
#define DISPID_HTTPREQUEST_SETAUTOLOGONPOLICY