Author: akhaldi
Date: Sun Nov 22 10:13:38 2015
New Revision: 70007
URL:
http://svn.reactos.org/svn/reactos?rev=70007&view=rev
Log:
[WINHTTP] Sync with Wine Staging 1.7.55. CORE-10536
Modified:
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_private.h
trunk/reactos/media/doc/README.WINE
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 Nov 22 10:13:38 2015
@@ -28,6 +28,7 @@
#include <assert.h>
#include <winuser.h>
#include <httprequest.h>
+#include <httprequestid.h>
#include "inet_ntop.c"
@@ -206,6 +207,11 @@
}
case WAIT_OBJECT_0 + 1:
TRACE("exiting\n");
+ CloseHandle( request->task_cancel );
+ CloseHandle( request->task_wait );
+ request->task_cs.DebugInfo->Spare[0] = 0;
+ DeleteCriticalSection( &request->task_cs );
+ request->hdr.vtbl->destroy( &request->hdr );
return 0;
default:
@@ -525,6 +531,7 @@
ret = add_request_headers( request, headers, len, flags );
release_object( &request->hdr );
+ if (ret) set_last_error( ERROR_SUCCESS );
return ret;
}
@@ -655,11 +662,8 @@
if (!(p = headers)) return FALSE;
for (len = 0; *p; p++) if (*p != '\r') len++;
- if (!buffer || (len + 1) * sizeof(WCHAR) > *buflen)
- {
- len++;
+ if (!buffer || len * sizeof(WCHAR) > *buflen)
set_last_error( ERROR_INSUFFICIENT_BUFFER );
- }
else
{
for (p = headers, q = buffer; *p; p++, q++)
@@ -671,8 +675,8 @@
p++; /* skip '\n' */
}
}
- *q = 0;
TRACE("returning data: %s\n", debugstr_wn(buffer, len));
+ if (len) len--;
ret = TRUE;
}
*buflen = len * sizeof(WCHAR);
@@ -832,6 +836,7 @@
ret = query_headers( request, level, name, buffer, buflen, index );
release_object( &request->hdr );
+ if (ret) set_last_error( ERROR_SUCCESS );
return ret;
}
@@ -1036,7 +1041,7 @@
return FALSE;
}
}
- if (!netconn_secure_connect( &request->netconn, connect->servername ))
+ if (!netconn_secure_connect( &request->netconn, connect->hostname ))
{
netconn_close( &request->netconn );
heap_free( addressW );
@@ -1249,6 +1254,7 @@
ret = send_request( request, headers, headers_len, optional, optional_len,
total_len, context, FALSE );
release_object( &request->hdr );
+ if (ret) set_last_error( ERROR_SUCCESS );
return ret;
}
@@ -1373,6 +1379,7 @@
}
release_object( &request->hdr );
+ if (ret) set_last_error( ERROR_SUCCESS );
return ret;
}
@@ -1827,6 +1834,7 @@
ret = set_credentials( request, target, scheme, username, password );
release_object( &request->hdr );
+ if (ret) set_last_error( ERROR_SUCCESS );
return ret;
}
@@ -2072,19 +2080,17 @@
static const WCHAR crlf[] = {'\r','\n',0};
char buffer[MAX_REPLY_LEN];
- DWORD buflen, len, offset, received_len, crlf_len = 2; /* strlenW(crlf) */
+ DWORD buflen, len, offset, crlf_len = 2; /* strlenW(crlf) */
char *status_code, *status_text;
WCHAR *versionW, *status_textW, *raw_headers;
WCHAR status_codeW[4]; /* sizeof("nnn") */
if (!netconn_connected( &request->netconn )) return FALSE;
- received_len = 0;
do
{
buflen = MAX_REPLY_LEN;
if (!read_line( request, buffer, &buflen )) return FALSE;
- received_len += buflen;
/* first line should look like 'HTTP/1.x nnn OK' where nnn is the status
code */
if (!(status_code = strchr( buffer, ' ' ))) return FALSE;
@@ -2137,8 +2143,7 @@
buflen = MAX_REPLY_LEN;
if (!read_line( request, buffer, &buflen )) return TRUE;
- received_len += buflen;
- if (!*buffer) break;
+ if (!*buffer) buflen = 1;
while (len - offset < buflen + crlf_len)
{
@@ -2146,6 +2151,11 @@
len *= 2;
if (!(tmp = heap_realloc( raw_headers, len * sizeof(WCHAR) ))) return FALSE;
request->raw_headers = raw_headers = tmp;
+ }
+ if (!*buffer)
+ {
+ memcpy( raw_headers + offset, crlf, sizeof(crlf) );
+ break;
}
MultiByteToWideChar( CP_ACP, 0, buffer, buflen, raw_headers + offset, buflen );
@@ -2469,6 +2479,7 @@
ret = receive_response( request, FALSE );
release_object( &request->hdr );
+ if (ret) set_last_error( ERROR_SUCCESS );
return ret;
}
@@ -2540,6 +2551,7 @@
ret = query_data_available( request, available, FALSE );
release_object( &request->hdr );
+ if (ret) set_last_error( ERROR_SUCCESS );
return ret;
}
@@ -2589,6 +2601,7 @@
ret = read_data( request, buffer, to_read, read, FALSE );
release_object( &request->hdr );
+ if (ret) set_last_error( ERROR_SUCCESS );
return ret;
}
@@ -2660,6 +2673,7 @@
ret = write_data( request, buffer, to_write, written, FALSE );
release_object( &request->hdr );
+ if (ret) set_last_error( ERROR_SUCCESS );
return ret;
}
@@ -2700,6 +2714,7 @@
LONG receive_timeout;
WINHTTP_PROXY_INFO proxy;
BOOL async;
+ UINT url_codepage;
};
static inline struct winhttp_request *impl_from_IWinHttpRequest( IWinHttpRequest *iface
)
@@ -2921,6 +2936,48 @@
TRACE("%p, %d, %s, %d, %d, %p, %p, %p, %p\n", request, member,
debugstr_guid(riid),
lcid, flags, params, result, excep_info, arg_err);
+
+ if (!IsEqualIID( riid, &IID_NULL )) return DISP_E_UNKNOWNINTERFACE;
+
+ if (member == DISPID_HTTPREQUEST_OPTION)
+ {
+ VARIANT ret_value, option;
+ UINT err_pos;
+
+ if (!result) result = &ret_value;
+ if (!arg_err) arg_err = &err_pos;
+
+ VariantInit( &option );
+ VariantInit( result );
+
+ if (!flags) return S_OK;
+
+ if (flags == DISPATCH_PROPERTYPUT)
+ {
+ hr = DispGetParam( params, 0, VT_I4, &option, arg_err );
+ if (FAILED(hr)) return hr;
+
+ hr = IWinHttpRequest_put_Option( &request->IWinHttpRequest_iface,
V_I4( &option ), params->rgvarg[0] );
+ if (FAILED(hr))
+ WARN("put_Option(%d) failed: %x\n", V_I4( &option ), hr);
+ return hr;
+ }
+ else if (flags & (DISPATCH_PROPERTYGET | DISPATCH_METHOD))
+ {
+ hr = DispGetParam( params, 0, VT_I4, &option, arg_err );
+ if (FAILED(hr)) return hr;
+
+ hr = IWinHttpRequest_get_Option( &request->IWinHttpRequest_iface,
V_I4( &option ), result );
+ if (FAILED(hr))
+ WARN("get_Option(%d) failed: %x\n", V_I4( &option ), hr);
+ return hr;
+ }
+
+ FIXME("unsupported flags %x\n", flags);
+ return E_NOTIMPL;
+ }
+
+ /* fallback to standard implementation */
hr = get_typeinfo( IWinHttpRequest_tid, &typeinfo );
if (SUCCEEDED(hr))
@@ -3048,6 +3105,7 @@
request->connect_timeout = 60000;
request->send_timeout = 30000;
request->receive_timeout = 30000;
+ request->url_codepage = CP_UTF8;
VariantInit( &request->data );
request->state = REQUEST_STATE_INITIALIZED;
}
@@ -3068,6 +3126,7 @@
request->bytes_read = 0;
request->error = ERROR_SUCCESS;
request->async = FALSE;
+ request->url_codepage = CP_UTF8;
VariantClear( &request->data );
request->state = REQUEST_STATE_INITIALIZED;
}
@@ -3973,8 +4032,25 @@
WinHttpRequestOption option,
VARIANT *value )
{
- FIXME("\n");
- return E_NOTIMPL;
+ struct winhttp_request *request = impl_from_IWinHttpRequest( iface );
+ HRESULT hr = S_OK;
+
+ TRACE("%p, %u, %p\n", request, option, value);
+
+ EnterCriticalSection( &request->cs );
+ switch (option)
+ {
+ case WinHttpRequestOption_URLCodePage:
+ V_VT( value ) = VT_I4;
+ V_I4( value ) = request->url_codepage;
+ break;
+ default:
+ FIXME("unimplemented option %u\n", option);
+ hr = E_NOTIMPL;
+ break;
+ }
+ LeaveCriticalSection( &request->cs );
+ return hr;
}
static HRESULT WINAPI winhttp_request_put_Option(
@@ -3996,6 +4072,28 @@
request->disable_feature &= ~WINHTTP_DISABLE_REDIRECTS;
else
request->disable_feature |= WINHTTP_DISABLE_REDIRECTS;
+ break;
+ }
+ case WinHttpRequestOption_URLCodePage:
+ {
+ static const WCHAR utf8W[] =
{'u','t','f','-','8',0};
+ VARIANT cp;
+
+ VariantInit( &cp );
+ hr = VariantChangeType( &cp, &value, 0, VT_UI4 );
+ if (SUCCEEDED( hr ))
+ {
+ request->url_codepage = V_UI4( &cp );
+ TRACE("URL codepage: %u\n", request->url_codepage);
+ }
+ else if (V_VT( &value ) == VT_BSTR && !strcmpiW( V_BSTR( &value
), utf8W ))
+ {
+ TRACE("URL codepage: UTF-8\n");
+ request->url_codepage = CP_UTF8;
+ hr = S_OK;
+ }
+ else
+ FIXME("URL codepage %s is not recognized\n", debugstr_variant(
&value ));
break;
}
default:
@@ -4151,6 +4249,7 @@
request->state = REQUEST_STATE_UNINITIALIZED;
request->proxy.lpszProxy = NULL;
request->proxy.lpszProxyBypass = NULL;
+ request->url_codepage = CP_UTF8;
InitializeCriticalSection( &request->cs );
request->cs.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ":
winhttp_request.cs");
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 Nov 22 10:13:38 2015
@@ -70,6 +70,8 @@
TRACE("%p\n", session);
+ if (session->unload_event) SetEvent( session->unload_event );
+
LIST_FOR_EACH_SAFE( item, next, &session->cookie_cache )
{
domain = LIST_ENTRY( item, domain_t, entry );
@@ -173,6 +175,10 @@
return TRUE;
case WINHTTP_OPTION_CONFIGURE_PASSPORT_AUTH:
FIXME("WINHTTP_OPTION_CONFIGURE_PASSPORT_AUTH: 0x%x\n", *(DWORD
*)buffer);
+ return TRUE;
+ case WINHTTP_OPTION_UNLOAD_NOTIFY_EVENT:
+ TRACE("WINHTTP_OPTION_UNLOAD_NOTIFY_EVENT: %p\n", *(HANDLE *)buffer);
+ session->unload_event = *(HANDLE *)buffer;
return TRUE;
default:
FIXME("unimplemented option %u\n", option);
@@ -250,6 +256,7 @@
end:
release_object( &session->hdr );
TRACE("returning %p\n", handle);
+ if (handle) set_last_error( ERROR_SUCCESS );
return handle;
}
@@ -526,6 +533,7 @@
release_object( &connect->hdr );
release_object( &session->hdr );
TRACE("returning %p\n", hconnect);
+ if (hconnect) set_last_error( ERROR_SUCCESS );
return hconnect;
}
@@ -541,13 +549,13 @@
if (request->task_thread)
{
+ /* Signal to the task proc to quit. It will call
+ this again when it does. */
+ HANDLE thread = request->task_thread;
+ request->task_thread = 0;
SetEvent( request->task_cancel );
- WaitForSingleObject( request->task_thread, INFINITE );
- CloseHandle( request->task_thread );
- CloseHandle( request->task_cancel );
- CloseHandle( request->task_wait );
- request->task_cs.DebugInfo->Spare[0] = 0;
- DeleteCriticalSection( &request->task_cs );
+ CloseHandle( thread );
+ return;
}
release_object( &request->connect->hdr );
@@ -1101,6 +1109,7 @@
release_object( &request->hdr );
release_object( &connect->hdr );
TRACE("returning %p\n", hrequest);
+ if (hrequest) set_last_error( ERROR_SUCCESS );
return hrequest;
}
@@ -1120,6 +1129,7 @@
}
release_object( hdr );
free_handle( handle );
+ set_last_error( ERROR_SUCCESS );
return TRUE;
}
@@ -1180,6 +1190,7 @@
ret = query_option( hdr, option, buffer, buflen );
release_object( hdr );
+ if (ret) set_last_error( ERROR_SUCCESS );
return ret;
}
@@ -1238,6 +1249,7 @@
ret = set_option( hdr, option, buffer, buflen );
release_object( hdr );
+ if (ret) set_last_error( ERROR_SUCCESS );
return ret;
}
@@ -1348,6 +1360,7 @@
if (!(urlW = strdupAW( system_url ))) return FALSE;
*url = urlW;
+ set_last_error( ERROR_SUCCESS );
return TRUE;
}
if (flags & WINHTTP_AUTO_DETECT_TYPE_DHCP)
@@ -1408,6 +1421,7 @@
set_last_error( ERROR_WINHTTP_AUTODETECTION_FAILED );
*url = NULL;
}
+ else set_last_error( ERROR_SUCCESS );
return ret;
}
@@ -1575,6 +1589,7 @@
info->lpszProxy = NULL;
info->lpszProxyBypass = NULL;
}
+ set_last_error( ERROR_SUCCESS );
return TRUE;
}
@@ -1657,6 +1672,7 @@
GlobalFree( config->lpszProxyBypass );
config->lpszProxyBypass = NULL;
}
+ else set_last_error( ERROR_SUCCESS );
return ret;
}
@@ -1841,6 +1857,7 @@
done:
GlobalFree( detected_pac_url );
release_object( &session->hdr );
+ if (ret) set_last_error( ERROR_SUCCESS );
return ret;
}
@@ -1948,6 +1965,7 @@
}
RegCloseKey( key );
}
+ if (ret) set_last_error( ERROR_SUCCESS );
return ret;
}
@@ -1972,6 +1990,7 @@
hdr->notify_mask = flags;
release_object( hdr );
+ set_last_error( ERROR_SUCCESS );
return ret;
}
@@ -2019,8 +2038,6 @@
if (netconn_set_timeout( &request->netconn, TRUE, send )) ret =
FALSE;
if (netconn_set_timeout( &request->netconn, FALSE, receive )) ret
= FALSE;
}
-
- release_object( &request->hdr );
break;
case WINHTTP_HANDLE_TYPE_SESSION:
@@ -2038,10 +2055,11 @@
break;
default:
- release_object( hdr );
set_last_error( ERROR_WINHTTP_INCORRECT_HANDLE_TYPE );
- return FALSE;
- }
+ ret = FALSE;
+ }
+ release_object( hdr );
+ if (ret) set_last_error( ERROR_SUCCESS );
return ret;
}
@@ -2064,7 +2082,11 @@
TRACE("%p, %p\n", time, string);
- if (!time || !string) return FALSE;
+ if (!time || !string)
+ {
+ set_last_error( ERROR_INVALID_PARAMETER );
+ return FALSE;
+ }
sprintfW( string, format,
wkday[time->wDayOfWeek],
@@ -2075,6 +2097,7 @@
time->wMinute,
time->wSecond );
+ set_last_error( ERROR_SUCCESS );
return TRUE;
}
@@ -2089,7 +2112,11 @@
TRACE("%s, %p\n", debugstr_w(string), time);
- if (!string || !time) return FALSE;
+ if (!string || !time)
+ {
+ set_last_error( ERROR_INVALID_PARAMETER );
+ return FALSE;
+ }
/* Windows does this too */
GetSystemTime( time );
@@ -2097,6 +2124,8 @@
/* Convert an RFC1123 time such as 'Fri, 07 Jan 2005 12:06:35 GMT' into
* a SYSTEMTIME structure.
*/
+
+ set_last_error( ERROR_SUCCESS );
while (*s && !isalphaW( *s )) s++;
if (s[0] == '\0' || s[1] == '\0' || s[2] == '\0') 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 Nov 22 10:13:38 2015
@@ -291,6 +291,7 @@
if (ret) uc->nScheme = scheme;
heap_free( url_decoded );
heap_free( url_escaped );
+ if (ret) set_last_error( ERROR_SUCCESS );
return ret;
}
@@ -509,5 +510,6 @@
}
}
*url = 0;
+ set_last_error( ERROR_SUCCESS );
return TRUE;
}
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 Nov 22 10:13:38
2015
@@ -125,6 +125,7 @@
LPWSTR proxy_username;
LPWSTR proxy_password;
struct list cookie_cache;
+ HANDLE unload_event;
} session_t;
typedef struct
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 Nov 22 10:13:38 2015
@@ -204,7 +204,7 @@
reactos/dll/win32/windowscodecsext # Synced to WineStaging-1.7.47
reactos/dll/win32/winemp3.acm # Synced to WineStaging-1.7.47
reactos/dll/win32/wing32 # Synced to WineStaging-1.7.55
-reactos/dll/win32/winhttp # Synced to WineStaging-1.7.47
+reactos/dll/win32/winhttp # Synced to WineStaging-1.7.55
reactos/dll/win32/wininet # Synced to WineStaging-1.7.47
reactos/dll/win32/winmm # Forked at Wine-20050628
reactos/dll/win32/winmm/midimap # Forked at Wine-20050628