ReactOS 0.4.16-dev-109-gf4cb10f
internet.h File Reference
#include "wine/heap.h"
#include "wine/list.h"
#include <time.h>
#include "winineti.h"
Include dependency graph for internet.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  server_t
 
struct  netconn_t
 
struct  substr_t
 
struct  req_file_t
 
struct  object_vtbl_t
 
struct  _object_header_t
 
struct  appinfo_t
 
struct  http_session_t
 
struct  HTTPHEADERW
 
struct  data_stream_t
 
struct  netconn_stream_t
 
struct  http_request_t
 
struct  task_header_t
 
struct  wininet_flag_info
 

Macros

#define INET_OPENURL   0x0001
 
#define INET_CALLBACKW   0x0002
 
#define INTERNET_HANDLE_IN_USE   1
 
#define HDR_ISREQUEST   0x0001
 
#define HDR_COMMADELIMITED   0x0002
 
#define HDR_SEMIDELIMITED   0x0004
 
#define READ_BUFFER_SIZE   8192
 
#define MAX_REPLY_LEN   0x5B4
 
#define _SECURITY_FLAG_CERT_REV_FAILED   0x00800000
 
#define _SECURITY_FLAG_CERT_INVALID_CA   0x01000000
 
#define _SECURITY_FLAG_CERT_INVALID_CN   0x02000000
 
#define _SECURITY_FLAG_CERT_INVALID_DATE   0x04000000
 
#define _SECURITY_ERROR_FLAGS_MASK
 

Typedefs

typedef struct _object_header_t object_header_t
 
typedef struct HTTPHEADERWLPHTTPHEADERW
 
typedef struct data_stream_vtbl_t data_stream_vtbl_t
 
typedef struct task_header_t task_header_t
 
typedef void(* async_task_proc_t) (task_header_t *)
 

Enumerations

enum  collect_type_t { COLLECT_TIMEOUT , COLLECT_CONNECTIONS , COLLECT_CLEANUP }
 
enum  WH_TYPE {
  WH_HINIT = INTERNET_HANDLE_TYPE_INTERNET , WH_HFTPSESSION = INTERNET_HANDLE_TYPE_CONNECT_FTP , WH_HGOPHERSESSION = INTERNET_HANDLE_TYPE_CONNECT_GOPHER , WH_HHTTPSESSION = INTERNET_HANDLE_TYPE_CONNECT_HTTP ,
  WH_HFILE = INTERNET_HANDLE_TYPE_FTP_FILE , WH_HFTPFINDNEXT = INTERNET_HANDLE_TYPE_FTP_FIND , WH_HHTTPREQ = INTERNET_HANDLE_TYPE_HTTP_REQUEST
}
 

Functions

void server_addref (server_t *) DECLSPEC_HIDDEN
 
void server_release (server_t *) DECLSPEC_HIDDEN
 
BOOL collect_connections (collect_type_t) DECLSPEC_HIDDEN
 
BOOL is_valid_netconn (netconn_t *) DECLSPEC_HIDDEN
 
void close_netconn (netconn_t *) DECLSPEC_HIDDEN
 
static void__WINE_ALLOC_SIZE (2) heap_realloc_zero(void *mem
 
static LPWSTR heap_strdupW (LPCWSTR str)
 
static charheap_strdupA (const char *str)
 
static LPWSTR heap_strndupW (LPCWSTR str, UINT max_len)
 
static WCHARheap_strndupAtoW (const char *str, int len_a, DWORD *len_w)
 
static WCHARheap_strdupAtoW (const char *str)
 
static charheap_strdupWtoA (LPCWSTR str)
 
static substr_t substr (const WCHAR *str, size_t len)
 
static substr_t substrz (const WCHAR *str)
 
static void WININET_find_data_WtoA (LPWIN32_FIND_DATAW dataW, LPWIN32_FIND_DATAA dataA)
 
voidalloc_async_task (object_header_t *, async_task_proc_t, size_t) DECLSPEC_HIDDEN
 
voidalloc_object (object_header_t *, const object_vtbl_t *, size_t) DECLSPEC_HIDDEN
 
object_header_tget_handle_object (HINTERNET hinternet) DECLSPEC_HIDDEN
 
object_header_tWININET_AddRef (object_header_t *info) DECLSPEC_HIDDEN
 
BOOL WININET_Release (object_header_t *info) DECLSPEC_HIDDEN
 
DWORD INET_QueryOption (object_header_t *, DWORD, void *, DWORD *, BOOL) DECLSPEC_HIDDEN
 
DWORD INET_SetOption (object_header_t *, DWORD, void *, DWORD) DECLSPEC_HIDDEN
 
time_t ConvertTimeString (LPCWSTR asctime) DECLSPEC_HIDDEN
 
HINTERNET FTP_Connect (appinfo_t *hIC, LPCWSTR lpszServerName, INTERNET_PORT nServerPort, LPCWSTR lpszUserName, LPCWSTR lpszPassword, DWORD dwFlags, DWORD_PTR dwContext, DWORD dwInternalFlags) DECLSPEC_HIDDEN
 
DWORD HTTP_Connect (appinfo_t *, LPCWSTR, INTERNET_PORT nServerPort, LPCWSTR lpszUserName, LPCWSTR lpszPassword, DWORD dwFlags, DWORD_PTR dwContext, DWORD dwInternalFlags, HINTERNET *) DECLSPEC_HIDDEN
 
BOOL GetAddress (const WCHAR *, INTERNET_PORT, SOCKADDR *, int *, char *) DECLSPEC_HIDDEN
 
DWORD get_cookie_header (const WCHAR *, const WCHAR *, WCHAR **) DECLSPEC_HIDDEN
 
DWORD set_cookie (substr_t, substr_t, substr_t, substr_t, DWORD) DECLSPEC_HIDDEN
 
void INTERNET_SetLastError (DWORD dwError) DECLSPEC_HIDDEN
 
DWORD INTERNET_GetLastError (void) DECLSPEC_HIDDEN
 
DWORD INTERNET_AsyncCall (task_header_t *) DECLSPEC_HIDDEN
 
LPSTR INTERNET_GetResponseBuffer (void) DECLSPEC_HIDDEN
 
VOID INTERNET_SendCallback (object_header_t *hdr, DWORD_PTR dwContext, DWORD dwInternetStatus, LPVOID lpvStatusInfo, DWORD dwStatusInfoLength) DECLSPEC_HIDDEN
 
WCHARINTERNET_FindProxyForProtocol (LPCWSTR szProxy, LPCWSTR proto) DECLSPEC_HIDDEN
 
DWORD create_netconn (server_t *, DWORD, BOOL, DWORD, netconn_t **) DECLSPEC_HIDDEN
 
void free_netconn (netconn_t *) DECLSPEC_HIDDEN
 
void NETCON_unload (void) DECLSPEC_HIDDEN
 
DWORD NETCON_secure_connect (netconn_t *, server_t *) DECLSPEC_HIDDEN
 
DWORD NETCON_send (netconn_t *connection, const void *msg, size_t len, int flags, int *sent) DECLSPEC_HIDDEN
 
DWORD NETCON_recv (netconn_t *, void *, size_t, BOOL, int *) DECLSPEC_HIDDEN
 
BOOL NETCON_is_alive (netconn_t *) DECLSPEC_HIDDEN
 
LPCVOID NETCON_GetCert (netconn_t *connection) DECLSPEC_HIDDEN
 
int NETCON_GetCipherStrength (netconn_t *) DECLSPEC_HIDDEN
 
DWORD NETCON_set_timeout (netconn_t *connection, BOOL send, DWORD value) DECLSPEC_HIDDEN
 
int sock_send (int fd, const void *msg, size_t len, int flags) DECLSPEC_HIDDEN
 
int sock_recv (int fd, void *msg, size_t len, int flags) DECLSPEC_HIDDEN
 
server_tget_server (substr_t, INTERNET_PORT, BOOL, BOOL) DECLSPEC_HIDDEN
 
DWORD create_req_file (const WCHAR *, req_file_t **) DECLSPEC_HIDDEN
 
void req_file_release (req_file_t *) DECLSPEC_HIDDEN
 
static req_file_treq_file_addref (req_file_t *req_file)
 
BOOL init_urlcache (void) DECLSPEC_HIDDEN
 
void free_urlcache (void) DECLSPEC_HIDDEN
 
void free_cookie (void) DECLSPEC_HIDDEN
 
void free_authorization_cache (void) DECLSPEC_HIDDEN
 
void init_winsock (void) DECLSPEC_HIDDEN
 

Variables

HMODULE WININET_hModule DECLSPEC_HIDDEN
 
static void size_t len
 

Macro Definition Documentation

◆ _SECURITY_ERROR_FLAGS_MASK

#define _SECURITY_ERROR_FLAGS_MASK
Value:
#define _SECURITY_FLAG_CERT_REV_FAILED
Definition: internet.h:472
#define _SECURITY_FLAG_CERT_INVALID_CN
Definition: internet.h:474
#define _SECURITY_FLAG_CERT_INVALID_DATE
Definition: internet.h:475
#define _SECURITY_FLAG_CERT_INVALID_CA
Definition: internet.h:473

Definition at line 477 of file internet.h.

◆ _SECURITY_FLAG_CERT_INVALID_CA

#define _SECURITY_FLAG_CERT_INVALID_CA   0x01000000

Definition at line 473 of file internet.h.

◆ _SECURITY_FLAG_CERT_INVALID_CN

#define _SECURITY_FLAG_CERT_INVALID_CN   0x02000000

Definition at line 474 of file internet.h.

◆ _SECURITY_FLAG_CERT_INVALID_DATE

#define _SECURITY_FLAG_CERT_INVALID_DATE   0x04000000

Definition at line 475 of file internet.h.

◆ _SECURITY_FLAG_CERT_REV_FAILED

#define _SECURITY_FLAG_CERT_REV_FAILED   0x00800000

Definition at line 472 of file internet.h.

◆ HDR_COMMADELIMITED

#define HDR_COMMADELIMITED   0x0002

Definition at line 315 of file internet.h.

◆ HDR_ISREQUEST

#define HDR_ISREQUEST   0x0001

Definition at line 314 of file internet.h.

◆ HDR_SEMIDELIMITED

#define HDR_SEMIDELIMITED   0x0004

Definition at line 316 of file internet.h.

◆ INET_CALLBACKW

#define INET_CALLBACKW   0x0002

Definition at line 244 of file internet.h.

◆ INET_OPENURL

#define INET_OPENURL   0x0001

Definition at line 243 of file internet.h.

◆ INTERNET_HANDLE_IN_USE

#define INTERNET_HANDLE_IN_USE   1

Definition at line 269 of file internet.h.

◆ MAX_REPLY_LEN

#define MAX_REPLY_LEN   0x5B4

Definition at line 462 of file internet.h.

◆ READ_BUFFER_SIZE

#define READ_BUFFER_SIZE   8192

Definition at line 341 of file internet.h.

Typedef Documentation

◆ async_task_proc_t

typedef void(* async_task_proc_t) (task_header_t *)

Definition at line 385 of file internet.h.

◆ data_stream_vtbl_t

Definition at line 329 of file internet.h.

◆ LPHTTPHEADERW

◆ object_header_t

Definition at line 255 of file internet.h.

◆ task_header_t

Definition at line 384 of file internet.h.

Enumeration Type Documentation

◆ collect_type_t

Enumerator
COLLECT_TIMEOUT 
COLLECT_CONNECTIONS 
COLLECT_CLEANUP 

Definition at line 59 of file internet.h.

59 {
collect_type_t
Definition: internet.h:59
@ COLLECT_TIMEOUT
Definition: internet.h:60
@ COLLECT_CONNECTIONS
Definition: internet.h:61
@ COLLECT_CLEANUP
Definition: internet.h:62

◆ WH_TYPE

Enumerator
WH_HINIT 
WH_HFTPSESSION 
WH_HGOPHERSESSION 
WH_HHTTPSESSION 
WH_HFILE 
WH_HFTPFINDNEXT 
WH_HHTTPREQ 

Definition at line 232 of file internet.h.

233{
241} WH_TYPE;
WH_TYPE
Definition: internet.h:233
@ WH_HFILE
Definition: internet.h:238
@ WH_HHTTPSESSION
Definition: internet.h:237
@ WH_HGOPHERSESSION
Definition: internet.h:236
@ WH_HFTPFINDNEXT
Definition: internet.h:239
@ WH_HHTTPREQ
Definition: internet.h:240
@ WH_HFTPSESSION
Definition: internet.h:235
@ WH_HINIT
Definition: internet.h:234
#define INTERNET_HANDLE_TYPE_CONNECT_GOPHER
Definition: wininet.h:804
#define INTERNET_HANDLE_TYPE_HTTP_REQUEST
Definition: wininet.h:814
#define INTERNET_HANDLE_TYPE_FTP_FIND
Definition: wininet.h:806
#define INTERNET_HANDLE_TYPE_INTERNET
Definition: wininet.h:802
#define INTERNET_HANDLE_TYPE_CONNECT_HTTP
Definition: wininet.h:805
#define INTERNET_HANDLE_TYPE_CONNECT_FTP
Definition: wininet.h:803
#define INTERNET_HANDLE_TYPE_FTP_FILE
Definition: wininet.h:808

Function Documentation

◆ __WINE_ALLOC_SIZE()

static void * __WINE_ALLOC_SIZE ( )
inlinestatic

◆ alloc_async_task()

void * alloc_async_task ( object_header_t hdr,
async_task_proc_t  proc,
size_t  size 
)

Definition at line 3894 of file internet.c.

3895{
3896 task_header_t *task;
3897
3898 task = heap_alloc(size);
3899 if(!task)
3900 return NULL;
3901
3902 task->hdr = WININET_AddRef(hdr);
3903 task->proc = proc;
3904 return task;
3905}
static void * heap_alloc(size_t len)
Definition: appwiz.h:66
#define NULL
Definition: types.h:112
object_header_t * WININET_AddRef(object_header_t *info)
Definition: internet.c:169
GLsizeiptr size
Definition: glext.h:5919
char hdr[14]
Definition: iptest.cpp:33
static HANDLE proc()
Definition: pdb.c:34
object_header_t * hdr
Definition: internet.h:390
async_task_proc_t proc
Definition: internet.h:389

Referenced by async_read(), FtpCreateDirectoryW(), FtpDeleteFileW(), FTPFILE_QueryDataAvailable(), FtpFindFirstFileW(), FTPFINDNEXT_FindNextFileW(), FtpGetCurrentDirectoryW(), FtpGetFileW(), FtpOpenFileW(), FtpPutFileW(), FtpRemoveDirectoryW(), FtpRenameFileW(), FtpSetCurrentDirectoryW(), HttpEndRequestW(), HttpSendRequestExW(), HttpSendRequestW(), and InternetOpenUrlW().

◆ alloc_object()

void * alloc_object ( object_header_t parent,
const object_vtbl_t vtbl,
size_t  size 
)

Definition at line 103 of file internet.c.

104{
105 UINT_PTR handle = 0, num;
108 BOOL res = TRUE;
109
110 ret = heap_alloc_zero(size);
111 if(!ret)
112 return NULL;
113
114 list_init(&ret->children);
115
117
118 if(!handle_table_size) {
119 num = 16;
120 p = heap_alloc_zero(sizeof(handle_table[0]) * num);
121 if(p) {
122 handle_table = p;
124 next_handle = 1;
125 }else {
126 res = FALSE;
127 }
128 }else if(next_handle == handle_table_size) {
130 p = heap_realloc_zero(handle_table, sizeof(handle_table[0]) * num);
131 if(p) {
132 handle_table = p;
134 }else {
135 res = FALSE;
136 }
137 }
138
139 if(res) {
142 ERR("handle isn't free but should be\n");
144 ret->valid_handle = TRUE;
145
147 next_handle++;
148 }
149
151
152 if(!res) {
153 heap_free(ret);
154 return NULL;
155 }
156
157 ret->vtbl = vtbl;
158 ret->refs = 1;
159 ret->hInternet = (HINTERNET)handle;
160
161 if(parent) {
162 ret->lpfnStatusCB = parent->lpfnStatusCB;
163 ret->dwInternalFlags = parent->dwInternalFlags & INET_CALLBACKW;
164 }
165
166 return ret;
167}
static BOOL heap_free(void *mem)
Definition: appwiz.h:76
static void list_init(struct list_entry *head)
Definition: list.h:51
#define ERR(fmt,...)
Definition: precomp.h:57
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
static UINT_PTR next_handle
Definition: internet.c:85
static CRITICAL_SECTION WININET_cs
Definition: internet.c:75
static UINT_PTR handle_table_size
Definition: internet.c:86
r parent
Definition: btrfs.c:3010
unsigned int BOOL
Definition: ntddk_ex.h:94
GLuint res
Definition: glext.h:9613
GLfloat GLfloat p
Definition: glext.h:8902
GLuint GLuint num
Definition: glext.h:9618
#define INET_CALLBACKW
Definition: internet.h:244
unsigned __int3264 UINT_PTR
Definition: mstsclib_h.h:274
int ret
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
LPVOID HINTERNET
Definition: winhttp.h:32

Referenced by FTP_Connect(), FTP_FtpOpenFileW(), FTP_ReceiveFileList(), HTTP_Connect(), HTTP_HttpOpenRequestW(), and InternetOpenW().

◆ close_netconn()

void close_netconn ( netconn_t netconn)

Definition at line 379 of file netconnection.c.

380{
382 netconn->socket = -1;
383}
#define closesocket
Definition: ncftp.h:477

Referenced by free_netconn(), and http_release_netconn().

◆ collect_connections()

BOOL collect_connections ( collect_type_t  collect_type)

Definition at line 235 of file http.c.

236{
237 netconn_t *netconn, *netconn_safe;
238 server_t *server, *server_safe;
239 BOOL remaining = FALSE;
240 DWORD64 now;
241
242#ifdef __REACTOS__
243 now = GetTickCount();
244#else
246#endif
247
249 LIST_FOR_EACH_ENTRY_SAFE(netconn, netconn_safe, &server->conn_pool, netconn_t, pool_entry) {
250 if(collect_type > COLLECT_TIMEOUT || netconn->keep_until < now) {
251 TRACE("freeing %p\n", netconn);
252 list_remove(&netconn->pool_entry);
254 }else {
255 remaining = TRUE;
256 }
257 }
258
259 if(collect_type == COLLECT_CLEANUP) {
260 list_remove(&server->entry);
261 list_init(&server->entry);
263 }
264 }
265
266 return remaining;
267}
ULONGLONG WINAPI GetTickCount64(VOID)
Definition: GetTickCount64.c:9
static void list_remove(struct list_entry *entry)
Definition: list.h:90
DWORD WINAPI GetTickCount(VOID)
Definition: time.c:455
static struct list connection_pool
Definition: http.c:146
void server_release(server_t *server)
Definition: http.c:154
time_t now
Definition: finger.c:65
void free_netconn(netconn_t *) DECLSPEC_HIDDEN
uint32_t entry
Definition: isohybrid.c:63
#define LIST_FOR_EACH_ENTRY_SAFE(cursor, cursor2, list, type, field)
Definition: list.h:204
#define TRACE(s)
Definition: solgame.cpp:4
ULONGLONG keep_until
uint64_t DWORD64
Definition: typedefs.h:67
static rfbScreenInfoPtr server
Definition: vnc.c:74

Referenced by collect_connections_proc(), DllMain(), and INET_SetOption().

◆ ConvertTimeString()

time_t ConvertTimeString ( LPCWSTR  asctime)

Definition at line 49 of file utility.c.

50{
51 WCHAR tmpChar[TIME_STRING_LEN];
52 WCHAR *tmpChar2;
53 struct tm t;
54 int timelen = lstrlenW(asctime);
55
56 if(!timelen)
57 return 0;
58
59 /* FIXME: the atoiWs below rely on that tmpChar is \0 padded */
60 memset( tmpChar, 0, sizeof(tmpChar) );
62
63 /* Assert that the string is the expected length */
65
66 /* Convert a time such as 'Mon, 15 Nov 1999 16:09:35 GMT' into a SYSTEMTIME structure
67 * We assume the time is in this format
68 * and divide it into easy to swallow chunks
69 */
70 tmpChar[3]='\0';
71 tmpChar[7]='\0';
72 tmpChar[11]='\0';
73 tmpChar[16]='\0';
74 tmpChar[19]='\0';
75 tmpChar[22]='\0';
76 tmpChar[25]='\0';
77
78 memset( &t, 0, sizeof(t) );
79 t.tm_year = wcstol(tmpChar+12, NULL, 10) - 1900;
80 t.tm_mday = wcstol(tmpChar+5, NULL, 10);
81 t.tm_hour = wcstol(tmpChar+17, NULL, 10);
82 t.tm_min = wcstol(tmpChar+20, NULL, 10);
83 t.tm_sec = wcstol(tmpChar+23, NULL, 10);
84
85 /* and month */
86 tmpChar2 = tmpChar + 8;
87 switch(tmpChar2[2])
88 {
89 case 'n':
90 if(tmpChar2[1]=='a')
91 t.tm_mon = 0;
92 else
93 t.tm_mon = 5;
94 break;
95 case 'b':
96 t.tm_mon = 1;
97 break;
98 case 'r':
99 if(tmpChar2[1]=='a')
100 t.tm_mon = 2;
101 else
102 t.tm_mon = 3;
103 break;
104 case 'y':
105 t.tm_mon = 4;
106 break;
107 case 'l':
108 t.tm_mon = 6;
109 break;
110 case 'g':
111 t.tm_mon = 7;
112 break;
113 case 'p':
114 t.tm_mon = 8;
115 break;
116 case 't':
117 t.tm_mon = 9;
118 break;
119 case 'v':
120 t.tm_mon = 10;
121 break;
122 case 'c':
123 t.tm_mon = 11;
124 break;
125 default:
126 FIXME("\n");
127 }
128
129 return mktime(&t);
130}
#define FIXME(fmt,...)
Definition: precomp.h:53
#define lstrcpynW
Definition: compat.h:738
#define lstrlenW
Definition: compat.h:750
#define TIME_STRING_LEN
Definition: utility.c:47
GLdouble GLdouble t
Definition: gl.h:2047
_Check_return_ long __cdecl wcstol(_In_z_ const wchar_t *_Str, _Out_opt_ _Deref_post_z_ wchar_t **_EndPtr, _In_ int _Radix)
_Check_return_ _CRTIMP char *__cdecl asctime(_In_ const struct tm *_Tm)
_CRTIMP time_t __cdecl mktime(struct tm *_Tm)
Definition: time.h:418
#define memset(x, y, z)
Definition: compat.h:39
Definition: time.h:68
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by HTTP_HttpQueryInfoW().

◆ create_netconn()

DWORD create_netconn ( server_t server,
DWORD  security_flags,
BOOL  mask_errors,
DWORD  timeout,
netconn_t **  ret 
)

Definition at line 347 of file netconnection.c.

348{
350 int result;
351
352 netconn = heap_alloc_zero(sizeof(*netconn));
353 if(!netconn)
354 return ERROR_OUTOFMEMORY;
355
356 netconn->socket = -1;
357 netconn->security_flags = security_flags | server->security_flags;
358 netconn->mask_errors = mask_errors;
359 list_init(&netconn->pool_entry);
361
363 if (result != ERROR_SUCCESS) {
365 return result;
366 }
367
369 netconn->server = server;
370 *ret = netconn;
371 return result;
372}
#define ERROR_OUTOFMEMORY
Definition: deptool.c:13
#define ERROR_SUCCESS
Definition: deptool.c:10
void server_addref(server_t *server)
Definition: http.c:149
GLuint64EXT * result
Definition: glext.h:11304
static DWORD create_netconn_socket(server_t *server, netconn_t *netconn, DWORD timeout)
#define SecInvalidateHandle(x)
Definition: sspi.h:58
CtxtHandle ssl_ctx
Definition: dhcpd.h:245

Referenced by open_http_connection().

◆ create_req_file()

DWORD create_req_file ( const WCHAR file_name,
req_file_t **  ret 
)

Definition at line 3988 of file internet.c.

3989{
3990 req_file_t *req_file;
3991
3992 req_file = heap_alloc_zero(sizeof(*req_file));
3993 if(!req_file)
3995
3996 req_file->ref = 1;
3997
3998 req_file->file_name = heap_strdupW(file_name);
3999 if(!req_file->file_name) {
4000 heap_free(req_file);
4002 }
4003
4006 if(req_file->file_handle == INVALID_HANDLE_VALUE) {
4007 req_file_release(req_file);
4008 return GetLastError();
4009 }
4010
4011 *ret = req_file;
4012 return ERROR_SUCCESS;
4013}
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
static WCHAR * heap_strdupW(const WCHAR *str)
Definition: edit.c:4312
#define OPEN_EXISTING
Definition: compat.h:775
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define GENERIC_READ
Definition: compat.h:135
#define CreateFileW
Definition: compat.h:741
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:137
#define FILE_SHARE_READ
Definition: compat.h:136
void req_file_release(req_file_t *req_file)
Definition: internet.c:4015
static LPCWSTR file_name
Definition: protocol.c:147
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
LONG ref
Definition: internet.h:248
WCHAR * file_name
Definition: internet.h:250
HANDLE file_handle
Definition: internet.h:249
DWORD WINAPI GetLastError(void)
Definition: except.c:1042

Referenced by create_cache_entry().

◆ free_authorization_cache()

void free_authorization_cache ( void  )

Definition at line 943 of file http.c.

944{
945 authorizationData *ad, *sa_safe;
946 basicAuthorizationData *basic, *basic_safe;
947
949
951 {
952 heap_free(basic->host);
953 heap_free(basic->realm);
954 heap_free(basic->authorization);
955
956 list_remove(&basic->entry);
957 heap_free(basic);
958 }
959
961 {
962 heap_free(ad->host);
963 heap_free(ad->scheme);
964 heap_free(ad->user);
965 heap_free(ad->password);
966 heap_free(ad->domain);
967 list_remove(&ad->entry);
968 heap_free(ad);
969 }
970
972}
static struct list authorizationCache
Definition: http.c:115
static struct list basicAuthorizationCache
Definition: http.c:114
static CRITICAL_SECTION authcache_cs
Definition: http.c:117
struct list entry
Definition: http.c:102
LPWSTR password
Definition: http.c:110
LPWSTR domain
Definition: http.c:106
LPWSTR host
Definition: http.c:104
LPWSTR scheme
Definition: http.c:105
LPWSTR user
Definition: http.c:108
struct list entry
Definition: http.c:92

Referenced by InternetSetOptionW().

◆ free_cookie()

void free_cookie ( void  )

Definition at line 1269 of file cookie.c.

1270{
1272
1274
1276}
static struct list domain_list
Definition: cookie.c:100
static CRITICAL_SECTION cookie_cs
Definition: cookie.c:92
static void free_cookie_domain_list(struct list *list)
Definition: cookie.c:689

Referenced by delete_cookie(), DllMain(), InternetSetOptionW(), parse_cookie(), and set_cookies().

◆ free_netconn()

void free_netconn ( netconn_t netconn)

Definition at line 385 of file netconnection.c.

386{
387 server_release(netconn->server);
388
389 if (netconn->secure) {
393 netconn->peek_len = 0;
398 netconn->extra_len = 0;
399 }
402
405}
void close_netconn(netconn_t *netconn)
#define SecIsValidHandle(x)
Definition: sspi.h:63
char * peek_msg
char * extra_buf
char * peek_msg_mem
char * ssl_buf
size_t extra_len
size_t peek_len
SECURITY_STATUS WINAPI DeleteSecurityContext(PCtxtHandle phContext)
Definition: wrapper.c:450

Referenced by collect_connections(), and open_http_connection().

◆ free_urlcache()

void free_urlcache ( void  )

Definition at line 4130 of file urlcache.c.

4131{
4137
4139}
#define CloseHandle
Definition: compat.h:739
static void cache_containers_free(void)
Definition: urlcache.c:827
static HANDLE free_cache_running
Definition: urlcache.c:2241
static HANDLE dll_unload_event
Definition: urlcache.c:2242
#define INFINITE
Definition: serial.h:102
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent(IN HANDLE hEvent)
Definition: synch.c:733
BOOL WINAPI DECLSPEC_HOTPATCH ReleaseSemaphore(IN HANDLE hSemaphore, IN LONG lReleaseCount, IN LPLONG lpPreviousCount)
Definition: synch.c:542

Referenced by DllMain().

◆ FTP_Connect()

HINTERNET FTP_Connect ( appinfo_t hIC,
LPCWSTR  lpszServerName,
INTERNET_PORT  nServerPort,
LPCWSTR  lpszUserName,
LPCWSTR  lpszPassword,
DWORD  dwFlags,
DWORD_PTR  dwContext,
DWORD  dwInternalFlags 
)

Definition at line 2428 of file ftp.c.

2432{
2433 struct sockaddr_in socketAddr;
2434 INT nsocket = -1;
2435 socklen_t sock_namelen;
2437 ftp_session_t *lpwfs = NULL;
2438 char szaddr[INET6_ADDRSTRLEN];
2439
2440 TRACE("%p Server(%s) Port(%d) User(%s) Paswd(%s)\n",
2441 hIC, debugstr_w(lpszServerName),
2442 nServerPort, debugstr_w(lpszUserName), debugstr_w(lpszPassword));
2443
2444 assert( hIC->hdr.htype == WH_HINIT );
2445
2446 if ((!lpszUserName || !*lpszUserName) && lpszPassword && *lpszPassword)
2447 {
2449 return NULL;
2450 }
2451
2452 lpwfs = alloc_object(&hIC->hdr, &FTPSESSIONVtbl, sizeof(ftp_session_t));
2453 if (NULL == lpwfs)
2454 {
2456 return NULL;
2457 }
2458
2459 if (nServerPort == INTERNET_INVALID_PORT_NUMBER)
2461 else
2462 lpwfs->serverport = nServerPort;
2463
2464 lpwfs->hdr.htype = WH_HFTPSESSION;
2465 lpwfs->hdr.dwFlags = dwFlags;
2466 lpwfs->hdr.dwContext = dwContext;
2467 lpwfs->hdr.dwInternalFlags |= dwInternalFlags;
2468 lpwfs->download_in_progress = NULL;
2469 lpwfs->sndSocket = -1;
2470 lpwfs->lstnSocket = -1;
2471 lpwfs->pasvSocket = -1;
2472
2473 WININET_AddRef( &hIC->hdr );
2474 lpwfs->lpAppInfo = hIC;
2475 list_add_head( &hIC->hdr.children, &lpwfs->hdr.entry );
2476
2477 if(hIC->proxy && hIC->accessType == INTERNET_OPEN_TYPE_PROXY) {
2478 if(wcschr(hIC->proxy, ' '))
2479 FIXME("Several proxies not implemented.\n");
2480 if(hIC->proxyBypass)
2481 FIXME("Proxy bypass is ignored.\n");
2482 }
2483 if (!lpszUserName || !lpszUserName[0]) {
2484 HKEY key;
2485 WCHAR szPassword[MAX_PATH];
2486 DWORD len = sizeof(szPassword);
2487
2488 lpwfs->lpszUserName = heap_strdupW(L"anonymous");
2489
2490 RegOpenKeyW(HKEY_CURRENT_USER, L"Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings", &key);
2491 if (RegQueryValueExW(key, L"EmailName", NULL, NULL, (LPBYTE)szPassword, &len)) {
2492 /* Nothing in the registry, get the username and use that as the password */
2493 if (!GetUserNameW(szPassword, &len)) {
2494 /* Should never get here, but use an empty password as failsafe */
2495 lstrcpyW(szPassword, L"");
2496 }
2497 }
2499
2500 TRACE("Password used for anonymous ftp : (%s)\n", debugstr_w(szPassword));
2501 lpwfs->lpszPassword = heap_strdupW(szPassword);
2502 }
2503 else {
2504 lpwfs->lpszUserName = heap_strdupW(lpszUserName);
2506 }
2507 lpwfs->servername = heap_strdupW(lpszServerName);
2508
2509 /* Don't send a handle created callback if this handle was created with InternetOpenUrl */
2510 if (!(lpwfs->hdr.dwInternalFlags & INET_OPENURL))
2511 {
2513
2514 iar.dwResult = (DWORD_PTR)lpwfs->hdr.hInternet;
2515 iar.dwError = ERROR_SUCCESS;
2516
2517 INTERNET_SendCallback(&hIC->hdr, dwContext,
2519 sizeof(INTERNET_ASYNC_RESULT));
2520 }
2521
2523 (LPWSTR) lpszServerName, (lstrlenW(lpszServerName)+1) * sizeof(WCHAR));
2524
2525 sock_namelen = sizeof(socketAddr);
2526 if (!GetAddress(lpszServerName, lpwfs->serverport, (struct sockaddr *)&socketAddr, &sock_namelen, szaddr))
2527 {
2529 goto lerror;
2530 }
2531
2532 if (socketAddr.sin_family != AF_INET)
2533 {
2534 WARN("unsupported address family %d\n", socketAddr.sin_family);
2536 goto lerror;
2537 }
2538
2540 szaddr, strlen(szaddr)+1);
2541
2542 init_winsock();
2543 nsocket = socket(AF_INET,SOCK_STREAM,0);
2544 if (nsocket == -1)
2545 {
2547 goto lerror;
2548 }
2549
2551 szaddr, strlen(szaddr)+1);
2552
2553 if (connect(nsocket, (struct sockaddr *)&socketAddr, sock_namelen) < 0)
2554 {
2555 ERR("Unable to connect (%d)\n", WSAGetLastError());
2557 closesocket(nsocket);
2558 }
2559 else
2560 {
2561 TRACE("Connected to server\n");
2562 lpwfs->sndSocket = nsocket;
2564 szaddr, strlen(szaddr)+1);
2565
2566 sock_namelen = sizeof(lpwfs->socketAddress);
2567 getsockname(nsocket, (struct sockaddr *) &lpwfs->socketAddress, &sock_namelen);
2568
2569 if (FTP_ConnectToHost(lpwfs))
2570 {
2571 TRACE("Successfully logged into server\n");
2572 bSuccess = TRUE;
2573 }
2574 }
2575
2576lerror:
2577 if (!bSuccess)
2578 {
2579 WININET_Release(&lpwfs->hdr);
2580 return NULL;
2581 }
2582
2583 return lpwfs->hdr.hInternet;
2584}
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
static void list_add_head(struct list_entry *head, struct list_entry *entry)
Definition: list.h:76
#define WARN(fmt,...)
Definition: precomp.h:61
#define RegCloseKey(hKey)
Definition: registry.h:49
LONG WINAPI RegOpenKeyW(HKEY hKey, LPCWSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:3268
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
BOOL WINAPI GetUserNameW(LPWSTR lpszName, LPDWORD lpSize)
Definition: misc.c:291
#define wcschr
Definition: compat.h:17
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define MAX_PATH
Definition: compat.h:34
#define lstrcpyW
Definition: compat.h:749
static const object_vtbl_t FTPSESSIONVtbl
Definition: ftp.c:2396
static BOOL FTP_ConnectToHost(ftp_session_t *)
Definition: ftp.c:2597
BOOL WININET_Release(object_header_t *info)
Definition: internet.c:211
void INTERNET_SetLastError(DWORD dwError)
Definition: internet.c:3837
void * alloc_object(object_header_t *parent, const object_vtbl_t *vtbl, size_t size)
Definition: internet.c:103
#define assert(x)
Definition: debug.h:53
static BOOLEAN bSuccess
Definition: drive.cpp:477
#define SOCK_STREAM
Definition: tcpip.h:118
#define AF_INET
Definition: tcpip.h:117
unsigned long DWORD
Definition: ntddk_ex.h:95
GLenum GLsizei len
Definition: glext.h:6722
void init_winsock(void) DECLSPEC_HIDDEN
#define INET_OPENURL
Definition: internet.h:243
BOOL GetAddress(const WCHAR *, INTERNET_PORT, SOCKADDR *, int *, char *) DECLSPEC_HIDDEN
Definition: utility.c:133
VOID INTERNET_SendCallback(object_header_t *hdr, DWORD_PTR dwContext, DWORD dwInternetStatus, LPVOID lpvStatusInfo, DWORD dwStatusInfoLength) DECLSPEC_HIDDEN
#define debugstr_w
Definition: kernel32.h:32
int socklen_t
Definition: tcp.c:35
#define L(x)
Definition: ntvdm.h:50
INT WSAAPI getsockname(IN SOCKET s, OUT LPSOCKADDR name, IN OUT INT FAR *namelen)
Definition: sockctrl.c:213
SOCKET WSAAPI socket(IN INT af, IN INT type, IN INT protocol)
Definition: socklife.c:143
DWORD_PTR dwResult
Definition: wininet.h:155
object_header_t hdr
Definition: ftp.c:75
ftp_file_t * download_in_progress
Definition: ftp.c:80
int lstnSocket
Definition: ftp.c:78
LPWSTR servername
Definition: ftp.c:83
INTERNET_PORT serverport
Definition: ftp.c:84
int pasvSocket
Definition: ftp.c:79
appinfo_t * lpAppInfo
Definition: ftp.c:76
int sndSocket
Definition: ftp.c:77
LPWSTR lpszPassword
Definition: ftp.c:85
struct sockaddr_in socketAddress
Definition: ftp.c:81
LPWSTR lpszUserName
Definition: ftp.c:86
WH_TYPE htype
Definition: internet.h:273
HINTERNET hInternet
Definition: internet.h:275
DWORD dwInternalFlags
Definition: internet.h:281
struct list children
Definition: internet.h:286
struct list entry
Definition: internet.h:285
DWORD_PTR dwContext
Definition: internet.h:278
LPWSTR proxy
Definition: internet.h:293
LPWSTR proxyBypass
Definition: internet.h:294
DWORD accessType
Definition: internet.h:297
object_header_t hdr
Definition: internet.h:291
Definition: copy.c:22
#define DWORD_PTR
Definition: treelist.c:76
unsigned char * LPBYTE
Definition: typedefs.h:53
int32_t INT
Definition: typedefs.h:58
_In_opt_ LPSTR _In_opt_ LPSTR lpszPassword
Definition: winbase.h:2712
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1176
#define INTERNET_DEFAULT_FTP_PORT
Definition: wininet.h:38
#define INTERNET_STATUS_RESOLVING_NAME
Definition: wininet.h:883
#define INTERNET_STATUS_CONNECTING_TO_SERVER
Definition: wininet.h:885
#define INTERNET_OPEN_TYPE_PROXY
Definition: wininet.h:523
#define INTERNET_INVALID_PORT_NUMBER
Definition: wininet.h:36
#define INTERNET_STATUS_HANDLE_CREATED
Definition: wininet.h:895
#define ERROR_INTERNET_CANNOT_CONNECT
Definition: wininet.h:2018
#define ERROR_INTERNET_NAME_NOT_RESOLVED
Definition: wininet.h:1996
#define INTERNET_STATUS_CONNECTED_TO_SERVER
Definition: wininet.h:886
#define INTERNET_STATUS_NAME_RESOLVED
Definition: wininet.h:884
#define HKEY_CURRENT_USER
Definition: winreg.h:11
int PASCAL FAR WSAGetLastError(void)
Definition: dllmain.c:112
#define INET6_ADDRSTRLEN
Definition: ws2ipdef.h:132
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by INTERNET_InternetOpenUrlW(), and InternetConnectW().

◆ get_cookie_header()

DWORD get_cookie_header ( const WCHAR host,
const WCHAR path,
WCHAR **  ret 
)

Definition at line 646 of file cookie.c.

647{
648 cookie_set_t cookie_set = {0};
649 DWORD res;
650
651 static const WCHAR cookieW[] = {'C','o','o','k','i','e',':',' '};
652
654
656 if(res != ERROR_SUCCESS) {
658 return res;
659 }
660
661 if(cookie_set.cnt) {
662 WCHAR *header, *ptr;
663
664 ptr = header = heap_alloc(sizeof(cookieW) + (cookie_set.string_len + 3 /* crlf0 */) * sizeof(WCHAR));
665 if(header) {
666 memcpy(ptr, cookieW, sizeof(cookieW));
667 ptr += ARRAY_SIZE(cookieW);
668
669 cookie_set_to_string(&cookie_set, ptr);
670 heap_free(cookie_set.cookies);
671 ptr += cookie_set.string_len;
672
673 *ptr++ = '\r';
674 *ptr++ = '\n';
675 *ptr++ = 0;
676
677 *ret = header;
678 }else {
680 }
681 }else {
682 *ret = NULL;
683 }
684
686 return res;
687}
#define ARRAY_SIZE(A)
Definition: main.h:20
static substr_t substrz(const WCHAR *str)
Definition: internet.h:209
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
static PVOID ptr
Definition: dispmode.c:27
cookie_t ** cookies
Definition: cookie.c:528
unsigned cnt
Definition: cookie.c:529
unsigned string_len
Definition: cookie.c:532
char * host
Definition: whois.c:55
static void cookie_set_to_string(const cookie_set_t *cookie_set, WCHAR *str)
Definition: cookie.c:619
static DWORD get_cookie(substr_t host, substr_t path, DWORD flags, cookie_set_t *res)
Definition: cookie.c:535
#define INTERNET_COOKIE_HTTPONLY
Definition: wininet.h:1828

Referenced by HTTP_InsertCookies().

◆ get_handle_object()

◆ get_server()

server_t * get_server ( substr_t  name,
INTERNET_PORT  port,
BOOL  is_https,
BOOL  do_create 
)

Definition at line 198 of file http.c.

199{
200 server_t *iter, *server = NULL;
201
203
205 if(iter->port == port && name.len == lstrlenW(iter->name) && !wcsnicmp(iter->name, name.str, name.len)
206 && iter->is_https == is_https) {
207 server = iter;
209 break;
210 }
211 }
212
213 if(!server && do_create) {
214 server = heap_alloc_zero(sizeof(*server));
215 if(server) {
216 server->ref = 2; /* list reference and return */
217 server->port = port;
218 server->is_https = is_https;
219 list_init(&server->conn_pool);
220 server->name = heap_strndupW(name.str, name.len);
221 if(server->name && process_host_port(server)) {
223 }else {
225 server = NULL;
226 }
227 }
228 }
229
231
232 return server;
233}
static WCHAR * heap_strndupW(const WCHAR *src, size_t length)
Definition: button.c:262
#define wcsnicmp
Definition: compat.h:14
USHORT port
Definition: uri.c:228
static BOOL process_host_port(server_t *server)
Definition: http.c:174
static CRITICAL_SECTION connection_pool_cs
Definition: http.c:137
#define LIST_FOR_EACH_ENTRY(elem, list, type, field)
Definition: list.h:198
Definition: name.c:39
WCHAR * name
Definition: internet.h:36
BOOL is_https
Definition: internet.h:38
INTERNET_PORT port
Definition: internet.h:37

Referenced by HTTP_DealWithProxy(), HTTP_HandleRedirect(), and HTTP_HttpOpenRequestW().

◆ GetAddress()

BOOL GetAddress ( const WCHAR name,
INTERNET_PORT  port,
SOCKADDR psa,
int sa_len,
char addr_str 
)

Definition at line 133 of file utility.c.

134{
136 void *addr = NULL;
137 int ret;
138
139 TRACE("%s\n", debugstr_w(name));
140
141 memset( &hints, 0, sizeof(hints) );
142 /* Prefer IPv4 to IPv6 addresses, since some servers do not listen on
143 * their IPv6 addresses even though they have IPv6 addresses in the DNS.
144 */
145 hints.ai_family = AF_INET;
146
148 if (ret != 0)
149 {
150 TRACE("failed to get IPv4 address of %s, retrying with IPv6\n", debugstr_w(name));
151 hints.ai_family = AF_INET6;
153 }
154 if (ret != 0)
155 {
156 TRACE("failed to get address of %s\n", debugstr_w(name));
157 return FALSE;
158 }
159 if (*sa_len < res->ai_addrlen)
160 {
161 WARN("address too small\n");
163 return FALSE;
164 }
165 *sa_len = res->ai_addrlen;
166 memcpy( psa, res->ai_addr, res->ai_addrlen );
167 /* Copy port */
168 switch (res->ai_family)
169 {
170 case AF_INET:
171 addr = &((struct sockaddr_in *)psa)->sin_addr;
172 ((struct sockaddr_in *)psa)->sin_port = htons(port);
173 break;
174 case AF_INET6:
175 addr = &((struct sockaddr_in6 *)psa)->sin6_addr;
176 ((struct sockaddr_in6 *)psa)->sin6_port = htons(port);
177 break;
178 }
179
180 if(addr_str)
181 inet_ntop(res->ai_family, addr, addr_str, INET6_ADDRSTRLEN);
183 return TRUE;
184}
#define FreeAddrInfoW(a)
Definition: addrinfo.c:21
INT WSAAPI GetAddrInfoW(IN PCWSTR pszNodeName, IN PCWSTR pszServiceName, IN const ADDRINFOW *ptHints, OUT PADDRINFOW *pptResult)
Definition: addrinfo.c:509
GLenum const GLvoid * addr
Definition: glext.h:9621
#define htons(x)
Definition: module.h:215
static SCRIPT_CACHE SCRIPT_ANALYSIS * psa
Definition: usp10.c:64
namespace GUID const ADDRINFOEXW * hints
Definition: sock.c:80
const char *WSAAPI inet_ntop(int af, const void *src, char *dst, size_t cnt)
Definition: unix_func.c:8
#define AF_INET6
Definition: winsock.h:369

Referenced by FTP_Connect(), HTTP_ResolveName(), and InternetCheckConnectionW().

◆ heap_strdupA()

static char * heap_strdupA ( const char str)
inlinestatic

Definition at line 113 of file internet.h.

114{
115 char *ret = NULL;
116
117 if(str) {
118 DWORD size = strlen(str)+1;
119
121 if(ret)
122 memcpy(ret, str, size);
123 }
124
125 return ret;
126}
const WCHAR * str

◆ heap_strdupAtoW()

static WCHAR * heap_strdupAtoW ( const char str)
inlinestatic

Definition at line 168 of file internet.h.

169{
170 LPWSTR ret = NULL;
171
172 if(str) {
173 DWORD len;
174
175 len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
176 ret = heap_alloc(len*sizeof(WCHAR));
177 if(ret)
179 }
180
181 return ret;
182}
#define CP_ACP
Definition: compat.h:109
#define MultiByteToWideChar
Definition: compat.h:110
static void size_t len
Definition: internet.h:93

◆ heap_strdupW()

static LPWSTR heap_strdupW ( LPCWSTR  str)
inlinestatic

Definition at line 97 of file internet.h.

98{
99 LPWSTR ret = NULL;
100
101 if(str) {
102 DWORD size;
103
104 size = (lstrlenW(str)+1)*sizeof(WCHAR);
106 if(ret)
107 memcpy(ret, str, size);
108 }
109
110 return ret;
111}

◆ heap_strdupWtoA()

static char * heap_strdupWtoA ( LPCWSTR  str)
inlinestatic

Definition at line 184 of file internet.h.

185{
186 char *ret = NULL;
187
188 if(str) {
191 if(ret)
193 }
194
195 return ret;
196}
#define WideCharToMultiByte
Definition: compat.h:111

◆ heap_strndupAtoW()

static WCHAR * heap_strndupAtoW ( const char str,
int  len_a,
DWORD len_w 
)
inlinestatic

Definition at line 149 of file internet.h.

150{
151 WCHAR *ret = NULL;
152
153 if(str) {
154 size_t len;
155 if(len_a < 0) len_a = strlen(str);
156 len = MultiByteToWideChar(CP_ACP, 0, str, len_a, NULL, 0);
157 ret = heap_alloc((len+1)*sizeof(WCHAR));
158 if(ret) {
159 MultiByteToWideChar(CP_ACP, 0, str, len_a, ret, len);
160 ret[len] = 0;
161 *len_w = len;
162 }
163 }
164
165 return ret;
166}

Referenced by HttpAddRequestHeadersA(), InternetCrackUrlA(), InternetOpenUrlA(), and retrieve_cached_basic_authorization().

◆ heap_strndupW()

static LPWSTR heap_strndupW ( LPCWSTR  str,
UINT  max_len 
)
inlinestatic

Definition at line 128 of file internet.h.

129{
130 LPWSTR ret;
131 UINT len;
132
133 if(!str)
134 return NULL;
135
136 for(len=0; len<max_len; len++)
137 if(str[len] == '\0')
138 break;
139
140 ret = heap_alloc(sizeof(WCHAR)*(len+1));
141 if(ret) {
142 memcpy(ret, str, sizeof(WCHAR)*len);
143 ret[len] = '\0';
144 }
145
146 return ret;
147}
unsigned int UINT
Definition: ndis.h:50

◆ HTTP_Connect()

DWORD HTTP_Connect ( appinfo_t hIC,
LPCWSTR  lpszServerName,
INTERNET_PORT  nServerPort,
LPCWSTR  lpszUserName,
LPCWSTR  lpszPassword,
DWORD  dwFlags,
DWORD_PTR  dwContext,
DWORD  dwInternalFlags,
HINTERNET ret 
)

Definition at line 5836 of file http.c.

5840{
5842
5843 TRACE("-->\n");
5844
5845 if (!lpszServerName || !lpszServerName[0])
5847
5848 assert( hIC->hdr.htype == WH_HINIT );
5849
5851 if (!session)
5852 return ERROR_OUTOFMEMORY;
5853
5854 /*
5855 * According to my tests. The name is not resolved until a request is sent
5856 */
5857
5858 session->hdr.htype = WH_HHTTPSESSION;
5859 session->hdr.dwFlags = dwFlags;
5860 session->hdr.dwContext = dwContext;
5861 session->hdr.dwInternalFlags |= dwInternalFlags;
5862 session->hdr.decoding = hIC->hdr.decoding;
5863
5864 WININET_AddRef( &hIC->hdr );
5865 session->appInfo = hIC;
5866 list_add_head( &hIC->hdr.children, &session->hdr.entry );
5867
5868 session->hostName = heap_strdupW(lpszServerName);
5869 if (lpszUserName && lpszUserName[0])
5870 session->userName = heap_strdupW(lpszUserName);
5871 session->password = heap_strdupW(lpszPassword);
5872 session->hostPort = serverPort;
5874 session->send_timeout = 0;
5876
5877 /* Don't send a handle created callback if this handle was created with InternetOpenUrl */
5878 if (!(session->hdr.dwInternalFlags & INET_OPENURL))
5879 {
5880 INTERNET_SendCallback(&hIC->hdr, dwContext,
5882 sizeof(HINTERNET));
5883 }
5884
5885/*
5886 * an INTERNET_STATUS_REQUEST_COMPLETE is NOT sent here as per my tests on
5887 * windows
5888 */
5889
5890 TRACE("%p --> %p\n", hIC, session);
5891
5892 *ret = session->hdr.hInternet;
5893 return ERROR_SUCCESS;
5894}
static const object_vtbl_t HTTPSESSIONVtbl
Definition: http.c:5814
DWORD connect_timeout
Definition: internet.h:298
int receive_timeout
struct object_header hdr
int send_timeout
int connect_timeout

Referenced by INTERNET_InternetOpenUrlW(), and InternetConnectW().

◆ INET_QueryOption()

DWORD INET_QueryOption ( object_header_t hdr,
DWORD  option,
void buffer,
DWORD size,
BOOL  unicode 
)

Definition at line 2654 of file internet.c.

2655{
2656 switch(option) {
2658 if (!size)
2660
2661 if (*size < sizeof(DWORD_PTR)) {
2662 *size = sizeof(DWORD_PTR);
2664 }
2665 if (!buffer)
2667
2668 *(DWORD_PTR *)buffer = hdr->dwContext;
2669 *size = sizeof(DWORD_PTR);
2670 return ERROR_SUCCESS;
2671
2673 WARN("INTERNET_OPTION_REQUEST_FLAGS\n");
2674 *size = sizeof(DWORD);
2676
2679 WARN("Called on global option %u\n", option);
2681 }
2682
2683 /* FIXME: we shouldn't call it here */
2684 return query_global_option(option, buffer, size, unicode);
2685}
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10
static DWORD query_global_option(DWORD option, void *buffer, DWORD *size, BOOL unicode)
Definition: internet.c:2458
GLuint buffer
Definition: glext.h:5915
#define DWORD
Definition: nt_native.h:44
Definition: getopt.h:109
uint32_t DWORD_PTR
Definition: typedefs.h:65
#define INTERNET_OPTION_MAX_CONNS_PER_SERVER
Definition: wininet.h:763
#define ERROR_INTERNET_INVALID_OPERATION
Definition: wininet.h:2005
#define INTERNET_OPTION_CONTEXT_VALUE
Definition: wininet.h:739
#define ERROR_INTERNET_INCORRECT_HANDLE_TYPE
Definition: wininet.h:2007
#define INTERNET_OPTION_MAX_CONNS_PER_1_0_SERVER
Definition: wininet.h:764
#define INTERNET_OPTION_REQUEST_FLAGS
Definition: wininet.h:718

Referenced by APPINFO_QueryOption(), FTPFILE_QueryOption(), FTPFINDNEXT_QueryOption(), FTPSESSION_QueryOption(), and HTTPSESSION_QueryOption().

◆ INET_SetOption()

DWORD INET_SetOption ( object_header_t hdr,
DWORD  option,
void buf,
DWORD  size 
)

Definition at line 2753 of file internet.c.

2754{
2755 switch(option) {
2757 FIXME("INTERNETOPTION_SETTINGS_CHANGED semi-stub\n");
2759 return ERROR_SUCCESS;
2761 WARN("Not settable option %u\n", option);
2765 WARN("Called on global option %u\n", option);
2769 }
2770
2772}
BOOL collect_connections(collect_type_t collect_type)
Definition: http.c:235
#define ERROR_INTERNET_OPTION_NOT_SETTABLE
Definition: wininet.h:2000
#define ERROR_INTERNET_INVALID_OPTION
Definition: wininet.h:1998
#define INTERNET_OPTION_REFRESH
Definition: wininet.h:731
#define INTERNET_OPTION_SETTINGS_CHANGED
Definition: wininet.h:733
#define INTERNET_OPTION_CALLBACK
Definition: wininet.h:700

Referenced by APPINFO_SetOption(), HTTPREQ_SetOption(), HTTPSESSION_SetOption(), and set_global_option().

◆ init_urlcache()

BOOL init_urlcache ( void  )

Definition at line 4112 of file urlcache.c.

4113{
4115 if(!dll_unload_event)
4116 return FALSE;
4117
4119 if(!free_cache_running) {
4121 return FALSE;
4122 }
4123
4124#ifndef __REACTOS__
4126#endif
4127 return TRUE;
4128}
static void cache_containers_init(void)
Definition: urlcache.c:747
HANDLE WINAPI DECLSPEC_HOTPATCH CreateEventW(IN LPSECURITY_ATTRIBUTES lpEventAttributes OPTIONAL, IN BOOL bManualReset, IN BOOL bInitialState, IN LPCWSTR lpName OPTIONAL)
Definition: synch.c:651
HANDLE WINAPI DECLSPEC_HOTPATCH CreateSemaphoreW(IN LPSECURITY_ATTRIBUTES lpSemaphoreAttributes OPTIONAL, IN LONG lInitialCount, IN LONG lMaximumCount, IN LPCWSTR lpName OPTIONAL)
Definition: synch.c:444

Referenced by DllMain().

◆ init_winsock()

void init_winsock ( void  )

Definition at line 281 of file netconnection.c.

282{
283 static INIT_ONCE init_once = INIT_ONCE_STATIC_INIT;
285}
BOOL WINAPI InitOnceExecuteOnce(_Inout_ PINIT_ONCE InitOnce, _In_ __callback PINIT_ONCE_FN InitFn, _Inout_opt_ PVOID Parameter, _Outptr_opt_result_maybenull_ LPVOID *Context)
Definition: InitOnce.c:12
static BOOL WINAPI winsock_startup(INIT_ONCE *once, void *param, void **context)
RTL_RUN_ONCE INIT_ONCE
Definition: winbase.h:3931
#define INIT_ONCE_STATIC_INIT
Definition: winbase.h:612

Referenced by create_netconn_socket(), FTP_Connect(), FTP_InitListenSocket(), InternetCheckConnectionW(), and InternetOpenW().

◆ INTERNET_AsyncCall()

DWORD INTERNET_AsyncCall ( task_header_t task)

Definition at line 3915 of file internet.c.

3916{
3917 BOOL bSuccess;
3918
3919 TRACE("\n");
3920
3922 if (!bSuccess)
3923 {
3924 heap_free(task);
3926 }
3927 return ERROR_SUCCESS;
3928}
BOOL WINAPI QueueUserWorkItem(IN LPTHREAD_START_ROUTINE Function, IN PVOID Context, IN ULONG Flags)
Definition: thread.c:1076
static DWORD CALLBACK INTERNET_WorkerThreadFunc(LPVOID lpvParam)
Definition: internet.c:3876
#define ERROR_INTERNET_ASYNC_THREAD_FAILED
Definition: wininet.h:2035
#define WT_EXECUTELONGFUNCTION
Definition: winnt_old.h:1043

Referenced by async_read(), FtpCreateDirectoryW(), FtpDeleteFileW(), FTPFILE_QueryDataAvailable(), FtpFindFirstFileW(), FTPFINDNEXT_FindNextFileW(), FtpGetCurrentDirectoryW(), FtpGetFileW(), FtpOpenFileW(), FtpPutFileW(), FtpRemoveDirectoryW(), FtpRenameFileW(), FtpSetCurrentDirectoryW(), HttpEndRequestW(), HttpSendRequestExW(), HttpSendRequestW(), and InternetOpenUrlW().

◆ INTERNET_FindProxyForProtocol()

WCHAR * INTERNET_FindProxyForProtocol ( LPCWSTR  szProxy,
LPCWSTR  proto 
)

Definition at line 384 of file internet.c.

385{
386 WCHAR *ret = NULL;
387 const WCHAR *ptr;
388
389 TRACE("(%s, %s)\n", debugstr_w(szProxy), debugstr_w(proto));
390
391 /* First, look for the specified protocol (proto=scheme://host:port) */
392 for (ptr = szProxy; ptr && *ptr; )
393 {
395
396 if (!(end = wcschr(ptr, ' ')))
397 end = ptr + lstrlenW(ptr);
398 if ((equal = wcschr(ptr, '=')) && equal < end &&
399 equal - ptr == lstrlenW(proto) &&
401 {
402 ret = heap_strndupW(equal + 1, end - equal - 1);
403 TRACE("found proxy for %s: %s\n", debugstr_w(proto), debugstr_w(ret));
404 return ret;
405 }
406 if (*end == ' ')
407 ptr = end + 1;
408 else
409 ptr = end;
410 }
411
412 /* It wasn't found: look for no protocol */
413 for (ptr = szProxy; ptr && *ptr; )
414 {
415 LPCWSTR end;
416
417 if (!(end = wcschr(ptr, ' ')))
418 end = ptr + lstrlenW(ptr);
419 if (!wcschr(ptr, '='))
420 {
422 TRACE("found proxy for %s: %s\n", debugstr_w(proto), debugstr_w(ret));
423 return ret;
424 }
425 if (*end == ' ')
426 ptr = end + 1;
427 else
428 ptr = end;
429 }
430
431 return NULL;
432}
GLuint GLuint end
Definition: gl.h:1545
#define equal(x, y)
Definition: reader.cc:56
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185

Referenced by HTTP_DealWithProxy().

◆ INTERNET_GetLastError()

DWORD INTERNET_GetLastError ( void  )

Definition at line 3858 of file internet.c.

3859{
3861 if (!lpwite) return 0;
3862 /* TlsGetValue clears last error, so set it again here */
3863 SetLastError(lpwite->dwError);
3864 return lpwite->dwError;
3865}
#define SetLastError(x)
Definition: compat.h:752
LPVOID WINAPI TlsGetValue(IN DWORD Index)
Definition: thread.c:1240
static DWORD g_dwTlsErrIndex
Definition: internet.c:72
DWORD dwError
Definition: internet.c:68

Referenced by FTP_FtpCreateDirectoryW(), FTP_FtpDeleteFileW(), FTP_FtpFindFirstFileW(), FTP_FtpGetFileW(), FTP_FtpOpenFileW(), FTP_FtpPutFileW(), FTP_FtpRemoveDirectoryW(), FTP_FtpRenameFileW(), FTP_ReceiveRequestData(), HTTP_HandleRedirect(), and InternetConnectW().

◆ INTERNET_GetResponseBuffer()

LPSTR INTERNET_GetResponseBuffer ( void  )

Definition at line 3937 of file internet.c.

3938{
3940 if (!lpwite)
3941 lpwite = INTERNET_AllocThreadError();
3942 TRACE("\n");
3943 return lpwite->response;
3944}
static LPWITHREADERROR INTERNET_AllocThreadError(void)
Definition: internet.c:3810
CHAR response[MAX_REPLY_LEN]
Definition: internet.c:69

Referenced by FTP_DoPassive(), FTP_FtpGetCurrentDirectoryW(), FTP_GetNextLine(), and FTP_ReceiveResponse().

◆ INTERNET_SendCallback()

◆ INTERNET_SetLastError()

◆ is_valid_netconn()

◆ NETCON_GetCert()

LPCVOID NETCON_GetCert ( netconn_t connection)

Definition at line 887 of file netconnection.c.

888{
889 const CERT_CONTEXT *ret;
891
893 return res == SEC_E_OK ? ret : NULL;
894}
LONG SECURITY_STATUS
Definition: sspi.h:34
#define SECPKG_ATTR_REMOTE_CERT_CONTEXT
Definition: schannel.h:69
CtxtHandle ssl_ctx
Definition: internet.h:72
#define SEC_E_OK
Definition: winerror.h:2356
SECURITY_STATUS WINAPI QueryContextAttributesW(PCtxtHandle phContext, ULONG ulAttribute, void *pBuffer)
Definition: wrapper.c:535

Referenced by get_security_cert_struct().

◆ NETCON_GetCipherStrength()

int NETCON_GetCipherStrength ( netconn_t connection)

Definition at line 896 of file netconnection.c.

897{
900
901 if (!connection->secure)
902 return 0;
903
904 res = QueryContextAttributesW(&connection->ssl_ctx, SECPKG_ATTR_CONNECTION_INFO, (void*)&conn_info);
905 if(res != SEC_E_OK)
906 WARN("QueryContextAttributesW failed: %08x\n", res);
907 return res == SEC_E_OK ? conn_info.dwCipherStrength : 0;
908}
#define SECPKG_ATTR_CONNECTION_INFO
Definition: schannel.h:76
BOOL secure
Definition: internet.h:70

Referenced by get_security_cert_struct(), and netcon_secure_connect_setup().

◆ NETCON_is_alive()

BOOL NETCON_is_alive ( netconn_t netconn)

Definition at line 876 of file netconnection.c.

877{
878 int len;
879 char b;
880
883
884 return len == 1 || (len == -1 && WSAGetLastError() == WSAEWOULDBLOCK);
885}
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
#define b
Definition: ke_i.h:79
static void set_socket_blocking(netconn_t *conn, BOOL is_blocking)
int sock_recv(int fd, void *msg, size_t len, int flags)
#define WSAEWOULDBLOCK
Definition: winerror.h:1948
#define MSG_PEEK
Definition: winsock.h:222

Referenced by open_http_connection().

◆ NETCON_recv()

DWORD NETCON_recv ( netconn_t connection,
void buf,
size_t  len,
BOOL  blocking,
int recvd 
)

Definition at line 824 of file netconnection.c.

825{
826 *recvd = 0;
827 if (!len)
828 return ERROR_SUCCESS;
829
830 if (!connection->secure)
831 {
832 set_socket_blocking(connection, blocking);
833 *recvd = sock_recv(connection->socket, buf, len, 0);
834 return *recvd == -1 ? WSAGetLastError() : ERROR_SUCCESS;
835 }
836 else
837 {
838 SIZE_T size = 0;
839 BOOL eof;
840 DWORD res;
841
842 if(connection->peek_msg) {
843 size = min(len, connection->peek_len);
844 memcpy(buf, connection->peek_msg, size);
845 connection->peek_len -= size;
846 connection->peek_msg += size;
847
848 if(!connection->peek_len) {
849 heap_free(connection->peek_msg_mem);
850 connection->peek_msg_mem = connection->peek_msg = NULL;
851 }
852
853 *recvd = size;
854 return ERROR_SUCCESS;
855 }
856
857 do {
858 res = read_ssl_chunk(connection, (BYTE*)buf, len, blocking, &size, &eof);
859 if(res != ERROR_SUCCESS) {
860 if(res == WSAEWOULDBLOCK) {
861 if(size)
863 }else {
864 WARN("read_ssl_chunk failed\n");
865 }
866 break;
867 }
868 }while(!size && !eof);
869
870 TRACE("received %ld bytes\n", size);
871 *recvd = size;
872 return res;
873 }
874}
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define min(a, b)
Definition: monoChain.cc:55
static BOOL read_ssl_chunk(netconn_t *conn, void *buf, SIZE_T buf_size, BOOL blocking, SIZE_T *ret_size, BOOL *eof)
_Check_return_ _CRTIMP int __cdecl __cdecl eof(_In_ int _FileHandle)
char * peek_msg_mem
Definition: internet.h:79
char * peek_msg
Definition: internet.h:78
size_t peek_len
Definition: internet.h:80
int socket
Definition: internet.h:69
ULONG_PTR SIZE_T
Definition: typedefs.h:80
unsigned char BYTE
Definition: xxhash.c:193

Referenced by chunked_read(), netconn_drain_content(), netconn_read(), and read_more_data().

◆ NETCON_secure_connect()

DWORD NETCON_secure_connect ( netconn_t connection,
server_t server 
)

Definition at line 604 of file netconnection.c.

605{
606 DWORD res;
607
608 /* can't connect if we are already connected */
609 if(connection->secure) {
610 ERR("already connected\n");
612 }
613
614 if(server != connection->server) {
615 server_release(connection->server);
617 connection->server = server;
618 }
619
620 /* connect with given TLS options */
622 if (res == ERROR_SUCCESS)
623 return res;
624
625 /* FIXME: when got version alert and FIN from server */
626 /* fallback to connect without TLSv1.1/TLSv1.2 */
628 {
629 closesocket(connection->socket);
630 res = create_netconn_socket(connection->server, connection, 500);
631 if (res != ERROR_SUCCESS)
632 return res;
633 res = netcon_secure_connect_setup(connection, TRUE);
634 }
635 return res;
636}
static BOOL have_compat_cred_handle
static DWORD netcon_secure_connect_setup(netconn_t *connection, BOOL compat_mode)
server_t * server
Definition: internet.h:74
#define ERROR_INTERNET_SECURITY_CHANNEL_ERROR
Definition: wininet.h:2069

Referenced by HTTP_HttpSendRequestW().

◆ NETCON_send()

DWORD NETCON_send ( netconn_t connection,
const void msg,
size_t  len,
int  flags,
int sent 
)

Definition at line 669 of file netconnection.c.

671{
672 /* send is always blocking. */
673 set_socket_blocking(connection, TRUE);
674
675 if(!connection->secure)
676 {
677 *sent = sock_send(connection->socket, msg, len, flags);
678 return *sent == -1 ? WSAGetLastError() : ERROR_SUCCESS;
679 }
680 else
681 {
682 const BYTE *ptr = msg;
683 size_t chunk_size;
684
685 *sent = 0;
686
687 while(len) {
688 chunk_size = min(len, connection->ssl_sizes.cbMaximumMessage);
689 if(!send_ssl_chunk(connection, ptr, chunk_size))
691
692 *sent += chunk_size;
693 ptr += chunk_size;
694 len -= chunk_size;
695 }
696
697 return ERROR_SUCCESS;
698 }
699}
@ sent
Definition: SystemMenu.c:27
#define msg(x)
Definition: auth_time.c:54
GLbitfield flags
Definition: glext.h:7161
int sock_send(int fd, const void *msg, size_t len, int flags)
static BOOL send_ssl_chunk(netconn_t *conn, const void *msg, size_t size)
SecPkgContext_StreamSizes ssl_sizes
Definition: internet.h:73

Referenced by HTTP_HttpSendRequestW(), and HTTPREQ_WriteFile().

◆ NETCON_set_timeout()

DWORD NETCON_set_timeout ( netconn_t connection,
BOOL  send,
DWORD  value 
)

Definition at line 910 of file netconnection.c.

911{
912 int result;
913
914 result = setsockopt(connection->socket, SOL_SOCKET,
915 send ? SO_SNDTIMEO : SO_RCVTIMEO, (void*)&value,
916 sizeof(value));
917 if (result == -1)
918 {
919 WARN("setsockopt failed\n");
920 return WSAGetLastError();
921 }
922 return ERROR_SUCCESS;
923}
INT WSAAPI send(IN SOCKET s, IN CONST CHAR FAR *buf, IN INT len, IN INT flags)
Definition: send.c:23
INT WSAAPI setsockopt(IN SOCKET s, IN INT level, IN INT optname, IN CONST CHAR FAR *optval, IN INT optlen)
Definition: sockctrl.c:421
Definition: pdh_main.c:94
#define SOL_SOCKET
Definition: winsock.h:398
#define SO_SNDTIMEO
Definition: winsock.h:192
#define SO_RCVTIMEO
Definition: winsock.h:193

Referenced by HTTP_GetResponseHeaders(), and HTTP_HttpSendRequestW().

◆ NETCON_unload()

void NETCON_unload ( void  )

Definition at line 407 of file netconnection.c.

408{
415 WSACleanup();
416}
static SecHandle compat_cred_handle
static CRITICAL_SECTION init_sechandle_cs
static BOOL cred_handle_initialized
static BOOL winsock_loaded
static SecHandle cred_handle
void WINAPI DeleteCriticalSection(PCRITICAL_SECTION)
int PASCAL FAR WSACleanup(void)
Definition: startup.c:60
SECURITY_STATUS WINAPI FreeCredentialsHandle(PCredHandle phCredential)
Definition: wrapper.c:151

Referenced by DllMain().

◆ req_file_addref()

static req_file_t * req_file_addref ( req_file_t req_file)
inlinestatic

Definition at line 449 of file internet.h.

450{
451 InterlockedIncrement(&req_file->ref);
452 return req_file;
453}
#define InterlockedIncrement
Definition: armddk.h:53

Referenced by HTTPREQ_LockRequestFile().

◆ req_file_release()

void req_file_release ( req_file_t req_file)

Definition at line 4015 of file internet.c.

4016{
4017 if(InterlockedDecrement(&req_file->ref))
4018 return;
4019
4020 if(!req_file->is_committed)
4021 DeleteFileW(req_file->file_name);
4022 if(req_file->file_handle && req_file->file_handle != INVALID_HANDLE_VALUE)
4023 CloseHandle(req_file->file_handle);
4024 heap_free(req_file->file_name);
4025 heap_free(req_file->url);
4026 heap_free(req_file);
4027}
#define InterlockedDecrement
Definition: armddk.h:52
BOOL WINAPI DeleteFileW(IN LPCWSTR lpFileName)
Definition: delete.c:39
WCHAR * url
Definition: internet.h:251
BOOL is_committed
Definition: internet.h:252

Referenced by create_cache_entry(), create_req_file(), HTTPREQ_Destroy(), and InternetUnlockRequestFile().

◆ server_addref()

void server_addref ( server_t server)

Definition at line 149 of file http.c.

150{
152}

Referenced by create_netconn(), get_server(), and NETCON_secure_connect().

◆ server_release()

void server_release ( server_t server)

Definition at line 154 of file http.c.

155{
157 return;
158
159#ifdef __REACTOS__
161#endif
162 list_remove(&server->entry);
163#ifdef __REACTOS__
165#endif
166
167 if(server->cert_chain)
168 CertFreeCertificateChain(server->cert_chain);
169 heap_free(server->name);
170 heap_free(server->scheme_host_port);
172}
VOID WINAPI CertFreeCertificateChain(PCCERT_CHAIN_CONTEXT pChainContext)
Definition: chain.c:2960

Referenced by collect_connections(), free_netconn(), HTTP_HandleRedirect(), HTTPREQ_Destroy(), InternetGetSecurityInfoByURLW(), and NETCON_secure_connect().

◆ set_cookie()

DWORD set_cookie ( substr_t  domain,
substr_t  path,
substr_t  name,
substr_t  data,
DWORD  flags 
)

Definition at line 912 of file cookie.c.

913{
915 cookie_t *thisCookie;
917 const WCHAR *end_ptr;
918 FILETIME expiry, create;
919 BOOL expired = FALSE, update_persistent = FALSE;
920 DWORD cookie_flags = 0, len;
921
922 TRACE("%s %s %s=%s %x\n", debugstr_wn(domain.str, domain.len), debugstr_wn(path.str, path.len),
923 debugstr_wn(name.str, name.len), debugstr_wn(data.str, data.len), flags);
924
925 memset(&expiry,0,sizeof(expiry));
927
928 /* lots of information can be parsed out of the cookie value */
929
930 if(!(end_ptr = wmemchr(data.str, ';', data.len)))
931 end_ptr = data.str + data.len;
932 value = substr(data.str, end_ptr-data.str);
933 data.str += value.len;
934 data.len -= value.len;
935
936 for(;;) {
937 static const WCHAR szDomain[] = {'d','o','m','a','i','n','='};
938 static const WCHAR szPath[] = {'p','a','t','h','='};
939 static const WCHAR szExpires[] = {'e','x','p','i','r','e','s','='};
940 static const WCHAR szSecure[] = {'s','e','c','u','r','e'};
941 static const WCHAR szHttpOnly[] = {'h','t','t','p','o','n','l','y'};
942 static const WCHAR szVersion[] = {'v','e','r','s','i','o','n','='};
943 static const WCHAR max_ageW[] = {'m','a','x','-','a','g','e','='};
944
945 /* Skip ';' */
946 if(data.len)
947 substr_skip(&data, 1);
948
949 while(data.len && *data.str == ' ')
950 substr_skip(&data, 1);
951
952 if(!data.len)
953 break;
954
955 if(!(end_ptr = wmemchr(data.str, ';', data.len)))
956 end_ptr = data.str + data.len;
957
958 if(data.len >= (len = ARRAY_SIZE(szDomain)) && !wcsnicmp(data.str, szDomain, len)) {
960
961 if(data.len && *data.str == '.')
962 substr_skip(&data, 1);
963
964 if(!is_domain_legal_for_cookie(substr(data.str, end_ptr-data.str), domain))
966
967 domain = substr(data.str, end_ptr-data.str);
968 TRACE("Parsing new domain %s\n", debugstr_wn(domain.str, domain.len));
969 }else if(data.len >= (len = ARRAY_SIZE(szPath)) && !wcsnicmp(data.str, szPath, len)) {
971 path = substr(data.str, end_ptr - data.str);
972 TRACE("Parsing new path %s\n", debugstr_wn(path.str, path.len));
973 }else if(data.len >= (len = ARRAY_SIZE(szExpires)) && !wcsnicmp(data.str, szExpires, len)) {
974 SYSTEMTIME st;
975 WCHAR buf[128];
976
978
979 if(end_ptr > data.str && (end_ptr - data.str < ARRAY_SIZE(buf) - 1)) {
980 memcpy(buf, data.str, data.len*sizeof(WCHAR));
981 buf[data.len] = 0;
982
983 if (InternetTimeToSystemTimeW(data.str, &st, 0)) {
984 SystemTimeToFileTime(&st, &expiry);
985
986 if (CompareFileTime(&create,&expiry) > 0) {
987 TRACE("Cookie already expired.\n");
988 expired = TRUE;
989 }
990 }
991 }
992 }else if(data.len >= (len = ARRAY_SIZE(szSecure)) && !wcsnicmp(data.str, szSecure, len)) {
994 FIXME("secure not handled\n");
995 }else if(data.len >= (len = ARRAY_SIZE(szHttpOnly)) && !wcsnicmp(data.str, szHttpOnly, len)) {
997
999 WARN("HTTP only cookie added without INTERNET_COOKIE_HTTPONLY flag\n");
1001 return COOKIE_STATE_REJECT;
1002 }
1003
1004 cookie_flags |= INTERNET_COOKIE_HTTPONLY;
1005 }else if(data.len >= (len = ARRAY_SIZE(szVersion)) && !wcsnicmp(data.str, szVersion, len)) {
1006 substr_skip(&data, len);
1007
1008 FIXME("version not handled (%s)\n",debugstr_wn(data.str, data.len));
1009 }else if(data.len >= (len = ARRAY_SIZE(max_ageW)) && !wcsnicmp(data.str, max_ageW, len)) {
1010 /* Native doesn't support Max-Age attribute. */
1011 WARN("Max-Age ignored\n");
1012 }else if(data.len) {
1013 FIXME("Unknown additional option %s\n", debugstr_wn(data.str, data.len));
1014 }
1015
1016 substr_skip(&data, end_ptr - data.str);
1017 }
1018
1020
1022
1024 if(!container) {
1026 return COOKIE_STATE_ACCEPT;
1027 }
1028
1029 if(!expiry.dwLowDateTime && !expiry.dwHighDateTime)
1030 cookie_flags |= INTERNET_COOKIE_IS_SESSION;
1031 else
1032 update_persistent = TRUE;
1033
1034 if ((thisCookie = find_cookie(container, name))) {
1035 if ((thisCookie->flags & INTERNET_COOKIE_HTTPONLY) && !(flags & INTERNET_COOKIE_HTTPONLY)) {
1036 WARN("An attempt to override httponly cookie\n");
1039 return COOKIE_STATE_REJECT;
1040 }
1041
1042 if (!(thisCookie->flags & INTERNET_COOKIE_IS_SESSION))
1043 update_persistent = TRUE;
1044 delete_cookie(thisCookie);
1045 }
1046
1047 TRACE("setting cookie %s=%s for domain %s path %s\n", debugstr_wn(name.str, name.len),
1048 debugstr_wn(value.str, value.len), debugstr_w(container->domain->domain),
1049 debugstr_wn(container->path.str, container->path.len));
1050
1051 if (!expired) {
1052 cookie_t *new_cookie;
1053
1054 new_cookie = alloc_cookie(name, value, expiry, create, cookie_flags);
1055 if(!new_cookie) {
1057 return COOKIE_STATE_UNKNOWN;
1058 }
1059
1060 add_cookie(container, new_cookie);
1061 }
1062
1063 if (!update_persistent || save_persistent_cookie(container))
1064 {
1066 return COOKIE_STATE_ACCEPT;
1067 }
1069 return COOKIE_STATE_UNKNOWN;
1070}
VOID WINAPI GetSystemTimeAsFileTime(OUT PFILETIME lpFileTime)
Definition: time.c:128
BOOL WINAPI SystemTimeToFileTime(IN CONST SYSTEMTIME *lpSystemTime, OUT LPFILETIME lpFileTime)
Definition: time.c:158
LONG WINAPI CompareFileTime(IN CONST FILETIME *lpFileTime1, IN CONST FILETIME *lpFileTime2)
Definition: time.c:106
BOOL WINAPI InternetTimeToSystemTimeW(LPCWSTR string, SYSTEMTIME *time, DWORD reserved)
Definition: internet.c:3378
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
_CONST_RETURN wchar_t *__cdecl wmemchr(_In_reads_(_N) const wchar_t *_S, _In_ wchar_t _C, _In_ size_t _N)
Definition: wchar.h:2554
static substr_t substr(const WCHAR *str, size_t len)
Definition: internet.h:203
#define debugstr_wn
Definition: kernel32.h:33
LPCWSTR szPath
Definition: env.c:37
static LPCWSTR szVersion
Definition: asmcache.c:748
static const struct access_res create[16]
Definition: package.c:7505
DWORD dwHighDateTime
Definition: mapidefs.h:66
DWORD dwLowDateTime
Definition: mapidefs.h:65
Definition: cookie.c:42
#define ERROR_INVALID_OPERATION
Definition: winerror.h:1261
static void delete_cookie(struct cookie *cookie)
Definition: cookie.c:98
static struct cookie * find_cookie(struct domain *domain, const WCHAR *path, const WCHAR *name)
Definition: cookie.c:64
static BOOL add_cookie(struct session *session, struct cookie *cookie, WCHAR *domain_name, WCHAR *path)
Definition: cookie.c:132
static BOOL load_persistent_cookie(substr_t domain, substr_t path)
Definition: cookie.c:308
static cookie_container_t * get_cookie_container(substr_t domain, substr_t path, BOOL create)
Definition: cookie.c:192
static BOOL save_persistent_cookie(cookie_container_t *container)
Definition: cookie.c:397
static cookie_t * alloc_cookie(substr_t name, substr_t data, FILETIME expiry, FILETIME create_time, DWORD flags)
Definition: cookie.c:245
static BOOL is_domain_legal_for_cookie(substr_t domain, substr_t full_domain)
Definition: cookie.c:869
static void substr_skip(substr_t *str, size_t len)
Definition: cookie.c:905
#define INTERNET_COOKIE_IS_SESSION
Definition: wininet.h:1819
@ COOKIE_STATE_ACCEPT
Definition: wininet.h:1792
@ COOKIE_STATE_UNKNOWN
Definition: wininet.h:1791
@ COOKIE_STATE_REJECT
Definition: wininet.h:1796

Referenced by HTTP_ProcessCookies(), InternetSetCookieExW(), and record_cookies().

◆ sock_recv()

int sock_recv ( int  fd,
void msg,
size_t  len,
int  flags 
)

Definition at line 429 of file netconnection.c.

430{
431 int ret;
432 do
433 {
434 ret = recv(fd, msg, len, flags);
435 }
436 while(ret == -1 && WSAGetLastError() == WSAEINTR);
437 return ret;
438}
INT WSAAPI recv(IN SOCKET s, OUT CHAR FAR *buf, IN INT len, IN INT flags)
Definition: recv.c:23
static int fd
Definition: io.c:51
#define WSAEINTR
Definition: winerror.h:1942

Referenced by NETCON_is_alive(), NETCON_recv(), netcon_secure_connect_setup(), and read_ssl_chunk().

◆ sock_send()

int sock_send ( int  fd,
const void msg,
size_t  len,
int  flags 
)

Definition at line 418 of file netconnection.c.

419{
420 int ret;
421 do
422 {
423 ret = send(fd, msg, len, flags);
424 }
425 while(ret == -1 && WSAGetLastError() == WSAEINTR);
426 return ret;
427}

Referenced by netcon_secure_connect_setup(), NETCON_send(), and send_ssl_chunk().

◆ substr()

static substr_t substr ( const WCHAR str,
size_t  len 
)
inlinestatic

◆ substrz()

◆ WININET_AddRef()

object_header_t * WININET_AddRef ( object_header_t info)

Definition at line 169 of file internet.c.

170{
171 ULONG refs = InterlockedIncrement(&info->refs);
172 TRACE("%p -> refcount = %d\n", info, refs );
173 return info;
174}
uint32_t ULONG
Definition: typedefs.h:59

Referenced by alloc_async_task(), FTP_Connect(), FTP_FtpOpenFileW(), FTP_ReceiveFileList(), get_handle_object(), HTTP_Connect(), and HTTP_HttpOpenRequestW().

◆ WININET_find_data_WtoA()

static void WININET_find_data_WtoA ( LPWIN32_FIND_DATAW  dataW,
LPWIN32_FIND_DATAA  dataA 
)
inlinestatic

Definition at line 214 of file internet.h.

215{
216 dataA->dwFileAttributes = dataW->dwFileAttributes;
217 dataA->ftCreationTime = dataW->ftCreationTime;
218 dataA->ftLastAccessTime = dataW->ftLastAccessTime;
219 dataA->ftLastWriteTime = dataW->ftLastWriteTime;
220 dataA->nFileSizeHigh = dataW->nFileSizeHigh;
221 dataA->nFileSizeLow = dataW->nFileSizeLow;
222 dataA->dwReserved0 = dataW->dwReserved0;
223 dataA->dwReserved1 = dataW->dwReserved1;
224 WideCharToMultiByte(CP_ACP, 0, dataW->cFileName, -1,
225 dataA->cFileName, sizeof(dataA->cFileName),
226 NULL, NULL);
228 dataA->cAlternateFileName, sizeof(dataA->cAlternateFileName),
229 NULL, NULL);
230}
DWORD dwReserved1
Definition: winbase.h:934
DWORD nFileSizeHigh
Definition: winbase.h:931
DWORD dwReserved0
Definition: winbase.h:933
DWORD dwFileAttributes
Definition: winbase.h:927
FILETIME ftLastAccessTime
Definition: winbase.h:929
CHAR cFileName[MAX_PATH]
Definition: winbase.h:935
CHAR cAlternateFileName[14]
Definition: winbase.h:936
DWORD nFileSizeLow
Definition: winbase.h:932
FILETIME ftCreationTime
Definition: winbase.h:928
FILETIME ftLastWriteTime
Definition: winbase.h:930
FILETIME ftLastWriteTime
Definition: winbase.h:942
WCHAR cFileName[MAX_PATH]
Definition: winbase.h:947
DWORD nFileSizeLow
Definition: winbase.h:944
DWORD nFileSizeHigh
Definition: winbase.h:943
DWORD dwReserved1
Definition: winbase.h:946
DWORD dwReserved0
Definition: winbase.h:945
DWORD dwFileAttributes
Definition: winbase.h:939
FILETIME ftLastAccessTime
Definition: winbase.h:941
FILETIME ftCreationTime
Definition: winbase.h:940
WCHAR cAlternateFileName[14]
Definition: winbase.h:948

Referenced by FtpFindFirstFileA(), and InternetFindNextFileA().

◆ WININET_Release()

BOOL WININET_Release ( object_header_t info)

Definition at line 211 of file internet.c.

212{
213 ULONG refs = InterlockedDecrement(&info->refs);
214 TRACE( "object %p refcount = %d\n", info, refs );
215 if( !refs )
216 {
218 if ( info->vtbl->CloseConnection )
219 {
220 TRACE( "closing connection %p\n", info);
221 info->vtbl->CloseConnection( info );
222 }
223 /* Don't send a callback if this is a session handle created with InternetOpenUrl */
224 if ((info->htype != WH_HHTTPSESSION && info->htype != WH_HFTPSESSION)
225 || !(info->dwInternalFlags & INET_OPENURL))
226 {
227 INTERNET_SendCallback(info, info->dwContext,
229 sizeof(HINTERNET));
230 }
231 TRACE( "destroying object %p\n", info);
232 if ( info->htype != WH_HINIT )
233 list_remove( &info->entry );
234 info->vtbl->Destroy( info );
235
236 if(info->hInternet) {
237 UINT_PTR handle = (UINT_PTR)info->hInternet;
238
240
242 if(next_handle > handle)
244
246 }
247
249 }
250 return TRUE;
251}
static void invalidate_handle(object_header_t *info)
Definition: internet.c:193
#define INTERNET_STATUS_HANDLE_CLOSING
Definition: wininet.h:896

Referenced by FTP_Connect(), FtpCommandW(), FtpCreateDirectoryW(), FtpDeleteFileW(), FTPFILE_Destroy(), FtpFindFirstFileW(), FTPFINDNEXT_Destroy(), FtpGetCurrentDirectoryW(), FtpGetFileW(), FtpOpenFileW(), FtpPutFileW(), FtpRemoveDirectoryW(), FtpRenameFileW(), FTPSESSION_Destroy(), FtpSetCurrentDirectoryW(), HTTP_HttpOpenRequestW(), HttpAddRequestHeadersW(), HttpEndRequestW(), HttpOpenRequestW(), HttpQueryInfoW(), HTTPREQ_Destroy(), HttpSendRequestExW(), HttpSendRequestW(), HTTPSESSION_Destroy(), INTERNET_WorkerThreadFunc(), InternetCloseHandle(), InternetConnectW(), InternetErrorDlg(), InternetFindNextFileW(), InternetLockRequestFile(), InternetOpenUrlW(), InternetQueryDataAvailable(), InternetQueryOptionA(), InternetQueryOptionW(), InternetReadFile(), InternetReadFileExA(), InternetReadFileExW(), InternetSetOptionW(), InternetSetStatusCallbackA(), InternetSetStatusCallbackW(), InternetWriteFile(), and invalidate_handle().

Variable Documentation

◆ DECLSPEC_HIDDEN

HMODULE WININET_hModule DECLSPEC_HIDDEN
extern

Definition at line 289 of file d3dcompiler_private.h.

◆ len

Initial value:
{
#define GetProcessHeap()
Definition: compat.h:736
#define HeapReAlloc
Definition: compat.h:734
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
Definition: mem.c:156

Definition at line 92 of file internet.h.

Referenced by heap_strdupAtoW(), heap_strndupAtoW(), and heap_strndupW().