| 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 2537 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2548 QuicSession* server_session = it->second.get(); | 2548 QuicSession* server_session = it->second.get(); |
| 2549 | 2549 |
| 2550 // The stream is not waiting for the arrival of the peer's final offset. | 2550 // The stream is not waiting for the arrival of the peer's final offset. |
| 2551 EXPECT_EQ( | 2551 EXPECT_EQ( |
| 2552 0u, QuicSessionPeer::GetLocallyClosedStreamsHighestOffset(server_session) | 2552 0u, QuicSessionPeer::GetLocallyClosedStreamsHighestOffset(server_session) |
| 2553 .size()); | 2553 .size()); |
| 2554 | 2554 |
| 2555 server_thread_->Resume(); | 2555 server_thread_->Resume(); |
| 2556 } | 2556 } |
| 2557 | 2557 |
| 2558 TEST_P(EndToEndTest, LargePostEarlyResponse) { | |
| 2559 const uint32_t kWindowSize = 65536; | |
| 2560 set_client_initial_stream_flow_control_receive_window(kWindowSize); | |
| 2561 set_client_initial_session_flow_control_receive_window(kWindowSize); | |
| 2562 set_server_initial_stream_flow_control_receive_window(kWindowSize); | |
| 2563 set_server_initial_session_flow_control_receive_window(kWindowSize); | |
| 2564 | |
| 2565 ASSERT_TRUE(Initialize()); | |
| 2566 if (FLAGS_quic_reloadable_flag_quic_always_enable_bidi_streaming) { | |
| 2567 // This test is testing the same behavior as | |
| 2568 // EarlyResponseWithQuicStreamNoError, except for the additional final check | |
| 2569 // that the stream is reset on early response. Once this flag is deprecated | |
| 2570 // the tests will be the same and this one can be removed. | |
| 2571 return; | |
| 2572 } | |
| 2573 | |
| 2574 EXPECT_TRUE(client_->client()->WaitForCryptoHandshakeConfirmed()); | |
| 2575 | |
| 2576 // POST to a URL that gets an early error response, after the headers are | |
| 2577 // received and before the body is received. | |
| 2578 SpdyHeaderBlock headers; | |
| 2579 headers[":method"] = "POST"; | |
| 2580 headers[":path"] = "/foo"; | |
| 2581 headers[":scheme"] = "https"; | |
| 2582 headers[":authority"] = server_hostname_; | |
| 2583 headers["content-length"] = "-1"; | |
| 2584 | |
| 2585 // Tell the client to not close the stream if it receives an early response. | |
| 2586 client_->set_allow_bidirectional_data(true); | |
| 2587 // Send the headers. | |
| 2588 client_->SendMessage(headers, "", /*fin=*/false); | |
| 2589 | |
| 2590 // Receive the response and let the server close writing. | |
| 2591 client_->WaitForInitialResponse(); | |
| 2592 EXPECT_EQ("500", client_->response_headers()->find(":status")->second); | |
| 2593 | |
| 2594 // Receive the reset stream from server on early response. | |
| 2595 QuicStream* stream = client_->client()->session()->GetOrCreateStream( | |
| 2596 GetNthClientInitiatedId(0)); | |
| 2597 // The stream is reset by server's reset stream. | |
| 2598 EXPECT_EQ(stream, nullptr); | |
| 2599 } | |
| 2600 | |
| 2601 TEST_P(EndToEndTest, Trailers) { | 2558 TEST_P(EndToEndTest, Trailers) { |
| 2602 // Test sending and receiving HTTP/2 Trailers (trailing HEADERS frames). | 2559 // Test sending and receiving HTTP/2 Trailers (trailing HEADERS frames). |
| 2603 ASSERT_TRUE(Initialize()); | 2560 ASSERT_TRUE(Initialize()); |
| 2604 EXPECT_TRUE(client_->client()->WaitForCryptoHandshakeConfirmed()); | 2561 EXPECT_TRUE(client_->client()->WaitForCryptoHandshakeConfirmed()); |
| 2605 | 2562 |
| 2606 // Set reordering to ensure that Trailers arriving before body is ok. | 2563 // Set reordering to ensure that Trailers arriving before body is ok. |
| 2607 SetPacketSendDelay(QuicTime::Delta::FromMilliseconds(2)); | 2564 SetPacketSendDelay(QuicTime::Delta::FromMilliseconds(2)); |
| 2608 SetReorderPercentage(30); | 2565 SetReorderPercentage(30); |
| 2609 | 2566 |
| 2610 // Add a response with headers, body, and trailers. | 2567 // Add a response with headers, body, and trailers. |
| (...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3135 client_->WaitForResponse(); | 3092 client_->WaitForResponse(); |
| 3136 EXPECT_EQ(kBarResponseBody, client_->response_body()); | 3093 EXPECT_EQ(kBarResponseBody, client_->response_body()); |
| 3137 QuicConnectionStats client_stats = | 3094 QuicConnectionStats client_stats = |
| 3138 client_->client()->session()->connection()->GetStats(); | 3095 client_->client()->session()->connection()->GetStats(); |
| 3139 EXPECT_EQ(0u, client_stats.packets_lost); | 3096 EXPECT_EQ(0u, client_stats.packets_lost); |
| 3140 EXPECT_EQ(1, client_->client()->GetNumSentClientHellos()); | 3097 EXPECT_EQ(1, client_->client()->GetNumSentClientHellos()); |
| 3141 } | 3098 } |
| 3142 } // namespace | 3099 } // namespace |
| 3143 } // namespace test | 3100 } // namespace test |
| 3144 } // namespace net | 3101 } // namespace net |
| OLD | NEW |