Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(683)

Side by Side Diff: net/spdy/spdy_network_transaction_unittest.cc

Issue 2820163004: Retry request upon GOAWAY frame with NO_ERROR. (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <cmath> 5 #include <cmath>
6 #include <memory> 6 #include <memory>
7 #include <utility> 7 #include <utility>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 3977 matching lines...) Expand 10 before | Expand all | Expand 10 after
3988 helper.ResetTrans(); 3988 helper.ResetTrans();
3989 3989
3990 // Flush the MessageLoop; this will cause the buffered IO task 3990 // Flush the MessageLoop; this will cause the buffered IO task
3991 // to run for the final time. 3991 // to run for the final time.
3992 base::RunLoop().RunUntilIdle(); 3992 base::RunLoop().RunUntilIdle();
3993 3993
3994 // Verify that we consumed all test data. 3994 // Verify that we consumed all test data.
3995 helper.VerifyDataConsumed(); 3995 helper.VerifyDataConsumed();
3996 } 3996 }
3997 3997
3998 TEST_F(SpdyNetworkTransactionTest, GoAwayWithActiveStream) { 3998 // Request should fail upon receiving a GOAWAY frame
3999 // with Last-Stream-ID lower than the stream id corresponding to the request
4000 // and with error code other than NO_ERROR.
4001 TEST_F(SpdyNetworkTransactionTest, FailOnGoAway) {
3999 SpdySerializedFrame req( 4002 SpdySerializedFrame req(
4000 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true)); 4003 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true));
4001 MockWrite writes[] = {CreateMockWrite(req, 0)}; 4004 MockWrite writes[] = {CreateMockWrite(req, 0)};
4002 4005
4003 SpdySerializedFrame go_away(spdy_util_.ConstructSpdyGoAway()); 4006 SpdySerializedFrame go_away(
4007 spdy_util_.ConstructSpdyGoAway(0, ERROR_CODE_INTERNAL_ERROR, ""));
4004 MockRead reads[] = { 4008 MockRead reads[] = {
4005 CreateMockRead(go_away, 1), 4009 CreateMockRead(go_away, 1),
4006 }; 4010 };
4007 4011
4008 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); 4012 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes));
4009 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, 4013 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY,
4010 NetLogWithSource(), nullptr); 4014 NetLogWithSource(), nullptr);
4011 helper.AddData(&data);
4012 helper.RunToCompletion(&data); 4015 helper.RunToCompletion(&data);
4013 TransactionHelperResult out = helper.output(); 4016 TransactionHelperResult out = helper.output();
4014 EXPECT_THAT(out.rv, IsError(ERR_ABORTED)); 4017 EXPECT_THAT(out.rv, IsError(ERR_ABORTED));
4015 } 4018 }
4016 4019
4020 // Request should be retried on a new connection upon receiving a GOAWAY frame
4021 // with Last-Stream-ID lower than the stream id corresponding to the request
4022 // and with error code NO_ERROR.
4023 TEST_F(SpdyNetworkTransactionTest, RetryOnGoAway) {
4024 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY,
4025 NetLogWithSource(), nullptr);
4026
4027 // First connection.
4028 SpdySerializedFrame req(
4029 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true));
4030 MockWrite writes1[] = {CreateMockWrite(req, 0)};
4031 SpdySerializedFrame go_away(
4032 spdy_util_.ConstructSpdyGoAway(0, ERROR_CODE_NO_ERROR, ""));
4033 MockRead reads1[] = {CreateMockRead(go_away, 1)};
4034 SequencedSocketData data1(reads1, arraysize(reads1), writes1,
4035 arraysize(writes1));
4036 helper.AddData(&data1);
4037
4038 // Second connection.
4039 MockWrite writes2[] = {CreateMockWrite(req, 0)};
4040 SpdySerializedFrame resp(spdy_util_.ConstructSpdyGetReply(nullptr, 0, 1));
4041 SpdySerializedFrame body(spdy_util_.ConstructSpdyDataFrame(1, true));
4042 MockRead reads2[] = {CreateMockRead(resp, 1), CreateMockRead(body, 2),
4043 MockRead(ASYNC, 0, 3)};
4044 SequencedSocketData data2(reads2, arraysize(reads2), writes2,
4045 arraysize(writes2));
4046 helper.AddData(&data2);
4047
4048 helper.RunPreTestSetup();
4049 helper.RunDefaultTest();
4050
4051 TransactionHelperResult out = helper.output();
4052 EXPECT_THAT(out.rv, IsOk());
4053
4054 helper.VerifyDataConsumed();
4055 }
4056
4017 // A server can gracefully shut down by sending a GOAWAY frame 4057 // A server can gracefully shut down by sending a GOAWAY frame
4018 // with maximum last-stream-id value. 4058 // with maximum last-stream-id value.
4019 // Transactions started before receiving such a GOAWAY frame should succeed, 4059 // Transactions started before receiving such a GOAWAY frame should succeed,
4020 // but SpdySession should be unavailable for new streams. 4060 // but SpdySession should be unavailable for new streams.
4021 TEST_F(SpdyNetworkTransactionTest, GracefulGoaway) { 4061 TEST_F(SpdyNetworkTransactionTest, GracefulGoaway) {
4022 SpdySerializedFrame req1( 4062 SpdySerializedFrame req1(
4023 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true)); 4063 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true));
4024 spdy_util_.UpdateWithStreamDestruction(1); 4064 spdy_util_.UpdateWithStreamDestruction(1);
4025 SpdySerializedFrame req2( 4065 SpdySerializedFrame req2(
4026 spdy_util_.ConstructSpdyGet("https://www.example.org/foo", 3, LOWEST)); 4066 spdy_util_.ConstructSpdyGet("https://www.example.org/foo", 3, LOWEST));
(...skipping 2567 matching lines...) Expand 10 before | Expand all | Expand 10 after
6594 TEST_F(SpdyNetworkTransactionTLSUsageCheckTest, TLSCipherSuiteSucky) { 6634 TEST_F(SpdyNetworkTransactionTLSUsageCheckTest, TLSCipherSuiteSucky) {
6595 std::unique_ptr<SSLSocketDataProvider> ssl_provider( 6635 std::unique_ptr<SSLSocketDataProvider> ssl_provider(
6596 new SSLSocketDataProvider(ASYNC, OK)); 6636 new SSLSocketDataProvider(ASYNC, OK));
6597 // Set to TLS_RSA_WITH_NULL_MD5 6637 // Set to TLS_RSA_WITH_NULL_MD5
6598 SSLConnectionStatusSetCipherSuite(0x1, &ssl_provider->connection_status); 6638 SSLConnectionStatusSetCipherSuite(0x1, &ssl_provider->connection_status);
6599 6639
6600 RunTLSUsageCheckTest(std::move(ssl_provider)); 6640 RunTLSUsageCheckTest(std::move(ssl_provider));
6601 } 6641 }
6602 6642
6603 } // namespace net 6643 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698