| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "net/http/http_request_info.h" | 7 #include "net/http/http_request_info.h" |
| 8 #include "net/http/http_response_headers.h" | 8 #include "net/http/http_response_headers.h" |
| 9 #include "net/http/http_vary_data.h" | 9 #include "net/http/http_vary_data.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 // All of these responses should result in an invalid vary data object. | 34 // All of these responses should result in an invalid vary data object. |
| 35 const char* kTestResponses[] = { | 35 const char* kTestResponses[] = { |
| 36 "HTTP/1.1 200 OK\n\n", | 36 "HTTP/1.1 200 OK\n\n", |
| 37 "HTTP/1.1 200 OK\nVary: *\n\n", | 37 "HTTP/1.1 200 OK\nVary: *\n\n", |
| 38 "HTTP/1.1 200 OK\nVary: cookie, *, bar\n\n", | 38 "HTTP/1.1 200 OK\nVary: cookie, *, bar\n\n", |
| 39 "HTTP/1.1 200 OK\nVary: cookie\nFoo: 1\nVary: *\n\n", | 39 "HTTP/1.1 200 OK\nVary: cookie\nFoo: 1\nVary: *\n\n", |
| 40 }; | 40 }; |
| 41 | 41 |
| 42 for (size_t i = 0; i < arraysize(kTestResponses); ++i) { | 42 for (size_t i = 0; i < arraysize(kTestResponses); ++i) { |
| 43 TestTransaction t; | 43 TestTransaction t; |
| 44 t.Init("", kTestResponses[i]); | 44 t.Init(std::string(), kTestResponses[i]); |
| 45 | 45 |
| 46 net::HttpVaryData v; | 46 net::HttpVaryData v; |
| 47 EXPECT_FALSE(v.is_valid()); | 47 EXPECT_FALSE(v.is_valid()); |
| 48 EXPECT_FALSE(v.Init(t.request, *t.response)); | 48 EXPECT_FALSE(v.Init(t.request, *t.response)); |
| 49 EXPECT_FALSE(v.is_valid()); | 49 EXPECT_FALSE(v.is_valid()); |
| 50 } | 50 } |
| 51 } | 51 } |
| 52 | 52 |
| 53 TEST(HttpVaryDataTest, MultipleInit) { | 53 TEST(HttpVaryDataTest, MultipleInit) { |
| 54 net::HttpVaryData v; | 54 net::HttpVaryData v; |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 a.Init("Cookie: 1", "HTTP/1.1 301 Moved\nLocation: x\nVary: coOkie\n\n"); | 138 a.Init("Cookie: 1", "HTTP/1.1 301 Moved\nLocation: x\nVary: coOkie\n\n"); |
| 139 | 139 |
| 140 TestTransaction b; | 140 TestTransaction b; |
| 141 b.Init("Cookie: 2", "HTTP/1.1 301 Moved\nLocation: x\nVary: cooKie\n\n"); | 141 b.Init("Cookie: 2", "HTTP/1.1 301 Moved\nLocation: x\nVary: cooKie\n\n"); |
| 142 | 142 |
| 143 net::HttpVaryData v; | 143 net::HttpVaryData v; |
| 144 EXPECT_TRUE(v.Init(a.request, *a.response)); | 144 EXPECT_TRUE(v.Init(a.request, *a.response)); |
| 145 | 145 |
| 146 EXPECT_FALSE(v.MatchesRequest(b.request, *b.response)); | 146 EXPECT_FALSE(v.MatchesRequest(b.request, *b.response)); |
| 147 } | 147 } |
| OLD | NEW |