TEST(SPDYCodecTest, SetSettings) { SPDYCodec codec(TransportDirection::DOWNSTREAM, SPDYVersion::SPDY3); HTTPSettings* settings = codec.getEgressSettings(); // There are 2 settings by default. Turn on another setting settings->setSetting(SettingsId::_SPDY_DOWNLOAD_BANDWIDTH, 10); // This should no-op since this setting should be off by default settings->unsetSetting(SettingsId::_SPDY_ROUND_TRIP_TIME); EXPECT_EQ(settings->getSetting(SettingsId::_SPDY_ROUND_TRIP_TIME), nullptr); EXPECT_EQ(settings->getSetting(SettingsId::_SPDY_CURRENT_CWND), nullptr); EXPECT_EQ(settings->getSetting(SettingsId::MAX_CONCURRENT_STREAMS)->value, spdy::kMaxConcurrentStreams); EXPECT_EQ(settings->getSetting(SettingsId::INITIAL_WINDOW_SIZE)->value, spdy::kInitialWindow); EXPECT_EQ( settings->getSetting(SettingsId::_SPDY_DOWNLOAD_BANDWIDTH)->value, 10); // Turn off one of the defaults settings->unsetSetting(SettingsId::MAX_CONCURRENT_STREAMS); // Change the value of an existing default setting settings->setSetting(SettingsId::INITIAL_WINDOW_SIZE, 123); EXPECT_EQ(settings->getSetting(SettingsId::MAX_CONCURRENT_STREAMS), nullptr); EXPECT_EQ(settings->getSetting(SettingsId::INITIAL_WINDOW_SIZE)->value, 123); EXPECT_EQ(settings->getNumSettings(), 2); // Change the value of a unset setting settings->setSetting(SettingsId::MAX_CONCURRENT_STREAMS, 400); EXPECT_EQ(settings->getSetting(SettingsId::MAX_CONCURRENT_STREAMS)->value, 400); EXPECT_EQ(settings->getNumSettings(), 3); }
TEST_F(HTTP2CodecTest, LongData) { // Hack the max frame size artificially low HTTPSettings* settings = (HTTPSettings*)upstreamCodec_.getIngressSettings(); settings->setSetting(SettingsId::MAX_FRAME_SIZE, 16); auto buf = makeBuf(100); upstreamCodec_.generateBody(output_, 1, std::move(buf->clone()), true); parse(); EXPECT_EQ(callbacks_.messageBegin, 0); EXPECT_EQ(callbacks_.headersComplete, 0); EXPECT_EQ(callbacks_.messageComplete, 1); EXPECT_EQ(callbacks_.bodyCalls, 7); EXPECT_EQ(callbacks_.bodyLength, 100); EXPECT_EQ(callbacks_.streamErrors, 0); EXPECT_EQ(callbacks_.sessionErrors, 0); EXPECT_EQ(callbacks_.data.move()->moveToFbString(), buf->moveToFbString()); }