| 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(StringToUpperASCII(std::string( | 53     EXPECT_FALSE(HttpUtil::IsSafeHeader( | 
| 54         unsafe_headers[i])))) << unsafe_headers[i]; | 54         base::StringToUpperASCII(std::string(unsafe_headers[i])))) | 
|  | 55         << unsafe_headers[i]; | 
| 55   } | 56   } | 
| 56   static const char* const safe_headers[] = { | 57   static const char* const safe_headers[] = { | 
| 57     "foo", | 58     "foo", | 
| 58     "x-", | 59     "x-", | 
| 59     "x-foo", | 60     "x-foo", | 
| 60     "content-disposition", | 61     "content-disposition", | 
| 61     "update", | 62     "update", | 
| 62     "accept-charseta", | 63     "accept-charseta", | 
| 63     "accept_charset", | 64     "accept_charset", | 
| 64     "accept-encodinga", | 65     "accept-encodinga", | 
| (...skipping 23 matching lines...) Expand all  Loading... | 
| 88     "trailera", | 89     "trailera", | 
| 89     "transfer-encodinga", | 90     "transfer-encodinga", | 
| 90     "transfer_encoding", | 91     "transfer_encoding", | 
| 91     "upgradea", | 92     "upgradea", | 
| 92     "user-agenta", | 93     "user-agenta", | 
| 93     "user_agent", | 94     "user_agent", | 
| 94     "viaa", | 95     "viaa", | 
| 95   }; | 96   }; | 
| 96   for (size_t i = 0; i < arraysize(safe_headers); ++i) { | 97   for (size_t i = 0; i < arraysize(safe_headers); ++i) { | 
| 97     EXPECT_TRUE(HttpUtil::IsSafeHeader(safe_headers[i])) << safe_headers[i]; | 98     EXPECT_TRUE(HttpUtil::IsSafeHeader(safe_headers[i])) << safe_headers[i]; | 
| 98     EXPECT_TRUE(HttpUtil::IsSafeHeader(StringToUpperASCII(std::string( | 99     EXPECT_TRUE(HttpUtil::IsSafeHeader( | 
| 99         safe_headers[i])))) << safe_headers[i]; | 100         base::StringToUpperASCII(std::string(safe_headers[i])))) | 
|  | 101         << safe_headers[i]; | 
| 100   } | 102   } | 
| 101 } | 103 } | 
| 102 | 104 | 
| 103 TEST(HttpUtilTest, HasHeader) { | 105 TEST(HttpUtilTest, HasHeader) { | 
| 104   static const struct { | 106   static const struct { | 
| 105     const char* const headers; | 107     const char* const headers; | 
| 106     const char* const name; | 108     const char* const name; | 
| 107     bool expected_result; | 109     bool expected_result; | 
| 108   } tests[] = { | 110   } tests[] = { | 
| 109     { "", "foo", false }, | 111     { "", "foo", false }, | 
| (...skipping 992 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1102   HttpUtil::NameValuePairsIterator parser(data.begin(), data.end(), ';'); | 1104   HttpUtil::NameValuePairsIterator parser(data.begin(), data.end(), ';'); | 
| 1103   EXPECT_TRUE(parser.valid()); | 1105   EXPECT_TRUE(parser.valid()); | 
| 1104 | 1106 | 
| 1105   ASSERT_NO_FATAL_FAILURE( | 1107   ASSERT_NO_FATAL_FAILURE( | 
| 1106       CheckNextNameValuePair(&parser, true, true, "name", "value")); | 1108       CheckNextNameValuePair(&parser, true, true, "name", "value")); | 
| 1107   ASSERT_NO_FATAL_FAILURE(CheckNextNameValuePair( | 1109   ASSERT_NO_FATAL_FAILURE(CheckNextNameValuePair( | 
| 1108       &parser, false, true, std::string(), std::string())); | 1110       &parser, false, true, std::string(), std::string())); | 
| 1109 } | 1111 } | 
| 1110 | 1112 | 
| 1111 }  // namespace net | 1113 }  // namespace net | 
| OLD | NEW | 
|---|