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 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 if (final_upload_progress_.position()) { | 359 if (final_upload_progress_.position()) { |
360 // The first job completed and none of the subsequent series of | 360 // The first job completed and none of the subsequent series of |
361 // GETs when following redirects will upload anything, so we return the | 361 // GETs when following redirects will upload anything, so we return the |
362 // cached results from the initial job, the POST. | 362 // cached results from the initial job, the POST. |
363 return final_upload_progress_; | 363 return final_upload_progress_; |
364 } | 364 } |
365 return job_->GetUploadProgress(); | 365 if (upload_data_stream_) { |
366 return upload_data_stream_->GetUploadProgress(); | |
367 } | |
mmenke
2016/09/12 19:35:31
nit: Don't use braces on single-line if.
shivanisha
2016/09/14 20:40:25
done.
| |
368 return UploadProgress(); | |
366 } | 369 } |
367 | 370 |
368 void URLRequest::GetResponseHeaderByName(const string& name, | 371 void URLRequest::GetResponseHeaderByName(const string& name, |
369 string* value) const { | 372 string* value) const { |
370 DCHECK(value); | 373 DCHECK(value); |
371 if (response_info_.headers.get()) { | 374 if (response_info_.headers.get()) { |
372 response_info_.headers->GetNormalizedHeader(name, value); | 375 response_info_.headers->GetNormalizedHeader(name, value); |
373 } else { | 376 } else { |
374 value->clear(); | 377 value->clear(); |
375 } | 378 } |
(...skipping 578 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
954 } | 957 } |
955 | 958 |
956 if (!redirect_info.new_url.is_valid()) | 959 if (!redirect_info.new_url.is_valid()) |
957 return ERR_INVALID_URL; | 960 return ERR_INVALID_URL; |
958 | 961 |
959 if (!job_->IsSafeRedirect(redirect_info.new_url)) { | 962 if (!job_->IsSafeRedirect(redirect_info.new_url)) { |
960 DVLOG(1) << "disallowing redirect: unsafe protocol"; | 963 DVLOG(1) << "disallowing redirect: unsafe protocol"; |
961 return ERR_UNSAFE_REDIRECT; | 964 return ERR_UNSAFE_REDIRECT; |
962 } | 965 } |
963 | 966 |
964 if (!final_upload_progress_.position()) | 967 if (!final_upload_progress_.position() && upload_data_stream_) |
965 final_upload_progress_ = job_->GetUploadProgress(); | 968 final_upload_progress_ = upload_data_stream_->GetUploadProgress(); |
966 PrepareToRestart(); | 969 PrepareToRestart(); |
967 | 970 |
968 if (redirect_info.new_method != method_) { | 971 if (redirect_info.new_method != method_) { |
969 // TODO(davidben): This logic still needs to be replicated at the consumers. | 972 // TODO(davidben): This logic still needs to be replicated at the consumers. |
970 if (method_ == "POST") { | 973 if (method_ == "POST") { |
971 // If being switched from POST, must remove Origin header. | 974 // If being switched from POST, must remove Origin header. |
972 // TODO(jww): This is Origin header removal is probably layering violation | 975 // TODO(jww): This is Origin header removal is probably layering violation |
973 // and | 976 // and |
974 // should be refactored into //content. See https://crbug.com/471397. | 977 // should be refactored into //content. See https://crbug.com/471397. |
975 extra_request_headers_.RemoveHeader(HttpRequestHeaders::kOrigin); | 978 extra_request_headers_.RemoveHeader(HttpRequestHeaders::kOrigin); |
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1235 out->clear(); | 1238 out->clear(); |
1236 } | 1239 } |
1237 | 1240 |
1238 void URLRequest::set_status(URLRequestStatus status) { | 1241 void URLRequest::set_status(URLRequestStatus status) { |
1239 DCHECK(status_.is_io_pending() || status_.is_success() || | 1242 DCHECK(status_.is_io_pending() || status_.is_success() || |
1240 (!status.is_success() && !status.is_io_pending())); | 1243 (!status.is_success() && !status.is_io_pending())); |
1241 status_ = status; | 1244 status_ = status; |
1242 } | 1245 } |
1243 | 1246 |
1244 } // namespace net | 1247 } // namespace net |
OLD | NEW |