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"
29 #define WINHTTP_HANDLE_TYPE_SOCKET 4
34 void (*destroy
)( struct object_header
* );
35 BOOL (*query_option
)( struct object_header
*, DWORD
, void *, DWORD
* );
36 BOOL (*set_option
)( struct object_header
*, DWORD
, void *, DWORD
);
43 const struct object_vtbl
*vtbl
;
47 DWORD redirect_policy
;
51 WINHTTP_STATUS_CALLBACK callback
;
63 struct list connections
;
68 struct object_header hdr
;
76 int receive_response_timeout
;
79 WCHAR
*proxy_username
;
80 WCHAR
*proxy_password
;
81 struct list cookie_cache
;
83 DWORD secure_protocols
;
89 struct object_header hdr
;
90 struct session
*session
;
91 WCHAR
*hostname
; /* final destination of the request */
92 WCHAR
*servername
; /* name of the server we directly connect to */
95 INTERNET_PORT hostport
;
96 INTERNET_PORT serverport
;
97 struct sockaddr_storage sockaddr
;
105 struct sockaddr_storage sockaddr
;
106 BOOL secure
; /* SSL active on connection? */
107 struct hostdata
*host
;
108 ULONGLONG keep_until
;
110 SecPkgContext_StreamSizes ssl_sizes
;
123 BOOL is_request
; /* part of request headers? */
147 enum auth_scheme scheme
;
154 unsigned int data_len
;
155 BOOL finished
; /* finished authenticating */
161 TP_CALLBACK_ENVIRON env
;
166 REQUEST_FLAG_WEBSOCKET_UPGRADE
= 0x01,
171 struct object_header hdr
;
172 struct connect
*connect
;
173 enum request_flags flags
;
180 struct netconn
*netconn
;
181 DWORD security_flags
;
182 BOOL check_revocation
;
183 const CERT_CONTEXT
*server_cert
;
184 const CERT_CONTEXT
*client_cert
;
185 CredHandle cred_handle
;
186 BOOL cred_handle_initialized
;
191 int receive_response_timeout
;
193 DWORD redirect_count
; /* total number of redirects during this request */
195 DWORD content_length
; /* total number of bytes to be read */
196 DWORD content_read
; /* bytes read so far */
197 BOOL read_chunked
; /* are we reading in chunked mode? */
198 BOOL read_chunked_eof
; /* end of stream in chunked mode */
199 BOOL read_chunked_size
; /* chunk size remaining */
200 DWORD read_pos
; /* current read position in read_buf */
201 DWORD read_size
; /* valid data size in read_buf */
202 char read_buf
[8192]; /* buffer for already read but not returned data */
203 struct header
*headers
;
205 struct authinfo
*authinfo
;
206 struct authinfo
*proxy_authinfo
;
212 } creds
[TARGET_MAX
][SCHEME_MAX
];
217 SOCKET_STATE_OPEN
= 0,
218 SOCKET_STATE_SHUTDOWN
= 1,
219 SOCKET_STATE_CLOSED
= 2,
225 SOCKET_OPCODE_CONTINUE
= 0x00,
226 SOCKET_OPCODE_TEXT
= 0x01,
227 SOCKET_OPCODE_BINARY
= 0x02,
228 SOCKET_OPCODE_RESERVED3
= 0x03,
229 SOCKET_OPCODE_RESERVED4
= 0x04,
230 SOCKET_OPCODE_RESERVED5
= 0x05,
231 SOCKET_OPCODE_RESERVED6
= 0x06,
232 SOCKET_OPCODE_RESERVED7
= 0x07,
233 SOCKET_OPCODE_CLOSE
= 0x08,
234 SOCKET_OPCODE_PING
= 0x09,
235 SOCKET_OPCODE_PONG
= 0x0a,
236 SOCKET_OPCODE_INVALID
= 0xff,
241 struct object_header hdr
;
242 struct request
*request
;
243 enum socket_state state
;
246 enum socket_opcode opcode
;
255 struct request
*request
;
264 struct receive_response
266 struct request
*request
;
271 struct request
*request
;
277 struct request
*request
;
285 struct request
*request
;
293 struct socket
*socket
;
294 WINHTTP_WEB_SOCKET_BUFFER_TYPE type
;
299 struct socket_receive
301 struct socket
*socket
;
306 struct socket_shutdown
308 struct socket
*socket
;
314 struct object_header
*addref_object( struct object_header
* ) DECLSPEC_HIDDEN
;
315 struct object_header
*grab_object( HINTERNET
) DECLSPEC_HIDDEN
;
316 void release_object( struct object_header
* ) DECLSPEC_HIDDEN
;
317 HINTERNET
alloc_handle( struct object_header
* ) DECLSPEC_HIDDEN
;
318 BOOL
free_handle( HINTERNET
) DECLSPEC_HIDDEN
;
320 void send_callback( struct object_header
*, DWORD
, LPVOID
, DWORD
) DECLSPEC_HIDDEN
;
321 void close_connection( struct request
* ) DECLSPEC_HIDDEN
;
322 void stop_queue( struct queue
* ) DECLSPEC_HIDDEN
;
324 void netconn_close( struct netconn
* ) DECLSPEC_HIDDEN
;
325 DWORD
netconn_create( struct hostdata
*, const struct sockaddr_storage
*, int, struct netconn
** ) DECLSPEC_HIDDEN
;
326 void netconn_unload( void ) DECLSPEC_HIDDEN
;
327 ULONG
netconn_query_data_available( struct netconn
* ) DECLSPEC_HIDDEN
;
328 DWORD
netconn_recv( struct netconn
*, void *, size_t, int, int * ) DECLSPEC_HIDDEN
;
329 DWORD
netconn_resolve( WCHAR
*, INTERNET_PORT
, struct sockaddr_storage
*, int ) DECLSPEC_HIDDEN
;
330 DWORD
netconn_secure_connect( struct netconn
*, WCHAR
*, DWORD
, CredHandle
*, BOOL
) DECLSPEC_HIDDEN
;
331 DWORD
netconn_send( struct netconn
*, const void *, size_t, int * ) DECLSPEC_HIDDEN
;
332 DWORD
netconn_set_timeout( struct netconn
*, BOOL
, int ) DECLSPEC_HIDDEN
;
333 BOOL
netconn_is_alive( struct netconn
* ) DECLSPEC_HIDDEN
;
334 const void *netconn_get_certificate( struct netconn
* ) DECLSPEC_HIDDEN
;
335 int netconn_get_cipher_strength( struct netconn
* ) DECLSPEC_HIDDEN
;
337 BOOL
set_cookies( struct request
*, const WCHAR
* ) DECLSPEC_HIDDEN
;
338 DWORD
add_cookie_headers( struct request
* ) DECLSPEC_HIDDEN
;
339 DWORD
add_request_headers( struct request
*, const WCHAR
*, DWORD
, DWORD
) DECLSPEC_HIDDEN
;
340 void destroy_cookies( struct session
* ) DECLSPEC_HIDDEN
;
341 BOOL
set_server_for_hostname( struct connect
*, const WCHAR
*, INTERNET_PORT
) DECLSPEC_HIDDEN
;
342 void destroy_authinfo( struct authinfo
* ) DECLSPEC_HIDDEN
;
344 void release_host( struct hostdata
* ) DECLSPEC_HIDDEN
;
345 DWORD
process_header( struct request
*, const WCHAR
*, const WCHAR
*, DWORD
, BOOL
) DECLSPEC_HIDDEN
;
347 extern HRESULT
WinHttpRequest_create( void ** ) DECLSPEC_HIDDEN
;
348 void release_typelib( void ) DECLSPEC_HIDDEN
;
350 static inline void* __WINE_ALLOC_SIZE(2) heap_realloc_zero( LPVOID mem
, SIZE_T size
)
352 return HeapReAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY
, mem
, size
);
355 static inline WCHAR
*strdupW( const WCHAR
*src
)
359 if (!src
) return NULL
;
360 dst
= heap_alloc( (lstrlenW( src
) + 1) * sizeof(WCHAR
) );
361 if (dst
) lstrcpyW( dst
, src
);
365 static inline WCHAR
*strdupAW( const char *src
)
370 int len
= MultiByteToWideChar( CP_ACP
, 0, src
, -1, NULL
, 0 );
371 if ((dst
= heap_alloc( len
* sizeof(WCHAR
) )))
372 MultiByteToWideChar( CP_ACP
, 0, src
, -1, dst
, len
);
377 static inline char *strdupWA( const WCHAR
*src
)
382 int len
= WideCharToMultiByte( CP_ACP
, 0, src
, -1, NULL
, 0, NULL
, NULL
);
383 if ((dst
= heap_alloc( len
)))
384 WideCharToMultiByte( CP_ACP
, 0, src
, -1, dst
, len
, NULL
, NULL
);
389 static inline char *strdupWA_sized( const WCHAR
*src
, DWORD size
)
394 int len
= WideCharToMultiByte( CP_ACP
, 0, src
, size
, NULL
, 0, NULL
, NULL
) + 1;
395 if ((dst
= heap_alloc( len
)))
397 WideCharToMultiByte( CP_ACP
, 0, src
, size
, dst
, len
, NULL
, NULL
);
404 extern HINSTANCE winhttp_instance DECLSPEC_HIDDEN
;
406 #endif /* _WINE_WINHTTP_PRIVATE_H_ */