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 <iostream> | 6 #include <iostream> |
7 #include <limits> | 7 #include <limits> |
8 | 8 |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 3541 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3552 const uint32 kFlags = 0x01; | 3552 const uint32 kFlags = 0x01; |
3553 const uint32 kWireFormat = htonl(IsSpdy2() ? 0x04030201 : 0x01020304); | 3553 const uint32 kWireFormat = htonl(IsSpdy2() ? 0x04030201 : 0x01020304); |
3554 | 3554 |
3555 SettingsFlagsAndId id_and_flags = | 3555 SettingsFlagsAndId id_and_flags = |
3556 SettingsFlagsAndId::FromWireFormat(spdy_version_, kWireFormat); | 3556 SettingsFlagsAndId::FromWireFormat(spdy_version_, kWireFormat); |
3557 EXPECT_EQ(kId, id_and_flags.id()); | 3557 EXPECT_EQ(kId, id_and_flags.id()); |
3558 EXPECT_EQ(kFlags, id_and_flags.flags()); | 3558 EXPECT_EQ(kFlags, id_and_flags.flags()); |
3559 EXPECT_EQ(kWireFormat, id_and_flags.GetWireFormat(spdy_version_)); | 3559 EXPECT_EQ(kWireFormat, id_and_flags.GetWireFormat(spdy_version_)); |
3560 } | 3560 } |
3561 | 3561 |
| 3562 // Tests handling of a GOAWAY frame with out-of-bounds stream ID. |
| 3563 TEST_P(SpdyFramerTest, GoAwayStreamIdBounds) { |
| 3564 const unsigned char kV2FrameData[] = { |
| 3565 0x80, spdy_version_, 0x00, 0x07, |
| 3566 0x00, 0x00, 0x00, 0x04, |
| 3567 0xff, 0xff, 0xff, 0xff, |
| 3568 }; |
| 3569 const unsigned char kV3FrameData[] = { |
| 3570 0x80, spdy_version_, 0x00, 0x07, |
| 3571 0x00, 0x00, 0x00, 0x08, |
| 3572 0xff, 0xff, 0xff, 0xff, |
| 3573 0x00, 0x00, 0x00, 0x00, |
| 3574 }; |
| 3575 |
| 3576 testing::StrictMock<net::test::MockVisitor> visitor; |
| 3577 SpdyFramer framer(spdy_version_); |
| 3578 framer.set_visitor(&visitor); |
| 3579 |
| 3580 EXPECT_CALL(visitor, OnGoAway(0x7fffffff, GOAWAY_OK)); |
| 3581 if (IsSpdy2()) { |
| 3582 framer.ProcessInput(reinterpret_cast<const char*>(kV2FrameData), |
| 3583 arraysize(kV2FrameData)); |
| 3584 } else { |
| 3585 framer.ProcessInput(reinterpret_cast<const char*>(kV3FrameData), |
| 3586 arraysize(kV3FrameData)); |
| 3587 } |
| 3588 EXPECT_EQ(SpdyFramer::SPDY_RESET, framer.state()); |
| 3589 EXPECT_EQ(SpdyFramer::SPDY_NO_ERROR, framer.error_code()); |
| 3590 } |
| 3591 |
3562 } // namespace net | 3592 } // namespace net |
OLD | NEW |