| 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 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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)); | 144 SpdyUtils::CopyAndValidateHeaders(*headers, &content_length, &block)); |
| 145 } | 145 } |
| 146 | 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( | |
| 153 SpdyUtils::CopyAndValidateHeaders(*headers, &content_length, &block)); | |
| 154 } | |
| 155 | |
| 156 TEST(SpdyUtilsTest, CopyAndValidateHeadersMultipleContentLengths) { | 147 TEST(SpdyUtilsTest, CopyAndValidateHeadersMultipleContentLengths) { |
| 157 auto headers = FromList({{"content-length", "9"}, | 148 auto headers = FromList({{"content-length", "9"}, |
| 158 {"foo", "foovalue"}, | 149 {"foo", "foovalue"}, |
| 159 {"content-length", "9"}, | 150 {"content-length", "9"}, |
| 160 {"bar", "barvalue"}, | 151 {"bar", "barvalue"}, |
| 161 {"baz", ""}}); | 152 {"baz", ""}}); |
| 162 int64_t content_length = -1; | 153 int64_t content_length = -1; |
| 163 SpdyHeaderBlock block; | 154 SpdyHeaderBlock block; |
| 164 ASSERT_TRUE( | 155 ASSERT_TRUE( |
| 165 SpdyUtils::CopyAndValidateHeaders(*headers, &content_length, &block)); | 156 SpdyUtils::CopyAndValidateHeaders(*headers, &content_length, &block)); |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 289 headers[":scheme"] = "https"; | 280 headers[":scheme"] = "https"; |
| 290 EXPECT_FALSE(SpdyUtils::UrlIsValid(headers)); | 281 EXPECT_FALSE(SpdyUtils::UrlIsValid(headers)); |
| 291 headers[":authority"] = "www.google.com"; | 282 headers[":authority"] = "www.google.com"; |
| 292 EXPECT_FALSE(SpdyUtils::UrlIsValid(headers)); | 283 EXPECT_FALSE(SpdyUtils::UrlIsValid(headers)); |
| 293 headers[":path"] = "/index.html"; | 284 headers[":path"] = "/index.html"; |
| 294 EXPECT_TRUE(SpdyUtils::UrlIsValid(headers)); | 285 EXPECT_TRUE(SpdyUtils::UrlIsValid(headers)); |
| 295 } | 286 } |
| 296 | 287 |
| 297 } // namespace test | 288 } // namespace test |
| 298 } // namespace net | 289 } // namespace net |
| OLD | NEW |