Author: akhaldi
Date: Sun Sep 17 22:58:01 2017
New Revision: 75902
URL:
http://svn.reactos.org/svn/reactos?rev=75902&view=rev
Log:
[URLMON] Sync with Wine Staging 2.16. CORE-13762
5660a9b urlmon: Remove a redundant NULL check before SysFreeString().
acb1f03 urlmon: Support BINDINFO_OPTIONS_DISABLEAUTOREDIRECTS in BindProtocol object.
ccc5ba2 urlmon: Added a helper function for releasing protocol handler.
cded077 urlmon: Release previously set URI in BindProtocol::StartEx.
9e92254 urlmon: Added support for BINDINFO_OPTIONS_DISABLEAUTOREDIRECTS in http protocol
handler.
Modified:
trunk/reactos/dll/win32/urlmon/bindprot.c
trunk/reactos/dll/win32/urlmon/http.c
trunk/reactos/dll/win32/urlmon/protocol.c
trunk/reactos/dll/win32/urlmon/urlmon_main.h
trunk/reactos/media/doc/README.WINE
Modified: trunk/reactos/dll/win32/urlmon/bindprot.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/urlmon/bindprot.…
==============================================================================
--- trunk/reactos/dll/win32/urlmon/bindprot.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/urlmon/bindprot.c [iso-8859-1] Sun Sep 17 22:58:01 2017
@@ -325,6 +325,31 @@
return ref;
}
+static void release_protocol_handler(BindProtocol *This)
+{
+ if(This->wininet_info) {
+ IWinInetInfo_Release(This->wininet_info);
+ This->wininet_info = NULL;
+ }
+ if(This->wininet_http_info) {
+ IWinInetHttpInfo_Release(This->wininet_http_info);
+ This->wininet_http_info = NULL;
+ }
+ if(This->protocol) {
+ IInternetProtocol_Release(This->protocol);
+ This->protocol = NULL;
+ }
+ if(This->protocol_handler && This->protocol_handler !=
&This->default_protocol_handler.IInternetProtocol_iface) {
+ IInternetProtocol_Release(This->protocol_handler);
+ This->protocol_handler =
&This->default_protocol_handler.IInternetProtocol_iface;
+ }
+ if(This->protocol_sink_handler &&
+ This->protocol_sink_handler !=
&This->default_protocol_handler.IInternetProtocolSink_iface) {
+ IInternetProtocolSink_Release(This->protocol_sink_handler);
+ This->protocol_sink_handler =
&This->default_protocol_handler.IInternetProtocolSink_iface;
+ }
+}
+
static ULONG WINAPI BindProtocol_Release(IInternetProtocolEx *iface)
{
BindProtocol *This = impl_from_IInternetProtocolEx(iface);
@@ -333,19 +358,11 @@
TRACE("(%p) ref=%d\n", This, ref);
if(!ref) {
- if(This->wininet_info)
- IWinInetInfo_Release(This->wininet_info);
- if(This->wininet_http_info)
- IWinInetHttpInfo_Release(This->wininet_http_info);
- if(This->protocol)
- IInternetProtocol_Release(This->protocol);
+ release_protocol_handler(This);
+ if(This->redirect_callback)
+ IBindCallbackRedirect_Release(This->redirect_callback);
if(This->bind_info)
IInternetBindInfo_Release(This->bind_info);
- if(This->protocol_handler && This->protocol_handler !=
&This->default_protocol_handler.IInternetProtocol_iface)
- IInternetProtocol_Release(This->protocol_handler);
- if(This->protocol_sink_handler &&
- This->protocol_sink_handler !=
&This->default_protocol_handler.IInternetProtocolSink_iface)
- IInternetProtocolSink_Release(This->protocol_sink_handler);
if(This->uri)
IUri_Release(This->uri);
SysFreeString(This->display_uri);
@@ -489,6 +506,10 @@
This->pi = grfPI;
+ if(This->uri) {
+ SysFreeString(This->display_uri);
+ IUri_Release(This->uri);
+ }
IUri_AddRef(pUri);
This->uri = pUri;
@@ -707,6 +728,11 @@
This->bind_info = NULL;
}
+ if(This->redirect_callback) {
+ IBindCallbackRedirect_Release(This->redirect_callback);
+ This->redirect_callback = NULL;
+ }
+
IInternetProtocolEx_Release(&This->IInternetProtocolEx_iface);
return S_OK;
}
@@ -969,12 +995,42 @@
return IInternetProtocolSink_ReportData(This->protocol_sink, bscf, progress,
progress_max);
}
+static HRESULT handle_redirect(BindProtocol *This, const WCHAR *url)
+{
+ HRESULT hres;
+
+ if(This->redirect_callback) {
+ VARIANT_BOOL cancel = VARIANT_FALSE;
+ IBindCallbackRedirect_Redirect(This->redirect_callback, url, &cancel);
+ if(cancel)
+ return INET_E_REDIRECT_FAILED;
+ }
+
+ if(This->protocol_sink) {
+ hres = IInternetProtocolSink_ReportProgress(This->protocol_sink,
BINDSTATUS_REDIRECTING, url);
+ if(FAILED(hres))
+ return hres;
+ }
+
+ IInternetProtocol_Terminate(This->protocol, 0); /* should this be done in StartEx?
*/
+ release_protocol_handler(This);
+
+ return IInternetProtocolEx_Start(&This->IInternetProtocolEx_iface, url,
This->protocol_sink, This->bind_info, This->pi, 0);
+}
+
static HRESULT WINAPI ProtocolSinkHandler_ReportResult(IInternetProtocolSink *iface,
HRESULT hrResult, DWORD dwError, LPCWSTR szResult)
{
BindProtocol *This = impl_from_IInternetProtocolSinkHandler(iface);
TRACE("(%p)->(%08x %d %s)\n", This, hrResult, dwError,
debugstr_w(szResult));
+
+ if(hrResult == INET_E_REDIRECT_FAILED) {
+ hrResult = handle_redirect(This, szResult);
+ if(hrResult == S_OK)
+ return S_OK;
+ szResult = NULL;
+ }
if(This->protocol_sink)
return IInternetProtocolSink_ReportResult(This->protocol_sink, hrResult,
dwError, szResult);
@@ -1029,6 +1085,17 @@
return hres;
}
+ if((pbindinfo->dwOptions & BINDINFO_OPTIONS_DISABLEAUTOREDIRECTS) &&
!This->redirect_callback) {
+ IServiceProvider *service_provider;
+
+ hres = IInternetProtocolSink_QueryInterface(This->protocol_sink,
&IID_IServiceProvider, (void**)&service_provider);
+ if(SUCCEEDED(hres)) {
+ hres = IServiceProvider_QueryService(service_provider,
&IID_IBindCallbackRedirect, &IID_IBindCallbackRedirect,
+
(void**)&This->redirect_callback);
+ IServiceProvider_Release(service_provider);
+ }
+ }
+
*grfBINDF |= BINDF_FROMURLMON;
return hres;
}
Modified: trunk/reactos/dll/win32/urlmon/http.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/urlmon/http.c?re…
==============================================================================
--- trunk/reactos/dll/win32/urlmon/http.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/urlmon/http.c [iso-8859-1] Sun Sep 17 22:58:01 2017
@@ -475,6 +475,18 @@
return S_OK;
}
+static BOOL is_redirect_response(DWORD status_code)
+{
+ switch(status_code) {
+ case HTTP_STATUS_REDIRECT:
+ case HTTP_STATUS_MOVED:
+ case HTTP_STATUS_REDIRECT_KEEP_VERB:
+ case HTTP_STATUS_REDIRECT_METHOD:
+ return TRUE;
+ }
+ return FALSE;
+}
+
static HRESULT HttpProtocol_start_downloading(Protocol *prot)
{
HttpProtocol *This = impl_from_Protocol(prot);
@@ -495,7 +507,21 @@
res = HttpQueryInfoW(This->base.request, HTTP_QUERY_STATUS_CODE |
HTTP_QUERY_FLAG_NUMBER,
&status_code, &len, NULL);
if(res) {
- LPWSTR response_headers = query_http_info(This, HTTP_QUERY_RAW_HEADERS_CRLF);
+ WCHAR *response_headers;
+
+ if((This->base.bind_info.dwOptions &
BINDINFO_OPTIONS_DISABLEAUTOREDIRECTS) && is_redirect_response(status_code)) {
+ WCHAR *location;
+
+ TRACE("Got redirect with disabled auto redirects\n");
+
+ location = query_http_info(This, HTTP_QUERY_LOCATION);
+ This->base.flags |= FLAG_RESULT_REPORTED | FLAG_LAST_DATA_REPORTED;
+ IInternetProtocolSink_ReportResult(This->base.protocol_sink,
INET_E_REDIRECT_FAILED, 0, location);
+ heap_free(location);
+ return INET_E_REDIRECT_FAILED;
+ }
+
+ response_headers = query_http_info(This, HTTP_QUERY_RAW_HEADERS_CRLF);
if(response_headers) {
hres = IHttpNegotiate_OnResponse(This->http_negotiate, status_code,
response_headers,
NULL, NULL);
Modified: trunk/reactos/dll/win32/urlmon/protocol.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/urlmon/protocol.…
==============================================================================
--- trunk/reactos/dll/win32/urlmon/protocol.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/urlmon/protocol.c [iso-8859-1] Sun Sep 17 22:58:01 2017
@@ -72,6 +72,8 @@
hres = protocol->vtbl->start_downloading(protocol);
if(FAILED(hres)) {
+ if(hres == INET_E_REDIRECT_FAILED)
+ return S_OK;
protocol_close_connection(protocol);
report_result(protocol, hres);
return hres;
@@ -334,6 +336,8 @@
request_flags |= INTERNET_FLAG_NO_CACHE_WRITE;
if(protocol->bindf & BINDF_NEEDFILE)
request_flags |= INTERNET_FLAG_NEED_FILE;
+ if(protocol->bind_info.dwOptions & BINDINFO_OPTIONS_DISABLEAUTOREDIRECTS)
+ request_flags |= INTERNET_FLAG_NO_AUTO_REDIRECT;
hres = protocol->vtbl->open_request(protocol, uri, request_flags,
internet_session, bind_info);
if(FAILED(hres)) {
Modified: trunk/reactos/dll/win32/urlmon/urlmon_main.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/urlmon/urlmon_ma…
==============================================================================
--- trunk/reactos/dll/win32/urlmon/urlmon_main.h [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/urlmon/urlmon_main.h [iso-8859-1] Sun Sep 17 22:58:01 2017
@@ -189,11 +189,13 @@
LONG ref;
IInternetProtocol *protocol;
+ IWinInetInfo *wininet_info;
+ IWinInetHttpInfo *wininet_http_info;
+
IInternetBindInfo *bind_info;
IInternetProtocolSink *protocol_sink;
IServiceProvider *service_provider;
- IWinInetInfo *wininet_info;
- IWinInetHttpInfo *wininet_http_info;
+ IBindCallbackRedirect *redirect_callback;
struct {
IInternetProtocol IInternetProtocol_iface;
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 Sep 17 22:58:01 2017
@@ -188,7 +188,7 @@
reactos/dll/win32/twain_32 # Synced to WineStaging-2.9
reactos/dll/win32/updspapi # Synced to WineStaging-2.9
reactos/dll/win32/url # Synced to WineStaging-2.9
-reactos/dll/win32/urlmon # Synced to WineStaging-2.9
+reactos/dll/win32/urlmon # Synced to WineStaging-2.16
reactos/dll/win32/usp10 # Synced to WineStaging-2.9
reactos/dll/win32/uxtheme # Forked
reactos/dll/win32/vbscript # Synced to WineStaging-2.9