Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "net/url_request/url_request_http_job.h" | 5 #include "net/url_request/url_request_http_job.h" |
| 6 | 6 |
| 7 #include "base/base_switches.h" | 7 #include "base/base_switches.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/bind_helpers.h" | 9 #include "base/bind_helpers.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 787 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 798 } | 798 } |
| 799 } | 799 } |
| 800 | 800 |
| 801 if (result == OK) { | 801 if (result == OK) { |
| 802 scoped_refptr<HttpResponseHeaders> headers = GetResponseHeaders(); | 802 scoped_refptr<HttpResponseHeaders> headers = GetResponseHeaders(); |
| 803 if (network_delegate()) { | 803 if (network_delegate()) { |
| 804 // Note that |this| may not be deleted until | 804 // Note that |this| may not be deleted until |
| 805 // |on_headers_received_callback_| or | 805 // |on_headers_received_callback_| or |
| 806 // |NetworkDelegate::URLRequestDestroyed()| has been called. | 806 // |NetworkDelegate::URLRequestDestroyed()| has been called. |
| 807 OnCallToDelegate(); | 807 OnCallToDelegate(); |
| 808 if (!allowed_unsafe_redirect_url_.is_empty()) | |
| 809 allowed_unsafe_redirect_url_ = GURL(); | |
|
mmenke
2014/03/21 18:15:04
Should just always clear it here. Code size and r
robwu
2014/03/25 00:04:00
Done.
| |
| 808 int error = network_delegate()->NotifyHeadersReceived( | 810 int error = network_delegate()->NotifyHeadersReceived( |
| 809 request_, | 811 request_, |
| 810 on_headers_received_callback_, | 812 on_headers_received_callback_, |
| 811 headers.get(), | 813 headers.get(), |
| 812 &override_response_headers_); | 814 &override_response_headers_, |
| 815 &allowed_unsafe_redirect_url_); | |
| 813 if (error != net::OK) { | 816 if (error != net::OK) { |
| 814 if (error == net::ERR_IO_PENDING) { | 817 if (error == net::ERR_IO_PENDING) { |
| 815 awaiting_callback_ = true; | 818 awaiting_callback_ = true; |
| 816 } else { | 819 } else { |
| 817 std::string source("delegate"); | 820 std::string source("delegate"); |
| 818 request_->net_log().AddEvent(NetLog::TYPE_CANCELLED, | 821 request_->net_log().AddEvent(NetLog::TYPE_CANCELLED, |
| 819 NetLog::StringCallback("source", | 822 NetLog::StringCallback("source", |
| 820 &source)); | 823 &source)); |
| 821 OnCallToDelegateComplete(); | 824 OnCallToDelegateComplete(); |
| 822 NotifyStartError(URLRequestStatus(URLRequestStatus::FAILED, error)); | 825 NotifyStartError(URLRequestStatus(URLRequestStatus::FAILED, error)); |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1030 ? Filter::Factory(encoding_types, *filter_context_) : NULL; | 1033 ? Filter::Factory(encoding_types, *filter_context_) : NULL; |
| 1031 } | 1034 } |
| 1032 | 1035 |
| 1033 bool URLRequestHttpJob::IsSafeRedirect(const GURL& location) { | 1036 bool URLRequestHttpJob::IsSafeRedirect(const GURL& location) { |
| 1034 // HTTP is always safe. | 1037 // HTTP is always safe. |
| 1035 // TODO(pauljensen): Remove once crbug.com/146591 is fixed. | 1038 // TODO(pauljensen): Remove once crbug.com/146591 is fixed. |
| 1036 if (location.is_valid() && | 1039 if (location.is_valid() && |
| 1037 (location.scheme() == "http" || location.scheme() == "https")) { | 1040 (location.scheme() == "http" || location.scheme() == "https")) { |
| 1038 return true; | 1041 return true; |
| 1039 } | 1042 } |
| 1043 // Delegates may mark an URL as safe for redirection. | |
| 1044 if (allowed_unsafe_redirect_url_.is_valid()) { | |
| 1045 GURL::Replacements replacements; | |
| 1046 replacements.ClearRef(); | |
| 1047 if (allowed_unsafe_redirect_url_.ReplaceComponents(replacements) == | |
| 1048 location.ReplaceComponents(replacements)) { | |
| 1049 return true; | |
| 1050 } | |
| 1051 } | |
| 1040 // Query URLRequestJobFactory as to whether |location| would be safe to | 1052 // Query URLRequestJobFactory as to whether |location| would be safe to |
| 1041 // redirect to. | 1053 // redirect to. |
| 1042 return request_->context()->job_factory() && | 1054 return request_->context()->job_factory() && |
| 1043 request_->context()->job_factory()->IsSafeRedirectTarget(location); | 1055 request_->context()->job_factory()->IsSafeRedirectTarget(location); |
| 1044 } | 1056 } |
| 1045 | 1057 |
| 1046 bool URLRequestHttpJob::NeedsAuth() { | 1058 bool URLRequestHttpJob::NeedsAuth() { |
| 1047 int code = GetResponseCode(); | 1059 int code = GetResponseCode(); |
| 1048 if (code == -1) | 1060 if (code == -1) |
| 1049 return false; | 1061 return false; |
| (...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1466 return override_response_headers_.get() ? | 1478 return override_response_headers_.get() ? |
| 1467 override_response_headers_.get() : | 1479 override_response_headers_.get() : |
| 1468 transaction_->GetResponseInfo()->headers.get(); | 1480 transaction_->GetResponseInfo()->headers.get(); |
| 1469 } | 1481 } |
| 1470 | 1482 |
| 1471 void URLRequestHttpJob::NotifyURLRequestDestroyed() { | 1483 void URLRequestHttpJob::NotifyURLRequestDestroyed() { |
| 1472 awaiting_callback_ = false; | 1484 awaiting_callback_ = false; |
| 1473 } | 1485 } |
| 1474 | 1486 |
| 1475 } // namespace net | 1487 } // namespace net |
| OLD | NEW |