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_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 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
324 if (request_) | 324 if (request_) |
325 request_->OnHeadersComplete(); | 325 request_->OnHeadersComplete(); |
326 | 326 |
327 GURL new_location; | 327 GURL new_location; |
328 int http_status_code; | 328 int http_status_code; |
329 if (IsRedirectResponse(&new_location, &http_status_code)) { | 329 if (IsRedirectResponse(&new_location, &http_status_code)) { |
330 // Redirect response bodies are not read. Notify the transaction | 330 // Redirect response bodies are not read. Notify the transaction |
331 // so it does not treat being stopped as an error. | 331 // so it does not treat being stopped as an error. |
332 DoneReadingRedirectResponse(); | 332 DoneReadingRedirectResponse(); |
333 | 333 |
334 const GURL& url = request_->url(); | |
mmenke
2014/03/27 14:41:46
This breaks URLRequestRedirectJobs, I believe. Or
| |
335 | |
336 // Move the reference fragment of the old location to the new one if the | |
337 // new one has none. This duplicates mozilla's behavior. | |
338 if (url.is_valid() && url.has_ref() && !new_location.has_ref()) { | |
339 GURL::Replacements replacements; | |
340 // Reference the |ref| directly out of the original URL to avoid a | |
341 // malloc. | |
342 replacements.SetRef(url.spec().data(), | |
343 url.parsed_for_possibly_invalid_spec().ref); | |
344 new_location = new_location.ReplaceComponents(replacements); | |
345 } | |
346 | |
347 bool defer_redirect = false; | 334 bool defer_redirect = false; |
348 request_->NotifyReceivedRedirect(new_location, &defer_redirect); | 335 request_->NotifyReceivedRedirect(new_location, &defer_redirect); |
349 | 336 |
350 // Ensure that the request wasn't detached or destroyed in | 337 // Ensure that the request wasn't detached or destroyed in |
351 // NotifyReceivedRedirect | 338 // NotifyReceivedRedirect |
352 if (!request_ || !request_->has_delegate()) | 339 if (!request_ || !request_->has_delegate()) |
353 return; | 340 return; |
354 | 341 |
355 // If we were not cancelled, then maybe follow the redirect. | 342 // If we were not cancelled, then maybe follow the redirect. |
356 if (request_->status().is_success()) { | 343 if (request_->status().is_success()) { |
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
762 } | 749 } |
763 | 750 |
764 bool URLRequestJob::FilterHasData() { | 751 bool URLRequestJob::FilterHasData() { |
765 return filter_.get() && filter_->stream_data_len(); | 752 return filter_.get() && filter_->stream_data_len(); |
766 } | 753 } |
767 | 754 |
768 void URLRequestJob::UpdatePacketReadTimes() { | 755 void URLRequestJob::UpdatePacketReadTimes() { |
769 } | 756 } |
770 | 757 |
771 } // namespace net | 758 } // namespace net |
OLD | NEW |