diff options
author | abarth@chromium.org <abarth@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-31 01:00:49 +0000 |
---|---|---|
committer | abarth@chromium.org <abarth@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-31 01:00:49 +0000 |
commit | b1fd7195a16a473e8446b24701579a3347a31b3b (patch) | |
tree | c1f28b37482d154b78c5f87f6fc0790a0bf3125a /net/http/http_util_unittest.cc | |
parent | 5ae7f230fb22a9cb8f7f23432b251bbbfbc0bb73 (diff) | |
download | chromium_src-b1fd7195a16a473e8446b24701579a3347a31b3b.zip chromium_src-b1fd7195a16a473e8446b24701579a3347a31b3b.tar.gz chromium_src-b1fd7195a16a473e8446b24701579a3347a31b3b.tar.bz2 |
Delete net::GetHeaderParamValue
This function is a trap. It's a quick-and-dirty parser that has many nutty
quirks. There's only one caller left, and that callers should really be using
a Content-Type-specific parser anyway.
Review URL: http://codereview.chromium.org/9296005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@119790 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/http/http_util_unittest.cc')
-rw-r--r-- | net/http/http_util_unittest.cc | 87 |
1 files changed, 86 insertions, 1 deletions
diff --git a/net/http/http_util_unittest.cc b/net/http/http_util_unittest.cc index 7da4fc9..8293c80 100644 --- a/net/http/http_util_unittest.cc +++ b/net/http/http_util_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -632,6 +632,91 @@ TEST(HttpUtilTest, GenerateAcceptCharsetHeader) { 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; |