proxygen
proxygen::HTTPDownstreamSession Class Referencefinal

#include <HTTPDownstreamSession.h>

Inheritance diagram for proxygen::HTTPDownstreamSession:
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 Member Functions

 HTTPDownstreamSession (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)
 
 HTTPDownstreamSession (folly::HHWheelTimer *timer, 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)
 
void startNow () 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)
 
void startNow () override
 
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

 ~HTTPDownstreamSession () override
 
void setupOnHeadersComplete (HTTPTransaction *txn, HTTPMessage *msg) override
 
HTTPTransaction::HandlergetTransactionTimeoutHandler (HTTPTransaction *txn) override
 
void onHeadersSent (const HTTPMessage &headers, bool codecWasReusable) override
 
bool allTransactionsStarted () const override
 
bool onNativeProtocolUpgrade (HTTPCodec::StreamID streamID, CodecProtocol protocol, const std::string &protocolString, HTTPMessage &msg) override
 
bool isDetachable (bool) const override
 
void attachThreadLocals (folly::EventBase *, folly::SSLContextPtr, const WheelTimerInstance &, HTTPSessionStats *, FilterIteratorFn, HeaderCodec::Stats *, HTTPSessionController *) override
 
void detachThreadLocals (bool) override
 
HTTPTransactionnewTransaction (HTTPTransaction::Handler *) override
 
bool isReplaySafe () const override
 
bool isReusable () const override
 
bool isClosing () const override
 

Additional Inherited Members

- 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 *)>
 
- 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
 
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)
 
virtual folly::Optional< const HTTPMessage::HTTPPrioritygetHTTPPriority (uint8_t) override
 
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 drain () 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 18 of file HTTPDownstreamSession.h.

Constructor & Destructor Documentation

proxygen::HTTPDownstreamSession::HTTPDownstreamSession ( 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 
)
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.

Definition at line 28 of file HTTPDownstreamSession.h.

References proxygen::HTTPSessionBase::codec_, proxygen::DOWNSTREAM, and proxygen::HTTPCodec::getTransportDirection().

36  :
37  HTTPSession(timeout, std::move(sock), localAddr, peerAddr,
38  CHECK_NOTNULL(controller), std::move(codec), tinfo,
39  infoCallback) {
41  }
HTTPCodecFilterChain codec_
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
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::HTTPDownstreamSession::HTTPDownstreamSession ( folly::HHWheelTimer timer,
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 
)
inline

Definition at line 44 of file HTTPDownstreamSession.h.

References allTransactionsStarted(), getTransactionTimeoutHandler(), onHeadersSent(), onNativeProtocolUpgrade(), setupOnHeadersComplete(), startNow(), streamID, string, and ~HTTPDownstreamSession().

52  :
53  HTTPDownstreamSession(WheelTimerInstance(timer), std::move(sock), localAddr,
54  peerAddr,CHECK_NOTNULL(controller), std::move(codec), tinfo,
55  infoCallback) {
56  }
HTTPDownstreamSession(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)
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
proxygen::HTTPDownstreamSession::~HTTPDownstreamSession ( )
overrideprivate

Definition at line 20 of file HTTPDownstreamSession.cpp.

Referenced by HTTPDownstreamSession().

20  {
21 }

Member Function Documentation

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

Implements proxygen::HTTPSession.

Definition at line 96 of file HTTPDownstreamSession.cpp.

References proxygen::HTTPSession::transactions_.

Referenced by HTTPDownstreamSession().

96  {
97  for (const auto& txn: transactions_) {
98  if (txn.second.isPushed() && !txn.second.isEgressStarted()) {
99  return false;
100  }
101  }
102  return true;
103 }
std::map< HTTPCodec::StreamID, HTTPTransaction > transactions_
Definition: HTTPSession.h:692
void proxygen::HTTPDownstreamSession::attachThreadLocals ( folly::EventBase ,
folly::SSLContextPtr  ,
const WheelTimerInstance ,
HTTPSessionStats ,
FilterIteratorFn  ,
HeaderCodec::Stats ,
HTTPSessionController  
)
inlineoverrideprivatevirtual

Implements proxygen::HTTPSessionBase.

Definition at line 95 of file HTTPDownstreamSession.h.

101  {
102  LOG(FATAL) << __func__ << " is an upstream interface";
103  }
void proxygen::HTTPDownstreamSession::detachThreadLocals ( bool  )
inlineoverrideprivatevirtual

Implements proxygen::HTTPSessionBase.

Definition at line 105 of file HTTPDownstreamSession.h.

105  {
106  LOG(FATAL) << __func__ << " is an upstream interface";
107  }
HTTPTransaction::Handler * proxygen::HTTPDownstreamSession::getTransactionTimeoutHandler ( HTTPTransaction txn)
overrideprivatevirtual

Called by transactionTimeout() in the downstream case. This function ensures that a handler is set for the transaction.

Implements proxygen::HTTPSession.

Definition at line 65 of file HTTPDownstreamSession.cpp.

References proxygen::HTTPSessionBase::getController(), proxygen::HTTPSession::getLocalAddress(), and proxygen::HTTPSessionController::getTransactionTimeoutHandler().

Referenced by HTTPDownstreamSession().

66  {
68 }
const folly::SocketAddress & getLocalAddress() const noexceptoverride
Definition: HTTPSession.h:122
virtual HTTPTransactionHandler * getTransactionTimeoutHandler(HTTPTransaction *txn, const folly::SocketAddress &localAddress)=0
HTTPSessionController * getController()
bool proxygen::HTTPDownstreamSession::isClosing ( ) const
inlineoverrideprivatevirtual

Returns true if the session is shutting down

Implements proxygen::HTTPSessionBase.

Definition at line 124 of file HTTPDownstreamSession.h.

124  {
125  LOG(FATAL) << __func__ << " is an upstream interface";
126  return false;
127  }
bool proxygen::HTTPDownstreamSession::isDetachable ( bool  ) const
inlineoverrideprivatevirtual

Implements proxygen::HTTPSessionBase.

Definition at line 90 of file HTTPDownstreamSession.h.

90  {
91  LOG(FATAL) << __func__ << " is an upstream interface";
92  return false;
93  }
bool proxygen::HTTPDownstreamSession::isReplaySafe ( ) const
inlineoverrideprivatevirtual

Implements proxygen::HTTPSessionBase.

Definition at line 114 of file HTTPDownstreamSession.h.

114  {
115  LOG(FATAL) << __func__ << " is an upstream interface";
116  return false;
117  }
bool proxygen::HTTPDownstreamSession::isReusable ( ) const
inlineoverrideprivatevirtual

Returns true if the underlying transport can be used again in a new request.

Implements proxygen::HTTPSessionBase.

Definition at line 119 of file HTTPDownstreamSession.h.

119  {
120  LOG(FATAL) << __func__ << " is an upstream interface";
121  return false;
122  }
HTTPTransaction* proxygen::HTTPDownstreamSession::newTransaction ( HTTPTransaction::Handler handler)
inlineoverrideprivatevirtual

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 109 of file HTTPDownstreamSession.h.

109  {
110  LOG(FATAL) << __func__ << " is an upstream interface";
111  return nullptr;
112  }
void proxygen::HTTPDownstreamSession::onHeadersSent ( const HTTPMessage headers,
bool  codecWasReusable 
)
overrideprivatevirtual

Invoked when headers have been sent.

Reimplemented from proxygen::HTTPSession.

Definition at line 71 of file HTTPDownstreamSession.cpp.

References proxygen::HTTPSessionBase::codec_, proxygen::ERR_RESP, proxygen::HTTPMessage::getStatusCode(), proxygen::HTTPCodec::isReusable(), proxygen::REMOTE_ERROR, proxygen::HTTPSessionBase::setCloseReason(), statusCode, uint32_t, and proxygen::UNKNOWN.

Referenced by HTTPDownstreamSession().

72  {
73  if (!codec_->isReusable()) {
74  // If the codec turned unreusable, some thing wrong must have happened.
75  // Basically, the proxy decides the connection is not reusable.
76  // e.g, an error message is being sent with Connection: close
77  if (codecWasReusable) {
78  uint32_t statusCode = headers.getStatusCode();
79  if (statusCode >= 500) {
81  } else {
82  if (statusCode >= 400) {
84  } else {
85  // should not be here
87  }
88  }
89  } else {
90  // shouldn't happen... this case is detected by REQ_NOTREUSABLE
92  }
93  }
94 }
spdy::GoawayStatusCode statusCode
Definition: SPDYCodec.cpp:110
HTTPCodecFilterChain codec_
void setCloseReason(ConnectionCloseReason reason)
virtual bool isReusable() const =0
bool proxygen::HTTPDownstreamSession::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 106 of file HTTPDownstreamSession.cpp.

References proxygen::HTTPCodec::addPriorityNodes(), codec, proxygen::HTTPSessionBase::codec_, proxygen::DOWNSTREAM, proxygen::HTTPSession::findTransaction(), proxygen::HTTPCodecFactory::getCodec(), proxygen::HTTPMessage::getHeaders(), proxygen::HTTP_HEADER_CONNECTION, proxygen::HTTP_HEADER_UPGRADE, folly::gen::move, proxygen::HTTPSession::onNativeProtocolUpgradeImpl(), proxygen::HTTPHeaders::set(), proxygen::HTTPMessage::setHTTPVersion(), proxygen::HTTPMessage::setStatusCode(), proxygen::HTTPMessage::setStatusMessage(), proxygen::HTTPSession::txnEgressQueue_, and proxygen::HTTPSession::writeBuf_.

Referenced by HTTPDownstreamSession().

109  {
110  VLOG(4) << *this << " onNativeProtocolUpgrade streamID=" << streamID <<
111  " protocol=" << protocolString;
112  auto txn = findTransaction(streamID);
113  CHECK(txn);
114  if (txn->canSendHeaders()) {
115  // Create the new Codec
116  auto codec = HTTPCodecFactory::getCodec(protocol,
118  CHECK(codec);
119  if (!codec->onIngressUpgradeMessage(msg)) {
120  VLOG(4) << *this << " codec rejected upgrade";
121  return false;
122  }
123 
124  // Send a 101 Switching Protocols message while we still have HTTP codec
125  // Note: it's possible that the client timed out waiting for a
126  // 100-continue and ended up here first. In this case the 100 may go
127  // out in the new protocol
128  HTTPMessage switchingProtos;
129  switchingProtos.setHTTPVersion(1, 1);
130  switchingProtos.setStatusCode(101);
131  switchingProtos.setStatusMessage("Switching Protocols");
132  switchingProtos.getHeaders().set(HTTP_HEADER_UPGRADE, protocolString);
133  switchingProtos.getHeaders().set(HTTP_HEADER_CONNECTION, "Upgrade");
134  txn->sendHeaders(switchingProtos);
135  // no sendEOM for 1xx
136 
137  // This will actually switch the protocol
139  streamID, std::move(codec), protocolString);
140  if (ret) {
142  }
143  return ret;
144  } else {
145  VLOG(4) << *this << " plaintext upgrade failed due to early response";
146  return false;
147  }
148 }
bool onNativeProtocolUpgradeImpl(HTTPCodec::StreamID txn, std::unique_ptr< HTTPCodec > codec, const std::string &protocolString)
HTTPCodecFilterChain codec_
HTTPTransaction * findTransaction(HTTPCodec::StreamID streamID)
virtual std::unique_ptr< HTTPCodec > getCodec(const std::string &protocolHint, TransportDirection direction, bool isTLS)=0
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::HTTPDownstreamSession::setupOnHeadersComplete ( HTTPTransaction txn,
HTTPMessage msg 
)
overrideprivatevirtual

Called by onHeadersComplete().

Implements proxygen::HTTPSession.

Definition at line 33 of file HTTPDownstreamSession.cpp.

References proxygen::HTTPSessionBase::codec_, proxygen::ENABLE_EX_HEADERS, proxygen::HTTPSessionBase::getController(), proxygen::HTTPTransaction::getControlStream(), proxygen::HTTPTransaction::getHandler(), proxygen::HTTPTransaction::getID(), proxygen::HTTPCodec::getIngressSettings(), proxygen::HTTPSessionController::getRequestHandler(), handler(), proxygen::HTTPTransaction::setHandler(), proxygen::HTTPSession::setNewTransactionPauseState(), and settings.

Referenced by HTTPDownstreamSession().

34  {
35  VLOG(5) << "setupOnHeadersComplete txn=" << txn << ", id=" << txn->getID()
36  << ", handlder=" << txn->getHandler() << ", msg=" << msg;
37  if (txn->getHandler()) {
38  // handler is installed before setupOnHeadersComplete callback. It must be
39  // an EX_HEADERS from client side, and ENABLE_EX_HEADERS == 1
40  const auto* settings = codec_->getIngressSettings();
41  CHECK(settings && settings->getSetting(SettingsId::ENABLE_EX_HEADERS, 0));
42  CHECK(txn->getControlStream());
43  return;
44  }
45 
46  // We need to find a Handler to process the transaction.
47  // Note: The handler is responsible for freeing itself
48  // when it has finished processing the transaction. The
49  // transaction is responsible for freeing itself when both the
50  // ingress and egress messages have completed (or failed).
52 
53  // In the general case, delegate to the handler factory to generate
54  // a handler for the transaction.
55  handler = getController()->getRequestHandler(*txn, msg);
56  CHECK(handler);
57 
58  DestructorGuard dg(this);
59  auto txnID = txn->getID();
60  txn->setHandler(handler);
62 }
HTTPTransactionHandler Handler
virtual const HTTPSettings * getIngressSettings() const
Definition: HTTPCodec.h:657
HTTPCodecFilterChain codec_
virtual HTTPTransactionHandler * getRequestHandler(HTTPTransaction &txn, HTTPMessage *msg)=0
void setNewTransactionPauseState(HTTPCodec::StreamID streamID)
static http_parser_settings settings
Definition: test.c:1529
void handler(int, siginfo_t *, void *)
HTTPSessionController * getController()
void proxygen::HTTPDownstreamSession::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.

Implements proxygen::HTTPSessionBase.

Definition at line 24 of file HTTPDownstreamSession.cpp.

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

Referenced by HTTPDownstreamSession(), proxygen::HTTPSessionAcceptor::onNewConnection(), and TEST().

24  {
25  // Create virtual nodes should happen before startNow since ingress may come
26  // before we can finish startNow. Since maxLevel = 0, this is a no-op unless
27  // SPDY is used. And no frame will be sent to peer, so ignore returned value.
30 }
HTTPCodecFilterChain codec_
HTTP2PriorityQueue txnEgressQueue_
Definition: HTTPSession.h:690
void startNow() override
virtual size_t addPriorityNodes(PriorityQueue &, folly::IOBufQueue &, uint8_t)
Definition: HTTPCodec.h:696
folly::IOBufQueue writeBuf_
Definition: HTTPSession.h:684

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