| 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 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 SpdyHeaderBlock block; | 195 SpdyHeaderBlock block; |
| 196 ASSERT_TRUE( | 196 ASSERT_TRUE( |
| 197 SpdyUtils::CopyAndValidateHeaders(*headers, &content_length, &block)); | 197 SpdyUtils::CopyAndValidateHeaders(*headers, &content_length, &block)); |
| 198 EXPECT_THAT( | 198 EXPECT_THAT( |
| 199 block, UnorderedElementsAre(Pair("foo", StringPiece("foovalue\0boo", 12)), | 199 block, UnorderedElementsAre(Pair("foo", StringPiece("foovalue\0boo", 12)), |
| 200 Pair("bar", "barvalue"), | 200 Pair("bar", "barvalue"), |
| 201 Pair("baz", StringPiece("\0buzz", 5)))); | 201 Pair("baz", StringPiece("\0buzz", 5)))); |
| 202 EXPECT_EQ(-1, content_length); | 202 EXPECT_EQ(-1, content_length); |
| 203 } | 203 } |
| 204 | 204 |
| 205 TEST(SpdyUtilsTest, CopyAndValidateHeadersMoreThanTwoValues) { |
| 206 auto headers = FromList({{"set-cookie", "value1"}, |
| 207 {"set-cookie", "value2"}, |
| 208 {"set-cookie", "value3"}}); |
| 209 int64_t content_length = -1; |
| 210 SpdyHeaderBlock block; |
| 211 ASSERT_TRUE( |
| 212 SpdyUtils::CopyAndValidateHeaders(*headers, &content_length, &block)); |
| 213 EXPECT_THAT(block, |
| 214 UnorderedElementsAre(Pair( |
| 215 "set-cookie", StringPiece("value1\0value2\0value3", 20)))); |
| 216 EXPECT_EQ(-1, content_length); |
| 217 } |
| 218 |
| 205 TEST(SpdyUtilsTest, CopyAndValidateHeadersCookie) { | 219 TEST(SpdyUtilsTest, CopyAndValidateHeadersCookie) { |
| 206 auto headers = FromList({{"foo", "foovalue"}, | 220 auto headers = FromList({{"foo", "foovalue"}, |
| 207 {"bar", "barvalue"}, | 221 {"bar", "barvalue"}, |
| 208 {"cookie", "value1"}, | 222 {"cookie", "value1"}, |
| 209 {"baz", ""}}); | 223 {"baz", ""}}); |
| 210 int64_t content_length = -1; | 224 int64_t content_length = -1; |
| 211 SpdyHeaderBlock block; | 225 SpdyHeaderBlock block; |
| 212 ASSERT_TRUE( | 226 ASSERT_TRUE( |
| 213 SpdyUtils::CopyAndValidateHeaders(*headers, &content_length, &block)); | 227 SpdyUtils::CopyAndValidateHeaders(*headers, &content_length, &block)); |
| 214 EXPECT_THAT(block, UnorderedElementsAre( | 228 EXPECT_THAT(block, UnorderedElementsAre( |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 275 headers[":scheme"] = "https"; | 289 headers[":scheme"] = "https"; |
| 276 EXPECT_FALSE(SpdyUtils::UrlIsValid(headers)); | 290 EXPECT_FALSE(SpdyUtils::UrlIsValid(headers)); |
| 277 headers[":authority"] = "www.google.com"; | 291 headers[":authority"] = "www.google.com"; |
| 278 EXPECT_FALSE(SpdyUtils::UrlIsValid(headers)); | 292 EXPECT_FALSE(SpdyUtils::UrlIsValid(headers)); |
| 279 headers[":path"] = "/index.html"; | 293 headers[":path"] = "/index.html"; |
| 280 EXPECT_TRUE(SpdyUtils::UrlIsValid(headers)); | 294 EXPECT_TRUE(SpdyUtils::UrlIsValid(headers)); |
| 281 } | 295 } |
| 282 | 296 |
| 283 } // namespace test | 297 } // namespace test |
| 284 } // namespace net | 298 } // namespace net |
| OLD | NEW |