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

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: 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_job.h ('k') | net/url_request/url_request_redirect_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_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::CopyFragmentOnRedirect(const GURL& location) const {
162 return true;
163 }
164
161 bool URLRequestJob::IsSafeRedirect(const GURL& location) { 165 bool URLRequestJob::IsSafeRedirect(const GURL& location) {
162 return true; 166 return true;
163 } 167 }
164 168
165 bool URLRequestJob::NeedsAuth() { 169 bool URLRequestJob::NeedsAuth() {
166 return false; 170 return false;
167 } 171 }
168 172
169 void URLRequestJob::GetAuthChallengeInfo( 173 void URLRequestJob::GetAuthChallengeInfo(
170 scoped_refptr<AuthChallengeInfo>* auth_info) { 174 scoped_refptr<AuthChallengeInfo>* auth_info) {
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 int http_status_code; 332 int http_status_code;
329 if (IsRedirectResponse(&new_location, &http_status_code)) { 333 if (IsRedirectResponse(&new_location, &http_status_code)) {
330 // Redirect response bodies are not read. Notify the transaction 334 // Redirect response bodies are not read. Notify the transaction
331 // so it does not treat being stopped as an error. 335 // so it does not treat being stopped as an error.
332 DoneReadingRedirectResponse(); 336 DoneReadingRedirectResponse();
333 337
334 const GURL& url = request_->url(); 338 const GURL& url = request_->url();
335 339
336 // Move the reference fragment of the old location to the new one if the 340 // Move the reference fragment of the old location to the new one if the
337 // new one has none. This duplicates mozilla's behavior. 341 // new one has none. This duplicates mozilla's behavior.
338 if (url.is_valid() && url.has_ref() && !new_location.has_ref()) { 342 if (url.is_valid() && url.has_ref() && !new_location.has_ref() &&
343 CopyFragmentOnRedirect(new_location)) {
339 GURL::Replacements replacements; 344 GURL::Replacements replacements;
340 // Reference the |ref| directly out of the original URL to avoid a 345 // Reference the |ref| directly out of the original URL to avoid a
341 // malloc. 346 // malloc.
342 replacements.SetRef(url.spec().data(), 347 replacements.SetRef(url.spec().data(),
343 url.parsed_for_possibly_invalid_spec().ref); 348 url.parsed_for_possibly_invalid_spec().ref);
344 new_location = new_location.ReplaceComponents(replacements); 349 new_location = new_location.ReplaceComponents(replacements);
345 } 350 }
346 351
347 bool defer_redirect = false; 352 bool defer_redirect = false;
348 request_->NotifyReceivedRedirect(new_location, &defer_redirect); 353 request_->NotifyReceivedRedirect(new_location, &defer_redirect);
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after
762 } 767 }
763 768
764 bool URLRequestJob::FilterHasData() { 769 bool URLRequestJob::FilterHasData() {
765 return filter_.get() && filter_->stream_data_len(); 770 return filter_.get() && filter_->stream_data_len();
766 } 771 }
767 772
768 void URLRequestJob::UpdatePacketReadTimes() { 773 void URLRequestJob::UpdatePacketReadTimes() {
769 } 774 }
770 775
771 } // namespace net 776 } // namespace net
OLDNEW
« no previous file with comments | « net/url_request/url_request_job.h ('k') | net/url_request/url_request_redirect_job.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698