ReactOS  0.4.14-dev-583-g2a1ba2c
session.c File Reference
#include "config.h"
#include <stdarg.h>
#include <stdlib.h>
#include "windef.h"
#include "winbase.h"
#include "winsock2.h"
#include "ws2ipdef.h"
#include "ws2tcpip.h"
#include "winhttp.h"
#include "winreg.h"
#include "wine/winternl.h"
#include "ole2.h"
#include "dispex.h"
#include "activscp.h"
#include "wine/debug.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 COBJMACROS
 
#define DEFAULT_RESOLVE_TIMEOUT   0
 
#define DEFAULT_CONNECT_TIMEOUT   20000
 
#define DEFAULT_SEND_TIMEOUT   30000
 
#define DEFAULT_RECEIVE_TIMEOUT   30000
 
#define DEFAULT_RECEIVE_RESPONSE_TIMEOUT   ~0u
 
#define MAX_HOST_NAME_LENGTH   256
 
#define INTERNET_MAX_URL_LENGTH   2084
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (winhttp)
 
void send_callback (struct object_header *hdr, DWORD status, void *info, DWORD buflen)
 
BOOL WINAPI WinHttpCheckPlatform (void)
 
static void session_destroy (struct object_header *hdr)
 
static BOOL session_query_option (struct object_header *hdr, DWORD option, void *buffer, DWORD *buflen)
 
static BOOL session_set_option (struct object_header *hdr, DWORD option, void *buffer, DWORD buflen)
 
HINTERNET WINAPI WinHttpOpen (LPCWSTR agent, DWORD access, LPCWSTR proxy, LPCWSTR bypass, DWORD flags)
 
static void connect_destroy (struct object_header *hdr)
 
static BOOL connect_query_option (struct object_header *hdr, DWORD option, void *buffer, DWORD *buflen)
 
static BOOL domain_matches (LPCWSTR server, LPCWSTR domain)
 
static BOOL should_bypass_proxy (struct session *session, LPCWSTR server)
 
BOOL set_server_for_hostname (struct connect *connect, const WCHAR *server, INTERNET_PORT port)
 
HINTERNET WINAPI WinHttpConnect (HINTERNET hsession, LPCWSTR server, INTERNET_PORT port, DWORD reserved)
 
static void request_destroy (struct object_header *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 copy_sockaddr (const struct sockaddr *addr, SOCKADDR_STORAGE *addr_storage)
 
static BOOL request_query_option (struct object_header *hdr, DWORD option, void *buffer, DWORD *buflen)
 
static WCHARbuffer_to_str (WCHAR *buffer, DWORD buflen)
 
static BOOL request_set_option (struct object_header *hdr, DWORD option, void *buffer, DWORD buflen)
 
static BOOL add_accept_types_header (struct request *request, const WCHAR **types)
 
static WCHARget_request_path (const WCHAR *object)
 
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 (struct object_header *hdr, DWORD option, void *buffer, DWORD *buflen)
 
BOOL WINAPI WinHttpQueryOption (HINTERNET handle, DWORD option, LPVOID buffer, LPDWORD buflen)
 
static BOOL set_option (struct object_header *hdr, DWORD option, void *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 struct object_vtbl session_vtbl
 
static const struct object_vtbl connect_vtbl
 
static const struct object_vtbl 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 39 of file session.c.

◆ DEFAULT_CONNECT_TIMEOUT

#define DEFAULT_CONNECT_TIMEOUT   20000

Definition at line 50 of file session.c.

◆ DEFAULT_RECEIVE_RESPONSE_TIMEOUT

#define DEFAULT_RECEIVE_RESPONSE_TIMEOUT   ~0u

Definition at line 53 of file session.c.

◆ DEFAULT_RECEIVE_TIMEOUT

#define DEFAULT_RECEIVE_TIMEOUT   30000

Definition at line 52 of file session.c.

◆ DEFAULT_RESOLVE_TIMEOUT

#define DEFAULT_RESOLVE_TIMEOUT   0

Definition at line 49 of file session.c.

◆ DEFAULT_SEND_TIMEOUT

#define DEFAULT_SEND_TIMEOUT   30000

Definition at line 51 of file session.c.

◆ INTERNET_MAX_URL_LENGTH

#define INTERNET_MAX_URL_LENGTH   2084

Definition at line 1410 of file session.c.

◆ MAX_HOST_NAME_LENGTH

#define MAX_HOST_NAME_LENGTH   256

Definition at line 435 of file session.c.

Function Documentation

◆ add_accept_types_header()

static BOOL add_accept_types_header ( struct request request,
const WCHAR **  types 
)
static

Definition at line 1079 of file session.c.

1080 {
1081  static const WCHAR acceptW[] = {'A','c','c','e','p','t',0};
1083 
1084  if (!types) return TRUE;
1085  while (*types)
1086  {
1087  if (!process_header( request, acceptW, *types, flags, TRUE )) return FALSE;
1088  types++;
1089  }
1090  return TRUE;
1091 }
#define TRUE
Definition: types.h:120
#define WINHTTP_ADDREQ_FLAG_ADD
Definition: winhttp.h:84
BOOL process_header(struct request *request, const WCHAR *field, const WCHAR *value, DWORD flags, BOOL request_only)
Definition: request.c:430
#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
Definition: tftpd.h:85

Referenced by WinHttpOpenRequest().

◆ blob_to_str()

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

Definition at line 664 of file session.c.

665 {
666  WCHAR *ret;
668 
670  if ((ret = LocalAlloc( 0, size * sizeof(WCHAR) )))
672 
673  return ret;
674 }
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:2839
#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 868 of file session.c.

869 {
870  WCHAR *ret;
871  if ((ret = heap_alloc( (buflen + 1) * sizeof(WCHAR))))
872  {
873  memcpy( ret, buffer, buflen * sizeof(WCHAR) );
874  ret[buflen] = 0;
875  return ret;
876  }
878  return NULL;
879 }
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
#define SetLastError(x)
Definition: compat.h:417
int ret
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#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 1354 of file session.c.

1355 {
1356  static const WCHAR httpW[] = {'h','t','t','p',':','/','/',0};
1357  static const WCHAR wpadW[] = {'/','w','p','a','d','.','d','a','t',0};
1358  char name[NI_MAXHOST];
1359  WCHAR *ret, *p;
1360  int len;
1361 
1362  while (ai && ai->ai_family != AF_INET && ai->ai_family != AF_INET6) ai = ai->ai_next;
1363  if (!ai) return NULL;
1364 
1365  if (!reverse_lookup( ai, name, sizeof(name) )) hostname = name;
1366 
1367  len = strlenW( httpW ) + strlen( hostname ) + strlenW( wpadW );
1368  if (!(ret = p = GlobalAlloc( 0, (len + 1) * sizeof(WCHAR) ))) return NULL;
1369  strcpyW( p, httpW );
1370  p += strlenW( httpW );
1371  while (*hostname) { *p++ = *hostname++; }
1372  strcpyW( p, wpadW );
1373  return ret;
1374 }
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:38
static int reverse_lookup(const struct addrinfo *ai, char *hostname, size_t len)
Definition: session.c:1349
#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 ( struct object_header hdr)
static

Definition at line 310 of file session.c.

311 {
312  struct connect *connect = (struct connect *)hdr;
313 
314  TRACE("%p\n", connect);
315 
316  release_object( &connect->session->hdr );
317 
322  heap_free( connect );
323 }
char hdr[14]
Definition: iptest.cpp:33
struct session * session
WCHAR * username
#define TRACE(s)
Definition: solgame.cpp:4
WCHAR * password
WCHAR * hostname
WCHAR * servername
static BOOL heap_free(void *mem)
Definition: appwiz.h:75
void release_object(struct object_header *hdr)
Definition: handle.c:72

◆ connect_query_option()

static BOOL connect_query_option ( struct object_header hdr,
DWORD  option,
void buffer,
DWORD buflen 
)
static

Definition at line 325 of file session.c.

326 {
327  struct connect *connect = (struct connect *)hdr;
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 = ((struct object_header *)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;
348 
350  *(DWORD *)buffer = connect->session->connect_timeout;
351  *buflen = sizeof(DWORD);
352  return TRUE;
353 
355  *(DWORD *)buffer = connect->session->send_timeout;
356  *buflen = sizeof(DWORD);
357  return TRUE;
358 
360  *(DWORD *)buffer = connect->session->receive_timeout;
361  *buflen = sizeof(DWORD);
362  return TRUE;
363 
365  *(DWORD *)buffer = connect->session->receive_response_timeout;
366  *buflen = sizeof(DWORD);
367  return TRUE;
368 
369  default:
370  FIXME("unimplemented option %u\n", option);
372  return FALSE;
373  }
374 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define WINHTTP_OPTION_RECEIVE_TIMEOUT
Definition: winhttp.h:99
LPVOID HINTERNET
Definition: winhttp.h:32
#define WINHTTP_OPTION_RECEIVE_RESPONSE_TIMEOUT
Definition: winhttp.h:100
#define TRUE
Definition: types.h:120
char hdr[14]
Definition: iptest.cpp:33
#define WINHTTP_OPTION_SEND_TIMEOUT
Definition: winhttp.h:98
struct session * session
GLuint buffer
Definition: glext.h:5915
#define WINHTTP_OPTION_PARENT_HANDLE
Definition: winhttp.h:104
#define FIXME(fmt,...)
Definition: debug.h:110
Definition: getopt.h:108
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:417
#define WINHTTP_OPTION_RESOLVE_TIMEOUT
Definition: winhttp.h:95
#define WINHTTP_OPTION_CONNECT_TIMEOUT
Definition: winhttp.h:96
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10

◆ copy_char_to_wchar_sz()

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

Definition at line 1517 of file session.c.

1518 {
1519  const BYTE *begin;
1520 
1521  for (begin = src; src - begin < len; src++, dst++)
1522  *dst = *src;
1523  *dst = 0;
1524 }
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().

◆ copy_sockaddr()

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

Definition at line 676 of file session.c.

677 {
678  switch (addr->sa_family)
679  {
680  case AF_INET:
681  {
682  struct sockaddr_in *addr_in = (struct sockaddr_in *)addr_storage;
683 
684  memcpy( addr_in, addr, sizeof(*addr_in) );
685  memset( addr_in + 1, 0, sizeof(*addr_storage) - sizeof(*addr_in) );
686  return TRUE;
687  }
688  case AF_INET6:
689  {
690  struct sockaddr_in6 *addr_in6 = (struct sockaddr_in6 *)addr_storage;
691 
692  memcpy( addr_in6, addr, sizeof(*addr_in6) );
693  memset( addr_in6 + 1, 0, sizeof(*addr_storage) - sizeof(*addr_in6) );
694  return TRUE;
695  }
696  default:
697  ERR("unhandled family %u\n", addr->sa_family);
698  return FALSE;
699  }
700 }
#define TRUE
Definition: types.h:120
#define AF_INET6
Definition: winsock.h:369
GLenum const GLvoid * addr
Definition: glext.h:9621
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define ERR(fmt,...)
Definition: debug.h:109
#define AF_INET
Definition: tcpip.h:117
#define memset(x, y, z)
Definition: compat.h:39

Referenced by request_query_option().

◆ domain_matches()

static BOOL domain_matches ( LPCWSTR  server,
LPCWSTR  domain 
)
static

Definition at line 383 of file session.c.

384 {
385  static const WCHAR localW[] = { '<','l','o','c','a','l','>',0 };
386  BOOL ret = FALSE;
387 
388  if (!strcmpiW( domain, localW ) && !strchrW( server, '.' ))
389  ret = TRUE;
390  else if (*domain == '*')
391  {
392  if (domain[1] == '.')
393  {
394  LPCWSTR dot;
395 
396  /* For a hostname to match a wildcard, the last domain must match
397  * the wildcard exactly. E.g. if the wildcard is *.a.b, and the
398  * hostname is www.foo.a.b, it matches, but a.b does not.
399  */
400  dot = strchrW( server, '.' );
401  if (dot)
402  {
403  int len = strlenW( dot + 1 );
404 
405  if (len > strlenW( domain + 2 ))
406  {
407  LPCWSTR ptr;
408 
409  /* The server's domain is longer than the wildcard, so it
410  * could be a subdomain. Compare the last portion of the
411  * server's domain.
412  */
413  ptr = dot + len + 1 - strlenW( domain + 2 );
414  if (!strcmpiW( ptr, domain + 2 ))
415  {
416  /* This is only a match if the preceding character is
417  * a '.', i.e. that it is a matching domain. E.g.
418  * if domain is '*.b.c' and server is 'www.ab.c' they
419  * do not match.
420  */
421  ret = *(ptr - 1) == '.';
422  }
423  }
424  else
425  ret = !strcmpiW( dot + 1, domain + 2 );
426  }
427  }
428  }
429  else
430  ret = !strcmpiW( server, domain );
431  return ret;
432 }
#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
Definition: cookie.c:41
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 1770 of file session.c.

1771 {
1772  static const WCHAR typeW[] = {'*','/','*',0};
1773  static const WCHAR *acceptW[] = {typeW, NULL};
1774  HINTERNET ses, con = NULL, req = NULL;
1775  WCHAR *hostname;
1776  URL_COMPONENTSW uc;
1777  DWORD status, size = sizeof(status), offset, to_read, bytes_read, flags = 0;
1778  char *tmp, *buffer = NULL;
1779 
1780  *out_size = 0;
1781 
1782  memset( &uc, 0, sizeof(uc) );
1783  uc.dwStructSize = sizeof(uc);
1784  uc.dwHostNameLength = -1;
1785  uc.dwUrlPathLength = -1;
1786  if (!WinHttpCrackUrl( url, 0, 0, &uc )) return NULL;
1787  if (!(hostname = heap_alloc( (uc.dwHostNameLength + 1) * sizeof(WCHAR) ))) return NULL;
1788  memcpy( hostname, uc.lpszHostName, uc.dwHostNameLength * sizeof(WCHAR) );
1789  hostname[uc.dwHostNameLength] = 0;
1790 
1791  if (!(ses = WinHttpOpen( NULL, WINHTTP_ACCESS_TYPE_NO_PROXY, NULL, NULL, 0 ))) goto done;
1792  if (!(con = WinHttpConnect( ses, hostname, uc.nPort, 0 ))) goto done;
1794  if (!(req = WinHttpOpenRequest( con, NULL, uc.lpszUrlPath, NULL, NULL, acceptW, flags ))) goto done;
1795  if (!WinHttpSendRequest( req, NULL, 0, NULL, 0, 0, 0 )) goto done;
1796 
1797  if (!(WinHttpReceiveResponse( req, 0 ))) goto done;
1799  &size, NULL ) || status != HTTP_STATUS_OK) goto done;
1800 
1801  size = 4096;
1802  if (!(buffer = heap_alloc( size ))) goto done;
1803  to_read = size;
1804  offset = 0;
1805  for (;;)
1806  {
1807  if (!WinHttpReadData( req, buffer + offset, to_read, &bytes_read )) goto done;
1808  if (!bytes_read) break;
1809  to_read -= bytes_read;
1810  offset += bytes_read;
1811  *out_size += bytes_read;
1812  if (!to_read)
1813  {
1814  to_read = size;
1815  size *= 2;
1816  if (!(tmp = heap_realloc( buffer, size ))) goto done;
1817  buffer = tmp;
1818  }
1819  }
1820 
1821 done:
1822  WinHttpCloseHandle( req );
1823  WinHttpCloseHandle( con );
1824  WinHttpCloseHandle( ses );
1825  heap_free( hostname );
1827  return buffer;
1828 }
HINTERNET WINAPI WinHttpConnect(HINTERNET hsession, LPCWSTR server, INTERNET_PORT port, DWORD reserved)
Definition: session.c:533
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:1187
#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:51
#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:856
INTERNET_PORT nPort
Definition: wininet.h:217
BOOL WINAPI WinHttpReceiveResponse(HINTERNET hrequest, LPVOID reserved)
Definition: request.c:2924
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:179
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:4136
unsigned long DWORD
Definition: ntddk_ex.h:95
#define HTTP_STATUS_OK
Definition: winhttp.h:240
#define SetLastError(x)
Definition: compat.h:417
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
HINTERNET WINAPI WinHttpOpenRequest(HINTERNET hconnect, LPCWSTR verb, LPCWSTR object, LPCWSTR version, LPCWSTR referrer, LPCWSTR *types, DWORD flags)
Definition: session.c:1109
#define memset(x, y, z)
Definition: compat.h:39
static SERVICE_STATUS status
Definition: service.c:31
BOOL WINAPI WinHttpSendRequest(HINTERNET hrequest, LPCWSTR headers, DWORD headers_len, LPVOID optional, DWORD optional_len, DWORD total_len, DWORD_PTR context)
Definition: request.c:2350
BOOL WINAPI WinHttpReadData(HINTERNET hrequest, LPVOID buffer, DWORD to_read, LPDWORD read)
Definition: request.c:3053
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 1324 of file session.c.

1325 {
1326  char *ret;
1327  DWORD size = 0;
1328 
1330  if (GetLastError() != ERROR_MORE_DATA) return NULL;
1331  if (!(ret = heap_alloc( size ))) return NULL;
1332  if (!GetComputerNameExA( format, ret, &size ))
1333  {
1334  heap_free( ret );
1335  return NULL;
1336  }
1337  return ret;
1338 }
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_request_path()

static WCHAR* get_request_path ( const WCHAR object)
static

Definition at line 1093 of file session.c.

1094 {
1095  int len = object ? strlenW(object) : 0;
1096  WCHAR *p, *ret;
1097 
1098  if (!object || object[0] != '/') len++;
1099  if (!(p = ret = heap_alloc( (len + 1) * sizeof(WCHAR) ))) return NULL;
1100  if (!object || object[0] != '/') *p++ = '/';
1101  if (object) strcpyW( p, object );
1102  ret[len] = 0;
1103  return ret;
1104 }
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
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
GLenum GLsizei len
Definition: glext.h:6722
WINE_UNICODE_INLINE WCHAR * strcpyW(WCHAR *dst, const WCHAR *src)
Definition: unicode.h:219
GLfloat GLfloat p
Definition: glext.h:8902

Referenced by WinHttpOpenRequest().

◆ get_system_proxy_autoconfig_url()

static BOOL get_system_proxy_autoconfig_url ( char buf,
DWORD  buflen 
)
static

Definition at line 1376 of file session.c.

1377 {
1378 #if defined(MAC_OS_X_VERSION_10_6) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6
1379  CFDictionaryRef settings = CFNetworkCopySystemProxySettings();
1380  const void *ref;
1381  BOOL ret = FALSE;
1382 
1383  if (!settings) return FALSE;
1384 
1385  if (!(ref = CFDictionaryGetValue( settings, kCFNetworkProxiesProxyAutoConfigURLString )))
1386  {
1387  CFRelease( settings );
1388  return FALSE;
1389  }
1390  if (CFStringGetCString( ref, buf, buflen, kCFStringEncodingASCII ))
1391  {
1392  TRACE( "returning %s\n", debugstr_a(buf) );
1393  ret = TRUE;
1394  }
1395  CFRelease( settings );
1396  return ret;
1397 #else
1398  static BOOL first = TRUE;
1399  if (first)
1400  {
1401  FIXME( "no support on this platform\n" );
1402  first = FALSE;
1403  }
1404  else
1405  TRACE( "no support on this platform\n" );
1406  return FALSE;
1407 #endif
1408 }
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 111 of file main.c.

112 {
113  TRACE( "%s, %u\n", debugstr_a(mime), reserved );
114 
116 
117  heap_free( global_script->text );
118  global_script->text = NULL;
119 
121  return TRUE;
122 }
#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:106
r reserved
Definition: btrfs.c:2865
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:46
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 1340 of file session.c.

1341 {
1342  int len_domain = strlen( domain ), len_suffix = strlen( suffix );
1343 
1344  if (len_suffix > len_domain) return FALSE;
1345  if (!_strnicmp( domain + len_domain - len_suffix, suffix, -1 )) return TRUE;
1346  return FALSE;
1347 }
#define TRUE
Definition: types.h:120
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
Definition: cookie.c:41
_Check_return_ _CRTIMP int __cdecl _strnicmp(_In_reads_or_z_(_MaxCount) const char *_Str1, _In_reads_or_z_(_MaxCount) const char *_Str2, _In_ size_t _MaxCount)

Referenced by WinHttpDetectAutoProxyConfigUrl().

◆ parse_script_result()

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

Definition at line 1736 of file session.c.

1737 {
1738  const char *p;
1739  WCHAR *q;
1740  int len;
1741 
1742  info->dwAccessType = WINHTTP_ACCESS_TYPE_NO_PROXY;
1743  info->lpszProxy = NULL;
1744  info->lpszProxyBypass = NULL;
1745 
1746  TRACE("%s\n", debugstr_a( result ));
1747 
1748  p = result;
1749  while (*p == ' ') p++;
1750  len = strlen( p );
1751  if (len >= 5 && !_strnicmp( p, "PROXY", sizeof("PROXY") - 1 ))
1752  {
1753  p += 5;
1754  while (*p == ' ') p++;
1755  if (!*p || *p == ';') return TRUE;
1756  if (!(info->lpszProxy = q = strdupAW( p ))) return FALSE;
1757  info->dwAccessType = WINHTTP_ACCESS_TYPE_NAMED_PROXY;
1758  for (; *q; q++)
1759  {
1760  if (*q == ' ' || *q == ';')
1761  {
1762  *q = 0;
1763  break;
1764  }
1765  }
1766  }
1767  return TRUE;
1768 }
#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:76
_Check_return_ _CRTIMP int __cdecl _strnicmp(_In_reads_or_z_(_MaxCount) const char *_Str1, _In_reads_or_z_(_MaxCount) const char *_Str2, _In_ size_t _MaxCount)
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 ( struct object_header hdr,
DWORD  option,
void buffer,
DWORD buflen 
)
static

Definition at line 1204 of file session.c.

1205 {
1206  BOOL ret = FALSE;
1207 
1208  if (!buflen)
1209  {
1211  return FALSE;
1212  }
1213 
1214  switch (option)
1215  {
1217  {
1218  if (!buffer || *buflen < sizeof(DWORD_PTR))
1219  {
1220  *buflen = sizeof(DWORD_PTR);
1222  return FALSE;
1223  }
1224 
1225  *(DWORD_PTR *)buffer = hdr->context;
1226  *buflen = sizeof(DWORD_PTR);
1227  return TRUE;
1228  }
1229  default:
1230  if (hdr->vtbl->query_option) ret = hdr->vtbl->query_option( hdr, option, buffer, buflen );
1231  else
1232  {
1233  FIXME("unimplemented option %u\n", option);
1235  return FALSE;
1236  }
1237  break;
1238  }
1239  return ret;
1240 }
#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
#define SetLastError(x)
Definition: compat.h:417
int ret
uint32_t DWORD_PTR
Definition: typedefs.h:63
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10

Referenced by WinHttpQueryOption().

◆ request_destroy()

static void request_destroy ( struct object_header hdr)
static

Definition at line 596 of file session.c.

597 {
598  struct request *request = (struct request *)hdr;
599  unsigned int i, j;
600 
601  TRACE("%p\n", request);
602 
603 #ifdef __REACTOS__
604  if (request->task_thread)
605 #else
607 #endif
608  {
609  /* Signal to the task proc to quit. It will call this again when it does. */
610 #ifdef __REACTOS__
611  HANDLE thread = request->task_thread;
612  request->task_thread = 0;
614  CloseHandle( thread );
615 #else
618 #endif
619  return;
620  }
621  release_object( &request->connect->hdr );
622 
626 
629 
630  heap_free( request->verb );
631  heap_free( request->path );
635  for (i = 0; i < request->num_headers; i++)
636  {
637  heap_free( request->headers[i].field );
638  heap_free( request->headers[i].value );
639  }
641  for (i = 0; i < TARGET_MAX; i++)
642  {
643  for (j = 0; j < SCHEME_MAX; j++)
644  {
645  heap_free( request->creds[i][j].username );
646  heap_free( request->creds[i][j].password );
647  }
648  }
649  heap_free( request );
650 }
struct connect * connect
#define CloseHandle
Definition: compat.h:406
char hdr[14]
Definition: iptest.cpp:33
CredHandle cred_handle
BOOL WINAPI CertFreeCertificateContext(PCCERT_CONTEXT pCertContext)
Definition: cert.c:371
const CERT_CONTEXT * client_cert
WCHAR * version
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent(IN HANDLE hEvent)
Definition: synch.c:733
SECURITY_STATUS WINAPI FreeCredentialsHandle(PCredHandle phCredential)
Definition: wrapper.c:151
BOOL cred_handle_initialized
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
WCHAR * status_text
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
WCHAR * raw_headers
const CERT_CONTEXT * server_cert
struct request::@580 creds[TARGET_MAX][SCHEME_MAX]
struct authinfo * proxy_authinfo
static HANDLE thread
Definition: service.c:33
struct header * headers
static void destroy_authinfo(struct authinfo *info)
WCHAR * verb
struct authinfo * authinfo
Definition: tftpd.h:85
DWORD num_headers
HANDLE task_cancel
BOOL task_proc_running
static BOOL heap_free(void *mem)
Definition: appwiz.h:75
void release_object(struct object_header *hdr)
Definition: handle.c:72

◆ request_query_option()

static BOOL request_query_option ( struct object_header hdr,
DWORD  option,
void buffer,
DWORD buflen 
)
static

Definition at line 702 of file session.c.

703 {
704  struct request *request = (struct request *)hdr;
705 
706  switch (option)
707  {
709  {
710  DWORD flags;
711  int bits;
712 
713  if (!buffer || *buflen < sizeof(flags))
714  {
715  *buflen = sizeof(flags);
717  return FALSE;
718  }
719 
721  if (request->netconn)
722  {
724  if (bits >= 128)
726  else if (bits >= 56)
728  else
730  }
731  *(DWORD *)buffer = flags;
732  *buflen = sizeof(flags);
733  return TRUE;
734  }
736  {
737  const CERT_CONTEXT *cert;
738 
739  if (!buffer || *buflen < sizeof(cert))
740  {
741  *buflen = sizeof(cert);
743  return FALSE;
744  }
745 
748  *buflen = sizeof(cert);
749  return TRUE;
750  }
752  {
754  const CRYPT_OID_INFO *oidInfo;
756 
757  FIXME("partial stub\n");
758 
759  if (!buffer || *buflen < sizeof(*ci))
760  {
761  *buflen = sizeof(*ci);
763  return FALSE;
764  }
765  if (!cert) return FALSE;
766 
767  ci->ftExpiry = cert->pCertInfo->NotAfter;
768  ci->ftStart = cert->pCertInfo->NotBefore;
769  ci->lpszSubjectInfo = blob_to_str( cert->dwCertEncodingType, &cert->pCertInfo->Subject );
770  ci->lpszIssuerInfo = blob_to_str( cert->dwCertEncodingType, &cert->pCertInfo->Issuer );
771  ci->lpszProtocolName = NULL;
772  oidInfo = CryptFindOIDInfo( CRYPT_OID_INFO_OID_KEY, cert->pCertInfo->SignatureAlgorithm.pszObjId, 0 );
773  if (oidInfo)
774  ci->lpszSignatureAlgName = (LPWSTR)oidInfo->pwszName;
775  else
779 
780  *buflen = sizeof(*ci);
781  return TRUE;
782  }
784  {
785  if (!buffer || *buflen < sizeof(DWORD))
786  {
787  *buflen = sizeof(DWORD);
789  return FALSE;
790  }
791 
793  *buflen = sizeof(DWORD);
794  return TRUE;
795  }
797  {
798  WINHTTP_CONNECTION_INFO *info = buffer;
799  struct sockaddr local;
800  socklen_t len = sizeof(local);
801  const struct sockaddr *remote = (const struct sockaddr *)&request->connect->sockaddr;
802 
803  if (!buffer || *buflen < sizeof(*info))
804  {
805  *buflen = sizeof(*info);
807  return FALSE;
808  }
809  if (!request->netconn)
810  {
812  return FALSE;
813  }
814  if (getsockname( request->netconn->socket, &local, &len )) return FALSE;
815  if (!copy_sockaddr( &local, &info->LocalAddress )) return FALSE;
816  if (!copy_sockaddr( remote, &info->RemoteAddress )) return FALSE;
817  info->cbSize = sizeof(*info);
818  return TRUE;
819  }
822  *buflen = sizeof(DWORD);
823  return TRUE;
824 
827  *buflen = sizeof(DWORD);
828  return TRUE;
829 
832  *buflen = sizeof(DWORD);
833  return TRUE;
834 
837  *buflen = sizeof(DWORD);
838  return TRUE;
839 
842  *buflen = sizeof(DWORD);
843  return TRUE;
844 
846  str_to_buffer( buffer, request->connect->username, buflen );
847  return TRUE;
848 
850  str_to_buffer( buffer, request->connect->password, buflen );
851  return TRUE;
852 
854  str_to_buffer( buffer, request->connect->session->proxy_username, buflen );
855  return TRUE;
856 
858  str_to_buffer( buffer, request->connect->session->proxy_password, buflen );
859  return TRUE;
860 
861  default:
862  FIXME("unimplemented option %u\n", option);
864  return FALSE;
865  }
866 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define WINHTTP_OPTION_PROXY_PASSWORD
Definition: winhttp.h:148
int receive_timeout
static BOOL copy_sockaddr(const struct sockaddr *addr, SOCKADDR_STORAGE *addr_storage)
Definition: session.c:676
#define WINHTTP_OPTION_RECEIVE_TIMEOUT
Definition: winhttp.h:99
#define SECURITY_FLAG_STRENGTH_MEDIUM
Definition: winhttp.h:287
struct connect * connect
#define WINHTTP_OPTION_RECEIVE_RESPONSE_TIMEOUT
Definition: winhttp.h:100
#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
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
int resolve_timeout
static WCHAR * blob_to_str(DWORD encoding, CERT_NAME_BLOB *blob)
Definition: session.c:664
int send_timeout
#define FIXME(fmt,...)
Definition: debug.h:110
int connect_timeout
smooth NULL
Definition: ftsmooth.c:416
Definition: getopt.h:108
static BYTE cert[]
Definition: msg.c:1437
LPWSTR lpszEncryptionAlgName
Definition: winhttp.h:498
static void str_to_buffer(WCHAR *buffer, const WCHAR *str, LPDWORD buflen)
Definition: session.c:652
if(!(yy_init))
Definition: macro.lex.yy.c:714
const CERT_CONTEXT * server_cert
unsigned long DWORD
Definition: ntddk_ex.h:95
int socklen_t
Definition: tcp.c:35
#define SetLastError(x)
Definition: compat.h:417
GLbitfield flags
Definition: glext.h:7161
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
struct netconn * netconn
#define WINHTTP_OPTION_RESOLVE_TIMEOUT
Definition: winhttp.h:95
int receive_response_timeout
PCCERT_CONTEXT WINAPI CertDuplicateCertificateContext(PCCERT_CONTEXT pCertContext)
Definition: cert.c:360
Definition: tftpd.h:85
#define WINHTTP_OPTION_SECURITY_KEY_BITNESS
Definition: winhttp.h:109
int netconn_get_cipher_strength(struct netconn *conn)
Definition: net.c:762
#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
DWORD security_flags
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 ( struct object_header hdr,
DWORD  option,
void buffer,
DWORD  buflen 
)
static

Definition at line 881 of file session.c.

882 {
883  struct request *request = (struct request *)hdr;
884 
885  switch (option)
886  {
888  {
890 
891  FIXME("%u %s %s\n", pi->dwAccessType, debugstr_w(pi->lpszProxy), debugstr_w(pi->lpszProxyBypass));
892  return TRUE;
893  }
895  {
896  DWORD disable;
897 
898  if (buflen != sizeof(DWORD))
899  {
901  return FALSE;
902  }
903 
904  disable = *(DWORD *)buffer;
905  TRACE("0x%x\n", disable);
906  hdr->disable_flags |= disable;
907  return TRUE;
908  }
910  {
911  DWORD policy;
912 
913  if (buflen != sizeof(DWORD))
914  {
916  return FALSE;
917  }
918 
919  policy = *(DWORD *)buffer;
920  TRACE("0x%x\n", policy);
921  hdr->logon_policy = policy;
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->redirect_policy = policy;
937  return TRUE;
938  }
940  {
941  DWORD flags;
946 
947  if (buflen < sizeof(DWORD))
948  {
950  return FALSE;
951  }
952  flags = *(DWORD *)buffer;
953  TRACE("0x%x\n", flags);
954  if (flags && (flags & ~accepted))
955  {
957  return FALSE;
958  }
960  return TRUE;
961  }
964  return TRUE;
965 
968  return TRUE;
969 
972  return TRUE;
973 
976  return TRUE;
977 
980  return TRUE;
981 
983  {
984  struct connect *connect = request->connect;
985 
987  if (!(connect->username = buffer_to_str( buffer, buflen ))) return FALSE;
988  return TRUE;
989  }
991  {
992  struct connect *connect = request->connect;
993 
995  if (!(connect->password = buffer_to_str( buffer, buflen ))) return FALSE;
996  return TRUE;
997  }
999  {
1000  struct session *session = request->connect->session;
1001 
1003  if (!(session->proxy_username = buffer_to_str( buffer, buflen ))) return FALSE;
1004  return TRUE;
1005  }
1007  {
1008  struct session *session = request->connect->session;
1009 
1011  if (!(session->proxy_password = buffer_to_str( buffer, buflen ))) return FALSE;
1012  return TRUE;
1013  }
1015  {
1016  const CERT_CONTEXT *cert;
1017 
1018  if (!(hdr->flags & WINHTTP_FLAG_SECURE))
1019  {
1021  return FALSE;
1022  }
1023  if (!buffer)
1024  {
1027  }
1028  else if (buflen >= sizeof(cert))
1029  {
1030  if (!(cert = CertDuplicateCertificateContext( buffer ))) return FALSE;
1033  }
1034  else
1035  {
1037  return FALSE;
1038  }
1039 
1041  {
1044  }
1045 
1046  return TRUE;
1047  }
1049  if(buflen == sizeof( DWORD ) && *(DWORD *)buffer == WINHTTP_ENABLE_SSL_REVOCATION)
1050  {
1053  return TRUE;
1054  }
1055  else
1056  {
1058  return FALSE;
1059  }
1060 
1062  FIXME("WINHTTP_OPTION_CONNECT_RETRIES\n");
1063  return TRUE;
1064 
1065  default:
1066  FIXME("unimplemented option %u\n", option);
1068  return FALSE;
1069  }
1070 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define WINHTTP_OPTION_PROXY_PASSWORD
Definition: winhttp.h:148
int receive_timeout
#define WINHTTP_OPTION_CLIENT_CERT_CONTEXT
Definition: winhttp.h:113
#define WINHTTP_OPTION_RECEIVE_TIMEOUT
Definition: winhttp.h:99
WCHAR * proxy_username
struct connect * connect
#define WINHTTP_OPTION_RECEIVE_RESPONSE_TIMEOUT
Definition: winhttp.h:100
#define TRUE
Definition: types.h:120
#define SECURITY_FLAG_IGNORE_UNKNOWN_CA
Definition: winhttp.h:281
char hdr[14]
Definition: iptest.cpp:33
WCHAR * proxy_password
#define WINHTTP_OPTION_PASSWORD
Definition: winhttp.h:146
CredHandle cred_handle
#define WINHTTP_OPTION_SEND_TIMEOUT
Definition: winhttp.h:98
#define WINHTTP_OPTION_PROXY
Definition: winhttp.h:110
BOOL WINAPI CertFreeCertificateContext(PCCERT_CONTEXT pCertContext)
Definition: cert.c:371
const CERT_CONTEXT * client_cert
static WCHAR * buffer_to_str(WCHAR *buffer, DWORD buflen)
Definition: session.c:868
GLuint buffer
Definition: glext.h:5915
BOOL check_revocation
SECURITY_STATUS WINAPI FreeCredentialsHandle(PCredHandle phCredential)
Definition: wrapper.c:151
#define WINHTTP_OPTION_PROXY_USERNAME
Definition: winhttp.h:147
#define WINHTTP_OPTION_USERNAME
Definition: winhttp.h:145
BOOL cred_handle_initialized
#define SECURITY_FLAG_IGNORE_CERT_CN_INVALID
Definition: winhttp.h:283
#define NO_ERROR
Definition: dderror.h:5
int resolve_timeout
int send_timeout
#define debugstr_w
Definition: kernel32.h:32
#define FIXME(fmt,...)
Definition: debug.h:110
WCHAR * username
int connect_timeout
smooth NULL
Definition: ftsmooth.c:416
Definition: getopt.h:108
#define WINHTTP_OPTION_REDIRECT_POLICY
Definition: winhttp.h:131
static BYTE cert[]
Definition: msg.c:1437
#define WINHTTP_FLAG_SECURE
Definition: winhttp.h:60
#define WINHTTP_OPTION_AUTOLOGON_POLICY
Definition: winhttp.h:120
#define TRACE(s)
Definition: solgame.cpp:4
WCHAR * password
#define WINHTTP_OPTION_ENABLE_FEATURE
Definition: winhttp.h:122
static refpint_t pi[]
Definition: server.c:96
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:417
GLbitfield flags
Definition: glext.h:7161
#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
int receive_response_timeout
PCCERT_CONTEXT WINAPI CertDuplicateCertificateContext(PCCERT_CONTEXT pCertContext)
Definition: cert.c:360
Definition: tftpd.h:85
int disable
Definition: msacm.c:1365
#define WINHTTP_OPTION_CONNECT_RETRIES
Definition: winhttp.h:97
#define WINHTTP_ENABLE_SSL_REVOCATION
Definition: winhttp.h:172
#define ERROR_WINHTTP_INCORRECT_HANDLE_STATE
Definition: winhttp.h:200
#define WINHTTP_OPTION_CONNECT_TIMEOUT
Definition: winhttp.h:96
DWORD security_flags
#define ERROR_WINHTTP_INVALID_OPTION
Definition: winhttp.h:194
static void accepted(enum accept_stat, struct rpc_err *)
Definition: rpc_prot.c:280
#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 1349 of file session.c.

1350 {
1351  return getnameinfo( ai->ai_addr, ai->ai_addrlen, hostname, len, NULL, 0, 0 );
1352 }
char * hostname
Definition: ftp.c:88
smooth NULL
Definition: ftsmooth.c:416
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 1841 of file session.c.

1842 {
1843  BOOL ret;
1844  char *result, *urlA;
1845  DWORD len_result;
1847  URL_COMPONENTSW uc;
1848 
1849  buffer.dwStructSize = sizeof(buffer);
1850  buffer.lpszScriptBuffer = script;
1851  buffer.dwScriptBufferSize = size;
1852 
1853  if (!(urlA = strdupWA( url ))) return FALSE;
1855  {
1856  heap_free( urlA );
1857  return FALSE;
1858  }
1859 
1860  memset( &uc, 0, sizeof(uc) );
1861  uc.dwStructSize = sizeof(uc);
1862  uc.dwHostNameLength = -1;
1863 
1864  if (WinHttpCrackUrl( url, 0, 0, &uc ))
1865  {
1866  char *hostnameA = strdupWA_sized( uc.lpszHostName, uc.dwHostNameLength );
1867 
1868  if ((ret = InternetGetProxyInfo( urlA, strlen(urlA),
1869  hostnameA, strlen(hostnameA), &result, &len_result )))
1870  {
1872  heap_free( result );
1873  }
1874 
1875  heap_free( hostnameA );
1876  }
1877  heap_free( urlA );
1879 }
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:111
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:179
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:1736
static char * strdupWA(const WCHAR *src)
Definition: main.c:91
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 ( struct object_header hdr,
DWORD  status,
void info,
DWORD  buflen 
)

Definition at line 55 of file session.c.

56 {
57  if (hdr->callback && (hdr->notify_mask & status))
58  {
59  TRACE("%p, 0x%08x, %p, %u\n", hdr, status, info, buflen);
60  hdr->callback( hdr->handle, hdr->context, status, info, buflen );
61  TRACE("returning from 0x%08x callback\n", status);
62  }
63 }
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 ( struct object_header hdr)
static

Definition at line 77 of file session.c.

78 {
79  struct session *session = (struct session *)hdr;
80 
81  TRACE("%p\n", session);
82 
85 
86  session->cs.DebugInfo->Spare[0] = 0;
93  heap_free( session );
94 }
WCHAR * proxy_username
char hdr[14]
Definition: iptest.cpp:33
WCHAR * proxy_password
WCHAR * proxy_server
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent(IN HANDLE hEvent)
Definition: synch.c:733
void destroy_cookies(struct session *session)
Definition: cookie.c:120
#define TRACE(s)
Definition: solgame.cpp:4
CRITICAL_SECTION cs
void WINAPI DeleteCriticalSection(PCRITICAL_SECTION)
WCHAR * proxy_bypass
WCHAR * agent
PCRITICAL_SECTION_DEBUG DebugInfo
Definition: winbase.h:866
HANDLE unload_event
DWORD_PTR Spare[8/sizeof(DWORD_PTR)]
Definition: winbase.h:859
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

◆ session_query_option()

static BOOL session_query_option ( struct object_header hdr,
DWORD  option,
void buffer,
DWORD buflen 
)
static

Definition at line 96 of file session.c.

97 {
98  struct session *session = (struct session *)hdr;
99 
100  switch (option)
101  {
103  {
104  if (!buffer || *buflen < sizeof(DWORD))
105  {
106  *buflen = sizeof(DWORD);
108  return FALSE;
109  }
110 
111  *(DWORD *)buffer = hdr->redirect_policy;
112  *buflen = sizeof(DWORD);
113  return TRUE;
114  }
117  *buflen = sizeof(DWORD);
118  return TRUE;
119 
122  *buflen = sizeof(DWORD);
123  return TRUE;
124 
127  *buflen = sizeof(DWORD);
128  return TRUE;
129 
132  *buflen = sizeof(DWORD);
133  return TRUE;
134 
137  *buflen = sizeof(DWORD);
138  return TRUE;
139 
140  default:
141  FIXME("unimplemented option %u\n", option);
143  return FALSE;
144  }
145 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define WINHTTP_OPTION_RECEIVE_TIMEOUT
Definition: winhttp.h:99
#define WINHTTP_OPTION_RECEIVE_RESPONSE_TIMEOUT
Definition: winhttp.h:100
#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
int receive_timeout
#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 SetLastError(x)
Definition: compat.h:417
int receive_response_timeout
#define WINHTTP_OPTION_RESOLVE_TIMEOUT
Definition: winhttp.h:95
int connect_timeout
int send_timeout
#define WINHTTP_OPTION_CONNECT_TIMEOUT
Definition: winhttp.h:96
int resolve_timeout
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10

◆ session_set_option()

static BOOL session_set_option ( struct object_header hdr,
DWORD  option,
void buffer,
DWORD  buflen 
)
static

Definition at line 147 of file session.c.

148 {
149  struct session *session = (struct session *)hdr;
150 
151  switch (option)
152  {
154  {
156 
157  FIXME("%u %s %s\n", pi->dwAccessType, debugstr_w(pi->lpszProxy), debugstr_w(pi->lpszProxyBypass));
158  return TRUE;
159  }
161  {
162  DWORD policy;
163 
164  if (buflen != sizeof(policy))
165  {
167  return FALSE;
168  }
169 
170  policy = *(DWORD *)buffer;
171  TRACE("0x%x\n", policy);
172  hdr->redirect_policy = policy;
173  return TRUE;
174  }
176  {
177  if (buflen != sizeof(session->secure_protocols))
178  {
180  return FALSE;
181  }
185  TRACE("0x%x\n", session->secure_protocols);
186  return TRUE;
187  }
190  return FALSE;
191 
194  return TRUE;
195 
198  return TRUE;
199 
202  return TRUE;
203 
206  return TRUE;
207 
210  return TRUE;
211 
214  return TRUE;
215 
217  TRACE("WINHTTP_OPTION_UNLOAD_NOTIFY_EVENT: %p\n", *(HANDLE *)buffer);
219  return TRUE;
220 
222  FIXME("WINHTTP_OPTION_MAX_CONNS_PER_SERVER: %d\n", *(DWORD *)buffer);
223  return TRUE;
224 
226  FIXME("WINHTTP_OPTION_MAX_CONNS_PER_1_0_SERVER: %d\n", *(DWORD *)buffer);
227  return TRUE;
228 
229  default:
230  FIXME("unimplemented option %u\n", option);
232  return FALSE;
233  }
234 }
#define WINHTTP_OPTION_RECEIVE_TIMEOUT
Definition: winhttp.h:99
#define WINHTTP_OPTION_RECEIVE_RESPONSE_TIMEOUT
Definition: winhttp.h:100
#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
int receive_timeout
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
#define WINHTTP_OPTION_MAX_CONNS_PER_SERVER
Definition: winhttp.h:118
#define debugstr_w
Definition: kernel32.h:32
#define FIXME(fmt,...)
Definition: debug.h:110
DWORD passport_flags
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
#define WINHTTP_OPTION_MAX_CONNS_PER_1_0_SERVER
Definition: winhttp.h:119
CRITICAL_SECTION cs
static refpint_t pi[]
Definition: server.c:96
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:417
HANDLE unload_event
int receive_response_timeout
#define WINHTTP_OPTION_RESOLVE_TIMEOUT
Definition: winhttp.h:95
int connect_timeout
int send_timeout
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
#define WINHTTP_OPTION_CONNECT_TIMEOUT
Definition: winhttp.h:96
int resolve_timeout
DWORD secure_protocols
#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_option()

static BOOL set_option ( struct object_header hdr,
DWORD  option,
void buffer,
DWORD  buflen 
)
static

Definition at line 1265 of file session.c.

1266 {
1267  BOOL ret = TRUE;
1268 
1269  if (!buffer && buflen)
1270  {
1272  return FALSE;
1273  }
1274 
1275  switch (option)
1276  {
1278  {
1279  if (buflen != sizeof(DWORD_PTR))
1280  {
1282  return FALSE;
1283  }
1284 
1285  hdr->context = *(DWORD_PTR *)buffer;
1286  return TRUE;
1287  }
1288  default:
1289  if (hdr->vtbl->set_option) ret = hdr->vtbl->set_option( hdr, option, buffer, buflen );
1290  else
1291  {
1292  FIXME("unimplemented option %u\n", option);
1294  return FALSE;
1295  }
1296  break;
1297  }
1298  return ret;
1299 }
#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
#define SetLastError(x)
Definition: compat.h:417
int ret
uint32_t DWORD_PTR
Definition: typedefs.h:63
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10

Referenced by WinHttpSetOption().

◆ set_server_for_hostname()

BOOL set_server_for_hostname ( struct connect connect,
const WCHAR server,
INTERNET_PORT  port 
)

Definition at line 468 of file session.c.

469 {
470  struct session *session = connect->session;
471  BOOL ret = TRUE;
472 
474  {
475  LPCWSTR colon;
476 
477  if ((colon = strchrW( session->proxy_server, ':' )))
478  {
480  session->proxy_server, colon - session->proxy_server - 1 ))
481  {
484  if (!(connect->servername = heap_alloc(
485  (colon - session->proxy_server + 1) * sizeof(WCHAR) )))
486  {
487  ret = FALSE;
488  goto end;
489  }
491  (colon - session->proxy_server) * sizeof(WCHAR) );
492  connect->servername[colon - session->proxy_server] = 0;
493  if (*(colon + 1))
494  connect->serverport = atoiW( colon + 1 );
495  else
497  }
498  }
499  else
500  {
503  {
507  {
508  ret = FALSE;
509  goto end;
510  }
512  }
513  }
514  }
515  else if (server)
516  {
519  if (!(connect->servername = strdupW( server )))
520  {
521  ret = FALSE;
522  goto end;
523  }
525  }
526 end:
527  return ret;
528 }
#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
WCHAR * proxy_server
struct session * session
GLuint GLuint end
Definition: gl.h:1545
#define strncmpiW(s1, s2, n)
Definition: unicode.h:40
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
unsigned int BOOL
Definition: ntddk_ex.h:94
INTERNET_PORT serverport
__wchar_t WCHAR
Definition: xmlstorage.h:180
static BOOL should_bypass_proxy(struct session *session, LPCWSTR server)
Definition: session.c:437
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
WCHAR * servername
USHORT port
Definition: uri.c:228
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 ( struct session session,
LPCWSTR  server 
)
static

Definition at line 437 of file session.c.

438 {
439  LPCWSTR ptr;
440  BOOL ret = FALSE;
441 
442  if (!session->proxy_bypass) return FALSE;
444  do {
445  LPCWSTR tmp = ptr;
446 
447  ptr = strchrW( ptr, ';' );
448  if (!ptr)
449  ptr = strchrW( tmp, ' ' );
450  if (ptr)
451  {
452  if (ptr - tmp < MAX_HOST_NAME_LENGTH)
453  {
455 
456  memcpy( domain, tmp, (ptr - tmp) * sizeof(WCHAR) );
457  domain[ptr - tmp] = 0;
459  }
460  ptr += 1;
461  }
462  else if (*tmp)
463  ret = domain_matches( server, tmp );
464  } while (ptr && !ret);
465  return ret;
466 }
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:383
Definition: cookie.c:41
unsigned int BOOL
Definition: ntddk_ex.h:94
static PVOID ptr
Definition: dispmode.c:27
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * proxy_bypass
int ret
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define MAX_HOST_NAME_LENGTH
Definition: session.c:435

Referenced by set_server_for_hostname().

◆ str_to_buffer()

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

Definition at line 652 of file session.c.

653 {
654  int len = 0;
655  if (str) len = strlenW( str );
656  if (buffer && *buflen > len)
657  {
658  if (str) memcpy( buffer, str, len * sizeof(WCHAR) );
659  buffer[len] = 0;
660  }
661  *buflen = len * sizeof(WCHAR);
662 }
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 68 of file session.c.

69 {
70  TRACE("\n");
71  return TRUE;
72 }
#define TRUE
Definition: types.h:120
#define TRACE(s)
Definition: solgame.cpp:4

◆ WinHttpCloseHandle()

BOOL WINAPI WinHttpCloseHandle ( HINTERNET  handle)

Definition at line 1187 of file session.c.

1188 {
1189  struct object_header *hdr;
1190 
1191  TRACE("%p\n", handle);
1192 
1193  if (!(hdr = grab_object( handle )))
1194  {
1196  return FALSE;
1197  }
1198  release_object( hdr );
1199  free_handle( handle );
1201  return TRUE;
1202 }
#define TRUE
Definition: types.h:120
char hdr[14]
Definition: iptest.cpp:33
#define ERROR_SUCCESS
Definition: deptool.c:10
struct object_header * grab_object(HINTERNET hinternet)
Definition: handle.c:56
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
#define TRACE(s)
Definition: solgame.cpp:4
#define SetLastError(x)
Definition: compat.h:417
BOOL free_handle(HINTERNET hinternet)
Definition: handle.c:123
void release_object(struct object_header *hdr)
Definition: handle.c:72

Referenced by close_request(), do_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_passport_auth(), test_redirect(), test_request_parameter_defaults(), test_request_path_escapes(), test_resolve_timeout(), test_secure_connection(), test_timeouts(), test_WinHttpAddHeaders(), test_WinHttpGetProxyForUrl(), test_WinHttpOpenRequest(), test_WinHttpQueryOption(), test_WinHttpSendRequest(), transfer_file_http(), and winhttp_request_Open().

◆ WinHttpConnect()

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

Definition at line 533 of file session.c.

534 {
535  struct connect *connect;
536  struct session *session;
537  HINTERNET hconnect = NULL;
538 
539  TRACE("%p, %s, %u, %x\n", hsession, debugstr_w(server), port, reserved);
540 
541  if (!server)
542  {
544  return NULL;
545  }
546  if (!(session = (struct session *)grab_object( hsession )))
547  {
549  return NULL;
550  }
552  {
555  return NULL;
556  }
557  if (!(connect = heap_alloc_zero( sizeof(struct connect) )))
558  {
560  return NULL;
561  }
563  connect->hdr.vtbl = &connect_vtbl;
564  connect->hdr.refs = 1;
565  connect->hdr.flags = session->hdr.flags;
566  connect->hdr.callback = session->hdr.callback;
567  connect->hdr.notify_mask = session->hdr.notify_mask;
568  connect->hdr.context = session->hdr.context;
569  connect->hdr.redirect_policy = session->hdr.redirect_policy;
570  list_init( &connect->hdr.children );
571 
574  list_add_head( &session->hdr.children, &connect->hdr.entry );
575 
576  if (!(connect->hostname = strdupW( server ))) goto end;
577  connect->hostport = port;
579 
580  if (!(hconnect = alloc_handle( &connect->hdr ))) goto end;
581  connect->hdr.handle = hconnect;
582 
583  send_callback( &session->hdr, WINHTTP_CALLBACK_STATUS_HANDLE_CREATED, &hconnect, sizeof(hconnect) );
584 
585 end:
588  TRACE("returning %p\n", hconnect);
589  if (hconnect) SetLastError( ERROR_SUCCESS );
590  return hconnect;
591 }
#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
struct object_header * grab_object(HINTERNET hinternet)
Definition: handle.c:56
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 session * session
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
BOOL set_server_for_hostname(struct connect *connect, const WCHAR *server, INTERNET_PORT port)
Definition: session.c:468
#define debugstr_w
Definition: kernel32.h:32
r reserved
Definition: btrfs.c:2865
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
#define TRACE(s)
Definition: solgame.cpp:4
struct object_header hdr
#define WINHTTP_CALLBACK_STATUS_HANDLE_CREATED
Definition: winhttp.h:390
#define WINHTTP_HANDLE_TYPE_CONNECT
Definition: winhttp.h:431
WCHAR * hostname
#define SetLastError(x)
Definition: compat.h:417
INTERNET_PORT hostport
void send_callback(struct object_header *hdr, DWORD status, void *info, DWORD buflen)
Definition: session.c:55
__WINE_SERVER_LIST_INLINE void list_init(struct list *list)
Definition: list.h:149
struct object_header hdr
USHORT port
Definition: uri.c:228
struct object_header * addref_object(struct object_header *hdr)
Definition: handle.c:49
static const struct object_vtbl connect_vtbl
Definition: session.c:376
void release_object(struct object_header *hdr)
Definition: handle.c:72

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_passport_auth(), test_redirect(), test_request_parameter_defaults(), test_request_path_escapes(), test_resolve_timeout(), test_secure_connection(), test_timeouts(), test_WinHttpAddHeaders(), test_WinHttpOpenRequest(), test_WinHttpQueryOption(), test_WinHttpSendRequest(), transfer_file_http(), and winhttp_request_Open().

◆ WinHttpDetectAutoProxyConfigUrl()

BOOL WINAPI WinHttpDetectAutoProxyConfigUrl ( DWORD  flags,
LPWSTR url 
)

Definition at line 1415 of file session.c.

1416 {
1417  BOOL ret = FALSE;
1418  char system_url[INTERNET_MAX_URL_LENGTH + 1];
1419 
1420  TRACE("0x%08x, %p\n", flags, url);
1421 
1422  if (!flags || !url)
1423  {
1425  return FALSE;
1426  }
1427  if (get_system_proxy_autoconfig_url( system_url, sizeof(system_url) ))
1428  {
1429  WCHAR *urlW;
1430 
1431  if (!(urlW = strdupAW( system_url ))) return FALSE;
1432  *url = urlW;
1434  return TRUE;
1435  }
1437  {
1438  static int fixme_shown;
1439  if (!fixme_shown++) FIXME("discovery via DHCP not supported\n");
1440  }
1442  {
1443  char *fqdn, *domain, *p;
1444 
1445  if (!(fqdn = get_computer_name( ComputerNamePhysicalDnsFullyQualified ))) return FALSE;
1446  if (!(domain = get_computer_name( ComputerNamePhysicalDnsDomain )))
1447  {
1448  heap_free( fqdn );
1449  return FALSE;
1450  }
1451  p = fqdn;
1452  while ((p = strchr( p, '.' )) && is_domain_suffix( p + 1, domain ))
1453  {
1454  struct addrinfo *ai;
1455  char *name;
1456  int res;
1457 
1458  if (!(name = heap_alloc( sizeof("wpad") + strlen(p) )))
1459  {
1460  heap_free( fqdn );
1461  heap_free( domain );
1462  return FALSE;
1463  }
1464  strcpy( name, "wpad" );
1465  strcat( name, p );
1466  res = getaddrinfo( name, NULL, NULL, &ai );
1467  if (!res)
1468  {
1469  *url = build_wpad_url( name, ai );
1470  freeaddrinfo( ai );
1471  if (*url)
1472  {
1473  TRACE("returning %s\n", debugstr_w(*url));
1474  heap_free( name );
1475  ret = TRUE;
1476  break;
1477  }
1478  }
1479  heap_free( name );
1480  p++;
1481  }
1482  heap_free( domain );
1483  heap_free( fqdn );
1484  }
1485  if (!ret)
1486  {
1488  *url = NULL;
1489  }
1490  else SetLastError( ERROR_SUCCESS );
1491  return ret;
1492 }
#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:76
#define ERROR_WINHTTP_AUTODETECTION_FAILED
Definition: winhttp.h:228
static WCHAR * build_wpad_url(const char *hostname, const struct addrinfo *ai)
Definition: session.c:1354
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
Definition: cookie.c:41
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:1410
#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
#define SetLastError(x)
Definition: compat.h:417
GLbitfield flags
Definition: glext.h:7161
static BOOL is_domain_suffix(const char *domain, const char *suffix)
Definition: session.c:1340
int ret
static BOOL get_system_proxy_autoconfig_url(char *buf, DWORD buflen)
Definition: session.c:1376
char * strchr(const char *String, int ch)
Definition: utclib.c:501
Definition: name.c:38
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:1324
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 1529 of file session.c.

1530 {
1531  LONG l;
1532  HKEY key;
1533  BOOL got_from_reg = FALSE, direct = TRUE;
1534  char *envproxy;
1535 
1536  TRACE("%p\n", info);
1537 
1539  if (!l)
1540  {
1541  DWORD type, size = 0;
1542 
1544  if (!l && type == REG_BINARY &&
1545  size >= sizeof(struct connection_settings_header) + 2 * sizeof(DWORD))
1546  {
1547  BYTE *buf = heap_alloc( size );
1548 
1549  if (buf)
1550  {
1552  (struct connection_settings_header *)buf;
1553  DWORD *len = (DWORD *)(hdr + 1);
1554 
1556  &size );
1557  if (!l && hdr->magic == WINHTTP_SETTINGS_MAGIC &&
1558  hdr->unknown == 0)
1559  {
1560  if (hdr->flags & PROXY_TYPE_PROXY)
1561  {
1562  BOOL sane = FALSE;
1563  LPWSTR proxy = NULL;
1564  LPWSTR proxy_bypass = NULL;
1565 
1566  /* Sanity-check length of proxy string */
1567  if ((BYTE *)len - buf + *len <= size)
1568  {
1569  sane = TRUE;
1570  proxy = GlobalAlloc( 0, (*len + 1) * sizeof(WCHAR) );
1571  if (proxy)
1572  copy_char_to_wchar_sz( (BYTE *)(len + 1), *len, proxy );
1573  len = (DWORD *)((BYTE *)(len + 1) + *len);
1574  }
1575  if (sane)
1576  {
1577  /* Sanity-check length of proxy bypass string */
1578  if ((BYTE *)len - buf + *len <= size)
1579  {
1580  proxy_bypass = GlobalAlloc( 0, (*len + 1) * sizeof(WCHAR) );
1581  if (proxy_bypass)
1582  copy_char_to_wchar_sz( (BYTE *)(len + 1), *len, proxy_bypass );
1583  }
1584  else
1585  {
1586  sane = FALSE;
1587  GlobalFree( proxy );
1588  proxy = NULL;
1589  }
1590  }
1591  info->lpszProxy = proxy;
1592  info->lpszProxyBypass = proxy_bypass;
1593  if (sane)
1594  {
1595  got_from_reg = TRUE;
1596  direct = FALSE;
1597  info->dwAccessType =
1599  TRACE("http proxy (from registry) = %s, bypass = %s\n",
1600  debugstr_w(info->lpszProxy),
1601  debugstr_w(info->lpszProxyBypass));
1602  }
1603  }
1604  }
1605  heap_free( buf );
1606  }
1607  }
1608  RegCloseKey( key );
1609  }
1610  if (!got_from_reg && (envproxy = getenv( "http_proxy" )))
1611  {
1612  char *colon, *http_proxy = NULL;
1613 
1614  if (!(colon = strchr( envproxy, ':' ))) http_proxy = envproxy;
1615  else
1616  {
1617  if (*(colon + 1) == '/' && *(colon + 2) == '/')
1618  {
1619  /* It's a scheme, check that it's http */
1620  if (!strncmp( envproxy, "http://", 7 )) http_proxy = envproxy + 7;
1621  else WARN("unsupported scheme in $http_proxy: %s\n", envproxy);
1622  }
1623  else http_proxy = envproxy;
1624  }
1625 
1626  if (http_proxy && http_proxy[0])
1627  {
1628  WCHAR *http_proxyW;
1629  int len;
1630 
1631  len = MultiByteToWideChar( CP_UNIXCP, 0, http_proxy, -1, NULL, 0 );
1632  if ((http_proxyW = GlobalAlloc( 0, len * sizeof(WCHAR))))
1633  {
1634  MultiByteToWideChar( CP_UNIXCP, 0, http_proxy, -1, http_proxyW, len );
1635  direct = FALSE;
1636  info->dwAccessType = WINHTTP_ACCESS_TYPE_NAMED_PROXY;
1637  info->lpszProxy = http_proxyW;
1638  info->lpszProxyBypass = NULL;
1639  TRACE("http proxy (from environment) = %s\n", debugstr_w(info->lpszProxy));
1640  }
1641  }
1642  }
1643  if (direct)
1644  {
1645  info->dwAccessType = WINHTTP_ACCESS_TYPE_NO_PROXY;
1646  info->lpszProxy = NULL;
1647  info->lpszProxyBypass = NULL;
1648  }
1650  return TRUE;
1651 }
#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:1494
#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:4116
#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
#define SetLastError(x)
Definition: compat.h:417
static void copy_char_to_wchar_sz(const BYTE *src, DWORD len, WCHAR *dst)
Definition: session.c:1517
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:1501
#define MultiByteToWideChar
Definition: compat.h:100
static const DWORD PROXY_TYPE_PROXY
Definition: session.c:1506
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:3366
static const DWORD WINHTTP_SETTINGS_MAGIC
Definition: session.c:1503
WCHAR * LPWSTR
Definition: xmlstorage.h:184
Definition: path.c:41
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 1656 of file session.c.

1657 {
1658  static const WCHAR settingsW[] =
1659  {'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};
1660  HKEY hkey = NULL;
1662  DWORD type, offset, len, size = 0;
1663  BOOL ret = FALSE;
1664 
1665  TRACE("%p\n", config);
1666 
1667  if (!config)
1668  {
1670  return FALSE;
1671  }
1672  memset( config, 0, sizeof(*config) );
1673  config->fAutoDetect = TRUE;
1674 
1675  if (RegOpenKeyExW( HKEY_CURRENT_USER, Connections, 0, KEY_READ, &hkey ) ||
1676  RegQueryValueExW( hkey, settingsW, NULL, &type, NULL, &size ) ||
1677  type != REG_BINARY || size < sizeof(struct connection_settings_header))
1678  {
1679  ret = TRUE;
1680  goto done;
1681  }
1682  if (!(hdr = heap_alloc( size ))) goto done;
1683  if (RegQueryValueExW( hkey, settingsW, NULL, &type, (BYTE *)hdr, &size ) ||
1684  hdr->magic != WININET_SETTINGS_MAGIC)
1685  {
1686  ret = TRUE;
1687  goto done;
1688  }
1689 
1690  config->fAutoDetect = (hdr->flags & PROXY_AUTODETECT_SETTINGS) != 0;
1691  offset = sizeof(*hdr);
1692  if (offset + sizeof(DWORD) > size) goto done;
1693  len = *(DWORD *)((char *)hdr + offset);
1694  offset += sizeof(DWORD);
1695  if (len && hdr->flags & PROXY_TYPE_PROXY)
1696  {
1697  if (!(config->lpszProxy = GlobalAlloc( 0, (len + 1) * sizeof(WCHAR) ))) goto done;
1698  copy_char_to_wchar_sz( (const BYTE *)hdr + offset , len, config->lpszProxy );
1699  }
1700  offset += len;
1701  if (offset + sizeof(DWORD) > size) goto done;
1702  len = *(DWORD *)((char *)hdr + offset);
1703  offset += sizeof(DWORD);
1704  if (len && (hdr->flags & PROXY_TYPE_PROXY))
1705  {
1706  if (!(config->lpszProxyBypass = GlobalAlloc( 0, (len + 1) * sizeof(WCHAR) ))) goto done;
1707  copy_char_to_wchar_sz( (const BYTE *)hdr + offset , len, config->lpszProxyBypass );
1708  }
1709  offset += len;
1710  if (offset + sizeof(DWORD) > size) goto done;
1711  len = *(DWORD *)((char *)hdr + offset);
1712  offset += sizeof(DWORD);
1713  if (len && (hdr->flags & PROXY_USE_PAC_SCRIPT))
1714  {
1715  if (!(config->lpszAutoConfigUrl = GlobalAlloc( 0, (len + 1) * sizeof(WCHAR) ))) goto done;
1716  copy_char_to_wchar_sz( (const BYTE *)hdr + offset , len, config->lpszAutoConfigUrl );
1717  }
1718  ret = TRUE;
1719 
1720 done:
1721  RegCloseKey( hkey );
1722  heap_free( hdr );
1723  if (!ret)
1724  {
1725  GlobalFree( config->lpszAutoConfigUrl );
1726  config->lpszAutoConfigUrl = NULL;
1727  GlobalFree( config->lpszProxy );
1728  config->lpszProxy = NULL;
1729  GlobalFree( config->lpszProxyBypass );
1730  config->lpszProxyBypass = NULL;
1731  }
1732  else SetLastError( ERROR_SUCCESS );
1733  return ret;
1734 }
#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:1494
#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:1504
#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:4116
__wchar_t WCHAR
Definition: xmlstorage.h:180
static const DWORD PROXY_USE_PAC_SCRIPT
Definition: session.c:1507
unsigned long DWORD
Definition: ntddk_ex.h:95
HGLOBAL NTAPI GlobalFree(HGLOBAL hMem)
Definition: heapmem.c:611
#define SetLastError(x)
Definition: compat.h:417
static const DWORD PROXY_AUTODETECT_SETTINGS
Definition: session.c:1508
static void copy_char_to_wchar_sz(const BYTE *src, DWORD len, WCHAR *dst)
Definition: session.c:1517
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:1506
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3366
#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 1884 of file session.c.

1886 {
1887  WCHAR *detected_pac_url = NULL;
1888  const WCHAR *pac_url;
1889  struct session *session;
1890  char *script;
1891  DWORD size;
1892  BOOL ret = FALSE;
1893 
1894  TRACE("%p, %s, %p, %p\n", hsession, debugstr_w(url), options, info);
1895 
1896  if (!(session = (struct session *)grab_object( hsession )))
1897  {
1899  return FALSE;
1900  }
1902  {
1903  release_object( &session->hdr );
1905  return FALSE;
1906  }
1907  if (!url || !options || !info ||
1909  ((options->dwFlags & WINHTTP_AUTOPROXY_AUTO_DETECT) && !options->dwAutoDetectFlags) ||
1910  ((options->dwFlags & WINHTTP_AUTOPROXY_AUTO_DETECT) &&
1911  (options->dwFlags & WINHTTP_AUTOPROXY_CONFIG_URL)))
1912  {
1913  release_object( &session->hdr );
1915  return FALSE;
1916  }
1917  if (options->dwFlags & WINHTTP_AUTOPROXY_AUTO_DETECT &&
1918  !WinHttpDetectAutoProxyConfigUrl( options->dwAutoDetectFlags, &detected_pac_url ))
1919  goto done;
1920 
1921  if (options->dwFlags & WINHTTP_AUTOPROXY_CONFIG_URL) pac_url = options->lpszAutoConfigUrl;
1922  else pac_url = detected_pac_url;
1923 
1924  if ((script = download_script( pac_url, &size )))
1925  {
1926  ret = run_script( script, size, url, info );
1927  heap_free( script );
1928  }
1929 
1930 done:
1931  GlobalFree( detected_pac_url );
1932  release_object( &session->hdr );
1933  if (ret) SetLastError( ERROR_SUCCESS );
1934  return ret;
1935 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define ERROR_SUCCESS
Definition: deptool.c:10
struct object_header * grab_object(HINTERNET hinternet)
Definition: handle.c:56
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
#define WINHTTP_AUTOPROXY_AUTO_DETECT
Definition: winhttp.h:530
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:1415
#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
struct object_header hdr
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
#define SetLastError(x)
Definition: compat.h:417
int ret
static BOOL run_script(char *script, DWORD size, const WCHAR *url, WINHTTP_PROXY_INFO *info)
Definition: session.c:1841
static char * download_script(const WCHAR *url, DWORD *out_size)
Definition: session.c:1770
#define WINHTTP_AUTOPROXY_CONFIG_URL
Definition: winhttp.h:531
static BOOL heap_free(void *mem)
Definition: appwiz.h:75
void release_object(struct object_header *hdr)
Definition: handle.c:72

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  struct session *session;
250 
251  TRACE("%s, %u, %s, %s, 0x%08x\n", debugstr_w(agent), access, debugstr_w(proxy), debugstr_w(bypass), flags);
252 
253  if (!(session = heap_alloc_zero( sizeof(struct session) ))) return NULL;
254 
256  session->hdr.vtbl = &session_vtbl;
257  session->hdr.flags = flags;
258  session->hdr.refs = 1;
260  list_init( &session->hdr.children );
268  session->cs.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": session.cs");
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:
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
#define DWORD_PTR
Definition: treelist.c:76
static WCHAR * strdupW(const WCHAR *src)
Definition: main.c:92
WCHAR * proxy_server
GLuint GLuint end
Definition: gl.h:1545
int receive_timeout
struct _test_info info[]
Definition: SetCursorPos.c:19
#define WINHTTP_ACCESS_TYPE_DEFAULT_PROXY
Definition: winhttp.h:62
#define debugstr_w
Definition: kernel32.h:32
VOID WINAPI InitializeCriticalSection(OUT LPCRITICAL_SECTION lpCriticalSection)
Definition: synch.c:751
smooth NULL
Definition: ftsmooth.c:416
#define WINHTTP_HANDLE_TYPE_SESSION
Definition: winhttp.h:430
#define TRACE(s)
Definition: solgame.cpp:4
CRITICAL_SECTION cs
struct object_header hdr
WCHAR * proxy_bypass
DWORD access
WCHAR * agent
HGLOBAL NTAPI GlobalFree(HGLOBAL hMem)
Definition: heapmem.c:611
#define SetLastError(x)
Definition: compat.h:417
PCRITICAL_SECTION_DEBUG DebugInfo
Definition: winbase.h:866
GLbitfield flags
Definition: glext.h:7161
static const struct object_vtbl session_vtbl
Definition: session.c:236
#define DEFAULT_SEND_TIMEOUT
Definition: session.c:51
struct list cookie_cache
#define DEFAULT_CONNECT_TIMEOUT
Definition: session.c:50
#define DEFAULT_RESOLVE_TIMEOUT
Definition: session.c:49
GLuint GLint GLboolean GLint GLenum access
Definition: glext.h:7866
int receive_response_timeout
BOOL WINAPI WinHttpGetDefaultProxyConfiguration(WINHTTP_PROXY_INFO *info)
Definition: session.c:1529
int connect_timeout
int send_timeout
__WINE_SERVER_LIST_INLINE void list_init(struct list *list)
Definition: list.h:149
#define DEFAULT_RECEIVE_RESPONSE_TIMEOUT
Definition: session.c:53
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define DEFAULT_RECEIVE_TIMEOUT
Definition: session.c:52
int resolve_timeout
DWORD_PTR Spare[8/sizeof(DWORD_PTR)]
Definition: winbase.h:859
void release_object(struct object_header *hdr)
Definition: handle.c:72

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_passport_auth(), test_redirect(), test_request_parameter_defaults(), test_request_path_escapes(), test_resolve_timeout(), test_secure_connection(), test_timeouts(), test_WinHttpAddHeaders(), test_WinHttpGetProxyForUrl(), test_WinHttpOpenRequest(), test_WinHttpQueryOption(), test_WinHttpSendRequest(), 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 1109 of file session.c.

1111 {
1112  struct request *request;
1113  struct connect *connect;
1114  HINTERNET hrequest = NULL;
1115 
1116  TRACE("%p, %s, %s, %s, %s, %p, 0x%08x\n", hconnect, debugstr_w(verb), debugstr_w(object),
1117  debugstr_w(version), debugstr_w(referrer), types, flags);
1118 
1119  if (types && TRACE_ON(winhttp))
1120  {
1121  const WCHAR **iter;
1122  TRACE("accept types:\n");
1123  for (iter = types; *iter; iter++) TRACE(" %s\n", debugstr_w(*iter));
1124  }
1125 
1126  if (!(connect = (struct connect *)grab_object( hconnect )))
1127  {
1129  return NULL;
1130  }
1132  {
1133  release_object( &connect->hdr );
1135  return NULL;
1136  }
1137  if (!(request = heap_alloc_zero( sizeof(struct request) )))
1138  {
1139  release_object( &connect->hdr );
1140  return NULL;
1141  }
1143  request->hdr.vtbl = &request_vtbl;
1144  request->hdr.refs = 1;
1145  request->hdr.flags = flags;
1146  request->hdr.callback = connect->hdr.callback;
1147  request->hdr.notify_mask = connect->hdr.notify_mask;
1148  request->hdr.context = connect->hdr.context;
1149  request->hdr.redirect_policy = connect->hdr.redirect_policy;
1150  list_init( &request->hdr.children );
1152 
1153  addref_object( &connect->hdr );
1154  request->connect = connect;
1155  list_add_head( &connect->hdr.children, &request->hdr.entry );
1156 
1157  request->resolve_timeout = connect->session->resolve_timeout;
1158  request->connect_timeout = connect->session->connect_timeout;
1159  request->send_timeout = connect->session->send_timeout;
1160  request->receive_timeout = connect->session->receive_timeout;
1161  request->receive_response_timeout = connect->session->receive_response_timeout;
1162 
1163  if (!verb || !verb[0]) verb = getW;
1164  if (!(request->verb = strdupW( verb ))) goto end;
1165  if (!(request->path = get_request_path( object ))) goto end;
1166 
1167  if (!version || !version[0]) version = http1_1;
1168  if (!(request->version = strdupW( version ))) goto end;
1169  if (!(add_accept_types_header( request, types ))) goto end;
1170 
1171  if (!(hrequest = alloc_handle( &request->hdr ))) goto end;
1172  request->hdr.handle = hrequest;
1173 
1174  send_callback( &request->hdr, WINHTTP_CALLBACK_STATUS_HANDLE_CREATED, &hrequest, sizeof(hrequest) );
1175 
1176 end:
1177  release_object( &request->hdr );
1178  release_object( &connect->hdr );
1179  TRACE("returning %p\n", hrequest);
1180  if (hrequest) SetLastError( ERROR_SUCCESS );
1181  return hrequest;
1182 }
#define WINHTTP_HANDLE_TYPE_REQUEST
Definition: winhttp.h:432
int receive_timeout
struct connect * connect
static BOOL alloc_handle(struct handle_table *lpTable, OBJECTHDR *lpObject, HCRYPTKEY *lpHandle)
Definition: handle.c:183
#define ERROR_SUCCESS
Definition: deptool.c:10
struct object_header * grab_object(HINTERNET hinternet)
Definition: handle.c:56
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
WCHAR * version
struct session * session
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 const struct object_vtbl request_vtbl
Definition: session.c:1072
static const WCHAR getW[]
Definition: object.c:50
int resolve_timeout
int send_timeout
#define debugstr_w
Definition: kernel32.h:32
int connect_timeout
char path[256]
Definition: tftpd.h:94
smooth NULL
Definition: ftsmooth.c:416
static const WCHAR version[]
Definition: asmname.c:66
#define ERROR_WINHTTP_INCORRECT_HANDLE_TYPE
Definition: winhttp.h:199
struct list task_queue
static BOOL add_accept_types_header(struct request *request, const WCHAR **types)
Definition: session.c:1079
#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
static WCHAR * get_request_path(const WCHAR *object)
Definition: session.c:1093
#define SetLastError(x)
Definition: compat.h:417
GLbitfield flags
Definition: glext.h:7161
WCHAR * verb
void send_callback(struct object_header *hdr, DWORD status, void *info, DWORD buflen)
Definition: session.c:55
static const WCHAR http1_1[]
struct object_header hdr
int receive_response_timeout
Definition: tftpd.h:85
__WINE_SERVER_LIST_INLINE void list_init(struct list *list)
Definition: list.h:149
struct object_header hdr
#define TRACE_ON(x)
Definition: compat.h:65
struct object_header * addref_object(struct object_header *hdr)
Definition: handle.c:49
void release_object(struct object_header *hdr)
Definition: handle.c:72

Referenced by do_request(), 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_passport_auth(), test_redirect(), test_request_parameter_defaults(), test_resolve_timeout(), test_secure_connection(), test_timeouts(), test_WinHttpAddHeaders(), test_WinHttpOpenRequest(), test_WinHttpQueryOption(), test_WinHttpSendRequest(), transfer_file_http(), and winhttp_request_Open().

◆ WinHttpQueryOption()

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

Definition at line 1245 of file session.c.

1246 {
1247  BOOL ret = FALSE;
1248  struct object_header *hdr;
1249 
1250  TRACE("%p, %u, %p, %p\n", handle, option, buffer, buflen);
1251 
1252  if (!(hdr = grab_object( handle )))
1253  {
1255  return FALSE;
1256  }
1257 
1258  ret = query_option( hdr, option, buffer, buflen );
1259 
1260  release_object( hdr );
1261  if (ret) SetLastError( ERROR_SUCCESS );
1262  return ret;
1263 }
char hdr[14]
Definition: iptest.cpp:33
#define ERROR_SUCCESS
Definition: deptool.c:10
struct object_header * grab_object(HINTERNET hinternet)
Definition: handle.c:56
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
GLuint buffer
Definition: glext.h:5915
static BOOL query_option(struct object_header *hdr, DWORD option, void *buffer, DWORD *buflen)
Definition: session.c:1204
unsigned int BOOL
Definition: ntddk_ex.h:94
Definition: getopt.h:108
#define TRACE(s)
Definition: solgame.cpp:4
#define SetLastError(x)
Definition: compat.h:417
int ret
void release_object(struct object_header *hdr)
Definition: handle.c:72

Referenced by check_notification(), test_basic_request(), test_connection_info(), test_credentials(), test_secure_connection(), test_timeouts(), test_WinHttpQueryOption(), and test_WinHttpSendRequest().

◆ WinHttpSetDefaultProxyConfiguration()

BOOL WINAPI WinHttpSetDefaultProxyConfiguration ( WINHTTP_PROXY_INFO info)

Definition at line 1940 of file session.c.

1941 {
1942  LONG l;
1943  HKEY key;
1944  BOOL ret = FALSE;
1945  const WCHAR *src;
1946 
1947  TRACE("%p\n", info);
1948 
1949  if (!info)
1950  {
1952  return FALSE;
1953  }
1954  switch (info->dwAccessType)
1955  {
1957  break;
1959  if (!info->lpszProxy)
1960  {
1962  return FALSE;
1963  }
1964  /* Only ASCII characters are allowed */
1965  for (src = info->lpszProxy; *src; src++)
1966  if (*src > 0x7f)
1967  {
1969  return FALSE;
1970  }
1971  if (info->lpszProxyBypass)
1972  {
1973  for (src = info->lpszProxyBypass; *src; src++)
1974  if (*src > 0x7f)
1975  {
1977  return FALSE;
1978  }
1979  }
1980  break;
1981  default:
1983  return FALSE;
1984  }
1985 
1987  KEY_WRITE, NULL, &key, NULL );
1988  if (!l)
1989  {
1990  DWORD size = sizeof(struct connection_settings_header) + 2 * sizeof(DWORD);
1991  BYTE *buf;
1992 
1993  if (info->dwAccessType == WINHTTP_ACCESS_TYPE_NAMED_PROXY)
1994  {
1995  size += strlenW( info->lpszProxy );
1996  if (info->lpszProxyBypass)
1997  size += strlenW( info->lpszProxyBypass );
1998  }
1999  buf = heap_alloc( size );
2000  if (buf)
2001  {
2003  (struct connection_settings_header *)buf;
2004  DWORD *len = (DWORD *)(hdr + 1);
2005 
2006  hdr->magic = WINHTTP_SETTINGS_MAGIC;
2007  hdr->unknown = 0;
2008  if (info->dwAccessType == WINHTTP_ACCESS_TYPE_NAMED_PROXY)
2009  {
2010  BYTE *dst;
2011 
2012  hdr->flags = PROXY_TYPE_PROXY;
2013  *len++ = strlenW( info->lpszProxy );
2014  for (dst = (BYTE *)len, src = info->lpszProxy; *src;
2015  src++, dst++)
2016  *dst = *src;
2017  len = (DWORD *)dst;
2018  if (info->lpszProxyBypass)
2019  {
2020  *len++ = strlenW( info->lpszProxyBypass );
2021  for (dst = (BYTE *)len, src = info->lpszProxyBypass; *src;
2022  src++, dst++)
2023  *dst = *src;
2024  }
2025  else
2026  *len++ = 0;
2027  }
2028  else
2029  {
2030  hdr->flags = PROXY_TYPE_DIRECT;
2031  *len++ = 0;
2032  *len++ = 0;
2033  }
2035  if (!l)
2036  ret = TRUE;
2037  heap_free( buf );
2038  }
2039  RegCloseKey( key );
2040  }
2041  if (ret) SetLastError( ERROR_SUCCESS );
2042  return ret;
2043 }
#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:1494
#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:1091
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:4895
#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
#define SetLastError(x)
Definition: compat.h:417
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:1501
static const DWORD PROXY_TYPE_PROXY
Definition: session.c:1506
static const DWORD PROXY_TYPE_DIRECT
Definition: session.c:1505
static const DWORD WINHTTP_SETTINGS_MAGIC
Definition: session.c:1503
Definition: path.c:41
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 1304 of file session.c.

1305 {
1306  BOOL ret = FALSE;
1307  struct object_header *hdr;
1308 
1309  TRACE("%p, %u, %p, %u\n", handle, option, buffer, buflen);
1310 
1311  if (!(hdr = grab_object( handle )))
1312  {
1314  return FALSE;
1315  }
1316 
1317  ret = set_option( hdr, option, buffer, buflen );
1318 
1319  release_object( hdr );
1320  if (ret) SetLastError( ERROR_SUCCESS );
1321  return ret;
1322 }
char hdr[14]
Definition: iptest.cpp:33
#define ERROR_SUCCESS
Definition: deptool.c:10
struct object_header * grab_object(HINTERNET hinternet)
Definition: handle.c:56
#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
#define SetLastError(x)
Definition: compat.h:417
int ret
static BOOL set_option(struct object_header *hdr, DWORD option, void *buffer, DWORD buflen)
Definition: session.c:1265
void release_object(struct object_header *hdr)
Definition: handle.c:72

Referenced by open_async_request(), request_set_parameters(), test_async(), test_basic_authentication(), test_basic_request(), test_connection_cache(), test_credentials(), test_passport_auth(), test_redirect(), test_resolve_timeout(), test_secure_connection(), test_timeouts(), test_WinHttpQueryOption(), test_WinHttpSendRequest(), 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 2048 of file session.c.

2050 {
2051  struct object_header *hdr;
2053 
2054  TRACE("%p, %p, 0x%08x, 0x%lx\n", handle, callback, flags, reserved);
2055 
2056  if (!(hdr = grab_object( handle )))
2057  {
2060  }
2061  ret = hdr->callback;
2062  hdr->callback = callback;
2063  hdr->notify_mask = flags;
2064 
2065  release_object( hdr );
2067  return ret;
2068 }
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
struct object_header * grab_object(HINTERNET hinternet)
Definition: handle.c:56
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
r reserved
Definition: btrfs.c:2865
MmuTrapHandler callback[0x30]
Definition: mmuobject.c:44
#define TRACE(s)
Definition: solgame.cpp:4
#define SetLastError(x)
Definition: compat.h:417
GLbitfield flags
Definition: glext.h:7161
int ret
void release_object(struct object_header *hdr)
Definition: handle.c:72

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 2073 of file session.c.

2074 {
2075  BOOL ret = TRUE;
2076  struct object_header *hdr;
2077 
2078  TRACE("%p, %d, %d, %d, %d\n", handle, resolve, connect, send, receive);
2079 
2080  if (resolve < -1 || connect < -1 || send < -1 || receive < -1)
2081  {
2083  return FALSE;
2084  }
2085 
2086  if (!(hdr = grab_object( handle )))
2087  {
2089  return FALSE;
2090  }
2091 
2092  switch(hdr->type)
2093  {
2095  {
2096  struct request *request = (struct request *)hdr;
2098 
2099  if (resolve < 0) resolve = 0;
2100  request->resolve_timeout = resolve;
2101 
2102  if (send < 0) send = 0;
2104 
2105  if (receive < 0) receive = 0;
2106  request->receive_timeout = receive;
2107 
2108  if (request->netconn)
2109  {
2111  if (netconn_set_timeout( request->netconn, FALSE, receive )) ret = FALSE;
2112  }
2113  break;
2114  }
2116  {
2117  struct session *session = (struct session *)hdr;
2118  session->