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 <algorithm> | 5 #include <algorithm> |
6 #include <memory> | 6 #include <memory> |
7 #include <ostream> | 7 #include <ostream> |
8 #include <string> | 8 #include <string> |
9 #include <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
(...skipping 4282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4293 net_log_.GetEntries(&entries); | 4293 net_log_.GetEntries(&entries); |
4294 EXPECT_LT(0u, entries.size()); | 4294 EXPECT_LT(0u, entries.size()); |
4295 | 4295 |
4296 // Check that we logged a QUIC_HTTP_STREAM_ADOPTED_PUSH_STREAM | 4296 // Check that we logged a QUIC_HTTP_STREAM_ADOPTED_PUSH_STREAM |
4297 int pos = ExpectLogContainsSomewhere( | 4297 int pos = ExpectLogContainsSomewhere( |
4298 entries, 0, NetLogEventType::QUIC_HTTP_STREAM_ADOPTED_PUSH_STREAM, | 4298 entries, 0, NetLogEventType::QUIC_HTTP_STREAM_ADOPTED_PUSH_STREAM, |
4299 NetLogEventPhase::NONE); | 4299 NetLogEventPhase::NONE); |
4300 EXPECT_LT(0, pos); | 4300 EXPECT_LT(0, pos); |
4301 } | 4301 } |
4302 | 4302 |
| 4303 // Regression test for http://crbug.com/719461 in which a promised stream |
| 4304 // is closed before the pushed headers arrive, but after the connection |
| 4305 // is closed and before the callbacks are executed. |
| 4306 TEST_P(QuicNetworkTransactionTest, CancelServerPushAfterConnectionClose) { |
| 4307 session_params_.origins_to_force_quic_on.insert( |
| 4308 HostPortPair::FromString("mail.example.org:443")); |
| 4309 |
| 4310 MockQuicData mock_quic_data; |
| 4311 QuicStreamOffset header_stream_offset = 0; |
| 4312 // Initial SETTINGS frame. |
| 4313 mock_quic_data.AddWrite( |
| 4314 ConstructInitialSettingsPacket(1, &header_stream_offset)); |
| 4315 // First request: GET https://mail.example.org/ |
| 4316 mock_quic_data.AddWrite(ConstructClientRequestHeadersPacket( |
| 4317 2, GetNthClientInitiatedStreamId(0), true, true, |
| 4318 GetRequestHeaders("GET", "https", "/"), &header_stream_offset)); |
| 4319 QuicStreamOffset server_header_offset = 0; |
| 4320 // Server promise for: https://mail.example.org/pushed.jpg |
| 4321 mock_quic_data.AddRead(ConstructServerPushPromisePacket( |
| 4322 1, GetNthClientInitiatedStreamId(0), GetNthServerInitiatedStreamId(0), |
| 4323 false, GetRequestHeaders("GET", "https", "/pushed.jpg"), |
| 4324 &server_header_offset, &server_maker_)); |
| 4325 // Response headers for first request. |
| 4326 mock_quic_data.AddRead(ConstructServerResponseHeadersPacket( |
| 4327 2, GetNthClientInitiatedStreamId(0), false, false, |
| 4328 GetResponseHeaders("200 OK"), &server_header_offset)); |
| 4329 // Client ACKs the response headers. |
| 4330 mock_quic_data.AddWrite(ConstructClientAckPacket(3, 2, 1, 1)); |
| 4331 // Response body for first request. |
| 4332 mock_quic_data.AddRead(ConstructServerDataPacket( |
| 4333 3, GetNthClientInitiatedStreamId(0), false, true, 0, "hello!")); |
| 4334 // Write error for the third request. |
| 4335 mock_quic_data.AddWrite(SYNCHRONOUS, ERR_FAILED); |
| 4336 mock_quic_data.AddRead(ASYNC, ERR_IO_PENDING); // No more data to read |
| 4337 mock_quic_data.AddRead(ASYNC, 0); // EOF |
| 4338 mock_quic_data.AddSocketDataToFactory(&socket_factory_); |
| 4339 |
| 4340 CreateSession(); |
| 4341 |
| 4342 // Send a request which triggers a push promise from the server. |
| 4343 SendRequestAndExpectQuicResponse("hello!"); |
| 4344 |
| 4345 // Start a push transaction that will be cancelled after the connection |
| 4346 // is closed, but before the callback is executed. |
| 4347 request_.url = GURL("https://mail.example.org/pushed.jpg"); |
| 4348 auto trans2 = base::MakeUnique<HttpNetworkTransaction>(DEFAULT_PRIORITY, |
| 4349 session_.get()); |
| 4350 TestCompletionCallback callback2; |
| 4351 int rv = trans2->Start(&request_, callback2.callback(), net_log_.bound()); |
| 4352 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); |
| 4353 base::RunLoop().RunUntilIdle(); |
| 4354 |
| 4355 // Cause the connection to close on a write error. |
| 4356 HttpRequestInfo request3; |
| 4357 request3.method = "GET"; |
| 4358 request3.url = GURL("https://mail.example.org/"); |
| 4359 request3.load_flags = 0; |
| 4360 HttpNetworkTransaction trans3(DEFAULT_PRIORITY, session_.get()); |
| 4361 TestCompletionCallback callback3; |
| 4362 EXPECT_THAT(trans3.Start(&request3, callback3.callback(), net_log_.bound()), |
| 4363 IsError(ERR_IO_PENDING)); |
| 4364 |
| 4365 base::RunLoop().RunUntilIdle(); |
| 4366 |
| 4367 // When |trans2| is destroyed, the underlying stream will be closed. |
| 4368 EXPECT_FALSE(callback2.have_result()); |
| 4369 trans2 = nullptr; |
| 4370 |
| 4371 EXPECT_THAT(callback3.WaitForResult(), IsError(ERR_QUIC_PROTOCOL_ERROR)); |
| 4372 } |
| 4373 |
4303 TEST_P(QuicNetworkTransactionTest, QuicForceHolBlocking) { | 4374 TEST_P(QuicNetworkTransactionTest, QuicForceHolBlocking) { |
4304 session_params_.quic_force_hol_blocking = true; | 4375 session_params_.quic_force_hol_blocking = true; |
4305 session_params_.origins_to_force_quic_on.insert( | 4376 session_params_.origins_to_force_quic_on.insert( |
4306 HostPortPair::FromString("mail.example.org:443")); | 4377 HostPortPair::FromString("mail.example.org:443")); |
4307 | 4378 |
4308 MockQuicData mock_quic_data; | 4379 MockQuicData mock_quic_data; |
4309 | 4380 |
4310 QuicStreamOffset offset = 0; | 4381 QuicStreamOffset offset = 0; |
4311 mock_quic_data.AddWrite(ConstructInitialSettingsPacket(1, &offset)); | 4382 mock_quic_data.AddWrite(ConstructInitialSettingsPacket(1, &offset)); |
4312 mock_quic_data.AddWrite(ConstructClientRequestHeadersPacket( | 4383 mock_quic_data.AddWrite(ConstructClientRequestHeadersPacket( |
(...skipping 714 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5027 | 5098 |
5028 request_.url = GURL("https://mail.example.org/pushed.jpg"); | 5099 request_.url = GURL("https://mail.example.org/pushed.jpg"); |
5029 ChunkedUploadDataStream upload_data(0); | 5100 ChunkedUploadDataStream upload_data(0); |
5030 upload_data.AppendData("1", 1, true); | 5101 upload_data.AppendData("1", 1, true); |
5031 request_.upload_data_stream = &upload_data; | 5102 request_.upload_data_stream = &upload_data; |
5032 SendRequestAndExpectQuicResponse("and hello!"); | 5103 SendRequestAndExpectQuicResponse("and hello!"); |
5033 } | 5104 } |
5034 | 5105 |
5035 } // namespace test | 5106 } // namespace test |
5036 } // namespace net | 5107 } // namespace net |
OLD | NEW |