2008-08-15 14:41:36 +02:00
|
|
|
/*
|
|
|
|
* Copyright 2008 Hans Leidekker for CodeWeavers
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _WINE_WINHTTP_PRIVATE_H_
|
|
|
|
#define _WINE_WINHTTP_PRIVATE_H_
|
|
|
|
|
2018-02-06 01:07:20 +01:00
|
|
|
#include "wine/heap.h"
|
2008-08-15 14:41:36 +02:00
|
|
|
#include "wine/list.h"
|
|
|
|
|
2011-07-08 16:46:14 +02:00
|
|
|
#include "ole2.h"
|
2013-01-23 15:49:15 +01:00
|
|
|
#include "sspi.h"
|
2018-06-11 09:20:35 +02:00
|
|
|
#include "wincrypt.h"
|
2008-08-15 14:42:28 +02:00
|
|
|
|
2018-11-15 12:38:50 +01:00
|
|
|
struct object_header;
|
|
|
|
struct object_vtbl
|
2008-08-15 14:41:36 +02:00
|
|
|
{
|
2018-11-15 12:38:50 +01:00
|
|
|
void (*destroy)( struct object_header * );
|
|
|
|
BOOL (*query_option)( struct object_header *, DWORD, void *, DWORD * );
|
|
|
|
BOOL (*set_option)( struct object_header *, DWORD, void *, DWORD );
|
|
|
|
};
|
2008-08-15 14:41:36 +02:00
|
|
|
|
2018-11-15 12:38:50 +01:00
|
|
|
struct object_header
|
2008-08-15 14:41:36 +02:00
|
|
|
{
|
|
|
|
DWORD type;
|
|
|
|
HINTERNET handle;
|
2018-11-15 12:38:50 +01:00
|
|
|
const struct object_vtbl *vtbl;
|
2008-08-15 14:41:36 +02:00
|
|
|
DWORD flags;
|
2008-09-03 16:58:06 +02:00
|
|
|
DWORD disable_flags;
|
|
|
|
DWORD logon_policy;
|
|
|
|
DWORD redirect_policy;
|
2008-08-15 14:41:36 +02:00
|
|
|
DWORD error;
|
|
|
|
DWORD_PTR context;
|
|
|
|
LONG refs;
|
|
|
|
WINHTTP_STATUS_CALLBACK callback;
|
|
|
|
DWORD notify_mask;
|
|
|
|
struct list entry;
|
|
|
|
struct list children;
|
|
|
|
};
|
|
|
|
|
2018-11-15 12:38:51 +01:00
|
|
|
struct hostdata
|
|
|
|
{
|
2017-07-18 00:25:10 +02:00
|
|
|
struct list entry;
|
|
|
|
LONG ref;
|
|
|
|
WCHAR *hostname;
|
|
|
|
INTERNET_PORT port;
|
|
|
|
BOOL secure;
|
2017-07-18 00:25:15 +02:00
|
|
|
struct list connections;
|
2018-11-15 12:38:51 +01:00
|
|
|
};
|
2017-07-18 00:25:10 +02:00
|
|
|
|
2018-11-22 21:15:51 +01:00
|
|
|
struct session
|
2008-08-15 14:42:15 +02:00
|
|
|
{
|
2018-11-15 12:38:50 +01:00
|
|
|
struct object_header hdr;
|
2018-10-05 14:59:10 +02:00
|
|
|
CRITICAL_SECTION cs;
|
2018-11-22 21:15:51 +01:00
|
|
|
WCHAR *agent;
|
2008-08-15 14:42:15 +02:00
|
|
|
DWORD access;
|
2010-02-22 12:27:30 +01:00
|
|
|
int resolve_timeout;
|
2010-01-29 01:45:15 +01:00
|
|
|
int connect_timeout;
|
|
|
|
int send_timeout;
|
2018-09-10 13:24:34 +02:00
|
|
|
int receive_timeout;
|
|
|
|
int receive_response_timeout;
|
2018-11-22 21:15:51 +01:00
|
|
|
WCHAR *proxy_server;
|
|
|
|
WCHAR *proxy_bypass;
|
|
|
|
WCHAR *proxy_username;
|
|
|
|
WCHAR *proxy_password;
|
2008-09-16 12:31:35 +02:00
|
|
|
struct list cookie_cache;
|
2015-07-22 10:02:01 +02:00
|
|
|
HANDLE unload_event;
|
2017-09-12 09:59:06 +02:00
|
|
|
DWORD secure_protocols;
|
2019-08-02 11:01:37 +02:00
|
|
|
DWORD passport_flags;
|
2018-11-22 21:15:51 +01:00
|
|
|
};
|
2008-08-15 14:42:15 +02:00
|
|
|
|
2018-11-22 21:15:52 +01:00
|
|
|
struct connect
|
2008-08-15 14:42:28 +02:00
|
|
|
{
|
2018-11-15 12:38:50 +01:00
|
|
|
struct object_header hdr;
|
2018-11-22 21:15:51 +01:00
|
|
|
struct session *session;
|
2018-11-22 21:15:52 +01:00
|
|
|
WCHAR *hostname; /* final destination of the request */
|
|
|
|
WCHAR *servername; /* name of the server we directly connect to */
|
|
|
|
WCHAR *username;
|
|
|
|
WCHAR *password;
|
2008-08-15 14:42:28 +02:00
|
|
|
INTERNET_PORT hostport;
|
|
|
|
INTERNET_PORT serverport;
|
2009-07-08 19:39:37 +02:00
|
|
|
struct sockaddr_storage sockaddr;
|
2011-11-25 14:55:13 +01:00
|
|
|
BOOL resolved;
|
2018-11-22 21:15:52 +01:00
|
|
|
};
|
2008-08-15 14:42:28 +02:00
|
|
|
|
2018-11-22 21:15:53 +01:00
|
|
|
struct netconn
|
2008-08-15 14:42:41 +02:00
|
|
|
{
|
2017-07-18 00:25:15 +02:00
|
|
|
struct list entry;
|
2008-08-15 14:42:41 +02:00
|
|
|
int socket;
|
2017-07-18 00:24:59 +02:00
|
|
|
struct sockaddr_storage sockaddr;
|
2008-08-28 13:49:19 +02:00
|
|
|
BOOL secure; /* SSL active on connection? */
|
2018-11-15 12:38:51 +01:00
|
|
|
struct hostdata *host;
|
2017-07-18 00:25:20 +02:00
|
|
|
ULONGLONG keep_until;
|
2013-01-23 15:49:15 +01:00
|
|
|
CtxtHandle ssl_ctx;
|
|
|
|
SecPkgContext_StreamSizes ssl_sizes;
|
2013-01-23 15:49:29 +01:00
|
|
|
char *ssl_buf;
|
2013-01-23 15:49:15 +01:00
|
|
|
char *extra_buf;
|
|
|
|
size_t extra_len;
|
2008-08-15 14:42:41 +02:00
|
|
|
char *peek_msg;
|
|
|
|
char *peek_msg_mem;
|
|
|
|
size_t peek_len;
|
2018-11-22 21:15:53 +01:00
|
|
|
};
|
2008-08-15 14:42:41 +02:00
|
|
|
|
2018-11-06 16:09:01 +01:00
|
|
|
struct header
|
2008-08-15 14:42:41 +02:00
|
|
|
{
|
2018-11-06 16:09:01 +01:00
|
|
|
WCHAR *field;
|
|
|
|
WCHAR *value;
|
2008-08-20 11:35:39 +02:00
|
|
|
BOOL is_request; /* part of request headers? */
|
2018-11-06 16:09:01 +01:00
|
|
|
};
|
2008-08-15 14:42:41 +02:00
|
|
|
|
2015-06-12 15:08:30 +02:00
|
|
|
enum auth_target
|
|
|
|
{
|
|
|
|
TARGET_INVALID = -1,
|
|
|
|
TARGET_SERVER,
|
|
|
|
TARGET_PROXY,
|
|
|
|
TARGET_MAX
|
|
|
|
};
|
|
|
|
|
2013-04-30 11:32:59 +02:00
|
|
|
enum auth_scheme
|
|
|
|
{
|
|
|
|
SCHEME_INVALID = -1,
|
|
|
|
SCHEME_BASIC,
|
|
|
|
SCHEME_NTLM,
|
|
|
|
SCHEME_PASSPORT,
|
|
|
|
SCHEME_DIGEST,
|
2015-06-12 15:08:30 +02:00
|
|
|
SCHEME_NEGOTIATE,
|
|
|
|
SCHEME_MAX
|
2013-04-30 11:32:59 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
struct authinfo
|
|
|
|
{
|
|
|
|
enum auth_scheme scheme;
|
|
|
|
CredHandle cred;
|
|
|
|
CtxtHandle ctx;
|
|
|
|
TimeStamp exp;
|
|
|
|
ULONG attr;
|
|
|
|
ULONG max_token;
|
|
|
|
char *data;
|
|
|
|
unsigned int data_len;
|
|
|
|
BOOL finished; /* finished authenticating */
|
|
|
|
};
|
|
|
|
|
2018-11-22 21:15:54 +01:00
|
|
|
struct request
|
2008-08-15 14:42:41 +02:00
|
|
|
{
|
2018-11-15 12:38:50 +01:00
|
|
|
struct object_header hdr;
|
2018-11-22 21:15:52 +01:00
|
|
|
struct connect *connect;
|
2018-11-22 21:15:54 +01:00
|
|
|
WCHAR *verb;
|
|
|
|
WCHAR *path;
|
|
|
|
WCHAR *version;
|
|
|
|
WCHAR *raw_headers;
|
2013-04-30 11:32:31 +02:00
|
|
|
void *optional;
|
|
|
|
DWORD optional_len;
|
2018-11-22 21:15:53 +01:00
|
|
|
struct netconn *netconn;
|
2017-07-13 13:00:26 +02:00
|
|
|
DWORD security_flags;
|
2018-08-24 10:32:49 +02:00
|
|
|
BOOL check_revocation;
|
2018-06-11 09:20:35 +02:00
|
|
|
const CERT_CONTEXT *server_cert;
|
2019-01-29 11:40:53 +01:00
|
|
|
const CERT_CONTEXT *client_cert;
|
|
|
|
CredHandle cred_handle;
|
|
|
|
BOOL cred_handle_initialized;
|
2010-02-22 12:27:30 +01:00
|
|
|
int resolve_timeout;
|
2009-07-23 18:11:32 +02:00
|
|
|
int connect_timeout;
|
2009-07-21 22:52:22 +02:00
|
|
|
int send_timeout;
|
2018-09-10 13:24:34 +02:00
|
|
|
int receive_timeout;
|
|
|
|
int receive_response_timeout;
|
2018-11-22 21:15:54 +01:00
|
|
|
WCHAR *status_text;
|
2013-09-23 10:03:40 +02:00
|
|
|
DWORD content_length; /* total number of bytes to be read */
|
2008-08-15 14:42:41 +02:00
|
|
|
DWORD content_read; /* bytes read so far */
|
2013-03-25 13:26:37 +01:00
|
|
|
BOOL read_chunked; /* are we reading in chunked mode? */
|
2013-09-23 10:03:40 +02:00
|
|
|
BOOL read_chunked_eof; /* end of stream in chunked mode */
|
|
|
|
BOOL read_chunked_size; /* chunk size remaining */
|
2013-03-25 13:26:37 +01:00
|
|
|
DWORD read_pos; /* current read position in read_buf */
|
|
|
|
DWORD read_size; /* valid data size in read_buf */
|
2014-12-09 12:49:02 +01:00
|
|
|
char read_buf[8192]; /* buffer for already read but not returned data */
|
2018-11-06 16:09:01 +01:00
|
|
|
struct header *headers;
|
2008-08-15 14:42:41 +02:00
|
|
|
DWORD num_headers;
|
2013-04-30 11:32:59 +02:00
|
|
|
struct authinfo *authinfo;
|
|
|
|
struct authinfo *proxy_authinfo;
|
2015-02-16 14:40:38 +01:00
|
|
|
HANDLE task_wait;
|
|
|
|
HANDLE task_cancel;
|
2018-11-23 11:35:26 +01:00
|
|
|
BOOL task_proc_running;
|
2015-02-16 14:40:38 +01:00
|
|
|
struct list task_queue;
|
|
|
|
CRITICAL_SECTION task_cs;
|
2015-06-12 15:08:30 +02:00
|
|
|
struct
|
|
|
|
{
|
|
|
|
WCHAR *username;
|
|
|
|
WCHAR *password;
|
|
|
|
} creds[TARGET_MAX][SCHEME_MAX];
|
2018-11-22 21:15:54 +01:00
|
|
|
};
|
2008-08-15 14:42:41 +02:00
|
|
|
|
2018-11-06 16:09:00 +01:00
|
|
|
struct task_header
|
2008-09-07 21:36:40 +02:00
|
|
|
{
|
2015-02-16 14:40:38 +01:00
|
|
|
struct list entry;
|
2018-11-22 21:15:54 +01:00
|
|
|
struct request *request;
|
2018-11-06 16:09:00 +01:00
|
|
|
void (*proc)( struct task_header * );
|
2008-09-07 21:36:40 +02:00
|
|
|
};
|
|
|
|
|
2018-11-06 16:09:02 +01:00
|
|
|
struct send_request
|
2008-09-07 21:36:40 +02:00
|
|
|
{
|
2018-11-06 16:09:00 +01:00
|
|
|
struct task_header hdr;
|
2018-11-06 16:09:02 +01:00
|
|
|
WCHAR *headers;
|
2008-09-07 21:36:40 +02:00
|
|
|
DWORD headers_len;
|
2018-11-06 16:09:02 +01:00
|
|
|
void *optional;
|
2008-09-07 21:36:40 +02:00
|
|
|
DWORD optional_len;
|
|
|
|
DWORD total_len;
|
|
|
|
DWORD_PTR context;
|
2018-11-06 16:09:02 +01:00
|
|
|
};
|
2008-09-07 21:36:40 +02:00
|
|
|
|
2018-11-15 12:38:46 +01:00
|
|
|
struct receive_response
|
2008-09-07 21:36:40 +02:00
|
|
|
{
|
2018-11-06 16:09:00 +01:00
|
|
|
struct task_header hdr;
|
2018-11-15 12:38:46 +01:00
|
|
|
};
|
2008-09-07 21:36:40 +02:00
|
|
|
|
2018-11-15 12:38:47 +01:00
|
|
|
struct query_data
|
2008-09-07 21:36:40 +02:00
|
|
|
{
|
2018-11-06 16:09:00 +01:00
|
|
|
struct task_header hdr;
|
2018-11-15 12:38:47 +01:00
|
|
|
DWORD *available;
|
|
|
|
};
|
2008-09-07 21:36:40 +02:00
|
|
|
|
2018-11-15 12:38:48 +01:00
|
|
|
struct read_data
|
2008-09-07 21:36:40 +02:00
|
|
|
{
|
2018-11-06 16:09:00 +01:00
|
|
|
struct task_header hdr;
|
2018-11-15 12:38:48 +01:00
|
|
|
void *buffer;
|
2008-09-07 21:36:40 +02:00
|
|
|
DWORD to_read;
|
2018-11-15 12:38:48 +01:00
|
|
|
DWORD *read;
|
|
|
|
};
|
2008-09-07 21:36:40 +02:00
|
|
|
|
2018-11-15 12:38:49 +01:00
|
|
|
struct write_data
|
2008-09-07 21:36:40 +02:00
|
|
|
{
|
2018-11-06 16:09:00 +01:00
|
|
|
struct task_header hdr;
|
2018-11-15 12:38:49 +01:00
|
|
|
const void *buffer;
|
2008-09-07 21:36:40 +02:00
|
|
|
DWORD to_write;
|
2018-11-15 12:38:49 +01:00
|
|
|
DWORD *written;
|
|
|
|
};
|
2008-09-07 21:36:40 +02:00
|
|
|
|
2018-11-15 12:38:50 +01:00
|
|
|
struct object_header *addref_object( struct object_header * ) DECLSPEC_HIDDEN;
|
|
|
|
struct object_header *grab_object( HINTERNET ) DECLSPEC_HIDDEN;
|
|
|
|
void release_object( struct object_header * ) DECLSPEC_HIDDEN;
|
|
|
|
HINTERNET alloc_handle( struct object_header * ) DECLSPEC_HIDDEN;
|
2011-04-29 10:08:40 +02:00
|
|
|
BOOL free_handle( HINTERNET ) DECLSPEC_HIDDEN;
|
2008-08-15 14:42:15 +02:00
|
|
|
|
2018-11-15 12:38:50 +01:00
|
|
|
void send_callback( struct object_header *, DWORD, LPVOID, DWORD ) DECLSPEC_HIDDEN;
|
2018-11-22 21:15:54 +01:00
|
|
|
void close_connection( struct request * ) DECLSPEC_HIDDEN;
|
2008-08-15 14:43:07 +02:00
|
|
|
|
2018-11-22 21:15:53 +01:00
|
|
|
void netconn_close( struct netconn * ) DECLSPEC_HIDDEN;
|
|
|
|
struct netconn *netconn_create( struct hostdata *, const struct sockaddr_storage *, int ) DECLSPEC_HIDDEN;
|
2011-04-29 10:08:40 +02:00
|
|
|
void netconn_unload( void ) DECLSPEC_HIDDEN;
|
2018-11-22 21:15:53 +01:00
|
|
|
ULONG netconn_query_data_available( struct netconn * ) DECLSPEC_HIDDEN;
|
|
|
|
BOOL netconn_recv( struct netconn *, void *, size_t, int, int * ) DECLSPEC_HIDDEN;
|
2017-07-18 00:24:53 +02:00
|
|
|
BOOL netconn_resolve( WCHAR *, INTERNET_PORT, struct sockaddr_storage *, int ) DECLSPEC_HIDDEN;
|
2018-11-22 21:15:53 +01:00
|
|
|
BOOL netconn_secure_connect( struct netconn *, WCHAR *, DWORD, CredHandle *, BOOL ) DECLSPEC_HIDDEN;
|
|
|
|
BOOL netconn_send( struct netconn *, const void *, size_t, int * ) DECLSPEC_HIDDEN;
|
|
|
|
DWORD netconn_set_timeout( struct netconn *, BOOL, int ) DECLSPEC_HIDDEN;
|
|
|
|
BOOL netconn_is_alive( struct netconn * ) DECLSPEC_HIDDEN;
|
|
|
|
const void *netconn_get_certificate( struct netconn * ) DECLSPEC_HIDDEN;
|
|
|
|
int netconn_get_cipher_strength( struct netconn * ) DECLSPEC_HIDDEN;
|
2008-08-26 11:03:19 +02:00
|
|
|
|
2018-11-22 21:15:54 +01:00
|
|
|
BOOL set_cookies( struct request *, const WCHAR * ) DECLSPEC_HIDDEN;
|
|
|
|
BOOL add_cookie_headers( struct request * ) DECLSPEC_HIDDEN;
|
|
|
|
BOOL add_request_headers( struct request *, const WCHAR *, DWORD, DWORD ) DECLSPEC_HIDDEN;
|
2018-11-22 21:15:51 +01:00
|
|
|
void destroy_cookies( struct session * ) DECLSPEC_HIDDEN;
|
2018-11-22 21:15:52 +01:00
|
|
|
BOOL set_server_for_hostname( struct connect *, const WCHAR *, INTERNET_PORT ) DECLSPEC_HIDDEN;
|
2013-04-30 11:32:59 +02:00
|
|
|
void destroy_authinfo( struct authinfo * ) DECLSPEC_HIDDEN;
|
2008-09-16 12:31:35 +02:00
|
|
|
|
2018-11-26 12:08:57 +01:00
|
|
|
void release_host( struct hostdata * ) DECLSPEC_HIDDEN;
|
|
|
|
BOOL process_header( struct request *, const WCHAR *, const WCHAR *, DWORD, BOOL ) DECLSPEC_HIDDEN;
|
2018-10-04 10:32:01 +02:00
|
|
|
|
2013-12-30 10:21:27 +01:00
|
|
|
extern HRESULT WinHttpRequest_create( void ** ) DECLSPEC_HIDDEN;
|
2015-01-14 11:48:48 +01:00
|
|
|
void release_typelib( void ) DECLSPEC_HIDDEN;
|
2011-07-08 16:46:14 +02:00
|
|
|
|
2017-02-08 17:53:47 +01:00
|
|
|
static inline void* __WINE_ALLOC_SIZE(2) heap_realloc_zero( LPVOID mem, SIZE_T size )
|
2008-08-15 14:41:36 +02:00
|
|
|
{
|
|
|
|
return HeapReAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, mem, size );
|
|
|
|
}
|
|
|
|
|
2008-08-15 14:42:15 +02:00
|
|
|
static inline WCHAR *strdupW( const WCHAR *src )
|
|
|
|
{
|
|
|
|
WCHAR *dst;
|
|
|
|
|
|
|
|
if (!src) return NULL;
|
2019-11-20 14:29:08 +01:00
|
|
|
dst = heap_alloc( (lstrlenW( src ) + 1) * sizeof(WCHAR) );
|
|
|
|
if (dst) lstrcpyW( dst, src );
|
2008-08-15 14:42:15 +02:00
|
|
|
return dst;
|
|
|
|
}
|
|
|
|
|
2008-08-26 11:03:40 +02:00
|
|
|
static inline WCHAR *strdupAW( const char *src )
|
|
|
|
{
|
|
|
|
WCHAR *dst = NULL;
|
|
|
|
if (src)
|
|
|
|
{
|
2019-11-20 14:29:07 +01:00
|
|
|
int len = MultiByteToWideChar( CP_ACP, 0, src, -1, NULL, 0 );
|
2008-08-26 11:03:40 +02:00
|
|
|
if ((dst = heap_alloc( len * sizeof(WCHAR) )))
|
|
|
|
MultiByteToWideChar( CP_ACP, 0, src, -1, dst, len );
|
|
|
|
}
|
|
|
|
return dst;
|
|
|
|
}
|
|
|
|
|
2008-08-26 11:03:19 +02:00
|
|
|
static inline char *strdupWA( const WCHAR *src )
|
|
|
|
{
|
|
|
|
char *dst = NULL;
|
|
|
|
if (src)
|
|
|
|
{
|
|
|
|
int len = WideCharToMultiByte( CP_ACP, 0, src, -1, NULL, 0, NULL, NULL );
|
|
|
|
if ((dst = heap_alloc( len )))
|
|
|
|
WideCharToMultiByte( CP_ACP, 0, src, -1, dst, len, NULL, NULL );
|
|
|
|
}
|
|
|
|
return dst;
|
|
|
|
}
|
|
|
|
|
2016-08-31 21:21:05 +02:00
|
|
|
static inline char *strdupWA_sized( const WCHAR *src, DWORD size )
|
|
|
|
{
|
|
|
|
char *dst = NULL;
|
|
|
|
if (src)
|
|
|
|
{
|
|
|
|
int len = WideCharToMultiByte( CP_ACP, 0, src, size, NULL, 0, NULL, NULL ) + 1;
|
|
|
|
if ((dst = heap_alloc( len )))
|
|
|
|
{
|
2019-11-20 14:29:07 +01:00
|
|
|
WideCharToMultiByte( CP_ACP, 0, src, size, dst, len, NULL, NULL );
|
2016-08-31 21:21:05 +02:00
|
|
|
dst[len - 1] = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return dst;
|
|
|
|
}
|
|
|
|
|
2017-07-18 00:25:20 +02:00
|
|
|
extern HINSTANCE winhttp_instance DECLSPEC_HIDDEN;
|
|
|
|
|
2008-08-15 14:41:36 +02:00
|
|
|
#endif /* _WINE_WINHTTP_PRIVATE_H_ */
|