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 <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/callback_helpers.h" | 10 #include "base/callback_helpers.h" |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
257 HttpResponseHeaders* headers = request_->response_headers(); | 257 HttpResponseHeaders* headers = request_->response_headers(); |
258 if (!headers) | 258 if (!headers) |
259 return false; | 259 return false; |
260 | 260 |
261 std::string value; | 261 std::string value; |
262 if (!headers->IsRedirect(&value)) | 262 if (!headers->IsRedirect(&value)) |
263 return false; | 263 return false; |
264 | 264 |
265 *location = request_->url().Resolve(value); | 265 *location = request_->url().Resolve(value); |
266 *http_status_code = headers->response_code(); | 266 *http_status_code = headers->response_code(); |
| 267 |
267 return true; | 268 return true; |
268 } | 269 } |
269 | 270 |
270 bool URLRequestJob::CopyFragmentOnRedirect(const GURL& location) const { | 271 bool URLRequestJob::CopyFragmentOnRedirect(const GURL& location) const { |
271 return true; | 272 return true; |
272 } | 273 } |
273 | 274 |
274 bool URLRequestJob::IsSafeRedirect(const GURL& location) { | 275 bool URLRequestJob::IsSafeRedirect(const GURL& location) { |
275 return true; | 276 return true; |
276 } | 277 } |
(...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
778 const GURL& url = request_->url(); | 779 const GURL& url = request_->url(); |
779 | 780 |
780 RedirectInfo redirect_info; | 781 RedirectInfo redirect_info; |
781 | 782 |
782 redirect_info.status_code = http_status_code; | 783 redirect_info.status_code = http_status_code; |
783 | 784 |
784 // The request method may change, depending on the status code. | 785 // The request method may change, depending on the status code. |
785 redirect_info.new_method = | 786 redirect_info.new_method = |
786 ComputeMethodForRedirect(request_->method(), http_status_code); | 787 ComputeMethodForRedirect(request_->method(), http_status_code); |
787 | 788 |
| 789 |
| 790 |
788 // Move the reference fragment of the old location to the new one if the | 791 // Move the reference fragment of the old location to the new one if the |
789 // new one has none. This duplicates mozilla's behavior. | 792 // new one has none. This duplicates mozilla's behavior. |
790 if (url.is_valid() && url.has_ref() && !location.has_ref() && | 793 if (url.is_valid() && url.has_ref() && !location.has_ref() && |
791 CopyFragmentOnRedirect(location)) { | 794 CopyFragmentOnRedirect(location)) { |
792 GURL::Replacements replacements; | 795 GURL::Replacements replacements; |
793 // Reference the |ref| directly out of the original URL to avoid a | 796 // Reference the |ref| directly out of the original URL to avoid a |
794 // malloc. | 797 // malloc. |
795 replacements.SetRef(url.spec().data(), | 798 replacements.SetRef(url.spec().data(), |
796 url.parsed_for_possibly_invalid_spec().ref); | 799 url.parsed_for_possibly_invalid_spec().ref); |
797 redirect_info.new_url = location.ReplaceComponents(replacements); | 800 redirect_info.new_url = location.ReplaceComponents(replacements); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
847 int64_t total_sent_bytes = GetTotalSentBytes(); | 850 int64_t total_sent_bytes = GetTotalSentBytes(); |
848 DCHECK_GE(total_sent_bytes, last_notified_total_sent_bytes_); | 851 DCHECK_GE(total_sent_bytes, last_notified_total_sent_bytes_); |
849 if (total_sent_bytes > last_notified_total_sent_bytes_) { | 852 if (total_sent_bytes > last_notified_total_sent_bytes_) { |
850 network_delegate_->NotifyNetworkBytesSent( | 853 network_delegate_->NotifyNetworkBytesSent( |
851 request_, total_sent_bytes - last_notified_total_sent_bytes_); | 854 request_, total_sent_bytes - last_notified_total_sent_bytes_); |
852 } | 855 } |
853 last_notified_total_sent_bytes_ = total_sent_bytes; | 856 last_notified_total_sent_bytes_ = total_sent_bytes; |
854 } | 857 } |
855 | 858 |
856 } // namespace net | 859 } // namespace net |
OLD | NEW |