| 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 <cstdint> | 8 #include <cstdint> |
| 9 #include <list> | 9 #include <list> |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 #include "net/quic/core/crypto/aes_128_gcm_12_encrypter.h" | 23 #include "net/quic/core/crypto/aes_128_gcm_12_encrypter.h" |
| 24 #include "net/quic/core/crypto/null_encrypter.h" | 24 #include "net/quic/core/crypto/null_encrypter.h" |
| 25 #include "net/quic/core/quic_client_session_base.h" | 25 #include "net/quic/core/quic_client_session_base.h" |
| 26 #include "net/quic/core/quic_flags.h" | 26 #include "net/quic/core/quic_flags.h" |
| 27 #include "net/quic/core/quic_framer.h" | 27 #include "net/quic/core/quic_framer.h" |
| 28 #include "net/quic/core/quic_packet_creator.h" | 28 #include "net/quic/core/quic_packet_creator.h" |
| 29 #include "net/quic/core/quic_packets.h" | 29 #include "net/quic/core/quic_packets.h" |
| 30 #include "net/quic/core/quic_server_id.h" | 30 #include "net/quic/core/quic_server_id.h" |
| 31 #include "net/quic/core/quic_session.h" | 31 #include "net/quic/core/quic_session.h" |
| 32 #include "net/quic/core/quic_utils.h" | 32 #include "net/quic/core/quic_utils.h" |
| 33 #include "net/quic/platform/api/quic_logging.h" |
| 33 #include "net/quic/platform/api/quic_socket_address.h" | 34 #include "net/quic/platform/api/quic_socket_address.h" |
| 34 #include "net/quic/platform/api/quic_str_cat.h" | 35 #include "net/quic/platform/api/quic_str_cat.h" |
| 35 #include "net/quic/platform/api/quic_text_utils.h" | 36 #include "net/quic/platform/api/quic_text_utils.h" |
| 36 #include "net/quic/test_tools/crypto_test_utils.h" | 37 #include "net/quic/test_tools/crypto_test_utils.h" |
| 37 #include "net/quic/test_tools/quic_config_peer.h" | 38 #include "net/quic/test_tools/quic_config_peer.h" |
| 38 #include "net/quic/test_tools/quic_connection_peer.h" | 39 #include "net/quic/test_tools/quic_connection_peer.h" |
| 39 #include "net/quic/test_tools/quic_flow_controller_peer.h" | 40 #include "net/quic/test_tools/quic_flow_controller_peer.h" |
| 40 #include "net/quic/test_tools/quic_sent_packet_manager_peer.h" | 41 #include "net/quic/test_tools/quic_sent_packet_manager_peer.h" |
| 41 #include "net/quic/test_tools/quic_session_peer.h" | 42 #include "net/quic/test_tools/quic_session_peer.h" |
| 42 #include "net/quic/test_tools/quic_spdy_session_peer.h" | 43 #include "net/quic/test_tools/quic_spdy_session_peer.h" |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 276 client_writer_(nullptr), | 277 client_writer_(nullptr), |
| 277 server_writer_(nullptr), | 278 server_writer_(nullptr), |
| 278 server_started_(false), | 279 server_started_(false), |
| 279 chlo_multiplier_(0), | 280 chlo_multiplier_(0), |
| 280 stream_factory_(nullptr), | 281 stream_factory_(nullptr), |
| 281 support_server_push_(false) { | 282 support_server_push_(false) { |
| 282 client_supported_versions_ = GetParam().client_supported_versions; | 283 client_supported_versions_ = GetParam().client_supported_versions; |
| 283 server_supported_versions_ = GetParam().server_supported_versions; | 284 server_supported_versions_ = GetParam().server_supported_versions; |
| 284 negotiated_version_ = GetParam().negotiated_version; | 285 negotiated_version_ = GetParam().negotiated_version; |
| 285 | 286 |
| 286 VLOG(1) << "Using Configuration: " << GetParam(); | 287 QUIC_LOG(INFO) << "Using Configuration: " << GetParam(); |
| 287 | 288 |
| 288 // Use different flow control windows for client/server. | 289 // Use different flow control windows for client/server. |
| 289 client_config_.SetInitialStreamFlowControlWindowToSend( | 290 client_config_.SetInitialStreamFlowControlWindowToSend( |
| 290 2 * kInitialStreamFlowControlWindowForTest); | 291 2 * kInitialStreamFlowControlWindowForTest); |
| 291 client_config_.SetInitialSessionFlowControlWindowToSend( | 292 client_config_.SetInitialSessionFlowControlWindowToSend( |
| 292 2 * kInitialSessionFlowControlWindowForTest); | 293 2 * kInitialSessionFlowControlWindowForTest); |
| 293 server_config_.SetInitialStreamFlowControlWindowToSend( | 294 server_config_.SetInitialStreamFlowControlWindowToSend( |
| 294 3 * kInitialStreamFlowControlWindowForTest); | 295 3 * kInitialStreamFlowControlWindowForTest); |
| 295 server_config_.SetInitialSessionFlowControlWindowToSend( | 296 server_config_.SetInitialSessionFlowControlWindowToSend( |
| 296 3 * kInitialSessionFlowControlWindowForTest); | 297 3 * kInitialSessionFlowControlWindowForTest); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 331 set_client_initial_stream_flow_control_receive_window(kClientIFCW); | 332 set_client_initial_stream_flow_control_receive_window(kClientIFCW); |
| 332 set_client_initial_session_flow_control_receive_window( | 333 set_client_initial_session_flow_control_receive_window( |
| 333 kSessionToStreamRatio * kClientIFCW); | 334 kSessionToStreamRatio * kClientIFCW); |
| 334 set_server_initial_stream_flow_control_receive_window(kServerIFCW); | 335 set_server_initial_stream_flow_control_receive_window(kServerIFCW); |
| 335 set_server_initial_session_flow_control_receive_window( | 336 set_server_initial_session_flow_control_receive_window( |
| 336 kSessionToStreamRatio * kServerIFCW); | 337 kSessionToStreamRatio * kServerIFCW); |
| 337 } | 338 } |
| 338 | 339 |
| 339 void set_client_initial_stream_flow_control_receive_window(uint32_t window) { | 340 void set_client_initial_stream_flow_control_receive_window(uint32_t window) { |
| 340 CHECK(client_.get() == nullptr); | 341 CHECK(client_.get() == nullptr); |
| 341 DVLOG(1) << "Setting client initial stream flow control window: " << window; | 342 QUIC_DLOG(INFO) << "Setting client initial stream flow control window: " |
| 343 << window; |
| 342 client_config_.SetInitialStreamFlowControlWindowToSend(window); | 344 client_config_.SetInitialStreamFlowControlWindowToSend(window); |
| 343 } | 345 } |
| 344 | 346 |
| 345 void set_client_initial_session_flow_control_receive_window(uint32_t window) { | 347 void set_client_initial_session_flow_control_receive_window(uint32_t window) { |
| 346 CHECK(client_.get() == nullptr); | 348 CHECK(client_.get() == nullptr); |
| 347 DVLOG(1) << "Setting client initial session flow control window: " | 349 QUIC_DLOG(INFO) << "Setting client initial session flow control window: " |
| 348 << window; | 350 << window; |
| 349 client_config_.SetInitialSessionFlowControlWindowToSend(window); | 351 client_config_.SetInitialSessionFlowControlWindowToSend(window); |
| 350 } | 352 } |
| 351 | 353 |
| 352 void set_server_initial_stream_flow_control_receive_window(uint32_t window) { | 354 void set_server_initial_stream_flow_control_receive_window(uint32_t window) { |
| 353 CHECK(server_thread_.get() == nullptr); | 355 CHECK(server_thread_.get() == nullptr); |
| 354 DVLOG(1) << "Setting server initial stream flow control window: " << window; | 356 QUIC_DLOG(INFO) << "Setting server initial stream flow control window: " |
| 357 << window; |
| 355 server_config_.SetInitialStreamFlowControlWindowToSend(window); | 358 server_config_.SetInitialStreamFlowControlWindowToSend(window); |
| 356 } | 359 } |
| 357 | 360 |
| 358 void set_server_initial_session_flow_control_receive_window(uint32_t window) { | 361 void set_server_initial_session_flow_control_receive_window(uint32_t window) { |
| 359 CHECK(server_thread_.get() == nullptr); | 362 CHECK(server_thread_.get() == nullptr); |
| 360 DVLOG(1) << "Setting server initial session flow control window: " | 363 QUIC_DLOG(INFO) << "Setting server initial session flow control window: " |
| 361 << window; | 364 << window; |
| 362 server_config_.SetInitialSessionFlowControlWindowToSend(window); | 365 server_config_.SetInitialSessionFlowControlWindowToSend(window); |
| 363 } | 366 } |
| 364 | 367 |
| 365 const QuicSentPacketManagerInterface* | 368 const QuicSentPacketManagerInterface* |
| 366 GetSentPacketManagerFromFirstServerSession() const { | 369 GetSentPacketManagerFromFirstServerSession() const { |
| 367 QuicDispatcher* dispatcher = | 370 QuicDispatcher* dispatcher = |
| 368 QuicServerPeer::GetDispatcher(server_thread_->server()); | 371 QuicServerPeer::GetDispatcher(server_thread_->server()); |
| 369 QuicSession* session = dispatcher->session_map().begin()->second.get(); | 372 QuicSession* session = dispatcher->session_map().begin()->second.get(); |
| 370 return &session->connection()->sent_packet_manager(); | 373 return &session->connection()->sent_packet_manager(); |
| 371 } | 374 } |
| (...skipping 965 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1337 case kRENO: | 1340 case kRENO: |
| 1338 expected_congestion_control_type = kReno; | 1341 expected_congestion_control_type = kReno; |
| 1339 break; | 1342 break; |
| 1340 case kTBBR: | 1343 case kTBBR: |
| 1341 expected_congestion_control_type = kBBR; | 1344 expected_congestion_control_type = kBBR; |
| 1342 break; | 1345 break; |
| 1343 case kQBIC: | 1346 case kQBIC: |
| 1344 expected_congestion_control_type = kCubicBytes; | 1347 expected_congestion_control_type = kCubicBytes; |
| 1345 break; | 1348 break; |
| 1346 default: | 1349 default: |
| 1347 DLOG(FATAL) << "Unexpected congestion control tag"; | 1350 QUIC_DLOG(FATAL) << "Unexpected congestion control tag"; |
| 1348 } | 1351 } |
| 1349 | 1352 |
| 1350 server_thread_->Pause(); | 1353 server_thread_->Pause(); |
| 1351 EXPECT_EQ(expected_congestion_control_type, | 1354 EXPECT_EQ(expected_congestion_control_type, |
| 1352 QuicSentPacketManagerPeer::GetSendAlgorithm( | 1355 QuicSentPacketManagerPeer::GetSendAlgorithm( |
| 1353 *static_cast<const QuicSentPacketManager*>( | 1356 *static_cast<const QuicSentPacketManager*>( |
| 1354 GetSentPacketManagerFromFirstServerSession())) | 1357 GetSentPacketManagerFromFirstServerSession())) |
| 1355 ->GetCongestionControlType()); | 1358 ->GetCongestionControlType()); |
| 1356 server_thread_->Resume(); | 1359 server_thread_->Resume(); |
| 1357 } | 1360 } |
| (...skipping 578 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1936 | 1939 |
| 1937 private: | 1940 private: |
| 1938 int num_notifications_; | 1941 int num_notifications_; |
| 1939 }; | 1942 }; |
| 1940 | 1943 |
| 1941 class TestResponseListener : public QuicClient::ResponseListener { | 1944 class TestResponseListener : public QuicClient::ResponseListener { |
| 1942 public: | 1945 public: |
| 1943 void OnCompleteResponse(QuicStreamId id, | 1946 void OnCompleteResponse(QuicStreamId id, |
| 1944 const SpdyHeaderBlock& response_headers, | 1947 const SpdyHeaderBlock& response_headers, |
| 1945 const string& response_body) override { | 1948 const string& response_body) override { |
| 1946 string debug_string = response_headers.DebugString(); | 1949 QUIC_DVLOG(1) << "response for stream " << id << " " |
| 1947 DVLOG(1) << "response for stream " << id << " " << debug_string << "\n" | 1950 << response_headers.DebugString() << "\n" |
| 1948 << response_body; | 1951 << response_body; |
| 1949 } | 1952 } |
| 1950 }; | 1953 }; |
| 1951 | 1954 |
| 1952 TEST_P(EndToEndTest, AckNotifierWithPacketLossAndBlockedSocket) { | 1955 TEST_P(EndToEndTest, AckNotifierWithPacketLossAndBlockedSocket) { |
| 1953 // Verify that even in the presence of packet loss and occasionally blocked | 1956 // Verify that even in the presence of packet loss and occasionally blocked |
| 1954 // socket, an AckNotifierDelegate will get informed that the data it is | 1957 // socket, an AckNotifierDelegate will get informed that the data it is |
| 1955 // interested in has been ACKed. This tests end-to-end ACK notification, and | 1958 // interested in has been ACKed. This tests end-to-end ACK notification, and |
| 1956 // demonstrates that retransmissions do not break this functionality. | 1959 // demonstrates that retransmissions do not break this functionality. |
| 1957 if (!BothSidesSupportStatelessRejects()) { | 1960 if (!BothSidesSupportStatelessRejects()) { |
| 1958 // TODO(jokulik): Until we support redundant SREJ packets, don't | 1961 // TODO(jokulik): Until we support redundant SREJ packets, don't |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2208 EXPECT_EQ(kFooResponseBody, client_->SendSynchronousRequest("/foo")); | 2211 EXPECT_EQ(kFooResponseBody, client_->SendSynchronousRequest("/foo")); |
| 2209 EXPECT_EQ("200", client_->response_headers()->find(":status")->second); | 2212 EXPECT_EQ("200", client_->response_headers()->find(":status")->second); |
| 2210 | 2213 |
| 2211 std::unique_ptr<QuicEncryptedPacket> packet(ConstructEncryptedPacket( | 2214 std::unique_ptr<QuicEncryptedPacket> packet(ConstructEncryptedPacket( |
| 2212 client_->client()->session()->connection()->connection_id(), false, false, | 2215 client_->client()->session()->connection()->connection_id(), false, false, |
| 2213 false, kDefaultPathId, 1, "At least 20 characters.", | 2216 false, kDefaultPathId, 1, "At least 20 characters.", |
| 2214 PACKET_8BYTE_CONNECTION_ID, PACKET_6BYTE_PACKET_NUMBER)); | 2217 PACKET_8BYTE_CONNECTION_ID, PACKET_6BYTE_PACKET_NUMBER)); |
| 2215 // Damage the encrypted data. | 2218 // Damage the encrypted data. |
| 2216 string damaged_packet(packet->data(), packet->length()); | 2219 string damaged_packet(packet->data(), packet->length()); |
| 2217 damaged_packet[30] ^= 0x01; | 2220 damaged_packet[30] ^= 0x01; |
| 2218 DVLOG(1) << "Sending bad packet."; | 2221 QUIC_DLOG(INFO) << "Sending bad packet."; |
| 2219 client_writer_->WritePacket( | 2222 client_writer_->WritePacket( |
| 2220 damaged_packet.data(), damaged_packet.length(), | 2223 damaged_packet.data(), damaged_packet.length(), |
| 2221 client_->client()->GetLatestClientAddress().host(), server_address_, | 2224 client_->client()->GetLatestClientAddress().host(), server_address_, |
| 2222 nullptr); | 2225 nullptr); |
| 2223 // Give the server time to process the packet. | 2226 // Give the server time to process the packet. |
| 2224 base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(100)); | 2227 base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(100)); |
| 2225 // This error is sent to the connection's OnError (which ignores it), so the | 2228 // This error is sent to the connection's OnError (which ignores it), so the |
| 2226 // dispatcher doesn't see it. | 2229 // dispatcher doesn't see it. |
| 2227 // Pause the server so we can access the server's internals without races. | 2230 // Pause the server so we can access the server's internals without races. |
| 2228 server_thread_->Pause(); | 2231 server_thread_->Pause(); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 2244 QuicSpdySession* session, | 2247 QuicSpdySession* session, |
| 2245 QuicHttpResponseCache* response_cache, | 2248 QuicHttpResponseCache* response_cache, |
| 2246 string response_body) | 2249 string response_body) |
| 2247 : QuicSimpleServerStream(id, session, response_cache), | 2250 : QuicSimpleServerStream(id, session, response_cache), |
| 2248 response_body_(std::move(response_body)) {} | 2251 response_body_(std::move(response_body)) {} |
| 2249 | 2252 |
| 2250 ~ServerStreamWithErrorResponseBody() override {} | 2253 ~ServerStreamWithErrorResponseBody() override {} |
| 2251 | 2254 |
| 2252 protected: | 2255 protected: |
| 2253 void SendErrorResponse() override { | 2256 void SendErrorResponse() override { |
| 2254 DVLOG(1) << "Sending error response for stream " << id(); | 2257 QUIC_DLOG(INFO) << "Sending error response for stream " << id(); |
| 2255 SpdyHeaderBlock headers; | 2258 SpdyHeaderBlock headers; |
| 2256 headers[":status"] = "500"; | 2259 headers[":status"] = "500"; |
| 2257 headers["content-length"] = | 2260 headers["content-length"] = |
| 2258 QuicTextUtils::Uint64ToString(response_body_.size()); | 2261 QuicTextUtils::Uint64ToString(response_body_.size()); |
| 2259 // This method must call CloseReadSide to cause the test case, StopReading | 2262 // This method must call CloseReadSide to cause the test case, StopReading |
| 2260 // is not sufficient. | 2263 // is not sufficient. |
| 2261 QuicStreamPeer::CloseReadSide(this); | 2264 QuicStreamPeer::CloseReadSide(this); |
| 2262 SendHeadersAndBody(std::move(headers), response_body_); | 2265 SendHeadersAndBody(std::move(headers), response_body_); |
| 2263 } | 2266 } |
| 2264 | 2267 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 2295 ~ServerStreamThatDropsBody() override {} | 2298 ~ServerStreamThatDropsBody() override {} |
| 2296 | 2299 |
| 2297 protected: | 2300 protected: |
| 2298 void OnDataAvailable() override { | 2301 void OnDataAvailable() override { |
| 2299 while (HasBytesToRead()) { | 2302 while (HasBytesToRead()) { |
| 2300 struct iovec iov; | 2303 struct iovec iov; |
| 2301 if (GetReadableRegions(&iov, 1) == 0) { | 2304 if (GetReadableRegions(&iov, 1) == 0) { |
| 2302 // No more data to read. | 2305 // No more data to read. |
| 2303 break; | 2306 break; |
| 2304 } | 2307 } |
| 2305 DVLOG(1) << "Processed " << iov.iov_len << " bytes for stream " << id(); | 2308 QUIC_DVLOG(1) << "Processed " << iov.iov_len << " bytes for stream " |
| 2309 << id(); |
| 2306 MarkConsumed(iov.iov_len); | 2310 MarkConsumed(iov.iov_len); |
| 2307 } | 2311 } |
| 2308 | 2312 |
| 2309 if (!sequencer()->IsClosed()) { | 2313 if (!sequencer()->IsClosed()) { |
| 2310 sequencer()->SetUnblocked(); | 2314 sequencer()->SetUnblocked(); |
| 2311 return; | 2315 return; |
| 2312 } | 2316 } |
| 2313 | 2317 |
| 2314 // If the sequencer is closed, then all the body, including the fin, has | 2318 // If the sequencer is closed, then all the body, including the fin, has |
| 2315 // been consumed. | 2319 // been consumed. |
| (...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2673 "https://example.com/script.js", | 2677 "https://example.com/script.js", |
| 2674 "https://fonts.example.com/font.woff", | 2678 "https://fonts.example.com/font.woff", |
| 2675 "https://example.com/logo-hires.jpg"}; | 2679 "https://example.com/logo-hires.jpg"}; |
| 2676 AddRequestAndResponseWithServerPush("example.com", "/push_example", kBody, | 2680 AddRequestAndResponseWithServerPush("example.com", "/push_example", kBody, |
| 2677 push_urls, kNumResources, 0); | 2681 push_urls, kNumResources, 0); |
| 2678 | 2682 |
| 2679 client_->client()->set_response_listener( | 2683 client_->client()->set_response_listener( |
| 2680 std::unique_ptr<QuicClientBase::ResponseListener>( | 2684 std::unique_ptr<QuicClientBase::ResponseListener>( |
| 2681 new TestResponseListener)); | 2685 new TestResponseListener)); |
| 2682 | 2686 |
| 2683 DVLOG(1) << "send request for /push_example"; | 2687 QUIC_DVLOG(1) << "send request for /push_example"; |
| 2684 EXPECT_EQ(kBody, client_->SendSynchronousRequest( | 2688 EXPECT_EQ(kBody, client_->SendSynchronousRequest( |
| 2685 "https://example.com/push_example")); | 2689 "https://example.com/push_example")); |
| 2686 QuicHeadersStream* headers_stream = | 2690 QuicHeadersStream* headers_stream = |
| 2687 QuicSpdySessionPeer::GetHeadersStream(client_->client()->session()); | 2691 QuicSpdySessionPeer::GetHeadersStream(client_->client()->session()); |
| 2688 QuicStreamSequencer* sequencer = QuicStreamPeer::sequencer(headers_stream); | 2692 QuicStreamSequencer* sequencer = QuicStreamPeer::sequencer(headers_stream); |
| 2689 // Headers stream's sequencer buffer shouldn't be released because server push | 2693 // Headers stream's sequencer buffer shouldn't be released because server push |
| 2690 // hasn't finished yet. | 2694 // hasn't finished yet. |
| 2691 EXPECT_TRUE(QuicStreamSequencerPeer::IsUnderlyingBufferAllocated(sequencer)); | 2695 EXPECT_TRUE(QuicStreamSequencerPeer::IsUnderlyingBufferAllocated(sequencer)); |
| 2692 | 2696 |
| 2693 for (const string& url : push_urls) { | 2697 for (const string& url : push_urls) { |
| 2694 DVLOG(1) << "send request for pushed stream on url " << url; | 2698 QUIC_DVLOG(1) << "send request for pushed stream on url " << url; |
| 2695 string expected_body = | 2699 string expected_body = |
| 2696 QuicStrCat("This is server push response body for ", url); | 2700 QuicStrCat("This is server push response body for ", url); |
| 2697 string response_body = client_->SendSynchronousRequest(url); | 2701 string response_body = client_->SendSynchronousRequest(url); |
| 2698 DVLOG(1) << "response body " << response_body; | 2702 QUIC_DVLOG(1) << "response body " << response_body; |
| 2699 EXPECT_EQ(expected_body, response_body); | 2703 EXPECT_EQ(expected_body, response_body); |
| 2700 } | 2704 } |
| 2701 EXPECT_NE( | 2705 EXPECT_NE( |
| 2702 FLAGS_quic_reloadable_flag_quic_headers_stream_release_sequencer_buffer && | 2706 FLAGS_quic_reloadable_flag_quic_headers_stream_release_sequencer_buffer && |
| 2703 FLAGS_quic_reloadable_flag_quic_reduce_sequencer_buffer_memory_life_ti
me, // NOLINT | 2707 FLAGS_quic_reloadable_flag_quic_reduce_sequencer_buffer_memory_life_ti
me, // NOLINT |
| 2704 QuicStreamSequencerPeer::IsUnderlyingBufferAllocated(sequencer)); | 2708 QuicStreamSequencerPeer::IsUnderlyingBufferAllocated(sequencer)); |
| 2705 } | 2709 } |
| 2706 | 2710 |
| 2707 TEST_P(EndToEndTestServerPush, ServerPushUnderLimit) { | 2711 TEST_P(EndToEndTestServerPush, ServerPushUnderLimit) { |
| 2708 // Tests that sending a request which has 4 push resources will trigger server | 2712 // Tests that sending a request which has 4 push resources will trigger server |
| (...skipping 23 matching lines...) Expand all Loading... |
| 2732 | 2736 |
| 2733 // Send the first request: this will trigger the server to send all the push | 2737 // Send the first request: this will trigger the server to send all the push |
| 2734 // resources associated with this request, and these will be cached by the | 2738 // resources associated with this request, and these will be cached by the |
| 2735 // client. | 2739 // client. |
| 2736 EXPECT_EQ(kBody, client_->SendSynchronousRequest( | 2740 EXPECT_EQ(kBody, client_->SendSynchronousRequest( |
| 2737 "https://example.com/push_example")); | 2741 "https://example.com/push_example")); |
| 2738 | 2742 |
| 2739 for (const string& url : push_urls) { | 2743 for (const string& url : push_urls) { |
| 2740 // Sending subsequent requesets will not actually send anything on the wire, | 2744 // Sending subsequent requesets will not actually send anything on the wire, |
| 2741 // as the responses are already in the client's cache. | 2745 // as the responses are already in the client's cache. |
| 2742 DVLOG(1) << "send request for pushed stream on url " << url; | 2746 QUIC_DVLOG(1) << "send request for pushed stream on url " << url; |
| 2743 string expected_body = | 2747 string expected_body = |
| 2744 QuicStrCat("This is server push response body for ", url); | 2748 QuicStrCat("This is server push response body for ", url); |
| 2745 string response_body = client_->SendSynchronousRequest(url); | 2749 string response_body = client_->SendSynchronousRequest(url); |
| 2746 DVLOG(1) << "response body " << response_body; | 2750 QUIC_DVLOG(1) << "response body " << response_body; |
| 2747 EXPECT_EQ(expected_body, response_body); | 2751 EXPECT_EQ(expected_body, response_body); |
| 2748 } | 2752 } |
| 2749 // Expect only original request has been sent and push responses have been | 2753 // Expect only original request has been sent and push responses have been |
| 2750 // received as normal response. | 2754 // received as normal response. |
| 2751 EXPECT_EQ(1u, client_->num_requests()); | 2755 EXPECT_EQ(1u, client_->num_requests()); |
| 2752 EXPECT_EQ(1u + kNumResources, client_->num_responses()); | 2756 EXPECT_EQ(1u + kNumResources, client_->num_responses()); |
| 2753 } | 2757 } |
| 2754 | 2758 |
| 2755 TEST_P(EndToEndTestServerPush, ServerPushOverLimitNonBlocking) { | 2759 TEST_P(EndToEndTestServerPush, ServerPushOverLimitNonBlocking) { |
| 2756 // Tests that when streams are not blocked by flow control or congestion | 2760 // Tests that when streams are not blocked by flow control or congestion |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3008 QuicStreamSequencer* sequencer = QuicStreamPeer::sequencer(headers_stream); | 3012 QuicStreamSequencer* sequencer = QuicStreamPeer::sequencer(headers_stream); |
| 3009 EXPECT_NE( | 3013 EXPECT_NE( |
| 3010 FLAGS_quic_reloadable_flag_quic_headers_stream_release_sequencer_buffer && | 3014 FLAGS_quic_reloadable_flag_quic_headers_stream_release_sequencer_buffer && |
| 3011 FLAGS_quic_reloadable_flag_quic_reduce_sequencer_buffer_memory_life_ti
me, // NOLINT | 3015 FLAGS_quic_reloadable_flag_quic_reduce_sequencer_buffer_memory_life_ti
me, // NOLINT |
| 3012 QuicStreamSequencerPeer::IsUnderlyingBufferAllocated(sequencer)); | 3016 QuicStreamSequencerPeer::IsUnderlyingBufferAllocated(sequencer)); |
| 3013 } | 3017 } |
| 3014 | 3018 |
| 3015 class EndToEndBufferedPacketsTest : public EndToEndTest { | 3019 class EndToEndBufferedPacketsTest : public EndToEndTest { |
| 3016 public: | 3020 public: |
| 3017 void CreateClientWithWriter() override { | 3021 void CreateClientWithWriter() override { |
| 3018 LOG(ERROR) << "create client with reorder_writer_ "; | 3022 QUIC_LOG(ERROR) << "create client with reorder_writer_ "; |
| 3019 reorder_writer_ = new PacketReorderingWriter(); | 3023 reorder_writer_ = new PacketReorderingWriter(); |
| 3020 client_.reset(EndToEndTest::CreateQuicClient(reorder_writer_)); | 3024 client_.reset(EndToEndTest::CreateQuicClient(reorder_writer_)); |
| 3021 } | 3025 } |
| 3022 | 3026 |
| 3023 void SetUp() override { | 3027 void SetUp() override { |
| 3024 // Don't initialize client writer in base class. | 3028 // Don't initialize client writer in base class. |
| 3025 server_writer_ = new PacketDroppingTestWriter(); | 3029 server_writer_ = new PacketDroppingTestWriter(); |
| 3026 } | 3030 } |
| 3027 | 3031 |
| 3028 protected: | 3032 protected: |
| (...skipping 30 matching lines...) Expand all Loading... |
| 3059 client_->WaitForResponse(); | 3063 client_->WaitForResponse(); |
| 3060 EXPECT_EQ(kBarResponseBody, client_->response_body()); | 3064 EXPECT_EQ(kBarResponseBody, client_->response_body()); |
| 3061 QuicConnectionStats client_stats = | 3065 QuicConnectionStats client_stats = |
| 3062 client_->client()->session()->connection()->GetStats(); | 3066 client_->client()->session()->connection()->GetStats(); |
| 3063 EXPECT_EQ(0u, client_stats.packets_lost); | 3067 EXPECT_EQ(0u, client_stats.packets_lost); |
| 3064 EXPECT_EQ(1, client_->client()->GetNumSentClientHellos()); | 3068 EXPECT_EQ(1, client_->client()->GetNumSentClientHellos()); |
| 3065 } | 3069 } |
| 3066 } // namespace | 3070 } // namespace |
| 3067 } // namespace test | 3071 } // namespace test |
| 3068 } // namespace net | 3072 } // namespace net |
| OLD | NEW |