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 839 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
850 } | 850 } |
851 | 851 |
852 // Parse things as well as we can and let the caller decide what to do. | 852 // Parse things as well as we can and let the caller decide what to do. |
853 int end_offset; | 853 int end_offset; |
854 if (response_header_start_offset_ >= 0) { | 854 if (response_header_start_offset_ >= 0) { |
855 // The response looks to be a truncated set of HTTP headers. | 855 // The response looks to be a truncated set of HTTP headers. |
856 io_state_ = STATE_READ_BODY_COMPLETE; | 856 io_state_ = STATE_READ_BODY_COMPLETE; |
857 end_offset = read_buf_->offset(); | 857 end_offset = read_buf_->offset(); |
858 RecordHeaderParserEvent(HEADER_ALLOWED_TRUNCATED_HEADERS); | 858 RecordHeaderParserEvent(HEADER_ALLOWED_TRUNCATED_HEADERS); |
859 } else { | 859 } else { |
860 // The server is apparently returning a very short HTTP/0.9 response. | 860 // The response is apparently using HTTP/0.9. Treat the entire response |
861 // TODO(mmenke): Clean up remnants of HTTP/0.9 code once HTTP/0.9 removal | 861 // as the body. |
862 // successfully ships. | |
863 end_offset = 0; | 862 end_offset = 0; |
864 // Treat it as an error. | |
865 return ERR_INVALID_HTTP_RESPONSE; | |
866 } | 863 } |
867 int rv = ParseResponseHeaders(end_offset); | 864 int rv = ParseResponseHeaders(end_offset); |
868 if (rv < 0) | 865 if (rv < 0) |
869 return rv; | 866 return rv; |
870 return result; | 867 return result; |
871 } | 868 } |
872 | 869 |
873 if (result < 0) { | 870 if (result < 0) { |
874 io_state_ = STATE_DONE; | 871 io_state_ = STATE_DONE; |
875 return result; | 872 return result; |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
953 } | 950 } |
954 | 951 |
955 if (response_header_start_offset_ >= 0) { | 952 if (response_header_start_offset_ >= 0) { |
956 end_offset = HttpUtil::LocateEndOfHeaders(read_buf_->StartOfBuffer(), | 953 end_offset = HttpUtil::LocateEndOfHeaders(read_buf_->StartOfBuffer(), |
957 read_buf_->offset(), | 954 read_buf_->offset(), |
958 response_header_start_offset_); | 955 response_header_start_offset_); |
959 } else if (read_buf_->offset() >= 8) { | 956 } else if (read_buf_->offset() >= 8) { |
960 // Enough data to decide that this is an HTTP/0.9 response. | 957 // Enough data to decide that this is an HTTP/0.9 response. |
961 // 8 bytes = (4 bytes of junk) + "http".length() | 958 // 8 bytes = (4 bytes of junk) + "http".length() |
962 end_offset = 0; | 959 end_offset = 0; |
963 // Treat a an error. | |
964 return ERR_INVALID_HTTP_RESPONSE; | |
965 } | 960 } |
966 | 961 |
967 if (end_offset == -1) | 962 if (end_offset == -1) |
968 return -1; | 963 return -1; |
969 | 964 |
970 int rv = ParseResponseHeaders(end_offset); | 965 int rv = ParseResponseHeaders(end_offset); |
971 if (rv < 0) | 966 if (rv < 0) |
972 return rv; | 967 return rv; |
973 return end_offset; | 968 return end_offset; |
974 } | 969 } |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1222 UMA_HISTOGRAM_ENUMERATION("Net.HttpStatusLineStatus", status, | 1217 UMA_HISTOGRAM_ENUMERATION("Net.HttpStatusLineStatus", status, |
1223 HttpStatusLineValidator::STATUS_LINE_MAX); | 1218 HttpStatusLineValidator::STATUS_LINE_MAX); |
1224 } | 1219 } |
1225 | 1220 |
1226 bool HttpStreamParser::SendRequestBuffersEmpty() { | 1221 bool HttpStreamParser::SendRequestBuffersEmpty() { |
1227 return request_headers_ == nullptr && request_body_send_buf_ == nullptr && | 1222 return request_headers_ == nullptr && request_body_send_buf_ == nullptr && |
1228 request_body_send_buf_ == nullptr; | 1223 request_body_send_buf_ == nullptr; |
1229 } | 1224 } |
1230 | 1225 |
1231 } // namespace net | 1226 } // namespace net |
OLD | NEW |