ReactOS  0.4.15-dev-448-gd6c4411
internet.h File Reference
#include "wine/unicode.h"
#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_INVALID_CN
Definition: internet.h:475
#define _SECURITY_FLAG_CERT_INVALID_DATE
Definition: internet.h:476
#define _SECURITY_FLAG_CERT_INVALID_CA
Definition: internet.h:474
#define _SECURITY_FLAG_CERT_REV_FAILED
Definition: internet.h:473

Definition at line 478 of file internet.h.

◆ _SECURITY_FLAG_CERT_INVALID_CA

#define _SECURITY_FLAG_CERT_INVALID_CA   0x01000000

Definition at line 474 of file internet.h.

◆ _SECURITY_FLAG_CERT_INVALID_CN

#define _SECURITY_FLAG_CERT_INVALID_CN   0x02000000

Definition at line 475 of file internet.h.

◆ _SECURITY_FLAG_CERT_INVALID_DATE

#define _SECURITY_FLAG_CERT_INVALID_DATE   0x04000000

Definition at line 476 of file internet.h.

◆ _SECURITY_FLAG_CERT_REV_FAILED

#define _SECURITY_FLAG_CERT_REV_FAILED   0x00800000

Definition at line 473 of file internet.h.

◆ HDR_COMMADELIMITED

#define HDR_COMMADELIMITED   0x0002

Definition at line 316 of file internet.h.

◆ HDR_ISREQUEST

#define HDR_ISREQUEST   0x0001

Definition at line 315 of file internet.h.

◆ HDR_SEMIDELIMITED

#define HDR_SEMIDELIMITED   0x0004

Definition at line 317 of file internet.h.

◆ INET_CALLBACKW

#define INET_CALLBACKW   0x0002

Definition at line 245 of file internet.h.

◆ INET_OPENURL

#define INET_OPENURL   0x0001

Definition at line 244 of file internet.h.

◆ INTERNET_HANDLE_IN_USE

#define INTERNET_HANDLE_IN_USE   1

Definition at line 270 of file internet.h.

◆ MAX_REPLY_LEN

#define MAX_REPLY_LEN   0x5B4

Definition at line 463 of file internet.h.

◆ READ_BUFFER_SIZE

#define READ_BUFFER_SIZE   8192

Definition at line 342 of file internet.h.

Typedef Documentation

◆ async_task_proc_t

typedef void(* async_task_proc_t) (task_header_t *)

Definition at line 386 of file internet.h.

◆ data_stream_vtbl_t

Definition at line 330 of file internet.h.

◆ LPHTTPHEADERW

◆ object_header_t

Definition at line 256 of file internet.h.

◆ task_header_t

Definition at line 385 of file internet.h.

Enumeration Type Documentation

◆ collect_type_t

Enumerator
COLLECT_TIMEOUT 
COLLECT_CONNECTIONS 
COLLECT_CLEANUP 

Definition at line 60 of file internet.h.

◆ WH_TYPE

Enumerator
WH_HINIT 
WH_HFTPSESSION 
WH_HGOPHERSESSION 
WH_HHTTPSESSION 
WH_HFILE 
WH_HFTPFINDNEXT 
WH_HHTTPREQ 

Definition at line 233 of file internet.h.

234 {
242 } WH_TYPE;
#define INTERNET_HANDLE_TYPE_CONNECT_GOPHER
Definition: wininet.h:804
WH_TYPE
Definition: internet.h:233
#define INTERNET_HANDLE_TYPE_FTP_FILE
Definition: wininet.h:808
#define INTERNET_HANDLE_TYPE_CONNECT_FTP
Definition: wininet.h:803
#define INTERNET_HANDLE_TYPE_HTTP_REQUEST
Definition: wininet.h:814
#define INTERNET_HANDLE_TYPE_INTERNET
Definition: wininet.h:802
#define INTERNET_HANDLE_TYPE_CONNECT_HTTP
Definition: wininet.h:805
#define INTERNET_HANDLE_TYPE_FTP_FIND
Definition: wininet.h:806

Function Documentation

◆ __WINE_ALLOC_SIZE()

static void* __WINE_ALLOC_SIZE ( )
inlinestatic

◆ alloc_async_task()

void* alloc_async_task ( object_header_t ,
async_task_proc_t  ,
size_t   
)

Definition at line 3777 of file internet.c.

3778 {
3779  task_header_t *task;
3780 
3781  task = heap_alloc(size);
3782  if(!task)
3783  return NULL;
3784 
3785  task->hdr = WININET_AddRef(hdr);
3786  task->proc = proc;
3787  return task;
3788 }
char hdr[14]
Definition: iptest.cpp:33
static HANDLE proc()
Definition: pdb.c:32
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
smooth NULL
Definition: ftsmooth.c:416
object_header_t * WININET_AddRef(object_header_t *info)
Definition: internet.c:177
GLsizeiptr size
Definition: glext.h:5919
object_header_t * hdr
Definition: internet.h:391
async_task_proc_t proc
Definition: internet.h:390

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 ,
const object_vtbl_t ,
size_t   
)

Definition at line 111 of file internet.c.

112 {
113  UINT_PTR handle = 0, num;
115  object_header_t **p;
116  BOOL res = TRUE;
117 
118  ret = heap_alloc_zero(size);
119  if(!ret)
120  return NULL;
121 
122  list_init(&ret->children);
123 
125 
126  if(!handle_table_size) {
127  num = 16;
128  p = heap_alloc_zero(sizeof(handle_table[0]) * num);
129  if(p) {
130  handle_table = p;
132  next_handle = 1;
133  }else {
134  res = FALSE;
135  }
136  }else if(next_handle == handle_table_size) {
137  num = handle_table_size * 2;
138  p = heap_realloc_zero(handle_table, sizeof(handle_table[0]) * num);
139  if(p) {
140  handle_table = p;
142  }else {
143  res = FALSE;
144  }
145  }
146 
147  if(res) {
149  if(handle_table[handle])
150  ERR("handle isn't free but should be\n");
152  ret->valid_handle = TRUE;
153 
155  next_handle++;
156  }
157 
159 
160  if(!res) {
161  heap_free(ret);
162  return NULL;
163  }
164 
165  ret->vtbl = vtbl;
166  ret->refs = 1;
167  ret->hInternet = (HINTERNET)handle;
168 
169  if(parent) {
170  ret->lpfnStatusCB = parent->lpfnStatusCB;
171  ret->dwInternalFlags = parent->dwInternalFlags & INET_CALLBACKW;
172  }
173 
174  return ret;
175 }
LPVOID HINTERNET
Definition: winhttp.h:32
namespace GUID const ADDRINFOEXW ADDRINFOEXW struct timeval OVERLAPPED LPLOOKUPSERVICE_COMPLETION_ROUTINE HANDLE * handle
Definition: sock.c:82
#define TRUE
Definition: types.h:120
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
#define INET_CALLBACKW
Definition: internet.h:245
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
static UINT_PTR next_handle
Definition: internet.c:88
GLsizeiptr size
Definition: glext.h:5919
r parent
Definition: btrfs.c:2944
static UINT_PTR handle_table_size
Definition: internet.c:89
static CRITICAL_SECTION WININET_cs
Definition: internet.c:78
GLuint GLuint num
Definition: glext.h:9618
unsigned __int3264 UINT_PTR
Definition: mstsclib_h.h:274
int ret
#define ERR(fmt,...)
Definition: debug.h:110
GLuint res
Definition: glext.h:9613
__WINE_SERVER_LIST_INLINE void list_init(struct list *list)
Definition: list.h:149
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
GLfloat GLfloat p
Definition: glext.h:8902
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

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

◆ close_netconn()

void close_netconn ( netconn_t )

Definition at line 375 of file netconnection.c.

376 {
378  netconn->socket = -1;
379 }
#define closesocket
Definition: precomp.h:57

Referenced by free_netconn(), and http_release_netconn().

◆ collect_connections()

BOOL collect_connections ( collect_type_t  )

Definition at line 310 of file http.c.

311 {
312  netconn_t *netconn, *netconn_safe;
313  server_t *server, *server_safe;
314  BOOL remaining = FALSE;
315  DWORD64 now;
316 
317 #ifdef __REACTOS__
318  now = GetTickCount();
319 #else
320  now = GetTickCount64();
321 #endif
322 
324  LIST_FOR_EACH_ENTRY_SAFE(netconn, netconn_safe, &server->conn_pool, netconn_t, pool_entry) {
325  if(collect_type > COLLECT_TIMEOUT || netconn->keep_until < now) {
326  TRACE("freeing %p\n", netconn);
327  list_remove(&netconn->pool_entry);
329  }else {
330  remaining = TRUE;
331  }
332  }
333 
334  if(collect_type == COLLECT_CLEANUP) {
335  list_remove(&server->entry);
336  list_init(&server->entry);
338  }
339  }
340 
341  return remaining;
342 }
ULONGLONG keep_until
#define TRUE
Definition: types.h:120
static rfbScreenInfoPtr server
Definition: vnc.c:74
DWORD WINAPI GetTickCount(VOID)
Definition: time.c:455
void server_release(server_t *server)
Definition: http.c:226
ULONGLONG WINAPI GetTickCount64(VOID)
Definition: GetTickCount64.c:9
unsigned int BOOL
Definition: ntddk_ex.h:94
time_t now
Definition: finger.c:65
void free_netconn(netconn_t *) DECLSPEC_HIDDEN
__WINE_SERVER_LIST_INLINE void list_remove(struct list *elem)
Definition: list.h:108
#define TRACE(s)
Definition: solgame.cpp:4
uint32_t entry
Definition: isohybrid.c:63
#define LIST_FOR_EACH_ENTRY_SAFE(cursor, cursor2, list, type, field)
Definition: list.h:204
uint64_t DWORD64
Definition: typedefs.h:66
__WINE_SERVER_LIST_INLINE void list_init(struct list *list)
Definition: list.h:149
static struct list connection_pool
Definition: http.c:218

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 = strlenW(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 */
64  if (strlenW(asctime) >= TIME_STRING_LEN) FIXME("\n");
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 = atoiW(tmpChar+12) - 1900;
80  t.tm_mday = atoiW(tmpChar+5);
81  t.tm_hour = atoiW(tmpChar+17);
82  t.tm_min = atoiW(tmpChar+20);
83  t.tm_sec = atoiW(tmpChar+23);
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 }
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
GLdouble GLdouble t
Definition: gl.h:2047
_Check_return_ _CRTIMP char *__cdecl asctime(_In_ const struct tm *_Tm)
#define lstrcpynW
Definition: compat.h:406
#define FIXME(fmt,...)
Definition: debug.h:111
#define TIME_STRING_LEN
Definition: utility.c:47
__wchar_t WCHAR
Definition: xmlstorage.h:180
Definition: time.h:76
_CRTIMP time_t __cdecl mktime(struct tm *_Tm)
Definition: time.h:426
#define memset(x, y, z)
Definition: compat.h:39
WINE_UNICODE_INLINE int atoiW(const WCHAR *str)
Definition: unicode.h:315

Referenced by HTTP_HttpQueryInfoW().

◆ create_netconn()

DWORD create_netconn ( server_t ,
DWORD  ,
BOOL  ,
DWORD  ,
netconn_t **   
)

Definition at line 343 of file netconnection.c.

344 {
346  int result;
347 
348  netconn = heap_alloc_zero(sizeof(*netconn));
349  if(!netconn)
350  return ERROR_OUTOFMEMORY;
351 
352  netconn->socket = -1;
353  netconn->security_flags = security_flags | server->security_flags;
354  netconn->mask_errors = mask_errors;
355  list_init(&netconn->pool_entry);
357 
359  if (result != ERROR_SUCCESS) {
361  return result;
362  }
363 
365  netconn->server = server;
366  *ret = netconn;
367  return result;
368 }
static rfbScreenInfoPtr server
Definition: vnc.c:74
#define ERROR_SUCCESS
Definition: deptool.c:10
Definition: dhcpd.h:245
#define SecInvalidateHandle(x)
Definition: sspi.h:58
CtxtHandle ssl_ctx
int ret
void server_addref(server_t *server)
Definition: http.c:221
__WINE_SERVER_LIST_INLINE void list_init(struct list *list)
Definition: list.h:149
static DWORD create_netconn_socket(server_t *server, netconn_t *netconn, DWORD timeout)
GLuint64EXT * result
Definition: glext.h:11304
#define ERROR_OUTOFMEMORY
Definition: deptool.c:13
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

Referenced by open_http_connection().

◆ create_req_file()

DWORD create_req_file ( const WCHAR ,
req_file_t **   
)

Definition at line 3871 of file internet.c.

3872 {
3873  req_file_t *req_file;
3874 
3875  req_file = heap_alloc_zero(sizeof(*req_file));
3876  if(!req_file)
3877  return ERROR_NOT_ENOUGH_MEMORY;
3878 
3879  req_file->ref = 1;
3880 
3881  req_file->file_name = heap_strdupW(file_name);
3882  if(!req_file->file_name) {
3883  heap_free(req_file);
3884  return ERROR_NOT_ENOUGH_MEMORY;
3885  }
3886 
3889  if(req_file->file_handle == INVALID_HANDLE_VALUE) {
3890  req_file_release(req_file);
3891  return GetLastError();
3892  }
3893 
3894  *ret = req_file;
3895  return ERROR_SUCCESS;
3896 }
void req_file_release(req_file_t *req_file)
Definition: internet.c:3898
#define ERROR_SUCCESS
Definition: deptool.c:10
LONG ref
Definition: internet.h:249
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
#define INVALID_HANDLE_VALUE
Definition: compat.h:400
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
#define FILE_SHARE_READ
Definition: compat.h:125
static WCHAR * heap_strdupW(const WCHAR *str)
Definition: propsheet.c:178
smooth NULL
Definition: ftsmooth.c:416
HANDLE file_handle
Definition: internet.h:250
#define OPEN_EXISTING
Definition: compat.h:435
int ret
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:126
#define GENERIC_READ
Definition: compat.h:124
static LPCWSTR file_name
Definition: protocol.c:147
#define CreateFileW
Definition: compat.h:409
WCHAR * file_name
Definition: internet.h:251
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

Referenced by create_cache_entry().

◆ free_authorization_cache()

void free_authorization_cache ( void  )

Definition at line 1041 of file http.c.

1042 {
1043  authorizationData *ad, *sa_safe;
1044  basicAuthorizationData *basic, *basic_safe;
1045 
1047 
1049  {
1050  heap_free(basic->host);
1051  heap_free(basic->realm);
1052  heap_free(basic->authorization);
1053 
1054  list_remove(&basic->entry);
1055  heap_free(basic);
1056  }
1057 
1059  {
1060  heap_free(ad->host);
1061  heap_free(ad->scheme);
1062  heap_free(ad->user);
1063  heap_free(ad->password);
1064  heap_free(ad->domain);
1065  list_remove(&ad->entry);
1066  heap_free(ad);
1067  }
1068 
1070 }
static struct list basicAuthorizationCache
Definition: http.c:186
struct list entry
Definition: http.c:174
LPWSTR password
Definition: http.c:182
LPWSTR domain
Definition: http.c:178
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
__WINE_SERVER_LIST_INLINE void list_remove(struct list *elem)
Definition: list.h:108
uint32_t entry
Definition: isohybrid.c:63
#define LIST_FOR_EACH_ENTRY_SAFE(cursor, cursor2, list, type, field)
Definition: list.h:204
LPWSTR scheme
Definition: http.c:177
struct list entry
Definition: http.c:164
LPWSTR host
Definition: http.c:176
LPWSTR user
Definition: http.c:180
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
static BOOL heap_free(void *mem)
Definition: appwiz.h:75
static struct list authorizationCache
Definition: http.c:187
static CRITICAL_SECTION authcache_cs
Definition: http.c:189

Referenced by InternetSetOptionW().

◆ free_cookie()

void free_cookie ( void  )

Definition at line 1266 of file cookie.c.

1267 {
1269 
1271 
1273 }
static void free_cookie_domain_list(struct list *list)
Definition: cookie.c:686
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
static CRITICAL_SECTION cookie_cs
Definition: cookie.c:87
static struct list domain_list
Definition: cookie.c:95
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)

◆ free_netconn()

void free_netconn ( netconn_t )

Definition at line 381 of file netconnection.c.

382 {
383  server_release(netconn->server);
384 
385  if (netconn->secure) {
388  netconn->peek_msg = NULL;
389  netconn->peek_len = 0;
391  netconn->ssl_buf = NULL;
394  netconn->extra_len = 0;
395  }
398 
401 }
char * peek_msg_mem
size_t peek_len
void close_netconn(netconn_t *netconn)
char * extra_buf
size_t extra_len
char * peek_msg
#define SecIsValidHandle(x)
Definition: sspi.h:63
void server_release(server_t *server)
Definition: http.c:226
smooth NULL
Definition: ftsmooth.c:416
CtxtHandle ssl_ctx
char * ssl_buf
SECURITY_STATUS WINAPI DeleteSecurityContext(PCtxtHandle phContext)
Definition: wrapper.c:450
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

Referenced by collect_connections(), and open_http_connection().

◆ free_urlcache()

void free_urlcache ( void  )

Definition at line 4142 of file urlcache.c.

4143 {
4149 
4151 }
#define CloseHandle
Definition: compat.h:407
static HANDLE dll_unload_event
Definition: urlcache.c:2252
static void cache_containers_free(void)
Definition: urlcache.c:837
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent(IN HANDLE hEvent)
Definition: synch.c:733
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
smooth NULL
Definition: ftsmooth.c:416
static HANDLE free_cache_running
Definition: urlcache.c:2251
BOOL WINAPI DECLSPEC_HOTPATCH ReleaseSemaphore(IN HANDLE hSemaphore, IN LONG lReleaseCount, IN LPLONG lpPreviousCount)
Definition: synch.c:542
#define INFINITE
Definition: serial.h:102

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 2425 of file ftp.c.

2429 {
2430  static const WCHAR szKey[] = {'S','o','f','t','w','a','r','e','\\',
2431  'M','i','c','r','o','s','o','f','t','\\',
2432  'W','i','n','d','o','w','s','\\',
2433  'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
2434  'I','n','t','e','r','n','e','t',' ','S','e','t','t','i','n','g','s',0};
2435  static const WCHAR szValue[] = {'E','m','a','i','l','N','a','m','e',0};
2436  static const WCHAR szDefaultUsername[] = {'a','n','o','n','y','m','o','u','s','\0'};
2437  static const WCHAR szEmpty[] = {'\0'};
2438  struct sockaddr_in socketAddr;
2439  INT nsocket = -1;
2440  socklen_t sock_namelen;
2441  BOOL bSuccess = FALSE;
2442  ftp_session_t *lpwfs = NULL;
2443  char szaddr[INET6_ADDRSTRLEN];
2444 
2445  TRACE("%p Server(%s) Port(%d) User(%s) Paswd(%s)\n",
2446  hIC, debugstr_w(lpszServerName),
2447  nServerPort, debugstr_w(lpszUserName), debugstr_w(lpszPassword));
2448 
2449  assert( hIC->hdr.htype == WH_HINIT );
2450 
2451  if ((!lpszUserName || !*lpszUserName) && lpszPassword && *lpszPassword)
2452  {
2454  return NULL;
2455  }
2456 
2457  lpwfs = alloc_object(&hIC->hdr, &FTPSESSIONVtbl, sizeof(ftp_session_t));
2458  if (NULL == lpwfs)
2459  {
2461  return NULL;
2462  }
2463 
2464  if (nServerPort == INTERNET_INVALID_PORT_NUMBER)
2466  else
2467  lpwfs->serverport = nServerPort;
2468 
2469  lpwfs->hdr.htype = WH_HFTPSESSION;
2470  lpwfs->hdr.dwFlags = dwFlags;
2471  lpwfs->hdr.dwContext = dwContext;
2472  lpwfs->hdr.dwInternalFlags |= dwInternalFlags;
2473  lpwfs->download_in_progress = NULL;
2474  lpwfs->sndSocket = -1;
2475  lpwfs->lstnSocket = -1;
2476  lpwfs->pasvSocket = -1;
2477 
2478  WININET_AddRef( &hIC->hdr );
2479  lpwfs->lpAppInfo = hIC;
2480  list_add_head( &hIC->hdr.children, &lpwfs->hdr.entry );
2481 
2482  if(hIC->proxy && hIC->accessType == INTERNET_OPEN_TYPE_PROXY) {
2483  if(strchrW(hIC->proxy, ' '))
2484  FIXME("Several proxies not implemented.\n");
2485  if(hIC->proxyBypass)
2486  FIXME("Proxy bypass is ignored.\n");
2487  }
2488  if (!lpszUserName || !lpszUserName[0]) {
2489  HKEY key;
2490  WCHAR szPassword[MAX_PATH];
2491  DWORD len = sizeof(szPassword);
2492 
2493  lpwfs->lpszUserName = heap_strdupW(szDefaultUsername);
2494 
2495  RegOpenKeyW(HKEY_CURRENT_USER, szKey, &key);
2496  if (RegQueryValueExW(key, szValue, NULL, NULL, (LPBYTE)szPassword, &len)) {
2497  /* Nothing in the registry, get the username and use that as the password */
2498  if (!GetUserNameW(szPassword, &len)) {
2499  /* Should never get here, but use an empty password as failsafe */
2500  strcpyW(szPassword, szEmpty);
2501  }
2502  }
2503  RegCloseKey(key);
2504 
2505  TRACE("Password used for anonymous ftp : (%s)\n", debugstr_w(szPassword));
2506  lpwfs->lpszPassword = heap_strdupW(szPassword);
2507  }
2508  else {
2509  lpwfs->lpszUserName = heap_strdupW(lpszUserName);
2511  }
2512  lpwfs->servername = heap_strdupW(lpszServerName);
2513 
2514  /* Don't send a handle created callback if this handle was created with InternetOpenUrl */
2515  if (!(lpwfs->hdr.dwInternalFlags & INET_OPENURL))
2516  {
2518 
2519  iar.dwResult = (DWORD_PTR)lpwfs->hdr.hInternet;
2520  iar.dwError = ERROR_SUCCESS;
2521 
2522  INTERNET_SendCallback(&hIC->hdr, dwContext,
2524  sizeof(INTERNET_ASYNC_RESULT));
2525  }
2526 
2528  (LPWSTR) lpszServerName, (strlenW(lpszServerName)+1) * sizeof(WCHAR));
2529 
2530  sock_namelen = sizeof(socketAddr);
2531  if (!GetAddress(lpszServerName, lpwfs->serverport, (struct sockaddr *)&socketAddr, &sock_namelen, szaddr))
2532  {
2534  goto lerror;
2535  }
2536 
2537  if (socketAddr.sin_family != AF_INET)
2538  {
2539  WARN("unsupported address family %d\n", socketAddr.sin_family);
2541  goto lerror;
2542  }
2543 
2545  szaddr, strlen(szaddr)+1);
2546 
2547  init_winsock();
2548  nsocket = socket(AF_INET,SOCK_STREAM,0);
2549  if (nsocket == -1)
2550  {
2552  goto lerror;
2553  }
2554 
2556  szaddr, strlen(szaddr)+1);
2557 
2558  if (connect(nsocket, (struct sockaddr *)&socketAddr, sock_namelen) < 0)
2559  {
2560  ERR("Unable to connect (%d)\n", WSAGetLastError());
2562  closesocket(nsocket);
2563  }
2564  else
2565  {
2566  TRACE("Connected to server\n");
2567  lpwfs->sndSocket = nsocket;
2569  szaddr, strlen(szaddr)+1);
2570 
2571  sock_namelen = sizeof(lpwfs->socketAddress);
2572  getsockname(nsocket, (struct sockaddr *) &lpwfs->socketAddress, &sock_namelen);
2573 
2574  if (FTP_ConnectToHost(lpwfs))
2575  {
2576  TRACE("Successfully logged into server\n");
2577  bSuccess = TRUE;
2578  }
2579  }
2580 
2581 lerror:
2582  if (!bSuccess)
2583  {
2584  WININET_Release(&lpwfs->hdr);
2585  return NULL;
2586  }
2587 
2588  return lpwfs->hdr.hInternet;
2589 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define TRUE
Definition: types.h:120
SOCKET WSAAPI socket(IN INT af, IN INT type, IN INT protocol)
Definition: socklife.c:143
static BOOL FTP_ConnectToHost(ftp_session_t *)
Definition: ftp.c:2602
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
#define ERROR_SUCCESS
Definition: deptool.c:10
void INTERNET_SetLastError(DWORD dwError)
Definition: internet.c:3720
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
WINE_UNICODE_INLINE WCHAR * strchrW(const WCHAR *str, WCHAR ch)
Definition: unicode.h:248
#define HKEY_CURRENT_USER
Definition: winreg.h:11
struct sockaddr_in socketAddress
Definition: ftp.c:77
LPWSTR lpszUserName
Definition: ftp.c:82
LPWSTR servername
Definition: ftp.c:79
#define WARN(fmt,...)
Definition: debug.h:112
#define INTERNET_STATUS_CONNECTING_TO_SERVER
Definition: wininet.h:885
#define closesocket
Definition: precomp.h:57
__WINE_SERVER_LIST_INLINE void list_add_head(struct list *list, struct list *elem)
Definition: list.h:96
struct list children
Definition: internet.h:287
#define INTERNET_OPEN_TYPE_PROXY
Definition: wininet.h:523
#define assert(x)
Definition: debug.h:53
ftp_file_t * download_in_progress
Definition: ftp.c:76
_In_opt_ LPSTR _In_opt_ LPSTR lpszPassword
Definition: winbase.h:2674
INT WSAAPI connect(IN SOCKET s, IN CONST struct sockaddr *name, IN INT namelen)
Definition: sockctrl.c:23
int32_t INT
Definition: typedefs.h:57
static BOOLEAN bSuccess
Definition: drive.cpp:419
VOID INTERNET_SendCallback(object_header_t *hdr, DWORD_PTR dwContext, DWORD dwInternetStatus, LPVOID lpvStatusInfo, DWORD dwStatusInfoLength) DECLSPEC_HIDDEN
#define INTERNET_INVALID_PORT_NUMBER
Definition: wininet.h:36
DWORD_PTR dwContext
Definition: internet.h:279
#define ERROR_INTERNET_CANNOT_CONNECT
Definition: wininet.h:2018
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:53
unsigned int BOOL
Definition: ntddk_ex.h:94
BOOL GetAddress(const WCHAR *, INTERNET_PORT, SOCKADDR *, int *, char *) DECLSPEC_HIDDEN
Definition: utility.c:133
static WCHAR * heap_strdupW(const WCHAR *str)
Definition: propsheet.c:178
LONG WINAPI RegOpenKeyW(HKEY hKey, LPCWSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:3296
#define debugstr_w
Definition: kernel32.h:32
DWORD accessType
Definition: internet.h:298
#define FIXME(fmt,...)
Definition: debug.h:111
static DWORD_PTR
Definition: ftp.c:44
smooth NULL
Definition: ftsmooth.c:416
object_header_t * WININET_AddRef(object_header_t *info)
Definition: internet.c:177
int pasvSocket
Definition: ftp.c:75
#define INTERNET_STATUS_NAME_RESOLVED
Definition: wininet.h:884
static const WCHAR szEmpty[]
Definition: provider.c:50
BOOL WINAPI GetUserNameW(LPWSTR lpszName, LPDWORD lpSize)
Definition: misc.c:291
#define TRACE(s)
Definition: solgame.cpp:4
INT WSAAPI WSAGetLastError(VOID)
Definition: dllmain.c:112
object_header_t hdr
Definition: ftp.c:71
INTERNET_PORT serverport
Definition: ftp.c:80
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4116
__wchar_t WCHAR
Definition: xmlstorage.h:180
LPWSTR lpszPassword
Definition: ftp.c:81
struct list entry
Definition: internet.h:286
#define MAX_PATH
Definition: compat.h:26
unsigned long DWORD
Definition: ntddk_ex.h:95
int socklen_t
Definition: tcp.c:35
#define ERROR_INTERNET_NAME_NOT_RESOLVED
Definition: wininet.h:1996
#define INTERNET_DEFAULT_FTP_PORT
Definition: wininet.h:38
DWORD_PTR dwResult
Definition: wininet.h:155
LPWSTR proxy
Definition: internet.h:294
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
HKEY key
Definition: reg.c:42
void * alloc_object(object_header_t *parent, const object_vtbl_t *vtbl, size_t size)
Definition: internet.c:111
GLenum GLsizei len
Definition: glext.h:6722
#define INTERNET_STATUS_RESOLVING_NAME
Definition: wininet.h:883
HINTERNET hInternet
Definition: internet.h:276
int sndSocket
Definition: ftp.c:73
BOOL WININET_Release(object_header_t *info)
Definition: internet.c:219
#define ERR(fmt,...)
Definition: debug.h:110
object_header_t hdr
Definition: internet.h:292
DWORD dwInternalFlags
Definition: internet.h:282
WINE_UNICODE_INLINE WCHAR * strcpyW(WCHAR *dst, const WCHAR *src)
Definition: unicode.h:219
int lstnSocket
Definition: ftp.c:74
#define INET_OPENURL
Definition: internet.h:244
static const object_vtbl_t FTPSESSIONVtbl
Definition: ftp.c:2393
#define INTERNET_STATUS_CONNECTED_TO_SERVER
Definition: wininet.h:886
#define INET6_ADDRSTRLEN
Definition: ws2ipdef.h:132
#define AF_INET
Definition: tcpip.h:117
#define INTERNET_STATUS_HANDLE_CREATED
Definition: wininet.h:895
#define SOCK_STREAM
Definition: tcpip.h:118
WCHAR * LPWSTR
Definition: xmlstorage.h:184
appinfo_t * lpAppInfo
Definition: ftp.c:72
LPWSTR proxyBypass
Definition: internet.h:295
WH_TYPE htype
Definition: internet.h:274
INT WSAAPI getsockname(IN SOCKET s, OUT LPSOCKADDR name, IN OUT INT FAR *namelen)
Definition: sockctrl.c:213
void init_winsock(void) DECLSPEC_HIDDEN
#define ERROR_OUTOFMEMORY
Definition: deptool.c:13
Definition: path.c:41

Referenced by INTERNET_InternetOpenUrlW(), and InternetConnectW().

◆ get_cookie_header()

DWORD get_cookie_header ( const WCHAR ,
const WCHAR ,
WCHAR **   
)

Definition at line 643 of file cookie.c.

644 {
645  cookie_set_t cookie_set = {0};
646  DWORD res;
647 
648  static const WCHAR cookieW[] = {'C','o','o','k','i','e',':',' '};
649 
651 
653  if(res != ERROR_SUCCESS) {
655  return res;
656  }
657 
658  if(cookie_set.cnt) {
659  WCHAR *header, *ptr;
660 
661  ptr = header = heap_alloc(sizeof(cookieW) + (cookie_set.string_len + 3 /* crlf0 */) * sizeof(WCHAR));
662  if(header) {
663  memcpy(ptr, cookieW, sizeof(cookieW));
664  ptr += ARRAY_SIZE(cookieW);
665 
666  cookie_set_to_string(&cookie_set, ptr);
667  heap_free(cookie_set.cookies);
668  ptr += cookie_set.string_len;
669 
670  *ptr++ = '\r';
671  *ptr++ = '\n';
672  *ptr++ = 0;
673 
674  *ret = header;
675  }else {
677  }
678  }else {
679  *ret = NULL;
680  }
681 
683  return res;
684 }
#define ERROR_SUCCESS
Definition: deptool.c:10
static substr_t substrz(const WCHAR *str)
Definition: internet.h:210
char * host
Definition: whois.c:55
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
static DWORD get_cookie(substr_t host, substr_t path, DWORD flags, cookie_set_t *res)
Definition: cookie.c:530
static void cookie_set_to_string(const cookie_set_t *cookie_set, WCHAR *str)
Definition: cookie.c:616
static PVOID ptr
Definition: dispmode.c:27
smooth NULL
Definition: ftsmooth.c:416
static CRITICAL_SECTION cookie_cs
Definition: cookie.c:87
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
cookie_t ** cookies
Definition: cookie.c:523
int ret
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define ARRAY_SIZE(a)
Definition: main.h:24
unsigned string_len
Definition: cookie.c:527
GLuint res
Definition: glext.h:9613
unsigned cnt
Definition: cookie.c:524
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
#define INTERNET_COOKIE_HTTPONLY
Definition: wininet.h:1828
struct CFHEADER header
Definition: fdi.c:101
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

Referenced by HTTP_InsertCookies().

◆ get_handle_object()

object_header_t* get_handle_object ( HINTERNET  hinternet)

Definition at line 184 of file internet.c.

185 {
187  UINT_PTR handle = (UINT_PTR) hinternet;
188 
190 
193 
195 
196  TRACE("handle %ld -> %p\n", handle, info);
197 
198  return info;
199 }
unsigned __int3264 UINT_PTR
Definition: activex.cpp:275
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
struct _test_info info[]
Definition: SetCursorPos.c:19
__inline int valid_handle(HANDLE handle)
Definition: util.h:281
smooth NULL
Definition: ftsmooth.c:416
object_header_t * WININET_AddRef(object_header_t *info)
Definition: internet.c:177
#define TRACE(s)
Definition: solgame.cpp:4
static UINT_PTR handle_table_size
Definition: internet.c:89
static CRITICAL_SECTION WININET_cs
Definition: internet.c:78
unsigned __int3264 UINT_PTR
Definition: mstsclib_h.h:274
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)

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

◆ get_server()

server_t* get_server ( substr_t  ,
INTERNET_PORT  ,
BOOL  ,
BOOL   
)

Definition at line 273 of file http.c.

274 {
275  server_t *iter, *server = NULL;
276 
278 
280  if(iter->port == port && name.len == strlenW(iter->name) && !strncmpiW(iter->name, name.str, name.len)
281  && iter->is_https == is_https) {
282  server = iter;
284  break;
285  }
286  }
287 
288  if(!server && do_create) {
289  server = heap_alloc_zero(sizeof(*server));
290  if(server) {
291  server->ref = 2; /* list reference and return */
292  server->port = port;
293  server->is_https = is_https;
294  list_init(&server->conn_pool);
295  server->name = heap_strndupW(name.str, name.len);
296  if(server->name && process_host_port(server)) {
298  }else {
299  heap_free(server);
300  server = NULL;
301  }
302  }
303  }
304 
306 
307  return server;
308 }
static BOOL process_host_port(server_t *server)
Definition: http.c:246
BOOL is_https
Definition: internet.h:39
static LPWSTR heap_strndupW(LPCWSTR str, unsigned len)
static rfbScreenInfoPtr server
Definition: vnc.c:74
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
__WINE_SERVER_LIST_INLINE void list_add_head(struct list *list, struct list *elem)
Definition: list.h:96
#define strncmpiW(s1, s2, n)
Definition: unicode.h:40
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
#define LIST_FOR_EACH_ENTRY(elem, list, type, field)
Definition: list.h:198
INTERNET_PORT port
Definition: internet.h:38
smooth NULL
Definition: ftsmooth.c:416
static CRITICAL_SECTION connection_pool_cs
Definition: http.c:209
uint32_t entry
Definition: isohybrid.c:63
void server_addref(server_t *server)
Definition: http.c:221
WCHAR * name
Definition: internet.h:37
Definition: name.c:38
__WINE_SERVER_LIST_INLINE void list_init(struct list *list)
Definition: list.h:149
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
USHORT port
Definition: uri.c:228
static struct list connection_pool
Definition: http.c:218
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

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

◆ GetAddress()

BOOL GetAddress ( const WCHAR ,
INTERNET_PORT  ,
SOCKADDR ,
int ,
char  
)

Definition at line 133 of file utility.c.

134 {
135  ADDRINFOW *res, hints;
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 
147  ret = GetAddrInfoW(name, NULL, &hints, &res);
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;
152  ret = GetAddrInfoW(name, NULL, &hints, &res);
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 }
namespace GUID const ADDRINFOEXW * hints
Definition: sock.c:80
#define TRUE
Definition: types.h:120
#define WARN(fmt,...)
Definition: debug.h:112
INT WSAAPI GetAddrInfoW(IN PCWSTR pszNodeName, IN PCWSTR pszServiceName, IN const ADDRINFOW *ptHints, OUT PADDRINFOW *pptResult)
Definition: addrinfo.c:509
#define debugstr_w
Definition: kernel32.h:32
smooth NULL
Definition: ftsmooth.c:416
#define AF_INET6
Definition: winsock.h:369
#define TRACE(s)
Definition: solgame.cpp:4
int ret
GLenum const GLvoid * addr
Definition: glext.h:9621
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
static SCRIPT_CACHE SCRIPT_ANALYSIS * psa
Definition: usp10.c:64
WINSOCK_API_LINKAGE VOID WSAAPI FreeAddrInfoW(_In_opt_ PADDRINFOW pAddrInfo)
Definition: name.c:38
GLuint res
Definition: glext.h:9613
#define INET6_ADDRSTRLEN
Definition: ws2ipdef.h:132
#define AF_INET
Definition: tcpip.h:117
const char *WSAAPI inet_ntop(int af, const void *src, char *dst, size_t cnt)
Definition: unix_func.c:8
#define htons(x)
Definition: module.h:213
USHORT port
Definition: uri.c:228
#define memset(x, y, z)
Definition: compat.h:39

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

◆ heap_strdupA()

static char* heap_strdupA ( const char str)
inlinestatic

Definition at line 114 of file internet.h.

115 {
116  char *ret = NULL;
117 
118  if(str) {
119  DWORD size = strlen(str)+1;
120 
121  ret = heap_alloc(size);
122  if(ret)
123  memcpy(ret, str, size);
124  }
125 
126  return ret;
127 }
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
const WCHAR * str
smooth NULL
Definition: ftsmooth.c:416
GLsizeiptr size
Definition: glext.h:5919
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878

◆ heap_strdupAtoW()

static WCHAR* heap_strdupAtoW ( const char str)
inlinestatic

Definition at line 169 of file internet.h.

170 {
171  LPWSTR ret = NULL;
172 
173  if(str) {
174  DWORD len;
175 
176  len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
177  ret = heap_alloc(len*sizeof(WCHAR));
178  if(ret)
179  MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len);
180  }
181 
182  return ret;
183 }
#define CP_ACP
Definition: compat.h:99
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
const WCHAR * str
smooth NULL
Definition: ftsmooth.c:416
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
GLenum GLsizei len
Definition: glext.h:6722
#define MultiByteToWideChar
Definition: compat.h:100
WCHAR * LPWSTR
Definition: xmlstorage.h:184
static void size_t len
Definition: internet.h:94

◆ heap_strdupW()

static LPWSTR heap_strdupW ( LPCWSTR  str)
inlinestatic

Definition at line 98 of file internet.h.

99 {
100  LPWSTR ret = NULL;
101 
102  if(str) {
103  DWORD size;
104 
105  size = (strlenW(str)+1)*sizeof(WCHAR);
106  ret = heap_alloc(size);
107  if(ret)
108  memcpy(ret, str, size);
109  }
110 
111  return ret;
112 }
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
const WCHAR * str
smooth NULL
Definition: ftsmooth.c:416
GLsizeiptr size
Definition: glext.h:5919
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
WCHAR * LPWSTR
Definition: xmlstorage.h:184

◆ heap_strdupWtoA()

static char* heap_strdupWtoA ( LPCWSTR  str)
inlinestatic

Definition at line 185 of file internet.h.

186 {
187  char *ret = NULL;
188 
189  if(str) {
191  ret = heap_alloc(size);
192  if(ret)
194  }
195 
196  return ret;
197 }
#define WideCharToMultiByte
Definition: compat.h:101
#define CP_ACP
Definition: compat.h:99
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
const WCHAR * str
smooth NULL
Definition: ftsmooth.c:416
GLsizeiptr size
Definition: glext.h:5919
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret

◆ heap_strndupAtoW()

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

Definition at line 150 of file internet.h.

151 {
152  WCHAR *ret = NULL;
153 
154  if(str) {
155  size_t len;
156  if(len_a < 0) len_a = strlen(str);
157  len = MultiByteToWideChar(CP_ACP, 0, str, len_a, NULL, 0);
158  ret = heap_alloc((len+1)*sizeof(WCHAR));
159  if(ret) {
160  MultiByteToWideChar(CP_ACP, 0, str, len_a, ret, len);
161  ret[len] = 0;
162  *len_w = len;
163  }
164  }
165 
166  return ret;
167 }
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define CP_ACP
Definition: compat.h:99
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
const WCHAR * str
smooth NULL
Definition: ftsmooth.c:416
__wchar_t WCHAR
Definition: xmlstorage.h:180
int ret
GLenum GLsizei len
Definition: glext.h:6722
#define MultiByteToWideChar
Definition: compat.h:100
static void size_t len
Definition: internet.h:94

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 129 of file internet.h.

130 {
131  LPWSTR ret;
132  UINT len;
133 
134  if(!str)
135  return NULL;
136 
137  for(len=0; len<max_len; len++)
138  if(str[len] == '\0')
139  break;
140 
141  ret = heap_alloc(sizeof(WCHAR)*(len+1));
142  if(ret) {
143  memcpy(ret, str, sizeof(WCHAR)*len);
144  ret[len] = '\0';
145  }
146 
147  return ret;
148 }
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
const WCHAR * str
smooth NULL
Definition: ftsmooth.c:416
__wchar_t WCHAR
Definition: xmlstorage.h:180
int ret
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
GLenum GLsizei len
Definition: glext.h:6722
unsigned int UINT
Definition: ndis.h:50
WCHAR * LPWSTR
Definition: xmlstorage.h:184
static void size_t len
Definition: internet.h:94

◆ HTTP_Connect()

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

Definition at line 5872 of file http.c.

5876 {
5878 
5879  TRACE("-->\n");
5880 
5881  if (!lpszServerName || !lpszServerName[0])
5882  return ERROR_INVALID_PARAMETER;
5883 
5884  assert( hIC->hdr.htype == WH_HINIT );
5885 
5886  session = alloc_object(&hIC->hdr, &HTTPSESSIONVtbl, sizeof(http_session_t));
5887  if (!session)
5888  return ERROR_OUTOFMEMORY;
5889 
5890  /*
5891  * According to my tests. The name is not resolved until a request is sent
5892  */
5893 
5894  session->hdr.htype = WH_HHTTPSESSION;
5895  session->hdr.dwFlags = dwFlags;
5896  session->hdr.dwContext = dwContext;
5897  session->hdr.dwInternalFlags |= dwInternalFlags;
5898  session->hdr.decoding = hIC->hdr.decoding;
5899 
5900  WININET_AddRef( &hIC->hdr );
5901  session->appInfo = hIC;
5902  list_add_head( &hIC->hdr.children, &session->hdr.entry );
5903 
5904  session->hostName = heap_strdupW(lpszServerName);
5905  if (lpszUserName && lpszUserName[0])
5906  session->userName = heap_strdupW(lpszUserName);
5907  session->password = heap_strdupW(lpszPassword);
5908  session->hostPort = serverPort;
5909  session->connect_timeout = hIC->connect_timeout;
5910  session->send_timeout = 0;
5911  session->receive_timeout = 0;
5912 
5913  /* Don't send a handle created callback if this handle was created with InternetOpenUrl */
5914  if (!(session->hdr.dwInternalFlags & INET_OPENURL))
5915  {
5916  INTERNET_SendCallback(&hIC->hdr, dwContext,
5918  sizeof(HINTERNET));
5919  }
5920 
5921 /*
5922  * an INTERNET_STATUS_REQUEST_COMPLETE is NOT sent here as per my tests on
5923  * windows
5924  */
5925 
5926  TRACE("%p --> %p\n", hIC, session);
5927 
5928  *ret = session->hdr.hInternet;
5929  return ERROR_SUCCESS;
5930 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define ERROR_SUCCESS
Definition: deptool.c:10
__WINE_SERVER_LIST_INLINE void list_add_head(struct list *list, struct list *elem)
Definition: list.h:96
#define assert(x)
Definition: debug.h:53
_In_opt_ LPSTR _In_opt_ LPSTR lpszPassword
Definition: winbase.h:2674
int receive_timeout
VOID INTERNET_SendCallback(object_header_t *hdr, DWORD_PTR dwContext, DWORD dwInternetStatus, LPVOID lpvStatusInfo, DWORD dwStatusInfoLength) DECLSPEC_HIDDEN
static WCHAR * heap_strdupW(const WCHAR *str)
Definition: propsheet.c:178
smooth NULL
Definition: ftsmooth.c:416
object_header_t * WININET_AddRef(object_header_t *info)
Definition: internet.c:177
#define TRACE(s)
Definition: solgame.cpp:4
struct object_header hdr
int ret
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
void * alloc_object(object_header_t *parent, const object_vtbl_t *vtbl, size_t size)
Definition: internet.c:111
static const object_vtbl_t HTTPSESSIONVtbl
Definition: http.c:5850
#define INET_OPENURL
Definition: internet.h:244
int connect_timeout
int send_timeout
#define INTERNET_STATUS_HANDLE_CREATED
Definition: wininet.h:895
#define ERROR_OUTOFMEMORY
Definition: deptool.c:13

Referenced by INTERNET_InternetOpenUrlW(), and InternetConnectW().

◆ INET_QueryOption()

DWORD INET_QueryOption ( object_header_t ,
DWORD  ,
void ,
DWORD ,
BOOL   
)

Definition at line 2531 of file internet.c.

2532 {
2533  switch(option) {
2535  if (!size)
2536  return ERROR_INVALID_PARAMETER;
2537 
2538  if (*size < sizeof(DWORD_PTR)) {
2539  *size = sizeof(DWORD_PTR);
2541  }
2542  if (!buffer)
2543  return ERROR_INVALID_PARAMETER;
2544 
2545  *(DWORD_PTR *)buffer = hdr->dwContext;
2546  *size = sizeof(DWORD_PTR);
2547  return ERROR_SUCCESS;
2548 
2550  WARN("INTERNET_OPTION_REQUEST_FLAGS\n");
2551  *size = sizeof(DWORD);
2553 
2556  WARN("Called on global option %u\n", option);
2558  }
2559 
2560  /* FIXME: we shouldn't call it here */
2561  return query_global_option(option, buffer, size, unicode);
2562 }
#define ERROR_INTERNET_INCORRECT_HANDLE_TYPE
Definition: wininet.h:2007
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
char hdr[14]
Definition: iptest.cpp:33
#define ERROR_SUCCESS
Definition: deptool.c:10
#define DWORD_PTR
Definition: treelist.c:76
#define INTERNET_OPTION_MAX_CONNS_PER_SERVER
Definition: wininet.h:763
#define WARN(fmt,...)
Definition: debug.h:112
GLuint buffer
Definition: glext.h:5915
static DWORD
Definition: internet.c:33
Definition: getopt.h:108
#define INTERNET_OPTION_REQUEST_FLAGS
Definition: wininet.h:718
GLsizeiptr size
Definition: glext.h:5919
#define INTERNET_OPTION_MAX_CONNS_PER_1_0_SERVER
Definition: wininet.h:764
static DWORD query_global_option(DWORD option, void *buffer, DWORD *size, BOOL unicode)
Definition: internet.c:2335
uint32_t DWORD_PTR
Definition: typedefs.h:64
#define ERROR_INTERNET_INVALID_OPERATION
Definition: wininet.h:2005
#define INTERNET_OPTION_CONTEXT_VALUE
Definition: wininet.h:739
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10

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

◆ INET_SetOption()

DWORD INET_SetOption ( object_header_t ,
DWORD  ,
void ,
DWORD   
)

Definition at line 2630 of file internet.c.

2631 {
2632  switch(option) {
2634  FIXME("INTERNETOPTION_SETTINGS_CHANGED semi-stub\n");
2636  return ERROR_SUCCESS;
2638  WARN("Not settable option %u\n", option);
2642  WARN("Called on global option %u\n", option);
2646  }
2647 
2649 }
#define ERROR_INTERNET_INCORRECT_HANDLE_TYPE
Definition: wininet.h:2007
#define ERROR_SUCCESS
Definition: deptool.c:10
#define INTERNET_OPTION_MAX_CONNS_PER_SERVER
Definition: wininet.h:763
#define ERROR_INTERNET_OPTION_NOT_SETTABLE
Definition: wininet.h:2000
#define WARN(fmt,...)
Definition: debug.h:112
#define FIXME(fmt,...)
Definition: debug.h:111
Definition: getopt.h:108
#define INTERNET_OPTION_CALLBACK
Definition: wininet.h:700
#define INTERNET_OPTION_REFRESH
Definition: wininet.h:731
#define INTERNET_OPTION_SETTINGS_CHANGED
Definition: wininet.h:733
BOOL collect_connections(collect_type_t collect_type)
Definition: http.c:310
#define INTERNET_OPTION_MAX_CONNS_PER_1_0_SERVER
Definition: wininet.h:764
#define ERROR_INTERNET_INVALID_OPTION
Definition: wininet.h:1998
#define ERROR_INTERNET_INVALID_OPERATION
Definition: wininet.h:2005

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

◆ init_urlcache()

BOOL init_urlcache ( void  )

Definition at line 4124 of file urlcache.c.

4125 {
4127  if(!dll_unload_event)
4128  return FALSE;
4129 
4131  if(!free_cache_running) {
4133  return FALSE;
4134  }
4135 
4136 #ifndef __REACTOS__
4138 #endif
4139  return TRUE;
4140 }
static void cache_containers_init(void)
Definition: urlcache.c:753
#define TRUE
Definition: types.h:120
#define CloseHandle
Definition: compat.h:407
HANDLE WINAPI DECLSPEC_HOTPATCH CreateSemaphoreW(IN LPSECURITY_ATTRIBUTES lpSemaphoreAttributes OPTIONAL, IN LONG lInitialCount, IN LONG lMaximumCount, IN LPCWSTR lpName OPTIONAL)
Definition: synch.c:444
static HANDLE dll_unload_event
Definition: urlcache.c:2252
HANDLE WINAPI DECLSPEC_HOTPATCH CreateEventW(IN LPSECURITY_ATTRIBUTES lpEventAttributes OPTIONAL, IN BOOL bManualReset, IN BOOL bInitialState, IN LPCWSTR lpName OPTIONAL)
Definition: synch.c:651
smooth NULL
Definition: ftsmooth.c:416
static HANDLE free_cache_running
Definition: urlcache.c:2251

Referenced by DllMain().

◆ init_winsock()

void init_winsock ( void  )

Definition at line 277 of file netconnection.c.

278 {
279  static INIT_ONCE init_once = INIT_ONCE_STATIC_INIT;
281 }
static BOOL WINAPI winsock_startup(INIT_ONCE *once, void *param, void **context)
#define INIT_ONCE_STATIC_INIT
Definition: winbase.h:593
smooth NULL
Definition: ftsmooth.c:416
BOOL NTAPI InitOnceExecuteOnce(INIT_ONCE *once, PINIT_ONCE_FN func, void *param, void **context)

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

◆ INTERNET_AsyncCall()

DWORD INTERNET_AsyncCall ( task_header_t )

Definition at line 3798 of file internet.c.

3799 {
3800  BOOL bSuccess;
3801 
3802  TRACE("\n");
3803 
3805  if (!bSuccess)
3806  {
3807  heap_free(task);
3809  }
3810  return ERROR_SUCCESS;
3811 }
#define ERROR_SUCCESS
Definition: deptool.c:10
static DWORD CALLBACK INTERNET_WorkerThreadFunc(LPVOID lpvParam)
Definition: internet.c:3759
static BOOLEAN bSuccess
Definition: drive.cpp:419
#define ERROR_INTERNET_ASYNC_THREAD_FAILED
Definition: wininet.h:2035
unsigned int BOOL
Definition: ntddk_ex.h:94
#define WT_EXECUTELONGFUNCTION
Definition: winnt_old.h:1076
#define TRACE(s)
Definition: solgame.cpp:4
BOOL WINAPI QueueUserWorkItem(IN LPTHREAD_START_ROUTINE Function, IN PVOID Context, IN ULONG Flags)
Definition: thread.c:1064
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

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 392 of file internet.c.

393 {
394  WCHAR *ret = NULL;
395  const WCHAR *ptr;
396 
397  TRACE("(%s, %s)\n", debugstr_w(szProxy), debugstr_w(proto));
398 
399  /* First, look for the specified protocol (proto=scheme://host:port) */
400  for (ptr = szProxy; ptr && *ptr; )
401  {
402  LPCWSTR end, equal;
403 
404  if (!(end = strchrW(ptr, ' ')))
405  end = ptr + strlenW(ptr);
406  if ((equal = strchrW(ptr, '=')) && equal < end &&
407  equal - ptr == strlenW(proto) &&
409  {
410  ret = heap_strndupW(equal + 1, end - equal - 1);
411  TRACE("found proxy for %s: %s\n", debugstr_w(proto), debugstr_w(ret));
412  return ret;
413  }
414  if (*end == ' ')
415  ptr = end + 1;
416  else
417  ptr = end;
418  }
419 
420  /* It wasn't found: look for no protocol */
421  for (ptr = szProxy; ptr && *ptr; )
422  {
423  LPCWSTR end;
424 
425  if (!(end = strchrW(ptr, ' ')))
426  end = ptr + strlenW(ptr);
427  if (!strchrW(ptr, '='))
428  {
429  ret = heap_strndupW(ptr, end - ptr);
430  TRACE("found proxy for %s: %s\n", debugstr_w(proto), debugstr_w(ret));
431  return ret;
432  }
433  if (*end == ' ')
434  ptr = end + 1;
435  else
436  ptr = end;
437  }
438 
439  return NULL;
440 }
static LPWSTR heap_strndupW(LPCWSTR str, unsigned len)
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
WINE_UNICODE_INLINE WCHAR * strchrW(const WCHAR *str, WCHAR ch)
Definition: unicode.h:248
#define equal(x, y)
Definition: reader.cc:56
GLuint GLuint end
Definition: gl.h:1545
#define strncmpiW(s1, s2, n)
Definition: unicode.h:40
#define debugstr_w
Definition: kernel32.h:32
static PVOID ptr
Definition: dispmode.c:27
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
int ret

Referenced by HTTP_DealWithProxy().

◆ INTERNET_GetLastError()

DWORD INTERNET_GetLastError ( void  )

Definition at line 3741 of file internet.c.

3742 {
3744  if (!lpwite) return 0;
3745  /* TlsGetValue clears last error, so set it again here */
3746  SetLastError(lpwite->dwError);
3747  return lpwite->dwError;
3748 }
DWORD dwError
Definition: internet.c:71
#define SetLastError(x)
Definition: compat.h:418
LPVOID WINAPI TlsGetValue(IN DWORD Index)
Definition: thread.c:1228
static DWORD g_dwTlsErrIndex
Definition: internet.c:75

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 3820 of file internet.c.

3821 {
3823  if (!lpwite)
3824  lpwite = INTERNET_AllocThreadError();
3825  TRACE("\n");
3826  return lpwite->response;
3827 }
CHAR response[MAX_REPLY_LEN]
Definition: internet.c:72
#define TRACE(s)
Definition: solgame.cpp:4
static LPWITHREADERROR INTERNET_AllocThreadError(void)
Definition: internet.c:3693
LPVOID WINAPI TlsGetValue(IN DWORD Index)
Definition: thread.c:1228
static DWORD g_dwTlsErrIndex
Definition: internet.c:75

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

◆ INTERNET_SendCallback()

◆ INTERNET_SetLastError()

void INTERNET_SetLastError ( DWORD  dwError)

Definition at line 3720 of file internet.c.

3721 {
3723 
3724  if (!lpwite)
3725  lpwite = INTERNET_AllocThreadError();
3726 
3727  SetLastError(dwError);
3728  if(lpwite)
3729  lpwite->dwError = dwError;
3730 }
DWORD dwError
Definition: internet.c:71
static LPWITHREADERROR INTERNET_AllocThreadError(void)
Definition: internet.c:3693
#define SetLastError(x)
Definition: compat.h:418
LPVOID WINAPI TlsGetValue(IN DWORD Index)
Definition: thread.c:1228
static DWORD g_dwTlsErrIndex
Definition: internet.c:75

Referenced by calc_url_length(), FTP_Connect(), FTP_FtpCreateDirectoryW(), FTP_FtpDeleteFileW(), FTP_FtpFindFirstFileW(), FTP_FtpGetCurrentDirectoryW(), FTP_FtpGetFileW(), FTP_FtpOpenFileW(), FTP_FtpPutFileW(), FTP_FtpRemoveDirectoryW(), FTP_FtpRenameFileW(), FTP_FtpSetCurrentDirectoryW(), FTP_GetNextLine(), FTP_ParseDirectory(), FTP_RetrieveFileData(), FTP_SendCommandA(), FTP_SetResponseError(), FtpCommandA(), FtpCommandW(), FtpCreateDirectoryW(), FtpDeleteFileW(), FtpFindFirstFileW(), FtpGetCurrentDirectoryA(), FtpGetCurrentDirectoryW(), FtpGetFileW(), FtpOpenFileW(), FtpPutFileW(), FtpRemoveDirectoryW(), FtpRenameFileW(), FtpSetCurrentDirectoryW(), GetUrlCacheConfigInfoA(), GetUrlCacheConfigInfoW(), INTERNET_InternetOpenUrlW(), InternetCheckConnectionW(), InternetCreateUrlW(), InternetOpenW(), InternetReadFile(), InternetReadFileExA(), InternetReadFileExW(), and res_to_le().

◆ is_valid_netconn()

◆ NETCON_GetCert()

LPCVOID NETCON_GetCert ( netconn_t connection)

Definition at line 883 of file netconnection.c.

884 {
885  const CERT_CONTEXT *ret;
887 
889  return res == SEC_E_OK ? ret : NULL;
890 }
CtxtHandle ssl_ctx
Definition: internet.h:73
#define SECPKG_ATTR_REMOTE_CERT_CONTEXT
Definition: schannel.h:69
smooth NULL
Definition: ftsmooth.c:416
LONG SECURITY_STATUS
Definition: sspi.h:34
int ret
#define SEC_E_OK
Definition: winerror.h:2356
SECURITY_STATUS WINAPI QueryContextAttributesW(PCtxtHandle phContext, ULONG ulAttribute, void *pBuffer)
Definition: wrapper.c:535
GLuint res
Definition: glext.h:9613

Referenced by HTTPREQ_QueryOption().

◆ NETCON_GetCipherStrength()

int NETCON_GetCipherStrength ( netconn_t )

Definition at line 892 of file netconnection.c.

893 {
896 
897  if (!connection->secure)
898  return 0;
899 
900  res = QueryContextAttributesW(&connection->ssl_ctx, SECPKG_ATTR_CONNECTION_INFO, (void*)&conn_info);
901  if(res != SEC_E_OK)
902  WARN("QueryContextAttributesW failed: %08x\n", res);
903  return res == SEC_E_OK ? conn_info.dwCipherStrength : 0;
904 }
#define WARN(fmt,...)
Definition: debug.h:112
LONG SECURITY_STATUS
Definition: sspi.h:34
#define SECPKG_ATTR_CONNECTION_INFO
Definition: schannel.h:76
#define SEC_E_OK
Definition: winerror.h:2356
SECURITY_STATUS WINAPI QueryContextAttributesW(PCtxtHandle phContext, ULONG ulAttribute, void *pBuffer)
Definition: wrapper.c:535
GLuint res
Definition: glext.h:9613

Referenced by HTTPREQ_QueryOption(), and netcon_secure_connect_setup().

◆ NETCON_is_alive()

BOOL NETCON_is_alive ( netconn_t )

Definition at line 872 of file netconnection.c.

873 {
874  int len;
875  char b;
876 
878  len = sock_recv(netconn->socket, &b, 1, MSG_PEEK);
879 
880  return len == 1 || (len == -1 && WSAGetLastError() == WSAEWOULDBLOCK);
881 }
int sock_recv(int fd, void *msg, size_t len, int flags)
#define WSAEWOULDBLOCK
Definition: winerror.h:1948
#define b
Definition: ke_i.h:79
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
INT WSAAPI WSAGetLastError(VOID)
Definition: dllmain.c:112
GLenum GLsizei len
Definition: glext.h:6722
static void set_socket_blocking(netconn_t *conn, BOOL is_blocking)
#define MSG_PEEK
Definition: winsock.h:222

Referenced by open_http_connection().

◆ NETCON_recv()

DWORD NETCON_recv ( netconn_t ,
void ,
size_t  ,
BOOL  ,
int  
)

Definition at line 820 of file netconnection.c.

821 {
822  *recvd = 0;
823  if (!len)
824  return ERROR_SUCCESS;
825 
826  if (!connection->secure)
827  {
828  set_socket_blocking(connection, blocking);
829  *recvd = sock_recv(connection->socket, buf, len, 0);
830  return *recvd == -1 ? WSAGetLastError() : ERROR_SUCCESS;
831  }
832  else
833  {
834  SIZE_T size = 0;
835  BOOL eof;
836  DWORD res;
837 
838  if(connection->peek_msg) {
839  size = min(len, connection->peek_len);
840  memcpy(buf, connection->peek_msg, size);
841  connection->peek_len -= size;
842  connection->peek_msg += size;
843 
844  if(!connection->peek_len) {
845  heap_free(connection->peek_msg_mem);
846  connection->peek_msg_mem = connection->peek_msg = NULL;
847  }
848 
849  *recvd = size;
850  return ERROR_SUCCESS;
851  }
852 
853  do {
854  res = read_ssl_chunk(connection, (BYTE*)buf, len, blocking, &size, &eof);
855  if(res != ERROR_SUCCESS) {
856  if(res == WSAEWOULDBLOCK) {
857  if(size)
858  res = ERROR_SUCCESS;
859  }else {
860  WARN("read_ssl_chunk failed\n");
861  }
862  break;
863  }
864  }while(!size && !eof);
865 
866  TRACE("received %ld bytes\n", size);
867  *recvd = size;
868  return res;
869  }
870 }
static BOOL read_ssl_chunk(netconn_t *conn, void *buf, SIZE_T buf_size, BOOL blocking, SIZE_T *ret_size, BOOL *eof)
#define ERROR_SUCCESS
Definition: deptool.c:10
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define WARN(fmt,...)
Definition: debug.h:112
int sock_recv(int fd, void *msg, size_t len, int flags)
#define WSAEWOULDBLOCK
Definition: winerror.h:1948
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
INT WSAAPI WSAGetLastError(VOID)
Definition: dllmain.c:112
GLsizeiptr size
Definition: glext.h:5919
unsigned long DWORD
Definition: ntddk_ex.h:95
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
GLenum GLsizei len
Definition: glext.h:6722
unsigned char BYTE
Definition: xxhash.c:193
_Check_return_ _CRTIMP int __cdecl __cdecl eof(_In_ int _FileHandle)
ULONG_PTR SIZE_T
Definition: typedefs.h:79
#define min(a, b)
Definition: monoChain.cc:55
static void set_socket_blocking(netconn_t *conn, BOOL is_blocking)
GLuint res
Definition: glext.h:9613
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

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

◆ NETCON_secure_connect()

DWORD NETCON_secure_connect ( netconn_t ,
server_t  
)

Definition at line 600 of file netconnection.c.

601 {
602  DWORD res;
603 
604  /* can't connect if we are already connected */
605  if(connection->secure) {
606  ERR("already connected\n");
608  }
609 
610  if(server != connection->server) {
611  server_release(connection->server);
613  connection->server = server;
614  }
615 
616  /* connect with given TLS options */
617  res = netcon_secure_connect_setup(connection, FALSE);
618  if (res == ERROR_SUCCESS)
619  return res;
620 
621  /* FIXME: when got version alert and FIN from server */
622  /* fallback to connect without TLSv1.1/TLSv1.2 */
624  {
625  closesocket(connection->socket);
626  res = create_netconn_socket(connection->server, connection, 500);
627  if (res != ERROR_SUCCESS)
628  return res;
629  res = netcon_secure_connect_setup(connection, TRUE);
630  }
631  return res;
632 }
#define TRUE
Definition: types.h:120
static rfbScreenInfoPtr server
Definition: vnc.c:74
#define ERROR_SUCCESS
Definition: deptool.c:10
#define closesocket
Definition: precomp.h:57
void server_release(server_t *server)
Definition: http.c:226
#define ERROR_INTERNET_CANNOT_CONNECT
Definition: wininet.h:2018
static DWORD netcon_secure_connect_setup(netconn_t *connection, BOOL compat_mode)
unsigned long DWORD
Definition: ntddk_ex.h:95
void server_addref(server_t *server)
Definition: http.c:221
#define ERR(fmt,...)
Definition: debug.h:110
#define ERROR_INTERNET_SECURITY_CHANNEL_ERROR
Definition: wininet.h:2069
GLuint res
Definition: glext.h:9613
static DWORD create_netconn_socket(server_t *server, netconn_t *netconn, DWORD timeout)
static BOOL have_compat_cred_handle

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 665 of file netconnection.c.

667 {
668  /* send is always blocking. */
669  set_socket_blocking(connection, TRUE);
670 
671  if(!connection->secure)
672  {
673  *sent = sock_send(connection->socket, msg, len, flags);
674  return *sent == -1 ? WSAGetLastError() : ERROR_SUCCESS;
675  }
676  else
677  {
678  const BYTE *ptr = msg;
679  size_t chunk_size;
680 
681  *sent = 0;
682 
683  while(len) {
684  chunk_size = min(len, connection->ssl_sizes.cbMaximumMessage);
685  if(!send_ssl_chunk(connection, ptr, chunk_size))
687 
688  *sent += chunk_size;
689  ptr += chunk_size;
690  len -= chunk_size;
691  }
692 
693  return ERROR_SUCCESS;
694  }
695 }
#define TRUE
Definition: types.h:120
#define ERROR_SUCCESS
Definition: deptool.c:10
int socket
Definition: internet.h:70
static PVOID ptr
Definition: dispmode.c:27
int sock_send(int fd, const void *msg, size_t len, int flags)
BOOL secure
Definition: internet.h:71
INT WSAAPI WSAGetLastError(VOID)
Definition: dllmain.c:112
GLbitfield flags
Definition: glext.h:7161
Definition: msg.h:34
GLenum GLsizei len
Definition: glext.h:6722
unsigned char BYTE
Definition: xxhash.c:193
static BOOL send_ssl_chunk(netconn_t *conn, const void *msg, size_t size)
#define ERROR_INTERNET_SECURITY_CHANNEL_ERROR
Definition: wininet.h:2069
#define min(a, b)
Definition: monoChain.cc:55
static void set_socket_blocking(netconn_t *conn, BOOL is_blocking)
#define msg(x)
Definition: auth_time.c:54
SecPkgContext_StreamSizes ssl_sizes
Definition: internet.h:74

Referenced by HTTP_HttpSendRequestW(), and HTTPREQ_WriteFile().

◆ NETCON_set_timeout()

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

Definition at line 906 of file netconnection.c.

907 {
908  int result;
909 
910  result = setsockopt(connection->socket, SOL_SOCKET,
911  send ? SO_SNDTIMEO : SO_RCVTIMEO, (void*)&value,
912  sizeof(value));
913  if (result == -1)
914  {
915  WARN("setsockopt failed\n");
916  return WSAGetLastError();
917  }
918  return ERROR_SUCCESS;
919 }
#define ERROR_SUCCESS
Definition: deptool.c:10
#define WARN(fmt,...)
Definition: debug.h:112
#define SOL_SOCKET
Definition: winsock.h:398
int socket
Definition: internet.h:70
INT WSAAPI setsockopt(IN SOCKET s, IN INT level, IN INT optname, IN CONST CHAR FAR *optval, IN INT optlen)
Definition: sockctrl.c:421
#define SO_RCVTIMEO
Definition: winsock.h:193
INT WSAAPI WSAGetLastError(VOID)
Definition: dllmain.c:112
INT WSAAPI send(IN SOCKET s, IN CONST CHAR FAR *buf, IN INT len, IN INT flags)
Definition: send.c:23
#define SO_SNDTIMEO
Definition: winsock.h:192
GLuint64EXT * result
Definition: glext.h:11304

Referenced by HTTP_GetResponseHeaders(), and HTTP_HttpSendRequestW().

◆ NETCON_unload()

void NETCON_unload ( void  )

Definition at line 403 of file netconnection.c.

404 {
410  if(winsock_loaded)
411  WSACleanup();
412 }
INT WSAAPI WSACleanup(VOID)
Definition: startup.c:60
static SecHandle cred_handle
SECURITY_STATUS WINAPI FreeCredentialsHandle(PCredHandle phCredential)
Definition: wrapper.c:151
static BOOL winsock_loaded
static BOOL cred_handle_initialized
static CRITICAL_SECTION init_sechandle_cs
static SecHandle compat_cred_handle
void WINAPI DeleteCriticalSection(PCRITICAL_SECTION)
static BOOL have_compat_cred_handle

Referenced by DllMain().

◆ req_file_addref()

static req_file_t* req_file_addref ( req_file_t req_file)
inlinestatic

Definition at line 450 of file internet.h.

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

Referenced by HTTPREQ_LockRequestFile().

◆ req_file_release()

void req_file_release ( req_file_t )

Definition at line 3898 of file internet.c.

3899 {
3900  if(InterlockedDecrement(&req_file->ref))
3901  return;
3902 
3903  if(!req_file->is_committed)
3904  DeleteFileW(req_file->file_name);
3905  if(req_file->file_handle && req_file->file_handle != INVALID_HANDLE_VALUE)
3906  CloseHandle(req_file->file_handle);
3907  heap_free(req_file->file_name);
3908  heap_free(req_file->url);
3909  heap_free(req_file);
3910 }
#define CloseHandle
Definition: compat.h:407
#define INVALID_HANDLE_VALUE
Definition: compat.h:400
BOOL WINAPI DeleteFileW(IN LPCWSTR lpFileName)
Definition: delete.c:39
#define InterlockedDecrement
Definition: armddk.h:52
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

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

◆ server_addref()

void server_addref ( server_t )

Definition at line 221 of file http.c.

222 {
224 }
static rfbScreenInfoPtr server
Definition: vnc.c:74
#define InterlockedIncrement
Definition: armddk.h:53

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

◆ server_release()

void server_release ( server_t )

Definition at line 226 of file http.c.

227 {
228  if(InterlockedDecrement(&server->ref))
229  return;
230 
231 #ifdef __REACTOS__
233 #endif
234  list_remove(&server->entry);
235 #ifdef __REACTOS__
237 #endif
238 
239  if(server->cert_chain)
240  CertFreeCertificateChain(server->cert_chain);
241  heap_free(server->name);
242  heap_free(server->scheme_host_port);
243  heap_free(server);
244 }
static rfbScreenInfoPtr server
Definition: vnc.c:74
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
VOID WINAPI CertFreeCertificateChain(PCCERT_CHAIN_CONTEXT pChainContext)
Definition: chain.c:2960
__WINE_SERVER_LIST_INLINE void list_remove(struct list *elem)
Definition: list.h:108
static CRITICAL_SECTION connection_pool_cs
Definition: http.c:209
#define InterlockedDecrement
Definition: armddk.h:52
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

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

◆ set_cookie()

DWORD set_cookie ( substr_t  ,
substr_t  ,
substr_t  ,
substr_t  ,
DWORD   
)

Definition at line 909 of file cookie.c.

910 {
912  cookie_t *thisCookie;
913  substr_t value;
914  const WCHAR *end_ptr;
915  FILETIME expiry, create;
916  BOOL expired = FALSE, update_persistent = FALSE;
917  DWORD cookie_flags = 0, len;
918 
919  TRACE("%s %s %s=%s %x\n", debugstr_wn(domain.str, domain.len), debugstr_wn(path.str, path.len),
920  debugstr_wn(name.str, name.len), debugstr_wn(data.str, data.len), flags);
921 
922  memset(&expiry,0,sizeof(expiry));
924 
925  /* lots of information can be parsed out of the cookie value */
926 
927  if(!(end_ptr = memchrW(data.str, ';', data.len)))
928  end_ptr = data.str + data.len;
929  value = substr(data.str, end_ptr-data.str);
930  data.str += value.len;
931  data.len -= value.len;
932 
933  for(;;) {
934  static const WCHAR szDomain[] = {'d','o','m','a','i','n','='};
935  static const WCHAR szPath[] = {'p','a','t','h','='};
936  static const WCHAR szExpires[] = {'e','x','p','i','r','e','s','='};
937  static const WCHAR szSecure[] = {'s','e','c','u','r','e'};
938  static const WCHAR szHttpOnly[] = {'h','t','t','p','o','n','l','y'};
939  static const WCHAR szVersion[] = {'v','e','r','s','i','o','n','='};
940  static const WCHAR max_ageW[] = {'m','a','x','-','a','g','e','='};
941 
942  /* Skip ';' */
943  if(data.len)
944  substr_skip(&data, 1);
945 
946  while(data.len && *data.str == ' ')
947  substr_skip(&data, 1);
948 
949  if(!data.len)
950  break;
951 
952  if(!(end_ptr = memchrW(data.str, ';', data.len)))
953  end_ptr = data.str + data.len;
954 
955  if(data.len >= (len = ARRAY_SIZE(szDomain)) && !strncmpiW(data.str, szDomain, len)) {
956  substr_skip(&data, len);
957 
958  if(data.len && *data.str == '.')
959  substr_skip(&data, 1);
960 
961  if(!is_domain_legal_for_cookie(substr(data.str, end_ptr-data.str), domain))
962  return COOKIE_STATE_UNKNOWN;
963 
964  domain = substr(data.str, end_ptr-data.str);
965  TRACE("Parsing new domain %s\n", debugstr_wn(domain.str, domain.len));
966  }else if(data.len >= (len = ARRAY_SIZE(szPath)) && !strncmpiW(data.str, szPath, len)) {
967  substr_skip(&data, len);
968  path = substr(data.str, end_ptr - data.str);
969  TRACE("Parsing new path %s\n", debugstr_wn(path.str, path.len));
970  }else if(data.len >= (len = ARRAY_SIZE(szExpires)) && !strncmpiW(data.str, szExpires, len)) {
971  SYSTEMTIME st;
972  WCHAR buf[128];
973 
974  substr_skip(&data, len);
975 
976  if(end_ptr - data.str < ARRAY_SIZE(buf)-1) {
977  memcpy(buf, data.str, data.len*sizeof(WCHAR));
978  buf[data.len] = 0;
979 
980  if (InternetTimeToSystemTimeW(data.str, &st, 0)) {
981  SystemTimeToFileTime(&st, &expiry);
982 
983  if (CompareFileTime(&create,&expiry) > 0) {
984  TRACE("Cookie already expired.\n");
985  expired = TRUE;
986  }
987  }
988  }
989  }else if(data.len >= (len = ARRAY_SIZE(szSecure)) && !strncmpiW(data.str, szSecure, len)) {
990  substr_skip(&data, len);
991  FIXME("secure not handled\n");
992  }else if(data.len >= (len = ARRAY_SIZE(szHttpOnly)) && !strncmpiW(data.str, szHttpOnly, len)) {
993  substr_skip(&data, len);
994 
996  WARN("HTTP only cookie added without INTERNET_COOKIE_HTTPONLY flag\n");
998  return COOKIE_STATE_REJECT;
999  }
1000 
1001  cookie_flags |= INTERNET_COOKIE_HTTPONLY;
1002  }else if(data.len >= (len = ARRAY_SIZE(szVersion)) && !strncmpiW(data.str, szVersion, len)) {
1003  substr_skip(&data, len);
1004 
1005  FIXME("version not handled (%s)\n",debugstr_wn(data.str, data.len));
1006  }else if(data.len >= (len = ARRAY_SIZE(max_ageW)) && !strncmpiW(data.str, max_ageW, len)) {
1007  /* Native doesn't support Max-Age attribute. */
1008  WARN("Max-Age ignored\n");
1009  }else if(data.len) {
1010  FIXME("Unknown additional option %s\n", debugstr_wn(data.str, data.len));
1011  }
1012 
1013  substr_skip(&data, end_ptr - data.str);
1014  }
1015 
1017 
1019 
1020  container = get_cookie_container(domain, path, !expired);
1021  if(!container) {
1023  return COOKIE_STATE_ACCEPT;
1024  }
1025 
1026  if(!expiry.dwLowDateTime && !expiry.dwHighDateTime)
1027  cookie_flags |= INTERNET_COOKIE_IS_SESSION;
1028  else
1029  update_persistent = TRUE;
1030 
1031  if ((thisCookie = find_cookie(container, name))) {
1032  if ((thisCookie->flags & INTERNET_COOKIE_HTTPONLY) && !(flags & INTERNET_COOKIE_HTTPONLY)) {
1033  WARN("An attempt to override httponly cookie\n");
1036  return COOKIE_STATE_REJECT;
1037  }
1038 
1039  if (!(thisCookie->flags & INTERNET_COOKIE_IS_SESSION))
1040  update_persistent = TRUE;
1041  delete_cookie(thisCookie);
1042  }
1043 
1044  TRACE("setting cookie %s=%s for domain %s path %s\n", debugstr_wn(name.str, name.len),
1045  debugstr_wn(value.str, value.len), debugstr_w(container->domain->domain),
1046  debugstr_wn(container->path.str, container->path.len));
1047 
1048  if (!expired) {
1049  cookie_t *new_cookie;
1050 
1051  new_cookie = alloc_cookie(name, value, expiry, create, cookie_flags);
1052  if(!new_cookie) {
1054  return COOKIE_STATE_UNKNOWN;
1055  }
1056 
1057  add_cookie(container, new_cookie);
1058  }
1059 
1060  if (!update_persistent || save_persistent_cookie(container))
1061  {
1063  return COOKIE_STATE_ACCEPT;
1064  }
1066  return COOKIE_STATE_UNKNOWN;
1067 }
static cookie_container_t * get_cookie_container(substr_t domain, substr_t path, BOOL create)
Definition: cookie.c:184
VOID WINAPI GetSystemTimeAsFileTime(OUT PFILETIME lpFileTime)
Definition: time.c:128
#define TRUE
Definition: types.h:120
#define INTERNET_COOKIE_IS_SESSION
Definition: wininet.h:1819
static BOOL is_domain_legal_for_cookie(substr_t domain, substr_t full_domain)
Definition: cookie.c:866
static void substr_skip(substr_t *str, size_t len)
Definition: cookie.c:902
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define WARN(fmt,...)
Definition: debug.h:112
#define strncmpiW(s1, s2, n)
Definition: unicode.h:40
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
Definition: cookie.c:41
struct container container
DWORD dwHighDateTime
Definition: mapidefs.h:66
unsigned int BOOL
Definition: ntddk_ex.h:94
#define debugstr_w
Definition: kernel32.h:32
#define FIXME(fmt,...)
Definition: debug.h:111
static BOOL save_persistent_cookie(cookie_container_t *container)
Definition: cookie.c:389
static void delete_cookie(cookie_t *cookie)
Definition: cookie.c:228
static CRITICAL_SECTION cookie_cs
Definition: cookie.c:87
static cookie_t * find_cookie(cookie_container_t *container, substr_t name)
Definition: cookie.c:263
#define TRACE(s)
Definition: solgame.cpp:4
LONG WINAPI CompareFileTime(IN CONST FILETIME *lpFileTime1, IN CONST FILETIME *lpFileTime2)
Definition: time.c:106
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:418
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLbitfield flags
Definition: glext.h:7161
static LPCWSTR szVersion
Definition: asmcache.c:748
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
GLenum GLsizei len
Definition: glext.h:6722
GLsizei const GLfloat * value
Definition: glext.h:6069
#define debugstr_wn
Definition: kernel32.h:33
static void add_cookie(cookie_container_t *container, cookie_t *new_cookie)
Definition: cookie.c:275
static const WCHAR szExpires[]
Definition: http.c:104
BOOL WINAPI SystemTimeToFileTime(IN CONST SYSTEMTIME *lpSystemTime, OUT LPFILETIME lpFileTime)
Definition: time.c:158
LPCWSTR szPath
Definition: env.c:35
#define ARRAY_SIZE(a)
Definition: main.h:24
#define ERROR_INVALID_OPERATION
Definition: winerror.h:1261
static BOOL load_persistent_cookie(substr_t domain, substr_t path)
Definition: cookie.c:300
Definition: name.c:38
static substr_t substr(const WCHAR *str, size_t len)
Definition: internet.h:204
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
#define INTERNET_COOKIE_HTTPONLY
Definition: wininet.h:1828
WINE_UNICODE_INLINE WCHAR * memchrW(const WCHAR *ptr, WCHAR ch, size_t n)
Definition: unicode.h:295
BOOL WINAPI InternetTimeToSystemTimeW(LPCWSTR string, SYSTEMTIME *time, DWORD reserved)
Definition: internet.c:3256
#define memset(x, y, z)
Definition: compat.h:39
static const struct access_res create[16]
Definition: package.c:7720
static cookie_t * alloc_cookie(substr_t name, substr_t data, FILETIME expiry, FILETIME create_time, DWORD flags)
Definition: cookie.c:237
DWORD dwLowDateTime
Definition: mapidefs.h:65

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 425 of file netconnection.c.

426 {
427  int ret;
428  do
429  {
430  ret = recv(fd, msg, len, flags);
431  }
432  while(ret == -1 && WSAGetLastError() == WSAEINTR);
433  return ret;
434 }
static int fd
Definition: io.c:51
INT WSAAPI WSAGetLastError(VOID)
Definition: dllmain.c:112
GLbitfield flags
Definition: glext.h:7161
int ret
GLenum GLsizei len
Definition: glext.h:6722
#define msg(x)
Definition: auth_time.c:54
INT WSAAPI recv(IN SOCKET s, OUT CHAR FAR *buf, IN INT len, IN INT flags)
Definition: recv.c:23
#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 414 of file netconnection.c.

415 {
416  int ret;
417  do
418  {
419  ret = send(fd, msg, len, flags);
420  }
421  while(ret == -1 && WSAGetLastError() == WSAEINTR);
422  return ret;
423 }
static int fd
Definition: io.c:51
INT WSAAPI WSAGetLastError(VOID)
Definition: dllmain.c:112
INT WSAAPI send(IN SOCKET s, IN CONST CHAR FAR *buf, IN INT len, IN INT flags)
Definition: send.c:23
GLbitfield flags
Definition: glext.h:7161
int ret
GLenum GLsizei len
Definition: glext.h:6722
#define msg(x)
Definition: auth_time.c:54
#define WSAEINTR
Definition: winerror.h:1942

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

◆ substr()

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

Definition at line 204 of file internet.h.

205 {
206  substr_t r = {str, len};
207  return r;
208 }
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
const WCHAR * str
GLenum GLsizei len
Definition: glext.h:6722

Referenced by cookie_parse_url(), get_cookie(), HTTP_DealWithProxy(), HTTP_HandleRedirect(), HTTP_ProcessCookies(), HTTP_ShouldBypassProxy(), InternetGetSecurityInfoByURLW(), InternetSetCookieExW(), load_persistent_cookie(), pbuf_strstr(), set_cookie(), and substrz().

◆ substrz()

static substr_t substrz ( const WCHAR str)
inlinestatic

Definition at line 210 of file internet.h.

211 {
212  return substr(str, strlenW(str));
213 }
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
const WCHAR * str
static substr_t substr(const WCHAR *str, size_t len)
Definition: internet.h:204

Referenced by get_cookie_container(), get_cookie_header(), HTTP_HttpOpenRequestW(), HTTP_ProcessCookies(), InternetSetCookieExW(), IsDomainLegalCookieDomainW(), and replace_cookie().

◆ WININET_AddRef()

object_header_t* WININET_AddRef ( object_header_t info)

Definition at line 177 of file internet.c.

178 {
179  ULONG refs = InterlockedIncrement(&info->refs);
180  TRACE("%p -> refcount = %d\n", info, refs );
181  return info;
182 }
struct _test_info info[]
Definition: SetCursorPos.c:19
#define TRACE(s)
Definition: solgame.cpp:4
#define InterlockedIncrement
Definition: armddk.h:53
unsigned int ULONG
Definition: retypes.h:1

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 215 of file internet.h.

216 {
217  dataA->dwFileAttributes = dataW->dwFileAttributes;
218  dataA->ftCreationTime = dataW->ftCreationTime;
219  dataA->ftLastAccessTime = dataW->ftLastAccessTime;
220  dataA->ftLastWriteTime = dataW->ftLastWriteTime;
221  dataA->nFileSizeHigh = dataW->nFileSizeHigh;
222  dataA->nFileSizeLow = dataW->nFileSizeLow;
223  dataA->dwReserved0 = dataW->dwReserved0;
224  dataA->dwReserved1 = dataW->dwReserved1;
225  WideCharToMultiByte(CP_ACP, 0, dataW->cFileName, -1,
226  dataA->cFileName, sizeof(dataA->cFileName),
227  NULL, NULL);
229  dataA->cAlternateFileName, sizeof(dataA->cAlternateFileName),
230  NULL, NULL);
231 }
DWORD nFileSizeHigh
Definition: winbase.h:921
DWORD dwReserved1
Definition: winbase.h:912
CHAR cFileName[MAX_PATH]
Definition: winbase.h:913
#define WideCharToMultiByte
Definition: compat.h:101
FILETIME ftLastAccessTime
Definition: winbase.h:907
#define CP_ACP
Definition: compat.h:99
WCHAR cAlternateFileName[14]
Definition: winbase.h:926
DWORD dwReserved0
Definition: winbase.h:911
DWORD nFileSizeLow
Definition: winbase.h:910
FILETIME ftCreationTime
Definition: winbase.h:906
DWORD nFileSizeLow
Definition: winbase.h:922
smooth NULL
Definition: ftsmooth.c:416
FILETIME ftLastWriteTime
Definition: winbase.h:908
WCHAR cFileName[MAX_PATH]
Definition: winbase.h:925
FILETIME ftLastWriteTime
Definition: winbase.h:920
DWORD dwFileAttributes
Definition: winbase.h:905
FILETIME ftLastAccessTime
Definition: winbase.h:919
DWORD dwReserved0
Definition: winbase.h:923
DWORD dwReserved1
Definition: winbase.h:924
DWORD dwFileAttributes
Definition: winbase.h:917
DWORD nFileSizeHigh
Definition: winbase.h:909
FILETIME ftCreationTime
Definition: winbase.h:918
CHAR cAlternateFileName[14]
Definition: winbase.h:914

Referenced by FtpFindFirstFileA(), and InternetFindNextFileA().

◆ WININET_Release()

BOOL WININET_Release ( object_header_t info)

Definition at line 219 of file internet.c.

220 {
221  ULONG refs = InterlockedDecrement(&info->refs);
222  TRACE( "object %p refcount = %d\n", info, refs );
223  if( !refs )
224  {
226  if ( info->vtbl->CloseConnection )
227  {
228  TRACE( "closing connection %p\n", info);
229  info->vtbl->CloseConnection( info );
230  }
231  /* Don't send a callback if this is a session handle created with InternetOpenUrl */
232  if ((info->htype != WH_HHTTPSESSION && info->htype != WH_HFTPSESSION)
233  || !(info->dwInternalFlags & INET_OPENURL))
234  {
235  INTERNET_SendCallback(info, info->dwContext,
237  sizeof(HINTERNET));
238  }
239  TRACE( "destroying object %p\n", info);
240  if ( info->htype != WH_HINIT )
241  list_remove( &info->entry );
242  info->vtbl->Destroy( info );
243 
244  if(info->hInternet) {
245  UINT_PTR handle = (UINT_PTR)info->hInternet;
246 
248 
250  if(next_handle > handle)
252 
254  }
255 
256  heap_free(info);
257  }
258  return TRUE;
259 }
unsigned __int3264 UINT_PTR
Definition: activex.cpp:275
namespace GUID const ADDRINFOEXW ADDRINFOEXW struct timeval OVERLAPPED LPLOOKUPSERVICE_COMPLETION_ROUTINE HANDLE * handle
Definition: sock.c:82
#define TRUE
Definition: types.h:120
#define INTERNET_STATUS_HANDLE_CLOSING
Definition: wininet.h:896
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
VOID INTERNET_SendCallback(object_header_t *hdr, DWORD_PTR dwContext, DWORD dwInternetStatus, LPVOID lpvStatusInfo, DWORD dwStatusInfoLength) DECLSPEC_HIDDEN
static void invalidate_handle(object_header_t *info)
Definition: internet.c:201
smooth NULL
Definition: ftsmooth.c:416
static UINT_PTR next_handle
Definition: internet.c:88
__WINE_SERVER_LIST_INLINE void list_remove(struct list *elem)
Definition: list.h:108
#define TRACE(s)
Definition: solgame.cpp:4
static CRITICAL_SECTION WININET_cs
Definition: internet.c:78
unsigned __int3264 UINT_PTR
Definition: mstsclib_h.h:274
#define InterlockedDecrement
Definition: armddk.h:52
#define INET_OPENURL
Definition: internet.h:244
unsigned int ULONG
Definition: retypes.h:1
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

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

Definition at line 155 of file crypt32_private.h.

◆ len

Initial value:
{
#define GetProcessHeap()
Definition: compat.h:404
GLenum GLsizei len
Definition: glext.h:6722
#define HeapReAlloc
Definition: compat.h:402
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
Definition: mem.c:156

Definition at line 94 of file internet.h.

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