mirror of
https://github.com/reactos/reactos.git
synced 2025-05-08 03:07:05 +00:00
[WINHTTP]
* Sync with Wine 1.7.1. CORE-7469 svn path=/trunk/; revision=60426
This commit is contained in:
parent
2437be8ea5
commit
74ff2a18e0
7 changed files with 679 additions and 355 deletions
|
@ -1,11 +1,8 @@
|
||||||
|
|
||||||
add_typelib(winhttp_tlb.idl)
|
|
||||||
|
|
||||||
add_definitions(
|
add_definitions(
|
||||||
-D__WINESRC__
|
-D__WINESRC__
|
||||||
-D_WINE)
|
-D_WINE)
|
||||||
include_directories(${REACTOS_SOURCE_DIR}/include/reactos/wine)
|
include_directories(${REACTOS_SOURCE_DIR}/include/reactos/wine)
|
||||||
|
|
||||||
spec2def(winhttp.dll winhttp.spec ADD_IMPORTLIB)
|
spec2def(winhttp.dll winhttp.spec ADD_IMPORTLIB)
|
||||||
|
|
||||||
list(APPEND SOURCE
|
list(APPEND SOURCE
|
||||||
|
@ -16,19 +13,14 @@ list(APPEND SOURCE
|
||||||
request.c
|
request.c
|
||||||
session.c
|
session.c
|
||||||
url.c
|
url.c
|
||||||
rsrc.rc
|
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/winhttp.def)
|
${CMAKE_CURRENT_BINARY_DIR}/winhttp.def)
|
||||||
|
|
||||||
set_source_files_properties(rsrc.rc PROPERTIES OBJECT_DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/winhttp_tlb.tlb)
|
set_source_files_properties(rsrc.rc PROPERTIES OBJECT_DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/winhttp_tlb.tlb)
|
||||||
|
add_typelib(winhttp_tlb.idl)
|
||||||
add_library(winhttp SHARED ${SOURCE})
|
add_library(winhttp SHARED ${SOURCE} rsrc.rc)
|
||||||
|
|
||||||
set_module_type(winhttp win32dll)
|
set_module_type(winhttp win32dll)
|
||||||
target_link_libraries(winhttp uuid wine)
|
target_link_libraries(winhttp uuid wine)
|
||||||
add_delay_importlibs(winhttp oleaut32 ole32 crypt32 secur32)
|
add_delay_importlibs(winhttp oleaut32 ole32 crypt32 secur32)
|
||||||
add_importlibs(winhttp user32 advapi32 ws2_32 msvcrt kernel32 ntdll)
|
add_importlibs(winhttp user32 advapi32 ws2_32 msvcrt kernel32 ntdll)
|
||||||
|
add_dependencies(winhttp stdole2) # wininet_tlb.tlb needs stdole2.tlb
|
||||||
# wininet_tlb.tlb needs stdole2.tlb
|
|
||||||
add_dependencies(winhttp stdole2)
|
|
||||||
|
|
||||||
add_cd_file(TARGET winhttp DESTINATION reactos/system32 FOR all)
|
add_cd_file(TARGET winhttp DESTINATION reactos/system32 FOR all)
|
||||||
|
|
|
@ -50,6 +50,7 @@ BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpv)
|
||||||
DisableThreadLibraryCalls(hInstDLL);
|
DisableThreadLibraryCalls(hInstDLL);
|
||||||
break;
|
break;
|
||||||
case DLL_PROCESS_DETACH:
|
case DLL_PROCESS_DETACH:
|
||||||
|
if (lpv) break;
|
||||||
netconn_unload();
|
netconn_unload();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -426,7 +426,7 @@ BOOL netconn_secure_connect( netconn_t *conn, WCHAR *hostname )
|
||||||
size = send(conn->socket, out_buf.pvBuffer, out_buf.cbBuffer, 0);
|
size = send(conn->socket, out_buf.pvBuffer, out_buf.cbBuffer, 0);
|
||||||
if(size != out_buf.cbBuffer) {
|
if(size != out_buf.cbBuffer) {
|
||||||
ERR("send failed\n");
|
ERR("send failed\n");
|
||||||
status = ERROR_WINHTTP_SECURE_CHANNEL_ERROR;
|
res = ERROR_WINHTTP_SECURE_CHANNEL_ERROR;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -551,7 +551,7 @@ static BOOL send_ssl_chunk(netconn_t *conn, const void *msg, size_t size)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL netconn_send( netconn_t *conn, const void *msg, size_t len, int flags, int *sent )
|
BOOL netconn_send( netconn_t *conn, const void *msg, size_t len, int *sent )
|
||||||
{
|
{
|
||||||
if (!netconn_connected( conn )) return FALSE;
|
if (!netconn_connected( conn )) return FALSE;
|
||||||
if (conn->secure)
|
if (conn->secure)
|
||||||
|
@ -559,8 +559,6 @@ BOOL netconn_send( netconn_t *conn, const void *msg, size_t len, int flags, int
|
||||||
const BYTE *ptr = msg;
|
const BYTE *ptr = msg;
|
||||||
size_t chunk_size;
|
size_t chunk_size;
|
||||||
|
|
||||||
if (flags) FIXME("flags %08x not supported in SSL\n", flags);
|
|
||||||
|
|
||||||
*sent = 0;
|
*sent = 0;
|
||||||
|
|
||||||
while(len) {
|
while(len) {
|
||||||
|
@ -575,7 +573,7 @@ BOOL netconn_send( netconn_t *conn, const void *msg, size_t len, int flags, int
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
if ((*sent = send( conn->socket, msg, len, flags )) == -1)
|
if ((*sent = send( conn->socket, msg, len, 0 )) == -1)
|
||||||
{
|
{
|
||||||
set_last_error( sock_get_error( errno ) );
|
set_last_error( sock_get_error( errno ) );
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -687,17 +685,7 @@ BOOL netconn_recv( netconn_t *conn, void *buf, size_t len, int flags, int *recvd
|
||||||
SIZE_T size, cread;
|
SIZE_T size, cread;
|
||||||
BOOL res, eof;
|
BOOL res, eof;
|
||||||
|
|
||||||
if (flags & ~(MSG_PEEK | MSG_WAITALL))
|
if (conn->peek_msg)
|
||||||
FIXME("SSL_read does not support the following flags: %08x\n", flags);
|
|
||||||
|
|
||||||
if (flags & MSG_PEEK && conn->peek_msg)
|
|
||||||
{
|
|
||||||
if (len < conn->peek_len) FIXME("buffer isn't big enough, should we wrap?\n");
|
|
||||||
*recvd = min( len, conn->peek_len );
|
|
||||||
memcpy( buf, conn->peek_msg, *recvd );
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
else if (conn->peek_msg)
|
|
||||||
{
|
{
|
||||||
*recvd = min( len, conn->peek_len );
|
*recvd = min( len, conn->peek_len );
|
||||||
memcpy( buf, conn->peek_msg, *recvd );
|
memcpy( buf, conn->peek_msg, *recvd );
|
||||||
|
@ -711,7 +699,7 @@ BOOL netconn_recv( netconn_t *conn, void *buf, size_t len, int flags, int *recvd
|
||||||
conn->peek_msg = NULL;
|
conn->peek_msg = NULL;
|
||||||
}
|
}
|
||||||
/* check if we have enough data from the peek buffer */
|
/* check if we have enough data from the peek buffer */
|
||||||
if (!(flags & MSG_WAITALL) || (*recvd == len)) return TRUE;
|
if (!(flags & MSG_WAITALL) || *recvd == len) return TRUE;
|
||||||
}
|
}
|
||||||
size = *recvd;
|
size = *recvd;
|
||||||
|
|
||||||
|
@ -732,14 +720,6 @@ BOOL netconn_recv( netconn_t *conn, void *buf, size_t len, int flags, int *recvd
|
||||||
size += cread;
|
size += cread;
|
||||||
}while(!size || ((flags & MSG_WAITALL) && size < len));
|
}while(!size || ((flags & MSG_WAITALL) && size < len));
|
||||||
|
|
||||||
if(size && (flags & MSG_PEEK)) {
|
|
||||||
conn->peek_msg_mem = conn->peek_msg = heap_alloc(size);
|
|
||||||
if(!conn->peek_msg)
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
memcpy(conn->peek_msg, buf, size);
|
|
||||||
}
|
|
||||||
|
|
||||||
TRACE("received %ld bytes\n", size);
|
TRACE("received %ld bytes\n", size);
|
||||||
*recvd = size;
|
*recvd = size;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -772,84 +752,6 @@ BOOL netconn_query_data_available( netconn_t *conn, DWORD *available )
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL netconn_get_next_line( netconn_t *conn, char *buffer, DWORD *buflen )
|
|
||||||
{
|
|
||||||
// ReactOS: use select instead of poll
|
|
||||||
fd_set infd;
|
|
||||||
BOOL ret = FALSE;
|
|
||||||
DWORD recvd = 0;
|
|
||||||
|
|
||||||
if (!netconn_connected( conn )) return FALSE;
|
|
||||||
|
|
||||||
if (conn->secure)
|
|
||||||
{
|
|
||||||
while (recvd < *buflen)
|
|
||||||
{
|
|
||||||
int dummy;
|
|
||||||
if (!netconn_recv( conn, &buffer[recvd], 1, 0, &dummy ))
|
|
||||||
{
|
|
||||||
set_last_error( ERROR_CONNECTION_ABORTED );
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (buffer[recvd] == '\n')
|
|
||||||
{
|
|
||||||
ret = TRUE;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (buffer[recvd] != '\r') recvd++;
|
|
||||||
}
|
|
||||||
if (ret)
|
|
||||||
{
|
|
||||||
buffer[recvd++] = 0;
|
|
||||||
*buflen = recvd;
|
|
||||||
TRACE("received line %s\n", debugstr_a(buffer));
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
FD_ZERO(&infd);
|
|
||||||
FD_SET(conn->socket, &infd);
|
|
||||||
|
|
||||||
while (recvd < *buflen)
|
|
||||||
{
|
|
||||||
int res;
|
|
||||||
struct timeval tv, *ptv;
|
|
||||||
socklen_t len = sizeof(tv);
|
|
||||||
|
|
||||||
if ((res = getsockopt( conn->socket, SOL_SOCKET, SO_RCVTIMEO, (void*)&tv, &len ) != -1))
|
|
||||||
ptv = &tv;
|
|
||||||
else
|
|
||||||
ptv = NULL;
|
|
||||||
|
|
||||||
if (select( 0, &infd, NULL, NULL, ptv ) > 0)
|
|
||||||
{
|
|
||||||
if ((res = recv( conn->socket, &buffer[recvd], 1, 0 )) <= 0)
|
|
||||||
{
|
|
||||||
if (res == -1) set_last_error( sock_get_error( errno ) );
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (buffer[recvd] == '\n')
|
|
||||||
{
|
|
||||||
ret = TRUE;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (buffer[recvd] != '\r') recvd++;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
set_last_error( ERROR_WINHTTP_TIMEOUT );
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (ret)
|
|
||||||
{
|
|
||||||
buffer[recvd++] = 0;
|
|
||||||
*buflen = recvd;
|
|
||||||
TRACE("received line %s\n", debugstr_a(buffer));
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
DWORD netconn_set_timeout( netconn_t *netconn, BOOL send, int value )
|
DWORD netconn_set_timeout( netconn_t *netconn, BOOL send, int value )
|
||||||
{
|
{
|
||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -560,6 +560,9 @@ static void request_destroy( object_header_t *hdr )
|
||||||
|
|
||||||
release_object( &request->connect->hdr );
|
release_object( &request->connect->hdr );
|
||||||
|
|
||||||
|
destroy_authinfo( request->authinfo );
|
||||||
|
destroy_authinfo( request->proxy_authinfo );
|
||||||
|
|
||||||
heap_free( request->verb );
|
heap_free( request->verb );
|
||||||
heap_free( request->path );
|
heap_free( request->path );
|
||||||
heap_free( request->version );
|
heap_free( request->version );
|
||||||
|
|
|
@ -51,6 +51,7 @@ static const WCHAR headW[] = {'H','E','A','D',0};
|
||||||
static const WCHAR slashW[] = {'/',0};
|
static const WCHAR slashW[] = {'/',0};
|
||||||
static const WCHAR http1_0[] = {'H','T','T','P','/','1','.','0',0};
|
static const WCHAR http1_0[] = {'H','T','T','P','/','1','.','0',0};
|
||||||
static const WCHAR http1_1[] = {'H','T','T','P','/','1','.','1',0};
|
static const WCHAR http1_1[] = {'H','T','T','P','/','1','.','1',0};
|
||||||
|
static const WCHAR chunkedW[] = {'c','h','u','n','k','e','d',0};
|
||||||
|
|
||||||
typedef struct _object_header_t object_header_t;
|
typedef struct _object_header_t object_header_t;
|
||||||
|
|
||||||
|
@ -146,6 +147,29 @@ typedef struct
|
||||||
BOOL is_request; /* part of request headers? */
|
BOOL is_request; /* part of request headers? */
|
||||||
} header_t;
|
} header_t;
|
||||||
|
|
||||||
|
enum auth_scheme
|
||||||
|
{
|
||||||
|
SCHEME_INVALID = -1,
|
||||||
|
SCHEME_BASIC,
|
||||||
|
SCHEME_NTLM,
|
||||||
|
SCHEME_PASSPORT,
|
||||||
|
SCHEME_DIGEST,
|
||||||
|
SCHEME_NEGOTIATE
|
||||||
|
};
|
||||||
|
|
||||||
|
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 */
|
||||||
|
};
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
object_header_t hdr;
|
object_header_t hdr;
|
||||||
|
@ -154,6 +178,8 @@ typedef struct
|
||||||
LPWSTR path;
|
LPWSTR path;
|
||||||
LPWSTR version;
|
LPWSTR version;
|
||||||
LPWSTR raw_headers;
|
LPWSTR raw_headers;
|
||||||
|
void *optional;
|
||||||
|
DWORD optional_len;
|
||||||
netconn_t netconn;
|
netconn_t netconn;
|
||||||
int resolve_timeout;
|
int resolve_timeout;
|
||||||
int connect_timeout;
|
int connect_timeout;
|
||||||
|
@ -162,10 +188,16 @@ typedef struct
|
||||||
LPWSTR status_text;
|
LPWSTR status_text;
|
||||||
DWORD content_length; /* total number of bytes to be read (per chunk) */
|
DWORD content_length; /* total number of bytes to be read (per chunk) */
|
||||||
DWORD content_read; /* bytes read so far */
|
DWORD content_read; /* bytes read so far */
|
||||||
|
BOOL read_chunked; /* are we reading in chunked mode? */
|
||||||
|
DWORD read_pos; /* current read position in read_buf */
|
||||||
|
DWORD read_size; /* valid data size in read_buf */
|
||||||
|
char read_buf[4096]; /* buffer for already read but not returned data */
|
||||||
header_t *headers;
|
header_t *headers;
|
||||||
DWORD num_headers;
|
DWORD num_headers;
|
||||||
WCHAR **accept_types;
|
WCHAR **accept_types;
|
||||||
DWORD num_accept_types;
|
DWORD num_accept_types;
|
||||||
|
struct authinfo *authinfo;
|
||||||
|
struct authinfo *proxy_authinfo;
|
||||||
} request_t;
|
} request_t;
|
||||||
|
|
||||||
typedef struct _task_header_t task_header_t;
|
typedef struct _task_header_t task_header_t;
|
||||||
|
@ -229,14 +261,13 @@ BOOL netconn_close( netconn_t * ) DECLSPEC_HIDDEN;
|
||||||
BOOL netconn_connect( netconn_t *, const struct sockaddr *, unsigned int, 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_connected( netconn_t * ) DECLSPEC_HIDDEN;
|
||||||
BOOL netconn_create( netconn_t *, int, int, int ) DECLSPEC_HIDDEN;
|
BOOL netconn_create( netconn_t *, int, int, int ) DECLSPEC_HIDDEN;
|
||||||
BOOL netconn_get_next_line( netconn_t *, char *, DWORD * ) DECLSPEC_HIDDEN;
|
|
||||||
BOOL netconn_init( netconn_t * ) DECLSPEC_HIDDEN;
|
BOOL netconn_init( netconn_t * ) DECLSPEC_HIDDEN;
|
||||||
void netconn_unload( void ) DECLSPEC_HIDDEN;
|
void netconn_unload( void ) DECLSPEC_HIDDEN;
|
||||||
BOOL netconn_query_data_available( netconn_t *, DWORD * ) DECLSPEC_HIDDEN;
|
BOOL netconn_query_data_available( netconn_t *, DWORD * ) 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 *, socklen_t *, int ) 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_secure_connect( netconn_t *, WCHAR * ) DECLSPEC_HIDDEN;
|
||||||
BOOL netconn_send( netconn_t *, const void *, size_t, int, 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;
|
||||||
const void *netconn_get_certificate( netconn_t * ) DECLSPEC_HIDDEN;
|
const void *netconn_get_certificate( netconn_t * ) DECLSPEC_HIDDEN;
|
||||||
int netconn_get_cipher_strength( netconn_t * ) DECLSPEC_HIDDEN;
|
int netconn_get_cipher_strength( netconn_t * ) DECLSPEC_HIDDEN;
|
||||||
|
@ -245,7 +276,8 @@ BOOL set_cookies( request_t *, const WCHAR * ) DECLSPEC_HIDDEN;
|
||||||
BOOL add_cookie_headers( request_t * ) DECLSPEC_HIDDEN;
|
BOOL add_cookie_headers( request_t * ) DECLSPEC_HIDDEN;
|
||||||
BOOL add_request_headers( request_t *, LPCWSTR, DWORD, DWORD ) DECLSPEC_HIDDEN;
|
BOOL add_request_headers( request_t *, LPCWSTR, DWORD, DWORD ) DECLSPEC_HIDDEN;
|
||||||
void delete_domain( domain_t * ) DECLSPEC_HIDDEN;
|
void delete_domain( domain_t * ) DECLSPEC_HIDDEN;
|
||||||
BOOL set_server_for_hostname( connect_t *connect, LPCWSTR server, INTERNET_PORT port ) DECLSPEC_HIDDEN;
|
BOOL set_server_for_hostname( connect_t *, LPCWSTR, INTERNET_PORT ) DECLSPEC_HIDDEN;
|
||||||
|
void destroy_authinfo( struct authinfo * ) DECLSPEC_HIDDEN;
|
||||||
|
|
||||||
extern HRESULT WinHttpRequest_create( IUnknown *, void ** ) DECLSPEC_HIDDEN;
|
extern HRESULT WinHttpRequest_create( IUnknown *, void ** ) DECLSPEC_HIDDEN;
|
||||||
|
|
||||||
|
|
|
@ -202,7 +202,7 @@ reactos/dll/win32/wer # Autosync
|
||||||
reactos/dll/win32/windowscodecs # Synced to Wine-1.7.1
|
reactos/dll/win32/windowscodecs # Synced to Wine-1.7.1
|
||||||
reactos/dll/win32/winemp3.acm # Synced to Wine-1.7.1
|
reactos/dll/win32/winemp3.acm # Synced to Wine-1.7.1
|
||||||
reactos/dll/win32/wing32 # Out of sync
|
reactos/dll/win32/wing32 # Out of sync
|
||||||
reactos/dll/win32/winhttp # Synced to Wine-1.5.26
|
reactos/dll/win32/winhttp # Synced to Wine-1.7.1
|
||||||
reactos/dll/win32/wininet # Synced to Wine-1.5.26
|
reactos/dll/win32/wininet # Synced to Wine-1.5.26
|
||||||
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…
Reference in a new issue