| 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/http/http_stream_parser.h" | 5 #include "net/http/http_stream_parser.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| (...skipping 1083 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1094 if (response_->headers->IsChunkEncoded()) { | 1094 if (response_->headers->IsChunkEncoded()) { |
| 1095 chunked_decoder_.reset(new HttpChunkedDecoder()); | 1095 chunked_decoder_.reset(new HttpChunkedDecoder()); |
| 1096 } else { | 1096 } else { |
| 1097 response_body_length_ = response_->headers->GetContentLength(); | 1097 response_body_length_ = response_->headers->GetContentLength(); |
| 1098 // If response_body_length_ is still -1, then we have to wait | 1098 // If response_body_length_ is still -1, then we have to wait |
| 1099 // for the server to close the connection. | 1099 // for the server to close the connection. |
| 1100 } | 1100 } |
| 1101 } | 1101 } |
| 1102 } | 1102 } |
| 1103 | 1103 |
| 1104 UploadProgress HttpStreamParser::GetUploadProgress() const { | |
| 1105 if (!request_->upload_data_stream) | |
| 1106 return UploadProgress(); | |
| 1107 | |
| 1108 return UploadProgress(request_->upload_data_stream->position(), | |
| 1109 request_->upload_data_stream->size()); | |
| 1110 } | |
| 1111 | |
| 1112 bool HttpStreamParser::IsResponseBodyComplete() const { | 1104 bool HttpStreamParser::IsResponseBodyComplete() const { |
| 1113 if (chunked_decoder_.get()) | 1105 if (chunked_decoder_.get()) |
| 1114 return chunked_decoder_->reached_eof(); | 1106 return chunked_decoder_->reached_eof(); |
| 1115 if (response_body_length_ != -1) | 1107 if (response_body_length_ != -1) |
| 1116 return response_body_read_ >= response_body_length_; | 1108 return response_body_read_ >= response_body_length_; |
| 1117 | 1109 |
| 1118 return false; // Must read to EOF. | 1110 return false; // Must read to EOF. |
| 1119 } | 1111 } |
| 1120 | 1112 |
| 1121 bool HttpStreamParser::CanFindEndOfResponse() const { | 1113 bool HttpStreamParser::CanFindEndOfResponse() const { |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1229 UMA_HISTOGRAM_ENUMERATION("Net.HttpStatusLineStatus", status, | 1221 UMA_HISTOGRAM_ENUMERATION("Net.HttpStatusLineStatus", status, |
| 1230 HttpStatusLineValidator::STATUS_LINE_MAX); | 1222 HttpStatusLineValidator::STATUS_LINE_MAX); |
| 1231 } | 1223 } |
| 1232 | 1224 |
| 1233 bool HttpStreamParser::SendRequestBuffersEmpty() { | 1225 bool HttpStreamParser::SendRequestBuffersEmpty() { |
| 1234 return request_headers_ == nullptr && request_body_send_buf_ == nullptr && | 1226 return request_headers_ == nullptr && request_body_send_buf_ == nullptr && |
| 1235 request_body_send_buf_ == nullptr; | 1227 request_body_send_buf_ == nullptr; |
| 1236 } | 1228 } |
| 1237 | 1229 |
| 1238 } // namespace net | 1230 } // namespace net |
| OLD | NEW |