| 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/string_util.h" | 8 #include "base/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" |
| 11 | 11 |
| 12 using net::HttpUtil; | 12 using net::HttpUtil; |
| 13 | 13 |
| 14 namespace { | 14 namespace { |
| 15 class HttpUtilTest : public testing::Test {}; | 15 class HttpUtilTest : public testing::Test {}; |
| 16 } | 16 } |
| 17 | 17 |
| 18 TEST(HttpUtilTest, IsSafeHeader) { | 18 TEST(HttpUtilTest, IsSafeHeader) { |
| 19 static const char* unsafe_headers[] = { | 19 static const char* unsafe_headers[] = { |
| 20 "sec-", | 20 "sec-", |
| 21 "sEc-", | 21 "sEc-", |
| 22 "sec-foo", | 22 "sec-foo", |
| 23 "sEc-FoO", | 23 "sEc-FoO", |
| 24 "proxy-", | 24 "proxy-", |
| 25 "pRoXy-", | 25 "pRoXy-", |
| 26 "proxy-foo", | 26 "proxy-foo", |
| 27 "pRoXy-FoO", | 27 "pRoXy-FoO", |
| 28 "accept-charset", | 28 "accept-charset", |
| 29 "accept-encoding", | 29 "accept-encoding", |
| 30 "access-control-request-headers", |
| 31 "access-control-request-method", |
| 30 "connection", | 32 "connection", |
| 31 "content-length", | 33 "content-length", |
| 32 "cookie", | 34 "cookie", |
| 33 "cookie2", | 35 "cookie2", |
| 34 "content-transfer-encoding", | 36 "content-transfer-encoding", |
| 35 "date", | 37 "date", |
| 36 "expect", | 38 "expect", |
| 37 "host", | 39 "host", |
| 38 "keep-alive", | 40 "keep-alive", |
| 39 "origin", | 41 "origin", |
| (...skipping 14 matching lines...) Expand all Loading... |
| 54 static const char* safe_headers[] = { | 56 static const char* safe_headers[] = { |
| 55 "foo", | 57 "foo", |
| 56 "x-", | 58 "x-", |
| 57 "x-foo", | 59 "x-foo", |
| 58 "content-disposition", | 60 "content-disposition", |
| 59 "update", | 61 "update", |
| 60 "accept-charseta", | 62 "accept-charseta", |
| 61 "accept_charset", | 63 "accept_charset", |
| 62 "accept-encodinga", | 64 "accept-encodinga", |
| 63 "accept_encoding", | 65 "accept_encoding", |
| 66 "access-control-request-headersa", |
| 67 "access-control-request-header", |
| 68 "access_control_request_header", |
| 69 "access-control-request-methoda", |
| 70 "access_control_request_method", |
| 64 "connectiona", | 71 "connectiona", |
| 65 "content-lengtha", | 72 "content-lengtha", |
| 66 "content_length", | 73 "content_length", |
| 67 "cookiea", | 74 "cookiea", |
| 68 "cookie2a", | 75 "cookie2a", |
| 69 "cookie3", | 76 "cookie3", |
| 70 "content-transfer-encodinga", | 77 "content-transfer-encodinga", |
| 71 "content_transfer_encoding", | 78 "content_transfer_encoding", |
| 72 "datea", | 79 "datea", |
| 73 "expecta", | 80 "expecta", |
| (...skipping 968 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1042 TEST(HttpUtilTest, NameValuePairsIteratorMissingEndQuote) { | 1049 TEST(HttpUtilTest, NameValuePairsIteratorMissingEndQuote) { |
| 1043 std::string data = "name='value"; | 1050 std::string data = "name='value"; |
| 1044 HttpUtil::NameValuePairsIterator parser(data.begin(), data.end(), ';'); | 1051 HttpUtil::NameValuePairsIterator parser(data.begin(), data.end(), ';'); |
| 1045 EXPECT_TRUE(parser.valid()); | 1052 EXPECT_TRUE(parser.valid()); |
| 1046 | 1053 |
| 1047 ASSERT_NO_FATAL_FAILURE( | 1054 ASSERT_NO_FATAL_FAILURE( |
| 1048 CheckNextNameValuePair(&parser, true, true, "name", "value")); | 1055 CheckNextNameValuePair(&parser, true, true, "name", "value")); |
| 1049 ASSERT_NO_FATAL_FAILURE( | 1056 ASSERT_NO_FATAL_FAILURE( |
| 1050 CheckNextNameValuePair(&parser, false, true, "", "")); | 1057 CheckNextNameValuePair(&parser, false, true, "", "")); |
| 1051 } | 1058 } |
| OLD | NEW |