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

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

Issue 710713002: Remove SPDY2 and SPDY/3.0 from tests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 6 years, 1 month 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
« no previous file with comments | « net/spdy/spdy_frame_builder_test.cc ('k') | net/spdy/spdy_headers_block_parser_test.cc » ('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 652 matching lines...) Expand 10 before | Expand all | Expand 10 after
663 LOG(ERROR) << "Expected header named '" << it->first 663 LOG(ERROR) << "Expected header named '" << it->first
664 << "' to have a value of '" << it->second 664 << "' to have a value of '" << it->second
665 << "'. The actual value received was '" << it2->second 665 << "'. The actual value received was '" << it2->second
666 << "'."; 666 << "'.";
667 return false; 667 return false;
668 } 668 }
669 } 669 }
670 return true; 670 return true;
671 } 671 }
672 672
673 bool IsSpdy2() { return spdy_version_ == SPDY2; }
Ryan Hamilton 2014/11/10 23:08:27 Have these changes been made server side too?
674 bool IsSpdy3() { return spdy_version_ == SPDY3; } 673 bool IsSpdy3() { return spdy_version_ == SPDY3; }
675 bool IsSpdy4() { return spdy_version_ == SPDY4; } 674 bool IsSpdy4() { return spdy_version_ == SPDY4; }
676 bool IsSpdy5() { return spdy_version_ == SPDY5; } 675 bool IsSpdy5() { return spdy_version_ == SPDY5; }
677 676
678 // Version of SPDY protocol to be used. 677 // Version of SPDY protocol to be used.
679 SpdyMajorVersion spdy_version_; 678 SpdyMajorVersion spdy_version_;
680 unsigned char spdy_version_ch_; 679 unsigned char spdy_version_ch_;
681 }; 680 };
682 681
683 // All tests are run with 3 different SPDY versions: SPDY/2, SPDY/3, SPDY/4.
684 INSTANTIATE_TEST_CASE_P(SpdyFramerTests, 682 INSTANTIATE_TEST_CASE_P(SpdyFramerTests,
685 SpdyFramerTest, 683 SpdyFramerTest,
686 ::testing::Values(SPDY2, SPDY3, SPDY4)); 684 ::testing::Values(SPDY3, SPDY4));
687 685
688 // Test that we ignore cookie where both name and value are empty. 686 // Test that we ignore cookie where both name and value are empty.
689 TEST_P(SpdyFramerTest, HeaderBlockWithEmptyCookie) { 687 TEST_P(SpdyFramerTest, HeaderBlockWithEmptyCookie) {
690 if (spdy_version_ > SPDY3) { 688 if (spdy_version_ > SPDY3) {
691 // Not implemented for hpack. 689 // Not implemented for hpack.
692 return; 690 return;
693 } 691 }
694 692
695 SpdyFramer framer(spdy_version_); 693 SpdyFramer framer(spdy_version_);
696 framer.set_enable_compression(true); 694 framer.set_enable_compression(true);
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
868 if (spdy_version_ <= SPDY3) { 866 if (spdy_version_ <= SPDY3) {
869 frame.WriteControlFrameHeader(framer, SYN_STREAM, CONTROL_FLAG_NONE); 867 frame.WriteControlFrameHeader(framer, SYN_STREAM, CONTROL_FLAG_NONE);
870 frame.WriteUInt32(3); // stream_id 868 frame.WriteUInt32(3); // stream_id
871 frame.WriteUInt32(0); // associated stream id 869 frame.WriteUInt32(0); // associated stream id
872 frame.WriteUInt16(0); // Priority. 870 frame.WriteUInt16(0); // Priority.
873 } else { 871 } else {
874 frame.BeginNewFrame(framer, HEADERS, HEADERS_FLAG_PRIORITY, 3); 872 frame.BeginNewFrame(framer, HEADERS, HEADERS_FLAG_PRIORITY, 3);
875 frame.WriteUInt32(framer.GetHighestPriority()); 873 frame.WriteUInt32(framer.GetHighestPriority());
876 } 874 }
877 875
878 if (IsSpdy2()) { 876 frame.WriteUInt32(2); // Number of headers.
879 frame.WriteUInt16(2); // Number of headers. 877 frame.WriteStringPiece32("name");
880 frame.WriteString("name"); 878 frame.WriteStringPiece32("value1");
881 frame.WriteString("value1"); 879 frame.WriteStringPiece32("name");
882 frame.WriteString("name"); 880 frame.WriteStringPiece32("value2");
883 frame.WriteString("value2");
884 } else {
885 frame.WriteUInt32(2); // Number of headers.
886 frame.WriteStringPiece32("name");
887 frame.WriteStringPiece32("value1");
888 frame.WriteStringPiece32("name");
889 frame.WriteStringPiece32("value2");
890 }
891 // write the length 881 // write the length
892 frame.RewriteLength(framer); 882 frame.RewriteLength(framer);
893 883
894 SpdyHeaderBlock new_headers; 884 SpdyHeaderBlock new_headers;
895 framer.set_enable_compression(false); 885 framer.set_enable_compression(false);
896 scoped_ptr<SpdyFrame> control_frame(frame.take()); 886 scoped_ptr<SpdyFrame> control_frame(frame.take());
897 base::StringPiece serialized_headers = 887 base::StringPiece serialized_headers =
898 GetSerializedHeaders(control_frame.get(), framer); 888 GetSerializedHeaders(control_frame.get(), framer);
899 // This should fail because duplicate headers are verboten by the spec. 889 // This should fail because duplicate headers are verboten by the spec.
900 EXPECT_FALSE(framer.ParseHeaderBlockInBuffer(serialized_headers.data(), 890 EXPECT_FALSE(framer.ParseHeaderBlockInBuffer(serialized_headers.data(),
(...skipping 13 matching lines...) Expand all
914 } else { 904 } else {
915 frame.BeginNewFrame(framer, 905 frame.BeginNewFrame(framer,
916 HEADERS, 906 HEADERS,
917 HEADERS_FLAG_PRIORITY | HEADERS_FLAG_END_HEADERS, 907 HEADERS_FLAG_PRIORITY | HEADERS_FLAG_END_HEADERS,
918 3); 908 3);
919 frame.WriteUInt32(0); // Priority exclusivity and dependent stream. 909 frame.WriteUInt32(0); // Priority exclusivity and dependent stream.
920 frame.WriteUInt8(255); // Priority weight. 910 frame.WriteUInt8(255); // Priority weight.
921 } 911 }
922 912
923 string value("value1\0value2", 13); 913 string value("value1\0value2", 13);
924 if (IsSpdy2()) { 914 if (spdy_version_ > SPDY3) {
925 frame.WriteUInt16(1); // Number of headers.
926 frame.WriteString("name");
927 frame.WriteString(value);
928 } else if (spdy_version_ > SPDY3) {
929 // TODO(jgraettinger): If this pattern appears again, move to test class. 915 // TODO(jgraettinger): If this pattern appears again, move to test class.
930 std::map<string, string> header_set; 916 std::map<string, string> header_set;
931 header_set["name"] = value; 917 header_set["name"] = value;
932 string buffer; 918 string buffer;
933 HpackEncoder encoder(ObtainHpackHuffmanTable()); 919 HpackEncoder encoder(ObtainHpackHuffmanTable());
934 encoder.EncodeHeaderSetWithoutCompression(header_set, &buffer); 920 encoder.EncodeHeaderSetWithoutCompression(header_set, &buffer);
935 frame.WriteBytes(&buffer[0], buffer.size()); 921 frame.WriteBytes(&buffer[0], buffer.size());
936 } else { 922 } else {
937 frame.WriteUInt32(1); // Number of headers. 923 frame.WriteUInt32(1); // Number of headers.
938 frame.WriteStringPiece32("name"); 924 frame.WriteStringPiece32("name");
(...skipping 28 matching lines...) Expand all
967 syn_stream.SetHeader("server", "SpdyServer 1.0"); 953 syn_stream.SetHeader("server", "SpdyServer 1.0");
968 syn_stream.SetHeader("date", "Mon 12 Jan 2009 12:12:12 PST"); 954 syn_stream.SetHeader("date", "Mon 12 Jan 2009 12:12:12 PST");
969 syn_stream.SetHeader("status", "200"); 955 syn_stream.SetHeader("status", "200");
970 syn_stream.SetHeader("version", "HTTP/1.1"); 956 syn_stream.SetHeader("version", "HTTP/1.1");
971 syn_stream.SetHeader("content-type", "text/html"); 957 syn_stream.SetHeader("content-type", "text/html");
972 syn_stream.SetHeader("content-length", "12"); 958 syn_stream.SetHeader("content-length", "12");
973 scoped_ptr<SpdyFrame> frame1(framer.SerializeSynStream(syn_stream)); 959 scoped_ptr<SpdyFrame> frame1(framer.SerializeSynStream(syn_stream));
974 size_t uncompressed_size1 = visitor->last_payload_len_; 960 size_t uncompressed_size1 = visitor->last_payload_len_;
975 size_t compressed_size1 = 961 size_t compressed_size1 =
976 visitor->last_frame_len_ - framer.GetSynStreamMinimumSize(); 962 visitor->last_frame_len_ - framer.GetSynStreamMinimumSize();
977 if (IsSpdy2()) { 963 EXPECT_EQ(165u, uncompressed_size1);
978 EXPECT_EQ(139u, uncompressed_size1);
979 #if defined(USE_SYSTEM_ZLIB) 964 #if defined(USE_SYSTEM_ZLIB)
980 EXPECT_EQ(155u, compressed_size1); 965 EXPECT_EQ(181u, compressed_size1);
981 #else // !defined(USE_SYSTEM_ZLIB) 966 #else // !defined(USE_SYSTEM_ZLIB)
982 EXPECT_EQ(135u, compressed_size1); 967 EXPECT_EQ(117u, compressed_size1);
983 #endif // !defined(USE_SYSTEM_ZLIB) 968 #endif // !defined(USE_SYSTEM_ZLIB)
984 } else {
985 EXPECT_EQ(165u, uncompressed_size1);
986 #if defined(USE_SYSTEM_ZLIB)
987 EXPECT_EQ(181u, compressed_size1);
988 #else // !defined(USE_SYSTEM_ZLIB)
989 EXPECT_EQ(117u, compressed_size1);
990 #endif // !defined(USE_SYSTEM_ZLIB)
991 }
992 scoped_ptr<SpdyFrame> frame2(framer.SerializeSynStream(syn_stream)); 969 scoped_ptr<SpdyFrame> frame2(framer.SerializeSynStream(syn_stream));
993 size_t uncompressed_size2 = visitor->last_payload_len_; 970 size_t uncompressed_size2 = visitor->last_payload_len_;
994 size_t compressed_size2 = 971 size_t compressed_size2 =
995 visitor->last_frame_len_ - framer.GetSynStreamMinimumSize(); 972 visitor->last_frame_len_ - framer.GetSynStreamMinimumSize();
996 973
997 // Expect the second frame to be more compact than the first. 974 // Expect the second frame to be more compact than the first.
998 EXPECT_LE(frame2->size(), frame1->size()); 975 EXPECT_LE(frame2->size(), frame1->size());
999 976
1000 // Decompress the first frame 977 // Decompress the first frame
1001 scoped_ptr<SpdyFrame> frame3( 978 scoped_ptr<SpdyFrame> frame3(
1002 SpdyFramerTestUtil::DecompressFrame(&framer, *frame1)); 979 SpdyFramerTestUtil::DecompressFrame(&framer, *frame1));
1003 980
1004 // Decompress the second frame 981 // Decompress the second frame
1005 visitor.reset(new TestSpdyVisitor(spdy_version_)); 982 visitor.reset(new TestSpdyVisitor(spdy_version_));
1006 framer.set_debug_visitor(visitor.get()); 983 framer.set_debug_visitor(visitor.get());
1007 scoped_ptr<SpdyFrame> frame4( 984 scoped_ptr<SpdyFrame> frame4(
1008 SpdyFramerTestUtil::DecompressFrame(&framer, *frame2)); 985 SpdyFramerTestUtil::DecompressFrame(&framer, *frame2));
1009 size_t uncompressed_size4 = 986 size_t uncompressed_size4 =
1010 frame4->size() - framer.GetSynStreamMinimumSize(); 987 frame4->size() - framer.GetSynStreamMinimumSize();
1011 size_t compressed_size4 = 988 size_t compressed_size4 =
1012 visitor->last_frame_len_ - framer.GetSynStreamMinimumSize(); 989 visitor->last_frame_len_ - framer.GetSynStreamMinimumSize();
1013 if (IsSpdy2()) { 990 EXPECT_EQ(165u, uncompressed_size4);
1014 EXPECT_EQ(139u, uncompressed_size4);
1015 #if defined(USE_SYSTEM_ZLIB) 991 #if defined(USE_SYSTEM_ZLIB)
1016 EXPECT_EQ(149u, compressed_size4); 992 EXPECT_EQ(175u, compressed_size4);
1017 #else // !defined(USE_SYSTEM_ZLIB) 993 #else // !defined(USE_SYSTEM_ZLIB)
1018 EXPECT_EQ(101u, compressed_size4); 994 EXPECT_EQ(102u, compressed_size4);
1019 #endif // !defined(USE_SYSTEM_ZLIB) 995 #endif // !defined(USE_SYSTEM_ZLIB)
1020 } else {
1021 EXPECT_EQ(165u, uncompressed_size4);
1022 #if defined(USE_SYSTEM_ZLIB)
1023 EXPECT_EQ(175u, compressed_size4);
1024 #else // !defined(USE_SYSTEM_ZLIB)
1025 EXPECT_EQ(102u, compressed_size4);
1026 #endif // !defined(USE_SYSTEM_ZLIB)
1027 }
1028 996
1029 EXPECT_EQ(uncompressed_size1, uncompressed_size2); 997 EXPECT_EQ(uncompressed_size1, uncompressed_size2);
1030 EXPECT_EQ(uncompressed_size1, uncompressed_size4); 998 EXPECT_EQ(uncompressed_size1, uncompressed_size4);
1031 EXPECT_EQ(compressed_size2, compressed_size4); 999 EXPECT_EQ(compressed_size2, compressed_size4);
1032 1000
1033 // Expect frames 3 & 4 to be the same. 1001 // Expect frames 3 & 4 to be the same.
1034 CompareFrames("Uncompressed SYN_STREAM", *frame3, *frame4); 1002 CompareFrames("Uncompressed SYN_STREAM", *frame3, *frame4);
1035 1003
1036 // Expect frames 3 to be the same as a uncompressed frame created 1004 // Expect frames 3 to be the same as a uncompressed frame created
1037 // from scratch. 1005 // from scratch.
(...skipping 13 matching lines...) Expand all
1051 headers.SetHeader("content-type", "text/html"); 1019 headers.SetHeader("content-type", "text/html");
1052 headers.SetHeader("content-length", "12"); 1020 headers.SetHeader("content-length", "12");
1053 headers.SetHeader("x-empty-header", ""); 1021 headers.SetHeader("x-empty-header", "");
1054 1022
1055 SpdyFramer framer(spdy_version_); 1023 SpdyFramer framer(spdy_version_);
1056 framer.set_enable_compression(true); 1024 framer.set_enable_compression(true);
1057 scoped_ptr<SpdyFrame> frame1(framer.SerializeHeaders(headers)); 1025 scoped_ptr<SpdyFrame> frame1(framer.SerializeHeaders(headers));
1058 } 1026 }
1059 1027
1060 TEST_P(SpdyFramerTest, Basic) { 1028 TEST_P(SpdyFramerTest, Basic) {
1061 const unsigned char kV2Input[] = {
1062 0x80, spdy_version_ch_, 0x00, 0x01, // SYN Stream #1
1063 0x00, 0x00, 0x00, 0x14,
1064 0x00, 0x00, 0x00, 0x01,
1065 0x00, 0x00, 0x00, 0x00,
1066 0x00, 0x00, 0x00, 0x01,
1067 0x00, 0x02, 'h', 'h',
1068 0x00, 0x02, 'v', 'v',
1069
1070 0x80, spdy_version_ch_, 0x00, 0x08, // HEADERS on Stream #1
1071 0x00, 0x00, 0x00, 0x18,
1072 0x00, 0x00, 0x00, 0x01,
1073 0x00, 0x00, 0x00, 0x02,
1074 0x00, 0x02, 'h', '2',
1075 0x00, 0x02, 'v', '2',
1076 0x00, 0x02, 'h', '3',
1077 0x00, 0x02, 'v', '3',
1078
1079 0x00, 0x00, 0x00, 0x01, // DATA on Stream #1
1080 0x00, 0x00, 0x00, 0x0c,
1081 0xde, 0xad, 0xbe, 0xef,
1082 0xde, 0xad, 0xbe, 0xef,
1083 0xde, 0xad, 0xbe, 0xef,
1084
1085 0x80, spdy_version_ch_, 0x00, 0x01, // SYN Stream #3
1086 0x00, 0x00, 0x00, 0x0c,
1087 0x00, 0x00, 0x00, 0x03,
1088 0x00, 0x00, 0x00, 0x00,
1089 0x00, 0x00, 0x00, 0x00,
1090
1091 0x00, 0x00, 0x00, 0x03, // DATA on Stream #3
1092 0x00, 0x00, 0x00, 0x08,
1093 0xde, 0xad, 0xbe, 0xef,
1094 0xde, 0xad, 0xbe, 0xef,
1095
1096 0x00, 0x00, 0x00, 0x01, // DATA on Stream #1
1097 0x00, 0x00, 0x00, 0x04,
1098 0xde, 0xad, 0xbe, 0xef,
1099
1100 0x80, spdy_version_ch_, 0x00, 0x03, // RST_STREAM on Stream #1
1101 0x00, 0x00, 0x00, 0x08,
1102 0x00, 0x00, 0x00, 0x01,
1103 0x00, 0x00, 0x00, 0x05, // RST_STREAM_CANCEL
1104
1105 0x00, 0x00, 0x00, 0x03, // DATA on Stream #3
1106 0x00, 0x00, 0x00, 0x00,
1107
1108 0x80, spdy_version_ch_, 0x00, 0x03, // RST_STREAM on Stream #3
1109 0x00, 0x00, 0x00, 0x08,
1110 0x00, 0x00, 0x00, 0x03,
1111 0x00, 0x00, 0x00, 0x05, // RST_STREAM_CANCEL
1112 };
1113
1114 const unsigned char kV3Input[] = { 1029 const unsigned char kV3Input[] = {
1115 0x80, spdy_version_ch_, 0x00, 0x01, // SYN Stream #1 1030 0x80, spdy_version_ch_, 0x00, 0x01, // SYN Stream #1
1116 0x00, 0x00, 0x00, 0x1a, 1031 0x00, 0x00, 0x00, 0x1a,
1117 0x00, 0x00, 0x00, 0x01, 1032 0x00, 0x00, 0x00, 0x01,
1118 0x00, 0x00, 0x00, 0x00, 1033 0x00, 0x00, 0x00, 0x00,
1119 0x00, 0x00, 0x00, 0x00, 1034 0x00, 0x00, 0x00, 0x00,
1120 0x00, 0x01, 0x00, 0x00, 1035 0x00, 0x01, 0x00, 0x00,
1121 0x00, 0x02, 'h', 'h', 1036 0x00, 0x02, 'h', 'h',
1122 0x00, 0x00, 0x00, 0x02, 1037 0x00, 0x00, 0x00, 0x02,
1123 'v', 'v', 1038 'v', 'v',
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
1216 1131
1217 0x00, 0x00, 0x0f, 0x03, // RST_STREAM on Stream #3 1132 0x00, 0x00, 0x0f, 0x03, // RST_STREAM on Stream #3
1218 0x00, 0x00, 0x00, 0x00, 1133 0x00, 0x00, 0x00, 0x00,
1219 0x03, 0x00, 0x00, 0x00, // RST_STREAM_CANCEL 1134 0x03, 0x00, 0x00, 0x00, // RST_STREAM_CANCEL
1220 0x08, 0x52, 0x45, 0x53, // opaque data 1135 0x08, 0x52, 0x45, 0x53, // opaque data
1221 0x45, 0x54, 0x53, 0x54, 1136 0x45, 0x54, 0x53, 0x54,
1222 0x52, 0x45, 0x41, 0x4d, 1137 0x52, 0x45, 0x41, 0x4d,
1223 }; 1138 };
1224 1139
1225 TestSpdyVisitor visitor(spdy_version_); 1140 TestSpdyVisitor visitor(spdy_version_);
1226 if (IsSpdy2()) { 1141 if (IsSpdy3()) {
1227 visitor.SimulateInFramer(kV2Input, sizeof(kV2Input));
1228 } else if (IsSpdy3()) {
1229 visitor.SimulateInFramer(kV3Input, sizeof(kV3Input)); 1142 visitor.SimulateInFramer(kV3Input, sizeof(kV3Input));
1230 } else { 1143 } else {
1231 visitor.SimulateInFramer(kV4Input, sizeof(kV4Input)); 1144 visitor.SimulateInFramer(kV4Input, sizeof(kV4Input));
1232 } 1145 }
1233 1146
1234 EXPECT_EQ(0, visitor.syn_reply_frame_count_); 1147 EXPECT_EQ(0, visitor.syn_reply_frame_count_);
1235 EXPECT_EQ(24, visitor.data_bytes_); 1148 EXPECT_EQ(24, visitor.data_bytes_);
1236 EXPECT_EQ(0, visitor.error_count_); 1149 EXPECT_EQ(0, visitor.error_count_);
1237 EXPECT_EQ(2, visitor.fin_frame_count_); 1150 EXPECT_EQ(2, visitor.fin_frame_count_);
1238 1151
1239 if (IsSpdy4()) { 1152 if (IsSpdy4()) {
1240 EXPECT_EQ(3, visitor.headers_frame_count_); 1153 EXPECT_EQ(3, visitor.headers_frame_count_);
1241 EXPECT_EQ(0, visitor.syn_frame_count_); 1154 EXPECT_EQ(0, visitor.syn_frame_count_);
1242 base::StringPiece reset_stream = "RESETSTREAM"; 1155 base::StringPiece reset_stream = "RESETSTREAM";
1243 EXPECT_EQ(reset_stream, visitor.fin_opaque_data_); 1156 EXPECT_EQ(reset_stream, visitor.fin_opaque_data_);
1244 } else { 1157 } else {
1245 EXPECT_EQ(1, visitor.headers_frame_count_); 1158 EXPECT_EQ(1, visitor.headers_frame_count_);
1246 EXPECT_EQ(2, visitor.syn_frame_count_); 1159 EXPECT_EQ(2, visitor.syn_frame_count_);
1247 EXPECT_TRUE(visitor.fin_opaque_data_.empty()); 1160 EXPECT_TRUE(visitor.fin_opaque_data_.empty());
1248 } 1161 }
1249 1162
1250 EXPECT_EQ(0, visitor.fin_flag_count_); 1163 EXPECT_EQ(0, visitor.fin_flag_count_);
1251 EXPECT_EQ(0, visitor.zero_length_data_frame_count_); 1164 EXPECT_EQ(0, visitor.zero_length_data_frame_count_);
1252 EXPECT_EQ(4, visitor.data_frame_count_); 1165 EXPECT_EQ(4, visitor.data_frame_count_);
1253 visitor.fin_opaque_data_.clear(); 1166 visitor.fin_opaque_data_.clear();
1254 } 1167 }
1255 1168
1256 // Test that the FIN flag on a data frame signifies EOF. 1169 // Test that the FIN flag on a data frame signifies EOF.
1257 TEST_P(SpdyFramerTest, FinOnDataFrame) { 1170 TEST_P(SpdyFramerTest, FinOnDataFrame) {
1258 const unsigned char kV2Input[] = {
1259 0x80, spdy_version_ch_, 0x00, 0x01, // SYN Stream #1
1260 0x00, 0x00, 0x00, 0x14,
1261 0x00, 0x00, 0x00, 0x01,
1262 0x00, 0x00, 0x00, 0x00,
1263 0x00, 0x00, 0x00, 0x01,
1264 0x00, 0x02, 'h', 'h',
1265 0x00, 0x02, 'v', 'v',
1266
1267 0x80, spdy_version_ch_, 0x00, 0x02, // SYN REPLY Stream #1
1268 0x00, 0x00, 0x00, 0x10,
1269 0x00, 0x00, 0x00, 0x01,
1270 0x00, 0x00, 0x00, 0x01,
1271 0x00, 0x02, 'a', 'a',
1272 0x00, 0x02, 'b', 'b',
1273
1274 0x00, 0x00, 0x00, 0x01, // DATA on Stream #1
1275 0x00, 0x00, 0x00, 0x0c,
1276 0xde, 0xad, 0xbe, 0xef,
1277 0xde, 0xad, 0xbe, 0xef,
1278 0xde, 0xad, 0xbe, 0xef,
1279
1280 0x00, 0x00, 0x00, 0x01, // DATA on Stream #1, with EOF
1281 0x01, 0x00, 0x00, 0x04,
1282 0xde, 0xad, 0xbe, 0xef,
1283 };
1284 const unsigned char kV3Input[] = { 1171 const unsigned char kV3Input[] = {
1285 0x80, spdy_version_ch_, 0x00, 0x01, // SYN Stream #1 1172 0x80, spdy_version_ch_, 0x00, 0x01, // SYN Stream #1
1286 0x00, 0x00, 0x00, 0x1a, 1173 0x00, 0x00, 0x00, 0x1a,
1287 0x00, 0x00, 0x00, 0x01, 1174 0x00, 0x00, 0x00, 0x01,
1288 0x00, 0x00, 0x00, 0x00, 1175 0x00, 0x00, 0x00, 0x00,
1289 0x00, 0x00, 0x00, 0x00, 1176 0x00, 0x00, 0x00, 0x00,
1290 0x00, 0x01, 0x00, 0x00, 1177 0x00, 0x01, 0x00, 0x00,
1291 0x00, 0x02, 'h', 'h', 1178 0x00, 0x02, 'h', 'h',
1292 0x00, 0x00, 0x00, 0x02, 1179 0x00, 0x00, 0x00, 0x02,
1293 'v', 'v', 1180 'v', 'v',
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1330 0xef, 0xde, 0xad, 0xbe, 1217 0xef, 0xde, 0xad, 0xbe,
1331 0xef, 1218 0xef,
1332 1219
1333 0x00, 0x00, 0x04, 0x00, // DATA on Stream #1, with FIN 1220 0x00, 0x00, 0x04, 0x00, // DATA on Stream #1, with FIN
1334 0x01, 0x00, 0x00, 0x00, 1221 0x01, 0x00, 0x00, 0x00,
1335 0x01, 0xde, 0xad, 0xbe, 1222 0x01, 0xde, 0xad, 0xbe,
1336 0xef, 1223 0xef,
1337 }; 1224 };
1338 1225
1339 TestSpdyVisitor visitor(spdy_version_); 1226 TestSpdyVisitor visitor(spdy_version_);
1340 if (IsSpdy2()) { 1227 if (IsSpdy3()) {
1341 visitor.SimulateInFramer(kV2Input, sizeof(kV2Input));
1342 } else if (IsSpdy3()) {
1343 visitor.SimulateInFramer(kV3Input, sizeof(kV3Input)); 1228 visitor.SimulateInFramer(kV3Input, sizeof(kV3Input));
1344 } else { 1229 } else {
1345 visitor.SimulateInFramer(kV4Input, sizeof(kV4Input)); 1230 visitor.SimulateInFramer(kV4Input, sizeof(kV4Input));
1346 } 1231 }
1347 1232
1348 EXPECT_EQ(0, visitor.error_count_); 1233 EXPECT_EQ(0, visitor.error_count_);
1349 if (IsSpdy4()) { 1234 if (IsSpdy4()) {
1350 EXPECT_EQ(0, visitor.syn_frame_count_); 1235 EXPECT_EQ(0, visitor.syn_frame_count_);
1351 EXPECT_EQ(0, visitor.syn_reply_frame_count_); 1236 EXPECT_EQ(0, visitor.syn_reply_frame_count_);
1352 EXPECT_EQ(2, visitor.headers_frame_count_); 1237 EXPECT_EQ(2, visitor.headers_frame_count_);
1353 } else { 1238 } else {
1354 EXPECT_EQ(1, visitor.syn_frame_count_); 1239 EXPECT_EQ(1, visitor.syn_frame_count_);
1355 EXPECT_EQ(1, visitor.syn_reply_frame_count_); 1240 EXPECT_EQ(1, visitor.syn_reply_frame_count_);
1356 EXPECT_EQ(0, visitor.headers_frame_count_); 1241 EXPECT_EQ(0, visitor.headers_frame_count_);
1357 } 1242 }
1358 EXPECT_EQ(16, visitor.data_bytes_); 1243 EXPECT_EQ(16, visitor.data_bytes_);
1359 EXPECT_EQ(0, visitor.fin_frame_count_); 1244 EXPECT_EQ(0, visitor.fin_frame_count_);
1360 EXPECT_EQ(0, visitor.fin_flag_count_); 1245 EXPECT_EQ(0, visitor.fin_flag_count_);
1361 EXPECT_EQ(1, visitor.zero_length_data_frame_count_); 1246 EXPECT_EQ(1, visitor.zero_length_data_frame_count_);
1362 EXPECT_EQ(2, visitor.data_frame_count_); 1247 EXPECT_EQ(2, visitor.data_frame_count_);
1363 } 1248 }
1364 1249
1365 // Test that the FIN flag on a SYN reply frame signifies EOF. 1250 // Test that the FIN flag on a SYN reply frame signifies EOF.
1366 TEST_P(SpdyFramerTest, FinOnSynReplyFrame) { 1251 TEST_P(SpdyFramerTest, FinOnSynReplyFrame) {
1367 const unsigned char kV2Input[] = {
1368 0x80, spdy_version_ch_, 0x00, // SYN Stream #1
1369 0x01, 0x00, 0x00, 0x00,
1370 0x14, 0x00, 0x00, 0x00,
1371 0x01, 0x00, 0x00, 0x00,
1372 0x00, 0x00, 0x00, 0x00,
1373 0x01, 0x00, 0x02, 'h',
1374 'h', 0x00, 0x02, 'v',
1375 'v',
1376
1377 0x80, spdy_version_ch_, 0x00, // SYN REPLY Stream #1
1378 0x02, 0x01, 0x00, 0x00,
1379 0x10, 0x00, 0x00, 0x00,
1380 0x01, 0x00, 0x00, 0x00,
1381 0x01, 0x00, 0x02, 'a',
1382 'a', 0x00, 0x02, 'b',
1383 'b',
1384 };
1385 const unsigned char kV3Input[] = { 1252 const unsigned char kV3Input[] = {
1386 0x80, spdy_version_ch_, 0x00, // SYN Stream #1 1253 0x80, spdy_version_ch_, 0x00, // SYN Stream #1
1387 0x01, 0x00, 0x00, 0x00, 1254 0x01, 0x00, 0x00, 0x00,
1388 0x1a, 0x00, 0x00, 0x00, 1255 0x1a, 0x00, 0x00, 0x00,
1389 0x01, 0x00, 0x00, 0x00, 1256 0x01, 0x00, 0x00, 0x00,
1390 0x00, 0x00, 0x00, 0x00, 1257 0x00, 0x00, 0x00, 0x00,
1391 0x00, 0x00, 0x01, 0x00, 1258 0x00, 0x00, 0x01, 0x00,
1392 0x00, 0x00, 0x02, 'h', 1259 0x00, 0x00, 0x02, 'h',
1393 'h', 0x00, 0x00, 0x00, 1260 'h', 0x00, 0x00, 0x00,
1394 0x02, 'v', 'v', 1261 0x02, 'v', 'v',
(...skipping 15 matching lines...) Expand all
1410 0x24, 0x00, 0x00, 0x00, 1277 0x24, 0x00, 0x00, 0x00,
1411 0x01, 0x00, 0x00, 0x00, // Stream 1, Priority 0 1278 0x01, 0x00, 0x00, 0x00, // Stream 1, Priority 0
1412 0x00, 0x82, // :method: GET 1279 0x00, 0x82, // :method: GET
1413 1280
1414 0x00, 0x00, 0x01, 0x01, // HEADERS: FIN | END_HEADERS 1281 0x00, 0x00, 0x01, 0x01, // HEADERS: FIN | END_HEADERS
1415 0x05, 0x00, 0x00, 0x00, 1282 0x05, 0x00, 0x00, 0x00,
1416 0x01, 0x8c, // Stream 1, :status: 200 1283 0x01, 0x8c, // Stream 1, :status: 200
1417 }; 1284 };
1418 1285
1419 TestSpdyVisitor visitor(spdy_version_); 1286 TestSpdyVisitor visitor(spdy_version_);
1420 if (IsSpdy2()) { 1287 if (IsSpdy3()) {
1421 visitor.SimulateInFramer(kV2Input, sizeof(kV2Input));
1422 } else if (IsSpdy3()) {
1423 visitor.SimulateInFramer(kV3Input, sizeof(kV3Input)); 1288 visitor.SimulateInFramer(kV3Input, sizeof(kV3Input));
1424 } else { 1289 } else {
1425 visitor.SimulateInFramer(kV4Input, sizeof(kV4Input)); 1290 visitor.SimulateInFramer(kV4Input, sizeof(kV4Input));
1426 } 1291 }
1427 1292
1428 EXPECT_EQ(0, visitor.error_count_); 1293 EXPECT_EQ(0, visitor.error_count_);
1429 if (IsSpdy4()) { 1294 if (IsSpdy4()) {
1430 EXPECT_EQ(0, visitor.syn_frame_count_); 1295 EXPECT_EQ(0, visitor.syn_frame_count_);
1431 EXPECT_EQ(0, visitor.syn_reply_frame_count_); 1296 EXPECT_EQ(0, visitor.syn_reply_frame_count_);
1432 EXPECT_EQ(2, visitor.headers_frame_count_); 1297 EXPECT_EQ(2, visitor.headers_frame_count_);
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after
1885 memset(expected_frame_data.get() + arraysize(kFrameHeader), 'A', kDataSize); 1750 memset(expected_frame_data.get() + arraysize(kFrameHeader), 'A', kDataSize);
1886 1751
1887 SpdyDataIR data_ir(1, StringPiece(kData.data(), kData.size())); 1752 SpdyDataIR data_ir(1, StringPiece(kData.data(), kData.size()));
1888 data_ir.set_fin(true); 1753 data_ir.set_fin(true);
1889 scoped_ptr<SpdyFrame> frame(framer.SerializeData(data_ir)); 1754 scoped_ptr<SpdyFrame> frame(framer.SerializeData(data_ir));
1890 CompareFrame(kDescription, *frame, expected_frame_data.get(), kFrameSize); 1755 CompareFrame(kDescription, *frame, expected_frame_data.get(), kFrameSize);
1891 } 1756 }
1892 } 1757 }
1893 1758
1894 TEST_P(SpdyFramerTest, CreateSynStreamUncompressed) { 1759 TEST_P(SpdyFramerTest, CreateSynStreamUncompressed) {
1895 if (!IsSpdy2() && !IsSpdy3()) { 1760 if (spdy_version_ > SPDY3) {
1896 // SYN_STREAM unsupported in SPDY>3 1761 // SYN_STREAM unsupported in SPDY>3
1897 return; 1762 return;
1898 } 1763 }
1899 SpdyFramer framer(spdy_version_); 1764 SpdyFramer framer(spdy_version_);
1900 framer.set_enable_compression(false); 1765 framer.set_enable_compression(false);
1901 1766
1902 { 1767 {
1903 const char kDescription[] = "SYN_STREAM frame, lowest pri, no FIN"; 1768 const char kDescription[] = "SYN_STREAM frame, lowest pri, no FIN";
1904 1769 const unsigned char kPri = 0xE0;
1905 const unsigned char kPri = IsSpdy2() ? 0xC0 : 0xE0;
1906 const unsigned char kV2FrameData[] = {
1907 0x80, spdy_version_ch_, 0x00, 0x01,
1908 0x00, 0x00, 0x00, 0x20,
1909 0x00, 0x00, 0x00, 0x01,
1910 0x00, 0x00, 0x00, 0x00,
1911 kPri, 0x00, 0x00, 0x02,
1912 0x00, 0x03, 'b', 'a',
1913 'r', 0x00, 0x03, 'f',
1914 'o', 'o', 0x00, 0x03,
1915 'f', 'o', 'o', 0x00,
1916 0x03, 'b', 'a', 'r'
1917 };
1918 const unsigned char kV3FrameData[] = { 1770 const unsigned char kV3FrameData[] = {
1919 0x80, spdy_version_ch_, 0x00, 0x01, 1771 0x80, spdy_version_ch_, 0x00, 0x01,
1920 0x00, 0x00, 0x00, 0x2a, 1772 0x00, 0x00, 0x00, 0x2a,
1921 0x00, 0x00, 0x00, 0x01, 1773 0x00, 0x00, 0x00, 0x01,
1922 0x00, 0x00, 0x00, 0x00, 1774 0x00, 0x00, 0x00, 0x00,
1923 kPri, 0x00, 0x00, 0x00, 1775 kPri, 0x00, 0x00, 0x00,
1924 0x00, 0x02, 0x00, 0x00, 1776 0x00, 0x02, 0x00, 0x00,
1925 0x00, 0x03, 'b', 'a', 1777 0x00, 0x03, 'b', 'a',
1926 'r', 0x00, 0x00, 0x00, 1778 'r', 0x00, 0x00, 0x00,
1927 0x03, 'f', 'o', 'o', 1779 0x03, 'f', 'o', 'o',
1928 0x00, 0x00, 0x00, 0x03, 1780 0x00, 0x00, 0x00, 0x03,
1929 'f', 'o', 'o', 0x00, 1781 'f', 'o', 'o', 0x00,
1930 0x00, 0x00, 0x03, 'b', 1782 0x00, 0x00, 0x03, 'b',
1931 'a', 'r' 1783 'a', 'r'
1932 }; 1784 };
1933 SpdySynStreamIR syn_stream(1); 1785 SpdySynStreamIR syn_stream(1);
1934 syn_stream.set_priority(framer.GetLowestPriority()); 1786 syn_stream.set_priority(framer.GetLowestPriority());
1935 syn_stream.SetHeader("bar", "foo"); 1787 syn_stream.SetHeader("bar", "foo");
1936 syn_stream.SetHeader("foo", "bar"); 1788 syn_stream.SetHeader("foo", "bar");
1937 scoped_ptr<SpdyFrame> frame(framer.SerializeSynStream(syn_stream)); 1789 scoped_ptr<SpdyFrame> frame(framer.SerializeSynStream(syn_stream));
1938 if (IsSpdy2()) { 1790 CompareFrame(kDescription, *frame, kV3FrameData, arraysize(kV3FrameData));
1939 CompareFrame(kDescription, *frame, kV2FrameData, arraysize(kV2FrameData));
1940 } else if (IsSpdy3()) {
1941 CompareFrame(kDescription, *frame, kV3FrameData, arraysize(kV3FrameData));
1942 } else {
1943 LOG(FATAL) << "Unsupported version in test.";
1944 }
1945 } 1791 }
1946 1792
1947 { 1793 {
1948 const char kDescription[] = 1794 const char kDescription[] =
1949 "SYN_STREAM frame with a 0-length header name, highest pri, FIN, " 1795 "SYN_STREAM frame with a 0-length header name, highest pri, FIN, "
1950 "max stream ID"; 1796 "max stream ID";
1951
1952 const unsigned char kV2FrameData[] = {
1953 0x80, spdy_version_ch_, 0x00, 0x01,
1954 0x01, 0x00, 0x00, 0x1D,
1955 0x7f, 0xff, 0xff, 0xff,
1956 0x7f, 0xff, 0xff, 0xff,
1957 0x00, 0x00, 0x00, 0x02,
1958 0x00, 0x00, 0x00, 0x03,
1959 'f', 'o', 'o', 0x00,
1960 0x03, 'f', 'o', 'o',
1961 0x00, 0x03, 'b', 'a',
1962 'r'
1963 };
1964 const unsigned char kV3FrameData[] = { 1797 const unsigned char kV3FrameData[] = {
1965 0x80, spdy_version_ch_, 0x00, 0x01, 1798 0x80, spdy_version_ch_, 0x00, 0x01,
1966 0x01, 0x00, 0x00, 0x27, 1799 0x01, 0x00, 0x00, 0x27,
1967 0x7f, 0xff, 0xff, 0xff, 1800 0x7f, 0xff, 0xff, 0xff,
1968 0x7f, 0xff, 0xff, 0xff, 1801 0x7f, 0xff, 0xff, 0xff,
1969 0x00, 0x00, 0x00, 0x00, 1802 0x00, 0x00, 0x00, 0x00,
1970 0x00, 0x02, 0x00, 0x00, 1803 0x00, 0x02, 0x00, 0x00,
1971 0x00, 0x00, 0x00, 0x00, 1804 0x00, 0x00, 0x00, 0x00,
1972 0x00, 0x03, 'f', 'o', 1805 0x00, 0x03, 'f', 'o',
1973 'o', 0x00, 0x00, 0x00, 1806 'o', 0x00, 0x00, 0x00,
1974 0x03, 'f', 'o', 'o', 1807 0x03, 'f', 'o', 'o',
1975 0x00, 0x00, 0x00, 0x03, 1808 0x00, 0x00, 0x00, 0x03,
1976 'b', 'a', 'r' 1809 'b', 'a', 'r'
1977 }; 1810 };
1978 SpdySynStreamIR syn_stream(0x7fffffff); 1811 SpdySynStreamIR syn_stream(0x7fffffff);
1979 syn_stream.set_associated_to_stream_id(0x7fffffff); 1812 syn_stream.set_associated_to_stream_id(0x7fffffff);
1980 syn_stream.set_priority(framer.GetHighestPriority()); 1813 syn_stream.set_priority(framer.GetHighestPriority());
1981 syn_stream.set_fin(true); 1814 syn_stream.set_fin(true);
1982 syn_stream.SetHeader("", "foo"); 1815 syn_stream.SetHeader("", "foo");
1983 syn_stream.SetHeader("foo", "bar"); 1816 syn_stream.SetHeader("foo", "bar");
1984 scoped_ptr<SpdyFrame> frame(framer.SerializeSynStream(syn_stream)); 1817 scoped_ptr<SpdyFrame> frame(framer.SerializeSynStream(syn_stream));
1985 if (IsSpdy2()) { 1818 CompareFrame(kDescription, *frame, kV3FrameData, arraysize(kV3FrameData));
1986 CompareFrame(kDescription, *frame, kV2FrameData, arraysize(kV2FrameData));
1987 } else if (IsSpdy3()) {
1988 CompareFrame(kDescription, *frame, kV3FrameData, arraysize(kV3FrameData));
1989 } else {
1990 LOG(FATAL) << "Unsupported version in test.";
1991 }
1992 } 1819 }
1993 1820
1994 { 1821 {
1995 const char kDescription[] = 1822 const char kDescription[] =
1996 "SYN_STREAM frame with a 0-length header val, high pri, FIN, " 1823 "SYN_STREAM frame with a 0-length header val, high pri, FIN, "
1997 "max stream ID"; 1824 "max stream ID";
1998 1825 const unsigned char kPri = 0x20;
1999 const unsigned char kPri = IsSpdy2() ? 0x40 : 0x20;
2000 const unsigned char kV2FrameData[] = {
2001 0x80, spdy_version_ch_, 0x00, 0x01,
2002 0x01, 0x00, 0x00, 0x1D,
2003 0x7f, 0xff, 0xff, 0xff,
2004 0x7f, 0xff, 0xff, 0xff,
2005 kPri, 0x00, 0x00, 0x02,
2006 0x00, 0x03, 'b', 'a',
2007 'r', 0x00, 0x03, 'f',
2008 'o', 'o', 0x00, 0x03,
2009 'f', 'o', 'o', 0x00,
2010 0x00
2011 };
2012 const unsigned char kV3FrameData[] = { 1826 const unsigned char kV3FrameData[] = {
2013 0x80, spdy_version_ch_, 0x00, 0x01, 1827 0x80, spdy_version_ch_, 0x00, 0x01,
2014 0x01, 0x00, 0x00, 0x27, 1828 0x01, 0x00, 0x00, 0x27,
2015 0x7f, 0xff, 0xff, 0xff, 1829 0x7f, 0xff, 0xff, 0xff,
2016 0x7f, 0xff, 0xff, 0xff, 1830 0x7f, 0xff, 0xff, 0xff,
2017 kPri, 0x00, 0x00, 0x00, 1831 kPri, 0x00, 0x00, 0x00,
2018 0x00, 0x02, 0x00, 0x00, 1832 0x00, 0x02, 0x00, 0x00,
2019 0x00, 0x03, 'b', 'a', 1833 0x00, 0x03, 'b', 'a',
2020 'r', 0x00, 0x00, 0x00, 1834 'r', 0x00, 0x00, 0x00,
2021 0x03, 'f', 'o', 'o', 1835 0x03, 'f', 'o', 'o',
2022 0x00, 0x00, 0x00, 0x03, 1836 0x00, 0x00, 0x00, 0x03,
2023 'f', 'o', 'o', 0x00, 1837 'f', 'o', 'o', 0x00,
2024 0x00, 0x00, 0x00 1838 0x00, 0x00, 0x00
2025 }; 1839 };
2026 SpdySynStreamIR syn_stream(0x7fffffff); 1840 SpdySynStreamIR syn_stream(0x7fffffff);
2027 syn_stream.set_associated_to_stream_id(0x7fffffff); 1841 syn_stream.set_associated_to_stream_id(0x7fffffff);
2028 syn_stream.set_priority(1); 1842 syn_stream.set_priority(1);
2029 syn_stream.set_fin(true); 1843 syn_stream.set_fin(true);
2030 syn_stream.SetHeader("bar", "foo"); 1844 syn_stream.SetHeader("bar", "foo");
2031 syn_stream.SetHeader("foo", ""); 1845 syn_stream.SetHeader("foo", "");
2032 scoped_ptr<SpdyFrame> frame(framer.SerializeSynStream(syn_stream)); 1846 scoped_ptr<SpdyFrame> frame(framer.SerializeSynStream(syn_stream));
2033 if (IsSpdy2()) { 1847 CompareFrame(kDescription, *frame, kV3FrameData, arraysize(kV3FrameData));
2034 CompareFrame(kDescription, *frame, kV2FrameData, arraysize(kV2FrameData));
2035 } else if (IsSpdy3()) {
2036 CompareFrame(kDescription, *frame, kV3FrameData, arraysize(kV3FrameData));
2037 } else {
2038 LOG(FATAL) << "Unsupported version in test.";
2039 }
2040 } 1848 }
2041 } 1849 }
2042 1850
2043 // TODO(phajdan.jr): Clean up after we no longer need 1851 // TODO(phajdan.jr): Clean up after we no longer need
2044 // to workaround http://crbug.com/139744. 1852 // to workaround http://crbug.com/139744.
2045 #if !defined(USE_SYSTEM_ZLIB) 1853 #if !defined(USE_SYSTEM_ZLIB)
2046 TEST_P(SpdyFramerTest, CreateSynStreamCompressed) { 1854 TEST_P(SpdyFramerTest, CreateSynStreamCompressed) {
2047 if (!IsSpdy2() && !IsSpdy3()) { 1855 if (spdy_version_ > SPDY3) {
2048 // SYN_STREAM not supported for SPDY>3 1856 // SYN_STREAM not supported for SPDY>3
2049 return; 1857 return;
2050 } 1858 }
2051 SpdyFramer framer(spdy_version_); 1859 SpdyFramer framer(spdy_version_);
2052 framer.set_enable_compression(true); 1860 framer.set_enable_compression(true);
2053 1861
2054 { 1862 {
2055 const char kDescription[] = 1863 const char kDescription[] =
2056 "SYN_STREAM frame, low pri, no FIN"; 1864 "SYN_STREAM frame, low pri, no FIN";
2057 const SpdyPriority priority = IsSpdy2() ? 2 : 4; 1865 const SpdyPriority priority = 4;
2058 1866
2059 const unsigned char kV2FrameData[] = {
2060 0x80, spdy_version_ch_, 0x00, 0x01,
2061 0x00, 0x00, 0x00, 0x36,
2062 0x00, 0x00, 0x00, 0x01,
2063 0x00, 0x00, 0x00, 0x00,
2064 0x80, 0x00, 0x38, 0xea,
2065 0xdf, 0xa2, 0x51, 0xb2,
2066 0x62, 0x60, 0x62, 0x60,
2067 0x4e, 0x4a, 0x2c, 0x62,
2068 0x60, 0x06, 0x08, 0xa0,
2069 0xb4, 0xfc, 0x7c, 0x80,
2070 0x00, 0x62, 0x60, 0x4e,
2071 0xcb, 0xcf, 0x67, 0x60,
2072 0x06, 0x08, 0xa0, 0xa4,
2073 0xc4, 0x22, 0x80, 0x00,
2074 0x02, 0x00, 0x00, 0x00,
2075 0xff, 0xff,
2076 };
2077 const unsigned char kV3FrameData[] = { 1867 const unsigned char kV3FrameData[] = {
2078 0x80, spdy_version_ch_, 0x00, 0x01, 1868 0x80, spdy_version_ch_, 0x00, 0x01,
2079 0x00, 0x00, 0x00, 0x37, 1869 0x00, 0x00, 0x00, 0x37,
2080 0x00, 0x00, 0x00, 0x01, 1870 0x00, 0x00, 0x00, 0x01,
2081 0x00, 0x00, 0x00, 0x00, 1871 0x00, 0x00, 0x00, 0x00,
2082 0x80, 0x00, 0x38, 0xEA, 1872 0x80, 0x00, 0x38, 0xEA,
2083 0xE3, 0xC6, 0xA7, 0xC2, 1873 0xE3, 0xC6, 0xA7, 0xC2,
2084 0x02, 0xE5, 0x0E, 0x50, 1874 0x02, 0xE5, 0x0E, 0x50,
2085 0xC2, 0x4B, 0x4A, 0x04, 1875 0xC2, 0x4B, 0x4A, 0x04,
2086 0xE5, 0x0B, 0x66, 0x80, 1876 0xE5, 0x0B, 0x66, 0x80,
2087 0x00, 0x4A, 0xCB, 0xCF, 1877 0x00, 0x4A, 0xCB, 0xCF,
2088 0x07, 0x08, 0x20, 0x10, 1878 0x07, 0x08, 0x20, 0x10,
2089 0x95, 0x96, 0x9F, 0x0F, 1879 0x95, 0x96, 0x9F, 0x0F,
2090 0xA2, 0x00, 0x02, 0x28, 1880 0xA2, 0x00, 0x02, 0x28,
2091 0x29, 0xB1, 0x08, 0x20, 1881 0x29, 0xB1, 0x08, 0x20,
2092 0x80, 0x00, 0x00, 0x00, 1882 0x80, 0x00, 0x00, 0x00,
2093 0x00, 0xFF, 0xFF, 1883 0x00, 0xFF, 0xFF,
2094 }; 1884 };
2095 const unsigned char kV2SIMDFrameData[] = {
2096 0x80, spdy_version_ch_, 0x00, 0x01,
2097 0x00, 0x00, 0x00, 0x33,
2098 0x00, 0x00, 0x00, 0x01,
2099 0x00, 0x00, 0x00, 0x00,
2100 0x80, 0x00, 0x38, 0xea,
2101 0xdf, 0xa2, 0x51, 0xb2,
2102 0x62, 0x60, 0x62, 0x60,
2103 0x4e, 0x4a, 0x2c, 0x62,
2104 0x60, 0x06, 0x08, 0xa0,
2105 0xb4, 0xfc, 0x7c, 0x80,
2106 0x00, 0x62, 0x60, 0x06,
2107 0x13, 0x00, 0x01, 0x94,
2108 0x94, 0x58, 0x04, 0x10,
2109 0x40, 0x00, 0x00, 0x00,
2110 0x00, 0xff, 0xff,
2111 };
2112 const unsigned char kV3SIMDFrameData[] = { 1885 const unsigned char kV3SIMDFrameData[] = {
2113 0x80, spdy_version_ch_, 0x00, 0x01, 1886 0x80, spdy_version_ch_, 0x00, 0x01,
2114 0x00, 0x00, 0x00, 0x32, 1887 0x00, 0x00, 0x00, 0x32,
2115 0x00, 0x00, 0x00, 0x01, 1888 0x00, 0x00, 0x00, 0x01,
2116 0x00, 0x00, 0x00, 0x00, 1889 0x00, 0x00, 0x00, 0x00,
2117 0x80, 0x00, 0x38, 0xea, 1890 0x80, 0x00, 0x38, 0xea,
2118 0xe3, 0xc6, 0xa7, 0xc2, 1891 0xe3, 0xc6, 0xa7, 0xc2,
2119 0x02, 0xe5, 0x0e, 0x50, 1892 0x02, 0xe5, 0x0e, 0x50,
2120 0xc2, 0x4b, 0x4a, 0x04, 1893 0xc2, 0x4b, 0x4a, 0x04,
2121 0xe5, 0x0b, 0x66, 0x80, 1894 0xe5, 0x0b, 0x66, 0x80,
2122 0x00, 0x4a, 0xcb, 0xcf, 1895 0x00, 0x4a, 0xcb, 0xcf,
2123 0x07, 0x08, 0x20, 0x24, 1896 0x07, 0x08, 0x20, 0x24,
2124 0x0a, 0x20, 0x80, 0x92, 1897 0x0a, 0x20, 0x80, 0x92,
2125 0x12, 0x8b, 0x00, 0x02, 1898 0x12, 0x8b, 0x00, 0x02,
2126 0x08, 0x00, 0x00, 0x00, 1899 0x08, 0x00, 0x00, 0x00,
2127 0xff, 0xff, 1900 0xff, 0xff,
2128 }; 1901 };
2129 1902
2130 SpdySynStreamIR syn_stream(1); 1903 SpdySynStreamIR syn_stream(1);
2131 syn_stream.set_priority(priority); 1904 syn_stream.set_priority(priority);
2132 syn_stream.SetHeader("bar", "foo"); 1905 syn_stream.SetHeader("bar", "foo");
2133 syn_stream.SetHeader("foo", "bar"); 1906 syn_stream.SetHeader("foo", "bar");
2134 scoped_ptr<SpdyFrame> frame(framer.SerializeSynStream(syn_stream)); 1907 scoped_ptr<SpdyFrame> frame(framer.SerializeSynStream(syn_stream));
2135 const unsigned char* frame_data = 1908 const unsigned char* frame_data =
2136 reinterpret_cast<const unsigned char*>(frame->data()); 1909 reinterpret_cast<const unsigned char*>(frame->data());
2137 if (IsSpdy2()) { 1910 if (memcmp(frame_data,
2138 // Try comparing with SIMD version, if that fails, do a failing check 1911 kV3SIMDFrameData,
2139 // with pretty printing against non-SIMD version 1912 std::min(arraysize(kV3SIMDFrameData), frame->size())) != 0) {
2140 if (memcmp(frame_data, 1913 CompareCharArraysWithHexError(kDescription,
2141 kV2SIMDFrameData, 1914 frame_data,
2142 std::min(arraysize(kV2SIMDFrameData), frame->size())) != 0) { 1915 frame->size(),
2143 CompareCharArraysWithHexError(kDescription, 1916 kV3FrameData,
2144 frame_data, 1917 arraysize(kV3FrameData));
2145 frame->size(),
2146 kV2FrameData,
2147 arraysize(kV2FrameData));
2148 }
2149 } else if (IsSpdy3()) {
2150 if (memcmp(frame_data,
2151 kV3SIMDFrameData,
2152 std::min(arraysize(kV3SIMDFrameData), frame->size())) != 0) {
2153 CompareCharArraysWithHexError(kDescription,
2154 frame_data,
2155 frame->size(),
2156 kV3FrameData,
2157 arraysize(kV3FrameData));
2158 }
2159 } else {
2160 LOG(FATAL) << "Unsupported version in test.";
2161 } 1918 }
2162 } 1919 }
2163 } 1920 }
2164 #endif // !defined(USE_SYSTEM_ZLIB) 1921 #endif // !defined(USE_SYSTEM_ZLIB)
2165 1922
2166 TEST_P(SpdyFramerTest, CreateSynReplyUncompressed) { 1923 TEST_P(SpdyFramerTest, CreateSynReplyUncompressed) {
2167 if (spdy_version_ > SPDY3) { 1924 if (spdy_version_ > SPDY3) {
2168 // SYN_REPLY unsupported in SPDY>3 1925 // SYN_REPLY unsupported in SPDY>3
2169 return; 1926 return;
2170 } 1927 }
2171 SpdyFramer framer(spdy_version_); 1928 SpdyFramer framer(spdy_version_);
2172 framer.set_enable_compression(false); 1929 framer.set_enable_compression(false);
2173 1930
2174 { 1931 {
2175 const char kDescription[] = "SYN_REPLY frame, no FIN"; 1932 const char kDescription[] = "SYN_REPLY frame, no FIN";
2176
2177 const unsigned char kV2FrameData[] = {
2178 0x80, spdy_version_ch_, 0x00, 0x02,
2179 0x00, 0x00, 0x00, 0x1C,
2180 0x00, 0x00, 0x00, 0x01,
2181 0x00, 0x00, 0x00, 0x02,
2182 0x00, 0x03, 'b', 'a',
2183 'r', 0x00, 0x03, 'f',
2184 'o', 'o', 0x00, 0x03,
2185 'f', 'o', 'o', 0x00,
2186 0x03, 'b', 'a', 'r'
2187 };
2188 const unsigned char kV3FrameData[] = { 1933 const unsigned char kV3FrameData[] = {
2189 0x80, spdy_version_ch_, 0x00, 0x02, 1934 0x80, spdy_version_ch_, 0x00, 0x02,
2190 0x00, 0x00, 0x00, 0x24, 1935 0x00, 0x00, 0x00, 0x24,
2191 0x00, 0x00, 0x00, 0x01, 1936 0x00, 0x00, 0x00, 0x01,
2192 0x00, 0x00, 0x00, 0x02, 1937 0x00, 0x00, 0x00, 0x02,
2193 0x00, 0x00, 0x00, 0x03, 1938 0x00, 0x00, 0x00, 0x03,
2194 'b', 'a', 'r', 0x00, 1939 'b', 'a', 'r', 0x00,
2195 0x00, 0x00, 0x03, 'f', 1940 0x00, 0x00, 0x03, 'f',
2196 'o', 'o', 0x00, 0x00, 1941 'o', 'o', 0x00, 0x00,
2197 0x00, 0x03, 'f', 'o', 1942 0x00, 0x03, 'f', 'o',
2198 'o', 0x00, 0x00, 0x00, 1943 'o', 0x00, 0x00, 0x00,
2199 0x03, 'b', 'a', 'r' 1944 0x03, 'b', 'a', 'r'
2200 }; 1945 };
2201 SpdySynReplyIR syn_reply(1); 1946 SpdySynReplyIR syn_reply(1);
2202 syn_reply.SetHeader("bar", "foo"); 1947 syn_reply.SetHeader("bar", "foo");
2203 syn_reply.SetHeader("foo", "bar"); 1948 syn_reply.SetHeader("foo", "bar");
2204 scoped_ptr<SpdyFrame> frame(framer.SerializeSynReply(syn_reply)); 1949 scoped_ptr<SpdyFrame> frame(framer.SerializeSynReply(syn_reply));
2205 if (IsSpdy2()) { 1950 CompareFrame(kDescription, *frame, kV3FrameData, arraysize(kV3FrameData));
2206 CompareFrame(kDescription, *frame, kV2FrameData, arraysize(kV2FrameData));
2207 } else if (IsSpdy3()) {
2208 CompareFrame(kDescription, *frame, kV3FrameData, arraysize(kV3FrameData));
2209 } else {
2210 LOG(FATAL) << "Unsupported version in test.";
2211 }
2212 } 1951 }
2213 1952
2214 { 1953 {
2215 const char kDescription[] = 1954 const char kDescription[] =
2216 "SYN_REPLY frame with a 0-length header name, FIN, max stream ID"; 1955 "SYN_REPLY frame with a 0-length header name, FIN, max stream ID";
2217
2218 const unsigned char kV2FrameData[] = {
2219 0x80, spdy_version_ch_, 0x00, 0x02,
2220 0x01, 0x00, 0x00, 0x19,
2221 0x7f, 0xff, 0xff, 0xff,
2222 0x00, 0x00, 0x00, 0x02,
2223 0x00, 0x00, 0x00, 0x03,
2224 'f', 'o', 'o', 0x00,
2225 0x03, 'f', 'o', 'o',
2226 0x00, 0x03, 'b', 'a',
2227 'r'
2228 };
2229 const unsigned char kV3FrameData[] = { 1956 const unsigned char kV3FrameData[] = {
2230 0x80, spdy_version_ch_, 0x00, 0x02, 1957 0x80, spdy_version_ch_, 0x00, 0x02,
2231 0x01, 0x00, 0x00, 0x21, 1958 0x01, 0x00, 0x00, 0x21,
2232 0x7f, 0xff, 0xff, 0xff, 1959 0x7f, 0xff, 0xff, 0xff,
2233 0x00, 0x00, 0x00, 0x02, 1960 0x00, 0x00, 0x00, 0x02,
2234 0x00, 0x00, 0x00, 0x00, 1961 0x00, 0x00, 0x00, 0x00,
2235 0x00, 0x00, 0x00, 0x03, 1962 0x00, 0x00, 0x00, 0x03,
2236 'f', 'o', 'o', 0x00, 1963 'f', 'o', 'o', 0x00,
2237 0x00, 0x00, 0x03, 'f', 1964 0x00, 0x00, 0x03, 'f',
2238 'o', 'o', 0x00, 0x00, 1965 'o', 'o', 0x00, 0x00,
2239 0x00, 0x03, 'b', 'a', 1966 0x00, 0x03, 'b', 'a',
2240 'r' 1967 'r'
2241 }; 1968 };
2242 SpdySynReplyIR syn_reply(0x7fffffff); 1969 SpdySynReplyIR syn_reply(0x7fffffff);
2243 syn_reply.set_fin(true); 1970 syn_reply.set_fin(true);
2244 syn_reply.SetHeader("", "foo"); 1971 syn_reply.SetHeader("", "foo");
2245 syn_reply.SetHeader("foo", "bar"); 1972 syn_reply.SetHeader("foo", "bar");
2246 scoped_ptr<SpdyFrame> frame(framer.SerializeSynReply(syn_reply)); 1973 scoped_ptr<SpdyFrame> frame(framer.SerializeSynReply(syn_reply));
2247 if (IsSpdy2()) { 1974 CompareFrame(kDescription, *frame, kV3FrameData, arraysize(kV3FrameData));
2248 CompareFrame(kDescription, *frame, kV2FrameData, arraysize(kV2FrameData));
2249 } else if (IsSpdy3()) {
2250 CompareFrame(kDescription, *frame, kV3FrameData, arraysize(kV3FrameData));
2251 } else {
2252 LOG(FATAL) << "Unsupported version in test.";
2253 }
2254 } 1975 }
2255 1976
2256 { 1977 {
2257 const char kDescription[] = 1978 const char kDescription[] =
2258 "SYN_REPLY frame with a 0-length header val, FIN, max stream ID"; 1979 "SYN_REPLY frame with a 0-length header val, FIN, max stream ID";
2259
2260 const unsigned char kV2FrameData[] = {
2261 0x80, spdy_version_ch_, 0x00, 0x02,
2262 0x01, 0x00, 0x00, 0x19,
2263 0x7f, 0xff, 0xff, 0xff,
2264 0x00, 0x00, 0x00, 0x02,
2265 0x00, 0x03, 'b', 'a',
2266 'r', 0x00, 0x03, 'f',
2267 'o', 'o', 0x00, 0x03,
2268 'f', 'o', 'o', 0x00,
2269 0x00
2270 };
2271 const unsigned char kV3FrameData[] = { 1980 const unsigned char kV3FrameData[] = {
2272 0x80, spdy_version_ch_, 0x00, 0x02, 1981 0x80, spdy_version_ch_, 0x00, 0x02,
2273 0x01, 0x00, 0x00, 0x21, 1982 0x01, 0x00, 0x00, 0x21,
2274 0x7f, 0xff, 0xff, 0xff, 1983 0x7f, 0xff, 0xff, 0xff,
2275 0x00, 0x00, 0x00, 0x02, 1984 0x00, 0x00, 0x00, 0x02,
2276 0x00, 0x00, 0x00, 0x03, 1985 0x00, 0x00, 0x00, 0x03,
2277 'b', 'a', 'r', 0x00, 1986 'b', 'a', 'r', 0x00,
2278 0x00, 0x00, 0x03, 'f', 1987 0x00, 0x00, 0x03, 'f',
2279 'o', 'o', 0x00, 0x00, 1988 'o', 'o', 0x00, 0x00,
2280 0x00, 0x03, 'f', 'o', 1989 0x00, 0x03, 'f', 'o',
2281 'o', 0x00, 0x00, 0x00, 1990 'o', 0x00, 0x00, 0x00,
2282 0x00 1991 0x00
2283 }; 1992 };
2284 SpdySynReplyIR syn_reply(0x7fffffff); 1993 SpdySynReplyIR syn_reply(0x7fffffff);
2285 syn_reply.set_fin(true); 1994 syn_reply.set_fin(true);
2286 syn_reply.SetHeader("bar", "foo"); 1995 syn_reply.SetHeader("bar", "foo");
2287 syn_reply.SetHeader("foo", ""); 1996 syn_reply.SetHeader("foo", "");
2288 scoped_ptr<SpdyFrame> frame(framer.SerializeSynReply(syn_reply)); 1997 scoped_ptr<SpdyFrame> frame(framer.SerializeSynReply(syn_reply));
2289 if (IsSpdy2()) { 1998 CompareFrame(kDescription, *frame, kV3FrameData, arraysize(kV3FrameData));
2290 CompareFrame(kDescription, *frame, kV2FrameData, arraysize(kV2FrameData));
2291 } else if (IsSpdy3()) {
2292 CompareFrame(kDescription, *frame, kV3FrameData, arraysize(kV3FrameData));
2293 } else {
2294 LOG(FATAL) << "Unsupported version in test.";
2295 }
2296 } 1999 }
2297 } 2000 }
2298 2001
2299 // TODO(phajdan.jr): Clean up after we no longer need 2002 // TODO(phajdan.jr): Clean up after we no longer need
2300 // to workaround http://crbug.com/139744. 2003 // to workaround http://crbug.com/139744.
2301 #if !defined(USE_SYSTEM_ZLIB) 2004 #if !defined(USE_SYSTEM_ZLIB)
2302 TEST_P(SpdyFramerTest, CreateSynReplyCompressed) { 2005 TEST_P(SpdyFramerTest, CreateSynReplyCompressed) {
2303 if (spdy_version_ > SPDY3) { 2006 if (spdy_version_ > SPDY3) {
2304 // SYN_REPLY unsupported in SPDY>3 2007 // SYN_REPLY unsupported in SPDY>3
2305 return; 2008 return;
2306 } 2009 }
2307 SpdyFramer framer(spdy_version_); 2010 SpdyFramer framer(spdy_version_);
2308 framer.set_enable_compression(true); 2011 framer.set_enable_compression(true);
2309 2012
2310 { 2013 {
2311 const char kDescription[] = "SYN_REPLY frame, no FIN"; 2014 const char kDescription[] = "SYN_REPLY frame, no FIN";
2312
2313 const unsigned char kV2FrameData[] = {
2314 0x80, spdy_version_ch_, 0x00, 0x02,
2315 0x00, 0x00, 0x00, 0x32,
2316 0x00, 0x00, 0x00, 0x01,
2317 0x00, 0x00, 0x38, 0xea,
2318 0xdf, 0xa2, 0x51, 0xb2,
2319 0x62, 0x60, 0x62, 0x60,
2320 0x4e, 0x4a, 0x2c, 0x62,
2321 0x60, 0x06, 0x08, 0xa0,
2322 0xb4, 0xfc, 0x7c, 0x80,
2323 0x00, 0x62, 0x60, 0x4e,
2324 0xcb, 0xcf, 0x67, 0x60,
2325 0x06, 0x08, 0xa0, 0xa4,
2326 0xc4, 0x22, 0x80, 0x00,
2327 0x02, 0x00, 0x00, 0x00,
2328 0xff, 0xff,
2329 };
2330 const unsigned char kV3FrameData[] = { 2015 const unsigned char kV3FrameData[] = {
2331 0x80, spdy_version_ch_, 0x00, 0x02, 2016 0x80, spdy_version_ch_, 0x00, 0x02,
2332 0x00, 0x00, 0x00, 0x31, 2017 0x00, 0x00, 0x00, 0x31,
2333 0x00, 0x00, 0x00, 0x01, 2018 0x00, 0x00, 0x00, 0x01,
2334 0x38, 0xea, 0xe3, 0xc6, 2019 0x38, 0xea, 0xe3, 0xc6,
2335 0xa7, 0xc2, 0x02, 0xe5, 2020 0xa7, 0xc2, 0x02, 0xe5,
2336 0x0e, 0x50, 0xc2, 0x4b, 2021 0x0e, 0x50, 0xc2, 0x4b,
2337 0x4a, 0x04, 0xe5, 0x0b, 2022 0x4a, 0x04, 0xe5, 0x0b,
2338 0x66, 0x80, 0x00, 0x4a, 2023 0x66, 0x80, 0x00, 0x4a,
2339 0xcb, 0xcf, 0x07, 0x08, 2024 0xcb, 0xcf, 0x07, 0x08,
2340 0x20, 0x10, 0x95, 0x96, 2025 0x20, 0x10, 0x95, 0x96,
2341 0x9f, 0x0f, 0xa2, 0x00, 2026 0x9f, 0x0f, 0xa2, 0x00,
2342 0x02, 0x28, 0x29, 0xb1, 2027 0x02, 0x28, 0x29, 0xb1,
2343 0x08, 0x20, 0x80, 0x00, 2028 0x08, 0x20, 0x80, 0x00,
2344 0x00, 0x00, 0x00, 0xff, 2029 0x00, 0x00, 0x00, 0xff,
2345 0xff, 2030 0xff,
2346 }; 2031 };
2347 const unsigned char kV2SIMDFrameData[] = {
2348 0x80, spdy_version_ch_, 0x00, 0x02,
2349 0x00, 0x00, 0x00, 0x2f,
2350 0x00, 0x00, 0x00, 0x01,
2351 0x00, 0x00, 0x38, 0xea,
2352 0xdf, 0xa2, 0x51, 0xb2,
2353 0x62, 0x60, 0x62, 0x60,
2354 0x4e, 0x4a, 0x2c, 0x62,
2355 0x60, 0x06, 0x08, 0xa0,
2356 0xb4, 0xfc, 0x7c, 0x80,
2357 0x00, 0x62, 0x60, 0x06,
2358 0x13, 0x00, 0x01, 0x94,
2359 0x94, 0x58, 0x04, 0x10,
2360 0x40, 0x00, 0x00, 0x00,
2361 0x00, 0xff, 0xff,
2362 };
2363 const unsigned char kV3SIMDFrameData[] = { 2032 const unsigned char kV3SIMDFrameData[] = {
2364 0x80, spdy_version_ch_, 0x00, 0x02, 2033 0x80, spdy_version_ch_, 0x00, 0x02,
2365 0x00, 0x00, 0x00, 0x2c, 2034 0x00, 0x00, 0x00, 0x2c,
2366 0x00, 0x00, 0x00, 0x01, 2035 0x00, 0x00, 0x00, 0x01,
2367 0x38, 0xea, 0xe3, 0xc6, 2036 0x38, 0xea, 0xe3, 0xc6,
2368 0xa7, 0xc2, 0x02, 0xe5, 2037 0xa7, 0xc2, 0x02, 0xe5,
2369 0x0e, 0x50, 0xc2, 0x4b, 2038 0x0e, 0x50, 0xc2, 0x4b,
2370 0x4a, 0x04, 0xe5, 0x0b, 2039 0x4a, 0x04, 0xe5, 0x0b,
2371 0x66, 0x80, 0x00, 0x4a, 2040 0x66, 0x80, 0x00, 0x4a,
2372 0xcb, 0xcf, 0x07, 0x08, 2041 0xcb, 0xcf, 0x07, 0x08,
2373 0x20, 0x24, 0x0a, 0x20, 2042 0x20, 0x24, 0x0a, 0x20,
2374 0x80, 0x92, 0x12, 0x8b, 2043 0x80, 0x92, 0x12, 0x8b,
2375 0x00, 0x02, 0x08, 0x00, 2044 0x00, 0x02, 0x08, 0x00,
2376 0x00, 0x00, 0xff, 0xff, 2045 0x00, 0x00, 0xff, 0xff,
2377 }; 2046 };
2378 2047
2379 SpdySynReplyIR syn_reply(1); 2048 SpdySynReplyIR syn_reply(1);
2380 syn_reply.SetHeader("bar", "foo"); 2049 syn_reply.SetHeader("bar", "foo");
2381 syn_reply.SetHeader("foo", "bar"); 2050 syn_reply.SetHeader("foo", "bar");
2382 scoped_ptr<SpdyFrame> frame(framer.SerializeSynReply(syn_reply)); 2051 scoped_ptr<SpdyFrame> frame(framer.SerializeSynReply(syn_reply));
2383 const unsigned char* frame_data = 2052 const unsigned char* frame_data =
2384 reinterpret_cast<const unsigned char*>(frame->data()); 2053 reinterpret_cast<const unsigned char*>(frame->data());
2385 if (IsSpdy2()) { 2054 if (memcmp(frame_data,
2386 // Try comparing with SIMD version, if that fails, do a failing check 2055 kV3SIMDFrameData,
2387 // with pretty printing against non-SIMD version 2056 std::min(arraysize(kV3SIMDFrameData), frame->size())) != 0) {
2388 if (memcmp(frame_data, 2057 CompareCharArraysWithHexError(kDescription,
2389 kV2SIMDFrameData, 2058 frame_data,
2390 std::min(arraysize(kV2SIMDFrameData), frame->size())) != 0) { 2059 frame->size(),
2391 CompareCharArraysWithHexError(kDescription, 2060 kV3FrameData,
2392 frame_data, 2061 arraysize(kV3FrameData));
2393 frame->size(),
2394 kV2FrameData,
2395 arraysize(kV2FrameData));
2396 }
2397 } else if (IsSpdy3()) {
2398 if (memcmp(frame_data,
2399 kV3SIMDFrameData,
2400 std::min(arraysize(kV3SIMDFrameData), frame->size())) != 0) {
2401 CompareCharArraysWithHexError(kDescription,
2402 frame_data,
2403 frame->size(),
2404 kV3FrameData,
2405 arraysize(kV3FrameData));
2406 }
2407 } else {
2408 LOG(FATAL) << "Unsupported version in test.";
2409 } 2062 }
2410 } 2063 }
2411 } 2064 }
2412 #endif // !defined(USE_SYSTEM_ZLIB) 2065 #endif // !defined(USE_SYSTEM_ZLIB)
2413 2066
2414 TEST_P(SpdyFramerTest, CreateRstStream) { 2067 TEST_P(SpdyFramerTest, CreateRstStream) {
2415 SpdyFramer framer(spdy_version_); 2068 SpdyFramer framer(spdy_version_);
2416 2069
2417 { 2070 {
2418 const char kDescription[] = "RST_STREAM frame"; 2071 const char kDescription[] = "RST_STREAM frame";
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
2486 CompareFrame(kDescription, *frame, kV3FrameData, arraysize(kV3FrameData)); 2139 CompareFrame(kDescription, *frame, kV3FrameData, arraysize(kV3FrameData));
2487 } 2140 }
2488 } 2141 }
2489 } 2142 }
2490 2143
2491 TEST_P(SpdyFramerTest, CreateSettings) { 2144 TEST_P(SpdyFramerTest, CreateSettings) {
2492 SpdyFramer framer(spdy_version_); 2145 SpdyFramer framer(spdy_version_);
2493 2146
2494 { 2147 {
2495 const char kDescription[] = "Network byte order SETTINGS frame"; 2148 const char kDescription[] = "Network byte order SETTINGS frame";
2496
2497 const unsigned char kV2FrameData[] = {
2498 0x80, spdy_version_ch_, 0x00, 0x04,
2499 0x00, 0x00, 0x00, 0x0c,
2500 0x00, 0x00, 0x00, 0x01,
2501 0x07, 0x00, 0x00, 0x01,
2502 0x0a, 0x0b, 0x0c, 0x0d,
2503 };
2504 const unsigned char kV3FrameData[] = { 2149 const unsigned char kV3FrameData[] = {
2505 0x80, spdy_version_ch_, 0x00, 0x04, 2150 0x80, spdy_version_ch_, 0x00, 0x04,
2506 0x00, 0x00, 0x00, 0x0c, 2151 0x00, 0x00, 0x00, 0x0c,
2507 0x00, 0x00, 0x00, 0x01, 2152 0x00, 0x00, 0x00, 0x01,
2508 0x01, 0x00, 0x00, 0x07, 2153 0x01, 0x00, 0x00, 0x07,
2509 0x0a, 0x0b, 0x0c, 0x0d, 2154 0x0a, 0x0b, 0x0c, 0x0d,
2510 }; 2155 };
2511 const unsigned char kV4FrameData[] = { 2156 const unsigned char kV4FrameData[] = {
2512 0x00, 0x00, 0x06, 0x04, 2157 0x00, 0x00, 0x06, 0x04,
2513 0x00, 0x00, 0x00, 0x00, 2158 0x00, 0x00, 0x00, 0x00,
2514 0x00, 0x00, 0x04, 0x0a, 2159 0x00, 0x00, 0x04, 0x0a,
2515 0x0b, 0x0c, 0x0d, 2160 0x0b, 0x0c, 0x0d,
2516 }; 2161 };
2517 2162
2518 uint32 kValue = 0x0a0b0c0d; 2163 uint32 kValue = 0x0a0b0c0d;
2519 SpdySettingsIR settings_ir; 2164 SpdySettingsIR settings_ir;
2520 2165
2521 SpdySettingsFlags kFlags = static_cast<SpdySettingsFlags>(0x01); 2166 SpdySettingsFlags kFlags = static_cast<SpdySettingsFlags>(0x01);
2522 SpdySettingsIds kId = SETTINGS_INITIAL_WINDOW_SIZE; 2167 SpdySettingsIds kId = SETTINGS_INITIAL_WINDOW_SIZE;
2523 SettingsMap settings; 2168 SettingsMap settings;
2524 settings[kId] = SettingsFlagsAndValue(kFlags, kValue); 2169 settings[kId] = SettingsFlagsAndValue(kFlags, kValue);
2525 EXPECT_EQ(kFlags, settings[kId].first); 2170 EXPECT_EQ(kFlags, settings[kId].first);
2526 EXPECT_EQ(kValue, settings[kId].second); 2171 EXPECT_EQ(kValue, settings[kId].second);
2527 settings_ir.AddSetting(kId, 2172 settings_ir.AddSetting(kId,
2528 kFlags & SETTINGS_FLAG_PLEASE_PERSIST, 2173 kFlags & SETTINGS_FLAG_PLEASE_PERSIST,
2529 kFlags & SETTINGS_FLAG_PERSISTED, 2174 kFlags & SETTINGS_FLAG_PERSISTED,
2530 kValue); 2175 kValue);
2531 2176
2532 scoped_ptr<SpdyFrame> frame(framer.SerializeSettings(settings_ir)); 2177 scoped_ptr<SpdyFrame> frame(framer.SerializeSettings(settings_ir));
2533 if (IsSpdy2()) { 2178 if (IsSpdy3()) {
2534 CompareFrame(kDescription, *frame, kV2FrameData, arraysize(kV2FrameData));
2535 } else if (IsSpdy3()) {
2536 CompareFrame(kDescription, *frame, kV3FrameData, arraysize(kV3FrameData)); 2179 CompareFrame(kDescription, *frame, kV3FrameData, arraysize(kV3FrameData));
2537 } else { 2180 } else {
2538 CompareFrame(kDescription, *frame, kV4FrameData, arraysize(kV4FrameData)); 2181 CompareFrame(kDescription, *frame, kV4FrameData, arraysize(kV4FrameData));
2539 } 2182 }
2540 } 2183 }
2541 2184
2542 { 2185 {
2543 const char kDescription[] = "Basic SETTINGS frame"; 2186 const char kDescription[] = "Basic SETTINGS frame";
2544
2545 const unsigned char kV2FrameData[] = {
2546 0x80, spdy_version_ch_, 0x00, 0x04,
2547 0x00, 0x00, 0x00, 0x24,
2548 0x00, 0x00, 0x00, 0x04,
2549 0x01, 0x00, 0x00, 0x00, // 1st Setting
2550 0x00, 0x00, 0x00, 0x05,
2551 0x02, 0x00, 0x00, 0x00, // 2nd Setting
2552 0x00, 0x00, 0x00, 0x06,
2553 0x03, 0x00, 0x00, 0x00, // 3rd Setting
2554 0x00, 0x00, 0x00, 0x07,
2555 0x04, 0x00, 0x00, 0x00, // 4th Setting
2556 0x00, 0x00, 0x00, 0x08,
2557 };
2558 const unsigned char kV3FrameData[] = { 2187 const unsigned char kV3FrameData[] = {
2559 0x80, spdy_version_ch_, 0x00, 0x04, 2188 0x80, spdy_version_ch_, 0x00, 0x04,
2560 0x00, 0x00, 0x00, 0x24, 2189 0x00, 0x00, 0x00, 0x24,
2561 0x00, 0x00, 0x00, 0x04, 2190 0x00, 0x00, 0x00, 0x04,
2562 0x00, 0x00, 0x00, 0x01, // 1st Setting 2191 0x00, 0x00, 0x00, 0x01, // 1st Setting
2563 0x00, 0x00, 0x00, 0x05, 2192 0x00, 0x00, 0x00, 0x05,
2564 0x00, 0x00, 0x00, 0x02, // 2nd Setting 2193 0x00, 0x00, 0x00, 0x02, // 2nd Setting
2565 0x00, 0x00, 0x00, 0x06, 2194 0x00, 0x00, 0x00, 0x06,
2566 0x00, 0x00, 0x00, 0x03, // 3rd Setting 2195 0x00, 0x00, 0x00, 0x03, // 3rd Setting
2567 0x00, 0x00, 0x00, 0x07, 2196 0x00, 0x00, 0x00, 0x07,
(...skipping 28 matching lines...) Expand all
2596 settings_ir.AddSetting(SpdyConstants::ParseSettingId(spdy_version_, 3), 2225 settings_ir.AddSetting(SpdyConstants::ParseSettingId(spdy_version_, 3),
2597 false, // persist 2226 false, // persist
2598 false, // persisted 2227 false, // persisted
2599 7); 2228 7);
2600 settings_ir.AddSetting(SpdyConstants::ParseSettingId(spdy_version_, 4), 2229 settings_ir.AddSetting(SpdyConstants::ParseSettingId(spdy_version_, 4),
2601 false, // persist 2230 false, // persist
2602 false, // persisted 2231 false, // persisted
2603 8); 2232 8);
2604 scoped_ptr<SpdyFrame> frame(framer.SerializeSettings(settings_ir)); 2233 scoped_ptr<SpdyFrame> frame(framer.SerializeSettings(settings_ir));
2605 2234
2606 if (IsSpdy2()) { 2235 if (IsSpdy3()) {
2607 CompareFrame(kDescription, *frame, kV2FrameData, arraysize(kV2FrameData));
2608 } else if (IsSpdy3()) {
2609 CompareFrame(kDescription, *frame, kV3FrameData, arraysize(kV3FrameData)); 2236 CompareFrame(kDescription, *frame, kV3FrameData, arraysize(kV3FrameData));
2610 } else { 2237 } else {
2611 CompareFrame(kDescription, *frame, kV4FrameData, arraysize(kV4FrameData)); 2238 CompareFrame(kDescription, *frame, kV4FrameData, arraysize(kV4FrameData));
2612 } 2239 }
2613 } 2240 }
2614 2241
2615 { 2242 {
2616 const char kDescription[] = "Empty SETTINGS frame"; 2243 const char kDescription[] = "Empty SETTINGS frame";
2617
2618 const unsigned char kV3FrameData[] = { // Also applies for V2. 2244 const unsigned char kV3FrameData[] = { // Also applies for V2.
2619 0x80, spdy_version_ch_, 0x00, 0x04, 2245 0x80, spdy_version_ch_, 0x00, 0x04,
2620 0x00, 0x00, 0x00, 0x04, 2246 0x00, 0x00, 0x00, 0x04,
2621 0x00, 0x00, 0x00, 0x00, 2247 0x00, 0x00, 0x00, 0x00,
2622 }; 2248 };
2623 const unsigned char kV4FrameData[] = { 2249 const unsigned char kV4FrameData[] = {
2624 0x00, 0x00, 0x00, 0x04, 2250 0x00, 0x00, 0x00, 0x04,
2625 0x00, 0x00, 0x00, 0x00, 2251 0x00, 0x00, 0x00, 0x00,
2626 0x00, 2252 0x00,
2627 }; 2253 };
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
2679 CompareFrame(kDescription, *frame, kV3FrameData, arraysize(kV3FrameData)); 2305 CompareFrame(kDescription, *frame, kV3FrameData, arraysize(kV3FrameData));
2680 } 2306 }
2681 } 2307 }
2682 } 2308 }
2683 2309
2684 TEST_P(SpdyFramerTest, CreateGoAway) { 2310 TEST_P(SpdyFramerTest, CreateGoAway) {
2685 SpdyFramer framer(spdy_version_); 2311 SpdyFramer framer(spdy_version_);
2686 2312
2687 { 2313 {
2688 const char kDescription[] = "GOAWAY frame"; 2314 const char kDescription[] = "GOAWAY frame";
2689 const unsigned char kV2FrameData[] = {
2690 0x80, spdy_version_ch_, 0x00, 0x07,
2691 0x00, 0x00, 0x00, 0x04,
2692 0x00, 0x00, 0x00, 0x00, // Stream Id
2693 };
2694 const unsigned char kV3FrameData[] = { 2315 const unsigned char kV3FrameData[] = {
2695 0x80, spdy_version_ch_, 0x00, 0x07, 2316 0x80, spdy_version_ch_, 0x00, 0x07,
2696 0x00, 0x00, 0x00, 0x08, 2317 0x00, 0x00, 0x00, 0x08,
2697 0x00, 0x00, 0x00, 0x00, // Stream Id 2318 0x00, 0x00, 0x00, 0x00, // Stream Id
2698 0x00, 0x00, 0x00, 0x00, // Status 2319 0x00, 0x00, 0x00, 0x00, // Status
2699 }; 2320 };
2700 const unsigned char kV4FrameData[] = { 2321 const unsigned char kV4FrameData[] = {
2701 0x00, 0x00, 0x0a, 0x07, 2322 0x00, 0x00, 0x0a, 0x07,
2702 0x00, 0x00, 0x00, 0x00, 2323 0x00, 0x00, 0x00, 0x00,
2703 0x00, 0x00, 0x00, 0x00, // Stream id 2324 0x00, 0x00, 0x00, 0x00, // Stream id
2704 0x00, 0x00, 0x00, 0x00, // Status 2325 0x00, 0x00, 0x00, 0x00, // Status
2705 0x00, 0x47, 0x41, // Opaque Description 2326 0x00, 0x47, 0x41, // Opaque Description
2706 }; 2327 };
2707 SpdyGoAwayIR goaway_ir(0, GOAWAY_OK, "GA"); 2328 SpdyGoAwayIR goaway_ir(0, GOAWAY_OK, "GA");
2708 scoped_ptr<SpdyFrame> frame(framer.SerializeGoAway(goaway_ir)); 2329 scoped_ptr<SpdyFrame> frame(framer.SerializeGoAway(goaway_ir));
2709 if (IsSpdy2()) { 2330 if (IsSpdy3()) {
2710 CompareFrame(kDescription, *frame, kV2FrameData, arraysize(kV2FrameData));
2711 } else if (IsSpdy3()) {
2712 CompareFrame(kDescription, *frame, kV3FrameData, arraysize(kV3FrameData)); 2331 CompareFrame(kDescription, *frame, kV3FrameData, arraysize(kV3FrameData));
2713 } else { 2332 } else {
2714 CompareFrame(kDescription, *frame, kV4FrameData, arraysize(kV4FrameData)); 2333 CompareFrame(kDescription, *frame, kV4FrameData, arraysize(kV4FrameData));
2715 } 2334 }
2716 } 2335 }
2717 2336
2718 { 2337 {
2719 const char kDescription[] = "GOAWAY frame with max stream ID, status"; 2338 const char kDescription[] = "GOAWAY frame with max stream ID, status";
2720 const unsigned char kV2FrameData[] = {
2721 0x80, spdy_version_ch_, 0x00, 0x07,
2722 0x00, 0x00, 0x00, 0x04,
2723 0x7f, 0xff, 0xff, 0xff, // Stream Id
2724 };
2725 const unsigned char kV3FrameData[] = { 2339 const unsigned char kV3FrameData[] = {
2726 0x80, spdy_version_ch_, 0x00, 0x07, 2340 0x80, spdy_version_ch_, 0x00, 0x07,
2727 0x00, 0x00, 0x00, 0x08, 2341 0x00, 0x00, 0x00, 0x08,
2728 0x7f, 0xff, 0xff, 0xff, // Stream Id 2342 0x7f, 0xff, 0xff, 0xff, // Stream Id
2729 0x00, 0x00, 0x00, 0x01, // Status: PROTOCOL_ERROR. 2343 0x00, 0x00, 0x00, 0x01, // Status: PROTOCOL_ERROR.
2730 }; 2344 };
2731 const unsigned char kV4FrameData[] = { 2345 const unsigned char kV4FrameData[] = {
2732 0x00, 0x00, 0x0a, 0x07, 2346 0x00, 0x00, 0x0a, 0x07,
2733 0x00, 0x00, 0x00, 0x00, 2347 0x00, 0x00, 0x00, 0x00,
2734 0x00, 0x7f, 0xff, 0xff, // Stream Id 2348 0x00, 0x7f, 0xff, 0xff, // Stream Id
2735 0xff, 0x00, 0x00, 0x00, // Status: INTERNAL_ERROR. 2349 0xff, 0x00, 0x00, 0x00, // Status: INTERNAL_ERROR.
2736 0x02, 0x47, 0x41, // Opaque Description 2350 0x02, 0x47, 0x41, // Opaque Description
2737 }; 2351 };
2738 SpdyGoAwayIR goaway_ir(0x7FFFFFFF, GOAWAY_INTERNAL_ERROR, "GA"); 2352 SpdyGoAwayIR goaway_ir(0x7FFFFFFF, GOAWAY_INTERNAL_ERROR, "GA");
2739 scoped_ptr<SpdyFrame> frame(framer.SerializeGoAway(goaway_ir)); 2353 scoped_ptr<SpdyFrame> frame(framer.SerializeGoAway(goaway_ir));
2740 if (IsSpdy2()) { 2354 if (IsSpdy3()) {
2741 CompareFrame(kDescription, *frame, kV2FrameData, arraysize(kV2FrameData));
2742 } else if (IsSpdy3()) {
2743 CompareFrame(kDescription, *frame, kV3FrameData, arraysize(kV3FrameData)); 2355 CompareFrame(kDescription, *frame, kV3FrameData, arraysize(kV3FrameData));
2744 } else { 2356 } else {
2745 CompareFrame(kDescription, *frame, kV4FrameData, arraysize(kV4FrameData)); 2357 CompareFrame(kDescription, *frame, kV4FrameData, arraysize(kV4FrameData));
2746 } 2358 }
2747 } 2359 }
2748 } 2360 }
2749 2361
2750 TEST_P(SpdyFramerTest, CreateHeadersUncompressed) { 2362 TEST_P(SpdyFramerTest, CreateHeadersUncompressed) {
2751 SpdyFramer framer(spdy_version_); 2363 SpdyFramer framer(spdy_version_);
2752 framer.set_enable_compression(false); 2364 framer.set_enable_compression(false);
2753 2365
2754 { 2366 {
2755 const char kDescription[] = "HEADERS frame, no FIN"; 2367 const char kDescription[] = "HEADERS frame, no FIN";
2756
2757 const unsigned char kV2FrameData[] = {
2758 0x80, spdy_version_ch_, 0x00, 0x08,
2759 0x00, 0x00, 0x00, 0x1C,
2760 0x00, 0x00, 0x00, 0x01,
2761 0x00, 0x00, 0x00, 0x02,
2762 0x00, 0x03, 'b', 'a',
2763 'r', 0x00, 0x03, 'f',
2764 'o', 'o', 0x00, 0x03,
2765 'f', 'o', 'o', 0x00,
2766 0x03, 'b', 'a', 'r'
2767 };
2768 const unsigned char kV3FrameData[] = { 2368 const unsigned char kV3FrameData[] = {
2769 0x80, spdy_version_ch_, 0x00, 0x08, 2369 0x80, spdy_version_ch_, 0x00, 0x08,
2770 0x00, 0x00, 0x00, 0x24, 2370 0x00, 0x00, 0x00, 0x24,
2771 0x00, 0x00, 0x00, 0x01, 2371 0x00, 0x00, 0x00, 0x01,
2772 0x00, 0x00, 0x00, 0x02, 2372 0x00, 0x00, 0x00, 0x02,
2773 0x00, 0x00, 0x00, 0x03, 2373 0x00, 0x00, 0x00, 0x03,
2774 'b', 'a', 'r', 0x00, 2374 'b', 'a', 'r', 0x00,
2775 0x00, 0x00, 0x03, 'f', 2375 0x00, 0x00, 0x03, 'f',
2776 'o', 'o', 0x00, 0x00, 2376 'o', 'o', 0x00, 0x00,
2777 0x00, 0x03, 'f', 'o', 2377 0x00, 0x03, 'f', 'o',
2778 'o', 0x00, 0x00, 0x00, 2378 'o', 0x00, 0x00, 0x00,
2779 0x03, 'b', 'a', 'r' 2379 0x03, 'b', 'a', 'r'
2780 }; 2380 };
2781 const unsigned char kV4FrameData[] = { 2381 const unsigned char kV4FrameData[] = {
2782 0x00, 0x00, 0x12, 0x01, // Headers: END_HEADERS 2382 0x00, 0x00, 0x12, 0x01, // Headers: END_HEADERS
2783 0x04, 0x00, 0x00, 0x00, // Stream 1 2383 0x04, 0x00, 0x00, 0x00, // Stream 1
2784 0x01, 0x00, 0x03, 0x62, // @.ba 2384 0x01, 0x00, 0x03, 0x62, // @.ba
2785 0x61, 0x72, 0x03, 0x66, // r.fo 2385 0x61, 0x72, 0x03, 0x66, // r.fo
2786 0x6f, 0x6f, 0x00, 0x03, // o@.f 2386 0x6f, 0x6f, 0x00, 0x03, // o@.f
2787 0x66, 0x6f, 0x6f, 0x03, // oo.b 2387 0x66, 0x6f, 0x6f, 0x03, // oo.b
2788 0x62, 0x61, 0x72, // ar 2388 0x62, 0x61, 0x72, // ar
2789 }; 2389 };
2790 SpdyHeadersIR headers_ir(1); 2390 SpdyHeadersIR headers_ir(1);
2791 headers_ir.SetHeader("bar", "foo"); 2391 headers_ir.SetHeader("bar", "foo");
2792 headers_ir.SetHeader("foo", "bar"); 2392 headers_ir.SetHeader("foo", "bar");
2793 scoped_ptr<SpdyFrame> frame(framer.SerializeHeaders(headers_ir)); 2393 scoped_ptr<SpdyFrame> frame(framer.SerializeHeaders(headers_ir));
2794 if (IsSpdy2()) { 2394 if (IsSpdy3()) {
2795 CompareFrame(kDescription, *frame, kV2FrameData, arraysize(kV2FrameData));
2796 } else if (IsSpdy3()) {
2797 CompareFrame(kDescription, *frame, kV3FrameData, arraysize(kV3FrameData)); 2395 CompareFrame(kDescription, *frame, kV3FrameData, arraysize(kV3FrameData));
2798 } else { 2396 } else {
2799 CompareFrame(kDescription, *frame, kV4FrameData, arraysize(kV4FrameData)); 2397 CompareFrame(kDescription, *frame, kV4FrameData, arraysize(kV4FrameData));
2800 } 2398 }
2801 } 2399 }
2802 2400
2803 { 2401 {
2804 const char kDescription[] = 2402 const char kDescription[] =
2805 "HEADERS frame with a 0-length header name, FIN, max stream ID"; 2403 "HEADERS frame with a 0-length header name, FIN, max stream ID";
2806
2807 const unsigned char kV2FrameData[] = {
2808 0x80, spdy_version_ch_, 0x00, 0x08,
2809 0x01, 0x00, 0x00, 0x19,
2810 0x7f, 0xff, 0xff, 0xff,
2811 0x00, 0x00, 0x00, 0x02,
2812 0x00, 0x00, 0x00, 0x03,
2813 'f', 'o', 'o', 0x00,
2814 0x03, 'f', 'o', 'o',
2815 0x00, 0x03, 'b', 'a',
2816 'r'
2817 };
2818 const unsigned char kV3FrameData[] = { 2404 const unsigned char kV3FrameData[] = {
2819 0x80, spdy_version_ch_, 0x00, 0x08, 2405 0x80, spdy_version_ch_, 0x00, 0x08,
2820 0x01, 0x00, 0x00, 0x21, 2406 0x01, 0x00, 0x00, 0x21,
2821 0x7f, 0xff, 0xff, 0xff, 2407 0x7f, 0xff, 0xff, 0xff,
2822 0x00, 0x00, 0x00, 0x02, 2408 0x00, 0x00, 0x00, 0x02,
2823 0x00, 0x00, 0x00, 0x00, 2409 0x00, 0x00, 0x00, 0x00,
2824 0x00, 0x00, 0x00, 0x03, 2410 0x00, 0x00, 0x00, 0x03,
2825 'f', 'o', 'o', 0x00, 2411 'f', 'o', 'o', 0x00,
2826 0x00, 0x00, 0x03, 'f', 2412 0x00, 0x00, 0x03, 'f',
2827 'o', 'o', 0x00, 0x00, 2413 'o', 'o', 0x00, 0x00,
2828 0x00, 0x03, 'b', 'a', 2414 0x00, 0x03, 'b', 'a',
2829 'r' 2415 'r'
2830 }; 2416 };
2831 const unsigned char kV4FrameData[] = { 2417 const unsigned char kV4FrameData[] = {
2832 0x00, 0x00, 0x0f, 0x01, // Headers: FIN | END_HEADERS 2418 0x00, 0x00, 0x0f, 0x01, // Headers: FIN | END_HEADERS
2833 0x05, 0x7f, 0xff, 0xff, // Stream 0x7fffffff 2419 0x05, 0x7f, 0xff, 0xff, // Stream 0x7fffffff
2834 0xff, 0x00, 0x00, 0x03, // @.. 2420 0xff, 0x00, 0x00, 0x03, // @..
2835 0x66, 0x6f, 0x6f, 0x00, // foo@ 2421 0x66, 0x6f, 0x6f, 0x00, // foo@
2836 0x03, 0x66, 0x6f, 0x6f, // .foo 2422 0x03, 0x66, 0x6f, 0x6f, // .foo
2837 0x03, 0x62, 0x61, 0x72, // .bar 2423 0x03, 0x62, 0x61, 0x72, // .bar
2838 }; 2424 };
2839 SpdyHeadersIR headers_ir(0x7fffffff); 2425 SpdyHeadersIR headers_ir(0x7fffffff);
2840 headers_ir.set_fin(true); 2426 headers_ir.set_fin(true);
2841 headers_ir.SetHeader("", "foo"); 2427 headers_ir.SetHeader("", "foo");
2842 headers_ir.SetHeader("foo", "bar"); 2428 headers_ir.SetHeader("foo", "bar");
2843 scoped_ptr<SpdyFrame> frame(framer.SerializeHeaders(headers_ir)); 2429 scoped_ptr<SpdyFrame> frame(framer.SerializeHeaders(headers_ir));
2844 if (IsSpdy2()) { 2430 if (IsSpdy3()) {
2845 CompareFrame(kDescription, *frame, kV2FrameData, arraysize(kV2FrameData));
2846 } else if (IsSpdy3()) {
2847 CompareFrame(kDescription, *frame, kV3FrameData, arraysize(kV3FrameData)); 2431 CompareFrame(kDescription, *frame, kV3FrameData, arraysize(kV3FrameData));
2848 } else { 2432 } else {
2849 CompareFrame(kDescription, *frame, kV4FrameData, arraysize(kV4FrameData)); 2433 CompareFrame(kDescription, *frame, kV4FrameData, arraysize(kV4FrameData));
2850 } 2434 }
2851 } 2435 }
2852 2436
2853 { 2437 {
2854 const char kDescription[] = 2438 const char kDescription[] =
2855 "HEADERS frame with a 0-length header val, FIN, max stream ID"; 2439 "HEADERS frame with a 0-length header val, FIN, max stream ID";
2856
2857 const unsigned char kV2FrameData[] = {
2858 0x80, spdy_version_ch_, 0x00, 0x08,
2859 0x01, 0x00, 0x00, 0x19,
2860 0x7f, 0xff, 0xff, 0xff,
2861 0x00, 0x00, 0x00, 0x02,
2862 0x00, 0x03, 'b', 'a',
2863 'r', 0x00, 0x03, 'f',
2864 'o', 'o', 0x00, 0x03,
2865 'f', 'o', 'o', 0x00,
2866 0x00
2867 };
2868 const unsigned char kV3FrameData[] = { 2440 const unsigned char kV3FrameData[] = {
2869 0x80, spdy_version_ch_, 0x00, 0x08, 2441 0x80, spdy_version_ch_, 0x00, 0x08,
2870 0x01, 0x00, 0x00, 0x21, 2442 0x01, 0x00, 0x00, 0x21,
2871 0x7f, 0xff, 0xff, 0xff, 2443 0x7f, 0xff, 0xff, 0xff,
2872 0x00, 0x00, 0x00, 0x02, 2444 0x00, 0x00, 0x00, 0x02,
2873 0x00, 0x00, 0x00, 0x03, 2445 0x00, 0x00, 0x00, 0x03,
2874 'b', 'a', 'r', 0x00, 2446 'b', 'a', 'r', 0x00,
2875 0x00, 0x00, 0x03, 'f', 2447 0x00, 0x00, 0x03, 'f',
2876 'o', 'o', 0x00, 0x00, 2448 'o', 'o', 0x00, 0x00,
2877 0x00, 0x03, 'f', 'o', 2449 0x00, 0x03, 'f', 'o',
2878 'o', 0x00, 0x00, 0x00, 2450 'o', 0x00, 0x00, 0x00,
2879 0x00 2451 0x00
2880 }; 2452 };
2881 const unsigned char kV4FrameData[] = { 2453 const unsigned char kV4FrameData[] = {
2882 0x00, 0x00, 0x0f, 0x01, // Headers: FIN | END_HEADERS 2454 0x00, 0x00, 0x0f, 0x01, // Headers: FIN | END_HEADERS
2883 0x05, 0x7f, 0xff, 0xff, // Stream 0x7fffffff 2455 0x05, 0x7f, 0xff, 0xff, // Stream 0x7fffffff
2884 0xff, 0x00, 0x03, 0x62, // @.b 2456 0xff, 0x00, 0x03, 0x62, // @.b
2885 0x61, 0x72, 0x03, 0x66, // ar.f 2457 0x61, 0x72, 0x03, 0x66, // ar.f
2886 0x6f, 0x6f, 0x00, 0x03, // oo@. 2458 0x6f, 0x6f, 0x00, 0x03, // oo@.
2887 0x66, 0x6f, 0x6f, 0x00, // foo. 2459 0x66, 0x6f, 0x6f, 0x00, // foo.
2888 }; 2460 };
2889 SpdyHeadersIR headers_ir(0x7fffffff); 2461 SpdyHeadersIR headers_ir(0x7fffffff);
2890 headers_ir.set_fin(true); 2462 headers_ir.set_fin(true);
2891 headers_ir.SetHeader("bar", "foo"); 2463 headers_ir.SetHeader("bar", "foo");
2892 headers_ir.SetHeader("foo", ""); 2464 headers_ir.SetHeader("foo", "");
2893 scoped_ptr<SpdyFrame> frame(framer.SerializeHeaders(headers_ir)); 2465 scoped_ptr<SpdyFrame> frame(framer.SerializeHeaders(headers_ir));
2894 if (IsSpdy2()) { 2466 if (IsSpdy3()) {
2895 CompareFrame(kDescription, *frame, kV2FrameData, arraysize(kV2FrameData));
2896 } else if (IsSpdy3()) {
2897 CompareFrame(kDescription, *frame, kV3FrameData, arraysize(kV3FrameData)); 2467 CompareFrame(kDescription, *frame, kV3FrameData, arraysize(kV3FrameData));
2898 } else { 2468 } else {
2899 CompareFrame(kDescription, *frame, kV4FrameData, arraysize(kV4FrameData)); 2469 CompareFrame(kDescription, *frame, kV4FrameData, arraysize(kV4FrameData));
2900 } 2470 }
2901 } 2471 }
2902 2472
2903 { 2473 {
2904 const char kDescription[] = 2474 const char kDescription[] =
2905 "HEADERS frame with a 0-length header val, FIN, max stream ID, pri"; 2475 "HEADERS frame with a 0-length header val, FIN, max stream ID, pri";
2906
2907 const unsigned char kV4FrameData[] = { 2476 const unsigned char kV4FrameData[] = {
2908 0x00, 0x00, 0x14, 0x01, // Headers: FIN | END_HEADERS | PRIORITY 2477 0x00, 0x00, 0x14, 0x01, // Headers: FIN | END_HEADERS | PRIORITY
2909 0x25, 0x7f, 0xff, 0xff, // Stream 0x7fffffff 2478 0x25, 0x7f, 0xff, 0xff, // Stream 0x7fffffff
2910 0xff, 0x00, 0x00, 0x00, // parent stream 2479 0xff, 0x00, 0x00, 0x00, // parent stream
2911 0x00, 0xdb, // weight 2480 0x00, 0xdb, // weight
2912 0x00, 0x03, 0x62, 0x61, // @.ba 2481 0x00, 0x03, 0x62, 0x61, // @.ba
2913 0x72, 0x03, 0x66, 0x6f, // r.fo 2482 0x72, 0x03, 0x66, 0x6f, // r.fo
2914 0x6f, 0x00, 0x03, 0x66, // o@.f 2483 0x6f, 0x00, 0x03, 0x66, // o@.f
2915 0x6f, 0x6f, 0x00, // oo. 2484 0x6f, 0x6f, 0x00, // oo.
2916 }; 2485 };
2917 SpdyHeadersIR headers_ir(0x7fffffff); 2486 SpdyHeadersIR headers_ir(0x7fffffff);
2918 headers_ir.set_fin(true); 2487 headers_ir.set_fin(true);
2919 headers_ir.set_priority(1); 2488 headers_ir.set_priority(1);
2920 headers_ir.set_has_priority(true); 2489 headers_ir.set_has_priority(true);
2921 headers_ir.SetHeader("bar", "foo"); 2490 headers_ir.SetHeader("bar", "foo");
2922 headers_ir.SetHeader("foo", ""); 2491 headers_ir.SetHeader("foo", "");
2923 scoped_ptr<SpdyFrame> frame(framer.SerializeHeaders(headers_ir)); 2492 scoped_ptr<SpdyFrame> frame(framer.SerializeHeaders(headers_ir));
2924 if (IsSpdy2() || IsSpdy3()) { 2493 if (spdy_version_ > SPDY3) {
2925 // HEADERS with priority not supported. 2494 // HEADERS with priority only supported in SPDY>3.
2926 } else {
2927 CompareFrame(kDescription, *frame, kV4FrameData, arraysize(kV4FrameData)); 2495 CompareFrame(kDescription, *frame, kV4FrameData, arraysize(kV4FrameData));
2928 } 2496 }
2929 } 2497 }
2930 2498
2931 { 2499 {
2932 const char kDescription[] = 2500 const char kDescription[] =
2933 "HEADERS frame with a 0-length header name, FIN, max stream ID, padded"; 2501 "HEADERS frame with a 0-length header name, FIN, max stream ID, padded";
2934
2935 const unsigned char kV4FrameData[] = { 2502 const unsigned char kV4FrameData[] = {
2936 0x00, 0x00, 0x15, 0x01, // Headers 2503 0x00, 0x00, 0x15, 0x01, // Headers
2937 0x0d, 0x7f, 0xff, 0xff, // FIN | END_HEADERS | PADDED, Stream 2504 0x0d, 0x7f, 0xff, 0xff, // FIN | END_HEADERS | PADDED, Stream
2938 // 0x7fffffff 2505 // 0x7fffffff
2939 0xff, 0x05, 0x00, 0x00, // Pad length field 2506 0xff, 0x05, 0x00, 0x00, // Pad length field
2940 0x03, 0x66, 0x6f, 0x6f, // .foo 2507 0x03, 0x66, 0x6f, 0x6f, // .foo
2941 0x00, 0x03, 0x66, 0x6f, // @.fo 2508 0x00, 0x03, 0x66, 0x6f, // @.fo
2942 0x6f, 0x03, 0x62, 0x61, // o.ba 2509 0x6f, 0x03, 0x62, 0x61, // o.ba
2943 0x72, // r 2510 0x72, // r
2944 // Padding payload 2511 // Padding payload
2945 0x00, 0x00, 0x00, 0x00, 0x00, 2512 0x00, 0x00, 0x00, 0x00, 0x00,
2946 }; 2513 };
2947 SpdyHeadersIR headers_ir(0x7fffffff); 2514 SpdyHeadersIR headers_ir(0x7fffffff);
2948 headers_ir.set_fin(true); 2515 headers_ir.set_fin(true);
2949 headers_ir.SetHeader("", "foo"); 2516 headers_ir.SetHeader("", "foo");
2950 headers_ir.SetHeader("foo", "bar"); 2517 headers_ir.SetHeader("foo", "bar");
2951 headers_ir.set_padding_len(6); 2518 headers_ir.set_padding_len(6);
2952 scoped_ptr<SpdyFrame> frame(framer.SerializeHeaders(headers_ir)); 2519 scoped_ptr<SpdyFrame> frame(framer.SerializeHeaders(headers_ir));
2953 if (IsSpdy2() || IsSpdy3()) { 2520 if (spdy_version_ > SPDY3) {
2954 // Padding is not supported. 2521 // Padding only supported in SPDY>3.
2955 } else {
2956 CompareFrame(kDescription, *frame, kV4FrameData, arraysize(kV4FrameData)); 2522 CompareFrame(kDescription, *frame, kV4FrameData, arraysize(kV4FrameData));
2957 } 2523 }
2958 } 2524 }
2959 } 2525 }
2960 2526
2961 // TODO(phajdan.jr): Clean up after we no longer need 2527 // TODO(phajdan.jr): Clean up after we no longer need
2962 // to workaround http://crbug.com/139744. 2528 // to workaround http://crbug.com/139744.
2963 #if !defined(USE_SYSTEM_ZLIB) 2529 #if !defined(USE_SYSTEM_ZLIB)
2964 TEST_P(SpdyFramerTest, CreateHeadersCompressed) { 2530 TEST_P(SpdyFramerTest, CreateHeadersCompressed) {
2531 if (spdy_version_ > SPDY3) {
2532 // Deflate compression doesn't apply to HPACK.
2533 return;
2534 }
2965 SpdyFramer framer(spdy_version_); 2535 SpdyFramer framer(spdy_version_);
2966 framer.set_enable_compression(true); 2536 framer.set_enable_compression(true);
2967 2537
2968 { 2538 {
2969 const char kDescription[] = "HEADERS frame, no FIN"; 2539 const char kDescription[] = "HEADERS frame, no FIN";
2970
2971 const unsigned char kV2FrameData[] = {
2972 0x80, spdy_version_ch_, 0x00, 0x08,
2973 0x00, 0x00, 0x00, 0x32,
2974 0x00, 0x00, 0x00, 0x01,
2975 0x00, 0x00, 0x38, 0xea,
2976 0xdf, 0xa2, 0x51, 0xb2,
2977 0x62, 0x60, 0x62, 0x60,
2978 0x4e, 0x4a, 0x2c, 0x62,
2979 0x60, 0x06, 0x08, 0xa0,
2980 0xb4, 0xfc, 0x7c, 0x80,
2981 0x00, 0x62, 0x60, 0x4e,
2982 0xcb, 0xcf, 0x67, 0x60,
2983 0x06, 0x08, 0xa0, 0xa4,
2984 0xc4, 0x22, 0x80, 0x00,
2985 0x02, 0x00, 0x00, 0x00,
2986 0xff, 0xff,
2987 };
2988 const unsigned char kV3FrameData[] = { 2540 const unsigned char kV3FrameData[] = {
2989 0x80, spdy_version_ch_, 0x00, 0x08, 2541 0x80, spdy_version_ch_, 0x00, 0x08,
2990 0x00, 0x00, 0x00, 0x31, 2542 0x00, 0x00, 0x00, 0x31,
2991 0x00, 0x00, 0x00, 0x01, 2543 0x00, 0x00, 0x00, 0x01,
2992 0x38, 0xea, 0xe3, 0xc6, 2544 0x38, 0xea, 0xe3, 0xc6,
2993 0xa7, 0xc2, 0x02, 0xe5, 2545 0xa7, 0xc2, 0x02, 0xe5,
2994 0x0e, 0x50, 0xc2, 0x4b, 2546 0x0e, 0x50, 0xc2, 0x4b,
2995 0x4a, 0x04, 0xe5, 0x0b, 2547 0x4a, 0x04, 0xe5, 0x0b,
2996 0x66, 0x80, 0x00, 0x4a, 2548 0x66, 0x80, 0x00, 0x4a,
2997 0xcb, 0xcf, 0x07, 0x08, 2549 0xcb, 0xcf, 0x07, 0x08,
2998 0x20, 0x10, 0x95, 0x96, 2550 0x20, 0x10, 0x95, 0x96,
2999 0x9f, 0x0f, 0xa2, 0x00, 2551 0x9f, 0x0f, 0xa2, 0x00,
3000 0x02, 0x28, 0x29, 0xb1, 2552 0x02, 0x28, 0x29, 0xb1,
3001 0x08, 0x20, 0x80, 0x00, 2553 0x08, 0x20, 0x80, 0x00,
3002 0x00, 0x00, 0x00, 0xff, 2554 0x00, 0x00, 0x00, 0xff,
3003 0xff, 2555 0xff,
3004 }; 2556 };
3005 const unsigned char kV2SIMDFrameData[] = {
3006 0x80, spdy_version_ch_, 0x00, 0x08,
3007 0x00, 0x00, 0x00, 0x2f,
3008 0x00, 0x00, 0x00, 0x01,
3009 0x00, 0x00, 0x38, 0xea,
3010 0xdf, 0xa2, 0x51, 0xb2,
3011 0x62, 0x60, 0x62, 0x60,
3012 0x4e, 0x4a, 0x2c, 0x62,
3013 0x60, 0x06, 0x08, 0xa0,
3014 0xb4, 0xfc, 0x7c, 0x80,
3015 0x00, 0x62, 0x60, 0x06,
3016 0x13, 0x00, 0x01, 0x94,
3017 0x94, 0x58, 0x04, 0x10,
3018 0x40, 0x00, 0x00, 0x00,
3019 0x00, 0xff, 0xff,
3020 };
3021 const unsigned char kV3SIMDFrameData[] = { 2557 const unsigned char kV3SIMDFrameData[] = {
3022 0x80, spdy_version_ch_, 0x00, 0x08, 2558 0x80, spdy_version_ch_, 0x00, 0x08,
3023 0x00, 0x00, 0x00, 0x2c, 2559 0x00, 0x00, 0x00, 0x2c,
3024 0x00, 0x00, 0x00, 0x01, 2560 0x00, 0x00, 0x00, 0x01,
3025 0x38, 0xea, 0xe3, 0xc6, 2561 0x38, 0xea, 0xe3, 0xc6,
3026 0xa7, 0xc2, 0x02, 0xe5, 2562 0xa7, 0xc2, 0x02, 0xe5,
3027 0x0e, 0x50, 0xc2, 0x4b, 2563 0x0e, 0x50, 0xc2, 0x4b,
3028 0x4a, 0x04, 0xe5, 0x0b, 2564 0x4a, 0x04, 0xe5, 0x0b,
3029 0x66, 0x80, 0x00, 0x4a, 2565 0x66, 0x80, 0x00, 0x4a,
3030 0xcb, 0xcf, 0x07, 0x08, 2566 0xcb, 0xcf, 0x07, 0x08,
3031 0x20, 0x24, 0x0a, 0x20, 2567 0x20, 0x24, 0x0a, 0x20,
3032 0x80, 0x92, 0x12, 0x8b, 2568 0x80, 0x92, 0x12, 0x8b,
3033 0x00, 0x02, 0x08, 0x00, 2569 0x00, 0x02, 0x08, 0x00,
3034 0x00, 0x00, 0xff, 0xff, 2570 0x00, 0x00, 0xff, 0xff,
3035 }; 2571 };
3036 2572
3037 SpdyHeadersIR headers_ir(1); 2573 SpdyHeadersIR headers_ir(1);
3038 headers_ir.SetHeader("bar", "foo"); 2574 headers_ir.SetHeader("bar", "foo");
3039 headers_ir.SetHeader("foo", "bar"); 2575 headers_ir.SetHeader("foo", "bar");
3040 scoped_ptr<SpdyFrame> frame(framer.SerializeHeaders(headers_ir)); 2576 scoped_ptr<SpdyFrame> frame(framer.SerializeHeaders(headers_ir));
3041 const unsigned char* frame_data = 2577 const unsigned char* frame_data =
3042 reinterpret_cast<const unsigned char*>(frame->data()); 2578 reinterpret_cast<const unsigned char*>(frame->data());
3043 if (IsSpdy2()) { 2579 if (memcmp(frame_data,
3044 // Try comparing with SIMD version, if that fails, do a failing check 2580 kV3SIMDFrameData,
3045 // with pretty printing against non-SIMD version 2581 std::min(arraysize(kV3SIMDFrameData), frame->size())) != 0) {
3046 if (memcmp(frame_data, 2582 CompareCharArraysWithHexError(kDescription,
3047 kV2SIMDFrameData, 2583 frame_data,
3048 std::min(arraysize(kV2SIMDFrameData), frame->size())) != 0) { 2584 frame->size(),
3049 CompareCharArraysWithHexError(kDescription, 2585 kV3FrameData,
3050 frame_data, 2586 arraysize(kV3FrameData));
3051 frame->size(),
3052 kV2FrameData,
3053 arraysize(kV2FrameData));
3054 }
3055 } else if (IsSpdy3()) {
3056 if (memcmp(frame_data,
3057 kV3SIMDFrameData,
3058 std::min(arraysize(kV3SIMDFrameData), frame->size())) != 0) {
3059 CompareCharArraysWithHexError(kDescription,
3060 frame_data,
3061 frame->size(),
3062 kV3FrameData,
3063 arraysize(kV3FrameData));
3064 }
3065 } else {
3066 // Deflate compression doesn't apply to HPACK.
3067 } 2587 }
3068 } 2588 }
3069 } 2589 }
3070 #endif // !defined(USE_SYSTEM_ZLIB) 2590 #endif // !defined(USE_SYSTEM_ZLIB)
3071 2591
3072 TEST_P(SpdyFramerTest, CreateWindowUpdate) { 2592 TEST_P(SpdyFramerTest, CreateWindowUpdate) {
3073 SpdyFramer framer(spdy_version_); 2593 SpdyFramer framer(spdy_version_);
3074 2594
3075 { 2595 {
3076 const char kDescription[] = "WINDOW_UPDATE frame"; 2596 const char kDescription[] = "WINDOW_UPDATE frame";
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
3183 TEST_P(SpdyFramerTest, CreatePushPromiseUncompressed) { 2703 TEST_P(SpdyFramerTest, CreatePushPromiseUncompressed) {
3184 if (spdy_version_ <= SPDY3) { 2704 if (spdy_version_ <= SPDY3) {
3185 return; 2705 return;
3186 } 2706 }
3187 2707
3188 { 2708 {
3189 // Test framing PUSH_PROMISE without padding. 2709 // Test framing PUSH_PROMISE without padding.
3190 SpdyFramer framer(spdy_version_); 2710 SpdyFramer framer(spdy_version_);
3191 framer.set_enable_compression(false); 2711 framer.set_enable_compression(false);
3192 const char kDescription[] = "PUSH_PROMISE frame without padding"; 2712 const char kDescription[] = "PUSH_PROMISE frame without padding";
3193
3194 const unsigned char kFrameData[] = { 2713 const unsigned char kFrameData[] = {
3195 0x00, 0x00, 0x16, 0x05, // PUSH_PROMISE 2714 0x00, 0x00, 0x16, 0x05, // PUSH_PROMISE
3196 0x04, 0x00, 0x00, 0x00, // END_HEADERS 2715 0x04, 0x00, 0x00, 0x00, // END_HEADERS
3197 0x2a, 0x00, 0x00, 0x00, // Stream 42 2716 0x2a, 0x00, 0x00, 0x00, // Stream 42
3198 0x39, 0x00, 0x03, 0x62, // Promised stream 57, @.b 2717 0x39, 0x00, 0x03, 0x62, // Promised stream 57, @.b
3199 0x61, 0x72, 0x03, 0x66, // ar.f 2718 0x61, 0x72, 0x03, 0x66, // ar.f
3200 0x6f, 0x6f, 0x00, 0x03, // oo@. 2719 0x6f, 0x6f, 0x00, 0x03, // oo@.
3201 0x66, 0x6f, 0x6f, 0x03, // foo. 2720 0x66, 0x6f, 0x6f, 0x03, // foo.
3202 0x62, 0x61, 0x72, // bar 2721 0x62, 0x61, 0x72, // bar
3203 }; 2722 };
3204 2723
3205 SpdyPushPromiseIR push_promise(42, 57); 2724 SpdyPushPromiseIR push_promise(42, 57);
3206 push_promise.SetHeader("bar", "foo"); 2725 push_promise.SetHeader("bar", "foo");
3207 push_promise.SetHeader("foo", "bar"); 2726 push_promise.SetHeader("foo", "bar");
3208 scoped_ptr<SpdySerializedFrame> frame( 2727 scoped_ptr<SpdySerializedFrame> frame(
3209 framer.SerializePushPromise(push_promise)); 2728 framer.SerializePushPromise(push_promise));
3210 CompareFrame(kDescription, *frame, kFrameData, arraysize(kFrameData)); 2729 CompareFrame(kDescription, *frame, kFrameData, arraysize(kFrameData));
3211 } 2730 }
3212 2731
3213 { 2732 {
3214 // Test framing PUSH_PROMISE with one byte of padding. 2733 // Test framing PUSH_PROMISE with one byte of padding.
3215 SpdyFramer framer(spdy_version_); 2734 SpdyFramer framer(spdy_version_);
3216 framer.set_enable_compression(false); 2735 framer.set_enable_compression(false);
3217 const char kDescription[] = "PUSH_PROMISE frame with one byte of padding"; 2736 const char kDescription[] = "PUSH_PROMISE frame with one byte of padding";
3218
3219 const unsigned char kFrameData[] = { 2737 const unsigned char kFrameData[] = {
3220 0x00, 0x00, 0x17, 0x05, // PUSH_PROMISE 2738 0x00, 0x00, 0x17, 0x05, // PUSH_PROMISE
3221 0x0c, 0x00, 0x00, 0x00, // END_HEADERS | PADDED 2739 0x0c, 0x00, 0x00, 0x00, // END_HEADERS | PADDED
3222 0x2a, 0x00, 0x00, 0x00, // Stream 42, Pad length field 2740 0x2a, 0x00, 0x00, 0x00, // Stream 42, Pad length field
3223 0x00, 0x39, 0x00, 0x03, // Promised stream 57 2741 0x00, 0x39, 0x00, 0x03, // Promised stream 57
3224 0x62, 0x61, 0x72, 0x03, // bar. 2742 0x62, 0x61, 0x72, 0x03, // bar.
3225 0x66, 0x6f, 0x6f, 0x00, // foo@ 2743 0x66, 0x6f, 0x6f, 0x00, // foo@
3226 0x03, 0x66, 0x6f, 0x6f, // .foo 2744 0x03, 0x66, 0x6f, 0x6f, // .foo
3227 0x03, 0x62, 0x61, 0x72, // .bar 2745 0x03, 0x62, 0x61, 0x72, // .bar
3228 }; 2746 };
3229 2747
3230 SpdyPushPromiseIR push_promise(42, 57); 2748 SpdyPushPromiseIR push_promise(42, 57);
3231 push_promise.set_padding_len(1); 2749 push_promise.set_padding_len(1);
3232 push_promise.SetHeader("bar", "foo"); 2750 push_promise.SetHeader("bar", "foo");
3233 push_promise.SetHeader("foo", "bar"); 2751 push_promise.SetHeader("foo", "bar");
3234 scoped_ptr<SpdySerializedFrame> frame( 2752 scoped_ptr<SpdySerializedFrame> frame(
3235 framer.SerializePushPromise(push_promise)); 2753 framer.SerializePushPromise(push_promise));
3236 CompareFrame(kDescription, *frame, kFrameData, arraysize(kFrameData)); 2754 CompareFrame(kDescription, *frame, kFrameData, arraysize(kFrameData));
3237 } 2755 }
3238 2756
3239 { 2757 {
3240 // Test framing PUSH_PROMISE with 177 bytes of padding. 2758 // Test framing PUSH_PROMISE with 177 bytes of padding.
3241 SpdyFramer framer(spdy_version_); 2759 SpdyFramer framer(spdy_version_);
3242 framer.set_enable_compression(false); 2760 framer.set_enable_compression(false);
3243 const char kDescription[] = "PUSH_PROMISE frame with 177 bytes of padding"; 2761 const char kDescription[] = "PUSH_PROMISE frame with 177 bytes of padding";
3244
3245 const unsigned char kFrameData[] = { 2762 const unsigned char kFrameData[] = {
3246 0x00, 0x00, 0xc7, 0x05, // PUSH_PROMISE 2763 0x00, 0x00, 0xc7, 0x05, // PUSH_PROMISE
3247 0x0c, 0x00, 0x00, 0x00, // END_HEADERS | PADDED 2764 0x0c, 0x00, 0x00, 0x00, // END_HEADERS | PADDED
3248 0x2a, 0xb0, 0x00, 0x00, // Stream 42, Pad length field 2765 0x2a, 0xb0, 0x00, 0x00, // Stream 42, Pad length field
3249 0x00, 0x39, 0x00, 0x03, // Promised stream 57 2766 0x00, 0x39, 0x00, 0x03, // Promised stream 57
3250 0x62, 0x61, 0x72, 0x03, // bar. 2767 0x62, 0x61, 0x72, 0x03, // bar.
3251 0x66, 0x6f, 0x6f, 0x00, // foo@ 2768 0x66, 0x6f, 0x6f, 0x00, // foo@
3252 0x03, 0x66, 0x6f, 0x6f, // .foo 2769 0x03, 0x66, 0x6f, 0x6f, // .foo
3253 0x03, 0x62, 0x61, 0x72, // .bar 2770 0x03, 0x62, 0x61, 0x72, // .bar
3254 // Padding of 176 0x00(s). 2771 // Padding of 176 0x00(s).
(...skipping 25 matching lines...) Expand all
3280 } 2797 }
3281 2798
3282 TEST_P(SpdyFramerTest, CreateContinuationUncompressed) { 2799 TEST_P(SpdyFramerTest, CreateContinuationUncompressed) {
3283 if (spdy_version_ <= SPDY3) { 2800 if (spdy_version_ <= SPDY3) {
3284 return; 2801 return;
3285 } 2802 }
3286 2803
3287 SpdyFramer framer(spdy_version_); 2804 SpdyFramer framer(spdy_version_);
3288 framer.set_enable_compression(false); 2805 framer.set_enable_compression(false);
3289 const char kDescription[] = "CONTINUATION frame"; 2806 const char kDescription[] = "CONTINUATION frame";
3290
3291 const unsigned char kFrameData[] = { 2807 const unsigned char kFrameData[] = {
3292 0x00, 0x00, 0x12, 0x09, 0x00, // CONTINUATION 2808 0x00, 0x00, 0x12, 0x09, 0x00, // CONTINUATION
3293 0x00, 0x00, 0x00, 0x2a, // Stream 42 2809 0x00, 0x00, 0x00, 0x2a, // Stream 42
3294 0x00, 0x03, 0x62, 0x61, // @.ba 2810 0x00, 0x03, 0x62, 0x61, // @.ba
3295 0x72, 0x03, 0x66, 0x6f, // r.fo 2811 0x72, 0x03, 0x66, 0x6f, // r.fo
3296 0x6f, 0x00, 0x03, 0x66, // o@.f 2812 0x6f, 0x00, 0x03, 0x66, // o@.f
3297 0x6f, 0x6f, 0x03, 0x62, // oo.b 2813 0x6f, 0x6f, 0x03, 0x62, // oo.b
3298 0x61, 0x72, // ar 2814 0x61, 0x72, // ar
3299 }; 2815 };
3300 2816
(...skipping 11 matching lines...) Expand all
3312 } 2828 }
3313 2829
3314 { 2830 {
3315 // Test framing in a case such that a PUSH_PROMISE frame, with one byte of 2831 // Test framing in a case such that a PUSH_PROMISE frame, with one byte of
3316 // padding, cannot hold all the data payload, which is overflowed to the 2832 // padding, cannot hold all the data payload, which is overflowed to the
3317 // consecutive CONTINUATION frame. 2833 // consecutive CONTINUATION frame.
3318 SpdyFramer framer(spdy_version_); 2834 SpdyFramer framer(spdy_version_);
3319 framer.set_enable_compression(false); 2835 framer.set_enable_compression(false);
3320 const char kDescription[] = 2836 const char kDescription[] =
3321 "PUSH_PROMISE and CONTINUATION frames with one byte of padding"; 2837 "PUSH_PROMISE and CONTINUATION frames with one byte of padding";
3322
3323 const unsigned char kPartialPushPromiseFrameData[] = { 2838 const unsigned char kPartialPushPromiseFrameData[] = {
3324 0x00, 0x03, 0xf7, 0x05, // PUSH_PROMISE 2839 0x00, 0x03, 0xf7, 0x05, // PUSH_PROMISE
3325 0x08, 0x00, 0x00, 0x00, // PADDED 2840 0x08, 0x00, 0x00, 0x00, // PADDED
3326 0x2a, 0x00, 0x00, 0x00, // Stream 42 2841 0x2a, 0x00, 0x00, 0x00, // Stream 42
3327 0x00, 0x39, 0x00, 0x03, // Promised stream 57 2842 0x00, 0x39, 0x00, 0x03, // Promised stream 57
3328 0x78, 0x78, 0x78, 0x7f, // xxx. 2843 0x78, 0x78, 0x78, 0x7f, // xxx.
3329 0x81, 0x07, 0x78, 0x78, // ..xx 2844 0x81, 0x07, 0x78, 0x78, // ..xx
3330 0x78, 0x78, 0x78, 0x78, // xxxx 2845 0x78, 0x78, 0x78, 0x78, // xxxx
3331 0x78, 0x78, 0x78, 0x78, // xxxx 2846 0x78, 0x78, 0x78, 0x78, // xxxx
3332 0x78, 0x78, 0x78, 0x78, // xxxx 2847 0x78, 0x78, 0x78, 0x78, // xxxx
(...skipping 571 matching lines...) Expand 10 before | Expand all | Expand 10 after
3904 EXPECT_EQ(3 * 2, visitor.setting_count_); 3419 EXPECT_EQ(3 * 2, visitor.setting_count_);
3905 if (spdy_version_ > SPDY3) { 3420 if (spdy_version_ > SPDY3) {
3906 EXPECT_EQ(2, visitor.settings_ack_sent_); 3421 EXPECT_EQ(2, visitor.settings_ack_sent_);
3907 } 3422 }
3908 } 3423 }
3909 3424
3910 // Tests handling of SETTINGS frame with duplicate entries. 3425 // Tests handling of SETTINGS frame with duplicate entries.
3911 TEST_P(SpdyFramerTest, ReadDuplicateSettings) { 3426 TEST_P(SpdyFramerTest, ReadDuplicateSettings) {
3912 SpdyFramer framer(spdy_version_); 3427 SpdyFramer framer(spdy_version_);
3913 3428
3914 const unsigned char kV2FrameData[] = {
3915 0x80, spdy_version_ch_, 0x00, 0x04,
3916 0x00, 0x00, 0x00, 0x1C,
3917 0x00, 0x00, 0x00, 0x03,
3918 0x01, 0x00, 0x00, 0x00, // 1st Setting
3919 0x00, 0x00, 0x00, 0x02,
3920 0x01, 0x00, 0x00, 0x00, // 2nd (duplicate) Setting
3921 0x00, 0x00, 0x00, 0x03,
3922 0x03, 0x00, 0x00, 0x00, // 3rd (unprocessed) Setting
3923 0x00, 0x00, 0x00, 0x03,
3924 };
3925 const unsigned char kV3FrameData[] = { 3429 const unsigned char kV3FrameData[] = {
3926 0x80, spdy_version_ch_, 0x00, 0x04, 3430 0x80, spdy_version_ch_, 0x00, 0x04,
3927 0x00, 0x00, 0x00, 0x1C, 3431 0x00, 0x00, 0x00, 0x1C,
3928 0x00, 0x00, 0x00, 0x03, 3432 0x00, 0x00, 0x00, 0x03,
3929 0x00, 0x00, 0x00, 0x01, // 1st Setting 3433 0x00, 0x00, 0x00, 0x01, // 1st Setting
3930 0x00, 0x00, 0x00, 0x02, 3434 0x00, 0x00, 0x00, 0x02,
3931 0x00, 0x00, 0x00, 0x01, // 2nd (duplicate) Setting 3435 0x00, 0x00, 0x00, 0x01, // 2nd (duplicate) Setting
3932 0x00, 0x00, 0x00, 0x03, 3436 0x00, 0x00, 0x00, 0x03,
3933 0x00, 0x00, 0x00, 0x03, // 3rd (unprocessed) Setting 3437 0x00, 0x00, 0x00, 0x03, // 3rd (unprocessed) Setting
3934 0x00, 0x00, 0x00, 0x03, 3438 0x00, 0x00, 0x00, 0x03,
3935 }; 3439 };
3936 const unsigned char kV4FrameData[] = { 3440 const unsigned char kV4FrameData[] = {
3937 0x00, 0x00, 0x12, 0x04, 3441 0x00, 0x00, 0x12, 0x04,
3938 0x00, 0x00, 0x00, 0x00, 3442 0x00, 0x00, 0x00, 0x00,
3939 0x00, 0x00, 0x01, // 1st Setting 3443 0x00, 0x00, 0x01, // 1st Setting
3940 0x00, 0x00, 0x00, 0x02, 3444 0x00, 0x00, 0x00, 0x02,
3941 0x00, 0x01, // 2nd (duplicate) Setting 3445 0x00, 0x01, // 2nd (duplicate) Setting
3942 0x00, 0x00, 0x00, 0x03, 3446 0x00, 0x00, 0x00, 0x03,
3943 0x00, 0x03, // 3rd (unprocessed) Setting 3447 0x00, 0x03, // 3rd (unprocessed) Setting
3944 0x00, 0x00, 0x00, 0x03, 3448 0x00, 0x00, 0x00, 0x03,
3945 }; 3449 };
3946 3450
3947 TestSpdyVisitor visitor(spdy_version_); 3451 TestSpdyVisitor visitor(spdy_version_);
3948 visitor.use_compression_ = false; 3452 visitor.use_compression_ = false;
3949 if (IsSpdy2()) { 3453 if (IsSpdy3()) {
3950 visitor.SimulateInFramer(kV2FrameData, sizeof(kV2FrameData));
3951 } else if (IsSpdy3()) {
3952 visitor.SimulateInFramer(kV3FrameData, sizeof(kV3FrameData)); 3454 visitor.SimulateInFramer(kV3FrameData, sizeof(kV3FrameData));
3953 } else { 3455 } else {
3954 visitor.SimulateInFramer(kV4FrameData, sizeof(kV4FrameData)); 3456 visitor.SimulateInFramer(kV4FrameData, sizeof(kV4FrameData));
3955 } 3457 }
3956 3458
3957 if (!IsSpdy4()) { 3459 if (!IsSpdy4()) {
3958 EXPECT_EQ(1, visitor.setting_count_); 3460 EXPECT_EQ(1, visitor.setting_count_);
3959 EXPECT_EQ(1, visitor.error_count_); 3461 EXPECT_EQ(1, visitor.error_count_);
3960 } else { 3462 } else {
3961 // In SPDY 4+, duplicate settings are allowed; 3463 // In SPDY 4+, duplicate settings are allowed;
3962 // each setting replaces the previous value for that setting. 3464 // each setting replaces the previous value for that setting.
3963 EXPECT_EQ(3, visitor.setting_count_); 3465 EXPECT_EQ(3, visitor.setting_count_);
3964 EXPECT_EQ(0, visitor.error_count_); 3466 EXPECT_EQ(0, visitor.error_count_);
3965 EXPECT_EQ(1, visitor.settings_ack_sent_); 3467 EXPECT_EQ(1, visitor.settings_ack_sent_);
3966 } 3468 }
3967 } 3469 }
3968 3470
3969 // Tests handling of SETTINGS frame with a setting we don't recognize. 3471 // Tests handling of SETTINGS frame with a setting we don't recognize.
3970 TEST_P(SpdyFramerTest, ReadUnknownSettingsId) { 3472 TEST_P(SpdyFramerTest, ReadUnknownSettingsId) {
3971 SpdyFramer framer(spdy_version_); 3473 SpdyFramer framer(spdy_version_);
3972 3474
3973 const unsigned char kV2FrameData[] = {
3974 0x80, spdy_version_ch_, 0x00, 0x04,
3975 0x00, 0x00, 0x00, 0x1C,
3976 0x00, 0x00, 0x00, 0x01,
3977 0x10, 0x00, 0x00, 0x00, // 1st Setting
3978 0x00, 0x00, 0x00, 0x02,
3979 };
3980 const unsigned char kV3FrameData[] = { 3475 const unsigned char kV3FrameData[] = {
3981 0x80, spdy_version_ch_, 0x00, 0x04, 3476 0x80, spdy_version_ch_, 0x00, 0x04,
3982 0x00, 0x00, 0x00, 0x1C, 3477 0x00, 0x00, 0x00, 0x1C,
3983 0x00, 0x00, 0x00, 0x01, 3478 0x00, 0x00, 0x00, 0x01,
3984 0x00, 0x00, 0x00, 0x10, // 1st Setting 3479 0x00, 0x00, 0x00, 0x10, // 1st Setting
3985 0x00, 0x00, 0x00, 0x02, 3480 0x00, 0x00, 0x00, 0x02,
3986 }; 3481 };
3987 const unsigned char kV4FrameData[] = { 3482 const unsigned char kV4FrameData[] = {
3988 0x00, 0x00, 0x06, 0x04, 3483 0x00, 0x00, 0x06, 0x04,
3989 0x00, 0x00, 0x00, 0x00, 3484 0x00, 0x00, 0x00, 0x00,
3990 0x00, 0x00, 0x10, // 1st Setting 3485 0x00, 0x00, 0x10, // 1st Setting
3991 0x00, 0x00, 0x00, 0x02, 3486 0x00, 0x00, 0x00, 0x02,
3992 }; 3487 };
3993 3488
3994 TestSpdyVisitor visitor(spdy_version_); 3489 TestSpdyVisitor visitor(spdy_version_);
3995 visitor.use_compression_ = false; 3490 visitor.use_compression_ = false;
3996 if (IsSpdy2()) { 3491 if (IsSpdy3()) {
3997 visitor.SimulateInFramer(kV2FrameData, sizeof(kV2FrameData));
3998 } else if (IsSpdy3()) {
3999 visitor.SimulateInFramer(kV3FrameData, sizeof(kV3FrameData)); 3492 visitor.SimulateInFramer(kV3FrameData, sizeof(kV3FrameData));
4000 } else { 3493 } else {
4001 visitor.SimulateInFramer(kV4FrameData, sizeof(kV4FrameData)); 3494 visitor.SimulateInFramer(kV4FrameData, sizeof(kV4FrameData));
4002 } 3495 }
4003 3496
4004 if (!IsSpdy4()) { 3497 if (!IsSpdy4()) {
4005 EXPECT_EQ(0, visitor.setting_count_); 3498 EXPECT_EQ(0, visitor.setting_count_);
4006 EXPECT_EQ(1, visitor.error_count_); 3499 EXPECT_EQ(1, visitor.error_count_);
4007 } else { 3500 } else {
4008 // In SPDY 4+, we ignore unknown settings because of extensions. 3501 // In SPDY 4+, we ignore unknown settings because of extensions.
4009 EXPECT_EQ(0, visitor.setting_count_); 3502 EXPECT_EQ(0, visitor.setting_count_);
4010 EXPECT_EQ(0, visitor.error_count_); 3503 EXPECT_EQ(0, visitor.error_count_);
4011 } 3504 }
4012 } 3505 }
4013 3506
4014 // Tests handling of SETTINGS frame with entries out of order. 3507 // Tests handling of SETTINGS frame with entries out of order.
4015 TEST_P(SpdyFramerTest, ReadOutOfOrderSettings) { 3508 TEST_P(SpdyFramerTest, ReadOutOfOrderSettings) {
4016 SpdyFramer framer(spdy_version_); 3509 SpdyFramer framer(spdy_version_);
4017 3510
4018 const unsigned char kV2FrameData[] = {
4019 0x80, spdy_version_ch_, 0x00, 0x04,
4020 0x00, 0x00, 0x00, 0x1C,
4021 0x00, 0x00, 0x00, 0x03,
4022 0x02, 0x00, 0x00, 0x00, // 1st Setting
4023 0x00, 0x00, 0x00, 0x02,
4024 0x01, 0x00, 0x00, 0x00, // 2nd (out of order) Setting
4025 0x00, 0x00, 0x00, 0x03,
4026 0x03, 0x00, 0x00, 0x00, // 3rd (unprocessed) Setting
4027 0x00, 0x00, 0x00, 0x03,
4028 };
4029 const unsigned char kV3FrameData[] = { 3511 const unsigned char kV3FrameData[] = {
4030 0x80, spdy_version_ch_, 0x00, 0x04, 3512 0x80, spdy_version_ch_, 0x00, 0x04,
4031 0x00, 0x00, 0x00, 0x1C, 3513 0x00, 0x00, 0x00, 0x1C,
4032 0x00, 0x00, 0x00, 0x03, 3514 0x00, 0x00, 0x00, 0x03,
4033 0x00, 0x00, 0x00, 0x02, // 1st Setting 3515 0x00, 0x00, 0x00, 0x02, // 1st Setting
4034 0x00, 0x00, 0x00, 0x02, 3516 0x00, 0x00, 0x00, 0x02,
4035 0x00, 0x00, 0x00, 0x01, // 2nd (out of order) Setting 3517 0x00, 0x00, 0x00, 0x01, // 2nd (out of order) Setting
4036 0x00, 0x00, 0x00, 0x03, 3518 0x00, 0x00, 0x00, 0x03,
4037 0x00, 0x00, 0x01, 0x03, // 3rd (unprocessed) Setting 3519 0x00, 0x00, 0x01, 0x03, // 3rd (unprocessed) Setting
4038 0x00, 0x00, 0x00, 0x03, 3520 0x00, 0x00, 0x00, 0x03,
4039 }; 3521 };
4040 const unsigned char kV4FrameData[] = { 3522 const unsigned char kV4FrameData[] = {
4041 0x00, 0x00, 0x12, 0x04, 3523 0x00, 0x00, 0x12, 0x04,
4042 0x00, 0x00, 0x00, 0x00, 3524 0x00, 0x00, 0x00, 0x00,
4043 0x00, 0x00, 0x02, // 1st Setting 3525 0x00, 0x00, 0x02, // 1st Setting
4044 0x00, 0x00, 0x00, 0x02, 3526 0x00, 0x00, 0x00, 0x02,
4045 0x00, 0x01, // 2nd (out of order) Setting 3527 0x00, 0x01, // 2nd (out of order) Setting
4046 0x00, 0x00, 0x00, 0x03, 3528 0x00, 0x00, 0x00, 0x03,
4047 0x00, 0x03, // 3rd (unprocessed) Setting 3529 0x00, 0x03, // 3rd (unprocessed) Setting
4048 0x00, 0x00, 0x00, 0x03, 3530 0x00, 0x00, 0x00, 0x03,
4049 }; 3531 };
4050 3532
4051 TestSpdyVisitor visitor(spdy_version_); 3533 TestSpdyVisitor visitor(spdy_version_);
4052 visitor.use_compression_ = false; 3534 visitor.use_compression_ = false;
4053 if (IsSpdy2()) { 3535 if (IsSpdy3()) {
4054 visitor.SimulateInFramer(kV2FrameData, sizeof(kV2FrameData));
4055 } else if (IsSpdy3()) {
4056 visitor.SimulateInFramer(kV3FrameData, sizeof(kV3FrameData)); 3536 visitor.SimulateInFramer(kV3FrameData, sizeof(kV3FrameData));
4057 } else { 3537 } else {
4058 visitor.SimulateInFramer(kV4FrameData, sizeof(kV4FrameData)); 3538 visitor.SimulateInFramer(kV4FrameData, sizeof(kV4FrameData));
4059 } 3539 }
4060 3540
4061 if (!IsSpdy4()) { 3541 if (!IsSpdy4()) {
4062 EXPECT_EQ(1, visitor.setting_count_); 3542 EXPECT_EQ(1, visitor.setting_count_);
4063 EXPECT_EQ(1, visitor.error_count_); 3543 EXPECT_EQ(1, visitor.error_count_);
4064 } else { 3544 } else {
4065 // In SPDY 4+, settings are allowed in any order. 3545 // In SPDY 4+, settings are allowed in any order.
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
4158 framer.SerializeWindowUpdate(SpdyWindowUpdateIR(1, 2))); 3638 framer.SerializeWindowUpdate(SpdyWindowUpdateIR(1, 2)));
4159 TestSpdyVisitor visitor(spdy_version_); 3639 TestSpdyVisitor visitor(spdy_version_);
4160 visitor.SimulateInFramer( 3640 visitor.SimulateInFramer(
4161 reinterpret_cast<unsigned char*>(control_frame->data()), 3641 reinterpret_cast<unsigned char*>(control_frame->data()),
4162 control_frame->size()); 3642 control_frame->size());
4163 EXPECT_EQ(1u, visitor.last_window_update_stream_); 3643 EXPECT_EQ(1u, visitor.last_window_update_stream_);
4164 EXPECT_EQ(2u, visitor.last_window_update_delta_); 3644 EXPECT_EQ(2u, visitor.last_window_update_delta_);
4165 } 3645 }
4166 3646
4167 TEST_P(SpdyFramerTest, ReceiveCredentialFrame) { 3647 TEST_P(SpdyFramerTest, ReceiveCredentialFrame) {
4168 if (!IsSpdy3()) { 3648 if (spdy_version_ > SPDY3) {
4169 return; 3649 return;
4170 } 3650 }
4171 SpdyFramer framer(spdy_version_); 3651 SpdyFramer framer(spdy_version_);
4172 const unsigned char kV3FrameData[] = { // Also applies for V2. 3652 const unsigned char kV3FrameData[] = { // Also applies for V2.
4173 0x80, spdy_version_ch_, 0x00, 0x0A, 3653 0x80, spdy_version_ch_, 0x00, 0x0A,
4174 0x00, 0x00, 0x00, 0x33, 3654 0x00, 0x00, 0x00, 0x33,
4175 0x00, 0x03, 0x00, 0x00, 3655 0x00, 0x03, 0x00, 0x00,
4176 0x00, 0x05, 'p', 'r', 3656 0x00, 0x05, 'p', 'r',
4177 'o', 'o', 'f', 0x00, 3657 'o', 'o', 'f', 0x00,
4178 0x00, 0x00, 0x06, 'a', 3658 0x00, 0x00, 0x06, 'a',
4179 ' ', 'c', 'e', 'r', 3659 ' ', 'c', 'e', 'r',
4180 't', 0x00, 0x00, 0x00, 3660 't', 0x00, 0x00, 0x00,
4181 0x0C, 'a', 'n', 'o', 3661 0x0C, 'a', 'n', 'o',
4182 't', 'h', 'e', 'r', 3662 't', 'h', 'e', 'r',
4183 ' ', 'c', 'e', 'r', 3663 ' ', 'c', 'e', 'r',
4184 't', 0x00, 0x00, 0x00, 3664 't', 0x00, 0x00, 0x00,
4185 0x0A, 'f', 'i', 'n', 3665 0x0A, 'f', 'i', 'n',
4186 'a', 'l', ' ', 'c', 3666 'a', 'l', ' ', 'c',
4187 'e', 'r', 't', 3667 'e', 'r', 't',
4188 }; 3668 };
4189 TestSpdyVisitor visitor(spdy_version_); 3669 TestSpdyVisitor visitor(spdy_version_);
4190 visitor.use_compression_ = false; 3670 visitor.use_compression_ = false;
4191 visitor.SimulateInFramer(kV3FrameData, arraysize(kV3FrameData)); 3671 visitor.SimulateInFramer(kV3FrameData, arraysize(kV3FrameData));
4192 EXPECT_EQ(0, visitor.error_count_); 3672 EXPECT_EQ(0, visitor.error_count_);
4193 } 3673 }
4194 3674
4195 TEST_P(SpdyFramerTest, ReadCredentialFrameFollowedByAnotherFrame) { 3675 TEST_P(SpdyFramerTest, ReadCredentialFrameFollowedByAnotherFrame) {
4196 if (!IsSpdy3()) { 3676 if (spdy_version_ > SPDY3) {
4197 return; 3677 return;
4198 } 3678 }
4199 SpdyFramer framer(spdy_version_); 3679 SpdyFramer framer(spdy_version_);
4200 const unsigned char kV3FrameData[] = { // Also applies for V2. 3680 const unsigned char kV3FrameData[] = { // Also applies for V2.
4201 0x80, spdy_version_ch_, 0x00, 0x0A, 3681 0x80, spdy_version_ch_, 0x00, 0x0A,
4202 0x00, 0x00, 0x00, 0x33, 3682 0x00, 0x00, 0x00, 0x33,
4203 0x00, 0x03, 0x00, 0x00, 3683 0x00, 0x03, 0x00, 0x00,
4204 0x00, 0x05, 'p', 'r', 3684 0x00, 0x05, 'p', 'r',
4205 'o', 'o', 'f', 0x00, 3685 'o', 'o', 'f', 0x00,
4206 0x00, 0x00, 0x06, 'a', 3686 0x00, 0x00, 0x06, 'a',
(...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after
4689 EXPECT_EQ(9u, framer.GetBlockedSize()); 4169 EXPECT_EQ(9u, framer.GetBlockedSize());
4690 EXPECT_EQ(13u, framer.GetPushPromiseMinimumSize()); 4170 EXPECT_EQ(13u, framer.GetPushPromiseMinimumSize());
4691 EXPECT_EQ(18u, framer.GetAltSvcMinimumSize()); 4171 EXPECT_EQ(18u, framer.GetAltSvcMinimumSize());
4692 EXPECT_EQ(9u, framer.GetFrameMinimumSize()); 4172 EXPECT_EQ(9u, framer.GetFrameMinimumSize());
4693 EXPECT_EQ(16393u, framer.GetFrameMaximumSize()); 4173 EXPECT_EQ(16393u, framer.GetFrameMaximumSize());
4694 EXPECT_EQ(16384u, framer.GetDataFrameMaximumPayload()); 4174 EXPECT_EQ(16384u, framer.GetDataFrameMaximumPayload());
4695 } else { 4175 } else {
4696 EXPECT_EQ(8u, framer.GetDataFrameMinimumSize()); 4176 EXPECT_EQ(8u, framer.GetDataFrameMinimumSize());
4697 EXPECT_EQ(8u, framer.GetControlFrameHeaderSize()); 4177 EXPECT_EQ(8u, framer.GetControlFrameHeaderSize());
4698 EXPECT_EQ(18u, framer.GetSynStreamMinimumSize()); 4178 EXPECT_EQ(18u, framer.GetSynStreamMinimumSize());
4699 EXPECT_EQ(IsSpdy2() ? 14u : 12u, framer.GetSynReplyMinimumSize()); 4179 EXPECT_EQ(12u, framer.GetSynReplyMinimumSize());
4700 EXPECT_EQ(16u, framer.GetRstStreamMinimumSize()); 4180 EXPECT_EQ(16u, framer.GetRstStreamMinimumSize());
4701 EXPECT_EQ(12u, framer.GetSettingsMinimumSize()); 4181 EXPECT_EQ(12u, framer.GetSettingsMinimumSize());
4702 EXPECT_EQ(12u, framer.GetPingSize()); 4182 EXPECT_EQ(12u, framer.GetPingSize());
4703 EXPECT_EQ(IsSpdy2() ? 12u : 16u, framer.GetGoAwayMinimumSize()); 4183 EXPECT_EQ(16u, framer.GetGoAwayMinimumSize());
4704 EXPECT_EQ(IsSpdy2() ? 14u : 12u, framer.GetHeadersMinimumSize()); 4184 EXPECT_EQ(12u, framer.GetHeadersMinimumSize());
4705 EXPECT_EQ(16u, framer.GetWindowUpdateSize()); 4185 EXPECT_EQ(16u, framer.GetWindowUpdateSize());
4706 EXPECT_EQ(8u, framer.GetFrameMinimumSize()); 4186 EXPECT_EQ(8u, framer.GetFrameMinimumSize());
4707 EXPECT_EQ(16777223u, framer.GetFrameMaximumSize()); 4187 EXPECT_EQ(16777223u, framer.GetFrameMaximumSize());
4708 EXPECT_EQ(16777215u, framer.GetDataFrameMaximumPayload()); 4188 EXPECT_EQ(16777215u, framer.GetDataFrameMaximumPayload());
4709 } 4189 }
4710 } 4190 }
4711 4191
4712 TEST_P(SpdyFramerTest, StateToStringTest) { 4192 TEST_P(SpdyFramerTest, StateToStringTest) {
4713 EXPECT_STREQ("ERROR", 4193 EXPECT_STREQ("ERROR",
4714 SpdyFramer::StateToString(SpdyFramer::SPDY_ERROR)); 4194 SpdyFramer::StateToString(SpdyFramer::SPDY_ERROR));
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
4937 << SpdyFramer::ErrorCodeToString(framer.error_code()); 4417 << SpdyFramer::ErrorCodeToString(framer.error_code());
4938 } else { 4418 } else {
4939 EXPECT_EQ(SpdyFramer::SPDY_RESET, framer.state()); 4419 EXPECT_EQ(SpdyFramer::SPDY_RESET, framer.state());
4940 EXPECT_EQ(SpdyFramer::SPDY_NO_ERROR, framer.error_code()) 4420 EXPECT_EQ(SpdyFramer::SPDY_NO_ERROR, framer.error_code())
4941 << SpdyFramer::ErrorCodeToString(framer.error_code()); 4421 << SpdyFramer::ErrorCodeToString(framer.error_code());
4942 } 4422 }
4943 } 4423 }
4944 } 4424 }
4945 4425
4946 TEST_P(SpdyFramerTest, SynStreamFrameFlags) { 4426 TEST_P(SpdyFramerTest, SynStreamFrameFlags) {
4947 if (!IsSpdy2() && !IsSpdy3()) { 4427 if (spdy_version_ > SPDY3) {
4948 // SYN_STREAM not supported in SPDY>3 4428 // SYN_STREAM not supported in SPDY>3
4949 return; 4429 return;
4950 } 4430 }
4951 for (int flags = 0; flags < 256; ++flags) { 4431 for (int flags = 0; flags < 256; ++flags) {
4952 SCOPED_TRACE(testing::Message() << "Flags " << flags); 4432 SCOPED_TRACE(testing::Message() << "Flags " << flags);
4953 4433
4954 testing::StrictMock<test::MockSpdyFramerVisitor> visitor; 4434 testing::StrictMock<test::MockSpdyFramerVisitor> visitor;
4955 testing::StrictMock<test::MockDebugVisitor> debug_visitor; 4435 testing::StrictMock<test::MockDebugVisitor> debug_visitor;
4956 SpdyFramer framer(spdy_version_); 4436 SpdyFramer framer(spdy_version_);
4957 framer.set_visitor(&visitor); 4437 framer.set_visitor(&visitor);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
4991 << SpdyFramer::ErrorCodeToString(framer.error_code()); 4471 << SpdyFramer::ErrorCodeToString(framer.error_code());
4992 } else { 4472 } else {
4993 EXPECT_EQ(SpdyFramer::SPDY_RESET, framer.state()); 4473 EXPECT_EQ(SpdyFramer::SPDY_RESET, framer.state());
4994 EXPECT_EQ(SpdyFramer::SPDY_NO_ERROR, framer.error_code()) 4474 EXPECT_EQ(SpdyFramer::SPDY_NO_ERROR, framer.error_code())
4995 << SpdyFramer::ErrorCodeToString(framer.error_code()); 4475 << SpdyFramer::ErrorCodeToString(framer.error_code());
4996 } 4476 }
4997 } 4477 }
4998 } 4478 }
4999 4479
5000 TEST_P(SpdyFramerTest, SynReplyFrameFlags) { 4480 TEST_P(SpdyFramerTest, SynReplyFrameFlags) {
5001 if (!IsSpdy2() && !IsSpdy3()) { 4481 if (spdy_version_ > SPDY3) {
5002 // SYN_REPLY not supported in SPDY>3 4482 // SYN_REPLY not supported in SPDY>3
5003 return; 4483 return;
5004 } 4484 }
5005 for (int flags = 0; flags < 256; ++flags) { 4485 for (int flags = 0; flags < 256; ++flags) {
5006 SCOPED_TRACE(testing::Message() << "Flags " << flags); 4486 SCOPED_TRACE(testing::Message() << "Flags " << flags);
5007 4487
5008 testing::StrictMock<test::MockSpdyFramerVisitor> visitor; 4488 testing::StrictMock<test::MockSpdyFramerVisitor> visitor;
5009 SpdyFramer framer(spdy_version_); 4489 SpdyFramer framer(spdy_version_);
5010 framer.set_visitor(&visitor); 4490 framer.set_visitor(&visitor);
5011 4491
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after
5439 << SpdyFramer::ErrorCodeToString(framer.error_code()); 4919 << SpdyFramer::ErrorCodeToString(framer.error_code());
5440 } 4920 }
5441 } 4921 }
5442 } 4922 }
5443 4923
5444 // TODO(mlavan): Add TEST_P(SpdyFramerTest, AltSvcFrameFlags) 4924 // TODO(mlavan): Add TEST_P(SpdyFramerTest, AltSvcFrameFlags)
5445 4925
5446 // TODO(hkhalil): Add TEST_P(SpdyFramerTest, BlockedFrameFlags) 4926 // TODO(hkhalil): Add TEST_P(SpdyFramerTest, BlockedFrameFlags)
5447 4927
5448 TEST_P(SpdyFramerTest, EmptySynStream) { 4928 TEST_P(SpdyFramerTest, EmptySynStream) {
5449 if (!IsSpdy2() && !IsSpdy3()) { 4929 if (spdy_version_ > SPDY3) {
5450 // SYN_STREAM not supported in SPDY>3. 4930 // SYN_STREAM not supported in SPDY>3.
5451 return; 4931 return;
5452 } 4932 }
5453 testing::StrictMock<test::MockSpdyFramerVisitor> visitor; 4933 testing::StrictMock<test::MockSpdyFramerVisitor> visitor;
5454 testing::StrictMock<test::MockDebugVisitor> debug_visitor; 4934 testing::StrictMock<test::MockDebugVisitor> debug_visitor;
5455 SpdyFramer framer(spdy_version_); 4935 SpdyFramer framer(spdy_version_);
5456 framer.set_visitor(&visitor); 4936 framer.set_visitor(&visitor);
5457 framer.set_debug_visitor(&debug_visitor); 4937 framer.set_debug_visitor(&debug_visitor);
5458 4938
5459 EXPECT_CALL(debug_visitor, OnSendCompressedFrame(1, SYN_STREAM, _, _)); 4939 EXPECT_CALL(debug_visitor, OnSendCompressedFrame(1, SYN_STREAM, _, _));
(...skipping 13 matching lines...) Expand all
5473 4953
5474 framer.ProcessInput(frame->data(), framer.GetSynStreamMinimumSize()); 4954 framer.ProcessInput(frame->data(), framer.GetSynStreamMinimumSize());
5475 EXPECT_EQ(SpdyFramer::SPDY_RESET, framer.state()); 4955 EXPECT_EQ(SpdyFramer::SPDY_RESET, framer.state());
5476 EXPECT_EQ(SpdyFramer::SPDY_NO_ERROR, framer.error_code()) 4956 EXPECT_EQ(SpdyFramer::SPDY_NO_ERROR, framer.error_code())
5477 << SpdyFramer::ErrorCodeToString(framer.error_code()); 4957 << SpdyFramer::ErrorCodeToString(framer.error_code());
5478 } 4958 }
5479 4959
5480 TEST_P(SpdyFramerTest, SettingsFlagsAndId) { 4960 TEST_P(SpdyFramerTest, SettingsFlagsAndId) {
5481 const uint32 kId = 0x020304; 4961 const uint32 kId = 0x020304;
5482 const uint32 kFlags = 0x01; 4962 const uint32 kFlags = 0x01;
5483 const uint32 kWireFormat = htonl(IsSpdy2() ? 0x04030201 : 0x01020304); 4963 const uint32 kWireFormat = htonl(0x01020304);
5484 4964
5485 SettingsFlagsAndId id_and_flags = 4965 SettingsFlagsAndId id_and_flags =
5486 SettingsFlagsAndId::FromWireFormat(spdy_version_, kWireFormat); 4966 SettingsFlagsAndId::FromWireFormat(spdy_version_, kWireFormat);
5487 EXPECT_EQ(kId, id_and_flags.id()); 4967 EXPECT_EQ(kId, id_and_flags.id());
5488 EXPECT_EQ(kFlags, id_and_flags.flags()); 4968 EXPECT_EQ(kFlags, id_and_flags.flags());
5489 EXPECT_EQ(kWireFormat, id_and_flags.GetWireFormat(spdy_version_)); 4969 EXPECT_EQ(kWireFormat, id_and_flags.GetWireFormat(spdy_version_));
5490 } 4970 }
5491 4971
5492 // Test handling of a RST_STREAM with out-of-bounds status codes. 4972 // Test handling of a RST_STREAM with out-of-bounds status codes.
5493 TEST_P(SpdyFramerTest, RstStreamStatusBounds) { 4973 TEST_P(SpdyFramerTest, RstStreamStatusBounds) {
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
5550 reinterpret_cast<const char*>(kV3RstStreamNumStatusCodes), 5030 reinterpret_cast<const char*>(kV3RstStreamNumStatusCodes),
5551 arraysize(kV3RstStreamNumStatusCodes)); 5031 arraysize(kV3RstStreamNumStatusCodes));
5552 } 5032 }
5553 EXPECT_EQ(SpdyFramer::SPDY_RESET, framer.state()); 5033 EXPECT_EQ(SpdyFramer::SPDY_RESET, framer.state());
5554 EXPECT_EQ(SpdyFramer::SPDY_NO_ERROR, framer.error_code()) 5034 EXPECT_EQ(SpdyFramer::SPDY_NO_ERROR, framer.error_code())
5555 << SpdyFramer::ErrorCodeToString(framer.error_code()); 5035 << SpdyFramer::ErrorCodeToString(framer.error_code());
5556 } 5036 }
5557 5037
5558 // Test handling of GOAWAY frames with out-of-bounds status code. 5038 // Test handling of GOAWAY frames with out-of-bounds status code.
5559 TEST_P(SpdyFramerTest, GoAwayStatusBounds) { 5039 TEST_P(SpdyFramerTest, GoAwayStatusBounds) {
5560 if (spdy_version_ <= SPDY2) {
5561 return;
5562 }
5563 SpdyFramer framer(spdy_version_); 5040 SpdyFramer framer(spdy_version_);
5564 5041
5565 const unsigned char kV3FrameData[] = { 5042 const unsigned char kV3FrameData[] = {
5566 0x80, spdy_version_ch_, 0x00, 0x07, 5043 0x80, spdy_version_ch_, 0x00, 0x07,
5567 0x00, 0x00, 0x00, 0x08, 5044 0x00, 0x00, 0x00, 0x08,
5568 0x00, 0x00, 0x00, 0x01, // Stream Id 5045 0x00, 0x00, 0x00, 0x01, // Stream Id
5569 0xff, 0xff, 0xff, 0xff, // Status 5046 0xff, 0xff, 0xff, 0xff, // Status
5570 }; 5047 };
5571 const unsigned char kV4FrameData[] = { 5048 const unsigned char kV4FrameData[] = {
5572 0x00, 0x00, 0x0a, 0x07, 5049 0x00, 0x00, 0x0a, 0x07,
(...skipping 14 matching lines...) Expand all
5587 framer.ProcessInput(reinterpret_cast<const char*>(kV4FrameData), 5064 framer.ProcessInput(reinterpret_cast<const char*>(kV4FrameData),
5588 arraysize(kV4FrameData)); 5065 arraysize(kV4FrameData));
5589 } 5066 }
5590 EXPECT_EQ(SpdyFramer::SPDY_RESET, framer.state()); 5067 EXPECT_EQ(SpdyFramer::SPDY_RESET, framer.state());
5591 EXPECT_EQ(SpdyFramer::SPDY_NO_ERROR, framer.error_code()) 5068 EXPECT_EQ(SpdyFramer::SPDY_NO_ERROR, framer.error_code())
5592 << SpdyFramer::ErrorCodeToString(framer.error_code()); 5069 << SpdyFramer::ErrorCodeToString(framer.error_code());
5593 } 5070 }
5594 5071
5595 // Tests handling of a GOAWAY frame with out-of-bounds stream ID. 5072 // Tests handling of a GOAWAY frame with out-of-bounds stream ID.
5596 TEST_P(SpdyFramerTest, GoAwayStreamIdBounds) { 5073 TEST_P(SpdyFramerTest, GoAwayStreamIdBounds) {
5597 const unsigned char kV2FrameData[] = {
5598 0x80, spdy_version_ch_, 0x00, 0x07,
5599 0x00, 0x00, 0x00, 0x04,
5600 0xff, 0xff, 0xff, 0xff,
5601 };
5602 const unsigned char kV3FrameData[] = { 5074 const unsigned char kV3FrameData[] = {
5603 0x80, spdy_version_ch_, 0x00, 0x07, 5075 0x80, spdy_version_ch_, 0x00, 0x07,
5604 0x00, 0x00, 0x00, 0x08, 5076 0x00, 0x00, 0x00, 0x08,
5605 0xff, 0xff, 0xff, 0xff, 5077 0xff, 0xff, 0xff, 0xff,
5606 0x00, 0x00, 0x00, 0x00, 5078 0x00, 0x00, 0x00, 0x00,
5607 }; 5079 };
5608 const unsigned char kV4FrameData[] = { 5080 const unsigned char kV4FrameData[] = {
5609 0x00, 0x00, 0x08, 0x07, 5081 0x00, 0x00, 0x08, 0x07,
5610 0x00, 0x00, 0x00, 0x00, 5082 0x00, 0x00, 0x00, 0x00,
5611 0x00, 0xff, 0xff, 0xff, 5083 0x00, 0xff, 0xff, 0xff,
5612 0xff, 0x00, 0x00, 0x00, 5084 0xff, 0x00, 0x00, 0x00,
5613 0x00, 5085 0x00,
5614 }; 5086 };
5615 5087
5616 testing::StrictMock<test::MockSpdyFramerVisitor> visitor; 5088 testing::StrictMock<test::MockSpdyFramerVisitor> visitor;
5617 SpdyFramer framer(spdy_version_); 5089 SpdyFramer framer(spdy_version_);
5618 framer.set_visitor(&visitor); 5090 framer.set_visitor(&visitor);
5619 5091
5620 EXPECT_CALL(visitor, OnGoAway(0x7fffffff, GOAWAY_OK)); 5092 EXPECT_CALL(visitor, OnGoAway(0x7fffffff, GOAWAY_OK));
5621 if (IsSpdy2()) { 5093 if (IsSpdy3()) {
5622 framer.ProcessInput(reinterpret_cast<const char*>(kV2FrameData),
5623 arraysize(kV2FrameData));
5624 } else if (IsSpdy3()) {
5625 framer.ProcessInput(reinterpret_cast<const char*>(kV3FrameData), 5094 framer.ProcessInput(reinterpret_cast<const char*>(kV3FrameData),
5626 arraysize(kV3FrameData)); 5095 arraysize(kV3FrameData));
5627 } else { 5096 } else {
5628 framer.ProcessInput(reinterpret_cast<const char*>(kV4FrameData), 5097 framer.ProcessInput(reinterpret_cast<const char*>(kV4FrameData),
5629 arraysize(kV4FrameData)); 5098 arraysize(kV4FrameData));
5630 } 5099 }
5631 EXPECT_EQ(SpdyFramer::SPDY_RESET, framer.state()); 5100 EXPECT_EQ(SpdyFramer::SPDY_RESET, framer.state());
5632 EXPECT_EQ(SpdyFramer::SPDY_NO_ERROR, framer.error_code()) 5101 EXPECT_EQ(SpdyFramer::SPDY_NO_ERROR, framer.error_code())
5633 << SpdyFramer::ErrorCodeToString(framer.error_code()); 5102 << SpdyFramer::ErrorCodeToString(framer.error_code());
5634 } 5103 }
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
5925 TestSpdyVisitor visitor(spdy_version_); 5394 TestSpdyVisitor visitor(spdy_version_);
5926 visitor.SimulateInFramer(kFrameData, sizeof(kFrameData)); 5395 visitor.SimulateInFramer(kFrameData, sizeof(kFrameData));
5927 5396
5928 EXPECT_EQ(SpdyFramer::SPDY_ERROR, visitor.framer_.state()); 5397 EXPECT_EQ(SpdyFramer::SPDY_ERROR, visitor.framer_.state());
5929 EXPECT_EQ(SpdyFramer::SPDY_INVALID_CONTROL_FRAME, 5398 EXPECT_EQ(SpdyFramer::SPDY_INVALID_CONTROL_FRAME,
5930 visitor.framer_.error_code()) 5399 visitor.framer_.error_code())
5931 << SpdyFramer::ErrorCodeToString(visitor.framer_.error_code()); 5400 << SpdyFramer::ErrorCodeToString(visitor.framer_.error_code());
5932 } 5401 }
5933 5402
5934 } // namespace net 5403 } // namespace net
OLDNEW
« no previous file with comments | « net/spdy/spdy_frame_builder_test.cc ('k') | net/spdy/spdy_headers_block_parser_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698