38 class HTTPSessionController;
39 class HTTPSessionStats;
41 #define PROXYGEN_HTTP_SESSION_USES_BASE 1 55 using UniquePtr = std::unique_ptr<HTTPSession, Destructor>;
67 return sock_->getEventBase();
105 size_t initialReceiveWindow,
106 size_t receiveStreamWindowSize,
107 size_t receiveSessionWindowSize)
override;
186 std::unique_ptr<folly::IOBuf> certificateRequestContext,
187 std::vector<fizz::Extension> extensions)
override;
194 void describe(std::ostream& os)
const override;
195 bool isBusy()
const override;
228 std::unique_ptr<SecondaryAuthManager> secondAuthManager);
266 std::unique_ptr<HTTPCodec>
codec,
277 std::unique_ptr<HTTPCodec> codec,
314 bool withRST =
false);
320 std::unique_ptr<folly::IOBuf>
getNextToSend(
bool* cork,
bool* eom);
323 bool ingressEOM,
bool egressEOM);
336 std::unique_ptr<HTTPCodec> codec,
354 void readEOF() noexcept
override;
359 return sock_->getSecurityProtocol();
372 std::unique_ptr<HTTPMessage> msg)
override;
374 std::unique_ptr<folly::IOBuf> chain,
uint16_t padding)
override;
378 std::unique_ptr<HTTPHeaders> trailers)
override;
386 std::unique_ptr<folly::IOBuf> debugData =
nullptr)
override;
395 std::unique_ptr<folly::IOBuf> authRequest)
override;
397 std::unique_ptr<folly::IOBuf> authenticator)
override;
412 bool includeEOM) noexcept
override;
414 bool includeEOM,
bool trackLastByteFlushed) noexcept
override;
416 size_t length) noexcept
override;
436 bool unidirectional =
false) noexcept
override;
447 const noexcept
override {
464 void drain()
override;
477 bool shutdownWrites =
true,
583 template<
typename... Args1,
typename... Args2>
587 std::vector<HTTPCodec::StreamID> ids;
589 ids.push_back(txn.first);
591 for (
auto idit = ids.begin(); idit != ids.end() && !transactions_.empty();
594 if (txn !=
nullptr) {
595 (txn->*fn)(std::forward<Args2>(args)...);
627 return reads_ == SocketState::UNPAUSED;
631 return reads_ == SocketState::PAUSED;
639 return writes_ == SocketState::UNPAUSED;
643 return writes_ == SocketState::PAUSED;
652 sock_->getEventBase()->runInLoop(
this);
772 uint64_t offset,
bool eomTracked) noexcept
override;
801 ReplaySafetyCallback* callback) noexcept
override {
802 if (sock_->isReplaySafe()) {
803 callback->onReplaySafe();
814 ReplaySafetyCallback* callback) noexcept
override {
888 void writeSuccess() noexcept
override;
987 VLOG(4) << *
session_ <<
" shutdown from onEgressMessageFinished";
996 std::unique_ptr<DestructorGuard>
dg_;
1014 duration_ = duration;
1018 std::chrono::milliseconds duration_{std::chrono::milliseconds(0)};
size_t sendAbort(HTTPTransaction *txn, ErrorCode statusCode) noexceptoverride
size_t sendBody(HTTPTransaction *txn, std::unique_ptr< folly::IOBuf >, bool includeEOM, bool trackLastByteFlushed) noexceptoverride
size_t getPipelineStreamCount() const
bool getCurrentTransportInfo(wangle::TransportInfo *tinfo) override
bool readsUnpaused() const
HTTPTransaction * createTransaction(HTTPCodec::StreamID streamID, const folly::Optional< HTTPCodec::StreamID > &assocStreamID, const folly::Optional< HTTPCodec::ExAttributes > &exAttributes, const http2::PriorityUpdate &priority=http2::DefaultPriority)
void onCertificate(uint16_t certId, std::unique_ptr< folly::IOBuf > authenticator) override
void shutdownTransport(bool shutdownReads=true, bool shutdownWrites=true, const std::string &errorMsg="")
size_t sendSettings() override
void addLastByteEvent(HTTPTransaction *txn, uint64_t byteNo) noexcept
bool onNativeProtocolUpgradeImpl(HTTPCodec::StreamID txn, std::unique_ptr< HTTPCodec > codec, const std::string &protocolString)
void invokeOnAllTransactions(void(HTTPTransaction::*fn)(Args1...), Args2 &&...args)
void errorOnTransactionId(HTTPCodec::StreamID id, HTTPException ex)
folly::AsyncTransportWrapper * getTransport() override
void setSessionStats(HTTPSessionStats *stats) override
size_t chainLength() const
spdy::GoawayStatusCode statusCode
void onPingReply(uint64_t uniqueID) override
void onPingReplyLatency(int64_t latency) noexceptoverride
void onEgressBuffered() override
bool resetSocketOnShutdown_
HTTPCodecFilterChain codec_
HTTPTransaction * findTransaction(HTTPCodec::StreamID streamID)
void onDeleteAckEvent() noexceptoverride
void rescheduleLoopCallbacks()
size_t receiveSessionWindowSize_
bool isBusy() const override
void resumeIngress(HTTPTransaction *txn) noexceptoverride
void onEgressMessageFinished(HTTPTransaction *txn, bool withRST=false)
const SocketAddress peerAddr
FlowControlFilter * connFlowControl_
void onNewTransactionParseError(HTTPCodec::StreamID streamID, const HTTPException &error)
void errorOnAllTransactions(ProxygenError err, const std::string &errorMsg)
std::string getSecurityProtocol() const override
std::unique_ptr< folly::IOBuf > getNextToSend(bool *cork, bool *eom)
size_t getCodecSendWindowSize() const
void sendHeaders(HTTPTransaction *txn, const HTTPMessage &headers, HTTPHeaderSize *size, bool includeEOM) noexceptoverride
bool connCloseByRemote() override
HTTP2PriorityQueue::NextEgressResult nextEgressResults_
void readErr(const folly::AsyncSocketException &) noexceptoverride
virtual bool isClosedByPeer() const
size_t sendCertificateRequest(std::unique_ptr< folly::IOBuf > certificateRequestContext, std::vector< fizz::Extension > extensions) override
WriteTimeout writeTimeout_
const T1 & getChainEnd() const
std::vector< std::pair< HTTPTransaction *, double >> NextEgressResult
void writeTimeoutExpired() noexcept
void onWriteError(size_t bytesWritten, const folly::AsyncSocketException &ex)
folly::IntrusiveList< WriteSegment,&WriteSegment::listHook > WriteSegmentList
size_t receiveStreamWindowSize_
void runLoopCallback() noexceptoverride
void onPingRequest(uint64_t uniqueID) override
void onCertificateRequest(uint16_t requestId, std::unique_ptr< folly::IOBuf > authRequest) override
void dropConnection() override
bool isBufferMovable() noexceptoverride
ByteEventTracker * getByteEventTracker()
bool getCurrentTransportInfoWithoutUpdate(wangle::TransportInfo *tinfo) const override
std::chrono::milliseconds getTimeoutDuration() const
virtual HTTPTransaction::Handler * getTransactionTimeoutHandler(HTTPTransaction *txn)=0
std::unique_ptr< DestructorGuard > dg_
void flowControlTimeoutExpired() noexcept
void setNewTransactionPauseState(HTTPCodec::StreamID streamID)
bool writesPaused() const
size_t initialReceiveWindow_
void onConnectionSendWindowOpen() override
size_t sendWindowUpdate(HTTPTransaction *txn, uint32_t bytes) noexceptoverride
folly::AsyncTransportWrapper::UniquePtr sock_
folly::IOBufQueue readBuf_
void readTimeoutExpired() noexcept
void setMaxConcurrentIncomingStreams(uint32_t num) override
virtual void setupOnHeadersComplete(HTTPTransaction *txn, HTTPMessage *msg)=0
HTTP2PriorityQueue txnEgressQueue_
static http_parser_settings settings
void timeoutExpired() noexceptoverride
void addAckToLastByteEvent(HTTPTransaction *txn, const ByteEvent &lastByteEvent)
uint32_t maxConcurrentIncomingStreams_
void setByteEventTracker(std::shared_ptr< ByteEventTracker > byteEventTracker)
const folly::SocketAddress & getLocalAddress() const noexceptoverride
requires E e noexcept(noexcept(s.error(std::move(e))))
uint32_t outgoingStreams_
const wangle::TransportInfo & getSetupTransportInfo() const noexceptoverride
void decrementTransactionCount(HTTPTransaction *txn, bool ingressEOM, bool egressEOM)
requires And< SemiMovable< VN >... > &&SemiMovable< E > auto error(E e)
bool resetAfterDrainingWrites_
void onSetSendWindow(uint32_t windowSize)
uint32_t maxConcurrentOutgoingStreamsRemote_
void removeWaitingForReplaySafety(ReplaySafetyCallback *callback) noexceptoverride
size_t sendPing() override
~FlowControlTimeout() override
bool writesUnpaused() const
const folly::SocketAddress & getPeerAddress() const noexceptoverride
unsigned numActiveWrites_
const folly::AsyncTransportWrapper * getUnderlyingTransport() const noexceptoverride
void commonEom(HTTPTransaction *txn, size_t encodedSize, bool piggybacked) noexcept
bool maybeResumePausedPipelinedTransaction(size_t oldStreamCount, uint32_t txnSeqn)
WheelTimerInstance timeout_
WriteSegmentList pendingWrites_
std::unique_ptr< ShutdownTransportCallback > shutdownTransportCb_
void notifyIngressBodyProcessed(uint32_t bytes) noexceptoverride
void onSetMaxInitiatedStreams(uint32_t maxTxns)
ShutdownTransportCallback(HTTPSession *session)
void resumeTransactions()
void handler(int, siginfo_t *, void *)
void readEOF() noexceptoverride
uint64_t bodyBytesPerWriteBuf_
bool getHTTP2PrioritiesEnabled() const override
FlowControlTimeout(HTTPSession *session)
HTTPCodec::StreamID getGracefulGoawayAck() const
bool isLoopCallbackScheduled() const
void setHeaderCodecStats(HeaderCodec::Stats *stats) override
uint32_t numIncomingStreams() const override
constexpr auto size(C const &c) -> decltype(c.size())
void notifyPendingEgress() noexceptoverride
void onSettingsAck() override
void setTimeoutDuration(std::chrono::milliseconds duration)
virtual bool getHTTP2PrioritiesEnabled() const
std::unique_ptr< AsyncTransportWrapper, Destructor > UniquePtr
virtual void onHeadersSent(const HTTPMessage &, bool)
void describe(std::ostream &os) const override
int64_t pendingWriteSizeDelta_
static Options cacheChainLength()
void onWindowUpdate(HTTPCodec::StreamID stream, uint32_t amount) override
const wangle::TransportInfo & getSetupTransportInfo() const noexcept
void incrementOutgoingStreams()
void cancelLoopCallback()
boost::intrusive::list_member_hook< boost::intrusive::link_mode< boost::intrusive::auto_unlink >> IntrusiveListHook
const HTTPCodec & getCodec() const noexceptoverride
void onSettings(const SettingsList &settings) override
size_t sendEOM(HTTPTransaction *txn, const HTTPHeaders *trailers) noexceptoverride
bool isConnWindowFull() const
folly::IntrusiveListHook listHook
void onMessageComplete(HTTPCodec::StreamID streamID, bool upgrade) override
void setFlowControl(size_t initialReceiveWindow, size_t receiveStreamWindowSize, size_t receiveSessionWindowSize) override
const T * getUnderlyingTransport() const
HTTPTransaction * newExTransaction(HTTPTransaction::Handler *handler, HTTPCodec::StreamID controlStream, bool unidirectional=false) noexceptoverride
void addWaitingForReplaySafety(ReplaySafetyCallback *callback) noexceptoverride
WriteTimeout(HTTPSession *session)
http2::PriorityUpdate getMessagePriority(const HTTPMessage *msg)
void timeoutExpired() noexceptoverride
void onHeadersComplete(HTTPCodec::StreamID streamID, std::unique_ptr< HTTPMessage > msg) override
bool isDraining() const override
void setHTTP2PrioritiesEnabled(bool enabled)
void onConnectionSendWindowClosed() override
HTTPCodec::StreamID sendPriority(http2::PriorityUpdate pri) override
void errorOnTransactionIds(const std::vector< HTTPCodec::StreamID > &ids, ProxygenError err, const std::string &extraErrorMsg="")
void onAbort(HTTPCodec::StreamID streamID, ErrorCode code) override
bool shouldShutdown() const
void setEgressSettings(const SettingsList &inSettings) override
HTTPTransaction * newPushedTransaction(HTTPCodec::StreamID assocStreamId, HTTPTransaction::PushHandler *handler) noexceptoverride
bool readsShutdown() const
void onChunkHeader(HTTPCodec::StreamID stream, size_t length) override
static const char *const value
bool writesShutdown() const
virtual void enableDoubleGoawayDrain()
uint32_t liveTransactions_
std::enable_if<!std::is_array< T >::value, std::unique_ptr< T > >::type make_unique(Args &&...args)
folly::WriteFlags getFlags()
void runLoopCallback() noexceptoverride
void invalidStream(HTTPCodec::StreamID stream, ErrorCode code=ErrorCode::_SPDY_INVALID_STREAM)
uint32_t incomingStreams_
uint32_t getMaxConcurrentOutgoingStreamsRemote() const override
uint32_t numOutgoingStreams() const override
const PriorityUpdate DefaultPriority
std::map< HTTPCodec::StreamID, HTTPTransaction > transactions_
void readDataAvailable(size_t readSize) noexceptoverride
void notifyPendingShutdown() override
size_t sendPriorityImpl(HTTPCodec::StreamID streamID, http2::PriorityUpdate pri)
std::tuple< uint32_t, bool, uint8_t > HTTPPriority
~ShutdownTransportCallback() override
void readBufferAvailable(std::unique_ptr< folly::IOBuf >) noexceptoverride
std::vector< HTTPSetting > SettingsList
virtual folly::Optional< const HTTPMessage::HTTPPriority > getHTTPPriority(uint8_t) override
void notifyEgressBodyBuffered(int64_t bytes) noexceptoverride
folly::IOBufQueue writeBuf_
std::list< ReplaySafetyCallback * > waitingForReplaySafety_
void getReadBuffer(void **buf, size_t *bufSize) override
void onReplaySafe() noexceptoverride
void onBody(HTTPCodec::StreamID streamID, std::unique_ptr< folly::IOBuf > chain, uint16_t padding) override
boost::intrusive::list< T, boost::intrusive::member_hook< T, IntrusiveListHook, PtrToMember >, boost::intrusive::constant_time_size< false >> IntrusiveList
virtual bool allTransactionsStarted() const =0
size_t sendChunkHeader(HTTPTransaction *txn, size_t length) noexceptoverride
void setHTTP2PrioritiesEnabled(bool enabled) override
folly::EventBase * getEventBase() const override
const folly::AsyncTransportWrapper * getTransport() const override
void setSecondAuthManager(std::unique_ptr< SecondaryAuthManager > secondAuthManager)
uint64_t getLength() const
void onPriority(HTTPCodec::StreamID stream, const HTTPMessage::HTTPPriority &) override
WriteFlags unSet(WriteFlags a, WriteFlags b)
void timeoutExpired() noexceptoverride
bool verifyCertAuthSetting(uint32_t value)
std::shared_ptr< ByteEventTracker > byteEventTracker_
void onSessionParseError(const HTTPException &error)
void onGoaway(uint64_t lastGoodStreamID, ErrorCode code, std::unique_ptr< folly::IOBuf > debugData=nullptr) override
void setEgressBytesLimit(uint64_t bytesLimit)
uint64_t egressBytesLimit_
size_t sendChunkTerminator(HTTPTransaction *txn) noexceptoverride
const SocketAddress localAddr
uint32_t getNumOutgoingStreams() const override
void onEgressBufferCleared() override
void onMessageBegin(HTTPCodec::StreamID streamID, HTTPMessage *msg) override
uint32_t getAvailableSend() const
DrainTimeout drainTimeout_
void onChunkComplete(HTTPCodec::StreamID stream) override
HTTPSession(const WheelTimerInstance &timeout, folly::AsyncTransportWrapper::UniquePtr sock, const folly::SocketAddress &localAddr, const folly::SocketAddress &peerAddr, HTTPSessionController *controller, std::unique_ptr< HTTPCodec > codec, const wangle::TransportInfo &tinfo, InfoCallback *infoCallback)
uint32_t getNumIncomingStreams() const override
void closeWhenIdle() override
DrainTimeout(HTTPSession *session)
std::unique_ptr< HTTPSession, Destructor > UniquePtr
void updateWriteBufSize(int64_t delta)
bool hasActiveTransactions() const override
virtual void setHeaderCodecStats(HeaderCodec::Stats *)
void transactionTimeout(HTTPTransaction *txn) noexceptoverride
FlowControlTimeout flowControlTimeout_
uint32_t getCertAuthSettingVal()
void detach(HTTPTransaction *txn) noexceptoverride
const folly::SocketAddress & getPeerAddress() const noexcept
void dumpConnectionState(uint8_t loglevel) override
const folly::SocketAddress & getLocalAddress() const noexcept
void cancelLoopCallbacks()
void timeoutExpired() noexceptoverride
SecondaryAuthManager * getSecondAuthManager() const
void onTrailersComplete(HTTPCodec::StreamID streamID, std::unique_ptr< HTTPHeaders > trailers) override
void enableDoubleGoawayDrain() override
void shutdownTransportWithReset(ProxygenError errorCode, const std::string &errorMsg="")
bool needToBlockForReplaySafety() const override
bool isDownstream() const
std::unique_ptr< SecondaryAuthManager > secondAuthManager_
void onPushMessageBegin(HTTPCodec::StreamID streamID, HTTPCodec::StreamID assocStreamID, HTTPMessage *msg) override
void onError(HTTPCodec::StreamID streamID, const HTTPException &error, bool newTxn) override
bool hasMoreWrites() const
void pauseIngress(HTTPTransaction *txn) noexceptoverride
uint64_t sessionByteOffset()
HTTPSessionBase::SessionType getType() const noexceptoverride
void onWriteSuccess(uint64_t bytesWritten)
void onExMessageBegin(HTTPCodec::StreamID streamID, HTTPCodec::StreamID controlStream, bool unidirectional, HTTPMessage *msg) override
void onLastByteEvent(HTTPTransaction *txn, uint64_t offset, bool eomTracked) noexceptoverride