mirror of
https://github.com/reactos/reactos.git
synced 2025-08-03 19:55:41 +00:00
[WINHTTP] Sync with Wine 3.0. CORE-14225
This commit is contained in:
parent
4f825146c2
commit
9048bdf976
6 changed files with 611 additions and 577 deletions
|
@ -140,7 +140,7 @@ static cookie_t *parse_cookie( const WCHAR *string )
|
||||||
|
|
||||||
if (*p++ == '=')
|
if (*p++ == '=')
|
||||||
{
|
{
|
||||||
while (*p && *p == ' ') p++;
|
while (*p == ' ') p++;
|
||||||
len = strlenW( p );
|
len = strlenW( p );
|
||||||
while (len && p[len - 1] == ' ') len--;
|
while (len && p[len - 1] == ' ') len--;
|
||||||
|
|
||||||
|
|
|
@ -131,7 +131,7 @@ static int sock_send(int fd, const void *msg, size_t len, int flags)
|
||||||
int ret;
|
int ret;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
ret = send(fd, msg, len, flags);
|
if ((ret = send(fd, msg, len, flags)) == -1) WARN("send error %s\n", strerror(errno));
|
||||||
}
|
}
|
||||||
while(ret == -1 && errno == EINTR);
|
while(ret == -1 && errno == EINTR);
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -142,7 +142,7 @@ static int sock_recv(int fd, void *msg, size_t len, int flags)
|
||||||
int ret;
|
int ret;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
ret = recv(fd, msg, len, flags);
|
if ((ret = recv(fd, msg, len, flags)) == -1) WARN("recv error %s\n", strerror(errno));
|
||||||
}
|
}
|
||||||
while(ret == -1 && errno == EINTR);
|
while(ret == -1 && errno == EINTR);
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -241,41 +241,6 @@ static DWORD netconn_verify_cert( PCCERT_CONTEXT cert, WCHAR *server, DWORD secu
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SecHandle cred_handle;
|
|
||||||
static BOOL cred_handle_initialized;
|
|
||||||
|
|
||||||
static CRITICAL_SECTION init_sechandle_cs;
|
|
||||||
static CRITICAL_SECTION_DEBUG init_sechandle_cs_debug = {
|
|
||||||
0, 0, &init_sechandle_cs,
|
|
||||||
{ &init_sechandle_cs_debug.ProcessLocksList,
|
|
||||||
&init_sechandle_cs_debug.ProcessLocksList },
|
|
||||||
0, 0, { (DWORD_PTR)(__FILE__ ": init_sechandle_cs") }
|
|
||||||
};
|
|
||||||
static CRITICAL_SECTION init_sechandle_cs = { &init_sechandle_cs_debug, -1, 0, 0, 0, 0 };
|
|
||||||
|
|
||||||
static BOOL ensure_cred_handle(void)
|
|
||||||
{
|
|
||||||
BOOL ret = TRUE;
|
|
||||||
|
|
||||||
EnterCriticalSection(&init_sechandle_cs);
|
|
||||||
|
|
||||||
if(!cred_handle_initialized) {
|
|
||||||
SECURITY_STATUS res;
|
|
||||||
|
|
||||||
res = AcquireCredentialsHandleW(NULL, (WCHAR*)UNISP_NAME_W, SECPKG_CRED_OUTBOUND, NULL, NULL,
|
|
||||||
NULL, NULL, &cred_handle, NULL);
|
|
||||||
if(res == SEC_E_OK) {
|
|
||||||
cred_handle_initialized = TRUE;
|
|
||||||
}else {
|
|
||||||
WARN("AcquireCredentialsHandleW failed: %u\n", res);
|
|
||||||
ret = FALSE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
LeaveCriticalSection(&init_sechandle_cs);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef __REACTOS__
|
#ifdef __REACTOS__
|
||||||
static BOOL winsock_initialized = FALSE;
|
static BOOL winsock_initialized = FALSE;
|
||||||
BOOL netconn_init_winsock()
|
BOOL netconn_init_winsock()
|
||||||
|
@ -300,9 +265,6 @@ BOOL netconn_init_winsock()
|
||||||
|
|
||||||
void netconn_unload( void )
|
void netconn_unload( void )
|
||||||
{
|
{
|
||||||
if(cred_handle_initialized)
|
|
||||||
FreeCredentialsHandle(&cred_handle);
|
|
||||||
DeleteCriticalSection(&init_sechandle_cs);
|
|
||||||
#ifndef HAVE_GETADDRINFO
|
#ifndef HAVE_GETADDRINFO
|
||||||
DeleteCriticalSection(&cs_gethostbyname);
|
DeleteCriticalSection(&cs_gethostbyname);
|
||||||
#endif
|
#endif
|
||||||
|
@ -439,7 +401,7 @@ BOOL netconn_close( netconn_t *conn )
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL netconn_secure_connect( netconn_t *conn, WCHAR *hostname, DWORD security_flags )
|
BOOL netconn_secure_connect( netconn_t *conn, WCHAR *hostname, DWORD security_flags, CredHandle *cred_handle )
|
||||||
{
|
{
|
||||||
SecBuffer out_buf = {0, SECBUFFER_TOKEN, NULL}, in_bufs[2] = {{0, SECBUFFER_TOKEN}, {0, SECBUFFER_EMPTY}};
|
SecBuffer out_buf = {0, SECBUFFER_TOKEN, NULL}, in_bufs[2] = {{0, SECBUFFER_TOKEN}, {0, SECBUFFER_EMPTY}};
|
||||||
SecBufferDesc out_desc = {SECBUFFER_VERSION, 1, &out_buf}, in_desc = {SECBUFFER_VERSION, 2, in_bufs};
|
SecBufferDesc out_desc = {SECBUFFER_VERSION, 1, &out_buf}, in_desc = {SECBUFFER_VERSION, 2, in_bufs};
|
||||||
|
@ -455,14 +417,11 @@ BOOL netconn_secure_connect( netconn_t *conn, WCHAR *hostname, DWORD security_fl
|
||||||
const DWORD isc_req_flags = ISC_REQ_ALLOCATE_MEMORY|ISC_REQ_USE_SESSION_KEY|ISC_REQ_CONFIDENTIALITY
|
const DWORD isc_req_flags = ISC_REQ_ALLOCATE_MEMORY|ISC_REQ_USE_SESSION_KEY|ISC_REQ_CONFIDENTIALITY
|
||||||
|ISC_REQ_SEQUENCE_DETECT|ISC_REQ_REPLAY_DETECT|ISC_REQ_MANUAL_CRED_VALIDATION;
|
|ISC_REQ_SEQUENCE_DETECT|ISC_REQ_REPLAY_DETECT|ISC_REQ_MANUAL_CRED_VALIDATION;
|
||||||
|
|
||||||
if(!ensure_cred_handle())
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
read_buf = heap_alloc(read_buf_size);
|
read_buf = heap_alloc(read_buf_size);
|
||||||
if(!read_buf)
|
if(!read_buf)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
status = InitializeSecurityContextW(&cred_handle, NULL, hostname, isc_req_flags, 0, 0, NULL, 0,
|
status = InitializeSecurityContextW(cred_handle, NULL, hostname, isc_req_flags, 0, 0, NULL, 0,
|
||||||
&ctx, &out_desc, &attrs, NULL);
|
&ctx, &out_desc, &attrs, NULL);
|
||||||
|
|
||||||
assert(status != SEC_E_OK);
|
assert(status != SEC_E_OK);
|
||||||
|
@ -514,7 +473,6 @@ BOOL netconn_secure_connect( netconn_t *conn, WCHAR *hostname, DWORD security_fl
|
||||||
|
|
||||||
size = sock_recv(conn->socket, read_buf+in_bufs[0].cbBuffer, read_buf_size-in_bufs[0].cbBuffer, 0);
|
size = sock_recv(conn->socket, read_buf+in_bufs[0].cbBuffer, read_buf_size-in_bufs[0].cbBuffer, 0);
|
||||||
if(size < 1) {
|
if(size < 1) {
|
||||||
WARN("recv error\n");
|
|
||||||
status = ERROR_WINHTTP_SECURE_CHANNEL_ERROR;
|
status = ERROR_WINHTTP_SECURE_CHANNEL_ERROR;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -523,7 +481,7 @@ BOOL netconn_secure_connect( netconn_t *conn, WCHAR *hostname, DWORD security_fl
|
||||||
|
|
||||||
in_bufs[0].cbBuffer += size;
|
in_bufs[0].cbBuffer += size;
|
||||||
in_bufs[0].pvBuffer = read_buf;
|
in_bufs[0].pvBuffer = read_buf;
|
||||||
status = InitializeSecurityContextW(&cred_handle, &ctx, hostname, isc_req_flags, 0, 0, &in_desc,
|
status = InitializeSecurityContextW(cred_handle, &ctx, hostname, isc_req_flags, 0, 0, &in_desc,
|
||||||
0, NULL, &out_desc, &attrs, NULL);
|
0, NULL, &out_desc, &attrs, NULL);
|
||||||
TRACE("InitializeSecurityContext ret %08x\n", status);
|
TRACE("InitializeSecurityContext ret %08x\n", status);
|
||||||
|
|
||||||
|
@ -650,10 +608,8 @@ static BOOL read_ssl_chunk(netconn_t *conn, void *buf, SIZE_T buf_size, SIZE_T *
|
||||||
conn->extra_buf = NULL;
|
conn->extra_buf = NULL;
|
||||||
}else {
|
}else {
|
||||||
buf_len = sock_recv(conn->socket, conn->ssl_buf+conn->extra_len, ssl_buf_size-conn->extra_len, 0);
|
buf_len = sock_recv(conn->socket, conn->ssl_buf+conn->extra_len, ssl_buf_size-conn->extra_len, 0);
|
||||||
if(buf_len < 0) {
|
if(buf_len < 0)
|
||||||
WARN("recv failed\n");
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
|
||||||
|
|
||||||
if(!buf_len) {
|
if(!buf_len) {
|
||||||
*eof = TRUE;
|
*eof = TRUE;
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -71,6 +71,7 @@ static void session_destroy( object_header_t *hdr )
|
||||||
TRACE("%p\n", session);
|
TRACE("%p\n", session);
|
||||||
|
|
||||||
if (session->unload_event) SetEvent( session->unload_event );
|
if (session->unload_event) SetEvent( session->unload_event );
|
||||||
|
if (session->cred_handle_initialized) FreeCredentialsHandle( &session->cred_handle );
|
||||||
|
|
||||||
LIST_FOR_EACH_SAFE( item, next, &session->cookie_cache )
|
LIST_FOR_EACH_SAFE( item, next, &session->cookie_cache )
|
||||||
{
|
{
|
||||||
|
@ -155,6 +156,17 @@ static BOOL session_set_option( object_header_t *hdr, DWORD option, LPVOID buffe
|
||||||
hdr->redirect_policy = policy;
|
hdr->redirect_policy = policy;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
case WINHTTP_OPTION_SECURE_PROTOCOLS:
|
||||||
|
{
|
||||||
|
if (buflen != sizeof(session->secure_protocols))
|
||||||
|
{
|
||||||
|
set_last_error( ERROR_INSUFFICIENT_BUFFER );
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
session->secure_protocols = *(DWORD *)buffer;
|
||||||
|
TRACE("0x%x\n", session->secure_protocols);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
case WINHTTP_OPTION_DISABLE_FEATURE:
|
case WINHTTP_OPTION_DISABLE_FEATURE:
|
||||||
set_last_error( ERROR_WINHTTP_INCORRECT_HANDLE_TYPE );
|
set_last_error( ERROR_WINHTTP_INCORRECT_HANDLE_TYPE );
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -577,6 +589,8 @@ static void request_destroy( object_header_t *hdr )
|
||||||
heap_free( request->headers[i].value );
|
heap_free( request->headers[i].value );
|
||||||
}
|
}
|
||||||
heap_free( request->headers );
|
heap_free( request->headers );
|
||||||
|
for (i = 0; i < request->num_accept_types; i++) heap_free( request->accept_types[i] );
|
||||||
|
heap_free( request->accept_types );
|
||||||
for (i = 0; i < TARGET_MAX; i++)
|
for (i = 0; i < TARGET_MAX; i++)
|
||||||
{
|
{
|
||||||
for (j = 0; j < SCHEME_MAX; j++)
|
for (j = 0; j < SCHEME_MAX; j++)
|
||||||
|
@ -1002,14 +1016,32 @@ static const object_vtbl_t request_vtbl =
|
||||||
|
|
||||||
static BOOL store_accept_types( request_t *request, const WCHAR **accept_types )
|
static BOOL store_accept_types( request_t *request, const WCHAR **accept_types )
|
||||||
{
|
{
|
||||||
static const WCHAR attr_accept[] = {'A','c','c','e','p','t',0};
|
|
||||||
static const DWORD flags = WINHTTP_ADDREQ_FLAG_ADD | WINHTTP_ADDREQ_FLAG_COALESCE_WITH_COMMA;
|
|
||||||
const WCHAR **types = accept_types;
|
const WCHAR **types = accept_types;
|
||||||
|
DWORD i;
|
||||||
|
|
||||||
if (!types) return TRUE;
|
if (!types) return TRUE;
|
||||||
while (*types)
|
while (*types)
|
||||||
{
|
{
|
||||||
process_header( request, attr_accept, *types, flags, TRUE );
|
request->num_accept_types++;
|
||||||
|
types++;
|
||||||
|
}
|
||||||
|
if (!request->num_accept_types) return TRUE;
|
||||||
|
if (!(request->accept_types = heap_alloc( request->num_accept_types * sizeof(WCHAR *))))
|
||||||
|
{
|
||||||
|
request->num_accept_types = 0;
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
types = accept_types;
|
||||||
|
for (i = 0; i < request->num_accept_types; i++)
|
||||||
|
{
|
||||||
|
if (!(request->accept_types[i] = strdupW( *types )))
|
||||||
|
{
|
||||||
|
for ( ; i > 0; --i) heap_free( request->accept_types[i - 1] );
|
||||||
|
heap_free( request->accept_types );
|
||||||
|
request->accept_types = NULL;
|
||||||
|
request->num_accept_types = 0;
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
types++;
|
types++;
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
|
@ -135,6 +135,9 @@ typedef struct
|
||||||
LPWSTR proxy_password;
|
LPWSTR proxy_password;
|
||||||
struct list cookie_cache;
|
struct list cookie_cache;
|
||||||
HANDLE unload_event;
|
HANDLE unload_event;
|
||||||
|
CredHandle cred_handle;
|
||||||
|
BOOL cred_handle_initialized;
|
||||||
|
DWORD secure_protocols;
|
||||||
} session_t;
|
} session_t;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
|
@ -235,6 +238,8 @@ typedef struct
|
||||||
char read_buf[8192]; /* buffer for already read but not returned data */
|
char read_buf[8192]; /* buffer for already read but not returned data */
|
||||||
header_t *headers;
|
header_t *headers;
|
||||||
DWORD num_headers;
|
DWORD num_headers;
|
||||||
|
WCHAR **accept_types;
|
||||||
|
DWORD num_accept_types;
|
||||||
struct authinfo *authinfo;
|
struct authinfo *authinfo;
|
||||||
struct authinfo *proxy_authinfo;
|
struct authinfo *proxy_authinfo;
|
||||||
HANDLE task_wait;
|
HANDLE task_wait;
|
||||||
|
@ -313,7 +318,7 @@ void netconn_unload( void ) DECLSPEC_HIDDEN;
|
||||||
ULONG netconn_query_data_available( netconn_t * ) DECLSPEC_HIDDEN;
|
ULONG netconn_query_data_available( netconn_t * ) DECLSPEC_HIDDEN;
|
||||||
BOOL netconn_recv( netconn_t *, void *, size_t, int, int * ) DECLSPEC_HIDDEN;
|
BOOL netconn_recv( netconn_t *, void *, size_t, int, int * ) DECLSPEC_HIDDEN;
|
||||||
BOOL netconn_resolve( WCHAR *, INTERNET_PORT, struct sockaddr_storage *, int ) DECLSPEC_HIDDEN;
|
BOOL netconn_resolve( WCHAR *, INTERNET_PORT, struct sockaddr_storage *, int ) DECLSPEC_HIDDEN;
|
||||||
BOOL netconn_secure_connect( netconn_t *, WCHAR *, DWORD ) DECLSPEC_HIDDEN;
|
BOOL netconn_secure_connect( netconn_t *, WCHAR *, DWORD, CredHandle * ) DECLSPEC_HIDDEN;
|
||||||
BOOL netconn_send( netconn_t *, const void *, size_t, int * ) DECLSPEC_HIDDEN;
|
BOOL netconn_send( netconn_t *, const void *, size_t, int * ) DECLSPEC_HIDDEN;
|
||||||
DWORD netconn_set_timeout( netconn_t *, BOOL, int ) DECLSPEC_HIDDEN;
|
DWORD netconn_set_timeout( netconn_t *, BOOL, int ) DECLSPEC_HIDDEN;
|
||||||
BOOL netconn_is_alive( netconn_t * ) DECLSPEC_HIDDEN;
|
BOOL netconn_is_alive( netconn_t * ) DECLSPEC_HIDDEN;
|
||||||
|
@ -329,8 +334,6 @@ void destroy_authinfo( struct authinfo * ) DECLSPEC_HIDDEN;
|
||||||
|
|
||||||
void release_host( hostdata_t *host ) DECLSPEC_HIDDEN;
|
void release_host( hostdata_t *host ) DECLSPEC_HIDDEN;
|
||||||
|
|
||||||
BOOL process_header( request_t *request, LPCWSTR field, LPCWSTR value, DWORD flags, BOOL request_only ) DECLSPEC_HIDDEN;
|
|
||||||
|
|
||||||
extern HRESULT WinHttpRequest_create( void ** ) DECLSPEC_HIDDEN;
|
extern HRESULT WinHttpRequest_create( void ** ) DECLSPEC_HIDDEN;
|
||||||
void release_typelib( void ) DECLSPEC_HIDDEN;
|
void release_typelib( void ) DECLSPEC_HIDDEN;
|
||||||
|
|
||||||
|
|
|
@ -200,7 +200,7 @@ reactos/dll/win32/windowscodecs # Synced to Wine-3.0
|
||||||
reactos/dll/win32/windowscodecsext # Synced to WineStaging-2.9
|
reactos/dll/win32/windowscodecsext # Synced to WineStaging-2.9
|
||||||
reactos/dll/win32/winemp3.acm # Synced to Wine-3.0
|
reactos/dll/win32/winemp3.acm # Synced to Wine-3.0
|
||||||
reactos/dll/win32/wing32 # Synced to WineStaging-2.9
|
reactos/dll/win32/wing32 # Synced to WineStaging-2.9
|
||||||
reactos/dll/win32/winhttp # Synced to WineStaging-2.16
|
reactos/dll/win32/winhttp # Synced to Wine-3.0
|
||||||
reactos/dll/win32/wininet # Synced to WineStaging-2.16
|
reactos/dll/win32/wininet # Synced to WineStaging-2.16
|
||||||
reactos/dll/win32/winmm # Forked at Wine-20050628
|
reactos/dll/win32/winmm # Forked at Wine-20050628
|
||||||
reactos/dll/win32/winmm/midimap # Forked at Wine-20050628
|
reactos/dll/win32/winmm/midimap # Forked at Wine-20050628
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue