Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1372)

Side by Side Diff: net/http/http_stream_parser.cc

Issue 2144803002: Remove HTTP/0.9 support from HttpStreamParser. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix websockets tests Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/http/http_network_transaction_unittest.cc ('k') | net/http/http_stream_parser_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 814 matching lines...) Expand 10 before | Expand all | Expand 10 after
825 } 825 }
826 826
827 // Parse things as well as we can and let the caller decide what to do. 827 // Parse things as well as we can and let the caller decide what to do.
828 int end_offset; 828 int end_offset;
829 if (response_header_start_offset_ >= 0) { 829 if (response_header_start_offset_ >= 0) {
830 // The response looks to be a truncated set of HTTP headers. 830 // The response looks to be a truncated set of HTTP headers.
831 io_state_ = STATE_READ_BODY_COMPLETE; 831 io_state_ = STATE_READ_BODY_COMPLETE;
832 end_offset = read_buf_->offset(); 832 end_offset = read_buf_->offset();
833 RecordHeaderParserEvent(HEADER_ALLOWED_TRUNCATED_HEADERS); 833 RecordHeaderParserEvent(HEADER_ALLOWED_TRUNCATED_HEADERS);
834 } else { 834 } else {
835 // The response is apparently using HTTP/0.9. Treat the entire response 835 // The server is apparently returning a very short HTTP/0.9 response.
836 // as the body. 836 // TODO(mmenke): Clean up remnants of HTTP/0.9 code once HTTP/0.9 removal
837 // successfully ships.
837 end_offset = 0; 838 end_offset = 0;
839 // Treat it as an error.
840 return ERR_INVALID_HTTP_RESPONSE;
838 } 841 }
839 int rv = ParseResponseHeaders(end_offset); 842 int rv = ParseResponseHeaders(end_offset);
840 if (rv < 0) 843 if (rv < 0)
841 return rv; 844 return rv;
842 return result; 845 return result;
843 } 846 }
844 847
845 if (result < 0) { 848 if (result < 0) {
846 io_state_ = STATE_DONE; 849 io_state_ = STATE_DONE;
847 return result; 850 return result;
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
925 } 928 }
926 929
927 if (response_header_start_offset_ >= 0) { 930 if (response_header_start_offset_ >= 0) {
928 end_offset = HttpUtil::LocateEndOfHeaders(read_buf_->StartOfBuffer(), 931 end_offset = HttpUtil::LocateEndOfHeaders(read_buf_->StartOfBuffer(),
929 read_buf_->offset(), 932 read_buf_->offset(),
930 response_header_start_offset_); 933 response_header_start_offset_);
931 } else if (read_buf_->offset() >= 8) { 934 } else if (read_buf_->offset() >= 8) {
932 // Enough data to decide that this is an HTTP/0.9 response. 935 // Enough data to decide that this is an HTTP/0.9 response.
933 // 8 bytes = (4 bytes of junk) + "http".length() 936 // 8 bytes = (4 bytes of junk) + "http".length()
934 end_offset = 0; 937 end_offset = 0;
938 // Treat a an error.
939 return ERR_INVALID_HTTP_RESPONSE;
935 } 940 }
936 941
937 if (end_offset == -1) 942 if (end_offset == -1)
938 return -1; 943 return -1;
939 944
940 int rv = ParseResponseHeaders(end_offset); 945 int rv = ParseResponseHeaders(end_offset);
941 if (rv < 0) 946 if (rv < 0)
942 return rv; 947 return rv;
943 return end_offset; 948 return end_offset;
944 } 949 }
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
1188 } 1193 }
1189 1194
1190 void HttpStreamParser::ValidateStatusLine(const std::string& status_line) { 1195 void HttpStreamParser::ValidateStatusLine(const std::string& status_line) {
1191 HttpStatusLineValidator::StatusLineStatus status = 1196 HttpStatusLineValidator::StatusLineStatus status =
1192 HttpStatusLineValidator::ValidateStatusLine(status_line); 1197 HttpStatusLineValidator::ValidateStatusLine(status_line);
1193 UMA_HISTOGRAM_ENUMERATION("Net.HttpStatusLineStatus", status, 1198 UMA_HISTOGRAM_ENUMERATION("Net.HttpStatusLineStatus", status,
1194 HttpStatusLineValidator::STATUS_LINE_MAX); 1199 HttpStatusLineValidator::STATUS_LINE_MAX);
1195 } 1200 }
1196 1201
1197 } // namespace net 1202 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_network_transaction_unittest.cc ('k') | net/http/http_stream_parser_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698