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

Side by Side Diff: net/url_request/url_request_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: Address mmenke's comments 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
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_job.h" 5 #include "net/url_request/url_request_job.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/power_monitor/power_monitor.h" 10 #include "base/power_monitor/power_monitor.h"
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 151
152 std::string value; 152 std::string value;
153 if (!headers->IsRedirect(&value)) 153 if (!headers->IsRedirect(&value))
154 return false; 154 return false;
155 155
156 *location = request_->url().Resolve(value); 156 *location = request_->url().Resolve(value);
157 *http_status_code = headers->response_code(); 157 *http_status_code = headers->response_code();
158 return true; 158 return true;
159 } 159 }
160 160
161 bool URLRequestJob::IsRedirectFragmentModificationAllowed(
162 const GURL& location) const {
163 return true;
164 }
165
161 bool URLRequestJob::IsSafeRedirect(const GURL& location) { 166 bool URLRequestJob::IsSafeRedirect(const GURL& location) {
162 return true; 167 return true;
163 } 168 }
164 169
165 bool URLRequestJob::NeedsAuth() { 170 bool URLRequestJob::NeedsAuth() {
166 return false; 171 return false;
167 } 172 }
168 173
169 void URLRequestJob::GetAuthChallengeInfo( 174 void URLRequestJob::GetAuthChallengeInfo(
170 scoped_refptr<AuthChallengeInfo>* auth_info) { 175 scoped_refptr<AuthChallengeInfo>* auth_info) {
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 int http_status_code; 333 int http_status_code;
329 if (IsRedirectResponse(&new_location, &http_status_code)) { 334 if (IsRedirectResponse(&new_location, &http_status_code)) {
330 // Redirect response bodies are not read. Notify the transaction 335 // Redirect response bodies are not read. Notify the transaction
331 // so it does not treat being stopped as an error. 336 // so it does not treat being stopped as an error.
332 DoneReadingRedirectResponse(); 337 DoneReadingRedirectResponse();
333 338
334 const GURL& url = request_->url(); 339 const GURL& url = request_->url();
335 340
336 // Move the reference fragment of the old location to the new one if the 341 // Move the reference fragment of the old location to the new one if the
337 // new one has none. This duplicates mozilla's behavior. 342 // new one has none. This duplicates mozilla's behavior.
338 if (url.is_valid() && url.has_ref() && !new_location.has_ref()) { 343 if (url.is_valid() && url.has_ref() && !new_location.has_ref() &&
344 IsRedirectFragmentModificationAllowed(new_location)) {
339 GURL::Replacements replacements; 345 GURL::Replacements replacements;
340 // Reference the |ref| directly out of the original URL to avoid a 346 // Reference the |ref| directly out of the original URL to avoid a
341 // malloc. 347 // malloc.
342 replacements.SetRef(url.spec().data(), 348 replacements.SetRef(url.spec().data(),
343 url.parsed_for_possibly_invalid_spec().ref); 349 url.parsed_for_possibly_invalid_spec().ref);
344 new_location = new_location.ReplaceComponents(replacements); 350 new_location = new_location.ReplaceComponents(replacements);
345 } 351 }
346 352
347 bool defer_redirect = false; 353 bool defer_redirect = false;
348 request_->NotifyReceivedRedirect(new_location, &defer_redirect); 354 request_->NotifyReceivedRedirect(new_location, &defer_redirect);
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after
762 } 768 }
763 769
764 bool URLRequestJob::FilterHasData() { 770 bool URLRequestJob::FilterHasData() {
765 return filter_.get() && filter_->stream_data_len(); 771 return filter_.get() && filter_->stream_data_len();
766 } 772 }
767 773
768 void URLRequestJob::UpdatePacketReadTimes() { 774 void URLRequestJob::UpdatePacketReadTimes() {
769 } 775 }
770 776
771 } // namespace net 777 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698