proxygen
proxygen::HTTPSessionBase Class Referenceabstract

#include <HTTPSessionBase.h>

Inheritance diagram for proxygen::HTTPSessionBase:
wangle::ManagedConnection folly::HHWheelTimer::Callback folly::DelayedDestruction folly::DelayedDestructionBase proxygen::HTTPSession proxygen::HTTPDownstreamSession proxygen::HTTPUpstreamSession

Classes

class  InfoCallback
 
class  PriorityAdapter
 
class  PriorityMapFactory
 

Public Types

enum  SessionType { SessionType::HTTP, SessionType::HQ }
 
using FilterIteratorFn = std::function< void(HTTPCodecFilter *)>
 

Public Member Functions

 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
 
virtual void setSessionStats (HTTPSessionStats *stats)
 
virtual SessionType getType () const noexcept=0
 
virtual folly::AsyncTransportWrappergetTransport ()=0
 
virtual const folly::AsyncTransportWrappergetTransport () const =0
 
virtual folly::EventBasegetEventBase () const =0
 
HTTPTransaction::HandlergetParseErrorHandler (HTTPTransaction *txn, const HTTPException &error)
 
virtual bool hasActiveTransactions () const =0
 
bool supportsMoreTransactions () const
 
virtual uint32_t getNumOutgoingStreams () const =0
 
uint32_t getHistoricalMaxOutgoingStreams () const
 
virtual uint32_t getNumIncomingStreams () const =0
 
virtual uint32_t getMaxConcurrentOutgoingStreamsRemote () const =0
 
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
 
virtual void setFlowControl (size_t initialReceiveWindow, size_t receiveStreamWindowSize, size_t receiveSessionWindowSize)=0
 
virtual void setEgressSettings (const SettingsList &inSettings)=0
 
void setHTTP2PrioritiesEnabled (bool enabled)
 
virtual bool getHTTP2PrioritiesEnabled () const
 
void setMaxConcurrentOutgoingStreams (uint32_t num)
 
virtual void setMaxConcurrentIncomingStreams (uint32_t num)=0
 
uint32_t getWriteBufferLimit () const
 
void setWriteBufferLimit (uint32_t limit)
 
void setReadBufferLimit (uint32_t limit)
 
virtual void startNow ()=0
 
virtual size_t sendSettings ()=0
 
virtual size_t sendPing ()=0
 
virtual HTTPCodec::StreamID sendPriority (http2::PriorityUpdate pri)=0
 
virtual size_t sendPriority (HTTPCodec::StreamID id, http2::PriorityUpdate pri)=0
 
virtual size_t sendCertificateRequest (std::unique_ptr< folly::IOBuf >, std::vector< fizz::Extension >)
 
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
 
virtual bool getCurrentTransportInfo (wangle::TransportInfo *tinfo)=0
 
virtual bool getCurrentTransportInfoWithoutUpdate (wangle::TransportInfo *tinfo) const =0
 
virtual void setHeaderCodecStats (HeaderCodec::Stats *stats)=0
 
virtual void enableDoubleGoawayDrain ()=0
 
wangle::TransportInfogetSetupTransportInfo () noexcept
 
virtual bool connCloseByRemote ()=0
 
virtual bool isDetachable (bool checkSocket) const =0
 
virtual void attachThreadLocals (folly::EventBase *eventBase, folly::SSLContextPtr sslContext, const WheelTimerInstance &timeout, HTTPSessionStats *stats, FilterIteratorFn fn, HeaderCodec::Stats *headerCodecStats, HTTPSessionController *controller)=0
 
virtual void detachThreadLocals (bool detachSSLContext=false)=0
 
virtual HTTPTransactionnewTransaction (HTTPTransaction::Handler *handler)=0
 
virtual bool isReplaySafe () const =0
 
virtual bool isReusable () const =0
 
virtual bool isClosing () const =0
 
virtual void drain ()=0
 
virtual folly::Optional< const HTTPMessage::HTTPPrioritygetHTTPPriority (uint8_t level)=0
 
void enableExHeadersSettings () noexcept
 
bool isExHeadersEnabled () noexcept
 
- Public Member Functions inherited from wangle::ManagedConnection
 ManagedConnection ()
 
void timeoutExpired () noexceptoverride=0
 
virtual void describe (std::ostream &os) const =0
 
virtual bool isBusy () const =0
 
virtual void notifyPendingShutdown ()=0
 
void fireNotifyPendingShutdown ()
 
virtual void closeWhenIdle ()=0
 
void fireCloseWhenIdle (bool force_to_close=false)
 
virtual void dropConnection ()=0
 
virtual void dumpConnectionState (uint8_t loglevel)=0
 
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
 

Static Public Member Functions

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

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
 

Static Protected Member Functions

static void handleLastByteEvents (ByteEventTracker *byteEventTracker, HTTPTransaction *txn, size_t encodedSize, size_t byteOffset, bool piggybacked)
 

Protected Attributes

HTTPSessionStatssessionStats_ {nullptr}
 
InfoCallbackinfoCallback_ {nullptr}
 
wangle::TransportInfo transportInfo_
 
HTTPCodecFilterChain codec_
 
folly::SocketAddress localAddr_
 
folly::SocketAddress peerAddr_
 

Static Protected Attributes

static uint32_t kDefaultReadBufLimit = 65536
 
static uint32_t maxReadBufferSize_ = 4000
 
static uint32_t kDefaultWriteBufLimit = 65536
 
static uint32_t egressBodySizeLimit_ = 4096
 

Private Member Functions

std::chrono::milliseconds getIdleTime () const override
 

Private Attributes

HTTPSessionControllercontroller_ {nullptr}
 
TimePoint latestActive_ {}
 
std::chrono::seconds latestIdleDuration_ {}
 
uint32_t transactionSeqNo_ {0}
 
ConnectionCloseReason closeReason_ {ConnectionCloseReason::kMAX_REASON}
 
uint32_t historicalMaxOutgoingStreams_ {0}
 
uint32_t maxConcurrentOutgoingStreamsConfig_
 
uint32_t readBufLimit_ {kDefaultReadBufLimit}
 
uint32_t writeBufLimit_ {kDefaultWriteBufLimit}
 
uint64_t pendingWriteSize_ {0}
 
uint32_t pendingReadSize_ {0}
 
bool prioritySample_:1
 
bool h2PrioritiesEnabled_:1
 
bool exHeadersEnabled_:1
 

Detailed Description

Definition at line 35 of file HTTPSessionBase.h.

Member Typedef Documentation

Definition at line 395 of file HTTPSessionBase.h.

Member Enumeration Documentation

Enumerator
HTTP 
HQ 

Definition at line 38 of file HTTPSessionBase.h.

38  {
39  HTTP,
40  HQ
41  };

Constructor & Destructor Documentation

proxygen::HTTPSessionBase::HTTPSessionBase ( const folly::SocketAddress localAddr,
const folly::SocketAddress peerAddr,
HTTPSessionController controller,
const wangle::TransportInfo tinfo,
InfoCallback infoCallback,
std::unique_ptr< HTTPCodec codec 
)

Definition at line 27 of file HTTPSessionBase.cpp.

References localAddr_, peerAddr_, setController(), and folly::SocketAddress::tryConvertToIPv4().

Referenced by proxygen::HTTPSession::WriteSegment::writeErr().

33  :
34  infoCallback_(infoCallback),
35  transportInfo_(tinfo),
36  codec_(std::move(codec)),
37  localAddr_(localAddr),
38  peerAddr_(peerAddr),
39  prioritySample_(false),
41  exHeadersEnabled_(false) {
42 
43  // If we receive IPv4-mapped IPv6 addresses, convert them to IPv4.
46 
47  setController(controller);
48 }
folly::SocketAddress localAddr_
HTTPCodecFilterChain codec_
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
void setController(HTTPSessionController *controller)
folly::SocketAddress peerAddr_
wangle::TransportInfo transportInfo_
virtual proxygen::HTTPSessionBase::~HTTPSessionBase ( )
inlinevirtual

Definition at line 89 of file HTTPSessionBase.h.

89 {}

Member Function Documentation

template<typename Filter , typename... Args>
void proxygen::HTTPSessionBase::addCodecFilter ( Args &&...  args)
inline

Definition at line 186 of file HTTPSessionBase.h.

References codec_.

186  {
187  codec_.add<Filter>(std::forward<Args>(args)...);
188  }
HTTPCodecFilterChain codec_
FilterChain< T1, T2, FilterType, set_callback, TakeOwnership > & add(Args &&...args)
Definition: FilterChain.h:341
virtual void proxygen::HTTPSessionBase::attachThreadLocals ( folly::EventBase eventBase,
folly::SSLContextPtr  sslContext,
const WheelTimerInstance timeout,
HTTPSessionStats stats,
FilterIteratorFn  fn,
HeaderCodec::Stats headerCodecStats,
HTTPSessionController controller 
)
pure virtual
void proxygen::HTTPSessionBase::attachToSessionController ( )
protected

Attaches Session to RevproxyController instance if it's set

Definition at line 153 of file HTTPSessionBase.cpp.

References getController().

Referenced by proxygen::HTTPSession::WriteSegment::writeErr().

153  {
154  auto controllerPtr = getController();
155  if (controllerPtr) {
156  controllerPtr->attachSession(this);
157  }
158 }
HTTPSessionController * getController()
virtual bool proxygen::HTTPSessionBase::connCloseByRemote ( )
pure virtual

If the connection is closed by remote end

Implemented in proxygen::HTTPSession.

virtual void proxygen::HTTPSessionBase::detachThreadLocals ( bool  detachSSLContext = false)
pure virtual
virtual void proxygen::HTTPSessionBase::drain ( )
pure virtual

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.

Implemented in proxygen::HTTPSession, and proxygen::HTTPUpstreamSession.

bool proxygen::HTTPSessionBase::egressLimitExceeded ( ) const
inlineprotected

Returns true iff egress should stop on this session.

Definition at line 476 of file HTTPSessionBase.h.

Referenced by proxygen::HTTPSession::resumeTransactions(), proxygen::HTTPSession::setNewTransactionPauseState(), and proxygen::HTTPSession::updateWriteBufSize().

476  {
477  // Changed to >
479  }
virtual void proxygen::HTTPSessionBase::enableDoubleGoawayDrain ( )
pure virtual

Implemented in proxygen::HTTPSession.

void proxygen::HTTPSessionBase::enableExHeadersSettings ( )
noexcept

Enable to use Ex Headers in HTTPSession

Definition at line 145 of file HTTPSessionBase.cpp.

References codec_, proxygen::ENABLE_EX_HEADERS, exHeadersEnabled_, proxygen::HTTPCodec::getEgressSettings(), proxygen::HTTPSettings::setSetting(), and settings.

145  {
146  HTTPSettings* settings = codec_->getEgressSettings();
147  if (settings) {
149  exHeadersEnabled_ = true;
150  }
151 }
virtual HTTPSettings * getEgressSettings()
Definition: HTTPCodec.h:653
HTTPCodecFilterChain codec_
static http_parser_settings settings
Definition: test.c:1529
void setSetting(SettingsId id, SettingsValue val)
virtual CodecProtocol proxygen::HTTPSessionBase::getCodecProtocol ( ) const
inlinevirtual

Definition at line 190 of file HTTPSessionBase.h.

References codec_.

Referenced by HTTPTargetSessionAcceptor::onCreate().

190  {
191  return codec_->getProtocol();
192  }
HTTPCodecFilterChain codec_
virtual CodecProtocol getProtocol() const =0
ConnectionCloseReason proxygen::HTTPSessionBase::getConnectionCloseReason ( ) const
inline

Definition at line 181 of file HTTPSessionBase.h.

References testing::Args().

Referenced by proxygen::HTTPSession::shutdownTransport().

181  {
182  return closeReason_;
183  }
ConnectionCloseReason closeReason_
virtual bool proxygen::HTTPSessionBase::getCurrentTransportInfo ( wangle::TransportInfo tinfo)
pure virtual

Implemented in proxygen::HTTPSession.

virtual bool proxygen::HTTPSessionBase::getCurrentTransportInfoWithoutUpdate ( wangle::TransportInfo tinfo) const
pure virtual

Implemented in proxygen::HTTPSession.

virtual folly::EventBase* proxygen::HTTPSessionBase::getEventBase ( ) const
pure virtual

Implemented in proxygen::HTTPSession.

uint32_t proxygen::HTTPSessionBase::getHistoricalMaxOutgoingStreams ( ) const
inline

Definition at line 158 of file HTTPSessionBase.h.

References uint32_t.

158  {
160  }
virtual bool proxygen::HTTPSessionBase::getHTTP2PrioritiesEnabled ( ) const
inlinevirtual

Reimplemented in proxygen::HTTPSession.

Definition at line 222 of file HTTPSessionBase.h.

Referenced by proxygen::HTTPSession::getHTTP2PrioritiesEnabled().

222  {
223  return h2PrioritiesEnabled_;
224  }
virtual folly::Optional<const HTTPMessage::HTTPPriority> proxygen::HTTPSessionBase::getHTTPPriority ( uint8_t  level)
pure virtual
std::chrono::milliseconds proxygen::HTTPSessionBase::getIdleTime ( ) const
inlineoverrideprivatevirtual

Get the idle time of the connection. If it returning 0, that means the idle connections will never be dropped during pre load shedding stage.

Reimplemented from wangle::ManagedConnection.

Definition at line 584 of file HTTPSessionBase.h.

References proxygen::millisecondsSince(), and proxygen::timePointInitialized().

584  {
587  } else {
588  return std::chrono::milliseconds(0);
589  }
590  }
std::chrono::milliseconds millisecondsSince(std::chrono::time_point< ClockType > t)
Definition: Time.h:101
bool timePointInitialized(const T &time)
Definition: Time.h:35
InfoCallback* proxygen::HTTPSessionBase::getInfoCallback ( ) const
inline

Definition at line 123 of file HTTPSessionBase.h.

123  {
124  return infoCallback_;
125  }
std::chrono::seconds proxygen::HTTPSessionBase::getLatestIdleTime ( ) const
inline

Definition at line 306 of file HTTPSessionBase.h.

References min.

306  {
307  DCHECK_GT(transactionSeqNo_, 0) << "No idle time for the first transaction";
308  DCHECK(latestActive_ > TimePoint::min());
309  return latestIdleDuration_;
310  }
std::chrono::seconds latestIdleDuration_
LogLevel min
Definition: LogLevel.cpp:30
const folly::SocketAddress& proxygen::HTTPSessionBase::getLocalAddress ( ) const
inlinenoexcept

Definition at line 317 of file HTTPSessionBase.h.

Referenced by proxygen::HTTPSession::getLocalAddress(), and getParseErrorHandler().

318  {
319  return localAddr_;
320  }
folly::SocketAddress localAddr_
uint32_t proxygen::HTTPSessionBase::getMaxConcurrentOutgoingStreams ( ) const
inline

Definition at line 167 of file HTTPSessionBase.h.

References min.

167  {
170  }
uint32_t maxConcurrentOutgoingStreamsConfig_
LogLevel min
Definition: LogLevel.cpp:30
virtual uint32_t getMaxConcurrentOutgoingStreamsRemote() const =0
virtual uint32_t proxygen::HTTPSessionBase::getMaxConcurrentOutgoingStreamsRemote ( ) const
pure virtual

Implemented in proxygen::HTTPSession.

virtual uint32_t proxygen::HTTPSessionBase::getNumIncomingStreams ( ) const
pure virtual

Implemented in proxygen::HTTPSession.

virtual uint32_t proxygen::HTTPSessionBase::getNumOutgoingStreams ( ) const
pure virtual

Implemented in proxygen::HTTPSession.

uint64_t proxygen::HTTPSessionBase::getNumTxnServed ( ) const
inline

Definition at line 302 of file HTTPSessionBase.h.

Referenced by proxygen::HTTPSession::createTransaction(), and proxygen::HTTPSession::readEOF().

302  {
303  return transactionSeqNo_;
304  }
HTTPTransaction::Handler * proxygen::HTTPSessionBase::getParseErrorHandler ( HTTPTransaction txn,
const HTTPException error 
)

Called by handleErrorDirectly (when handling parse errors) if the transaction has no handler.

Definition at line 134 of file HTTPSessionBase.cpp.

References codec_, controller_, getLocalAddress(), proxygen::HTTPSessionController::getParseErrorHandler(), proxygen::HTTPCodec::getTransportDirection(), and proxygen::UPSTREAM.

Referenced by handleErrorDirectly().

135  {
136  // we encounter an error before we finish reading the ingress headers.
138  // do not return the parse error handler for upstreams, since all we
139  // can do in that direction is abort.
140  return nullptr;
141  }
143 }
HTTPCodecFilterChain codec_
requires And< SemiMovable< VN >... > &&SemiMovable< E > auto error(E e)
Definition: error.h:48
virtual HTTPTransactionHandler * getParseErrorHandler(HTTPTransaction *txn, const HTTPException &error, const folly::SocketAddress &localAddress)=0
const folly::SocketAddress & getLocalAddress() const noexcept
HTTPSessionController * controller_
virtual TransportDirection getTransportDirection() const =0
const folly::SocketAddress& proxygen::HTTPSessionBase::getPeerAddress ( ) const
inlinenoexcept

Definition at line 321 of file HTTPSessionBase.h.

Referenced by proxygen::HTTPSession::getPeerAddress().

322  {
323  return peerAddr_;
324  }
folly::SocketAddress peerAddr_
const wangle::TransportInfo& proxygen::HTTPSessionBase::getSetupTransportInfo ( ) const
inlinenoexcept

Definition at line 325 of file HTTPSessionBase.h.

Referenced by proxygen::HTTPSession::getSetupTransportInfo().

326  {
327  return transportInfo_;
328  }
wangle::TransportInfo transportInfo_
wangle::TransportInfo& proxygen::HTTPSessionBase::getSetupTransportInfo ( )
inlinenoexcept

Definition at line 339 of file HTTPSessionBase.h.

339  {
340  return transportInfo_;
341  }
wangle::TransportInfo transportInfo_
virtual folly::AsyncTransportWrapper* proxygen::HTTPSessionBase::getTransport ( )
pure virtual

Implemented in proxygen::HTTPSession.

virtual const folly::AsyncTransportWrapper* proxygen::HTTPSessionBase::getTransport ( ) const
pure virtual

Implemented in proxygen::HTTPSession.

virtual SessionType proxygen::HTTPSessionBase::getType ( ) const
pure virtualnoexcept

Implemented in proxygen::HTTPSession.

uint32_t proxygen::HTTPSessionBase::getWriteBufferLimit ( ) const
inline

Get/Set the number of egress bytes this session will buffer before pausing all transactions' egress.

Definition at line 245 of file HTTPSessionBase.h.

245  {
246  return writeBufLimit_;
247  }
void proxygen::HTTPSessionBase::handleErrorDirectly ( HTTPTransaction txn,
const HTTPException error 
)
protected

Install a direct response handler for the transaction based on the error.

Definition at line 117 of file HTTPSessionBase.cpp.

References getParseErrorHandler(), proxygen::Exception::getProxygenError(), handler(), infoCallback_, proxygen::HTTPTransaction::onError(), proxygen::HTTPSessionBase::InfoCallback::onIngressError(), proxygen::HTTPTransaction::sendAbort(), and proxygen::HTTPTransaction::setHandler().

Referenced by proxygen::HTTPSession::onError().

118  {
119  VLOG(4) << *this << " creating direct error handler";
120  DCHECK(txn);
121  auto handler = getParseErrorHandler(txn, error);
122  if (!handler) {
123  txn->sendAbort();
124  return;
125  }
126  txn->setHandler(handler);
127  if (infoCallback_) {
128  infoCallback_->onIngressError(*this, error.getProxygenError());
129  }
130  txn->onError(error);
131 }
virtual void onIngressError(const HTTPSessionBase &, ProxygenError)
requires And< SemiMovable< VN >... > &&SemiMovable< E > auto error(E e)
Definition: error.h:48
void handler(int, siginfo_t *, void *)
HTTPTransaction::Handler * getParseErrorHandler(HTTPTransaction *txn, const HTTPException &error)
void proxygen::HTTPSessionBase::handleLastByteEvents ( ByteEventTracker byteEventTracker,
HTTPTransaction txn,
size_t  encodedSize,
size_t  byteOffset,
bool  piggybacked 
)
staticprotected

Definition at line 160 of file HTTPSessionBase.cpp.

References proxygen::ByteEventTracker::addLastByteEvent(), proxygen::HTTPTransaction::onEgressBodyFirstByte(), proxygen::HTTPTransaction::onEgressBodyLastByte(), and proxygen::HTTPTransaction::testAndSetFirstByteSent().

Referenced by proxygen::HTTPSession::commonEom().

165  {
166  // TODO: sort out the TransportCallback for all the EOM handling cases.
167  // Current code has the same behavior as before when there wasn't commonEom.
168  // The issue here is onEgressBodyLastByte can be called twice, depending on
169  // the encodedSize. E.g., when codec actually write to buffer in sendEOM.
170  if (!txn->testAndSetFirstByteSent()) {
171  txn->onEgressBodyFirstByte();
172  }
173  if (!piggybacked) {
174  txn->onEgressBodyLastByte();
175  }
176  // in case encodedSize == 0 we won't get TTLBA which is acceptable
177  // noting the fact that we don't have a response body
178  if (byteEventTracker && (encodedSize > 0)) {
179  byteEventTracker->addLastByteEvent(txn, byteOffset);
180  }
181 }
virtual bool proxygen::HTTPSessionBase::hasActiveTransactions ( ) const
pure virtual

Implemented in proxygen::HTTPSession.

void proxygen::HTTPSessionBase::incrementSeqNo ( )
inlineprotected

Definition at line 493 of file HTTPSessionBase.h.

Referenced by proxygen::HTTPSession::createTransaction().

493  {
495  }
bool proxygen::HTTPSessionBase::ingressLimitExceeded ( ) const
inlineprotected
void proxygen::HTTPSessionBase::initCodecHeaderIndexingStrategy ( )
protected

Initializes the underlying codec's header indexing strategy, if applicable, by retrieving the requisite strategy from the bound controller. This methods exists as some sessions, notably HTTPUpstreamSessions, have

their parent controller set after instantiation

Definition at line 68 of file HTTPSessionBase.cpp.

References codec_, controller_, proxygen::FilterChain< T1, T2, FilterType, set_callback, TakeOwnership >::getChainEndPtr(), proxygen::HTTPSessionController::getHeaderIndexingStrategy(), proxygen::HTTPCodec::getProtocol(), proxygen::isHTTP2CodecProtocol(), and proxygen::HTTP2Codec::setHeaderIndexingStrategy().

Referenced by onCodecChanged().

68  {
69  // Set the header indexing strategy to be employed by the codec if H2
70  // This is done here so that the strategy could be dynamic depending on the
71  // session
73  HTTP2Codec* h2Codec = static_cast<HTTP2Codec*>(codec_.getChainEndPtr());
74  h2Codec->setHeaderIndexingStrategy(
76  }
77 }
HTTPCodecFilterChain codec_
virtual CodecProtocol getProtocol() const =0
virtual const HeaderIndexingStrategy * getHeaderIndexingStrategy() const
bool isHTTP2CodecProtocol(CodecProtocol protocol)
HTTPSessionController * controller_
virtual bool proxygen::HTTPSessionBase::isClosing ( ) const
pure virtual

Returns true if the session is shutting down

Implemented in proxygen::HTTPUpstreamSession, and proxygen::HTTPDownstreamSession.

virtual bool proxygen::HTTPSessionBase::isDetachable ( bool  checkSocket) const
pure virtual
bool proxygen::HTTPSessionBase::isExHeadersEnabled ( )
inlinenoexcept

Definition at line 448 of file HTTPSessionBase.h.

References uint16_t, and uint32_t.

448  {
449  return exHeadersEnabled_;
450  }
bool proxygen::HTTPSessionBase::isPrioritySampled ( ) const
inlineprotected
virtual bool proxygen::HTTPSessionBase::isReplaySafe ( ) const
pure virtual
virtual bool proxygen::HTTPSessionBase::isReusable ( ) const
pure virtual

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

Implemented in proxygen::HTTPUpstreamSession, and proxygen::HTTPDownstreamSession.

virtual HTTPTransaction* proxygen::HTTPSessionBase::newTransaction ( HTTPTransaction::Handler handler)
pure virtual

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.

Implemented in proxygen::HTTPUpstreamSession, and proxygen::HTTPDownstreamSession.

bool proxygen::HTTPSessionBase::notifyBodyProcessed ( uint32_t  bytes)
protected

Definition at line 102 of file HTTPSessionBase.cpp.

References pendingReadSize_, and readBufLimit_.

Referenced by proxygen::HTTPSession::notifyIngressBodyProcessed().

102  {
103  CHECK_GE(pendingReadSize_, bytes);
104  auto oldSize = pendingReadSize_;
105  pendingReadSize_ -= bytes;
106  VLOG(4) << *this << " Dequeued " << bytes << " bytes of ingress. "
107  << "Ingress buffer uses " << pendingReadSize_ << " of "
108  << readBufLimit_ << " bytes.";
109  if (oldSize > readBufLimit_ &&
110  pendingReadSize_ <= readBufLimit_) {
111  return true;
112  }
113  return false;
114 }
bool proxygen::HTTPSessionBase::onBodyImpl ( std::unique_ptr< folly::IOBuf chain,
size_t  length,
uint16_t  padding,
HTTPTransaction txn 
)
protected

Definition at line 79 of file HTTPSessionBase.cpp.

References infoCallback_, folly::gen::move, proxygen::HTTPTransaction::onIngressBody(), proxygen::HTTPSessionBase::InfoCallback::onIngressLimitExceeded(), pendingReadSize_, and readBufLimit_.

Referenced by proxygen::HTTPSession::onBody().

80  {
81  DestructorGuard dg(this);
82  auto oldSize = pendingReadSize_;
83  pendingReadSize_ += length + padding;
84  txn->onIngressBody(std::move(chain), padding);
85  if (oldSize < pendingReadSize_) {
86  // Transaction must have buffered something and not called
87  // notifyBodyProcessed() on it.
88  VLOG(4) << *this << " Enqueued ingress. Ingress buffer uses "
89  << pendingReadSize_ << " of " << readBufLimit_
90  << " bytes.";
91  if (pendingReadSize_ > readBufLimit_ &&
92  oldSize <= readBufLimit_) {
93  if (infoCallback_) {
95  }
96  return true;
97  }
98  }
99  return false;
100 }
virtual void onIngressLimitExceeded(const HTTPSessionBase &)
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
void proxygen::HTTPSessionBase::onCodecChanged ( )
protected
void proxygen::HTTPSessionBase::onCreateTransaction ( )
inlineprotected

Definition at line 486 of file HTTPSessionBase.h.

References proxygen::secondsSince().

Referenced by proxygen::HTTPSession::createTransaction().

486  {
487  if (transactionSeqNo_ >= 1) {
488  // idle duration only exists since the 2nd transaction in the session
490  }
491  }
std::chrono::seconds latestIdleDuration_
std::chrono::seconds secondsSince(std::chrono::time_point< ClockType > t)
Definition: Time.h:107
void proxygen::HTTPSessionBase::onNewOutgoingStream ( uint32_t  outgoingStreams)
inlineprotected

Definition at line 501 of file HTTPSessionBase.h.

Referenced by proxygen::HTTPSession::incrementOutgoingStreams().

501  {
502  if (outgoingStreams > historicalMaxOutgoingStreams_) {
503  historicalMaxOutgoingStreams_ = outgoingStreams;
504  }
505  }
void proxygen::HTTPSessionBase::runDestroyCallbacks ( )
protected

Definition at line 50 of file HTTPSessionBase.cpp.

References controller_, proxygen::HTTPSessionController::detachSession(), infoCallback_, and proxygen::HTTPSessionBase::InfoCallback::onDestroy().

Referenced by proxygen::HTTPSession::~HTTPSession().

50  {
51  if (infoCallback_) {
52  infoCallback_->onDestroy(*this);
53  }
54  if (controller_) {
56  controller_ = nullptr;
57  }
58 }
virtual void detachSession(const HTTPSessionBase *session)=0
virtual void onDestroy(const HTTPSessionBase &)
HTTPSessionController * controller_
virtual size_t proxygen::HTTPSessionBase::sendCertificateRequest ( std::unique_ptr< folly::IOBuf ,
std::vector< fizz::Extension  
)
inlinevirtual

Send a CERTIFICATE_REQUEST frame. If the underlying protocol doesn't support secondary authentication, this is a no-op and 0 is returned.

Reimplemented in proxygen::HTTPSession.

Definition at line 296 of file HTTPSessionBase.h.

298  {
299  return 0;
300  }
virtual size_t proxygen::HTTPSessionBase::sendPing ( )
pure virtual

Causes a ping to be sent on the session. If the underlying protocol doesn't support pings, this will return 0. Otherwise, it will return the number of bytes written on the transport to send the ping.

Implemented in proxygen::HTTPSession.

virtual HTTPCodec::StreamID proxygen::HTTPSessionBase::sendPriority ( http2::PriorityUpdate  pri)
pure virtual

Sends a priority message on this session. If the underlying protocol doesn't support priority, this is a no-op. A new stream identifier will be selected and returned.

Implemented in proxygen::HTTPSession.

virtual size_t proxygen::HTTPSessionBase::sendPriority ( HTTPCodec::StreamID  id,
http2::PriorityUpdate  pri 
)
pure virtual

As above, but updates an existing priority node. Do not use for real nodes, prefer HTTPTransaction::changePriority.

Implemented in proxygen::HTTPSession.

virtual size_t proxygen::HTTPSessionBase::sendSettings ( )
pure virtual

Send a settings frame

Implemented in proxygen::HTTPSession.

void proxygen::HTTPSessionBase::setController ( HTTPSessionController controller)
inline

Definition at line 174 of file HTTPSessionBase.h.

Referenced by proxygen::HTTPUpstreamSession::attachThreadLocals(), proxygen::HTTPUpstreamSession::detachThreadLocals(), and HTTPSessionBase().

174  {
175  controller_ = controller;
176 
177  // Controller controlled settings
179  }
HTTPSessionController * controller_
static void proxygen::HTTPSessionBase::setDefaultReadBufferLimit ( uint32_t  limit)
inlinestatic

Set the read buffer limit to be used for all new HTTPSessionBase objects.

Definition at line 94 of file HTTPSessionBase.h.

94  {
95  kDefaultReadBufLimit = limit;
96  VLOG(3) << "read buffer limit: " << int(limit / 1000) << "KB";
97  }
static uint32_t kDefaultReadBufLimit
static void proxygen::HTTPSessionBase::setDefaultWriteBufferLimit ( uint32_t  max)
inlinestatic

Set the default number of egress bytes this session will buffer before pausing all transactions' egress.

Definition at line 115 of file HTTPSessionBase.h.

References max.

115  {
117  }
LogLevel max
Definition: LogLevel.cpp:31
static uint32_t kDefaultWriteBufLimit
virtual void proxygen::HTTPSessionBase::setEgressSettings ( const SettingsList inSettings)
pure virtual

Set outgoing settings for this session

Implemented in proxygen::HTTPSession.

virtual void proxygen::HTTPSessionBase::setFlowControl ( size_t  initialReceiveWindow,
size_t  receiveStreamWindowSize,
size_t  receiveSessionWindowSize 
)
pure virtual

Set flow control properties on the session.

Parameters
initialReceiveWindowsize of initial receive window for all ingress streams; set via the initial SETTINGS frame
receiveStreamWindowSizeper-stream receive window for NEW streams; sent via a WINDOW_UPDATE frame
receiveSessionWindowSizeper-session receive window; sent via a WINDOW_UPDATE frame

Implemented in proxygen::HTTPSession.

static void proxygen::HTTPSessionBase::setFlowControlledBodySizeLimit ( uint32_t  limit)
inlinestatic

Set the maximum egress body size for any outbound body bytes per loop, when there are > 1 transactions.

Definition at line 107 of file HTTPSessionBase.h.

107  {
108  egressBodySizeLimit_ = limit;
109  }
static uint32_t egressBodySizeLimit_
virtual void proxygen::HTTPSessionBase::setHeaderCodecStats ( HeaderCodec::Stats stats)
pure virtual

Implemented in proxygen::HTTPSession.

void proxygen::HTTPSessionBase::setHTTP2PrioritiesEnabled ( bool  enabled)
inline

Global flag for turning HTTP2 priorities off

Definition at line 218 of file HTTPSessionBase.h.

Referenced by proxygen::HTTPSession::setHTTP2PrioritiesEnabled().

218  {
219  h2PrioritiesEnabled_ = enabled;
220  }
void proxygen::HTTPSessionBase::setInfoCallback ( InfoCallback callback)
inline

Definition at line 119 of file HTTPSessionBase.h.

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

119  {
120  infoCallback_ = callback;
121  }
void proxygen::HTTPSessionBase::setLatestActive ( )
inlineprotected

Definition at line 465 of file HTTPSessionBase.h.

References proxygen::getCurrentTime().

Referenced by proxygen::HTTPSession::detach().

465  {
467  }
std::chrono::time_point< ClockType > getCurrentTime()
Definition: Time.h:41
virtual void proxygen::HTTPSessionBase::setMaxConcurrentIncomingStreams ( uint32_t  num)
pure virtual

Set the maximum number of transactions the remote can open at once.

Implemented in proxygen::HTTPSession.

void proxygen::HTTPSessionBase::setMaxConcurrentOutgoingStreams ( uint32_t  num)
inline

Set the maximum number of outgoing transactions this session can open at once. Note: you can only call function before startNow() is called since the remote side can change this value.

Definition at line 231 of file HTTPSessionBase.h.

References uint32_t.

231  {
232  // TODO: CHECK(started_);
234  }
uint32_t maxConcurrentOutgoingStreamsConfig_
static void proxygen::HTTPSessionBase::setMaxReadBufferSize ( uint32_t  bytes)
inlinestatic

Definition at line 99 of file HTTPSessionBase.h.

99  {
100  maxReadBufferSize_ = bytes;
101  }
static uint32_t maxReadBufferSize_
void proxygen::HTTPSessionBase::setPrioritySampled ( bool  sampled)
inline

Definition at line 312 of file HTTPSessionBase.h.

Referenced by HTTPDownstreamTest< SPDY3_1CodecPair >::HTTPDownstreamTest().

312  {
313  prioritySample_ = sampled;
314  }
void proxygen::HTTPSessionBase::setReadBufferLimit ( uint32_t  limit)
inline

Definition at line 254 of file HTTPSessionBase.h.

References proxygen::HTTPPriorityMapFactoryProvider::sendPriority().

Referenced by proxygen::HTTPSession::setFlowControl().

254  {
255  readBufLimit_ = limit;
256  }
virtual void proxygen::HTTPSessionBase::setSessionStats ( HTTPSessionStats stats)
inlinevirtual

Reimplemented in proxygen::HTTPSession.

Definition at line 127 of file HTTPSessionBase.h.

References folly::pushmi::operators::error(), folly::getEventBase(), and folly::pushmi::__adl::noexcept().

Referenced by proxygen::HTTPSession::setSessionStats().

127  {
128  sessionStats_ = stats;
129  }
HTTPSessionStats * sessionStats_
void proxygen::HTTPSessionBase::setWriteBufferLimit ( uint32_t  limit)
inline

Definition at line 249 of file HTTPSessionBase.h.

Referenced by proxygen::HTTPSessionAcceptor::onNewConnection().

249  {
250  writeBufLimit_ = limit;
251  VLOG(4) << "write buffer limit: " << int(limit / 1000) << "KB";
252  }
virtual void proxygen::HTTPSessionBase::startNow ( )
pure virtual

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.

Implemented in proxygen::HTTPSession, proxygen::HTTPUpstreamSession, and proxygen::HTTPDownstreamSession.

bool proxygen::HTTPSessionBase::supportsMoreTransactions ( ) const
inline

Returns true iff a new outgoing transaction can be made on this session

Definition at line 151 of file HTTPSessionBase.h.

References uint32_t.

Referenced by proxygen::HTTPUpstreamSession::newTransaction(), and proxygen::HTTPSession::onSetMaxInitiatedStreams().

151  {
153  }
uint32_t getMaxConcurrentOutgoingStreams() const
virtual uint32_t getNumOutgoingStreams() const =0
void proxygen::HTTPSessionBase::updatePendingWriteSize ( int64_t  delta)
inlineprotected

Definition at line 481 of file HTTPSessionBase.h.

References uint64_t.

Referenced by proxygen::HTTPSession::updateWriteBufSize().

481  {
482  DCHECK(delta >= 0 || uint64_t(-delta) <= pendingWriteSize_);
483  pendingWriteSize_ += delta;
484  }

Member Data Documentation

ConnectionCloseReason proxygen::HTTPSessionBase::closeReason_ {ConnectionCloseReason::kMAX_REASON}
private

The root cause reason this connection was closed.

Definition at line 609 of file HTTPSessionBase.h.

HTTPCodecFilterChain proxygen::HTTPSessionBase::codec_
protected

Definition at line 547 of file HTTPSessionBase.h.

Referenced by proxygen::HTTPUpstreamSession::attachThreadLocals(), proxygen::HTTPSession::closeWhenIdle(), proxygen::HTTPSession::createTransaction(), proxygen::HTTPSession::describe(), proxygen::HTTPUpstreamSession::detachThreadLocals(), proxygen::HTTPSession::drainImpl(), proxygen::HTTPSession::enableDoubleGoawayDrain(), enableExHeadersSettings(), proxygen::HTTPSession::getCodec(), proxygen::HTTPSession::getCodecSendWindowSize(), proxygen::HTTPSession::getGracefulGoawayAck(), proxygen::HTTPSession::getMessagePriority(), proxygen::HTTPSession::getNextToSend(), getParseErrorHandler(), proxygen::HTTPDownstreamSession::HTTPDownstreamSession(), proxygen::HTTPUpstreamSession::HTTPUpstreamSession(), initCodecHeaderIndexingStrategy(), proxygen::HTTPSession::invalidStream(), proxygen::HTTPSession::isBusy(), proxygen::HTTPSession::isDownstream(), proxygen::HTTPUpstreamSession::isReusable(), proxygen::HTTPSession::isUpstream(), proxygen::HTTPSession::maybeResumePausedPipelinedTransaction(), proxygen::HTTPSession::newExTransaction(), proxygen::HTTPSession::newPushedTransaction(), proxygen::HTTPUpstreamSession::newTransaction(), proxygen::HTTPSession::onCertificateRequest(), proxygen::HTTPSession::onEgressMessageFinished(), proxygen::HTTPSession::onError(), proxygen::HTTPSession::onHeadersComplete(), proxygen::HTTPDownstreamSession::onHeadersSent(), proxygen::HTTPSession::onMessageBegin(), proxygen::HTTPSession::onMessageComplete(), proxygen::HTTPDownstreamSession::onNativeProtocolUpgrade(), proxygen::HTTPUpstreamSession::onNativeProtocolUpgrade(), proxygen::HTTPSession::onNativeProtocolUpgradeImpl(), proxygen::HTTPSession::onNewTransactionParseError(), proxygen::HTTPSession::onPingRequest(), proxygen::HTTPSession::onSessionParseError(), proxygen::HTTPSession::onSettings(), proxygen::HTTPSession::onWriteSuccess(), proxygen::HTTPSession::pauseReads(), proxygen::HTTPSession::processReadData(), proxygen::HTTPSession::resumeReads(), proxygen::HTTPSession::resumeReadsImpl(), proxygen::HTTPSession::sendAbort(), proxygen::HTTPSession::sendBody(), proxygen::HTTPSession::sendCertificateRequest(), proxygen::HTTPSession::sendChunkHeader(), proxygen::HTTPSession::sendChunkTerminator(), proxygen::HTTPSession::sendEOM(), proxygen::HTTPSession::sendHeaders(), proxygen::HTTPSession::sendPing(), proxygen::HTTPSession::sendPriority(), proxygen::HTTPSession::sendPriorityImpl(), proxygen::HTTPSession::sendSettings(), proxygen::HTTPSession::sendWindowUpdate(), proxygen::HTTPSession::setEgressSettings(), proxygen::HTTPSession::setFlowControl(), proxygen::HTTPSession::setHeaderCodecStats(), proxygen::HTTPSession::setMaxConcurrentIncomingStreams(), proxygen::HTTPSession::setupCodec(), proxygen::HTTPDownstreamSession::setupOnHeadersComplete(), proxygen::HTTPSession::shouldShutdown(), proxygen::HTTPSession::shutdownTransport(), proxygen::HTTPDownstreamSession::startNow(), proxygen::HTTPUpstreamSession::startNow(), proxygen::HTTPSession::startNow(), proxygen::HTTPSession::transactionTimeout(), and proxygen::HTTPSession::WriteSegment::writeErr().

HTTPSessionController* proxygen::HTTPSessionBase::controller_ {nullptr}
private
uint32_t proxygen::HTTPSessionBase::egressBodySizeLimit_ = 4096
staticprotected

Maximum number of bytes to egress per loop when there are > 1 transactions. Otherwise defaults to kDefaultWriteBufLimit.

Definition at line 569 of file HTTPSessionBase.h.

Referenced by proxygen::HTTPSession::getNextToSend().

bool proxygen::HTTPSessionBase::exHeadersEnabled_
private

Indicates whether Ex Headers is supported in HTTPSession

Definition at line 651 of file HTTPSessionBase.h.

Referenced by enableExHeadersSettings().

bool proxygen::HTTPSessionBase::h2PrioritiesEnabled_
private

Definition at line 646 of file HTTPSessionBase.h.

uint32_t proxygen::HTTPSessionBase::historicalMaxOutgoingStreams_ {0}
private

The maximum number concurrent transactions in the history of this session

Definition at line 614 of file HTTPSessionBase.h.

uint32_t proxygen::HTTPSessionBase::kDefaultReadBufLimit = 65536
staticprotected

Maximum number of ingress body bytes that can be buffered across all transactions for this single session/connection.

Definition at line 553 of file HTTPSessionBase.h.

uint32_t proxygen::HTTPSessionBase::kDefaultWriteBufLimit = 65536
staticprotected

Maximum number of bytes that can be buffered across all transactions before this session will start applying backpressure to its transactions.

Definition at line 564 of file HTTPSessionBase.h.

TimePoint proxygen::HTTPSessionBase::latestActive_ {}
private

The latest time when this session became idle status

Definition at line 595 of file HTTPSessionBase.h.

std::chrono::seconds proxygen::HTTPSessionBase::latestIdleDuration_ {}
private

The idle duration between latest two consecutive active status

Definition at line 600 of file HTTPSessionBase.h.

folly::SocketAddress proxygen::HTTPSessionBase::localAddr_
protected

Address of this end of the connection

Definition at line 572 of file HTTPSessionBase.h.

Referenced by HTTPSessionBase().

uint32_t proxygen::HTTPSessionBase::maxConcurrentOutgoingStreamsConfig_
private
Initial value:

The maximum number of concurrent transactions that this session may create, as configured locally.

Definition at line 620 of file HTTPSessionBase.h.

uint32_t proxygen::HTTPSessionBase::maxReadBufferSize_ = 4000
staticprotected

The maximum size of the read buffer from the socket.

Definition at line 558 of file HTTPSessionBase.h.

Referenced by proxygen::HTTPSession::getReadBuffer().

folly::SocketAddress proxygen::HTTPSessionBase::peerAddr_
protected

Address of the remote end of the connection

Definition at line 575 of file HTTPSessionBase.h.

Referenced by HTTPSessionBase().

uint32_t proxygen::HTTPSessionBase::pendingReadSize_ {0}
private

Bytes of ingress data read from the socket, but not yet sent to a transaction.

Definition at line 643 of file HTTPSessionBase.h.

Referenced by notifyBodyProcessed(), and onBodyImpl().

uint64_t proxygen::HTTPSessionBase::pendingWriteSize_ {0}
private

Bytes of egress data sent to the socket but not yet written to the network.

Definition at line 637 of file HTTPSessionBase.h.

bool proxygen::HTTPSessionBase::prioritySample_
private

Definition at line 645 of file HTTPSessionBase.h.

uint32_t proxygen::HTTPSessionBase::readBufLimit_ {kDefaultReadBufLimit}
private

Maximum number of cumulative bytes that can be buffered by the transactions in this session before applying backpressure.

Note readBufLimit_ is settable via setFlowControl

Definition at line 630 of file HTTPSessionBase.h.

Referenced by notifyBodyProcessed(), and onBodyImpl().

uint32_t proxygen::HTTPSessionBase::transactionSeqNo_ {0}
private

Transaction sequence number

Definition at line 603 of file HTTPSessionBase.h.

uint32_t proxygen::HTTPSessionBase::writeBufLimit_ {kDefaultWriteBufLimit}
private

Definition at line 631 of file HTTPSessionBase.h.


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