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/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "net/spdy/spdy_framer.h" | 10 #include "net/spdy/spdy_framer.h" |
(...skipping 1568 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1579 const char kDescription[] = | 1579 const char kDescription[] = |
1580 "SYN_STREAM frame, low pri, no FIN"; | 1580 "SYN_STREAM frame, low pri, no FIN"; |
1581 | 1581 |
1582 SpdyHeaderBlock headers; | 1582 SpdyHeaderBlock headers; |
1583 headers["bar"] = "foo"; | 1583 headers["bar"] = "foo"; |
1584 headers["foo"] = "bar"; | 1584 headers["foo"] = "bar"; |
1585 | 1585 |
1586 const SpdyPriority priority = IsSpdy2() ? 2 : 4; | 1586 const SpdyPriority priority = IsSpdy2() ? 2 : 4; |
1587 const unsigned char kV2FrameData[] = { | 1587 const unsigned char kV2FrameData[] = { |
1588 0x80, spdy_version_, 0x00, 0x01, | 1588 0x80, spdy_version_, 0x00, 0x01, |
1589 0x00, 0x00, 0x00, 0x25, | 1589 0x00, 0x00, 0x00, 0x36, |
1590 0x00, 0x00, 0x00, 0x01, | 1590 0x00, 0x00, 0x00, 0x01, |
1591 0x00, 0x00, 0x00, 0x00, | 1591 0x00, 0x00, 0x00, 0x00, |
1592 0x80, 0x00, 0x38, 0xea, | 1592 0x80, 0x00, 0x38, 0xea, |
1593 0xdf, 0xa2, 0x51, 0xb2, | 1593 0xdf, 0xa2, 0x51, 0xb2, |
1594 0x62, 0x60, 0x62, 0x60, | 1594 0x62, 0x60, 0x62, 0x60, |
1595 0x4e, 0x4a, 0x2c, 0x62, | 1595 0x4e, 0x4a, 0x2c, 0x62, |
1596 0x60, 0x4e, 0xcb, 0xcf, | 1596 0x60, 0x06, 0x08, 0xa0, |
1597 0x87, 0x12, 0x40, 0x2e, | 1597 0xb4, 0xfc, 0x7c, 0x80, |
1598 0x00, 0x00, 0x00, 0xff, | 1598 0x00, 0x62, 0x60, 0x4e, |
1599 0xff | 1599 0xcb, 0xcf, 0x67, 0x60, |
| 1600 0x06, 0x08, 0xa0, 0xa4, |
| 1601 0xc4, 0x22, 0x80, 0x00, |
| 1602 0x02, 0x00, 0x00, 0x00, |
| 1603 0xff, 0xff, |
1600 }; | 1604 }; |
1601 const unsigned char kV3FrameData[] = { | 1605 const unsigned char kV3FrameData[] = { |
1602 0x80, spdy_version_, 0x00, 0x01, | 1606 0x80, spdy_version_, 0x00, 0x01, |
1603 0x00, 0x00, 0x00, 0x27, | 1607 0x00, 0x00, 0x00, 0x37, |
1604 0x00, 0x00, 0x00, 0x01, | 1608 0x00, 0x00, 0x00, 0x01, |
1605 0x00, 0x00, 0x00, 0x00, | 1609 0x00, 0x00, 0x00, 0x00, |
1606 0x80, 0x00, 0x38, 0xEA, | 1610 0x80, 0x00, 0x38, 0xEA, |
1607 0xE3, 0xC6, 0xA7, 0xC2, | 1611 0xE3, 0xC6, 0xA7, 0xC2, |
1608 0x02, 0xE5, 0x0E, 0x50, | 1612 0x02, 0xE5, 0x0E, 0x50, |
1609 0xC2, 0x4B, 0x4A, 0x04, | 1613 0xC2, 0x4B, 0x4A, 0x04, |
1610 0xE5, 0x0B, 0xE6, 0xB4, | 1614 0xE5, 0x0B, 0x66, 0x80, |
1611 0xFC, 0x7C, 0x24, 0x0A, | 1615 0x00, 0x4A, 0xCB, 0xCF, |
1612 0x28, 0x08, 0x00, 0x00, | 1616 0x07, 0x08, 0x20, 0x10, |
1613 0x00, 0xFF, 0xFF | 1617 0x95, 0x96, 0x9F, 0x0F, |
| 1618 0xA2, 0x00, 0x02, 0x28, |
| 1619 0x29, 0xB1, 0x08, 0x20, |
| 1620 0x80, 0x00, 0x00, 0x00, |
| 1621 0x00, 0xFF, 0xFF, |
1614 }; | 1622 }; |
1615 scoped_ptr<SpdyFrame> frame( | 1623 scoped_ptr<SpdyFrame> frame( |
1616 framer.CreateSynStream(1, // stream id | 1624 framer.CreateSynStream(1, // stream id |
1617 0, // associated stream id | 1625 0, // associated stream id |
1618 priority, | 1626 priority, |
1619 0, // credential slot | 1627 0, // credential slot |
1620 CONTROL_FLAG_NONE, | 1628 CONTROL_FLAG_NONE, |
1621 true, // compress | 1629 true, // compress |
1622 &headers)); | 1630 &headers)); |
1623 CompareFrame(kDescription, | 1631 CompareFrame(kDescription, |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1757 | 1765 |
1758 { | 1766 { |
1759 const char kDescription[] = "SYN_REPLY frame, no FIN"; | 1767 const char kDescription[] = "SYN_REPLY frame, no FIN"; |
1760 | 1768 |
1761 SpdyHeaderBlock headers; | 1769 SpdyHeaderBlock headers; |
1762 headers["bar"] = "foo"; | 1770 headers["bar"] = "foo"; |
1763 headers["foo"] = "bar"; | 1771 headers["foo"] = "bar"; |
1764 | 1772 |
1765 const unsigned char kV2FrameData[] = { | 1773 const unsigned char kV2FrameData[] = { |
1766 0x80, spdy_version_, 0x00, 0x02, | 1774 0x80, spdy_version_, 0x00, 0x02, |
1767 0x00, 0x00, 0x00, 0x21, | 1775 0x00, 0x00, 0x00, 0x32, |
1768 0x00, 0x00, 0x00, 0x01, | 1776 0x00, 0x00, 0x00, 0x01, |
1769 0x00, 0x00, 0x38, 0xea, | 1777 0x00, 0x00, 0x38, 0xea, |
1770 0xdf, 0xa2, 0x51, 0xb2, | 1778 0xdf, 0xa2, 0x51, 0xb2, |
1771 0x62, 0x60, 0x62, 0x60, | 1779 0x62, 0x60, 0x62, 0x60, |
1772 0x4e, 0x4a, 0x2c, 0x62, | 1780 0x4e, 0x4a, 0x2c, 0x62, |
1773 0x60, 0x4e, 0xcb, 0xcf, | 1781 0x60, 0x06, 0x08, 0xa0, |
1774 0x87, 0x12, 0x40, 0x2e, | 1782 0xb4, 0xfc, 0x7c, 0x80, |
1775 0x00, 0x00, 0x00, 0xff, | 1783 0x00, 0x62, 0x60, 0x4e, |
1776 0xff | 1784 0xcb, 0xcf, 0x67, 0x60, |
| 1785 0x06, 0x08, 0xa0, 0xa4, |
| 1786 0xc4, 0x22, 0x80, 0x00, |
| 1787 0x02, 0x00, 0x00, 0x00, |
| 1788 0xff, 0xff, |
1777 }; | 1789 }; |
1778 const unsigned char kV3FrameData[] = { | 1790 const unsigned char kV3FrameData[] = { |
1779 0x80, spdy_version_, 0x00, 0x02, | 1791 0x80, spdy_version_, 0x00, 0x02, |
1780 0x00, 0x00, 0x00, 0x21, | 1792 0x00, 0x00, 0x00, 0x31, |
1781 0x00, 0x00, 0x00, 0x01, | 1793 0x00, 0x00, 0x00, 0x01, |
1782 0x38, 0xea, 0xe3, 0xc6, | 1794 0x38, 0xea, 0xe3, 0xc6, |
1783 0xa7, 0xc2, 0x02, 0xe5, | 1795 0xa7, 0xc2, 0x02, 0xe5, |
1784 0x0e, 0x50, 0xc2, 0x4b, | 1796 0x0e, 0x50, 0xc2, 0x4b, |
1785 0x4a, 0x04, 0xe5, 0x0b, | 1797 0x4a, 0x04, 0xe5, 0x0b, |
1786 0xe6, 0xb4, 0xfc, 0x7c, | 1798 0x66, 0x80, 0x00, 0x4a, |
1787 0x24, 0x0a, 0x28, 0x08, | 1799 0xcb, 0xcf, 0x07, 0x08, |
| 1800 0x20, 0x10, 0x95, 0x96, |
| 1801 0x9f, 0x0f, 0xa2, 0x00, |
| 1802 0x02, 0x28, 0x29, 0xb1, |
| 1803 0x08, 0x20, 0x80, 0x00, |
1788 0x00, 0x00, 0x00, 0xff, | 1804 0x00, 0x00, 0x00, 0xff, |
1789 0xff | 1805 0xff, |
1790 }; | 1806 }; |
1791 scoped_ptr<SpdyFrame> frame(framer.CreateSynReply( | 1807 scoped_ptr<SpdyFrame> frame(framer.CreateSynReply( |
1792 1, CONTROL_FLAG_NONE, true, &headers)); | 1808 1, CONTROL_FLAG_NONE, true, &headers)); |
1793 CompareFrame(kDescription, | 1809 CompareFrame(kDescription, |
1794 *frame, | 1810 *frame, |
1795 IsSpdy2() ? kV2FrameData : kV3FrameData, | 1811 IsSpdy2() ? kV2FrameData : kV3FrameData, |
1796 IsSpdy2() ? arraysize(kV2FrameData) : arraysize(kV3FrameData)); | 1812 IsSpdy2() ? arraysize(kV2FrameData) : arraysize(kV3FrameData)); |
1797 } | 1813 } |
1798 } | 1814 } |
1799 | 1815 |
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2141 | 2157 |
2142 { | 2158 { |
2143 const char kDescription[] = "HEADERS frame, no FIN"; | 2159 const char kDescription[] = "HEADERS frame, no FIN"; |
2144 | 2160 |
2145 SpdyHeaderBlock headers; | 2161 SpdyHeaderBlock headers; |
2146 headers["bar"] = "foo"; | 2162 headers["bar"] = "foo"; |
2147 headers["foo"] = "bar"; | 2163 headers["foo"] = "bar"; |
2148 | 2164 |
2149 const unsigned char kV2FrameData[] = { | 2165 const unsigned char kV2FrameData[] = { |
2150 0x80, spdy_version_, 0x00, 0x08, | 2166 0x80, spdy_version_, 0x00, 0x08, |
2151 0x00, 0x00, 0x00, 0x21, | 2167 0x00, 0x00, 0x00, 0x32, |
2152 0x00, 0x00, 0x00, 0x01, | 2168 0x00, 0x00, 0x00, 0x01, |
2153 0x00, 0x00, 0x38, 0xea, | 2169 0x00, 0x00, 0x38, 0xea, |
2154 0xdf, 0xa2, 0x51, 0xb2, | 2170 0xdf, 0xa2, 0x51, 0xb2, |
2155 0x62, 0x60, 0x62, 0x60, | 2171 0x62, 0x60, 0x62, 0x60, |
2156 0x4e, 0x4a, 0x2c, 0x62, | 2172 0x4e, 0x4a, 0x2c, 0x62, |
2157 0x60, 0x4e, 0xcb, 0xcf, | 2173 0x60, 0x06, 0x08, 0xa0, |
2158 0x87, 0x12, 0x40, 0x2e, | 2174 0xb4, 0xfc, 0x7c, 0x80, |
2159 0x00, 0x00, 0x00, 0xff, | 2175 0x00, 0x62, 0x60, 0x4e, |
2160 0xff | 2176 0xcb, 0xcf, 0x67, 0x60, |
| 2177 0x06, 0x08, 0xa0, 0xa4, |
| 2178 0xc4, 0x22, 0x80, 0x00, |
| 2179 0x02, 0x00, 0x00, 0x00, |
| 2180 0xff, 0xff, |
2161 }; | 2181 }; |
2162 const unsigned char kV3FrameData[] = { | 2182 const unsigned char kV3FrameData[] = { |
2163 0x80, spdy_version_, 0x00, 0x08, | 2183 0x80, spdy_version_, 0x00, 0x08, |
2164 0x00, 0x00, 0x00, 0x21, | 2184 0x00, 0x00, 0x00, 0x31, |
2165 0x00, 0x00, 0x00, 0x01, | 2185 0x00, 0x00, 0x00, 0x01, |
2166 0x38, 0xea, 0xe3, 0xc6, | 2186 0x38, 0xea, 0xe3, 0xc6, |
2167 0xa7, 0xc2, 0x02, 0xe5, | 2187 0xa7, 0xc2, 0x02, 0xe5, |
2168 0x0e, 0x50, 0xc2, 0x4b, | 2188 0x0e, 0x50, 0xc2, 0x4b, |
2169 0x4a, 0x04, 0xe5, 0x0b, | 2189 0x4a, 0x04, 0xe5, 0x0b, |
2170 0xe6, 0xb4, 0xfc, 0x7c, | 2190 0x66, 0x80, 0x00, 0x4a, |
2171 0x24, 0x0a, 0x28, 0x08, | 2191 0xcb, 0xcf, 0x07, 0x08, |
| 2192 0x20, 0x10, 0x95, 0x96, |
| 2193 0x9f, 0x0f, 0xa2, 0x00, |
| 2194 0x02, 0x28, 0x29, 0xb1, |
| 2195 0x08, 0x20, 0x80, 0x00, |
2172 0x00, 0x00, 0x00, 0xff, | 2196 0x00, 0x00, 0x00, 0xff, |
2173 0xff | 2197 0xff, |
2174 }; | 2198 }; |
2175 scoped_ptr<SpdyFrame> frame(framer.CreateHeaders( | 2199 scoped_ptr<SpdyFrame> frame(framer.CreateHeaders( |
2176 1, CONTROL_FLAG_NONE, true, &headers)); | 2200 1, CONTROL_FLAG_NONE, true, &headers)); |
2177 CompareFrame(kDescription, | 2201 CompareFrame(kDescription, |
2178 *frame, | 2202 *frame, |
2179 IsSpdy2() ? kV2FrameData : kV3FrameData, | 2203 IsSpdy2() ? kV2FrameData : kV3FrameData, |
2180 IsSpdy2() ? arraysize(kV2FrameData) : arraysize(kV3FrameData)); | 2204 IsSpdy2() ? arraysize(kV2FrameData) : arraysize(kV3FrameData)); |
2181 } | 2205 } |
2182 } | 2206 } |
2183 | 2207 |
(...skipping 858 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3042 const uint32 kWireFormat = htonl(IsSpdy2() ? 0x04030201 : 0x01020304); | 3066 const uint32 kWireFormat = htonl(IsSpdy2() ? 0x04030201 : 0x01020304); |
3043 | 3067 |
3044 SettingsFlagsAndId id_and_flags = | 3068 SettingsFlagsAndId id_and_flags = |
3045 SettingsFlagsAndId::FromWireFormat(spdy_version_, kWireFormat); | 3069 SettingsFlagsAndId::FromWireFormat(spdy_version_, kWireFormat); |
3046 EXPECT_EQ(kId, id_and_flags.id()); | 3070 EXPECT_EQ(kId, id_and_flags.id()); |
3047 EXPECT_EQ(kFlags, id_and_flags.flags()); | 3071 EXPECT_EQ(kFlags, id_and_flags.flags()); |
3048 EXPECT_EQ(kWireFormat, id_and_flags.GetWireFormat(spdy_version_)); | 3072 EXPECT_EQ(kWireFormat, id_and_flags.GetWireFormat(spdy_version_)); |
3049 } | 3073 } |
3050 | 3074 |
3051 } // namespace net | 3075 } // namespace net |
OLD | NEW |