ReactOS  0.4.14-dev-838-g99f979d
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 "ole2.h"
31 #include "sspi.h"
32 #include "wincrypt.h"
33 
34 static const WCHAR getW[] = {'G','E','T',0};
35 static const WCHAR postW[] = {'P','O','S','T',0};
36 static const WCHAR headW[] = {'H','E','A','D',0};
37 static const WCHAR slashW[] = {'/',0};
38 static const WCHAR http1_0[] = {'H','T','T','P','/','1','.','0',0};
39 static const WCHAR http1_1[] = {'H','T','T','P','/','1','.','1',0};
40 static const WCHAR chunkedW[] = {'c','h','u','n','k','e','d',0};
41 
42 struct object_header;
44 {
45  void (*destroy)( struct object_header * );
46  BOOL (*query_option)( struct object_header *, DWORD, void *, DWORD * );
47  BOOL (*set_option)( struct object_header *, DWORD, void *, DWORD );
48 };
49 
51 {
54  const struct object_vtbl *vtbl;
64  struct list entry;
65  struct list children;
66 };
67 
68 struct hostdata
69 {
70  struct list entry;
75  struct list connections;
76 };
77 
78 struct session
79 {
97 };
98 
99 struct connect
100 {
102  struct session *session;
103  WCHAR *hostname; /* final destination of the request */
104  WCHAR *servername; /* name of the server we directly connect to */
111 };
112 
113 struct netconn
114 {
115  struct list entry;
116  int socket;
118  BOOL secure; /* SSL active on connection? */
119  struct hostdata *host;
123  char *ssl_buf;
124  char *extra_buf;
125  size_t extra_len;
126  char *peek_msg;
128  size_t peek_len;
129 };
130 
131 struct header
132 {
135  BOOL is_request; /* part of request headers? */
136 };
137 
139 {
144 };
145 
147 {
155 };
156 
157 struct authinfo
158 {
161  CtxtHandle ctx;
162  TimeStamp exp;
163  ULONG attr;
165  char *data;
166  unsigned int data_len;
167  BOOL finished; /* finished authenticating */
168 };
169 
170 struct request
171 {
173  struct connect *connect;
178  void *optional;
180  struct netconn *netconn;
193  DWORD content_length; /* total number of bytes to be read */
194  DWORD content_read; /* bytes read so far */
195  BOOL read_chunked; /* are we reading in chunked mode? */
196  BOOL read_chunked_eof; /* end of stream in chunked mode */
197  BOOL read_chunked_size; /* chunk size remaining */
198  DWORD read_pos; /* current read position in read_buf */
199  DWORD read_size; /* valid data size in read_buf */
200  char read_buf[8192]; /* buffer for already read but not returned data */
201  struct header *headers;
207 #ifdef __REACTOS__
208  HANDLE task_thread;
209 #else
211 #endif
212  struct list task_queue;
214  struct
215  {
219 };
220 
222 {
223  struct list entry;
224  struct request *request;
225  void (*proc)( struct task_header * );
226 };
227 
229 {
230  struct task_header hdr;
233  void *optional;
237 };
238 
240 {
241  struct task_header hdr;
242 };
243 
245 {
246  struct task_header hdr;
248 };
249 
250 struct read_data
251 {
252  struct task_header hdr;
253  void *buffer;
256 };
257 
259 {
260  struct task_header hdr;
261  const void *buffer;
264 };
265 
271 
273 void close_connection( struct request * ) DECLSPEC_HIDDEN;
274 
275 void netconn_close( struct netconn * ) DECLSPEC_HIDDEN;
276 struct netconn *netconn_create( struct hostdata *, const struct sockaddr_storage *, int ) DECLSPEC_HIDDEN;
277 void netconn_unload( void ) DECLSPEC_HIDDEN;
279 BOOL netconn_recv( struct netconn *, void *, size_t, int, int * ) DECLSPEC_HIDDEN;
282 BOOL netconn_send( struct netconn *, const void *, size_t, int * ) DECLSPEC_HIDDEN;
285 const void *netconn_get_certificate( struct netconn * ) DECLSPEC_HIDDEN;
287 
288 BOOL set_cookies( struct request *, const WCHAR * ) DECLSPEC_HIDDEN;
291 void destroy_cookies( struct session * ) DECLSPEC_HIDDEN;
293 void destroy_authinfo( struct authinfo * ) DECLSPEC_HIDDEN;
294 
295 void release_host( struct hostdata * ) DECLSPEC_HIDDEN;
296 BOOL process_header( struct request *, const WCHAR *, const WCHAR *, DWORD, BOOL ) DECLSPEC_HIDDEN;
297 
299 void release_typelib( void ) DECLSPEC_HIDDEN;
300 
301 static inline void* __WINE_ALLOC_SIZE(2) heap_realloc_zero( LPVOID mem, SIZE_T size )
302 {
304 }
305 
306 static inline WCHAR *strdupW( const WCHAR *src )
307 {
308  WCHAR *dst;
309 
310  if (!src) return NULL;
311  dst = heap_alloc( (strlenW( src ) + 1) * sizeof(WCHAR) );
312  if (dst) strcpyW( dst, src );
313  return dst;
314 }
315 
316 static inline WCHAR *strdupAW( const char *src )
317 {
318  WCHAR *dst = NULL;
319  if (src)
320  {
321  DWORD len = MultiByteToWideChar( CP_ACP, 0, src, -1, NULL, 0 );
322  if ((dst = heap_alloc( len * sizeof(WCHAR) )))
323  MultiByteToWideChar( CP_ACP, 0, src, -1, dst, len );
324  }
325  return dst;
326 }
327 
328 static inline char *strdupWA( const WCHAR *src )
329 {
330  char *dst = NULL;
331  if (src)
332  {
333  int len = WideCharToMultiByte( CP_ACP, 0, src, -1, NULL, 0, NULL, NULL );
334  if ((dst = heap_alloc( len )))
335  WideCharToMultiByte( CP_ACP, 0, src, -1, dst, len, NULL, NULL );
336  }
337  return dst;
338 }
339 
340 static inline char *strdupWA_sized( const WCHAR *src, DWORD size )
341 {
342  char *dst = NULL;
343  if (src)
344  {
345  int len = WideCharToMultiByte( CP_ACP, 0, src, size, NULL, 0, NULL, NULL ) + 1;
346  if ((dst = heap_alloc( len )))
347  {
349  dst[len - 1] = 0;
350  }
351  }
352  return dst;
353 }
354 
356 
357 #endif /* _WINE_WINHTTP_PRIVATE_H_ */
struct list entry
VOID(CALLBACK * WINHTTP_STATUS_CALLBACK)(_In_ HINTERNET, _In_ DWORD_PTR, _In_ DWORD, _In_ LPVOID, _In_ DWORD)
Definition: winhttp.h:520
ULONGLONG keep_until
char * peek_msg_mem
BOOL netconn_resolve(WCHAR *, INTERNET_PORT, struct sockaddr_storage *, int) DECLSPEC_HIDDEN
Definition: net.c:725
ULONG netconn_query_data_available(struct netconn *) DECLSPEC_HIDDEN
Definition: net.c:591
void netconn_unload(void) DECLSPEC_HIDDEN
Definition: net.c:156
int receive_timeout
size_t peek_len
BOOL(* set_option)(struct object_header *, DWORD, void *, DWORD)
WCHAR * proxy_username
struct connect * connect
DWORD content_length
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
BOOL set_cookies(struct request *, const WCHAR *) DECLSPEC_HIDDEN
Definition: cookie.c:263
char * extra_buf
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
WCHAR * proxy_password
DWORD optional_len
static const WCHAR http1_0[]
size_t extra_len
#define WideCharToMultiByte
Definition: compat.h:101
CredHandle cred_handle
BOOL is_request
HANDLE task_wait
#define CP_ACP
Definition: compat.h:99
WCHAR * proxy_server
char * peek_msg
WCHAR * field
const CERT_CONTEXT * client_cert
WCHAR * path
DWORD_PTR context
DWORD netconn_set_timeout(struct netconn *, BOOL, int) DECLSPEC_HIDDEN
Definition: net.c:596
WCHAR * version
struct session * session
WCHAR * hostname
SecPkgContext_StreamSizes ssl_sizes
BOOL check_revocation
DWORD content_read
DWORD * read
BOOL cred_handle_initialized
int receive_timeout
BOOL free_handle(HINTERNET) DECLSPEC_HIDDEN
Definition: handle.c:123
struct netconn * netconn_create(struct hostdata *, const struct sockaddr_storage *, int) DECLSPEC_HIDDEN
Definition: net.c:186
#define BOOL
Definition: nt_native.h:43
#define DWORD
Definition: nt_native.h:44
auth_target
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
struct list entry
BOOL netconn_send(struct netconn *, const void *, size_t, int *) DECLSPEC_HIDDEN
Definition: net.c:424
const void * buffer
BOOL read_chunked
char read_buf[8192]
static const WCHAR postW[]
WORD INTERNET_PORT
Definition: winhttp.h:38
struct task_header hdr
BOOL add_request_headers(struct request *, const WCHAR *, DWORD, DWORD) DECLSPEC_HIDDEN
Definition: request.c:495
struct task_header hdr
CredHandle cred
static void * __WINE_ALLOC_SIZE(2) heap_realloc_zero(LPVOID mem
unsigned int BOOL
Definition: ntddk_ex.h:94
int resolve_timeout
long LONG
Definition: pedump.c:60
int send_timeout
DWORD read_pos
void release_object(struct object_header *) DECLSPEC_HIDDEN
Definition: handle.c:72
struct request * request
WCHAR * username
int connect_timeout
DWORD passport_flags
WCHAR * status_text
smooth NULL
Definition: ftsmooth.c:416
int netconn_get_cipher_strength(struct netconn *) DECLSPEC_HIDDEN
Definition: net.c:768
static WCHAR * strdupW(const WCHAR *src)
DWORD * available
struct list task_queue
BOOL(* query_option)(struct object_header *, DWORD, void *, DWORD *)
HINTERNET alloc_handle(struct object_header *) DECLSPEC_HIDDEN
Definition: handle.c:88
INTERNET_PORT serverport
BOOL netconn_secure_connect(struct netconn *, WCHAR *, DWORD, CredHandle *, BOOL) DECLSPEC_HIDDEN
Definition: net.c:264
WINHTTP_STATUS_CALLBACK callback
GLsizeiptr size
Definition: glext.h:5919
static char * strdupWA_sized(const WCHAR *src, DWORD size)
WCHAR * password
#define GetProcessHeap()
Definition: compat.h:403
TimeStamp exp
void(* destroy)(struct object_header *)
WCHAR * raw_headers
static char * strdupWA(const WCHAR *src)
WCHAR * value
CRITICAL_SECTION cs
__wchar_t WCHAR
Definition: xmlstorage.h:180
struct object_header hdr
void destroy_cookies(struct session *) DECLSPEC_HIDDEN
Definition: cookie.c:120
LONG HRESULT
Definition: typedefs.h:77
WCHAR * proxy_bypass
struct task_header hdr
uint64_t ULONGLONG
Definition: typedefs.h:65
const CERT_CONTEXT * server_cert
CtxtHandle ssl_ctx
DWORD access
void send_callback(struct object_header *, DWORD, LPVOID, DWORD) DECLSPEC_HIDDEN
WCHAR * agent
unsigned long DWORD
Definition: ntddk_ex.h:95
BOOL netconn_recv(struct netconn *, void *, size_t, int, int *) DECLSPEC_HIDDEN
Definition: net.c:539
WCHAR * hostname
unsigned int data_len
DWORD read_size
BOOL add_cookie_headers(struct request *) DECLSPEC_HIDDEN
Definition: cookie.c:324
struct authinfo * proxy_authinfo
BOOL process_header(struct request *, const WCHAR *, const WCHAR *, DWORD, BOOL) DECLSPEC_HIDDEN
Definition: request.c:430
const struct object_vtbl * vtbl
void netconn_close(struct netconn *) DECLSPEC_HIDDEN
Definition: net.c:250
void(* proc)(struct task_header *)
struct header * headers
void release_typelib(void) DECLSPEC_HIDDEN
Definition: apps.c:159
struct request::@582 creds[TARGET_MAX][SCHEME_MAX]
struct list entry
struct list cookie_cache
GLenum GLsizei len
Definition: glext.h:6722
DWORD * written
Definition: _list.h:228
WCHAR * password
HANDLE unload_event
GLenum src
Definition: glext.h:6340
struct task_header hdr
HINTERNET handle
uint32_t DWORD_PTR
Definition: typedefs.h:63
DWORD scheme
struct hostdata * host
WCHAR * verb
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
const void * netconn_get_certificate(struct netconn *) DECLSPEC_HIDDEN
Definition: net.c:758
CRITICAL_SECTION task_cs
INTERNET_PORT hostport
struct list connections
struct object_header * grab_object(HINTERNET) DECLSPEC_HIDDEN
Definition: handle.c:56
void release_host(struct hostdata *) DECLSPEC_HIDDEN
Definition: request.c:1494
void destroy_authinfo(struct authinfo *) DECLSPEC_HIDDEN
Definition: request.c:1138
DWORD_PTR context
int receive_response_timeout
#define HeapReAlloc
Definition: compat.h:401
GLenum GLenum dst
Definition: glext.h:6340
static const WCHAR http1_1[]
struct object_header hdr
struct netconn * netconn
BOOL netconn_is_alive(struct netconn *) DECLSPEC_HIDDEN
Definition: net.c:608
int receive_response_timeout
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
#define MultiByteToWideChar
Definition: compat.h:100
struct authinfo * authinfo
Definition: tftpd.h:85
int connect_timeout
int send_timeout
Definition: mem.c:156
WCHAR * username
static WCHAR * strdupAW(const char *src)
BOOL read_chunked_eof
unsigned int ULONG
Definition: retypes.h:1
struct task_header hdr
auth_scheme
static const WCHAR getW[]
void * optional
struct list children
struct object_header hdr
DWORD num_headers
WCHAR * servername
static const WCHAR headW[]
int resolve_timeout
BOOL set_server_for_hostname(struct connect *, const WCHAR *, INTERNET_PORT) DECLSPEC_HIDDEN
Definition: session.c:476
DWORD secure_protocols
DWORD security_flags
struct object_header * addref_object(struct object_header *) DECLSPEC_HIDDEN
Definition: handle.c:49
struct list entry
HINSTANCE winhttp_instance
Definition: main.c:34
char * ssl_buf
INTERNET_PORT port
ULONG max_token
HANDLE task_cancel
BOOL task_proc_running
static const WCHAR chunkedW[]
HINSTANCE winhttp_instance DECLSPEC_HIDDEN
HRESULT WinHttpRequest_create(void **) DECLSPEC_HIDDEN
Definition: request.c:4782
BOOL read_chunked_size
CtxtHandle ctx
void close_connection(struct request *) DECLSPEC_HIDDEN
Definition: request.c:1809