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

Unified Diff: net/http/http_stream_parser_unittest.cc

Issue 1255123006: Revert of Net: Stop treating partial HTTP headers as a valid response. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 4 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') | 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 ec9368aaacc81e4bb163c4e1ba39dcae302bdb42..76f998a0e97a78d3c9db169712bbdc6a197961e1 100644
--- a/net/http/http_stream_parser_unittest.cc
+++ b/net/http/http_stream_parser_unittest.cc
@@ -605,32 +605,53 @@
MockWrite(SYNCHRONOUS, 0, "GET / HTTP/1.1\r\n\r\n"),
};
- 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");
-
- 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());
+ enum {
+ HTTP = 0,
+ HTTPS,
+ NUM_PROTOCOLS,
+ };
+
+ 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());
+ }
+ }
}
}
}
« no previous file with comments | « net/http/http_stream_parser.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698