Commit 9e92254d authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

urlmon: Added support for BINDINFO_OPTIONS_DISABLEAUTOREDIRECTS in http protocol handler.

parent 9e37dd32
...@@ -485,6 +485,18 @@ static HRESULT HttpProtocol_end_request(Protocol *protocol) ...@@ -485,6 +485,18 @@ static HRESULT HttpProtocol_end_request(Protocol *protocol)
return S_OK; 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) static HRESULT HttpProtocol_start_downloading(Protocol *prot)
{ {
HttpProtocol *This = impl_from_Protocol(prot); HttpProtocol *This = impl_from_Protocol(prot);
...@@ -505,7 +517,21 @@ static HRESULT HttpProtocol_start_downloading(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, res = HttpQueryInfoW(This->base.request, HTTP_QUERY_STATUS_CODE | HTTP_QUERY_FLAG_NUMBER,
&status_code, &len, NULL); &status_code, &len, NULL);
if(res) { 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) { if(response_headers) {
hres = IHttpNegotiate_OnResponse(This->http_negotiate, status_code, response_headers, hres = IHttpNegotiate_OnResponse(This->http_negotiate, status_code, response_headers,
NULL, NULL); NULL, NULL);
......
...@@ -76,6 +76,8 @@ static HRESULT start_downloading(Protocol *protocol) ...@@ -76,6 +76,8 @@ static HRESULT start_downloading(Protocol *protocol)
hres = protocol->vtbl->start_downloading(protocol); hres = protocol->vtbl->start_downloading(protocol);
if(FAILED(hres)) { if(FAILED(hres)) {
if(hres == INET_E_REDIRECT_FAILED)
return S_OK;
protocol_close_connection(protocol); protocol_close_connection(protocol);
report_result(protocol, hres); report_result(protocol, hres);
return hres; return hres;
...@@ -338,6 +340,8 @@ HRESULT protocol_start(Protocol *protocol, IInternetProtocol *prot, IUri *uri, ...@@ -338,6 +340,8 @@ HRESULT protocol_start(Protocol *protocol, IInternetProtocol *prot, IUri *uri,
request_flags |= INTERNET_FLAG_NO_CACHE_WRITE; request_flags |= INTERNET_FLAG_NO_CACHE_WRITE;
if(protocol->bindf & BINDF_NEEDFILE) if(protocol->bindf & BINDF_NEEDFILE)
request_flags |= INTERNET_FLAG_NEED_FILE; 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); hres = protocol->vtbl->open_request(protocol, uri, request_flags, internet_session, bind_info);
if(FAILED(hres)) { if(FAILED(hres)) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment