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

Unified Diff: net/http/http_stream_parser_unittest.cc

Issue 1266713007: Net: Stop treating partial HTTP headers as a valid response. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix < 8-byte HTTP/0.9 responses over HTTPS Created 5 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
« net/http/http_stream_parser.cc ('K') | « net/http/http_stream_parser.cc ('k') | no next file » | 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 76f998a0e97a78d3c9db169712bbdc6a197961e1..ec9368aaacc81e4bb163c4e1ba39dcae302bdb42 100644
--- a/net/http/http_stream_parser_unittest.cc
+++ b/net/http/http_stream_parser_unittest.cc
@@ -605,53 +605,32 @@ TEST(HttpStreamParser, TruncatedHeaders) {
MockWrite(SYNCHRONOUS, 0, "GET / HTTP/1.1\r\n\r\n"),
};
- enum {
- HTTP = 0,
- HTTPS,
- NUM_PROTOCOLS,
davidben 2015/07/31 21:32:50 [Confirmed there are no other interesting HTTP vs
- };
+ for (size_t i = 0; i < arraysize(reads); i++) {
+ SCOPED_TRACE(i);
+ SequencedSocketData data(reads[i], 2, writes, arraysize(writes));
+ scoped_ptr<ClientSocketHandle> socket_handle(
+ CreateConnectedSocketHandle(&data));
+
+ HttpRequestInfo request_info;
+ request_info.url = GURL("http://localhost");
- for (size_t protocol = 0; protocol < NUM_PROTOCOLS; protocol++) {
- SCOPED_TRACE(protocol);
-
- for (size_t i = 0; i < arraysize(reads); i++) {
- SCOPED_TRACE(i);
- SequencedSocketData data(reads[i], 2, writes, arraysize(writes));
- scoped_ptr<ClientSocketHandle> socket_handle(
- CreateConnectedSocketHandle(&data));
-
- HttpRequestInfo request_info;
- request_info.method = "GET";
- if (protocol == HTTP) {
- request_info.url = GURL("http://localhost");
- } else {
- request_info.url = GURL("https://localhost");
- }
- request_info.load_flags = LOAD_NORMAL;
-
- scoped_refptr<GrowableIOBuffer> read_buffer(new GrowableIOBuffer);
- HttpStreamParser parser(
- socket_handle.get(), &request_info, read_buffer.get(), BoundNetLog());
-
- HttpRequestHeaders request_headers;
- HttpResponseInfo response_info;
- TestCompletionCallback callback;
- ASSERT_EQ(OK, parser.SendRequest("GET / HTTP/1.1\r\n", request_headers,
- &response_info, callback.callback()));
-
- int rv = parser.ReadResponseHeaders(callback.callback());
- if (i == arraysize(reads) - 1) {
- EXPECT_EQ(OK, rv);
- EXPECT_TRUE(response_info.headers.get());
- } else {
- if (protocol == HTTP) {
- EXPECT_EQ(ERR_CONNECTION_CLOSED, rv);
- EXPECT_TRUE(response_info.headers.get());
- } else {
- EXPECT_EQ(ERR_RESPONSE_HEADERS_TRUNCATED, rv);
- EXPECT_FALSE(response_info.headers.get());
- }
- }
+ scoped_refptr<GrowableIOBuffer> read_buffer(new GrowableIOBuffer);
+ HttpStreamParser parser(socket_handle.get(), &request_info,
+ read_buffer.get(), BoundNetLog());
+
+ HttpRequestHeaders request_headers;
+ HttpResponseInfo response_info;
+ TestCompletionCallback callback;
+ ASSERT_EQ(OK, parser.SendRequest("GET / HTTP/1.1\r\n", request_headers,
+ &response_info, callback.callback()));
+
+ int rv = parser.ReadResponseHeaders(callback.callback());
+ if (i == arraysize(reads) - 1) {
+ EXPECT_EQ(OK, rv);
+ EXPECT_TRUE(response_info.headers.get());
+ } else {
+ EXPECT_EQ(ERR_RESPONSE_HEADERS_TRUNCATED, rv);
+ EXPECT_FALSE(response_info.headers.get());
}
}
}
« net/http/http_stream_parser.cc ('K') | « net/http/http_stream_parser.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698