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

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

Issue 212543005: Do not copy reference fragments for overridden redirects. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 6 years, 8 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_job.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 1016 matching lines...) Expand 10 before | Expand all | Expand 10 after
1027 // Even if encoding types are empty, there is a chance that we need to add 1027 // Even if encoding types are empty, there is a chance that we need to add
1028 // some decoding, as some proxies strip encoding completely. In such cases, 1028 // some decoding, as some proxies strip encoding completely. In such cases,
1029 // we may need to add (for example) SDCH filtering (when the context suggests 1029 // we may need to add (for example) SDCH filtering (when the context suggests
1030 // it is appropriate). 1030 // it is appropriate).
1031 Filter::FixupEncodingTypes(*filter_context_, &encoding_types); 1031 Filter::FixupEncodingTypes(*filter_context_, &encoding_types);
1032 1032
1033 return !encoding_types.empty() 1033 return !encoding_types.empty()
1034 ? Filter::Factory(encoding_types, *filter_context_) : NULL; 1034 ? Filter::Factory(encoding_types, *filter_context_) : NULL;
1035 } 1035 }
1036 1036
1037 bool URLRequestHttpJob::CopyFragmentOnRedirect(const GURL& location) const {
1038 // Allow modification of reference fragments by default, unless
1039 // |allowed_unsafe_redirect_url_| is set and equal to the redirect URL.
1040 // When this is the case, we assume that the network delegate has set the
1041 // desired redirect URL (with or without fragment), so it must not be changed
1042 // any more.
1043 return !allowed_unsafe_redirect_url_.is_valid() ||
1044 allowed_unsafe_redirect_url_ != location;
1045 }
1046
1037 bool URLRequestHttpJob::IsSafeRedirect(const GURL& location) { 1047 bool URLRequestHttpJob::IsSafeRedirect(const GURL& location) {
1038 // HTTP is always safe. 1048 // HTTP is always safe.
1039 // TODO(pauljensen): Remove once crbug.com/146591 is fixed. 1049 // TODO(pauljensen): Remove once crbug.com/146591 is fixed.
1040 if (location.is_valid() && 1050 if (location.is_valid() &&
1041 (location.scheme() == "http" || location.scheme() == "https")) { 1051 (location.scheme() == "http" || location.scheme() == "https")) {
1042 return true; 1052 return true;
1043 } 1053 }
1044 // Delegates may mark an URL as safe for redirection. 1054 // Delegates may mark a URL as safe for redirection.
1045 if (allowed_unsafe_redirect_url_.is_valid()) { 1055 if (allowed_unsafe_redirect_url_.is_valid() &&
1046 GURL::Replacements replacements; 1056 allowed_unsafe_redirect_url_ == location) {
1047 replacements.ClearRef(); 1057 return true;
1048 if (allowed_unsafe_redirect_url_.ReplaceComponents(replacements) ==
1049 location.ReplaceComponents(replacements)) {
1050 return true;
1051 }
1052 } 1058 }
1053 // Query URLRequestJobFactory as to whether |location| would be safe to 1059 // Query URLRequestJobFactory as to whether |location| would be safe to
1054 // redirect to. 1060 // redirect to.
1055 return request_->context()->job_factory() && 1061 return request_->context()->job_factory() &&
1056 request_->context()->job_factory()->IsSafeRedirectTarget(location); 1062 request_->context()->job_factory()->IsSafeRedirectTarget(location);
1057 } 1063 }
1058 1064
1059 bool URLRequestHttpJob::NeedsAuth() { 1065 bool URLRequestHttpJob::NeedsAuth() {
1060 int code = GetResponseCode(); 1066 int code = GetResponseCode();
1061 if (code == -1) 1067 if (code == -1)
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after
1498 return override_response_headers_.get() ? 1504 return override_response_headers_.get() ?
1499 override_response_headers_.get() : 1505 override_response_headers_.get() :
1500 transaction_->GetResponseInfo()->headers.get(); 1506 transaction_->GetResponseInfo()->headers.get();
1501 } 1507 }
1502 1508
1503 void URLRequestHttpJob::NotifyURLRequestDestroyed() { 1509 void URLRequestHttpJob::NotifyURLRequestDestroyed() {
1504 awaiting_callback_ = false; 1510 awaiting_callback_ = false;
1505 } 1511 }
1506 1512
1507 } // namespace net 1513 } // namespace net
OLDNEW
« no previous file with comments | « net/url_request/url_request_http_job.h ('k') | net/url_request/url_request_job.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698