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 14 matching lines...) Expand all Loading... |
25 | 25 |
26 request.extra_headers.Clear(); | 26 request.extra_headers.Clear(); |
27 request.extra_headers.AddHeadersFromString(request_headers); | 27 request.extra_headers.AddHeadersFromString(request_headers); |
28 } | 28 } |
29 }; | 29 }; |
30 | 30 |
31 } // namespace | 31 } // namespace |
32 | 32 |
33 TEST(HttpVaryDataTest, IsInvalid) { | 33 TEST(HttpVaryDataTest, IsInvalid) { |
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* const 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(std::string(), kTestResponses[i]); | 44 t.Init(std::string(), kTestResponses[i]); |
45 | 45 |
(...skipping 92 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.get())); | 144 EXPECT_TRUE(v.Init(a.request, *a.response.get())); |
145 | 145 |
146 EXPECT_FALSE(v.MatchesRequest(b.request, *b.response.get())); | 146 EXPECT_FALSE(v.MatchesRequest(b.request, *b.response.get())); |
147 } | 147 } |
OLD | NEW |