Jacek Caban : urlmon: Added support for BINDINFO_OPTIONS_DISABLEAUTOREDIRECTS in http protocol handler.

Alexandre Julliard julliard at winehq.org
Tue Jun 6 15:23:35 CDT 2017


Module: wine
Branch: master
Commit: 9e92254d6315179054444ab820e26265d6bfb828
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=9e92254d6315179054444ab820e26265d6bfb828

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Tue Jun  6 17:14:49 2017 +0200

urlmon: Added support for BINDINFO_OPTIONS_DISABLEAUTOREDIRECTS in http protocol handler.

Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/urlmon/http.c     | 28 +++++++++++++++++++++++++++-
 dlls/urlmon/protocol.c |  4 ++++
 2 files changed, 31 insertions(+), 1 deletion(-)

diff --git a/dlls/urlmon/http.c b/dlls/urlmon/http.c
index b0c7d2a..2fd9be6 100644
--- a/dlls/urlmon/http.c
+++ b/dlls/urlmon/http.c
@@ -485,6 +485,18 @@ static HRESULT HttpProtocol_end_request(Protocol *protocol)
     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);
@@ -505,7 +517,21 @@ static HRESULT HttpProtocol_start_downloading(Protocol *prot)
     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);
diff --git a/dlls/urlmon/protocol.c b/dlls/urlmon/protocol.c
index abe8668..a6ccf83 100644
--- a/dlls/urlmon/protocol.c
+++ b/dlls/urlmon/protocol.c
@@ -76,6 +76,8 @@ static HRESULT start_downloading(Protocol *protocol)
 
     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;
@@ -338,6 +340,8 @@ HRESULT protocol_start(Protocol *protocol, IInternetProtocol *prot, IUri *uri,
         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)) {




More information about the wine-cvs mailing list