user32/tests: Test pending redraw state with owner-drawn list box.
[wine.git] / dlls / winhttp / winhttp_private.h
blob069951d4811d600148c1d95427f94ac109ca3e2b
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 struct list entry;
55 struct hostdata
57 struct list entry;
58 LONG ref;
59 WCHAR *hostname;
60 INTERNET_PORT port;
61 BOOL secure;
62 struct list connections;
65 struct session
67 struct object_header hdr;
68 CRITICAL_SECTION cs;
69 WCHAR *agent;
70 DWORD access;
71 int resolve_timeout;
72 int connect_timeout;
73 int send_timeout;
74 int receive_timeout;
75 int receive_response_timeout;
76 WCHAR *proxy_server;
77 WCHAR *proxy_bypass;
78 WCHAR *proxy_username;
79 WCHAR *proxy_password;
80 struct list cookie_cache;
81 HANDLE unload_event;
82 DWORD secure_protocols;
83 DWORD passport_flags;
86 struct connect
88 struct object_header hdr;
89 struct session *session;
90 WCHAR *hostname; /* final destination of the request */
91 WCHAR *servername; /* name of the server we directly connect to */
92 WCHAR *username;
93 WCHAR *password;
94 INTERNET_PORT hostport;
95 INTERNET_PORT serverport;
96 struct sockaddr_storage sockaddr;
97 BOOL resolved;
100 struct netconn
102 struct list entry;
103 int socket;
104 struct sockaddr_storage sockaddr;
105 BOOL secure; /* SSL active on connection? */
106 struct hostdata *host;
107 ULONGLONG keep_until;
108 CtxtHandle ssl_ctx;
109 SecPkgContext_StreamSizes ssl_sizes;
110 char *ssl_buf;
111 char *extra_buf;
112 size_t extra_len;
113 char *peek_msg;
114 char *peek_msg_mem;
115 size_t peek_len;
118 struct header
120 WCHAR *field;
121 WCHAR *value;
122 BOOL is_request; /* part of request headers? */
125 enum auth_target
127 TARGET_INVALID = -1,
128 TARGET_SERVER,
129 TARGET_PROXY,
130 TARGET_MAX
133 enum auth_scheme
135 SCHEME_INVALID = -1,
136 SCHEME_BASIC,
137 SCHEME_NTLM,
138 SCHEME_PASSPORT,
139 SCHEME_DIGEST,
140 SCHEME_NEGOTIATE,
141 SCHEME_MAX
144 struct authinfo
146 enum auth_scheme scheme;
147 CredHandle cred;
148 CtxtHandle ctx;
149 TimeStamp exp;
150 ULONG attr;
151 ULONG max_token;
152 char *data;
153 unsigned int data_len;
154 BOOL finished; /* finished authenticating */
157 struct queue
159 TP_POOL *pool;
160 TP_CALLBACK_ENVIRON env;
163 enum request_flags
165 REQUEST_FLAG_WEBSOCKET_UPGRADE = 0x01,
168 struct request
170 struct object_header hdr;
171 struct connect *connect;
172 enum request_flags flags;
173 WCHAR *verb;
174 WCHAR *path;
175 WCHAR *version;
176 WCHAR *raw_headers;
177 void *optional;
178 DWORD optional_len;
179 struct netconn *netconn;
180 DWORD security_flags;
181 BOOL check_revocation;
182 const CERT_CONTEXT *server_cert;
183 const CERT_CONTEXT *client_cert;
184 CredHandle cred_handle;
185 BOOL cred_handle_initialized;
186 int resolve_timeout;
187 int connect_timeout;
188 int send_timeout;
189 int receive_timeout;
190 int receive_response_timeout;
191 DWORD max_redirects;
192 DWORD redirect_count; /* total number of redirects during this request */
193 WCHAR *status_text;
194 DWORD content_length; /* total number of bytes to be read */
195 DWORD content_read; /* bytes read so far */
196 BOOL read_chunked; /* are we reading in chunked mode? */
197 BOOL read_chunked_eof; /* end of stream in chunked mode */
198 BOOL read_chunked_size; /* chunk size remaining */
199 DWORD read_pos; /* current read position in read_buf */
200 DWORD read_size; /* valid data size in read_buf */
201 char read_buf[8192]; /* buffer for already read but not returned data */
202 struct header *headers;
203 DWORD num_headers;
204 struct authinfo *authinfo;
205 struct authinfo *proxy_authinfo;
206 struct queue queue;
207 struct
209 WCHAR *username;
210 WCHAR *password;
211 } creds[TARGET_MAX][SCHEME_MAX];
214 enum socket_state
216 SOCKET_STATE_OPEN = 0,
217 SOCKET_STATE_SHUTDOWN = 1,
218 SOCKET_STATE_CLOSED = 2,
221 /* rfc6455 */
222 enum socket_opcode
224 SOCKET_OPCODE_CONTINUE = 0x00,
225 SOCKET_OPCODE_TEXT = 0x01,
226 SOCKET_OPCODE_BINARY = 0x02,
227 SOCKET_OPCODE_RESERVED3 = 0x03,
228 SOCKET_OPCODE_RESERVED4 = 0x04,
229 SOCKET_OPCODE_RESERVED5 = 0x05,
230 SOCKET_OPCODE_RESERVED6 = 0x06,
231 SOCKET_OPCODE_RESERVED7 = 0x07,
232 SOCKET_OPCODE_CLOSE = 0x08,
233 SOCKET_OPCODE_PING = 0x09,
234 SOCKET_OPCODE_PONG = 0x0a,
235 SOCKET_OPCODE_INVALID = 0xff,
238 struct socket
240 struct object_header hdr;
241 struct request *request;
242 enum socket_state state;
243 struct queue send_q;
244 struct queue recv_q;
245 enum socket_opcode opcode;
246 DWORD read_size;
247 USHORT status;
248 char reason[123];
249 DWORD reason_len;
252 struct send_request
254 struct request *request;
255 WCHAR *headers;
256 DWORD headers_len;
257 void *optional;
258 DWORD optional_len;
259 DWORD total_len;
260 DWORD_PTR context;
263 struct receive_response
265 struct request *request;
268 struct query_data
270 struct request *request;
271 DWORD *available;
274 struct read_data
276 struct request *request;
277 void *buffer;
278 DWORD to_read;
279 DWORD *read;
282 struct write_data
284 struct request *request;
285 const void *buffer;
286 DWORD to_write;
287 DWORD *written;
290 struct socket_send
292 struct socket *socket;
293 WINHTTP_WEB_SOCKET_BUFFER_TYPE type;
294 const void *buf;
295 DWORD len;
298 struct socket_receive
300 struct socket *socket;
301 void *buf;
302 DWORD len;
305 struct socket_shutdown
307 struct socket *socket;
308 USHORT status;
309 char reason[123];
310 DWORD len;
313 struct object_header *addref_object( struct object_header * ) DECLSPEC_HIDDEN;
314 struct object_header *grab_object( HINTERNET ) DECLSPEC_HIDDEN;
315 void release_object( struct object_header * ) DECLSPEC_HIDDEN;
316 HINTERNET alloc_handle( struct object_header * ) DECLSPEC_HIDDEN;
317 BOOL free_handle( HINTERNET ) DECLSPEC_HIDDEN;
319 void send_callback( struct object_header *, DWORD, LPVOID, DWORD ) DECLSPEC_HIDDEN;
320 void close_connection( struct request * ) DECLSPEC_HIDDEN;
321 void stop_queue( struct queue * ) DECLSPEC_HIDDEN;
323 void netconn_close( struct netconn * ) DECLSPEC_HIDDEN;
324 DWORD netconn_create( struct hostdata *, const struct sockaddr_storage *, int, struct netconn ** ) DECLSPEC_HIDDEN;
325 void netconn_unload( void ) DECLSPEC_HIDDEN;
326 ULONG netconn_query_data_available( struct netconn * ) DECLSPEC_HIDDEN;
327 DWORD netconn_recv( struct netconn *, void *, size_t, int, int * ) DECLSPEC_HIDDEN;
328 DWORD netconn_resolve( WCHAR *, INTERNET_PORT, struct sockaddr_storage *, int ) DECLSPEC_HIDDEN;
329 DWORD netconn_secure_connect( struct netconn *, WCHAR *, DWORD, CredHandle *, BOOL ) DECLSPEC_HIDDEN;
330 DWORD netconn_send( struct netconn *, const void *, size_t, int * ) DECLSPEC_HIDDEN;
331 DWORD netconn_set_timeout( struct netconn *, BOOL, int ) DECLSPEC_HIDDEN;
332 BOOL netconn_is_alive( struct netconn * ) DECLSPEC_HIDDEN;
333 const void *netconn_get_certificate( struct netconn * ) DECLSPEC_HIDDEN;
334 int netconn_get_cipher_strength( struct netconn * ) DECLSPEC_HIDDEN;
336 BOOL set_cookies( struct request *, const WCHAR * ) DECLSPEC_HIDDEN;
337 DWORD add_cookie_headers( struct request * ) DECLSPEC_HIDDEN;
338 DWORD add_request_headers( struct request *, const WCHAR *, DWORD, DWORD ) DECLSPEC_HIDDEN;
339 void destroy_cookies( struct session * ) DECLSPEC_HIDDEN;
340 BOOL set_server_for_hostname( struct connect *, const WCHAR *, INTERNET_PORT ) DECLSPEC_HIDDEN;
341 void destroy_authinfo( struct authinfo * ) DECLSPEC_HIDDEN;
343 void release_host( struct hostdata * ) DECLSPEC_HIDDEN;
344 DWORD process_header( struct request *, const WCHAR *, const WCHAR *, DWORD, BOOL ) DECLSPEC_HIDDEN;
346 extern HRESULT WinHttpRequest_create( void ** ) DECLSPEC_HIDDEN;
347 void release_typelib( void ) DECLSPEC_HIDDEN;
349 static inline WCHAR *strdupW( const WCHAR *src )
351 WCHAR *dst;
353 if (!src) return NULL;
354 dst = malloc( (lstrlenW( src ) + 1) * sizeof(WCHAR) );
355 if (dst) lstrcpyW( dst, src );
356 return dst;
359 static inline WCHAR *strdupAW( const char *src )
361 WCHAR *dst = NULL;
362 if (src)
364 int len = MultiByteToWideChar( CP_ACP, 0, src, -1, NULL, 0 );
365 if ((dst = malloc( len * sizeof(WCHAR) )))
366 MultiByteToWideChar( CP_ACP, 0, src, -1, dst, len );
368 return dst;
371 static inline char *strdupWA( const WCHAR *src )
373 char *dst = NULL;
374 if (src)
376 int len = WideCharToMultiByte( CP_ACP, 0, src, -1, NULL, 0, NULL, NULL );
377 if ((dst = malloc( len )))
378 WideCharToMultiByte( CP_ACP, 0, src, -1, dst, len, NULL, NULL );
380 return dst;
383 static inline char *strdupWA_sized( const WCHAR *src, DWORD size )
385 char *dst = NULL;
386 if (src)
388 int len = WideCharToMultiByte( CP_ACP, 0, src, size, NULL, 0, NULL, NULL ) + 1;
389 if ((dst = malloc( len )))
391 WideCharToMultiByte( CP_ACP, 0, src, size, dst, len, NULL, NULL );
392 dst[len - 1] = 0;
395 return dst;
398 extern HINSTANCE winhttp_instance DECLSPEC_HIDDEN;
400 #endif /* _WINE_WINHTTP_PRIVATE_H_ */