OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <algorithm> | 5 #include <algorithm> |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
9 #include "net/http/http_util.h" | 9 #include "net/http/http_util.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 "te", | 43 "te", |
44 "trailer", | 44 "trailer", |
45 "transfer-encoding", | 45 "transfer-encoding", |
46 "upgrade", | 46 "upgrade", |
47 "user-agent", | 47 "user-agent", |
48 "via", | 48 "via", |
49 }; | 49 }; |
50 for (size_t i = 0; i < arraysize(unsafe_headers); ++i) { | 50 for (size_t i = 0; i < arraysize(unsafe_headers); ++i) { |
51 EXPECT_FALSE(HttpUtil::IsSafeHeader(unsafe_headers[i])) | 51 EXPECT_FALSE(HttpUtil::IsSafeHeader(unsafe_headers[i])) |
52 << unsafe_headers[i]; | 52 << unsafe_headers[i]; |
53 EXPECT_FALSE(HttpUtil::IsSafeHeader(base::StringToUpperASCII(std::string( | 53 EXPECT_FALSE(HttpUtil::IsSafeHeader(StringToUpperASCII(std::string( |
54 unsafe_headers[i])))) << unsafe_headers[i]; | 54 unsafe_headers[i])))) << unsafe_headers[i]; |
55 } | 55 } |
56 static const char* safe_headers[] = { | 56 static const char* safe_headers[] = { |
57 "foo", | 57 "foo", |
58 "x-", | 58 "x-", |
59 "x-foo", | 59 "x-foo", |
60 "content-disposition", | 60 "content-disposition", |
61 "update", | 61 "update", |
62 "accept-charseta", | 62 "accept-charseta", |
63 "accept_charset", | 63 "accept_charset", |
(...skipping 24 matching lines...) Expand all Loading... |
88 "trailera", | 88 "trailera", |
89 "transfer-encodinga", | 89 "transfer-encodinga", |
90 "transfer_encoding", | 90 "transfer_encoding", |
91 "upgradea", | 91 "upgradea", |
92 "user-agenta", | 92 "user-agenta", |
93 "user_agent", | 93 "user_agent", |
94 "viaa", | 94 "viaa", |
95 }; | 95 }; |
96 for (size_t i = 0; i < arraysize(safe_headers); ++i) { | 96 for (size_t i = 0; i < arraysize(safe_headers); ++i) { |
97 EXPECT_TRUE(HttpUtil::IsSafeHeader(safe_headers[i])) << safe_headers[i]; | 97 EXPECT_TRUE(HttpUtil::IsSafeHeader(safe_headers[i])) << safe_headers[i]; |
98 EXPECT_TRUE(HttpUtil::IsSafeHeader(base::StringToUpperASCII(std::string( | 98 EXPECT_TRUE(HttpUtil::IsSafeHeader(StringToUpperASCII(std::string( |
99 safe_headers[i])))) << safe_headers[i]; | 99 safe_headers[i])))) << safe_headers[i]; |
100 } | 100 } |
101 } | 101 } |
102 | 102 |
103 TEST(HttpUtilTest, HasHeader) { | 103 TEST(HttpUtilTest, HasHeader) { |
104 static const struct { | 104 static const struct { |
105 const char* headers; | 105 const char* headers; |
106 const char* name; | 106 const char* name; |
107 bool expected_result; | 107 bool expected_result; |
108 } tests[] = { | 108 } tests[] = { |
(...skipping 955 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1064 TEST(HttpUtilTest, NameValuePairsIteratorMissingEndQuote) { | 1064 TEST(HttpUtilTest, NameValuePairsIteratorMissingEndQuote) { |
1065 std::string data = "name='value"; | 1065 std::string data = "name='value"; |
1066 HttpUtil::NameValuePairsIterator parser(data.begin(), data.end(), ';'); | 1066 HttpUtil::NameValuePairsIterator parser(data.begin(), data.end(), ';'); |
1067 EXPECT_TRUE(parser.valid()); | 1067 EXPECT_TRUE(parser.valid()); |
1068 | 1068 |
1069 ASSERT_NO_FATAL_FAILURE( | 1069 ASSERT_NO_FATAL_FAILURE( |
1070 CheckNextNameValuePair(&parser, true, true, "name", "value")); | 1070 CheckNextNameValuePair(&parser, true, true, "name", "value")); |
1071 ASSERT_NO_FATAL_FAILURE(CheckNextNameValuePair( | 1071 ASSERT_NO_FATAL_FAILURE(CheckNextNameValuePair( |
1072 &parser, false, true, std::string(), std::string())); | 1072 &parser, false, true, std::string(), std::string())); |
1073 } | 1073 } |
OLD | NEW |