proxygen
SPDYCodecTest.cpp File Reference

Go to the source code of this file.

Classes

class  SPDYCodecTestF
 

Macros

#define copyForMe(F, C, V)
 
#define permuteTest(f)
 

Functions

size_t parseSPDY (SPDYCodec *codec, const uint8_t *inputData, uint32_t length, int32_t atOnce, FakeHTTPCodecCallback &callbacks)
 
 TEST (SPDYCodecTest, SPDYVersionSettingsCommonHeaderNameCheck)
 
 TEST (SPDYCodecTest, JunkSPDY)
 
 TEST (SPDYCodecTest, LongPing)
 
 TEST (SPDYCodecTest, BadType)
 
 TEST (SPDYCodecTest, SynStreamBoundaries)
 
 TEST (SPDYCodecTest, SetSettings)
 
 TEST (SPDYCodecTest, FrameTooLarge)
 
 TEST (SPDYCodecTest, FrameUncompressedTooLarge)
 
 TEST (SPDYCodecTest, UnsupportedVersion)
 
 TEST (SPDYCodecTest, UnsupportedFrameType)
 
template<typename Codec >
unique_ptr< folly::IOBufgetSynStream (Codec &egressCodec, uint32_t streamID, const HTTPMessage &msg, uint32_t assocStreamId=SPDYCodec::NoStream, bool eom=false, HTTPHeaderSize *size=nullptr)
 
template<typename Codec >
unique_ptr< folly::IOBufgetSynStream (Codec &egressCodec, uint32_t streamID)
 
template<typename Codec , typename F , typename V >
void callFunction (F f, V version)
 
unique_ptr< folly::IOBufgetVersionedSpdyFrame (const uint8_t *bytes, size_t len, uint8_t version)
 
template<typename Codec1 , typename Codec2 >
void maxTransactionHelper (Codec1 &ingressCodec, Codec2 &egressCodec, uint32_t parallel)
 
template<typename Codec1 , typename Codec2 >
void doDefaultMaxTransactionTest (Codec1 &ingressCodec, Codec2 &egressCodec)
 
template<typename Codec1 , typename Codec2 >
void doNonDefaultMaxTransactionTest (Codec1 &ingressCodec, Codec2 &egressCodec)
 
 TEST (SPDYCodecTest, DefaultMaxTransactions)
 
 TEST (SPDYCodecTest, NonDefaultMaxTransactions)
 
template<typename Codec1 , typename Codec2 >
void doEmptyHeaderValueTest (Codec1 &ingressCodec, Codec2 &egressCodec)
 
 TEST (SPDYCodecTest, EmptyHeaderValue)
 
 TEST (SPDYCodecTest, SynStreamWrongVersion)
 
template<typename Codec1 , typename Codec2 >
void doShortSynReplyTest (Codec1 &, Codec2 &egressCodec)
 
 TEST (SPDYCodecTest, ShortSynReply)
 
 TEST (SPDYCodecTest, SupportsSessionFlowControl)
 
 TEST (SPDYCodecTest, HeaderWithManyValues)
 
 TEST (SPDYCodecTest, MultiplePaths)
 
 TEST (SPDYCodecTest, LargeFrameEncoding)
 
 TEST (SPDYCodecTest, InvalidSettings)
 
 TEST (SPDYCodecTest, HeaderWithFin)
 
 TEST (SPDYCodecTest, ServerPush)
 
 TEST (SPDYCodecTest, ServerPushWithStatus)
 
 TEST (SPDYCodecTest, ServerPushHostMissing)
 
 TEST (SPDYCodecTest, ServerPushInvalidId)
 
 TEST (SPDYCodecTest, ServerPushInvalidFlags)
 
 TEST (SPDYCodecTest, ServerPushWithoutAssoc)
 
 TEST (SPDYCodecTest, StatusReason)
 
 TEST (SPDYCodecTest, UpstreamPing)
 
 TEST (SPDYCodecTest, DownstreamPing)
 
 TEST (SPDYCodecTest, DateHeader)
 
 TEST (SPDYCodecTest, HeaderDoS)
 
 TEST (SPDYCodecTest, DoubleGoawayServer)
 
 TEST (SPDYCodecTest, DoubleGoawayClient)
 
 TEST (SPDYCodecTest, SingleGoawayClient)
 
 TEST (SPDYCodecTest, OddHeaderListTest)
 
 TEST (SPDYCodecTest, SendRstParsingFrame)
 
 TEST (SPDYCodecTest, BadNumNameValues)
 
 TEST (SPDYCodecTest, ShortSettings)
 
 TEST (SPDYCodecTest, SegmentedHeaderBlock)
 
 TEST (SPDYCodecTest, ColonHeaders)
 
 TEST (SPDYCodecTest, StreamIdOverflow)
 
 TEST (SPDYCodecTest, BadNVBlock)
 
 TEST_F (SPDYCodecTestF, GoawayHandling)
 

Variables

uint8_t shortSynStream []
 
uint8_t longPing []
 
uint8_t badType []
 
uint8_t synStream []
 
uint8_t spdy3UnknownCtlFrame []
 
uint8_t shortSynReply []
 
uint8_t multiple_path_headers []
 
uint8_t pushStreamWithHostMissing []
 
uint8_t pushStreamWithOddId []
 
uint8_t pushStreamWithoutUnidirectional []
 
uint8_t pushStreamWithoutAssoc []
 
uint8_t multiValuedHeaderAttack []
 
uint8_t invalidHeaderPlusEmptyBlock []
 
uint8_t invalidNumNameValuesBlock []
 
const uint8_t kShortSettings []
 
const uint8_t kColonHeaders []
 
const uint8_t kBufBadNVBlock []
 

Macro Definition Documentation

#define copyForMe (   F,
  C,
 
)
Value:
callFunction<C>(F<C, C>, \
SPDYVersion::V)

Definition at line 380 of file SPDYCodecTest.cpp.

#define permuteTest (   f)
Value:
copyForMe(f, SPDYCodec, SPDY3_1);
auto f
#define copyForMe(F, C, V)

Definition at line 383 of file SPDYCodecTest.cpp.

Referenced by TEST().

Function Documentation

template<typename Codec , typename F , typename V >
void callFunction ( f,
version 
)

Definition at line 374 of file SPDYCodecTest.cpp.

References f.

374  {
375  Codec ingressCodec(TransportDirection::DOWNSTREAM, version);
376  Codec egressCodec(TransportDirection::UPSTREAM, version);
377  f(ingressCodec, egressCodec);
378 }
auto f
ProtocolVersion version
template<typename Codec1 , typename Codec2 >
void doDefaultMaxTransactionTest ( Codec1 &  ingressCodec,
Codec2 &  egressCodec 
)

Definition at line 419 of file SPDYCodecTest.cpp.

References maxTransactionHelper().

Referenced by TEST().

419  {
420  maxTransactionHelper(ingressCodec, egressCodec, 50);
421 }
void maxTransactionHelper(Codec1 &ingressCodec, Codec2 &egressCodec, uint32_t parallel)
template<typename Codec1 , typename Codec2 >
void doEmptyHeaderValueTest ( Codec1 &  ingressCodec,
Codec2 &  egressCodec 
)

Definition at line 437 of file SPDYCodecTest.cpp.

References ASSERT_NE, wangle::HTTPHeaderSize::compressed, EXPECT_EQ, EXPECT_TRUE, proxygen::HTTPMessage::getHeaders(), getSynStream(), proxygen::HTTP_HEADER_HOST, proxygen::HTTP_HEADER_PRAGMA, i, proxygen::FakeHTTPCodecCallback::msg, proxygen::FakeHTTPCodecCallback::sessionErrors, proxygen::HTTPHeaders::set(), proxygen::HTTPMessage::setMethod(), proxygen::HTTPMessage::setURL(), folly::size(), proxygen::FakeHTTPCodecCallback::streamErrors, string, uint8_t, wangle::HTTPHeaderSize::uncompressed, and version.

Referenced by TEST().

437  {
438  uint8_t version = ingressCodec.getVersion();
439  bool emptyAllowed = version != 2;
440  FakeHTTPCodecCallback callbacks;
441  ingressCodec.setCallback(&callbacks);
442  HTTPMessage toSend;
443  toSend.setMethod("GET");
444  toSend.setURL("http://www.foo.com");
445  auto& headers = toSend.getHeaders();
446  headers.set(HTTP_HEADER_HOST, "www.foo.com");
447  headers.set(HTTP_HEADER_PRAGMA, "");
448  headers.set("X-Test1", "yup");
450  std::string pragmaValue;
451  HTTPCodec::StreamID id(1);
452 
453  for (auto i = 0; i < 3; i++) {
454  auto toParse = getSynStream(egressCodec, id + 2 * i,
455  toSend, 0, false, &size);
456  ingressCodec.onIngress(*toParse);
457 
458  EXPECT_EQ(callbacks.sessionErrors, 0);
459  EXPECT_EQ(callbacks.streamErrors, 0);
460  ASSERT_NE(callbacks.msg.get(), nullptr);
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");
466  // All codecs add the accept-encoding header
467  EXPECT_EQ(parsed.exists("accept-encoding"), true);
468  // SPDY/2 subtracts the Host header, but it should infer it from the
469  // host:port portion of the requested url and present it in the headers
470  EXPECT_EQ(parsed.exists("host"), true);
471  EXPECT_EQ(callbacks.msg->getURL(), "http://www.foo.com");
472  EXPECT_EQ(parsed.size(), emptyAllowed ? 4 : 3);
473  EXPECT_TRUE(size.uncompressed > 0);
474  EXPECT_TRUE(size.compressed > 0);
475 
476  if (i == 0) {
477  headers.add("Pragma", "");
478  }
479  if (i == 1) {
480  pragmaValue = "foo";
481  headers.add("Pragma", pragmaValue);
482  emptyAllowed = true; // SPDY/2 better have it now too
483  }
484  }
485 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
ProtocolVersion version
void set(folly::StringPiece name, const std::string &value)
Definition: HTTPHeaders.h:119
constexpr auto size(C const &c) -> decltype(c.size())
Definition: Access.h:45
ParseURL setURL(T &&url)
Definition: HTTPMessage.h:183
HTTPHeaders & getHeaders()
Definition: HTTPMessage.h:273
void setMethod(HTTPMethod method)
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
unique_ptr< folly::IOBuf > getSynStream(Codec &egressCodec, uint32_t streamID, const HTTPMessage &msg, uint32_t assocStreamId=SPDYCodec::NoStream, bool eom=false, HTTPHeaderSize *size=nullptr)
const char * string
Definition: Conv.cpp:212
uint64_t StreamID
Definition: HTTPCodec.h:49
#define ASSERT_NE(val1, val2)
Definition: gtest.h:1960
std::unique_ptr< HTTPMessage > msg
Definition: TestUtils.h:404
template<typename Codec1 , typename Codec2 >
void doNonDefaultMaxTransactionTest ( Codec1 &  ingressCodec,
Codec2 &  egressCodec 
)

Definition at line 424 of file SPDYCodecTest.cpp.

References maxTransactionHelper().

Referenced by TEST().

424  {
425  maxTransactionHelper(ingressCodec, egressCodec, 100);
426 }
void maxTransactionHelper(Codec1 &ingressCodec, Codec2 &egressCodec, uint32_t parallel)
template<typename Codec1 , typename Codec2 >
void doShortSynReplyTest ( Codec1 &  ,
Codec2 &  egressCodec 
)

Definition at line 521 of file SPDYCodecTest.cpp.

References EXPECT_EQ, getVersionedSpdyFrame(), proxygen::FakeHTTPCodecCallback::sessionErrors, shortSynReply, and proxygen::FakeHTTPCodecCallback::streamErrors.

Referenced by TEST().

521  {
522  FakeHTTPCodecCallback callbacks;
523  egressCodec.setCallback(&callbacks);
524  auto frame = getVersionedSpdyFrame(shortSynReply, sizeof(shortSynReply),
525  egressCodec.getVersion());
526  egressCodec.onIngress(*frame);
527  EXPECT_EQ(callbacks.sessionErrors, 1);
528  EXPECT_EQ(callbacks.streamErrors, 0);
529 }
unique_ptr< folly::IOBuf > getVersionedSpdyFrame(const uint8_t *bytes, size_t len, uint8_t version)
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
uint8_t shortSynReply[]
template<typename Codec >
unique_ptr<folly::IOBuf> getSynStream ( Codec &  egressCodec,
uint32_t  streamID,
const HTTPMessage msg,
uint32_t  assocStreamId = SPDYCodec::NoStream,
bool  eom = false,
HTTPHeaderSize size = nullptr 
)

Definition at line 345 of file SPDYCodecTest.cpp.

References folly::IOBufQueue::cacheChainLength(), folly::IOBufQueue::move(), gmock_output_test::output, and folly::size().

Referenced by doEmptyHeaderValueTest(), getSynStream(), maxTransactionHelper(), and TEST().

351  {
353  if (assocStreamId == SPDYCodec::NoStream) {
354  egressCodec.generateHeader(output, streamID, msg, eom, size);
355  } else {
356  egressCodec.generatePushPromise(output, streamID, msg, assocStreamId, eom,
357  size);
358  }
359  return output.move();
360 }
static Options cacheChainLength()
Definition: IOBufQueue.h:83
uint32_t streamID
Definition: SPDYCodec.cpp:131
template<typename Codec >
unique_ptr<folly::IOBuf> getSynStream ( Codec &  egressCodec,
uint32_t  streamID 
)

Definition at line 363 of file SPDYCodecTest.cpp.

References proxygen::HTTPMessage::getHeaders(), getSynStream(), proxygen::HTTPHeaders::set(), proxygen::HTTPMessage::setMethod(), and proxygen::HTTPMessage::setURL().

364  {
365  HTTPMessage msg;
366  msg.setMethod("GET");
367  msg.getHeaders().set("HOST", "www.foo.com");
368  msg.setURL("https://www.foo.com");
369  return getSynStream(egressCodec, streamID, msg);
370 }
void set(folly::StringPiece name, const std::string &value)
Definition: HTTPHeaders.h:119
ParseURL setURL(T &&url)
Definition: HTTPMessage.h:183
HTTPHeaders & getHeaders()
Definition: HTTPMessage.h:273
void setMethod(HTTPMethod method)
unique_ptr< folly::IOBuf > getSynStream(Codec &egressCodec, uint32_t streamID, const HTTPMessage &msg, uint32_t assocStreamId=SPDYCodec::NoStream, bool eom=false, HTTPHeaderSize *size=nullptr)
uint32_t streamID
Definition: SPDYCodec.cpp:131
unique_ptr<folly::IOBuf> getVersionedSpdyFrame ( const uint8_t bytes,
size_t  len,
uint8_t  version 
)

Returns a SPDY frame with the specified version

Definition at line 389 of file SPDYCodecTest.cpp.

References folly::IOBuf::copyBuffer(), folly::data(), uint8_t, and version.

Referenced by doShortSynReplyTest(), and TEST().

391  {
392  auto frame = folly::IOBuf::copyBuffer(bytes, len);
393  uint8_t* data = frame->writableData();
394  data[1] = version; /* Set the version */
395  return frame;
396 }
ProtocolVersion version
static std::unique_ptr< IOBuf > copyBuffer(const void *buf, std::size_t size, std::size_t headroom=0, std::size_t minTailroom=0)
Definition: IOBuf.h:1587
static constexpr uint64_t data[1]
Definition: Fingerprint.cpp:43
template<typename Codec1 , typename Codec2 >
void maxTransactionHelper ( Codec1 &  ingressCodec,
Codec2 &  egressCodec,
uint32_t  parallel 
)

Definition at line 399 of file SPDYCodecTest.cpp.

References EXPECT_EQ, getSynStream(), i, proxygen::FakeHTTPCodecCallback::sessionErrors, proxygen::FakeHTTPCodecCallback::streamErrors, and uint16_t.

Referenced by doDefaultMaxTransactionTest(), and doNonDefaultMaxTransactionTest().

400  {
401  uint16_t expectedFailures = 0;
402  uint16_t synCount = 101;
403  ingressCodec.getEgressSettings()->setSetting(
404  SettingsId::MAX_CONCURRENT_STREAMS, parallel);
405  FakeHTTPCodecCallback callbacks;
406  ingressCodec.setCallback(&callbacks);
407  for (uint16_t i = 0; i < synCount; ++i) {
408  if (i >= parallel) {
409  ++expectedFailures;
410  }
411  auto toParse = getSynStream(egressCodec, 2*i + 1);
412  ingressCodec.onIngress(*toParse);
413  EXPECT_EQ(callbacks.sessionErrors, 0);
414  EXPECT_EQ(callbacks.streamErrors, expectedFailures);
415  }
416 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
Parallel parallel(Ops ops, size_t threads=0)
Definition: Parallel.h:88
unique_ptr< folly::IOBuf > getSynStream(Codec &egressCodec, uint32_t streamID, const HTTPMessage &msg, uint32_t assocStreamId=SPDYCodec::NoStream, bool eom=false, HTTPHeaderSize *size=nullptr)
size_t parseSPDY ( SPDYCodec codec,
const uint8_t inputData,
uint32_t  length,
int32_t  atOnce,
FakeHTTPCodecCallback callbacks 
)

Definition at line 26 of file SPDYCodecTest.cpp.

References proxygen::FakeHTTPCodecCallback::getStopFn(), parse(), and proxygen::HTTPParallelCodec::setCallback().

Referenced by TEST().

27  {
28  codec->setCallback(&callbacks);
29  return parse(codec, inputData, length, atOnce, callbacks.getStopFn());
30 }
size_t parse(const char *buf, size_t len)
Definition: test.c:1591
void setCallback(Callback *callback) override
std::function< bool()> getStopFn()
Definition: TestUtils.h:291
TEST ( SPDYCodecTest  ,
SPDYVersionSettingsCommonHeaderNameCheck   
)

Definition at line 38 of file SPDYCodecTest.cpp.

References EXPECT_EQ, proxygen::HTTP_HEADER_COLON_METHOD, proxygen::HTTP_HEADER_COLON_PATH, proxygen::HTTP_HEADER_COLON_SCHEME, proxygen::HTTP_HEADER_COLON_STATUS, proxygen::HTTP_HEADER_OTHER, proxygen::spdy::kNameHostv3, proxygen::spdy::kNameMethodv3, proxygen::spdy::kNamePathv3, proxygen::spdy::kNameSchemev3, proxygen::spdy::kNameStatusv3, and proxygen::spdy::kNameVersionv3.

38  {
39  // The purpose of this test is to ensure that should the below header names
40  // become part of the common set, it fails indicating that the SPDYCodec
41  // needs updating in those places that create compress/Header objects using
42  // the failed name.
43  EXPECT_EQ(HTTPCommonHeaders::hash(spdy::kNameVersionv3), HTTP_HEADER_OTHER);
44  EXPECT_EQ(HTTPCommonHeaders::hash(spdy::kNameHostv3), HTTP_HEADER_OTHER);
45  // The follow verifies assumptions that should never change regarding the
46  // mapping of specific SPDY3 constants to common headers. Should they fail,
47  // the SPDYCodec would require updating in the places in which they are used
48  // in creating compress/Header objects.
49  EXPECT_EQ(HTTPCommonHeaders::hash(
51  EXPECT_EQ(HTTPCommonHeaders::hash(
53  EXPECT_EQ(HTTPCommonHeaders::hash(
55  EXPECT_EQ(HTTPCommonHeaders::hash(
57 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
const std::string kNamePathv3
const std::string kNameMethodv3
const std::string kNameVersionv3
const std::string kNameHostv3
const std::string kNameStatusv3
const std::string kNameSchemev3
TEST ( SPDYCodecTest  ,
JunkSPDY   
)

Definition at line 59 of file SPDYCodecTest.cpp.

References codec, EXPECT_EQ, parseSPDY(), proxygen::FakeHTTPCodecCallback::sessionErrors, shortSynStream, and proxygen::FakeHTTPCodecCallback::streamErrors.

59  {
60  SPDYCodec codec(TransportDirection::DOWNSTREAM, SPDYVersion::SPDY3);
61  FakeHTTPCodecCallback callbacks;
62  size_t unconsumed =
63  parseSPDY(&codec, shortSynStream, sizeof(shortSynStream), -1, callbacks);
64  EXPECT_EQ(unconsumed, 0);
65  EXPECT_EQ(callbacks.sessionErrors, 1);
66  EXPECT_EQ(callbacks.streamErrors, 0);
67 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
CodecFactory codec
size_t parseSPDY(SPDYCodec *codec, const uint8_t *inputData, uint32_t length, int32_t atOnce, FakeHTTPCodecCallback &callbacks)
uint8_t shortSynStream[]
TEST ( SPDYCodecTest  ,
LongPing   
)

Definition at line 76 of file SPDYCodecTest.cpp.

References codec, EXPECT_EQ, longPing, parseSPDY(), proxygen::FakeHTTPCodecCallback::sessionErrors, and proxygen::FakeHTTPCodecCallback::streamErrors.

76  {
77  SPDYCodec codec(TransportDirection::DOWNSTREAM, SPDYVersion::SPDY3);
78  FakeHTTPCodecCallback callbacks;
79  size_t unconsumed =
80  parseSPDY(&codec, longPing, sizeof(longPing), -1, callbacks);
81  EXPECT_EQ(unconsumed, 0);
82  EXPECT_EQ(callbacks.sessionErrors, 1);
83  EXPECT_EQ(callbacks.streamErrors, 0);
84 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
CodecFactory codec
size_t parseSPDY(SPDYCodec *codec, const uint8_t *inputData, uint32_t length, int32_t atOnce, FakeHTTPCodecCallback &callbacks)
uint8_t longPing[]
TEST ( SPDYCodecTest  ,
BadType   
)

Definition at line 93 of file SPDYCodecTest.cpp.

References badType, codec, EXPECT_EQ, parseSPDY(), proxygen::FakeHTTPCodecCallback::sessionErrors, and proxygen::FakeHTTPCodecCallback::streamErrors.

93  {
94  // If an endpoint receives a control frame for a type it does not recognize,
95  // it must ignore the frame.
96  SPDYCodec codec(TransportDirection::DOWNSTREAM, SPDYVersion::SPDY3);
97  FakeHTTPCodecCallback callbacks;
98  size_t unconsumed =
99  parseSPDY(&codec, badType, sizeof(badType), -1, callbacks);
100  EXPECT_EQ(unconsumed, 0);
101  EXPECT_EQ(callbacks.sessionErrors, 0);
102  EXPECT_EQ(callbacks.streamErrors, 0);
103 }
uint8_t badType[]
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
CodecFactory codec
size_t parseSPDY(SPDYCodec *codec, const uint8_t *inputData, uint32_t length, int32_t atOnce, FakeHTTPCodecCallback &callbacks)
TEST ( SPDYCodecTest  ,
SynStreamBoundaries   
)

Definition at line 245 of file SPDYCodecTest.cpp.

References codec, EXPECT_EQ, proxygen::FakeHTTPCodecCallback::headersComplete, i, proxygen::FakeHTTPCodecCallback::messageBegin, proxygen::FakeHTTPCodecCallback::messageComplete, parseSPDY(), proxygen::FakeHTTPCodecCallback::sessionErrors, proxygen::FakeHTTPCodecCallback::streamErrors, and synStream.

245  {
246  for (int i = -1; i < int(sizeof(synStream)); i++) {
247  SPDYCodec codec(TransportDirection::DOWNSTREAM, SPDYVersion::SPDY3_1);
248  FakeHTTPCodecCallback callbacks;
249  size_t unconsumed =
250  parseSPDY(&codec, synStream, sizeof(synStream), i, callbacks);
251  EXPECT_EQ(unconsumed, 0);
252  EXPECT_EQ(callbacks.messageBegin, 1);
253  EXPECT_EQ(callbacks.headersComplete, 1);
254  EXPECT_EQ(callbacks.messageComplete, 1);
255  EXPECT_EQ(callbacks.streamErrors, 0);
256  EXPECT_EQ(callbacks.sessionErrors, 0);
257  }
258 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
CodecFactory codec
size_t parseSPDY(SPDYCodec *codec, const uint8_t *inputData, uint32_t length, int32_t atOnce, FakeHTTPCodecCallback &callbacks)
uint8_t synStream[]
TEST ( SPDYCodecTest  ,
SetSettings   
)

Definition at line 260 of file SPDYCodecTest.cpp.

References codec, EXPECT_EQ, proxygen::SPDYCodec::getEgressSettings(), proxygen::HTTPSettings::getNumSettings(), proxygen::HTTPSettings::getSetting(), proxygen::http2::kInitialWindow, proxygen::spdy::kMaxConcurrentStreams, proxygen::HTTPSettings::setSetting(), settings, proxygen::HTTPSettings::unsetSetting(), and proxygen::HTTPSetting::value.

260  {
261  SPDYCodec codec(TransportDirection::DOWNSTREAM, SPDYVersion::SPDY3);
262  HTTPSettings* settings = codec.getEgressSettings();
263  // There are 2 settings by default. Turn on another setting
264  settings->setSetting(SettingsId::_SPDY_DOWNLOAD_BANDWIDTH, 10);
265  // This should no-op since this setting should be off by default
266  settings->unsetSetting(SettingsId::_SPDY_ROUND_TRIP_TIME);
267  EXPECT_EQ(settings->getSetting(SettingsId::_SPDY_ROUND_TRIP_TIME), nullptr);
268  EXPECT_EQ(settings->getSetting(SettingsId::_SPDY_CURRENT_CWND), nullptr);
269  EXPECT_EQ(settings->getSetting(SettingsId::MAX_CONCURRENT_STREAMS)->value,
271  EXPECT_EQ(settings->getSetting(SettingsId::INITIAL_WINDOW_SIZE)->value,
273  EXPECT_EQ(
274  settings->getSetting(SettingsId::_SPDY_DOWNLOAD_BANDWIDTH)->value, 10);
275  // Turn off one of the defaults
276  settings->unsetSetting(SettingsId::MAX_CONCURRENT_STREAMS);
277  // Change the value of an existing default setting
278  settings->setSetting(SettingsId::INITIAL_WINDOW_SIZE, 123);
279  EXPECT_EQ(settings->getSetting(SettingsId::MAX_CONCURRENT_STREAMS),
280  nullptr);
281  EXPECT_EQ(settings->getSetting(SettingsId::INITIAL_WINDOW_SIZE)->value,
282  123);
283  EXPECT_EQ(settings->getNumSettings(), 2);
284  // Change the value of a unset setting
285  settings->setSetting(SettingsId::MAX_CONCURRENT_STREAMS, 400);
286  EXPECT_EQ(settings->getSetting(SettingsId::MAX_CONCURRENT_STREAMS)->value,
287  400);
288  EXPECT_EQ(settings->getNumSettings(), 3);
289 }
const uint32_t kInitialWindow
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
CodecFactory codec
static http_parser_settings settings
Definition: test.c:1529
std::size_t getNumSettings() const
Definition: HTTPSettings.h:58
void unsetSetting(SettingsId id)
SettingsValue value
Definition: HTTPSettings.h:32
const uint32_t kMaxConcurrentStreams
const HTTPSetting * getSetting(SettingsId id) const
void setSetting(SettingsId id, SettingsValue val)
TEST ( SPDYCodecTest  ,
FrameTooLarge   
)

Definition at line 291 of file SPDYCodecTest.cpp.

References codec, EXPECT_EQ, parseSPDY(), proxygen::FakeHTTPCodecCallback::sessionErrors, proxygen::SPDYCodec::setMaxFrameLength(), proxygen::FakeHTTPCodecCallback::streamErrors, and synStream.

291  {
292  SPDYCodec codec(TransportDirection::DOWNSTREAM, SPDYVersion::SPDY3_1);
293  codec.setMaxFrameLength(500);
294  FakeHTTPCodecCallback callbacks;
295  size_t unconsumed = parseSPDY(&codec, synStream, sizeof(synStream), -1,
296  callbacks);
297  EXPECT_EQ(unconsumed, 0);
298  EXPECT_EQ(callbacks.sessionErrors, 1);
299  EXPECT_EQ(callbacks.streamErrors, 1);
300 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
CodecFactory codec
size_t parseSPDY(SPDYCodec *codec, const uint8_t *inputData, uint32_t length, int32_t atOnce, FakeHTTPCodecCallback &callbacks)
uint8_t synStream[]
TEST ( SPDYCodecTest  ,
FrameUncompressedTooLarge   
)

Definition at line 302 of file SPDYCodecTest.cpp.

References codec, EXPECT_EQ, parseSPDY(), proxygen::FakeHTTPCodecCallback::sessionErrors, proxygen::SPDYCodec::setMaxUncompressedHeaders(), proxygen::FakeHTTPCodecCallback::streamErrors, and synStream.

302  {
303  SPDYCodec codec(TransportDirection::DOWNSTREAM, SPDYVersion::SPDY3_1);
304  codec.setMaxUncompressedHeaders(600);
305  FakeHTTPCodecCallback callbacks;
306  size_t unconsumed = parseSPDY(&codec, synStream, sizeof(synStream), -1,
307  callbacks);
308  EXPECT_EQ(unconsumed, 0);
309  EXPECT_EQ(callbacks.sessionErrors, 1);
310  EXPECT_EQ(callbacks.streamErrors, 1);
311 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
CodecFactory codec
size_t parseSPDY(SPDYCodec *codec, const uint8_t *inputData, uint32_t length, int32_t atOnce, FakeHTTPCodecCallback &callbacks)
uint8_t synStream[]
TEST ( SPDYCodecTest  ,
UnsupportedVersion   
)

Definition at line 319 of file SPDYCodecTest.cpp.

References codec, EXPECT_EQ, proxygen::FakeHTTPCodecCallback::lastParseError, parseSPDY(), proxygen::spdy::RST_PROTOCOL_ERROR, proxygen::spdy::rstToErrorCode(), proxygen::FakeHTTPCodecCallback::sessionErrors, shortSynStream, and proxygen::FakeHTTPCodecCallback::streamErrors.

319  {
320  // Send a spdy/2 frame on a spdy/3 codec
321  SPDYCodec codec(TransportDirection::DOWNSTREAM, SPDYVersion::SPDY3);
322  FakeHTTPCodecCallback callbacks;
323  size_t unconsumed = parseSPDY(&codec, shortSynStream,
324  sizeof(shortSynStream), -1, callbacks);
325  EXPECT_EQ(unconsumed, 0);
326  // Expect a GOAWAY with PROTOCOL_ERROR (because of unsupported version)
327  EXPECT_EQ(callbacks.sessionErrors, 1);
328  EXPECT_EQ(callbacks.streamErrors, 0);
329  EXPECT_EQ(callbacks.lastParseError->getCodecStatusCode(),
331 }
std::unique_ptr< HTTPException > lastParseError
Definition: TestUtils.h:405
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
CodecFactory codec
size_t parseSPDY(SPDYCodec *codec, const uint8_t *inputData, uint32_t length, int32_t atOnce, FakeHTTPCodecCallback &callbacks)
ErrorCode rstToErrorCode(uint32_t code)
uint8_t shortSynStream[]
TEST ( SPDYCodecTest  ,
UnsupportedFrameType   
)

Definition at line 333 of file SPDYCodecTest.cpp.

References codec, EXPECT_EQ, parseSPDY(), proxygen::FakeHTTPCodecCallback::sessionErrors, spdy3UnknownCtlFrame, and proxygen::FakeHTTPCodecCallback::streamErrors.

333  {
334  SPDYCodec codec(TransportDirection::DOWNSTREAM, SPDYVersion::SPDY3);
335  FakeHTTPCodecCallback callbacks;
336  size_t unconsumed = parseSPDY(&codec, spdy3UnknownCtlFrame,
337  sizeof(spdy3UnknownCtlFrame), -1, callbacks);
338  EXPECT_EQ(unconsumed, 0);
339  EXPECT_EQ(callbacks.sessionErrors, 0);
340  EXPECT_EQ(callbacks.streamErrors, 0);
341  // Spec says unknown control frames must be ignored
342 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
CodecFactory codec
size_t parseSPDY(SPDYCodec *codec, const uint8_t *inputData, uint32_t length, int32_t atOnce, FakeHTTPCodecCallback &callbacks)
uint8_t spdy3UnknownCtlFrame[]
TEST ( SPDYCodecTest  ,
DefaultMaxTransactions   
)

Definition at line 428 of file SPDYCodecTest.cpp.

References doDefaultMaxTransactionTest(), and permuteTest.

428  {
430 }
#define permuteTest(f)
void doDefaultMaxTransactionTest(Codec1 &ingressCodec, Codec2 &egressCodec)
TEST ( SPDYCodecTest  ,
NonDefaultMaxTransactions   
)

Definition at line 432 of file SPDYCodecTest.cpp.

References doNonDefaultMaxTransactionTest(), and permuteTest.

432  {
434 }
#define permuteTest(f)
void doNonDefaultMaxTransactionTest(Codec1 &ingressCodec, Codec2 &egressCodec)
TEST ( SPDYCodecTest  ,
EmptyHeaderValue   
)

Definition at line 487 of file SPDYCodecTest.cpp.

References doEmptyHeaderValueTest(), and permuteTest.

487  {
489 }
#define permuteTest(f)
void doEmptyHeaderValueTest(Codec1 &ingressCodec, Codec2 &egressCodec)
TEST ( SPDYCodecTest  ,
SynStreamWrongVersion   
)

Tests a syn stream request containing the wrong version. This frame is generated by using the v3 synStream firefox frame specified above and changing the version field to 2. The dictionary used for the zlib compression will be different and the session will be rejected.

Definition at line 497 of file SPDYCodecTest.cpp.

References codec, EXPECT_EQ, getVersionedSpdyFrame(), proxygen::FakeHTTPCodecCallback::lastParseError, parseSPDY(), proxygen::spdy::RST_PROTOCOL_ERROR, proxygen::spdy::rstToErrorCode(), proxygen::FakeHTTPCodecCallback::sessionErrors, proxygen::FakeHTTPCodecCallback::streamErrors, and synStream.

497  {
498  SPDYCodec codec(TransportDirection::DOWNSTREAM, SPDYVersion::SPDY3);
499  FakeHTTPCodecCallback callbacks;
500  auto frame = getVersionedSpdyFrame(synStream, sizeof(synStream), 2);
501  size_t unconsumed = parseSPDY(&codec, frame->data(), frame->length(), -1,
502  callbacks);
503  EXPECT_EQ(unconsumed, 0);
504  // Since the session compression state is inconsistent we need to send a
505  // session error. Expect a GOAWAY with PROTOCOL_ERROR.
506  EXPECT_EQ(callbacks.sessionErrors, 1);
507  EXPECT_EQ(callbacks.streamErrors, 0);
508  EXPECT_EQ(callbacks.lastParseError->getCodecStatusCode(),
510 }
unique_ptr< folly::IOBuf > getVersionedSpdyFrame(const uint8_t *bytes, size_t len, uint8_t version)
std::unique_ptr< HTTPException > lastParseError
Definition: TestUtils.h:405
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
CodecFactory codec
size_t parseSPDY(SPDYCodec *codec, const uint8_t *inputData, uint32_t length, int32_t atOnce, FakeHTTPCodecCallback &callbacks)
uint8_t synStream[]
ErrorCode rstToErrorCode(uint32_t code)
TEST ( SPDYCodecTest  ,
ShortSynReply   
)

Definition at line 531 of file SPDYCodecTest.cpp.

References doShortSynReplyTest(), and permuteTest.

531  {
533 }
void doShortSynReplyTest(Codec1 &, Codec2 &egressCodec)
#define permuteTest(f)
TEST ( SPDYCodecTest  ,
SupportsSessionFlowControl   
)

Definition at line 535 of file SPDYCodecTest.cpp.

References EXPECT_FALSE, EXPECT_TRUE, and proxygen::SPDYCodec::supportsSessionFlowControl().

535  {
536  SPDYCodec spdy3(TransportDirection::UPSTREAM,
537  SPDYVersion::SPDY3);
538  SPDYCodec spdy3_1(TransportDirection::UPSTREAM,
539  SPDYVersion::SPDY3_1);
540  EXPECT_FALSE(spdy3.supportsSessionFlowControl());
541  EXPECT_TRUE(spdy3_1.supportsSessionFlowControl());
542 }
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
TEST ( SPDYCodecTest  ,
HeaderWithManyValues   
)

Definition at line 545 of file SPDYCodecTest.cpp.

References proxygen::HTTPHeaders::add(), EXPECT_EQ, proxygen::HTTPMessage::getHeaders(), getSynStream(), proxygen::FakeHTTPCodecCallback::headersComplete, i, proxygen::FakeHTTPCodecCallback::messageBegin, proxygen::FakeHTTPCodecCallback::messageComplete, proxygen::FakeHTTPCodecCallback::msg, proxygen::SPDYCodec::onIngress(), proxygen::FakeHTTPCodecCallback::sessionErrors, proxygen::HTTPHeaders::set(), proxygen::HTTPParallelCodec::setCallback(), proxygen::HTTPMessage::setMethod(), proxygen::HTTPMessage::setURL(), proxygen::FakeHTTPCodecCallback::streamErrors, and string.

545  {
546  const std::string kMultiValued = "X-Multi-Valued";
547  const unsigned kNumValues = 1000;
548 
549  FakeHTTPCodecCallback callbacks;
550  SPDYCodec egressCodec(TransportDirection::UPSTREAM,
551  SPDYVersion::SPDY3);
552  SPDYCodec ingressCodec(TransportDirection::DOWNSTREAM,
553  SPDYVersion::SPDY3);
554  ingressCodec.setCallback(&callbacks);
555 
556  HTTPMessage req;
557  req.setMethod("GET");
558  req.getHeaders().set("HOST", "www.foo.com");
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));
562  }
563  auto syn = getSynStream(egressCodec, 1, req);
564  ingressCodec.onIngress(*syn);
565  EXPECT_EQ(callbacks.messageBegin, 1);
566  EXPECT_EQ(callbacks.headersComplete, 1);
567  EXPECT_EQ(callbacks.messageComplete, 0);
568  EXPECT_EQ(callbacks.streamErrors, 0);
569  EXPECT_EQ(callbacks.sessionErrors, 0);
570  CHECK_NOTNULL(callbacks.msg.get());
571  EXPECT_EQ(callbacks.msg->getHeaders().getNumberOfValues(kMultiValued),
572  kNumValues);
573 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
void set(folly::StringPiece name, const std::string &value)
Definition: HTTPHeaders.h:119
ParseURL setURL(T &&url)
Definition: HTTPMessage.h:183
HTTPHeaders & getHeaders()
Definition: HTTPMessage.h:273
void setMethod(HTTPMethod method)
unique_ptr< folly::IOBuf > getSynStream(Codec &egressCodec, uint32_t streamID, const HTTPMessage &msg, uint32_t assocStreamId=SPDYCodec::NoStream, bool eom=false, HTTPHeaderSize *size=nullptr)
const char * string
Definition: Conv.cpp:212
void add(folly::StringPiece name, folly::StringPiece value)
Definition: HTTPHeaders.cpp:52
std::unique_ptr< HTTPMessage > msg
Definition: TestUtils.h:404
TEST ( SPDYCodecTest  ,
MultiplePaths   
)

Definition at line 604 of file SPDYCodecTest.cpp.

References EXPECT_EQ, proxygen::SPDYCodec::getVersion(), getVersionedSpdyFrame(), multiple_path_headers, proxygen::SPDYCodec::onIngress(), proxygen::FakeHTTPCodecCallback::sessionErrors, proxygen::HTTPParallelCodec::setCallback(), and proxygen::FakeHTTPCodecCallback::streamErrors.

604  {
605  FakeHTTPCodecCallback callbacks;
606  SPDYCodec ingressCodec(TransportDirection::DOWNSTREAM, SPDYVersion::SPDY3);
608  sizeof(multiple_path_headers), ingressCodec.getVersion());
609  ingressCodec.setCallback(&callbacks);
610  ingressCodec.onIngress(*frame);
611  EXPECT_EQ(callbacks.streamErrors, 1);
612  EXPECT_EQ(callbacks.sessionErrors, 0);
613 }
uint8_t multiple_path_headers[]
unique_ptr< folly::IOBuf > getVersionedSpdyFrame(const uint8_t *bytes, size_t len, uint8_t version)
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
TEST ( SPDYCodecTest  ,
LargeFrameEncoding   
)

Definition at line 615 of file SPDYCodecTest.cpp.

References codec, proxygen::getGetRequest(), getSynStream(), i, proxygen::SPDYCodec::setMaxUncompressedHeaders(), and string.

615  {
616  const std::string kMultiValued = "X-Multi-Valued";
617  const unsigned kNumValues = 1000;
618 
619  SPDYCodec codec(TransportDirection::UPSTREAM, SPDYVersion::SPDY3);
620  // This will simulate the condition where we have a very small
621  // compresed headers size compared to the number of headers we
622  // have.
623  codec.setMaxUncompressedHeaders(0);
624  auto req = getGetRequest();
625  for (unsigned i = 0; i < kNumValues; ++i) {
626  req.getHeaders().add(kMultiValued, folly::to<string>("Value", i));
627  }
628  auto syn = getSynStream(codec, 1, req);
629 }
CodecFactory codec
unique_ptr< folly::IOBuf > getSynStream(Codec &egressCodec, uint32_t streamID, const HTTPMessage &msg, uint32_t assocStreamId=SPDYCodec::NoStream, bool eom=false, HTTPHeaderSize *size=nullptr)
HTTPMessage getGetRequest(const std::string &url)
Definition: TestUtils.cpp:76
const char * string
Definition: Conv.cpp:212
TEST ( SPDYCodecTest  ,
InvalidSettings   
)

Definition at line 632 of file SPDYCodecTest.cpp.

References folly::IOBufQueue::cacheChainLength(), EXPECT_EQ, proxygen::SPDYCodec::generateSettings(), proxygen::SPDYCodec::getEgressSettings(), proxygen::FakeHTTPCodecCallback::headersComplete, max, proxygen::FakeHTTPCodecCallback::messageBegin, proxygen::FakeHTTPCodecCallback::messageComplete, folly::IOBufQueue::move(), proxygen::SPDYCodec::onIngress(), gmock_output_test::output, proxygen::FakeHTTPCodecCallback::sessionErrors, proxygen::HTTPParallelCodec::setCallback(), proxygen::HTTPSettings::setSetting(), proxygen::FakeHTTPCodecCallback::streamErrors, and uint32_t.

632  {
633  FakeHTTPCodecCallback callbacks;
634 
635  SPDYCodec egressCodec(TransportDirection::UPSTREAM,
636  SPDYVersion::SPDY3);
637  SPDYCodec ingressCodec(TransportDirection::DOWNSTREAM,
638  SPDYVersion::SPDY3);
639  ingressCodec.setCallback(&callbacks);
640 
642  egressCodec.getEgressSettings()->setSetting(
643  SettingsId::INITIAL_WINDOW_SIZE,
645  egressCodec.generateSettings(output);
646  auto ingress = output.move();
647  ingressCodec.onIngress(*ingress);
648  EXPECT_EQ(callbacks.messageBegin, 0);
649  EXPECT_EQ(callbacks.headersComplete, 0);
650  EXPECT_EQ(callbacks.messageComplete, 0);
651  EXPECT_EQ(callbacks.streamErrors, 0);
652  EXPECT_EQ(callbacks.sessionErrors, 1);
653 }
LogLevel max
Definition: LogLevel.cpp:31
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
static Options cacheChainLength()
Definition: IOBufQueue.h:83
TEST ( SPDYCodecTest  ,
HeaderWithFin   
)

Definition at line 655 of file SPDYCodecTest.cpp.

References proxygen::FakeHTTPCodecCallback::assocStreamId, EXPECT_EQ, proxygen::HTTPMessage::getHeaders(), getSynStream(), proxygen::FakeHTTPCodecCallback::headersComplete, proxygen::FakeHTTPCodecCallback::messageBegin, proxygen::FakeHTTPCodecCallback::messageComplete, proxygen::SPDYCodec::onIngress(), proxygen::FakeHTTPCodecCallback::sessionErrors, proxygen::HTTPHeaders::set(), proxygen::HTTPParallelCodec::setCallback(), proxygen::HTTPMessage::setMethod(), proxygen::HTTPMessage::setURL(), and proxygen::FakeHTTPCodecCallback::streamErrors.

655  {
656  FakeHTTPCodecCallback callbacks;
657  SPDYCodec egressCodec(TransportDirection::UPSTREAM,
658  SPDYVersion::SPDY3);
659  SPDYCodec ingressCodec(TransportDirection::DOWNSTREAM,
660  SPDYVersion::SPDY3);
661  ingressCodec.setCallback(&callbacks);
662 
663  HTTPMessage req;
664  req.setMethod("GET");
665  req.getHeaders().set("HOST", "www.foo.com");
666  req.setURL("https://www.foo.com/");
667  auto syn = getSynStream(egressCodec, 1, req, 0, true /* eom */);
668  ingressCodec.onIngress(*syn);
669  EXPECT_EQ(callbacks.messageBegin, 1);
670  EXPECT_EQ(callbacks.headersComplete, 1);
671  EXPECT_EQ(callbacks.messageComplete, 1);
672  EXPECT_EQ(callbacks.streamErrors, 0);
673  EXPECT_EQ(callbacks.sessionErrors, 0);
674  EXPECT_EQ(callbacks.assocStreamId, 0);
675 }
HTTPCodec::StreamID assocStreamId
Definition: TestUtils.h:370
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
void set(folly::StringPiece name, const std::string &value)
Definition: HTTPHeaders.h:119
ParseURL setURL(T &&url)
Definition: HTTPMessage.h:183
HTTPHeaders & getHeaders()
Definition: HTTPMessage.h:273
void setMethod(HTTPMethod method)
unique_ptr< folly::IOBuf > getSynStream(Codec &egressCodec, uint32_t streamID, const HTTPMessage &msg, uint32_t assocStreamId=SPDYCodec::NoStream, bool eom=false, HTTPHeaderSize *size=nullptr)
TEST ( SPDYCodecTest  ,
ServerPush   
)

Definition at line 677 of file SPDYCodecTest.cpp.

References proxygen::FakeHTTPCodecCallback::assocStreamId, EXPECT_EQ, proxygen::HTTPMessage::getHeaders(), getSynStream(), proxygen::FakeHTTPCodecCallback::headersComplete, proxygen::FakeHTTPCodecCallback::messageBegin, proxygen::FakeHTTPCodecCallback::messageComplete, proxygen::SPDYCodec::onIngress(), proxygen::FakeHTTPCodecCallback::sessionErrors, proxygen::HTTPHeaders::set(), proxygen::HTTPParallelCodec::setCallback(), proxygen::HTTPMessage::setURL(), and proxygen::FakeHTTPCodecCallback::streamErrors.

677  {
678  FakeHTTPCodecCallback callbacks;
679  SPDYCodec egressCodec(TransportDirection::DOWNSTREAM,
680  SPDYVersion::SPDY3);
681  SPDYCodec ingressCodec(TransportDirection::UPSTREAM,
682  SPDYVersion::SPDY3);
683  ingressCodec.setCallback(&callbacks);
684 
685  HTTPMessage push;
686  push.getHeaders().set("HOST", "www.foo.com");
687  push.setURL("https://www.foo.com/");
688  auto syn = getSynStream(egressCodec, 2, push, 1);
689  ingressCodec.onIngress(*syn);
690  EXPECT_EQ(callbacks.messageBegin, 1);
691  EXPECT_EQ(callbacks.headersComplete, 1);
692  EXPECT_EQ(callbacks.messageComplete, 0);
693  EXPECT_EQ(callbacks.streamErrors, 0);
694  EXPECT_EQ(callbacks.sessionErrors, 0);
695  EXPECT_EQ(callbacks.assocStreamId, 1);
696 }
HTTPCodec::StreamID assocStreamId
Definition: TestUtils.h:370
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
void set(folly::StringPiece name, const std::string &value)
Definition: HTTPHeaders.h:119
ParseURL setURL(T &&url)
Definition: HTTPMessage.h:183
HTTPHeaders & getHeaders()
Definition: HTTPMessage.h:273
unique_ptr< folly::IOBuf > getSynStream(Codec &egressCodec, uint32_t streamID, const HTTPMessage &msg, uint32_t assocStreamId=SPDYCodec::NoStream, bool eom=false, HTTPHeaderSize *size=nullptr)
TEST ( SPDYCodecTest  ,
ServerPushWithStatus   
)

Definition at line 698 of file SPDYCodecTest.cpp.

References proxygen::FakeHTTPCodecCallback::assocStreamId, EXPECT_EQ, proxygen::HTTPMessage::getHeaders(), getSynStream(), proxygen::FakeHTTPCodecCallback::headersComplete, proxygen::FakeHTTPCodecCallback::messageBegin, proxygen::FakeHTTPCodecCallback::messageComplete, proxygen::FakeHTTPCodecCallback::msg, proxygen::SPDYCodec::onIngress(), proxygen::FakeHTTPCodecCallback::sessionErrors, proxygen::HTTPHeaders::set(), proxygen::HTTPParallelCodec::setCallback(), proxygen::HTTPMessage::setPushStatusCode(), proxygen::HTTPMessage::setURL(), and proxygen::FakeHTTPCodecCallback::streamErrors.

698  {
699  FakeHTTPCodecCallback callbacks;
700  SPDYCodec egressCodec(TransportDirection::DOWNSTREAM,
701  SPDYVersion::SPDY3);
702  SPDYCodec ingressCodec(TransportDirection::UPSTREAM,
703  SPDYVersion::SPDY3);
704  ingressCodec.setCallback(&callbacks);
705 
706  HTTPMessage push;
707  push.getHeaders().set("HOST", "www.foo.com");
708  push.setURL("https://www.foo.com/");
709  push.setPushStatusCode(200);
710  auto syn = getSynStream(egressCodec, 2, push, 1);
711  ingressCodec.onIngress(*syn);
712  EXPECT_EQ(callbacks.messageBegin, 1);
713  EXPECT_EQ(callbacks.headersComplete, 1);
714  EXPECT_EQ(callbacks.messageComplete, 0);
715  EXPECT_EQ(callbacks.streamErrors, 0);
716  EXPECT_EQ(callbacks.sessionErrors, 0);
717  EXPECT_EQ(callbacks.assocStreamId, 1);
718  EXPECT_EQ(callbacks.msg->getPushStatusCode(), 200);
719 }
HTTPCodec::StreamID assocStreamId
Definition: TestUtils.h:370
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
void setPushStatusCode(const uint16_t status)
void set(folly::StringPiece name, const std::string &value)
Definition: HTTPHeaders.h:119
ParseURL setURL(T &&url)
Definition: HTTPMessage.h:183
HTTPHeaders & getHeaders()
Definition: HTTPMessage.h:273
unique_ptr< folly::IOBuf > getSynStream(Codec &egressCodec, uint32_t streamID, const HTTPMessage &msg, uint32_t assocStreamId=SPDYCodec::NoStream, bool eom=false, HTTPHeaderSize *size=nullptr)
std::unique_ptr< HTTPMessage > msg
Definition: TestUtils.h:404
TEST ( SPDYCodecTest  ,
ServerPushHostMissing   
)

Definition at line 744 of file SPDYCodecTest.cpp.

References proxygen::FakeHTTPCodecCallback::assocStreamId, folly::IOBuf::copyBuffer(), EXPECT_EQ, proxygen::FakeHTTPCodecCallback::headersComplete, proxygen::FakeHTTPCodecCallback::messageBegin, proxygen::FakeHTTPCodecCallback::messageComplete, proxygen::SPDYCodec::onIngress(), pushStreamWithHostMissing, proxygen::FakeHTTPCodecCallback::sessionErrors, proxygen::HTTPParallelCodec::setCallback(), and proxygen::FakeHTTPCodecCallback::streamErrors.

744  {
745  FakeHTTPCodecCallback callbacks;
746  SPDYCodec ingressCodec(TransportDirection::UPSTREAM,
747  SPDYVersion::SPDY3);
748  ingressCodec.setCallback(&callbacks);
749 
751  sizeof(pushStreamWithHostMissing));
752  ingressCodec.onIngress(*syn);
753  EXPECT_EQ(callbacks.messageBegin, 0);
754  EXPECT_EQ(callbacks.headersComplete, 0);
755  EXPECT_EQ(callbacks.messageComplete, 0);
756  EXPECT_EQ(callbacks.streamErrors, 1);
757  EXPECT_EQ(callbacks.sessionErrors, 0);
758  EXPECT_EQ(callbacks.assocStreamId, 0);
759 }
uint8_t pushStreamWithHostMissing[]
HTTPCodec::StreamID assocStreamId
Definition: TestUtils.h:370
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
static std::unique_ptr< IOBuf > copyBuffer(const void *buf, std::size_t size, std::size_t headroom=0, std::size_t minTailroom=0)
Definition: IOBuf.h:1587
TEST ( SPDYCodecTest  ,
ServerPushInvalidId   
)

Definition at line 787 of file SPDYCodecTest.cpp.

References proxygen::FakeHTTPCodecCallback::assocStreamId, folly::IOBuf::copyBuffer(), EXPECT_EQ, proxygen::FakeHTTPCodecCallback::headersComplete, proxygen::FakeHTTPCodecCallback::messageBegin, proxygen::FakeHTTPCodecCallback::messageComplete, proxygen::SPDYCodec::onIngress(), pushStreamWithOddId, proxygen::FakeHTTPCodecCallback::sessionErrors, proxygen::HTTPParallelCodec::setCallback(), and proxygen::FakeHTTPCodecCallback::streamErrors.

787  {
788  FakeHTTPCodecCallback callbacks;
789  SPDYCodec ingressCodec(TransportDirection::UPSTREAM,
790  SPDYVersion::SPDY3);
791  ingressCodec.setCallback(&callbacks);
792 
794  sizeof(pushStreamWithOddId));
795  ingressCodec.onIngress(*syn);
796  EXPECT_EQ(callbacks.messageBegin, 0);
797  EXPECT_EQ(callbacks.headersComplete, 0);
798  EXPECT_EQ(callbacks.messageComplete, 0);
799  EXPECT_EQ(callbacks.streamErrors, 0);
800  EXPECT_EQ(callbacks.sessionErrors, 1);
801  EXPECT_EQ(callbacks.assocStreamId, 0);
802 }
HTTPCodec::StreamID assocStreamId
Definition: TestUtils.h:370
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
uint8_t pushStreamWithOddId[]
static std::unique_ptr< IOBuf > copyBuffer(const void *buf, std::size_t size, std::size_t headroom=0, std::size_t minTailroom=0)
Definition: IOBuf.h:1587
TEST ( SPDYCodecTest  ,
ServerPushInvalidFlags   
)

Definition at line 830 of file SPDYCodecTest.cpp.

References proxygen::FakeHTTPCodecCallback::assocStreamId, folly::IOBuf::copyBuffer(), EXPECT_EQ, proxygen::FakeHTTPCodecCallback::headersComplete, proxygen::FakeHTTPCodecCallback::messageBegin, proxygen::FakeHTTPCodecCallback::messageComplete, proxygen::SPDYCodec::onIngress(), pushStreamWithoutUnidirectional, proxygen::FakeHTTPCodecCallback::sessionErrors, proxygen::HTTPParallelCodec::setCallback(), and proxygen::FakeHTTPCodecCallback::streamErrors.

830  {
831  FakeHTTPCodecCallback callbacks;
832  SPDYCodec ingressCodec(TransportDirection::UPSTREAM,
833  SPDYVersion::SPDY3);
834  ingressCodec.setCallback(&callbacks);
835 
838  ingressCodec.onIngress(*syn);
839  EXPECT_EQ(callbacks.messageBegin, 0);
840  EXPECT_EQ(callbacks.headersComplete, 0);
841  EXPECT_EQ(callbacks.messageComplete, 0);
842  EXPECT_EQ(callbacks.streamErrors, 1);
843  EXPECT_EQ(callbacks.sessionErrors, 0);
844  EXPECT_EQ(callbacks.assocStreamId, 0);
845 }
HTTPCodec::StreamID assocStreamId
Definition: TestUtils.h:370
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
uint8_t pushStreamWithoutUnidirectional[]
static std::unique_ptr< IOBuf > copyBuffer(const void *buf, std::size_t size, std::size_t headroom=0, std::size_t minTailroom=0)
Definition: IOBuf.h:1587
TEST ( SPDYCodecTest  ,
ServerPushWithoutAssoc   
)

Definition at line 873 of file SPDYCodecTest.cpp.

References proxygen::FakeHTTPCodecCallback::assocStreamId, folly::IOBuf::copyBuffer(), EXPECT_EQ, proxygen::FakeHTTPCodecCallback::headersComplete, proxygen::FakeHTTPCodecCallback::messageBegin, proxygen::FakeHTTPCodecCallback::messageComplete, proxygen::SPDYCodec::onIngress(), pushStreamWithoutAssoc, proxygen::FakeHTTPCodecCallback::sessionErrors, proxygen::HTTPParallelCodec::setCallback(), and proxygen::FakeHTTPCodecCallback::streamErrors.

873  {
874  FakeHTTPCodecCallback callbacks;
875  SPDYCodec ingressCodec(TransportDirection::UPSTREAM,
876  SPDYVersion::SPDY3);
877  ingressCodec.setCallback(&callbacks);
878 
880  sizeof(pushStreamWithoutAssoc));
881  ingressCodec.onIngress(*syn);
882  EXPECT_EQ(callbacks.messageBegin, 0);
883  EXPECT_EQ(callbacks.headersComplete, 0);
884  EXPECT_EQ(callbacks.messageComplete, 0);
885  EXPECT_EQ(callbacks.streamErrors, 0);
886  EXPECT_EQ(callbacks.sessionErrors, 1);
887  EXPECT_EQ(callbacks.assocStreamId, 0);
888 }
HTTPCodec::StreamID assocStreamId
Definition: TestUtils.h:370
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
uint8_t pushStreamWithoutAssoc[]
static std::unique_ptr< IOBuf > copyBuffer(const void *buf, std::size_t size, std::size_t headroom=0, std::size_t minTailroom=0)
Definition: IOBuf.h:1587
TEST ( SPDYCodecTest  ,
StatusReason   
)

Definition at line 890 of file SPDYCodecTest.cpp.

References EXPECT_EQ, EXPECT_TRUE, getSynStream(), proxygen::FakeHTTPCodecCallback::headersComplete, proxygen::FakeHTTPCodecCallback::lastParseError, proxygen::FakeHTTPCodecCallback::messageBegin, proxygen::FakeHTTPCodecCallback::messageComplete, proxygen::FakeHTTPCodecCallback::msg, proxygen::SPDYCodec::onIngress(), proxygen::FakeHTTPCodecCallback::reset(), proxygen::spdy::RST_PROTOCOL_ERROR, proxygen::spdy::rstToErrorCode(), proxygen::FakeHTTPCodecCallback::sessionErrors, proxygen::HTTPParallelCodec::setCallback(), proxygen::HTTPMessage::setStatusCode(), proxygen::HTTPMessage::setStatusMessage(), and proxygen::FakeHTTPCodecCallback::streamErrors.

890  {
891  FakeHTTPCodecCallback callbacks;
892  SPDYCodec egressCodec(TransportDirection::DOWNSTREAM,
893  SPDYVersion::SPDY3);
894  SPDYCodec ingressCodec(TransportDirection::UPSTREAM,
895  SPDYVersion::SPDY3);
896  ingressCodec.setCallback(&callbacks);
897 
898  HTTPMessage resp;
899  resp.setStatusCode(200);
900  auto syn = getSynStream(egressCodec, 1, resp, 0);
901  ingressCodec.onIngress(*syn);
902  EXPECT_EQ(callbacks.messageBegin, 1);
903  EXPECT_EQ(callbacks.headersComplete, 1);
904  EXPECT_EQ(callbacks.messageComplete, 0);
905  EXPECT_EQ(callbacks.streamErrors, 0);
906  EXPECT_EQ(callbacks.sessionErrors, 0);
907  EXPECT_EQ(callbacks.msg->getStatusCode(), 200);
908  EXPECT_EQ(callbacks.msg->getStatusMessage(), "");
909  callbacks.reset();
910 
911  resp.setStatusCode(200);
912  resp.setStatusMessage("Awesome");
913  syn = getSynStream(egressCodec, 1, resp, 0);
914  ingressCodec.onIngress(*syn);
915  EXPECT_EQ(callbacks.messageBegin, 1);
916  EXPECT_EQ(callbacks.headersComplete, 1);
917  EXPECT_EQ(callbacks.messageComplete, 0);
918  EXPECT_EQ(callbacks.streamErrors, 0);
919  EXPECT_EQ(callbacks.sessionErrors, 0);
920  EXPECT_EQ(callbacks.msg->getStatusCode(), 200);
921  EXPECT_EQ(callbacks.msg->getStatusMessage(), "Awesome");
922  callbacks.reset();
923 
924  // Out of range
925  resp.setStatusCode(2000);
926  resp.setStatusMessage("10x OK");
927  syn = getSynStream(egressCodec, 1, resp, 0);
928  ingressCodec.onIngress(*syn);
929  EXPECT_EQ(callbacks.messageBegin, 0);
930  EXPECT_EQ(callbacks.headersComplete, 0);
931  EXPECT_EQ(callbacks.messageComplete, 0);
932  EXPECT_EQ(callbacks.streamErrors, 1);
933  EXPECT_EQ(callbacks.sessionErrors, 0);
934  EXPECT_TRUE(callbacks.lastParseError->hasCodecStatusCode());
935  EXPECT_EQ(callbacks.lastParseError->getCodecStatusCode(),
937  callbacks.reset();
938 
939  resp.setStatusCode(64);
940  resp.setStatusMessage("Ought to be enough for anybody");
941  syn = getSynStream(egressCodec, 1, resp, 0);
942  ingressCodec.onIngress(*syn);
943  EXPECT_EQ(callbacks.messageBegin, 0);
944  EXPECT_EQ(callbacks.headersComplete, 0);
945  EXPECT_EQ(callbacks.messageComplete, 0);
946  EXPECT_EQ(callbacks.streamErrors, 1);
947  EXPECT_EQ(callbacks.sessionErrors, 0);
948  EXPECT_TRUE(callbacks.lastParseError->hasCodecStatusCode());
949  EXPECT_EQ(callbacks.lastParseError->getCodecStatusCode(),
951  callbacks.reset();
952 }
std::unique_ptr< HTTPException > lastParseError
Definition: TestUtils.h:405
void setStatusMessage(T &&msg)
Definition: HTTPMessage.h:242
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
unique_ptr< folly::IOBuf > getSynStream(Codec &egressCodec, uint32_t streamID, const HTTPMessage &msg, uint32_t assocStreamId=SPDYCodec::NoStream, bool eom=false, HTTPHeaderSize *size=nullptr)
std::unique_ptr< HTTPMessage > msg
Definition: TestUtils.h:404
ErrorCode rstToErrorCode(uint32_t code)
void setStatusCode(uint16_t status)
TEST ( SPDYCodecTest  ,
UpstreamPing   
)

Definition at line 954 of file SPDYCodecTest.cpp.

References ASSERT_EQ, ASSERT_GT, folly::IOBufQueue::cacheChainLength(), proxygen::SPDYCodec::generatePingReply(), proxygen::SPDYCodec::generatePingRequest(), i, folly::IOBufQueue::move(), proxygen::SPDYCodec::onIngress(), proxygen::FakeHTTPCodecCallback::recvPingReply, proxygen::FakeHTTPCodecCallback::recvPingRequest, and proxygen::HTTPParallelCodec::setCallback().

954  {
956  FakeHTTPCodecCallback callbacks;
957  SPDYCodec egressCodec(TransportDirection::UPSTREAM,
958  SPDYVersion::SPDY3);
959  SPDYCodec ingressCodec(TransportDirection::DOWNSTREAM,
960  SPDYVersion::SPDY3);
961  ingressCodec.setCallback(&callbacks);
962 
963  // Send a reply with no corresponding ping request
964  egressCodec.generatePingReply(buf, 2);
965  auto pingReply = buf.move();
966  ingressCodec.onIngress(*pingReply);
967  ASSERT_EQ(callbacks.recvPingReply, 0); // should be ignored
968 
969  auto lastRequest = callbacks.recvPingRequest;
970  for (unsigned i = 0; i < 10; ++i) {
971  egressCodec.generatePingRequest(buf);
972  auto pingReq = buf.move();
973  ingressCodec.onIngress(*pingReq);
974  ASSERT_GT(callbacks.recvPingRequest, lastRequest);
975  ASSERT_EQ(callbacks.recvPingRequest % 2, 1);
976  lastRequest = callbacks.recvPingRequest;
977  }
978 }
#define ASSERT_GT(val1, val2)
Definition: gtest.h:1976
#define ASSERT_EQ(val1, val2)
Definition: gtest.h:1956
static Options cacheChainLength()
Definition: IOBufQueue.h:83
TEST ( SPDYCodecTest  ,
DownstreamPing   
)

Definition at line 980 of file SPDYCodecTest.cpp.

References ASSERT_EQ, ASSERT_GT, folly::IOBufQueue::cacheChainLength(), proxygen::SPDYCodec::generatePingReply(), proxygen::SPDYCodec::generatePingRequest(), i, folly::IOBufQueue::move(), proxygen::SPDYCodec::onIngress(), proxygen::FakeHTTPCodecCallback::recvPingReply, proxygen::FakeHTTPCodecCallback::recvPingRequest, and proxygen::HTTPParallelCodec::setCallback().

980  {
982  FakeHTTPCodecCallback callbacks;
983  SPDYCodec egressCodec(TransportDirection::DOWNSTREAM,
984  SPDYVersion::SPDY3);
985  SPDYCodec ingressCodec(TransportDirection::UPSTREAM,
986  SPDYVersion::SPDY3);
987  ingressCodec.setCallback(&callbacks);
988 
989  // Send a reply with no corresponding ping request
990  egressCodec.generatePingReply(buf, 1);
991  auto pingReply = buf.move();
992  ingressCodec.onIngress(*pingReply);
993  ASSERT_EQ(callbacks.recvPingReply, 0); // should be ignored
994 
995  auto lastRequest = callbacks.recvPingRequest;
996  for (unsigned i = 0; i < 10; ++i) {
997  egressCodec.generatePingRequest(buf);
998  auto pingReq = buf.move();
999  ingressCodec.onIngress(*pingReq);
1000  ASSERT_GT(callbacks.recvPingRequest, lastRequest);
1001  ASSERT_EQ(callbacks.recvPingRequest % 2, 0);
1002  lastRequest = callbacks.recvPingRequest;
1003  }
1004 }
#define ASSERT_GT(val1, val2)
Definition: gtest.h:1976
#define ASSERT_EQ(val1, val2)
Definition: gtest.h:1956
static Options cacheChainLength()
Definition: IOBufQueue.h:83
TEST ( SPDYCodecTest  ,
DateHeader   
)

Definition at line 1006 of file SPDYCodecTest.cpp.

References EXPECT_EQ, EXPECT_TRUE, getSynStream(), proxygen::FakeHTTPCodecCallback::headersComplete, proxygen::HTTP_HEADER_DATE, proxygen::FakeHTTPCodecCallback::messageBegin, proxygen::FakeHTTPCodecCallback::messageComplete, proxygen::FakeHTTPCodecCallback::msg, proxygen::SPDYCodec::onIngress(), proxygen::FakeHTTPCodecCallback::sessionErrors, proxygen::HTTPParallelCodec::setCallback(), proxygen::HTTPMessage::setStatusCode(), and proxygen::FakeHTTPCodecCallback::streamErrors.

1006  {
1007  FakeHTTPCodecCallback callbacks;
1008  SPDYCodec egressCodec(TransportDirection::DOWNSTREAM,
1009  SPDYVersion::SPDY3);
1010  SPDYCodec ingressCodec(TransportDirection::UPSTREAM,
1011  SPDYVersion::SPDY3);
1012  ingressCodec.setCallback(&callbacks);
1013 
1014  HTTPMessage resp;
1015  resp.setStatusCode(200);
1016  auto syn = getSynStream(egressCodec, 1, resp, 0);
1017  ingressCodec.onIngress(*syn);
1018  EXPECT_EQ(callbacks.messageBegin, 1);
1019  EXPECT_EQ(callbacks.headersComplete, 1);
1020  EXPECT_EQ(callbacks.messageComplete, 0);
1021  EXPECT_EQ(callbacks.streamErrors, 0);
1022  EXPECT_EQ(callbacks.sessionErrors, 0);
1023  EXPECT_TRUE(callbacks.msg->getHeaders().exists(HTTP_HEADER_DATE));
1024 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
unique_ptr< folly::IOBuf > getSynStream(Codec &egressCodec, uint32_t streamID, const HTTPMessage &msg, uint32_t assocStreamId=SPDYCodec::NoStream, bool eom=false, HTTPHeaderSize *size=nullptr)
std::unique_ptr< HTTPMessage > msg
Definition: TestUtils.h:404
void setStatusCode(uint16_t status)
TEST ( SPDYCodecTest  ,
HeaderDoS   
)

Definition at line 1100 of file SPDYCodecTest.cpp.

References folly::IOBuf::copyBuffer(), EXPECT_EQ, proxygen::FakeHTTPCodecCallback::headersComplete, proxygen::FakeHTTPCodecCallback::messageBegin, proxygen::FakeHTTPCodecCallback::messageComplete, multiValuedHeaderAttack, proxygen::SPDYCodec::onIngress(), proxygen::FakeHTTPCodecCallback::sessionErrors, proxygen::HTTPParallelCodec::setCallback(), and proxygen::FakeHTTPCodecCallback::streamErrors.

1100  {
1101  FakeHTTPCodecCallback callbacks;
1102  SPDYCodec ingressCodec(TransportDirection::UPSTREAM,
1103  SPDYVersion::SPDY3);
1104  ingressCodec.setCallback(&callbacks);
1105 
1107  sizeof(multiValuedHeaderAttack));
1108 
1109  ingressCodec.onIngress(*attack);
1110  EXPECT_EQ(callbacks.messageBegin, 0);
1111  EXPECT_EQ(callbacks.headersComplete, 0);
1112  EXPECT_EQ(callbacks.messageComplete, 0);
1113  EXPECT_EQ(callbacks.streamErrors, 1);
1114  EXPECT_EQ(callbacks.sessionErrors, 1);
1115 }
uint8_t multiValuedHeaderAttack[]
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
static std::unique_ptr< IOBuf > copyBuffer(const void *buf, std::size_t size, std::size_t headroom=0, std::size_t minTailroom=0)
Definition: IOBuf.h:1587
TEST ( SPDYCodecTest  ,
DoubleGoawayServer   
)

Definition at line 1119 of file SPDYCodecTest.cpp.

References folly::IOBufQueue::cacheChainLength(), proxygen::HTTPParallelCodec::enableDoubleGoawayDrain(), EXPECT_EQ, EXPECT_FALSE, EXPECT_TRUE, f, proxygen::SPDYCodec::generateGoaway(), proxygen::FakeHTTPCodecCallback::goaways, proxygen::HTTPParallelCodec::isReusable(), proxygen::HTTPParallelCodec::isWaitingToDrain(), max, folly::IOBufQueue::move(), proxygen::SPDYCodec::onIngress(), gmock_output_test::output, and proxygen::HTTPParallelCodec::setCallback().

1119  {
1120  FakeHTTPCodecCallback callbacks;
1121  SPDYCodec egressCodec(TransportDirection::DOWNSTREAM,
1122  SPDYVersion::SPDY3);
1123  SPDYCodec ingressCodec(TransportDirection::UPSTREAM,
1124  SPDYVersion::SPDY3);
1125 
1126  egressCodec.enableDoubleGoawayDrain();
1127  ingressCodec.setCallback(&callbacks);
1128  egressCodec.setCallback(&callbacks);
1129 
1130  unsigned ack = std::numeric_limits<int32_t>::max();
1131  auto f = [&] () {
1133  egressCodec.generateGoaway(output, ack, ErrorCode::NO_ERROR);
1134  auto ingress = output.move();
1135  ingressCodec.onIngress(*ingress);
1136  ack -= 2;
1137  };
1138 
1139  EXPECT_TRUE(egressCodec.isReusable());
1140  EXPECT_FALSE(egressCodec.isWaitingToDrain());
1141  EXPECT_TRUE(ingressCodec.isReusable());
1142  f();
1143  // server spdy codec remains reusable after the first goaway
1144  EXPECT_TRUE(egressCodec.isReusable());
1145  EXPECT_TRUE(egressCodec.isWaitingToDrain());
1146  f();
1147  EXPECT_FALSE(egressCodec.isReusable());
1148  EXPECT_FALSE(egressCodec.isWaitingToDrain());
1149 
1150  EXPECT_EQ(2, callbacks.goaways);
1151 }
auto f
LogLevel max
Definition: LogLevel.cpp:31
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
static Options cacheChainLength()
Definition: IOBufQueue.h:83
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
TEST ( SPDYCodecTest  ,
DoubleGoawayClient   
)

Definition at line 1153 of file SPDYCodecTest.cpp.

References folly::IOBufQueue::cacheChainLength(), proxygen::HTTPParallelCodec::enableDoubleGoawayDrain(), EXPECT_EQ, EXPECT_FALSE, EXPECT_TRUE, f, proxygen::SPDYCodec::generateGoaway(), proxygen::FakeHTTPCodecCallback::goaways, proxygen::HTTPParallelCodec::isReusable(), proxygen::HTTPParallelCodec::isWaitingToDrain(), max, folly::IOBufQueue::move(), proxygen::SPDYCodec::onIngress(), gmock_output_test::output, and proxygen::HTTPParallelCodec::setCallback().

1153  {
1154  FakeHTTPCodecCallback callbacks;
1155  SPDYCodec egressCodec(TransportDirection::UPSTREAM,
1156  SPDYVersion::SPDY3);
1157  SPDYCodec ingressCodec(TransportDirection::DOWNSTREAM,
1158  SPDYVersion::SPDY3);
1159 
1160  egressCodec.enableDoubleGoawayDrain();
1161  ingressCodec.setCallback(&callbacks);
1162  egressCodec.setCallback(&callbacks);
1163 
1164  unsigned ack = std::numeric_limits<int32_t>::max();
1165  auto f = [&] () {
1167  egressCodec.generateGoaway(output, ack, ErrorCode::NO_ERROR);
1168  auto ingress = output.move();
1169  ingressCodec.onIngress(*ingress);
1170  ack -= 2;
1171  };
1172 
1173  EXPECT_TRUE(egressCodec.isReusable());
1174  EXPECT_FALSE(egressCodec.isWaitingToDrain());
1175  f();
1176  // client spdy codec not reusable after the first goaway
1177  EXPECT_FALSE(egressCodec.isReusable());
1178  EXPECT_TRUE(egressCodec.isWaitingToDrain());
1179  EXPECT_FALSE(ingressCodec.isReusable());
1180  f();
1181  EXPECT_FALSE(egressCodec.isReusable());
1182  EXPECT_FALSE(egressCodec.isWaitingToDrain());
1183  EXPECT_FALSE(ingressCodec.isReusable());
1184 
1185  EXPECT_EQ(2, callbacks.goaways);
1186 }
auto f
LogLevel max
Definition: LogLevel.cpp:31
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
static Options cacheChainLength()
Definition: IOBufQueue.h:83
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
TEST ( SPDYCodecTest  ,
SingleGoawayClient   
)

Definition at line 1189 of file SPDYCodecTest.cpp.

References folly::IOBufQueue::cacheChainLength(), EXPECT_EQ, EXPECT_FALSE, EXPECT_TRUE, f, proxygen::SPDYCodec::generateGoaway(), proxygen::FakeHTTPCodecCallback::goaways, proxygen::HTTPParallelCodec::isReusable(), proxygen::HTTPParallelCodec::isWaitingToDrain(), folly::IOBufQueue::move(), proxygen::SPDYCodec::onIngress(), gmock_output_test::output, and proxygen::HTTPParallelCodec::setCallback().

1189  {
1190  FakeHTTPCodecCallback callbacks;
1191  SPDYCodec egressCodec(TransportDirection::UPSTREAM,
1192  SPDYVersion::SPDY3);
1193  SPDYCodec ingressCodec(TransportDirection::DOWNSTREAM,
1194  SPDYVersion::SPDY3);
1195 
1196  ingressCodec.setCallback(&callbacks);
1197  egressCodec.setCallback(&callbacks);
1198 
1199  unsigned ack = 0;
1200  auto f = [&] () {
1202  egressCodec.generateGoaway(output, ack, ErrorCode::NO_ERROR);
1203  auto ingress = output.move();
1204  ingressCodec.onIngress(*ingress);
1205  ack -= 2;
1206  };
1207 
1208  EXPECT_TRUE(egressCodec.isReusable());
1209  EXPECT_TRUE(egressCodec.isWaitingToDrain());
1210  f();
1211  // client spdy codec not reusable after the first goaway
1212  EXPECT_FALSE(egressCodec.isReusable());
1213  EXPECT_FALSE(egressCodec.isWaitingToDrain());
1214  EXPECT_FALSE(ingressCodec.isReusable());
1215 
1216  EXPECT_EQ(1, callbacks.goaways);
1217 }
auto f
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
static Options cacheChainLength()
Definition: IOBufQueue.h:83
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
TEST ( SPDYCodecTest  ,
OddHeaderListTest   
)

Definition at line 1235 of file SPDYCodecTest.cpp.

References folly::IOBuf::copyBuffer(), EXPECT_EQ, proxygen::FakeHTTPCodecCallback::headersComplete, invalidHeaderPlusEmptyBlock, proxygen::FakeHTTPCodecCallback::messageBegin, proxygen::SPDYCodec::onIngress(), proxygen::HTTPParallelCodec::setCallback(), and proxygen::FakeHTTPCodecCallback::streamErrors.

1235  {
1236  FakeHTTPCodecCallback callbacks;
1237  SPDYCodec ingressCodec(TransportDirection::DOWNSTREAM,
1238  SPDYVersion::SPDY3);
1239  ingressCodec.setCallback(&callbacks);
1240 
1242  sizeof(invalidHeaderPlusEmptyBlock));
1243 
1244  ingressCodec.onIngress(*attack);
1245  EXPECT_EQ(callbacks.messageBegin, 1);
1246  EXPECT_EQ(callbacks.headersComplete, 1);
1247  EXPECT_EQ(callbacks.streamErrors, 1);
1248 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
static std::unique_ptr< IOBuf > copyBuffer(const void *buf, std::size_t size, std::size_t headroom=0, std::size_t minTailroom=0)
Definition: IOBuf.h:1587
uint8_t invalidHeaderPlusEmptyBlock[]
TEST ( SPDYCodecTest  ,
SendRstParsingFrame   
)

Definition at line 1252 of file SPDYCodecTest.cpp.

References testing::_, folly::IOBufQueue::append(), folly::IOBufQueue::cacheChainLength(), EXPECT_CALL, proxygen::SPDYCodec::generateEOM(), proxygen::SPDYCodec::generateRstStream(), getSynStream(), testing::InvokeWithoutArgs(), folly::IOBufQueue::move(), folly::gen::move, proxygen::SPDYCodec::onIngress(), and proxygen::HTTPParallelCodec::setCallback().

1252  {
1254  SPDYCodec egressCodec(TransportDirection::UPSTREAM,
1255  SPDYVersion::SPDY3_1);
1256  SPDYCodec ingressCodec(TransportDirection::DOWNSTREAM,
1257  SPDYVersion::SPDY3_1);
1260 
1261  InSequence enforceOrder;
1262 
1263  EXPECT_CALL(callbacks, onHeadersComplete(3, _))
1264  .WillOnce(InvokeWithoutArgs([&] {
1265  ingressCodec.generateRstStream(ingressCodecQueue,
1266  1, ErrorCode::CANCEL);
1267  }));
1268  EXPECT_CALL(callbacks, onMessageComplete(3, false));
1269 
1270  ingressCodec.setCallback(&callbacks);
1271  auto syn = getSynStream(egressCodec, 3);
1272  egressCodecQueue.append(std::move(syn));
1273  egressCodec.generateEOM(egressCodecQueue, 3);
1274  auto ingress = egressCodecQueue.move();
1275  ingress->coalesce();
1276  ingressCodec.onIngress(*ingress);
1277 }
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
PolymorphicAction< internal::InvokeWithoutArgsAction< FunctionImpl > > InvokeWithoutArgs(FunctionImpl function_impl)
static Options cacheChainLength()
Definition: IOBufQueue.h:83
unique_ptr< folly::IOBuf > getSynStream(Codec &egressCodec, uint32_t streamID, const HTTPMessage &msg, uint32_t assocStreamId=SPDYCodec::NoStream, bool eom=false, HTTPHeaderSize *size=nullptr)
#define EXPECT_CALL(obj, call)
const internal::AnythingMatcher _
TEST ( SPDYCodecTest  ,
BadNumNameValues   
)

Definition at line 1303 of file SPDYCodecTest.cpp.

References folly::IOBuf::copyBuffer(), EXPECT_EQ, proxygen::FakeHTTPCodecCallback::headersComplete, invalidNumNameValuesBlock, proxygen::FakeHTTPCodecCallback::messageBegin, proxygen::SPDYCodec::onIngress(), proxygen::FakeHTTPCodecCallback::sessionErrors, proxygen::HTTPParallelCodec::setCallback(), and proxygen::FakeHTTPCodecCallback::streamErrors.

1303  {
1304  FakeHTTPCodecCallback callbacks;
1305  SPDYCodec ingressCodec(TransportDirection::DOWNSTREAM,
1306  SPDYVersion::SPDY3_1);
1307  ingressCodec.setCallback(&callbacks);
1308 
1310  sizeof(invalidNumNameValuesBlock));
1311 
1312  ingressCodec.onIngress(*attack);
1313  EXPECT_EQ(callbacks.messageBegin, 0);
1314  EXPECT_EQ(callbacks.headersComplete, 0);
1315  EXPECT_EQ(callbacks.streamErrors, 0);
1316  EXPECT_EQ(callbacks.sessionErrors, 1);
1317 }
uint8_t invalidNumNameValuesBlock[]
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
static std::unique_ptr< IOBuf > copyBuffer(const void *buf, std::size_t size, std::size_t headroom=0, std::size_t minTailroom=0)
Definition: IOBuf.h:1587
TEST ( SPDYCodecTest  ,
ShortSettings   
)

Definition at line 1323 of file SPDYCodecTest.cpp.

References folly::IOBuf::copyBuffer(), EXPECT_EQ, proxygen::FakeHTTPCodecCallback::headersComplete, kShortSettings, proxygen::FakeHTTPCodecCallback::messageBegin, proxygen::SPDYCodec::onIngress(), proxygen::FakeHTTPCodecCallback::sessionErrors, proxygen::HTTPParallelCodec::setCallback(), and proxygen::FakeHTTPCodecCallback::streamErrors.

1323  {
1324  FakeHTTPCodecCallback callbacks;
1325  SPDYCodec ingressCodec(TransportDirection::DOWNSTREAM,
1326  SPDYVersion::SPDY3_1);
1327  ingressCodec.setCallback(&callbacks);
1328 
1330  sizeof(kShortSettings));
1331 
1332  ingressCodec.onIngress(*attack);
1333  EXPECT_EQ(callbacks.messageBegin, 0);
1334  EXPECT_EQ(callbacks.headersComplete, 0);
1335  EXPECT_EQ(callbacks.streamErrors, 0);
1336  EXPECT_EQ(callbacks.sessionErrors, 1);
1337 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
const uint8_t kShortSettings[]
static std::unique_ptr< IOBuf > copyBuffer(const void *buf, std::size_t size, std::size_t headroom=0, std::size_t minTailroom=0)
Definition: IOBuf.h:1587
TEST ( SPDYCodecTest  ,
SegmentedHeaderBlock   
)

Definition at line 1339 of file SPDYCodecTest.cpp.

References ch, EXPECT_EQ, proxygen::HTTPMessage::getHeaders(), getSynStream(), proxygen::FakeHTTPCodecCallback::headersComplete, huge, i, proxygen::FakeHTTPCodecCallback::msg, proxygen::SPDYCodec::onIngress(), proxygen::FakeHTTPCodecCallback::reset(), proxygen::FakeHTTPCodecCallback::sessionErrors, proxygen::HTTPHeaders::set(), proxygen::HTTPParallelCodec::setCallback(), proxygen::HTTPMessage::setMethod(), proxygen::HTTPMessage::setStatusCode(), proxygen::HTTPMessage::setURL(), folly::size(), proxygen::FakeHTTPCodecCallback::streamErrors, and uint32_t.

1339  {
1340  SPDYCodec egressCodec(TransportDirection::UPSTREAM,
1341  SPDYVersion::SPDY3_1);
1342  SPDYCodec ingressCodec(TransportDirection::DOWNSTREAM,
1343  SPDYVersion::SPDY3_1);
1344  // generate huge string to use as a header value
1345  string huge;
1346  uint32_t size = 20000;
1347  char ch = 'a';
1348  for (uint32_t i = 0; i < size; i++) {
1349  huge.push_back(ch);
1350  if (ch == 'z') {
1351  ch = 'a';
1352  } else {
1353  ch++;
1354  }
1355  }
1356  HTTPMessage req;
1357  req.setMethod("GET");
1358  req.setURL("http://www.facebook.com");
1359  auto& reqHeaders = req.getHeaders();
1360  reqHeaders.set("HOST", "www.facebook.com");
1361  // setting this huge header value will cause allocation of a separate IOBuf
1362  reqHeaders.set("X-FB-Huge", huge);
1363  auto buf = getSynStream(egressCodec, 1, req);
1364  FakeHTTPCodecCallback callbacks;
1365  ingressCodec.setCallback(&callbacks);
1366  ingressCodec.onIngress(*buf);
1367  EXPECT_EQ(callbacks.streamErrors, 0);
1368  EXPECT_EQ(callbacks.sessionErrors, 0);
1369  EXPECT_EQ(callbacks.headersComplete, 1);
1370  EXPECT_EQ(callbacks.msg->getHeaders().getSingleOrEmpty("x-fb-huge").size(),
1371  size);
1372 
1373  // do it for responses
1374  HTTPMessage resp;
1375  resp.setStatusCode(200);
1376  resp.setStatusMessage("OK");
1377  auto& respHeaders = resp.getHeaders();
1378  respHeaders.set("X-FB-Huge", huge);
1379  auto buf2 = getSynStream(ingressCodec, 1, resp);
1380  callbacks.reset();
1381  egressCodec.setCallback(&callbacks);
1382  egressCodec.onIngress(*buf2);
1383  EXPECT_EQ(callbacks.streamErrors, 0);
1384  EXPECT_EQ(callbacks.sessionErrors, 0);
1385  EXPECT_EQ(callbacks.headersComplete, 1);
1386  EXPECT_EQ(callbacks.msg->getHeaders().getSingleOrEmpty("x-fb-huge").size(),
1387  size);
1388 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
auto ch
void set(folly::StringPiece name, const std::string &value)
Definition: HTTPHeaders.h:119
constexpr auto size(C const &c) -> decltype(c.size())
Definition: Access.h:45
ParseURL setURL(T &&url)
Definition: HTTPMessage.h:183
HTTPHeaders & getHeaders()
Definition: HTTPMessage.h:273
auto huge
void setMethod(HTTPMethod method)
unique_ptr< folly::IOBuf > getSynStream(Codec &egressCodec, uint32_t streamID, const HTTPMessage &msg, uint32_t assocStreamId=SPDYCodec::NoStream, bool eom=false, HTTPHeaderSize *size=nullptr)
std::unique_ptr< HTTPMessage > msg
Definition: TestUtils.h:404
void setStatusCode(uint16_t status)
TEST ( SPDYCodecTest  ,
ColonHeaders   
)

Definition at line 1397 of file SPDYCodecTest.cpp.

References folly::IOBuf::copyBuffer(), EXPECT_EQ, proxygen::FakeHTTPCodecCallback::headersComplete, kColonHeaders, proxygen::SPDYCodec::onIngress(), proxygen::FakeHTTPCodecCallback::sessionErrors, proxygen::HTTPParallelCodec::setCallback(), and proxygen::FakeHTTPCodecCallback::streamErrors.

1397  {
1398  FakeHTTPCodecCallback callbacks;
1399  SPDYCodec ingressCodec(TransportDirection::DOWNSTREAM,
1400  SPDYVersion::SPDY3_1);
1401  ingressCodec.setCallback(&callbacks);
1402 
1403  auto testBuf = folly::IOBuf::copyBuffer(kColonHeaders,
1404  sizeof(kColonHeaders));
1405 
1406  ingressCodec.onIngress(*testBuf);
1407  EXPECT_EQ(callbacks.headersComplete, 0);
1408  EXPECT_EQ(callbacks.streamErrors, 1);
1409  EXPECT_EQ(callbacks.sessionErrors, 0);
1410 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
static std::unique_ptr< IOBuf > copyBuffer(const void *buf, std::size_t size, std::size_t headroom=0, std::size_t minTailroom=0)
Definition: IOBuf.h:1587
const uint8_t kColonHeaders[]
TEST ( SPDYCodecTest  ,
StreamIdOverflow   
)

Definition at line 1412 of file SPDYCodecTest.cpp.

References codec, proxygen::HTTPParallelCodec::createStream(), EXPECT_EQ, proxygen::HTTPParallelCodec::isReusable(), max, and proxygen::HTTPParallelCodec::setNextEgressStreamId().

1412  {
1413  SPDYCodec codec(TransportDirection::UPSTREAM,
1414  SPDYVersion::SPDY3_1);
1415 
1416  HTTPCodec::StreamID streamId;
1417  codec.setNextEgressStreamId(std::numeric_limits<int32_t>::max() - 10);
1418  while (codec.isReusable()) {
1419  streamId = codec.createStream();
1420  }
1422 }
LogLevel max
Definition: LogLevel.cpp:31
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
CodecFactory codec
uint64_t StreamID
Definition: HTTPCodec.h:49
TEST ( SPDYCodecTest  ,
BadNVBlock   
)

Test case where nv item length is greater than total frame length

Definition at line 1435 of file SPDYCodecTest.cpp.

References folly::IOBuf::copyBuffer(), EXPECT_EQ, proxygen::FakeHTTPCodecCallback::headersComplete, kBufBadNVBlock, proxygen::SPDYCodec::onIngress(), proxygen::FakeHTTPCodecCallback::sessionErrors, proxygen::HTTPParallelCodec::setCallback(), and proxygen::FakeHTTPCodecCallback::streamErrors.

1435  {
1436  FakeHTTPCodecCallback callbacks;
1437  SPDYCodec ingressCodec(TransportDirection::DOWNSTREAM,
1438  SPDYVersion::SPDY3_1);
1439 
1440  auto testBuf = IOBuf::copyBuffer(kBufBadNVBlock, sizeof(kBufBadNVBlock));
1441  ingressCodec.setCallback(&callbacks);
1442  ingressCodec.onIngress(*testBuf);
1443  EXPECT_EQ(callbacks.headersComplete, 0);
1444  EXPECT_EQ(callbacks.streamErrors, 0);
1445  EXPECT_EQ(callbacks.sessionErrors, 1);
1446 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
std::unique_ptr< IOBuf > copyBuffer(const folly::IOBuf &buf)
const uint8_t kBufBadNVBlock[]
TEST_F ( SPDYCodecTestF  ,
GoawayHandling   
)

Definition at line 1460 of file SPDYCodecTest.cpp.

References proxygen::HTTPHeaders::add(), folly::IOBufQueue::cacheChainLength(), wangle::HTTPHeaderSize::compressed, dummy(), EXPECT_EQ, EXPECT_GT, proxygen::getGetRequest(), proxygen::HTTPMessage::getHeaders(), makeBuf(), parse(), proxygen::HTTPMessage::setPushStatusCode(), proxygen::HTTPMessage::setStatusCode(), folly::size(), and wangle::HTTPHeaderSize::uncompressed.

1460  {
1461  // send request
1462  HTTPMessage req = getGetRequest();
1464  size.uncompressed = size.compressed = 0;
1465  upstreamCodec_.generateHeader(output_, 1, req, true, &size);
1466  EXPECT_GT(size.uncompressed, 0);
1467  parse();
1468  callbacks_.expectMessage(true, 2, "/");
1469  callbacks_.reset();
1470 
1471  SetUpUpstreamTest();
1472  // drain after this message
1473  downstreamCodec_.generateGoaway(output_, 1, ErrorCode::NO_ERROR);
1474  parseUpstream();
1475  // upstream cannot generate id > 1
1476  upstreamCodec_.generateHeader(output_, 3, req, false, &size);
1477  EXPECT_EQ(size.uncompressed, 0);
1478  upstreamCodec_.generateWindowUpdate(output_, 3, 100);
1479  upstreamCodec_.generateBody(output_, 3, makeBuf(10), HTTPCodec::NoPadding,
1480  false);
1481  upstreamCodec_.generatePriority(output_, 3,
1482  HTTPMessage::HTTPPriority(0, true, 1));
1483  upstreamCodec_.generateEOM(output_, 3);
1484  upstreamCodec_.generateRstStream(output_, 3, ErrorCode::CANCEL);
1485  EXPECT_EQ(output_.chainLength(), 0);
1486 
1487  // send a push promise that will be rejected by downstream
1488  req.setPushStatusCode(200);
1489  req.getHeaders().add("foomonkey", "george");
1490  downstreamCodec_.generatePushPromise(output_, 2, req, 1, false, &size);
1491  EXPECT_GT(size.uncompressed, 0);
1492  // window update for push doesn't make any sense, but whatever
1493  downstreamCodec_.generateWindowUpdate(output_, 2, 100);
1494  downstreamCodec_.generateBody(output_, 2, makeBuf(10), HTTPCodec::NoPadding,
1495  false);
1496 
1497  // tell the upstream no pushing, and parse the first batch
1498  IOBufQueue dummy{IOBufQueue::cacheChainLength()};
1499  upstreamCodec_.generateGoaway(dummy, 0, ErrorCode::NO_ERROR);
1500  parseUpstream();
1501 
1502  downstreamCodec_.generatePriority(output_, 2,
1503  HTTPMessage::HTTPPriority(0, true, 1));
1504  downstreamCodec_.generateEOM(output_, 2);
1505  downstreamCodec_.generateRstStream(output_, 2, ErrorCode::CANCEL);
1506 
1507  // send a response that will be accepted, headers should be ok
1508  HTTPMessage resp;
1509  resp.setStatusCode(200);
1510  downstreamCodec_.generateHeader(output_, 1, resp, true, &size);
1511  EXPECT_GT(size.uncompressed, 0);
1512 
1513  // parse the remainder
1514  parseUpstream();
1515  callbacks_.expectMessage(true, 1, 200);
1516 }
size_t parse(const char *buf, size_t len)
Definition: test.c:1591
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
void setPushStatusCode(const uint16_t status)
std::unique_ptr< folly::IOBuf > makeBuf(uint32_t size)
Definition: ZlibTests.cpp:26
constexpr auto size(C const &c) -> decltype(c.size())
Definition: Access.h:45
void dummy()
HTTPHeaders & getHeaders()
Definition: HTTPMessage.h:273
std::tuple< uint32_t, bool, uint8_t > HTTPPriority
Definition: HTTPMessage.h:592
HTTPMessage getGetRequest(const std::string &url)
Definition: TestUtils.cpp:76
void add(folly::StringPiece name, folly::StringPiece value)
Definition: HTTPHeaders.cpp:52
#define EXPECT_GT(val1, val2)
Definition: gtest.h:1934
void setStatusCode(uint16_t status)

Variable Documentation

uint8_t badType[]
Initial value:
=
{ 0x80, 0x03, 0x00, 0x0A,
0x00, 0x00, 0x00, 0x05,
0x00, 0x00, 0x00, 0x00,
0x00
}

Definition at line 86 of file SPDYCodecTest.cpp.

Referenced by TEST().

uint8_t invalidHeaderPlusEmptyBlock[]
Initial value:
=
{ 0x80, 0x03, 0x00, 0x02, 0xc4, 0x00, 0x00, 0x14,
0xf7, 0x76, 0x2d, 0x37, 0x78, 0x9c, 0x93, 0x60,
0x00, 0x03, 0x75, 0x06, 0xbd, 0x76, 0x21, 0xb2,
0xd0, 0xd9, 0x54, 0x91, 0x80, 0x03, 0x00, 0x01,
0x4e, 0x00, 0x00, 0x0a, 0xbe, 0x14, 0x31, 0x55,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00
}

Definition at line 1222 of file SPDYCodecTest.cpp.

Referenced by TEST().

uint8_t invalidNumNameValuesBlock[]
Initial value:
= {
0x80, 0x03, 0x00, 0x01, 0x00, 0x00, 0x00, 0x91,
0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01,
0x00, 0x00, 0x38, 0x30, 0xe3, 0xc6, 0xa7, 0xc2,
0x00, 0x77, 0x00, 0x88, 0xff, 0x00, 0x00, 0x00,
0x05, 0x00, 0x00, 0x00, 0x05, 0x3a, 0x68, 0x6f,
0x73, 0x74, 0x00, 0x00, 0x00, 0x0b, 0x77, 0x77,
0x77, 0x2e, 0x66, 0x6f, 0x6f, 0x2e, 0x63, 0x6f,
0x6d, 0x00, 0x00, 0x00, 0x77, 0x3a, 0x6d, 0x65,
0x74, 0x68, 0x6f, 0x64, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x05, 0x3a, 0x70, 0x61, 0x74,
0x68, 0x00, 0x13, 0x00, 0x14, 0x68, 0x74, 0x74,
0x39, 0x73, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77,
0x2e, 0x66, 0x6f, 0x6f, 0x2e, 0x63, 0x6f, 0x6d,
0x2f, 0x00, 0x00, 0x00, 0x07, 0x3a, 0x73, 0x63,
0x68, 0x65, 0x6d, 0x65, 0x00, 0x00, 0x00, 0x04,
0x68, 0x74, 0x74, 0x70, 0x00, 0x00, 0x00, 0x08,
0x3a, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e,
0x00, 0x00, 0x00, 0x08, 0x48, 0x54, 0x54, 0x50,
0x2f, 0x31, 0x2e, 0x31, 0x00, 0x00, 0x00, 0xff,
0xff
}

Definition at line 1279 of file SPDYCodecTest.cpp.

Referenced by TEST().

const uint8_t kBufBadNVBlock[]
Initial value:
= {
0x80, 0x03, 0x00, 0x01, 0x00, 0x00, 0x00, 0x1c,
0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x78, 0xbb, 0xe3, 0xc6, 0xa7, 0xc2,
0x02, 0xa6, 0x23, 0xc6, 0xff, 0x40, 0x00, 0x00,
0x00, 0x00, 0xff, 0xff
}

Definition at line 1424 of file SPDYCodecTest.cpp.

Referenced by TEST().

const uint8_t kColonHeaders[]
Initial value:
= {
0x80, 0x03, 0x00, 0x01, 0x48, 0x00, 0x00, 0x1a, 0xf6, 0xf6, 0x1a, 0xb5,
0x00, 0x00, 0x00, 0x00, 0x17, 0x28, 0x28, 0x53, 0x62, 0x60, 0x60, 0x10,
0x60, 0x60, 0x60, 0x60, 0xb4, 0x1a, 0xbc, 0x84, 0xa4, 0xa4
}

Definition at line 1390 of file SPDYCodecTest.cpp.

Referenced by TEST().

const uint8_t kShortSettings[]
Initial value:
= {
0x80, 0x03, 0x00, 0x04, 0xee, 0x00, 0x00, 0x01, 0x00, 0x00
}

Definition at line 1319 of file SPDYCodecTest.cpp.

Referenced by TEST().

uint8_t longPing[]
Initial value:
=
{ 0x80, 0x03, 0x00, 0x06,
0x00, 0x00, 0x00, 0x05,
0x00, 0x00, 0x00, 0x00,
0x00
}

Definition at line 69 of file SPDYCodecTest.cpp.

Referenced by TEST().

uint8_t multiple_path_headers[]
Initial value:
=
{0x80, 0x03, 0x00, 0x01, 0x01, 0x00, 0x01, 0x13, 0x00, 0x00, 0x00, 0x01,
0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 0x38, 0x30, 0xe3, 0xc6, 0xa7, 0xc2,
0x00, 0xf9, 0x00, 0x06, 0xff, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
0x05, 0x3a, 0x68, 0x6f, 0x73, 0x74, 0x00, 0x00, 0x00, 0x10, 0x77, 0x77,
0x77, 0x2e, 0x66, 0x61, 0x63, 0x65, 0x62, 0x6f, 0x6f, 0x6b, 0x2e, 0x63,
0x6f, 0x6d, 0x00, 0x00, 0x00, 0x07, 0x3a, 0x6d, 0x65, 0x74, 0x68, 0x6f,
0x64, 0x00, 0x00, 0x00, 0x03, 0x47, 0x45, 0x54, 0x00, 0x00, 0x00, 0x05,
0x3a, 0x70, 0x61, 0x74, 0x68, 0x00, 0x00, 0x00, 0x35, 0x2f, 0x65, 0x6e,
0x63, 0x72, 0x79, 0x70, 0x74, 0x65, 0x64, 0x72, 0x65, 0x71, 0x75, 0x65,
0x73, 0x74, 0x00, 0x2a, 0x23, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e,
0x2f, 0x61, 0x67, 0x65, 0x6e, 0x74, 0x2f, 0x73, 0x69, 0x74, 0x65, 0x5f,
0x76, 0x61, 0x72, 0x69, 0x61, 0x62, 0x6c, 0x65, 0x73, 0x2e, 0x70, 0x68,
0x70, 0x3f, 0x00, 0x00, 0x00, 0x07, 0x3a, 0x73, 0x63, 0x68, 0x65, 0x6d,
0x65, 0x00, 0x00, 0x00, 0x05, 0x68, 0x74, 0x74, 0x70, 0x73, 0x00, 0x00,
0x00, 0x08, 0x3a, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x00, 0x00,
0x00, 0x08, 0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x31, 0x00, 0x00,
0x00, 0x06, 0x61, 0x63, 0x63, 0x65, 0x70, 0x74, 0x00, 0x00, 0x00, 0x03,
0x2a, 0x2f, 0x2a, 0x00, 0x00, 0x00, 0x0f, 0x61, 0x63, 0x63, 0x65, 0x70,
0x74, 0x2d, 0x65, 0x6e, 0x63, 0x6f, 0x64, 0x69, 0x6e, 0x67, 0x00, 0x00,
0x00, 0x0d, 0x67, 0x7a, 0x69, 0x70, 0x2c, 0x20, 0x64, 0x65, 0x66, 0x6c,
0x61, 0x74, 0x65, 0x00, 0x00, 0x00, 0x0a, 0x75, 0x73, 0x65, 0x72, 0x2d,
0x61, 0x67, 0x65, 0x6e, 0x74, 0x00, 0x00, 0x00, 0x11, 0x73, 0x70, 0x64,
0x79, 0x6c, 0x61, 0x79, 0x2f, 0x31, 0x2e, 0x33, 0x2e, 0x33, 0x2d, 0x44,
0x45, 0x56, 0x00, 0x00, 0x00, 0xff, 0xff, 0x80, 0x03, 0x00, 0x07, 0x00,
0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}

Definition at line 576 of file SPDYCodecTest.cpp.

Referenced by TEST().

uint8_t multiValuedHeaderAttack[]

Definition at line 1027 of file SPDYCodecTest.cpp.

Referenced by TEST().

uint8_t pushStreamWithHostMissing[]
Initial value:
=
{ 0x80, 0x3, 0x0, 0x1, 0x2, 0x0, 0x0, 0x7c,
0x0, 0x0, 0x0, 0x2, 0x0, 0x0, 0x0, 0x1,
0x0, 0x0, 0x38, 0x30, 0xe3, 0xc6, 0xa7, 0xc2,
0x0, 0x62, 0x0, 0x9d, 0xff, 0x0, 0x0, 0x0,
0x4, 0x0, 0x0, 0x0, 0x5, 0x3a, 0x70, 0x61,
0x74, 0x68, 0x0, 0x0, 0x0, 0x14, 0x68, 0x74,
0x74, 0x70, 0x73, 0x3a, 0x2f, 0x2f, 0x77, 0x77,
0x77, 0x2e, 0x66, 0x6f, 0x6f, 0x2e, 0x63, 0x6f,
0x6d, 0x2f, 0x0, 0x0, 0x0, 0x7, 0x3a, 0x73,
0x63, 0x68, 0x65, 0x6d, 0x65, 0x0, 0x0, 0x0,
0x4, 0x68, 0x74, 0x74, 0x70, 0x0, 0x0, 0x0,
0x7, 0x3a, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73,
0x0, 0x0, 0x0, 0x3, 0x32, 0x30, 0x30, 0x0,
0x0, 0x0, 0x8, 0x3a, 0x76, 0x65, 0x72, 0x73,
0x69, 0x6f, 0x6e, 0x0, 0x0, 0x0, 0x8, 0x48,
0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x31, 0x0,
0x0, 0x0, 0xff, 0xff
}

A push stream with Host header missing

Definition at line 724 of file SPDYCodecTest.cpp.

Referenced by TEST().

uint8_t pushStreamWithOddId[]
Initial value:
=
{ 0x80, 0x03, 0x00, 0x01, 0x02, 0x00, 0x00, 0x91,
0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01,
0x00, 0x00, 0x38, 0x30, 0xe3, 0xc6, 0xa7, 0xc2,
0x00, 0x77, 0x00, 0x88, 0xff, 0x00, 0x00, 0x00,
0x05, 0x00, 0x00, 0x00, 0x05, 0x3a, 0x68, 0x6f,
0x73, 0x74, 0x00, 0x00, 0x00, 0x0b, 0x77, 0x77,
0x77, 0x2e, 0x66, 0x6f, 0x6f, 0x2e, 0x63, 0x6f,
0x6d, 0x00, 0x00, 0x00, 0x07, 0x3a, 0x6d, 0x65,
0x74, 0x68, 0x6f, 0x64, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x05, 0x3a, 0x70, 0x61, 0x74,
0x68, 0x00, 0x00, 0x00, 0x14, 0x68, 0x74, 0x74,
0x70, 0x73, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77,
0x2e, 0x66, 0x6f, 0x6f, 0x2e, 0x63, 0x6f, 0x6d,
0x2f, 0x00, 0x00, 0x00, 0x07, 0x3a, 0x73, 0x63,
0x68, 0x65, 0x6d, 0x65, 0x00, 0x00, 0x00, 0x04,
0x68, 0x74, 0x74, 0x70, 0x00, 0x00, 0x00, 0x08,
0x3a, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e,
0x00, 0x00, 0x00, 0x08, 0x48, 0x54, 0x54, 0x50,
0x2f, 0x31, 0x2e, 0x31, 0x00, 0x00, 0x00, 0xff,
0xff
}

A push stream with an odd StreamID

Definition at line 764 of file SPDYCodecTest.cpp.

Referenced by TEST().

uint8_t pushStreamWithoutAssoc[]
Initial value:
=
{ 0x80, 0x03, 0x00, 0x01, 0x02, 0x00, 0x00, 0x91,
0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x38, 0x30, 0xe3, 0xc6, 0xa7, 0xc2,
0x00, 0x77, 0x00, 0x88, 0xff, 0x00, 0x00, 0x00,
0x05, 0x00, 0x00, 0x00, 0x05, 0x3a, 0x68, 0x6f,
0x73, 0x74, 0x00, 0x00, 0x00, 0x0b, 0x77, 0x77,
0x77, 0x2e, 0x66, 0x6f, 0x6f, 0x2e, 0x63, 0x6f,
0x6d, 0x00, 0x00, 0x00, 0x07, 0x3a, 0x6d, 0x65,
0x74, 0x68, 0x6f, 0x64, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x05, 0x3a, 0x70, 0x61, 0x74,
0x68, 0x00, 0x00, 0x00, 0x14, 0x68, 0x74, 0x74,
0x70, 0x73, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77,
0x2e, 0x66, 0x6f, 0x6f, 0x2e, 0x63, 0x6f, 0x6d,
0x2f, 0x00, 0x00, 0x00, 0x07, 0x3a, 0x73, 0x63,
0x68, 0x65, 0x6d, 0x65, 0x00, 0x00, 0x00, 0x04,
0x68, 0x74, 0x74, 0x70, 0x00, 0x00, 0x00, 0x08,
0x3a, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e,
0x00, 0x00, 0x00, 0x08, 0x48, 0x54, 0x54, 0x50,
0x2f, 0x31, 0x2e, 0x31, 0x00, 0x00, 0x00, 0xff,
0xff
}

A push stream with assocStreamID = SPDYCodec::NoStream

Definition at line 850 of file SPDYCodecTest.cpp.

Referenced by TEST().

uint8_t pushStreamWithoutUnidirectional[]
Initial value:
=
{ 0x80, 0x03, 0x00, 0x01, 0x00, 0x00, 0x00, 0x91,
0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01,
0x00, 0x00, 0x38, 0x30, 0xe3, 0xc6, 0xa7, 0xc2,
0x00, 0x77, 0x00, 0x88, 0xff, 0x00, 0x00, 0x00,
0x05, 0x00, 0x00, 0x00, 0x05, 0x3a, 0x68, 0x6f,
0x73, 0x74, 0x00, 0x00, 0x00, 0x0b, 0x77, 0x77,
0x77, 0x2e, 0x66, 0x6f, 0x6f, 0x2e, 0x63, 0x6f,
0x6d, 0x00, 0x00, 0x00, 0x07, 0x3a, 0x6d, 0x65,
0x74, 0x68, 0x6f, 0x64, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x05, 0x3a, 0x70, 0x61, 0x74,
0x68, 0x00, 0x00, 0x00, 0x14, 0x68, 0x74, 0x74,
0x70, 0x73, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77,
0x2e, 0x66, 0x6f, 0x6f, 0x2e, 0x63, 0x6f, 0x6d,
0x2f, 0x00, 0x00, 0x00, 0x07, 0x3a, 0x73, 0x63,
0x68, 0x65, 0x6d, 0x65, 0x00, 0x00, 0x00, 0x04,
0x68, 0x74, 0x74, 0x70, 0x00, 0x00, 0x00, 0x08,
0x3a, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e,
0x00, 0x00, 0x00, 0x08, 0x48, 0x54, 0x54, 0x50,
0x2f, 0x31, 0x2e, 0x31, 0x00, 0x00, 0x00, 0xff,
0xff
}

A push stream without unidirectional flag

Definition at line 807 of file SPDYCodecTest.cpp.

Referenced by TEST().

uint8_t shortSynReply[]
Initial value:
=
{ 0x80, 0x02, 0x00, 0x02, 0x01, 0x00, 0x00, 0x04,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
}

A syn reply frame with invalid length

Definition at line 515 of file SPDYCodecTest.cpp.

Referenced by doShortSynReplyTest().

uint8_t shortSynStream[]
Initial value:
=
{ 0x80, 0x03, 0x00, 0x01,
0x01, 0x00, 0x00, 0x04,
0x61, 0x62, 0x63, 0x64
}

Definition at line 32 of file SPDYCodecTest.cpp.

Referenced by TEST().

uint8_t spdy3UnknownCtlFrame[]
Initial value:
=
{ 0x80, 0x03, 0x00, 0x0B,
0x00, 0x00, 0x00, 0x02,
0xD4, 0x74
}

Definition at line 313 of file SPDYCodecTest.cpp.

Referenced by TEST().

uint8_t synStream[]

A request from firefox for facebook.com

Definition at line 108 of file SPDYCodecTest.cpp.

Referenced by TEST().