| Index: net/http/http_util_unittest.cc
|
| ===================================================================
|
| --- net/http/http_util_unittest.cc (revision 119592)
|
| +++ net/http/http_util_unittest.cc (working copy)
|
| @@ -632,6 +632,91 @@
|
| HttpUtil::GenerateAcceptCharsetHeader("EUC-JP"));
|
| }
|
|
|
| +// HttpResponseHeadersTest.GetMimeType also tests ParseContentType.
|
| +TEST(HttpUtilTest, ParseContentType) {
|
| + const struct {
|
| + const char* content_type;
|
| + const char* expected_mime_type;
|
| + const char* expected_charset;
|
| + const bool expected_had_charset;
|
| + const char* expected_boundary;
|
| + } tests[] = {
|
| + { "text/html; charset=utf-8",
|
| + "text/html",
|
| + "utf-8",
|
| + true,
|
| + ""
|
| + },
|
| + { "text/html; charset =utf-8",
|
| + "text/html",
|
| + "utf-8",
|
| + true,
|
| + ""
|
| + },
|
| + { "text/html; charset= utf-8",
|
| + "text/html",
|
| + "utf-8",
|
| + true,
|
| + ""
|
| + },
|
| + { "text/html; charset=utf-8 ",
|
| + "text/html",
|
| + "utf-8",
|
| + true,
|
| + ""
|
| + },
|
| + { "text/html; boundary=\"WebKit-ada-df-dsf-adsfadsfs\"",
|
| + "text/html",
|
| + "",
|
| + false,
|
| + "\"WebKit-ada-df-dsf-adsfadsfs\""
|
| + },
|
| + { "text/html; boundary =\"WebKit-ada-df-dsf-adsfadsfs\"",
|
| + "text/html",
|
| + "",
|
| + false,
|
| + "\"WebKit-ada-df-dsf-adsfadsfs\""
|
| + },
|
| + { "text/html; boundary= \"WebKit-ada-df-dsf-adsfadsfs\"",
|
| + "text/html",
|
| + "",
|
| + false,
|
| + "\"WebKit-ada-df-dsf-adsfadsfs\""
|
| + },
|
| + { "text/html; boundary= \"WebKit-ada-df-dsf-adsfadsfs\" ",
|
| + "text/html",
|
| + "",
|
| + false,
|
| + "\"WebKit-ada-df-dsf-adsfadsfs\""
|
| + },
|
| + { "text/html; boundary=\"WebKit-ada-df-dsf-adsfadsfs \"",
|
| + "text/html",
|
| + "",
|
| + false,
|
| + "\"WebKit-ada-df-dsf-adsfadsfs \""
|
| + },
|
| + { "text/html; boundary=WebKit-ada-df-dsf-adsfadsfs",
|
| + "text/html",
|
| + "",
|
| + false,
|
| + "WebKit-ada-df-dsf-adsfadsfs"
|
| + },
|
| + // TODO(abarth): Add more interesting test cases.
|
| + };
|
| + for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) {
|
| + std::string mime_type;
|
| + std::string charset;
|
| + bool had_charset = false;
|
| + std::string boundary;
|
| + net::HttpUtil::ParseContentType(tests[i].content_type, &mime_type,
|
| + &charset, &had_charset, &boundary);
|
| + EXPECT_EQ(tests[i].expected_mime_type, mime_type) << "i=" << i;
|
| + EXPECT_EQ(tests[i].expected_charset, charset) << "i=" << i;
|
| + EXPECT_EQ(tests[i].expected_had_charset, had_charset) << "i=" << i;
|
| + EXPECT_EQ(tests[i].expected_boundary, boundary) << "i=" << i;
|
| + }
|
| +}
|
| +
|
| TEST(HttpUtilTest, ParseRanges) {
|
| const struct {
|
| const char* headers;
|
|
|