Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(64)

Side by Side Diff: net/url_request/url_request_http_job.cc

Issue 154473002: Support redirectUrl at onHeadersReceived in WebRequest / DWR API (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix WebRequestRulesRegistrySimpleTest.StageChecker test Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/url_request/url_request_http_job.h ('k') | net/url_request/url_request_test_util.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 794 matching lines...) Expand 10 before | Expand all | Expand 10 after
805 } 805 }
806 } 806 }
807 807
808 if (result == OK) { 808 if (result == OK) {
809 scoped_refptr<HttpResponseHeaders> headers = GetResponseHeaders(); 809 scoped_refptr<HttpResponseHeaders> headers = GetResponseHeaders();
810 if (network_delegate()) { 810 if (network_delegate()) {
811 // Note that |this| may not be deleted until 811 // Note that |this| may not be deleted until
812 // |on_headers_received_callback_| or 812 // |on_headers_received_callback_| or
813 // |NetworkDelegate::URLRequestDestroyed()| has been called. 813 // |NetworkDelegate::URLRequestDestroyed()| has been called.
814 OnCallToDelegate(); 814 OnCallToDelegate();
815 allowed_unsafe_redirect_url_ = GURL();
815 int error = network_delegate()->NotifyHeadersReceived( 816 int error = network_delegate()->NotifyHeadersReceived(
816 request_, 817 request_,
817 on_headers_received_callback_, 818 on_headers_received_callback_,
818 headers.get(), 819 headers.get(),
819 &override_response_headers_); 820 &override_response_headers_,
821 &allowed_unsafe_redirect_url_);
820 if (error != net::OK) { 822 if (error != net::OK) {
821 if (error == net::ERR_IO_PENDING) { 823 if (error == net::ERR_IO_PENDING) {
822 awaiting_callback_ = true; 824 awaiting_callback_ = true;
823 } else { 825 } else {
824 std::string source("delegate"); 826 std::string source("delegate");
825 request_->net_log().AddEvent(NetLog::TYPE_CANCELLED, 827 request_->net_log().AddEvent(NetLog::TYPE_CANCELLED,
826 NetLog::StringCallback("source", 828 NetLog::StringCallback("source",
827 &source)); 829 &source));
828 OnCallToDelegateComplete(); 830 OnCallToDelegateComplete();
829 NotifyStartError(URLRequestStatus(URLRequestStatus::FAILED, error)); 831 NotifyStartError(URLRequestStatus(URLRequestStatus::FAILED, error));
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
1037 ? Filter::Factory(encoding_types, *filter_context_) : NULL; 1039 ? Filter::Factory(encoding_types, *filter_context_) : NULL;
1038 } 1040 }
1039 1041
1040 bool URLRequestHttpJob::IsSafeRedirect(const GURL& location) { 1042 bool URLRequestHttpJob::IsSafeRedirect(const GURL& location) {
1041 // HTTP is always safe. 1043 // HTTP is always safe.
1042 // TODO(pauljensen): Remove once crbug.com/146591 is fixed. 1044 // TODO(pauljensen): Remove once crbug.com/146591 is fixed.
1043 if (location.is_valid() && 1045 if (location.is_valid() &&
1044 (location.scheme() == "http" || location.scheme() == "https")) { 1046 (location.scheme() == "http" || location.scheme() == "https")) {
1045 return true; 1047 return true;
1046 } 1048 }
1049 // Delegates may mark an URL as safe for redirection.
1050 if (allowed_unsafe_redirect_url_.is_valid()) {
1051 GURL::Replacements replacements;
1052 replacements.ClearRef();
1053 if (allowed_unsafe_redirect_url_.ReplaceComponents(replacements) ==
1054 location.ReplaceComponents(replacements)) {
1055 return true;
1056 }
1057 }
1047 // Query URLRequestJobFactory as to whether |location| would be safe to 1058 // Query URLRequestJobFactory as to whether |location| would be safe to
1048 // redirect to. 1059 // redirect to.
1049 return request_->context()->job_factory() && 1060 return request_->context()->job_factory() &&
1050 request_->context()->job_factory()->IsSafeRedirectTarget(location); 1061 request_->context()->job_factory()->IsSafeRedirectTarget(location);
1051 } 1062 }
1052 1063
1053 bool URLRequestHttpJob::NeedsAuth() { 1064 bool URLRequestHttpJob::NeedsAuth() {
1054 int code = GetResponseCode(); 1065 int code = GetResponseCode();
1055 if (code == -1) 1066 if (code == -1)
1056 return false; 1067 return false;
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after
1492 return override_response_headers_.get() ? 1503 return override_response_headers_.get() ?
1493 override_response_headers_.get() : 1504 override_response_headers_.get() :
1494 transaction_->GetResponseInfo()->headers.get(); 1505 transaction_->GetResponseInfo()->headers.get();
1495 } 1506 }
1496 1507
1497 void URLRequestHttpJob::NotifyURLRequestDestroyed() { 1508 void URLRequestHttpJob::NotifyURLRequestDestroyed() {
1498 awaiting_callback_ = false; 1509 awaiting_callback_ = false;
1499 } 1510 }
1500 1511
1501 } // namespace net 1512 } // namespace net
OLDNEW
« no previous file with comments | « net/url_request/url_request_http_job.h ('k') | net/url_request/url_request_test_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698