21 using namespace folly;
29 return parse(codec, inputData, length, atOnce, callbacks.
getStopFn());
33 { 0x80, 0x03, 0x00, 0x01,
34 0x01, 0x00, 0x00, 0x04,
35 0x61, 0x62, 0x63, 0x64
38 TEST(SPDYCodecTest, SPDYVersionSettingsCommonHeaderNameCheck) {
59 TEST(SPDYCodecTest, JunkSPDY) {
60 SPDYCodec codec(TransportDirection::DOWNSTREAM, SPDYVersion::SPDY3);
70 { 0x80, 0x03, 0x00, 0x06,
71 0x00, 0x00, 0x00, 0x05,
72 0x00, 0x00, 0x00, 0x00,
76 TEST(SPDYCodecTest, LongPing) {
77 SPDYCodec codec(TransportDirection::DOWNSTREAM, SPDYVersion::SPDY3);
87 { 0x80, 0x03, 0x00, 0x0A,
88 0x00, 0x00, 0x00, 0x05,
89 0x00, 0x00, 0x00, 0x00,
93 TEST(SPDYCodecTest, BadType) {
96 SPDYCodec codec(TransportDirection::DOWNSTREAM, SPDYVersion::SPDY3);
110 0x80, 0x03, 0x00, 0x01, 0x01, 0x00, 0x04, 0x1a,
111 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
112 0x00, 0x00, 0x38, 0xea, 0xe3, 0xc6, 0xa7, 0xc2,
113 0x02, 0x65, 0x57, 0x50, 0x22, 0xb4, 0xc2, 0x9e,
114 0x20, 0xd9, 0xad, 0x10, 0xa9, 0xd9, 0xdd, 0x35,
115 0x04, 0x94, 0xf1, 0xac, 0xa0, 0x45, 0x87, 0x14,
116 0x30, 0xed, 0xeb, 0x25, 0xa6, 0x15, 0x65, 0xe6,
117 0xa5, 0xe8, 0x15, 0x27, 0xe9, 0xa5, 0x01, 0x8b,
118 0xe9, 0x24, 0x60, 0x42, 0xd5, 0x4b, 0x06, 0x17,
119 0x30, 0xec, 0x56, 0xc5, 0xc0, 0xa2, 0x33, 0x17,
120 0x5c, 0xbe, 0x66, 0x94, 0x94, 0x14, 0x14, 0x83,
121 0xb5, 0x16, 0x24, 0x82, 0x8b, 0x3b, 0x6e, 0x80,
122 0x00, 0xd2, 0x2f, 0x2e, 0x49, 0x2c, 0x29, 0x2d,
123 0xd6, 0x2b, 0xc8, 0x28, 0x00, 0x08, 0x20, 0x94,
124 0x22, 0x80, 0x03, 0x20, 0x80, 0xf2, 0xf2, 0x75,
125 0x93, 0x13, 0x93, 0x33, 0x52, 0x01, 0x02, 0x08,
126 0x5b, 0xe1, 0xcb, 0x01, 0x10, 0x40, 0x79, 0xf9,
127 0xba, 0xc9, 0x89, 0xc9, 0x19, 0xa9, 0x00, 0x01,
128 0x84, 0x52, 0x1b, 0x78, 0x21, 0x42, 0x1f, 0x7b,
129 0x78, 0xa2, 0x85, 0xba, 0x35, 0xc8, 0xd7, 0x96,
130 0xd0, 0x58, 0x29, 0x4f, 0x4d, 0x2a, 0xd0, 0xd1,
131 0xd2, 0xd7, 0x02, 0x0b, 0x5a, 0x00, 0x4d, 0x93,
132 0x84, 0x96, 0x01, 0xba, 0x99, 0x79, 0xc5, 0xa9,
133 0xc9, 0xa5, 0x45, 0xa9, 0xba, 0x45, 0x90, 0x84,
134 0x0b, 0x72, 0x3f, 0x23, 0x40, 0x00, 0x19, 0x02,
135 0x04, 0x10, 0x46, 0xd1, 0x50, 0xee, 0x9b, 0x5f,
136 0x95, 0x99, 0x93, 0x93, 0xa8, 0x6f, 0xaa, 0x67,
137 0xa0, 0xa0, 0xe1, 0x9b, 0x98, 0x9c, 0x99, 0x57,
138 0x92, 0x5f, 0x9c, 0x61, 0x0d, 0x4e, 0xba, 0x39,
139 0xc0, 0x14, 0x97, 0xac, 0xe0, 0x1f, 0xac, 0x10,
140 0xa1, 0x60, 0x68, 0x10, 0x0f, 0x44, 0xa6, 0x9a,
141 0xc0, 0x74, 0x08, 0x4c, 0xb5, 0xe1, 0xa9, 0x49,
142 0xde, 0x99, 0x25, 0xfa, 0xa6, 0xc6, 0xe6, 0x7a,
143 0xc6, 0x66, 0x0a, 0x1a, 0xde, 0x1e, 0x21, 0xbe,
144 0x3e, 0x3a, 0x0a, 0x39, 0x99, 0xd9, 0xa9, 0x0a,
145 0xee, 0xa9, 0xc9, 0xd9, 0xf9, 0x9a, 0x0a, 0xce,
146 0x19, 0xc0, 0x72, 0x3a, 0x55, 0xdf, 0xc4, 0x42,
147 0xcf, 0x40, 0xcf, 0xc8, 0xd4, 0x18, 0x64, 0x7a,
148 0x70, 0x62, 0x5a, 0x62, 0x51, 0x26, 0x54, 0x13,
149 0xf6, 0x4a, 0x4f, 0x18, 0x9c, 0x16, 0x14, 0x60,
150 0x89, 0x41, 0x01, 0x94, 0x1a, 0x90, 0x54, 0x22,
151 0x57, 0x41, 0xa9, 0x79, 0xba, 0xa1, 0xc1, 0xc0,
152 0x34, 0x00, 0xf7, 0x39, 0x1b, 0xac, 0x94, 0x61,
153 0x7a, 0x0c, 0x10, 0x40, 0xb9, 0xf1, 0x25, 0xc5,
154 0xb6, 0x86, 0x26, 0x86, 0x66, 0x96, 0xa6, 0x86,
155 0xe6, 0x06, 0x66, 0xd6, 0x00, 0x01, 0xa4, 0x90,
156 0x92, 0x58, 0x52, 0x64, 0xeb, 0x1b, 0x5f, 0x60,
157 0x10, 0xe6, 0x58, 0x92, 0x15, 0x6e, 0xe9, 0x92,
158 0x57, 0x61, 0xe9, 0x1b, 0x16, 0xe8, 0xe9, 0x13,
159 0xef, 0x98, 0x9d, 0x66, 0x69, 0x0d, 0x10, 0x40,
160 0x0a, 0xf1, 0xe9, 0x89, 0xb6, 0xee, 0x8e, 0x86,
161 0x7a, 0x46, 0x7a, 0x86, 0x46, 0x46, 0x86, 0xe6,
162 0x66, 0x66, 0x16, 0x66, 0x96, 0x7a, 0x86, 0x26,
163 0xc6, 0xc6, 0xe6, 0x96, 0xc6, 0x26, 0x26, 0x26,
164 0xd6, 0x00, 0x01, 0xa4, 0x90, 0x53, 0x6a, 0x1b,
165 0x92, 0xee, 0x53, 0x18, 0x5a, 0xe2, 0x63, 0xee,
166 0xe5, 0x9a, 0xa9, 0xeb, 0xef, 0x5e, 0x98, 0x96,
167 0x14, 0x98, 0xeb, 0xe1, 0x5d, 0x9a, 0x51, 0x6e,
168 0x0d, 0x10, 0x40, 0x0a, 0x15, 0x25, 0x45, 0x79,
169 0xb6, 0x8e, 0x21, 0xa6, 0xc1, 0xc6, 0xc5, 0xba,
170 0x61, 0xa6, 0x7e, 0x49, 0xa5, 0x65, 0x51, 0xa1,
171 0xce, 0x29, 0xc9, 0x8e, 0xd6, 0x00, 0x01, 0x08,
172 0x82, 0x43, 0x23, 0x86, 0x61, 0x20, 0x00, 0x82,
173 0xad, 0x84, 0x1c, 0xf4, 0x8c, 0xfe, 0x5e, 0x8a,
174 0x51, 0x80, 0xa2, 0x4a, 0x6c, 0x68, 0x31, 0xcb,
175 0x24, 0xdd, 0x67, 0xf7, 0x75, 0x44, 0xfc, 0x3e,
176 0xec, 0x5f, 0x74, 0xdd, 0x28, 0xd9, 0x0b, 0x0e,
177 0x74, 0xdd, 0xdb, 0xb3, 0x50, 0xb2, 0x47, 0x8d,
178 0xac, 0x91, 0xb5, 0xb4, 0x30, 0x71, 0xa0, 0xd7,
179 0x44, 0xc9, 0x5e, 0x70, 0xa0, 0xd7, 0xdc, 0x9e,
180 0x85, 0x92, 0x3d, 0x6a, 0xd5, 0xb6, 0xe7, 0xbb,
181 0x94, 0xda, 0x70, 0xa0, 0xf3, 0x44, 0xc9, 0x1e,
182 0x38, 0xd0, 0x79, 0x6e, 0xcf, 0x42, 0xc9, 0x3f,
183 0x41, 0x70, 0x8e, 0x03, 0x20, 0x08, 0x00, 0x01,
184 0xf0, 0x35, 0x5b, 0x9a, 0xb0, 0x07, 0x51, 0x62,
185 0x45, 0xf0, 0x27, 0x34, 0x34, 0x54, 0xfa, 0xff,
186 0x38, 0xd3, 0x99, 0xc4, 0xbe, 0x6a, 0xd8, 0xdc,
187 0xa0, 0x01, 0x69, 0xcd, 0x0d, 0x09, 0xee, 0x05,
188 0x1a, 0x90, 0xd6, 0xdc, 0xc7, 0xf7, 0x42, 0x82,
189 0x3b, 0x43, 0x87, 0x4e, 0xa9, 0x94, 0x71, 0x3e,
190 0xf7, 0x2f, 0x80, 0x14, 0x0a, 0x6c, 0x75, 0x8d,
191 0xac, 0x01, 0x02, 0x48, 0x21, 0xb9, 0x38, 0xd7,
192 0xd6, 0xc8, 0x1a, 0x20, 0x80, 0x14, 0x2a, 0x8a,
193 0x6d, 0x4d, 0x8c, 0x54, 0x8d, 0x1d, 0xb3, 0x8a,
194 0x2c, 0x13, 0x53, 0x7d, 0xb3, 0x2c, 0x3c, 0x75,
195 0x83, 0x93, 0x0b, 0x03, 0x55, 0x8d, 0x1d, 0x8d,
196 0x54, 0x8d, 0x1d, 0x0d, 0x4d, 0x0c, 0x2c, 0x4c,
197 0xcd, 0x2c, 0x4c, 0xcc, 0x0d, 0x55, 0x8d, 0x1d,
198 0x4d, 0x0d, 0x8d, 0x8c, 0xad, 0x01, 0x02, 0x48,
199 0xa1, 0xd8, 0xd6, 0x31, 0xd1, 0xc4, 0xa8, 0xa4,
200 0x28, 0xa2, 0xd2, 0xdd, 0x33, 0xb0, 0x3c, 0xaa,
201 0x2c, 0xd0, 0xdf, 0x3b, 0xbc, 0x5c, 0xcf, 0x29,
202 0xc4, 0x32, 0xb0, 0x32, 0xc2, 0x1a, 0x20, 0x80,
203 0x14, 0xd2, 0x8a, 0x6c, 0x0d, 0x4c, 0xfc, 0x3c,
204 0x93, 0x7c, 0x9c, 0x0a, 0x9d, 0x42, 0x83, 0x53,
205 0xbc, 0x7d, 0xfc, 0x32, 0x83, 0xf5, 0x1c, 0xc3,
206 0x23, 0xfc, 0x33, 0xf3, 0x92, 0x53, 0x33, 0x0c,
207 0x82, 0xcd, 0x4a, 0x3d, 0x92, 0x8b, 0x83, 0x53,
208 0x12, 0x43, 0xe2, 0xbd, 0x4d, 0xe3, 0x33, 0xdd,
209 0xb3, 0xf5, 0x9c, 0x82, 0x8b, 0x4c, 0x72, 0x13,
210 0xf5, 0x5c, 0x0b, 0xf5, 0xdc, 0x22, 0x73, 0xf5,
211 0x0c, 0xf4, 0x1c, 0xc3, 0x43, 0xbd, 0x22, 0x1d,
212 0x5d, 0x52, 0xac, 0x01, 0x02, 0x48, 0x21, 0x39,
213 0xbe, 0xb4, 0x38, 0xb5, 0xc8, 0xd6, 0xd4, 0xc2,
214 0xc0, 0xd4, 0xdc, 0xd4, 0xcc, 0xd0, 0xd0, 0x1a,
215 0x20, 0x80, 0x14, 0x12, 0x93, 0x4b, 0x6c, 0x0d,
216 0x4d, 0x4c, 0x4c, 0x8d, 0x2d, 0x4c, 0x0d, 0x4d,
217 0xcc, 0xcc, 0x0d, 0x2c, 0x54, 0x8d, 0xdc, 0x4c,
218 0xac, 0x01, 0x02, 0x10, 0x04, 0x07, 0x37, 0x08,
219 0xc3, 0x30, 0x00, 0x00, 0x57, 0x61, 0x84, 0xd8,
220 0xb1, 0xc1, 0x79, 0xf0, 0xa8, 0x54, 0x7b, 0x8d,
221 0x8a, 0x16, 0x3f, 0x90, 0xd2, 0x08, 0x25, 0x0e,
222 0x5d, 0x9f, 0xbb, 0xdb, 0xb7, 0xfb, 0xf0, 0x76,
223 0xf8, 0x53, 0xd7, 0x9f, 0x65, 0x8d, 0xcf, 0xe9,
224 0x06, 0x44, 0x9c, 0x85, 0x11, 0x8b, 0xce, 0xe1,
225 0xdd, 0x16, 0x64, 0x49, 0xfc, 0xe0, 0x3b, 0xc0,
226 0x82, 0x3a, 0xe2, 0x15, 0x6e, 0xeb, 0xd8, 0xd1,
227 0x80, 0x88, 0xb3, 0x50, 0x4a, 0x52, 0x72, 0xd1,
228 0x40, 0xdb, 0x78, 0xdf, 0xf8, 0xad, 0xf5, 0x44,
229 0x6b, 0xb3, 0x56, 0x9d, 0x47, 0xa0, 0x01, 0x11,
230 0x67, 0xa1, 0x94, 0xa4, 0x10, 0x68, 0x74, 0x6b,
231 0xb3, 0x56, 0x8d, 0xcb, 0x00, 0xff, 0x04, 0xc1,
232 0x41, 0x0e, 0x80, 0x30, 0x08, 0x04, 0xc0, 0x2f,
233 0x95, 0xc2, 0x42, 0x37, 0x1e, 0xb1, 0xf4, 0x19,
234 0xc6, 0x98, 0x18, 0x8f, 0x1e, 0xfc, 0x7f, 0x9c,
235 0xa1, 0x36, 0xd0, 0xdd, 0xe7, 0xf9, 0x95, 0x98,
236 0x41, 0x87, 0x19, 0xe9, 0x9d, 0xcb, 0x0c, 0x3a,
237 0xd0, 0x3b, 0x23, 0x34, 0xe7, 0xf5, 0xd4, 0xfe,
238 0x1e, 0xb8, 0x31, 0x1a, 0x02, 0x2e, 0x52, 0x02,
239 0x32, 0x73, 0xfb, 0x05, 0x90, 0x42, 0x79, 0x8a,
240 0xad, 0x91, 0x85, 0x89, 0x49, 0x85, 0xa1, 0xa9,
241 0xa9, 0x05, 0x40, 0x00, 0x01, 0x00, 0x00, 0x00,
245 TEST(SPDYCodecTest, SynStreamBoundaries) {
247 SPDYCodec codec(TransportDirection::DOWNSTREAM, SPDYVersion::SPDY3_1);
260 TEST(SPDYCodecTest, SetSettings) {
261 SPDYCodec codec(TransportDirection::DOWNSTREAM, SPDYVersion::SPDY3);
264 settings->
setSetting(SettingsId::_SPDY_DOWNLOAD_BANDWIDTH, 10);
266 settings->
unsetSetting(SettingsId::_SPDY_ROUND_TRIP_TIME);
274 settings->
getSetting(SettingsId::_SPDY_DOWNLOAD_BANDWIDTH)->
value, 10);
276 settings->
unsetSetting(SettingsId::MAX_CONCURRENT_STREAMS);
278 settings->
setSetting(SettingsId::INITIAL_WINDOW_SIZE, 123);
285 settings->
setSetting(SettingsId::MAX_CONCURRENT_STREAMS, 400);
291 TEST(SPDYCodecTest, FrameTooLarge) {
292 SPDYCodec codec(TransportDirection::DOWNSTREAM, SPDYVersion::SPDY3_1);
302 TEST(SPDYCodecTest, FrameUncompressedTooLarge) {
303 SPDYCodec codec(TransportDirection::DOWNSTREAM, SPDYVersion::SPDY3_1);
314 { 0x80, 0x03, 0x00, 0x0B,
315 0x00, 0x00, 0x00, 0x02,
319 TEST(SPDYCodecTest, UnsupportedVersion) {
321 SPDYCodec codec(TransportDirection::DOWNSTREAM, SPDYVersion::SPDY3);
333 TEST(SPDYCodecTest, UnsupportedFrameType) {
334 SPDYCodec codec(TransportDirection::DOWNSTREAM, SPDYVersion::SPDY3);
344 template <
typename Codec>
349 uint32_t assocStreamId = SPDYCodec::NoStream,
353 if (assocStreamId == SPDYCodec::NoStream) {
354 egressCodec.generateHeader(output, streamID, msg, eom,
size);
356 egressCodec.generatePushPromise(output, streamID, msg, assocStreamId, eom,
359 return output.
move();
362 template <
typename Codec>
368 msg.
setURL(
"https://www.foo.com");
373 template <
typename Codec,
typename F,
typename V>
375 Codec ingressCodec(TransportDirection::DOWNSTREAM, version);
376 Codec egressCodec(TransportDirection::UPSTREAM, version);
377 f(ingressCodec, egressCodec);
380 #define copyForMe(F, C, V) callFunction<C>(F<C, C>, \ 383 #define permuteTest(f) copyForMe(f, SPDYCodec, SPDY3); \ 384 copyForMe(f, SPDYCodec, SPDY3_1); 398 template <
typename Codec1,
typename Codec2>
403 ingressCodec.getEgressSettings()->setSetting(
404 SettingsId::MAX_CONCURRENT_STREAMS, parallel);
406 ingressCodec.setCallback(&callbacks);
412 ingressCodec.onIngress(*toParse);
418 template <
typename Codec1,
typename Codec2>
423 template <
typename Codec1,
typename Codec2>
428 TEST(SPDYCodecTest, DefaultMaxTransactions) {
432 TEST(SPDYCodecTest, NonDefaultMaxTransactions) {
436 template <
typename Codec1,
typename Codec2>
439 bool emptyAllowed = version != 2;
441 ingressCodec.setCallback(&callbacks);
444 toSend.
setURL(
"http://www.foo.com");
448 headers.set(
"X-Test1",
"yup");
453 for (
auto i = 0;
i < 3;
i++) {
455 toSend, 0,
false, &size);
456 ingressCodec.onIngress(*toParse);
461 const auto& parsed = callbacks.
msg->getHeaders();
462 EXPECT_EQ(parsed.exists(
"Pragma"), emptyAllowed);
463 EXPECT_EQ(parsed.exists(
"pragma"), emptyAllowed);
464 EXPECT_EQ(parsed.getSingleOrEmpty(
"Pragma"), pragmaValue);
465 EXPECT_EQ(parsed.getSingleOrEmpty(
"X-Test1"),
"yup");
467 EXPECT_EQ(parsed.exists(
"accept-encoding"),
true);
471 EXPECT_EQ(callbacks.
msg->getURL(),
"http://www.foo.com");
472 EXPECT_EQ(parsed.size(), emptyAllowed ? 4 : 3);
477 headers.add(
"Pragma",
"");
481 headers.add(
"Pragma", pragmaValue);
487 TEST(SPDYCodecTest, EmptyHeaderValue) {
497 TEST(SPDYCodecTest, SynStreamWrongVersion) {
498 SPDYCodec codec(TransportDirection::DOWNSTREAM, SPDYVersion::SPDY3);
501 size_t unconsumed =
parseSPDY(&codec, frame->data(), frame->length(), -1,
516 { 0x80, 0x02, 0x00, 0x02, 0x01, 0x00, 0x00, 0x04,
517 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
520 template <
typename Codec1,
typename Codec2>
523 egressCodec.setCallback(&callbacks);
525 egressCodec.getVersion());
526 egressCodec.onIngress(*frame);
531 TEST(SPDYCodecTest, ShortSynReply) {
535 TEST(SPDYCodecTest, SupportsSessionFlowControl) {
536 SPDYCodec spdy3(TransportDirection::UPSTREAM,
538 SPDYCodec spdy3_1(TransportDirection::UPSTREAM,
539 SPDYVersion::SPDY3_1);
545 TEST(SPDYCodecTest, HeaderWithManyValues) {
547 const unsigned kNumValues = 1000;
550 SPDYCodec egressCodec(TransportDirection::UPSTREAM,
552 SPDYCodec ingressCodec(TransportDirection::DOWNSTREAM,
559 req.
setURL(
"https://www.foo.com");
560 for (
unsigned i = 0;
i < kNumValues; ++
i) {
561 req.
getHeaders().
add(kMultiValued, folly::to<string>(
"Value",
i));
570 CHECK_NOTNULL(callbacks.
msg.get());
571 EXPECT_EQ(callbacks.
msg->getHeaders().getNumberOfValues(kMultiValued),
577 {0x80, 0x03, 0x00, 0x01, 0x01, 0x00, 0x01, 0x13, 0x00, 0x00, 0x00, 0x01,
578 0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 0x38, 0x30, 0xe3, 0xc6, 0xa7, 0xc2,
579 0x00, 0xf9, 0x00, 0x06, 0xff, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
580 0x05, 0x3a, 0x68, 0x6f, 0x73, 0x74, 0x00, 0x00, 0x00, 0x10, 0x77, 0x77,
581 0x77, 0x2e, 0x66, 0x61, 0x63, 0x65, 0x62, 0x6f, 0x6f, 0x6b, 0x2e, 0x63,
582 0x6f, 0x6d, 0x00, 0x00, 0x00, 0x07, 0x3a, 0x6d, 0x65, 0x74, 0x68, 0x6f,
583 0x64, 0x00, 0x00, 0x00, 0x03, 0x47, 0x45, 0x54, 0x00, 0x00, 0x00, 0x05,
584 0x3a, 0x70, 0x61, 0x74, 0x68, 0x00, 0x00, 0x00, 0x35, 0x2f, 0x65, 0x6e,
585 0x63, 0x72, 0x79, 0x70, 0x74, 0x65, 0x64, 0x72, 0x65, 0x71, 0x75, 0x65,
586 0x73, 0x74, 0x00, 0x2a, 0x23, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e,
587 0x2f, 0x61, 0x67, 0x65, 0x6e, 0x74, 0x2f, 0x73, 0x69, 0x74, 0x65, 0x5f,
588 0x76, 0x61, 0x72, 0x69, 0x61, 0x62, 0x6c, 0x65, 0x73, 0x2e, 0x70, 0x68,
589 0x70, 0x3f, 0x00, 0x00, 0x00, 0x07, 0x3a, 0x73, 0x63, 0x68, 0x65, 0x6d,
590 0x65, 0x00, 0x00, 0x00, 0x05, 0x68, 0x74, 0x74, 0x70, 0x73, 0x00, 0x00,
591 0x00, 0x08, 0x3a, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x00, 0x00,
592 0x00, 0x08, 0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x31, 0x00, 0x00,
593 0x00, 0x06, 0x61, 0x63, 0x63, 0x65, 0x70, 0x74, 0x00, 0x00, 0x00, 0x03,
594 0x2a, 0x2f, 0x2a, 0x00, 0x00, 0x00, 0x0f, 0x61, 0x63, 0x63, 0x65, 0x70,
595 0x74, 0x2d, 0x65, 0x6e, 0x63, 0x6f, 0x64, 0x69, 0x6e, 0x67, 0x00, 0x00,
596 0x00, 0x0d, 0x67, 0x7a, 0x69, 0x70, 0x2c, 0x20, 0x64, 0x65, 0x66, 0x6c,
597 0x61, 0x74, 0x65, 0x00, 0x00, 0x00, 0x0a, 0x75, 0x73, 0x65, 0x72, 0x2d,
598 0x61, 0x67, 0x65, 0x6e, 0x74, 0x00, 0x00, 0x00, 0x11, 0x73, 0x70, 0x64,
599 0x79, 0x6c, 0x61, 0x79, 0x2f, 0x31, 0x2e, 0x33, 0x2e, 0x33, 0x2d, 0x44,
600 0x45, 0x56, 0x00, 0x00, 0x00, 0xff, 0xff, 0x80, 0x03, 0x00, 0x07, 0x00,
601 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
604 TEST(SPDYCodecTest, MultiplePaths) {
606 SPDYCodec ingressCodec(TransportDirection::DOWNSTREAM, SPDYVersion::SPDY3);
615 TEST(SPDYCodecTest, LargeFrameEncoding) {
617 const unsigned kNumValues = 1000;
619 SPDYCodec codec(TransportDirection::UPSTREAM, SPDYVersion::SPDY3);
625 for (
unsigned i = 0;
i < kNumValues; ++
i) {
626 req.getHeaders().add(kMultiValued, folly::to<string>(
"Value",
i));
632 TEST(SPDYCodecTest, InvalidSettings) {
635 SPDYCodec egressCodec(TransportDirection::UPSTREAM,
637 SPDYCodec ingressCodec(TransportDirection::DOWNSTREAM,
643 SettingsId::INITIAL_WINDOW_SIZE,
646 auto ingress = output.
move();
655 TEST(SPDYCodecTest, HeaderWithFin) {
657 SPDYCodec egressCodec(TransportDirection::UPSTREAM,
659 SPDYCodec ingressCodec(TransportDirection::DOWNSTREAM,
666 req.
setURL(
"https://www.foo.com/");
677 TEST(SPDYCodecTest, ServerPush) {
679 SPDYCodec egressCodec(TransportDirection::DOWNSTREAM,
681 SPDYCodec ingressCodec(TransportDirection::UPSTREAM,
687 push.
setURL(
"https://www.foo.com/");
698 TEST(SPDYCodecTest, ServerPushWithStatus) {
700 SPDYCodec egressCodec(TransportDirection::DOWNSTREAM,
702 SPDYCodec ingressCodec(TransportDirection::UPSTREAM,
708 push.
setURL(
"https://www.foo.com/");
725 { 0x80, 0x3, 0x0, 0x1, 0x2, 0x0, 0x0, 0x7c,
726 0x0, 0x0, 0x0, 0x2, 0x0, 0x0, 0x0, 0x1,
727 0x0, 0x0, 0x38, 0x30, 0xe3, 0xc6, 0xa7, 0xc2,
728 0x0, 0x62, 0x0, 0x9d, 0xff, 0x0, 0x0, 0x0,
729 0x4, 0x0, 0x0, 0x0, 0x5, 0x3a, 0x70, 0x61,
730 0x74, 0x68, 0x0, 0x0, 0x0, 0x14, 0x68, 0x74,
731 0x74, 0x70, 0x73, 0x3a, 0x2f, 0x2f, 0x77, 0x77,
732 0x77, 0x2e, 0x66, 0x6f, 0x6f, 0x2e, 0x63, 0x6f,
733 0x6d, 0x2f, 0x0, 0x0, 0x0, 0x7, 0x3a, 0x73,
734 0x63, 0x68, 0x65, 0x6d, 0x65, 0x0, 0x0, 0x0,
735 0x4, 0x68, 0x74, 0x74, 0x70, 0x0, 0x0, 0x0,
736 0x7, 0x3a, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73,
737 0x0, 0x0, 0x0, 0x3, 0x32, 0x30, 0x30, 0x0,
738 0x0, 0x0, 0x8, 0x3a, 0x76, 0x65, 0x72, 0x73,
739 0x69, 0x6f, 0x6e, 0x0, 0x0, 0x0, 0x8, 0x48,
740 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x31, 0x0,
744 TEST(SPDYCodecTest, ServerPushHostMissing) {
746 SPDYCodec ingressCodec(TransportDirection::UPSTREAM,
765 { 0x80, 0x03, 0x00, 0x01, 0x02, 0x00, 0x00, 0x91,
766 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01,
767 0x00, 0x00, 0x38, 0x30, 0xe3, 0xc6, 0xa7, 0xc2,
768 0x00, 0x77, 0x00, 0x88, 0xff, 0x00, 0x00, 0x00,
769 0x05, 0x00, 0x00, 0x00, 0x05, 0x3a, 0x68, 0x6f,
770 0x73, 0x74, 0x00, 0x00, 0x00, 0x0b, 0x77, 0x77,
771 0x77, 0x2e, 0x66, 0x6f, 0x6f, 0x2e, 0x63, 0x6f,
772 0x6d, 0x00, 0x00, 0x00, 0x07, 0x3a, 0x6d, 0x65,
773 0x74, 0x68, 0x6f, 0x64, 0x00, 0x00, 0x00, 0x00,
774 0x00, 0x00, 0x00, 0x05, 0x3a, 0x70, 0x61, 0x74,
775 0x68, 0x00, 0x00, 0x00, 0x14, 0x68, 0x74, 0x74,
776 0x70, 0x73, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77,
777 0x2e, 0x66, 0x6f, 0x6f, 0x2e, 0x63, 0x6f, 0x6d,
778 0x2f, 0x00, 0x00, 0x00, 0x07, 0x3a, 0x73, 0x63,
779 0x68, 0x65, 0x6d, 0x65, 0x00, 0x00, 0x00, 0x04,
780 0x68, 0x74, 0x74, 0x70, 0x00, 0x00, 0x00, 0x08,
781 0x3a, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e,
782 0x00, 0x00, 0x00, 0x08, 0x48, 0x54, 0x54, 0x50,
783 0x2f, 0x31, 0x2e, 0x31, 0x00, 0x00, 0x00, 0xff,
787 TEST(SPDYCodecTest, ServerPushInvalidId) {
789 SPDYCodec ingressCodec(TransportDirection::UPSTREAM,
808 { 0x80, 0x03, 0x00, 0x01, 0x00, 0x00, 0x00, 0x91,
809 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01,
810 0x00, 0x00, 0x38, 0x30, 0xe3, 0xc6, 0xa7, 0xc2,
811 0x00, 0x77, 0x00, 0x88, 0xff, 0x00, 0x00, 0x00,
812 0x05, 0x00, 0x00, 0x00, 0x05, 0x3a, 0x68, 0x6f,
813 0x73, 0x74, 0x00, 0x00, 0x00, 0x0b, 0x77, 0x77,
814 0x77, 0x2e, 0x66, 0x6f, 0x6f, 0x2e, 0x63, 0x6f,
815 0x6d, 0x00, 0x00, 0x00, 0x07, 0x3a, 0x6d, 0x65,
816 0x74, 0x68, 0x6f, 0x64, 0x00, 0x00, 0x00, 0x00,
817 0x00, 0x00, 0x00, 0x05, 0x3a, 0x70, 0x61, 0x74,
818 0x68, 0x00, 0x00, 0x00, 0x14, 0x68, 0x74, 0x74,
819 0x70, 0x73, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77,
820 0x2e, 0x66, 0x6f, 0x6f, 0x2e, 0x63, 0x6f, 0x6d,
821 0x2f, 0x00, 0x00, 0x00, 0x07, 0x3a, 0x73, 0x63,
822 0x68, 0x65, 0x6d, 0x65, 0x00, 0x00, 0x00, 0x04,
823 0x68, 0x74, 0x74, 0x70, 0x00, 0x00, 0x00, 0x08,
824 0x3a, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e,
825 0x00, 0x00, 0x00, 0x08, 0x48, 0x54, 0x54, 0x50,
826 0x2f, 0x31, 0x2e, 0x31, 0x00, 0x00, 0x00, 0xff,
830 TEST(SPDYCodecTest, ServerPushInvalidFlags) {
832 SPDYCodec ingressCodec(TransportDirection::UPSTREAM,
851 { 0x80, 0x03, 0x00, 0x01, 0x02, 0x00, 0x00, 0x91,
852 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00,
853 0x00, 0x00, 0x38, 0x30, 0xe3, 0xc6, 0xa7, 0xc2,
854 0x00, 0x77, 0x00, 0x88, 0xff, 0x00, 0x00, 0x00,
855 0x05, 0x00, 0x00, 0x00, 0x05, 0x3a, 0x68, 0x6f,
856 0x73, 0x74, 0x00, 0x00, 0x00, 0x0b, 0x77, 0x77,
857 0x77, 0x2e, 0x66, 0x6f, 0x6f, 0x2e, 0x63, 0x6f,
858 0x6d, 0x00, 0x00, 0x00, 0x07, 0x3a, 0x6d, 0x65,
859 0x74, 0x68, 0x6f, 0x64, 0x00, 0x00, 0x00, 0x00,
860 0x00, 0x00, 0x00, 0x05, 0x3a, 0x70, 0x61, 0x74,
861 0x68, 0x00, 0x00, 0x00, 0x14, 0x68, 0x74, 0x74,
862 0x70, 0x73, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77,
863 0x2e, 0x66, 0x6f, 0x6f, 0x2e, 0x63, 0x6f, 0x6d,
864 0x2f, 0x00, 0x00, 0x00, 0x07, 0x3a, 0x73, 0x63,
865 0x68, 0x65, 0x6d, 0x65, 0x00, 0x00, 0x00, 0x04,
866 0x68, 0x74, 0x74, 0x70, 0x00, 0x00, 0x00, 0x08,
867 0x3a, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e,
868 0x00, 0x00, 0x00, 0x08, 0x48, 0x54, 0x54, 0x50,
869 0x2f, 0x31, 0x2e, 0x31, 0x00, 0x00, 0x00, 0xff,
873 TEST(SPDYCodecTest, ServerPushWithoutAssoc) {
875 SPDYCodec ingressCodec(TransportDirection::UPSTREAM,
890 TEST(SPDYCodecTest, StatusReason) {
892 SPDYCodec egressCodec(TransportDirection::DOWNSTREAM,
894 SPDYCodec ingressCodec(TransportDirection::UPSTREAM,
921 EXPECT_EQ(callbacks.
msg->getStatusMessage(),
"Awesome");
954 TEST(SPDYCodecTest, UpstreamPing) {
957 SPDYCodec egressCodec(TransportDirection::UPSTREAM,
959 SPDYCodec ingressCodec(TransportDirection::DOWNSTREAM,
965 auto pingReply = buf.
move();
970 for (
unsigned i = 0;
i < 10; ++
i) {
972 auto pingReq = buf.
move();
980 TEST(SPDYCodecTest, DownstreamPing) {
983 SPDYCodec egressCodec(TransportDirection::DOWNSTREAM,
985 SPDYCodec ingressCodec(TransportDirection::UPSTREAM,
991 auto pingReply = buf.
move();
996 for (
unsigned i = 0;
i < 10; ++
i) {
998 auto pingReq = buf.
move();
1008 SPDYCodec egressCodec(TransportDirection::DOWNSTREAM,
1009 SPDYVersion::SPDY3);
1010 SPDYCodec ingressCodec(TransportDirection::UPSTREAM,
1011 SPDYVersion::SPDY3);
1028 { 0x80, 0x03, 0x00, 0x01, 0x01, 0x00, 0x02, 0x11,
1029 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
1030 0x60, 0x00, 0x38, 0xea, 0xe3, 0xc6, 0xa7, 0xc2,
1031 0xec, 0xd4, 0x31, 0x0e, 0x82, 0x40, 0x10, 0x46,
1032 0x61, 0x8c, 0x85, 0x1a, 0x43, 0x6f, 0x69, 0x4d,
1033 0x31, 0x24, 0xda, 0x6d, 0x4f, 0xb8, 0x80, 0x17,
1034 0x00, 0x8d, 0xa1, 0xd0, 0x30, 0xc9, 0x6e, 0x01,
1035 0x57, 0xb7, 0x72, 0x18, 0x49, 0x28, 0xe4, 0x08,
1036 0xef, 0xab, 0x61, 0x93, 0x4d, 0xfe, 0x7d, 0xb6,
1037 0xa3, 0xc3, 0xf4, 0x9c, 0xc2, 0x1c, 0x84, 0x93,
1038 0x2d, 0x5a, 0xfa, 0x94, 0x7a, 0x89, 0xad, 0x3c,
1039 0x2d, 0xbd, 0xad, 0x8d, 0x4f, 0xee, 0x1e, 0x8d,
1040 0x5d, 0x58, 0xa6, 0x5d, 0x57, 0x37, 0xff, 0x4d,
1041 0x1b, 0x0f, 0xd8, 0xb1, 0xfc, 0x8d, 0x5c, 0xb4,
1042 0x53, 0xff, 0x32, 0x5a, 0x38, 0xdf, 0x5e, 0xd7,
1043 0x2e, 0x25, 0x9d, 0xc6, 0xbf, 0x0f, 0xeb, 0x9b,
1044 0x5f, 0xc2, 0xbe, 0x2d, 0xca, 0x62, 0xbd, 0xe6,
1045 0xb9, 0x5f, 0xf2, 0x3c, 0xdf, 0xf2, 0xef, 0x81,
1046 0xe6, 0x51, 0x1f, 0xe3, 0xab, 0x19, 0xed, 0xc4,
1047 0x8b, 0x5c, 0xb3, 0xcd, 0x27, 0x1b, 0x00, 0x00,
1048 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1049 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8,
1050 0xb2, 0x07, 0x07, 0x02, 0x00, 0x00, 0x00, 0x00,
1051 0x40, 0xfe, 0xaf, 0x8d, 0xa0, 0xaa, 0xaa, 0xaa,
1052 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1053 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1054 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1055 0xaa, 0xaa, 0xaa, 0xaa, 0xc2, 0x1e, 0x1c, 0x08,
1056 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xbf, 0x36,
1057 0x82, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1058 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1059 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1060 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1061 0x0a, 0x7b, 0x70, 0x20, 0x00, 0x00, 0x00, 0x00,
1062 0x00, 0xe4, 0xff, 0xda, 0x08, 0xaa, 0xaa, 0xaa,
1063 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1064 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1065 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1066 0xaa, 0xaa, 0xaa, 0xaa, 0x2a, 0xec, 0xc1, 0x41,
1067 0x01, 0x00, 0x00, 0x04, 0x04, 0xb0, 0x53, 0x47,
1068 0x3f, 0xe5, 0xbd, 0x14, 0x10, 0x61, 0x1b, 0x00,
1069 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1070 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1071 0x00, 0xf0, 0x48, 0x6d, 0x7a, 0xa2, 0xaa, 0xaa,
1072 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1073 0x7a, 0xec, 0xc2, 0x01, 0x09, 0x00, 0x00, 0x00,
1074 0x00, 0x90, 0xff, 0xaf, 0x1d, 0x11, 0x55, 0x55,
1075 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
1076 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
1077 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
1078 0x55, 0x55, 0x55, 0x55, 0x55, 0x15, 0x76, 0xe1,
1079 0x80, 0x04, 0x00, 0x00, 0x00, 0x00, 0xc8, 0xff,
1080 0xd7, 0x8e, 0x88, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1081 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1082 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1083 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1084 0xaa, 0xaa, 0x0a, 0xbb, 0x70, 0x40, 0x02, 0x00,
1085 0x00, 0x00, 0x00, 0xe4, 0xff, 0x6b, 0x47, 0x44,
1086 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
1087 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
1088 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
1089 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x85,
1090 0x5d, 0x38, 0xa6, 0x01, 0x00, 0x00, 0x60, 0x18,
1091 0xe4, 0x67, 0xfe, 0x05, 0xf6, 0x9f, 0x06, 0x02,
1092 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1093 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1094 0x00, 0x00, 0x00, 0xbc, 0x05, 0x00, 0x00, 0xff,
1102 SPDYCodec ingressCodec(TransportDirection::UPSTREAM,
1103 SPDYVersion::SPDY3);
1119 TEST(SPDYCodecTest, DoubleGoawayServer) {
1121 SPDYCodec egressCodec(TransportDirection::DOWNSTREAM,
1122 SPDYVersion::SPDY3);
1123 SPDYCodec ingressCodec(TransportDirection::UPSTREAM,
1124 SPDYVersion::SPDY3);
1134 auto ingress = output.
move();
1153 TEST(SPDYCodecTest, DoubleGoawayClient) {
1155 SPDYCodec egressCodec(TransportDirection::UPSTREAM,
1156 SPDYVersion::SPDY3);
1157 SPDYCodec ingressCodec(TransportDirection::DOWNSTREAM,
1158 SPDYVersion::SPDY3);
1168 auto ingress = output.
move();
1189 TEST(SPDYCodecTest, SingleGoawayClient) {
1191 SPDYCodec egressCodec(TransportDirection::UPSTREAM,
1192 SPDYVersion::SPDY3);
1193 SPDYCodec ingressCodec(TransportDirection::DOWNSTREAM,
1194 SPDYVersion::SPDY3);
1203 auto ingress = output.
move();
1223 { 0x80, 0x03, 0x00, 0x02, 0xc4, 0x00, 0x00, 0x14,
1224 0xf7, 0x76, 0x2d, 0x37, 0x78, 0x9c, 0x93, 0x60,
1225 0x00, 0x03, 0x75, 0x06, 0xbd, 0x76, 0x21, 0xb2,
1226 0xd0, 0xd9, 0x54, 0x91, 0x80, 0x03, 0x00, 0x01,
1227 0x4e, 0x00, 0x00, 0x0a, 0xbe, 0x14, 0x31, 0x55,
1228 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1235 TEST(SPDYCodecTest, OddHeaderListTest) {
1237 SPDYCodec ingressCodec(TransportDirection::DOWNSTREAM,
1238 SPDYVersion::SPDY3);
1252 TEST(SPDYCodecTest, SendRstParsingFrame) {
1254 SPDYCodec egressCodec(TransportDirection::UPSTREAM,
1255 SPDYVersion::SPDY3_1);
1256 SPDYCodec ingressCodec(TransportDirection::DOWNSTREAM,
1257 SPDYVersion::SPDY3_1);
1266 1, ErrorCode::CANCEL);
1268 EXPECT_CALL(callbacks, onMessageComplete(3,
false));
1274 auto ingress = egressCodecQueue.
move();
1275 ingress->coalesce();
1280 0x80, 0x03, 0x00, 0x01, 0x00, 0x00, 0x00, 0x91,
1281 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01,
1282 0x00, 0x00, 0x38, 0x30, 0xe3, 0xc6, 0xa7, 0xc2,
1283 0x00, 0x77, 0x00, 0x88, 0xff, 0x00, 0x00, 0x00,
1284 0x05, 0x00, 0x00, 0x00, 0x05, 0x3a, 0x68, 0x6f,
1285 0x73, 0x74, 0x00, 0x00, 0x00, 0x0b, 0x77, 0x77,
1286 0x77, 0x2e, 0x66, 0x6f, 0x6f, 0x2e, 0x63, 0x6f,
1287 0x6d, 0x00, 0x00, 0x00, 0x77, 0x3a, 0x6d, 0x65,
1288 0x74, 0x68, 0x6f, 0x64, 0x00, 0x00, 0x00, 0x00,
1289 0x00, 0x00, 0x00, 0x05, 0x3a, 0x70, 0x61, 0x74,
1290 0x68, 0x00, 0x13, 0x00, 0x14, 0x68, 0x74, 0x74,
1291 0x39, 0x73, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77,
1292 0x2e, 0x66, 0x6f, 0x6f, 0x2e, 0x63, 0x6f, 0x6d,
1293 0x2f, 0x00, 0x00, 0x00, 0x07, 0x3a, 0x73, 0x63,
1294 0x68, 0x65, 0x6d, 0x65, 0x00, 0x00, 0x00, 0x04,
1295 0x68, 0x74, 0x74, 0x70, 0x00, 0x00, 0x00, 0x08,
1296 0x3a, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e,
1297 0x00, 0x00, 0x00, 0x08, 0x48, 0x54, 0x54, 0x50,
1298 0x2f, 0x31, 0x2e, 0x31, 0x00, 0x00, 0x00, 0xff,
1303 TEST(SPDYCodecTest, BadNumNameValues) {
1305 SPDYCodec ingressCodec(TransportDirection::DOWNSTREAM,
1306 SPDYVersion::SPDY3_1);
1320 0x80, 0x03, 0x00, 0x04, 0xee, 0x00, 0x00, 0x01, 0x00, 0x00
1323 TEST(SPDYCodecTest, ShortSettings) {
1325 SPDYCodec ingressCodec(TransportDirection::DOWNSTREAM,
1326 SPDYVersion::SPDY3_1);
1339 TEST(SPDYCodecTest, SegmentedHeaderBlock) {
1340 SPDYCodec egressCodec(TransportDirection::UPSTREAM,
1341 SPDYVersion::SPDY3_1);
1342 SPDYCodec ingressCodec(TransportDirection::DOWNSTREAM,
1343 SPDYVersion::SPDY3_1);
1358 req.
setURL(
"http://www.facebook.com");
1360 reqHeaders.
set(
"HOST",
"www.facebook.com");
1362 reqHeaders.set(
"X-FB-Huge", huge);
1370 EXPECT_EQ(callbacks.
msg->getHeaders().getSingleOrEmpty(
"x-fb-huge").size(),
1376 resp.setStatusMessage(
"OK");
1377 auto& respHeaders = resp.getHeaders();
1378 respHeaders.set(
"X-FB-Huge", huge);
1386 EXPECT_EQ(callbacks.
msg->getHeaders().getSingleOrEmpty(
"x-fb-huge").size(),
1391 0x80, 0x03, 0x00, 0x01, 0x48, 0x00, 0x00, 0x1a, 0xf6, 0xf6, 0x1a, 0xb5,
1392 0x00, 0x00, 0x00, 0x00, 0x17, 0x28, 0x28, 0x53, 0x62, 0x60, 0x60, 0x10,
1393 0x60, 0x60, 0x60, 0x60, 0xb4, 0x1a, 0xbc, 0x84, 0xa4, 0xa4
1397 TEST(SPDYCodecTest, ColonHeaders) {
1399 SPDYCodec ingressCodec(TransportDirection::DOWNSTREAM,
1400 SPDYVersion::SPDY3_1);
1412 TEST(SPDYCodecTest, StreamIdOverflow) {
1414 SPDYVersion::SPDY3_1);
1425 0x80, 0x03, 0x00, 0x01, 0x00, 0x00, 0x00, 0x1c,
1426 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
1427 0x00, 0x00, 0x78, 0xbb, 0xe3, 0xc6, 0xa7, 0xc2,
1428 0x02, 0xa6, 0x23, 0xc6, 0xff, 0x40, 0x00, 0x00,
1429 0x00, 0x00, 0xff, 0xff
1437 SPDYCodec ingressCodec(TransportDirection::DOWNSTREAM,
1438 SPDYVersion::SPDY3_1);
1455 SPDYCodec upstreamCodec_{TransportDirection::UPSTREAM, SPDYVersion::SPDY3_1};
1457 SPDYVersion::SPDY3_1};
1465 upstreamCodec_.generateHeader(output_, 1, req,
true, &size);
1468 callbacks_.expectMessage(
true, 2,
"/");
1471 SetUpUpstreamTest();
1473 downstreamCodec_.generateGoaway(output_, 1, ErrorCode::NO_ERROR);
1476 upstreamCodec_.generateHeader(output_, 3, req,
false, &size);
1478 upstreamCodec_.generateWindowUpdate(output_, 3, 100);
1479 upstreamCodec_.generateBody(output_, 3,
makeBuf(10), HTTPCodec::NoPadding,
1481 upstreamCodec_.generatePriority(output_, 3,
1483 upstreamCodec_.generateEOM(output_, 3);
1484 upstreamCodec_.generateRstStream(output_, 3, ErrorCode::CANCEL);
1490 downstreamCodec_.generatePushPromise(output_, 2, req, 1,
false, &size);
1493 downstreamCodec_.generateWindowUpdate(output_, 2, 100);
1494 downstreamCodec_.generateBody(output_, 2,
makeBuf(10), HTTPCodec::NoPadding,
1499 upstreamCodec_.generateGoaway(
dummy, 0, ErrorCode::NO_ERROR);
1502 downstreamCodec_.generatePriority(output_, 2,
1504 downstreamCodec_.generateEOM(output_, 2);
1505 downstreamCodec_.generateRstStream(output_, 2, ErrorCode::CANCEL);
1510 downstreamCodec_.generateHeader(output_, 1, resp,
true, &size);
1515 callbacks_.expectMessage(
true, 1, 200);
size_t parse(const char *buf, size_t len)
uint8_t multiValuedHeaderAttack[]
#define ASSERT_GT(val1, val2)
size_t onIngress(const folly::IOBuf &buf) override
uint8_t pushStreamWithHostMissing[]
void setCallback(Callback *callback) override
uint8_t invalidNumNameValuesBlock[]
HTTPCodec::StreamID assocStreamId
void append(std::unique_ptr< folly::IOBuf > &&buf, bool pack=false)
const uint32_t kInitialWindow
uint8_t multiple_path_headers[]
unique_ptr< folly::IOBuf > getVersionedSpdyFrame(const uint8_t *bytes, size_t len, uint8_t version)
void maxTransactionHelper(Codec1 &ingressCodec, Codec2 &egressCodec, uint32_t parallel)
uint8_t getVersion() const
#define ASSERT_EQ(val1, val2)
std::unique_ptr< HTTPException > lastParseError
void setStatusMessage(T &&msg)
#define EXPECT_EQ(val1, val2)
constexpr detail::Map< Move > move
const std::string kNamePathv3
void setMaxFrameLength(uint32_t maxFrameLength)
void doShortSynReplyTest(Codec1 &, Codec2 &egressCodec)
std::function< bool()> getStopFn()
void setNextEgressStreamId(StreamID nextEgressStreamID)
std::unique_ptr< folly::IOBuf > move()
bool supportsSessionFlowControl() const override
static http_parser_settings settings
size_t generateRstStream(folly::IOBufQueue &writeBuf, StreamID txn, ErrorCode statusCode) override
—— Concurrent Priority Queue Implementation ——
PolymorphicAction< internal::InvokeWithoutArgsAction< FunctionImpl > > InvokeWithoutArgs(FunctionImpl function_impl)
bool isReusable() const override
void setPushStatusCode(const uint16_t status)
uint8_t pushStreamWithoutAssoc[]
std::size_t getNumSettings() const
std::unique_ptr< folly::IOBuf > makeBuf(uint32_t size)
size_t generatePingReply(folly::IOBufQueue &writeBuf, uint64_t uniqueID) override
size_t generateEOM(folly::IOBufQueue &writeBuf, StreamID stream) override
constexpr auto size(C const &c) -> decltype(c.size())
static Options cacheChainLength()
HTTPSettings * getEgressSettings() override
constexpr auto data(C &c) -> decltype(c.data())
const std::string kNameMethodv3
void doEmptyHeaderValueTest(Codec1 &ingressCodec, Codec2 &egressCodec)
const std::string kNameVersionv3
uint8_t pushStreamWithoutUnidirectional[]
Parallel parallel(Ops ops, size_t threads=0)
StreamID createStream() override
size_t parseSPDY(SPDYCodec *codec, const uint8_t *inputData, uint32_t length, int32_t atOnce, FakeHTTPCodecCallback &callbacks)
HTTPHeaders & getHeaders()
const std::string kNameHostv3
void doNonDefaultMaxTransactionTest(Codec1 &ingressCodec, Codec2 &egressCodec)
TEST_F(AsyncSSLSocketWriteTest, write_coalescing1)
void enableDoubleGoawayDrain() override
void setMethod(HTTPMethod method)
std::tuple< uint32_t, bool, uint8_t > HTTPPriority
const std::string kNameStatusv3
#define EXPECT_TRUE(condition)
unique_ptr< folly::IOBuf > getSynStream(Codec &egressCodec, uint32_t streamID, const HTTPMessage &msg, uint32_t assocStreamId=SPDYCodec::NoStream, bool eom=false, HTTPHeaderSize *size=nullptr)
uint8_t spdy3UnknownCtlFrame[]
HTTPMessage getGetRequest(const std::string &url)
void unsetSetting(SettingsId id)
const std::string kNameSchemev3
bool isWaitingToDrain() const override
#define EXPECT_CALL(obj, call)
const internal::AnythingMatcher _
uint8_t pushStreamWithOddId[]
#define ASSERT_NE(val1, val2)
void callFunction(F f, V version)
#define EXPECT_FALSE(condition)
const uint8_t kBufBadNVBlock[]
std::unique_ptr< HTTPMessage > msg
const uint8_t kShortSettings[]
void doDefaultMaxTransactionTest(Codec1 &ingressCodec, Codec2 &egressCodec)
const uint32_t kMaxConcurrentStreams
size_t generateSettings(folly::IOBufQueue &writeBuf) override
static std::unique_ptr< IOBuf > copyBuffer(const void *buf, std::size_t size, std::size_t headroom=0, std::size_t minTailroom=0)
size_t generatePingRequest(folly::IOBufQueue &writeBuf) override
TEST(SequencedExecutor, CPUThreadPoolExecutor)
uint8_t invalidHeaderPlusEmptyBlock[]
ErrorCode rstToErrorCode(uint32_t code)
const uint8_t kColonHeaders[]
const HTTPSetting * getSetting(SettingsId id) const
size_t generateGoaway(folly::IOBufQueue &writeBuf, StreamID lastStream, ErrorCode statusCode, std::unique_ptr< folly::IOBuf > debugData=nullptr) override
#define EXPECT_GT(val1, val2)
void setSetting(SettingsId id, SettingsValue val)
void setStatusCode(uint16_t status)
void setMaxUncompressedHeaders(uint32_t maxUncompressed)