dbghelp: Properly fail on PDB files generated by MSVC compiler version 14.31.
[wine.git] / dlls / winhttp / winhttp_private.h
blob4754d9258d15797e47dc19f68867049bc0f8d6b0
1 /*
2 * Copyright 2008 Hans Leidekker for CodeWeavers
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.
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.
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
19 #ifndef _WINE_WINHTTP_PRIVATE_H_
20 #define _WINE_WINHTTP_PRIVATE_H_
22 #include "ole2.h"
23 #include "sspi.h"
24 #include "wincrypt.h"
26 #include "wine/list.h"
28 #define WINHTTP_HANDLE_TYPE_SOCKET 4
30 struct object_header;
31 struct object_vtbl
33 void (*destroy)( struct object_header * );
34 BOOL (*query_option)( struct object_header *, DWORD, void *, DWORD * );
35 BOOL (*set_option)( struct object_header *, DWORD, void *, DWORD );
38 struct object_header
40 DWORD type;
41 HINTERNET handle;
42 const struct object_vtbl *vtbl;
43 DWORD flags;
44 DWORD disable_flags;
45 DWORD logon_policy;
46 DWORD redirect_policy;
47 DWORD error;
48 DWORD_PTR context;
49 LONG refs;
50 WINHTTP_STATUS_CALLBACK callback;
51 DWORD notify_mask;
52 LONG recursion_count;
53 struct list entry;
54 volatile LONG pending_sends;
55 volatile LONG pending_receives;
58 struct hostdata
60 struct list entry;
61 LONG ref;
62 WCHAR *hostname;
63 INTERNET_PORT port;
64 BOOL secure;
65 struct list connections;
68 struct session
70 struct object_header hdr;
71 CRITICAL_SECTION cs;
72 WCHAR *agent;
73 DWORD access;
74 int resolve_timeout;
75 int connect_timeout;
76 int send_timeout;
77 int receive_timeout;
78 int receive_response_timeout;
79 WCHAR *proxy_server;
80 WCHAR *proxy_bypass;
81 WCHAR *proxy_username;
82 WCHAR *proxy_password;
83 struct list cookie_cache;
84 HANDLE unload_event;
85 DWORD secure_protocols;
86 DWORD passport_flags;
89 struct connect
91 struct object_header hdr;
92 struct session *session;
93 WCHAR *hostname; /* final destination of the request */
94 WCHAR *servername; /* name of the server we directly connect to */
95 WCHAR *username;
96 WCHAR *password;
97 INTERNET_PORT hostport;
98 INTERNET_PORT serverport;
99 struct sockaddr_storage sockaddr;
100 BOOL resolved;
103 struct netconn
105 struct list entry;
106 int socket;
107 struct sockaddr_storage sockaddr;
108 BOOL secure; /* SSL active on connection? */
109 struct hostdata *host;
110 ULONGLONG keep_until;
111 CtxtHandle ssl_ctx;
112 SecPkgContext_StreamSizes ssl_sizes;
113 char *ssl_read_buf, *ssl_write_buf;
114 char *extra_buf;
115 size_t extra_len;
116 char *peek_msg;
117 char *peek_msg_mem;
118 size_t peek_len;
121 struct header
123 WCHAR *field;
124 WCHAR *value;
125 BOOL is_request; /* part of request headers? */
128 enum auth_target
130 TARGET_INVALID = -1,
131 TARGET_SERVER,
132 TARGET_PROXY,
133 TARGET_MAX
136 enum auth_scheme
138 SCHEME_INVALID = -1,
139 SCHEME_BASIC,
140 SCHEME_NTLM,
141 SCHEME_PASSPORT,
142 SCHEME_DIGEST,
143 SCHEME_NEGOTIATE,
144 SCHEME_MAX
147 struct authinfo
149 enum auth_scheme scheme;
150 CredHandle cred;
151 CtxtHandle ctx;
152 TimeStamp exp;
153 ULONG attr;
154 ULONG max_token;
155 char *data;
156 unsigned int data_len;
157 BOOL finished; /* finished authenticating */
160 struct queue
162 SRWLOCK lock;
163 struct list queued_tasks;
164 BOOL callback_running;
167 enum request_flags
169 REQUEST_FLAG_WEBSOCKET_UPGRADE = 0x01,
172 struct request
174 struct object_header hdr;
175 struct connect *connect;
176 enum request_flags flags;
177 WCHAR *verb;
178 WCHAR *path;
179 WCHAR *version;
180 WCHAR *raw_headers;
181 void *optional;
182 DWORD optional_len;
183 struct netconn *netconn;
184 DWORD security_flags;
185 BOOL check_revocation;
186 const CERT_CONTEXT *server_cert;
187 const CERT_CONTEXT *client_cert;
188 CredHandle cred_handle;
189 BOOL cred_handle_initialized;
190 int resolve_timeout;
191 int connect_timeout;
192 int send_timeout;
193 int receive_timeout;
194 int receive_response_timeout;
195 DWORD max_redirects;
196 DWORD redirect_count; /* total number of redirects during this request */
197 WCHAR *status_text;
198 DWORD content_length; /* total number of bytes to be read */
199 DWORD content_read; /* bytes read so far */
200 BOOL read_chunked; /* are we reading in chunked mode? */
201 BOOL read_chunked_eof; /* end of stream in chunked mode */
202 BOOL read_chunked_size; /* chunk size remaining */
203 DWORD read_pos; /* current read position in read_buf */
204 DWORD read_size; /* valid data size in read_buf */
205 char read_buf[8192]; /* buffer for already read but not returned data */
206 struct header *headers;
207 DWORD num_headers;
208 struct authinfo *authinfo;
209 struct authinfo *proxy_authinfo;
210 struct queue queue;
211 struct
213 WCHAR *username;
214 WCHAR *password;
215 } creds[TARGET_MAX][SCHEME_MAX];
218 enum socket_state
220 SOCKET_STATE_OPEN = 0,
221 SOCKET_STATE_SHUTDOWN = 1,
222 SOCKET_STATE_CLOSED = 2,
225 /* rfc6455 */
226 enum socket_opcode
228 SOCKET_OPCODE_CONTINUE = 0x00,
229 SOCKET_OPCODE_TEXT = 0x01,
230 SOCKET_OPCODE_BINARY = 0x02,
231 SOCKET_OPCODE_RESERVED3 = 0x03,
232 SOCKET_OPCODE_RESERVED4 = 0x04,
233 SOCKET_OPCODE_RESERVED5 = 0x05,
234 SOCKET_OPCODE_RESERVED6 = 0x06,
235 SOCKET_OPCODE_RESERVED7 = 0x07,
236 SOCKET_OPCODE_CLOSE = 0x08,
237 SOCKET_OPCODE_PING = 0x09,
238 SOCKET_OPCODE_PONG = 0x0a,
239 SOCKET_OPCODE_INVALID = 0xff,
242 enum fragment_type
244 SOCKET_FRAGMENT_NONE,
245 SOCKET_FRAGMENT_BINARY,
246 SOCKET_FRAGMENT_UTF8,
249 struct socket
251 struct object_header hdr;
252 struct request *request;
253 enum socket_state state;
254 struct queue send_q;
255 struct queue recv_q;
256 enum socket_opcode opcode;
257 DWORD read_size;
258 char mask[4];
259 unsigned int mask_index;
260 BOOL close_frame_received;
261 DWORD close_frame_receive_err;
262 USHORT status;
263 char reason[123];
264 DWORD reason_len;
265 char *send_frame_buffer;
266 unsigned int send_frame_buffer_size;
267 unsigned int send_remaining_size;
268 unsigned int bytes_in_send_frame_buffer;
269 unsigned int client_buffer_offset;
270 SRWLOCK send_lock;
271 volatile LONG pending_noncontrol_send;
272 enum fragment_type sending_fragment_type;
273 enum fragment_type receiving_fragment_type;
274 BOOL last_receive_final;
277 typedef void (*TASK_CALLBACK)( void *ctx );
279 struct task_header
281 struct list entry;
282 TASK_CALLBACK callback;
283 struct object_header *obj;
286 struct send_request
288 struct task_header task_hdr;
289 WCHAR *headers;
290 DWORD headers_len;
291 void *optional;
292 DWORD optional_len;
293 DWORD total_len;
294 DWORD_PTR context;
297 struct receive_response
299 struct task_header task_hdr;
302 struct query_data
304 struct task_header task_hdr;
305 DWORD *available;
308 struct read_data
310 struct task_header task_hdr;
311 void *buffer;
312 DWORD to_read;
313 DWORD *read;
316 struct write_data
318 struct task_header task_hdr;
319 const void *buffer;
320 DWORD to_write;
321 DWORD *written;
324 struct socket_send
326 struct task_header task_hdr;
327 WINHTTP_WEB_SOCKET_BUFFER_TYPE type;
328 const void *buf;
329 DWORD len;
330 WSAOVERLAPPED ovr;
331 BOOL complete_async;
334 struct socket_receive
336 struct task_header task_hdr;
337 void *buf;
338 DWORD len;
341 struct socket_shutdown
343 struct task_header task_hdr;
344 USHORT status;
345 char reason[123];
346 DWORD len;
347 BOOL send_callback;
348 WSAOVERLAPPED ovr;
349 BOOL complete_async;
352 struct object_header *addref_object( struct object_header * ) DECLSPEC_HIDDEN;
353 struct object_header *grab_object( HINTERNET ) DECLSPEC_HIDDEN;
354 void release_object( struct object_header * ) DECLSPEC_HIDDEN;
355 HINTERNET alloc_handle( struct object_header * ) DECLSPEC_HIDDEN;
356 BOOL free_handle( HINTERNET ) DECLSPEC_HIDDEN;
358 void send_callback( struct object_header *, DWORD, LPVOID, DWORD ) DECLSPEC_HIDDEN;
359 void close_connection( struct request * ) DECLSPEC_HIDDEN;
360 void init_queue( struct queue *queue ) DECLSPEC_HIDDEN;
361 void stop_queue( struct queue * ) DECLSPEC_HIDDEN;
363 void netconn_close( struct netconn * ) DECLSPEC_HIDDEN;
364 DWORD netconn_create( struct hostdata *, const struct sockaddr_storage *, int, struct netconn ** ) DECLSPEC_HIDDEN;
365 void netconn_unload( void ) DECLSPEC_HIDDEN;
366 ULONG netconn_query_data_available( struct netconn * ) DECLSPEC_HIDDEN;
367 DWORD netconn_recv( struct netconn *, void *, size_t, int, int * ) DECLSPEC_HIDDEN;
368 DWORD netconn_resolve( WCHAR *, INTERNET_PORT, struct sockaddr_storage *, int ) DECLSPEC_HIDDEN;
369 DWORD netconn_secure_connect( struct netconn *, WCHAR *, DWORD, CredHandle *, BOOL ) DECLSPEC_HIDDEN;
370 DWORD netconn_send( struct netconn *, const void *, size_t, int *, WSAOVERLAPPED * ) DECLSPEC_HIDDEN;
371 DWORD netconn_set_timeout( struct netconn *, BOOL, int ) DECLSPEC_HIDDEN;
372 BOOL netconn_is_alive( struct netconn * ) DECLSPEC_HIDDEN;
373 const void *netconn_get_certificate( struct netconn * ) DECLSPEC_HIDDEN;
374 int netconn_get_cipher_strength( struct netconn * ) DECLSPEC_HIDDEN;
376 BOOL set_cookies( struct request *, const WCHAR * ) DECLSPEC_HIDDEN;
377 DWORD add_cookie_headers( struct request * ) DECLSPEC_HIDDEN;
378 DWORD add_request_headers( struct request *, const WCHAR *, DWORD, DWORD ) DECLSPEC_HIDDEN;
379 void destroy_cookies( struct session * ) DECLSPEC_HIDDEN;
380 BOOL set_server_for_hostname( struct connect *, const WCHAR *, INTERNET_PORT ) DECLSPEC_HIDDEN;
381 void destroy_authinfo( struct authinfo * ) DECLSPEC_HIDDEN;
383 void release_host( struct hostdata * ) DECLSPEC_HIDDEN;
384 DWORD process_header( struct request *, const WCHAR *, const WCHAR *, DWORD, BOOL ) DECLSPEC_HIDDEN;
386 extern HRESULT WinHttpRequest_create( void ** ) DECLSPEC_HIDDEN;
387 void release_typelib( void ) DECLSPEC_HIDDEN;
389 static inline WCHAR *strdupW( const WCHAR *src )
391 WCHAR *dst;
393 if (!src) return NULL;
394 dst = malloc( (lstrlenW( src ) + 1) * sizeof(WCHAR) );
395 if (dst) lstrcpyW( dst, src );
396 return dst;
399 static inline WCHAR *strdupAW( const char *src )
401 WCHAR *dst = NULL;
402 if (src)
404 int len = MultiByteToWideChar( CP_ACP, 0, src, -1, NULL, 0 );
405 if ((dst = malloc( len * sizeof(WCHAR) )))
406 MultiByteToWideChar( CP_ACP, 0, src, -1, dst, len );
408 return dst;
411 static inline char *strdupWA( const WCHAR *src )
413 char *dst = NULL;
414 if (src)
416 int len = WideCharToMultiByte( CP_ACP, 0, src, -1, NULL, 0, NULL, NULL );
417 if ((dst = malloc( len )))
418 WideCharToMultiByte( CP_ACP, 0, src, -1, dst, len, NULL, NULL );
420 return dst;
423 static inline char *strdupWA_sized( const WCHAR *src, DWORD size )
425 char *dst = NULL;
426 if (src)
428 int len = WideCharToMultiByte( CP_ACP, 0, src, size, NULL, 0, NULL, NULL ) + 1;
429 if ((dst = malloc( len )))
431 WideCharToMultiByte( CP_ACP, 0, src, size, dst, len, NULL, NULL );
432 dst[len - 1] = 0;
435 return dst;
438 extern HINSTANCE winhttp_instance DECLSPEC_HIDDEN;
440 #define MAX_FRAME_BUFFER_SIZE 65536
442 #endif /* _WINE_WINHTTP_PRIVATE_H_ */