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

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

Issue 202073003: Introduce new SpdyConstants class (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « net/spdy/spdy_framer.cc ('k') | net/spdy/spdy_protocol.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <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 1029 matching lines...) Expand 10 before | Expand all | Expand 10 after
1040 1040
1041 0x80, spdy_version_ch_, 0x00, 0x03, // RST_STREAM on Stream #3 1041 0x80, spdy_version_ch_, 0x00, 0x03, // RST_STREAM on Stream #3
1042 0x00, 0x00, 0x00, 0x08, 1042 0x00, 0x00, 0x00, 0x08,
1043 0x00, 0x00, 0x00, 0x03, 1043 0x00, 0x00, 0x00, 0x03,
1044 0x00, 0x00, 0x00, 0x00, 1044 0x00, 0x00, 0x00, 0x00,
1045 }; 1045 };
1046 1046
1047 // SYN_STREAM doesn't exist in SPDY4, so instead we send 1047 // SYN_STREAM doesn't exist in SPDY4, so instead we send
1048 // HEADERS frames with PRIORITY and END_HEADERS set. 1048 // HEADERS frames with PRIORITY and END_HEADERS set.
1049 const unsigned char kV4Input[] = { 1049 const unsigned char kV4Input[] = {
1050 0x00, 0x05, 0x08, 0x0c, // HEADERS: PRIORITY | END_HEADERS 1050 0x00, 0x05, 0x01, 0x0c, // HEADERS: PRIORITY | END_HEADERS
1051 0x00, 0x00, 0x00, 0x01, // Stream 1 1051 0x00, 0x00, 0x00, 0x01, // Stream 1
1052 0x00, 0x00, 0x00, 0x00, // Priority 0 1052 0x00, 0x00, 0x00, 0x00, // Priority 0
1053 0x82, // :method: GET 1053 0x82, // :method: GET
1054 1054
1055 0x00, 0x01, 0x08, 0x04, // HEADERS: END_HEADERS 1055 0x00, 0x01, 0x01, 0x04, // HEADERS: END_HEADERS
1056 0x00, 0x00, 0x00, 0x01, // Stream 1 1056 0x00, 0x00, 0x00, 0x01, // Stream 1
1057 0x8c, // :status: 200 1057 0x8c, // :status: 200
1058 1058
1059 0x00, 0x0c, 0x00, 0x00, // DATA on Stream #1 1059 0x00, 0x0c, 0x00, 0x00, // DATA on Stream #1
1060 0x00, 0x00, 0x00, 0x01, 1060 0x00, 0x00, 0x00, 0x01,
1061 0xde, 0xad, 0xbe, 0xef, 1061 0xde, 0xad, 0xbe, 0xef,
1062 0xde, 0xad, 0xbe, 0xef, 1062 0xde, 0xad, 0xbe, 0xef,
1063 0xde, 0xad, 0xbe, 0xef, 1063 0xde, 0xad, 0xbe, 0xef,
1064 1064
1065 0x00, 0x05, 0x08, 0x0c, // HEADERS: PRIORITY | END_HEADERS 1065 0x00, 0x05, 0x01, 0x0c, // HEADERS: PRIORITY | END_HEADERS
1066 0x00, 0x00, 0x00, 0x03, // Stream 3 1066 0x00, 0x00, 0x00, 0x03, // Stream 3
1067 0x00, 0x00, 0x00, 0x00, // Priority 0 1067 0x00, 0x00, 0x00, 0x00, // Priority 0
1068 0x82, // :method: GET 1068 0x82, // :method: GET
1069 1069
1070 0x00, 0x08, 0x00, 0x00, // DATA on Stream #3 1070 0x00, 0x08, 0x00, 0x00, // DATA on Stream #3
1071 0x00, 0x00, 0x00, 0x03, 1071 0x00, 0x00, 0x00, 0x03,
1072 0xde, 0xad, 0xbe, 0xef, 1072 0xde, 0xad, 0xbe, 0xef,
1073 0xde, 0xad, 0xbe, 0xef, 1073 0xde, 0xad, 0xbe, 0xef,
1074 1074
1075 0x00, 0x04, 0x00, 0x00, // DATA on Stream #1 1075 0x00, 0x04, 0x00, 0x00, // DATA on Stream #1
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
1175 0xde, 0xad, 0xbe, 0xef, 1175 0xde, 0xad, 0xbe, 0xef,
1176 1176
1177 0x00, 0x00, 0x00, 0x01, // DATA on Stream #1, with EOF 1177 0x00, 0x00, 0x00, 0x01, // DATA on Stream #1, with EOF
1178 0x01, 0x00, 0x00, 0x04, 1178 0x01, 0x00, 0x00, 0x04,
1179 0xde, 0xad, 0xbe, 0xef, 1179 0xde, 0xad, 0xbe, 0xef,
1180 }; 1180 };
1181 1181
1182 // SYN_STREAM and SYN_REPLY don't exist in SPDY4, so instead we send 1182 // SYN_STREAM and SYN_REPLY don't exist in SPDY4, so instead we send
1183 // HEADERS frames with PRIORITY(SYN_STREAM only) and END_HEADERS set. 1183 // HEADERS frames with PRIORITY(SYN_STREAM only) and END_HEADERS set.
1184 const unsigned char kV4Input[] = { 1184 const unsigned char kV4Input[] = {
1185 0x00, 0x05, 0x08, 0x0c, // HEADERS: PRIORITY | END_HEADERS 1185 0x00, 0x05, 0x01, 0x0c, // HEADERS: PRIORITY | END_HEADERS
1186 0x00, 0x00, 0x00, 0x01, // Stream 1 1186 0x00, 0x00, 0x00, 0x01, // Stream 1
1187 0x00, 0x00, 0x00, 0x00, // Priority 0 1187 0x00, 0x00, 0x00, 0x00, // Priority 0
1188 0x82, // :method: GET 1188 0x82, // :method: GET
1189 1189
1190 0x00, 0x01, 0x08, 0x04, // HEADERS: END_HEADERS 1190 0x00, 0x01, 0x01, 0x04, // HEADERS: END_HEADERS
1191 0x00, 0x00, 0x00, 0x01, // Stream 1 1191 0x00, 0x00, 0x00, 0x01, // Stream 1
1192 0x8c, // :status: 200 1192 0x8c, // :status: 200
1193 1193
1194 0x00, 0x0c, 0x00, 0x00, // DATA on Stream #1 1194 0x00, 0x0c, 0x00, 0x00, // DATA on Stream #1
1195 0x00, 0x00, 0x00, 0x01, 1195 0x00, 0x00, 0x00, 0x01,
1196 0xde, 0xad, 0xbe, 0xef, 1196 0xde, 0xad, 0xbe, 0xef,
1197 0xde, 0xad, 0xbe, 0xef, 1197 0xde, 0xad, 0xbe, 0xef,
1198 0xde, 0xad, 0xbe, 0xef, 1198 0xde, 0xad, 0xbe, 0xef,
1199 1199
1200 0x00, 0x04, 0x00, 0x01, // DATA on Stream #1, with FIN 1200 0x00, 0x04, 0x00, 0x01, // DATA on Stream #1, with FIN
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
1261 0x00, 0x00, 0x00, 0x01, 1261 0x00, 0x00, 0x00, 0x01,
1262 0x00, 0x00, 0x00, 0x01, 1262 0x00, 0x00, 0x00, 0x01,
1263 0x00, 0x00, 0x00, 0x02, 1263 0x00, 0x00, 0x00, 0x02,
1264 'a', 'a', 0x00, 0x00, 1264 'a', 'a', 0x00, 0x00,
1265 0x00, 0x02, 'b', 'b', 1265 0x00, 0x02, 'b', 'b',
1266 }; 1266 };
1267 1267
1268 // SYN_STREAM and SYN_REPLY don't exist in SPDY4, so instead we send 1268 // SYN_STREAM and SYN_REPLY don't exist in SPDY4, so instead we send
1269 // HEADERS frames with PRIORITY(SYN_STREAM only) and END_HEADERS set. 1269 // HEADERS frames with PRIORITY(SYN_STREAM only) and END_HEADERS set.
1270 const unsigned char kV4Input[] = { 1270 const unsigned char kV4Input[] = {
1271 0x00, 0x05, 0x08, 0x0c, // HEADERS: PRIORITY | END_HEADERS 1271 0x00, 0x05, 0x01, 0x0c, // HEADERS: PRIORITY | END_HEADERS
1272 0x00, 0x00, 0x00, 0x01, // Stream 1 1272 0x00, 0x00, 0x00, 0x01, // Stream 1
1273 0x00, 0x00, 0x00, 0x00, // Priority 0 1273 0x00, 0x00, 0x00, 0x00, // Priority 0
1274 0x82, // :method: GET 1274 0x82, // :method: GET
1275 1275
1276 0x00, 0x01, 0x08, 0x05, // HEADERS: FIN | END_HEADERS 1276 0x00, 0x01, 0x01, 0x05, // HEADERS: FIN | END_HEADERS
1277 0x00, 0x00, 0x00, 0x01, // Stream 1 1277 0x00, 0x00, 0x00, 0x01, // Stream 1
1278 0x8c, // :status: 200 1278 0x8c, // :status: 200
1279 }; 1279 };
1280 1280
1281 TestSpdyVisitor visitor(spdy_version_); 1281 TestSpdyVisitor visitor(spdy_version_);
1282 if (IsSpdy2()) { 1282 if (IsSpdy2()) {
1283 visitor.SimulateInFramer(kV2Input, sizeof(kV2Input)); 1283 visitor.SimulateInFramer(kV2Input, sizeof(kV2Input));
1284 } else if (IsSpdy3()) { 1284 } else if (IsSpdy3()) {
1285 visitor.SimulateInFramer(kV3Input, sizeof(kV3Input)); 1285 visitor.SimulateInFramer(kV3Input, sizeof(kV3Input));
1286 } else { 1286 } else {
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
1469 net::SpdyWindowUpdateIR(1, 0x12345678))); 1469 net::SpdyWindowUpdateIR(1, 0x12345678)));
1470 1470
1471 const char kDescription[] = "WINDOW_UPDATE frame, stream 1, delta 0x12345678"; 1471 const char kDescription[] = "WINDOW_UPDATE frame, stream 1, delta 0x12345678";
1472 const unsigned char kV3FrameData[] = { // Also applies for V2. 1472 const unsigned char kV3FrameData[] = { // Also applies for V2.
1473 0x80, spdy_version_ch_, 0x00, 0x09, 1473 0x80, spdy_version_ch_, 0x00, 0x09,
1474 0x00, 0x00, 0x00, 0x08, 1474 0x00, 0x00, 0x00, 0x08,
1475 0x00, 0x00, 0x00, 0x01, 1475 0x00, 0x00, 0x00, 0x01,
1476 0x12, 0x34, 0x56, 0x78 1476 0x12, 0x34, 0x56, 0x78
1477 }; 1477 };
1478 const unsigned char kV4FrameData[] = { 1478 const unsigned char kV4FrameData[] = {
1479 0x00, 0x04, 0x09, 0x00, 1479 0x00, 0x04, 0x08, 0x00,
1480 0x00, 0x00, 0x00, 0x01, 1480 0x00, 0x00, 0x00, 0x01,
1481 0x12, 0x34, 0x56, 0x78 1481 0x12, 0x34, 0x56, 0x78
1482 }; 1482 };
1483 1483
1484 if (IsSpdy4()) { 1484 if (IsSpdy4()) {
1485 CompareFrame(kDescription, *frame, kV4FrameData, arraysize(kV4FrameData)); 1485 CompareFrame(kDescription, *frame, kV4FrameData, arraysize(kV4FrameData));
1486 } else { 1486 } else {
1487 CompareFrame(kDescription, *frame, kV3FrameData, arraysize(kV3FrameData)); 1487 CompareFrame(kDescription, *frame, kV3FrameData, arraysize(kV3FrameData));
1488 } 1488 }
1489 } 1489 }
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
1710 0x00, 0x02, 0x00, 0x00, 1710 0x00, 0x02, 0x00, 0x00,
1711 0x00, 0x03, 'b', 'a', 1711 0x00, 0x03, 'b', 'a',
1712 'r', 0x00, 0x00, 0x00, 1712 'r', 0x00, 0x00, 0x00,
1713 0x03, 'f', 'o', 'o', 1713 0x03, 'f', 'o', 'o',
1714 0x00, 0x00, 0x00, 0x03, 1714 0x00, 0x00, 0x00, 0x03,
1715 'f', 'o', 'o', 0x00, 1715 'f', 'o', 'o', 0x00,
1716 0x00, 0x00, 0x03, 'b', 1716 0x00, 0x00, 0x03, 'b',
1717 'a', 'r' 1717 'a', 'r'
1718 }; 1718 };
1719 const unsigned char kV4FrameData[] = { 1719 const unsigned char kV4FrameData[] = {
1720 0x00, 0x16, 0x08, 0x0c, // HEADERS: PRIORITY | END_HEADERS 1720 0x00, 0x16, 0x01, 0x0c, // HEADERS: PRIORITY | END_HEADERS
1721 0x00, 0x00, 0x00, 0x01, // Stream 1 1721 0x00, 0x00, 0x00, 0x01, // Stream 1
1722 0x00, 0x00, 0x00, 0x07, // Priority 7 1722 0x00, 0x00, 0x00, 0x07, // Priority 7
1723 0x40, 0x03, 0x62, 0x61, // @.ba 1723 0x40, 0x03, 0x62, 0x61, // @.ba
1724 0x72, 0x03, 0x66, 0x6f, // r.fo 1724 0x72, 0x03, 0x66, 0x6f, // r.fo
1725 0x6f, 0x40, 0x03, 0x66, // o@.f 1725 0x6f, 0x40, 0x03, 0x66, // o@.f
1726 0x6f, 0x6f, 0x03, 0x62, // oo.b 1726 0x6f, 0x6f, 0x03, 0x62, // oo.b
1727 0x61, 0x72, // ar 1727 0x61, 0x72, // ar
1728 }; 1728 };
1729 SpdySynStreamIR syn_stream(1); 1729 SpdySynStreamIR syn_stream(1);
1730 syn_stream.set_priority(framer.GetLowestPriority()); 1730 syn_stream.set_priority(framer.GetLowestPriority());
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
1765 0x00, 0x00, 0x00, 0x00, 1765 0x00, 0x00, 0x00, 0x00,
1766 0x00, 0x02, 0x00, 0x00, 1766 0x00, 0x02, 0x00, 0x00,
1767 0x00, 0x00, 0x00, 0x00, 1767 0x00, 0x00, 0x00, 0x00,
1768 0x00, 0x03, 'f', 'o', 1768 0x00, 0x03, 'f', 'o',
1769 'o', 0x00, 0x00, 0x00, 1769 'o', 0x00, 0x00, 0x00,
1770 0x03, 'f', 'o', 'o', 1770 0x03, 'f', 'o', 'o',
1771 0x00, 0x00, 0x00, 0x03, 1771 0x00, 0x00, 0x00, 0x03,
1772 'b', 'a', 'r' 1772 'b', 'a', 'r'
1773 }; 1773 };
1774 const unsigned char kV4FrameData[] = { 1774 const unsigned char kV4FrameData[] = {
1775 0x00, 0x13, 0x08, 0x0d, // HEADERS: PRIORITY | FIN | END_HEADERS 1775 0x00, 0x13, 0x01, 0x0d, // HEADERS: PRIORITY | FIN | END_HEADERS
1776 0x7f, 0xff, 0xff, 0xff, // Stream 0x7fffffff 1776 0x7f, 0xff, 0xff, 0xff, // Stream 0x7fffffff
1777 0x00, 0x00, 0x00, 0x00, // Priority 0 1777 0x00, 0x00, 0x00, 0x00, // Priority 0
1778 0x40, 0x00, 0x03, 0x66, // @..f 1778 0x40, 0x00, 0x03, 0x66, // @..f
1779 0x6f, 0x6f, 0x40, 0x03, // oo@. 1779 0x6f, 0x6f, 0x40, 0x03, // oo@.
1780 0x66, 0x6f, 0x6f, 0x03, // foo. 1780 0x66, 0x6f, 0x6f, 0x03, // foo.
1781 0x62, 0x61, 0x72, // bar 1781 0x62, 0x61, 0x72, // bar
1782 }; 1782 };
1783 SpdySynStreamIR syn_stream(0x7fffffff); 1783 SpdySynStreamIR syn_stream(0x7fffffff);
1784 syn_stream.set_associated_to_stream_id(0x7fffffff); 1784 syn_stream.set_associated_to_stream_id(0x7fffffff);
1785 syn_stream.set_priority(framer.GetHighestPriority()); 1785 syn_stream.set_priority(framer.GetHighestPriority());
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1822 kPri, 0x00, 0x00, 0x00, 1822 kPri, 0x00, 0x00, 0x00,
1823 0x00, 0x02, 0x00, 0x00, 1823 0x00, 0x02, 0x00, 0x00,
1824 0x00, 0x03, 'b', 'a', 1824 0x00, 0x03, 'b', 'a',
1825 'r', 0x00, 0x00, 0x00, 1825 'r', 0x00, 0x00, 0x00,
1826 0x03, 'f', 'o', 'o', 1826 0x03, 'f', 'o', 'o',
1827 0x00, 0x00, 0x00, 0x03, 1827 0x00, 0x00, 0x00, 0x03,
1828 'f', 'o', 'o', 0x00, 1828 'f', 'o', 'o', 0x00,
1829 0x00, 0x00, 0x00 1829 0x00, 0x00, 0x00
1830 }; 1830 };
1831 const unsigned char kV4FrameData[] = { 1831 const unsigned char kV4FrameData[] = {
1832 0x00, 0x13, 0x08, 0x0d, // HEADERS: PRIORITY | FIN | END_HEADERS 1832 0x00, 0x13, 0x01, 0x0d, // HEADERS: PRIORITY | FIN | END_HEADERS
1833 0x7f, 0xff, 0xff, 0xff, // Stream 0x7fffffff 1833 0x7f, 0xff, 0xff, 0xff, // Stream 0x7fffffff
1834 0x00, 0x00, 0x00, 0x01, // Priority 1 1834 0x00, 0x00, 0x00, 0x01, // Priority 1
1835 0x40, 0x03, 0x62, 0x61, // @.ba 1835 0x40, 0x03, 0x62, 0x61, // @.ba
1836 0x72, 0x03, 0x66, 0x6f, // r.fo 1836 0x72, 0x03, 0x66, 0x6f, // r.fo
1837 0x6f, 0x40, 0x03, 0x66, // o@.f 1837 0x6f, 0x40, 0x03, 0x66, // o@.f
1838 0x6f, 0x6f, 0x00, // oo. 1838 0x6f, 0x6f, 0x00, // oo.
1839 }; 1839 };
1840 SpdySynStreamIR syn_stream(0x7fffffff); 1840 SpdySynStreamIR syn_stream(0x7fffffff);
1841 syn_stream.set_associated_to_stream_id(0x7fffffff); 1841 syn_stream.set_associated_to_stream_id(0x7fffffff);
1842 syn_stream.set_priority(1); 1842 syn_stream.set_priority(1);
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
1943 0x00, 0x00, 0x00, 0x02, 1943 0x00, 0x00, 0x00, 0x02,
1944 0x00, 0x00, 0x00, 0x03, 1944 0x00, 0x00, 0x00, 0x03,
1945 'b', 'a', 'r', 0x00, 1945 'b', 'a', 'r', 0x00,
1946 0x00, 0x00, 0x03, 'f', 1946 0x00, 0x00, 0x03, 'f',
1947 'o', 'o', 0x00, 0x00, 1947 'o', 'o', 0x00, 0x00,
1948 0x00, 0x03, 'f', 'o', 1948 0x00, 0x03, 'f', 'o',
1949 'o', 0x00, 0x00, 0x00, 1949 'o', 0x00, 0x00, 0x00,
1950 0x03, 'b', 'a', 'r' 1950 0x03, 'b', 'a', 'r'
1951 }; 1951 };
1952 const unsigned char kV4FrameData[] = { 1952 const unsigned char kV4FrameData[] = {
1953 0x00, 0x12, 0x08, 0x04, // HEADER: END_HEADERS 1953 0x00, 0x12, 0x01, 0x04, // HEADER: END_HEADERS
1954 0x00, 0x00, 0x00, 0x01, // Stream 1 1954 0x00, 0x00, 0x00, 0x01, // Stream 1
1955 0x40, 0x03, 0x62, 0x61, // @.ba 1955 0x40, 0x03, 0x62, 0x61, // @.ba
1956 0x72, 0x03, 0x66, 0x6f, // r.fo 1956 0x72, 0x03, 0x66, 0x6f, // r.fo
1957 0x6f, 0x40, 0x03, 0x66, // o@.f 1957 0x6f, 0x40, 0x03, 0x66, // o@.f
1958 0x6f, 0x6f, 0x03, 0x62, // oo.b 1958 0x6f, 0x6f, 0x03, 0x62, // oo.b
1959 0x61, 0x72, // ar 1959 0x61, 0x72, // ar
1960 }; 1960 };
1961 SpdySynReplyIR syn_reply(1); 1961 SpdySynReplyIR syn_reply(1);
1962 syn_reply.SetHeader("bar", "foo"); 1962 syn_reply.SetHeader("bar", "foo");
1963 syn_reply.SetHeader("foo", "bar"); 1963 syn_reply.SetHeader("foo", "bar");
(...skipping 29 matching lines...) Expand all
1993 0x00, 0x00, 0x00, 0x02, 1993 0x00, 0x00, 0x00, 0x02,
1994 0x00, 0x00, 0x00, 0x00, 1994 0x00, 0x00, 0x00, 0x00,
1995 0x00, 0x00, 0x00, 0x03, 1995 0x00, 0x00, 0x00, 0x03,
1996 'f', 'o', 'o', 0x00, 1996 'f', 'o', 'o', 0x00,
1997 0x00, 0x00, 0x03, 'f', 1997 0x00, 0x00, 0x03, 'f',
1998 'o', 'o', 0x00, 0x00, 1998 'o', 'o', 0x00, 0x00,
1999 0x00, 0x03, 'b', 'a', 1999 0x00, 0x03, 'b', 'a',
2000 'r' 2000 'r'
2001 }; 2001 };
2002 const unsigned char kV4FrameData[] = { 2002 const unsigned char kV4FrameData[] = {
2003 0x00, 0x0f, 0x08, 0x05, // HEADER: FIN | END_HEADERS 2003 0x00, 0x0f, 0x01, 0x05, // HEADER: FIN | END_HEADERS
2004 0x7f, 0xff, 0xff, 0xff, // Stream 0x7fffffff 2004 0x7f, 0xff, 0xff, 0xff, // Stream 0x7fffffff
2005 0x40, 0x00, 0x03, 0x66, // @..f 2005 0x40, 0x00, 0x03, 0x66, // @..f
2006 0x6f, 0x6f, 0x40, 0x03, // oo@. 2006 0x6f, 0x6f, 0x40, 0x03, // oo@.
2007 0x66, 0x6f, 0x6f, 0x03, // foo. 2007 0x66, 0x6f, 0x6f, 0x03, // foo.
2008 0x62, 0x61, 0x72, // bar 2008 0x62, 0x61, 0x72, // bar
2009 }; 2009 };
2010 SpdySynReplyIR syn_reply(0x7fffffff); 2010 SpdySynReplyIR syn_reply(0x7fffffff);
2011 syn_reply.set_fin(true); 2011 syn_reply.set_fin(true);
2012 syn_reply.SetHeader("", "foo"); 2012 syn_reply.SetHeader("", "foo");
2013 syn_reply.SetHeader("foo", "bar"); 2013 syn_reply.SetHeader("foo", "bar");
(...skipping 29 matching lines...) Expand all
2043 0x00, 0x00, 0x00, 0x02, 2043 0x00, 0x00, 0x00, 0x02,
2044 0x00, 0x00, 0x00, 0x03, 2044 0x00, 0x00, 0x00, 0x03,
2045 'b', 'a', 'r', 0x00, 2045 'b', 'a', 'r', 0x00,
2046 0x00, 0x00, 0x03, 'f', 2046 0x00, 0x00, 0x03, 'f',
2047 'o', 'o', 0x00, 0x00, 2047 'o', 'o', 0x00, 0x00,
2048 0x00, 0x03, 'f', 'o', 2048 0x00, 0x03, 'f', 'o',
2049 'o', 0x00, 0x00, 0x00, 2049 'o', 0x00, 0x00, 0x00,
2050 0x00 2050 0x00
2051 }; 2051 };
2052 const unsigned char kV4FrameData[] = { 2052 const unsigned char kV4FrameData[] = {
2053 0x00, 0x0f, 0x08, 0x05, // HEADER: FIN | END_HEADERS 2053 0x00, 0x0f, 0x01, 0x05, // HEADER: FIN | END_HEADERS
2054 0x7f, 0xff, 0xff, 0xff, // Stream 0x7fffffff 2054 0x7f, 0xff, 0xff, 0xff, // Stream 0x7fffffff
2055 0x40, 0x03, 0x62, 0x61, // @.ba 2055 0x40, 0x03, 0x62, 0x61, // @.ba
2056 0x72, 0x03, 0x66, 0x6f, // r.fo 2056 0x72, 0x03, 0x66, 0x6f, // r.fo
2057 0x6f, 0x40, 0x03, 0x66, // o@.f 2057 0x6f, 0x40, 0x03, 0x66, // o@.f
2058 0x6f, 0x6f, 0x00, // oo. 2058 0x6f, 0x6f, 0x00, // oo.
2059 }; 2059 };
2060 SpdySynReplyIR syn_reply(0x7fffffff); 2060 SpdySynReplyIR syn_reply(0x7fffffff);
2061 syn_reply.set_fin(true); 2061 syn_reply.set_fin(true);
2062 syn_reply.SetHeader("bar", "foo"); 2062 syn_reply.SetHeader("bar", "foo");
2063 syn_reply.SetHeader("foo", ""); 2063 syn_reply.SetHeader("foo", "");
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after
2483 0x00, 0x00, 0x00, 0x02, 2483 0x00, 0x00, 0x00, 0x02,
2484 0x00, 0x00, 0x00, 0x03, 2484 0x00, 0x00, 0x00, 0x03,
2485 'b', 'a', 'r', 0x00, 2485 'b', 'a', 'r', 0x00,
2486 0x00, 0x00, 0x03, 'f', 2486 0x00, 0x00, 0x03, 'f',
2487 'o', 'o', 0x00, 0x00, 2487 'o', 'o', 0x00, 0x00,
2488 0x00, 0x03, 'f', 'o', 2488 0x00, 0x03, 'f', 'o',
2489 'o', 0x00, 0x00, 0x00, 2489 'o', 0x00, 0x00, 0x00,
2490 0x03, 'b', 'a', 'r' 2490 0x03, 'b', 'a', 'r'
2491 }; 2491 };
2492 const unsigned char kV4FrameData[] = { 2492 const unsigned char kV4FrameData[] = {
2493 0x00, 0x12, 0x08, 0x04, // Headers: END_HEADERS 2493 0x00, 0x12, 0x01, 0x04, // Headers: END_HEADERS
2494 0x00, 0x00, 0x00, 0x01, // Stream 1 2494 0x00, 0x00, 0x00, 0x01, // Stream 1
2495 0x40, 0x03, 0x62, 0x61, // @.ba 2495 0x40, 0x03, 0x62, 0x61, // @.ba
2496 0x72, 0x03, 0x66, 0x6f, // r.fo 2496 0x72, 0x03, 0x66, 0x6f, // r.fo
2497 0x6f, 0x40, 0x03, 0x66, // o@.f 2497 0x6f, 0x40, 0x03, 0x66, // o@.f
2498 0x6f, 0x6f, 0x03, 0x62, // oo.b 2498 0x6f, 0x6f, 0x03, 0x62, // oo.b
2499 0x61, 0x72, // ar 2499 0x61, 0x72, // ar
2500 }; 2500 };
2501 SpdyHeadersIR headers_ir(1); 2501 SpdyHeadersIR headers_ir(1);
2502 headers_ir.SetHeader("bar", "foo"); 2502 headers_ir.SetHeader("bar", "foo");
2503 headers_ir.SetHeader("foo", "bar"); 2503 headers_ir.SetHeader("foo", "bar");
(...skipping 29 matching lines...) Expand all
2533 0x00, 0x00, 0x00, 0x02, 2533 0x00, 0x00, 0x00, 0x02,
2534 0x00, 0x00, 0x00, 0x00, 2534 0x00, 0x00, 0x00, 0x00,
2535 0x00, 0x00, 0x00, 0x03, 2535 0x00, 0x00, 0x00, 0x03,
2536 'f', 'o', 'o', 0x00, 2536 'f', 'o', 'o', 0x00,
2537 0x00, 0x00, 0x03, 'f', 2537 0x00, 0x00, 0x03, 'f',
2538 'o', 'o', 0x00, 0x00, 2538 'o', 'o', 0x00, 0x00,
2539 0x00, 0x03, 'b', 'a', 2539 0x00, 0x03, 'b', 'a',
2540 'r' 2540 'r'
2541 }; 2541 };
2542 const unsigned char kV4FrameData[] = { 2542 const unsigned char kV4FrameData[] = {
2543 0x00, 0x0f, 0x08, 0x05, // HEADER: FIN | END_HEADERS 2543 0x00, 0x0f, 0x01, 0x05, // HEADER: FIN | END_HEADERS
2544 0x7f, 0xff, 0xff, 0xff, // Stream 0x7fffffff 2544 0x7f, 0xff, 0xff, 0xff, // Stream 0x7fffffff
2545 0x40, 0x00, 0x03, 0x66, // @..f 2545 0x40, 0x00, 0x03, 0x66, // @..f
2546 0x6f, 0x6f, 0x40, 0x03, // oo@. 2546 0x6f, 0x6f, 0x40, 0x03, // oo@.
2547 0x66, 0x6f, 0x6f, 0x03, // foo. 2547 0x66, 0x6f, 0x6f, 0x03, // foo.
2548 0x62, 0x61, 0x72, // bar 2548 0x62, 0x61, 0x72, // bar
2549 }; 2549 };
2550 SpdyHeadersIR headers_ir(0x7fffffff); 2550 SpdyHeadersIR headers_ir(0x7fffffff);
2551 headers_ir.set_fin(true); 2551 headers_ir.set_fin(true);
2552 headers_ir.SetHeader("", "foo"); 2552 headers_ir.SetHeader("", "foo");
2553 headers_ir.SetHeader("foo", "bar"); 2553 headers_ir.SetHeader("foo", "bar");
(...skipping 29 matching lines...) Expand all
2583 0x00, 0x00, 0x00, 0x02, 2583 0x00, 0x00, 0x00, 0x02,
2584 0x00, 0x00, 0x00, 0x03, 2584 0x00, 0x00, 0x00, 0x03,
2585 'b', 'a', 'r', 0x00, 2585 'b', 'a', 'r', 0x00,
2586 0x00, 0x00, 0x03, 'f', 2586 0x00, 0x00, 0x03, 'f',
2587 'o', 'o', 0x00, 0x00, 2587 'o', 'o', 0x00, 0x00,
2588 0x00, 0x03, 'f', 'o', 2588 0x00, 0x03, 'f', 'o',
2589 'o', 0x00, 0x00, 0x00, 2589 'o', 0x00, 0x00, 0x00,
2590 0x00 2590 0x00
2591 }; 2591 };
2592 const unsigned char kV4FrameData[] = { 2592 const unsigned char kV4FrameData[] = {
2593 0x00, 0x0f, 0x08, 0x05, // HEADER: FIN | END_HEADERS 2593 0x00, 0x0f, 0x01, 0x05, // HEADER: FIN | END_HEADERS
2594 0x7f, 0xff, 0xff, 0xff, // Stream 0x7fffffff 2594 0x7f, 0xff, 0xff, 0xff, // Stream 0x7fffffff
2595 0x40, 0x03, 0x62, 0x61, // @.ba 2595 0x40, 0x03, 0x62, 0x61, // @.ba
2596 0x72, 0x03, 0x66, 0x6f, // r.fo 2596 0x72, 0x03, 0x66, 0x6f, // r.fo
2597 0x6f, 0x40, 0x03, 0x66, // o@.f 2597 0x6f, 0x40, 0x03, 0x66, // o@.f
2598 0x6f, 0x6f, 0x00, // oo. 2598 0x6f, 0x6f, 0x00, // oo.
2599 }; 2599 };
2600 SpdyHeadersIR headers_ir(0x7fffffff); 2600 SpdyHeadersIR headers_ir(0x7fffffff);
2601 headers_ir.set_fin(true); 2601 headers_ir.set_fin(true);
2602 headers_ir.SetHeader("bar", "foo"); 2602 headers_ir.SetHeader("bar", "foo");
2603 headers_ir.SetHeader("foo", ""); 2603 headers_ir.SetHeader("foo", "");
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
2676 2676
2677 { 2677 {
2678 const char kDescription[] = "WINDOW_UPDATE frame"; 2678 const char kDescription[] = "WINDOW_UPDATE frame";
2679 const unsigned char kV3FrameData[] = { // Also applies for V2. 2679 const unsigned char kV3FrameData[] = { // Also applies for V2.
2680 0x80, spdy_version_ch_, 0x00, 0x09, 2680 0x80, spdy_version_ch_, 0x00, 0x09,
2681 0x00, 0x00, 0x00, 0x08, 2681 0x00, 0x00, 0x00, 0x08,
2682 0x00, 0x00, 0x00, 0x01, 2682 0x00, 0x00, 0x00, 0x01,
2683 0x00, 0x00, 0x00, 0x01, 2683 0x00, 0x00, 0x00, 0x01,
2684 }; 2684 };
2685 const unsigned char kV4FrameData[] = { 2685 const unsigned char kV4FrameData[] = {
2686 0x00, 0x04, 0x09, 0x00, 2686 0x00, 0x04, 0x08, 0x00,
2687 0x00, 0x00, 0x00, 0x01, 2687 0x00, 0x00, 0x00, 0x01,
2688 0x00, 0x00, 0x00, 0x01, 2688 0x00, 0x00, 0x00, 0x01,
2689 }; 2689 };
2690 scoped_ptr<SpdyFrame> frame( 2690 scoped_ptr<SpdyFrame> frame(
2691 framer.SerializeWindowUpdate(net::SpdyWindowUpdateIR(1, 1))); 2691 framer.SerializeWindowUpdate(net::SpdyWindowUpdateIR(1, 1)));
2692 if (IsSpdy4()) { 2692 if (IsSpdy4()) {
2693 CompareFrame(kDescription, *frame, kV4FrameData, arraysize(kV4FrameData)); 2693 CompareFrame(kDescription, *frame, kV4FrameData, arraysize(kV4FrameData));
2694 } else { 2694 } else {
2695 CompareFrame(kDescription, *frame, kV3FrameData, arraysize(kV3FrameData)); 2695 CompareFrame(kDescription, *frame, kV3FrameData, arraysize(kV3FrameData));
2696 } 2696 }
2697 } 2697 }
2698 2698
2699 { 2699 {
2700 const char kDescription[] = "WINDOW_UPDATE frame with max stream ID"; 2700 const char kDescription[] = "WINDOW_UPDATE frame with max stream ID";
2701 const unsigned char kV3FrameData[] = { // Also applies for V2. 2701 const unsigned char kV3FrameData[] = { // Also applies for V2.
2702 0x80, spdy_version_ch_, 0x00, 0x09, 2702 0x80, spdy_version_ch_, 0x00, 0x09,
2703 0x00, 0x00, 0x00, 0x08, 2703 0x00, 0x00, 0x00, 0x08,
2704 0x7f, 0xff, 0xff, 0xff, 2704 0x7f, 0xff, 0xff, 0xff,
2705 0x00, 0x00, 0x00, 0x01, 2705 0x00, 0x00, 0x00, 0x01,
2706 }; 2706 };
2707 const unsigned char kV4FrameData[] = { 2707 const unsigned char kV4FrameData[] = {
2708 0x00, 0x04, 0x09, 0x00, 2708 0x00, 0x04, 0x08, 0x00,
2709 0x7f, 0xff, 0xff, 0xff, 2709 0x7f, 0xff, 0xff, 0xff,
2710 0x00, 0x00, 0x00, 0x01, 2710 0x00, 0x00, 0x00, 0x01,
2711 }; 2711 };
2712 scoped_ptr<SpdyFrame> frame(framer.SerializeWindowUpdate( 2712 scoped_ptr<SpdyFrame> frame(framer.SerializeWindowUpdate(
2713 net::SpdyWindowUpdateIR(0x7FFFFFFF, 1))); 2713 net::SpdyWindowUpdateIR(0x7FFFFFFF, 1)));
2714 if (IsSpdy4()) { 2714 if (IsSpdy4()) {
2715 CompareFrame(kDescription, *frame, kV4FrameData, arraysize(kV4FrameData)); 2715 CompareFrame(kDescription, *frame, kV4FrameData, arraysize(kV4FrameData));
2716 } else { 2716 } else {
2717 CompareFrame(kDescription, *frame, kV3FrameData, arraysize(kV3FrameData)); 2717 CompareFrame(kDescription, *frame, kV3FrameData, arraysize(kV3FrameData));
2718 } 2718 }
2719 } 2719 }
2720 2720
2721 { 2721 {
2722 const char kDescription[] = "WINDOW_UPDATE frame with max window delta"; 2722 const char kDescription[] = "WINDOW_UPDATE frame with max window delta";
2723 const unsigned char kV3FrameData[] = { // Also applies for V2. 2723 const unsigned char kV3FrameData[] = { // Also applies for V2.
2724 0x80, spdy_version_ch_, 0x00, 0x09, 2724 0x80, spdy_version_ch_, 0x00, 0x09,
2725 0x00, 0x00, 0x00, 0x08, 2725 0x00, 0x00, 0x00, 0x08,
2726 0x00, 0x00, 0x00, 0x01, 2726 0x00, 0x00, 0x00, 0x01,
2727 0x7f, 0xff, 0xff, 0xff, 2727 0x7f, 0xff, 0xff, 0xff,
2728 }; 2728 };
2729 const unsigned char kV4FrameData[] = { 2729 const unsigned char kV4FrameData[] = {
2730 0x00, 0x04, 0x09, 0x00, 2730 0x00, 0x04, 0x08, 0x00,
2731 0x00, 0x00, 0x00, 0x01, 2731 0x00, 0x00, 0x00, 0x01,
2732 0x7f, 0xff, 0xff, 0xff, 2732 0x7f, 0xff, 0xff, 0xff,
2733 }; 2733 };
2734 scoped_ptr<SpdyFrame> frame(framer.SerializeWindowUpdate( 2734 scoped_ptr<SpdyFrame> frame(framer.SerializeWindowUpdate(
2735 net::SpdyWindowUpdateIR(1, 0x7FFFFFFF))); 2735 net::SpdyWindowUpdateIR(1, 0x7FFFFFFF)));
2736 if (IsSpdy4()) { 2736 if (IsSpdy4()) {
2737 CompareFrame(kDescription, *frame, kV4FrameData, arraysize(kV4FrameData)); 2737 CompareFrame(kDescription, *frame, kV4FrameData, arraysize(kV4FrameData));
2738 } else { 2738 } else {
2739 CompareFrame(kDescription, *frame, kV3FrameData, arraysize(kV3FrameData)); 2739 CompareFrame(kDescription, *frame, kV3FrameData, arraysize(kV3FrameData));
2740 } 2740 }
2741 } 2741 }
2742 } 2742 }
2743 2743
2744 TEST_P(SpdyFramerTest, SerializeBlocked) { 2744 TEST_P(SpdyFramerTest, SerializeBlocked) {
2745 if (spdy_version_ < SPDY4) { 2745 if (spdy_version_ < SPDY4) {
2746 return; 2746 return;
2747 } 2747 }
2748 2748
2749 SpdyFramer framer(spdy_version_); 2749 SpdyFramer framer(spdy_version_);
2750 2750
2751 const char kDescription[] = "BLOCKED frame"; 2751 const char kDescription[] = "BLOCKED frame";
2752 const unsigned char kFrameData[] = { 2752 const unsigned char kFrameData[] = {
2753 0x00, 0x00, 0x0b, 0x00, 2753 0x00, 0x00, 0x0a, 0x00,
2754 0x00, 0x00, 0x00, 0x00, 2754 0x00, 0x00, 0x00, 0x00,
2755 }; 2755 };
2756 SpdyBlockedIR blocked_ir(0); 2756 SpdyBlockedIR blocked_ir(0);
2757 scoped_ptr<SpdySerializedFrame> frame(framer.SerializeFrame(blocked_ir)); 2757 scoped_ptr<SpdySerializedFrame> frame(framer.SerializeFrame(blocked_ir));
2758 CompareFrame(kDescription, *frame, kFrameData, arraysize(kFrameData)); 2758 CompareFrame(kDescription, *frame, kFrameData, arraysize(kFrameData));
2759 } 2759 }
2760 2760
2761 TEST_P(SpdyFramerTest, CreateBlocked) { 2761 TEST_P(SpdyFramerTest, CreateBlocked) {
2762 if (spdy_version_ < SPDY4) { 2762 if (spdy_version_ < SPDY4) {
2763 return; 2763 return;
(...skipping 16 matching lines...) Expand all
2780 TEST_P(SpdyFramerTest, CreatePushPromise) { 2780 TEST_P(SpdyFramerTest, CreatePushPromise) {
2781 if (spdy_version_ < SPDY4) { 2781 if (spdy_version_ < SPDY4) {
2782 return; 2782 return;
2783 } 2783 }
2784 2784
2785 SpdyFramer framer(spdy_version_); 2785 SpdyFramer framer(spdy_version_);
2786 2786
2787 const char kDescription[] = "PUSH_PROMISE frame"; 2787 const char kDescription[] = "PUSH_PROMISE frame";
2788 2788
2789 const unsigned char kFrameData[] = { 2789 const unsigned char kFrameData[] = {
2790 0x00, 0x16, 0x0c, 0x04, // PUSH_PROMISE: END_HEADERS 2790 0x00, 0x16, 0x05, 0x04, // PUSH_PROMISE: END_HEADERS
2791 0x00, 0x00, 0x00, 0x2a, // Stream 42 2791 0x00, 0x00, 0x00, 0x2a, // Stream 42
2792 0x00, 0x00, 0x00, 0x39, // Promised stream 57 2792 0x00, 0x00, 0x00, 0x39, // Promised stream 57
2793 0x40, 0x03, 0x62, 0x61, // @.ba 2793 0x40, 0x03, 0x62, 0x61, // @.ba
2794 0x72, 0x03, 0x66, 0x6f, // r.fo 2794 0x72, 0x03, 0x66, 0x6f, // r.fo
2795 0x6f, 0x40, 0x03, 0x66, // o@.f 2795 0x6f, 0x40, 0x03, 0x66, // o@.f
2796 0x6f, 0x6f, 0x03, 0x62, // oo.b 2796 0x6f, 0x6f, 0x03, 0x62, // oo.b
2797 0x61, 0x72, // ar 2797 0x61, 0x72, // ar
2798 }; 2798 };
2799 2799
2800 SpdyPushPromiseIR push_promise(42, 57); 2800 SpdyPushPromiseIR push_promise(42, 57);
(...skipping 672 matching lines...) Expand 10 before | Expand all | Expand 10 after
3473 TEST_P(SpdyFramerTest, CreateContinuation) { 3473 TEST_P(SpdyFramerTest, CreateContinuation) {
3474 if (spdy_version_ < SPDY4) { 3474 if (spdy_version_ < SPDY4) {
3475 return; 3475 return;
3476 } 3476 }
3477 3477
3478 SpdyFramer framer(spdy_version_); 3478 SpdyFramer framer(spdy_version_);
3479 3479
3480 const char kDescription[] = "CONTINUATION frame"; 3480 const char kDescription[] = "CONTINUATION frame";
3481 3481
3482 const unsigned char kFrameData[] = { 3482 const unsigned char kFrameData[] = {
3483 0x00, 0x12, 0x0d, 0x00, // CONTINUATION 3483 0x00, 0x12, 0x09, 0x00, // CONTINUATION
3484 0x00, 0x00, 0x00, 0x2a, // Stream 42 3484 0x00, 0x00, 0x00, 0x2a, // Stream 42
3485 0x40, 0x03, 0x62, 0x61, // @.ba 3485 0x40, 0x03, 0x62, 0x61, // @.ba
3486 0x72, 0x03, 0x66, 0x6f, // r.fo 3486 0x72, 0x03, 0x66, 0x6f, // r.fo
3487 0x6f, 0x40, 0x03, 0x66, // o@.f 3487 0x6f, 0x40, 0x03, 0x66, // o@.f
3488 0x6f, 0x6f, 0x03, 0x62, // oo.b 3488 0x6f, 0x6f, 0x03, 0x62, // oo.b
3489 0x61, 0x72, // ar 3489 0x61, 0x72, // ar
3490 }; 3490 };
3491 3491
3492 SpdyContinuationIR continuation(42); 3492 SpdyContinuationIR continuation(42);
3493 continuation.SetHeader("bar", "foo"); 3493 continuation.SetHeader("bar", "foo");
(...skipping 25 matching lines...) Expand all
3519 EXPECT_EQ(57u, visitor.last_push_promise_promised_stream_); 3519 EXPECT_EQ(57u, visitor.last_push_promise_promised_stream_);
3520 EXPECT_TRUE(CompareHeaderBlocks(&headers, &visitor.headers_)); 3520 EXPECT_TRUE(CompareHeaderBlocks(&headers, &visitor.headers_));
3521 } 3521 }
3522 3522
3523 TEST_P(SpdyFramerTest, ReadHeadersWithContinuation) { 3523 TEST_P(SpdyFramerTest, ReadHeadersWithContinuation) {
3524 if (spdy_version_ < 4) { 3524 if (spdy_version_ < 4) {
3525 return; 3525 return;
3526 } 3526 }
3527 3527
3528 const unsigned char kInput[] = { 3528 const unsigned char kInput[] = {
3529 0x00, 0x10, 0x08, 0x00, // HEADERS 3529 0x00, 0x10, 0x01, 0x00, // HEADERS
3530 0x00, 0x00, 0x00, 0x01, // Stream 1 3530 0x00, 0x00, 0x00, 0x01, // Stream 1
3531 0x40, 0x06, 0x43, 0x6f, 3531 0x40, 0x06, 0x43, 0x6f,
3532 0x6f, 0x6b, 0x69, 0x65, 3532 0x6f, 0x6b, 0x69, 0x65,
3533 0x07, 0x66, 0x6f, 0x6f, 3533 0x07, 0x66, 0x6f, 0x6f,
3534 0x3d, 0x62, 0x61, 0x72, 3534 0x3d, 0x62, 0x61, 0x72,
3535 3535
3536 0x00, 0x14, 0x0D, 0x00, // CONTINUATION 3536 0x00, 0x14, 0x09, 0x00, // CONTINUATION
3537 0x00, 0x00, 0x00, 0x01, // Stream 1 3537 0x00, 0x00, 0x00, 0x01, // Stream 1
3538 0x40, 0x06, 0x43, 0x6f, 3538 0x40, 0x06, 0x43, 0x6f,
3539 0x6f, 0x6b, 0x69, 0x65, 3539 0x6f, 0x6b, 0x69, 0x65,
3540 0x08, 0x62, 0x61, 0x7a, 3540 0x08, 0x62, 0x61, 0x7a,
3541 0x3d, 0x62, 0x69, 0x6e, 3541 0x3d, 0x62, 0x69, 0x6e,
3542 0x67, 0x40, 0x06, 0x43, 3542 0x67, 0x40, 0x06, 0x43,
3543 3543
3544 0x00, 0x12, 0x0D, 0x04, // CONTINUATION: END_HEADERS 3544 0x00, 0x12, 0x09, 0x04, // CONTINUATION: END_HEADERS
3545 0x00, 0x00, 0x00, 0x01, // Stream 1 3545 0x00, 0x00, 0x00, 0x01, // Stream 1
3546 0x6f, 0x6f, 0x6b, 0x69, 3546 0x6f, 0x6f, 0x6b, 0x69,
3547 0x65, 0x00, 0x40, 0x04, 3547 0x65, 0x00, 0x40, 0x04,
3548 0x6e, 0x61, 0x6d, 0x65, 3548 0x6e, 0x61, 0x6d, 0x65,
3549 0x05, 0x76, 0x61, 0x6c, 3549 0x05, 0x76, 0x61, 0x6c,
3550 0x75, 0x65, 3550 0x75, 0x65,
3551 }; 3551 };
3552 3552
3553 SpdyFramer framer(spdy_version_); 3553 SpdyFramer framer(spdy_version_);
3554 TestSpdyVisitor visitor(spdy_version_); 3554 TestSpdyVisitor visitor(spdy_version_);
3555 visitor.SimulateInFramer(kInput, sizeof(kInput)); 3555 visitor.SimulateInFramer(kInput, sizeof(kInput));
3556 3556
3557 EXPECT_EQ(0, visitor.error_count_); 3557 EXPECT_EQ(0, visitor.error_count_);
3558 EXPECT_EQ(1, visitor.headers_frame_count_); 3558 EXPECT_EQ(1, visitor.headers_frame_count_);
3559 EXPECT_EQ(2, visitor.continuation_count_); 3559 EXPECT_EQ(2, visitor.continuation_count_);
3560 EXPECT_EQ(1, visitor.zero_length_control_frame_header_data_count_); 3560 EXPECT_EQ(1, visitor.zero_length_control_frame_header_data_count_);
3561 EXPECT_EQ(0, visitor.zero_length_data_frame_count_); 3561 EXPECT_EQ(0, visitor.zero_length_data_frame_count_);
3562 3562
3563 EXPECT_THAT(visitor.headers_, ElementsAre( 3563 EXPECT_THAT(visitor.headers_, ElementsAre(
3564 Pair("Cookie", "foo=bar; baz=bing; "), 3564 Pair("Cookie", "foo=bar; baz=bing; "),
3565 Pair("name", "value"))); 3565 Pair("name", "value")));
3566 } 3566 }
3567 3567
3568 TEST_P(SpdyFramerTest, ReadHeadersWithContinuationAndFin) { 3568 TEST_P(SpdyFramerTest, ReadHeadersWithContinuationAndFin) {
3569 if (spdy_version_ < 4) { 3569 if (spdy_version_ < 4) {
3570 return; 3570 return;
3571 } 3571 }
3572 3572
3573 const unsigned char kInput[] = { 3573 const unsigned char kInput[] = {
3574 0x00, 0x10, 0x08, 0x01, // HEADERS: FIN 3574 0x00, 0x10, 0x01, 0x01, // HEADERS: FIN
3575 0x00, 0x00, 0x00, 0x01, // Stream 1 3575 0x00, 0x00, 0x00, 0x01, // Stream 1
3576 0x40, 0x06, 0x43, 0x6f, 3576 0x40, 0x06, 0x43, 0x6f,
3577 0x6f, 0x6b, 0x69, 0x65, 3577 0x6f, 0x6b, 0x69, 0x65,
3578 0x07, 0x66, 0x6f, 0x6f, 3578 0x07, 0x66, 0x6f, 0x6f,
3579 0x3d, 0x62, 0x61, 0x72, 3579 0x3d, 0x62, 0x61, 0x72,
3580 3580
3581 0x00, 0x14, 0x0D, 0x00, // CONTINUATION 3581 0x00, 0x14, 0x09, 0x00, // CONTINUATION
3582 0x00, 0x00, 0x00, 0x01, // Stream 1 3582 0x00, 0x00, 0x00, 0x01, // Stream 1
3583 0x40, 0x06, 0x43, 0x6f, 3583 0x40, 0x06, 0x43, 0x6f,
3584 0x6f, 0x6b, 0x69, 0x65, 3584 0x6f, 0x6b, 0x69, 0x65,
3585 0x08, 0x62, 0x61, 0x7a, 3585 0x08, 0x62, 0x61, 0x7a,
3586 0x3d, 0x62, 0x69, 0x6e, 3586 0x3d, 0x62, 0x69, 0x6e,
3587 0x67, 0x40, 0x06, 0x43, 3587 0x67, 0x40, 0x06, 0x43,
3588 3588
3589 0x00, 0x12, 0x0D, 0x04, // CONTINUATION: END_HEADERS 3589 0x00, 0x12, 0x09, 0x04, // CONTINUATION: END_HEADERS
3590 0x00, 0x00, 0x00, 0x01, // Stream 1 3590 0x00, 0x00, 0x00, 0x01, // Stream 1
3591 0x6f, 0x6f, 0x6b, 0x69, 3591 0x6f, 0x6f, 0x6b, 0x69,
3592 0x65, 0x00, 0x40, 0x04, 3592 0x65, 0x00, 0x40, 0x04,
3593 0x6e, 0x61, 0x6d, 0x65, 3593 0x6e, 0x61, 0x6d, 0x65,
3594 0x05, 0x76, 0x61, 0x6c, 3594 0x05, 0x76, 0x61, 0x6c,
3595 0x75, 0x65, 3595 0x75, 0x65,
3596 }; 3596 };
3597 3597
3598 SpdyFramer framer(spdy_version_); 3598 SpdyFramer framer(spdy_version_);
3599 TestSpdyVisitor visitor(spdy_version_); 3599 TestSpdyVisitor visitor(spdy_version_);
(...skipping 10 matching lines...) Expand all
3610 Pair("Cookie", "foo=bar; baz=bing; "), 3610 Pair("Cookie", "foo=bar; baz=bing; "),
3611 Pair("name", "value"))); 3611 Pair("name", "value")));
3612 } 3612 }
3613 3613
3614 TEST_P(SpdyFramerTest, ReadPushPromiseWithContinuation) { 3614 TEST_P(SpdyFramerTest, ReadPushPromiseWithContinuation) {
3615 if (spdy_version_ < 4) { 3615 if (spdy_version_ < 4) {
3616 return; 3616 return;
3617 } 3617 }
3618 3618
3619 const unsigned char kInput[] = { 3619 const unsigned char kInput[] = {
3620 0x00, 0x14, 0x0C, 0x00, // PUSH_PROMISE 3620 0x00, 0x14, 0x05, 0x00, // PUSH_PROMISE
3621 0x00, 0x00, 0x00, 0x01, // Stream 1 3621 0x00, 0x00, 0x00, 0x01, // Stream 1
3622 0x00, 0x00, 0x00, 0x2A, // Promised stream 42 3622 0x00, 0x00, 0x00, 0x2A, // Promised stream 42
3623 0x40, 0x06, 0x43, 0x6f, 3623 0x40, 0x06, 0x43, 0x6f,
3624 0x6f, 0x6b, 0x69, 0x65, 3624 0x6f, 0x6b, 0x69, 0x65,
3625 0x07, 0x66, 0x6f, 0x6f, 3625 0x07, 0x66, 0x6f, 0x6f,
3626 0x3d, 0x62, 0x61, 0x72, 3626 0x3d, 0x62, 0x61, 0x72,
3627 3627
3628 0x00, 0x14, 0x0D, 0x00, // CONTINUATION 3628 0x00, 0x14, 0x09, 0x00, // CONTINUATION
3629 0x00, 0x00, 0x00, 0x01, // Stream 1 3629 0x00, 0x00, 0x00, 0x01, // Stream 1
3630 0x40, 0x06, 0x43, 0x6f, 3630 0x40, 0x06, 0x43, 0x6f,
3631 0x6f, 0x6b, 0x69, 0x65, 3631 0x6f, 0x6b, 0x69, 0x65,
3632 0x08, 0x62, 0x61, 0x7a, 3632 0x08, 0x62, 0x61, 0x7a,
3633 0x3d, 0x62, 0x69, 0x6e, 3633 0x3d, 0x62, 0x69, 0x6e,
3634 0x67, 0x40, 0x06, 0x43, 3634 0x67, 0x40, 0x06, 0x43,
3635 3635
3636 0x00, 0x12, 0x0D, 0x04, // CONTINUATION: END_HEADERS 3636 0x00, 0x12, 0x09, 0x04, // CONTINUATION: END_HEADERS
3637 0x00, 0x00, 0x00, 0x01, // Stream 1 3637 0x00, 0x00, 0x00, 0x01, // Stream 1
3638 0x6f, 0x6f, 0x6b, 0x69, 3638 0x6f, 0x6f, 0x6b, 0x69,
3639 0x65, 0x00, 0x40, 0x04, 3639 0x65, 0x00, 0x40, 0x04,
3640 0x6e, 0x61, 0x6d, 0x65, 3640 0x6e, 0x61, 0x6d, 0x65,
3641 0x05, 0x76, 0x61, 0x6c, 3641 0x05, 0x76, 0x61, 0x6c,
3642 0x75, 0x65, 3642 0x75, 0x65,
3643 }; 3643 };
3644 3644
3645 SpdyFramer framer(spdy_version_); 3645 SpdyFramer framer(spdy_version_);
3646 TestSpdyVisitor visitor(spdy_version_); 3646 TestSpdyVisitor visitor(spdy_version_);
(...skipping 10 matching lines...) Expand all
3657 Pair("Cookie", "foo=bar; baz=bing; "), 3657 Pair("Cookie", "foo=bar; baz=bing; "),
3658 Pair("name", "value"))); 3658 Pair("name", "value")));
3659 } 3659 }
3660 3660
3661 TEST_P(SpdyFramerTest, ReadContinuationWithWrongStreamId) { 3661 TEST_P(SpdyFramerTest, ReadContinuationWithWrongStreamId) {
3662 if (spdy_version_ < 4) { 3662 if (spdy_version_ < 4) {
3663 return; 3663 return;
3664 } 3664 }
3665 3665
3666 const unsigned char kInput[] = { 3666 const unsigned char kInput[] = {
3667 0x00, 0x10, 0x08, 0x00, // HEADERS 3667 0x00, 0x10, 0x01, 0x00, // HEADERS
3668 0x00, 0x00, 0x00, 0x01, // Stream 1 3668 0x00, 0x00, 0x00, 0x01, // Stream 1
3669 0x40, 0x06, 0x43, 0x6f, 3669 0x40, 0x06, 0x43, 0x6f,
3670 0x6f, 0x6b, 0x69, 0x65, 3670 0x6f, 0x6b, 0x69, 0x65,
3671 0x07, 0x66, 0x6f, 0x6f, 3671 0x07, 0x66, 0x6f, 0x6f,
3672 0x3d, 0x62, 0x61, 0x72, 3672 0x3d, 0x62, 0x61, 0x72,
3673 3673
3674 0x00, 0x14, 0x0D, 0x00, // CONTINUATION 3674 0x00, 0x14, 0x09, 0x00, // CONTINUATION
3675 0x00, 0x00, 0x00, 0x02, // Stream 2 3675 0x00, 0x00, 0x00, 0x02, // Stream 2
3676 0x40, 0x06, 0x43, 0x6f, 3676 0x40, 0x06, 0x43, 0x6f,
3677 0x6f, 0x6b, 0x69, 0x65, 3677 0x6f, 0x6b, 0x69, 0x65,
3678 0x08, 0x62, 0x61, 0x7a, 3678 0x08, 0x62, 0x61, 0x7a,
3679 0x3d, 0x62, 0x69, 0x6e, 3679 0x3d, 0x62, 0x69, 0x6e,
3680 0x67, 0x40, 0x06, 0x43, 3680 0x67, 0x40, 0x06, 0x43,
3681 }; 3681 };
3682 3682
3683 SpdyFramer framer(spdy_version_); 3683 SpdyFramer framer(spdy_version_);
3684 TestSpdyVisitor visitor(spdy_version_); 3684 TestSpdyVisitor visitor(spdy_version_);
3685 framer.set_visitor(&visitor); 3685 framer.set_visitor(&visitor);
3686 visitor.SimulateInFramer(kInput, sizeof(kInput)); 3686 visitor.SimulateInFramer(kInput, sizeof(kInput));
3687 3687
3688 EXPECT_EQ(1, visitor.error_count_); 3688 EXPECT_EQ(1, visitor.error_count_);
3689 EXPECT_EQ(SpdyFramer::SPDY_INVALID_CONTROL_FRAME, 3689 EXPECT_EQ(SpdyFramer::SPDY_INVALID_CONTROL_FRAME,
3690 visitor.framer_.error_code()) 3690 visitor.framer_.error_code())
3691 << SpdyFramer::ErrorCodeToString(framer.error_code()); 3691 << SpdyFramer::ErrorCodeToString(framer.error_code());
3692 EXPECT_EQ(1, visitor.headers_frame_count_); 3692 EXPECT_EQ(1, visitor.headers_frame_count_);
3693 EXPECT_EQ(0, visitor.continuation_count_); 3693 EXPECT_EQ(0, visitor.continuation_count_);
3694 EXPECT_EQ(0u, visitor.header_buffer_length_); 3694 EXPECT_EQ(0u, visitor.header_buffer_length_);
3695 } 3695 }
3696 3696
3697 TEST_P(SpdyFramerTest, ReadContinuationOutOfOrder) { 3697 TEST_P(SpdyFramerTest, ReadContinuationOutOfOrder) {
3698 if (spdy_version_ < 4) { 3698 if (spdy_version_ < 4) {
3699 return; 3699 return;
3700 } 3700 }
3701 3701
3702 const unsigned char kInput[] = { 3702 const unsigned char kInput[] = {
3703 0x00, 0x10, 0x0D, 0x00, // CONTINUATION 3703 0x00, 0x10, 0x09, 0x00, // CONTINUATION
3704 0x00, 0x00, 0x00, 0x01, // Stream 1 3704 0x00, 0x00, 0x00, 0x01, // Stream 1
3705 0x40, 0x06, 0x43, 0x6f, 3705 0x40, 0x06, 0x43, 0x6f,
3706 0x6f, 0x6b, 0x69, 0x65, 3706 0x6f, 0x6b, 0x69, 0x65,
3707 0x07, 0x66, 0x6f, 0x6f, 3707 0x07, 0x66, 0x6f, 0x6f,
3708 0x3d, 0x62, 0x61, 0x72, 3708 0x3d, 0x62, 0x61, 0x72,
3709 }; 3709 };
3710 3710
3711 SpdyFramer framer(spdy_version_); 3711 SpdyFramer framer(spdy_version_);
3712 TestSpdyVisitor visitor(spdy_version_); 3712 TestSpdyVisitor visitor(spdy_version_);
3713 framer.set_visitor(&visitor); 3713 framer.set_visitor(&visitor);
3714 visitor.SimulateInFramer(kInput, sizeof(kInput)); 3714 visitor.SimulateInFramer(kInput, sizeof(kInput));
3715 3715
3716 EXPECT_EQ(1, visitor.error_count_); 3716 EXPECT_EQ(1, visitor.error_count_);
3717 EXPECT_EQ(SpdyFramer::SPDY_UNEXPECTED_FRAME, 3717 EXPECT_EQ(SpdyFramer::SPDY_UNEXPECTED_FRAME,
3718 visitor.framer_.error_code()) 3718 visitor.framer_.error_code())
3719 << SpdyFramer::ErrorCodeToString(framer.error_code()); 3719 << SpdyFramer::ErrorCodeToString(framer.error_code());
3720 EXPECT_EQ(0, visitor.continuation_count_); 3720 EXPECT_EQ(0, visitor.continuation_count_);
3721 EXPECT_EQ(0u, visitor.header_buffer_length_); 3721 EXPECT_EQ(0u, visitor.header_buffer_length_);
3722 } 3722 }
3723 3723
3724 TEST_P(SpdyFramerTest, ExpectContinuationReceiveData) { 3724 TEST_P(SpdyFramerTest, ExpectContinuationReceiveData) {
3725 if (spdy_version_ < 4) { 3725 if (spdy_version_ < 4) {
3726 return; 3726 return;
3727 } 3727 }
3728 3728
3729 const unsigned char kInput[] = { 3729 const unsigned char kInput[] = {
3730 0x00, 0x10, 0x08, 0x00, // HEADERS 3730 0x00, 0x10, 0x01, 0x00, // HEADERS
3731 0x00, 0x00, 0x00, 0x01, // Stream 1 3731 0x00, 0x00, 0x00, 0x01, // Stream 1
3732 0x40, 0x06, 0x43, 0x6f, 3732 0x40, 0x06, 0x43, 0x6f,
3733 0x6f, 0x6b, 0x69, 0x65, 3733 0x6f, 0x6b, 0x69, 0x65,
3734 0x07, 0x66, 0x6f, 0x6f, 3734 0x07, 0x66, 0x6f, 0x6f,
3735 0x3d, 0x62, 0x61, 0x72, 3735 0x3d, 0x62, 0x61, 0x72,
3736 3736
3737 0x00, 0x00, 0x00, 0x01, // DATA on Stream #1 3737 0x00, 0x00, 0x00, 0x01, // DATA on Stream #1
3738 0x00, 0x00, 0x00, 0x04, 3738 0x00, 0x00, 0x00, 0x04,
3739 0xde, 0xad, 0xbe, 0xef, 3739 0xde, 0xad, 0xbe, 0xef,
3740 }; 3740 };
(...skipping 12 matching lines...) Expand all
3753 EXPECT_EQ(0u, visitor.header_buffer_length_); 3753 EXPECT_EQ(0u, visitor.header_buffer_length_);
3754 EXPECT_EQ(0, visitor.data_frame_count_); 3754 EXPECT_EQ(0, visitor.data_frame_count_);
3755 } 3755 }
3756 3756
3757 TEST_P(SpdyFramerTest, ExpectContinuationReceiveControlFrame) { 3757 TEST_P(SpdyFramerTest, ExpectContinuationReceiveControlFrame) {
3758 if (spdy_version_ < 4) { 3758 if (spdy_version_ < 4) {
3759 return; 3759 return;
3760 } 3760 }
3761 3761
3762 const unsigned char kInput[] = { 3762 const unsigned char kInput[] = {
3763 0x00, 0x10, 0x08, 0x00, // HEADERS 3763 0x00, 0x10, 0x01, 0x00, // HEADERS
3764 0x00, 0x00, 0x00, 0x01, // Stream 1 3764 0x00, 0x00, 0x00, 0x01, // Stream 1
3765 0x40, 0x06, 0x43, 0x6f, 3765 0x40, 0x06, 0x43, 0x6f,
3766 0x6f, 0x6b, 0x69, 0x65, 3766 0x6f, 0x6b, 0x69, 0x65,
3767 0x07, 0x66, 0x6f, 0x6f, 3767 0x07, 0x66, 0x6f, 0x6f,
3768 0x3d, 0x62, 0x61, 0x72, 3768 0x3d, 0x62, 0x61, 0x72,
3769 3769
3770 0x00, 0x14, 0x08, 0x00, // HEADERS 3770 0x00, 0x14, 0x08, 0x00, // HEADERS
3771 0x00, 0x00, 0x00, 0x01, // Stream 1 3771 0x00, 0x00, 0x00, 0x01, // Stream 1
3772 0x40, 0x06, 0x43, 0x6f, // (Note this is a valid continued encoding). 3772 0x40, 0x06, 0x43, 0x6f, // (Note this is a valid continued encoding).
3773 0x6f, 0x6b, 0x69, 0x65, 3773 0x6f, 0x6b, 0x69, 0x65,
(...skipping 977 matching lines...) Expand 10 before | Expand all | Expand 10 after
4751 SpdyBlockedIR blocked_ir(0); 4751 SpdyBlockedIR blocked_ir(0);
4752 scoped_ptr<SpdySerializedFrame> frame(framer.SerializeFrame(blocked_ir)); 4752 scoped_ptr<SpdySerializedFrame> frame(framer.SerializeFrame(blocked_ir));
4753 framer.ProcessInput(frame->data(), framer.GetBlockedSize()); 4753 framer.ProcessInput(frame->data(), framer.GetBlockedSize());
4754 4754
4755 EXPECT_EQ(SpdyFramer::SPDY_RESET, framer.state()); 4755 EXPECT_EQ(SpdyFramer::SPDY_RESET, framer.state());
4756 EXPECT_EQ(SpdyFramer::SPDY_NO_ERROR, framer.error_code()) 4756 EXPECT_EQ(SpdyFramer::SPDY_NO_ERROR, framer.error_code())
4757 << SpdyFramer::ErrorCodeToString(framer.error_code()); 4757 << SpdyFramer::ErrorCodeToString(framer.error_code());
4758 } 4758 }
4759 4759
4760 } // namespace net 4760 } // namespace net
OLDNEW
« no previous file with comments | « net/spdy/spdy_framer.cc ('k') | net/spdy/spdy_protocol.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698