ReactOS 0.4.16-dev-297-gc569aee
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 1418 of file session.c.

◆ MAX_HOST_NAME_LENGTH

#define MAX_HOST_NAME_LENGTH   256

Definition at line 443 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 1087 of file session.c.

1088{
1089 static const WCHAR acceptW[] = {'A','c','c','e','p','t',0};
1091
1092 if (!types) return TRUE;
1093 while (*types)
1094 {
1095 if (!process_header( request, acceptW, *types, flags, TRUE )) return FALSE;
1096 types++;
1097 }
1098 return TRUE;
1099}
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
unsigned long DWORD
Definition: ntddk_ex.h:95
GLbitfield flags
Definition: glext.h:7161
BOOL process_header(struct request *request, const WCHAR *field, const WCHAR *value, DWORD flags, BOOL request_only)
Definition: request.c:430
Definition: tftpd.h:86
Definition: cmds.c:130
#define WINHTTP_ADDREQ_FLAG_ADD
Definition: winhttp.h:84
#define WINHTTP_ADDREQ_FLAG_COALESCE_WITH_COMMA
Definition: winhttp.h:85
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by WinHttpOpenRequest().

◆ blob_to_str()

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

Definition at line 672 of file session.c.

673{
674 WCHAR *ret;
676
678 if ((ret = LocalAlloc( 0, size * sizeof(WCHAR) )))
680
681 return ret;
682}
#define NULL
Definition: types.h:112
DWORD WINAPI CertNameToStrW(DWORD dwCertEncodingType, PCERT_NAME_BLOB pName, DWORD dwStrType, LPWSTR psz, DWORD csz)
Definition: str.c:702
GLsizeiptr size
Definition: glext.h:5919
HLOCAL NTAPI LocalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:1390
Definition: image.c:134
Definition: format.c:58
int ret
#define CERT_SIMPLE_NAME_STR
Definition: wincrypt.h:3484
#define CERT_NAME_STR_CRLF_FLAG
Definition: wincrypt.h:3490
static char * encoding
Definition: xmllint.c:155

Referenced by request_query_option().

◆ buffer_to_str()

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

Definition at line 876 of file session.c.

877{
878 WCHAR *ret;
879 if ((ret = heap_alloc( (buflen + 1) * sizeof(WCHAR))))
880 {
881 memcpy( ret, buffer, buflen * sizeof(WCHAR) );
882 ret[buflen] = 0;
883 return ret;
884 }
886 return NULL;
887}
static void * heap_alloc(size_t len)
Definition: appwiz.h:66
#define ERROR_OUTOFMEMORY
Definition: deptool.c:13
#define SetLastError(x)
Definition: compat.h:752
GLuint buffer
Definition: glext.h:5915
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878

Referenced by request_set_option().

◆ build_wpad_url()

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

Definition at line 1362 of file session.c.

1363{
1364 static const WCHAR httpW[] = {'h','t','t','p',':','/','/',0};
1365 static const WCHAR wpadW[] = {'/','w','p','a','d','.','d','a','t',0};
1366 char name[NI_MAXHOST];
1367 WCHAR *ret, *p;
1368 int len;
1369
1370 while (ai && ai->ai_family != AF_INET && ai->ai_family != AF_INET6) ai = ai->ai_next;
1371 if (!ai) return NULL;
1372
1373 if (!reverse_lookup( ai, name, sizeof(name) )) hostname = name;
1374
1375 len = strlenW( httpW ) + strlen( hostname ) + strlenW( wpadW );
1376 if (!(ret = p = GlobalAlloc( 0, (len + 1) * sizeof(WCHAR) ))) return NULL;
1377 strcpyW( p, httpW );
1378 p += strlenW( httpW );
1379 while (*hostname) { *p++ = *hostname++; }
1380 strcpyW( p, wpadW );
1381 return ret;
1382}
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
char * hostname
Definition: ftp.c:88
static int reverse_lookup(const struct addrinfo *ai, char *hostname, size_t len)
Definition: session.c:1357
#define AF_INET
Definition: tcpip.h:117
GLfloat GLfloat p
Definition: glext.h:8902
GLenum GLsizei len
Definition: glext.h:6722
HGLOBAL NTAPI GlobalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:368
static const WCHAR httpW[]
Definition: assoc.c:94
#define strlenW(s)
Definition: unicode.h:34
#define strcpyW(d, s)
Definition: unicode.h:35
struct addrinfo * ai_next
Definition: ws2def.h:672
int ai_family
Definition: ws2def.h:666
Definition: name.c:39
#define AF_INET6
Definition: winsock.h:369
#define NI_MAXHOST
Definition: ws2def.h:359

Referenced by WinHttpDetectAutoProxyConfigUrl().

◆ connect_destroy()

static void connect_destroy ( struct object_header hdr)
static

Definition at line 318 of file session.c.

319{
320 struct connect *connect = (struct connect *)hdr;
321
322 TRACE("%p\n", connect);
323
325
331}
static BOOL heap_free(void *mem)
Definition: appwiz.h:76
void release_object(struct object_header *hdr)
Definition: handle.c:72
char hdr[14]
Definition: iptest.cpp:33
#define TRACE(s)
Definition: solgame.cpp:4
WCHAR * hostname
struct session * session
WCHAR * password
WCHAR * servername
WCHAR * username

◆ connect_query_option()

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

Definition at line 333 of file session.c.

334{
335 struct connect *connect = (struct connect *)hdr;
336
337 switch (option)
338 {
340 {
341 if (!buffer || *buflen < sizeof(HINTERNET))
342 {
343 *buflen = sizeof(HINTERNET);
345 return FALSE;
346 }
347
349 *buflen = sizeof(HINTERNET);
350 return TRUE;
351 }
353 *(DWORD *)buffer = connect->session->resolve_timeout;
354 *buflen = sizeof(DWORD);
355 return TRUE;
356
358 *(DWORD *)buffer = connect->session->connect_timeout;
359 *buflen = sizeof(DWORD);
360 return TRUE;
361
363 *(DWORD *)buffer = connect->session->send_timeout;
364 *buflen = sizeof(DWORD);
365 return TRUE;
366
368 *(DWORD *)buffer = connect->session->receive_timeout;
369 *buflen = sizeof(DWORD);
370 return TRUE;
371
373 *(DWORD *)buffer = connect->session->receive_response_timeout;
374 *buflen = sizeof(DWORD);
375 return TRUE;
376
377 default:
378 FIXME("unimplemented option %u\n", option);
380 return FALSE;
381 }
382}
#define FIXME(fmt,...)
Definition: precomp.h:53
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
Definition: getopt.h:109
#define WINHTTP_OPTION_SEND_TIMEOUT
Definition: winhttp.h:98
LPVOID HINTERNET
Definition: winhttp.h:32
#define WINHTTP_OPTION_RESOLVE_TIMEOUT
Definition: winhttp.h:95
#define WINHTTP_OPTION_CONNECT_TIMEOUT
Definition: winhttp.h:96
#define WINHTTP_OPTION_RECEIVE_TIMEOUT
Definition: winhttp.h:99
#define WINHTTP_OPTION_RECEIVE_RESPONSE_TIMEOUT
Definition: winhttp.h:100
#define WINHTTP_OPTION_PARENT_HANDLE
Definition: winhttp.h:104

◆ copy_char_to_wchar_sz()

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

Definition at line 1525 of file session.c.

1526{
1527 const BYTE *begin;
1528
1529 for (begin = src; src - begin < len; src++, dst++)
1530 *dst = *src;
1531 *dst = 0;
1532}
GLenum src
Definition: glext.h:6340
GLenum GLenum dst
Definition: glext.h:6340
static clock_t begin
Definition: xmllint.c:458
unsigned char BYTE
Definition: xxhash.c:193

Referenced by WinHttpGetDefaultProxyConfiguration(), and WinHttpGetIEProxyConfigForCurrentUser().

◆ copy_sockaddr()

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

Definition at line 684 of file session.c.

685{
686 switch (addr->sa_family)
687 {
688 case AF_INET:
689 {
690 struct sockaddr_in *addr_in = (struct sockaddr_in *)addr_storage;
691
692 memcpy( addr_in, addr, sizeof(*addr_in) );
693 memset( addr_in + 1, 0, sizeof(*addr_storage) - sizeof(*addr_in) );
694 return TRUE;
695 }
696 case AF_INET6:
697 {
698 struct sockaddr_in6 *addr_in6 = (struct sockaddr_in6 *)addr_storage;
699
700 memcpy( addr_in6, addr, sizeof(*addr_in6) );
701 memset( addr_in6 + 1, 0, sizeof(*addr_storage) - sizeof(*addr_in6) );
702 return TRUE;
703 }
704 default:
705 ERR("unhandled family %u\n", addr->sa_family);
706 return FALSE;
707 }
708}
#define ERR(fmt,...)
Definition: precomp.h:57
GLenum const GLvoid * addr
Definition: glext.h:9621
#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 391 of file session.c.

392{
393 static const WCHAR localW[] = { '<','l','o','c','a','l','>',0 };
394 BOOL ret = FALSE;
395
396 if (!strcmpiW( domain, localW ) && !strchrW( server, '.' ))
397 ret = TRUE;
398 else if (*domain == '*')
399 {
400 if (domain[1] == '.')
401 {
402 LPCWSTR dot;
403
404 /* For a hostname to match a wildcard, the last domain must match
405 * the wildcard exactly. E.g. if the wildcard is *.a.b, and the
406 * hostname is www.foo.a.b, it matches, but a.b does not.
407 */
408 dot = strchrW( server, '.' );
409 if (dot)
410 {
411 int len = strlenW( dot + 1 );
412
413 if (len > strlenW( domain + 2 ))
414 {
415 LPCWSTR ptr;
416
417 /* The server's domain is longer than the wildcard, so it
418 * could be a subdomain. Compare the last portion of the
419 * server's domain.
420 */
421 ptr = dot + len + 1 - strlenW( domain + 2 );
422 if (!strcmpiW( ptr, domain + 2 ))
423 {
424 /* This is only a match if the preceding character is
425 * a '.', i.e. that it is a matching domain. E.g.
426 * if domain is '*.b.c' and server is 'www.ab.c' they
427 * do not match.
428 */
429 ret = *(ptr - 1) == '.';
430 }
431 }
432 else
433 ret = !strcmpiW( dot + 1, domain + 2 );
434 }
435 }
436 }
437 else
438 ret = !strcmpiW( server, domain );
439 return ret;
440}
unsigned int BOOL
Definition: ntddk_ex.h:94
static PVOID ptr
Definition: dispmode.c:27
#define strchrW(s, c)
Definition: unicode.h:40
#define strcmpiW(s1, s2)
Definition: unicode.h:45
Definition: cookie.c:42
static rfbScreenInfoPtr server
Definition: vnc.c:74
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185

Referenced by should_bypass_proxy().

◆ download_script()

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

Definition at line 1778 of file session.c.

1779{
1780 static const WCHAR typeW[] = {'*','/','*',0};
1781 static const WCHAR *acceptW[] = {typeW, NULL};
1782 HINTERNET ses, con = NULL, req = NULL;
1783 WCHAR *hostname;
1784 URL_COMPONENTSW uc;
1785 DWORD status, size = sizeof(status), offset, to_read, bytes_read, flags = 0;
1786 char *tmp, *buffer = NULL;
1787
1788 *out_size = 0;
1789
1790 memset( &uc, 0, sizeof(uc) );
1791 uc.dwStructSize = sizeof(uc);
1792 uc.dwHostNameLength = -1;
1793 uc.dwUrlPathLength = -1;
1794 if (!WinHttpCrackUrl( url, 0, 0, &uc )) return NULL;
1795 if (!(hostname = heap_alloc( (uc.dwHostNameLength + 1) * sizeof(WCHAR) ))) return NULL;
1796 memcpy( hostname, uc.lpszHostName, uc.dwHostNameLength * sizeof(WCHAR) );
1797 hostname[uc.dwHostNameLength] = 0;
1798
1799 if (!(ses = WinHttpOpen( NULL, WINHTTP_ACCESS_TYPE_NO_PROXY, NULL, NULL, 0 ))) goto done;
1800 if (!(con = WinHttpConnect( ses, hostname, uc.nPort, 0 ))) goto done;
1802 if (!(req = WinHttpOpenRequest( con, NULL, uc.lpszUrlPath, NULL, NULL, acceptW, flags ))) goto done;
1803 if (!WinHttpSendRequest( req, NULL, 0, NULL, 0, 0, 0 )) goto done;
1804
1805 if (!(WinHttpReceiveResponse( req, 0 ))) goto done;
1807 &size, NULL ) || status != HTTP_STATUS_OK) goto done;
1808
1809 size = 4096;
1810 if (!(buffer = heap_alloc( size ))) goto done;
1811 to_read = size;
1812 offset = 0;
1813 for (;;)
1814 {
1815 if (!WinHttpReadData( req, buffer + offset, to_read, &bytes_read )) goto done;
1816 if (!bytes_read) break;
1817 to_read -= bytes_read;
1818 offset += bytes_read;
1819 *out_size += bytes_read;
1820 if (!to_read)
1821 {
1822 to_read = size;
1823 size *= 2;
1824 if (!(tmp = heap_realloc( buffer, size ))) goto done;
1825 buffer = tmp;
1826 }
1827 }
1828
1829done:
1830 WinHttpCloseHandle( req );
1831 WinHttpCloseHandle( con );
1832 WinHttpCloseHandle( ses );
1835 return buffer;
1836}
static void * heap_realloc(void *mem, size_t len)
Definition: appwiz.h:71
static const WCHAR typeW[]
Definition: name.c:51
HINTERNET WINAPI WinHttpOpen(LPCWSTR agent, DWORD access, LPCWSTR proxy, LPCWSTR bypass, DWORD flags)
Definition: session.c:250
HINTERNET WINAPI WinHttpConnect(HINTERNET hsession, LPCWSTR server, INTERNET_PORT port, DWORD reserved)
Definition: session.c:541
BOOL WINAPI WinHttpCloseHandle(HINTERNET handle)
Definition: session.c:1195
HINTERNET WINAPI WinHttpOpenRequest(HINTERNET hconnect, LPCWSTR verb, LPCWSTR object, LPCWSTR version, LPCWSTR referrer, LPCWSTR *types, DWORD flags)
Definition: session.c:1117
BOOL WINAPI WinHttpCrackUrl(LPCWSTR url, DWORD len, DWORD flags, LPURL_COMPONENTSW uc)
Definition: url.c:179
ULONG to_read
Definition: btrfs.c:4260
GLintptr offset
Definition: glext.h:5920
static const WCHAR url[]
Definition: encode.c:1432
static HANDLE PIO_APC_ROUTINE PVOID PIO_STATUS_BLOCK ULONG PVOID ULONG PVOID ULONG out_size
Definition: file.c:100
BOOL WINAPI WinHttpQueryHeaders(HINTERNET hrequest, DWORD level, LPCWSTR name, LPVOID buffer, LPDWORD buflen, LPDWORD index)
Definition: request.c:856
BOOL WINAPI WinHttpReadData(HINTERNET hrequest, LPVOID buffer, DWORD to_read, LPDWORD read)
Definition: request.c:3053
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 WinHttpReceiveResponse(HINTERNET hrequest, LPVOID reserved)
Definition: request.c:2924
DWORD dwStructSize
Definition: wininet.h:211
DWORD dwUrlPathLength
Definition: wininet.h:223
LPWSTR lpszHostName
Definition: wininet.h:215
DWORD dwHostNameLength
Definition: wininet.h:216
INTERNET_SCHEME nScheme
Definition: wininet.h:214
LPWSTR lpszUrlPath
Definition: wininet.h:222
INTERNET_PORT nPort
Definition: wininet.h:217
Definition: ps.c:97
#define HTTP_STATUS_OK
Definition: winhttp.h:240
#define WINHTTP_QUERY_STATUS_CODE
Definition: winhttp.h:317
#define WINHTTP_QUERY_FLAG_NUMBER
Definition: winhttp.h:377
#define ERROR_WINHTTP_UNABLE_TO_DOWNLOAD_SCRIPT
Definition: winhttp.h:221
#define WINHTTP_ACCESS_TYPE_NO_PROXY
Definition: winhttp.h:63
#define WINHTTP_FLAG_SECURE
Definition: winhttp.h:60
#define INTERNET_SCHEME_HTTPS
Definition: winhttp.h:43

Referenced by WinHttpGetProxyForUrl().

◆ get_computer_name()

static char * get_computer_name ( COMPUTER_NAME_FORMAT  format)
static

Definition at line 1332 of file session.c.

1333{
1334 char *ret;
1335 DWORD size = 0;
1336
1338 if (GetLastError() != ERROR_MORE_DATA) return NULL;
1339 if (!(ret = heap_alloc( size ))) return NULL;
1340 if (!GetComputerNameExA( format, ret, &size ))
1341 {
1342 heap_free( ret );
1343 return NULL;
1344 }
1345 return ret;
1346}
#define ERROR_MORE_DATA
Definition: dderror.h:13
BOOL WINAPI GetComputerNameExA(COMPUTER_NAME_FORMAT, LPSTR, LPDWORD)
Definition: compname.c:376
DWORD WINAPI GetLastError(void)
Definition: except.c:1042

Referenced by WinHttpDetectAutoProxyConfigUrl().

◆ get_request_path()

static WCHAR * get_request_path ( const WCHAR object)
static

Definition at line 1101 of file session.c.

1102{
1103 int len = object ? strlenW(object) : 0;
1104 WCHAR *p, *ret;
1105
1106 if (!object || object[0] != '/') len++;
1107 if (!(p = ret = heap_alloc( (len + 1) * sizeof(WCHAR) ))) return NULL;
1108 if (!object || object[0] != '/') *p++ = '/';
1109 if (object) strcpyW( p, object );
1110 ret[len] = 0;
1111 return ret;
1112}

Referenced by WinHttpOpenRequest().

◆ get_system_proxy_autoconfig_url()

static BOOL get_system_proxy_autoconfig_url ( char buf,
DWORD  buflen 
)
static

Definition at line 1384 of file session.c.

1385{
1386#if defined(MAC_OS_X_VERSION_10_6) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6
1387 CFDictionaryRef settings = CFNetworkCopySystemProxySettings();
1388 const void *ref;
1389 BOOL ret = FALSE;
1390
1391 if (!settings) return FALSE;
1392
1393 if (!(ref = CFDictionaryGetValue( settings, kCFNetworkProxiesProxyAutoConfigURLString )))
1394 {
1395 CFRelease( settings );
1396 return FALSE;
1397 }
1398 if (CFStringGetCString( ref, buf, buflen, kCFStringEncodingASCII ))
1399 {
1400 TRACE( "returning %s\n", debugstr_a(buf) );
1401 ret = TRUE;
1402 }
1403 CFRelease( settings );
1404 return ret;
1405#else
1406 static BOOL first = TRUE;
1407 if (first)
1408 {
1409 FIXME( "no support on this platform\n" );
1410 first = FALSE;
1411 }
1412 else
1413 TRACE( "no support on this platform\n" );
1414 return FALSE;
1415#endif
1416}
struct mke2fs_defaults settings[]
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
const GLint * first
Definition: glext.h:5794
#define debugstr_a
Definition: kernel32.h:31
Definition: send.c:48

Referenced by WinHttpDetectAutoProxyConfigUrl().

◆ InternetDeInitializeAutoProxyDll()

BOOL WINAPI InternetDeInitializeAutoProxyDll ( LPSTR  mime,
DWORD  reserved 
)

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}
static CRITICAL_SECTION cs_jsproxy
Definition: main.c:46
static struct pac_script * global_script
Definition: main.c:106
r reserved
Definition: btrfs.c:3006
const WCHAR * mime
Definition: mimefilter.c:512
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)

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

1349{
1350 int len_domain = strlen( domain ), len_suffix = strlen( suffix );
1351
1352 if (len_suffix > len_domain) return FALSE;
1353 if (!_strnicmp( domain + len_domain - len_suffix, suffix, -1 )) return TRUE;
1354 return FALSE;
1355}
#define _strnicmp(_String1, _String2, _MaxCount)
Definition: compat.h:23

Referenced by WinHttpDetectAutoProxyConfigUrl().

◆ parse_script_result()

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

Definition at line 1744 of file session.c.

1745{
1746 const char *p;
1747 WCHAR *q;
1748 int len;
1749
1750 info->dwAccessType = WINHTTP_ACCESS_TYPE_NO_PROXY;
1751 info->lpszProxy = NULL;
1752 info->lpszProxyBypass = NULL;
1753
1754 TRACE("%s\n", debugstr_a( result ));
1755
1756 p = result;
1757 while (*p == ' ') p++;
1758 len = strlen( p );
1759 if (len >= 5 && !_strnicmp( p, "PROXY", sizeof("PROXY") - 1 ))
1760 {
1761 p += 5;
1762 while (*p == ' ') p++;
1763 if (!*p || *p == ';') return TRUE;
1764 if (!(info->lpszProxy = q = strdupAW( p ))) return FALSE;
1765 info->dwAccessType = WINHTTP_ACCESS_TYPE_NAMED_PROXY;
1766 for (; *q; q++)
1767 {
1768 if (*q == ' ' || *q == ';')
1769 {
1770 *q = 0;
1771 break;
1772 }
1773 }
1774 }
1775 return TRUE;
1776}
static WCHAR * strdupAW(const char *src)
Definition: main.c:31
GLdouble GLdouble GLdouble GLdouble q
Definition: gl.h:2063
GLuint64EXT * result
Definition: glext.h:11304
#define WINHTTP_ACCESS_TYPE_NAMED_PROXY
Definition: winhttp.h:64

Referenced by run_script().

◆ query_option()

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

Definition at line 1212 of file session.c.

1213{
1214 BOOL ret = FALSE;
1215
1216 if (!buflen)
1217 {
1219 return FALSE;
1220 }
1221
1222 switch (option)
1223 {
1225 {
1226 if (!buffer || *buflen < sizeof(DWORD_PTR))
1227 {
1228 *buflen = sizeof(DWORD_PTR);
1230 return FALSE;
1231 }
1232
1233 *(DWORD_PTR *)buffer = hdr->context;
1234 *buflen = sizeof(DWORD_PTR);
1235 return TRUE;
1236 }
1237 default:
1238 if (hdr->vtbl->query_option) ret = hdr->vtbl->query_option( hdr, option, buffer, buflen );
1239 else
1240 {
1241 FIXME("unimplemented option %u\n", option);
1243 return FALSE;
1244 }
1245 break;
1246 }
1247 return ret;
1248}
#define DWORD_PTR
Definition: treelist.c:76
uint32_t DWORD_PTR
Definition: typedefs.h:65
#define WINHTTP_OPTION_CONTEXT_VALUE
Definition: winhttp.h:112
#define ERROR_WINHTTP_INCORRECT_HANDLE_TYPE
Definition: winhttp.h:199

Referenced by WinHttpQueryOption().

◆ request_destroy()

static void request_destroy ( struct object_header hdr)
static

Definition at line 604 of file session.c.

605{
606 struct request *request = (struct request *)hdr;
607 unsigned int i, j;
608
609 TRACE("%p\n", request);
610
611#ifdef __REACTOS__
612 if (request->task_thread)
613#else
615#endif
616 {
617 /* Signal to the task proc to quit. It will call this again when it does. */
618#ifdef __REACTOS__
619 HANDLE thread = request->task_thread;
620 request->task_thread = 0;
623#else
626#endif
627 return;
628 }
630
634
637
643 for (i = 0; i < request->num_headers; i++)
644 {
645 heap_free( request->headers[i].field );
646 heap_free( request->headers[i].value );
647 }
649 for (i = 0; i < TARGET_MAX; i++)
650 {
651 for (j = 0; j < SCHEME_MAX; j++)
652 {
653 heap_free( request->creds[i][j].username );
654 heap_free( request->creds[i][j].password );
655 }
656 }
658}
static HANDLE thread
Definition: service.c:33
BOOL WINAPI CertFreeCertificateContext(PCCERT_CONTEXT pCertContext)
Definition: cert.c:371
#define CloseHandle
Definition: compat.h:739
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
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
static void destroy_authinfo(struct authinfo *info)
HANDLE task_cancel
BOOL task_proc_running
const CERT_CONTEXT * server_cert
WCHAR * version
char path[256]
Definition: tftpd.h:94
const CERT_CONTEXT * client_cert
struct header * headers
WCHAR * verb
struct authinfo * authinfo
DWORD num_headers
CredHandle cred_handle
struct request::@599 creds[TARGET_MAX][SCHEME_MAX]
WCHAR * status_text
WCHAR * raw_headers
struct connect * connect
BOOL cred_handle_initialized
struct authinfo * proxy_authinfo
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent(IN HANDLE hEvent)
Definition: synch.c:733
@ TARGET_MAX
@ SCHEME_MAX
SECURITY_STATUS WINAPI FreeCredentialsHandle(PCredHandle phCredential)
Definition: wrapper.c:151

◆ request_query_option()

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

Definition at line 710 of file session.c.

711{
712 struct request *request = (struct request *)hdr;
713
714 switch (option)
715 {
717 {
718 DWORD flags;
719 int bits;
720
721 if (!buffer || *buflen < sizeof(flags))
722 {
723 *buflen = sizeof(flags);
725 return FALSE;
726 }
727
729 if (request->netconn)
730 {
732 if (bits >= 128)
734 else if (bits >= 56)
736 else
738 }
739 *(DWORD *)buffer = flags;
740 *buflen = sizeof(flags);
741 return TRUE;
742 }
744 {
745 const CERT_CONTEXT *cert;
746
747 if (!buffer || *buflen < sizeof(cert))
748 {
749 *buflen = sizeof(cert);
751 return FALSE;
752 }
753
756 *buflen = sizeof(cert);
757 return TRUE;
758 }
760 {
762 const CRYPT_OID_INFO *oidInfo;
764
765 FIXME("partial stub\n");
766
767 if (!buffer || *buflen < sizeof(*ci))
768 {
769 *buflen = sizeof(*ci);
771 return FALSE;
772 }
773 if (!cert) return FALSE;
774
775 ci->ftExpiry = cert->pCertInfo->NotAfter;
776 ci->ftStart = cert->pCertInfo->NotBefore;
777 ci->lpszSubjectInfo = blob_to_str( cert->dwCertEncodingType, &cert->pCertInfo->Subject );
778 ci->lpszIssuerInfo = blob_to_str( cert->dwCertEncodingType, &cert->pCertInfo->Issuer );
780 oidInfo = CryptFindOIDInfo( CRYPT_OID_INFO_OID_KEY, cert->pCertInfo->SignatureAlgorithm.pszObjId, 0 );
781 if (oidInfo)
782 ci->lpszSignatureAlgName = (LPWSTR)oidInfo->pwszName;
783 else
787
788 *buflen = sizeof(*ci);
789 return TRUE;
790 }
792 {
793 if (!buffer || *buflen < sizeof(DWORD))
794 {
795 *buflen = sizeof(DWORD);
797 return FALSE;
798 }
799
801 *buflen = sizeof(DWORD);
802 return TRUE;
803 }
805 {
806 WINHTTP_CONNECTION_INFO *info = buffer;
807 struct sockaddr local;
808 socklen_t len = sizeof(local);
809 const struct sockaddr *remote = (const struct sockaddr *)&request->connect->sockaddr;
810
811 if (!buffer || *buflen < sizeof(*info))
812 {
813 *buflen = sizeof(*info);
815 return FALSE;
816 }
817 if (!request->netconn)
818 {
820 return FALSE;
821 }
822 if (getsockname( request->netconn->socket, &local, &len )) return FALSE;
823 if (!copy_sockaddr( &local, &info->LocalAddress )) return FALSE;
824 if (!copy_sockaddr( remote, &info->RemoteAddress )) return FALSE;
825 info->cbSize = sizeof(*info);
826 return TRUE;
827 }
830 *buflen = sizeof(DWORD);
831 return TRUE;
832
835 *buflen = sizeof(DWORD);
836 return TRUE;
837
840 *buflen = sizeof(DWORD);
841 return TRUE;
842
845 *buflen = sizeof(DWORD);
846 return TRUE;
847
850 *buflen = sizeof(DWORD);
851 return TRUE;
852
854 str_to_buffer( buffer, request->connect->username, buflen );
855 return TRUE;
856
858 str_to_buffer( buffer, request->connect->password, buflen );
859 return TRUE;
860
862 str_to_buffer( buffer, request->connect->session->proxy_username, buflen );
863 return TRUE;
864
866 str_to_buffer( buffer, request->connect->session->proxy_password, buflen );
867 return TRUE;
868
869 default:
870 FIXME("unimplemented option %u\n", option);
872 return FALSE;
873 }
874}
PCCERT_CONTEXT WINAPI CertDuplicateCertificateContext(PCCERT_CONTEXT pCertContext)
Definition: cert.c:360
static struct list oidInfo
Definition: oid.c:1206
PCCRYPT_OID_INFO WINAPI CryptFindOIDInfo(DWORD dwKeyType, void *pvKey, DWORD dwGroupId)
Definition: oid.c:1799
int netconn_get_cipher_strength(struct netconn *conn)
Definition: net.c:768
static WCHAR * blob_to_str(DWORD encoding, CERT_NAME_BLOB *blob)
Definition: session.c:672
static BOOL copy_sockaddr(const struct sockaddr *addr, SOCKADDR_STORAGE *addr_storage)
Definition: session.c:684
static void str_to_buffer(WCHAR *buffer, const WCHAR *str, LPDWORD buflen)
Definition: session.c:660
#define local
Definition: zutil.h:30
GLenum GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * bits
Definition: glext.h:10929
#define bits
Definition: infblock.c:15
if(dx< 0)
Definition: linetemp.h:194
int socklen_t
Definition: tcp.c:35
static BYTE cert[]
Definition: msg.c:1437
#define DWORD
Definition: nt_native.h:44
INT WSAAPI getsockname(IN SOCKET s, OUT LPSOCKADDR name, IN OUT INT FAR *namelen)
Definition: sockctrl.c:213
LPWSTR lpszEncryptionAlgName
Definition: winhttp.h:498
int send_timeout
DWORD security_flags
int receive_timeout
int connect_timeout
int resolve_timeout
int receive_response_timeout
struct netconn * netconn
#define CRYPT_OID_INFO_OID_KEY
Definition: wincrypt.h:1702
#define SECURITY_FLAG_STRENGTH_MEDIUM
Definition: winhttp.h:287
#define WINHTTP_OPTION_PROXY_PASSWORD
Definition: winhttp.h:148
#define WINHTTP_OPTION_USERNAME
Definition: winhttp.h:145
#define WINHTTP_OPTION_CONNECTION_INFO
Definition: winhttp.h:136
#define WINHTTP_OPTION_SERVER_CERT_CONTEXT
Definition: winhttp.h:121
#define WINHTTP_OPTION_SECURITY_FLAGS
Definition: winhttp.h:106
#define SECURITY_FLAG_STRENGTH_WEAK
Definition: winhttp.h:286
#define WINHTTP_OPTION_PROXY_USERNAME
Definition: winhttp.h:147
#define WINHTTP_OPTION_PASSWORD
Definition: winhttp.h:146
#define ERROR_WINHTTP_INCORRECT_HANDLE_STATE
Definition: winhttp.h:200
#define WINHTTP_OPTION_SECURITY_CERTIFICATE_STRUCT
Definition: winhttp.h:107
#define WINHTTP_OPTION_SECURITY_KEY_BITNESS
Definition: winhttp.h:109
#define SECURITY_FLAG_STRENGTH_STRONG
Definition: winhttp.h:288
WCHAR * LPWSTR
Definition: xmlstorage.h:184

◆ request_set_option()

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

Definition at line 889 of file session.c.

890{
891 struct request *request = (struct request *)hdr;
892
893 switch (option)
894 {
896 {
898
899 FIXME("%u %s %s\n", pi->dwAccessType, debugstr_w(pi->lpszProxy), debugstr_w(pi->lpszProxyBypass));
900 return TRUE;
901 }
903 {
905
906 if (buflen != sizeof(DWORD))
907 {
909 return FALSE;
910 }
911
912 disable = *(DWORD *)buffer;
913 TRACE("0x%x\n", disable);
914 hdr->disable_flags |= disable;
915 return TRUE;
916 }
918 {
920
921 if (buflen != sizeof(DWORD))
922 {
924 return FALSE;
925 }
926
927 policy = *(DWORD *)buffer;
928 TRACE("0x%x\n", policy);
929 hdr->logon_policy = policy;
930 return TRUE;
931 }
933 {
935
936 if (buflen != sizeof(DWORD))
937 {
939 return FALSE;
940 }
941
942 policy = *(DWORD *)buffer;
943 TRACE("0x%x\n", policy);
944 hdr->redirect_policy = policy;
945 return TRUE;
946 }
948 {
949 DWORD flags;
954
955 if (buflen < sizeof(DWORD))
956 {
958 return FALSE;
959 }
960 flags = *(DWORD *)buffer;
961 TRACE("0x%x\n", flags);
962 if (flags && (flags & ~accepted))
963 {
965 return FALSE;
966 }
968 return TRUE;
969 }
972 return TRUE;
973
976 return TRUE;
977
980 return TRUE;
981
984 return TRUE;
985
988 return TRUE;
989
991 {
992 struct connect *connect = request->connect;
993
995 if (!(connect->username = buffer_to_str( buffer, buflen ))) return FALSE;
996 return TRUE;
997 }
999 {
1000 struct connect *connect = request->connect;
1001
1003 if (!(connect->password = buffer_to_str( buffer, buflen ))) return FALSE;
1004 return TRUE;
1005 }
1007 {
1008 struct session *session = request->connect->session;
1009
1011 if (!(session->proxy_username = buffer_to_str( buffer, buflen ))) return FALSE;
1012 return TRUE;
1013 }
1015 {
1016 struct session *session = request->connect->session;
1017
1019 if (!(session->proxy_password = buffer_to_str( buffer, buflen ))) return FALSE;
1020 return TRUE;
1021 }
1023 {
1024 const CERT_CONTEXT *cert;
1025
1026 if (!(hdr->flags & WINHTTP_FLAG_SECURE))
1027 {
1029 return FALSE;
1030 }
1031 if (!buffer)
1032 {
1035 }
1036 else if (buflen >= sizeof(cert))
1037 {
1041 }
1042 else
1043 {
1045 return FALSE;
1046 }
1047
1049 {
1052 }
1053
1054 return TRUE;
1055 }
1057 if(buflen == sizeof( DWORD ) && *(DWORD *)buffer == WINHTTP_ENABLE_SSL_REVOCATION)
1058 {
1061 return TRUE;
1062 }
1063 else
1064 {
1066 return FALSE;
1067 }
1068
1070 FIXME("WINHTTP_OPTION_CONNECT_RETRIES\n");
1071 return TRUE;
1072
1073 default:
1074 FIXME("unimplemented option %u\n", option);
1076 return FALSE;
1077 }
1078}
WINBASEAPI _Check_return_ _Out_ AppPolicyProcessTerminationMethod * policy
Definition: appmodel.h:47
#define NO_ERROR
Definition: dderror.h:5
static WCHAR * buffer_to_str(WCHAR *buffer, DWORD buflen)
Definition: session.c:876
#define debugstr_w
Definition: kernel32.h:32
static refpint_t pi[]
Definition: server.c:96
int disable
Definition: msacm.c:1365
static void accepted(enum accept_stat, struct rpc_err *)
Definition: rpc_prot.c:280
BOOL check_revocation
WCHAR * proxy_password
WCHAR * proxy_username
#define WINHTTP_OPTION_PROXY
Definition: winhttp.h:110
#define SECURITY_FLAG_IGNORE_CERT_WRONG_USAGE
Definition: winhttp.h:284
#define WINHTTP_OPTION_ENABLE_FEATURE
Definition: winhttp.h:122
#define WINHTTP_OPTION_DISABLE_FEATURE
Definition: winhttp.h:116
#define WINHTTP_OPTION_CLIENT_CERT_CONTEXT
Definition: winhttp.h:113
#define WINHTTP_ENABLE_SSL_REVOCATION
Definition: winhttp.h:172
#define ERROR_WINHTTP_INVALID_OPTION
Definition: winhttp.h:194
#define WINHTTP_OPTION_CONNECT_RETRIES
Definition: winhttp.h:97
#define SECURITY_FLAG_IGNORE_CERT_DATE_INVALID
Definition: winhttp.h:282
#define WINHTTP_OPTION_AUTOLOGON_POLICY
Definition: winhttp.h:120
#define WINHTTP_OPTION_REDIRECT_POLICY
Definition: winhttp.h:131
#define SECURITY_FLAG_IGNORE_UNKNOWN_CA
Definition: winhttp.h:281
#define SECURITY_FLAG_IGNORE_CERT_CN_INVALID
Definition: winhttp.h:283

◆ reverse_lookup()

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

Definition at line 1357 of file session.c.

1358{
1359 return getnameinfo( ai->ai_addr, ai->ai_addrlen, hostname, len, NULL, 0, 0 );
1360}
size_t ai_addrlen
Definition: ws2def.h:669
struct sockaddr * ai_addr
Definition: ws2def.h:671
#define getnameinfo
Definition: wspiapi.h:45

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

1850{
1851 BOOL ret;
1852 char *result, *urlA;
1853 DWORD len_result;
1855 URL_COMPONENTSW uc;
1856
1857 buffer.dwStructSize = sizeof(buffer);
1858 buffer.lpszScriptBuffer = script;
1859 buffer.dwScriptBufferSize = size;
1860
1861 if (!(urlA = strdupWA( url ))) return FALSE;
1863 {
1864 heap_free( urlA );
1865 return FALSE;
1866 }
1867
1868 memset( &uc, 0, sizeof(uc) );
1869 uc.dwStructSize = sizeof(uc);
1870 uc.dwHostNameLength = -1;
1871
1872 if (WinHttpCrackUrl( url, 0, 0, &uc ))
1873 {
1874 char *hostnameA = strdupWA_sized( uc.lpszHostName, uc.dwHostNameLength );
1875
1876 if ((ret = InternetGetProxyInfo( urlA, strlen(urlA),
1877 hostnameA, strlen(hostnameA), &result, &len_result )))
1878 {
1880 heap_free( result );
1881 }
1882
1883 heap_free( hostnameA );
1884 }
1885 heap_free( urlA );
1887}
static char * strdupWA(const WCHAR *src)
Definition: main.c:91
BOOL WINAPI InternetDeInitializeAutoProxyDll(LPSTR, DWORD)
Definition: main.c:111
BOOL WINAPI InternetInitializeAutoProxyDll(DWORD, LPSTR, LPSTR, void *, struct AUTO_PROXY_SCRIPT_BUFFER *)
static BOOL parse_script_result(const char *result, WINHTTP_PROXY_INFO *info)
Definition: session.c:1744
BOOL WINAPI InternetGetProxyInfo(LPCSTR, DWORD, LPSTR, DWORD, LPSTR *, LPDWORD)
script
Definition: msipriv.h:383
static char * strdupWA_sized(const WCHAR *src, DWORD size)

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}

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;
94}
DWORD_PTR Spare[8/sizeof(DWORD_PTR)]
Definition: winbase.h:912
PCRITICAL_SECTION_DEBUG DebugInfo
Definition: winbase.h:919
WCHAR * proxy_bypass
CRITICAL_SECTION cs
HANDLE unload_event
WCHAR * agent
WCHAR * proxy_server
void WINAPI DeleteCriticalSection(PCRITICAL_SECTION)
void destroy_cookies(struct session *session)
Definition: cookie.c:120

◆ 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}
int resolve_timeout
int receive_response_timeout
int receive_timeout
int send_timeout
int connect_timeout

◆ 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 {
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}
DWORD passport_flags
DWORD secure_protocols
#define WINHTTP_OPTION_CONFIGURE_PASSPORT_AUTH
Definition: winhttp.h:126
#define WINHTTP_OPTION_MAX_CONNS_PER_SERVER
Definition: winhttp.h:118
#define WINHTTP_OPTION_UNLOAD_NOTIFY_EVENT
Definition: winhttp.h:141
#define WINHTTP_OPTION_SECURE_PROTOCOLS
Definition: winhttp.h:127
#define WINHTTP_OPTION_MAX_CONNS_PER_1_0_SERVER
Definition: winhttp.h:119

◆ set_option()

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

Definition at line 1273 of file session.c.

1274{
1275 BOOL ret = TRUE;
1276
1277 if (!buffer && buflen)
1278 {
1280 return FALSE;
1281 }
1282
1283 switch (option)
1284 {
1286 {
1287 if (buflen != sizeof(DWORD_PTR))
1288 {
1290 return FALSE;
1291 }
1292
1293 hdr->context = *(DWORD_PTR *)buffer;
1294 return TRUE;
1295 }
1296 default:
1297 if (hdr->vtbl->set_option) ret = hdr->vtbl->set_option( hdr, option, buffer, buflen );
1298 else
1299 {
1300 FIXME("unimplemented option %u\n", option);
1302 return FALSE;
1303 }
1304 break;
1305 }
1306 return ret;
1307}

Referenced by WinHttpSetOption().

◆ set_server_for_hostname()

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

Definition at line 476 of file session.c.

477{
478 struct session *session = connect->session;
479 BOOL ret = TRUE;
480
482 {
483 LPCWSTR colon;
484
485 if ((colon = strchrW( session->proxy_server, ':' )))
486 {
488 session->proxy_server, colon - session->proxy_server - 1 ))
489 {
493 (colon - session->proxy_server + 1) * sizeof(WCHAR) )))
494 {
495 ret = FALSE;
496 goto end;
497 }
499 (colon - session->proxy_server) * sizeof(WCHAR) );
500 connect->servername[colon - session->proxy_server] = 0;
501 if (*(colon + 1))
502 connect->serverport = atoiW( colon + 1 );
503 else
505 }
506 }
507 else
508 {
511 {
515 {
516 ret = FALSE;
517 goto end;
518 }
520 }
521 }
522 }
523 else if (server)
524 {
527 if (!(connect->servername = strdupW( server )))
528 {
529 ret = FALSE;
530 goto end;
531 }
533 }
534end:
535 return ret;
536}
static WCHAR * strdupW(const WCHAR *src)
Definition: main.c:92
USHORT port
Definition: uri.c:228
static BOOL should_bypass_proxy(struct session *session, LPCWSTR server)
Definition: session.c:445
GLuint GLuint end
Definition: gl.h:1545
#define atoiW(s)
Definition: unicode.h:60
#define strncmpiW(s1, s2, n)
Definition: unicode.h:46
INTERNET_PORT serverport
#define INTERNET_DEFAULT_PORT
Definition: winhttp.h:35

Referenced by handle_redirect(), and WinHttpConnect().

◆ should_bypass_proxy()

static BOOL should_bypass_proxy ( struct session session,
LPCWSTR  server 
)
static

Definition at line 445 of file session.c.

446{
447 LPCWSTR ptr;
448 BOOL ret = FALSE;
449
450 if (!session->proxy_bypass) return FALSE;
452 do {
453 LPCWSTR tmp = ptr;
454
455 ptr = strchrW( ptr, ';' );
456 if (!ptr)
457 ptr = strchrW( tmp, ' ' );
458 if (ptr)
459 {
460 if (ptr - tmp < MAX_HOST_NAME_LENGTH)
461 {
463
464 memcpy( domain, tmp, (ptr - tmp) * sizeof(WCHAR) );
465 domain[ptr - tmp] = 0;
467 }
468 ptr += 1;
469 }
470 else if (*tmp)
471 ret = domain_matches( server, tmp );
472 } while (ptr && !ret);
473 return ret;
474}
#define MAX_HOST_NAME_LENGTH
Definition: session.c:443
static BOOL domain_matches(LPCWSTR server, LPCWSTR domain)
Definition: session.c:391

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

661{
662 int len = 0;
663 if (str) len = strlenW( str );
664 if (buffer && *buflen > len)
665 {
666 if (str) memcpy( buffer, str, len * sizeof(WCHAR) );
667 buffer[len] = 0;
668 }
669 *buflen = len * sizeof(WCHAR);
670}
const WCHAR * str

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}

◆ WinHttpCloseHandle()

BOOL WINAPI WinHttpCloseHandle ( HINTERNET  handle)

◆ WinHttpConnect()

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

Definition at line 541 of file session.c.

542{
543 struct connect *connect;
544 struct session *session;
545 HINTERNET hconnect = NULL;
546
547 TRACE("%p, %s, %u, %x\n", hsession, debugstr_w(server), port, reserved);
548
549 if (!server)
550 {
552 return NULL;
553 }
554 if (!(session = (struct session *)grab_object( hsession )))
555 {
557 return NULL;
558 }
560 {
563 return NULL;
564 }
565 if (!(connect = heap_alloc_zero( sizeof(struct connect) )))
566 {
568 return NULL;
569 }
571 connect->hdr.vtbl = &connect_vtbl;
572 connect->hdr.refs = 1;
573 connect->hdr.flags = session->hdr.flags;
574 connect->hdr.callback = session->hdr.callback;
575 connect->hdr.notify_mask = session->hdr.notify_mask;
576 connect->hdr.context = session->hdr.context;
577 connect->hdr.redirect_policy = session->hdr.redirect_policy;
578 list_init( &connect->hdr.children );
579
582 list_add_head( &session->hdr.children, &connect->hdr.entry );
583
584 if (!(connect->hostname = strdupW( server ))) goto end;
587
588 if (!(hconnect = alloc_handle( &connect->hdr ))) goto end;
589 connect->hdr.handle = hconnect;
590
591 send_callback( &session->hdr, WINHTTP_CALLBACK_STATUS_HANDLE_CREATED, &hconnect, sizeof(hconnect) );
592
593end:
596 TRACE("returning %p\n", hconnect);
597 if (hconnect) SetLastError( ERROR_SUCCESS );
598 return hconnect;
599}
static void list_add_head(struct list_entry *head, struct list_entry *entry)
Definition: list.h:76
static void list_init(struct list_entry *head)
Definition: list.h:51
static BOOL alloc_handle(struct handle_table *lpTable, OBJECTHDR *lpObject, HCRYPTKEY *lpHandle)
Definition: handle.c:183
struct object_header * addref_object(struct object_header *hdr)
Definition: handle.c:49
void send_callback(struct object_header *hdr, DWORD status, void *info, DWORD buflen)
Definition: session.c:55
BOOL set_server_for_hostname(struct connect *connect, const WCHAR *server, INTERNET_PORT port)
Definition: session.c:476
static const struct object_vtbl connect_vtbl
Definition: session.c:384
INTERNET_PORT hostport
struct object_header hdr
struct object_header hdr
#define WINHTTP_HANDLE_TYPE_CONNECT
Definition: winhttp.h:431
#define WINHTTP_HANDLE_TYPE_SESSION
Definition: winhttp.h:430
#define WINHTTP_CALLBACK_STATUS_HANDLE_CREATED
Definition: winhttp.h:390

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

1424{
1425 BOOL ret = FALSE;
1426 char system_url[INTERNET_MAX_URL_LENGTH + 1];
1427
1428 TRACE("0x%08x, %p\n", flags, url);
1429
1430 if (!flags || !url)
1431 {
1433 return FALSE;
1434 }
1435 if (get_system_proxy_autoconfig_url( system_url, sizeof(system_url) ))
1436 {
1437 WCHAR *urlW;
1438
1439 if (!(urlW = strdupAW( system_url ))) return FALSE;
1440 *url = urlW;
1442 return TRUE;
1443 }
1445 {
1446 static int fixme_shown;
1447 if (!fixme_shown++) FIXME("discovery via DHCP not supported\n");
1448 }
1450 {
1451 char *fqdn, *domain, *p;
1452
1453 if (!(fqdn = get_computer_name( ComputerNamePhysicalDnsFullyQualified ))) return FALSE;
1454 if (!(domain = get_computer_name( ComputerNamePhysicalDnsDomain )))
1455 {
1456 heap_free( fqdn );
1457 return FALSE;
1458 }
1459 p = fqdn;
1460 while ((p = strchr( p, '.' )) && is_domain_suffix( p + 1, domain ))
1461 {
1462 struct addrinfo *ai;
1463 char *name;
1464 int res;
1465
1466 if (!(name = heap_alloc( sizeof("wpad") + strlen(p) )))
1467 {
1468 heap_free( fqdn );
1469 heap_free( domain );
1470 return FALSE;
1471 }
1472 strcpy( name, "wpad" );
1473 strcat( name, p );
1474 res = getaddrinfo( name, NULL, NULL, &ai );
1475 if (!res)
1476 {
1477 *url = build_wpad_url( name, ai );
1478 freeaddrinfo( ai );
1479 if (*url)
1480 {
1481 TRACE("returning %s\n", debugstr_w(*url));
1482 heap_free( name );
1483 ret = TRUE;
1484 break;
1485 }
1486 }
1487 heap_free( name );
1488 p++;
1489 }
1490 heap_free( domain );
1491 heap_free( fqdn );
1492 }
1493 if (!ret)
1494 {
1496 *url = NULL;
1497 }
1499 return ret;
1500}
char * strcat(char *DstString, const char *SrcString)
Definition: utclib.c:568
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
char * strchr(const char *String, int ch)
Definition: utclib.c:501
#define INTERNET_MAX_URL_LENGTH
Definition: session.c:1418
static WCHAR * build_wpad_url(const char *hostname, const struct addrinfo *ai)
Definition: session.c:1362
static BOOL get_system_proxy_autoconfig_url(char *buf, DWORD buflen)
Definition: session.c:1384
static char * get_computer_name(COMPUTER_NAME_FORMAT format)
Definition: session.c:1332
static BOOL is_domain_suffix(const char *domain, const char *suffix)
Definition: session.c:1348
GLuint res
Definition: glext.h:9613
#define WINHTTP_AUTO_DETECT_TYPE_DHCP
Definition: winhttp.h:527
#define WINHTTP_AUTO_DETECT_TYPE_DNS_A
Definition: winhttp.h:528
#define ERROR_WINHTTP_AUTODETECTION_FAILED
Definition: winhttp.h:228
#define getaddrinfo
Definition: wspiapi.h:44
#define freeaddrinfo
Definition: wspiapi.h:46

Referenced by test_WinHttpDetectAutoProxyConfigUrl(), and WinHttpGetProxyForUrl().

◆ WinHttpGetDefaultProxyConfiguration()

BOOL WINAPI WinHttpGetDefaultProxyConfiguration ( WINHTTP_PROXY_INFO info)

Definition at line 1537 of file session.c.

1538{
1539 LONG l;
1540 HKEY key;
1541 BOOL got_from_reg = FALSE, direct = TRUE;
1542 char *envproxy;
1543
1544 TRACE("%p\n", info);
1545
1547 if (!l)
1548 {
1549 DWORD type, size = 0;
1550
1552 if (!l && type == REG_BINARY &&
1553 size >= sizeof(struct connection_settings_header) + 2 * sizeof(DWORD))
1554 {
1555 BYTE *buf = heap_alloc( size );
1556
1557 if (buf)
1558 {
1561 DWORD *len = (DWORD *)(hdr + 1);
1562
1564 &size );
1565 if (!l && hdr->magic == WINHTTP_SETTINGS_MAGIC &&
1566 hdr->unknown == 0)
1567 {
1568 if (hdr->flags & PROXY_TYPE_PROXY)
1569 {
1570 BOOL sane = FALSE;
1571 LPWSTR proxy = NULL;
1572 LPWSTR proxy_bypass = NULL;
1573
1574 /* Sanity-check length of proxy string */
1575 if ((BYTE *)len - buf + *len <= size)
1576 {
1577 sane = TRUE;
1578 proxy = GlobalAlloc( 0, (*len + 1) * sizeof(WCHAR) );
1579 if (proxy)
1580 copy_char_to_wchar_sz( (BYTE *)(len + 1), *len, proxy );
1581 len = (DWORD *)((BYTE *)(len + 1) + *len);
1582 }
1583 if (sane)
1584 {
1585 /* Sanity-check length of proxy bypass string */
1586 if ((BYTE *)len - buf + *len <= size)
1587 {
1588 proxy_bypass = GlobalAlloc( 0, (*len + 1) * sizeof(WCHAR) );
1589 if (proxy_bypass)
1590 copy_char_to_wchar_sz( (BYTE *)(len + 1), *len, proxy_bypass );
1591 }
1592 else
1593 {
1594 sane = FALSE;
1595 GlobalFree( proxy );
1596 proxy = NULL;
1597 }
1598 }
1599 info->lpszProxy = proxy;
1600 info->lpszProxyBypass = proxy_bypass;
1601 if (sane)
1602 {
1603 got_from_reg = TRUE;
1604 direct = FALSE;
1605 info->dwAccessType =
1607 TRACE("http proxy (from registry) = %s, bypass = %s\n",
1608 debugstr_w(info->lpszProxy),
1609 debugstr_w(info->lpszProxyBypass));
1610 }
1611 }
1612 }
1613 heap_free( buf );
1614 }
1615 }
1616 RegCloseKey( key );
1617 }
1618 if (!got_from_reg && (envproxy = getenv( "http_proxy" )))
1619 {
1620 char *colon, *http_proxy = NULL;
1621
1622 if (!(colon = strchr( envproxy, ':' ))) http_proxy = envproxy;
1623 else
1624 {
1625 if (*(colon + 1) == '/' && *(colon + 2) == '/')
1626 {
1627 /* It's a scheme, check that it's http */
1628 if (!strncmp( envproxy, "http://", 7 )) http_proxy = envproxy + 7;
1629 else WARN("unsupported scheme in $http_proxy: %s\n", envproxy);
1630 }
1631 else http_proxy = envproxy;
1632 }
1633
1634 if (http_proxy && http_proxy[0])
1635 {
1636 WCHAR *http_proxyW;
1637 int len;
1638
1639 len = MultiByteToWideChar( CP_UNIXCP, 0, http_proxy, -1, NULL, 0 );
1640 if ((http_proxyW = GlobalAlloc( 0, len * sizeof(WCHAR))))
1641 {
1642 MultiByteToWideChar( CP_UNIXCP, 0, http_proxy, -1, http_proxyW, len );
1643 direct = FALSE;
1644 info->dwAccessType = WINHTTP_ACCESS_TYPE_NAMED_PROXY;
1645 info->lpszProxy = http_proxyW;
1646 info->lpszProxyBypass = NULL;
1647 TRACE("http proxy (from environment) = %s\n", debugstr_w(info->lpszProxy));
1648 }
1649 }
1650 }
1651 if (direct)
1652 {
1653 info->dwAccessType = WINHTTP_ACCESS_TYPE_NO_PROXY;
1654 info->lpszProxy = NULL;
1655 info->lpszProxyBypass = NULL;
1656 }
1658 return TRUE;
1659}
int strncmp(const char *String1, const char *String2, ACPI_SIZE Count)
Definition: utclib.c:534
#define WARN(fmt,...)
Definition: precomp.h:61
#define RegCloseKey(hKey)
Definition: registry.h:49
r l[0]
Definition: byte_order.h:168
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3333
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4103
#define CP_UNIXCP
Definition: compat.h:79
#define MultiByteToWideChar
Definition: compat.h:110
static const WCHAR WinHttpSettings[]
Definition: session.c:1509
static const DWORD PROXY_TYPE_PROXY
Definition: session.c:1514
static void copy_char_to_wchar_sz(const BYTE *src, DWORD len, WCHAR *dst)
Definition: session.c:1525
static const WCHAR Connections[]
Definition: session.c:1502
static const DWORD WINHTTP_SETTINGS_MAGIC
Definition: session.c:1511
int proxy
Definition: main.c:67
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
HGLOBAL NTAPI GlobalFree(HGLOBAL hMem)
Definition: heapmem.c:611
_Check_return_ char *__cdecl getenv(_In_z_ const char *_VarName)
#define REG_BINARY
Definition: nt_native.h:1496
#define KEY_READ
Definition: nt_native.h:1023
long LONG
Definition: pedump.c:60
Definition: copy.c:22
#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 1664 of file session.c.

1665{
1666 static const WCHAR settingsW[] =
1667 {'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};
1668 HKEY hkey = NULL;
1670 DWORD type, offset, len, size = 0;
1671 BOOL ret = FALSE;
1672
1673 TRACE("%p\n", config);
1674
1675 if (!config)
1676 {
1678 return FALSE;
1679 }
1680 memset( config, 0, sizeof(*config) );
1681 config->fAutoDetect = TRUE;
1682
1684 RegQueryValueExW( hkey, settingsW, NULL, &type, NULL, &size ) ||
1685 type != REG_BINARY || size < sizeof(struct connection_settings_header))
1686 {
1687 ret = TRUE;
1688 goto done;
1689 }
1690 if (!(hdr = heap_alloc( size ))) goto done;
1691 if (RegQueryValueExW( hkey, settingsW, NULL, &type, (BYTE *)hdr, &size ) ||
1692 hdr->magic != WININET_SETTINGS_MAGIC)
1693 {
1694 ret = TRUE;
1695 goto done;
1696 }
1697
1698 config->fAutoDetect = (hdr->flags & PROXY_AUTODETECT_SETTINGS) != 0;
1699 offset = sizeof(*hdr);
1700 if (offset + sizeof(DWORD) > size) goto done;
1701 len = *(DWORD *)((char *)hdr + offset);
1702 offset += sizeof(DWORD);
1703 if (len && hdr->flags & PROXY_TYPE_PROXY)
1704 {
1705 if (!(config->lpszProxy = GlobalAlloc( 0, (len + 1) * sizeof(WCHAR) ))) goto done;
1706 copy_char_to_wchar_sz( (const BYTE *)hdr + offset , len, config->lpszProxy );
1707 }
1708 offset += len;
1709 if (offset + sizeof(DWORD) > size) goto done;
1710 len = *(DWORD *)((char *)hdr + offset);
1711 offset += sizeof(DWORD);
1712 if (len && (hdr->flags & PROXY_TYPE_PROXY))
1713 {
1714 if (!(config->lpszProxyBypass = GlobalAlloc( 0, (len + 1) * sizeof(WCHAR) ))) goto done;
1715 copy_char_to_wchar_sz( (const BYTE *)hdr + offset , len, config->lpszProxyBypass );
1716 }
1717 offset += len;
1718 if (offset + sizeof(DWORD) > size) goto done;
1719 len = *(DWORD *)((char *)hdr + offset);
1720 offset += sizeof(DWORD);
1721 if (len && (hdr->flags & PROXY_USE_PAC_SCRIPT))
1722 {
1723 if (!(config->lpszAutoConfigUrl = GlobalAlloc( 0, (len + 1) * sizeof(WCHAR) ))) goto done;
1724 copy_char_to_wchar_sz( (const BYTE *)hdr + offset , len, config->lpszAutoConfigUrl );
1725 }
1726 ret = TRUE;
1727
1728done:
1729 RegCloseKey( hkey );
1730 heap_free( hdr );
1731 if (!ret)
1732 {
1733 GlobalFree( config->lpszAutoConfigUrl );
1734 config->lpszAutoConfigUrl = NULL;
1735 GlobalFree( config->lpszProxy );
1736 config->lpszProxy = NULL;
1737 GlobalFree( config->lpszProxyBypass );
1738 config->lpszProxyBypass = NULL;
1739 }
1741 return ret;
1742}
static const DWORD PROXY_AUTODETECT_SETTINGS
Definition: session.c:1516
static const DWORD WININET_SETTINGS_MAGIC
Definition: session.c:1512
static const DWORD PROXY_USE_PAC_SCRIPT
Definition: session.c:1515
#define HKEY_CURRENT_USER
Definition: winreg.h:11

Referenced by test_WinHttpGetIEProxyConfigForCurrentUser().

◆ WinHttpGetProxyForUrl()

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

Definition at line 1892 of file session.c.

1894{
1895 WCHAR *detected_pac_url = NULL;
1896 const WCHAR *pac_url;
1897 struct session *session;
1898 char *script;
1899 DWORD size;
1900 BOOL ret = FALSE;
1901
1902 TRACE("%p, %s, %p, %p\n", hsession, debugstr_w(url), options, info);
1903
1904 if (!(session = (struct session *)grab_object( hsession )))
1905 {
1907 return FALSE;
1908 }
1910 {
1913 return FALSE;
1914 }
1915 if (!url || !options || !info ||
1917 ((options->dwFlags & WINHTTP_AUTOPROXY_AUTO_DETECT) && !options->dwAutoDetectFlags) ||
1918 ((options->dwFlags & WINHTTP_AUTOPROXY_AUTO_DETECT) &&
1920 {
1923 return FALSE;
1924 }
1925 if (options->dwFlags & WINHTTP_AUTOPROXY_AUTO_DETECT &&
1926 !WinHttpDetectAutoProxyConfigUrl( options->dwAutoDetectFlags, &detected_pac_url ))
1927 goto done;
1928
1929 if (options->dwFlags & WINHTTP_AUTOPROXY_CONFIG_URL) pac_url = options->lpszAutoConfigUrl;
1930 else pac_url = detected_pac_url;
1931
1932 if ((script = download_script( pac_url, &size )))
1933 {
1934 ret = run_script( script, size, url, info );
1935 heap_free( script );
1936 }
1937
1938done:
1939 GlobalFree( detected_pac_url );
1942 return ret;
1943}
static char * download_script(const WCHAR *url, DWORD *out_size)
Definition: session.c:1778
static BOOL run_script(char *script, DWORD size, const WCHAR *url, WINHTTP_PROXY_INFO *info)
Definition: session.c:1849
BOOL WINAPI WinHttpDetectAutoProxyConfigUrl(DWORD flags, LPWSTR *url)
Definition: session.c:1423
#define WINHTTP_AUTOPROXY_AUTO_DETECT
Definition: winhttp.h:530
#define WINHTTP_AUTOPROXY_CONFIG_URL
Definition: winhttp.h:531

Referenced by test_WinHttpGetProxyForUrl().

◆ WinHttpOpen()

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

Definition at line 250 of file session.c.

251{
252 struct session *session;
254
255 TRACE("%s, %u, %s, %s, 0x%08x\n", debugstr_w(agent), access, debugstr_w(proxy), debugstr_w(bypass), flags);
256
257 if (!(session = heap_alloc_zero( sizeof(struct session) ))) return NULL;
258
260 session->hdr.vtbl = &session_vtbl;
261 session->hdr.flags = flags;
262 session->hdr.refs = 1;
264 list_init( &session->hdr.children );
272 session->cs.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": session.cs");
273
274 if (agent && !(session->agent = strdupW( agent ))) goto end;
276 {
278
280 session->access = info.dwAccessType;
281 if (info.lpszProxy && !(session->proxy_server = strdupW( info.lpszProxy )))
282 {
283 GlobalFree( (LPWSTR)info.lpszProxy );
284 GlobalFree( (LPWSTR)info.lpszProxyBypass );
285 goto end;
286 }
287 if (info.lpszProxyBypass && !(session->proxy_bypass = strdupW( info.lpszProxyBypass )))
288 {
289 GlobalFree( (LPWSTR)info.lpszProxy );
290 GlobalFree( (LPWSTR)info.lpszProxyBypass );
291 goto end;
292 }
293 }
295 {
297 if (proxy && !(session->proxy_server = strdupW( proxy ))) goto end;
298 if (bypass && !(session->proxy_bypass = strdupW( bypass ))) goto end;
299 }
300
301 if (!(handle = alloc_handle( &session->hdr ))) goto end;
302 session->hdr.handle = handle;
303
304#ifdef __REACTOS__
305 winsock_init();
306#endif
307
308end:
310 TRACE("returning %p\n", handle);
312 return handle;
313}
BOOL WINAPI WinHttpGetDefaultProxyConfiguration(WINHTTP_PROXY_INFO *info)
Definition: session.c:1537
static const struct object_vtbl session_vtbl
Definition: session.c:236
#define DEFAULT_RECEIVE_TIMEOUT
Definition: session.c:52
#define DEFAULT_RESOLVE_TIMEOUT
Definition: session.c:49
#define DEFAULT_SEND_TIMEOUT
Definition: session.c:51
#define DEFAULT_RECEIVE_RESPONSE_TIMEOUT
Definition: session.c:53
#define DEFAULT_CONNECT_TIMEOUT
Definition: session.c:50
GLuint GLint GLboolean GLint GLenum access
Definition: glext.h:7866
DWORD access
struct list cookie_cache
VOID WINAPI InitializeCriticalSection(OUT LPCRITICAL_SECTION lpCriticalSection)
Definition: synch.c:751
#define WINHTTP_ACCESS_TYPE_DEFAULT_PROXY
Definition: winhttp.h:62
#define WINHTTP_OPTION_REDIRECT_POLICY_DISALLOW_HTTPS_TO_HTTP
Definition: winhttp.h:158
BOOL winsock_init(void)
Definition: wintirpc.c:77

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

1119{
1120 struct request *request;
1121 struct connect *connect;
1122 HINTERNET hrequest = NULL;
1123
1124 TRACE("%p, %s, %s, %s, %s, %p, 0x%08x\n", hconnect, debugstr_w(verb), debugstr_w(object),
1125 debugstr_w(version), debugstr_w(referrer), types, flags);
1126
1127 if (types && TRACE_ON(winhttp))
1128 {
1129 const WCHAR **iter;
1130 TRACE("accept types:\n");
1131 for (iter = types; *iter; iter++) TRACE(" %s\n", debugstr_w(*iter));
1132 }
1133
1134 if (!(connect = (struct connect *)grab_object( hconnect )))
1135 {
1137 return NULL;
1138 }
1140 {
1143 return NULL;
1144 }
1145 if (!(request = heap_alloc_zero( sizeof(struct request) )))
1146 {
1148 return NULL;
1149 }
1151 request->hdr.vtbl = &request_vtbl;
1152 request->hdr.refs = 1;
1153 request->hdr.flags = flags;
1154 request->hdr.callback = connect->hdr.callback;
1155 request->hdr.notify_mask = connect->hdr.notify_mask;
1156 request->hdr.context = connect->hdr.context;
1157 request->hdr.redirect_policy = connect->hdr.redirect_policy;
1158 list_init( &request->hdr.children );
1160
1163 list_add_head( &connect->hdr.children, &request->hdr.entry );
1164
1165 request->resolve_timeout = connect->session->resolve_timeout;
1166 request->connect_timeout = connect->session->connect_timeout;
1167 request->send_timeout = connect->session->send_timeout;
1168 request->receive_timeout = connect->session->receive_timeout;
1169 request->receive_response_timeout = connect->session->receive_response_timeout;
1170
1171 if (!verb || !verb[0]) verb = getW;
1172 if (!(request->verb = strdupW( verb ))) goto end;
1173 if (!(request->path = get_request_path( object ))) goto end;
1174
1175 if (!version || !version[0]) version = http1_1;
1176 if (!(request->version = strdupW( version ))) goto end;
1177 if (!(add_accept_types_header( request, types ))) goto end;
1178
1179 if (!(hrequest = alloc_handle( &request->hdr ))) goto end;
1180 request->hdr.handle = hrequest;
1181
1182 send_callback( &request->hdr, WINHTTP_CALLBACK_STATUS_HANDLE_CREATED, &hrequest, sizeof(hrequest) );
1183
1184end:
1187 TRACE("returning %p\n", hrequest);
1188 if (hrequest) SetLastError( ERROR_SUCCESS );
1189 return hrequest;
1190}
#define TRACE_ON(x)
Definition: compat.h:75
static const WCHAR version[]
Definition: asmname.c:66
static const WCHAR getW[]
Definition: object.c:50
static const struct object_vtbl request_vtbl
Definition: session.c:1080
static WCHAR * get_request_path(const WCHAR *object)
Definition: session.c:1101
static BOOL add_accept_types_header(struct request *request, const WCHAR **types)
Definition: session.c:1087
struct list task_queue
struct object_header hdr
#define WINHTTP_HANDLE_TYPE_REQUEST
Definition: winhttp.h:432
static const WCHAR http1_1[]

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

1254{
1255 BOOL ret = FALSE;
1256 struct object_header *hdr;
1257
1258 TRACE("%p, %u, %p, %p\n", handle, option, buffer, buflen);
1259
1260 if (!(hdr = grab_object( handle )))
1261 {
1263 return FALSE;
1264 }
1265
1266 ret = query_option( hdr, option, buffer, buflen );
1267
1270 return ret;
1271}
static BOOL query_option(struct object_header *hdr, DWORD option, void *buffer, DWORD *buflen)
Definition: session.c:1212

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

1949{
1950 LONG l;
1951 HKEY key;
1952 BOOL ret = FALSE;
1953 const WCHAR *src;
1954
1955 TRACE("%p\n", info);
1956
1957 if (!info)
1958 {
1960 return FALSE;
1961 }
1962 switch (info->dwAccessType)
1963 {
1965 break;
1967 if (!info->lpszProxy)
1968 {
1970 return FALSE;
1971 }
1972 /* Only ASCII characters are allowed */
1973 for (src = info->lpszProxy; *src; src++)
1974 if (*src > 0x7f)
1975 {
1977 return FALSE;
1978 }
1979 if (info->lpszProxyBypass)
1980 {
1981 for (src = info->lpszProxyBypass; *src; src++)
1982 if (*src > 0x7f)
1983 {
1985 return FALSE;
1986 }
1987 }
1988 break;
1989 default:
1991 return FALSE;
1992 }
1993
1995 KEY_WRITE, NULL, &key, NULL );
1996 if (!l)
1997 {
1998 DWORD size = sizeof(struct connection_settings_header) + 2 * sizeof(DWORD);
1999 BYTE *buf;
2000
2001 if (info->dwAccessType == WINHTTP_ACCESS_TYPE_NAMED_PROXY)
2002 {
2003 size += strlenW( info->lpszProxy );
2004 if (info->lpszProxyBypass)
2005 size += strlenW( info->lpszProxyBypass );
2006 }
2007 buf = heap_alloc( size );
2008 if (buf)
2009 {
2012 DWORD *len = (DWORD *)(hdr + 1);
2013
2014 hdr->magic = WINHTTP_SETTINGS_MAGIC;
2015 hdr->unknown = 0;
2016 if (info->dwAccessType == WINHTTP_ACCESS_TYPE_NAMED_PROXY)
2017 {
2018 BYTE *dst;
2019
2020 hdr->flags = PROXY_TYPE_PROXY;
2021 *len++ = strlenW( info->lpszProxy );
2022 for (dst = (BYTE *)len, src = info->lpszProxy; *src;
2023 src++, dst++)
2024 *dst = *src;
2025 len = (DWORD *)dst;
2026 if (info->lpszProxyBypass)
2027 {
2028 *len++ = strlenW( info->lpszProxyBypass );
2029 for (dst = (BYTE *)len, src = info->lpszProxyBypass; *src;
2030 src++, dst++)
2031 *dst = *src;
2032 }
2033 else
2034 *len++ = 0;
2035 }
2036 else
2037 {
2038 hdr->flags = PROXY_TYPE_DIRECT;
2039 *len++ = 0;
2040 *len++ = 0;
2041 }
2043 if (!l)
2044 ret = TRUE;
2045 heap_free( buf );
2046 }
2047 RegCloseKey( key );
2048 }
2050 return ret;
2051}
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:1096
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:4882
static const DWORD PROXY_TYPE_DIRECT
Definition: session.c:1513
#define KEY_WRITE
Definition: nt_native.h:1031

Referenced by test_set_default_proxy_config().

◆ WinHttpSetOption()

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

Definition at line 1312 of file session.c.

1313{
1314 BOOL ret = FALSE;
1315 struct object_header *hdr;
1316
1317 TRACE("%p, %u, %p, %u\n", handle, option, buffer, buflen);
1318
1319 if (!(hdr = grab_object( handle )))
1320 {
1322 return FALSE;
1323 }
1324
1325 ret = set_option( hdr, option, buffer, buflen );
1326
1329 return ret;
1330}
static BOOL set_option(struct object_header *hdr, DWORD option, void *buffer, DWORD buflen)
Definition: session.c:1273

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

2058{
2059 struct object_header *hdr;
2061
2062 TRACE("%p, %p, 0x%08x, 0x%lx\n", handle, callback, flags, reserved);
2063
2064 if (!(hdr = grab_object( handle )))
2065 {
2068 }
2069 ret = hdr->callback;
2070 hdr->callback = callback;
2071 hdr->notify_mask = flags;
2072
2075 return ret;
2076}
static IPrintDialogCallback callback
Definition: printdlg.c:326
#define WINHTTP_INVALID_STATUS_CALLBACK
Definition: winhttp.h:422
VOID(CALLBACK * WINHTTP_STATUS_CALLBACK)(_In_ HINTERNET, _In_ DWORD_PTR, _In_ DWORD, _In_ LPVOID, _In_ DWORD)
Definition: winhttp.h:520

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

2082{
2083 BOOL ret = TRUE;
2084 struct object_header *hdr;
2085
2086 TRACE("%p, %d, %d, %d, %d\n", handle, resolve, connect, send, receive);
2087
2088 if (resolve < -1 || connect < -1 || send < -1 || receive < -1)
2089 {
2091 return FALSE;
2092 }
2093
2094 if (!(hdr = grab_object( handle )))
2095 {
2097 return FALSE;
2098 }
2099
2100 switch(hdr->type)
2101 {
2103 {
2104 struct request *request = (struct request *)hdr;
2106
2107 if (resolve < 0) resolve = 0;
2108 request->resolve_timeout = resolve;
2109
2110 if (send < 0) send = 0;
2112
2113 if (receive < 0) receive = 0;
2114 request->receive_timeout = receive;
2115
2116 if (request->netconn)
2117 {
2119 if (netconn_set_timeout( request->netconn, FALSE, receive )) ret = FALSE;
2120 }
2121 break;
2122 }
2124 {
2125 struct session *session = (struct session *)hdr;
2127
2128 if (resolve < 0) resolve = 0;
2129 session->resolve_timeout = resolve;
2130
2131 if (send < 0) send = 0;
2133
2134 if (receive < 0) receive = 0;
2135 session->receive_timeout = receive;
2136 break;
2137 }
2138 default:
2140 ret = FALSE;
2141 }
2144 return ret;
2145}
DWORD netconn_set_timeout(struct netconn *netconn, BOOL send, int value)
Definition: net.c:596
INT WSAAPI send(IN SOCKET s, IN CONST CHAR FAR *buf, IN INT len, IN INT flags)
Definition: send.c:23

Referenced by request_set_parameters(), and test_timeouts().

◆ WinHttpTimeFromSystemTime()

BOOL WINAPI WinHttpTimeFromSystemTime ( const SYSTEMTIME time,
LPWSTR  string 
)

Definition at line 2158 of file session.c.

2159{
2160 static const WCHAR format[] =
2161 {'%','s',',',' ','%','0','2','d',' ','%','s',' ','%','4','d',' ','%','0',
2162 '2','d',':','%','0','2','d',':','%','0','2','d',' ','G','M','T', 0};
2163
2164 TRACE("%p, %p\n", time, string);
2165
2166 if (!time || !string)
2167 {
2169 return FALSE;
2170 }
2171
2172 sprintfW( string, format,
2173 wkday[time->wDayOfWeek],
2174 time->wDay,
2175 month[time->wMonth - 1],
2176 time->wYear,
2177 time->wHour,
2178 time->wMinute,
2179 time->wSecond );
2180
2182 return TRUE;
2183}
static const WCHAR wkday[7][4]
Definition: session.c:2147
static const WCHAR month[12][4]
Definition: session.c:2150
__u16 time
Definition: mkdosfs.c:8
#define sprintfW
Definition: unicode.h:64

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

◆ WinHttpTimeToSystemTime()

BOOL WINAPI WinHttpTimeToSystemTime ( LPCWSTR  string,
SYSTEMTIME time 
)

Definition at line 2188 of file session.c.

2189{
2190 unsigned int i;
2191 const WCHAR *s = string;
2192 WCHAR *end;
2193
2194 TRACE("%s, %p\n", debugstr_w(string), time);
2195
2196 if (!string || !time)
2197 {
2199 return FALSE;
2200 }
2201
2202 /* Windows does this too */
2204
2205 /* Convert an RFC1123 time such as 'Fri, 07 Jan 2005 12:06:35 GMT' into
2206 * a SYSTEMTIME structure.
2207 */
2208
2210
2211 while (*s && !isalphaW( *s )) s++;
2212 if (s[0] == '\0' || s[1] == '\0' || s[2] == '\0') return TRUE;
2213 time->wDayOfWeek = 7;
2214
2215 for (i = 0; i < 7; i++)
2216 {
2217 if (toupperW( wkday[i][0] ) == toupperW( s[0] ) &&
2218 toupperW( wkday[i][1] ) == toupperW( s[1] ) &&
2219 toupperW( wkday[i][2] ) == toupperW( s[2] ) )
2220 {
2221 time->wDayOfWeek = i;
2222 break;
2223 }
2224 }
2225
2226 if (time->wDayOfWeek > 6) return TRUE;
2227 while (*s && !isdigitW( *s )) s++;
2228 time->wDay = strtolW( s, &end, 10 );
2229 s = end;
2230
2231 while (*s && !isalphaW( *s )) s++;
2232 if (s[0] == '\0' || s[1] == '\0' || s[2] == '\0') return TRUE;
2233 time->wMonth = 0;
2234
2235 for (i = 0; i < 12; i++)
2236 {
2237 if (toupperW( month[i][0]) == toupperW( s[0] ) &&
2238 toupperW( month[i][1]) == toupperW( s[1] ) &&
2239 toupperW( month[i][2]) == toupperW( s[2] ) )
2240 {
2241 time->wMonth = i + 1;
2242 break;
2243 }
2244 }
2245 if (time->wMonth == 0) return TRUE;
2246
2247 while (*s && !isdigitW( *s )) s++;
2248 if (*s == '\0') return TRUE;
2249 time->wYear = strtolW( s, &end, 10 );
2250 s = end;
2251
2252 while (*s && !isdigitW( *s )) s++;
2253 if (*s == '\0') return TRUE;
2254 time->wHour = strtolW( s, &end, 10 );
2255 s = end;
2256
2257 while (*s && !isdigitW( *s )) s++;
2258 if (*s == '\0') return TRUE;
2259 time->wMinute = strtolW( s, &end, 10 );
2260 s = end;
2261
2262 while (*s && !isdigitW( *s )) s++;
2263 if (*s == '\0') return TRUE;
2264 time->wSecond = strtolW( s, &end, 10 );
2265
2266 time->wMilliseconds = 0;
2267 return TRUE;
2268}
VOID WINAPI GetSystemTime(OUT LPSYSTEMTIME lpSystemTime)
Definition: time.c:327
GLdouble s
Definition: gl.h:2039
char string[160]
Definition: util.h:11
#define toupperW(n)
Definition: unicode.h:51
#define isdigitW(n)
Definition: unicode.h:56
#define strtolW(s, e, b)
Definition: unicode.h:39
#define isalphaW(n)
Definition: unicode.h:54

Referenced by query_headers(), and test_WinHttpTimeToSystemTime().

Variable Documentation

◆ connect_vtbl

const struct object_vtbl connect_vtbl
static
Initial value:
=
{
}
static void connect_destroy(struct object_header *hdr)
Definition: session.c:318
static BOOL connect_query_option(struct object_header *hdr, DWORD option, void *buffer, DWORD *buflen)
Definition: session.c:333

Definition at line 384 of file session.c.

Referenced by WinHttpConnect().

◆ Connections

const WCHAR Connections[]
static
Initial value:
= {
'S','o','f','t','w','a','r','e','\\',
'M','i','c','r','o','s','o','f','t','\\',
'W','i','n','d','o','w','s','\\',
'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
'I','n','t','e','r','n','e','t',' ','S','e','t','t','i','n','g','s','\\',
'C','o','n','n','e','c','t','i','o','n','s',0 }

Definition at line 1502 of file session.c.

Referenced by BuildUSBAudioFilterTopology(), WinHttpGetDefaultProxyConfiguration(), WinHttpGetIEProxyConfigForCurrentUser(), and WinHttpSetDefaultProxyConfiguration().

◆ month

◆ PROXY_AUTODETECT_SETTINGS

const DWORD PROXY_AUTODETECT_SETTINGS = 8
static

Definition at line 1516 of file session.c.

Referenced by WinHttpGetIEProxyConfigForCurrentUser().

◆ PROXY_TYPE_DIRECT

const DWORD PROXY_TYPE_DIRECT = 1
static

Definition at line 1513 of file session.c.

Referenced by WinHttpSetDefaultProxyConfiguration().

◆ PROXY_TYPE_PROXY

◆ PROXY_USE_PAC_SCRIPT

const DWORD PROXY_USE_PAC_SCRIPT = 4
static

Definition at line 1515 of file session.c.

Referenced by WinHttpGetIEProxyConfigForCurrentUser().

◆ request_vtbl

const struct object_vtbl request_vtbl
static
Initial value:
=
{
}
static BOOL request_set_option(struct object_header *hdr, DWORD option, void *buffer, DWORD buflen)
Definition: session.c:889
static BOOL request_query_option(struct object_header *hdr, DWORD option, void *buffer, DWORD *buflen)
Definition: session.c:710
static void request_destroy(struct object_header *hdr)
Definition: session.c:604

Definition at line 1080 of file session.c.

Referenced by WinHttpOpenRequest().

◆ session_vtbl

const struct object_vtbl session_vtbl
static
Initial value:
=
{
}
static void session_destroy(struct object_header *hdr)
Definition: session.c:77
static BOOL session_set_option(struct object_header *hdr, DWORD option, void *buffer, DWORD buflen)
Definition: session.c:147
static BOOL session_query_option(struct object_header *hdr, DWORD option, void *buffer, DWORD *buflen)
Definition: session.c:96

Definition at line 236 of file session.c.

Referenced by WinHttpOpen().

◆ WINHTTP_SETTINGS_MAGIC

const DWORD WINHTTP_SETTINGS_MAGIC = 0x18
static

◆ WinHttpSettings

const WCHAR WinHttpSettings[]
static
Initial value:
= {
'W','i','n','H','t','t','p','S','e','t','t','i','n','g','s',0 }

Definition at line 1509 of file session.c.

Referenced by WinHttpGetDefaultProxyConfiguration(), and WinHttpSetDefaultProxyConfiguration().

◆ WININET_SETTINGS_MAGIC

const DWORD WININET_SETTINGS_MAGIC = 0x46
static

Definition at line 1512 of file session.c.

Referenced by WinHttpGetIEProxyConfigForCurrentUser().

◆ wkday

const WCHAR wkday[7][4]
static
Initial value:
=
{{'S','u','n', 0}, {'M','o','n', 0}, {'T','u','e', 0}, {'W','e','d', 0},
{'T','h','u', 0}, {'F','r','i', 0}, {'S','a','t', 0}}

Definition at line 2147 of file session.c.

Referenced by WinHttpTimeFromSystemTime(), and WinHttpTimeToSystemTime().