15 #include <boost/optional/optional_io.hpp> 32 std::function<
bool()> stopFn = [] {
return false; }) {
36 std::uniform_int_distribution<uint32_t> lenDistribution(1, length / 2 + 1);
44 while (length > 0 && !stopFn()) {
50 len = lenDistribution(rng);
57 consumed = codec->onIngress(*input.
front());
58 input.
split(consumed);
59 if (input.
front() ==
nullptr && consumed > 0) {
71 std::function<
bool()> stopFn = [] {
return false; }) {
75 std::uniform_int_distribution<uint32_t> lenDistribution(1, length / 2 + 1);
83 while (length > 0 && !stopFn()) {
89 len = lenDistribution(rng);
97 auto ret = codec->onUnidirectionalIngress(input.
move());
100 if (input.
front() ==
nullptr && consumed > 0) {
129 std::unique_ptr<HTTPMessage> inMsg)
override {
135 std::unique_ptr<folly::IOBuf> chain,
150 std::unique_ptr<HTTPHeaders> inTrailers)
override {
187 std::unique_ptr<folly::IOBuf> debugData)
override {
214 for (
auto& setting: inSettings) {
228 uint16_t requestId, std::unique_ptr<folly::IOBuf> authRequest)
override {
235 std::unique_ptr<folly::IOBuf> authenticator)
override {
273 if (headerCount >= 0) {
278 }
else if (statusCode > 0) {
279 if (
msg->isResponse()) {
338 VLOG(verbosity) <<
"Dumping HTTP codec callback counters";
345 VLOG(verbosity) <<
"bodyCalls: " <<
bodyCalls;
346 VLOG(verbosity) <<
"bodyLength: " <<
bodyLength;
350 VLOG(verbosity) <<
"trailers: " <<
trailers;
351 VLOG(verbosity) <<
"aborts: " <<
aborts;
352 VLOG(verbosity) <<
"goaways: " <<
goaways;
358 VLOG(verbosity) <<
"settings: " <<
settings;
363 VLOG(verbosity) <<
"lastCertId: " <<
lastCertId;
364 VLOG(verbosity) <<
"windowSize: " <<
windowSize;
365 VLOG(verbosity) <<
"maxStreams: " <<
maxStreams;
401 std::map<proxygen::HTTPCodec::StreamID, std::vector<uint32_t> >
windowUpdates;
404 std::unique_ptr<HTTPMessage>
msg;
411 return arg->computeChainDataLength() == n;
418 std::unique_ptr<testing::NiceMock<MockHTTPCodec>>
421 std::unique_ptr<testing::NiceMock<MockHTTPCodec>>
438 std::tuple<std::unique_ptr<HTTPMessage>, std::unique_ptr<folly::IOBuf> >
std::unique_ptr< folly::IOBuf > split(size_t n)
std::unique_ptr< testing::NiceMock< MockHTTPCodec > > makeDownstreamParallelCodec()
std::unique_ptr< folly::IOBuf > makeBuf(uint32_t size)
const folly::IOBuf * front() const
HTTPCodec::StreamID assocStreamId
void append(std::unique_ptr< folly::IOBuf > &&buf, bool pack=false)
bool sessionError() const
size_t chainLength() const
spdy::GoawayStatusCode statusCode
void onMessageBegin(HTTPCodec::StreamID, HTTPMessage *) override
HTTPMessage getChunkedPostRequest()
void onSettingsAck() override
void onMessageComplete(HTTPCodec::StreamID, bool) override
void expectMessageHelper(bool eom, int32_t headerCount, const std::string &url, int32_t statusCode) const
void onChunkHeader(HTTPCodec::StreamID, size_t) override
std::unique_ptr< HTTPException > lastParseError
StreamCodecFactory stream
#define EXPECT_EQ(val1, val2)
void onExMessageBegin(HTTPCodec::StreamID, HTTPCodec::StreamID controlStream, bool unidirectional, HTTPMessage *) override
constexpr detail::Map< Move > move
void onPingReply(uint64_t uniqueID) override
uint32_t certificateRequests
HTTPMessage getBigGetRequest(const std::string &url)
void onGoaway(uint64_t lastStreamId, ErrorCode, std::unique_ptr< folly::IOBuf > debugData) override
void onPingRequest(uint64_t uniqueID) override
size_t parseUnidirectional(T *codec, const uint8_t *inputData, uint32_t length, int32_t atOnce=0, std::function< bool()> stopFn=[]{return false;})
uint32_t windowUpdateCalls
std::function< bool()> getStopFn()
std::unique_ptr< folly::IOBuf > move()
void onPushMessageBegin(HTTPCodec::StreamID, HTTPCodec::StreamID assocStream, HTTPMessage *) override
HTTPCodec::StreamID headersCompleteId
uint32_t numOutgoingStreams() const override
std::unique_ptr< HTTPMessage > makePostRequest(uint32_t contentLength)
void onFrameHeader(HTTPCodec::StreamID, uint8_t, uint64_t, uint8_t, uint16_t) override
requires And< SemiMovable< VN >... > &&SemiMovable< E > auto error(E e)
void expectMessage(bool eom, int32_t headerCount, const std::string &url) const
void setSessionStreamId(HTTPCodec::StreamID streamId)
uint16_t lastCertRequestId
std::map< proxygen::HTTPCodec::StreamID, std::vector< uint32_t > > windowUpdates
void onAbort(HTTPCodec::StreamID, ErrorCode code) override
std::vector< HTTPCodec::StreamID > goawayStreamIds
HTTPCodec::StreamID sessionStreamId
void onPriority(HTTPCodec::StreamID, const HTTPMessage::HTTPPriority &pri) override
constexpr auto size(C const &c) -> decltype(c.size())
std::unique_ptr< HTTPMessage > getPriorityMessage(uint8_t priority)
static Options cacheChainLength()
bool onNativeProtocolUpgrade(HTTPCodec::StreamID, CodecProtocol, const std::string &, HTTPMessage &) override
void onSettings(const SettingsList &inSettings) override
void onBody(HTTPCodec::StreamID, std::unique_ptr< folly::IOBuf > chain, uint16_t padding) override
HTTPMessage getResponse(uint32_t code, uint32_t bodyLen)
void fakeMockCodec(MockHTTPCodec &codec)
void onTrailersComplete(HTTPCodec::StreamID, std::unique_ptr< HTTPHeaders > inTrailers) override
void expectMessage(bool eom, int32_t headerCount, int32_t statusCode) const
void onError(HTTPCodec::StreamID stream, const HTTPException &error, bool) override
std::unique_ptr< HTTPMessage > makeResponse(uint16_t statusCode)
uint32_t numIncomingStreams() const override
std::size_t computeChainDataLength() const
void onCertificate(uint16_t certId, std::unique_ptr< folly::IOBuf > authenticator) override
void onHeadersComplete(HTTPCodec::StreamID stream, std::unique_ptr< HTTPMessage > inMsg) override
std::tuple< uint32_t, bool, uint8_t > HTTPPriority
std::vector< HTTPSetting > SettingsList
HTTPCodec::StreamID controlStreamId
void onWindowUpdate(HTTPCodec::StreamID stream, uint32_t amount) override
HTTPMessage getGetRequest(const std::string &url)
int bind(NetworkSocket s, const sockaddr *name, socklen_t namelen)
void dumpCounters(int verbosity) const
#define EXPECT_NE(val1, val2)
HTTPMessage getPostRequest(uint32_t contentLength)
std::unique_ptr< HTTPMessage > makeGetRequest()
HTTPMessage getUpgradeRequest(const std::string &upgradeHeader, HTTPMethod method, uint32_t bodyLen)
size_t parse(T *codec, const uint8_t *inputData, uint32_t length, int32_t atOnce=0, std::function< bool()> stopFn=[]{return false;})
std::unique_ptr< HTTPMessage > msg
void onChunkComplete(HTTPCodec::StreamID) override
void onCertificateRequest(uint16_t requestId, std::unique_ptr< folly::IOBuf > authRequest) override
static std::unique_ptr< IOBuf > copyBuffer(const void *buf, std::size_t size, std::size_t headroom=0, std::size_t minTailroom=0)
MATCHER_P(PtrBufHasLen, n,"")
HTTPMessage::HTTPPriority priority
std::unique_ptr< testing::NiceMock< MockHTTPCodec > > makeUpstreamParallelCodec()
HTTPMessage getPubRequest(const std::string &url)