OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #include "net/quic/spdy_utils.h" | 4 #include "net/quic/spdy_utils.h" |
5 | 5 |
6 #include "base/macros.h" | 6 #include "base/macros.h" |
7 #include "base/strings/string_number_conversions.h" | 7 #include "base/strings/string_number_conversions.h" |
8 #include "base/strings/string_piece.h" | 8 #include "base/strings/string_piece.h" |
9 #include "net/test/gtest_util.h" | 9 #include "net/test/gtest_util.h" |
10 | 10 |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 UnorderedElementsAre(Pair("foo", "foovalue"), | 134 UnorderedElementsAre(Pair("foo", "foovalue"), |
135 Pair("bar", "barvalue"), Pair("baz", ""))); | 135 Pair("bar", "barvalue"), Pair("baz", ""))); |
136 EXPECT_EQ(-1, content_length); | 136 EXPECT_EQ(-1, content_length); |
137 } | 137 } |
138 | 138 |
139 TEST(SpdyUtilsTest, CopyAndValidateHeadersEmptyName) { | 139 TEST(SpdyUtilsTest, CopyAndValidateHeadersEmptyName) { |
140 auto headers = FromList({{"foo", "foovalue"}, {"", "barvalue"}, {"baz", ""}}); | 140 auto headers = FromList({{"foo", "foovalue"}, {"", "barvalue"}, {"baz", ""}}); |
141 int64_t content_length = -1; | 141 int64_t content_length = -1; |
142 SpdyHeaderBlock block; | 142 SpdyHeaderBlock block; |
143 ASSERT_FALSE( | 143 ASSERT_FALSE( |
| 144 SpdyUtils::CopyAndValidateHeaders(*headers, &content_length, &block)); |
| 145 } |
| 146 |
| 147 TEST(SpdyUtilsTest, CopyAndValidateHeadersUpperCaseName) { |
| 148 auto headers = |
| 149 FromList({{"foo", "foovalue"}, {"bar", "barvalue"}, {"bAz", ""}}); |
| 150 int64_t content_length = -1; |
| 151 SpdyHeaderBlock block; |
| 152 ASSERT_FALSE( |
144 SpdyUtils::CopyAndValidateHeaders(*headers, &content_length, &block)); | 153 SpdyUtils::CopyAndValidateHeaders(*headers, &content_length, &block)); |
145 } | 154 } |
146 | 155 |
147 TEST(SpdyUtilsTest, CopyAndValidateHeadersMultipleContentLengths) { | 156 TEST(SpdyUtilsTest, CopyAndValidateHeadersMultipleContentLengths) { |
148 auto headers = FromList({{"content-length", "9"}, | 157 auto headers = FromList({{"content-length", "9"}, |
149 {"foo", "foovalue"}, | 158 {"foo", "foovalue"}, |
150 {"content-length", "9"}, | 159 {"content-length", "9"}, |
151 {"bar", "barvalue"}, | 160 {"bar", "barvalue"}, |
152 {"baz", ""}}); | 161 {"baz", ""}}); |
153 int64_t content_length = -1; | 162 int64_t content_length = -1; |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
266 headers[":scheme"] = "https"; | 275 headers[":scheme"] = "https"; |
267 EXPECT_FALSE(SpdyUtils::UrlIsValid(headers)); | 276 EXPECT_FALSE(SpdyUtils::UrlIsValid(headers)); |
268 headers[":authority"] = "www.google.com"; | 277 headers[":authority"] = "www.google.com"; |
269 EXPECT_FALSE(SpdyUtils::UrlIsValid(headers)); | 278 EXPECT_FALSE(SpdyUtils::UrlIsValid(headers)); |
270 headers[":path"] = "/index.html"; | 279 headers[":path"] = "/index.html"; |
271 EXPECT_TRUE(SpdyUtils::UrlIsValid(headers)); | 280 EXPECT_TRUE(SpdyUtils::UrlIsValid(headers)); |
272 } | 281 } |
273 | 282 |
274 } // namespace test | 283 } // namespace test |
275 } // namespace net | 284 } // namespace net |
OLD | NEW |