| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <stddef.h> | 5 #include <stddef.h> |
| 6 #include <string> | 6 #include <string> |
| 7 #include <sys/epoll.h> | 7 #include <sys/epoll.h> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 2128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2139 // Test sending and receiving HTTP/2 Trailers (trailing HEADERS frames). | 2139 // Test sending and receiving HTTP/2 Trailers (trailing HEADERS frames). |
| 2140 ValueRestore<bool> old_flag(&FLAGS_quic_supports_trailers, true); | 2140 ValueRestore<bool> old_flag(&FLAGS_quic_supports_trailers, true); |
| 2141 ASSERT_TRUE(Initialize()); | 2141 ASSERT_TRUE(Initialize()); |
| 2142 client_->client()->WaitForCryptoHandshakeConfirmed(); | 2142 client_->client()->WaitForCryptoHandshakeConfirmed(); |
| 2143 | 2143 |
| 2144 // Set reordering to ensure that Trailers arriving before body is ok. | 2144 // Set reordering to ensure that Trailers arriving before body is ok. |
| 2145 SetPacketSendDelay(QuicTime::Delta::FromMilliseconds(2)); | 2145 SetPacketSendDelay(QuicTime::Delta::FromMilliseconds(2)); |
| 2146 SetReorderPercentage(30); | 2146 SetReorderPercentage(30); |
| 2147 | 2147 |
| 2148 // Add a response with headers, body, and trailers. | 2148 // Add a response with headers, body, and trailers. |
| 2149 const int kBodySize = 64 * 1024; // 1 MB; | 2149 const string kBody = "body content"; |
| 2150 |
| 2150 SpdyHeaderBlock headers; | 2151 SpdyHeaderBlock headers; |
| 2151 headers[":status"] = "200"; | 2152 headers[":status"] = "200"; |
| 2152 headers[":version"] = "HTTP/1.1"; | 2153 headers[":version"] = "HTTP/1.1"; |
| 2153 headers["content-length"] = IntToString(kBodySize); | 2154 headers["content-length"] = IntToString(kBody.size()); |
| 2154 | |
| 2155 const string kBody = string(kBodySize, 'x'); | |
| 2156 | 2155 |
| 2157 SpdyHeaderBlock trailers; | 2156 SpdyHeaderBlock trailers; |
| 2158 trailers["some-trailing-header"] = "trailing-header-value"; | 2157 trailers["some-trailing-header"] = "trailing-header-value"; |
| 2159 | 2158 |
| 2160 QuicInMemoryCache::GetInstance()->AddResponse( | 2159 QuicInMemoryCache::GetInstance()->AddResponse( |
| 2161 "www.google.com", "/trailer_url", headers, kBody, trailers); | 2160 "www.google.com", "/trailer_url", headers, kBody, trailers); |
| 2162 | 2161 |
| 2163 EXPECT_EQ(kBody, client_->SendSynchronousRequest("/trailer_url")); | 2162 EXPECT_EQ(kBody, client_->SendSynchronousRequest("/trailer_url")); |
| 2164 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code()); | 2163 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code()); |
| 2165 EXPECT_EQ(trailers, client_->response_trailers()); | 2164 EXPECT_EQ(trailers, client_->response_trailers()); |
| 2166 } | 2165 } |
| 2167 | 2166 |
| 2168 } // namespace | 2167 } // namespace |
| 2169 } // namespace test | 2168 } // namespace test |
| 2170 } // namespace tools | 2169 } // namespace tools |
| 2171 } // namespace net | 2170 } // namespace net |
| OLD | NEW |