proxygen
proxygen::HTTPUpstreamSession Class Referencefinal

#include <HTTPUpstreamSession.h>

Inheritance diagram for proxygen::HTTPUpstreamSession:
proxygen::HTTPSession folly::AsyncTransport::ReplaySafetyCallback folly::AsyncReader::ReadCallback folly::EventBase::LoopCallback proxygen::HTTPCodec::Callback proxygen::FlowControlFilter::Callback proxygen::HTTPPriorityMapFactoryProvider folly::AsyncTransport::BufferCallback proxygen::ByteEventTracker::Callback proxygen::HTTPTransaction::Transport proxygen::HTTPSessionBase

Public Types

using FilterIteratorFn = std::function< void(HTTPCodecFilter *)>
 
- Public Types inherited from proxygen::HTTPSession
using UniquePtr = std::unique_ptr< HTTPSession, Destructor >
 
- Public Types inherited from proxygen::HTTPSessionBase
enum  SessionType { SessionType::HTTP, SessionType::HQ }
 
using FilterIteratorFn = std::function< void(HTTPCodecFilter *)>
 

Public Member Functions

 HTTPUpstreamSession (const WheelTimerInstance &timeout, folly::AsyncTransportWrapper::UniquePtr &&sock, const folly::SocketAddress &localAddr, const folly::SocketAddress &peerAddr, std::unique_ptr< HTTPCodec > codec, const wangle::TransportInfo &tinfo, InfoCallback *infoCallback, uint8_t maxVirtualPri=0, std::shared_ptr< const PriorityMapFactory > priorityMapFactory=std::shared_ptr< const PriorityMapFactory >())
 
 HTTPUpstreamSession (folly::HHWheelTimer *timeout, folly::AsyncTransportWrapper::UniquePtr &&sock, const folly::SocketAddress &localAddr, const folly::SocketAddress &peerAddr, std::unique_ptr< HTTPCodec > codec, const wangle::TransportInfo &tinfo, InfoCallback *infoCallback, uint8_t maxVirtualPri=0, std::shared_ptr< const PriorityMapFactory > priorityMapFactory=std::shared_ptr< const PriorityMapFactory >())
 
void detachTransactions ()
 
bool isDetachable (bool checkSocket=true) const override
 
void attachThreadLocals (folly::EventBase *eventBase, folly::SSLContextPtr sslContext, const WheelTimerInstance &timeout, HTTPSessionStats *stats, FilterIteratorFn fn, HeaderCodec::Stats *headerCodecStats, HTTPSessionController *controller) override
 
void detachThreadLocals (bool detachSSLContext=false) override
 
void startNow () override
 
HTTPTransactionnewTransaction (HTTPTransaction::Handler *handler) override
 
bool isReplaySafe () const override
 
bool isReusable () const override
 
bool isClosing () const override
 
void drain () override
 
virtual folly::Optional< const HTTPMessage::HTTPPrioritygetHTTPPriority (uint8_t level) override
 
- Public Member Functions inherited from proxygen::HTTPSession
HTTPSessionBase::SessionType getType () const noexceptoverride
 
folly::AsyncTransportWrappergetTransport () override
 
folly::EventBasegetEventBase () const override
 
const folly::AsyncTransportWrappergetTransport () const override
 
bool hasActiveTransactions () const override
 
uint32_t getNumOutgoingStreams () const override
 
uint32_t getNumIncomingStreams () const override
 
ByteEventTrackergetByteEventTracker ()
 
void setByteEventTracker (std::shared_ptr< ByteEventTracker > byteEventTracker)
 
void setSessionStats (HTTPSessionStats *stats) override
 
void setFlowControl (size_t initialReceiveWindow, size_t receiveStreamWindowSize, size_t receiveSessionWindowSize) override
 
void setEgressSettings (const SettingsList &inSettings) override
 
bool getHTTP2PrioritiesEnabled () const override
 
void setHTTP2PrioritiesEnabled (bool enabled) override
 
const folly::SocketAddressgetLocalAddress () const noexceptoverride
 
const folly::SocketAddressgetPeerAddress () const noexceptoverride
 
const wangle::TransportInfogetSetupTransportInfo () const noexceptoverride
 
bool getCurrentTransportInfo (wangle::TransportInfo *tinfo) override
 
void setMaxConcurrentIncomingStreams (uint32_t num) override
 
void setEgressBytesLimit (uint64_t bytesLimit)
 
size_t sendSettings () override
 
size_t sendPing () override
 
HTTPCodec::StreamID sendPriority (http2::PriorityUpdate pri) override
 
size_t sendPriority (HTTPCodec::StreamID id, http2::PriorityUpdate pri) override
 
size_t sendCertificateRequest (std::unique_ptr< folly::IOBuf > certificateRequestContext, std::vector< fizz::Extension > extensions) override
 
void timeoutExpired () noexceptoverride
 
void describe (std::ostream &os) const override
 
bool isBusy () const override
 
void notifyPendingShutdown () override
 
void closeWhenIdle () override
 
void dropConnection () override
 
void dumpConnectionState (uint8_t loglevel) override
 
bool getCurrentTransportInfoWithoutUpdate (wangle::TransportInfo *tinfo) const override
 
void setHeaderCodecStats (HeaderCodec::Stats *stats) override
 
void enableDoubleGoawayDrain () override
 
bool connCloseByRemote () override
 
void setSecondAuthManager (std::unique_ptr< SecondaryAuthManager > secondAuthManager)
 
SecondaryAuthManagergetSecondAuthManager () const
 
- Public Member Functions inherited from proxygen::HTTPSessionBase
 HTTPSessionBase (const folly::SocketAddress &localAddr, const folly::SocketAddress &peerAddr, HTTPSessionController *controller, const wangle::TransportInfo &tinfo, InfoCallback *infoCallback, std::unique_ptr< HTTPCodec > codec)
 
virtual ~HTTPSessionBase ()
 
void setInfoCallback (InfoCallback *callback)
 
InfoCallbackgetInfoCallback () const
 
HTTPTransaction::HandlergetParseErrorHandler (HTTPTransaction *txn, const HTTPException &error)
 
bool supportsMoreTransactions () const
 
uint32_t getHistoricalMaxOutgoingStreams () const
 
uint32_t getMaxConcurrentOutgoingStreams () const
 
HTTPSessionControllergetController ()
 
void setController (HTTPSessionController *controller)
 
ConnectionCloseReason getConnectionCloseReason () const
 
template<typename Filter , typename... Args>
void addCodecFilter (Args &&...args)
 
virtual CodecProtocol getCodecProtocol () const
 
void setHTTP2PrioritiesEnabled (bool enabled)
 
void setMaxConcurrentOutgoingStreams (uint32_t num)
 
uint32_t getWriteBufferLimit () const
 
void setWriteBufferLimit (uint32_t limit)
 
void setReadBufferLimit (uint32_t limit)
 
uint64_t getNumTxnServed () const
 
std::chrono::seconds getLatestIdleTime () const
 
void setPrioritySampled (bool sampled)
 
const folly::SocketAddressgetLocalAddress () const noexcept
 
const folly::SocketAddressgetPeerAddress () const noexcept
 
const wangle::TransportInfogetSetupTransportInfo () const noexcept
 
wangle::TransportInfogetSetupTransportInfo () noexcept
 
void enableExHeadersSettings () noexcept
 
bool isExHeadersEnabled () noexcept
 
- Public Member Functions inherited from wangle::ManagedConnection
 ManagedConnection ()
 
void fireNotifyPendingShutdown ()
 
void fireCloseWhenIdle (bool force_to_close=false)
 
virtual void resetTimeout ()
 
void resetTimeoutTo (std::chrono::milliseconds)
 
virtual void scheduleTimeout (folly::HHWheelTimer::Callback *callback, std::chrono::milliseconds timeout)
 
ConnectionManagergetConnectionManager ()
 
- Public Member Functions inherited from folly::HHWheelTimer::Callback
 Callback ()=default
 
virtual ~Callback ()
 
virtual void callbackCanceled () noexcept
 
void cancelTimeout ()
 
bool isScheduled () const
 
std::chrono::milliseconds getTimeRemaining ()
 
- Public Member Functions inherited from folly::DelayedDestruction
virtual void destroy ()
 
bool getDestroyPending () const
 
- Public Member Functions inherited from folly::DelayedDestructionBase
virtual ~DelayedDestructionBase ()=default
 
- Public Member Functions inherited from proxygen::HTTPTransaction::Transport
virtual ~Transport ()
 
virtual void addWaitingForReplaySafety (folly::AsyncTransport::ReplaySafetyCallback *callback) noexcept=0
 
virtual void removeWaitingForReplaySafety (folly::AsyncTransport::ReplaySafetyCallback *callback) noexcept=0
 
- Public Member Functions inherited from proxygen::ByteEventTracker::Callback
virtual ~Callback ()
 

Private Member Functions

 ~HTTPUpstreamSession () override
 
void setupOnHeadersComplete (HTTPTransaction *, HTTPMessage *) override
 
HTTPTransaction::HandlergetTransactionTimeoutHandler (HTTPTransaction *txn) override
 
bool allTransactionsStarted () const override
 
bool onNativeProtocolUpgrade (HTTPCodec::StreamID streamID, CodecProtocol protocol, const std::string &protocolString, HTTPMessage &msg) override
 
void maybeAttachSSLContext (folly::SSLContextPtr sslContext) const
 
void maybeDetachSSLContext () const
 

Private Attributes

uint8_t maxVirtualPriorityLevel_ {0}
 
std::shared_ptr< const PriorityMapFactorypriorityMapFactory_
 
std::unique_ptr< PriorityAdapterpriorityAdapter_
 

Additional Inherited Members

- Static Public Member Functions inherited from proxygen::HTTPSessionBase
static void setDefaultReadBufferLimit (uint32_t limit)
 
static void setMaxReadBufferSize (uint32_t bytes)
 
static void setFlowControlledBodySizeLimit (uint32_t limit)
 
static void setDefaultWriteBufferLimit (uint32_t max)
 
- Protected Member Functions inherited from proxygen::HTTPSession
 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)
 
 HTTPSession (folly::HHWheelTimer *transactionTimeouts, 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)
 
 ~HTTPSession () override
 
virtual void onHeadersSent (const HTTPMessage &, bool)
 
void setNewTransactionPauseState (HTTPCodec::StreamID streamID)
 
void onEgressMessageFinished (HTTPTransaction *txn, bool withRST=false)
 
std::unique_ptr< folly::IOBufgetNextToSend (bool *cork, bool *eom)
 
void decrementTransactionCount (HTTPTransaction *txn, bool ingressEOM, bool egressEOM)
 
size_t getCodecSendWindowSize () const
 
size_t sendPriorityImpl (HTTPCodec::StreamID streamID, http2::PriorityUpdate pri)
 
bool onNativeProtocolUpgradeImpl (HTTPCodec::StreamID txn, std::unique_ptr< HTTPCodec > codec, const std::string &protocolString)
 
void readTimeoutExpired () noexcept
 
void writeTimeoutExpired () noexcept
 
void flowControlTimeoutExpired () noexcept
 
void getReadBuffer (void **buf, size_t *bufSize) override
 
void readDataAvailable (size_t readSize) noexceptoverride
 
bool isBufferMovable () noexceptoverride
 
void readBufferAvailable (std::unique_ptr< folly::IOBuf >) noexceptoverride
 
void processReadData ()
 
void readEOF () noexceptoverride
 
void readErr (const folly::AsyncSocketException &) noexceptoverride
 
std::string getSecurityProtocol () const override
 
void onMessageBegin (HTTPCodec::StreamID streamID, HTTPMessage *msg) override
 
void onPushMessageBegin (HTTPCodec::StreamID streamID, HTTPCodec::StreamID assocStreamID, HTTPMessage *msg) override
 
void onExMessageBegin (HTTPCodec::StreamID streamID, HTTPCodec::StreamID controlStream, bool unidirectional, HTTPMessage *msg) override
 
void onHeadersComplete (HTTPCodec::StreamID streamID, std::unique_ptr< HTTPMessage > msg) override
 
void onBody (HTTPCodec::StreamID streamID, std::unique_ptr< folly::IOBuf > chain, uint16_t padding) override
 
void onChunkHeader (HTTPCodec::StreamID stream, size_t length) override
 
void onChunkComplete (HTTPCodec::StreamID stream) override
 
void onTrailersComplete (HTTPCodec::StreamID streamID, std::unique_ptr< HTTPHeaders > trailers) override
 
void onMessageComplete (HTTPCodec::StreamID streamID, bool upgrade) override
 
void onError (HTTPCodec::StreamID streamID, const HTTPException &error, bool newTxn) override
 
void onAbort (HTTPCodec::StreamID streamID, ErrorCode code) override
 
void onGoaway (uint64_t lastGoodStreamID, ErrorCode code, std::unique_ptr< folly::IOBuf > debugData=nullptr) override
 
void onPingRequest (uint64_t uniqueID) override
 
void onPingReply (uint64_t uniqueID) override
 
void onWindowUpdate (HTTPCodec::StreamID stream, uint32_t amount) override
 
void onSettings (const SettingsList &settings) override
 
void onSettingsAck () override
 
void onPriority (HTTPCodec::StreamID stream, const HTTPMessage::HTTPPriority &) override
 
void onCertificateRequest (uint16_t requestId, std::unique_ptr< folly::IOBuf > authRequest) override
 
void onCertificate (uint16_t certId, std::unique_ptr< folly::IOBuf > authenticator) override
 
uint32_t numOutgoingStreams () const override
 
uint32_t numIncomingStreams () const override
 
void pauseIngress (HTTPTransaction *txn) noexceptoverride
 
void resumeIngress (HTTPTransaction *txn) noexceptoverride
 
void transactionTimeout (HTTPTransaction *txn) noexceptoverride
 
void sendHeaders (HTTPTransaction *txn, const HTTPMessage &headers, HTTPHeaderSize *size, bool includeEOM) noexceptoverride
 
size_t sendBody (HTTPTransaction *txn, std::unique_ptr< folly::IOBuf >, bool includeEOM, bool trackLastByteFlushed) noexceptoverride
 
size_t sendChunkHeader (HTTPTransaction *txn, size_t length) noexceptoverride
 
size_t sendChunkTerminator (HTTPTransaction *txn) noexceptoverride
 
size_t sendEOM (HTTPTransaction *txn, const HTTPHeaders *trailers) noexceptoverride
 
size_t sendAbort (HTTPTransaction *txn, ErrorCode statusCode) noexceptoverride
 
size_t sendPriority (HTTPTransaction *txn, const http2::PriorityUpdate &pri) noexceptoverride
 
void detach (HTTPTransaction *txn) noexceptoverride
 
size_t sendWindowUpdate (HTTPTransaction *txn, uint32_t bytes) noexceptoverride
 
void notifyPendingEgress () noexceptoverride
 
void notifyIngressBodyProcessed (uint32_t bytes) noexceptoverride
 
void notifyEgressBodyBuffered (int64_t bytes) noexceptoverride
 
HTTPTransactionnewPushedTransaction (HTTPCodec::StreamID assocStreamId, HTTPTransaction::PushHandler *handler) noexceptoverride
 
HTTPTransactionnewExTransaction (HTTPTransaction::Handler *handler, HTTPCodec::StreamID controlStream, bool unidirectional=false) noexceptoverride
 
const HTTPCodecgetCodec () const noexceptoverride
 
const folly::AsyncTransportWrappergetUnderlyingTransport () const noexceptoverride
 
bool isDraining () const override
 
void shutdownTransport (bool shutdownReads=true, bool shutdownWrites=true, const std::string &errorMsg="")
 
void shutdownTransportWithReset (ProxygenError errorCode, const std::string &errorMsg="")
 
void runLoopCallback () noexceptoverride
 
void scheduleWrite ()
 
void updateWriteCount ()
 
void updateWriteBufSize (int64_t delta)
 
uint64_t sessionByteOffset ()
 
void immediateShutdown ()
 
void checkForShutdown ()
 
HTTPTransactionfindTransaction (HTTPCodec::StreamID streamID)
 
HTTPTransactioncreateTransaction (HTTPCodec::StreamID streamID, const folly::Optional< HTTPCodec::StreamID > &assocStreamID, const folly::Optional< HTTPCodec::ExAttributes > &exAttributes, const http2::PriorityUpdate &priority=http2::DefaultPriority)
 
void onWriteSuccess (uint64_t bytesWritten)
 
void onWriteError (size_t bytesWritten, const folly::AsyncSocketException &ex)
 
void onWriteCompleted ()
 
void pauseReads ()
 
void onSessionParseError (const HTTPException &error)
 
void onNewTransactionParseError (HTTPCodec::StreamID streamID, const HTTPException &error)
 
void resumeReads ()
 
bool hasMoreWrites () const
 
template<typename... Args1, typename... Args2>
void invokeOnAllTransactions (void(HTTPTransaction::*fn)(Args1...), Args2 &&...args)
 
void resumeTransactions ()
 
void errorOnAllTransactions (ProxygenError err, const std::string &errorMsg)
 
void errorOnTransactionIds (const std::vector< HTTPCodec::StreamID > &ids, ProxygenError err, const std::string &extraErrorMsg="")
 
void errorOnTransactionId (HTTPCodec::StreamID id, HTTPException ex)
 
bool shouldShutdown () const
 
void drainImpl ()
 
void pauseReadsImpl ()
 
void resumeReadsImpl ()
 
bool readsUnpaused () const
 
bool readsPaused () const
 
bool readsShutdown () const
 
bool writesUnpaused () const
 
bool writesPaused () const
 
bool writesShutdown () const
 
void rescheduleLoopCallbacks ()
 
void cancelLoopCallbacks ()
 
- Protected Member Functions inherited from proxygen::HTTPSessionBase
void handleErrorDirectly (HTTPTransaction *txn, const HTTPException &error)
 
bool onBodyImpl (std::unique_ptr< folly::IOBuf > chain, size_t length, uint16_t padding, HTTPTransaction *txn)
 
bool notifyBodyProcessed (uint32_t bytes)
 
void setLatestActive ()
 
bool ingressLimitExceeded () const
 
bool egressLimitExceeded () const
 
void updatePendingWriteSize (int64_t delta)
 
void onCreateTransaction ()
 
void incrementSeqNo ()
 
bool isPrioritySampled () const
 
void onNewOutgoingStream (uint32_t outgoingStreams)
 
void setCloseReason (ConnectionCloseReason reason)
 
void runDestroyCallbacks ()
 
void onCodecChanged ()
 
void initCodecHeaderIndexingStrategy ()
 
void attachToSessionController ()
 
- Protected Member Functions inherited from wangle::ManagedConnection
 ~ManagedConnection () override
 
- Protected Member Functions inherited from folly::HHWheelTimer::Callback
virtual std::chrono::steady_clock::time_point getCurTime ()
 
- Protected Member Functions inherited from folly::DelayedDestruction
 ~DelayedDestruction () override=default
 
 DelayedDestruction ()
 
- Protected Member Functions inherited from folly::DelayedDestructionBase
 DelayedDestructionBase ()
 
uint32_t getDestructorGuardCount () const
 
- Protected Member Functions inherited from folly::AsyncTransport::BufferCallback
virtual ~BufferCallback ()
 
- Protected Member Functions inherited from proxygen::HTTPPriorityMapFactoryProvider
virtual ~HTTPPriorityMapFactoryProvider ()=default
 
- Static Protected Member Functions inherited from proxygen::HTTPSessionBase
static void handleLastByteEvents (ByteEventTracker *byteEventTracker, HTTPTransaction *txn, size_t encodedSize, size_t byteOffset, bool piggybacked)
 
- Protected Attributes inherited from proxygen::HTTPSession
WriteTimeout writeTimeout_
 
folly::IOBufQueue writeBuf_ {folly::IOBufQueue::cacheChainLength()}
 
folly::IOBufQueue readBuf_ {folly::IOBufQueue::cacheChainLength()}
 
HTTP2PriorityQueue txnEgressQueue_
 
std::map< HTTPCodec::StreamID, HTTPTransactiontransactions_
 
uint32_t liveTransactions_ {0}
 
folly::AsyncTransportWrapper::UniquePtr sock_
 
WheelTimerInstance timeout_
 
unsigned numActiveWrites_ {0}
 
bool draining_:1
 
bool started_:1
 
bool writesDraining_:1
 
bool resetAfterDrainingWrites_:1
 
bool ingressError_:1
 
- Protected Attributes inherited from proxygen::HTTPSessionBase
HTTPSessionStatssessionStats_ {nullptr}
 
InfoCallbackinfoCallback_ {nullptr}
 
wangle::TransportInfo transportInfo_
 
HTTPCodecFilterChain codec_
 
folly::SocketAddress localAddr_
 
folly::SocketAddress peerAddr_
 
- Static Protected Attributes inherited from proxygen::HTTPSessionBase
static uint32_t kDefaultReadBufLimit = 65536
 
static uint32_t maxReadBufferSize_ = 4000
 
static uint32_t kDefaultWriteBufLimit = 65536
 
static uint32_t egressBodySizeLimit_ = 4096
 

Detailed Description

Definition at line 22 of file HTTPUpstreamSession.h.

Member Typedef Documentation

Definition at line 89 of file HTTPUpstreamSession.h.

Constructor & Destructor Documentation

proxygen::HTTPUpstreamSession::HTTPUpstreamSession ( const WheelTimerInstance timeout,
folly::AsyncTransportWrapper::UniquePtr &&  sock,
const folly::SocketAddress localAddr,
const folly::SocketAddress peerAddr,
std::unique_ptr< HTTPCodec codec,
const wangle::TransportInfo tinfo,
InfoCallback infoCallback,
uint8_t  maxVirtualPri = 0,
std::shared_ptr< const PriorityMapFactory priorityMapFactory = std::shared_ptr<const PriorityMapFactory>() 
)
inline
Parameters
sockAn open socket on which any applicable TLS handshaking has been completed already.
localAddrAddress and port of the local end of the socket.
peerAddrAddress and port of the remote end of the socket.
codecA codec with which to parse/generate messages in whatever HTTP-like wire format this session needs.
maxVirtualPriNumber of virtual priority nodes to represent fixed priority levels.

Definition at line 34 of file HTTPUpstreamSession.h.

References proxygen::HTTPSessionBase::codec_, proxygen::HTTPCodec::getTransportDirection(), folly::AsyncSocket::setBufferCallback(), proxygen::HTTPSession::sock_, and proxygen::UPSTREAM.

44  :
46  timeout,
47  std::move(sock),
48  localAddr,
49  peerAddr,
50  nullptr,
51  std::move(codec),
52  tinfo,
53  infoCallback),
54  maxVirtualPriorityLevel_(priorityMapFactory ? 0 : maxVirtualPri),
55  priorityMapFactory_(priorityMapFactory) {
56  if (sock_) {
57  auto asyncSocket = sock_->getUnderlyingTransport<folly::AsyncSocket>();
58  if (asyncSocket) {
59  asyncSocket->setBufferCallback(this);
60  }
61  }
63  }
HTTPCodecFilterChain codec_
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
folly::AsyncTransportWrapper::UniquePtr sock_
Definition: HTTPSession.h:697
std::shared_ptr< const PriorityMapFactory > priorityMapFactory_
void setBufferCallback(BufferCallback *cb)
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)
virtual TransportDirection getTransportDirection() const =0
proxygen::HTTPUpstreamSession::HTTPUpstreamSession ( folly::HHWheelTimer timeout,
folly::AsyncTransportWrapper::UniquePtr &&  sock,
const folly::SocketAddress localAddr,
const folly::SocketAddress peerAddr,
std::unique_ptr< HTTPCodec codec,
const wangle::TransportInfo tinfo,
InfoCallback infoCallback,
uint8_t  maxVirtualPri = 0,
std::shared_ptr< const PriorityMapFactory priorityMapFactory = std::shared_ptr<const PriorityMapFactory>() 
)
inline

Definition at line 66 of file HTTPUpstreamSession.h.

76  :
78  WheelTimerInstance(timeout),
79  std::move(sock),
80  localAddr,
81  peerAddr,
82  std::move(codec),
83  tinfo,
84  infoCallback,
85  maxVirtualPri,
86  priorityMapFactory) {
87  }
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
HTTPUpstreamSession(const WheelTimerInstance &timeout, folly::AsyncTransportWrapper::UniquePtr &&sock, const folly::SocketAddress &localAddr, const folly::SocketAddress &peerAddr, std::unique_ptr< HTTPCodec > codec, const wangle::TransportInfo &tinfo, InfoCallback *infoCallback, uint8_t maxVirtualPri=0, std::shared_ptr< const PriorityMapFactory > priorityMapFactory=std::shared_ptr< const PriorityMapFactory >())
proxygen::HTTPUpstreamSession::~HTTPUpstreamSession ( )
overrideprivate

Definition at line 20 of file HTTPUpstreamSession.cpp.

Referenced by getHTTPPriority().

20 {}

Member Function Documentation

bool proxygen::HTTPUpstreamSession::allTransactionsStarted ( ) const
overrideprivatevirtual

Implements proxygen::HTTPSession.

Definition at line 119 of file HTTPUpstreamSession.cpp.

References proxygen::HTTPSession::transactions_.

Referenced by setupOnHeadersComplete().

119  {
120  for (const auto& txn: transactions_) {
121  if (!txn.second.isPushed() && !txn.second.isEgressStarted()) {
122  return false;
123  }
124  }
125  return true;
126 }
std::map< HTTPCodec::StreamID, HTTPTransaction > transactions_
Definition: HTTPSession.h:692
void proxygen::HTTPUpstreamSession::attachThreadLocals ( folly::EventBase eventBase,
folly::SSLContextPtr  sslContext,
const WheelTimerInstance timeout,
HTTPSessionStats stats,
FilterIteratorFn  fn,
HeaderCodec::Stats headerCodecStats,
HTTPSessionController controller 
)
overridevirtual

Implements proxygen::HTTPSessionBase.

Definition at line 174 of file HTTPUpstreamSession.cpp.

References proxygen::HTTP2PriorityQueue::attachThreadLocals(), proxygen::HTTPSessionBase::codec_, proxygen::FilterChain< T1, T2, FilterType, set_callback, TakeOwnership >::foreach(), maybeAttachSSLContext(), proxygen::HTTPSession::rescheduleLoopCallbacks(), proxygen::HTTPSession::resumeReadsImpl(), proxygen::HTTPSessionBase::setController(), proxygen::HTTPCodec::setHeaderCodecStats(), proxygen::HTTPSession::setSessionStats(), proxygen::HTTPSession::sock_, proxygen::HTTPSession::timeout_, and proxygen::HTTPSession::txnEgressQueue_.

180  {
182  timeout_ = timeout;
183  setController(controller);
184  setSessionStats(stats);
185  if (sock_) {
186  sock_->attachEventBase(eventBase);
187  maybeAttachSSLContext(sslContext);
188  }
189  codec_.foreach(fn);
190  codec_->setHeaderCodecStats(headerCodecStats);
191  resumeReadsImpl();
193 }
void setSessionStats(HTTPSessionStats *stats) override
void foreach(folly::FunctionRef< void(FilterChainType *)> fn)
Definition: FilterChain.h:349
HTTPCodecFilterChain codec_
void rescheduleLoopCallbacks()
Definition: HTTPSession.h:650
folly::AsyncTransportWrapper::UniquePtr sock_
Definition: HTTPSession.h:697
HTTP2PriorityQueue txnEgressQueue_
Definition: HTTPSession.h:690
WheelTimerInstance timeout_
Definition: HTTPSession.h:699
void attachThreadLocals(const WheelTimerInstance &timeout)
class HTTP2PriorityQueue
void maybeAttachSSLContext(folly::SSLContextPtr sslContext) const
void setController(HTTPSessionController *controller)
virtual void setHeaderCodecStats(HeaderCodec::Stats *)
Definition: HTTPCodec.h:670
void proxygen::HTTPUpstreamSession::detachThreadLocals ( bool  detachSSLContext = false)
overridevirtual

Implements proxygen::HTTPSessionBase.

Definition at line 206 of file HTTPUpstreamSession.cpp.

References proxygen::HTTPSession::cancelLoopCallbacks(), proxygen::HTTPSessionBase::codec_, proxygen::HTTP2PriorityQueue::detachThreadLocals(), wangle::ManagedConnection::getConnectionManager(), maybeDetachSSLContext(), proxygen::HTTPSession::pauseReadsImpl(), proxygen::HTTPSessionBase::setController(), proxygen::HTTPCodec::setHeaderCodecStats(), proxygen::HTTPSession::setSessionStats(), proxygen::HTTPSession::sock_, proxygen::HTTPSession::transactions_, and proxygen::HTTPSession::txnEgressQueue_.

206  {
207  CHECK(transactions_.empty());
209  pauseReadsImpl();
210  if (sock_) {
211  if (detachSSLContext) {
213  }
214  sock_->detachEventBase();
215  }
217  setController(nullptr);
218  setSessionStats(nullptr);
219  // The codec filters *shouldn't* be accessible while the socket is detached,
220  // I hope
221  codec_->setHeaderCodecStats(nullptr);
222  auto cm = getConnectionManager();
223  if (cm) {
224  cm->removeConnection(this);
225  }
226 }
void setSessionStats(HTTPSessionStats *stats) override
HTTPCodecFilterChain codec_
folly::AsyncTransportWrapper::UniquePtr sock_
Definition: HTTPSession.h:697
HTTP2PriorityQueue txnEgressQueue_
Definition: HTTPSession.h:690
ConnectionManager * getConnectionManager()
std::map< HTTPCodec::StreamID, HTTPTransaction > transactions_
Definition: HTTPSession.h:692
void setController(HTTPSessionController *controller)
virtual void setHeaderCodecStats(HeaderCodec::Stats *)
Definition: HTTPCodec.h:670
void proxygen::HTTPUpstreamSession::detachTransactions ( )

Definition at line 158 of file HTTPUpstreamSession.cpp.

References proxygen::HTTPSession::detach(), and proxygen::HTTPSession::transactions_.

158  {
159  while (!transactions_.empty()) {
160  auto txn = transactions_.begin();
161  detach(&txn->second);
162  }
163 }
std::map< HTTPCodec::StreamID, HTTPTransaction > transactions_
Definition: HTTPSession.h:692
void detach(HTTPTransaction *txn) noexceptoverride
void proxygen::HTTPUpstreamSession::drain ( )
inlineoverridevirtual

Drains the current transactions and prevents new transactions from being created on this session. When the number of transactions reaches zero, this session will shutdown the transport and delete itself.

Reimplemented from proxygen::HTTPSession.

Definition at line 137 of file HTTPUpstreamSession.h.

References proxygen::HTTPSession::drain().

Referenced by ProxyService::SessionWrapper::~SessionWrapper().

137  {
139  }
void drain() override
virtual folly::Optional<const HTTPMessage::HTTPPriority> proxygen::HTTPUpstreamSession::getHTTPPriority ( uint8_t  level)
inlineoverridevirtual

Reimplemented from proxygen::HTTPSession.

Definition at line 141 of file HTTPUpstreamSession.h.

References proxygen::HTTPSession::getHTTPPriority(), priorityAdapter_, and ~HTTPUpstreamSession().

142  {
143  if (!priorityAdapter_) {
144  return HTTPSession::getHTTPPriority(level);
145  }
146  return priorityAdapter_->getHTTPPriority(level);
147  }
std::unique_ptr< PriorityAdapter > priorityAdapter_
virtual folly::Optional< const HTTPMessage::HTTPPriority > getHTTPPriority(uint8_t) override
Definition: HTTPSession.h:339
HTTPTransaction::Handler * proxygen::HTTPUpstreamSession::getTransactionTimeoutHandler ( HTTPTransaction txn)
overrideprivatevirtual

Called by transactionTimeout() if the transaction has no handler.

Implements proxygen::HTTPSession.

Definition at line 113 of file HTTPUpstreamSession.cpp.

Referenced by setupOnHeadersComplete().

114  {
115  // No special handler for upstream requests that time out
116  return nullptr;
117 }
bool proxygen::HTTPUpstreamSession::isClosing ( ) const
overridevirtual

Returns true if the session is shutting down

Implements proxygen::HTTPSessionBase.

Definition at line 52 of file HTTPUpstreamSession.cpp.

References proxygen::HTTPSession::draining_, proxygen::HTTPSession::readsShutdown(), proxygen::HTTPSession::resetAfterDrainingWrites_, proxygen::HTTPSession::sock_, proxygen::HTTPSession::writesDraining_, and proxygen::HTTPSession::writesShutdown().

Referenced by isReusable().

52  {
53  VLOG(5) << "isClosing: " << *this
54  << ", sock_->good()=" << sock_->good()
55  << ", draining_=" << draining_
56  << ", readsShutdown()=" << readsShutdown()
57  << ", writesShutdown()=" << writesShutdown()
58  << ", writesDraining_=" << writesDraining_
59  << ", resetAfterDrainingWrites_=" << resetAfterDrainingWrites_;
60  return
61  !sock_->good() ||
62  draining_ ||
63  readsShutdown() ||
64  writesShutdown() ||
67 }
folly::AsyncTransportWrapper::UniquePtr sock_
Definition: HTTPSession.h:697
bool readsShutdown() const
Definition: HTTPSession.h:634
bool writesShutdown() const
Definition: HTTPSession.h:646
bool proxygen::HTTPUpstreamSession::isDetachable ( bool  checkSocket = true) const
overridevirtual

Implements proxygen::HTTPSessionBase.

Definition at line 165 of file HTTPUpstreamSession.cpp.

References proxygen::HTTPSession::getNumIncomingStreams(), proxygen::HTTPSession::sock_, proxygen::HTTPSession::transactions_, and proxygen::HTTPSession::writesPaused().

165  {
166  if (checkSocket && sock_ && !sock_->isDetachable()) {
167  return false;
168  }
169  return transactions_.size() == 0 && getNumIncomingStreams() == 0 &&
170  !writesPaused();
171 }
bool writesPaused() const
Definition: HTTPSession.h:642
folly::AsyncTransportWrapper::UniquePtr sock_
Definition: HTTPSession.h:697
std::map< HTTPCodec::StreamID, HTTPTransaction > transactions_
Definition: HTTPSession.h:692
uint32_t getNumIncomingStreams() const override
Definition: HTTPSession.h:84
bool proxygen::HTTPUpstreamSession::isReplaySafe ( ) const
overridevirtual

Returns true if the underlying transport has completed full handshake.

Implements proxygen::HTTPSessionBase.

Definition at line 22 of file HTTPUpstreamSession.cpp.

References proxygen::HTTPSession::sock_.

22  {
23  return sock_ ? sock_->isReplaySafe() : false;
24 }
folly::AsyncTransportWrapper::UniquePtr sock_
Definition: HTTPSession.h:697
bool proxygen::HTTPUpstreamSession::isReusable ( ) const
overridevirtual

Returns true if this session has no open transactions and the underlying transport can be used again in a new request.

Implements proxygen::HTTPSessionBase.

Definition at line 26 of file HTTPUpstreamSession.cpp.

References proxygen::HTTPSessionBase::codec_, proxygen::HTTPSession::hasMoreWrites(), proxygen::HTTPSession::ingressError_, proxygen::HTTPCodec::isBusy(), isClosing(), proxygen::HTTPCodec::isReusable(), folly::HHWheelTimer::Callback::isScheduled(), proxygen::HTTPSession::liveTransactions_, proxygen::HTTPSession::numActiveWrites_, proxygen::HTTPSession::sock_, proxygen::HTTPCodec::supportsParallelRequests(), and proxygen::HTTPSession::writeTimeout_.

26  {
27  VLOG(4) << "isReusable: " << *this
28  << ", liveTransactions_=" << liveTransactions_
29  << ", isClosing()=" << isClosing()
30  << ", sock_->connecting()=" << sock_->connecting()
31  << ", codec_->isReusable()=" << codec_->isReusable()
32  << ", codec_->isBusy()=" << codec_->isBusy()
33  << ", numActiveWrites_=" << numActiveWrites_
34  << ", writeTimeout_.isScheduled()=" << writeTimeout_.isScheduled()
35  << ", ingressError_=" << ingressError_
36  << ", hasMoreWrites()=" << hasMoreWrites()
37  << ", codec_->supportsParallelRequests()="
39  return
40  !isClosing() &&
41  !sock_->connecting() &&
42  codec_->isReusable() &&
43  !codec_->isBusy() &&
44  !ingressError_ &&
46  // These conditions only apply to serial codec sessions
47  !hasMoreWrites() &&
48  liveTransactions_ == 0 &&
50 }
HTTPCodecFilterChain codec_
WriteTimeout writeTimeout_
Definition: HTTPSession.h:681
folly::AsyncTransportWrapper::UniquePtr sock_
Definition: HTTPSession.h:697
uint32_t liveTransactions_
Definition: HTTPSession.h:695
virtual bool isReusable() const =0
virtual bool isBusy() const =0
virtual bool supportsParallelRequests() const =0
bool hasMoreWrites() const
void proxygen::HTTPUpstreamSession::maybeAttachSSLContext ( folly::SSLContextPtr  sslContext) const
private

Definition at line 195 of file HTTPUpstreamSession.cpp.

References proxygen::HTTPSession::sock_.

Referenced by attachThreadLocals(), and setupOnHeadersComplete().

196  {
197 #ifndef NO_ASYNCSSLSOCKET
198  auto sslSocket = sock_->getUnderlyingTransport<folly::AsyncSSLSocket>();
199  if (sslSocket && sslContext) {
200  sslSocket->attachSSLContext(sslContext);
201  }
202 #endif
203 }
folly::AsyncTransportWrapper::UniquePtr sock_
Definition: HTTPSession.h:697
void proxygen::HTTPUpstreamSession::maybeDetachSSLContext ( ) const
private

Definition at line 228 of file HTTPUpstreamSession.cpp.

References proxygen::HTTPSession::sock_.

Referenced by detachThreadLocals(), and setupOnHeadersComplete().

228  {
229 #ifndef NO_ASYNCSSLSOCKET
230  auto sslSocket = sock_->getUnderlyingTransport<folly::AsyncSSLSocket>();
231  if (sslSocket) {
232  sslSocket->detachSSLContext();
233  }
234 #endif
235 }
folly::AsyncTransportWrapper::UniquePtr sock_
Definition: HTTPSession.h:697
HTTPTransaction * proxygen::HTTPUpstreamSession::newTransaction ( HTTPTransaction::Handler handler)
overridevirtual

Creates a new transaction on this upstream session. Invoking this function also has the side-affect of starting reads after this event loop completes.

Parameters
handlerThe request handler to attach to this transaction. It must not be null.

Implements proxygen::HTTPSessionBase.

Definition at line 91 of file HTTPUpstreamSession.cpp.

References proxygen::HTTPSessionBase::codec_, proxygen::HTTPCodec::createStream(), proxygen::HTTPSession::createTransaction(), proxygen::HTTPSession::draining_, proxygen::HTTPCodec::NoExAttributes, proxygen::HTTPCodec::NoStream, proxygen::HTTPSession::setNewTransactionPauseState(), proxygen::HTTPSession::started_, startNow(), and proxygen::HTTPSessionBase::supportsMoreTransactions().

Referenced by CurlService::CurlClient::connectSuccess(), and ProxyService::ProxyHandler::connectSuccess().

91  {
93  // This session doesn't support any more parallel transactions
94  return nullptr;
95  }
96 
97  if (!started_) {
98  startNow();
99  }
100 
103 
104  if (txn) {
105  DestructorGuard dg(this);
106  auto txnID = txn->getID();
107  txn->setHandler(CHECK_NOTNULL(handler));
109  }
110  return txn;
111 }
HTTPTransaction * createTransaction(HTTPCodec::StreamID streamID, const folly::Optional< HTTPCodec::StreamID > &assocStreamID, const folly::Optional< HTTPCodec::ExAttributes > &exAttributes, const http2::PriorityUpdate &priority=http2::DefaultPriority)
virtual StreamID createStream()=0
HTTPCodecFilterChain codec_
void setNewTransactionPauseState(HTTPCodec::StreamID streamID)
void handler(int, siginfo_t *, void *)
static const folly::Optional< StreamID > NoStream
Definition: HTTPCodec.h:51
bool supportsMoreTransactions() const
static const folly::Optional< ExAttributes > NoExAttributes
Definition: HTTPCodec.h:66
bool proxygen::HTTPUpstreamSession::onNativeProtocolUpgrade ( HTTPCodec::StreamID  ,
CodecProtocol  ,
const std::string ,
HTTPMessage  
)
overrideprivatevirtual

Called upon receipt of a valid protocol switch. Return false if protocol switch could not be completed.

Reimplemented from proxygen::HTTPCodec::Callback.

Definition at line 128 of file HTTPUpstreamSession.cpp.

References proxygen::HTTPCodec::addPriorityNodes(), codec, proxygen::HTTPSessionBase::codec_, proxygen::HTTP_2, maxVirtualPriorityLevel_, folly::gen::move, proxygen::HTTPSession::onNativeProtocolUpgradeImpl(), proxygen::HTTPSession::scheduleWrite(), proxygen::HTTPSession::txnEgressQueue_, proxygen::UPSTREAM, and proxygen::HTTPSession::writeBuf_.

Referenced by setupOnHeadersComplete().

131  {
132 
133  VLOG(4) << *this << " onNativeProtocolUpgrade streamID=" << streamID <<
134  " protocol=" << protocolString;
135 
136  if (protocol != CodecProtocol::HTTP_2) {
137  return false;
138  }
139 
140  // Create the new Codec
141  std::unique_ptr<HTTPCodec> codec =
142  std::make_unique<HTTP2Codec>(TransportDirection::UPSTREAM);
143 
145  protocolString);
146  if (ret) {
147  auto bytes = codec_->addPriorityNodes(
149  writeBuf_,
151  if (bytes) {
152  scheduleWrite();
153  }
154  }
155  return ret;
156 }
bool onNativeProtocolUpgradeImpl(HTTPCodec::StreamID txn, std::unique_ptr< HTTPCodec > codec, const std::string &protocolString)
HTTPCodecFilterChain codec_
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
CodecFactory codec
HTTP2PriorityQueue txnEgressQueue_
Definition: HTTPSession.h:690
virtual size_t addPriorityNodes(PriorityQueue &, folly::IOBufQueue &, uint8_t)
Definition: HTTPCodec.h:696
folly::IOBufQueue writeBuf_
Definition: HTTPSession.h:684
uint32_t streamID
Definition: SPDYCodec.cpp:131
void proxygen::HTTPUpstreamSession::setupOnHeadersComplete ( HTTPTransaction ,
HTTPMessage  
)
inlineoverrideprivatevirtual
void proxygen::HTTPUpstreamSession::startNow ( )
overridevirtual

Start reading from the transport and send any introductory messages to the remote side. This function must be called once per session to begin reads.

Reimplemented from proxygen::HTTPSession.

Definition at line 69 of file HTTPUpstreamSession.cpp.

References proxygen::HTTPCodec::addPriorityNodes(), proxygen::HTTPSessionBase::codec_, maxVirtualPriorityLevel_, priorityAdapter_, priorityMapFactory_, proxygen::HTTPSession::scheduleWrite(), proxygen::HTTPSession::startNow(), proxygen::HTTPSession::txnEgressQueue_, and proxygen::HTTPSession::writeBuf_.

Referenced by newTransaction().

69  {
70  // startNow in base class CHECKs this session has not started.
72  // Upstream specific:
73  // create virtual priority nodes and send Priority frames to peer if necessary
74  if (priorityMapFactory_) {
75  priorityAdapter_ = priorityMapFactory_->createVirtualStreams(this);
76  scheduleWrite();
77  } else {
78  // TODO/T17420249 Move this to the PriorityAdapter and remove it from the
79  // codec.
80  auto bytes = codec_->addPriorityNodes(
82  writeBuf_,
84  if (bytes) {
85  scheduleWrite();
86  }
87  }
88 }
HTTPCodecFilterChain codec_
std::unique_ptr< PriorityAdapter > priorityAdapter_
HTTP2PriorityQueue txnEgressQueue_
Definition: HTTPSession.h:690
void startNow() override
virtual size_t addPriorityNodes(PriorityQueue &, folly::IOBufQueue &, uint8_t)
Definition: HTTPCodec.h:696
std::shared_ptr< const PriorityMapFactory > priorityMapFactory_
folly::IOBufQueue writeBuf_
Definition: HTTPSession.h:684

Member Data Documentation

uint8_t proxygen::HTTPUpstreamSession::maxVirtualPriorityLevel_ {0}
private

Definition at line 174 of file HTTPUpstreamSession.h.

Referenced by onNativeProtocolUpgrade(), and startNow().

std::unique_ptr<PriorityAdapter> proxygen::HTTPUpstreamSession::priorityAdapter_
private

Definition at line 177 of file HTTPUpstreamSession.h.

Referenced by getHTTPPriority(), and startNow().

std::shared_ptr<const PriorityMapFactory> proxygen::HTTPUpstreamSession::priorityMapFactory_
private

Definition at line 176 of file HTTPUpstreamSession.h.

Referenced by startNow().


The documentation for this class was generated from the following files: