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 <list> | 9 #include <list> |
9 #include <memory> | 10 #include <memory> |
10 #include <string> | 11 #include <string> |
11 #include <utility> | 12 #include <utility> |
12 #include <vector> | 13 #include <vector> |
13 | 14 |
14 #include "base/memory/ptr_util.h" | 15 #include "base/memory/ptr_util.h" |
15 #include "base/memory/singleton.h" | 16 #include "base/memory/singleton.h" |
16 #include "base/strings/string_number_conversions.h" | 17 #include "base/strings/string_number_conversions.h" |
17 #include "base/synchronization/waitable_event.h" | 18 #include "base/synchronization/waitable_event.h" |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
56 #include "net/tools/quic/test_tools/quic_server_peer.h" | 57 #include "net/tools/quic/test_tools/quic_server_peer.h" |
57 #include "net/tools/quic/test_tools/quic_test_client.h" | 58 #include "net/tools/quic/test_tools/quic_test_client.h" |
58 #include "net/tools/quic/test_tools/quic_test_server.h" | 59 #include "net/tools/quic/test_tools/quic_test_server.h" |
59 #include "net/tools/quic/test_tools/server_thread.h" | 60 #include "net/tools/quic/test_tools/server_thread.h" |
60 #include "testing/gtest/include/gtest/gtest.h" | 61 #include "testing/gtest/include/gtest/gtest.h" |
61 | 62 |
62 using base::IntToString; | 63 using base::IntToString; |
63 using base::StringPiece; | 64 using base::StringPiece; |
64 using base::WaitableEvent; | 65 using base::WaitableEvent; |
65 using net::EpollServer; | 66 using net::EpollServer; |
66 using net::test::ConstructEncryptedPacket; | |
67 using net::test::CryptoTestUtils; | |
68 using net::test::GenerateBody; | |
69 using net::test::Loopback4; | |
70 using net::test::MockQuicConnectionDebugVisitor; | |
71 using net::test::QuicConnectionPeer; | |
72 using net::test::QuicFlowControllerPeer; | |
73 using net::test::QuicSentPacketManagerPeer; | |
74 using net::test::QuicSessionPeer; | |
75 using net::test::QuicSpdySessionPeer; | |
76 using net::test::ReliableQuicStreamPeer; | |
77 using net::test::kClientDataStreamId1; | |
78 using net::test::kInitialSessionFlowControlWindowForTest; | |
79 using net::test::kInitialStreamFlowControlWindowForTest; | |
80 using net::test::PacketDroppingTestWriter; | |
81 using net::test::QuicDispatcherPeer; | |
82 using net::test::QuicServerPeer; | |
83 using std::ostream; | 67 using std::ostream; |
84 using std::string; | 68 using std::string; |
85 using std::vector; | 69 using std::vector; |
86 | 70 |
87 namespace net { | 71 namespace net { |
88 namespace test { | 72 namespace test { |
89 namespace { | 73 namespace { |
90 | 74 |
91 const char kFooResponseBody[] = "Artichoke hearts make me happy."; | 75 const char kFooResponseBody[] = "Artichoke hearts make me happy."; |
92 const char kBarResponseBody[] = "Palm hearts are pretty delicious, also."; | 76 const char kBarResponseBody[] = "Palm hearts are pretty delicious, also."; |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
146 bool use_cheap_stateless_reject; | 130 bool use_cheap_stateless_reject; |
147 bool buffer_packet_till_chlo; | 131 bool buffer_packet_till_chlo; |
148 }; | 132 }; |
149 | 133 |
150 // Constructs various test permutations. | 134 // Constructs various test permutations. |
151 std::vector<TestParams> GetTestParams() { | 135 std::vector<TestParams> GetTestParams() { |
152 // Divide the versions into buckets in which the intra-frame format | 136 // Divide the versions into buckets in which the intra-frame format |
153 // is compatible. When clients encounter QUIC version negotiation | 137 // is compatible. When clients encounter QUIC version negotiation |
154 // they simply retransmit all packets using the new version's | 138 // they simply retransmit all packets using the new version's |
155 // QUIC framing. However, they are unable to change the intra-frame | 139 // QUIC framing. However, they are unable to change the intra-frame |
156 // layout (for example to change HTTP2 headers to SPDY/3). So | 140 // layout (for example to change HTTP/2 headers to SPDY/3). So |
157 // these tests need to ensure that clients are never attempting | 141 // these tests need to ensure that clients are never attempting |
158 // to do 0-RTT across incompatible versions. Chromium only supports | 142 // to do 0-RTT across incompatible versions. Chromium only supports |
159 // a single version at a time anyway. :) | 143 // a single version at a time anyway. :) |
160 QuicVersionVector all_supported_versions = AllSupportedVersions(); | 144 QuicVersionVector all_supported_versions = AllSupportedVersions(); |
161 QuicVersionVector version_buckets[3]; | 145 QuicVersionVector version_buckets[3]; |
162 | 146 |
163 for (const QuicVersion version : all_supported_versions) { | 147 for (const QuicVersion version : all_supported_versions) { |
164 if (version <= QUIC_VERSION_32) { | 148 if (version <= QUIC_VERSION_32) { |
165 // Versions: 31-32 | 149 // Versions: 31-32 |
166 // v31 adds a hash of the CHLO into the proof signature. | 150 // v31 adds a hash of the CHLO into the proof signature. |
(...skipping 10 matching lines...) Expand all Loading... | |
177 } | 161 } |
178 } | 162 } |
179 | 163 |
180 // This must be kept in sync with the number of nested for-loops below as it | 164 // This must be kept in sync with the number of nested for-loops below as it |
181 // is used to prune the number of tests that are run. | 165 // is used to prune the number of tests that are run. |
182 const int kMaxEnabledOptions = 6; | 166 const int kMaxEnabledOptions = 6; |
183 int max_enabled_options = 0; | 167 int max_enabled_options = 0; |
184 std::vector<TestParams> params; | 168 std::vector<TestParams> params; |
185 for (bool server_uses_stateless_rejects_if_peer_supported : {true, false}) { | 169 for (bool server_uses_stateless_rejects_if_peer_supported : {true, false}) { |
186 for (bool client_supports_stateless_rejects : {true, false}) { | 170 for (bool client_supports_stateless_rejects : {true, false}) { |
187 for (const QuicTag congestion_control_tag : {kRENO, kQBIC}) { | 171 for (const QuicTag congestion_control_tag : {kRENO, kTBBR, kQBIC}) { |
188 for (bool disable_hpack_dynamic_table : {false}) { | 172 for (bool disable_hpack_dynamic_table : {false}) { |
189 for (bool force_hol_blocking : {true, false}) { | 173 for (bool force_hol_blocking : {true, false}) { |
190 for (bool use_cheap_stateless_reject : {true, false}) { | 174 for (bool use_cheap_stateless_reject : {true, false}) { |
191 for (bool buffer_packet_till_chlo : {true, false}) { | 175 for (bool buffer_packet_till_chlo : {true, false}) { |
192 if (!buffer_packet_till_chlo && use_cheap_stateless_reject) { | 176 if (!buffer_packet_till_chlo && use_cheap_stateless_reject) { |
193 // Doing stateless reject while not buffering packet | 177 // Doing stateless reject while not buffering packet |
194 // before CHLO is not allowed. | 178 // before CHLO is not allowed. |
195 break; | 179 break; |
196 } | 180 } |
197 int enabled_options = 0; | 181 int enabled_options = 0; |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
438 client_config_.SetConnectionOptionsToSend(copt); | 422 client_config_.SetConnectionOptionsToSend(copt); |
439 | 423 |
440 // Start the server first, because CreateQuicClient() attempts | 424 // Start the server first, because CreateQuicClient() attempts |
441 // to connect to the server. | 425 // to connect to the server. |
442 StartServer(); | 426 StartServer(); |
443 | 427 |
444 CreateClientWithWriter(); | 428 CreateClientWithWriter(); |
445 static EpollEvent event(EPOLLOUT, false); | 429 static EpollEvent event(EPOLLOUT, false); |
446 if (client_writer_ != nullptr) { | 430 if (client_writer_ != nullptr) { |
447 client_writer_->Initialize( | 431 client_writer_->Initialize( |
448 reinterpret_cast<QuicEpollConnectionHelper*>( | 432 QuicConnectionPeer::GetHelper( |
449 QuicConnectionPeer::GetHelper( | 433 client_->client()->session()->connection()), |
450 client_->client()->session()->connection())), | |
451 QuicConnectionPeer::GetAlarmFactory( | 434 QuicConnectionPeer::GetAlarmFactory( |
452 client_->client()->session()->connection()), | 435 client_->client()->session()->connection()), |
453 new ClientDelegate(client_->client())); | 436 new ClientDelegate(client_->client())); |
454 } | 437 } |
455 initialized_ = true; | 438 initialized_ = true; |
456 return client_->client()->connected(); | 439 return client_->client()->connected(); |
457 } | 440 } |
458 | 441 |
459 void SetUp() override { | 442 void SetUp() override { |
460 // The ownership of these gets transferred to the QuicPacketWriterWrapper | 443 // The ownership of these gets transferred to the QuicPacketWriterWrapper |
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
780 } | 763 } |
781 | 764 |
782 TEST_P(EndToEndTest, LargePostNoPacketLoss) { | 765 TEST_P(EndToEndTest, LargePostNoPacketLoss) { |
783 ASSERT_TRUE(Initialize()); | 766 ASSERT_TRUE(Initialize()); |
784 | 767 |
785 client_->client()->WaitForCryptoHandshakeConfirmed(); | 768 client_->client()->WaitForCryptoHandshakeConfirmed(); |
786 | 769 |
787 // 1 MB body. | 770 // 1 MB body. |
788 string body; | 771 string body; |
789 GenerateBody(&body, 1024 * 1024); | 772 GenerateBody(&body, 1024 * 1024); |
790 | |
791 SpdyHeaderBlock headers; | 773 SpdyHeaderBlock headers; |
792 headers[":method"] = "POST"; | 774 headers[":method"] = "POST"; |
793 headers[":path"] = "/foo"; | 775 headers[":path"] = "/foo"; |
794 headers[":scheme"] = "https"; | 776 headers[":scheme"] = "https"; |
795 headers[":authority"] = server_hostname_; | 777 headers[":authority"] = server_hostname_; |
796 | 778 |
797 EXPECT_EQ(kFooResponseBody, | 779 EXPECT_EQ(kFooResponseBody, |
798 client_->SendCustomSynchronousRequest(headers, body)); | 780 client_->SendCustomSynchronousRequest(headers, body)); |
799 // TODO(ianswett): There should not be packet loss in this test, but on some | 781 // TODO(ianswett): There should not be packet loss in this test, but on some |
800 // platforms the receive buffer overflows. | 782 // platforms the receive buffer overflows. |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
832 } | 814 } |
833 ASSERT_TRUE(Initialize()); | 815 ASSERT_TRUE(Initialize()); |
834 | 816 |
835 // Wait for the server SHLO before upping the packet loss. | 817 // Wait for the server SHLO before upping the packet loss. |
836 client_->client()->WaitForCryptoHandshakeConfirmed(); | 818 client_->client()->WaitForCryptoHandshakeConfirmed(); |
837 SetPacketLossPercentage(30); | 819 SetPacketLossPercentage(30); |
838 | 820 |
839 // 10 KB body. | 821 // 10 KB body. |
840 string body; | 822 string body; |
841 GenerateBody(&body, 1024 * 10); | 823 GenerateBody(&body, 1024 * 10); |
842 test::GenerateBody(&body, 1024 * 10); | |
843 SpdyHeaderBlock headers; | 824 SpdyHeaderBlock headers; |
844 headers[":method"] = "POST"; | 825 headers[":method"] = "POST"; |
845 headers[":path"] = "/foo"; | 826 headers[":path"] = "/foo"; |
846 headers[":scheme"] = "https"; | 827 headers[":scheme"] = "https"; |
847 headers[":authority"] = server_hostname_; | 828 headers[":authority"] = server_hostname_; |
848 | 829 |
849 EXPECT_EQ(kFooResponseBody, | 830 EXPECT_EQ(kFooResponseBody, |
850 client_->SendCustomSynchronousRequest(headers, body)); | 831 client_->SendCustomSynchronousRequest(headers, body)); |
851 VerifyCleanConnection(true); | 832 VerifyCleanConnection(true); |
852 } | 833 } |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
926 const int expected_num_hellos_latest_session = | 907 const int expected_num_hellos_latest_session = |
927 BothSidesSupportStatelessRejects() ? 1 : 2; | 908 BothSidesSupportStatelessRejects() ? 1 : 2; |
928 EXPECT_EQ(expected_num_hellos_latest_session, | 909 EXPECT_EQ(expected_num_hellos_latest_session, |
929 client_->client()->session()->GetNumSentClientHellos()); | 910 client_->client()->session()->GetNumSentClientHellos()); |
930 EXPECT_EQ(2, client_->client()->GetNumSentClientHellos()); | 911 EXPECT_EQ(2, client_->client()->GetNumSentClientHellos()); |
931 | 912 |
932 client_->Disconnect(); | 913 client_->Disconnect(); |
933 | 914 |
934 // The 0-RTT handshake should succeed. | 915 // The 0-RTT handshake should succeed. |
935 client_->Connect(); | 916 client_->Connect(); |
936 client_->WaitForResponseForMs(-1); | 917 client_->WaitForInitialResponse(); |
937 ASSERT_TRUE(client_->client()->connected()); | 918 ASSERT_TRUE(client_->client()->connected()); |
938 EXPECT_EQ(kFooResponseBody, | 919 EXPECT_EQ(kFooResponseBody, |
939 client_->SendCustomSynchronousRequest(headers, body)); | 920 client_->SendCustomSynchronousRequest(headers, body)); |
940 | 921 |
941 if (negotiated_version_ <= QUIC_VERSION_32) { | 922 if (negotiated_version_ <= QUIC_VERSION_32) { |
942 EXPECT_EQ(expected_num_hellos_latest_session, | 923 EXPECT_EQ(expected_num_hellos_latest_session, |
943 client_->client()->session()->GetNumSentClientHellos()); | 924 client_->client()->session()->GetNumSentClientHellos()); |
944 EXPECT_EQ(2, client_->client()->GetNumSentClientHellos()); | 925 EXPECT_EQ(2, client_->client()->GetNumSentClientHellos()); |
945 } else { | 926 } else { |
946 EXPECT_EQ(1, client_->client()->session()->GetNumSentClientHellos()); | 927 EXPECT_EQ(1, client_->client()->session()->GetNumSentClientHellos()); |
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1198 QuicConnectionPeer::GetResumeWritesAlarm(session->connection()); | 1179 QuicConnectionPeer::GetResumeWritesAlarm(session->connection()); |
1199 EXPECT_FALSE(resume_writes_alarm->IsSet()); | 1180 EXPECT_FALSE(resume_writes_alarm->IsSet()); |
1200 } | 1181 } |
1201 | 1182 |
1202 TEST_P(EndToEndTest, InvalidStream) { | 1183 TEST_P(EndToEndTest, InvalidStream) { |
1203 ASSERT_TRUE(Initialize()); | 1184 ASSERT_TRUE(Initialize()); |
1204 client_->client()->WaitForCryptoHandshakeConfirmed(); | 1185 client_->client()->WaitForCryptoHandshakeConfirmed(); |
1205 | 1186 |
1206 string body; | 1187 string body; |
1207 GenerateBody(&body, kMaxPacketSize); | 1188 GenerateBody(&body, kMaxPacketSize); |
1208 | |
1209 SpdyHeaderBlock headers; | 1189 SpdyHeaderBlock headers; |
1210 headers[":method"] = "POST"; | 1190 headers[":method"] = "POST"; |
1211 headers[":path"] = "/foo"; | 1191 headers[":path"] = "/foo"; |
1212 headers[":scheme"] = "https"; | 1192 headers[":scheme"] = "https"; |
1213 headers[":authority"] = server_hostname_; | 1193 headers[":authority"] = server_hostname_; |
1194 | |
1214 // Force the client to write with a stream ID belonging to a nonexistent | 1195 // Force the client to write with a stream ID belonging to a nonexistent |
1215 // server-side stream. | 1196 // server-side stream. |
1216 QuicSessionPeer::SetNextOutgoingStreamId(client_->client()->session(), 2); | 1197 QuicSessionPeer::SetNextOutgoingStreamId(client_->client()->session(), 2); |
1217 | 1198 |
1218 client_->SendCustomSynchronousRequest(headers, body); | 1199 client_->SendCustomSynchronousRequest(headers, body); |
1219 // EXPECT_EQ(QUIC_STREAM_CONNECTION_ERROR, client_->stream_error()); | |
1220 EXPECT_EQ(QUIC_STREAM_CONNECTION_ERROR, client_->stream_error()); | 1200 EXPECT_EQ(QUIC_STREAM_CONNECTION_ERROR, client_->stream_error()); |
1221 EXPECT_EQ(QUIC_INVALID_STREAM_ID, client_->connection_error()); | 1201 EXPECT_EQ(QUIC_INVALID_STREAM_ID, client_->connection_error()); |
1222 } | 1202 } |
1223 | 1203 |
1224 // Test that if the the server will close the connection if the client attempts | 1204 // Test that if the the server will close the connection if the client attempts |
1225 // to send a request with overly large headers. | 1205 // to send a request with overly large headers. |
1226 TEST_P(EndToEndTest, LargeHeaders) { | 1206 TEST_P(EndToEndTest, LargeHeaders) { |
1227 ASSERT_TRUE(Initialize()); | 1207 ASSERT_TRUE(Initialize()); |
1228 client_->client()->WaitForCryptoHandshakeConfirmed(); | 1208 client_->client()->WaitForCryptoHandshakeConfirmed(); |
1229 | 1209 |
1230 string body; | 1210 string body; |
1231 test::GenerateBody(&body, kMaxPacketSize); | 1211 GenerateBody(&body, kMaxPacketSize); |
1232 | |
1233 SpdyHeaderBlock headers; | 1212 SpdyHeaderBlock headers; |
1234 headers[":method"] = "POST"; | 1213 headers[":method"] = "POST"; |
1235 headers[":path"] = "/foo"; | 1214 headers[":path"] = "/foo"; |
1236 headers[":scheme"] = "https"; | 1215 headers[":scheme"] = "https"; |
1237 headers[":authority"] = server_hostname_; | 1216 headers[":authority"] = server_hostname_; |
1238 headers["key1"] = string(15 * 1024, 'a'); | 1217 headers["key1"] = string(15 * 1024, 'a'); |
1239 headers["key2"] = string(15 * 1024, 'a'); | 1218 headers["key2"] = string(15 * 1024, 'a'); |
1240 headers["key3"] = string(15 * 1024, 'a'); | 1219 headers["key3"] = string(15 * 1024, 'a'); |
1241 | 1220 |
1242 client_->SendCustomSynchronousRequest(headers, body); | 1221 client_->SendCustomSynchronousRequest(headers, body); |
1243 if (FLAGS_quic_limit_uncompressed_headers) { | 1222 if (FLAGS_quic_limit_uncompressed_headers) { |
1244 EXPECT_EQ(QUIC_HEADERS_TOO_LARGE, client_->stream_error()); | 1223 EXPECT_EQ(QUIC_HEADERS_TOO_LARGE, client_->stream_error()); |
1245 } else { | 1224 } else { |
1246 EXPECT_EQ(QUIC_STREAM_NO_ERROR, client_->stream_error()); | 1225 EXPECT_EQ(QUIC_STREAM_NO_ERROR, client_->stream_error()); |
1247 EXPECT_EQ(kFooResponseBody, client_->response_body()); | 1226 EXPECT_EQ(kFooResponseBody, client_->response_body()); |
1248 EXPECT_EQ("200", client_->response_headers()->find(":status")->second); | 1227 EXPECT_EQ("200", client_->response_headers()->find(":status")->second); |
1249 } | 1228 } |
1250 EXPECT_EQ(QUIC_NO_ERROR, client_->connection_error()); | 1229 EXPECT_EQ(QUIC_NO_ERROR, client_->connection_error()); |
1251 } | 1230 } |
1252 | 1231 |
1253 TEST_P(EndToEndTest, EarlyResponseWithQuicStreamNoError) { | 1232 TEST_P(EndToEndTest, EarlyResponseWithQuicStreamNoError) { |
1254 ASSERT_TRUE(Initialize()); | 1233 ASSERT_TRUE(Initialize()); |
1255 client_->client()->WaitForCryptoHandshakeConfirmed(); | 1234 client_->client()->WaitForCryptoHandshakeConfirmed(); |
1256 | 1235 |
1257 string large_body; | 1236 string large_body; |
1258 GenerateBody(&large_body, 1024 * 1024); | 1237 GenerateBody(&large_body, 1024 * 1024); |
1259 | |
1260 SpdyHeaderBlock headers; | 1238 SpdyHeaderBlock headers; |
1261 headers[":method"] = "POST"; | 1239 headers[":method"] = "POST"; |
1262 headers[":path"] = "/foo"; | 1240 headers[":path"] = "/foo"; |
1263 headers[":scheme"] = "https"; | 1241 headers[":scheme"] = "https"; |
1264 headers[":authority"] = server_hostname_; | 1242 headers[":authority"] = server_hostname_; |
1265 | |
1266 // Insert an invalid content_length field in request to trigger an early | 1243 // Insert an invalid content_length field in request to trigger an early |
1267 // response from server. | 1244 // response from server. |
1268 headers["content-length"] = "-3"; | 1245 headers["content-length"] = "-3"; |
1269 | 1246 |
1270 client_->SendCustomSynchronousRequest(headers, large_body); | 1247 client_->SendCustomSynchronousRequest(headers, large_body); |
1271 EXPECT_EQ("bad", client_->response_body()); | 1248 EXPECT_EQ("bad", client_->response_body()); |
1272 EXPECT_EQ("500", client_->response_headers()->find(":status")->second); | 1249 EXPECT_EQ("500", client_->response_headers()->find(":status")->second); |
1273 EXPECT_EQ(QUIC_STREAM_NO_ERROR, client_->stream_error()); | 1250 EXPECT_EQ(QUIC_STREAM_NO_ERROR, client_->stream_error()); |
1274 EXPECT_EQ(QUIC_NO_ERROR, client_->connection_error()); | 1251 EXPECT_EQ(QUIC_NO_ERROR, client_->connection_error()); |
1275 } | 1252 } |
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1581 EXPECT_EQ(kFooResponseBody, client_->SendSynchronousRequest("/foo")); | 1558 EXPECT_EQ(kFooResponseBody, client_->SendSynchronousRequest("/foo")); |
1582 EXPECT_EQ("200", client_->response_headers()->find(":status")->second); | 1559 EXPECT_EQ("200", client_->response_headers()->find(":status")->second); |
1583 QuicPacketHeader* header = QuicConnectionPeer::GetLastHeader( | 1560 QuicPacketHeader* header = QuicConnectionPeer::GetLastHeader( |
1584 client_->client()->session()->connection()); | 1561 client_->client()->session()->connection()); |
1585 EXPECT_EQ(PACKET_8BYTE_CONNECTION_ID, | 1562 EXPECT_EQ(PACKET_8BYTE_CONNECTION_ID, |
1586 header->public_header.connection_id_length); | 1563 header->public_header.connection_id_length); |
1587 } | 1564 } |
1588 | 1565 |
1589 TEST_P(EndToEndTest, ResetConnection) { | 1566 TEST_P(EndToEndTest, ResetConnection) { |
1590 ASSERT_TRUE(Initialize()); | 1567 ASSERT_TRUE(Initialize()); |
1591 client_->client()->WaitForCryptoHandshakeConfirmed(); | |
1592 | 1568 |
1593 EXPECT_EQ(kFooResponseBody, client_->SendSynchronousRequest("/foo")); | 1569 EXPECT_EQ(kFooResponseBody, client_->SendSynchronousRequest("/foo")); |
1594 EXPECT_EQ("200", client_->response_headers()->find(":status")->second); | 1570 EXPECT_EQ("200", client_->response_headers()->find(":status")->second); |
1595 client_->ResetConnection(); | 1571 client_->ResetConnection(); |
1596 EXPECT_EQ(kBarResponseBody, client_->SendSynchronousRequest("/bar")); | 1572 EXPECT_EQ(kBarResponseBody, client_->SendSynchronousRequest("/bar")); |
1597 EXPECT_EQ("200", client_->response_headers()->find(":status")->second); | 1573 EXPECT_EQ("200", client_->response_headers()->find(":status")->second); |
1598 } | 1574 } |
1599 | 1575 |
1600 TEST_P(EndToEndTest, MaxStreamsUberTest) { | 1576 TEST_P(EndToEndTest, MaxStreamsUberTest) { |
1601 if (!BothSidesSupportStatelessRejects()) { | 1577 if (!BothSidesSupportStatelessRejects()) { |
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1980 | 1956 |
1981 // Send the request, and register the delegate for ACKs. | 1957 // Send the request, and register the delegate for ACKs. |
1982 client_->SendData(request_string, true, delegate.get()); | 1958 client_->SendData(request_string, true, delegate.get()); |
1983 client_->WaitForResponse(); | 1959 client_->WaitForResponse(); |
1984 EXPECT_EQ(kFooResponseBody, client_->response_body()); | 1960 EXPECT_EQ(kFooResponseBody, client_->response_body()); |
1985 EXPECT_EQ("200", client_->response_headers()->find(":status")->second); | 1961 EXPECT_EQ("200", client_->response_headers()->find(":status")->second); |
1986 | 1962 |
1987 // Send another request to flush out any pending ACKs on the server. | 1963 // Send another request to flush out any pending ACKs on the server. |
1988 client_->SendSynchronousRequest("/bar"); | 1964 client_->SendSynchronousRequest("/bar"); |
1989 | 1965 |
1990 // Pause the server to avoid races. | |
1991 server_thread_->Pause(); | |
Jana
2016/11/03 17:51:40
Assuming that this doesn't cause races now?
Ryan Hamilton
2016/11/03 17:57:29
Right. To be safe, I took the chrome code and atte
| |
1992 // Make sure the delegate does get the notification it expects. | 1966 // Make sure the delegate does get the notification it expects. |
1993 while (!delegate->has_been_notified()) { | 1967 while (!delegate->has_been_notified()) { |
1994 // Waits for up to 50 ms. | 1968 // Waits for up to 50 ms. |
1995 client_->client()->WaitForEvents(); | 1969 client_->client()->WaitForEvents(); |
1996 } | 1970 } |
1997 server_thread_->Resume(); | |
1998 } | 1971 } |
1999 | 1972 |
2000 // Send a public reset from the server. | 1973 // Send a public reset from the server. |
2001 TEST_P(EndToEndTest, ServerSendPublicReset) { | 1974 TEST_P(EndToEndTest, ServerSendPublicReset) { |
2002 ASSERT_TRUE(Initialize()); | 1975 ASSERT_TRUE(Initialize()); |
2003 | 1976 |
2004 // Send the public reset. | 1977 // Send the public reset. |
2005 QuicConnectionId connection_id = | 1978 QuicConnectionId connection_id = |
2006 client_->client()->session()->connection()->connection_id(); | 1979 client_->client()->session()->connection()->connection_id(); |
2007 QuicPublicResetPacket header; | 1980 QuicPublicResetPacket header; |
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2332 QuicSpdySession* session, | 2305 QuicSpdySession* session, |
2333 int64_t body_bytes) | 2306 int64_t body_bytes) |
2334 : QuicSimpleServerStream(id, session), body_bytes_(body_bytes) {} | 2307 : QuicSimpleServerStream(id, session), body_bytes_(body_bytes) {} |
2335 | 2308 |
2336 ~ServerStreamThatSendsHugeResponse() override {} | 2309 ~ServerStreamThatSendsHugeResponse() override {} |
2337 | 2310 |
2338 protected: | 2311 protected: |
2339 void SendResponse() override { | 2312 void SendResponse() override { |
2340 QuicInMemoryCache::Response response; | 2313 QuicInMemoryCache::Response response; |
2341 string body; | 2314 string body; |
2342 test::GenerateBody(&body, body_bytes_); | 2315 GenerateBody(&body, body_bytes_); |
2343 response.set_body(body); | 2316 response.set_body(body); |
2344 SendHeadersAndBodyAndTrailers(response.headers().Clone(), response.body(), | 2317 SendHeadersAndBodyAndTrailers(response.headers().Clone(), response.body(), |
2345 response.trailers().Clone()); | 2318 response.trailers().Clone()); |
2346 } | 2319 } |
2347 | 2320 |
2348 private: | 2321 private: |
2349 // Use a explicit int64 rather than size_t to simulate a 64-bit server talking | 2322 // Use a explicit int64_t rather than size_t to simulate a 64-bit server |
2350 // to a 32-bit client. | 2323 // talking to a 32-bit client. |
2351 int64_t body_bytes_; | 2324 int64_t body_bytes_; |
2352 }; | 2325 }; |
2353 | 2326 |
2354 class ServerStreamThatSendsHugeResponseFactory | 2327 class ServerStreamThatSendsHugeResponseFactory |
2355 : public QuicTestServer::StreamFactory { | 2328 : public QuicTestServer::StreamFactory { |
2356 public: | 2329 public: |
2357 explicit ServerStreamThatSendsHugeResponseFactory(int64_t body_bytes) | 2330 explicit ServerStreamThatSendsHugeResponseFactory(int64_t body_bytes) |
2358 : body_bytes_(body_bytes) {} | 2331 : body_bytes_(body_bytes) {} |
2359 | 2332 |
2360 ~ServerStreamThatSendsHugeResponseFactory() override{}; | 2333 ~ServerStreamThatSendsHugeResponseFactory() override{}; |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2474 | 2447 |
2475 StreamWithErrorFactory stream_factory(response_body); | 2448 StreamWithErrorFactory stream_factory(response_body); |
2476 SetSpdyStreamFactory(&stream_factory); | 2449 SetSpdyStreamFactory(&stream_factory); |
2477 | 2450 |
2478 ASSERT_TRUE(Initialize()); | 2451 ASSERT_TRUE(Initialize()); |
2479 | 2452 |
2480 client_->client()->WaitForCryptoHandshakeConfirmed(); | 2453 client_->client()->WaitForCryptoHandshakeConfirmed(); |
2481 | 2454 |
2482 // A POST that gets an early error response, after the headers are received | 2455 // A POST that gets an early error response, after the headers are received |
2483 // and before the body is received, due to invalid content-length. | 2456 // and before the body is received, due to invalid content-length. |
2457 // Set an invalid content-length, so the request will receive an early 500 | |
2458 // response. | |
2484 SpdyHeaderBlock headers; | 2459 SpdyHeaderBlock headers; |
2485 headers[":method"] = "POST"; | 2460 headers[":method"] = "POST"; |
2486 headers[":path"] = "/garbage"; | 2461 headers[":path"] = "/garbage"; |
2487 headers[":scheme"] = "https"; | 2462 headers[":scheme"] = "https"; |
2488 headers[":authority"] = server_hostname_; | 2463 headers[":authority"] = server_hostname_; |
2464 headers["content-length"] = "-1"; | |
2489 | 2465 |
2490 // The body must be large enough that the FIN will be in a different packet | 2466 // The body must be large enough that the FIN will be in a different packet |
2491 // than the end of the headers, but short enough to not require a flow control | 2467 // than the end of the headers, but short enough to not require a flow control |
2492 // update. This allows headers processing to trigger the error response | 2468 // update. This allows headers processing to trigger the error response |
2493 // before the request FIN is processed but receive the request FIN before the | 2469 // before the request FIN is processed but receive the request FIN before the |
2494 // response is sent completely. | 2470 // response is sent completely. |
2495 const uint32_t kRequestBodySize = kMaxPacketSize + 10; | 2471 const uint32_t kRequestBodySize = kMaxPacketSize + 10; |
2496 string request_body; | 2472 string request_body; |
2497 GenerateBody(&request_body, kRequestBodySize); | 2473 GenerateBody(&request_body, kRequestBodySize); |
2498 // Set an invalid content-length, so the request will receive an early 500 | |
2499 // response. Must be done after AddBody, which also sets content-length. | |
2500 headers["content-length"] = "-1"; | |
2501 | 2474 |
2502 // Send the request. | 2475 // Send the request. |
2503 client_->SendMessage(headers, request_body); | 2476 client_->SendMessage(headers, request_body); |
2504 client_->WaitForResponse(); | 2477 client_->WaitForResponse(); |
2505 EXPECT_EQ("500", client_->response_headers()->find(":status")->second); | 2478 EXPECT_EQ("500", client_->response_headers()->find(":status")->second); |
2506 | 2479 |
2507 // Pause the server so we can access the server's internals without races. | 2480 // Pause the server so we can access the server's internals without races. |
2508 server_thread_->Pause(); | 2481 server_thread_->Pause(); |
2509 | 2482 |
2510 QuicDispatcher* dispatcher = | 2483 QuicDispatcher* dispatcher = |
(...skipping 20 matching lines...) Expand all Loading... | |
2531 set_server_initial_session_flow_control_receive_window(kWindowSize); | 2504 set_server_initial_session_flow_control_receive_window(kWindowSize); |
2532 | 2505 |
2533 ASSERT_TRUE(Initialize()); | 2506 ASSERT_TRUE(Initialize()); |
2534 | 2507 |
2535 client_->client()->WaitForCryptoHandshakeConfirmed(); | 2508 client_->client()->WaitForCryptoHandshakeConfirmed(); |
2536 | 2509 |
2537 // POST to a URL that gets an early error response, after the headers are | 2510 // POST to a URL that gets an early error response, after the headers are |
2538 // received and before the body is received. | 2511 // received and before the body is received. |
2539 SpdyHeaderBlock headers; | 2512 SpdyHeaderBlock headers; |
2540 headers[":method"] = "POST"; | 2513 headers[":method"] = "POST"; |
2541 headers[":path"] = "/garbage"; | 2514 headers[":path"] = "/foo"; |
2542 headers[":scheme"] = "https"; | 2515 headers[":scheme"] = "https"; |
2543 headers[":authority"] = server_hostname_; | 2516 headers[":authority"] = server_hostname_; |
2544 | |
2545 // Invalid content-length so the request will receive an early 500 response. | |
Jana
2016/11/03 17:51:40
nit: move this comment to the comment block above
Ryan Hamilton
2016/11/03 17:57:28
meh. the comment above headers already talks about
| |
2546 headers["content-length"] = "-1"; | 2517 headers["content-length"] = "-1"; |
2547 | 2518 |
2548 // Tell the client to not close the stream if it receives an early response. | 2519 // Tell the client to not close the stream if it receives an early response. |
2549 client_->set_allow_bidirectional_data(true); | 2520 client_->set_allow_bidirectional_data(true); |
2550 // Send the headers. | 2521 // Send the headers. |
2551 client_->SendMessage(headers, "", false); | 2522 client_->SendMessage(headers, "", /*fin=*/false); |
2523 | |
2552 // Receive the response and let the server close writing. | 2524 // Receive the response and let the server close writing. |
2553 client_->WaitForInitialResponse(); | 2525 client_->WaitForInitialResponse(); |
2554 EXPECT_EQ("500", client_->response_headers()->find(":status")->second); | 2526 EXPECT_EQ("500", client_->response_headers()->find(":status")->second); |
2555 | 2527 |
2556 // Receive the reset stream from server on early response. | 2528 // Receive the reset stream from server on early response. |
2557 ReliableQuicStream* stream = | 2529 ReliableQuicStream* stream = |
2558 client_->client()->session()->GetOrCreateStream(kClientDataStreamId1); | 2530 client_->client()->session()->GetOrCreateStream(kClientDataStreamId1); |
2559 // The stream is reset by server's reset stream. | 2531 // The stream is reset by server's reset stream. |
2560 EXPECT_EQ(stream, nullptr); | 2532 EXPECT_EQ(stream, nullptr); |
2561 } | 2533 } |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2610 string path, | 2582 string path, |
2611 string response_body, | 2583 string response_body, |
2612 string* push_urls, | 2584 string* push_urls, |
2613 const size_t num_resources, | 2585 const size_t num_resources, |
2614 const size_t resource_size) { | 2586 const size_t resource_size) { |
2615 bool use_large_response = resource_size != 0; | 2587 bool use_large_response = resource_size != 0; |
2616 string large_resource; | 2588 string large_resource; |
2617 if (use_large_response) { | 2589 if (use_large_response) { |
2618 // Generate a response common body larger than flow control window for | 2590 // Generate a response common body larger than flow control window for |
2619 // push response. | 2591 // push response. |
2620 test::GenerateBody(&large_resource, resource_size); | 2592 GenerateBody(&large_resource, resource_size); |
2621 } | 2593 } |
2622 std::list<QuicInMemoryCache::ServerPushInfo> push_resources; | 2594 std::list<QuicInMemoryCache::ServerPushInfo> push_resources; |
2623 for (size_t i = 0; i < num_resources; ++i) { | 2595 for (size_t i = 0; i < num_resources; ++i) { |
2624 string url = push_urls[i]; | 2596 string url = push_urls[i]; |
2625 GURL resource_url(url); | 2597 GURL resource_url(url); |
2626 string body = use_large_response | 2598 string body = use_large_response |
2627 ? large_resource | 2599 ? large_resource |
2628 : "This is server push response body for " + url; | 2600 : "This is server push response body for " + url; |
2629 SpdyHeaderBlock response_headers; | 2601 SpdyHeaderBlock response_headers; |
2630 response_headers[":version"] = "HTTP/1.1"; | 2602 response_headers[":version"] = "HTTP/1.1"; |
(...skipping 17 matching lines...) Expand all Loading... | |
2648 ASSERT_TRUE(Initialize()); | 2620 ASSERT_TRUE(Initialize()); |
2649 client_->client()->WaitForCryptoHandshakeConfirmed(); | 2621 client_->client()->WaitForCryptoHandshakeConfirmed(); |
2650 | 2622 |
2651 // Set reordering to ensure that body arriving before PUSH_PROMISE is ok. | 2623 // Set reordering to ensure that body arriving before PUSH_PROMISE is ok. |
2652 SetPacketSendDelay(QuicTime::Delta::FromMilliseconds(2)); | 2624 SetPacketSendDelay(QuicTime::Delta::FromMilliseconds(2)); |
2653 SetReorderPercentage(30); | 2625 SetReorderPercentage(30); |
2654 | 2626 |
2655 // Add a response with headers, body, and push resources. | 2627 // Add a response with headers, body, and push resources. |
2656 const string kBody = "body content"; | 2628 const string kBody = "body content"; |
2657 size_t kNumResources = 4; | 2629 size_t kNumResources = 4; |
2658 string push_urls[] = { | 2630 string push_urls[] = {"https://example.com/font.woff", |
2659 "https://google.com/font.woff", "https://google.com/script.js", | 2631 "https://example.com/script.js", |
2660 "https://fonts.google.com/font.woff", "https://google.com/logo-hires.jpg", | 2632 "https://fonts.example.com/font.woff", |
2661 }; | 2633 "https://example.com/logo-hires.jpg"}; |
2662 AddRequestAndResponseWithServerPush("example.com", "/push_example", kBody, | 2634 AddRequestAndResponseWithServerPush("example.com", "/push_example", kBody, |
2663 push_urls, kNumResources, 0); | 2635 push_urls, kNumResources, 0); |
2664 | 2636 |
2665 client_->client()->set_response_listener( | 2637 client_->client()->set_response_listener( |
2666 std::unique_ptr<QuicClientBase::ResponseListener>( | 2638 std::unique_ptr<QuicClientBase::ResponseListener>( |
2667 new TestResponseListener)); | 2639 new TestResponseListener)); |
2668 | 2640 |
2669 DVLOG(1) << "send request for /push_example"; | 2641 DVLOG(1) << "send request for /push_example"; |
2670 EXPECT_EQ(kBody, client_->SendSynchronousRequest( | 2642 EXPECT_EQ(kBody, client_->SendSynchronousRequest( |
2671 "https://example.com/push_example")); | 2643 "https://example.com/push_example")); |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2747 // Set reordering to ensure that body arriving before PUSH_PROMISE is ok. | 2719 // Set reordering to ensure that body arriving before PUSH_PROMISE is ok. |
2748 SetPacketSendDelay(QuicTime::Delta::FromMilliseconds(2)); | 2720 SetPacketSendDelay(QuicTime::Delta::FromMilliseconds(2)); |
2749 SetReorderPercentage(30); | 2721 SetReorderPercentage(30); |
2750 | 2722 |
2751 // Add a response with headers, body, and push resources. | 2723 // Add a response with headers, body, and push resources. |
2752 const string kBody = "body content"; | 2724 const string kBody = "body content"; |
2753 | 2725 |
2754 // One more resource than max number of outgoing stream of this session. | 2726 // One more resource than max number of outgoing stream of this session. |
2755 const size_t kNumResources = 1 + kNumMaxStreams; // 11. | 2727 const size_t kNumResources = 1 + kNumMaxStreams; // 11. |
2756 string push_urls[11]; | 2728 string push_urls[11]; |
2757 for (uint32_t i = 0; i < kNumResources; ++i) { | 2729 for (size_t i = 0; i < kNumResources; ++i) { |
2758 push_urls[i] = "https://example.com/push_resources" + base::UintToString(i); | 2730 push_urls[i] = "https://example.com/push_resources" + base::UintToString(i); |
2759 } | 2731 } |
2760 AddRequestAndResponseWithServerPush("example.com", "/push_example", kBody, | 2732 AddRequestAndResponseWithServerPush("example.com", "/push_example", kBody, |
2761 push_urls, kNumResources, 0); | 2733 push_urls, kNumResources, 0); |
2762 client_->client()->set_response_listener( | 2734 client_->client()->set_response_listener( |
2763 std::unique_ptr<QuicClientBase::ResponseListener>( | 2735 std::unique_ptr<QuicClientBase::ResponseListener>( |
2764 new TestResponseListener)); | 2736 new TestResponseListener)); |
2765 | 2737 |
2766 // Send the first request: this will trigger the server to send all the push | 2738 // Send the first request: this will trigger the server to send all the push |
2767 // resources associated with this request, and these will be cached by the | 2739 // resources associated with this request, and these will be cached by the |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2804 | 2776 |
2805 // Set reordering to ensure that body arriving before PUSH_PROMISE is ok. | 2777 // Set reordering to ensure that body arriving before PUSH_PROMISE is ok. |
2806 SetPacketSendDelay(QuicTime::Delta::FromMilliseconds(2)); | 2778 SetPacketSendDelay(QuicTime::Delta::FromMilliseconds(2)); |
2807 SetReorderPercentage(30); | 2779 SetReorderPercentage(30); |
2808 | 2780 |
2809 // Add a response with headers, body, and push resources. | 2781 // Add a response with headers, body, and push resources. |
2810 const string kBody = "body content"; | 2782 const string kBody = "body content"; |
2811 | 2783 |
2812 const size_t kNumResources = kNumMaxStreams + 1; | 2784 const size_t kNumResources = kNumMaxStreams + 1; |
2813 string push_urls[11]; | 2785 string push_urls[11]; |
2814 for (uint32_t i = 0; i < kNumResources; ++i) { | 2786 for (size_t i = 0; i < kNumResources; ++i) { |
2815 push_urls[i] = "http://example.com/push_resources" + base::UintToString(i); | 2787 push_urls[i] = "http://example.com/push_resources" + base::UintToString(i); |
2816 } | 2788 } |
2817 AddRequestAndResponseWithServerPush("example.com", "/push_example", kBody, | 2789 AddRequestAndResponseWithServerPush("example.com", "/push_example", kBody, |
2818 push_urls, kNumResources, kBodySize); | 2790 push_urls, kNumResources, kBodySize); |
2819 | 2791 |
2820 client_->client()->set_response_listener( | 2792 client_->client()->set_response_listener( |
2821 std::unique_ptr<QuicClientBase::ResponseListener>( | 2793 std::unique_ptr<QuicClientBase::ResponseListener>( |
2822 new TestResponseListener)); | 2794 new TestResponseListener)); |
2823 | 2795 |
2824 client_->SendRequest("https://example.com/push_example"); | 2796 client_->SendRequest("https://example.com/push_example"); |
(...skipping 21 matching lines...) Expand all Loading... | |
2846 | 2818 |
2847 // "Send" request for a promised resources will not really send out it because | 2819 // "Send" request for a promised resources will not really send out it because |
2848 // its response is being pushed(but blocked). And the following ack and | 2820 // its response is being pushed(but blocked). And the following ack and |
2849 // flow control behavior of SendSynchronousRequests() | 2821 // flow control behavior of SendSynchronousRequests() |
2850 // will unblock the stream to finish receiving response. | 2822 // will unblock the stream to finish receiving response. |
2851 client_->SendSynchronousRequest(push_urls[0]); | 2823 client_->SendSynchronousRequest(push_urls[0]); |
2852 EXPECT_EQ(1u, client_->num_requests()); | 2824 EXPECT_EQ(1u, client_->num_requests()); |
2853 EXPECT_EQ(2u, client_->num_responses()); | 2825 EXPECT_EQ(2u, client_->num_responses()); |
2854 | 2826 |
2855 // Do same thing for the rest 10 resources. | 2827 // Do same thing for the rest 10 resources. |
2856 for (uint32_t i = 1; i < kNumResources; ++i) { | 2828 for (size_t i = 1; i < kNumResources; ++i) { |
2857 client_->SendSynchronousRequest(push_urls[i]); | 2829 client_->SendSynchronousRequest(push_urls[i]); |
2858 } | 2830 } |
2859 | 2831 |
2860 // Because of server push, client gets all pushed resources without actually | 2832 // Because of server push, client gets all pushed resources without actually |
2861 // sending requests for them. | 2833 // sending requests for them. |
2862 EXPECT_EQ(1u, client_->num_requests()); | 2834 EXPECT_EQ(1u, client_->num_requests()); |
2863 // Including response to original request, 12 responses in total were | 2835 // Including response to original request, 12 responses in total were |
2864 // recieved. | 2836 // recieved. |
2865 EXPECT_EQ(12u, client_->num_responses()); | 2837 EXPECT_EQ(12u, client_->num_responses()); |
2866 } | 2838 } |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2911 ASSERT_TRUE(Initialize()); | 2883 ASSERT_TRUE(Initialize()); |
2912 // Set client's epoll server's time out to 0 to make this test be finished | 2884 // Set client's epoll server's time out to 0 to make this test be finished |
2913 // within a short time. | 2885 // within a short time. |
2914 client_->epoll_server()->set_timeout_in_us(0); | 2886 client_->epoll_server()->set_timeout_in_us(0); |
2915 | 2887 |
2916 client_->client()->WaitForCryptoHandshakeConfirmed(); | 2888 client_->client()->WaitForCryptoHandshakeConfirmed(); |
2917 SetPacketLossPercentage(1); | 2889 SetPacketLossPercentage(1); |
2918 // To avoid storing the whole request body in memory, use a loop to repeatedly | 2890 // To avoid storing the whole request body in memory, use a loop to repeatedly |
2919 // send body size of kSizeBytes until the whole request body size is reached. | 2891 // send body size of kSizeBytes until the whole request body size is reached. |
2920 const int kSizeBytes = 128 * 1024; | 2892 const int kSizeBytes = 128 * 1024; |
2893 // Request body size is 4G plus one more kSizeBytes. | |
2894 int64_t request_body_size_bytes = pow(2, 32) + kSizeBytes; | |
2895 ASSERT_LT(INT64_C(4294967296), request_body_size_bytes); | |
2896 string body; | |
2897 GenerateBody(&body, kSizeBytes); | |
2898 | |
2921 SpdyHeaderBlock headers; | 2899 SpdyHeaderBlock headers; |
2922 headers[":method"] = "POST"; | 2900 headers[":method"] = "POST"; |
2923 headers[":path"] = "/foo"; | 2901 headers[":path"] = "/foo"; |
2924 headers[":scheme"] = "https"; | 2902 headers[":scheme"] = "https"; |
2925 headers[":authority"] = server_hostname_; | 2903 headers[":authority"] = server_hostname_; |
2926 | |
2927 // Request body size is 4G plus one more kSizeBytes. | |
2928 int64_t request_body_size_bytes = pow(2, 32) + kSizeBytes; | |
2929 ASSERT_LT(INT64_C(4294967296), request_body_size_bytes); | |
2930 headers["content-length"] = IntToString(request_body_size_bytes); | 2904 headers["content-length"] = IntToString(request_body_size_bytes); |
2931 string body; | |
2932 test::GenerateBody(&body, kSizeBytes); | |
2933 | 2905 |
2934 client_->SendMessage(headers, "", /*fin=*/false); | 2906 client_->SendMessage(headers, "", /*fin=*/false); |
2907 | |
2935 for (int i = 0; i < request_body_size_bytes / kSizeBytes; ++i) { | 2908 for (int i = 0; i < request_body_size_bytes / kSizeBytes; ++i) { |
2936 bool fin = (i == request_body_size_bytes - 1); | 2909 bool fin = (i == request_body_size_bytes - 1); |
2937 client_->SendData(string(body.data(), kSizeBytes), fin); | 2910 client_->SendData(string(body.data(), kSizeBytes), fin); |
2938 client_->client()->WaitForEvents(); | 2911 client_->client()->WaitForEvents(); |
2939 } | 2912 } |
2940 VerifyCleanConnection(true); | 2913 VerifyCleanConnection(true); |
2941 } | 2914 } |
2942 | 2915 |
2943 // TODO(fayang): this test seems to cause net_unittests timeouts :| | 2916 // TODO(fayang): this test seems to cause net_unittests timeouts :| |
2944 TEST_P(EndToEndTest, DISABLED_TestHugeResponseWithPacketLoss) { | 2917 TEST_P(EndToEndTest, DISABLED_TestHugeResponseWithPacketLoss) { |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3031 // Disconnect for next 0-rtt request. | 3004 // Disconnect for next 0-rtt request. |
3032 client_->Disconnect(); | 3005 client_->Disconnect(); |
3033 | 3006 |
3034 // Client get valid STK now. Do a 0-rtt request. | 3007 // Client get valid STK now. Do a 0-rtt request. |
3035 // Buffer a CHLO till another packets sent out. | 3008 // Buffer a CHLO till another packets sent out. |
3036 reorder_writer_->SetDelay(1); | 3009 reorder_writer_->SetDelay(1); |
3037 // Only send out a CHLO. | 3010 // Only send out a CHLO. |
3038 client_->client()->Initialize(); | 3011 client_->client()->Initialize(); |
3039 client_->client()->StartConnect(); | 3012 client_->client()->StartConnect(); |
3040 ASSERT_TRUE(client_->client()->connected()); | 3013 ASSERT_TRUE(client_->client()->connected()); |
3014 | |
3041 // Send a request before handshake finishes. | 3015 // Send a request before handshake finishes. |
3042 SpdyHeaderBlock headers; | 3016 SpdyHeaderBlock headers; |
3043 headers[":method"] = "POST"; | 3017 headers[":method"] = "POST"; |
3044 headers[":path"] = "/bar"; | 3018 headers[":path"] = "/bar"; |
3045 headers[":scheme"] = "https"; | 3019 headers[":scheme"] = "https"; |
3046 headers[":authority"] = server_hostname_; | 3020 headers[":authority"] = server_hostname_; |
3047 | 3021 |
3048 client_->SendMessage(headers, ""); | 3022 client_->SendMessage(headers, ""); |
3049 client_->WaitForResponse(); | 3023 client_->WaitForResponse(); |
3050 EXPECT_EQ(kBarResponseBody, client_->response_body()); | 3024 EXPECT_EQ(kBarResponseBody, client_->response_body()); |
3051 QuicConnectionStats client_stats = | 3025 QuicConnectionStats client_stats = |
3052 client_->client()->session()->connection()->GetStats(); | 3026 client_->client()->session()->connection()->GetStats(); |
3053 EXPECT_EQ(0u, client_stats.packets_lost); | 3027 EXPECT_EQ(0u, client_stats.packets_lost); |
3054 EXPECT_EQ(1, client_->client()->GetNumSentClientHellos()); | 3028 EXPECT_EQ(1, client_->client()->GetNumSentClientHellos()); |
3055 } | 3029 } |
3056 } // namespace | 3030 } // namespace |
3057 } // namespace test | 3031 } // namespace test |
3058 } // namespace net | 3032 } // namespace net |
OLD | NEW |