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 <sys/epoll.h> | 6 #include <sys/epoll.h> |
7 | 7 |
8 #include <list> | 8 #include <list> |
9 #include <memory> | 9 #include <memory> |
10 #include <string> | 10 #include <string> |
(...skipping 1350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1361 case kTBBR: | 1361 case kTBBR: |
1362 expected_congestion_control_type = kBBR; | 1362 expected_congestion_control_type = kBBR; |
1363 break; | 1363 break; |
1364 case kQBIC: | 1364 case kQBIC: |
1365 expected_congestion_control_type = kCubic; | 1365 expected_congestion_control_type = kCubic; |
1366 break; | 1366 break; |
1367 default: | 1367 default: |
1368 DLOG(FATAL) << "Unexpected congestion control tag"; | 1368 DLOG(FATAL) << "Unexpected congestion control tag"; |
1369 } | 1369 } |
1370 | 1370 |
| 1371 server_thread_->Pause(); |
1371 EXPECT_EQ(expected_congestion_control_type, | 1372 EXPECT_EQ(expected_congestion_control_type, |
1372 QuicSentPacketManagerPeer::GetSendAlgorithm( | 1373 QuicSentPacketManagerPeer::GetSendAlgorithm( |
1373 *static_cast<const QuicSentPacketManager*>( | 1374 *static_cast<const QuicSentPacketManager*>( |
1374 GetSentPacketManagerFromFirstServerSession())) | 1375 GetSentPacketManagerFromFirstServerSession())) |
1375 ->GetCongestionControlType()); | 1376 ->GetCongestionControlType()); |
| 1377 server_thread_->Resume(); |
1376 } | 1378 } |
1377 | 1379 |
1378 TEST_P(EndToEndTest, LimitMaxOpenStreams) { | 1380 TEST_P(EndToEndTest, LimitMaxOpenStreams) { |
1379 // Server limits the number of max streams to 2. | 1381 // Server limits the number of max streams to 2. |
1380 server_config_.SetMaxStreamsPerConnection(2, 2); | 1382 server_config_.SetMaxStreamsPerConnection(2, 2); |
1381 // Client tries to negotiate for 10. | 1383 // Client tries to negotiate for 10. |
1382 client_config_.SetMaxStreamsPerConnection(10, 5); | 1384 client_config_.SetMaxStreamsPerConnection(10, 5); |
1383 | 1385 |
1384 ASSERT_TRUE(Initialize()); | 1386 ASSERT_TRUE(Initialize()); |
1385 client_->client()->WaitForCryptoHandshakeConfirmed(); | 1387 client_->client()->WaitForCryptoHandshakeConfirmed(); |
(...skipping 772 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2158 EXPECT_EQ(kFooResponseBody, client_->SendSynchronousRequest("/foo")); | 2160 EXPECT_EQ(kFooResponseBody, client_->SendSynchronousRequest("/foo")); |
2159 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code()); | 2161 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code()); |
2160 } | 2162 } |
2161 | 2163 |
2162 // A test stream that gives |response_body_| as an error response body. | 2164 // A test stream that gives |response_body_| as an error response body. |
2163 class ServerStreamWithErrorResponseBody : public QuicSimpleServerStream { | 2165 class ServerStreamWithErrorResponseBody : public QuicSimpleServerStream { |
2164 public: | 2166 public: |
2165 ServerStreamWithErrorResponseBody(QuicStreamId id, | 2167 ServerStreamWithErrorResponseBody(QuicStreamId id, |
2166 QuicSpdySession* session, | 2168 QuicSpdySession* session, |
2167 string response_body) | 2169 string response_body) |
2168 : QuicSimpleServerStream(id, session), response_body_(response_body) {} | 2170 : QuicSimpleServerStream(id, session), |
| 2171 response_body_(std::move(response_body)) {} |
2169 | 2172 |
2170 ~ServerStreamWithErrorResponseBody() override {} | 2173 ~ServerStreamWithErrorResponseBody() override {} |
2171 | 2174 |
2172 protected: | 2175 protected: |
2173 void SendErrorResponse() override { | 2176 void SendErrorResponse() override { |
2174 DVLOG(1) << "Sending error response for stream " << id(); | 2177 DVLOG(1) << "Sending error response for stream " << id(); |
2175 SpdyHeaderBlock headers; | 2178 SpdyHeaderBlock headers; |
2176 headers[":status"] = "500"; | 2179 headers[":status"] = "500"; |
2177 headers["content-length"] = base::UintToString(response_body_.size()); | 2180 headers["content-length"] = base::UintToString(response_body_.size()); |
2178 // This method must call CloseReadSide to cause the test case, StopReading | 2181 // This method must call CloseReadSide to cause the test case, StopReading |
2179 // is not sufficient. | 2182 // is not sufficient. |
2180 ReliableQuicStreamPeer::CloseReadSide(this); | 2183 ReliableQuicStreamPeer::CloseReadSide(this); |
2181 SendHeadersAndBody(std::move(headers), response_body_); | 2184 SendHeadersAndBody(std::move(headers), response_body_); |
2182 } | 2185 } |
2183 | 2186 |
2184 string response_body_; | 2187 string response_body_; |
2185 }; | 2188 }; |
2186 | 2189 |
2187 class StreamWithErrorFactory : public QuicTestServer::StreamFactory { | 2190 class StreamWithErrorFactory : public QuicTestServer::StreamFactory { |
2188 public: | 2191 public: |
2189 explicit StreamWithErrorFactory(string response_body) | 2192 explicit StreamWithErrorFactory(string response_body) |
2190 : response_body_(response_body) {} | 2193 : response_body_(std::move(response_body)) {} |
2191 | 2194 |
2192 ~StreamWithErrorFactory() override {} | 2195 ~StreamWithErrorFactory() override {} |
2193 | 2196 |
2194 QuicSimpleServerStream* CreateStream(QuicStreamId id, | 2197 QuicSimpleServerStream* CreateStream(QuicStreamId id, |
2195 QuicSpdySession* session) override { | 2198 QuicSpdySession* session) override { |
2196 return new ServerStreamWithErrorResponseBody(id, session, response_body_); | 2199 return new ServerStreamWithErrorResponseBody(id, session, response_body_); |
2197 } | 2200 } |
2198 | 2201 |
2199 private: | 2202 private: |
2200 string response_body_; | 2203 string response_body_; |
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2616 AddRequestAndResponseWithServerPush("example.com", "/push_example", kBody, | 2619 AddRequestAndResponseWithServerPush("example.com", "/push_example", kBody, |
2617 push_urls, kNumResources, 0); | 2620 push_urls, kNumResources, 0); |
2618 client_->client()->set_response_listener(new TestResponseListener); | 2621 client_->client()->set_response_listener(new TestResponseListener); |
2619 | 2622 |
2620 // Send the first request: this will trigger the server to send all the push | 2623 // Send the first request: this will trigger the server to send all the push |
2621 // resources associated with this request, and these will be cached by the | 2624 // resources associated with this request, and these will be cached by the |
2622 // client. | 2625 // client. |
2623 EXPECT_EQ(kBody, client_->SendSynchronousRequest( | 2626 EXPECT_EQ(kBody, client_->SendSynchronousRequest( |
2624 "https://example.com/push_example")); | 2627 "https://example.com/push_example")); |
2625 | 2628 |
2626 for (string url : push_urls) { | 2629 for (const string& url : push_urls) { |
2627 // Sending subsequent requesets will not actually send anything on the wire, | 2630 // Sending subsequent requesets will not actually send anything on the wire, |
2628 // as the responses are already in the client's cache. | 2631 // as the responses are already in the client's cache. |
2629 DVLOG(1) << "send request for pushed stream on url " << url; | 2632 DVLOG(1) << "send request for pushed stream on url " << url; |
2630 string expected_body = "This is server push response body for " + url; | 2633 string expected_body = "This is server push response body for " + url; |
2631 string response_body = client_->SendSynchronousRequest(url); | 2634 string response_body = client_->SendSynchronousRequest(url); |
2632 DVLOG(1) << "response body " << response_body; | 2635 DVLOG(1) << "response body " << response_body; |
2633 EXPECT_EQ(expected_body, response_body); | 2636 EXPECT_EQ(expected_body, response_body); |
2634 } | 2637 } |
2635 // Expect only original request has been sent and push responses have been | 2638 // Expect only original request has been sent and push responses have been |
2636 // received as normal response. | 2639 // received as normal response. |
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2920 EXPECT_EQ(kBarResponseBody, client_->response_body()); | 2923 EXPECT_EQ(kBarResponseBody, client_->response_body()); |
2921 QuicConnectionStats client_stats = | 2924 QuicConnectionStats client_stats = |
2922 client_->client()->session()->connection()->GetStats(); | 2925 client_->client()->session()->connection()->GetStats(); |
2923 EXPECT_EQ(0u, client_stats.packets_lost); | 2926 EXPECT_EQ(0u, client_stats.packets_lost); |
2924 EXPECT_EQ(1, client_->client()->GetNumSentClientHellos()); | 2927 EXPECT_EQ(1, client_->client()->GetNumSentClientHellos()); |
2925 } | 2928 } |
2926 | 2929 |
2927 } // namespace | 2930 } // namespace |
2928 } // namespace test | 2931 } // namespace test |
2929 } // namespace net | 2932 } // namespace net |
OLD | NEW |