mirror of
https://github.com/reactos/reactos.git
synced 2024-09-28 13:34:53 +00:00
[WINHTTP] Sync with Wine Staging 2.2. CORE-12823
6053db9 winhttp: Fix handling of Accept headers. c43dd19 winhttp: Add __WINE_ALLOC_SIZE attributes to heap_xxx() functions. 5b9beca winhttp: Fix some spec file entries. 542998e winhttp: Accept NULL buffer for size queries in WinHttpCreateUrl. ec35394 winhttp: Handle EINTR from connect and poll. 613e239 winhttp: Use return value of sprintf() instead of calling strlen() and simplify code. svn path=/trunk/; revision=74197
This commit is contained in:
parent
557197382e
commit
1d323c7f36
|
@ -366,7 +366,7 @@ BOOL netconn_close( netconn_t *conn )
|
|||
BOOL netconn_connect( netconn_t *conn, const struct sockaddr *sockaddr, unsigned int addr_len, int timeout )
|
||||
{
|
||||
BOOL ret = FALSE;
|
||||
int res = 0;
|
||||
int res;
|
||||
ULONG state;
|
||||
|
||||
if (timeout > 0)
|
||||
|
@ -374,37 +374,59 @@ BOOL netconn_connect( netconn_t *conn, const struct sockaddr *sockaddr, unsigned
|
|||
state = 1;
|
||||
ioctlsocket( conn->socket, FIONBIO, &state );
|
||||
}
|
||||
if (connect( conn->socket, sockaddr, addr_len ) < 0)
|
||||
|
||||
for (;;)
|
||||
{
|
||||
res = sock_get_error( errno );
|
||||
if (res == WSAEWOULDBLOCK || res == WSAEINPROGRESS)
|
||||
res = 0;
|
||||
if (connect( conn->socket, sockaddr, addr_len ) < 0)
|
||||
{
|
||||
res = sock_get_error( errno );
|
||||
if (res == WSAEWOULDBLOCK || res == WSAEINPROGRESS)
|
||||
{
|
||||
#ifdef __REACTOS__
|
||||
/* ReactOS: use select instead of poll */
|
||||
fd_set outfd;
|
||||
struct timeval tv;
|
||||
/* ReactOS: use select instead of poll */
|
||||
fd_set outfd;
|
||||
struct timeval tv;
|
||||
|
||||
FD_ZERO(&outfd);
|
||||
FD_SET(conn->socket, &outfd);
|
||||
FD_ZERO(&outfd);
|
||||
FD_SET(conn->socket, &outfd);
|
||||
|
||||
tv.tv_sec = 0;
|
||||
tv.tv_usec = timeout * 1000;
|
||||
tv.tv_sec = 0;
|
||||
tv.tv_usec = timeout * 1000;
|
||||
for (;;)
|
||||
{
|
||||
res = 0;
|
||||
|
||||
if (select( 0, NULL, &outfd, NULL, &tv ) > 0)
|
||||
if (select( 0, NULL, &outfd, NULL, &tv ) > 0)
|
||||
#else
|
||||
struct pollfd pfd;
|
||||
struct pollfd pfd;
|
||||
|
||||
pfd.fd = conn->socket;
|
||||
pfd.events = POLLOUT;
|
||||
if (poll( &pfd, 1, timeout ) > 0)
|
||||
pfd.fd = conn->socket;
|
||||
pfd.events = POLLOUT;
|
||||
for (;;)
|
||||
{
|
||||
res = 0;
|
||||
if (poll( &pfd, 1, timeout ) > 0)
|
||||
#endif
|
||||
ret = TRUE;
|
||||
else
|
||||
res = sock_get_error( errno );
|
||||
{
|
||||
ret = TRUE;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
res = sock_get_error( errno );
|
||||
if (res != WSAEINTR) break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (res != WSAEINTR) break;
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
ret = TRUE;
|
||||
if (timeout > 0)
|
||||
{
|
||||
state = 0;
|
||||
|
|
|
@ -392,7 +392,7 @@ static BOOL delete_header( request_t *request, DWORD index )
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
static BOOL process_header( request_t *request, LPCWSTR field, LPCWSTR value, DWORD flags, BOOL request_only )
|
||||
BOOL process_header( request_t *request, LPCWSTR field, LPCWSTR value, DWORD flags, BOOL request_only )
|
||||
{
|
||||
int index;
|
||||
header_t hdr;
|
||||
|
@ -1119,15 +1119,10 @@ static BOOL send_request( request_t *request, LPCWSTR headers, DWORD headers_len
|
|||
WCHAR *req = NULL;
|
||||
char *req_ascii;
|
||||
int bytes_sent;
|
||||
DWORD len, i, flags;
|
||||
DWORD len;
|
||||
|
||||
clear_response_headers( request );
|
||||
|
||||
flags = WINHTTP_ADDREQ_FLAG_ADD|WINHTTP_ADDREQ_FLAG_COALESCE_WITH_COMMA;
|
||||
for (i = 0; i < request->num_accept_types; i++)
|
||||
{
|
||||
process_header( request, attr_accept, request->accept_types[i], flags, TRUE );
|
||||
}
|
||||
if (session->agent)
|
||||
process_header( request, attr_user_agent, session->agent, WINHTTP_ADDREQ_FLAG_ADD_IF_NEW, TRUE );
|
||||
|
||||
|
|
|
@ -577,8 +577,6 @@ static void request_destroy( object_header_t *hdr )
|
|||
heap_free( request->headers[i].value );
|
||||
}
|
||||
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 (j = 0; j < SCHEME_MAX; j++)
|
||||
|
@ -1001,32 +999,14 @@ static const object_vtbl_t request_vtbl =
|
|||
|
||||
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;
|
||||
DWORD i;
|
||||
|
||||
if (!types) return TRUE;
|
||||
while (*types)
|
||||
{
|
||||
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;
|
||||
}
|
||||
process_header( request, attr_accept, *types, flags, TRUE );
|
||||
types++;
|
||||
}
|
||||
return TRUE;
|
||||
|
|
|
@ -387,8 +387,7 @@ static BOOL calc_length( URL_COMPONENTS *uc, DWORD flags, LPDWORD len )
|
|||
{
|
||||
WCHAR port[sizeof("65535")];
|
||||
|
||||
sprintfW( port, formatW, uc->nPort );
|
||||
*len += strlenW( port );
|
||||
*len += sprintfW( port, formatW, uc->nPort );
|
||||
*len += 1; /* ":" */
|
||||
}
|
||||
if (uc->lpszUrlPath && *uc->lpszUrlPath != '/') *len += 1; /* '/' */
|
||||
|
@ -405,13 +404,12 @@ BOOL WINAPI WinHttpCreateUrl( LPURL_COMPONENTS uc, DWORD flags, LPWSTR url, LPDW
|
|||
{
|
||||
static const WCHAR formatW[] = {'%','u',0};
|
||||
static const WCHAR twoslashW[] = {'/','/'};
|
||||
|
||||
DWORD len;
|
||||
INTERNET_SCHEME scheme;
|
||||
|
||||
TRACE("%p, 0x%08x, %p, %p\n", uc, flags, url, required);
|
||||
|
||||
if (!uc || uc->dwStructSize != sizeof(URL_COMPONENTS) || !required || !url)
|
||||
if (!uc || uc->dwStructSize != sizeof(URL_COMPONENTS) || !required)
|
||||
{
|
||||
set_last_error( ERROR_INVALID_PARAMETER );
|
||||
return FALSE;
|
||||
|
@ -425,6 +423,11 @@ BOOL WINAPI WinHttpCreateUrl( LPURL_COMPONENTS uc, DWORD flags, LPWSTR url, LPDW
|
|||
set_last_error( ERROR_INSUFFICIENT_BUFFER );
|
||||
return FALSE;
|
||||
}
|
||||
if (!url)
|
||||
{
|
||||
set_last_error( ERROR_INVALID_PARAMETER );
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
url[0] = 0;
|
||||
*required = len;
|
||||
|
@ -484,15 +487,10 @@ BOOL WINAPI WinHttpCreateUrl( LPURL_COMPONENTS uc, DWORD flags, LPWSTR url, LPDW
|
|||
|
||||
if (!uses_default_port( scheme, uc->nPort ))
|
||||
{
|
||||
WCHAR port[sizeof("65535")];
|
||||
|
||||
sprintfW( port, formatW, uc->nPort );
|
||||
*url = ':';
|
||||
url++;
|
||||
|
||||
len = strlenW( port );
|
||||
memcpy( url, port, len * sizeof(WCHAR) );
|
||||
url += len;
|
||||
url += sprintfW( url, formatW, uc->nPort );
|
||||
}
|
||||
|
||||
/* add slash between hostname and path if necessary */
|
||||
|
|
|
@ -20,11 +20,11 @@
|
|||
@ stdcall WinHttpQueryOption(ptr long ptr ptr)
|
||||
@ stdcall WinHttpReadData(ptr ptr long ptr)
|
||||
@ stdcall WinHttpReceiveResponse(ptr ptr)
|
||||
@ stdcall WinHttpSendRequest(ptr wstr long ptr long long ptr)
|
||||
@ stdcall WinHttpSendRequest(ptr wstr long ptr long long long)
|
||||
@ stdcall WinHttpSetCredentials(ptr long long wstr ptr ptr)
|
||||
@ stdcall WinHttpSetDefaultProxyConfiguration(ptr)
|
||||
@ stdcall WinHttpSetOption(ptr long ptr long)
|
||||
@ stdcall WinHttpSetStatusCallback(ptr ptr long ptr)
|
||||
@ stdcall WinHttpSetStatusCallback(ptr ptr long long)
|
||||
@ stdcall WinHttpSetTimeouts(ptr long long long long)
|
||||
@ stdcall WinHttpTimeFromSystemTime(ptr ptr)
|
||||
@ stdcall WinHttpTimeToSystemTime(wstr ptr)
|
||||
|
|
|
@ -222,8 +222,6 @@ typedef struct
|
|||
char read_buf[8192]; /* buffer for already read but not returned data */
|
||||
header_t *headers;
|
||||
DWORD num_headers;
|
||||
WCHAR **accept_types;
|
||||
DWORD num_accept_types;
|
||||
struct authinfo *authinfo;
|
||||
struct authinfo *proxy_authinfo;
|
||||
HANDLE task_wait;
|
||||
|
@ -318,25 +316,27 @@ 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;
|
||||
|
||||
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 *heap_alloc( SIZE_T size )
|
||||
static inline void* __WINE_ALLOC_SIZE(1) heap_alloc( SIZE_T size )
|
||||
{
|
||||
return HeapAlloc( GetProcessHeap(), 0, size );
|
||||
}
|
||||
|
||||
static inline void *heap_alloc_zero( SIZE_T size )
|
||||
static inline void* __WINE_ALLOC_SIZE(1) heap_alloc_zero( SIZE_T size )
|
||||
{
|
||||
return HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, size );
|
||||
}
|
||||
|
||||
static inline void *heap_realloc( LPVOID mem, SIZE_T size )
|
||||
static inline void* __WINE_ALLOC_SIZE(2) heap_realloc( LPVOID mem, SIZE_T size )
|
||||
{
|
||||
return HeapReAlloc( GetProcessHeap(), 0, mem, size );
|
||||
}
|
||||
|
||||
static inline void *heap_realloc_zero( LPVOID mem, SIZE_T size )
|
||||
static inline void* __WINE_ALLOC_SIZE(2) heap_realloc_zero( LPVOID mem, SIZE_T size )
|
||||
{
|
||||
return HeapReAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, mem, size );
|
||||
}
|
||||
|
|
|
@ -200,7 +200,7 @@ reactos/dll/win32/windowscodecs # Synced to WineStaging-1.9.23
|
|||
reactos/dll/win32/windowscodecsext # Synced to WineStaging-1.9.11
|
||||
reactos/dll/win32/winemp3.acm # Synced to WineStaging-2.2
|
||||
reactos/dll/win32/wing32 # Synced to WineStaging-1.9.11
|
||||
reactos/dll/win32/winhttp # Synced to WineStaging-1.9.23
|
||||
reactos/dll/win32/winhttp # Synced to WineStaging-2.2
|
||||
reactos/dll/win32/wininet # Synced to WineStaging-2.2
|
||||
reactos/dll/win32/winmm # Forked at Wine-20050628
|
||||
reactos/dll/win32/winmm/midimap # Forked at Wine-20050628
|
||||
|
|
Loading…
Reference in a new issue