| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 <string> | 5 #include <string> |
| 6 | 6 |
| 7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
| 8 #include "base/memory/singleton.h" | 8 #include "base/memory/singleton.h" |
| 9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
| 10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
| 11 #include "base/strings/string_number_conversions.h" | 11 #include "base/strings/string_number_conversions.h" |
| 12 #include "base/strings/string_piece.h" | 12 #include "base/strings/string_piece.h" |
| 13 #include "net/quic/platform/api/quic_str_cat.h" |
| 13 #include "net/spdy/spdy_framer.h" | 14 #include "net/spdy/spdy_framer.h" |
| 14 #include "net/tools/quic/quic_http_response_cache.h" | 15 #include "net/tools/quic/quic_http_response_cache.h" |
| 15 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
| 16 | 17 |
| 17 using base::ContainsKey; | 18 using base::ContainsKey; |
| 18 using base::IntToString; | 19 using base::IntToString; |
| 19 using base::StringPiece; | 20 using base::StringPiece; |
| 20 using net::SpdyHeaderBlock; | 21 using net::SpdyHeaderBlock; |
| 21 using std::string; | 22 using std::string; |
| 22 | 23 |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 string request_host = "www.foo.com"; | 173 string request_host = "www.foo.com"; |
| 173 string response_body("hello response"); | 174 string response_body("hello response"); |
| 174 const size_t kNumResources = 5; | 175 const size_t kNumResources = 5; |
| 175 int NumResources = 5; | 176 int NumResources = 5; |
| 176 std::list<QuicHttpResponseCache::ServerPushInfo> push_resources; | 177 std::list<QuicHttpResponseCache::ServerPushInfo> push_resources; |
| 177 string scheme = "http"; | 178 string scheme = "http"; |
| 178 for (int i = 0; i < NumResources; ++i) { | 179 for (int i = 0; i < NumResources; ++i) { |
| 179 string path = "/server_push_src" + base::IntToString(i); | 180 string path = "/server_push_src" + base::IntToString(i); |
| 180 string url = scheme + "://" + request_host + path; | 181 string url = scheme + "://" + request_host + path; |
| 181 GURL resource_url(url); | 182 GURL resource_url(url); |
| 182 string body = "This is server push response body for " + path; | 183 string body = QuicStrCat("This is server push response body for ", path); |
| 183 SpdyHeaderBlock response_headers; | 184 SpdyHeaderBlock response_headers; |
| 184 response_headers[":version"] = "HTTP/1.1"; | 185 response_headers[":version"] = "HTTP/1.1"; |
| 185 response_headers[":status"] = "200"; | 186 response_headers[":status"] = "200"; |
| 186 response_headers["content-length"] = base::UintToString(body.size()); | 187 response_headers["content-length"] = base::UintToString(body.size()); |
| 187 push_resources.push_back( | 188 push_resources.push_back( |
| 188 ServerPushInfo(resource_url, response_headers.Clone(), i, body)); | 189 ServerPushInfo(resource_url, response_headers.Clone(), i, body)); |
| 189 } | 190 } |
| 190 | 191 |
| 191 cache_.AddSimpleResponseWithServerPushResources( | 192 cache_.AddSimpleResponseWithServerPushResources( |
| 192 request_host, "/", 200, response_body, push_resources); | 193 request_host, "/", 200, response_body, push_resources); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 239 ASSERT_TRUE(ContainsKey(response->headers(), ":status")); | 240 ASSERT_TRUE(ContainsKey(response->headers(), ":status")); |
| 240 EXPECT_EQ(push_response_status[i++], | 241 EXPECT_EQ(push_response_status[i++], |
| 241 response->headers().find(":status")->second); | 242 response->headers().find(":status")->second); |
| 242 EXPECT_EQ(push_resource.body, response->body()); | 243 EXPECT_EQ(push_resource.body, response->body()); |
| 243 resources.pop_front(); | 244 resources.pop_front(); |
| 244 } | 245 } |
| 245 } | 246 } |
| 246 | 247 |
| 247 } // namespace test | 248 } // namespace test |
| 248 } // namespace net | 249 } // namespace net |
| OLD | NEW |