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 <string> | 5 #include <string> |
6 #include <vector> | 6 #include <vector> |
7 | 7 |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/bind_helpers.h" | 9 #include "base/bind_helpers.h" |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
(...skipping 3630 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3641 // SPDY4 treats a header decompression failure as a connection-level error. | 3641 // SPDY4 treats a header decompression failure as a connection-level error. |
3642 TEST_P(SpdyNetworkTransactionTest, CorruptFrameSessionErrorSpdy4) { | 3642 TEST_P(SpdyNetworkTransactionTest, CorruptFrameSessionErrorSpdy4) { |
3643 if (spdy_util_.spdy_version() < SPDY4) { | 3643 if (spdy_util_.spdy_version() < SPDY4) { |
3644 return; | 3644 return; |
3645 } | 3645 } |
3646 // This is the length field that's too short. | 3646 // This is the length field that's too short. |
3647 scoped_ptr<SpdyFrame> syn_reply_wrong_length( | 3647 scoped_ptr<SpdyFrame> syn_reply_wrong_length( |
3648 spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); | 3648 spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); |
3649 BufferedSpdyFramer framer(spdy_util_.spdy_version(), false); | 3649 BufferedSpdyFramer framer(spdy_util_.spdy_version(), false); |
3650 size_t right_size = | 3650 size_t right_size = |
3651 (spdy_util_.spdy_version() < SPDY4) ? | 3651 syn_reply_wrong_length->size() - framer.GetControlFrameHeaderSize(); |
3652 syn_reply_wrong_length->size() - framer.GetControlFrameHeaderSize() : | |
3653 syn_reply_wrong_length->size(); | |
3654 size_t wrong_size = right_size - 4; | 3652 size_t wrong_size = right_size - 4; |
3655 test::SetFrameLength(syn_reply_wrong_length.get(), | 3653 test::SetFrameLength(syn_reply_wrong_length.get(), |
3656 wrong_size, | 3654 wrong_size, |
3657 spdy_util_.spdy_version()); | 3655 spdy_util_.spdy_version()); |
3658 | 3656 |
3659 // TODO(jgraettinger): SpdySession::OnError() should send a GOAWAY before | 3657 // TODO(jgraettinger): SpdySession::OnError() should send a GOAWAY before |
3660 // breaking the connection. | 3658 // breaking the connection. |
3661 scoped_ptr<SpdyFrame> req( | 3659 scoped_ptr<SpdyFrame> req( |
3662 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); | 3660 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); |
3663 MockWrite writes[] = { | 3661 MockWrite writes[] = { |
3664 CreateMockWrite(*req), | 3662 CreateMockWrite(*req), |
3665 }; | 3663 }; |
3666 | 3664 |
3667 scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, true)); | 3665 scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, true)); |
3668 MockRead reads[] = { | 3666 MockRead reads[] = { |
3669 MockRead(ASYNC, syn_reply_wrong_length->data(), wrong_size), | 3667 MockRead(ASYNC, syn_reply_wrong_length->data(), |
| 3668 syn_reply_wrong_length->size() - 4), |
3670 }; | 3669 }; |
3671 | 3670 |
3672 DelayedSocketData data(1, reads, arraysize(reads), | 3671 DelayedSocketData data(1, reads, arraysize(reads), |
3673 writes, arraysize(writes)); | 3672 writes, arraysize(writes)); |
3674 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, | 3673 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, |
3675 BoundNetLog(), GetParam(), NULL); | 3674 BoundNetLog(), GetParam(), NULL); |
3676 helper.RunToCompletion(&data); | 3675 helper.RunToCompletion(&data); |
3677 TransactionHelperResult out = helper.output(); | 3676 TransactionHelperResult out = helper.output(); |
3678 EXPECT_EQ(ERR_SPDY_PROTOCOL_ERROR, out.rv); | 3677 EXPECT_EQ(ERR_SPDY_PROTOCOL_ERROR, out.rv); |
3679 } | 3678 } |
(...skipping 724 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4404 EXPECT_TRUE(it3 != settings_map.end()); | 4403 EXPECT_TRUE(it3 != settings_map.end()); |
4405 SettingsFlagsAndValue flags_and_value3 = it3->second; | 4404 SettingsFlagsAndValue flags_and_value3 = it3->second; |
4406 EXPECT_EQ(SETTINGS_FLAG_PERSISTED, flags_and_value3.first); | 4405 EXPECT_EQ(SETTINGS_FLAG_PERSISTED, flags_and_value3.first); |
4407 EXPECT_EQ(kSampleValue3, flags_and_value3.second); | 4406 EXPECT_EQ(kSampleValue3, flags_and_value3.second); |
4408 } | 4407 } |
4409 } | 4408 } |
4410 | 4409 |
4411 // Test that when there are settings saved that they are sent back to the | 4410 // Test that when there are settings saved that they are sent back to the |
4412 // server upon session establishment. | 4411 // server upon session establishment. |
4413 TEST_P(SpdyNetworkTransactionTest, SettingsPlayback) { | 4412 TEST_P(SpdyNetworkTransactionTest, SettingsPlayback) { |
| 4413 // TODO(jgraettinger): Remove settings persistence mechanisms altogether. |
4414 static const SpdyHeaderInfo kSynReplyInfo = { | 4414 static const SpdyHeaderInfo kSynReplyInfo = { |
4415 SYN_REPLY, // Syn Reply | 4415 SYN_REPLY, // Syn Reply |
4416 1, // Stream ID | 4416 1, // Stream ID |
4417 0, // Associated Stream ID | 4417 0, // Associated Stream ID |
4418 ConvertRequestPriorityToSpdyPriority( | 4418 ConvertRequestPriorityToSpdyPriority( |
4419 LOWEST, spdy_util_.spdy_version()), | 4419 LOWEST, spdy_util_.spdy_version()), |
4420 kSpdyCredentialSlotUnused, | 4420 kSpdyCredentialSlotUnused, |
4421 CONTROL_FLAG_NONE, // Control Flags | 4421 CONTROL_FLAG_NONE, // Control Flags |
4422 false, // Compressed | 4422 false, // Compressed |
4423 RST_STREAM_INVALID, // Status | 4423 RST_STREAM_INVALID, // Status |
(...skipping 10 matching lines...) Expand all Loading... |
4434 SpdySessionPool* spdy_session_pool = helper.session()->spdy_session_pool(); | 4434 SpdySessionPool* spdy_session_pool = helper.session()->spdy_session_pool(); |
4435 | 4435 |
4436 SpdySessionPoolPeer pool_peer(spdy_session_pool); | 4436 SpdySessionPoolPeer pool_peer(spdy_session_pool); |
4437 pool_peer.SetEnableSendingInitialData(true); | 4437 pool_peer.SetEnableSendingInitialData(true); |
4438 | 4438 |
4439 // Verify that no settings exist initially. | 4439 // Verify that no settings exist initially. |
4440 HostPortPair host_port_pair("www.google.com", helper.port()); | 4440 HostPortPair host_port_pair("www.google.com", helper.port()); |
4441 EXPECT_TRUE(spdy_session_pool->http_server_properties()->GetSpdySettings( | 4441 EXPECT_TRUE(spdy_session_pool->http_server_properties()->GetSpdySettings( |
4442 host_port_pair).empty()); | 4442 host_port_pair).empty()); |
4443 | 4443 |
4444 const SpdySettingsIds kSampleId1 = SETTINGS_UPLOAD_BANDWIDTH; | 4444 const SpdySettingsIds kSampleId1 = SETTINGS_MAX_CONCURRENT_STREAMS; |
4445 unsigned int kSampleValue1 = 0x0a0a0a0a; | 4445 unsigned int kSampleValue1 = 0x0a0a0a0a; |
4446 const SpdySettingsIds kSampleId2 = SETTINGS_ROUND_TRIP_TIME; | 4446 const SpdySettingsIds kSampleId2 = SETTINGS_INITIAL_WINDOW_SIZE; |
4447 unsigned int kSampleValue2 = 0x0c0c0c0c; | 4447 unsigned int kSampleValue2 = 0x0c0c0c0c; |
4448 | 4448 |
4449 // First add a persisted setting. | 4449 // First add a persisted setting. |
4450 spdy_session_pool->http_server_properties()->SetSpdySetting( | 4450 spdy_session_pool->http_server_properties()->SetSpdySetting( |
4451 host_port_pair, | 4451 host_port_pair, |
4452 kSampleId1, | 4452 kSampleId1, |
4453 SETTINGS_FLAG_PLEASE_PERSIST, | 4453 SETTINGS_FLAG_PLEASE_PERSIST, |
4454 kSampleValue1); | 4454 kSampleValue1); |
4455 | 4455 |
4456 // Next add another persisted setting. | 4456 // Next add another persisted setting. |
(...skipping 2089 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6546 // since we're send-stalled. | 6546 // since we're send-stalled. |
6547 EXPECT_TRUE(stream->stream()->send_stalled_by_flow_control()); | 6547 EXPECT_TRUE(stream->stream()->send_stalled_by_flow_control()); |
6548 | 6548 |
6549 // Read in WINDOW_UPDATE or SETTINGS frame. | 6549 // Read in WINDOW_UPDATE or SETTINGS frame. |
6550 data.RunFor((GetParam().protocol >= kProtoSPDY31) ? 8 : 7); | 6550 data.RunFor((GetParam().protocol >= kProtoSPDY31) ? 8 : 7); |
6551 rv = callback.WaitForResult(); | 6551 rv = callback.WaitForResult(); |
6552 helper.VerifyDataConsumed(); | 6552 helper.VerifyDataConsumed(); |
6553 } | 6553 } |
6554 | 6554 |
6555 } // namespace net | 6555 } // namespace net |
OLD | NEW |