2008-08-15 12:41:36 +00: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_
|
|
|
|
|
2008-08-15 12:42:28 +00:00
|
|
|
#ifndef __WINE_CONFIG_H
|
|
|
|
# error You must include config.h to use this header
|
|
|
|
#endif
|
|
|
|
|
2008-08-15 12:41:36 +00:00
|
|
|
#include "wine/list.h"
|
2008-08-15 12:42:15 +00:00
|
|
|
#include "wine/unicode.h"
|
2008-08-15 12:41:36 +00:00
|
|
|
|
2008-12-29 03:00:24 +00:00
|
|
|
#include <sys/types.h>
|
2009-07-25 16:57:18 +00:00
|
|
|
#ifdef HAVE_SYS_SOCKET_H
|
|
|
|
# include <sys/socket.h>
|
|
|
|
#endif
|
2008-08-20 18:34:43 +00:00
|
|
|
#ifdef HAVE_NETINET_IN_H
|
|
|
|
# include <netinet/in.h>
|
|
|
|
#endif
|
2008-08-15 12:42:28 +00:00
|
|
|
#ifdef HAVE_NETDB_H
|
|
|
|
# include <netdb.h>
|
|
|
|
#endif
|
2008-08-25 13:56:50 +00:00
|
|
|
#if defined(__MINGW32__) || defined (_MSC_VER)
|
|
|
|
# include <ws2tcpip.h>
|
2008-10-01 10:20:31 +00:00
|
|
|
#else
|
|
|
|
# define closesocket close
|
|
|
|
# define ioctlsocket ioctl
|
2008-08-25 13:56:50 +00:00
|
|
|
#endif
|
2008-08-15 12:42:28 +00:00
|
|
|
|
2008-09-16 10:31:16 +00:00
|
|
|
static const WCHAR getW[] = {'G','E','T',0};
|
|
|
|
static const WCHAR postW[] = {'P','O','S','T',0};
|
|
|
|
static const WCHAR slashW[] = {'/',0};
|
2008-09-16 19:32:46 +00:00
|
|
|
static const WCHAR http1_0[] = {'H','T','T','P','/','1','.','0',0};
|
2008-09-16 10:31:16 +00:00
|
|
|
static const WCHAR http1_1[] = {'H','T','T','P','/','1','.','1',0};
|
|
|
|
|
2008-08-15 12:41:36 +00:00
|
|
|
typedef struct _object_header_t object_header_t;
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
void (*destroy)( object_header_t * );
|
2008-09-03 10:31:24 +00:00
|
|
|
BOOL (*query_option)( object_header_t *, DWORD, void *, DWORD * );
|
2008-08-15 12:41:36 +00:00
|
|
|
BOOL (*set_option)( object_header_t *, DWORD, void *, DWORD );
|
|
|
|
} object_vtbl_t;
|
|
|
|
|
|
|
|
struct _object_header_t
|
|
|
|
{
|
|
|
|
DWORD type;
|
|
|
|
HINTERNET handle;
|
|
|
|
const object_vtbl_t *vtbl;
|
|
|
|
DWORD flags;
|
2008-09-03 14:58:06 +00:00
|
|
|
DWORD disable_flags;
|
|
|
|
DWORD logon_policy;
|
|
|
|
DWORD redirect_policy;
|
2008-08-15 12:41:36 +00:00
|
|
|
DWORD error;
|
|
|
|
DWORD_PTR context;
|
|
|
|
LONG refs;
|
|
|
|
WINHTTP_STATUS_CALLBACK callback;
|
|
|
|
DWORD notify_mask;
|
|
|
|
struct list entry;
|
|
|
|
struct list children;
|
|
|
|
};
|
|
|
|
|
2008-09-16 10:31:35 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
struct list entry;
|
|
|
|
WCHAR *name;
|
|
|
|
struct list cookies;
|
|
|
|
} domain_t;
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
struct list entry;
|
|
|
|
WCHAR *name;
|
|
|
|
WCHAR *value;
|
|
|
|
WCHAR *path;
|
|
|
|
} cookie_t;
|
|
|
|
|
2008-08-15 12:42:15 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
object_header_t hdr;
|
|
|
|
LPWSTR agent;
|
|
|
|
DWORD access;
|
2010-02-22 11:27:30 +00:00
|
|
|
int resolve_timeout;
|
2010-01-29 00:45:15 +00:00
|
|
|
int connect_timeout;
|
|
|
|
int send_timeout;
|
|
|
|
int recv_timeout;
|
2008-08-15 12:42:15 +00:00
|
|
|
LPWSTR proxy_server;
|
|
|
|
LPWSTR proxy_bypass;
|
|
|
|
LPWSTR proxy_username;
|
|
|
|
LPWSTR proxy_password;
|
2008-09-16 10:31:35 +00:00
|
|
|
struct list cookie_cache;
|
2008-08-15 12:42:15 +00:00
|
|
|
} session_t;
|
|
|
|
|
2008-08-15 12:42:28 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
object_header_t hdr;
|
|
|
|
session_t *session;
|
|
|
|
LPWSTR hostname; /* final destination of the request */
|
|
|
|
LPWSTR servername; /* name of the server we directly connect to */
|
|
|
|
LPWSTR username;
|
|
|
|
LPWSTR password;
|
|
|
|
INTERNET_PORT hostport;
|
|
|
|
INTERNET_PORT serverport;
|
2009-07-08 17:39:37 +00:00
|
|
|
struct sockaddr_storage sockaddr;
|
2008-08-15 12:42:28 +00:00
|
|
|
} connect_t;
|
|
|
|
|
2008-08-15 12:42:41 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
int socket;
|
2008-08-28 11:49:19 +00:00
|
|
|
BOOL secure; /* SSL active on connection? */
|
|
|
|
void *ssl_conn;
|
2008-08-15 12:42:41 +00:00
|
|
|
char *peek_msg;
|
|
|
|
char *peek_msg_mem;
|
|
|
|
size_t peek_len;
|
2010-05-17 17:04:18 +00:00
|
|
|
DWORD security_flags;
|
2008-08-15 12:42:41 +00:00
|
|
|
} netconn_t;
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
LPWSTR field;
|
|
|
|
LPWSTR value;
|
2008-08-20 09:35:39 +00:00
|
|
|
BOOL is_request; /* part of request headers? */
|
2008-08-15 12:42:41 +00:00
|
|
|
} header_t;
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
object_header_t hdr;
|
|
|
|
connect_t *connect;
|
|
|
|
LPWSTR verb;
|
|
|
|
LPWSTR path;
|
|
|
|
LPWSTR version;
|
|
|
|
LPWSTR raw_headers;
|
|
|
|
netconn_t netconn;
|
2010-02-22 11:27:30 +00:00
|
|
|
int resolve_timeout;
|
2009-07-23 16:11:32 +00:00
|
|
|
int connect_timeout;
|
2009-07-21 20:52:22 +00:00
|
|
|
int send_timeout;
|
|
|
|
int recv_timeout;
|
2008-08-15 12:42:41 +00:00
|
|
|
LPWSTR status_text;
|
|
|
|
DWORD content_length; /* total number of bytes to be read (per chunk) */
|
|
|
|
DWORD content_read; /* bytes read so far */
|
|
|
|
header_t *headers;
|
|
|
|
DWORD num_headers;
|
|
|
|
} request_t;
|
|
|
|
|
2008-09-07 19:36:40 +00:00
|
|
|
typedef struct _task_header_t task_header_t;
|
|
|
|
|
|
|
|
struct _task_header_t
|
|
|
|
{
|
|
|
|
request_t *request;
|
|
|
|
void (*proc)( task_header_t * );
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
task_header_t hdr;
|
|
|
|
LPWSTR headers;
|
|
|
|
DWORD headers_len;
|
|
|
|
LPVOID optional;
|
|
|
|
DWORD optional_len;
|
|
|
|
DWORD total_len;
|
|
|
|
DWORD_PTR context;
|
|
|
|
} send_request_t;
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
task_header_t hdr;
|
|
|
|
} receive_response_t;
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
task_header_t hdr;
|
|
|
|
LPDWORD available;
|
|
|
|
} query_data_t;
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
task_header_t hdr;
|
|
|
|
LPVOID buffer;
|
|
|
|
DWORD to_read;
|
|
|
|
LPDWORD read;
|
|
|
|
} read_data_t;
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
task_header_t hdr;
|
|
|
|
LPCVOID buffer;
|
|
|
|
DWORD to_write;
|
|
|
|
LPDWORD written;
|
|
|
|
} write_data_t;
|
|
|
|
|
2008-08-15 12:42:15 +00:00
|
|
|
object_header_t *addref_object( object_header_t * );
|
|
|
|
object_header_t *grab_object( HINTERNET );
|
|
|
|
void release_object( object_header_t * );
|
|
|
|
HINTERNET alloc_handle( object_header_t * );
|
|
|
|
BOOL free_handle( HINTERNET );
|
|
|
|
|
2008-08-20 09:35:39 +00:00
|
|
|
void set_last_error( DWORD );
|
2008-09-07 19:29:44 +00:00
|
|
|
DWORD get_last_error( void );
|
2008-08-15 12:43:07 +00:00
|
|
|
void send_callback( object_header_t *, DWORD, LPVOID, DWORD );
|
2008-08-26 09:03:40 +00:00
|
|
|
void close_connection( request_t * );
|
2008-08-15 12:43:07 +00:00
|
|
|
|
2008-08-26 09:03:19 +00:00
|
|
|
BOOL netconn_close( netconn_t * );
|
2009-07-23 16:11:32 +00:00
|
|
|
BOOL netconn_connect( netconn_t *, const struct sockaddr *, unsigned int, int );
|
2008-08-26 09:03:19 +00:00
|
|
|
BOOL netconn_connected( netconn_t * );
|
|
|
|
BOOL netconn_create( netconn_t *, int, int, int );
|
|
|
|
BOOL netconn_get_next_line( netconn_t *, char *, DWORD * );
|
2008-08-28 11:49:19 +00:00
|
|
|
BOOL netconn_init( netconn_t *, BOOL );
|
2009-10-02 14:53:01 +00:00
|
|
|
void netconn_unload( void );
|
2008-08-26 09:03:19 +00:00
|
|
|
BOOL netconn_query_data_available( netconn_t *, DWORD * );
|
|
|
|
BOOL netconn_recv( netconn_t *, void *, size_t, int, int * );
|
2010-02-22 11:27:30 +00:00
|
|
|
BOOL netconn_resolve( WCHAR *, INTERNET_PORT, struct sockaddr *, socklen_t *, int );
|
2009-11-12 21:28:23 +00:00
|
|
|
BOOL netconn_secure_connect( netconn_t *, WCHAR * );
|
2008-08-26 09:03:19 +00:00
|
|
|
BOOL netconn_send( netconn_t *, const void *, size_t, int, int * );
|
2009-07-07 08:14:11 +00:00
|
|
|
DWORD netconn_set_timeout( netconn_t *, BOOL, int );
|
2008-09-07 19:30:31 +00:00
|
|
|
const void *netconn_get_certificate( netconn_t * );
|
2008-08-26 09:03:19 +00:00
|
|
|
|
2008-09-16 10:31:35 +00:00
|
|
|
BOOL set_cookies( request_t *, const WCHAR * );
|
|
|
|
BOOL add_cookie_headers( request_t * );
|
|
|
|
BOOL add_request_headers( request_t *, LPCWSTR, DWORD, DWORD );
|
|
|
|
void delete_domain( domain_t * );
|
2009-07-14 20:03:52 +00:00
|
|
|
BOOL set_server_for_hostname( connect_t *connect, LPCWSTR server, INTERNET_PORT port );
|
2008-09-16 10:31:35 +00:00
|
|
|
|
2008-08-15 12:41:36 +00:00
|
|
|
static inline void *heap_alloc( SIZE_T size )
|
|
|
|
{
|
|
|
|
return HeapAlloc( GetProcessHeap(), 0, size );
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void *heap_alloc_zero( SIZE_T size )
|
|
|
|
{
|
|
|
|
return HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, size );
|
|
|
|
}
|
|
|
|
|
2008-08-20 09:35:39 +00:00
|
|
|
static inline void *heap_realloc( LPVOID mem, SIZE_T size )
|
|
|
|
{
|
|
|
|
return HeapReAlloc( GetProcessHeap(), 0, mem, size );
|
|
|
|
}
|
|
|
|
|
2008-08-15 12:41:36 +00:00
|
|
|
static inline void *heap_realloc_zero( LPVOID mem, SIZE_T size )
|
|
|
|
{
|
|
|
|
return HeapReAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, mem, size );
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline BOOL heap_free( LPVOID mem )
|
|
|
|
{
|
|
|
|
return HeapFree( GetProcessHeap(), 0, mem );
|
|
|
|
}
|
|
|
|
|
2008-08-15 12:42:15 +00:00
|
|
|
static inline WCHAR *strdupW( const WCHAR *src )
|
|
|
|
{
|
|
|
|
WCHAR *dst;
|
|
|
|
|
|
|
|
if (!src) return NULL;
|
|
|
|
dst = heap_alloc( (strlenW( src ) + 1) * sizeof(WCHAR) );
|
|
|
|
if (dst) strcpyW( dst, src );
|
|
|
|
return dst;
|
|
|
|
}
|
|
|
|
|
2008-08-26 09:03:40 +00:00
|
|
|
static inline WCHAR *strdupAW( const char *src )
|
|
|
|
{
|
|
|
|
WCHAR *dst = NULL;
|
|
|
|
if (src)
|
|
|
|
{
|
|
|
|
DWORD len = MultiByteToWideChar( CP_ACP, 0, src, -1, NULL, 0 );
|
|
|
|
if ((dst = heap_alloc( len * sizeof(WCHAR) )))
|
|
|
|
MultiByteToWideChar( CP_ACP, 0, src, -1, dst, len );
|
|
|
|
}
|
|
|
|
return dst;
|
|
|
|
}
|
|
|
|
|
2008-08-26 09:03:19 +00: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;
|
|
|
|
}
|
|
|
|
|
2008-08-15 12:41:36 +00:00
|
|
|
#endif /* _WINE_WINHTTP_PRIVATE_H_ */
|