proxygen
|
#include <HTTPCodec.h>
Classes | |
class | Callback |
struct | ExAttributes |
class | PriorityQueue |
Public Types | |
using | StreamID = uint64_t |
Static Public Attributes | |
static const folly::Optional< StreamID > | NoStream |
static const folly::Optional< uint8_t > | NoPadding = folly::none |
static const StreamID | MAX_STREAM_ID = 1u << 31 |
static const folly::Optional< ExAttributes > | NoExAttributes |
Interface for a parser&generator that can translate between an internal representation of an HTTP request and a wire format. The details of the wire format (e.g., HTTP/1.x encoding vs. SPDY encoding) are left for subclasses to implement.
Definition at line 36 of file HTTPCodec.h.
Key that uniquely identifies a request/response pair within (and only within) the scope of the codec. Code outside the codec should regard the StreamID as an opaque data structure; different subclasses of HTTPCodec are likely to use different conventions for generating StreamID values.
A value of zero indicates an uninitialized/unknown/unspecified StreamID.
Definition at line 49 of file HTTPCodec.h.
|
inlinevirtual |
Definition at line 332 of file HTTPCodec.h.
|
inlinevirtual |
Create virtual nodes in HTTP/2 priority tree. Some protocols (SPDY) have a linear priority structure which must be simulated in the HTTP/2 tree structure with "virtual" nodes representing different priority bands. There are other cases we simply want a "plain" linear priority structure even with HTTP/2. In that case a Priority frame will also be sent out for each virtual node created so that peer will have the same linear structure.
queue | the priority queue to add nodes |
writeBuf | IOBufQueue to append priority frames to send. For SPDY, the writeBuf will be ignored. |
maxLavel | the max level of virtual priority nodes to create. For SPDY, this value will be ignored. |
Reimplemented in proxygen::HTTP2Codec, and proxygen::SPDYCodec.
Definition at line 696 of file HTTPCodec.h.
Referenced by proxygen::MockHTTPCodec::generateCertificate(), proxygen::HTTPDownstreamSession::onNativeProtocolUpgrade(), proxygen::HTTPUpstreamSession::onNativeProtocolUpgrade(), proxygen::HTTPDownstreamSession::startNow(), and proxygen::HTTPUpstreamSession::startNow().
|
pure virtual |
Checks whether the socket needs to be closed when EOM is sent. This is used during CONNECT when EOF needs to be sent after upgrade to notify the server
Implemented in proxygen::HTTP1xCodec, and proxygen::HTTPParallelCodec.
Referenced by onIngressUpgradeMessage(), and proxygen::HTTPSession::shutdownTransport().
|
pure virtual |
Reserve a stream ID.
Implemented in proxygen::HTTP1xCodec, and proxygen::HTTPParallelCodec.
Referenced by proxygen::HTTPSession::newExTransaction(), proxygen::HTTPSession::newPushedTransaction(), proxygen::HTTPUpstreamSession::newTransaction(), proxygen::HTTPSession::onNativeProtocolUpgradeImpl(), proxygen::HTTPSession::sendPriority(), and supportsSessionFlowControl().
|
inlinevirtual |
This enables HTTP/2 style behavior during graceful shutdown that allows 2 GOAWAYs to be sent during shutdown.
Reimplemented in proxygen::HTTPParallelCodec.
Definition at line 665 of file HTTPCodec.h.
Referenced by proxygen::HTTPSession::enableDoubleGoawayDrain(), and proxygen::MockHTTPCodec::generateCertificate().
|
pure virtual |
Write part of an egress message body.
This will automatically generate a chunk header and footer around the data if necessary (e.g. you haven't manually sent a chunk header and the message should be chunked).
padding | Optionally add padding bytes to the body if possible |
eom | implicitly generate the EOM marker with this body frame |
Implemented in proxygen::HTTP2Codec, proxygen::SPDYCodec, proxygen::HTTP1xCodec, and proxygen::MockHTTPCodec.
Referenced by generateExHeader(), and proxygen::HTTPSession::sendBody().
|
inlinevirtual |
Reimplemented in proxygen::MockHTTPCodec, and proxygen::HTTP2Codec.
Definition at line 642 of file HTTPCodec.h.
Referenced by proxygen::HTTPSession::onCertificateRequest().
|
inlinevirtual |
Reimplemented in proxygen::HTTP2Codec, and proxygen::MockHTTPCodec.
Definition at line 631 of file HTTPCodec.h.
Referenced by proxygen::HTTPSession::sendCertificateRequest().
|
pure virtual |
Write a body chunk header, if relevant.
Implemented in proxygen::HTTP2Codec, proxygen::SPDYCodec, and proxygen::HTTP1xCodec.
Referenced by proxygen::MockHTTPCodec::generateBody(), generateExHeader(), and proxygen::HTTPSession::sendChunkHeader().
|
pure virtual |
Write a body chunk terminator, if relevant.
Implemented in proxygen::HTTP2Codec, proxygen::SPDYCodec, and proxygen::HTTP1xCodec.
Referenced by proxygen::MockHTTPCodec::generateBody(), generateExHeader(), and proxygen::HTTPSession::sendChunkTerminator().
|
inlinevirtual |
Generate a connection preface, if there is any for this protocol.
Reimplemented in proxygen::HTTP2Codec.
Definition at line 475 of file HTTPCodec.h.
References generateHeader(), folly::size(), and fizz::detail::writeBuf().
Referenced by HTTPParallelCodecTest::SetUp(), proxygen::HTTPSession::setupCodec(), and HTTPParallelCodecTest::SetUpUpstreamTest().
|
pure virtual |
Generate any protocol framing needed to finalize an egress message. This method must be called to complete a stream.
Implemented in proxygen::HTTP2Codec, proxygen::SPDYCodec, and proxygen::HTTP1xCodec.
Referenced by proxygen::MockHTTPCodec::generateBody(), generateExHeader(), and proxygen::HTTPSession::sendEOM().
|
inlinevirtual |
Reimplemented in proxygen::HTTP2Codec.
Definition at line 499 of file HTTPCodec.h.
References generateBody(), generateChunkHeader(), generateChunkTerminator(), generateEOM(), generateGoaway(), generateRstStream(), and generateTrailers().
Referenced by proxygen::HTTPSession::sendHeaders().
|
pure virtual |
Generate any protocol framing needed to abort a connection.
Implemented in proxygen::HTTP2Codec, proxygen::MockHTTPCodec, proxygen::SPDYCodec, and proxygen::HTTP1xCodec.
Referenced by proxygen::HTTPSession::closeWhenIdle(), proxygen::HTTPSession::drainImpl(), generateExHeader(), proxygen::HTTPSession::onSessionParseError(), proxygen::HTTPSession::shutdownTransport(), and proxygen::HTTPSession::startNow().
|
pure virtual |
Write an egress message header. For pushed streams, you must specify the assocStream.
size | the size of the generated message, both the actual size and the size of the uncompressed data. |
Implemented in proxygen::SPDYCodec, proxygen::HTTP1xCodec, and proxygen::HTTP2Codec.
Referenced by generateConnectionPreface(), and proxygen::HTTPSession::sendHeaders().
|
inlinevirtual |
Generate a reply to a ping message, if supported in the protocol implemented by the codec.
Reimplemented in proxygen::HTTP2Codec, and proxygen::SPDYCodec.
Definition at line 584 of file HTTPCodec.h.
Referenced by proxygen::MockHTTPCodec::generateGoaway(), and proxygen::HTTPSession::onPingRequest().
|
inlinevirtual |
If the protocol supports it, generate a ping message that the other side should respond to.
Reimplemented in proxygen::HTTP2Codec, and proxygen::SPDYCodec.
Definition at line 576 of file HTTPCodec.h.
Referenced by proxygen::MockHTTPCodec::generateGoaway(), and proxygen::HTTPSession::sendPing().
|
inlinevirtual |
Reimplemented in proxygen::HTTP2Codec.
Definition at line 620 of file HTTPCodec.h.
Referenced by proxygen::HTTPSession::sendPriorityImpl().
|
inlinevirtual |
Reimplemented in proxygen::HTTP2Codec, and proxygen::SPDYCodec.
Definition at line 492 of file HTTPCodec.h.
Referenced by proxygen::HTTPSession::sendHeaders().
|
pure virtual |
Generate any protocol framing needed to abort a stream.
Implemented in proxygen::HTTP2Codec, proxygen::SPDYCodec, and proxygen::HTTP1xCodec.
Referenced by proxygen::MockHTTPCodec::generateBody(), generateExHeader(), proxygen::HTTPSession::onNewTransactionParseError(), and proxygen::HTTPSession::sendAbort().
|
inlinevirtual |
Generate a settings message, if supported in the protocol implemented by the codec.
Reimplemented in proxygen::HTTP2Codec, and proxygen::SPDYCodec.
Definition at line 592 of file HTTPCodec.h.
Referenced by proxygen::MockHTTPCodec::generateGoaway(), proxygen::HTTPSession::sendSettings(), HTTPParallelCodecTest::SetUpUpstreamTest(), and proxygen::HTTPSession::startNow().
|
inlinevirtual |
Generate a settings ack message, if supported in the protocol implemented by the codec.
Reimplemented in proxygen::HTTP2Codec.
Definition at line 600 of file HTTPCodec.h.
Referenced by proxygen::MockHTTPCodec::generateGoaway(), and proxygen::HTTPSession::onSettings().
|
pure virtual |
Write the message trailers
Implemented in proxygen::HTTP2Codec, proxygen::SPDYCodec, and proxygen::HTTP1xCodec.
Referenced by proxygen::MockHTTPCodec::generateBody(), generateExHeader(), and proxygen::HTTPSession::sendEOM().
|
inlinevirtual |
Reimplemented in proxygen::HTTP2Codec, and proxygen::SPDYCodec.
Definition at line 610 of file HTTPCodec.h.
Referenced by proxygen::FlowControlFilter::FlowControlFilter(), proxygen::MockHTTPCodec::generateGoaway(), and proxygen::HTTPSession::sendWindowUpdate().
|
inlinevirtual |
Get the default size of flow control windows for this protocol
Reimplemented in proxygen::HTTP2Codec, and proxygen::SPDYCodec.
Definition at line 680 of file HTTPCodec.h.
Referenced by HTTPUpstreamTest< SPDY3CodecPair >::commonSetUp(), proxygen::FlowControlFilter::FlowControlFilter(), proxygen::MockHTTPCodec::generateCertificate(), proxygen::HTTPSession::getCodecSendWindowSize(), proxygen::HTTPSession::onNativeProtocolUpgradeImpl(), and proxygen::HTTPSession::WriteSegment::writeErr().
|
inlinevirtual |
Reimplemented in proxygen::HTTP2Codec, and proxygen::SPDYCodec.
Definition at line 653 of file HTTPCodec.h.
Referenced by proxygen::HTTPSessionBase::enableExHeadersSettings(), proxygen::MockHTTPCodec::generateCertificate(), proxygen::HTTPSession::newExTransaction(), proxygen::HTTPSession::onNativeProtocolUpgradeImpl(), proxygen::HTTPSession::sendCertificateRequest(), proxygen::HTTPSession::setEgressSettings(), proxygen::HTTPSession::setFlowControl(), proxygen::HTTPSession::setMaxConcurrentIncomingStreams(), and proxygen::HTTPSession::setupCodec().
|
inlinevirtual |
Gets both the egress and ingress header table size, bytes stored in header table, and the number of headers stored in the header table
Reimplemented in proxygen::HTTP2Codec.
Definition at line 338 of file HTTPCodec.h.
References getProtocol(), getTransportDirection(), getUserAgent(), and string.
Referenced by proxygen::HTTPTransaction::onIngressHeadersComplete(), and proxygen::HTTPTransaction::sendHeadersWithOptionalEOM().
|
inlinevirtual |
Reimplemented in proxygen::HTTP2Codec, and proxygen::SPDYCodec.
Definition at line 657 of file HTTPCodec.h.
Referenced by proxygen::MockHTTPCodec::generateCertificate(), proxygen::HTTPSession::getCodecSendWindowSize(), proxygen::HTTPSession::sendCertificateRequest(), and proxygen::HTTPDownstreamSession::setupOnHeadersComplete().
|
inlinevirtual |
Get the identifier of the last stream started by the remote.
Reimplemented in proxygen::HTTPParallelCodec.
Definition at line 675 of file HTTPCodec.h.
Referenced by proxygen::HTTPSession::closeWhenIdle(), proxygen::HTTPSession::getGracefulGoawayAck(), proxygen::HTTPSession::onSessionParseError(), and proxygen::HTTPSession::shutdownTransport().
|
pure virtual |
Gets the session protocol currently used by the codec. This can be mapped to a string for logging and diagnostic use.
Implemented in proxygen::SPDYCodec, proxygen::HTTP2Codec, and proxygen::HTTP1xCodec.
Referenced by proxygen::HTTPSession::describe(), getHPACKTableInfo(), proxygen::HTTPSession::getNextToSend(), proxygen::HTTPSessionBase::initCodecHeaderIndexingStrategy(), proxygen::HTTPSession::newExTransaction(), proxygen::HTTPTransaction::onIngressHeadersComplete(), proxygen::HTTPSession::onSessionParseError(), proxygen::HTTPSession::sendEOM(), proxygen::HTTPTransaction::sendHeadersWithOptionalEOM(), and proxygen::HTTPSession::WriteSegment::writeErr().
|
pure virtual |
Get the transport direction of this codec: DOWNSTREAM if the codec receives requests from clients or UPSTREAM if the codec sends requests to servers.
Implemented in proxygen::HTTP1xCodec, and proxygen::HTTPParallelCodec.
Referenced by proxygen::HTTPSession::createTransaction(), getHPACKTableInfo(), proxygen::HTTPSessionBase::getParseErrorHandler(), proxygen::HTTPDownstreamSession::HTTPDownstreamSession(), proxygen::HTTPUpstreamSession::HTTPUpstreamSession(), proxygen::HTTPSession::isDownstream(), and proxygen::HTTPSession::isUpstream().
|
pure virtual |
Gets the user agent string of the client. Thus, it is only meaningful for a DOWNSTREAM session. Note that the value is available after onHeadersComplete(). It can help in diagnosing the interactions between different codec implementation.
Implemented in proxygen::SPDYCodec, proxygen::HTTP2Codec, and proxygen::HTTP1xCodec.
Referenced by proxygen::HTTPSession::describe(), and getHPACKTableInfo().
|
pure virtual |
Check whether the codec still has at least one HTTP stream to parse.
Implemented in proxygen::HTTP1xCodec, and proxygen::HTTPParallelCodec.
Referenced by proxygen::HTTPSession::isBusy(), proxygen::HTTPUpstreamSession::isReusable(), and supportsSessionFlowControl().
|
pure virtual |
Check whether the codec can process new streams. Typically, an implementing subclass will return true when a new codec is created and false once it encounters a situation that would prevent reuse of the underlying transport (e.g., a "Connection: close" in HTTP/1.x).
Implemented in proxygen::HTTPParallelCodec, and proxygen::HTTP1xCodec.
Referenced by proxygen::HTTPSession::drainImpl(), proxygen::HTTPSession::getGracefulGoawayAck(), proxygen::HTTPUpstreamSession::isReusable(), proxygen::HTTPSession::onEgressMessageFinished(), proxygen::HTTPSession::onError(), proxygen::HTTPSession::onHeadersComplete(), proxygen::HTTPDownstreamSession::onHeadersSent(), onIngressUpgradeMessage(), proxygen::HTTPSession::onMessageComplete(), proxygen::HTTPSession::onNewTransactionParseError(), proxygen::HTTPSession::onWriteSuccess(), proxygen::HTTPSession::sendAbort(), proxygen::HTTPSession::sendHeaders(), and proxygen::HTTPSession::shouldShutdown().
|
pure virtual |
Returns true if this codec is in a state where it accepting new requests but will soon begin to reject new requests. For SPDY and HTTP/2, this is true when the first GOAWAY NO_ERROR is sent during graceful shutdown.
Implemented in proxygen::HTTPParallelCodec, and proxygen::HTTP1xCodec.
Referenced by proxygen::HTTPSession::drainImpl(), proxygen::HTTPSession::getGracefulGoawayAck(), and onIngressUpgradeMessage().
Map the parent back to the priority, -1 if this doesn't make sense.
Reimplemented in proxygen::SPDYCodec.
Definition at line 713 of file HTTPCodec.h.
Map the given linear priority to the correct parent node dependency
Reimplemented in proxygen::HTTP2Codec, and proxygen::SPDYCodec.
Definition at line 706 of file HTTPCodec.h.
Referenced by proxygen::MockHTTPCodec::generateCertificate(), proxygen::HTTPSession::getMessagePriority(), and proxygen::HTTPTransaction::updateAndSendPriority().
|
pure virtual |
Parse ingress data.
buf | A single IOBuf of data to parse |
Implemented in proxygen::SPDYCodec, proxygen::HTTP2Codec, and proxygen::HTTP1xCodec.
Referenced by HTTPParallelCodecTest::parseImpl(), HTTPUpstreamTest< SPDY3CodecPair >::parseOutput(), HTTPDownstreamTest< SPDY3_1CodecPair >::parseOutput(), proxygen::HTTPSession::processReadData(), and supportsSessionFlowControl().
|
pure virtual |
Finish parsing when the ingress stream has ended.
Implemented in proxygen::HTTPParallelCodec, and proxygen::HTTP1xCodec.
Referenced by proxygen::HTTPSession::shutdownTransport(), and supportsSessionFlowControl().
|
inlinevirtual |
Invoked on a codec that has been upgraded to via an HTTPMessage on a different codec. The codec may return false to halt the upgrade.
Reimplemented in proxygen::HTTPParallelCodec, and proxygen::HTTP2Codec.
Definition at line 418 of file HTTPCodec.h.
References closeOnEgressComplete(), isReusable(), isWaitingToDrain(), supportsParallelRequests(), and supportsPushTransactions().
|
pure virtual |
Set the callback to notify on ingress events
callback | The callback object |
Implemented in proxygen::HTTPParallelCodec, and proxygen::HTTP1xCodec.
Referenced by proxygen::PassThroughHTTPCodecFilter::PassThroughHTTPCodecFilter(), and supportsSessionFlowControl().
|
inlinevirtual |
set stats for the header codec, if the protocol supports header compression
Reimplemented in proxygen::HTTP2Codec, and proxygen::SPDYCodec.
Definition at line 670 of file HTTPCodec.h.
Referenced by proxygen::HTTPUpstreamSession::attachThreadLocals(), proxygen::HTTPUpstreamSession::detachThreadLocals(), and proxygen::HTTPSession::setHeaderCodecStats().
|
pure virtual |
Pause or resume the ingress parser
paused | Whether the caller wants the parser to be paused |
Implemented in proxygen::HTTPParallelCodec, and proxygen::HTTP1xCodec.
Referenced by proxygen::HTTPSession::pauseReads(), proxygen::HTTPSession::processReadData(), proxygen::HTTPSession::resumeReadsImpl(), proxygen::HTTPSession::shutdownTransport(), and supportsSessionFlowControl().
|
inlinevirtual |
Check whether the codec supports bidirectional communications between server and client.
Reimplemented in proxygen::HTTP2Codec.
Definition at line 466 of file HTTPCodec.h.
|
pure virtual |
Check whether the codec supports the processing of multiple requests in parallel.
Implemented in proxygen::HTTP1xCodec, and proxygen::HTTPParallelCodec.
Referenced by proxygen::HTTPSession::invalidStream(), proxygen::HTTPUpstreamSession::isReusable(), proxygen::HTTPSession::maybeResumePausedPipelinedTransaction(), proxygen::HTTPSession::onError(), onIngressUpgradeMessage(), proxygen::HTTPSession::onMessageBegin(), proxygen::HTTPSession::onMessageComplete(), proxygen::HTTPSession::onNativeProtocolUpgradeImpl(), proxygen::HTTPSession::pauseReads(), proxygen::HTTPSession::resumeReads(), proxygen::HTTPSession::sendPriority(), proxygen::HTTPSession::setMaxConcurrentIncomingStreams(), proxygen::HTTPSession::setupCodec(), proxygen::HTTPSession::shouldShutdown(), and proxygen::HTTPSession::transactionTimeout().
|
pure virtual |
Check whether the codec supports pushing resources from server to client.
Implemented in proxygen::HTTP2Codec, proxygen::SPDYCodec, and proxygen::HTTP1xCodec.
Referenced by proxygen::HTTPSession::newPushedTransaction(), and onIngressUpgradeMessage().
|
inlinevirtual |
Returns true iff this codec supports session level flow control
Reimplemented in proxygen::SPDYCodec, and proxygen::HTTPParallelCodec.
Definition at line 374 of file HTTPCodec.h.
References createStream(), isBusy(), onIngress(), onIngressEOF(), setCallback(), and setParserPaused().
Referenced by proxygen::HTTPSession::setupCodec().
|
inlinevirtual |
Returns true iff this codec supports per stream flow control
Reimplemented in proxygen::SPDYCodec, and proxygen::HTTPParallelCodec.
Definition at line 367 of file HTTPCodec.h.
Referenced by proxygen::HTTPSession::createTransaction(), and proxygen::HTTPSession::onNativeProtocolUpgradeImpl().
|
static |
Definition at line 55 of file HTTPCodec.h.
Referenced by proxygen::SPDYCodec::addPriorityNodes(), and proxygen::SPDYCodec::onSynCommon().
|
static |
Definition at line 66 of file HTTPCodec.h.
Referenced by proxygen::checkForProtocolUpgrade(), proxygen::HTTPSession::newPushedTransaction(), proxygen::HTTPUpstreamSession::newTransaction(), proxygen::HTTPSession::onError(), proxygen::HTTPSession::onMessageBegin(), and proxygen::HTTPSession::onPushMessageBegin().
|
static |
Definition at line 53 of file HTTPCodec.h.
Referenced by proxygen::checkForProtocolUpgrade(), proxygen::HTTPSession::sendBody(), TEST(), and TEST_F().
|
static |
Definition at line 51 of file HTTPCodec.h.
Referenced by proxygen::checkForProtocolUpgrade(), proxygen::HTTPTransaction::getControlStream(), proxygen::HTTPSession::newExTransaction(), proxygen::HTTPUpstreamSession::newTransaction(), proxygen::HTTPSession::onError(), proxygen::HTTPSession::onExMessageBegin(), proxygen::HTTPSession::onGoaway(), and proxygen::HTTPSession::onMessageBegin().