Index: net/url_request/url_request_http_job.cc |
diff --git a/net/url_request/url_request_http_job.cc b/net/url_request/url_request_http_job.cc |
index 56fed937e3b6fb781de75d205b3f59b32c0ee796..96609344ae500bfd4b7f60e05c25cf05d90e4d47 100644 |
--- a/net/url_request/url_request_http_job.cc |
+++ b/net/url_request/url_request_http_job.cc |
@@ -812,11 +812,13 @@ void URLRequestHttpJob::OnStartCompleted(int result) { |
// |on_headers_received_callback_| or |
// |NetworkDelegate::URLRequestDestroyed()| has been called. |
OnCallToDelegate(); |
+ allowed_unsafe_redirect_url_ = GURL(); |
int error = network_delegate()->NotifyHeadersReceived( |
request_, |
on_headers_received_callback_, |
headers.get(), |
- &override_response_headers_); |
+ &override_response_headers_, |
+ &allowed_unsafe_redirect_url_); |
if (error != net::OK) { |
if (error == net::ERR_IO_PENDING) { |
awaiting_callback_ = true; |
@@ -1044,6 +1046,15 @@ bool URLRequestHttpJob::IsSafeRedirect(const GURL& location) { |
(location.scheme() == "http" || location.scheme() == "https")) { |
return true; |
} |
+ // Delegates may mark an URL as safe for redirection. |
+ if (allowed_unsafe_redirect_url_.is_valid()) { |
+ GURL::Replacements replacements; |
+ replacements.ClearRef(); |
+ if (allowed_unsafe_redirect_url_.ReplaceComponents(replacements) == |
+ location.ReplaceComponents(replacements)) { |
+ return true; |
+ } |
+ } |
// Query URLRequestJobFactory as to whether |location| would be safe to |
// redirect to. |
return request_->context()->job_factory() && |