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.h" | 5 #include "net/url_request/url_request.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
(...skipping 603 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
614 job_->SetPriority(priority_); | 614 job_->SetPriority(priority_); |
615 | 615 |
616 if (upload_data_stream_.get()) | 616 if (upload_data_stream_.get()) |
617 job_->SetUpload(upload_data_stream_.get()); | 617 job_->SetUpload(upload_data_stream_.get()); |
618 | 618 |
619 is_pending_ = true; | 619 is_pending_ = true; |
620 is_redirecting_ = false; | 620 is_redirecting_ = false; |
621 | 621 |
622 response_info_.was_cached = false; | 622 response_info_.was_cached = false; |
623 | 623 |
624 if (GURL(referrer_) != URLRequestJob::ComputeReferrerForRedirect( | 624 if (referrer_ != URLRequestJob::ComputeReferrerForRedirect(referrer_policy_, r
eferrer_, url())) { |
625 referrer_policy_, referrer_, url())) { | |
626 if (!network_delegate_ || | 625 if (!network_delegate_ || |
627 !network_delegate_->CancelURLRequestWithPolicyViolatingReferrerHeader( | 626 !network_delegate_->CancelURLRequestWithPolicyViolatingReferrerHeader( |
628 *this, url(), GURL(referrer_))) { | 627 *this, url(), GURL(referrer_))) { |
629 referrer_.clear(); | 628 referrer_.clear(); |
630 } else { | 629 } else { |
631 // We need to clear the referrer anyway to avoid an infinite recursion | 630 // We need to clear the referrer anyway to avoid an infinite recursion |
632 // when starting the error job. | 631 // when starting the error job. |
633 referrer_.clear(); | 632 referrer_.clear(); |
634 std::string source("delegate"); | 633 std::string source("delegate"); |
635 net_log_.AddEvent(NetLog::TYPE_CANCELLED, | 634 net_log_.AddEvent(NetLog::TYPE_CANCELLED, |
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
943 // (https://fetch.spec.whatwg.org/#concept-http-fetch), it states that on | 942 // (https://fetch.spec.whatwg.org/#concept-http-fetch), it states that on |
944 // cross-origin 301, 302, 303, 307, and 308 redirects, the user agent should | 943 // cross-origin 301, 302, 303, 307, and 308 redirects, the user agent should |
945 // set the request's origin to an "opaque identifier," which serializes to | 944 // set the request's origin to an "opaque identifier," which serializes to |
946 // "null." This matches Firefox and IE behavior, although it supercedes the | 945 // "null." This matches Firefox and IE behavior, although it supercedes the |
947 // suggested behavior in RFC 6454, "The Web Origin Concept." | 946 // suggested behavior in RFC 6454, "The Web Origin Concept." |
948 // | 947 // |
949 // See also https://crbug.com/465517. | 948 // See also https://crbug.com/465517. |
950 // | 949 // |
951 // TODO(jww): This is probably layering violation and should be refactored | 950 // TODO(jww): This is probably layering violation and should be refactored |
952 // into //content. See https://crbug.com/471397. | 951 // into //content. See https://crbug.com/471397. |
953 if (redirect_info.new_url.GetOrigin() != url().GetOrigin() && | 952 if (url::Origin(redirect_info.new_url) != url::Origin(url()) && |
954 extra_request_headers_.HasHeader(HttpRequestHeaders::kOrigin)) { | 953 extra_request_headers_.HasHeader(HttpRequestHeaders::kOrigin)) { |
955 extra_request_headers_.SetHeader(HttpRequestHeaders::kOrigin, | 954 extra_request_headers_.SetHeader(HttpRequestHeaders::kOrigin, |
956 url::Origin().string()); | 955 url::Origin().serialize()); |
957 } | 956 } |
958 | 957 |
959 referrer_ = redirect_info.new_referrer; | 958 referrer_ = redirect_info.new_referrer; |
960 first_party_for_cookies_ = redirect_info.new_first_party_for_cookies; | 959 first_party_for_cookies_ = redirect_info.new_first_party_for_cookies; |
961 | 960 |
962 url_chain_.push_back(redirect_info.new_url); | 961 url_chain_.push_back(redirect_info.new_url); |
963 --redirect_limit_; | 962 --redirect_limit_; |
964 | 963 |
965 Start(); | 964 Start(); |
966 return OK; | 965 return OK; |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1190 } | 1189 } |
1191 | 1190 |
1192 void URLRequest::GetConnectionAttempts(ConnectionAttempts* out) const { | 1191 void URLRequest::GetConnectionAttempts(ConnectionAttempts* out) const { |
1193 if (job_) | 1192 if (job_) |
1194 job_->GetConnectionAttempts(out); | 1193 job_->GetConnectionAttempts(out); |
1195 else | 1194 else |
1196 out->clear(); | 1195 out->clear(); |
1197 } | 1196 } |
1198 | 1197 |
1199 } // namespace net | 1198 } // namespace net |
OLD | NEW |