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 <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/base_switches.h" | 9 #include "base/base_switches.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 1109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1120 return nullptr; | 1120 return nullptr; |
1121 } | 1121 } |
1122 if (downstream == nullptr) | 1122 if (downstream == nullptr) |
1123 return nullptr; | 1123 return nullptr; |
1124 upstream = std::move(downstream); | 1124 upstream = std::move(downstream); |
1125 } | 1125 } |
1126 | 1126 |
1127 return upstream; | 1127 return upstream; |
1128 } | 1128 } |
1129 | 1129 |
1130 RedirectInfo URLRequestHttpJob::ComputeRedirectInfo(const GURL& location, | |
estark
2016/12/15 20:49:54
Why is this logic in URLRequestHttpJob instead of
| |
1131 int http_status_code) { | |
1132 // If |request|'s insecure request policy matches its URL, then upgrade it | |
1133 // from a non-secure protocol to a secure protocol (e.g. "http" => "https"). | |
1134 // See https://www.w3.org/TR/upgrade-insecure-requests/ for details. | |
1135 // | |
1136 // TODO(mkwst): HSTS is currently modeled as a redirect, which makes sense, | |
1137 // given the web-exposed behavior developers currently rely upon. At some | |
1138 // point, however, https://wicg.github.io/hsts-priming/ will change that | |
1139 // expectation. Once those changes are in place, it might make sense to | |
1140 // merge the HSTS logic from 'MaybeInternallyRedirect' into this function. | |
1141 if (request_->insecure_request_policy() == | |
1142 net::URLRequest::DO_NOT_UPGRADE_INSECURE_REQUESTS || | |
1143 location.SchemeIsCryptographic() || | |
1144 (request_->initiator() && | |
1145 request_->insecure_request_policy() == | |
1146 net::URLRequest::UPGRADE_SAME_HOST_INSECURE_REQUESTS && | |
1147 request_->initiator()->host() != location.host())) { | |
mmenke
2016/12/15 19:24:22
->host() => ->host_piece()? No need to create new
mmenke
2016/12/15 19:24:22
I think this would be clearer with the unusual cas
| |
1148 return URLRequestJob::ComputeRedirectInfo(location, http_status_code); | |
1149 } | |
1150 | |
1151 request_->net_log().AddEvent( | |
1152 NetLogEventType::URL_REQUEST_REWRITTEN, | |
1153 NetLog::StringCallback("reason", "Upgrade-Insecure-Requests")); | |
1154 | |
1155 DCHECK(location.SchemeIs(url::kHttpScheme) || | |
1156 location.SchemeIs(url::kWsScheme)); | |
1157 GURL::Replacements replacements; | |
1158 replacements.SetSchemeStr(location.SchemeIs(url::kHttpScheme) | |
1159 ? url::kHttpsScheme | |
1160 : url::kWssScheme); | |
1161 return URLRequestJob::ComputeRedirectInfo( | |
1162 location.ReplaceComponents(replacements), http_status_code); | |
1163 } | |
1164 | |
1130 bool URLRequestHttpJob::CopyFragmentOnRedirect(const GURL& location) const { | 1165 bool URLRequestHttpJob::CopyFragmentOnRedirect(const GURL& location) const { |
1131 // Allow modification of reference fragments by default, unless | 1166 // Allow modification of reference fragments by default, unless |
1132 // |allowed_unsafe_redirect_url_| is set and equal to the redirect URL. | 1167 // |allowed_unsafe_redirect_url_| is set and equal to the redirect URL. |
1133 // When this is the case, we assume that the network delegate has set the | 1168 // When this is the case, we assume that the network delegate has set the |
1134 // desired redirect URL (with or without fragment), so it must not be changed | 1169 // desired redirect URL (with or without fragment), so it must not be changed |
1135 // any more. | 1170 // any more. |
1136 return !allowed_unsafe_redirect_url_.is_valid() || | 1171 return !allowed_unsafe_redirect_url_.is_valid() || |
1137 allowed_unsafe_redirect_url_ != location; | 1172 allowed_unsafe_redirect_url_ != location; |
1138 } | 1173 } |
1139 | 1174 |
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1547 awaiting_callback_ = false; | 1582 awaiting_callback_ = false; |
1548 | 1583 |
1549 // Notify NetworkQualityEstimator. | 1584 // Notify NetworkQualityEstimator. |
1550 NetworkQualityEstimator* network_quality_estimator = | 1585 NetworkQualityEstimator* network_quality_estimator = |
1551 request()->context()->network_quality_estimator(); | 1586 request()->context()->network_quality_estimator(); |
1552 if (network_quality_estimator) | 1587 if (network_quality_estimator) |
1553 network_quality_estimator->NotifyURLRequestDestroyed(*request()); | 1588 network_quality_estimator->NotifyURLRequestDestroyed(*request()); |
1554 } | 1589 } |
1555 | 1590 |
1556 } // namespace net | 1591 } // namespace net |
OLD | NEW |