ReactOS  0.4.13-dev-99-g7e18b6d
session.c File Reference
#include "config.h"
#include "wine/port.h"
#include "wine/debug.h"
#include <stdarg.h>
#include <stdlib.h>
#include "windef.h"
#include "winbase.h"
#include "winsock2.h"
#include "ws2ipdef.h"
#include "winhttp.h"
#include "wincrypt.h"
#include "winreg.h"
#include "ole2.h"
#include "dispex.h"
#include "activscp.h"
#include "winhttp_private.h"
Include dependency graph for session.c:

Go to the source code of this file.

Classes

struct  connection_settings_header
 
struct  AUTO_PROXY_SCRIPT_BUFFER
 

Macros

#define USE_WS_PREFIX
 
#define COBJMACROS
 
#define DEFAULT_RESOLVE_TIMEOUT   0
 
#define DEFAULT_CONNECT_TIMEOUT   20000
 
#define DEFAULT_SEND_TIMEOUT   30000
 
#define DEFAULT_RECEIVE_TIMEOUT   30000
 
#define MAX_HOST_NAME_LENGTH   256
 
#define INTERNET_MAX_URL_LENGTH   2084
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (winhttp)
 
void set_last_error (DWORD error)
 
DWORD get_last_error (void)
 
void send_callback (object_header_t *hdr, DWORD status, LPVOID info, DWORD buflen)
 
BOOL WINAPI WinHttpCheckPlatform (void)
 
static void session_destroy (object_header_t *hdr)
 
static BOOL session_query_option (object_header_t *hdr, DWORD option, LPVOID buffer, LPDWORD buflen)
 
static BOOL session_set_option (object_header_t *hdr, DWORD option, LPVOID buffer, DWORD buflen)
 
HINTERNET WINAPI WinHttpOpen (LPCWSTR agent, DWORD access, LPCWSTR proxy, LPCWSTR bypass, DWORD flags)
 
static void connect_destroy (object_header_t *hdr)
 
static BOOL connect_query_option (object_header_t *hdr, DWORD option, LPVOID buffer, LPDWORD buflen)
 
static BOOL domain_matches (LPCWSTR server, LPCWSTR domain)
 
static BOOL should_bypass_proxy (session_t *session, LPCWSTR server)
 
BOOL set_server_for_hostname (connect_t *connect, LPCWSTR server, INTERNET_PORT port)
 
HINTERNET WINAPI WinHttpConnect (HINTERNET hsession, LPCWSTR server, INTERNET_PORT port, DWORD reserved)
 
static void request_destroy (object_header_t *hdr)
 
static void str_to_buffer (WCHAR *buffer, const WCHAR *str, LPDWORD buflen)
 
static WCHARblob_to_str (DWORD encoding, CERT_NAME_BLOB *blob)
 
static BOOL convert_sockaddr (const struct sockaddr *addr, SOCKADDR_STORAGE *addr_storage)
 
static BOOL request_query_option (object_header_t *hdr, DWORD option, LPVOID buffer, LPDWORD buflen)
 
static WCHARbuffer_to_str (WCHAR *buffer, DWORD buflen)
 
static BOOL request_set_option (object_header_t *hdr, DWORD option, LPVOID buffer, DWORD buflen)
 
static BOOL store_accept_types (request_t *request, const WCHAR **accept_types)
 
HINTERNET WINAPI WinHttpOpenRequest (HINTERNET hconnect, LPCWSTR verb, LPCWSTR object, LPCWSTR version, LPCWSTR referrer, LPCWSTR *types, DWORD flags)
 
BOOL WINAPI WinHttpCloseHandle (HINTERNET handle)
 
static BOOL query_option (object_header_t *hdr, DWORD option, LPVOID buffer, LPDWORD buflen)
 
BOOL WINAPI WinHttpQueryOption (HINTERNET handle, DWORD option, LPVOID buffer, LPDWORD buflen)
 
static BOOL set_option (object_header_t *hdr, DWORD option, LPVOID buffer, DWORD buflen)
 
BOOL WINAPI WinHttpSetOption (HINTERNET handle, DWORD option, LPVOID buffer, DWORD buflen)
 
static charget_computer_name (COMPUTER_NAME_FORMAT format)
 
static BOOL is_domain_suffix (const char *domain, const char *suffix)
 
static int reverse_lookup (const struct addrinfo *ai, char *hostname, size_t len)
 
static WCHARbuild_wpad_url (const char *hostname, const struct addrinfo *ai)
 
static BOOL get_system_proxy_autoconfig_url (char *buf, DWORD buflen)
 
BOOL WINAPI WinHttpDetectAutoProxyConfigUrl (DWORD flags, LPWSTR *url)
 
static void copy_char_to_wchar_sz (const BYTE *src, DWORD len, WCHAR *dst)
 
BOOL WINAPI WinHttpGetDefaultProxyConfiguration (WINHTTP_PROXY_INFO *info)
 
BOOL WINAPI WinHttpGetIEProxyConfigForCurrentUser (WINHTTP_CURRENT_USER_IE_PROXY_CONFIG *config)
 
static BOOL parse_script_result (const char *result, WINHTTP_PROXY_INFO *info)
 
static chardownload_script (const WCHAR *url, DWORD *out_size)
 
BOOL WINAPI InternetDeInitializeAutoProxyDll (LPSTR, DWORD)
 
BOOL WINAPI InternetGetProxyInfo (LPCSTR, DWORD, LPSTR, DWORD, LPSTR *, LPDWORD)
 
BOOL WINAPI InternetInitializeAutoProxyDll (DWORD, LPSTR, LPSTR, void *, struct AUTO_PROXY_SCRIPT_BUFFER *)
 
static BOOL run_script (char *script, DWORD size, const WCHAR *url, WINHTTP_PROXY_INFO *info)
 
BOOL WINAPI WinHttpGetProxyForUrl (HINTERNET hsession, LPCWSTR url, WINHTTP_AUTOPROXY_OPTIONS *options, WINHTTP_PROXY_INFO *info)
 
BOOL WINAPI WinHttpSetDefaultProxyConfiguration (WINHTTP_PROXY_INFO *info)
 
WINHTTP_STATUS_CALLBACK WINAPI WinHttpSetStatusCallback (HINTERNET handle, WINHTTP_STATUS_CALLBACK callback, DWORD flags, DWORD_PTR reserved)
 
BOOL WINAPI WinHttpSetTimeouts (HINTERNET handle, int resolve, int connect, int send, int receive)
 
BOOL WINAPI WinHttpTimeFromSystemTime (const SYSTEMTIME *time, LPWSTR string)
 
BOOL WINAPI WinHttpTimeToSystemTime (LPCWSTR string, SYSTEMTIME *time)
 

Variables

static const object_vtbl_t session_vtbl
 
static const object_vtbl_t connect_vtbl
 
static const object_vtbl_t request_vtbl
 
static const WCHAR Connections []
 
static const WCHAR WinHttpSettings []
 
static const DWORD WINHTTP_SETTINGS_MAGIC = 0x18
 
static const DWORD WININET_SETTINGS_MAGIC = 0x46
 
static const DWORD PROXY_TYPE_DIRECT = 1
 
static const DWORD PROXY_TYPE_PROXY = 2
 
static const DWORD PROXY_USE_PAC_SCRIPT = 4
 
static const DWORD PROXY_AUTODETECT_SETTINGS = 8
 
static const WCHAR wkday [7][4]
 
static const WCHAR month [12][4]
 

Macro Definition Documentation

◆ COBJMACROS

#define COBJMACROS

Definition at line 45 of file session.c.

◆ DEFAULT_CONNECT_TIMEOUT

#define DEFAULT_CONNECT_TIMEOUT   20000

Definition at line 55 of file session.c.

◆ DEFAULT_RECEIVE_TIMEOUT

#define DEFAULT_RECEIVE_TIMEOUT   30000

Definition at line 57 of file session.c.

◆ DEFAULT_RESOLVE_TIMEOUT

#define DEFAULT_RESOLVE_TIMEOUT   0

Definition at line 54 of file session.c.

◆ DEFAULT_SEND_TIMEOUT

#define DEFAULT_SEND_TIMEOUT   30000

Definition at line 56 of file session.c.

◆ INTERNET_MAX_URL_LENGTH

#define INTERNET_MAX_URL_LENGTH   2084

Definition at line 1380 of file session.c.

◆ MAX_HOST_NAME_LENGTH

#define MAX_HOST_NAME_LENGTH   256

Definition at line 426 of file session.c.

◆ USE_WS_PREFIX

#define USE_WS_PREFIX

Definition at line 38 of file session.c.

Function Documentation

◆ blob_to_str()

static WCHAR* blob_to_str ( DWORD  encoding,
CERT_NAME_BLOB blob 
)
static

Definition at line 643 of file session.c.

644 {
645  WCHAR *ret;
647 
649  if ((ret = LocalAlloc( 0, size * sizeof(WCHAR) )))
651 
652  return ret;
653 }
Definition: image.c:133
DWORD WINAPI CertNameToStrW(DWORD dwCertEncodingType, PCERT_NAME_BLOB pName, DWORD dwStrType, LPWSTR psz, DWORD csz)
Definition: str.c:702
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
smooth NULL
Definition: ftsmooth.c:416
#define CERT_NAME_STR_CRLF_FLAG
Definition: wincrypt.h:3490
GLsizeiptr size
Definition: glext.h:5919
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
ed encoding
Definition: write.c:2847
#define CERT_SIMPLE_NAME_STR
Definition: wincrypt.h:3484
HLOCAL NTAPI LocalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:1373

Referenced by request_query_option().

◆ buffer_to_str()

static WCHAR* buffer_to_str ( WCHAR buffer,
DWORD  buflen 
)
static

Definition at line 883 of file session.c.

884 {
885  WCHAR *ret;
886  if ((ret = heap_alloc( (buflen + 1) * sizeof(WCHAR))))
887  {
888  memcpy( ret, buffer, buflen * sizeof(WCHAR) );
889  ret[buflen] = 0;
890  return ret;
891  }
893  return NULL;
894 }
GLuint buffer
Definition: glext.h:5915
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
smooth NULL
Definition: ftsmooth.c:416
__wchar_t WCHAR
Definition: xmlstorage.h:180
int ret
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
void set_last_error(DWORD error)
Definition: session.c:59
#define ERROR_OUTOFMEMORY
Definition: deptool.c:13

Referenced by request_set_option().

◆ build_wpad_url()

static WCHAR* build_wpad_url ( const char hostname,
const struct addrinfo ai 
)
static

Definition at line 1324 of file session.c.

1325 {
1326  static const WCHAR httpW[] = {'h','t','t','p',':','/','/',0};
1327  static const WCHAR wpadW[] = {'/','w','p','a','d','.','d','a','t',0};
1328  char name[NI_MAXHOST];
1329  WCHAR *ret, *p;
1330  int len;
1331 
1332  while (ai && ai->ai_family != AF_INET && ai->ai_family != AF_INET6) ai = ai->ai_next;
1333  if (!ai) return NULL;
1334 
1335  if (!reverse_lookup( ai, name, sizeof(name) )) hostname = name;
1336 
1337  len = strlenW( httpW ) + strlen( hostname ) + strlenW( wpadW );
1338  if (!(ret = p = GlobalAlloc( 0, (len + 1) * sizeof(WCHAR) ))) return NULL;
1339  strcpyW( p, httpW );
1340  p += strlenW( httpW );
1341  while (*hostname) { *p++ = *hostname++; }
1342  strcpyW( p, wpadW );
1343  return ret;
1344 }
HGLOBAL NTAPI GlobalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:368
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
char * hostname
Definition: ftp.c:88
smooth NULL
Definition: ftsmooth.c:416
#define AF_INET6
Definition: winsock.h:369
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NI_MAXHOST
Definition: ws2def.h:359
int ret
GLenum GLsizei len
Definition: glext.h:6722
WINE_UNICODE_INLINE WCHAR * strcpyW(WCHAR *dst, const WCHAR *src)
Definition: unicode.h:219
struct addrinfo * ai_next
Definition: ws2def.h:672
Definition: name.c:36
static int reverse_lookup(const struct addrinfo *ai, char *hostname, size_t len)
Definition: session.c:1315
#define AF_INET
Definition: tcpip.h:117
static const WCHAR httpW[]
Definition: assoc.c:94
GLfloat GLfloat p
Definition: glext.h:8902
GLuint const GLchar * name
Definition: glext.h:6031
int ai_family
Definition: ws2def.h:666

Referenced by WinHttpDetectAutoProxyConfigUrl().

◆ connect_destroy()

static void connect_destroy ( object_header_t hdr)
static

Definition at line 310 of file session.c.

311 {
313 
314  TRACE("%p\n", connect);
315 
316  release_object( &connect->session->hdr );
317 
318  heap_free( connect->hostname );
319  heap_free( connect->servername );
320  heap_free( connect->username );
321  heap_free( connect->password );
322  heap_free( connect );
323 }
char hdr[14]
Definition: iptest.cpp:33
INT WSAAPI connect(IN SOCKET s, IN CONST struct sockaddr *name, IN INT namelen)
Definition: sockctrl.c:23
#define TRACE(s)
Definition: solgame.cpp:4
void release_object(object_header_t *hdr)
Definition: handle.c:73
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

◆ connect_query_option()

static BOOL connect_query_option ( object_header_t hdr,
DWORD  option,
LPVOID  buffer,
LPDWORD  buflen 
)
static

Definition at line 325 of file session.c.

326 {
328 
329  switch (option)
330  {
332  {
333  if (!buffer || *buflen < sizeof(HINTERNET))
334  {
335  *buflen = sizeof(HINTERNET);
337  return FALSE;
338  }
339 
340  *(HINTERNET *)buffer = ((object_header_t *)connect->session)->handle;
341  *buflen = sizeof(HINTERNET);
342  return TRUE;
343  }
345  *(DWORD *)buffer = connect->session->resolve_timeout;
346  *buflen = sizeof(DWORD);
347  return TRUE;
349  *(DWORD *)buffer = connect->session->connect_timeout;
350  *buflen = sizeof(DWORD);
351  return TRUE;
353  *(DWORD *)buffer = connect->session->send_timeout;
354  *buflen = sizeof(DWORD);
355  return TRUE;
357  *(DWORD *)buffer = connect->session->recv_timeout;
358  *buflen = sizeof(DWORD);
359  return TRUE;
360  default:
361  FIXME("unimplemented option %u\n", option);
363  return FALSE;
364  }
365 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define WINHTTP_OPTION_RECEIVE_TIMEOUT
Definition: winhttp.h:99
LPVOID HINTERNET
Definition: winhttp.h:32
#define TRUE
Definition: types.h:120
char hdr[14]
Definition: iptest.cpp:33
#define WINHTTP_OPTION_SEND_TIMEOUT
Definition: winhttp.h:98
GLuint buffer
Definition: glext.h:5915
#define WINHTTP_OPTION_PARENT_HANDLE
Definition: winhttp.h:104
INT WSAAPI connect(IN SOCKET s, IN CONST struct sockaddr *name, IN INT namelen)
Definition: sockctrl.c:23
#define FIXME(fmt,...)
Definition: debug.h:110
Definition: getopt.h:108
unsigned long DWORD
Definition: ntddk_ex.h:95
#define WINHTTP_OPTION_RESOLVE_TIMEOUT
Definition: winhttp.h:95
void set_last_error(DWORD error)
Definition: session.c:59
#define WINHTTP_OPTION_CONNECT_TIMEOUT
Definition: winhttp.h:96
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10

◆ convert_sockaddr()

static BOOL convert_sockaddr ( const struct sockaddr addr,
SOCKADDR_STORAGE *  addr_storage 
)
static

Definition at line 655 of file session.c.

656 {
657 #if !defined(__MINGW32__) && !defined(_MSC_VER)
658  switch (addr->sa_family)
659  {
660  case AF_INET:
661  {
662  const struct sockaddr_in *addr_unix = (const struct sockaddr_in *)addr;
663  struct WS_sockaddr_in *addr_win = (struct WS_sockaddr_in *)addr_storage;
664  char *p;
665 
666  addr_win->sin_family = WS_AF_INET;
667  addr_win->sin_port = addr_unix->sin_port;
668  memcpy( &addr_win->sin_addr, &addr_unix->sin_addr, 4 );
669  p = (char *)&addr_win->sin_addr + 4;
670  memset( p, 0, sizeof(*addr_storage) - (p - (char *)addr_win) );
671  return TRUE;
672  }
673  case AF_INET6:
674  {
675  const struct sockaddr_in6 *addr_unix = (const struct sockaddr_in6 *)addr;
676  struct WS_sockaddr_in6 *addr_win = (struct WS_sockaddr_in6 *)addr_storage;
677 
678  addr_win->sin6_family = WS_AF_INET6;
679  addr_win->sin6_port = addr_unix->sin6_port;
680  addr_win->sin6_flowinfo = addr_unix->sin6_flowinfo;
681  memcpy( &addr_win->sin6_addr, &addr_unix->sin6_addr, 16 );
682 #ifdef HAVE_STRUCT_SOCKADDR_IN6_SIN6_SCOPE_ID
683  addr_win->sin6_scope_id = addr_unix->sin6_scope_id;
684 #else
685  addr_win->sin6_scope_id = 0;
686 #endif
687  memset( addr_win + 1, 0, sizeof(*addr_storage) - sizeof(*addr_win) );
688  return TRUE;
689  }
690  default:
691  ERR("unhandled family %u\n", addr->sa_family);
692  return FALSE;
693  }
694 #else
695  switch (addr->sa_family)
696  {
697  case AF_INET:
698  {
699  struct sockaddr_in *addr_in = (struct sockaddr_in *)addr_storage;
700 
701  memcpy( addr_in, addr, sizeof(*addr_in) );
702  memset( addr_in + 1, 0, sizeof(*addr_storage) - sizeof(*addr_in) );
703  return TRUE;
704  }
705  case AF_INET6:
706  {
707  struct sockaddr_in6 *addr_in6 = (struct sockaddr_in6 *)addr_storage;
708 
709  memcpy( addr_in6, addr, sizeof(*addr_in6) );
710  memset( addr_in6 + 1, 0, sizeof(*addr_storage) - sizeof(*addr_in6) );
711  return TRUE;
712  }
713  default:
714  ERR("unhandled family %u\n", addr->sa_family);
715  return FALSE;
716  }
717 #endif
718 }
#define TRUE
Definition: types.h:120
ULONG sin6_flowinfo
Definition: ws2ipdef.h:181
u_short sin_port
Definition: winsock.h:511
USHORT sin6_port
Definition: ws2ipdef.h:180
ULONG sin6_scope_id
Definition: ws2ipdef.h:184
#define AF_INET6
Definition: winsock.h:369
IN6_ADDR sin6_addr
Definition: ws2ipdef.h:182
GLenum const GLvoid * addr
Definition: glext.h:9621
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
struct in_addr sin_addr
Definition: winsock.h:512
#define ERR(fmt,...)
Definition: debug.h:109
#define AF_INET
Definition: tcpip.h:117
GLfloat GLfloat p
Definition: glext.h:8902
#define memset(x, y, z)
Definition: compat.h:39

Referenced by request_query_option().

◆ copy_char_to_wchar_sz()

static void copy_char_to_wchar_sz ( const BYTE src,
DWORD  len,
WCHAR dst 
)
inlinestatic

Definition at line 1491 of file session.c.

1492 {
1493  const BYTE *begin;
1494 
1495  for (begin = src; src - begin < len; src++, dst++)
1496  *dst = *src;
1497  *dst = 0;
1498 }
static clock_t begin
Definition: xmllint.c:466
GLenum GLsizei len
Definition: glext.h:6722
unsigned char BYTE
Definition: mem.h:68
GLenum src
Definition: glext.h:6340
GLenum GLenum dst
Definition: glext.h:6340

Referenced by WinHttpGetDefaultProxyConfiguration(), and WinHttpGetIEProxyConfigForCurrentUser().

◆ domain_matches()

static BOOL domain_matches ( LPCWSTR  server,
LPCWSTR  domain 
)
static

Definition at line 374 of file session.c.

375 {
376  static const WCHAR localW[] = { '<','l','o','c','a','l','>',0 };
377  BOOL ret = FALSE;
378 
379  if (!strcmpiW( domain, localW ) && !strchrW( server, '.' ))
380  ret = TRUE;
381  else if (*domain == '*')
382  {
383  if (domain[1] == '.')
384  {
385  LPCWSTR dot;
386 
387  /* For a hostname to match a wildcard, the last domain must match
388  * the wildcard exactly. E.g. if the wildcard is *.a.b, and the
389  * hostname is www.foo.a.b, it matches, but a.b does not.
390  */
391  dot = strchrW( server, '.' );
392  if (dot)
393  {
394  int len = strlenW( dot + 1 );
395 
396  if (len > strlenW( domain + 2 ))
397  {
398  LPCWSTR ptr;
399 
400  /* The server's domain is longer than the wildcard, so it
401  * could be a subdomain. Compare the last portion of the
402  * server's domain.
403  */
404  ptr = dot + len + 1 - strlenW( domain + 2 );
405  if (!strcmpiW( ptr, domain + 2 ))
406  {
407  /* This is only a match if the preceding character is
408  * a '.', i.e. that it is a matching domain. E.g.
409  * if domain is '*.b.c' and server is 'www.ab.c' they
410  * do not match.
411  */
412  ret = *(ptr - 1) == '.';
413  }
414  }
415  else
416  ret = !strcmpiW( dot + 1, domain + 2 );
417  }
418  }
419  }
420  else
421  ret = !strcmpiW( server, domain );
422  return ret;
423 }
#define TRUE
Definition: types.h:120
static rfbScreenInfoPtr server
Definition: vnc.c:74
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
WINE_UNICODE_INLINE WCHAR * strchrW(const WCHAR *str, WCHAR ch)
Definition: unicode.h:248
unsigned int BOOL
Definition: ntddk_ex.h:94
static PVOID ptr
Definition: dispmode.c:27
__wchar_t WCHAR
Definition: xmlstorage.h:180
int ret
GLenum GLsizei len
Definition: glext.h:6722
#define strcmpiW(s1, s2)
Definition: unicode.h:39

Referenced by should_bypass_proxy().

◆ download_script()

static char* download_script ( const WCHAR url,
DWORD out_size 
)
static

Definition at line 1744 of file session.c.

1745 {
1746  static const WCHAR typeW[] = {'*','/','*',0};
1747  static const WCHAR *acceptW[] = {typeW, NULL};
1748  HINTERNET ses, con = NULL, req = NULL;
1749  WCHAR *hostname;
1750  URL_COMPONENTSW uc;
1751  DWORD status, size = sizeof(status), offset, to_read, bytes_read, flags = 0;
1752  char *tmp, *buffer = NULL;
1753 
1754  *out_size = 0;
1755 
1756  memset( &uc, 0, sizeof(uc) );
1757  uc.dwStructSize = sizeof(uc);
1758  uc.dwHostNameLength = -1;
1759  uc.dwUrlPathLength = -1;
1760  if (!WinHttpCrackUrl( url, 0, 0, &uc )) return NULL;
1761  if (!(hostname = heap_alloc( (uc.dwHostNameLength + 1) * sizeof(WCHAR) ))) return NULL;
1762  memcpy( hostname, uc.lpszHostName, uc.dwHostNameLength * sizeof(WCHAR) );
1763  hostname[uc.dwHostNameLength] = 0;
1764 
1765  if (!(ses = WinHttpOpen( NULL, WINHTTP_ACCESS_TYPE_NO_PROXY, NULL, NULL, 0 ))) goto done;
1766  if (!(con = WinHttpConnect( ses, hostname, uc.nPort, 0 ))) goto done;
1768  if (!(req = WinHttpOpenRequest( con, NULL, uc.lpszUrlPath, NULL, NULL, acceptW, flags ))) goto done;
1769  if (!WinHttpSendRequest( req, NULL, 0, NULL, 0, 0, 0 )) goto done;
1770 
1771  if (!(WinHttpReceiveResponse( req, 0 ))) goto done;
1773  &size, NULL ) || status != HTTP_STATUS_OK) goto done;
1774 
1775  size = 4096;
1776  if (!(buffer = heap_alloc( size ))) goto done;
1777  to_read = size;
1778  offset = 0;
1779  for (;;)
1780  {
1781  if (!WinHttpReadData( req, buffer + offset, to_read, &bytes_read )) goto done;
1782  if (!bytes_read) break;
1783  to_read -= bytes_read;
1784  offset += bytes_read;
1785  *out_size += bytes_read;
1786  if (!to_read)
1787  {
1788  to_read = size;
1789  size *= 2;
1790  if (!(tmp = heap_realloc( buffer, size ))) goto done;
1791  buffer = tmp;
1792  }
1793  }
1794 
1795 done:
1796  WinHttpCloseHandle( req );
1797  WinHttpCloseHandle( con );
1798  WinHttpCloseHandle( ses );
1799  heap_free( hostname );
1801  return buffer;
1802 }
HINTERNET WINAPI WinHttpConnect(HINTERNET hsession, LPCWSTR server, INTERNET_PORT port, DWORD reserved)
Definition: session.c:524
static HANDLE PIO_APC_ROUTINE PVOID PIO_STATUS_BLOCK ULONG PVOID ULONG PVOID ULONG out_size
Definition: file.c:100
BOOL WINAPI WinHttpCloseHandle(HINTERNET handle)
Definition: session.c:1153
#define WINHTTP_ACCESS_TYPE_NO_PROXY
Definition: winhttp.h:63
DWORD dwStructSize
Definition: wininet.h:211
GLintptr offset
Definition: glext.h:5920
static const WCHAR typeW[]
Definition: name.c:49
#define WINHTTP_QUERY_STATUS_CODE
Definition: winhttp.h:317
GLuint buffer
Definition: glext.h:5915
LPWSTR lpszHostName
Definition: wininet.h:215
static void * heap_realloc(void *mem, size_t len)
Definition: appwiz.h:70
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
char * hostname
Definition: ftp.c:88
BOOL WINAPI WinHttpQueryHeaders(HINTERNET hrequest, DWORD level, LPCWSTR name, LPVOID buffer, LPDWORD buflen, LPDWORD index)
Definition: request.c:831
INTERNET_PORT nPort
Definition: wininet.h:217
BOOL WINAPI WinHttpReceiveResponse(HINTERNET hrequest, LPVOID reserved)
Definition: request.c:2692
smooth NULL
Definition: ftsmooth.c:416
#define WINHTTP_FLAG_SECURE
Definition: winhttp.h:60
BOOL WINAPI WinHttpCrackUrl(LPCWSTR url, DWORD len, DWORD flags, LPURL_COMPONENTSW uc)
Definition: url.c:183
GLsizeiptr size
Definition: glext.h:5919
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define WINHTTP_QUERY_FLAG_NUMBER
Definition: winhttp.h:377
static const WCHAR url[]
Definition: encode.c:1432
INTERNET_SCHEME nScheme
Definition: wininet.h:214
ULONG to_read
Definition: btrfs.c:3875
unsigned long DWORD
Definition: ntddk_ex.h:95
#define HTTP_STATUS_OK
Definition: winhttp.h:240
GLbitfield flags
Definition: glext.h:7161
DWORD dwHostNameLength
Definition: wininet.h:216
LPWSTR lpszUrlPath
Definition: wininet.h:222
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
DWORD dwUrlPathLength
Definition: wininet.h:223
#define ERROR_WINHTTP_UNABLE_TO_DOWNLOAD_SCRIPT
Definition: winhttp.h:221
HINTERNET WINAPI WinHttpOpen(LPCWSTR agent, DWORD access, LPCWSTR proxy, LPCWSTR bypass, DWORD flags)
Definition: session.c:246
void set_last_error(DWORD error)
Definition: session.c:59
HINTERNET WINAPI WinHttpOpenRequest(HINTERNET hconnect, LPCWSTR verb, LPCWSTR object, LPCWSTR version, LPCWSTR referrer, LPCWSTR *types, DWORD flags)
Definition: session.c:1061
#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
BOOL WINAPI WinHttpReadData(HINTERNET hrequest, LPVOID buffer, DWORD to_read, LPDWORD read)
Definition: request.c:2811
static BOOL heap_free(void *mem)
Definition: appwiz.h:75
Definition: ps.c:97

Referenced by WinHttpGetProxyForUrl().

◆ get_computer_name()

static char* get_computer_name ( COMPUTER_NAME_FORMAT  format)
static

Definition at line 1290 of file session.c.

1291 {
1292  char *ret;
1293  DWORD size = 0;
1294 
1296  if (GetLastError() != ERROR_MORE_DATA) return NULL;
1297  if (!(ret = heap_alloc( size ))) return NULL;
1298  if (!GetComputerNameExA( format, ret, &size ))
1299  {
1300  heap_free( ret );
1301  return NULL;
1302  }
1303  return ret;
1304 }
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
BOOL WINAPI GetComputerNameExA(COMPUTER_NAME_FORMAT, LPSTR, LPDWORD)
Definition: compname.c:370
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
smooth NULL
Definition: ftsmooth.c:416
GLsizeiptr size
Definition: glext.h:5919
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
#define ERROR_MORE_DATA
Definition: dderror.h:13
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

Referenced by WinHttpDetectAutoProxyConfigUrl().

◆ get_last_error()

◆ get_system_proxy_autoconfig_url()

static BOOL get_system_proxy_autoconfig_url ( char buf,
DWORD  buflen 
)
static

Definition at line 1346 of file session.c.

1347 {
1348 #if defined(MAC_OS_X_VERSION_10_6) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6
1349  CFDictionaryRef settings = CFNetworkCopySystemProxySettings();
1350  const void *ref;
1351  BOOL ret = FALSE;
1352 
1353  if (!settings) return FALSE;
1354 
1355  if (!(ref = CFDictionaryGetValue( settings, kCFNetworkProxiesProxyAutoConfigURLString )))
1356  {
1357  CFRelease( settings );
1358  return FALSE;
1359  }
1360  if (CFStringGetCString( ref, buf, buflen, kCFStringEncodingASCII ))
1361  {
1362  TRACE( "returning %s\n", debugstr_a(buf) );
1363  ret = TRUE;
1364  }
1365  CFRelease( settings );
1366  return ret;
1367 #else
1368  static BOOL first = TRUE;
1369  if (first)
1370  {
1371  FIXME( "no support on this platform\n" );
1372  first = FALSE;
1373  }
1374  else
1375  TRACE( "no support on this platform\n" );
1376  return FALSE;
1377 #endif
1378 }
struct mke2fs_defaults settings[]
#define TRUE
Definition: types.h:120
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
const GLint * first
Definition: glext.h:5794
Definition: send.c:47
unsigned int BOOL
Definition: ntddk_ex.h:94
GLenum GLint ref
Definition: glext.h:6028
#define FIXME(fmt,...)
Definition: debug.h:110
#define TRACE(s)
Definition: solgame.cpp:4
#define debugstr_a
Definition: kernel32.h:31
int ret

Referenced by WinHttpDetectAutoProxyConfigUrl().

◆ InternetDeInitializeAutoProxyDll()

BOOL WINAPI InternetDeInitializeAutoProxyDll ( LPSTR  ,
DWORD   
)

Definition at line 131 of file main.c.

132 {
133  TRACE( "%s, %u\n", debugstr_a(mime), reserved );
134 
136 
137  heap_free( global_script->text );
138  global_script->text = NULL;
139 
141  return TRUE;
142 }
#define TRUE
Definition: types.h:120
const WCHAR * mime
Definition: mimefilter.c:512
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
static struct pac_script * global_script
Definition: main.c:126
r reserved
Definition: btrfs.c:2655
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
#define debugstr_a
Definition: kernel32.h:31
static CRITICAL_SECTION cs_jsproxy
Definition: main.c:66
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

Referenced by run_script().

◆ InternetGetProxyInfo()

BOOL WINAPI InternetGetProxyInfo ( LPCSTR  ,
DWORD  ,
LPSTR  ,
DWORD  ,
LPSTR ,
LPDWORD   
)

Referenced by run_script().

◆ InternetInitializeAutoProxyDll()

BOOL WINAPI InternetInitializeAutoProxyDll ( DWORD  ,
LPSTR  ,
LPSTR  ,
void ,
struct AUTO_PROXY_SCRIPT_BUFFER  
)

Referenced by run_script().

◆ is_domain_suffix()

static BOOL is_domain_suffix ( const char domain,
const char suffix 
)
static

Definition at line 1306 of file session.c.

1307 {
1308  int len_domain = strlen( domain ), len_suffix = strlen( suffix );
1309 
1310  if (len_suffix > len_domain) return FALSE;
1311  if (!strcasecmp( domain + len_domain - len_suffix, suffix )) return TRUE;
1312  return FALSE;
1313 }
#define TRUE
Definition: types.h:120
#define strcasecmp
Definition: fake.h:9
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269

Referenced by WinHttpDetectAutoProxyConfigUrl().

◆ parse_script_result()

static BOOL parse_script_result ( const char result,
WINHTTP_PROXY_INFO info 
)
static

Definition at line 1710 of file session.c.

1711 {
1712  const char *p;
1713  WCHAR *q;
1714  int len;
1715 
1716  info->dwAccessType = WINHTTP_ACCESS_TYPE_NO_PROXY;
1717  info->lpszProxy = NULL;
1718  info->lpszProxyBypass = NULL;
1719 
1720  TRACE("%s\n", debugstr_a( result ));
1721 
1722  p = result;
1723  while (*p == ' ') p++;
1724  len = strlen( p );
1725  if (len >= 5 && !strncasecmp( p, "PROXY", sizeof("PROXY") - 1 ))
1726  {
1727  p += 5;
1728  while (*p == ' ') p++;
1729  if (!*p || *p == ';') return TRUE;
1730  if (!(info->lpszProxy = q = strdupAW( p ))) return FALSE;
1731  info->dwAccessType = WINHTTP_ACCESS_TYPE_NAMED_PROXY;
1732  for (; *q; q++)
1733  {
1734  if (*q == ' ' || *q == ';')
1735  {
1736  *q = 0;
1737  break;
1738  }
1739  }
1740  }
1741  return TRUE;
1742 }
#define WINHTTP_ACCESS_TYPE_NAMED_PROXY
Definition: winhttp.h:64
#define TRUE
Definition: types.h:120
#define WINHTTP_ACCESS_TYPE_NO_PROXY
Definition: winhttp.h:63
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
static WCHAR * strdupAW(const char *src, int len)
Definition: main.c:96
#define strncasecmp
Definition: fake.h:10
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define debugstr_a
Definition: kernel32.h:31
GLdouble GLdouble GLdouble GLdouble q
Definition: gl.h:2063
GLenum GLsizei len
Definition: glext.h:6722
GLfloat GLfloat p
Definition: glext.h:8902
GLuint64EXT * result
Definition: glext.h:11304

Referenced by run_script().

◆ query_option()

static BOOL query_option ( object_header_t hdr,
DWORD  option,
LPVOID  buffer,
LPDWORD  buflen 
)
static

Definition at line 1170 of file session.c.

1171 {
1172  BOOL ret = FALSE;
1173 
1174  if (!buflen)
1175  {
1177  return FALSE;
1178  }
1179 
1180  switch (option)
1181  {
1183  {
1184  if (!buffer || *buflen < sizeof(DWORD_PTR))
1185  {
1186  *buflen = sizeof(DWORD_PTR);
1188  return FALSE;
1189  }
1190 
1191  *(DWORD_PTR *)buffer = hdr->context;
1192  *buflen = sizeof(DWORD_PTR);
1193  return TRUE;
1194  }
1195  default:
1196  if (hdr->vtbl->query_option) ret = hdr->vtbl->query_option( hdr, option, buffer, buflen );
1197  else
1198  {
1199  FIXME("unimplemented option %u\n", option);
1201  return FALSE;
1202  }
1203  break;
1204  }
1205  return ret;
1206 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define TRUE
Definition: types.h:120
char hdr[14]
Definition: iptest.cpp:33
#define DWORD_PTR
Definition: treelist.c:76
GLuint buffer
Definition: glext.h:5915
unsigned int BOOL
Definition: ntddk_ex.h:94
#define FIXME(fmt,...)
Definition: debug.h:110
Definition: getopt.h:108
#define ERROR_WINHTTP_INCORRECT_HANDLE_TYPE
Definition: winhttp.h:199
#define WINHTTP_OPTION_CONTEXT_VALUE
Definition: winhttp.h:112
int ret
uint32_t DWORD_PTR
Definition: typedefs.h:63
void set_last_error(DWORD error)
Definition: session.c:59
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10

Referenced by WinHttpQueryOption().

◆ request_destroy()

static void request_destroy ( object_header_t hdr)
static

Definition at line 587 of file session.c.

588 {
590  unsigned int i, j;
591 
592  TRACE("%p\n", request);
593 
594  if (request->task_thread)
595  {
596  /* Signal to the task proc to quit. It will call
597  this again when it does. */
598  HANDLE thread = request->task_thread;
599  request->task_thread = 0;
600  SetEvent( request->task_cancel );
601  CloseHandle( thread );
602  return;
603  }
604  release_object( &request->connect->hdr );
605 
606  destroy_authinfo( request->authinfo );
607  destroy_authinfo( request->proxy_authinfo );
608 
609  heap_free( request->verb );
610  heap_free( request->path );
611  heap_free( request->version );
612  heap_free( request->raw_headers );
613  heap_free( request->status_text );
614  for (i = 0; i < request->num_headers; i++)
615  {
616  heap_free( request->headers[i].field );
617  heap_free( request->headers[i].value );
618  }
619  heap_free( request->headers );
620  for (i = 0; i < TARGET_MAX; i++)
621  {
622  for (j = 0; j < SCHEME_MAX; j++)
623  {
624  heap_free( request->creds[i][j].username );
625  heap_free( request->creds[i][j].password );
626  }
627  }
628  heap_free( request );
629 }
#define CloseHandle
Definition: compat.h:398
char hdr[14]
Definition: iptest.cpp:33
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent(IN HANDLE hEvent)
Definition: synch.c:679
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
char path[256]
Definition: tftpd.h:94
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 GLint GLint j
Definition: glfuncs.h:250
#define TRACE(s)
Definition: solgame.cpp:4
static HANDLE thread
Definition: service.c:33
static void destroy_authinfo(struct authinfo *info)
void release_object(object_header_t *hdr)
Definition: handle.c:73
Definition: tftpd.h:85
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

◆ request_query_option()

static BOOL request_query_option ( object_header_t hdr,
DWORD  option,
LPVOID  buffer,
LPDWORD  buflen 
)
static

Definition at line 720 of file session.c.

721 {
723 
724  switch (option)
725  {
727  {
728  DWORD flags = 0;
729  int bits;
730 
731  if (!buffer || *buflen < sizeof(flags))
732  {
733  *buflen = sizeof(flags);
735  return FALSE;
736  }
737 
738  flags = 0;
740  flags |= request->security_flags;
741  if (request->netconn)
742  {
744  if (bits >= 128)
746  else if (bits >= 56)
748  else
750  }
751  *(DWORD *)buffer = flags;
752  *buflen = sizeof(flags);
753  return TRUE;
754  }
756  {
757  const CERT_CONTEXT *cert;
758 
759  if (!buffer || *buflen < sizeof(cert))
760  {
761  *buflen = sizeof(cert);
763  return FALSE;
764  }
765 
766  if (!request->netconn || !(cert = netconn_get_certificate( request->netconn ))) return FALSE;
768  *buflen = sizeof(cert);
769  return TRUE;
770  }
772  {
773  const CERT_CONTEXT *cert;
774  const CRYPT_OID_INFO *oidInfo;
776 
777  FIXME("partial stub\n");
778 
779  if (!buffer || *buflen < sizeof(*ci))
780  {
781  *buflen = sizeof(*ci);
783  return FALSE;
784  }
785  if (!request->netconn || !(cert = netconn_get_certificate( request->netconn ))) return FALSE;
786 
787  ci->ftExpiry = cert->pCertInfo->NotAfter;
788  ci->ftStart = cert->pCertInfo->NotBefore;
789  ci->lpszSubjectInfo = blob_to_str( cert->dwCertEncodingType, &cert->pCertInfo->Subject );
790  ci->lpszIssuerInfo = blob_to_str( cert->dwCertEncodingType, &cert->pCertInfo->Issuer );
791  ci->lpszProtocolName = NULL;
793  cert->pCertInfo->SignatureAlgorithm.pszObjId,
794  0 );
795  if (oidInfo)
796  ci->lpszSignatureAlgName = (LPWSTR)oidInfo->pwszName;
797  else
800  ci->dwKeySize = request->netconn ? netconn_get_cipher_strength( request->netconn ) : 0;
801 
803  *buflen = sizeof(*ci);
804  return TRUE;
805  }
807  {
808  if (!buffer || *buflen < sizeof(DWORD))
809  {
810  *buflen = sizeof(DWORD);
812  return FALSE;
813  }
814 
815  *(DWORD *)buffer = request->netconn ? netconn_get_cipher_strength( request->netconn ) : 0;
816  *buflen = sizeof(DWORD);
817  return TRUE;
818  }
820  {
821  WINHTTP_CONNECTION_INFO *info = buffer;
822  struct sockaddr local;
823  socklen_t len = sizeof(local);
824  const struct sockaddr *remote = (const struct sockaddr *)&request->connect->sockaddr;
825 
826  if (!buffer || *buflen < sizeof(*info))
827  {
828  *buflen = sizeof(*info);
830  return FALSE;
831  }
832  if (!request->netconn)
833  {
835  return FALSE;
836  }
837  if (getsockname( request->netconn->socket, &local, &len )) return FALSE;
838  if (!convert_sockaddr( &local, &info->LocalAddress )) return FALSE;
839  if (!convert_sockaddr( remote, &info->RemoteAddress )) return FALSE;
840  info->cbSize = sizeof(*info);
841  return TRUE;
842  }
844  *(DWORD *)buffer = request->resolve_timeout;
845  *buflen = sizeof(DWORD);
846  return TRUE;
848  *(DWORD *)buffer = request->connect_timeout;
849  *buflen = sizeof(DWORD);
850  return TRUE;
852  *(DWORD *)buffer = request->send_timeout;
853  *buflen = sizeof(DWORD);
854  return TRUE;
856  *(DWORD *)buffer = request->recv_timeout;
857  *buflen = sizeof(DWORD);
858  return TRUE;
859 
861  str_to_buffer( buffer, request->connect->username, buflen );
862  return TRUE;
863 
865  str_to_buffer( buffer, request->connect->password, buflen );
866  return TRUE;
867 
869  str_to_buffer( buffer, request->connect->session->proxy_username, buflen );
870  return TRUE;
871 
873  str_to_buffer( buffer, request->connect->session->proxy_password, buflen );
874  return TRUE;
875 
876  default:
877  FIXME("unimplemented option %u\n", option);
879  return FALSE;
880  }
881 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define WINHTTP_OPTION_PROXY_PASSWORD
Definition: winhttp.h:148
#define WINHTTP_OPTION_RECEIVE_TIMEOUT
Definition: winhttp.h:99
#define SECURITY_FLAG_STRENGTH_MEDIUM
Definition: winhttp.h:287
#define TRUE
Definition: types.h:120
char hdr[14]
Definition: iptest.cpp:33
#define SECURITY_FLAG_STRENGTH_STRONG
Definition: winhttp.h:288
#define WINHTTP_OPTION_PASSWORD
Definition: winhttp.h:146
#define WINHTTP_OPTION_SECURITY_CERTIFICATE_STRUCT
Definition: winhttp.h:107
#define WINHTTP_OPTION_SEND_TIMEOUT
Definition: winhttp.h:98
BOOL WINAPI CertFreeCertificateContext(PCCERT_CONTEXT pCertContext)
Definition: cert.c:371
GLuint buffer
Definition: glext.h:5915
#define WINHTTP_OPTION_PROXY_USERNAME
Definition: winhttp.h:147
#define WINHTTP_OPTION_USERNAME
Definition: winhttp.h:145
#define WINHTTP_OPTION_SERVER_CERT_CONTEXT
Definition: winhttp.h:121
#define DWORD
Definition: nt_native.h:44
GLenum GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * bits
Definition: glext.h:10929
static struct list oidInfo
Definition: oid.c:1206
static WCHAR * blob_to_str(DWORD encoding, CERT_NAME_BLOB *blob)
Definition: session.c:643
const void * netconn_get_certificate(netconn_t *conn)
Definition: net.c:928
#define FIXME(fmt,...)
Definition: debug.h:110
smooth NULL
Definition: ftsmooth.c:416
Definition: getopt.h:108
static BYTE cert[]
Definition: msg.c:1437
int netconn_get_cipher_strength(netconn_t *conn)
Definition: net.c:938
LPWSTR lpszEncryptionAlgName
Definition: winhttp.h:498
#define WINHTTP_FLAG_SECURE
Definition: winhttp.h:60
static void str_to_buffer(WCHAR *buffer, const WCHAR *str, LPDWORD buflen)
Definition: session.c:631
if(!(yy_init))
Definition: macro.lex.yy.c:714
unsigned long DWORD
Definition: ntddk_ex.h:95
int socklen_t
Definition: tcp.c:35
GLbitfield flags
Definition: glext.h:7161
static BOOL convert_sockaddr(const struct sockaddr *addr, SOCKADDR_STORAGE *addr_storage)
Definition: session.c:655
GLenum GLsizei len
Definition: glext.h:6722
#define CRYPT_OID_INFO_OID_KEY
Definition: wincrypt.h:1702
#define WINHTTP_OPTION_CONNECTION_INFO
Definition: winhttp.h:136
#define local
Definition: zutil.h:30
#define WINHTTP_OPTION_SECURITY_FLAGS
Definition: winhttp.h:106
#define WINHTTP_OPTION_RESOLVE_TIMEOUT
Definition: winhttp.h:95
Definition: tftpd.h:85
#define WINHTTP_OPTION_SECURITY_KEY_BITNESS
Definition: winhttp.h:109
#define SECURITY_FLAG_SECURE
Definition: winhttp.h:285
void set_last_error(DWORD error)
Definition: session.c:59
#define ERROR_WINHTTP_INCORRECT_HANDLE_STATE
Definition: winhttp.h:200
PCCRYPT_OID_INFO WINAPI CryptFindOIDInfo(DWORD dwKeyType, void *pvKey, DWORD dwGroupId)
Definition: oid.c:1799
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define WINHTTP_OPTION_CONNECT_TIMEOUT
Definition: winhttp.h:96
INT WSAAPI getsockname(IN SOCKET s, OUT LPSOCKADDR name, IN OUT INT FAR *namelen)
Definition: sockctrl.c:213
#define SECURITY_FLAG_STRENGTH_WEAK
Definition: winhttp.h:286
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10

◆ request_set_option()

static BOOL request_set_option ( object_header_t hdr,
DWORD  option,
LPVOID  buffer,
DWORD  buflen 
)
static

Definition at line 896 of file session.c.

897 {
899 
900  switch (option)
901  {
903  {
905 
906  FIXME("%u %s %s\n", pi->dwAccessType, debugstr_w(pi->lpszProxy), debugstr_w(pi->lpszProxyBypass));
907  return TRUE;
908  }
910  {
911  DWORD disable;
912 
913  if (buflen != sizeof(DWORD))
914  {
916  return FALSE;
917  }
918 
919  disable = *(DWORD *)buffer;
920  TRACE("0x%x\n", disable);
921  hdr->disable_flags |= disable;
922  return TRUE;
923  }
925  {
926  DWORD policy;
927 
928  if (buflen != sizeof(DWORD))
929  {
931  return FALSE;
932  }
933 
934  policy = *(DWORD *)buffer;
935  TRACE("0x%x\n", policy);
936  hdr->logon_policy = policy;
937  return TRUE;
938  }
940  {
941  DWORD policy;
942 
943  if (buflen != sizeof(DWORD))
944  {
946  return FALSE;
947  }
948 
949  policy = *(DWORD *)buffer;
950  TRACE("0x%x\n", policy);
951  hdr->redirect_policy = policy;
952  return TRUE;
953  }
955  {
956  DWORD flags;
957 
958  if (buflen < sizeof(DWORD))
959  {
961  return FALSE;
962  }
963  flags = *(DWORD *)buffer;
964  TRACE("0x%x\n", flags);
969  {
971  return FALSE;
972  }
973  request->security_flags = flags;
974  return TRUE;
975  }
977  request->resolve_timeout = *(DWORD *)buffer;
978  return TRUE;
980  request->connect_timeout = *(DWORD *)buffer;
981  return TRUE;
983  request->send_timeout = *(DWORD *)buffer;
984  return TRUE;
986  request->recv_timeout = *(DWORD *)buffer;
987  return TRUE;
988 
990  {
991  connect_t *connect = request->connect;
992 
993  heap_free( connect->username );
994  if (!(connect->username = buffer_to_str( buffer, buflen ))) return FALSE;
995  return TRUE;
996  }
998  {
999  connect_t *connect = request->connect;
1000 
1001  heap_free( connect->password );
1002  if (!(connect->password = buffer_to_str( buffer, buflen ))) return FALSE;
1003  return TRUE;
1004  }
1006  {
1007  session_t *session = request->connect->session;
1008 
1009  heap_free( session->proxy_username );
1010  if (!(session->proxy_username = buffer_to_str( buffer, buflen ))) return FALSE;
1011  return TRUE;
1012  }
1014  {
1015  session_t *session = request->connect->session;
1016 
1017  heap_free( session->proxy_password );
1018  if (!(session->proxy_password = buffer_to_str( buffer, buflen ))) return FALSE;
1019  return TRUE;
1020  }
1022  if (!(hdr->flags & WINHTTP_FLAG_SECURE))
1023  {
1025  return FALSE;
1026  }
1027  FIXME("WINHTTP_OPTION_CLIENT_CERT_CONTEXT\n");
1028  return TRUE;
1029  default:
1030  FIXME("unimplemented option %u\n", option);
1032  return FALSE;
1033  }
1034 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define WINHTTP_OPTION_PROXY_PASSWORD
Definition: winhttp.h:148
#define WINHTTP_OPTION_CLIENT_CERT_CONTEXT
Definition: winhttp.h:113
#define WINHTTP_OPTION_RECEIVE_TIMEOUT
Definition: winhttp.h:99
#define TRUE
Definition: types.h:120
#define SECURITY_FLAG_IGNORE_UNKNOWN_CA
Definition: winhttp.h:281
char hdr[14]
Definition: iptest.cpp:33
#define WINHTTP_OPTION_PASSWORD
Definition: winhttp.h:146
#define WINHTTP_OPTION_SEND_TIMEOUT
Definition: winhttp.h:98
#define WINHTTP_OPTION_PROXY
Definition: winhttp.h:110
static WCHAR * buffer_to_str(WCHAR *buffer, DWORD buflen)
Definition: session.c:883
GLuint buffer
Definition: glext.h:5915
#define WINHTTP_OPTION_PROXY_USERNAME
Definition: winhttp.h:147
#define WINHTTP_OPTION_USERNAME
Definition: winhttp.h:145
#define SECURITY_FLAG_IGNORE_CERT_CN_INVALID
Definition: winhttp.h:283
INT WSAAPI connect(IN SOCKET s, IN CONST struct sockaddr *name, IN INT namelen)
Definition: sockctrl.c:23
LPWSTR proxy_password
#define debugstr_w
Definition: kernel32.h:32
#define FIXME(fmt,...)
Definition: debug.h:110
Definition: getopt.h:108
#define WINHTTP_OPTION_REDIRECT_POLICY
Definition: winhttp.h:131
#define WINHTTP_FLAG_SECURE
Definition: winhttp.h:60
#define WINHTTP_OPTION_AUTOLOGON_POLICY
Definition: winhttp.h:120
#define TRACE(s)
Definition: solgame.cpp:4
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SECURITY_FLAG_IGNORE_CERT_WRONG_USAGE
Definition: winhttp.h:284
#define SetLastError(x)
Definition: compat.h:409
GLbitfield flags
Definition: glext.h:7161
static DWORD pi
Definition: protocol.c:150
LPWSTR proxy_username
#define SECURITY_FLAG_IGNORE_CERT_DATE_INVALID
Definition: winhttp.h:282
#define WINHTTP_OPTION_SECURITY_FLAGS
Definition: winhttp.h:106
#define WINHTTP_OPTION_RESOLVE_TIMEOUT
Definition: winhttp.h:95
Definition: tftpd.h:85
int disable
Definition: msacm.c:1353
void set_last_error(DWORD error)
Definition: session.c:59
#define ERROR_WINHTTP_INCORRECT_HANDLE_STATE
Definition: winhttp.h:200
#define WINHTTP_OPTION_CONNECT_TIMEOUT
Definition: winhttp.h:96
#define ERROR_WINHTTP_INVALID_OPTION
Definition: winhttp.h:194
#define WINHTTP_OPTION_DISABLE_FEATURE
Definition: winhttp.h:116
static BOOL heap_free(void *mem)
Definition: appwiz.h:75
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10

◆ reverse_lookup()

static int reverse_lookup ( const struct addrinfo ai,
char hostname,
size_t  len 
)
static

Definition at line 1315 of file session.c.

1316 {
1317  int ret = -1;
1318 #ifdef HAVE_GETNAMEINFO
1319  ret = getnameinfo( ai->ai_addr, ai->ai_addrlen, hostname, len, NULL, 0, 0 );
1320 #endif
1321  return ret;
1322 }
char * hostname
Definition: ftp.c:88
smooth NULL
Definition: ftsmooth.c:416
int ret
GLenum GLsizei len
Definition: glext.h:6722
#define getnameinfo
Definition: wspiapi.h:45
size_t ai_addrlen
Definition: ws2def.h:669
struct sockaddr * ai_addr
Definition: ws2def.h:671

Referenced by build_wpad_url().

◆ run_script()

static BOOL run_script ( char script,
DWORD  size,
const WCHAR url,
WINHTTP_PROXY_INFO info 
)
static

Definition at line 1815 of file session.c.

1816 {
1817  BOOL ret;
1818  char *result, *urlA;
1819  DWORD len_result;
1821  URL_COMPONENTSW uc;
1822 
1823  buffer.dwStructSize = sizeof(buffer);
1824  buffer.lpszScriptBuffer = script;
1825  buffer.dwScriptBufferSize = size;
1826 
1827  if (!(urlA = strdupWA( url ))) return FALSE;
1829  {
1830  heap_free( urlA );
1831  return FALSE;
1832  }
1833 
1834  memset( &uc, 0, sizeof(uc) );
1835  uc.dwStructSize = sizeof(uc);
1836  uc.dwHostNameLength = -1;
1837 
1838  if (WinHttpCrackUrl( url, 0, 0, &uc ))
1839  {
1840  char *hostnameA = strdupWA_sized( uc.lpszHostName, uc.dwHostNameLength );
1841 
1842  if ((ret = InternetGetProxyInfo( urlA, strlen(urlA),
1843  hostnameA, strlen(hostnameA), &result, &len_result )))
1844  {
1846  heap_free( result );
1847  }
1848 
1849  heap_free( hostnameA );
1850  }
1851  heap_free( urlA );
1853 }
DWORD dwStructSize
Definition: wininet.h:211
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
GLuint buffer
Definition: glext.h:5915
BOOL WINAPI InternetDeInitializeAutoProxyDll(LPSTR, DWORD)
Definition: main.c:131
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
script
Definition: msipriv.h:374
BOOL WINAPI WinHttpCrackUrl(LPCWSTR url, DWORD len, DWORD flags, LPURL_COMPONENTSW uc)
Definition: url.c:183
GLsizeiptr size
Definition: glext.h:5919
static char * strdupWA_sized(const WCHAR *src, DWORD size)
BOOL WINAPI InternetInitializeAutoProxyDll(DWORD, LPSTR, LPSTR, void *, struct AUTO_PROXY_SCRIPT_BUFFER *)
static const WCHAR url[]
Definition: encode.c:1432
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
static BOOL parse_script_result(const char *result, WINHTTP_PROXY_INFO *info)
Definition: session.c:1710
static char * strdupWA(const WCHAR *src)
Definition: main.c:111
BOOL WINAPI InternetGetProxyInfo(LPCSTR, DWORD, LPSTR, DWORD, LPSTR *, LPDWORD)
GLuint64EXT * result
Definition: glext.h:11304
#define memset(x, y, z)
Definition: compat.h:39
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

Referenced by WinHttpGetProxyForUrl().

◆ send_callback()

void send_callback ( object_header_t hdr,
DWORD  status,
LPVOID  info,
DWORD  buflen 
)

Definition at line 71 of file session.c.

72 {
73  if (hdr->callback && (hdr->notify_mask & status))
74  {
75  TRACE("%p, 0x%08x, %p, %u\n", hdr, status, info, buflen);
76  hdr->callback( hdr->handle, hdr->context, status, info, buflen );
77  TRACE("returning from 0x%08x callback\n", status);
78  }
79 }
char hdr[14]
Definition: iptest.cpp:33
#define TRACE(s)
Definition: solgame.cpp:4
Definition: ps.c:97

Referenced by close_connection(), handle_redirect(), open_connection(), query_data_available(), read_data(), read_more_data(), receive_response(), release_object(), send_request(), WinHttpConnect(), WinHttpOpenRequest(), and write_data().

◆ session_destroy()

static void session_destroy ( object_header_t hdr)
static

Definition at line 93 of file session.c.

94 {
95  session_t *session = (session_t *)hdr;
96  struct list *item, *next;
97  domain_t *domain;
98 
99  TRACE("%p\n", session);
100 
101  if (session->unload_event) SetEvent( session->unload_event );
102  if (session->cred_handle_initialized) FreeCredentialsHandle( &session->cred_handle );
103 
105  {
106  domain = LIST_ENTRY( item, domain_t, entry );
107  delete_domain( domain );
108  }
109  heap_free( session->agent );
110  heap_free( session->proxy_server );
111  heap_free( session->proxy_bypass );
112  heap_free( session->proxy_username );
113  heap_free( session->proxy_password );
114  heap_free( session );
115 }
#define LIST_FOR_EACH_SAFE(cursor, cursor2, list)
Definition: list.h:192
char hdr[14]
Definition: iptest.cpp:33
uint8_t entry
Definition: isohybrid.c:63
BOOL cred_handle_initialized
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent(IN HANDLE hEvent)
Definition: synch.c:679
SECURITY_STATUS WINAPI FreeCredentialsHandle(PCredHandle phCredential)
Definition: wrapper.c:151
LPWSTR proxy_password
struct list cookie_cache
#define TRACE(s)
Definition: solgame.cpp:4
LPWSTR proxy_server
HANDLE unload_event
CredHandle cred_handle
Definition: _list.h:228
LPWSTR proxy_username
LPWSTR proxy_bypass
static unsigned __int64 next
Definition: rand_nt.c:6
static ATOM item
Definition: dde.c:856
#define LIST_ENTRY(type)
Definition: queue.h:175
void delete_domain(domain_t *domain)
Definition: cookie.c:89
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

◆ session_query_option()

static BOOL session_query_option ( object_header_t hdr,
DWORD  option,
LPVOID  buffer,
LPDWORD  buflen 
)
static

Definition at line 117 of file session.c.

118 {
119  session_t *session = (session_t *)hdr;
120 
121  switch (option)
122  {
124  {
125  if (!buffer || *buflen < sizeof(DWORD))
126  {
127  *buflen = sizeof(DWORD);
129  return FALSE;
130  }
131 
132  *(DWORD *)buffer = hdr->redirect_policy;
133  *buflen = sizeof(DWORD);
134  return TRUE;
135  }
137  *(DWORD *)buffer = session->resolve_timeout;
138  *buflen = sizeof(DWORD);
139  return TRUE;
141  *(DWORD *)buffer = session->connect_timeout;
142  *buflen = sizeof(DWORD);
143  return TRUE;
145  *(DWORD *)buffer = session->send_timeout;
146  *buflen = sizeof(DWORD);
147  return TRUE;
149  *(DWORD *)buffer = session->recv_timeout;
150  *buflen = sizeof(DWORD);
151  return TRUE;
152  default:
153  FIXME("unimplemented option %u\n", option);
155  return FALSE;
156  }
157 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define WINHTTP_OPTION_RECEIVE_TIMEOUT
Definition: winhttp.h:99
#define TRUE
Definition: types.h:120
char hdr[14]
Definition: iptest.cpp:33
#define WINHTTP_OPTION_SEND_TIMEOUT
Definition: winhttp.h:98
GLuint buffer
Definition: glext.h:5915
#define DWORD
Definition: nt_native.h:44
#define FIXME(fmt,...)
Definition: debug.h:110
Definition: getopt.h:108
#define WINHTTP_OPTION_REDIRECT_POLICY
Definition: winhttp.h:131
unsigned long DWORD
Definition: ntddk_ex.h:95
#define WINHTTP_OPTION_RESOLVE_TIMEOUT
Definition: winhttp.h:95
void set_last_error(DWORD error)
Definition: session.c:59
#define WINHTTP_OPTION_CONNECT_TIMEOUT
Definition: winhttp.h:96
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10

◆ session_set_option()

static BOOL session_set_option ( object_header_t hdr,
DWORD  option,
LPVOID  buffer,
DWORD  buflen 
)
static

Definition at line 159 of file session.c.

160 {
161  session_t *session = (session_t *)hdr;
162 
163  switch (option)
164  {
166  {
168 
169  FIXME("%u %s %s\n", pi->dwAccessType, debugstr_w(pi->lpszProxy), debugstr_w(pi->lpszProxyBypass));
170  return TRUE;
171  }
173  {
174  DWORD policy;
175 
176  if (buflen != sizeof(policy))
177  {
179  return FALSE;
180  }
181 
182  policy = *(DWORD *)buffer;
183  TRACE("0x%x\n", policy);
184  hdr->redirect_policy = policy;
185  return TRUE;
186  }
188  {
189  if (buflen != sizeof(session->secure_protocols))
190  {
192  return FALSE;
193  }
194  session->secure_protocols = *(DWORD *)buffer;
195  TRACE("0x%x\n", session->secure_protocols);
196  return TRUE;
197  }
200  return FALSE;
202  session->resolve_timeout = *(DWORD *)buffer;
203  return TRUE;
205  session->connect_timeout = *(DWORD *)buffer;
206  return TRUE;
208  session->send_timeout = *(DWORD *)buffer;
209  return TRUE;
211  session->recv_timeout = *(DWORD *)buffer;
212  return TRUE;
214  FIXME("WINHTTP_OPTION_CONFIGURE_PASSPORT_AUTH: 0x%x\n", *(DWORD *)buffer);
215  return TRUE;
217  TRACE("WINHTTP_OPTION_UNLOAD_NOTIFY_EVENT: %p\n", *(HANDLE *)buffer);
218  session->unload_event = *(HANDLE *)buffer;
219  return TRUE;
221  FIXME("WINHTTP_OPTION_MAX_CONNS_PER_SERVER: %d\n", *(DWORD *)buffer);
222  return TRUE;
224  FIXME("WINHTTP_OPTION_MAX_CONNS_PER_1_0_SERVER: %d\n", *(DWORD *)buffer);
225  return TRUE;
226  default:
227  FIXME("unimplemented option %u\n", option);
229  return FALSE;
230  }
231 }
#define WINHTTP_OPTION_RECEIVE_TIMEOUT
Definition: winhttp.h:99
#define TRUE
Definition: types.h:120
char hdr[14]
Definition: iptest.cpp:33
#define WINHTTP_OPTION_SEND_TIMEOUT
Definition: winhttp.h:98
#define WINHTTP_OPTION_SECURE_PROTOCOLS
Definition: winhttp.h:127
#define WINHTTP_OPTION_PROXY
Definition: winhttp.h:110
GLuint buffer
Definition: glext.h:5915
#define WINHTTP_OPTION_MAX_CONNS_PER_SERVER
Definition: winhttp.h:118
DWORD secure_protocols
#define debugstr_w
Definition: kernel32.h:32
#define FIXME(fmt,...)
Definition: debug.h:110
Definition: getopt.h:108
#define WINHTTP_OPTION_REDIRECT_POLICY
Definition: winhttp.h:131
#define ERROR_WINHTTP_INCORRECT_HANDLE_TYPE
Definition: winhttp.h:199
#define TRACE(s)
Definition: solgame.cpp:4
HANDLE unload_event
#define WINHTTP_OPTION_MAX_CONNS_PER_1_0_SERVER
Definition: winhttp.h:119
unsigned long DWORD
Definition: ntddk_ex.h:95
static DWORD pi
Definition: protocol.c:150
#define WINHTTP_OPTION_RESOLVE_TIMEOUT
Definition: winhttp.h:95
void set_last_error(DWORD error)
Definition: session.c:59
#define WINHTTP_OPTION_CONNECT_TIMEOUT
Definition: winhttp.h:96
#define ERROR_WINHTTP_INVALID_OPTION
Definition: winhttp.h:194
#define WINHTTP_OPTION_UNLOAD_NOTIFY_EVENT
Definition: winhttp.h:141
#define WINHTTP_OPTION_DISABLE_FEATURE
Definition: winhttp.h:116
#define WINHTTP_OPTION_CONFIGURE_PASSPORT_AUTH
Definition: winhttp.h:126
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10

◆ set_last_error()

◆ set_option()

static BOOL set_option ( object_header_t hdr,
DWORD  option,
LPVOID  buffer,
DWORD  buflen 
)
static

Definition at line 1231 of file session.c.

1232 {
1233  BOOL ret = TRUE;
1234 
1235  if (!buffer && buflen)
1236  {
1238  return FALSE;
1239  }
1240 
1241  switch (option)
1242  {
1244  {
1245  if (buflen != sizeof(DWORD_PTR))
1246  {
1248  return FALSE;
1249  }
1250 
1251  hdr->context = *(DWORD_PTR *)buffer;
1252  return TRUE;
1253  }
1254  default:
1255  if (hdr->vtbl->set_option) ret = hdr->vtbl->set_option( hdr, option, buffer, buflen );
1256  else
1257  {
1258  FIXME("unimplemented option %u\n", option);
1260  return FALSE;
1261  }
1262  break;
1263  }
1264  return ret;
1265 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define TRUE
Definition: types.h:120
char hdr[14]
Definition: iptest.cpp:33
GLuint buffer
Definition: glext.h:5915
unsigned int BOOL
Definition: ntddk_ex.h:94
#define FIXME(fmt,...)
Definition: debug.h:110
Definition: getopt.h:108
#define ERROR_WINHTTP_INCORRECT_HANDLE_TYPE
Definition: winhttp.h:199
#define WINHTTP_OPTION_CONTEXT_VALUE
Definition: winhttp.h:112
int ret
uint32_t DWORD_PTR
Definition: typedefs.h:63
void set_last_error(DWORD error)
Definition: session.c:59
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10

Referenced by WinHttpSetOption().

◆ set_server_for_hostname()

BOOL set_server_for_hostname ( connect_t connect,
LPCWSTR  server,
INTERNET_PORT  port 
)

Definition at line 459 of file session.c.

460 {
461  session_t *session = connect->session;
462  BOOL ret = TRUE;
463 
464  if (session->proxy_server && !should_bypass_proxy(session, server))
465  {
466  LPCWSTR colon;
467 
468  if ((colon = strchrW( session->proxy_server, ':' )))
469  {
470  if (!connect->servername || strncmpiW( connect->servername,
471  session->proxy_server, colon - session->proxy_server - 1 ))
472  {
473  heap_free( connect->servername );
474  connect->resolved = FALSE;
475  if (!(connect->servername = heap_alloc(
476  (colon - session->proxy_server + 1) * sizeof(WCHAR) )))
477  {
478  ret = FALSE;
479  goto end;
480  }
481  memcpy( connect->servername, session->proxy_server,
482  (colon - session->proxy_server) * sizeof(WCHAR) );
483  connect->servername[colon - session->proxy_server] = 0;
484  if (*(colon + 1))
485  connect->serverport = atoiW( colon + 1 );
486  else
487  connect->serverport = INTERNET_DEFAULT_PORT;
488  }
489  }
490  else
491  {
492  if (!connect->servername || strcmpiW( connect->servername,
493  session->proxy_server ))
494  {
495  heap_free( connect->servername );
496  connect->resolved = FALSE;
497  if (!(connect->servername = strdupW( session->proxy_server )))
498  {
499  ret = FALSE;
500  goto end;
501  }
502  connect->serverport = INTERNET_DEFAULT_PORT;
503  }
504  }
505  }
506  else if (server)
507  {
508  heap_free( connect->servername );
509  connect->resolved = FALSE;
510  if (!(connect->servername = strdupW( server )))
511  {
512  ret = FALSE;
513  goto end;
514  }
515  connect->serverport = port;
516  }
517 end:
518  return ret;
519 }
#define TRUE
Definition: types.h:120
static rfbScreenInfoPtr server
Definition: vnc.c:74
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
static WCHAR * strdupW(const WCHAR *src)
Definition: main.c:92
WINE_UNICODE_INLINE WCHAR * strchrW(const WCHAR *str, WCHAR ch)
Definition: unicode.h:248
GLuint GLuint end
Definition: gl.h:1545
#define strncmpiW(s1, s2, n)
Definition: unicode.h:40
INT WSAAPI connect(IN SOCKET s, IN CONST struct sockaddr *name, IN INT namelen)
Definition: sockctrl.c:23
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
unsigned int BOOL
Definition: ntddk_ex.h:94
LPWSTR proxy_server
__wchar_t WCHAR
Definition: xmlstorage.h:180
int ret
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define strcmpiW(s1, s2)
Definition: unicode.h:39
#define INTERNET_DEFAULT_PORT
Definition: winhttp.h:35
USHORT port
Definition: uri.c:227
static BOOL should_bypass_proxy(session_t *session, LPCWSTR server)
Definition: session.c:428
WINE_UNICODE_INLINE int atoiW(const WCHAR *str)
Definition: unicode.h:315
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

Referenced by handle_redirect(), and WinHttpConnect().

◆ should_bypass_proxy()

static BOOL should_bypass_proxy ( session_t session,
LPCWSTR  server 
)
static

Definition at line 428 of file session.c.

429 {
430  LPCWSTR ptr;
431  BOOL ret = FALSE;
432 
433  if (!session->proxy_bypass) return FALSE;
434  ptr = session->proxy_bypass;
435  do {
436  LPCWSTR tmp = ptr;
437 
438  ptr = strchrW( ptr, ';' );
439  if (!ptr)
440  ptr = strchrW( tmp, ' ' );
441  if (ptr)
442  {
443  if (ptr - tmp < MAX_HOST_NAME_LENGTH)
444  {
445  WCHAR domain[MAX_HOST_NAME_LENGTH];
446 
447  memcpy( domain, tmp, (ptr - tmp) * sizeof(WCHAR) );
448  domain[ptr - tmp] = 0;
449  ret = domain_matches( server, domain );
450  }
451  ptr += 1;
452  }
453  else if (*tmp)
454  ret = domain_matches( server, tmp );
455  } while (ptr && !ret);
456  return ret;
457 }
static rfbScreenInfoPtr server
Definition: vnc.c:74
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
WINE_UNICODE_INLINE WCHAR * strchrW(const WCHAR *str, WCHAR ch)
Definition: unicode.h:248
static BOOL domain_matches(LPCWSTR server, LPCWSTR domain)
Definition: session.c:374
unsigned int BOOL
Definition: ntddk_ex.h:94
static PVOID ptr
Definition: dispmode.c:27
__wchar_t WCHAR
Definition: xmlstorage.h:180
int ret
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
LPWSTR proxy_bypass
#define MAX_HOST_NAME_LENGTH
Definition: session.c:426

Referenced by set_server_for_hostname().

◆ store_accept_types()

static BOOL store_accept_types ( request_t request,
const WCHAR **  accept_types 
)
static

Definition at line 1043 of file session.c.

1044 {
1045  static const WCHAR attr_accept[] = {'A','c','c','e','p','t',0};
1047  const WCHAR **types = accept_types;
1048 
1049  if (!types) return TRUE;
1050  while (*types)
1051  {
1053  types++;
1054  }
1055  return TRUE;
1056 }
#define TRUE
Definition: types.h:120
#define WINHTTP_ADDREQ_FLAG_ADD
Definition: winhttp.h:84
#define WINHTTP_ADDREQ_FLAG_COALESCE_WITH_COMMA
Definition: winhttp.h:85
Definition: cmds.c:130
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
GLbitfield flags
Definition: glext.h:7161
BOOL process_header(request_t *request, LPCWSTR field, LPCWSTR value, DWORD flags, BOOL request_only)
Definition: request.c:409
Definition: tftpd.h:85
static const WCHAR attr_accept[]
Definition: request.c:53

Referenced by WinHttpOpenRequest().

◆ str_to_buffer()

static void str_to_buffer ( WCHAR buffer,
const WCHAR str,
LPDWORD  buflen 
)
static

Definition at line 631 of file session.c.

632 {
633  int len = 0;
634  if (str) len = strlenW( str );
635  if (buffer && *buflen > len)
636  {
637  if (str) memcpy( buffer, str, len * sizeof(WCHAR) );
638  buffer[len] = 0;
639  }
640  *buflen = len * sizeof(WCHAR);
641 }
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
GLuint buffer
Definition: glext.h:5915
const WCHAR * str
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
GLenum GLsizei len
Definition: glext.h:6722

Referenced by request_query_option().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( winhttp  )

◆ WinHttpCheckPlatform()

BOOL WINAPI WinHttpCheckPlatform ( void  )

Definition at line 84 of file session.c.

85 {
86  TRACE("\n");
87  return TRUE;
88 }
#define TRUE
Definition: types.h:120
#define TRACE(s)
Definition: solgame.cpp:4

◆ WinHttpCloseHandle()

BOOL WINAPI WinHttpCloseHandle ( HINTERNET  handle)

Definition at line 1153 of file session.c.

1154 {
1156 
1157  TRACE("%p\n", handle);
1158 
1159  if (!(hdr = grab_object( handle )))
1160  {
1162  return FALSE;
1163  }
1164  release_object( hdr );
1165  free_handle( handle );
1167  return TRUE;
1168 }
#define TRUE
Definition: types.h:120
char hdr[14]
Definition: iptest.cpp:33
#define ERROR_SUCCESS
Definition: deptool.c:10
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
#define TRACE(s)
Definition: solgame.cpp:4
object_header_t * grab_object(HINTERNET hinternet)
Definition: handle.c:57
BOOL free_handle(HINTERNET hinternet)
Definition: handle.c:124
void release_object(object_header_t *hdr)
Definition: handle.c:73
void set_last_error(DWORD error)
Definition: session.c:59

Referenced by close_request(), download_script(), free_request(), reset_request(), test_async(), test_bad_header(), test_basic_authentication(), test_basic_request(), test_chunked_read(), test_connection_cache(), test_connection_info(), test_cookies(), test_credentials(), test_empty_headers_param(), test_head_request(), test_large_data_authentication(), test_multi_authentication(), test_multiple_reads(), test_no_content(), test_no_headers(), test_not_modified(), test_OpenRequest(), test_QueryOption(), test_redirect(), test_request_parameter_defaults(), test_resolve_timeout(), test_secure_connection(), test_SendRequest(), test_Timeouts(), test_WinHttpAddHeaders(), test_WinHttpGetProxyForUrl(), transfer_file_http(), and winhttp_request_Open().

◆ WinHttpConnect()

HINTERNET WINAPI WinHttpConnect ( HINTERNET  hsession,
LPCWSTR  server,
INTERNET_PORT  port,
DWORD  reserved 
)

Definition at line 524 of file session.c.

525 {
527  session_t *session;
528  HINTERNET hconnect = NULL;
529 
530  TRACE("%p, %s, %u, %x\n", hsession, debugstr_w(server), port, reserved);
531 
532  if (!server)
533  {
535  return NULL;
536  }
537  if (!(session = (session_t *)grab_object( hsession )))
538  {
540  return NULL;
541  }
542  if (session->hdr.type != WINHTTP_HANDLE_TYPE_SESSION)
543  {
544  release_object( &session->hdr );
546  return NULL;
547  }
548  if (!(connect = heap_alloc_zero( sizeof(connect_t) )))
549  {
550  release_object( &session->hdr );
551  return NULL;
552  }
554  connect->hdr.vtbl = &connect_vtbl;
555  connect->hdr.refs = 1;
556  connect->hdr.flags = session->hdr.flags;
557  connect->hdr.callback = session->hdr.callback;
558  connect->hdr.notify_mask = session->hdr.notify_mask;
559  connect->hdr.context = session->hdr.context;
560  connect->hdr.redirect_policy = session->hdr.redirect_policy;
561  list_init( &connect->hdr.children );
562 
563  addref_object( &session->hdr );
564  connect->session = session;
565  list_add_head( &session->hdr.children, &connect->hdr.entry );
566 
567  if (!(connect->hostname = strdupW( server ))) goto end;
568  connect->hostport = port;
570 
571  if (!(hconnect = alloc_handle( &connect->hdr ))) goto end;
572  connect->hdr.handle = hconnect;
573 
574  send_callback( &session->hdr, WINHTTP_CALLBACK_STATUS_HANDLE_CREATED, &hconnect, sizeof(hconnect) );
575 
576 end:
577  release_object( &connect->hdr );
578  release_object( &session->hdr );
579  TRACE("returning %p\n", hconnect);
580  if (hconnect) set_last_error( ERROR_SUCCESS );
581  return hconnect;
582 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
static BOOL alloc_handle(struct handle_table *lpTable, OBJECTHDR *lpObject, HCRYPTKEY *lpHandle)
Definition: handle.c:183
static rfbScreenInfoPtr server
Definition: vnc.c:74
#define ERROR_SUCCESS
Definition: deptool.c:10
static WCHAR * strdupW(const WCHAR *src)
Definition: main.c:92
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
__WINE_SERVER_LIST_INLINE void list_add_head(struct list *list, struct list *elem)
Definition: list.h:96
struct list children
WINHTTP_STATUS_CALLBACK callback
GLuint GLuint end
Definition: gl.h:1545
INT WSAAPI connect(IN SOCKET s, IN CONST struct sockaddr *name, IN INT namelen)
Definition: sockctrl.c:23
void send_callback(object_header_t *hdr, DWORD status, LPVOID info, DWORD buflen)
Definition: session.c:71
object_header_t hdr
BOOL set_server_for_hostname(connect_t *connect, LPCWSTR server, INTERNET_PORT port)
Definition: session.c:459
#define debugstr_w
Definition: kernel32.h:32
r reserved
Definition: btrfs.c:2655
smooth NULL
Definition: ftsmooth.c:416
#define ERROR_WINHTTP_INCORRECT_HANDLE_TYPE
Definition: winhttp.h:199
#define WINHTTP_HANDLE_TYPE_SESSION
Definition: winhttp.h:430
static const object_vtbl_t connect_vtbl
Definition: session.c:367
#define TRACE(s)
Definition: solgame.cpp:4
#define WINHTTP_CALLBACK_STATUS_HANDLE_CREATED
Definition: winhttp.h:390
#define WINHTTP_HANDLE_TYPE_CONNECT
Definition: winhttp.h:431
object_header_t * grab_object(HINTERNET hinternet)
Definition: handle.c:57
void release_object(object_header_t *hdr)
Definition: handle.c:73
object_header_t * addref_object(object_header_t *hdr)
Definition: handle.c:50
__WINE_SERVER_LIST_INLINE void list_init(struct list *list)
Definition: list.h:149
void set_last_error(DWORD error)
Definition: session.c:59
USHORT port
Definition: uri.c:227

Referenced by download_script(), open_async_request(), test_async(), test_bad_header(), test_basic_authentication(), test_basic_request(), test_chunked_read(), test_connection_cache(), test_connection_info(), test_cookies(), test_credentials(), test_empty_headers_param(), test_head_request(), test_large_data_authentication(), test_multi_authentication(), test_multiple_reads(), test_no_content(), test_no_headers(), test_not_modified(), test_OpenRequest(), test_QueryOption(), test_redirect(), test_request_parameter_defaults(), test_resolve_timeout(), test_secure_connection(), test_SendRequest(), test_Timeouts(), test_WinHttpAddHeaders(), transfer_file_http(), and winhttp_request_Open().

◆ WinHttpDetectAutoProxyConfigUrl()

BOOL WINAPI WinHttpDetectAutoProxyConfigUrl ( DWORD  flags,
LPWSTR url 
)

Definition at line 1385 of file session.c.

1386 {
1387  BOOL ret = FALSE;
1388  char system_url[INTERNET_MAX_URL_LENGTH + 1];
1389 
1390  TRACE("0x%08x, %p\n", flags, url);
1391 
1392  if (!flags || !url)
1393  {
1395  return FALSE;
1396  }
1397  if (get_system_proxy_autoconfig_url( system_url, sizeof(system_url) ))
1398  {
1399  WCHAR *urlW;
1400 
1401  if (!(urlW = strdupAW( system_url ))) return FALSE;
1402  *url = urlW;
1404  return TRUE;
1405  }
1407  {
1408  static int fixme_shown;
1409  if (!fixme_shown++) FIXME("discovery via DHCP not supported\n");
1410  }
1412  {
1413 #ifdef HAVE_GETADDRINFO
1414  char *fqdn, *domain, *p;
1415 
1416  if (!(fqdn = get_computer_name( ComputerNamePhysicalDnsFullyQualified ))) return FALSE;
1417  if (!(domain = get_computer_name( ComputerNamePhysicalDnsDomain )))
1418  {
1419  heap_free( fqdn );
1420  return FALSE;
1421  }
1422  p = fqdn;
1423  while ((p = strchr( p, '.' )) && is_domain_suffix( p + 1, domain ))
1424  {
1425  struct addrinfo *ai;
1426  char *name;
1427  int res;
1428 
1429  if (!(name = heap_alloc( sizeof("wpad") + strlen(p) )))
1430  {
1431  heap_free( fqdn );
1432  heap_free( domain );
1433  return FALSE;
1434  }
1435  strcpy( name, "wpad" );
1436  strcat( name, p );
1437  res = getaddrinfo( name, NULL, NULL, &ai );
1438  if (!res)
1439  {
1440  *url = build_wpad_url( name, ai );
1441  freeaddrinfo( ai );
1442  if (*url)
1443  {
1444  TRACE("returning %s\n", debugstr_w(*url));
1445  heap_free( name );
1446  ret = TRUE;
1447  break;
1448  }
1449  }
1450  heap_free( name );
1451  p++;
1452  }
1453  heap_free( domain );
1454  heap_free( fqdn );
1455 #else
1456  FIXME("getaddrinfo not found at build time\n");
1457 #endif
1458  }
1459  if (!ret)
1460  {
1462  *url = NULL;
1463  }
1464  else set_last_error( ERROR_SUCCESS );
1465  return ret;
1466 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define TRUE
Definition: types.h:120
#define freeaddrinfo
Definition: wspiapi.h:46
#define ERROR_SUCCESS
Definition: deptool.c:10
char * strcat(char *DstString, const char *SrcString)
Definition: utclib.c:568
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define WINHTTP_AUTO_DETECT_TYPE_DHCP
Definition: winhttp.h:527
static WCHAR * strdupAW(const char *src, int len)
Definition: main.c:96
#define ERROR_WINHTTP_AUTODETECTION_FAILED
Definition: winhttp.h:228
static WCHAR * build_wpad_url(const char *hostname, const struct addrinfo *ai)
Definition: session.c:1324
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
unsigned int BOOL
Definition: ntddk_ex.h:94
#define debugstr_w
Definition: kernel32.h:32
#define FIXME(fmt,...)
Definition: debug.h:110
smooth NULL
Definition: ftsmooth.c:416
#define INTERNET_MAX_URL_LENGTH
Definition: session.c:1380
#define WINHTTP_AUTO_DETECT_TYPE_DNS_A
Definition: winhttp.h:528
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
static const WCHAR url[]
Definition: encode.c:1432
GLbitfield flags
Definition: glext.h:7161
static BOOL is_domain_suffix(const char *domain, const char *suffix)
Definition: session.c:1306
int ret
static BOOL get_system_proxy_autoconfig_url(char *buf, DWORD buflen)
Definition: session.c:1346
char * strchr(const char *String, int ch)
Definition: utclib.c:501
Definition: name.c:36
GLuint res
Definition: glext.h:9613
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
static char * get_computer_name(COMPUTER_NAME_FORMAT format)
Definition: session.c:1290
void set_last_error(DWORD error)
Definition: session.c:59
GLfloat GLfloat p
Definition: glext.h:8902
static BOOL heap_free(void *mem)
Definition: appwiz.h:75
#define getaddrinfo
Definition: wspiapi.h:44
GLuint const GLchar * name
Definition: glext.h:6031

Referenced by test_WinHttpDetectAutoProxyConfigUrl(), and WinHttpGetProxyForUrl().

◆ WinHttpGetDefaultProxyConfiguration()

BOOL WINAPI WinHttpGetDefaultProxyConfiguration ( WINHTTP_PROXY_INFO info)

Definition at line 1503 of file session.c.

1504 {
1505  LONG l;
1506  HKEY key;
1507  BOOL got_from_reg = FALSE, direct = TRUE;
1508  char *envproxy;
1509 
1510  TRACE("%p\n", info);
1511 
1513  if (!l)
1514  {
1515  DWORD type, size = 0;
1516 
1518  if (!l && type == REG_BINARY &&
1519  size >= sizeof(struct connection_settings_header) + 2 * sizeof(DWORD))
1520  {
1521  BYTE *buf = heap_alloc( size );
1522 
1523  if (buf)
1524  {
1526  (struct connection_settings_header *)buf;
1527  DWORD *len = (DWORD *)(hdr + 1);
1528 
1530  &size );
1531  if (!l && hdr->magic == WINHTTP_SETTINGS_MAGIC &&
1532  hdr->unknown == 0)
1533  {
1534  if (hdr->flags & PROXY_TYPE_PROXY)
1535  {
1536  BOOL sane = FALSE;
1537  LPWSTR proxy = NULL;
1538  LPWSTR proxy_bypass = NULL;
1539 
1540  /* Sanity-check length of proxy string */
1541  if ((BYTE *)len - buf + *len <= size)
1542  {
1543  sane = TRUE;
1544  proxy = GlobalAlloc( 0, (*len + 1) * sizeof(WCHAR) );
1545  if (proxy)
1546  copy_char_to_wchar_sz( (BYTE *)(len + 1), *len, proxy );
1547  len = (DWORD *)((BYTE *)(len + 1) + *len);
1548  }
1549  if (sane)
1550  {
1551  /* Sanity-check length of proxy bypass string */
1552  if ((BYTE *)len - buf + *len <= size)
1553  {
1554  proxy_bypass = GlobalAlloc( 0, (*len + 1) * sizeof(WCHAR) );
1555  if (proxy_bypass)
1556  copy_char_to_wchar_sz( (BYTE *)(len + 1), *len, proxy_bypass );
1557  }
1558  else
1559  {
1560  sane = FALSE;
1561  GlobalFree( proxy );
1562  proxy = NULL;
1563  }
1564  }
1565  info->lpszProxy = proxy;
1566  info->lpszProxyBypass = proxy_bypass;
1567  if (sane)
1568  {
1569  got_from_reg = TRUE;
1570  direct = FALSE;
1571  info->dwAccessType =
1573  TRACE("http proxy (from registry) = %s, bypass = %s\n",
1574  debugstr_w(info->lpszProxy),
1575  debugstr_w(info->lpszProxyBypass));
1576  }
1577  }
1578  }
1579  heap_free( buf );
1580  }
1581  }
1582  RegCloseKey( key );
1583  }
1584  if (!got_from_reg && (envproxy = getenv( "http_proxy" )))
1585  {
1586  char *colon, *http_proxy = NULL;
1587 
1588  if (!(colon = strchr( envproxy, ':' ))) http_proxy = envproxy;
1589  else
1590  {
1591  if (*(colon + 1) == '/' && *(colon + 2) == '/')
1592  {
1593  /* It's a scheme, check that it's http */
1594  if (!strncmp( envproxy, "http://", 7 )) http_proxy = envproxy + 7;
1595  else WARN("unsupported scheme in $http_proxy: %s\n", envproxy);
1596  }
1597  else http_proxy = envproxy;
1598  }
1599 
1600  if (http_proxy && http_proxy[0])
1601  {
1602  WCHAR *http_proxyW;
1603  int len;
1604 
1605  len = MultiByteToWideChar( CP_UNIXCP, 0, http_proxy, -1, NULL, 0 );
1606  if ((http_proxyW = GlobalAlloc( 0, len * sizeof(WCHAR))))
1607  {
1608  MultiByteToWideChar( CP_UNIXCP, 0, http_proxy, -1, http_proxyW, len );
1609  direct = FALSE;
1610  info->dwAccessType = WINHTTP_ACCESS_TYPE_NAMED_PROXY;
1611  info->lpszProxy = http_proxyW;
1612  info->lpszProxyBypass = NULL;
1613  TRACE("http proxy (from environment) = %s\n", debugstr_w(info->lpszProxy));
1614  }
1615  }
1616  }
1617  if (direct)
1618  {
1619  info->dwAccessType = WINHTTP_ACCESS_TYPE_NO_PROXY;
1620  info->lpszProxy = NULL;
1621  info->lpszProxyBypass = NULL;
1622  }
1624  return TRUE;
1625 }
#define WINHTTP_ACCESS_TYPE_NAMED_PROXY
Definition: winhttp.h:64
int proxy
Definition: main.c:67
#define TRUE
Definition: types.h:120
HGLOBAL NTAPI GlobalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:368
char hdr[14]
Definition: iptest.cpp:33
Definition: dir.h:83
#define ERROR_SUCCESS
Definition: deptool.c:10
#define WINHTTP_ACCESS_TYPE_NO_PROXY
Definition: winhttp.h:63
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define REG_BINARY
Definition: nt_native.h:1496
#define KEY_READ
Definition: nt_native.h:1023
static const WCHAR Connections[]
Definition: session.c:1468
#define WARN(fmt,...)
Definition: debug.h:111
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned int BOOL
Definition: ntddk_ex.h:94
long LONG
Definition: pedump.c:60
#define debugstr_w
Definition: kernel32.h:32
smooth NULL
Definition: ftsmooth.c:416
r l[0]
Definition: byte_order.h:167
#define TRACE(s)
Definition: solgame.cpp:4
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:4134
#define CP_UNIXCP
Definition: compat.h:69
__wchar_t WCHAR
Definition: xmlstorage.h:180
int strncmp(const char *String1, const char *String2, ACPI_SIZE Count)
Definition: utclib.c:534
unsigned long DWORD
Definition: ntddk_ex.h:95
HGLOBAL NTAPI GlobalFree(HGLOBAL hMem)
Definition: heapmem.c:611
static void copy_char_to_wchar_sz(const BYTE *src, DWORD len, WCHAR *dst)
Definition: session.c:1491
HKEY key
Definition: reg.c:42
GLenum GLsizei len
Definition: glext.h:6722
unsigned char BYTE
Definition: mem.h:68
_Check_return_ char *__cdecl getenv(_In_z_ const char *_VarName)
static const WCHAR WinHttpSettings[]
Definition: session.c:1475
#define MultiByteToWideChar
Definition: compat.h:100
static const DWORD PROXY_TYPE_PROXY
Definition: session.c:1480
char * strchr(const char *String, int ch)
Definition: utclib.c:501
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3381
static const DWORD WINHTTP_SETTINGS_MAGIC
Definition: session.c:1477
void set_last_error(DWORD error)
Definition: session.c:59
WCHAR * LPWSTR
Definition: xmlstorage.h:184
Definition: path.c:42
static BOOL heap_free(void *mem)
Definition: appwiz.h:75
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12

Referenced by proxy_active(), and WinHttpOpen().

◆ WinHttpGetIEProxyConfigForCurrentUser()

BOOL WINAPI WinHttpGetIEProxyConfigForCurrentUser ( WINHTTP_CURRENT_USER_IE_PROXY_CONFIG config)

Definition at line 1630 of file session.c.

1631 {
1632  static const WCHAR settingsW[] =
1633  {'D','e','f','a','u','l','t','C','o','n','n','e','c','t','i','o','n','S','e','t','t','i','n','g','s',0};
1634  HKEY hkey = NULL;
1636  DWORD type, offset, len, size = 0;
1637  BOOL ret = FALSE;
1638 
1639  TRACE("%p\n", config);
1640 
1641  if (!config)
1642  {
1644  return FALSE;
1645  }
1646  memset( config, 0, sizeof(*config) );
1647  config->fAutoDetect = TRUE;
1648 
1649  if (RegOpenKeyExW( HKEY_CURRENT_USER, Connections, 0, KEY_READ, &hkey ) ||
1650  RegQueryValueExW( hkey, settingsW, NULL, &type, NULL, &size ) ||
1651  type != REG_BINARY || size < sizeof(struct connection_settings_header))
1652  {
1653  ret = TRUE;
1654  goto done;
1655  }
1656  if (!(hdr = heap_alloc( size ))) goto done;
1657  if (RegQueryValueExW( hkey, settingsW, NULL, &type, (BYTE *)hdr, &size ) ||
1658  hdr->magic != WININET_SETTINGS_MAGIC)
1659  {
1660  ret = TRUE;
1661  goto done;
1662  }
1663 
1664  config->fAutoDetect = (hdr->flags & PROXY_AUTODETECT_SETTINGS) != 0;
1665  offset = sizeof(*hdr);
1666  if (offset + sizeof(DWORD) > size) goto done;
1667  len = *(DWORD *)((char *)hdr + offset);
1668  offset += sizeof(DWORD);
1669  if (len && hdr->flags & PROXY_TYPE_PROXY)
1670  {
1671  if (!(config->lpszProxy = GlobalAlloc( 0, (len + 1) * sizeof(WCHAR) ))) goto done;
1672  copy_char_to_wchar_sz( (const BYTE *)hdr + offset , len, config->lpszProxy );
1673  }
1674  offset += len;
1675  if (offset + sizeof(DWORD) > size) goto done;
1676  len = *(DWORD *)((char *)hdr + offset);
1677  offset += sizeof(DWORD);
1678  if (len && (hdr->flags & PROXY_TYPE_PROXY))
1679  {
1680  if (!(config->lpszProxyBypass = GlobalAlloc( 0, (len + 1) * sizeof(WCHAR) ))) goto done;
1681  copy_char_to_wchar_sz( (const BYTE *)hdr + offset , len, config->lpszProxyBypass );
1682  }
1683  offset += len;
1684  if (offset + sizeof(DWORD) > size) goto done;
1685  len = *(DWORD *)((char *)hdr + offset);
1686  offset += sizeof(DWORD);
1687  if (len && (hdr->flags & PROXY_USE_PAC_SCRIPT))
1688  {
1689  if (!(config->lpszAutoConfigUrl = GlobalAlloc( 0, (len + 1) * sizeof(WCHAR) ))) goto done;
1690  copy_char_to_wchar_sz( (const BYTE *)hdr + offset , len, config->lpszAutoConfigUrl );
1691  }
1692  ret = TRUE;
1693 
1694 done:
1695  RegCloseKey( hkey );
1696  heap_free( hdr );
1697  if (!ret)
1698  {
1699  GlobalFree( config->lpszAutoConfigUrl );
1700  config->lpszAutoConfigUrl = NULL;
1701  GlobalFree( config->lpszProxy );
1702  config->lpszProxy = NULL;
1703  GlobalFree( config->lpszProxyBypass );
1704  config->lpszProxyBypass = NULL;
1705  }
1706  else set_last_error( ERROR_SUCCESS );
1707  return ret;
1708 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define TRUE
Definition: types.h:120
HGLOBAL NTAPI GlobalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:368
char hdr[14]
Definition: iptest.cpp:33
#define ERROR_SUCCESS
Definition: deptool.c:10
#define REG_BINARY
Definition: nt_native.h:1496
#define KEY_READ
Definition: nt_native.h:1023
static const WCHAR Connections[]
Definition: session.c:1468
#define HKEY_CURRENT_USER
Definition: winreg.h:11
GLintptr offset
Definition: glext.h:5920
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
static const DWORD WININET_SETTINGS_MAGIC
Definition: session.c:1478
#define DWORD
Definition: nt_native.h:44
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
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:4134
__wchar_t WCHAR
Definition: xmlstorage.h:180
static const DWORD PROXY_USE_PAC_SCRIPT
Definition: session.c:1481
unsigned long DWORD
Definition: ntddk_ex.h:95
HGLOBAL NTAPI GlobalFree(HGLOBAL hMem)
Definition: heapmem.c:611
static const DWORD PROXY_AUTODETECT_SETTINGS
Definition: session.c:1482
static void copy_char_to_wchar_sz(const BYTE *src, DWORD len, WCHAR *dst)
Definition: session.c:1491
int ret
GLenum GLsizei len
Definition: glext.h:6722
unsigned char BYTE
Definition: mem.h:68
static const DWORD PROXY_TYPE_PROXY
Definition: session.c:1480
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3381
void set_last_error(DWORD error)
Definition: session.c:59
#define memset(x, y, z)
Definition: compat.h:39
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

Referenced by test_WinHttpGetIEProxyConfigForCurrentUser().

◆ WinHttpGetProxyForUrl()

BOOL WINAPI WinHttpGetProxyForUrl ( HINTERNET  hsession,
LPCWSTR  url,
WINHTTP_AUTOPROXY_OPTIONS options,
WINHTTP_PROXY_INFO info 
)

Definition at line 1858 of file session.c.

1860 {
1861  WCHAR *detected_pac_url = NULL;
1862  const WCHAR *pac_url;
1863  session_t *session;
1864  char *script;
1865  DWORD size;
1866  BOOL ret = FALSE;
1867 
1868  TRACE("%p, %s, %p, %p\n", hsession, debugstr_w(url), options, info);
1869 
1870  if (!(session = (session_t *)grab_object( hsession )))
1871  {
1873  return FALSE;
1874  }
1875  if (session->hdr.type != WINHTTP_HANDLE_TYPE_SESSION)
1876  {
1877  release_object( &session->hdr );
1879  return FALSE;
1880  }
1881  if (!url || !options || !info ||
1883  ((options->dwFlags & WINHTTP_AUTOPROXY_AUTO_DETECT) && !options->dwAutoDetectFlags) ||
1884  ((options->dwFlags & WINHTTP_AUTOPROXY_AUTO_DETECT) &&
1885  (options->dwFlags & WINHTTP_AUTOPROXY_CONFIG_URL)))
1886  {
1887  release_object( &session->hdr );
1889  return FALSE;
1890  }
1891  if (options->dwFlags & WINHTTP_AUTOPROXY_AUTO_DETECT &&
1892  !WinHttpDetectAutoProxyConfigUrl( options->dwAutoDetectFlags, &detected_pac_url ))
1893  goto done;
1894 
1895  if (options->dwFlags & WINHTTP_AUTOPROXY_CONFIG_URL) pac_url = options->lpszAutoConfigUrl;
1896  else pac_url = detected_pac_url;
1897 
1898  if ((script = download_script( pac_url, &size )))
1899  {
1900  ret = run_script( script, size, url, info );
1901  heap_free( script );
1902  }
1903 
1904 done:
1905  GlobalFree( detected_pac_url );
1906  release_object( &session->hdr );
1908  return ret;
1909 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define ERROR_SUCCESS
Definition: deptool.c:10
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
#define WINHTTP_AUTOPROXY_AUTO_DETECT
Definition: winhttp.h:530
object_header_t hdr
unsigned int BOOL
Definition: ntddk_ex.h:94
#define debugstr_w
Definition: kernel32.h:32
smooth NULL
Definition: ftsmooth.c:416
script
Definition: msipriv.h:374
#define ERROR_WINHTTP_INCORRECT_HANDLE_TYPE
Definition: winhttp.h:199
BOOL WINAPI WinHttpDetectAutoProxyConfigUrl(DWORD flags, LPWSTR *url)
Definition: session.c:1385
#define WINHTTP_HANDLE_TYPE_SESSION
Definition: winhttp.h:430
#define TRACE(s)
Definition: solgame.cpp:4
GLsizeiptr size
Definition: glext.h:5919
__wchar_t WCHAR
Definition: xmlstorage.h:180
static const WCHAR url[]
Definition: encode.c:1432
unsigned long DWORD
Definition: ntddk_ex.h:95
HGLOBAL NTAPI GlobalFree(HGLOBAL hMem)
Definition: heapmem.c:611
object_header_t * grab_object(HINTERNET hinternet)
Definition: handle.c:57
int ret
static BOOL run_script(char *script, DWORD size, const WCHAR *url, WINHTTP_PROXY_INFO *info)
Definition: session.c:1815
static char * download_script(const WCHAR *url, DWORD *out_size)
Definition: session.c:1744
void release_object(object_header_t *hdr)
Definition: handle.c:73
void set_last_error(DWORD error)
Definition: session.c:59
#define WINHTTP_AUTOPROXY_CONFIG_URL
Definition: winhttp.h:531
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

Referenced by test_WinHttpGetProxyForUrl().

◆ WinHttpOpen()

HINTERNET WINAPI WinHttpOpen ( LPCWSTR  agent,
DWORD  access,
LPCWSTR  proxy,
LPCWSTR  bypass,
DWORD  flags 
)

Definition at line 246 of file session.c.

247 {
248  session_t *session;
250 #ifdef __REACTOS__
251  if (!netconn_init_winsock()) return NULL;
252 #endif
253 
254  TRACE("%s, %u, %s, %s, 0x%08x\n", debugstr_w(agent), access, debugstr_w(proxy), debugstr_w(bypass), flags);
255 
256  if (!(session = heap_alloc_zero( sizeof(session_t) ))) return NULL;
257 
259  session->hdr.vtbl = &session_vtbl;
260  session->hdr.flags = flags;
261  session->hdr.refs = 1;
263  list_init( &session->hdr.children );
268  list_init( &session->cookie_cache );
269 
270  if (agent && !(session->agent = strdupW( agent ))) goto end;
272  {
274 
276  session->access = info.dwAccessType;
277  if (info.lpszProxy && !(session->proxy_server = strdupW( info.lpszProxy )))
278  {
279  GlobalFree( (LPWSTR)info.lpszProxy );
280  GlobalFree( (LPWSTR)info.lpszProxyBypass );
281  goto end;
282  }
283  if (info.lpszProxyBypass && !(session->proxy_bypass = strdupW( info.lpszProxyBypass )))
284  {
285  GlobalFree( (LPWSTR)info.lpszProxy );
286  GlobalFree( (LPWSTR)info.lpszProxyBypass );
287  goto end;
288  }
289  }
291  {
292  session->access = access;
293  if (proxy && !(session->proxy_server = strdupW( proxy ))) goto end;
294  if (bypass && !(session->proxy_bypass = strdupW( bypass ))) goto end;
295  }
296 
297  if (!(handle = alloc_handle( &session->hdr ))) goto end;
298  session->hdr.handle = handle;
299 
300 end:
301  release_object( &session->hdr );
302  TRACE("returning %p\n", handle);
304  return handle;
305 }
#define WINHTTP_ACCESS_TYPE_NAMED_PROXY
Definition: winhttp.h:64
#define WINHTTP_OPTION_REDIRECT_POLICY_DISALLOW_HTTPS_TO_HTTP
Definition: winhttp.h:158
namespace GUID const ADDRINFOEXW ADDRINFOEXW struct timeval OVERLAPPED LPLOOKUPSERVICE_COMPLETION_ROUTINE HANDLE * handle
Definition: sock.c:82
int proxy
Definition: main.c:67
static BOOL alloc_handle(struct handle_table *lpTable, OBJECTHDR *lpObject, HCRYPTKEY *lpHandle)
Definition: handle.c:183
#define ERROR_SUCCESS
Definition: deptool.c:10
static WCHAR * strdupW(const WCHAR *src)
Definition: main.c:92
struct list children
GLuint GLuint end
Definition: gl.h:1545
struct _test_info info[]
Definition: SetCursorPos.c:19
object_header_t hdr
#define WINHTTP_ACCESS_TYPE_DEFAULT_PROXY
Definition: winhttp.h:62
#define debugstr_w
Definition: kernel32.h:32
smooth NULL
Definition: ftsmooth.c:416
struct list cookie_cache
#define WINHTTP_HANDLE_TYPE_SESSION
Definition: winhttp.h:430
#define TRACE(s)
Definition: solgame.cpp:4
LPWSTR proxy_server
HGLOBAL NTAPI GlobalFree(HGLOBAL hMem)
Definition: heapmem.c:611
GLbitfield flags
Definition: glext.h:7161
const object_vtbl_t * vtbl
#define DEFAULT_SEND_TIMEOUT
Definition: session.c:56
void release_object(object_header_t *hdr)
Definition: handle.c:73
#define DEFAULT_CONNECT_TIMEOUT
Definition: session.c:55
static const object_vtbl_t session_vtbl
Definition: session.c:233
LPWSTR proxy_bypass
#define DEFAULT_RESOLVE_TIMEOUT
Definition: session.c:54
GLuint GLint GLboolean GLint GLenum access
Definition: glext.h:7866
BOOL WINAPI WinHttpGetDefaultProxyConfiguration(WINHTTP_PROXY_INFO *info)
Definition: session.c:1503
__WINE_SERVER_LIST_INLINE void list_init(struct list *list)
Definition: list.h:149
void set_last_error(DWORD error)
Definition: session.c:59
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define DEFAULT_RECEIVE_TIMEOUT
Definition: session.c:57

Referenced by download_script(), open_async_request(), test_async(), test_bad_header(), test_basic_authentication(), test_basic_request(), test_chunked_read(), test_connection_cache(), test_connection_info(), test_cookies(), test_credentials(), test_empty_headers_param(), test_head_request(), test_large_data_authentication(), test_multi_authentication(), test_multiple_reads(), test_no_content(), test_no_headers(), test_not_modified(), test_OpenRequest(), test_QueryOption(), test_redirect(), test_request_parameter_defaults(), test_resolve_timeout(), test_secure_connection(), test_SendRequest(), test_Timeouts(), test_WinHttpAddHeaders(), test_WinHttpGetProxyForUrl(), transfer_file_http(), and winhttp_request_Open().

◆ WinHttpOpenRequest()

HINTERNET WINAPI WinHttpOpenRequest ( HINTERNET  hconnect,
LPCWSTR  verb,
LPCWSTR  object,
LPCWSTR  version,
LPCWSTR  referrer,
LPCWSTR types,
DWORD  flags 
)

Definition at line 1061 of file session.c.

1063 {
1064  request_t *request;
1065  connect_t *connect;
1066  HINTERNET hrequest = NULL;
1067 
1068  TRACE("%p, %s, %s, %s, %s, %p, 0x%08x\n", hconnect, debugstr_w(verb), debugstr_w(object),
1069  debugstr_w(version), debugstr_w(referrer), types, flags);
1070 
1071  if(types && TRACE_ON(winhttp)) {
1072  const WCHAR **iter;
1073 
1074  TRACE("accept types:\n");
1075  for(iter = types; *iter; iter++)
1076  TRACE(" %s\n", debugstr_w(*iter));
1077  }
1078 
1079  if (!(connect = (connect_t *)grab_object( hconnect )))
1080  {
1082  return NULL;
1083  }
1084  if (connect->hdr.type != WINHTTP_HANDLE_TYPE_CONNECT)
1085  {
1086  release_object( &connect->hdr );
1088  return NULL;
1089  }
1090  if (!(request = heap_alloc_zero( sizeof(request_t) )))
1091  {
1092  release_object( &connect->hdr );
1093  return NULL;
1094  }
1096  request->hdr.vtbl = &request_vtbl;
1097  request->hdr.refs = 1;
1098  request->hdr.flags = flags;
1099  request->hdr.callback = connect->hdr.callback;
1100  request->hdr.notify_mask = connect->hdr.notify_mask;
1101  request->hdr.context = connect->hdr.context;
1102  request->hdr.redirect_policy = connect->hdr.redirect_policy;
1103  list_init( &request->hdr.children );
1104  list_init( &request->task_queue );
1105 
1106  addref_object( &connect->hdr );
1107  request->connect = connect;
1108  list_add_head( &connect->hdr.children, &request->hdr.entry );
1109 
1110  request->resolve_timeout = connect->session->resolve_timeout;
1111  request->connect_timeout = connect->session->connect_timeout;
1112  request->send_timeout = connect->session->send_timeout;
1113  request->recv_timeout = connect->session->recv_timeout;
1114 
1115  if (!verb || !verb[0]) verb = getW;
1116  if (!(request->verb = strdupW( verb ))) goto end;
1117 
1118  if (object)
1119  {
1120  WCHAR *path, *p;
1121  unsigned int len;
1122 
1123  len = strlenW( object ) + 1;
1124  if (object[0] != '/') len++;
1125  if (!(p = path = heap_alloc( len * sizeof(WCHAR) ))) goto end;
1126 
1127  if (object[0] != '/') *p++ = '/';
1128  strcpyW( p, object );
1129  request->path = path;
1130  }
1131  else if (!(request->path = strdupW( slashW ))) goto end;
1132 
1133  if (!version || !version[0]) version = http1_1;
1134  if (!(request->version = strdupW( version ))) goto end;
1135  if (!(store_accept_types( request, types ))) goto end;
1136 
1137  if (!(hrequest = alloc_handle( &request->hdr ))) goto end;
1138  request->hdr.handle = hrequest;
1139 
1140  send_callback( &request->hdr, WINHTTP_CALLBACK_STATUS_HANDLE_CREATED, &hrequest, sizeof(hrequest) );
1141 
1142 end:
1143  release_object( &request->hdr );
1144  release_object( &connect->hdr );
1145  TRACE("returning %p\n", hrequest);
1146  if (hrequest) set_last_error( ERROR_SUCCESS );
1147  return hrequest;
1148 }
#define WINHTTP_HANDLE_TYPE_REQUEST
Definition: winhttp.h:432
static BOOL alloc_handle(struct handle_table *lpTable, OBJECTHDR *lpObject, HCRYPTKEY *lpHandle)
Definition: handle.c:183
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
#define ERROR_SUCCESS
Definition: deptool.c:10
GLsizei const GLchar ** path
Definition: glext.h:7234
static WCHAR * strdupW(const WCHAR *src)
Definition: main.c:92
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
__WINE_SERVER_LIST_INLINE void list_add_head(struct list *list, struct list *elem)
Definition: list.h:96
static BOOL store_accept_types(request_t *request, const WCHAR **accept_types)
Definition: session.c:1043
GLuint GLuint end
Definition: gl.h:1545
INT WSAAPI connect(IN SOCKET s, IN CONST struct sockaddr *name, IN INT namelen)
Definition: sockctrl.c:23
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
void send_callback(object_header_t *hdr, DWORD status, LPVOID info, DWORD buflen)
Definition: session.c:71
#define debugstr_w
Definition: kernel32.h:32
char path[256]
Definition: tftpd.h:94
smooth NULL
Definition: ftsmooth.c:416
static const WCHAR version[]
Definition: asmname.c:64
#define ERROR_WINHTTP_INCORRECT_HANDLE_TYPE
Definition: winhttp.h:199
#define TRACE(s)
Definition: solgame.cpp:4
Definition: cmds.c:130
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define WINHTTP_CALLBACK_STATUS_HANDLE_CREATED
Definition: winhttp.h:390
#define WINHTTP_HANDLE_TYPE_CONNECT
Definition: winhttp.h:431
GLbitfield flags
Definition: glext.h:7161
object_header_t * grab_object(HINTERNET hinternet)
Definition: handle.c:57
GLenum GLsizei len
Definition: glext.h:6722
void release_object(object_header_t *hdr)
Definition: handle.c:73
WINE_UNICODE_INLINE WCHAR * strcpyW(WCHAR *dst, const WCHAR *src)
Definition: unicode.h:219
static const object_vtbl_t request_vtbl
Definition: session.c:1036
Definition: services.c:325
static const WCHAR http1_1[]
Definition: tftpd.h:85
object_header_t * addref_object(object_header_t *hdr)
Definition: handle.c:50
__WINE_SERVER_LIST_INLINE void list_init(struct list *list)
Definition: list.h:149
void set_last_error(DWORD error)
Definition: session.c:59
GLfloat GLfloat p
Definition: glext.h:8902
static const WCHAR getW[]
Definition: lex.c:55
#define TRACE_ON(x)
Definition: compat.h:65
static const WCHAR slashW[]
Definition: devenum.c:62

Referenced by download_script(), open_async_request(), test_async(), test_bad_header(), test_basic_authentication(), test_basic_request(), test_chunked_read(), test_connection_cache(), test_connection_info(), test_cookies(), test_credentials(), test_empty_headers_param(), test_head_request(), test_large_data_authentication(), test_multi_authentication(), test_multiple_reads(), test_no_content(), test_no_headers(), test_not_modified(), test_OpenRequest(), test_QueryOption(), test_redirect(), test_request_parameter_defaults(), test_resolve_timeout(), test_secure_connection(), test_SendRequest(), test_Timeouts(), test_WinHttpAddHeaders(), transfer_file_http(), and winhttp_request_Open().

◆ WinHttpQueryOption()

BOOL WINAPI WinHttpQueryOption ( HINTERNET  handle,
DWORD  option,
LPVOID  buffer,
LPDWORD  buflen 
)

Definition at line 1211 of file session.c.

1212 {
1213  BOOL ret = FALSE;
1215 
1216  TRACE("%p, %u, %p, %p\n", handle, option, buffer, buflen);
1217 
1218  if (!(hdr = grab_object( handle )))
1219  {
1221  return FALSE;
1222  }
1223 
1224  ret = query_option( hdr, option, buffer, buflen );
1225 
1226  release_object( hdr );
1228  return ret;
1229 }
char hdr[14]
Definition: iptest.cpp:33
#define ERROR_SUCCESS
Definition: deptool.c:10
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
GLuint buffer
Definition: glext.h:5915
static BOOL query_option(object_header_t *hdr, DWORD option, LPVOID buffer, LPDWORD buflen)
Definition: session.c:1170
unsigned int BOOL
Definition: ntddk_ex.h:94
Definition: getopt.h:108
#define TRACE(s)
Definition: solgame.cpp:4
object_header_t * grab_object(HINTERNET hinternet)
Definition: handle.c:57
int ret
void release_object(object_header_t *hdr)
Definition: handle.c:73
void set_last_error(DWORD error)
Definition: session.c:59

Referenced by check_notification(), test_basic_request(), test_connection_info(), test_credentials(), test_QueryOption(), test_secure_connection(), test_SendRequest(), and test_Timeouts().

◆ WinHttpSetDefaultProxyConfiguration()

BOOL WINAPI WinHttpSetDefaultProxyConfiguration ( WINHTTP_PROXY_INFO info)

Definition at line 1914 of file session.c.

1915 {
1916  LONG l;
1917  HKEY key;
1918  BOOL ret = FALSE;
1919  const WCHAR *src;
1920 
1921  TRACE("%p\n", info);
1922 
1923  if (!info)
1924  {
1926  return FALSE;
1927  }
1928  switch (info->dwAccessType)
1929  {
1931  break;
1933  if (!info->lpszProxy)
1934  {
1936  return FALSE;
1937  }
1938  /* Only ASCII characters are allowed */
1939  for (src = info->lpszProxy; *src; src++)
1940  if (*src > 0x7f)
1941  {
1943  return FALSE;
1944  }
1945  if (info->lpszProxyBypass)
1946  {
1947  for (src = info->lpszProxyBypass; *src; src++)
1948  if (*src > 0x7f)
1949  {
1951  return FALSE;
1952  }
1953  }
1954  break;
1955  default:
1957  return FALSE;
1958  }
1959 
1961  KEY_WRITE, NULL, &key, NULL );
1962  if (!l)
1963  {
1964  DWORD size = sizeof(struct connection_settings_header) + 2 * sizeof(DWORD);
1965  BYTE *buf;
1966 
1967  if (info->dwAccessType == WINHTTP_ACCESS_TYPE_NAMED_PROXY)
1968  {
1969  size += strlenW( info->lpszProxy );
1970  if (info->lpszProxyBypass)
1971  size += strlenW( info->lpszProxyBypass );
1972  }
1973  buf = heap_alloc( size );
1974  if (buf)
1975  {
1977  (struct connection_settings_header *)buf;
1978  DWORD *len = (DWORD *)(hdr + 1);
1979 
1980  hdr->magic = WINHTTP_SETTINGS_MAGIC;
1981  hdr->unknown = 0;
1982  if (info->dwAccessType == WINHTTP_ACCESS_TYPE_NAMED_PROXY)
1983  {
1984  BYTE *dst;
1985 
1986  hdr->flags = PROXY_TYPE_PROXY;
1987  *len++ = strlenW( info->lpszProxy );
1988  for (dst = (BYTE *)len, src = info->lpszProxy; *src;
1989  src++, dst++)
1990  *dst = *src;
1991  len = (DWORD *)dst;
1992  if (info->lpszProxyBypass)
1993  {
1994  *len++ = strlenW( info->lpszProxyBypass );
1995  for (dst = (BYTE *)len, src = info->lpszProxyBypass; *src;
1996  src++, dst++)
1997  *dst = *src;
1998  }
1999  else
2000  *len++ = 0;
2001  }
2002  else
2003  {
2004  hdr->flags = PROXY_TYPE_DIRECT;
2005  *len++ = 0;
2006  *len++ = 0;
2007  }
2009  if (!l)
2010  ret = TRUE;
2011  heap_free( buf );
2012  }
2013  RegCloseKey( key );
2014  }
2016  return ret;
2017 }
#define WINHTTP_ACCESS_TYPE_NAMED_PROXY
Definition: winhttp.h:64
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define TRUE
Definition: types.h:120
char hdr[14]
Definition: iptest.cpp:33
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
#define ERROR_SUCCESS
Definition: deptool.c:10
#define WINHTTP_ACCESS_TYPE_NO_PROXY
Definition: winhttp.h:63
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define REG_BINARY
Definition: nt_native.h:1496
static const WCHAR Connections[]
Definition: session.c:1468
#define DWORD
Definition: nt_native.h:44
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
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:1094
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned int BOOL
Definition: ntddk_ex.h:94
long LONG
Definition: pedump.c:60
smooth NULL
Definition: ftsmooth.c:416
r l[0]
Definition: byte_order.h:167
#define KEY_WRITE
Definition: nt_native.h:1031
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:4917
#define TRACE(s)
Definition: solgame.cpp:4
GLsizeiptr size
Definition: glext.h:5919
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
HKEY key
Definition: reg.c:42
GLenum GLsizei len
Definition: glext.h:6722
unsigned char BYTE
Definition: mem.h:68
GLenum src
Definition: glext.h:6340
GLenum GLenum dst
Definition: glext.h:6340
static const WCHAR WinHttpSettings[]
Definition: session.c:1475
static const DWORD PROXY_TYPE_PROXY
Definition: session.c:1480
static const DWORD PROXY_TYPE_DIRECT
Definition: session.c:1479
static const DWORD WINHTTP_SETTINGS_MAGIC
Definition: session.c:1477
void set_last_error(DWORD error)
Definition: session.c:59
Definition: path.c:42
static BOOL heap_free(void *mem)
Definition: appwiz.h:75
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12

Referenced by test_set_default_proxy_config().

◆ WinHttpSetOption()

BOOL WINAPI WinHttpSetOption ( HINTERNET  handle,
DWORD  option,
LPVOID  buffer,
DWORD  buflen 
)

Definition at line 1270 of file session.c.

1271 {
1272  BOOL ret = FALSE;
1274 
1275  TRACE("%p, %u, %p, %u\n", handle, option, buffer, buflen);
1276 
1277  if (!(hdr = grab_object( handle )))
1278  {
1280  return FALSE;
1281  }
1282 
1283  ret = set_option( hdr, option, buffer, buflen );
1284 
1285  release_object( hdr );
1287  return ret;
1288 }
char hdr[14]
Definition: iptest.cpp:33
#define ERROR_SUCCESS
Definition: deptool.c:10
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
GLuint buffer
Definition: glext.h:5915
unsigned int BOOL
Definition: ntddk_ex.h:94
Definition: getopt.h:108
#define TRACE(s)
Definition: solgame.cpp:4
object_header_t * grab_object(HINTERNET hinternet)
Definition: handle.c:57
int ret
void release_object(object_header_t *hdr)
Definition: handle.c:73
void set_last_error(DWORD error)
Definition: session.c:59
static BOOL set_option(object_header_t *hdr, DWORD option, LPVOID buffer, DWORD buflen)
Definition: session.c:1231

Referenced by open_async_request(), request_set_parameters(), test_async(), test_basic_authentication(), test_basic_request(), test_connection_cache(), test_credentials(), test_QueryOption(), test_redirect(), test_resolve_timeout(), test_secure_connection(), test_SendRequest(), test_Timeouts(), transfer_file_http(), and winhttp_request_Open().

◆ WinHttpSetStatusCallback()

WINHTTP_STATUS_CALLBACK WINAPI WinHttpSetStatusCallback ( HINTERNET  handle,
WINHTTP_STATUS_CALLBACK  callback,
DWORD  flags,
DWORD_PTR  reserved 
)

Definition at line 2022 of file session.c.

2024 {
2027 
2028  TRACE("%p, %p, 0x%08x, 0x%lx\n", handle, callback, flags, reserved);
2029 
2030  if (!(hdr = grab_object( handle )))
2031  {
2034  }
2035  ret = hdr->callback;
2036  hdr->callback = callback;
2037  hdr->notify_mask = flags;
2038 
2039  release_object( hdr );
2041  return ret;
2042 }
VOID(CALLBACK * WINHTTP_STATUS_CALLBACK)(_In_ HINTERNET, _In_ DWORD_PTR, _In_ DWORD, _In_ LPVOID, _In_ DWORD)
Definition: winhttp.h:520
#define WINHTTP_INVALID_STATUS_CALLBACK
Definition: winhttp.h:422
char hdr[14]
Definition: iptest.cpp:33
#define ERROR_SUCCESS
Definition: deptool.c:10
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
r reserved
Definition: btrfs.c:2655
MmuTrapHandler callback[0x30]
Definition: mmuobject.c:44
#define TRACE(s)
Definition: solgame.cpp:4
GLbitfield flags
Definition: glext.h:7161
object_header_t * grab_object(HINTERNET hinternet)
Definition: handle.c:57
int ret
void release_object(object_header_t *hdr)
Definition: handle.c:73
void set_last_error(DWORD error)
Definition: session.c:59

Referenced by open_async_request(), test_async(), test_connection_cache(), test_redirect(), test_secure_connection(), transfer_file_http(), and wait_set_status_callback().

◆ WinHttpSetTimeouts()

BOOL WINAPI WinHttpSetTimeouts ( HINTERNET  handle,
int  resolve,
int  connect,
int  send,
int  receive 
)

Definition at line 2047 of file session.c.

2048 {
2049  BOOL ret = TRUE;
2051  request_t *request;
2052  session_t *session;
2053 
2054  TRACE("%p, %d, %d, %d, %d\n", handle, resolve, connect, send, receive);
2055 
2056  if (resolve < -1 || connect < -1 || send < -1 || receive < -1)
2057  {
2059  return FALSE;
2060  }
2061 
2062  if (!(hdr = grab_object( handle )))
2063  {
2065  return FALSE;
2066  }
2067 
2068  switch(hdr->type)
2069  {
2071  request = (request_t *)hdr;
2072  request->connect_timeout = connect;
2073 
2074  if (resolve < 0) resolve = 0;
2075  request->resolve_timeout = resolve;
2076 
2077  if (send < 0) send = 0;
2078  request->send_timeout = send;
2079 
2080  if (receive < 0) receive = 0;
2081  request->recv_timeout = receive;
2082 
2083  if (request->netconn)
2084  {
2085  if (netconn_set_timeout( request->netconn, TRUE, send )) ret = FALSE;
2086  if (netconn_set_timeout( request->netconn, FALSE, receive )) ret = FALSE;
2087  }
2088  break;
2089 
2091  session = (session_t *)hdr;
2092  session->connect_timeout = connect;
2093 
2094  if (resolve < 0) resolve = 0;
2095  session->resolve_timeout = resolve;
2096 
2097  if (send < 0) send = 0;
2098  session->send_timeout = send;
2099 
2100  if (receive < 0) receive = 0;
2101  session->recv_timeout = receive;
2102  break;
2103 
2104  default:
2106  ret = FALSE;
2107  }
2108  release_object( hdr );
2110  return ret;
2111 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define WINHTTP_HANDLE_TYPE_REQUEST
Definition: winhttp.h:432
#define TRUE
Definition: types.h:120
char hdr[14]
Definition: iptest.cpp:33
#define ERROR_SUCCESS
Definition: deptool.c:10
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
INT WSAAPI connect(IN SOCKET s, IN CONST struct sockaddr *name, IN INT namelen)
Definition: sockctrl.c:23
unsigned int BOOL
Definition: ntddk_ex.h:94
#define ERROR_WINHTTP_INCORRECT_HANDLE_TYPE
Definition: winhttp.h:199
#define WINHTTP_HANDLE_TYPE_SESSION
Definition: winhttp.h:430
#define TRACE(s)
Definition: solgame.cpp:4
INT WSAAPI send(IN SOCKET s, IN CONST CHAR FAR *buf, IN INT len, IN INT flags)
Definition: send.c:23
object_header_t * grab_object(HINTERNET hinternet)
Definition: handle.c:57
int ret
void release_object(object_header_t *hdr)
Definition: handle.c:73
DWORD netconn_set_timeout(netconn_t *netconn, BOOL send, int value)
Definition: net.c:768
Definition: tftpd.h:85
void set_last_error(DWORD error)
Definition: session.c:59

Referenced by request_set_parameters(), and test_Timeouts().

◆ WinHttpTimeFromSystemTime()

BOOL WINAPI WinHttpTimeFromSystemTime ( const SYSTEMTIME time,
LPWSTR  string 
)

Definition at line 2124 of file session.c.

2125 {
2126  static const WCHAR format[] =
2127  {'%','s',',',' ','%','0','2','d',' ','%','s',' ','%','4','d',' ','%','0',
2128  '2','d',':','%','0','2','d',':','%','0','2','d',' ','G','M','T', 0};
2129 
2130  TRACE("%p, %p\n", time, string);
2131 
2132  if (!time || !string)
2133  {
2135  return FALSE;
2136  }
2137 
2138  sprintfW( string, format,
2139  wkday[time->wDayOfWeek],
2140  time->wDay,
2141  month[time->wMonth - 1],
2142  time->wYear,
2143  time->wHour,
2144  time->wMinute,
2145  time->wSecond );
2146 
2148  return TRUE;
2149 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define TRUE
Definition: types.h:120
#define ERROR_SUCCESS
Definition: deptool.c:10
__u16 time
Definition: mkdosfs.c:366
static const WCHAR wkday[7][4]
Definition: session.c:2113
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define sprintfW
Definition: unicode.h:58
void set_last_error(DWORD error)
Definition: session.c:59
static const WCHAR month[12][4]
Definition: session.c:2116

Referenced by test_IWinHttpRequest(), test_not_modified(), and test_WinHttpTimeFromSystemTime().

◆ WinHttpTimeToSystemTime()

BOOL WINAPI WinHttpTimeToSystemTime ( LPCWSTR  string,
SYSTEMTIME time 
)

Definition at line 2154 of file session.c.

2155 {
2156  unsigned int i;
2157  const WCHAR *s = string;
2158  WCHAR *end;
2159 
2160  TRACE("%s, %p\n", debugstr_w(string), time);
2161 
2162  if (!string || !time)
2163  {
2165  return FALSE;
2166  }
2167 
2168  /* Windows does this too */
2169  GetSystemTime( time );
2170 
2171  /* Convert an RFC1123 time such as 'Fri, 07 Jan 2005 12:06:35 GMT' into
2172  * a SYSTEMTIME structure.
2173  */
2174 
2176 
2177  while (*s && !isalphaW( *s )) s++;
2178  if (s[0] == '\0' || s[1] == '\0' || s[2] == '\0') return TRUE;
2179  time->wDayOfWeek = 7;
2180 
2181  for (i = 0; i < 7; i++)
2182  {
2183  if (toupperW( wkday[i][0] ) == toupperW( s[0] ) &&
2184  toupperW( wkday[i][1] ) == toupperW( s[1] ) &&
2185  toupperW( wkday[i][2] ) == toupperW( s[2] ) )
2186  {
2187  time->wDayOfWeek = i;
2188  break;
2189  }
2190  }
2191 
2192  if (time->wDayOfWeek > 6) return TRUE;
2193  while (*s && !isdigitW( *s )) s++;
2194  time->wDay = strtolW( s, &end, 10 );
2195  s = end;
2196 
2197  while (*s && !isalphaW( *s )) s++;
2198  if (s[0] == '\0' || s[1] == '\0' || s[2] == '\0') return TRUE;
2199  time->wMonth = 0;
2200 
2201  for (i = 0; i &