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 1629 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1640 if (IsSpdy4()) { | 1640 if (IsSpdy4()) { |
1641 CompareFrame( | 1641 CompareFrame( |
1642 kDescription, *frame, kV4FrameData, arraysize(kV4FrameData)); | 1642 kDescription, *frame, kV4FrameData, arraysize(kV4FrameData)); |
1643 } else { | 1643 } else { |
1644 CompareFrame( | 1644 CompareFrame( |
1645 kDescription, *frame, kV3FrameData, arraysize(kV3FrameData)); | 1645 kDescription, *frame, kV3FrameData, arraysize(kV3FrameData)); |
1646 } | 1646 } |
1647 } | 1647 } |
1648 | 1648 |
1649 { | 1649 { |
| 1650 const char kDescription[] = |
| 1651 "'hello' data frame with 1 byte padding, no FIN"; |
| 1652 const unsigned char kV3FrameData[] = { // Also applies for V2. |
| 1653 0x00, 0x00, 0x00, 0x01, |
| 1654 0x00, 0x00, 0x00, 0x05, |
| 1655 'h', 'e', 'l', 'l', |
| 1656 'o' |
| 1657 }; |
| 1658 |
| 1659 const unsigned char kV4FrameData[] = { |
| 1660 0x00, 0x06, 0x00, 0x10, // Length = 6. PAD_LOW set. |
| 1661 0x00, 0x00, 0x00, 0x01, |
| 1662 0x00, // Pad Low field. |
| 1663 'h', 'e', 'l', 'l', // Data |
| 1664 'o', |
| 1665 }; |
| 1666 const char bytes[] = "hello"; |
| 1667 |
| 1668 SpdyDataIR data_ir(1, StringPiece(bytes, strlen(bytes))); |
| 1669 // The pad low field itself is used for the 1-byte padding and no padding |
| 1670 // payload is needed. |
| 1671 data_ir.set_padding_len(1); |
| 1672 scoped_ptr<SpdyFrame> frame(framer.SerializeData(data_ir)); |
| 1673 if (IsSpdy4()) { |
| 1674 CompareFrame( |
| 1675 kDescription, *frame, kV4FrameData, arraysize(kV4FrameData)); |
| 1676 } else { |
| 1677 CompareFrame( |
| 1678 kDescription, *frame, kV3FrameData, arraysize(kV3FrameData)); |
| 1679 } |
| 1680 |
| 1681 frame.reset(framer.SerializeDataFrameHeaderWithPaddingLengthField(data_ir)); |
| 1682 CompareCharArraysWithHexError( |
| 1683 kDescription, |
| 1684 reinterpret_cast<const unsigned char*>(frame->data()), |
| 1685 framer.GetDataFrameMinimumSize(), |
| 1686 IsSpdy4() ? kV4FrameData : kV3FrameData, |
| 1687 framer.GetDataFrameMinimumSize()); |
| 1688 } |
| 1689 |
| 1690 { |
1650 const char kDescription[] = "Data frame with negative data byte, no FIN"; | 1691 const char kDescription[] = "Data frame with negative data byte, no FIN"; |
1651 const unsigned char kV3FrameData[] = { // Also applies for V2. | 1692 const unsigned char kV3FrameData[] = { // Also applies for V2. |
1652 0x00, 0x00, 0x00, 0x01, | 1693 0x00, 0x00, 0x00, 0x01, |
1653 0x00, 0x00, 0x00, 0x01, | 1694 0x00, 0x00, 0x00, 0x01, |
1654 0xff | 1695 0xff |
1655 }; | 1696 }; |
1656 const unsigned char kV4FrameData[] = { | 1697 const unsigned char kV4FrameData[] = { |
1657 0x00, 0x01, 0x00, 0x00, | 1698 0x00, 0x01, 0x00, 0x00, |
1658 0x00, 0x00, 0x00, 0x01, | 1699 0x00, 0x00, 0x00, 0x01, |
1659 0xff | 1700 0xff |
(...skipping 3249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4909 SpdyBlockedIR blocked_ir(0); | 4950 SpdyBlockedIR blocked_ir(0); |
4910 scoped_ptr<SpdySerializedFrame> frame(framer.SerializeFrame(blocked_ir)); | 4951 scoped_ptr<SpdySerializedFrame> frame(framer.SerializeFrame(blocked_ir)); |
4911 framer.ProcessInput(frame->data(), framer.GetBlockedSize()); | 4952 framer.ProcessInput(frame->data(), framer.GetBlockedSize()); |
4912 | 4953 |
4913 EXPECT_EQ(SpdyFramer::SPDY_RESET, framer.state()); | 4954 EXPECT_EQ(SpdyFramer::SPDY_RESET, framer.state()); |
4914 EXPECT_EQ(SpdyFramer::SPDY_NO_ERROR, framer.error_code()) | 4955 EXPECT_EQ(SpdyFramer::SPDY_NO_ERROR, framer.error_code()) |
4915 << SpdyFramer::ErrorCodeToString(framer.error_code()); | 4956 << SpdyFramer::ErrorCodeToString(framer.error_code()); |
4916 } | 4957 } |
4917 | 4958 |
4918 } // namespace net | 4959 } // namespace net |
OLD | NEW |