ReactOS  0.4.14-dev-337-gf981a68
winhttp_private.h
Go to the documentation of this file.
1 /*
2  * Copyright 2008 Hans Leidekker for CodeWeavers
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17  */
18 
19 #ifndef _WINE_WINHTTP_PRIVATE_H_
20 #define _WINE_WINHTTP_PRIVATE_H_
21 
22 #ifndef __WINE_CONFIG_H
23 # error You must include config.h to use this header
24 #endif
25 
26 #include "wine/heap.h"
27 #include "wine/list.h"
28 #include "wine/unicode.h"
29 
30 #include <sys/types.h>
31 #ifdef HAVE_SYS_SOCKET_H
32 # include <sys/socket.h>
33 #endif
34 #ifdef HAVE_NETINET_IN_H
35 # include <netinet/in.h>
36 #endif
37 #ifdef HAVE_NETDB_H
38 # include <netdb.h>
39 #endif
40 #if defined(__MINGW32__) || defined (_MSC_VER)
41 # include <ws2tcpip.h>
42 #else
43 # define closesocket close
44 # define ioctlsocket ioctl
45 #endif
46 
47 #include "ole2.h"
48 #include "sspi.h"
49 
50 static const WCHAR getW[] = {'G','E','T',0};
51 static const WCHAR postW[] = {'P','O','S','T',0};
52 static const WCHAR headW[] = {'H','E','A','D',0};
53 static const WCHAR slashW[] = {'/',0};
54 static const WCHAR http1_0[] = {'H','T','T','P','/','1','.','0',0};
55 static const WCHAR http1_1[] = {'H','T','T','P','/','1','.','1',0};
56 static const WCHAR chunkedW[] = {'c','h','u','n','k','e','d',0};
57 
59 
60 typedef struct
61 {
66 
68 {
81  struct list entry;
82  struct list children;
83 };
84 
85 typedef struct
86 {
87  struct list entry;
89  struct list cookies;
90 } domain_t;
91 
92 typedef struct
93 {
94  struct list entry;
98 } cookie_t;
99 
100 typedef struct {
101  struct list entry;
107 } hostdata_t;
108 
109 typedef struct
110 {
122  struct list cookie_cache;
127 } session_t;
128 
129 typedef struct
130 {
133  LPWSTR hostname; /* final destination of the request */
134  LPWSTR servername; /* name of the server we directly connect to */
141 } connect_t;
142 
143 typedef struct
144 {
145  struct list entry;
146  int socket;
148  BOOL secure; /* SSL active on connection? */
153  char *ssl_buf;
154  char *extra_buf;
155  size_t extra_len;
156  char *peek_msg;
158  size_t peek_len;
159 } netconn_t;
160 
161 typedef struct
162 {
165  BOOL is_request; /* part of request headers? */
166 } header_t;
167 
169 {
174 };
175 
177 {
185 };
186 
187 struct authinfo
188 {
191  CtxtHandle ctx;
192  TimeStamp exp;
193  ULONG attr;
195  char *data;
196  unsigned int data_len;
197  BOOL finished; /* finished authenticating */
198 };
199 
200 typedef struct
201 {
208  void *optional;
217  DWORD content_length; /* total number of bytes to be read */
218  DWORD content_read; /* bytes read so far */
219  BOOL read_chunked; /* are we reading in chunked mode? */
220  BOOL read_chunked_eof; /* end of stream in chunked mode */
221  BOOL read_chunked_size; /* chunk size remaining */
222  DWORD read_pos; /* current read position in read_buf */
223  DWORD read_size; /* valid data size in read_buf */
224  char read_buf[8192]; /* buffer for already read but not returned data */
232  struct list task_queue;
234  struct
235  {
238  } creds[TARGET_MAX][SCHEME_MAX];
239 } request_t;
240 
242 
243 struct _task_header_t
244 {
245  struct list entry;
248 };
249 
250 typedef struct
251 {
260 
261 typedef struct
262 {
265 
266 typedef struct
267 {
270 } query_data_t;
271 
272 typedef struct
273 {
278 } read_data_t;
279 
280 typedef struct
281 {
286 } write_data_t;
287 
293 
298 
301 void netconn_unload( void ) DECLSPEC_HIDDEN;
303 BOOL netconn_recv( netconn_t *, void *, size_t, int, int * ) DECLSPEC_HIDDEN;
306 BOOL netconn_send( netconn_t *, const void *, size_t, int * ) DECLSPEC_HIDDEN;
311 
317 void destroy_authinfo( struct authinfo * ) DECLSPEC_HIDDEN;
318 
320 
322 
324 void release_typelib( void ) DECLSPEC_HIDDEN;
325 
326 static inline void* __WINE_ALLOC_SIZE(2) heap_realloc_zero( LPVOID mem, SIZE_T size )
327 {
329 }
330 
331 static inline WCHAR *strdupW( const WCHAR *src )
332 {
333  WCHAR *dst;
334 
335  if (!src) return NULL;
336  dst = heap_alloc( (strlenW( src ) + 1) * sizeof(WCHAR) );
337  if (dst) strcpyW( dst, src );
338  return dst;
339 }
340 
341 static inline WCHAR *strdupAW( const char *src )
342 {
343  WCHAR *dst = NULL;
344  if (src)
345  {
346  DWORD len = MultiByteToWideChar( CP_ACP, 0, src, -1, NULL, 0 );
347  if ((dst = heap_alloc( len * sizeof(WCHAR) )))
348  MultiByteToWideChar( CP_ACP, 0, src, -1, dst, len );
349  }
350  return dst;
351 }
352 
353 static inline char *strdupWA( const WCHAR *src )
354 {
355  char *dst = NULL;
356  if (src)
357  {
358  int len = WideCharToMultiByte( CP_ACP, 0, src, -1, NULL, 0, NULL, NULL );
359  if ((dst = heap_alloc( len )))
360  WideCharToMultiByte( CP_ACP, 0, src, -1, dst, len, NULL, NULL );
361  }
362  return dst;
363 }
364 
365 static inline char *strdupWA_sized( const WCHAR *src, DWORD size )
366 {
367  char *dst = NULL;
368  if (src)
369  {
370  int len = WideCharToMultiByte( CP_ACP, 0, src, size, NULL, 0, NULL, NULL ) + 1;
371  if ((dst = heap_alloc( len )))
372  {
374  dst[len - 1] = 0;
375  }
376  }
377  return dst;
378 }
379 
381 
382 #endif /* _WINE_WINHTTP_PRIVATE_H_ */
VOID(CALLBACK * WINHTTP_STATUS_CALLBACK)(_In_ HINTERNET, _In_ DWORD_PTR, _In_ DWORD, _In_ LPVOID, _In_ DWORD)
Definition: winhttp.h:520
WCHAR * password
size_t extra_len
BOOL netconn_resolve(WCHAR *, INTERNET_PORT, struct sockaddr_storage *, int) DECLSPEC_HIDDEN
Definition: net.c:896
void netconn_unload(void) DECLSPEC_HIDDEN
Definition: net.c:289
task_proc_t proc
Definition: ieframe.h:80
struct _cookie_t cookie_t
CtxtHandle ssl_ctx
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
LPWSTR servername
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
static const WCHAR http1_0[]
#define WideCharToMultiByte
Definition: compat.h:101
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
LPWSTR username
#define CP_ACP
Definition: compat.h:99
LPWSTR field
BOOL netconn_is_alive(netconn_t *) DECLSPEC_HIDDEN
Definition: net.c:784
ULONG netconn_query_data_available(netconn_t *) DECLSPEC_HIDDEN
Definition: net.c:763
DWORD security_flags
char * host
Definition: whois.c:55
DWORD get_last_error(void) DECLSPEC_HIDDEN
Definition: session.c:65
BOOL cred_handle_initialized
struct list children
session_t * session
request_t * request
task_header_t hdr
task_header_t hdr
WINHTTP_STATUS_CALLBACK callback
char * ssl_buf
size_t peek_len
BOOL free_handle(HINTERNET) DECLSPEC_HIDDEN
Definition: handle.c:124
void delete_domain(domain_t *) DECLSPEC_HIDDEN
Definition: cookie.c:89
#define BOOL
Definition: nt_native.h:43
BOOL process_header(request_t *request, LPCWSTR field, LPCWSTR value, DWORD flags, BOOL request_only) DECLSPEC_HIDDEN
Definition: request.c:409
static BOOL query_option(object_header_t *hdr, DWORD option, LPVOID buffer, LPDWORD buflen)
Definition: session.c:1170
#define DWORD
Definition: nt_native.h:44
auth_target
DWORD content_length
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
unsigned read_buf(z_streamp strm, Bytef *buf, unsigned size)
Definition: deflate.c:1167
HANDLE task_cancel
void * optional
netconn_t * netconn_create(hostdata_t *, const struct sockaddr_storage *, int) DECLSPEC_HIDDEN
Definition: net.c:300
BOOL netconn_close(netconn_t *) DECLSPEC_HIDDEN
Definition: net.c:405
DWORD secure_protocols
static const WCHAR postW[]
WCHAR * username
WORD INTERNET_PORT
Definition: winhttp.h:38
DWORD num_headers
LPWSTR proxy_password
HANDLE task_wait
CredHandle cred
object_header_t hdr
DWORD content_read
WCHAR * name
static void * __WINE_ALLOC_SIZE(2) heap_realloc_zero(LPVOID mem
unsigned int BOOL
Definition: ntddk_ex.h:94
long LONG
Definition: pedump.c:60
object_header_t hdr
char * extra_buf
void set_last_error(DWORD) DECLSPEC_HIDDEN
Definition: session.c:59
WCHAR * hostname
BOOL set_cookies(request_t *, const WCHAR *) DECLSPEC_HIDDEN
Definition: cookie.c:232
void release_object(object_header_t *) DECLSPEC_HIDDEN
Definition: handle.c:73
static const WCHAR connections[]
Definition: connections.c:41
smooth NULL
Definition: ftsmooth.c:416
object_header_t * addref_object(object_header_t *) DECLSPEC_HIDDEN
Definition: handle.c:50
static WCHAR * strdupW(const WCHAR *src)
BOOL add_request_headers(request_t *, LPCWSTR, DWORD, DWORD) DECLSPEC_HIDDEN
Definition: request.c:474
HINTERNET alloc_handle(object_header_t *) DECLSPEC_HIDDEN
Definition: handle.c:89
struct authinfo * authinfo
connect_t * connect
GLsizeiptr size
Definition: glext.h:5919
static char * strdupWA_sized(const WCHAR *src, DWORD size)
LPWSTR proxy_server
#define GetProcessHeap()
Definition: compat.h:403
TimeStamp exp
static char * strdupWA(const WCHAR *src)
HANDLE unload_event
netconn_t * netconn
__wchar_t WCHAR
Definition: xmlstorage.h:180
Definition: parser.c:43
LONG HRESULT
Definition: typedefs.h:77
uint64_t ULONGLONG
Definition: typedefs.h:65
LPWSTR hostname
CredHandle cred_handle
struct list entry
LPWSTR value
unsigned long DWORD
Definition: ntddk_ex.h:95
INTERNET_PORT hostport
char * peek_msg
unsigned int data_len
void send_callback(object_header_t *, DWORD, LPVOID, DWORD) DECLSPEC_HIDDEN
Definition: session.c:71
GLbitfield flags
Definition: glext.h:7161
const object_vtbl_t * vtbl
BOOL read_chunked_eof
static CookieInternal * cookies
Definition: msctf.c:65
void destroy(_Tp *__pointer)
Definition: _construct.h:278
const void * netconn_get_certificate(netconn_t *) DECLSPEC_HIDDEN
Definition: net.c:928
void release_typelib(void) DECLSPEC_HIDDEN
Definition: apps.c:159
HANDLE task_thread
uint32_t entry
Definition: isohybrid.c:63
object_header_t * grab_object(HINTERNET) DECLSPEC_HIDDEN
Definition: handle.c:57
GLenum GLsizei len
Definition: glext.h:6722
Definition: _list.h:228
header_t * headers
GLenum src
Definition: glext.h:6340
WCHAR * name
struct authinfo * proxy_authinfo
LPWSTR proxy_username
uint32_t DWORD_PTR
Definition: typedefs.h:63
DWORD scheme
struct list entry
Definition: ieframe.h:79
BOOL netconn_recv(netconn_t *, void *, size_t, int, int *) DECLSPEC_HIDDEN
Definition: net.c:706
int netconn_get_cipher_strength(netconn_t *) DECLSPEC_HIDDEN
Definition: net.c:938
LPWSTR proxy_bypass
task_header_t hdr
BOOL read_chunked_size
ULONG_PTR SIZE_T
Definition: typedefs.h:78
static const WCHAR slashW[]
char * data
WINE_UNICODE_INLINE WCHAR * strcpyW(WCHAR *dst, const WCHAR *src)
Definition: unicode.h:219
LPWSTR status_text
void destroy_authinfo(struct authinfo *) DECLSPEC_HIDDEN
Definition: request.c:1117
#define HeapReAlloc
Definition: compat.h:401
GLenum GLenum dst
Definition: glext.h:6340
static const WCHAR http1_1[]
INTERNET_PORT port
void close_connection(request_t *) DECLSPEC_HIDDEN
Definition: request.c:1803
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
BOOL add_cookie_headers(request_t *) DECLSPEC_HIDDEN
Definition: cookie.c:293
WCHAR * value
#define MultiByteToWideChar
Definition: compat.h:100
hostdata_t * host
Definition: tftpd.h:85
BOOL set_server_for_hostname(connect_t *, LPCWSTR, INTERNET_PORT) DECLSPEC_HIDDEN
Definition: session.c:459
void release_host(hostdata_t *host) DECLSPEC_HIDDEN
Definition: request.c:1526
CRITICAL_SECTION task_cs
Definition: mem.c:156
CONST void * LPCVOID
Definition: windef.h:191
DWORD optional_len
static WCHAR * strdupAW(const char *src)
uint32_t * LPDWORD
Definition: typedefs.h:57
unsigned int ULONG
Definition: retypes.h:1
auth_scheme
static const WCHAR getW[]
object_header_t hdr
LPWSTR raw_headers
task_header_t hdr
ULONGLONG keep_until
WCHAR * LPWSTR
Definition: xmlstorage.h:184
static const WCHAR headW[]
DWORD netconn_set_timeout(netconn_t *, BOOL, int) DECLSPEC_HIDDEN
Definition: net.c:768
LPWSTR version
BOOL netconn_secure_connect(netconn_t *, WCHAR *, DWORD, CredHandle *) DECLSPEC_HIDDEN
Definition: net.c:427
static BOOL set_option(object_header_t *hdr, DWORD option, LPVOID buffer, DWORD buflen)
Definition: session.c:1231
LPWSTR password
HINSTANCE winhttp_instance
Definition: main.c:33
SecPkgContext_StreamSizes ssl_sizes
INTERNET_PORT serverport
char * peek_msg_mem
ULONG max_token
WCHAR * path
BOOL netconn_send(netconn_t *, const void *, size_t, int *) DECLSPEC_HIDDEN
Definition: net.c:586
static const WCHAR chunkedW[]
HINSTANCE winhttp_instance DECLSPEC_HIDDEN
HRESULT WinHttpRequest_create(void **) DECLSPEC_HIDDEN
Definition: request.c:4484
CtxtHandle ctx