[0.4.9] [WINHTTP] Revert to SVN r75943 to fix regression CORE-13952

Our RCs were still affected by that regression.
The revert allows to run the current Online! setup
of Flash-Player 29.0.0.171 to download.
(I was able to watch a flash video in Opera 12.18 afterwards.)
This commit is contained in:
Joachim Henze 2018-05-26 17:00:47 +02:00
parent c71d198fd8
commit d33b71e9d4
11 changed files with 857 additions and 1197 deletions

View file

@ -1,7 +1,4 @@
remove_definitions(-D_WIN32_WINNT=0x502)
add_definitions(-D_WIN32_WINNT=0x600)
add_definitions(
-D__WINESRC__
-D_WINE)
@ -17,7 +14,7 @@ list(APPEND SOURCE
request.c
session.c
url.c
precomp.h)
winhttp_private.h)
set_source_files_properties(rsrc.rc PROPERTIES OBJECT_DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/winhttp_tlb.tlb)
add_typelib(winhttp_tlb.idl)
@ -30,7 +27,7 @@ add_library(winhttp SHARED
set_module_type(winhttp win32dll)
target_link_libraries(winhttp uuid wine)
add_delay_importlibs(winhttp oleaut32 ole32 crypt32 secur32)
add_importlibs(winhttp user32 advapi32 ws2_32 jsproxy kernel32_vista msvcrt kernel32 ntdll)
add_importlibs(winhttp user32 advapi32 ws2_32 jsproxy msvcrt kernel32 ntdll)
add_dependencies(winhttp stdole2)
add_pch(winhttp precomp.h SOURCE)
add_pch(winhttp winhttp_private.h SOURCE)
add_cd_file(TARGET winhttp DESTINATION reactos/system32 FOR all)

View file

@ -16,20 +16,8 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "config.h"
#include <stdarg.h>
#include "wine/debug.h"
#include "wine/list.h"
#include "windef.h"
#include "winbase.h"
#include "winhttp.h"
#include "winhttp_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(winhttp);
static domain_t *add_domain( session_t *session, WCHAR *name )
{
domain_t *domain;
@ -152,7 +140,7 @@ static cookie_t *parse_cookie( const WCHAR *string )
if (*p++ == '=')
{
while (*p == ' ') p++;
while (*p && *p == ' ') p++;
len = strlenW( p );
while (len && p[len - 1] == ' ') len--;

View file

@ -18,20 +18,8 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "config.h"
#include "wine/port.h"
#include "wine/debug.h"
#include <stdarg.h>
#include "windef.h"
#include "winbase.h"
#include "winhttp.h"
#include "winhttp_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(winhttp);
#define HANDLE_CHUNK_SIZE 0x10
static CRITICAL_SECTION handle_cs;

View file

@ -51,18 +51,16 @@ static const char *inet_ntop6(const u_char *src, char *dst, size_t size);
* author:
* Paul Vixie, 1996.
*/
PCSTR
WSAAPI
inet_ntop(INT Family, PVOID pAddr, PSTR pStringBuf, size_t StringBufSize)
const char *
inet_ntop(int af, const void *src, char *dst, size_t size)
{
switch (Family) {
switch (af) {
case AF_INET:
return (inet_ntop4(pAddr, pStringBuf, StringBufSize));
return (inet_ntop4(src, dst, size));
#ifdef INET6
case AF_INET6:
return (inet_ntop6(pAddr, pStringBuf, StringBufSize));
return (inet_ntop6(src, dst, size));
#endif
default:
WSASetLastError(WSAEAFNOSUPPORT);

View file

@ -16,23 +16,12 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#define COBJMACROS
#include "config.h"
#include <stdarg.h>
#include "windef.h"
#include "winbase.h"
#include "objbase.h"
#include "rpcproxy.h"
#include "httprequest.h"
#include "winhttp.h"
#include "wine/debug.h"
#include "winhttp_private.h"
HINSTANCE winhttp_instance;
#include <rpcproxy.h>
#include <httprequest.h>
WINE_DEFAULT_DEBUG_CHANNEL(winhttp);
static HINSTANCE instance;
/******************************************************************
* DllMain (winhttp.@)
@ -42,7 +31,7 @@ BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpv)
switch(fdwReason)
{
case DLL_PROCESS_ATTACH:
winhttp_instance = hInstDLL;
instance = hInstDLL;
DisableThreadLibraryCalls(hInstDLL);
break;
case DLL_PROCESS_DETACH:
@ -169,7 +158,7 @@ HRESULT WINAPI DllCanUnloadNow(void)
*/
HRESULT WINAPI DllRegisterServer(void)
{
return __wine_register_resources( winhttp_instance );
return __wine_register_resources( instance );
}
/***********************************************************************
@ -177,5 +166,5 @@ HRESULT WINAPI DllRegisterServer(void)
*/
HRESULT WINAPI DllUnregisterServer(void)
{
return __wine_unregister_resources( winhttp_instance );
return __wine_unregister_resources( instance );
}

View file

@ -17,15 +17,11 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "config.h"
#include "wine/port.h"
#include "winhttp_private.h"
#include <stdarg.h>
#include <stdio.h>
#include <errno.h>
#include <assert.h>
#include <schannel.h>
#include <sys/types.h>
#ifdef HAVE_SYS_SOCKET_H
# include <sys/socket.h>
#endif
@ -39,25 +35,6 @@
# include <poll.h>
#endif
#define NONAMELESSUNION
#include "wine/debug.h"
#include "wine/library.h"
#include "windef.h"
#include "winbase.h"
#include "winhttp.h"
#include "wincrypt.h"
#include "schannel.h"
#include "winhttp_private.h"
/* to avoid conflicts with the Unix socket headers */
#define USE_WS_PREFIX
#include "winsock2.h"
WINE_DEFAULT_DEBUG_CHANNEL(winhttp);
#ifndef HAVE_GETADDRINFO
/* critical section to protect non-reentrant gethostbyname() */
@ -154,7 +131,7 @@ static int sock_send(int fd, const void *msg, size_t len, int flags)
int ret;
do
{
if ((ret = send(fd, msg, len, flags)) == -1) WARN("send error %s\n", strerror(errno));
ret = send(fd, msg, len, flags);
}
while(ret == -1 && errno == EINTR);
return ret;
@ -165,7 +142,7 @@ static int sock_recv(int fd, void *msg, size_t len, int flags)
int ret;
do
{
if ((ret = recv(fd, msg, len, flags)) == -1) WARN("recv error %s\n", strerror(errno));
ret = recv(fd, msg, len, flags);
}
while(ret == -1 && errno == EINTR);
return ret;
@ -264,6 +241,41 @@ static DWORD netconn_verify_cert( PCCERT_CONTEXT cert, WCHAR *server, DWORD secu
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__
static BOOL winsock_initialized = FALSE;
BOOL netconn_init_winsock()
@ -286,8 +298,18 @@ BOOL netconn_init_winsock()
#endif
BOOL netconn_init( netconn_t *conn )
{
memset(conn, 0, sizeof(*conn));
conn->socket = -1;
return TRUE;
}
void netconn_unload( void )
{
if(cred_handle_initialized)
FreeCredentialsHandle(&cred_handle);
DeleteCriticalSection(&init_sechandle_cs);
#ifndef HAVE_GETADDRINFO
DeleteCriticalSection(&cs_gethostbyname);
#endif
@ -297,37 +319,55 @@ void netconn_unload( void )
#endif
}
netconn_t *netconn_create( hostdata_t *host, const struct sockaddr_storage *sockaddr, int timeout )
BOOL netconn_connected( netconn_t *conn )
{
netconn_t *conn;
unsigned int addr_len;
BOOL ret = FALSE;
int res;
ULONG state;
return (conn->socket != -1);
}
conn = heap_alloc_zero(sizeof(*conn));
if (!conn) return NULL;
conn->host = host;
conn->sockaddr = *sockaddr;
if ((conn->socket = socket( sockaddr->ss_family, SOCK_STREAM, 0 )) == -1)
BOOL netconn_create( netconn_t *conn, int domain, int type, int protocol )
{
if ((conn->socket = socket( domain, type, protocol )) == -1)
{
WARN("unable to create socket (%s)\n", strerror(errno));
set_last_error( sock_get_error( errno ) );
heap_free(conn);
return NULL;
return FALSE;
}
return TRUE;
}
switch (conn->sockaddr.ss_family)
BOOL netconn_close( netconn_t *conn )
{
int res;
if (conn->secure)
{
case AF_INET:
addr_len = sizeof(struct sockaddr_in);
break;
case AF_INET6:
addr_len = sizeof(struct sockaddr_in6);
break;
default:
assert(0);
heap_free( conn->peek_msg_mem );
conn->peek_msg_mem = NULL;
conn->peek_msg = NULL;
conn->peek_len = 0;
heap_free(conn->ssl_buf);
conn->ssl_buf = NULL;
heap_free(conn->extra_buf);
conn->extra_buf = NULL;
conn->extra_len = 0;
DeleteSecurityContext(&conn->ssl_ctx);
conn->secure = FALSE;
}
res = closesocket( conn->socket );
conn->socket = -1;
if (res == -1)
{
set_last_error( sock_get_error( errno ) );
return FALSE;
}
return TRUE;
}
BOOL netconn_connect( netconn_t *conn, const struct sockaddr *sockaddr, unsigned int addr_len, int timeout )
{
BOOL ret = FALSE;
int res;
ULONG state;
if (timeout > 0)
{
@ -338,7 +378,7 @@ netconn_t *netconn_create( hostdata_t *host, const struct sockaddr_storage *sock
for (;;)
{
res = 0;
if (connect( conn->socket, (const struct sockaddr *)&conn->sockaddr, addr_len ) < 0)
if (connect( conn->socket, sockaddr, addr_len ) < 0)
{
res = sock_get_error( errno );
if (res == WSAEWOULDBLOCK || res == WSAEINPROGRESS)
@ -396,35 +436,11 @@ netconn_t *netconn_create( hostdata_t *host, const struct sockaddr_storage *sock
{
WARN("unable to connect to host (%d)\n", res);
set_last_error( res );
netconn_close( conn );
return NULL;
}
return conn;
return ret;
}
BOOL netconn_close( netconn_t *conn )
{
int res;
if (conn->secure)
{
heap_free( conn->peek_msg_mem );
heap_free(conn->ssl_buf);
heap_free(conn->extra_buf);
DeleteSecurityContext(&conn->ssl_ctx);
}
res = closesocket( conn->socket );
release_host( conn->host );
heap_free(conn);
if (res == -1)
{
set_last_error( sock_get_error( errno ) );
return FALSE;
}
return TRUE;
}
BOOL netconn_secure_connect( netconn_t *conn, WCHAR *hostname, DWORD security_flags, CredHandle *cred_handle )
BOOL netconn_secure_connect( netconn_t *conn, WCHAR *hostname )
{
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};
@ -440,11 +456,14 @@ 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
|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);
if(!read_buf)
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);
assert(status != SEC_E_OK);
@ -496,6 +515,7 @@ 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);
if(size < 1) {
WARN("recv error\n");
status = ERROR_WINHTTP_SECURE_CHANNEL_ERROR;
break;
}
@ -504,7 +524,7 @@ BOOL netconn_secure_connect( netconn_t *conn, WCHAR *hostname, DWORD security_fl
in_bufs[0].cbBuffer += size;
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);
TRACE("InitializeSecurityContext ret %08x\n", status);
@ -520,7 +540,7 @@ BOOL netconn_secure_connect( netconn_t *conn, WCHAR *hostname, DWORD security_fl
status = QueryContextAttributesW(&ctx, SECPKG_ATTR_REMOTE_CERT_CONTEXT, (void*)&cert);
if(status == SEC_E_OK) {
res = netconn_verify_cert(cert, hostname, security_flags);
res = netconn_verify_cert(cert, hostname, conn->security_flags);
CertFreeCertificateContext(cert);
if(res != ERROR_SUCCESS) {
WARN("cert verify failed: %u\n", res);
@ -585,6 +605,7 @@ static BOOL send_ssl_chunk(netconn_t *conn, const void *msg, size_t size)
BOOL netconn_send( netconn_t *conn, const void *msg, size_t len, int *sent )
{
if (!netconn_connected( conn )) return FALSE;
if (conn->secure)
{
const BYTE *ptr = msg;
@ -631,8 +652,10 @@ static BOOL read_ssl_chunk(netconn_t *conn, void *buf, SIZE_T buf_size, SIZE_T *
conn->extra_buf = NULL;
}else {
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;
}
if(!buf_len) {
*eof = TRUE;
@ -706,6 +729,7 @@ static BOOL read_ssl_chunk(netconn_t *conn, void *buf, SIZE_T buf_size, SIZE_T *
BOOL netconn_recv( netconn_t *conn, void *buf, size_t len, int flags, int *recvd )
{
*recvd = 0;
if (!netconn_connected( conn )) return FALSE;
if (!len) return TRUE;
if (conn->secure)
@ -762,7 +786,13 @@ BOOL netconn_recv( netconn_t *conn, void *buf, size_t len, int flags, int *recvd
ULONG netconn_query_data_available( netconn_t *conn )
{
return conn->secure ? conn->peek_len : 0;
if(!netconn_connected(conn))
return 0;
if(conn->secure)
return conn->peek_len;
return 0;
}
DWORD netconn_set_timeout( netconn_t *netconn, BOOL send, int value )
@ -781,37 +811,7 @@ DWORD netconn_set_timeout( netconn_t *netconn, BOOL send, int value )
return ERROR_SUCCESS;
}
BOOL netconn_is_alive( netconn_t *netconn )
{
#ifdef MSG_DONTWAIT
ssize_t len;
BYTE b;
len = recv( netconn->socket, &b, 1, MSG_PEEK | MSG_DONTWAIT );
return len == 1 || (len == -1 && errno == EWOULDBLOCK);
#elif defined(__MINGW32__) || defined(_MSC_VER)
ULONG mode;
int len;
char b;
mode = 1;
if(!ioctlsocket(netconn->socket, FIONBIO, &mode))
return FALSE;
len = recv(netconn->socket, &b, 1, MSG_PEEK);
mode = 0;
if(!ioctlsocket(netconn->socket, FIONBIO, &mode))
return FALSE;
return len == 1 || (len == -1 && WSAGetLastError() == WSAEWOULDBLOCK);
#else
FIXME("not supported on this platform\n");
return TRUE;
#endif
}
static DWORD resolve_hostname( const WCHAR *hostnameW, INTERNET_PORT port, struct sockaddr_storage *sa )
static DWORD resolve_hostname( const WCHAR *hostnameW, INTERNET_PORT port, struct sockaddr *sa, socklen_t *sa_len )
{
char *hostname;
#ifdef HAVE_GETADDRINFO
@ -845,6 +845,13 @@ static DWORD resolve_hostname( const WCHAR *hostnameW, INTERNET_PORT port, struc
}
}
heap_free( hostname );
if (*sa_len < res->ai_addrlen)
{
WARN("address too small\n");
freeaddrinfo( res );
return ERROR_WINHTTP_NAME_NOT_RESOLVED;
}
*sa_len = res->ai_addrlen;
memcpy( sa, res->ai_addr, res->ai_addrlen );
/* Copy port */
switch (res->ai_family)
@ -870,6 +877,13 @@ static DWORD resolve_hostname( const WCHAR *hostnameW, INTERNET_PORT port, struc
LeaveCriticalSection( &cs_gethostbyname );
return ERROR_WINHTTP_NAME_NOT_RESOLVED;
}
if (*sa_len < sizeof(struct sockaddr_in))
{
WARN("address too small\n");
LeaveCriticalSection( &cs_gethostbyname );
return ERROR_WINHTTP_NAME_NOT_RESOLVED;
}
*sa_len = sizeof(struct sockaddr_in);
memset( sa, 0, sizeof(struct sockaddr_in) );
memcpy( &sin->sin_addr, he->h_addr, he->h_length );
sin->sin_family = he->h_addrtype;
@ -882,18 +896,19 @@ static DWORD resolve_hostname( const WCHAR *hostnameW, INTERNET_PORT port, struc
struct resolve_args
{
const WCHAR *hostname;
INTERNET_PORT port;
struct sockaddr_storage *sa;
const WCHAR *hostname;
INTERNET_PORT port;
struct sockaddr *sa;
socklen_t *sa_len;
};
static DWORD CALLBACK resolve_proc( LPVOID arg )
{
struct resolve_args *ra = arg;
return resolve_hostname( ra->hostname, ra->port, ra->sa );
return resolve_hostname( ra->hostname, ra->port, ra->sa, ra->sa_len );
}
BOOL netconn_resolve( WCHAR *hostname, INTERNET_PORT port, struct sockaddr_storage *sa, int timeout )
BOOL netconn_resolve( WCHAR *hostname, INTERNET_PORT port, struct sockaddr *sa, socklen_t *sa_len, int timeout )
{
DWORD ret;
@ -906,6 +921,7 @@ BOOL netconn_resolve( WCHAR *hostname, INTERNET_PORT port, struct sockaddr_stora
ra.hostname = hostname;
ra.port = port;
ra.sa = sa;
ra.sa_len = sa_len;
thread = CreateThread( NULL, 0, resolve_proc, &ra, 0, NULL );
if (!thread) return FALSE;
@ -915,7 +931,7 @@ BOOL netconn_resolve( WCHAR *hostname, INTERNET_PORT port, struct sockaddr_stora
else ret = ERROR_WINHTTP_TIMEOUT;
CloseHandle( thread );
}
else ret = resolve_hostname( hostname, port, sa );
else ret = resolve_hostname( hostname, port, sa, sa_len );
if (ret)
{

View file

@ -1,26 +0,0 @@
#ifndef _WINHTTP_PRECOMP_H_
#define _WINHTTP_PRECOMP_H_
#include <wine/config.h>
#include <stdarg.h>
#define WIN32_NO_STATUS
#define _INC_WINDOWS
#define COM_NO_WINDOWS_H
#define COBJMACROS
#define NONAMELESSUNION
#include <windef.h>
#include <winbase.h>
#include <ole2.h>
#include <winsock2.h>
#include <winhttp.h>
#include <wine/debug.h>
#include "winhttp_private.h"
#endif /* !_WINHTTP_PRECOMP_H_ */

File diff suppressed because it is too large Load diff

View file

@ -16,40 +16,12 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "config.h"
#include "wine/port.h"
#include "wine/debug.h"
#include <stdarg.h>
#include <stdlib.h>
#ifdef HAVE_CORESERVICES_CORESERVICES_H
#define GetCurrentThread MacGetCurrentThread
#define LoadResource MacLoadResource
#include <CoreServices/CoreServices.h>
#undef GetCurrentThread
#undef LoadResource
#undef DPRINTF
#endif
#include "windef.h"
#include "winbase.h"
#ifndef __MINGW32__
#define USE_WS_PREFIX
#endif
#include "winsock2.h"
#include "ws2ipdef.h"
#include "winhttp.h"
#include "wincrypt.h"
#include "winreg.h"
#define COBJMACROS
#include "ole2.h"
#include "dispex.h"
#include "activscp.h"
#include "winhttp_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(winhttp);
#include <wincrypt.h>
#include <winreg.h>
#include <dispex.h>
#include <activscp.h>
#define DEFAULT_RESOLVE_TIMEOUT 0
#define DEFAULT_CONNECT_TIMEOUT 20000
@ -99,7 +71,6 @@ static void session_destroy( object_header_t *hdr )
TRACE("%p\n", session);
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 )
{
@ -184,17 +155,6 @@ static BOOL session_set_option( object_header_t *hdr, DWORD option, LPVOID buffe
hdr->redirect_policy = policy;
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:
set_last_error( ERROR_WINHTTP_INCORRECT_HANDLE_TYPE );
return FALSE;
@ -725,7 +685,7 @@ static BOOL request_query_option( object_header_t *hdr, DWORD option, LPVOID buf
{
case WINHTTP_OPTION_SECURITY_FLAGS:
{
DWORD flags = 0;
DWORD flags;
int bits;
if (!buffer || *buflen < sizeof(flags))
@ -737,17 +697,14 @@ static BOOL request_query_option( object_header_t *hdr, DWORD option, LPVOID buf
flags = 0;
if (hdr->flags & WINHTTP_FLAG_SECURE) flags |= SECURITY_FLAG_SECURE;
flags |= request->security_flags;
if (request->netconn)
{
bits = netconn_get_cipher_strength( request->netconn );
if (bits >= 128)
flags |= SECURITY_FLAG_STRENGTH_STRONG;
else if (bits >= 56)
flags |= SECURITY_FLAG_STRENGTH_MEDIUM;
else
flags |= SECURITY_FLAG_STRENGTH_WEAK;
}
flags |= request->netconn.security_flags;
bits = netconn_get_cipher_strength( &request->netconn );
if (bits >= 128)
flags |= SECURITY_FLAG_STRENGTH_STRONG;
else if (bits >= 56)
flags |= SECURITY_FLAG_STRENGTH_MEDIUM;
else
flags |= SECURITY_FLAG_STRENGTH_WEAK;
*(DWORD *)buffer = flags;
*buflen = sizeof(flags);
return TRUE;
@ -763,7 +720,7 @@ static BOOL request_query_option( object_header_t *hdr, DWORD option, LPVOID buf
return FALSE;
}
if (!request->netconn || !(cert = netconn_get_certificate( request->netconn ))) return FALSE;
if (!(cert = netconn_get_certificate( &request->netconn ))) return FALSE;
*(CERT_CONTEXT **)buffer = (CERT_CONTEXT *)cert;
*buflen = sizeof(cert);
return TRUE;
@ -782,7 +739,7 @@ static BOOL request_query_option( object_header_t *hdr, DWORD option, LPVOID buf
set_last_error( ERROR_INSUFFICIENT_BUFFER );
return FALSE;
}
if (!request->netconn || !(cert = netconn_get_certificate( request->netconn ))) return FALSE;
if (!(cert = netconn_get_certificate( &request->netconn ))) return FALSE;
ci->ftExpiry = cert->pCertInfo->NotAfter;
ci->ftStart = cert->pCertInfo->NotBefore;
@ -797,7 +754,7 @@ static BOOL request_query_option( object_header_t *hdr, DWORD option, LPVOID buf
else
ci->lpszSignatureAlgName = NULL;
ci->lpszEncryptionAlgName = NULL;
ci->dwKeySize = request->netconn ? netconn_get_cipher_strength( request->netconn ) : 0;
ci->dwKeySize = netconn_get_cipher_strength( &request->netconn );
CertFreeCertificateContext( cert );
*buflen = sizeof(*ci);
@ -812,7 +769,7 @@ static BOOL request_query_option( object_header_t *hdr, DWORD option, LPVOID buf
return FALSE;
}
*(DWORD *)buffer = request->netconn ? netconn_get_cipher_strength( request->netconn ) : 0;
*(DWORD *)buffer = netconn_get_cipher_strength( &request->netconn );
*buflen = sizeof(DWORD);
return TRUE;
}
@ -829,12 +786,12 @@ static BOOL request_query_option( object_header_t *hdr, DWORD option, LPVOID buf
set_last_error( ERROR_INSUFFICIENT_BUFFER );
return FALSE;
}
if (!request->netconn)
if (!netconn_connected( &request->netconn ))
{
set_last_error( ERROR_WINHTTP_INCORRECT_HANDLE_STATE );
return FALSE;
}
if (getsockname( request->netconn->socket, &local, &len )) return FALSE;
if (getsockname( request->netconn.socket, &local, &len )) return FALSE;
if (!convert_sockaddr( &local, &info->LocalAddress )) return FALSE;
if (!convert_sockaddr( remote, &info->RemoteAddress )) return FALSE;
info->cbSize = sizeof(*info);
@ -970,7 +927,7 @@ static BOOL request_set_option( object_header_t *hdr, DWORD option, LPVOID buffe
set_last_error( ERROR_INVALID_PARAMETER );
return FALSE;
}
request->security_flags = flags;
request->netconn.security_flags = flags;
return TRUE;
}
case WINHTTP_OPTION_RESOLVE_TIMEOUT:
@ -1107,6 +1064,7 @@ HINTERNET WINAPI WinHttpOpenRequest( HINTERNET hconnect, LPCWSTR verb, LPCWSTR o
request->connect = connect;
list_add_head( &connect->hdr.children, &request->hdr.entry );
if (!netconn_init( &request->netconn )) goto end;
request->resolve_timeout = connect->session->resolve_timeout;
request->connect_timeout = connect->session->connect_timeout;
request->send_timeout = connect->session->send_timeout;
@ -2089,10 +2047,10 @@ BOOL WINAPI WinHttpSetTimeouts( HINTERNET handle, int resolve, int connect, int
if (receive < 0) receive = 0;
request->recv_timeout = receive;
if (request->netconn)
if (netconn_connected( &request->netconn ))
{
if (netconn_set_timeout( request->netconn, TRUE, send )) ret = FALSE;
if (netconn_set_timeout( request->netconn, FALSE, receive )) ret = FALSE;
if (netconn_set_timeout( &request->netconn, TRUE, send )) ret = FALSE;
if (netconn_set_timeout( &request->netconn, FALSE, receive )) ret = FALSE;
}
break;

View file

@ -16,21 +16,8 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "config.h"
#include <stdarg.h>
#include "wine/debug.h"
#include "windef.h"
#include "winbase.h"
#include "winreg.h"
#include "winhttp.h"
#include "shlwapi.h"
#include "winhttp_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(winhttp);
static const WCHAR scheme_http[] = {'h','t','t','p',0};
static const WCHAR scheme_https[] = {'h','t','t','p','s',0};

View file

@ -19,15 +19,27 @@
#ifndef _WINE_WINHTTP_PRIVATE_H_
#define _WINE_WINHTTP_PRIVATE_H_
#ifndef __WINE_CONFIG_H
# error You must include config.h to use this header
#endif
#include <wine/config.h>
#include "wine/heap.h"
#include "wine/list.h"
#include "wine/unicode.h"
#include <stdarg.h>
#define WIN32_NO_STATUS
#define _INC_WINDOWS
#define COM_NO_WINDOWS_H
#define COBJMACROS
#define NONAMELESSUNION
#include <windef.h>
#include <winbase.h>
#include <objbase.h>
#include <oleauto.h>
#include <winsock2.h>
#include <winhttp.h>
#include <wine/list.h>
#include <wine/unicode.h>
#include <sys/types.h>
#ifdef HAVE_SYS_SOCKET_H
# include <sys/socket.h>
#endif
@ -44,8 +56,10 @@
# define ioctlsocket ioctl
#endif
#include "ole2.h"
#include "sspi.h"
#include <sspi.h>
#include <wine/debug.h>
WINE_DEFAULT_DEBUG_CHANNEL(winhttp);
static const WCHAR getW[] = {'G','E','T',0};
static const WCHAR postW[] = {'P','O','S','T',0};
@ -97,15 +111,6 @@ typedef struct
WCHAR *path;
} cookie_t;
typedef struct {
struct list entry;
LONG ref;
WCHAR *hostname;
INTERNET_PORT port;
BOOL secure;
struct list connections;
} hostdata_t;
typedef struct
{
object_header_t hdr;
@ -121,9 +126,6 @@ typedef struct
LPWSTR proxy_password;
struct list cookie_cache;
HANDLE unload_event;
CredHandle cred_handle;
BOOL cred_handle_initialized;
DWORD secure_protocols;
} session_t;
typedef struct
@ -142,12 +144,8 @@ typedef struct
typedef struct
{
struct list entry;
int socket;
struct sockaddr_storage sockaddr;
BOOL secure; /* SSL active on connection? */
hostdata_t *host;
ULONGLONG keep_until;
CtxtHandle ssl_ctx;
SecPkgContext_StreamSizes ssl_sizes;
char *ssl_buf;
@ -156,6 +154,7 @@ typedef struct
char *peek_msg;
char *peek_msg_mem;
size_t peek_len;
DWORD security_flags;
} netconn_t;
typedef struct
@ -207,8 +206,7 @@ typedef struct
LPWSTR raw_headers;
void *optional;
DWORD optional_len;
netconn_t *netconn;
DWORD security_flags;
netconn_t netconn;
int resolve_timeout;
int connect_timeout;
int send_timeout;
@ -297,15 +295,17 @@ void send_callback( object_header_t *, DWORD, LPVOID, DWORD ) DECLSPEC_HIDDEN;
void close_connection( request_t * ) DECLSPEC_HIDDEN;
BOOL netconn_close( netconn_t * ) DECLSPEC_HIDDEN;
netconn_t *netconn_create( hostdata_t *, const struct sockaddr_storage *, int ) DECLSPEC_HIDDEN;
BOOL netconn_connect( netconn_t *, const struct sockaddr *, unsigned int, int ) DECLSPEC_HIDDEN;
BOOL netconn_connected( netconn_t * ) DECLSPEC_HIDDEN;
BOOL netconn_create( netconn_t *, int, int, int ) DECLSPEC_HIDDEN;
BOOL netconn_init( netconn_t * ) DECLSPEC_HIDDEN;
void netconn_unload( void ) 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_resolve( WCHAR *, INTERNET_PORT, struct sockaddr_storage *, int ) DECLSPEC_HIDDEN;
BOOL netconn_secure_connect( netconn_t *, WCHAR *, DWORD, CredHandle * ) DECLSPEC_HIDDEN;
BOOL netconn_resolve( WCHAR *, INTERNET_PORT, struct sockaddr *, socklen_t *, int ) DECLSPEC_HIDDEN;
BOOL netconn_secure_connect( netconn_t *, WCHAR * ) DECLSPEC_HIDDEN;
BOOL netconn_send( netconn_t *, const void *, size_t, int * ) DECLSPEC_HIDDEN;
DWORD netconn_set_timeout( netconn_t *, BOOL, int ) DECLSPEC_HIDDEN;
BOOL netconn_is_alive( netconn_t * ) DECLSPEC_HIDDEN;
const void *netconn_get_certificate( netconn_t * ) DECLSPEC_HIDDEN;
int netconn_get_cipher_strength( netconn_t * ) DECLSPEC_HIDDEN;
@ -316,18 +316,36 @@ void delete_domain( domain_t * ) DECLSPEC_HIDDEN;
BOOL set_server_for_hostname( connect_t *, LPCWSTR, INTERNET_PORT ) DECLSPEC_HIDDEN;
void destroy_authinfo( struct authinfo * ) 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;
void release_typelib( void ) DECLSPEC_HIDDEN;
static inline void* __WINE_ALLOC_SIZE(1) heap_alloc( SIZE_T size )
{
return HeapAlloc( GetProcessHeap(), 0, size );
}
static inline void* __WINE_ALLOC_SIZE(1) heap_alloc_zero( SIZE_T size )
{
return HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, size );
}
static inline void* __WINE_ALLOC_SIZE(2) heap_realloc( LPVOID mem, SIZE_T size )
{
return HeapReAlloc( GetProcessHeap(), 0, mem, size );
}
static inline void* __WINE_ALLOC_SIZE(2) 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 );
}
static inline WCHAR *strdupW( const WCHAR *src )
{
WCHAR *dst;
@ -377,6 +395,4 @@ static inline char *strdupWA_sized( const WCHAR *src, DWORD size )
return dst;
}
extern HINSTANCE winhttp_instance DECLSPEC_HIDDEN;
#endif /* _WINE_WINHTTP_PRIVATE_H_ */