po: Update Lithuanian translation.
[wine.git] / dlls / winhttp / winhttp_private.h
blobb3f7092d856c21704bf94549abc37f89b8bcb564
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 "wine/heap.h"
23 #include "wine/list.h"
25 #include "ole2.h"
26 #include "sspi.h"
27 #include "wincrypt.h"
29 struct object_header;
30 struct object_vtbl
32 void (*destroy)( struct object_header * );
33 BOOL (*query_option)( struct object_header *, DWORD, void *, DWORD * );
34 BOOL (*set_option)( struct object_header *, DWORD, void *, DWORD );
37 struct object_header
39 DWORD type;
40 HINTERNET handle;
41 const struct object_vtbl *vtbl;
42 DWORD flags;
43 DWORD disable_flags;
44 DWORD logon_policy;
45 DWORD redirect_policy;
46 DWORD error;
47 DWORD_PTR context;
48 LONG refs;
49 WINHTTP_STATUS_CALLBACK callback;
50 DWORD notify_mask;
51 struct list entry;
52 struct list children;
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 request
159 struct object_header hdr;
160 struct connect *connect;
161 WCHAR *verb;
162 WCHAR *path;
163 WCHAR *version;
164 WCHAR *raw_headers;
165 void *optional;
166 DWORD optional_len;
167 struct netconn *netconn;
168 DWORD security_flags;
169 BOOL check_revocation;
170 const CERT_CONTEXT *server_cert;
171 const CERT_CONTEXT *client_cert;
172 CredHandle cred_handle;
173 BOOL cred_handle_initialized;
174 int resolve_timeout;
175 int connect_timeout;
176 int send_timeout;
177 int receive_timeout;
178 int receive_response_timeout;
179 WCHAR *status_text;
180 DWORD content_length; /* total number of bytes to be read */
181 DWORD content_read; /* bytes read so far */
182 BOOL read_chunked; /* are we reading in chunked mode? */
183 BOOL read_chunked_eof; /* end of stream in chunked mode */
184 BOOL read_chunked_size; /* chunk size remaining */
185 DWORD read_pos; /* current read position in read_buf */
186 DWORD read_size; /* valid data size in read_buf */
187 char read_buf[8192]; /* buffer for already read but not returned data */
188 struct header *headers;
189 DWORD num_headers;
190 struct authinfo *authinfo;
191 struct authinfo *proxy_authinfo;
192 HANDLE task_wait;
193 HANDLE task_cancel;
194 BOOL task_proc_running;
195 struct list task_queue;
196 CRITICAL_SECTION task_cs;
197 struct
199 WCHAR *username;
200 WCHAR *password;
201 } creds[TARGET_MAX][SCHEME_MAX];
204 struct task_header
206 struct list entry;
207 struct request *request;
208 void (*proc)( struct task_header * );
211 struct send_request
213 struct task_header hdr;
214 WCHAR *headers;
215 DWORD headers_len;
216 void *optional;
217 DWORD optional_len;
218 DWORD total_len;
219 DWORD_PTR context;
222 struct receive_response
224 struct task_header hdr;
227 struct query_data
229 struct task_header hdr;
230 DWORD *available;
233 struct read_data
235 struct task_header hdr;
236 void *buffer;
237 DWORD to_read;
238 DWORD *read;
241 struct write_data
243 struct task_header hdr;
244 const void *buffer;
245 DWORD to_write;
246 DWORD *written;
249 struct object_header *addref_object( struct object_header * ) DECLSPEC_HIDDEN;
250 struct object_header *grab_object( HINTERNET ) DECLSPEC_HIDDEN;
251 void release_object( struct object_header * ) DECLSPEC_HIDDEN;
252 HINTERNET alloc_handle( struct object_header * ) DECLSPEC_HIDDEN;
253 BOOL free_handle( HINTERNET ) DECLSPEC_HIDDEN;
255 void send_callback( struct object_header *, DWORD, LPVOID, DWORD ) DECLSPEC_HIDDEN;
256 void close_connection( struct request * ) DECLSPEC_HIDDEN;
258 void netconn_close( struct netconn * ) DECLSPEC_HIDDEN;
259 struct netconn *netconn_create( struct hostdata *, const struct sockaddr_storage *, int ) DECLSPEC_HIDDEN;
260 void netconn_unload( void ) DECLSPEC_HIDDEN;
261 ULONG netconn_query_data_available( struct netconn * ) DECLSPEC_HIDDEN;
262 BOOL netconn_recv( struct netconn *, void *, size_t, int, int * ) DECLSPEC_HIDDEN;
263 BOOL netconn_resolve( WCHAR *, INTERNET_PORT, struct sockaddr_storage *, int ) DECLSPEC_HIDDEN;
264 BOOL netconn_secure_connect( struct netconn *, WCHAR *, DWORD, CredHandle *, BOOL ) DECLSPEC_HIDDEN;
265 BOOL netconn_send( struct netconn *, const void *, size_t, int * ) DECLSPEC_HIDDEN;
266 DWORD netconn_set_timeout( struct netconn *, BOOL, int ) DECLSPEC_HIDDEN;
267 BOOL netconn_is_alive( struct netconn * ) DECLSPEC_HIDDEN;
268 const void *netconn_get_certificate( struct netconn * ) DECLSPEC_HIDDEN;
269 int netconn_get_cipher_strength( struct netconn * ) DECLSPEC_HIDDEN;
271 BOOL set_cookies( struct request *, const WCHAR * ) DECLSPEC_HIDDEN;
272 BOOL add_cookie_headers( struct request * ) DECLSPEC_HIDDEN;
273 BOOL add_request_headers( struct request *, const WCHAR *, DWORD, DWORD ) DECLSPEC_HIDDEN;
274 void destroy_cookies( struct session * ) DECLSPEC_HIDDEN;
275 BOOL set_server_for_hostname( struct connect *, const WCHAR *, INTERNET_PORT ) DECLSPEC_HIDDEN;
276 void destroy_authinfo( struct authinfo * ) DECLSPEC_HIDDEN;
278 void release_host( struct hostdata * ) DECLSPEC_HIDDEN;
279 BOOL process_header( struct request *, const WCHAR *, const WCHAR *, DWORD, BOOL ) DECLSPEC_HIDDEN;
281 extern HRESULT WinHttpRequest_create( void ** ) DECLSPEC_HIDDEN;
282 void release_typelib( void ) DECLSPEC_HIDDEN;
284 static inline void* __WINE_ALLOC_SIZE(2) heap_realloc_zero( LPVOID mem, SIZE_T size )
286 return HeapReAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, mem, size );
289 static inline WCHAR *strdupW( const WCHAR *src )
291 WCHAR *dst;
293 if (!src) return NULL;
294 dst = heap_alloc( (lstrlenW( src ) + 1) * sizeof(WCHAR) );
295 if (dst) lstrcpyW( dst, src );
296 return dst;
299 static inline WCHAR *strdupAW( const char *src )
301 WCHAR *dst = NULL;
302 if (src)
304 int len = MultiByteToWideChar( CP_ACP, 0, src, -1, NULL, 0 );
305 if ((dst = heap_alloc( len * sizeof(WCHAR) )))
306 MultiByteToWideChar( CP_ACP, 0, src, -1, dst, len );
308 return dst;
311 static inline char *strdupWA( const WCHAR *src )
313 char *dst = NULL;
314 if (src)
316 int len = WideCharToMultiByte( CP_ACP, 0, src, -1, NULL, 0, NULL, NULL );
317 if ((dst = heap_alloc( len )))
318 WideCharToMultiByte( CP_ACP, 0, src, -1, dst, len, NULL, NULL );
320 return dst;
323 static inline char *strdupWA_sized( const WCHAR *src, DWORD size )
325 char *dst = NULL;
326 if (src)
328 int len = WideCharToMultiByte( CP_ACP, 0, src, size, NULL, 0, NULL, NULL ) + 1;
329 if ((dst = heap_alloc( len )))
331 WideCharToMultiByte( CP_ACP, 0, src, size, dst, len, NULL, NULL );
332 dst[len - 1] = 0;
335 return dst;
338 extern HINSTANCE winhttp_instance DECLSPEC_HIDDEN;
340 #endif /* _WINE_WINHTTP_PRIVATE_H_ */