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

Unified Diff: net/http/http_util_unittest.cc

Issue 1166953002: Use net's response header parser for parsing multipart headers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address more comments Created 5 years, 6 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_util.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_util_unittest.cc
diff --git a/net/http/http_util_unittest.cc b/net/http/http_util_unittest.cc
index 71602844ad8d4054b08413c8d372a20ab83fc3d9..2619e3e8c14d272a93db7a5044311121bc55775d 100644
--- a/net/http/http_util_unittest.cc
+++ b/net/http/http_util_unittest.cc
@@ -265,12 +265,17 @@ TEST(HttpUtilTest, LocateEndOfHeaders) {
const char* const input;
int expected_result;
} tests[] = {
- { "foo\r\nbar\r\n\r\n", 12 },
- { "foo\nbar\n\n", 9 },
- { "foo\r\nbar\r\n\r\njunk", 12 },
- { "foo\nbar\n\njunk", 9 },
- { "foo\nbar\n\r\njunk", 10 },
- { "foo\nbar\r\n\njunk", 10 },
+ {"\r\n", -1},
+ {"\n", -1},
+ {"\r", -1},
+ {"foo", -1},
+ {"\r\n\r\n", 4},
+ {"foo\r\nbar\r\n\r\n", 12},
+ {"foo\nbar\n\n", 9},
+ {"foo\r\nbar\r\n\r\njunk", 12},
+ {"foo\nbar\n\njunk", 9},
+ {"foo\nbar\n\r\njunk", 10},
+ {"foo\nbar\r\n\njunk", 10},
};
for (size_t i = 0; i < arraysize(tests); ++i) {
int input_len = static_cast<int>(strlen(tests[i].input));
@@ -279,6 +284,29 @@ TEST(HttpUtilTest, LocateEndOfHeaders) {
}
}
+TEST(HttpUtilTest, LocateEndOfAdditionalHeaders) {
+ struct {
+ const char* const input;
+ int expected_result;
+ } tests[] = {
+ {"\r\n", 2},
+ {"\n", 1},
+ {"\r", -1},
+ {"foo", -1},
+ {"\r\n\r\n", 2},
+ {"foo\r\nbar\r\n\r\n", 12},
+ {"foo\nbar\n\n", 9},
+ {"foo\r\nbar\r\n\r\njunk", 12},
+ {"foo\nbar\n\njunk", 9},
+ {"foo\nbar\n\r\njunk", 10},
+ {"foo\nbar\r\n\njunk", 10},
+ };
+ for (size_t i = 0; i < arraysize(tests); ++i) {
+ int input_len = static_cast<int>(strlen(tests[i].input));
+ int eoh = HttpUtil::LocateEndOfAdditionalHeaders(tests[i].input, input_len);
+ EXPECT_EQ(tests[i].expected_result, eoh);
+ }
+}
TEST(HttpUtilTest, AssembleRawHeaders) {
struct {
const char* const input; // with '|' representing '\0'
« no previous file with comments | « net/http/http_util.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698