urlmon: Added support for BINDINFO_OPTIONS_DISABLEAUTOREDIRECTS in http protocol handler.

Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Jacek Caban 2017-06-06 17:14:49 +02:00 committed by Alexandre Julliard
parent 9e37dd3229
commit 9e92254d63
2 changed files with 31 additions and 1 deletions

View File

@ -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);

View File

@ -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)) {