Author: akhaldi
Date: Sun Mar 19 17:04:32 2017
New Revision: 74197
URL:
http://svn.reactos.org/svn/reactos?rev=74197&view=rev
Log:
[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.
Modified:
trunk/reactos/dll/win32/winhttp/net.c
trunk/reactos/dll/win32/winhttp/request.c
trunk/reactos/dll/win32/winhttp/session.c
trunk/reactos/dll/win32/winhttp/url.c
trunk/reactos/dll/win32/winhttp/winhttp.spec
trunk/reactos/dll/win32/winhttp/winhttp_private.h
trunk/reactos/media/doc/README.WINE
Modified: trunk/reactos/dll/win32/winhttp/net.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/winhttp/net.c?re…
==============================================================================
--- trunk/reactos/dll/win32/winhttp/net.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/winhttp/net.c [iso-8859-1] Sun Mar 19 17:04:32 2017
@@ -366,7 +366,7 @@
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 @@
state = 1;
ioctlsocket( conn->socket, FIONBIO, &state );
}
- if (connect( conn->socket, sockaddr, addr_len ) < 0)
- {
- res = sock_get_error( errno );
- if (res == WSAEWOULDBLOCK || res == WSAEINPROGRESS)
+
+ for (;;)
+ {
+ 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;
-
- FD_ZERO(&outfd);
- FD_SET(conn->socket, &outfd);
-
- tv.tv_sec = 0;
- tv.tv_usec = timeout * 1000;
-
- if (select( 0, NULL, &outfd, NULL, &tv ) > 0)
+ /* ReactOS: use select instead of poll */
+ fd_set outfd;
+ struct timeval tv;
+
+ FD_ZERO(&outfd);
+ FD_SET(conn->socket, &outfd);
+
+ tv.tv_sec = 0;
+ tv.tv_usec = timeout * 1000;
+ for (;;)
+ {
+ res = 0;
+
+ if (select( 0, NULL, &outfd, NULL, &tv ) > 0)
#else
- struct pollfd pfd;
-
- pfd.fd = conn->socket;
- pfd.events = POLLOUT;
- if (poll( &pfd, 1, timeout ) > 0)
-#endif
- ret = TRUE;
- else
- res = sock_get_error( errno );
- }
- }
- else
- ret = TRUE;
+ struct pollfd pfd;
+
+ pfd.fd = conn->socket;
+ pfd.events = POLLOUT;
+ for (;;)
+ {
+ res = 0;
+ if (poll( &pfd, 1, timeout ) > 0)
+#endif
+ {
+ ret = TRUE;
+ break;
+ }
+ else
+ {
+ res = sock_get_error( errno );
+ if (res != WSAEINTR) break;
+ }
+ }
+ }
+ if (res != WSAEINTR) break;
+ }
+ else
+ {
+ ret = TRUE;
+ break;
+ }
+ }
if (timeout > 0)
{
state = 0;
Modified: trunk/reactos/dll/win32/winhttp/request.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/winhttp/request.…
==============================================================================
--- trunk/reactos/dll/win32/winhttp/request.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/winhttp/request.c [iso-8859-1] Sun Mar 19 17:04:32 2017
@@ -392,7 +392,7 @@
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 @@
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 );
Modified: trunk/reactos/dll/win32/winhttp/session.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/winhttp/session.…
==============================================================================
--- trunk/reactos/dll/win32/winhttp/session.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/winhttp/session.c [iso-8859-1] Sun Mar 19 17:04:32 2017
@@ -577,8 +577,6 @@
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 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;
Modified: trunk/reactos/dll/win32/winhttp/url.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/winhttp/url.c?re…
==============================================================================
--- trunk/reactos/dll/win32/winhttp/url.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/winhttp/url.c [iso-8859-1] Sun Mar 19 17:04:32 2017
@@ -387,8 +387,7 @@
{
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 @@
{
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;
@@ -423,6 +421,11 @@
{
*required = len + 1;
set_last_error( ERROR_INSUFFICIENT_BUFFER );
+ return FALSE;
+ }
+ if (!url)
+ {
+ set_last_error( ERROR_INVALID_PARAMETER );
return FALSE;
}
@@ -484,15 +487,10 @@
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 */
Modified: trunk/reactos/dll/win32/winhttp/winhttp.spec
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/winhttp/winhttp.…
==============================================================================
--- trunk/reactos/dll/win32/winhttp/winhttp.spec [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/winhttp/winhttp.spec [iso-8859-1] Sun Mar 19 17:04:32 2017
@@ -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)
Modified: trunk/reactos/dll/win32/winhttp/winhttp_private.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/winhttp/winhttp_…
==============================================================================
--- trunk/reactos/dll/win32/winhttp/winhttp_private.h [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/winhttp/winhttp_private.h [iso-8859-1] Sun Mar 19 17:04:32
2017
@@ -222,8 +222,6 @@
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 @@
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 );
}
Modified: trunk/reactos/media/doc/README.WINE
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/media/doc/README.WINE?rev=…
==============================================================================
--- trunk/reactos/media/doc/README.WINE [iso-8859-1] (original)
+++ trunk/reactos/media/doc/README.WINE [iso-8859-1] Sun Mar 19 17:04:32 2017
@@ -200,7 +200,7 @@
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