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

Unified Diff: net/http/http_stream_parser_unittest.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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/http/http_stream_parser.cc ('k') | net/url_request/url_request_http_job_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/http/http_stream_parser_unittest.cc
diff --git a/net/http/http_stream_parser_unittest.cc b/net/http/http_stream_parser_unittest.cc
index f72cd5f7d5e1fffa05fae5947660cb431adad9b6..911f846c5779c870601a1bbd652abd0757cd732b 100644
--- a/net/http/http_stream_parser_unittest.cc
+++ b/net/http/http_stream_parser_unittest.cc
@@ -1127,21 +1127,36 @@ class SimpleGetRunner {
int sequence_number_;
};
-// Test that HTTP/0.9 response size is correctly calculated.
+// Test that HTTP/0.9 response correctly results in an error.
TEST(HttpStreamParser, ReceivedBytesNoHeaders) {
- std::string response = "hello\r\nworld\r\n";
+ MockWrite writes[] = {
+ MockWrite(SYNCHRONOUS, 0, "GET / HTTP/1.1\r\n\r\n"),
+ };
- SimpleGetRunner get_runner;
- get_runner.AddRead(response);
- get_runner.SetupParserAndSendRequest();
- get_runner.ReadHeaders();
- EXPECT_EQ(0, get_runner.parser()->received_bytes());
- int response_size = response.size();
- int read_lengths[] = {response_size, 0};
- get_runner.ReadBody(response_size, read_lengths);
- EXPECT_EQ(response_size, get_runner.parser()->received_bytes());
- EXPECT_EQ(HttpResponseInfo::CONNECTION_INFO_HTTP0_9,
- get_runner.response_info()->connection_info);
+ MockRead reads[] = {
+ MockRead(SYNCHRONOUS, 1, "hello\r\nworld\r\n"),
+ MockRead(SYNCHRONOUS, OK, 2),
+ };
+
+ SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes));
+ std::unique_ptr<ClientSocketHandle> socket_handle =
+ CreateConnectedSocketHandle(&data);
+
+ HttpRequestInfo request;
+ request.method = "GET";
+ request.url = GURL("http://localhost");
+
+ HttpStreamParser parser(socket_handle.get(), &request, new GrowableIOBuffer(),
+ BoundNetLog());
+
+ HttpRequestHeaders headers;
+ HttpResponseInfo response;
+ TestCompletionCallback callback;
+ int result = parser.SendRequest("GET / HTTP/1.1\r\n", headers, &response,
+ callback.callback());
+ EXPECT_THAT(callback.GetResult(result), IsOk());
+ result = parser.ReadResponseHeaders(callback.callback());
+ EXPECT_THAT(callback.GetResult(result), IsError(ERR_INVALID_HTTP_RESPONSE));
}
// Test basic case where there is no keep-alive or extra data from the socket,
« no previous file with comments | « net/http/http_stream_parser.cc ('k') | net/url_request/url_request_http_job_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698