20 #include <type_traits> 24 using namespace folly;
44 headerCodec_(direction),
53 if (decoderHeaderTableMaxSize) {
58 if (maxHeaderListSize) {
80 if (
frameState_ == FrameState::UPSTREAM_CONNECTION_PREFACE) {
93 }
else if (
frameState_ == FrameState::FRAME_HEADER ||
94 frameState_ == FrameState::DOWNSTREAM_CONNECTION_PREFACE) {
99 if (
frameState_ == FrameState::DOWNSTREAM_CONNECTION_PREFACE &&
102 "GOAWAY error: got invalid connection preface frame type=",
122 FrameState::DATA_FRAME_DATA : FrameState::FRAME_DATA;
131 }
else if (
frameState_ == FrameState::DATA_FRAME_DATA && bufLen > 0 &&
135 size_t dataParsed = 0;
141 parsed += dataParsed;
150 if (bufLen >= frameLen) {
169 "GOAWAY error: while expected CONTINUATION with stream=",
178 "GOAWAY error: unexpected CONTINUATION received with streamID=",
196 "Failing connection due to excessively large headers");
222 VLOG(2) <<
"EX_HEADERS not enabled, ignoring the frame";
282 std::unique_ptr<IOBuf> outData;
284 VLOG(10) <<
"parsing all frame DATA bytes for stream=" <<
curHeader_.
stream <<
289 if (
callback_ && (padding > 0 || (outData && !outData->
empty()))) {
291 outData = std::make_unique<IOBuf>();
304 VLOG(10) <<
"No data to parse";
308 std::unique_ptr<IOBuf> outData;
314 " parsed=" << parsed;
331 VLOG(10) <<
"out padding=" << padding <<
" pendingDataFrameBytes_=" <<
334 " parsed=" << parsed;
339 const size_t pendingAppData =
341 const size_t toClone =
std::min(pendingAppData, bufLen);
342 cursor.
clone(outData, toClone);
346 VLOG(10) <<
"parsed some app data, pendingDataFrameBytes_=" <<
348 pendingDataFramePaddingBytes_ <<
" bufLen=" << bufLen <<
349 " parsed=" << parsed;
360 VLOG(10) <<
"parsed some padding, pendingDataFrameBytes_=" <<
363 " parsed=" << parsed;
367 if (
callback_ && (padding > 0 || (outData && !outData->
empty()))) {
369 outData = std::make_unique<IOBuf>();
381 std::unique_ptr<IOBuf> headerBuf;
399 std::unique_ptr<IOBuf> headerBuf;
403 cursor,
curHeader_, exAttributes, priority, headerBuf);
414 std::unique_ptr<IOBuf> headerBuf;
426 std::unique_ptr<IOBuf> headerBuf,
431 std::unique_ptr<HTTPMessage> msg;
435 if (errorCode.hasValue()) {
436 return errorCode.value();
448 if (concurError.hasValue()) {
449 return concurError.value();
453 bool allHeaderFramesReceived =
456 if (allHeaderFramesReceived && !trailers) {
476 DCHECK(promisedStream);
478 "onPushMessageBegin", *promisedStream,
482 headersCompleteStream = *promisedStream;
488 msg->setIsChunked(
true);
491 VLOG(4) <<
"Trailers complete for streamId=" << headersCompleteStream
493 auto trailerHeaders =
494 std::make_unique<HTTPHeaders>(msg->extractHeaders());
511 std::unique_ptr<HTTPMessage>& msg) {
515 if (promisedStream) {
517 }
else if (exAttributes) {
526 streamError(folly::to<string>(
"Circular dependency for txn=",
546 "Failed decoding header block for stream=";
570 folly::to<std::string>(
"HTTP2Codec stream error: ",
577 err.setHttpStatusCode(400);
598 streamError(folly::to<string>(
"Exceeded max_concurrent_streams"),
609 if (name ==
"user-agent" &&
userAgent_.empty()) {
637 folly::to<string>(
"Invalid response code to a websocket upgrade: ",
657 streamError(folly::to<string>(
"Circular dependency for txn=",
723 for (
auto& setting: settings) {
724 switch (setting.first) {
727 uint32_t tableSize = setting.second;
729 VLOG(2) <<
"Limiting table size from " << tableSize <<
" to " <<
737 if ((setting.second != 0 && setting.second != 1) ||
738 (setting.second == 1 &&
741 "GOAWAY error: ENABLE_PUSH invalid setting=", setting.second,
752 "GOAWAY error: INITIAL_WINDOW_SIZE invalid size=", setting.second,
762 "GOAWAY error: MAX_FRAME_SIZE invalid size=", setting.second,
774 if (
ptr &&
ptr->value > 0) {
776 <<
" got ENABLE_EX_HEADERS=" << setting.second;
777 if (setting.second != 0 && setting.second != 1) {
779 "GOAWAY error: invalid ENABLE_EX_HEADERS=", setting.second,
792 if (setting.second > 1) {
794 "GOAWAY error: ENABLE_CONNECT_PROTOCOL invalid number=",
831 "Received PUSH_PROMISE on DOWNSTREAM codec");
837 "Received PUSH_PROMISE on codec with push disabled");
844 std::unique_ptr<IOBuf> headerBlockFragment;
846 headerBlockFragment);
873 std::unique_ptr<IOBuf> debugData;
879 <<
" lastStream=" << lastGoodStream
880 <<
" user-agent=" <<
userAgent_ <<
" debugData=" <<
881 ((debugData) ?
string((
char*)debugData->
data(), debugData->
length()):
893 LOG(
WARNING) <<
"Received multiple GOAWAY with increasing ack";
899 VLOG(4) <<
"parsing WINDOW_UPDATE frame for stream=" <<
curHeader_.
stream <<
908 "GOAWAY error: invalid/0 length delta for streamID=",
915 "parseWindowUpdate Invalid 0 length");
918 " with HTTP2Codec stream error: ",
919 "window update delta=", delta),
932 VLOG(4) <<
"parsing CERTIFICATE_REQUEST frame length=" <<
curHeader_.
length;
934 std::unique_ptr<IOBuf> authRequest;
948 std::unique_ptr<IOBuf> authData;
976 "GOAWAY error: received streamID=", streamId,
983 VLOG(4) <<
"Parsing downstream trailers streamId=" << streamId;
993 "GOAWAY error: invalid new stream received with streamID=", streamId);
1003 VLOG(4) <<
"generating connection preface";
1015 VLOG(4) << __func__ <<
" with no HTTP2-Settings";
1021 if (settingsHeader.empty()) {
1025 auto decoded = base64url_decode(settingsHeader);
1029 VLOG(4) << __func__ <<
" failed to decode HTTP2-Settings";
1032 std::unique_ptr<IOBuf> decodedBuf = IOBuf::wrapBuffer(decoded.data(),
1034 IOBufQueue settingsQueue{IOBufQueue::cacheChainLength()};
1036 Cursor c(settingsQueue.front());
1043 VLOG(4) << __func__ <<
" bad settings frame";
1048 VLOG(4) << __func__ <<
" handleSettings failed";
1108 CHECK(!exAttributes);
1109 VLOG(4) <<
"generating PUSH_PROMISE for stream=" <<
stream;
1110 }
else if (exAttributes) {
1111 CHECK(!assocStream);
1112 VLOG(4) <<
"generating ExHEADERS for stream=" << stream
1113 <<
" with control stream=" << exAttributes->controlStream
1114 <<
" unidirectional=" << exAttributes->unidirectional;
1116 VLOG(4) <<
"generating HEADERS for stream=" <<
stream;
1120 VLOG(2) <<
"Suppressing HEADERS/PROMISE for stream=" << stream <<
1131 assocStream || exAttributes);
1140 std::vector<std::string> temps;
1143 IOBufQueue queue(IOBufQueue::cacheChainLength());
1146 if (queue.chainLength() > 0) {
1149 auto remainingFrameSize = maxFrameSize;
1154 <<
"no enough space for priority? frameHeadroom=" << remainingFrameSize;
1157 auto chunk = queue.split(
std::min(remainingFrameSize, queue.chainLength()));
1159 bool endHeaders = queue.chainLength() == 0;
1171 }
else if (exAttributes) {
1203 size_t maxFrameSize) {
1204 bool endHeaders =
false;
1205 while (!endHeaders) {
1208 VLOG(4) <<
"generating CONTINUATION for stream=" <<
stream;
1213 writeBuf, stream, endHeaders,
std::move(chunk)));
1219 std::vector<compress::Header>& allHeaders,
1233 string serializedHeaders;
1235 [&serializedHeaders] (
const string&
name,
const string&
value) {
1236 serializedHeaders = folly::to<string>(serializedHeaders,
"\\n",
name,
1239 LOG(
ERROR) <<
"generating HEADERS frame larger than peer maximum nHeaders=" 1240 << headers.
size() <<
" all headers=" 1241 << serializedHeaders;
1251 static_cast<uint8_t>(type),
1259 std::unique_ptr<folly::IOBuf> chain,
1265 VLOG(2) <<
"Suppressing DATA for stream=" << stream <<
" ingressGoawayAck_=" 1269 IOBufQueue queue(IOBufQueue::cacheChainLength());
1273 auto chunk = queue.
split(maxFrameSize);
1312 std::vector<compress::Header> allHeaders;
1318 IOBufQueue queue(IOBufQueue::cacheChainLength());
1323 auto remainingFrameSize = maxFrameSize;
1346 VLOG(4) <<
"sending EOM for stream=" <<
stream;
1349 VLOG(2) <<
"suppressed EOM for stream=" << stream <<
" ingressGoawayAck_=" 1367 VLOG(4) <<
"sending RST_STREAM for stream=" << stream
1370 VLOG(2) <<
"suppressed RST_STREAM for stream=" << stream
1384 <<
" for stream=" << stream <<
" user-agent=" <<
userAgent_;
1394 std::unique_ptr<folly::IOBuf> debugData) {
1395 DCHECK_LE(lastStream,
egressGoawayAck_) <<
"Cannot increase last good stream";
1398 VLOG(4) <<
"Not sending GOAWAY for closed session";
1402 case ClosingState::OPEN:
1403 case ClosingState::OPEN_WITH_GRACEFUL_DRAIN_ENABLED:
1413 case ClosingState::FIRST_GOAWAY_SENT:
1416 case ClosingState::CLOSING:
1417 case ClosingState::CLOSED:
1418 LOG(
FATAL) <<
"unreachable";
1421 VLOG(4) <<
"Sending GOAWAY with last acknowledged stream=" 1424 VLOG(2) <<
"sending GOAWAY with last acknowledged stream=" << lastStream
1443 VLOG(4) <<
"Generating ping request with opaqueData=" << opaqueData;
1450 VLOG(4) <<
"Generating ping reply with opaqueData=" << uniqueID;
1458 switch (setting.id) {
1468 CHECK(setting.value == 0 || setting.value == 1);
1479 CHECK(setting.value == 0 || setting.value == 1);
1480 if (setting.value == 0) {
1483 VLOG(4) <<
"generating ENABLE_EX_HEADERS=" << setting.value;
1487 if (setting.value == 0) {
1495 LOG(
ERROR) <<
"ignore unknown settingsId=" 1497 <<
" value=" << setting.value;
1501 settings.push_back(
SettingPair(setting.id, setting.value));
1504 <<
" generating " << (unsigned)settings.size() <<
" settings";
1533 <<
" generating settings ack";
1541 VLOG(4) <<
"generating window update for stream=" << stream
1542 <<
": Processed " << delta <<
" bytes";
1544 VLOG(2) <<
"suppressed WINDOW_UPDATE for stream=" << stream
1555 VLOG(4) <<
"generating priority for stream=" <<
stream;
1557 VLOG(2) <<
"suppressed PRIORITY for stream=" << stream
1567 std::get<2>(pri)}));
1573 std::unique_ptr<folly::IOBuf> certificateRequestData) {
1574 VLOG(4) <<
"generating CERTIFICATE_REQUEST with Request-ID=" << requestId;
1576 writeBuf, requestId,
std::move(certificateRequestData));
1581 std::unique_ptr<folly::IOBuf> certData) {
1583 VLOG(4) <<
"sending CERTIFICATE with Cert-ID=" << certId <<
"for stream=0";
1584 IOBufQueue queue(IOBufQueue::cacheChainLength());
1601 <<
" with ingress=";
size_t addPriorityNodes(PriorityQueue &queue, folly::IOBufQueue &writeBuf, uint8_t maxLevel) override
const uint32_t kMaxAuthenticatorBufSize
#define FOLLY_SCOPED_TRACE_SECTION(arg,...)
std::unique_ptr< folly::IOBuf > split(size_t n)
static std::vector< compress::Header > prepareMessageForCompression(const HTTPMessage &msg, std::vector< std::string > &temps)
ErrorCode parseContinuation(Cursor &cursor, const FrameHeader &header, std::unique_ptr< IOBuf > &outBuf) noexcept
void generateContinuation(folly::IOBufQueue &writeBuf, folly::IOBufQueue &queue, StreamID stream, size_t maxFrameSize)
ErrorCode parseFrame(folly::io::Cursor &cursor)
ErrorCode parseDataFrameData(folly::io::Cursor &cursor, size_t bufLen, size_t &parsed)
const folly::IOBuf * front() const
void append(std::unique_ptr< folly::IOBuf > &&buf, bool pack=false)
ErrorCode parsePushPromise(folly::io::Cursor &cursor)
bool onIngressUpgradeMessage(const HTTPMessage &msg) override
size_t chainLength() const
spdy::GoawayStatusCode statusCode
static std::string urlEncode(folly::ByteRange buffer)
size_t writePing(IOBufQueue &queue, uint64_t opaqueData, bool ack) noexcept
void setDecoderHeaderTableMaxSize(uint32_t size)
std::unique_ptr< folly::IOBuf > splitAtMost(size_t n)
virtual void onError(StreamID stream, const HTTPException &error, bool newTxn=false)=0
ErrorCode parsePushPromise(Cursor &cursor, const FrameHeader &header, uint32_t &outPromisedStream, std::unique_ptr< IOBuf > &outBuf) noexcept
virtual void onMessageBegin(StreamID stream, HTTPMessage *msg)=0
folly::IOBufQueue curHeaderBlock_
ErrorCode parseFrameHeader(Cursor &cursor, FrameHeader &header) noexcept
const uint32_t kFramePrioritySize
void decodeStreaming(folly::io::Cursor &cursor, uint32_t length, HPACK::StreamingCallback *streamingCb) noexcept
http2::FrameType headerBlockFrameType_
ErrorCode parseWindowUpdate(folly::io::Cursor &cursor)
uint32_t streamDependency
HTTP2Codec(TransportDirection direction)
HTTPSettings ingressSettings_
ErrorCode parseContinuation(folly::io::Cursor &cursor)
ErrorCode parseCertificateRequest(folly::io::Cursor &cursor)
ErrorCode parseGoaway(Cursor &cursor, const FrameHeader &header, uint32_t &outLastStreamID, ErrorCode &outCode, std::unique_ptr< IOBuf > &outDebugData) noexcept
ErrorCode parseCertificate(folly::io::Cursor &cursor)
static std::string printHexFolly(const folly::IOBuf *buf, bool coalesce=false)
bool deliverCallbackIfAllowed(T callbackFn, char const *cbName, StreamID stream, Args &&...args)
static std::string urlDecode(const std::string &b64message)
const std::string * getUpgradeProtocol() const
StreamID egressGoawayAck_
virtual void onSettings(const SettingsList &)
const char * getTransportDirectionString(TransportDirection dir)
virtual void onExMessageBegin(StreamID, StreamID, bool, HTTPMessage *)
virtual void onGenerateFrameHeader(StreamID, uint8_t, uint64_t, uint16_t=0)
HTTPCodec::Callback * callback_
const uint32_t kFrameHeaderSize
ErrorCode parseHeadersImpl(folly::io::Cursor &cursor, std::unique_ptr< folly::IOBuf > headerBuf, const folly::Optional< http2::PriorityUpdate > &priority, const folly::Optional< uint32_t > &promisedStream, const folly::Optional< ExAttributes > &exAttributes)
HTTPSettings egressSettings_
size_t generatePingReply(folly::IOBufQueue &writeBuf, uint64_t uniqueID) override
const std::string kProtocolCleartextString
StreamCodecFactory stream
void generatePushPromise(folly::IOBufQueue &writeBuf, StreamID stream, const HTTPMessage &msg, StreamID assocStream, bool eom=false, HTTPHeaderSize *size=nullptr) override
void setEncoderHeaderTableSize(uint32_t size)
bool isInitiatedStream(StreamID stream) const
virtual void onMessageComplete(StreamID stream, bool upgrade)=0
void setIngressWebsocketUpgrade()
size_t writeHeaders(IOBufQueue &queue, std::unique_ptr< IOBuf > headers, uint32_t stream, folly::Optional< PriorityUpdate > priority, folly::Optional< uint8_t > padding, bool endStream, bool endHeaders) noexcept
void clone(std::unique_ptr< folly::IOBuf > &buf, size_t len)
size_t generatePingRequest(folly::IOBufQueue &writeBuf) override
const std::string kProtocolString
void onHeader(const folly::fbstring &name, const folly::fbstring &value) override
ErrorCode parseGoaway(folly::io::Cursor &cursor)
uint16_t getStatusCode() const
virtual void onPingReply(uint64_t)
void generateExHeader(folly::IOBufQueue &writeBuf, StreamID stream, const HTTPMessage &msg, const HTTPCodec::ExAttributes &exAttributes, bool eom=false, HTTPHeaderSize *size=nullptr) override
size_t onIngress(const folly::IOBuf &buf) override
void generateHeaderImpl(folly::IOBufQueue &writeBuf, StreamID stream, const HTTPMessage &msg, const folly::Optional< StreamID > &assocStream, const folly::Optional< ExAttributes > &exAttributes, bool eom, HTTPHeaderSize *size)
virtual void onTrailersComplete(StreamID stream, std::unique_ptr< HTTPHeaders > trailers)=0
folly::Optional< ErrorCode > parseHeadersDecodeFrames(const folly::Optional< http2::PriorityUpdate > &priority, const folly::Optional< uint32_t > &promisedStream, const folly::Optional< ExAttributes > &exAttributes, std::unique_ptr< HTTPMessage > &msg)
constexpr detail::Map< Move > move
ErrorCode parsePriority(Cursor &cursor, const FrameHeader &header, PriorityUpdate &outPriority) noexcept
ErrorCode parseSettings(Cursor &cursor, const FrameHeader &header, std::deque< SettingPair > &settings) noexcept
virtual void onCertificate(uint16_t, std::unique_ptr< folly::IOBuf >)
virtual void onCertificateRequest(uint16_t, std::unique_ptr< folly::IOBuf >)
std::unordered_set< StreamID > upgradedStreams_
ErrorCode errorCodeToGoaway(ErrorCode code)
const uint8_t * data() const
const uint32_t kMaxFramePayloadLength
size_t writePushPromise(IOBufQueue &queue, uint32_t associatedStream, uint32_t promisedStream, std::unique_ptr< IOBuf > headers, folly::Optional< uint8_t > padding, bool endHeaders) noexcept
std::unique_ptr< folly::IOBuf > move()
void generateHeader(folly::IOBufQueue &writeBuf, StreamID stream, const HTTPMessage &msg, bool eom=false, HTTPHeaderSize *size=nullptr) override
size_t generateRstStream(folly::IOBufQueue &writeBuf, StreamID stream, ErrorCode statusCode) override
virtual void onPriority(StreamID, const HTTPMessage::HTTPPriority &)
static http_parser_settings settings
ErrorCode checkNewStream(uint32_t stream, bool trailersAllowed)
ErrorCode parseAllData(folly::io::Cursor &cursor)
—— Concurrent Priority Queue Implementation ——
void setCodecStatusCode(ErrorCode statusCode)
std::string goawayErrorMessage_
size_t generateCertificate(folly::IOBufQueue &writeBuf, uint16_t certId, std::unique_ptr< folly::IOBuf > certData) override
requires And< SemiMovable< VN >... > &&SemiMovable< E > auto error(E e)
size_t generateEOM(folly::IOBufQueue &writeBuf, StreamID stream) override
ErrorCode parseWindowUpdate(Cursor &cursor, const FrameHeader &header, uint32_t &outAmount) noexcept
size_t writeContinuation(IOBufQueue &queue, uint32_t stream, bool endHeaders, std::unique_ptr< IOBuf > headers) noexcept
ErrorCode parseCertificateRequest(folly::io::Cursor &cursor, const FrameHeader &header, uint16_t &outRequestId, std::unique_ptr< folly::IOBuf > &outAuthRequest) noexcept
bool frameHasPadding(const FrameHeader &header)
size_t generateBody(folly::IOBufQueue &writeBuf, StreamID stream, std::unique_ptr< folly::IOBuf > chain, folly::Optional< uint8_t > padding, bool eom) override
size_t writeSettings(IOBufQueue &queue, const std::deque< SettingPair > &settings)
const uint32_t kMaxWindowUpdateSize
size_t generatePriority(folly::IOBufQueue &writeBuf, StreamID stream, const HTTPMessage::HTTPPriority &pri) override
std::string readFixedString(size_t len)
size_t pendingDataFrameBytes_
size_t maxSendFrameSize() const
Gen range(Value begin, Value end)
static void requestUpgrade(HTTPMessage &request)
HTTPCodec::StreamID mapPriorityToDependency(uint8_t priority) const override
bool pendingEndStreamHandling_
bool onIngressUpgradeMessage(const HTTPMessage &msg) override
const uint32_t kMaxFramePayloadLengthMin
size_t generateSettingsAck(folly::IOBufQueue &writeBuf) override
uint32_t maxRecvFrameSize() const
folly::Optional< ErrorCode > parseHeadersCheckConcurrentStreams(const folly::Optional< http2::PriorityUpdate > &priority)
ErrorCode handleSettings(const std::deque< SettingPair > &settings)
constexpr auto size(C const &c) -> decltype(c.size())
const uint32_t kMaxHeaderTableSize
bool checkForHeaderToken(const HTTPHeaderCode headerCode, char const *token, bool caseSensitive) const
enum proxygen::HTTPParallelCodec::ClosingState sessionClosing_
virtual void onPingRequest(uint64_t)
void writeBuf(const Buf &buf, folly::io::Appender &out)
virtual uint32_t numIncomingStreams() const
StreamID ingressGoawayAck_
size_t generateConnectionPreface(folly::IOBufQueue &writeBuf) override
ErrorCode parseExHeaders(Cursor &cursor, const FrameHeader &header, HTTPCodec::ExAttributes &outExAttributes, folly::Optional< PriorityUpdate > &outPriority, std::unique_ptr< IOBuf > &outBuf) noexcept
ErrorCode errorCodeToReset(ErrorCode code)
virtual void addPriorityNode(StreamID id, StreamID parent)=0
size_t writePriority(IOBufQueue &queue, uint32_t stream, PriorityUpdate priority) noexcept
size_t writeCertificate(folly::IOBufQueue &writeBuf, uint16_t certId, std::unique_ptr< folly::IOBuf > authenticator, bool toBeContinued)
ErrorCode parseRstStream(Cursor &cursor, const FrameHeader &header, ErrorCode &outCode) noexcept
virtual void onFrameHeader(StreamID, uint8_t, uint64_t, uint8_t, uint16_t=0)
void onDecodeError(HPACK::DecodeError decodeError) override
std::size_t length() const
std::basic_string< E, T, A > toStdString() const
size_t generateGoaway(folly::IOBufQueue &writeBuf, StreamID lastStream, ErrorCode statusCode, std::unique_ptr< folly::IOBuf > debugData=nullptr) override
HeaderDecodeInfo decodeInfo_
ErrorCode parseCertificate(folly::io::Cursor &cursor, const FrameHeader &header, uint16_t &outCertId, std::unique_ptr< folly::IOBuf > &outAuthenticator) noexcept
const uint32_t kFrameHeadersBaseMaxSize
const char * getErrorCodeString(ErrorCode error)
std::vector< StreamID > virtualPriorityNodes_
bool hasUpgradeProtocol()
ErrorCode parseDataBegin(Cursor &cursor, const FrameHeader &header, size_t &, uint16_t &outPadding) noexcept
StreamID createStream() override
folly::Optional< HTTPPriority > getHTTP2Priority() const
std::pair< SettingsId, uint32_t > SettingPair
static const char *const value
StreamID expectedContinuationStream_
bool isStreamIngressEgressAllowed(StreamID stream) const
HTTPHeaders & getHeaders()
folly::IOBufQueue curAuthenticatorBlock_
http2::FrameHeader curHeader_
virtual void onSettingsAck()
ErrorCode parseExHeaders(folly::io::Cursor &cursor)
size_t generateHeaderCallbackWrapper(StreamID stream, http2::FrameType type, size_t length)
bool ingressWebsocketUpgrade_
size_t writeCertificateRequest(folly::IOBufQueue &writeBuf, uint16_t requestId, std::unique_ptr< folly::IOBuf > authRequest)
const std::string kProtocolSettingsHeader
ErrorCode parseHeaders(Cursor &cursor, const FrameHeader &header, folly::Optional< PriorityUpdate > &outPriority, std::unique_ptr< IOBuf > &outBuf) noexcept
size_t writeSettingsAck(IOBufQueue &queue)
size_t writeRstStream(IOBufQueue &queue, uint32_t stream, ErrorCode errorCode) noexcept
std::tuple< uint32_t, bool, uint8_t > HTTPPriority
size_t generateTrailers(folly::IOBufQueue &writeBuf, StreamID stream, const HTTPHeaders &trailers) override
uint64_t receivedFrameCount_
bool reuseIOBufHeadroomForData_
FOLLY_NODISCARD detail::ScopeGuardImplDecay< F, true > makeGuard(F &&f) noexcept(noexcept(detail::ScopeGuardImplDecay< F, true >(static_cast< F && >(f))))
void streamError(const std::string &msg, ErrorCode error, bool newTxn=false)
bool parsingDownstreamTrailers_
virtual void onHeadersComplete(StreamID stream, std::unique_ptr< HTTPMessage > msg)=0
const std::string empty_string
std::vector< HTTPSetting > SettingsList
virtual void onGoaway(uint64_t, ErrorCode, std::unique_ptr< folly::IOBuf >=nullptr)
std::unique_ptr< folly::IOBuf > encodeHeaders(const HTTPHeaders &headers, std::vector< compress::Header > &allHeaders, HTTPHeaderSize *size)
size_t writeExHeaders(IOBufQueue &queue, std::unique_ptr< IOBuf > headers, uint32_t stream, const HTTPCodec::ExAttributes &exAttributes, const folly::Optional< PriorityUpdate > &priority, const folly::Optional< uint8_t > &padding, bool endStream, bool endHeaders) noexcept
const std::vector< HTTPSetting > & getAllSettings()
size_t pendingDataFramePaddingBytes_
bool checkConnectionError(ErrorCode, const folly::IOBuf *buf)
virtual void onAbort(StreamID, ErrorCode)
ErrorCode parseSettings(folly::io::Cursor &cursor)
size_t writeGoaway(IOBufQueue &queue, uint32_t lastStreamID, ErrorCode errorCode, std::unique_ptr< IOBuf > debugData) noexcept
size_t generateChunkHeader(folly::IOBufQueue &writeBuf, StreamID stream, size_t length) override
ErrorCode parseRstStream(folly::io::Cursor &cursor)
size_t generateWindowUpdate(folly::IOBufQueue &writeBuf, StreamID stream, uint32_t delta) override
static bool appendHeaders(const HTTPHeaders &inputHeaders, std::vector< compress::Header > &headers, HTTPHeaderCode headerToCheck)
const std::string kConnectionPreface
ErrorCode parsePriority(folly::io::Cursor &cursor)
void onHeadersComplete(HTTPHeaderSize decodedSize) override
virtual void onWindowUpdate(StreamID, uint32_t)
bool frameAffectsCompression(FrameType t)
std::unique_ptr< folly::IOBuf > encode(std::vector< compress::Header > &headers) noexcept
folly::Optional< HTTPMethod > getMethod() const
#define RETURN_IF_ERROR(err)
const char * getFrameTypeString(FrameType type)
virtual void onPushMessageBegin(StreamID, StreamID, HTTPMessage *)
TransportDirection transportDirection_
ErrorCode handleEndStream()
ErrorCode parseData(Cursor &cursor, const FrameHeader &header, std::unique_ptr< IOBuf > &outBuf, uint16_t &outPadding) noexcept
size_t writeData(IOBufQueue &queue, std::unique_ptr< IOBuf > data, uint32_t stream, folly::Optional< uint8_t > padding, bool endStream, bool reuseIOBufHeadroom) noexcept
ErrorCode parsePing(folly::io::Cursor &cursor)
virtual void onBody(StreamID stream, std::unique_ptr< folly::IOBuf > chain, uint16_t padding)=0
size_t writeWindowUpdate(IOBufQueue &queue, uint32_t stream, uint32_t amount) noexcept
size_t totalLength() const
ErrorCode parseDataEnd(Cursor &cursor, const size_t bufLen, const size_t pendingDataFramePaddingBytes, size_t &toSkip) noexcept
bool isEgressWebsocketUpgrade() const
TransportDirection getTransportDirection() const override
folly::Function< void()> parent
bool parsingTrailers() const
size_t generateChunkTerminator(folly::IOBufQueue &writeBuf, StreamID stream) override
void setMaxUncompressed(uint64_t maxUncompressed) override
size_t generateSettings(folly::IOBufQueue &writeBuf) override
ErrorCode parsePing(Cursor &cursor, const FrameHeader &header, uint64_t &outOpaqueData) noexcept
const HTTPSetting * getSetting(SettingsId id) const
size_t generateCertificateRequest(folly::IOBufQueue &writeBuf, uint16_t requestId, std::unique_ptr< folly::IOBuf > certificateRequestData) override
ErrorCode parseHeaders(folly::io::Cursor &cursor)
void setSetting(SettingsId id, SettingsValue val)
bool isRequest(StreamID id) const