mfplat: Implement IMFAttributes::GetItemByIndex().
[wine.git] / dlls / winhttp / winhttp_private.h
blob38e39cb925eb6e18e21bb6ce45d241cdde781503
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 #ifndef __WINE_CONFIG_H
23 # error You must include config.h to use this header
24 #endif
26 #include "wine/heap.h"
27 #include "wine/list.h"
28 #include "wine/unicode.h"
30 #include "ole2.h"
31 #include "sspi.h"
32 #include "wincrypt.h"
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};
42 struct object_header;
43 struct object_vtbl
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 );
50 struct object_header
52 DWORD type;
53 HINTERNET handle;
54 const struct object_vtbl *vtbl;
55 DWORD flags;
56 DWORD disable_flags;
57 DWORD logon_policy;
58 DWORD redirect_policy;
59 DWORD error;
60 DWORD_PTR context;
61 LONG refs;
62 WINHTTP_STATUS_CALLBACK callback;
63 DWORD notify_mask;
64 struct list entry;
65 struct list children;
68 struct hostdata
70 struct list entry;
71 LONG ref;
72 WCHAR *hostname;
73 INTERNET_PORT port;
74 BOOL secure;
75 struct list connections;
78 struct session
80 struct object_header hdr;
81 CRITICAL_SECTION cs;
82 WCHAR *agent;
83 DWORD access;
84 int resolve_timeout;
85 int connect_timeout;
86 int send_timeout;
87 int receive_timeout;
88 int receive_response_timeout;
89 WCHAR *proxy_server;
90 WCHAR *proxy_bypass;
91 WCHAR *proxy_username;
92 WCHAR *proxy_password;
93 struct list cookie_cache;
94 HANDLE unload_event;
95 DWORD secure_protocols;
98 struct connect
100 struct object_header hdr;
101 struct session *session;
102 WCHAR *hostname; /* final destination of the request */
103 WCHAR *servername; /* name of the server we directly connect to */
104 WCHAR *username;
105 WCHAR *password;
106 INTERNET_PORT hostport;
107 INTERNET_PORT serverport;
108 struct sockaddr_storage sockaddr;
109 BOOL resolved;
112 struct netconn
114 struct list entry;
115 int socket;
116 struct sockaddr_storage sockaddr;
117 BOOL secure; /* SSL active on connection? */
118 struct hostdata *host;
119 ULONGLONG keep_until;
120 CtxtHandle ssl_ctx;
121 SecPkgContext_StreamSizes ssl_sizes;
122 char *ssl_buf;
123 char *extra_buf;
124 size_t extra_len;
125 char *peek_msg;
126 char *peek_msg_mem;
127 size_t peek_len;
130 struct header
132 WCHAR *field;
133 WCHAR *value;
134 BOOL is_request; /* part of request headers? */
137 enum auth_target
139 TARGET_INVALID = -1,
140 TARGET_SERVER,
141 TARGET_PROXY,
142 TARGET_MAX
145 enum auth_scheme
147 SCHEME_INVALID = -1,
148 SCHEME_BASIC,
149 SCHEME_NTLM,
150 SCHEME_PASSPORT,
151 SCHEME_DIGEST,
152 SCHEME_NEGOTIATE,
153 SCHEME_MAX
156 struct authinfo
158 enum auth_scheme scheme;
159 CredHandle cred;
160 CtxtHandle ctx;
161 TimeStamp exp;
162 ULONG attr;
163 ULONG max_token;
164 char *data;
165 unsigned int data_len;
166 BOOL finished; /* finished authenticating */
169 struct request
171 struct object_header hdr;
172 struct connect *connect;
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 WCHAR *status_text;
192 DWORD content_length; /* total number of bytes to be read */
193 DWORD content_read; /* bytes read so far */
194 BOOL read_chunked; /* are we reading in chunked mode? */
195 BOOL read_chunked_eof; /* end of stream in chunked mode */
196 BOOL read_chunked_size; /* chunk size remaining */
197 DWORD read_pos; /* current read position in read_buf */
198 DWORD read_size; /* valid data size in read_buf */
199 char read_buf[8192]; /* buffer for already read but not returned data */
200 struct header *headers;
201 DWORD num_headers;
202 struct authinfo *authinfo;
203 struct authinfo *proxy_authinfo;
204 HANDLE task_wait;
205 HANDLE task_cancel;
206 BOOL task_proc_running;
207 struct list task_queue;
208 CRITICAL_SECTION task_cs;
209 struct
211 WCHAR *username;
212 WCHAR *password;
213 } creds[TARGET_MAX][SCHEME_MAX];
216 struct task_header
218 struct list entry;
219 struct request *request;
220 void (*proc)( struct task_header * );
223 struct send_request
225 struct task_header hdr;
226 WCHAR *headers;
227 DWORD headers_len;
228 void *optional;
229 DWORD optional_len;
230 DWORD total_len;
231 DWORD_PTR context;
234 struct receive_response
236 struct task_header hdr;
239 struct query_data
241 struct task_header hdr;
242 DWORD *available;
245 struct read_data
247 struct task_header hdr;
248 void *buffer;
249 DWORD to_read;
250 DWORD *read;
253 struct write_data
255 struct task_header hdr;
256 const void *buffer;
257 DWORD to_write;
258 DWORD *written;
261 struct object_header *addref_object( struct object_header * ) DECLSPEC_HIDDEN;
262 struct object_header *grab_object( HINTERNET ) DECLSPEC_HIDDEN;
263 void release_object( struct object_header * ) DECLSPEC_HIDDEN;
264 HINTERNET alloc_handle( struct object_header * ) DECLSPEC_HIDDEN;
265 BOOL free_handle( HINTERNET ) DECLSPEC_HIDDEN;
267 void send_callback( struct object_header *, DWORD, LPVOID, DWORD ) DECLSPEC_HIDDEN;
268 void close_connection( struct request * ) DECLSPEC_HIDDEN;
270 void netconn_close( struct netconn * ) DECLSPEC_HIDDEN;
271 struct netconn *netconn_create( struct hostdata *, const struct sockaddr_storage *, int ) DECLSPEC_HIDDEN;
272 void netconn_unload( void ) DECLSPEC_HIDDEN;
273 ULONG netconn_query_data_available( struct netconn * ) DECLSPEC_HIDDEN;
274 BOOL netconn_recv( struct netconn *, void *, size_t, int, int * ) DECLSPEC_HIDDEN;
275 BOOL netconn_resolve( WCHAR *, INTERNET_PORT, struct sockaddr_storage *, int ) DECLSPEC_HIDDEN;
276 BOOL netconn_secure_connect( struct netconn *, WCHAR *, DWORD, CredHandle *, BOOL ) DECLSPEC_HIDDEN;
277 BOOL netconn_send( struct netconn *, const void *, size_t, int * ) DECLSPEC_HIDDEN;
278 DWORD netconn_set_timeout( struct netconn *, BOOL, int ) DECLSPEC_HIDDEN;
279 BOOL netconn_is_alive( struct netconn * ) DECLSPEC_HIDDEN;
280 const void *netconn_get_certificate( struct netconn * ) DECLSPEC_HIDDEN;
281 int netconn_get_cipher_strength( struct netconn * ) DECLSPEC_HIDDEN;
283 BOOL set_cookies( struct request *, const WCHAR * ) DECLSPEC_HIDDEN;
284 BOOL add_cookie_headers( struct request * ) DECLSPEC_HIDDEN;
285 BOOL add_request_headers( struct request *, const WCHAR *, DWORD, DWORD ) DECLSPEC_HIDDEN;
286 void destroy_cookies( struct session * ) DECLSPEC_HIDDEN;
287 BOOL set_server_for_hostname( struct connect *, const WCHAR *, INTERNET_PORT ) DECLSPEC_HIDDEN;
288 void destroy_authinfo( struct authinfo * ) DECLSPEC_HIDDEN;
290 void release_host( struct hostdata * ) DECLSPEC_HIDDEN;
291 BOOL process_header( struct request *, const WCHAR *, const WCHAR *, DWORD, BOOL ) DECLSPEC_HIDDEN;
293 extern HRESULT WinHttpRequest_create( void ** ) DECLSPEC_HIDDEN;
294 void release_typelib( void ) DECLSPEC_HIDDEN;
296 static inline void* __WINE_ALLOC_SIZE(2) heap_realloc_zero( LPVOID mem, SIZE_T size )
298 return HeapReAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, mem, size );
301 static inline WCHAR *strdupW( const WCHAR *src )
303 WCHAR *dst;
305 if (!src) return NULL;
306 dst = heap_alloc( (strlenW( src ) + 1) * sizeof(WCHAR) );
307 if (dst) strcpyW( dst, src );
308 return dst;
311 static inline WCHAR *strdupAW( const char *src )
313 WCHAR *dst = NULL;
314 if (src)
316 DWORD len = MultiByteToWideChar( CP_ACP, 0, src, -1, NULL, 0 );
317 if ((dst = heap_alloc( len * sizeof(WCHAR) )))
318 MultiByteToWideChar( CP_ACP, 0, src, -1, dst, len );
320 return dst;
323 static inline char *strdupWA( const WCHAR *src )
325 char *dst = NULL;
326 if (src)
328 int len = WideCharToMultiByte( CP_ACP, 0, src, -1, NULL, 0, NULL, NULL );
329 if ((dst = heap_alloc( len )))
330 WideCharToMultiByte( CP_ACP, 0, src, -1, dst, len, NULL, NULL );
332 return dst;
335 static inline char *strdupWA_sized( const WCHAR *src, DWORD size )
337 char *dst = NULL;
338 if (src)
340 int len = WideCharToMultiByte( CP_ACP, 0, src, size, NULL, 0, NULL, NULL ) + 1;
341 if ((dst = heap_alloc( len )))
343 WideCharToMultiByte( CP_ACP, 0, src, len, dst, size, NULL, NULL );
344 dst[len - 1] = 0;
347 return dst;
350 extern HINSTANCE winhttp_instance DECLSPEC_HIDDEN;
352 #endif /* _WINE_WINHTTP_PRIVATE_H_ */