| 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.h" | 5 #include "net/url_request/url_request.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 349 | 349 |
| 350 net_log_.EndEvent(NetLogEventType::DELEGATE_INFO); | 350 net_log_.EndEvent(NetLogEventType::DELEGATE_INFO); |
| 351 blocked_by_.clear(); | 351 blocked_by_.clear(); |
| 352 } | 352 } |
| 353 | 353 |
| 354 UploadProgress URLRequest::GetUploadProgress() const { | 354 UploadProgress URLRequest::GetUploadProgress() const { |
| 355 if (!job_.get()) { | 355 if (!job_.get()) { |
| 356 // We haven't started or the request was cancelled | 356 // We haven't started or the request was cancelled |
| 357 return UploadProgress(); | 357 return UploadProgress(); |
| 358 } | 358 } |
| 359 |
| 359 if (final_upload_progress_.position()) { | 360 if (final_upload_progress_.position()) { |
| 360 // The first job completed and none of the subsequent series of | 361 // The first job completed and none of the subsequent series of |
| 361 // GETs when following redirects will upload anything, so we return the | 362 // GETs when following redirects will upload anything, so we return the |
| 362 // cached results from the initial job, the POST. | 363 // cached results from the initial job, the POST. |
| 363 return final_upload_progress_; | 364 return final_upload_progress_; |
| 364 } | 365 } |
| 365 return job_->GetUploadProgress(); | 366 |
| 367 if (upload_data_stream_) |
| 368 return upload_data_stream_->GetUploadProgress(); |
| 369 |
| 370 return UploadProgress(); |
| 366 } | 371 } |
| 367 | 372 |
| 368 void URLRequest::GetResponseHeaderByName(const string& name, | 373 void URLRequest::GetResponseHeaderByName(const string& name, |
| 369 string* value) const { | 374 string* value) const { |
| 370 DCHECK(value); | 375 DCHECK(value); |
| 371 if (response_info_.headers.get()) { | 376 if (response_info_.headers.get()) { |
| 372 response_info_.headers->GetNormalizedHeader(name, value); | 377 response_info_.headers->GetNormalizedHeader(name, value); |
| 373 } else { | 378 } else { |
| 374 value->clear(); | 379 value->clear(); |
| 375 } | 380 } |
| (...skipping 578 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 954 } | 959 } |
| 955 | 960 |
| 956 if (!redirect_info.new_url.is_valid()) | 961 if (!redirect_info.new_url.is_valid()) |
| 957 return ERR_INVALID_URL; | 962 return ERR_INVALID_URL; |
| 958 | 963 |
| 959 if (!job_->IsSafeRedirect(redirect_info.new_url)) { | 964 if (!job_->IsSafeRedirect(redirect_info.new_url)) { |
| 960 DVLOG(1) << "disallowing redirect: unsafe protocol"; | 965 DVLOG(1) << "disallowing redirect: unsafe protocol"; |
| 961 return ERR_UNSAFE_REDIRECT; | 966 return ERR_UNSAFE_REDIRECT; |
| 962 } | 967 } |
| 963 | 968 |
| 964 if (!final_upload_progress_.position()) | 969 if (!final_upload_progress_.position() && upload_data_stream_) |
| 965 final_upload_progress_ = job_->GetUploadProgress(); | 970 final_upload_progress_ = upload_data_stream_->GetUploadProgress(); |
| 966 PrepareToRestart(); | 971 PrepareToRestart(); |
| 967 | 972 |
| 968 if (redirect_info.new_method != method_) { | 973 if (redirect_info.new_method != method_) { |
| 969 // TODO(davidben): This logic still needs to be replicated at the consumers. | 974 // TODO(davidben): This logic still needs to be replicated at the consumers. |
| 970 if (method_ == "POST") { | 975 if (method_ == "POST") { |
| 971 // If being switched from POST, must remove Origin header. | 976 // If being switched from POST, must remove Origin header. |
| 972 // TODO(jww): This is Origin header removal is probably layering violation | 977 // TODO(jww): This is Origin header removal is probably layering violation |
| 973 // and | 978 // and |
| 974 // should be refactored into //content. See https://crbug.com/471397. | 979 // should be refactored into //content. See https://crbug.com/471397. |
| 975 extra_request_headers_.RemoveHeader(HttpRequestHeaders::kOrigin); | 980 extra_request_headers_.RemoveHeader(HttpRequestHeaders::kOrigin); |
| (...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1235 out->clear(); | 1240 out->clear(); |
| 1236 } | 1241 } |
| 1237 | 1242 |
| 1238 void URLRequest::set_status(URLRequestStatus status) { | 1243 void URLRequest::set_status(URLRequestStatus status) { |
| 1239 DCHECK(status_.is_io_pending() || status_.is_success() || | 1244 DCHECK(status_.is_io_pending() || status_.is_success() || |
| 1240 (!status.is_success() && !status.is_io_pending())); | 1245 (!status.is_success() && !status.is_io_pending())); |
| 1241 status_ = status; | 1246 status_ = status; |
| 1242 } | 1247 } |
| 1243 | 1248 |
| 1244 } // namespace net | 1249 } // namespace net |
| OLD | NEW |